├── README.md
├── lib
└── esbuild
│ ├── esbuild.go
│ ├── logger
│ ├── logger_other.go
│ ├── logger_linux.go
│ └── logger_darwin.go
│ ├── helpers
│ ├── hash.go
│ ├── serializer.go
│ ├── bitset.go
│ ├── path.go
│ ├── mime.go
│ ├── typos.go
│ └── stack.go
│ ├── css_parser
│ └── css_decls_font_weight.go
│ ├── test
│ └── util.go
│ ├── compat
│ └── compat.go
│ └── LICENSE.md
├── .prettierignore
├── packages
└── compiler
│ ├── .gitignore
│ ├── sync.d.ts
│ ├── utils.d.ts
│ ├── types.d.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── test
│ ├── tsx-sourcemaps
│ │ ├── 404.ts
│ │ ├── frontmatter.ts
│ │ ├── script.ts
│ │ ├── deprecated.ts
│ │ ├── module.ts
│ │ ├── tags.ts
│ │ ├── error.ts
│ │ ├── hover.ts
│ │ ├── multibyte.ts
│ │ └── attributes.ts
│ ├── js-sourcemaps
│ │ ├── frontmatter.ts
│ │ ├── script.ts
│ │ ├── deprecated.ts
│ │ ├── windows-linereturns.ts
│ │ ├── module.ts
│ │ ├── error.ts
│ │ └── hover.ts
│ ├── head-metadata
│ │ ├── without-head.ts
│ │ └── with-head.ts
│ ├── basic
│ │ ├── script-fragment.ts
│ │ ├── comment.ts
│ │ ├── component-name.ts
│ │ ├── head-injection.ts
│ │ ├── body-expression.ts
│ │ ├── null-chars.ts
│ │ ├── fragment.ts
│ │ ├── trailing-spaces-ii.ts
│ │ ├── props-interface.ts
│ │ ├── top-level-expressions.ts
│ │ ├── body-after-head-component.ts
│ │ ├── trailing-space.ts
│ │ ├── expression-then-node.ts
│ │ ├── script-before-html.ts
│ │ ├── export.ts
│ │ ├── trailing-newline.ts
│ │ └── expressions.ts
│ ├── teardown
│ │ └── parse.ts
│ ├── transition
│ │ ├── meta.ts
│ │ └── data-astro.ts
│ ├── static-extraction
│ │ ├── hoist-expression.ts
│ │ └── css.ts
│ ├── tsx
│ │ ├── line-terminator.ts
│ │ ├── raw.ts
│ │ └── comment-whitespace.ts
│ ├── parse
│ │ ├── escaping.ts
│ │ ├── client-component-unfound.ts
│ │ ├── multibyte-characters.ts
│ │ ├── orphan-slot.ts
│ │ ├── fragment.ts
│ │ └── orphan-head.ts
│ ├── styles
│ │ ├── emit-scope.ts
│ │ ├── empty-style.ts
│ │ ├── define-vars.ts
│ │ ├── sass.ts
│ │ └── hash.ts
│ ├── css-order
│ │ ├── astro-styles.ts
│ │ └── imported-styles.ts
│ ├── tsx-errors
│ │ ├── unfinished-component.ts
│ │ ├── eof.ts
│ │ └── fragment-shorthand.ts
│ ├── slot-result
│ │ └── result.ts
│ ├── client-directive
│ │ └── warn.ts
│ ├── scripts
│ │ ├── isinline-hint.ts
│ │ └── order.ts
│ ├── errors
│ │ ├── invalid-spread.ts
│ │ ├── jsx-comment.ts
│ │ ├── html-comment.ts
│ │ ├── define-vars.ts
│ │ ├── client-only-unfound.ts
│ │ └── fragment-shorthand.ts
│ ├── bad-styles
│ │ ├── unclosed-style.ts
│ │ └── sass.ts
│ ├── table
│ │ └── components.ts
│ ├── scope
│ │ └── same-source.ts
│ └── resolve-path
│ │ └── preserve.ts
│ └── src
│ └── shared
│ └── diagnostics.ts
├── pnpm-workspace.yaml
├── .git-blame-ignore-revs
├── internal
├── t
│ └── t.go
├── js_scanner
│ └── testdata
│ │ └── fuzz
│ │ └── FuzzHoistImport
│ │ └── ec55358ab2929fbf4deab52587664e42682f0a6ea201a325c5c33f9d18c50456
├── printer
│ ├── __printer_json__
│ │ ├── Comment.snap
│ │ ├── Doctype.snap
│ │ ├── Component.snap
│ │ ├── Comment_preserves_whitespace.snap
│ │ ├── custom-element.snap
│ │ ├── basic.snap
│ │ ├── Fragment_Shorthand.snap
│ │ ├── Fragment_Literal.snap
│ │ ├── expression.snap
│ │ ├── style_after_empty_html.snap
│ │ ├── Frontmatter.snap
│ │ ├── element_with_unterminated_double_quote_attribute.snap
│ │ ├── element_with_unterminated_single_quote_attribute.snap
│ │ ├── element_with_unterminated_template_literal_attribute.snap
│ │ ├── JSON_escape.snap
│ │ ├── style_in_body.snap
│ │ ├── style_in_html.snap
│ │ ├── style_after_html.snap
│ │ ├── style_before_html.snap
│ │ ├── style_after_html_with_component_in_head.snap
│ │ ├── Preserve_namespaces.snap
│ │ ├── style_after_body_with_component_in_head_and_body.snap
│ │ └── style_after_html_with_component_in_head_and_body.snap
│ ├── __printer_css__
│ │ ├── scopedStyleStrategy___class_.snap
│ │ ├── styles__no_frontmatter_.snap
│ │ └── scopedStyleStrategy___attribute_.snap
│ ├── print-css.go
│ └── __printer_js__
│ │ ├── Empty_script.snap
│ │ ├── Self-closing_title.snap
│ │ ├── doctype.snap
│ │ ├── orphan_slot.snap
│ │ ├── anchor_expressions.snap
│ │ ├── iframe.snap
│ │ ├── Empty_expression.snap
│ │ ├── preserve_is_inline_slot.snap
│ │ ├── set_html_on_style.snap
│ │ ├── set_text.snap
│ │ ├── text_after_title_expression.snap
│ │ ├── set_html_on_script.snap
│ │ ├── user-defined__implicit__is_printed.snap
│ │ ├── caption_only.snap
│ │ ├── is_raw.snap
│ │ ├── basic__no_frontmatter_.snap
│ │ ├── division_inside_expression.snap
│ │ ├── set_html.snap
│ │ ├── trailing_expression.snap
│ │ ├── multibyte_characters.snap
│ │ ├── text_after_title_expressions.snap
│ │ ├── anchor_inside_expression.snap
│ │ ├── preserve_is_inline_slot_II.snap
│ │ ├── table_slot_I.snap
│ │ ├── unusual_line_terminator_II.snap
│ │ ├── SVG_styles.snap
│ │ ├── head_slot.snap
│ │ ├── noscript_only.snap
│ │ ├── set_html_on_script_with_quoted_attribute.snap
│ │ ├── Empty_expression_with_whitespace.snap
│ │ ├── Empty_style.snap
│ │ ├── Fragment_shorthand_only.snap
│ │ ├── basic_renderHead.snap
│ │ ├── set_text_with_quoted_attribute.snap
│ │ ├── tr_only.snap
│ │ ├── unusual_line_terminator_I.snap
│ │ ├── Empty_attribute_expression.snap
│ │ ├── attribute_with_template_literal.snap
│ │ ├── escaped_entity.snap
│ │ ├── script_before_elements.snap
│ │ ├── set_html_on_style_with_quoted_attribute.snap
│ │ ├── set_html_with_quoted_attribute.snap
│ │ ├── table_IV.snap
│ │ ├── Fragment_literal_only.snap
│ │ ├── class_list.snap
│ │ ├── component_with_only_a_script.snap
│ │ ├── set_html_on_empty_tag.snap
│ │ ├── table_slot_II.snap
│ │ ├── anchor_content.snap
│ │ ├── backtick_in_HTML_comment.snap
│ │ ├── component_with_quoted_attributes.snap
│ │ ├── set_html_on_self-closing_tag.snap
│ │ ├── table_slot_III.snap
│ │ ├── set_html_and_set_text.snap
│ │ ├── table_slot_V.snap
│ │ ├── Component_siblings_are_siblings.snap
│ │ ├── Self-closing_title_II.snap
│ │ ├── comment_only_expressions_are_removed_I.snap
│ │ ├── noscript_styles.snap
│ │ ├── set_text_on_Component.snap
│ │ ├── table.snap
│ │ ├── table_slot_IV.snap
│ │ ├── template_literal_attribute_on_component.snap
│ │ ├── th_expressions.snap
│ │ ├── Preserve_namespaces_for_components.snap
│ │ ├── conditional_iframe.snap
│ │ ├── export_comments_I.snap
│ │ ├── export_member_does_not_panic.snap
│ │ └── head_inside_slot.snap
├── doc.go
├── hash.go
├── helpers
│ └── js_comment_utils.go
├── xxhash
│ └── LICENSE.txt
└── loc
│ └── diagnostics.go
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .vscode
└── settings.json
├── .github
├── workflows
│ ├── issue-labeled.yml
│ ├── issue-opened.yml
│ ├── congrats.yml
│ └── issue-needs-repro.yml
├── PULL_REQUEST_TEMPLATE.md
└── ISSUE_TEMPLATE
│ └── config.yml
├── .changeset
├── config.json
└── README.md
├── .golangci.yml
├── .gitpod.yml
├── Makefile
├── go.mod
├── .devcontainer
├── devcontainer.json
└── Dockerfile
└── package.json
/README.md:
--------------------------------------------------------------------------------
1 | ./packages/compiler/README.md
--------------------------------------------------------------------------------
/lib/esbuild/esbuild.go:
--------------------------------------------------------------------------------
1 | package esbuild
2 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | **/dist
2 | pnpm-lock.yaml
3 |
--------------------------------------------------------------------------------
/packages/compiler/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | wasm
3 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'packages/*'
3 |
--------------------------------------------------------------------------------
/packages/compiler/sync.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/node/sync.js';
2 |
--------------------------------------------------------------------------------
/packages/compiler/utils.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/node/utils.js';
2 |
--------------------------------------------------------------------------------
/packages/compiler/types.d.ts:
--------------------------------------------------------------------------------
1 | export type * from './dist/shared/types.js';
2 |
--------------------------------------------------------------------------------
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # chore: format everything (#1020)
2 | 402060270f50fe273d5e7387241d7eb36f99ca11
3 |
--------------------------------------------------------------------------------
/internal/t/t.go:
--------------------------------------------------------------------------------
1 | package t
2 |
3 | type ParseOptions struct {
4 | Filename string
5 | Position bool
6 | }
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.go]
4 | indent_style = tab
5 | indent_size = 2
6 | trim_trailing_whitespace = true
7 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Files with the language manually specified, sorted alphabetically.
2 | /internal/**/*.snap linguist-language=Markdown
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .pnpm-store
3 | node_modules
4 | *.wasm
5 | /astro
6 | debug.test
7 | __debug_bin
8 | packages/compiler/sourcemap.mjs
9 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "go.toolsEnvVars": {
3 | "GOOS": "js",
4 | "GOARCH": "wasm"
5 | },
6 | "editor.unusualLineTerminators": "off"
7 | }
8 |
--------------------------------------------------------------------------------
/internal/js_scanner/testdata/fuzz/FuzzHoistImport/ec55358ab2929fbf4deab52587664e42682f0a6ea201a325c5c33f9d18c50456:
--------------------------------------------------------------------------------
1 | go test fuzz v1
2 | string("import\"\nimport \"\";")
3 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/Comment.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/Comment - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"comment","value":"hello"}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/Doctype.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/Doctype - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"doctype","value":"html"}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/.github/workflows/issue-labeled.yml:
--------------------------------------------------------------------------------
1 | name: Issue Labeled
2 |
3 | on:
4 | issues:
5 | types: [labeled]
6 |
7 | jobs:
8 | reply_labelled:
9 | if: github.repository_owner == 'withastro'
10 | uses: withastro/automation/.github/workflows/issue-labeled.yml@main
11 |
--------------------------------------------------------------------------------
/internal/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This example demonstrates parsing HTML data and walking the resulting tree.
6 | package astro
7 |
--------------------------------------------------------------------------------
/.github/workflows/issue-opened.yml:
--------------------------------------------------------------------------------
1 | name: Label issues
2 | on:
3 | issues:
4 | types:
5 | - reopened
6 | - opened
7 |
8 | jobs:
9 | label_issues:
10 | if: github.repository_owner == 'withastro'
11 | uses: withastro/automation/.github/workflows/issue-opened.yml@main
12 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/Component.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/Component - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"component","name":"Component","attributes":[],"children":[]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/Comment_preserves_whitespace.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/Comment_preserves_whitespace - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"comment","value":" hello "}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@1.6.1/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": false,
5 | "linked": [],
6 | "access": "public",
7 | "baseBranch": "main",
8 | "updateInternalDependencies": "patch",
9 | "ignore": []
10 | }
11 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/custom-element.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/custom-element - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"custom-element","name":"custom-element","attributes":[],"children":[]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/basic.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/basic - 1]
3 | ## Input
4 |
5 | ```
6 |
{
6 | const input = '';
7 |
8 | const output = await convertToTSX(input, { filename: '404.astro', sourcemap: 'inline' });
9 | assert.match(output.code, 'export default function __AstroComponent_');
10 | });
11 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/element_with_unterminated_template_literal_attribute.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/element_with_unterminated_template_literal_attribute - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"main","attributes":[{"type":"attribute","kind":"template-literal","name":"id","value":"gotcha","raw":"`gotcha"}],"children":[]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/JSON_escape.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/JSON_escape - 1]
3 | ## Input
4 |
5 | ```
6 | /-/-/-/
7 | const a = "\n"
8 | const b = "\""
9 | const c = '\''
10 | /-/-/-/
11 | {a + b + c}
12 | ```
13 |
14 | ## Output
15 |
16 | ```json
17 | {"type":"root","children":[{"type":"frontmatter","value":"\nconst a = \"\\n\"\nconst b = \"\\\"\"\nconst c = '\\''\n"},{"type":"expression","children":[{"type":"text","value":"a + b + c"}]}]}
18 | ```
19 | ---
20 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/hash.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | // From: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
4 | func HashCombine(seed uint32, hash uint32) uint32 {
5 | return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2))
6 | }
7 |
8 | func HashCombineString(seed uint32, text string) uint32 {
9 | seed = HashCombine(seed, uint32(len(text)))
10 | for _, c := range text {
11 | seed = HashCombine(seed, uint32(c))
12 | }
13 | return seed
14 | }
15 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Changes
2 |
3 | - What does this change?
4 | - Be short and concise. Bullet points can help!
5 | - Before/after screenshots can be helpful as well.
6 |
7 | ## Testing
8 |
9 |
10 |
11 |
12 | ## Docs
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/compiler/test/js-sourcemaps/frontmatter.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testJSSourcemap } from '../utils.js';
4 |
5 | test('frontmatter', async () => {
6 | const input = `---
7 | nonexistent
8 | ---
9 | `;
10 | const output = await testJSSourcemap(input, 'nonexistent');
11 |
12 | assert.equal(output, {
13 | line: 2,
14 | column: 1,
15 | source: 'index.astro',
16 | name: null,
17 | });
18 | });
19 |
20 | test.run();
21 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/frontmatter.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('frontmatter', async () => {
6 | const input = `---
7 | nonexistent
8 | ---
9 | `;
10 | const output = await testTSXSourcemap(input, 'nonexistent');
11 |
12 | assert.equal(output, {
13 | line: 2,
14 | column: 1,
15 | source: 'index.astro',
16 | name: null,
17 | });
18 | });
19 |
20 | test.run();
21 |
--------------------------------------------------------------------------------
/packages/compiler/test/head-metadata/without-head.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 | `;
8 |
9 | let result: TransformResult;
10 | test.before(async () => {
11 | result = await transform(FIXTURE, {
12 | filename: 'test.astro',
13 | });
14 | });
15 |
16 | test('containsHead is false', () => {
17 | assert.equal(result.containsHead, false);
18 | });
19 |
20 | test.run();
21 |
--------------------------------------------------------------------------------
/.changeset/README.md:
--------------------------------------------------------------------------------
1 | # Changesets
2 |
3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4 | with multi-package repos, or single-package repos to help you version and publish your code. You can
5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6 |
7 | We have a quick list of common questions to get you started engaging with this project in
8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/script-fragment.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = ``;
6 |
7 | let result: TransformResult;
8 | test.before(async () => {
9 | result = await transform(FIXTURE);
10 | });
11 |
12 | test('script fragment', () => {
13 | assert.ok(result.code, 'Can compile script fragment');
14 | });
15 |
16 | test.run();
17 |
--------------------------------------------------------------------------------
/packages/compiler/test/teardown/parse.ts:
--------------------------------------------------------------------------------
1 | import { parse, teardown } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = 'hello
';
6 |
7 | test('parse still works after teardown', async () => {
8 | const ast1 = await parse(FIXTURE);
9 | assert.ok(ast1);
10 | teardown();
11 | // Make sure `parse` creates a new WASM instance after teardown removed the previous one
12 | const ast2 = await parse(FIXTURE);
13 | assert.ok(ast2);
14 | });
15 |
16 | test.run();
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: 🏡 Main Astro Repo
4 | url: https://github.com/withastro/astro
5 | about: Unsure if your bug is related to the compiler? Please open an issue in the main Astro repo!
6 | - name: 👾 Chat
7 | url: https://astro.build/chat
8 | about: Our Discord server is active, come join us!
9 | - name: 💁 Support
10 | url: https://astro.build/chat
11 | about: 'This issue tracker is not for support questions. Join us on Discord for assistance!'
12 |
--------------------------------------------------------------------------------
/packages/compiler/test/js-sourcemaps/script.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testJSSourcemap } from '../utils.js';
4 |
5 | test('script is:inline', async () => {
6 | const input = `
10 | `;
11 | const output = await testJSSourcemap(input, '\n');
12 |
13 | assert.equal(output, {
14 | line: 1,
15 | column: 18,
16 | source: 'index.astro',
17 | name: null,
18 | });
19 | });
20 |
21 | test.run();
22 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/script.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('script is:inline', async () => {
6 | const input = `
10 | `;
11 | const output = await testTSXSourcemap(input, '\n');
12 |
13 | assert.equal(output, {
14 | line: 1,
15 | column: 18,
16 | source: 'index.astro',
17 | name: null,
18 | });
19 | });
20 |
21 | test.run();
22 |
--------------------------------------------------------------------------------
/.github/workflows/issue-needs-repro.yml:
--------------------------------------------------------------------------------
1 | name: Close Issues (needs repro)
2 |
3 | on:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | close-issues:
9 | if: github.repository == 'withastro/compiler'
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: needs repro
13 | uses: actions-cool/issues-helper@9861779a695cf1898bd984c727f685f351cfc372 # v3.7.2
14 | with:
15 | actions: "close-issues"
16 | token: ${{ secrets.GITHUB_TOKEN }}
17 | labels: "needs repro"
18 | inactive-day: 3
19 |
--------------------------------------------------------------------------------
/packages/compiler/test/transition/meta.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 | `;
8 |
9 | let result: TransformResult;
10 | test.before(async () => {
11 | result = await transform(FIXTURE, {
12 | resolvePath: async (s) => s,
13 | });
14 | });
15 |
16 | test('tagged with propagation metadata', () => {
17 | assert.equal(result.propagation, true);
18 | });
19 |
20 | test.run();
21 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_in_body.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_in_body - 1]
3 | ## Input
4 |
5 | ```
6 | Hello world!
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]},{"type":"element","name":"style","attributes":[],"children":[]}]}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_in_html.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_in_html - 1]
3 | ## Input
4 |
5 | ```
6 | Hello world!
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]},{"type":"element","name":"style","attributes":[],"children":[]}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_after_html.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_after_html - 1]
3 | ## Input
4 |
5 | ```
6 | Hello world!
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]}]},{"type":"element","name":"style","attributes":[],"children":[]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_before_html.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_before_html - 1]
3 | ## Input
4 |
5 | ```
6 | Hello world!
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"style","attributes":[],"children":[]},{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/packages/compiler/test/static-extraction/hoist-expression.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | const url = 'foo';
8 | ---
9 |
10 | `;
11 |
12 | let result: TransformResult;
13 | test.before(async () => {
14 | result = await transform(FIXTURE);
15 | });
16 |
17 | test('logs warning with hoisted expression', () => {
18 | assert.ok(result.code);
19 | });
20 |
21 | test.run();
22 |
--------------------------------------------------------------------------------
/packages/compiler/src/shared/diagnostics.ts:
--------------------------------------------------------------------------------
1 | export enum DiagnosticCode {
2 | ERROR = 1000,
3 | ERROR_UNTERMINATED_JS_COMMENT = 1001,
4 | ERROR_FRAGMENT_SHORTHAND_ATTRS = 1002,
5 | ERROR_UNMATCHED_IMPORT = 1003,
6 | ERROR_UNSUPPORTED_SLOT_ATTRIBUTE = 1004,
7 | WARNING = 2000,
8 | WARNING_UNTERMINATED_HTML_COMMENT = 2001,
9 | WARNING_UNCLOSED_HTML_TAG = 2002,
10 | WARNING_DEPRECATED_DIRECTIVE = 2003,
11 | WARNING_IGNORED_DIRECTIVE = 2004,
12 | WARNING_UNSUPPORTED_EXPRESSION = 2005,
13 | WARNING_SET_WITH_CHILDREN = 2006,
14 | INFO = 3000,
15 | HINT = 4000,
16 | }
17 |
--------------------------------------------------------------------------------
/packages/compiler/test/js-sourcemaps/deprecated.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testJSSourcemap } from '../utils.js';
4 |
5 | test('script is:inline', async () => {
6 | const input = `---
7 | /** @deprecated */
8 | const deprecated = "Astro"
9 | deprecated;
10 | const hello = "Astro"
11 | ---
12 | `;
13 | const output = await testJSSourcemap(input, 'deprecated;');
14 |
15 | assert.equal(output, {
16 | line: 4,
17 | column: 1,
18 | source: 'index.astro',
19 | name: null,
20 | });
21 | });
22 |
23 | test.run();
24 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/comment.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `---
6 | /***/
7 | ---
8 |
9 |
10 | `;
11 |
12 | let result: TransformResult;
13 | test.before(async () => {
14 | result = await transform(FIXTURE);
15 | });
16 |
17 | test('Can handle multi-* comments', () => {
18 | assert.ok(result.code, 'Expected to compile');
19 | assert.equal(result.diagnostics.length, 0, 'Expected no diagnostics');
20 | });
21 |
22 | test.run();
23 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/deprecated.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('script is:inline', async () => {
6 | const input = `---
7 | /** @deprecated */
8 | const deprecated = "Astro"
9 | deprecated;
10 | const hello = "Astro"
11 | ---
12 | `;
13 | const output = await testTSXSourcemap(input, 'deprecated;');
14 |
15 | assert.equal(output, {
16 | line: 4,
17 | column: 1,
18 | source: 'index.astro',
19 | name: null,
20 | });
21 | });
22 |
23 | test.run();
24 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx/line-terminator.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('handles non-standard line terminators', async () => {
6 | const inputs = ['
', 'something
something', 'something
', '
'];
7 | let err = 0;
8 | for (const input of inputs) {
9 | try {
10 | await convertToTSX(input, { filename: 'index.astro', sourcemap: 'inline' });
11 | } catch (e) {
12 | err = 1;
13 | }
14 | }
15 | assert.equal(err, 0, 'did not error');
16 | });
17 |
18 | test.run();
19 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/component-name.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = 'Hello world!
';
6 |
7 | let result: TransformResult;
8 | test.before(async () => {
9 | result = await transform(FIXTURE, {
10 | filename: '/src/components/Cool.astro',
11 | });
12 | });
13 |
14 | test('exports named component', () => {
15 | assert.match(result.code, 'export default $$Cool', 'Expected output to contain named export');
16 | });
17 |
18 | test.run();
19 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/serializer.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import "sync"
4 |
5 | // Each call to "Enter(i)" doesn't start until "Leave(i-1)" is called
6 | type Serializer struct {
7 | flags []sync.WaitGroup
8 | }
9 |
10 | func MakeSerializer(count int) Serializer {
11 | flags := make([]sync.WaitGroup, count)
12 | for i := 0; i < count; i++ {
13 | flags[i].Add(1)
14 | }
15 | return Serializer{flags: flags}
16 | }
17 |
18 | func (s *Serializer) Enter(i int) {
19 | if i > 0 {
20 | s.flags[i-1].Wait()
21 | }
22 | }
23 |
24 | func (s *Serializer) Leave(i int) {
25 | s.flags[i].Done()
26 | }
27 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/head-injection.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = 'Ah';
6 |
7 | let result: TransformResult;
8 | test.before(async () => {
9 | result = await transform(FIXTURE);
10 | });
11 |
12 | test('head injection', () => {
13 | assert.match(
14 | result.code,
15 | '$$renderHead($$result)',
16 | 'Expected output to contain $$renderHead($$result) injection point'
17 | );
18 | });
19 |
20 | test.run();
21 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/escaping.ts:
--------------------------------------------------------------------------------
1 | import { parse } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const STYLE = 'div { & span { color: red; }}';
6 | const FIXTURE = ``;
7 |
8 | test('ampersand', async () => {
9 | const result = await parse(FIXTURE);
10 | assert.ok(result.ast, 'Expected an AST to be generated');
11 | const [
12 | {
13 | children: [{ value: output }],
14 | },
15 | ] = result.ast.children as any;
16 | assert.equal(output, STYLE, 'Expected AST style to equal input');
17 | });
18 |
19 | test.run();
20 |
--------------------------------------------------------------------------------
/internal/printer/__printer_css__/scopedStyleStrategy___class_.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinterCSS/scopedStyleStrategy:_'class' - 1]
3 | ## Input
4 |
5 | ```
6 |
16 |
17 | Page Title
18 | I’m a page
19 | ```
20 |
21 | ## Output
22 |
23 | ```css
24 | .title.astro-dpohflym{font-family:fantasy;font-size:28px}.body.astro-dpohflym{font-size:1em}
25 | ```
26 | ---
27 |
--------------------------------------------------------------------------------
/lib/esbuild/css_parser/css_decls_font_weight.go:
--------------------------------------------------------------------------------
1 | package css_parser
2 |
3 | import (
4 | "strings"
5 |
6 | "github.com/withastro/compiler/lib/esbuild/css_ast"
7 | "github.com/withastro/compiler/lib/esbuild/css_lexer"
8 | )
9 |
10 | func (p *parser) mangleFontWeight(token css_ast.Token) css_ast.Token {
11 | if token.Kind != css_lexer.TIdent {
12 | return token
13 | }
14 |
15 | switch strings.ToLower(token.Text) {
16 | case "normal":
17 | token.Text = "400"
18 | token.Kind = css_lexer.TNumber
19 | case "bold":
20 | token.Text = "700"
21 | token.Kind = css_lexer.TNumber
22 | }
23 |
24 | return token
25 | }
26 |
--------------------------------------------------------------------------------
/packages/compiler/test/styles/emit-scope.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | let value = 'world';
8 | ---
9 |
10 |
11 |
12 | Hello world!
13 | `;
14 |
15 | let result: TransformResult;
16 | test.before(async () => {
17 | result = await transform(FIXTURE, {
18 | sourcemap: true,
19 | });
20 | });
21 |
22 | test('emits a scope', () => {
23 | assert.ok(result.scope, 'Expected to return a scope');
24 | });
25 |
26 | test.run();
27 |
--------------------------------------------------------------------------------
/internal/printer/__printer_css__/styles__no_frontmatter_.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinterCSS/styles_(no_frontmatter) - 1]
3 | ## Input
4 |
5 | ```
6 |
16 |
17 | Page Title
18 | I’m a page
19 | ```
20 |
21 | ## Output
22 |
23 | ```css
24 | .title:where(.astro-dpohflym){font-family:fantasy;font-size:28px}.body:where(.astro-dpohflym){font-size:1em}
25 | ```
26 | ---
27 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/bitset.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import "bytes"
4 |
5 | type BitSet struct {
6 | entries []byte
7 | }
8 |
9 | func NewBitSet(bitCount uint) BitSet {
10 | return BitSet{make([]byte, (bitCount+7)/8)}
11 | }
12 |
13 | func (bs BitSet) HasBit(bit uint) bool {
14 | return (bs.entries[bit/8] & (1 << (bit & 7))) != 0
15 | }
16 |
17 | func (bs BitSet) SetBit(bit uint) {
18 | bs.entries[bit/8] |= 1 << (bit & 7)
19 | }
20 |
21 | func (bs BitSet) Equals(other BitSet) bool {
22 | return bytes.Equal(bs.entries, other.entries)
23 | }
24 |
25 | func (bs BitSet) String() string {
26 | return string(bs.entries)
27 | }
28 |
--------------------------------------------------------------------------------
/packages/compiler/test/head-metadata/with-head.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 |
8 | Testing
9 |
10 |
11 | Testing
12 |
13 |
14 | `;
15 |
16 | let result: TransformResult;
17 | test.before(async () => {
18 | result = await transform(FIXTURE, {
19 | filename: 'test.astro',
20 | });
21 | });
22 |
23 | test('containsHead is true', () => {
24 | assert.equal(result.containsHead, true);
25 | });
26 |
27 | test.run();
28 |
--------------------------------------------------------------------------------
/internal/printer/__printer_css__/scopedStyleStrategy___attribute_.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinterCSS/scopedStyleStrategy:_'attribute' - 1]
3 | ## Input
4 |
5 | ```
6 |
16 |
17 | Page Title
18 | I’m a page
19 | ```
20 |
21 | ## Output
22 |
23 | ```css
24 | .title[data-astro-cid-dpohflym]{font-family:fantasy;font-size:28px}.body[data-astro-cid-dpohflym]{font-size:1em}
25 | ```
26 | ---
27 |
--------------------------------------------------------------------------------
/packages/compiler/test/css-order/astro-styles.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
9 | `;
10 |
11 | let result: TransformResult;
12 | test.before(async () => {
13 | result = await transform(FIXTURE, {
14 | filename: 'test.astro',
15 | });
16 | });
17 |
18 | test('Astro style imports are included in the compiled JS', () => {
19 | const idx = result.code.indexOf('test.astro?astro&type=style&index=0&lang.css');
20 | assert.not.equal(idx, -1);
21 | });
22 |
23 | test.run();
24 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-errors/unfinished-component.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import type { TSXResult } from '../../types.js';
5 |
6 | const FIXTURE = ' {
10 | result = await convertToTSX(FIXTURE, {
11 | filename: '/src/components/unfinished.astro',
12 | });
13 | });
14 |
15 | test('did not crash on unfinished component', () => {
16 | assert.ok(result);
17 | assert.ok(Array.isArray(result.diagnostics));
18 | assert.is(result.diagnostics.length, 0);
19 | });
20 |
21 | test.run();
22 |
--------------------------------------------------------------------------------
/packages/compiler/test/slot-result/result.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | import Parent from './Parent.astro';
8 | ---
9 |
10 |
11 |
12 | `;
13 |
14 | let result: TransformResult;
15 | test.before(async () => {
16 | result = await transform(FIXTURE, {
17 | resolvePath: async (s) => s,
18 | resultScopedSlot: true,
19 | });
20 | });
21 |
22 | test('resultScopedSlot: includes the result object in the call to the slot', () => {
23 | assert.match(result.code, /\(\$\$result\) =>/);
24 | });
25 |
26 | test.run();
27 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/client-component-unfound.ts:
--------------------------------------------------------------------------------
1 | import { parse } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `{
6 | headers && (
7 |
15 | )
16 | }
17 | `;
18 |
19 | test('unfound client component', async () => {
20 | const result = await parse(FIXTURE);
21 | assert.ok(result.ast, 'Expected an AST to be generated');
22 | });
23 |
24 | test.run();
25 |
--------------------------------------------------------------------------------
/packages/compiler/test/client-directive/warn.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 | `;
8 |
9 | let result: TransformResult;
10 | test.before(async () => {
11 | result = await transform(FIXTURE);
12 | });
13 |
14 | test('reports a warning for using a client directive', () => {
15 | assert.ok(Array.isArray(result.diagnostics));
16 | assert.is(result.diagnostics.length, 2);
17 | assert.equal(result.diagnostics[0].severity, 2);
18 | assert.match(result.diagnostics[0].text, 'does not need the client:load directive');
19 | });
20 |
21 | test.run();
22 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/multibyte-characters.ts:
--------------------------------------------------------------------------------
1 | import { parse } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = '{foo},';
6 |
7 | test('does not crash', async () => {
8 | const result = await parse(FIXTURE);
9 | assert.ok(result.ast, 'does not crash');
10 | });
11 |
12 | test('properly maps the position', async () => {
13 | const {
14 | ast: { children },
15 | } = await parse(FIXTURE);
16 |
17 | const text = children[1];
18 | assert.equal(text.position?.start.offset, 5, 'properly maps the text start position');
19 | assert.equal(text.position?.end?.offset, 8, 'properly maps the text end position');
20 | });
21 |
22 | test.run();
23 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/path.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import "strings"
4 |
5 | func IsInsideNodeModules(path string) bool {
6 | for {
7 | // This is written in a platform-independent manner because it's run on
8 | // user-specified paths which can be arbitrary non-file-system things. So
9 | // for example Windows paths may end up being used on Unix or URLs may end
10 | // up being used on Windows. Be consistently agnostic to which kind of
11 | // slash is used on all platforms.
12 | slash := strings.LastIndexAny(path, "/\\")
13 | if slash == -1 {
14 | return false
15 | }
16 | dir, base := path[:slash], path[slash+1:]
17 | if base == "node_modules" {
18 | return true
19 | }
20 | path = dir
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/body-expression.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | const slugs = ['one', 'two', 'three'];
8 | ---
9 |
10 |
11 |
12 |
13 | {slugs.map((slug) => (
14 |
{slug}
15 | ))}
16 |
17 |
18 | `;
19 |
20 | let result: TransformResult;
21 | test.before(async () => {
22 | result = await transform(FIXTURE);
23 | });
24 |
25 | test('can compiler body expression', () => {
26 | assert.ok(result.code, 'Expected to compiler body expression!');
27 | });
28 |
29 | test.run();
30 |
--------------------------------------------------------------------------------
/packages/compiler/test/styles/empty-style.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import { preprocessStyle } from '../utils.js';
5 |
6 | const FIXTURE = `
7 | ---
8 | let value = 'world';
9 | ---
10 |
11 |
12 |
13 |
Hello world!
14 |
15 |
Ahhh
16 | `;
17 |
18 | let result: TransformResult;
19 | test.before(async () => {
20 | result = await transform(FIXTURE, {
21 | sourcemap: true,
22 | preprocessStyle,
23 | });
24 | });
25 |
26 | test('can compile empty style', () => {
27 | assert.ok(result.code, 'Expected to compile with empty style.');
28 | });
29 |
30 | test.run();
31 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_after_html_with_component_in_head.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_after_html_with_component_in_head - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/packages/compiler/test/scripts/isinline-hint.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('reports a hint for adding attributes to a script tag without is:inline', async () => {
6 | const result = await transform(``);
7 | assert.equal(result.diagnostics[0].severity, 4);
8 | assert.match(result.diagnostics[0].text, /\#script-processing/);
9 | });
10 |
11 | test('does not report a diagnostic for the src attribute', async () => {
12 | const result = await transform(``);
13 | console.log(result.diagnostics);
14 | assert.equal(result.diagnostics.length, 0);
15 | });
16 |
17 | test.run();
18 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/null-chars.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 |

8 |
9 | `;
10 |
11 | let result: TransformResult;
12 | test.before(async () => {
13 | result = await transform(FIXTURE, {
14 | filename:
15 | '/Users/matthew/dev/astro/packages/astro/test/fixtures/astro-attrs/src/pages/namespaced.astro',
16 | sourcemap: 'both',
17 | });
18 | });
19 |
20 | test('Includes null characters', () => {
21 | assert.not.match(result.code, '\x00', 'Corrupted output');
22 | });
23 |
24 | test.run();
25 |
--------------------------------------------------------------------------------
/packages/compiler/test/errors/invalid-spread.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('...spread has warning', async () => {
6 | const result = await transform('
', { filename: '/src/components/Foo.astro' });
7 | assert.ok(Array.isArray(result.diagnostics));
8 | assert.is(result.diagnostics.length, 1);
9 | assert.is(result.diagnostics[0].code, 2008);
10 | });
11 |
12 | test('{...spread} does not have warning', async () => {
13 | const result = await transform('', { filename: '/src/components/Foo.astro' });
14 | assert.ok(Array.isArray(result.diagnostics));
15 | assert.is(result.diagnostics.length, 0);
16 | });
17 |
18 | test.run();
19 |
--------------------------------------------------------------------------------
/packages/compiler/test/css-order/imported-styles.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | import '../styles/global.css';
8 | ---
9 |
12 | `;
13 |
14 | let result: TransformResult;
15 | test.before(async () => {
16 | result = await transform(FIXTURE, {
17 | filename: 'test.astro',
18 | });
19 | });
20 |
21 | test('Astro style imports placed after frontmatter imports', () => {
22 | const idx1 = result.code.indexOf('../styles/global.css');
23 | const idx2 = result.code.indexOf('test.astro?astro&type=style&index=0&lang.css');
24 | assert.ok(idx2 > idx1);
25 | });
26 |
27 | test.run();
28 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/orphan-slot.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | import { Code, Markdown } from 'astro/components';
8 |
9 | const {isRequired, description, example} = Astro.props;
10 | ---
11 |
12 |
11 |
13 | {false && (
14 |
15 | )}
16 |
17 |
18 | {null && (
19 |
20 | )}
21 |
22 |
23 | {true && (
24 |
25 | )}
26 |
27 |
28 | {false && (
)}
29 | `;
30 |
31 | let result: TransformResult;
32 | test.before(async () => {
33 | result = await transform(FIXTURE);
34 | });
35 |
36 | test('top-level expressions', () => {
37 | assert.ok(result.code, 'Can compile top-level expressions');
38 | });
39 |
40 | test.run();
41 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-errors/eof.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import type { TSXResult } from '../../types.js';
5 |
6 | const FIXTURE = `
7 |
8 |
Hello world
9 |
10 |
11 |
12 | {/*
13 |
14 |
15 | `;
16 |
17 | let result: TSXResult;
18 | test.before(async () => {
19 | result = await convertToTSX(FIXTURE, {
20 | filename: '/src/components/EOF.astro',
21 | });
22 | });
23 |
24 | test('got a tokenizer error', () => {
25 | assert.ok(Array.isArray(result.diagnostics));
26 | assert.is(result.diagnostics.length, 1);
27 | assert.is(result.diagnostics[0].text, 'Unterminated comment');
28 | assert.is(FIXTURE.split('\n')[result.diagnostics[0].location.line - 1], ' {/*');
29 | });
30 |
31 | test.run();
32 |
--------------------------------------------------------------------------------
/packages/compiler/test/errors/define-vars.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('define:vars warning', async () => {
6 | const result = await transform(
7 | `
8 | `,
9 | { filename: '/src/components/Foo.astro' }
10 | );
11 | assert.ok(Array.isArray(result.diagnostics));
12 | assert.is(result.diagnostics.length, 1);
13 | assert.is(result.diagnostics[0].code, 2007);
14 | });
15 |
16 | test('define:vars no warning', async () => {
17 | const result = await transform(
18 | `
19 | `,
20 | { filename: '/src/components/Foo.astro' }
21 | );
22 | assert.ok(Array.isArray(result.diagnostics));
23 | assert.is(result.diagnostics.length, 0);
24 | });
25 |
26 | test.run();
27 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_after_body_with_component_in_head_and_body.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_after_body_with_component_in_head_and_body - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]},{"type":"element","name":"body","attributes":[],"children":[{"type":"component","name":"Header","attributes":[],"children":[]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/internal/printer/__printer_json__/style_after_html_with_component_in_head_and_body.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrintToJSON/style_after_html_with_component_in_head_and_body - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```json
12 | {"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]},{"type":"element","name":"body","attributes":[],"children":[{"type":"component","name":"Header","attributes":[],"children":[]}]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]}
13 | ```
14 | ---
15 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/body-after-head-component.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `---
6 | const isProd = true;
7 | ---
8 |
9 |
10 |
11 | {isProd &&
}
12 |
document
13 | {isProd &&
}
14 |
15 |
16 |
17 | Welcome to Astro
18 |
19 |
20 |
21 | `;
22 |
23 | let result: TransformResult;
24 | test.before(async () => {
25 | result = await transform(FIXTURE);
26 | });
27 |
28 | test('has body in output', () => {
29 | assert.match(
30 | result.code,
31 | '',
32 | 'Expected output to contain body element!'
33 | );
34 | });
35 |
36 | test.run();
37 |
--------------------------------------------------------------------------------
/lib/esbuild/test/util.go:
--------------------------------------------------------------------------------
1 | package test
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 |
7 | "github.com/withastro/compiler/lib/esbuild/logger"
8 | )
9 |
10 | func AssertEqual(t *testing.T, observed interface{}, expected interface{}) {
11 | t.Helper()
12 | if observed != expected {
13 | t.Fatalf("%s != %s", observed, expected)
14 | }
15 | }
16 |
17 | func AssertEqualWithDiff(t *testing.T, observed interface{}, expected interface{}) {
18 | t.Helper()
19 | if observed != expected {
20 | stringA := fmt.Sprintf("%v", observed)
21 | stringB := fmt.Sprintf("%v", expected)
22 | color := true
23 | t.Fatal(diff(stringB, stringA, color))
24 | }
25 | }
26 |
27 | func SourceForTest(contents string) logger.Source {
28 | return logger.Source{
29 | Index: 0,
30 | KeyPath: logger.Path{Text: "
"},
31 | PrettyPath: "",
32 | Contents: contents,
33 | IdentifierName: "stdin",
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/trailing-space.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `---
6 | import { Markdown } from 'astro/components';
7 | import Layout from '../layouts/content.astro';
8 | ---
9 |
10 |
15 |
16 |
17 |
18 |
19 | ## Interesting Topic
20 |
21 |
22 | `; // NOTE: the lack of trailing space is important to this test!
23 |
24 | let result: TransformResult;
25 | test.before(async () => {
26 | result = await transform(FIXTURE);
27 | });
28 |
29 | test('trailing space', () => {
30 | assert.ok(result.code, 'Expected to compiler');
31 | assert.not.match(result.code, 'html', 'Expected output to not contain ');
32 | });
33 |
34 | test.run();
35 |
--------------------------------------------------------------------------------
/packages/compiler/test/static-extraction/css.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | ---
8 |
13 | `;
14 |
15 | let result: TransformResult;
16 | test.before(async () => {
17 | result = await transform(FIXTURE);
18 | });
19 |
20 | test('extracts styles', () => {
21 | assert.equal(
22 | result.css.length,
23 | 1,
24 | `Incorrect CSS returned. Expected a length of 1 and got ${result.css.length}`
25 | );
26 | });
27 |
28 | test('escape url with space', () => {
29 | assert.match(result.css[0], 'background:url(/white\\ space.png)');
30 | });
31 |
32 | test('escape css syntax', () => {
33 | assert.match(result.css[0], ':not(#\\#)');
34 | });
35 |
36 | test.run();
37 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/withastro/compiler
2 |
3 | go 1.21
4 |
5 | require (
6 | github.com/gkampitakis/go-snaps v0.5.2
7 | github.com/google/go-cmp v0.5.9
8 | github.com/iancoleman/strcase v0.2.0
9 | github.com/lithammer/dedent v1.1.0
10 | github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd
11 | github.com/tdewolff/parse/v2 v2.6.4
12 | golang.org/x/net v0.0.0-20221004154528-8021a29435af
13 | golang.org/x/sys v0.0.0-20221010170243-090e33056c14
14 | )
15 |
16 | require (
17 | github.com/gkampitakis/ciinfo v0.3.0 // indirect
18 | github.com/gkampitakis/go-diff v1.3.2 // indirect
19 | github.com/kr/pretty v0.3.1 // indirect
20 | github.com/kr/text v0.2.0 // indirect
21 | github.com/maruel/natural v1.1.1 // indirect
22 | github.com/rogpeppe/go-internal v1.12.0 // indirect
23 | github.com/tidwall/gjson v1.17.0 // indirect
24 | github.com/tidwall/match v1.1.1 // indirect
25 | github.com/tidwall/pretty v1.2.1 // indirect
26 | github.com/tidwall/sjson v1.2.5 // indirect
27 | )
28 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/fragment.ts:
--------------------------------------------------------------------------------
1 | import { type ParseResult, parse } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import type { FragmentNode } from '../../types.js';
5 |
6 | const FIXTURE = '<>Hello>World';
7 |
8 | let result: ParseResult;
9 | test.before(async () => {
10 | result = await parse(FIXTURE);
11 | });
12 |
13 | test('fragment shorthand', () => {
14 | const [first] = result.ast.children as FragmentNode[];
15 | assert.equal(first.type, 'fragment', 'Expected first child to be of type "fragment"');
16 | assert.equal(first.name, '', 'Expected first child to have name of ""');
17 | });
18 |
19 | test('fragment literal', () => {
20 | const [, second] = result.ast.children as FragmentNode[];
21 | assert.equal(second.type, 'fragment', 'Expected second child to be of type "fragment"');
22 | assert.equal(second.name, 'Fragment', 'Expected second child to have name of ""');
23 | });
24 |
25 | test.run();
26 |
--------------------------------------------------------------------------------
/lib/esbuild/compat/compat.go:
--------------------------------------------------------------------------------
1 | package compat
2 |
3 | type v struct {
4 | major uint16
5 | minor uint8
6 | patch uint8
7 | }
8 |
9 | // Returns <0 if "a < b"
10 | // Returns 0 if "a == b"
11 | // Returns >0 if "a > b"
12 | func compareVersions(a v, b []int) int {
13 | diff := int(a.major)
14 | if len(b) > 0 {
15 | diff -= b[0]
16 | }
17 | if diff == 0 {
18 | diff = int(a.minor)
19 | if len(b) > 1 {
20 | diff -= b[1]
21 | }
22 | }
23 | if diff == 0 {
24 | diff = int(a.patch)
25 | if len(b) > 2 {
26 | diff -= b[2]
27 | }
28 | }
29 | return diff
30 | }
31 |
32 | // The start is inclusive and the end is exclusive
33 | type versionRange struct {
34 | start v
35 | end v // Use 0.0.0 for "no end"
36 | }
37 |
38 | func isVersionSupported(ranges []versionRange, version []int) bool {
39 | for _, r := range ranges {
40 | if compareVersions(r.start, version) <= 0 && (r.end == (v{}) || compareVersions(r.end, version) > 0) {
41 | return true
42 | }
43 | }
44 | return false
45 | }
46 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/tags.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { TraceMap, generatedPositionFor } from '@jridgewell/trace-mapping';
3 | import { test } from 'uvu';
4 | import * as assert from 'uvu/assert';
5 | import { testTSXSourcemap } from '../utils.js';
6 |
7 | test('tag close', async () => {
8 | const input = '';
9 | const output = await testTSXSourcemap(input, '>');
10 |
11 | assert.equal(output, {
12 | line: 1,
13 | column: 6,
14 | source: 'index.astro',
15 | name: null,
16 | });
17 | });
18 |
19 | test('tag with spaces', async () => {
20 | const input = '';
21 | const { map } = await convertToTSX(input, { sourcemap: 'both', filename: 'index.astro' });
22 | const tracer = new TraceMap(map as any);
23 |
24 | const generated = generatedPositionFor(tracer, { source: 'index.astro', line: 1, column: 14 });
25 |
26 | assert.equal(generated, {
27 | line: 4,
28 | column: 9,
29 | });
30 | });
31 |
32 | test.run();
33 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/expression-then-node.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | import Show from './Show.astro';
8 |
9 | export interface Props {
10 | each: Iterable;
11 | }
12 |
13 | const { each } = Astro.props;
14 | ---
15 |
16 | {
17 | (async function* () {
18 | for await (const value of each) {
19 | let html = await Astro.slots.render('default', [value]);
20 | yield ;
21 | yield '\n';
22 | }
23 | })()
24 | }
25 |
26 |
27 |
28 |
29 | `;
30 |
31 | let result: TransformResult;
32 | test.before(async () => {
33 | result = await transform(FIXTURE);
34 | });
35 |
36 | test('expression followed by node', () => {
37 | assert.match(
38 | result.code,
39 | `yield '
40 | ';
41 | }`,
42 | 'Expected output to properly handle expression!'
43 | );
44 | });
45 |
46 | test.run();
47 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/mime.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import "strings"
4 |
5 | var builtinTypesLower = map[string]string{
6 | ".css": "text/css; charset=utf-8",
7 | ".gif": "image/gif",
8 | ".htm": "text/html; charset=utf-8",
9 | ".html": "text/html; charset=utf-8",
10 | ".jpeg": "image/jpeg",
11 | ".jpg": "image/jpeg",
12 | ".js": "text/javascript; charset=utf-8",
13 | ".json": "application/json",
14 | ".mjs": "text/javascript; charset=utf-8",
15 | ".pdf": "application/pdf",
16 | ".png": "image/png",
17 | ".svg": "image/svg+xml",
18 | ".wasm": "application/wasm",
19 | ".webp": "image/webp",
20 | ".xml": "text/xml; charset=utf-8",
21 | }
22 |
23 | // This is used instead of Go's built-in "mime.TypeByExtension" function because
24 | // that function is broken on Windows: https://github.com/golang/go/issues/32350.
25 | func MimeTypeByExtension(ext string) string {
26 | contentType := builtinTypesLower[ext]
27 | if contentType == "" {
28 | contentType = builtinTypesLower[strings.ToLower(ext)]
29 | }
30 | return contentType
31 | }
32 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/typos.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import "unicode/utf8"
4 |
5 | type TypoDetector struct {
6 | oneCharTypos map[string]string
7 | }
8 |
9 | func MakeTypoDetector(valid []string) TypoDetector {
10 | detector := TypoDetector{oneCharTypos: make(map[string]string)}
11 |
12 | // Add all combinations of each valid word with one character missing
13 | for _, correct := range valid {
14 | if len(correct) > 3 {
15 | for i, ch := range correct {
16 | detector.oneCharTypos[correct[:i]+correct[i+utf8.RuneLen(ch):]] = correct
17 | }
18 | }
19 | }
20 |
21 | return detector
22 | }
23 |
24 | func (detector TypoDetector) MaybeCorrectTypo(typo string) (string, bool) {
25 | // Check for a single deleted character
26 | if corrected, ok := detector.oneCharTypos[typo]; ok {
27 | return corrected, true
28 | }
29 |
30 | // Check for a single misplaced character
31 | for i, ch := range typo {
32 | if corrected, ok := detector.oneCharTypos[typo[:i]+typo[i+utf8.RuneLen(ch):]]; ok {
33 | return corrected, true
34 | }
35 | }
36 |
37 | return "", false
38 | }
39 |
--------------------------------------------------------------------------------
/packages/compiler/test/parse/orphan-head.ts:
--------------------------------------------------------------------------------
1 | import { type ParseResult, parse } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 |
8 |
9 |
10 |
11 |
12 | Document
13 |
14 |
15 |
16 | Hello world!
17 |
18 |
19 | `;
20 |
21 | let result: ParseResult;
22 | test.before(async () => {
23 | result = await parse(FIXTURE);
24 | });
25 |
26 | test('orphan head', () => {
27 | assert.ok(result, 'able to parse');
28 |
29 | const [doctype, html, ...others] = result.ast.children;
30 | assert.equal(others.length, 1, 'Expected only three child nodes!');
31 | assert.equal(doctype.type, 'doctype', `Expected first child node to be of type "doctype"`);
32 | assert.equal(html.type, 'element', `Expected first child node to be of type "element"`);
33 | });
34 |
35 | test.run();
36 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx/raw.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import { TSXPrefix } from '../utils.js';
5 |
6 | test('style is raw', async () => {
7 | const input = '';
8 | const output = `${TSXPrefix}
9 |
10 |
11 | export default function __AstroComponent_(_props: Record): any {}\n`;
12 | const { code } = await convertToTSX(input, { sourcemap: 'external' });
13 | assert.snapshot(code, output, 'expected code to match snapshot');
14 | });
15 |
16 | test('is:raw is raw', async () => {
17 | const input = 'A{B}C
';
18 | const output = `${TSXPrefix}
19 | {\`A{B}C\`}
20 |
21 | export default function __AstroComponent_(_props: Record): any {}\n`;
22 | const { code } = await convertToTSX(input, { sourcemap: 'external' });
23 | assert.snapshot(code, output, 'expected code to match snapshot');
24 | });
25 |
26 | test.run();
27 |
--------------------------------------------------------------------------------
/packages/compiler/test/scope/same-source.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | ---
8 |
9 |
16 |
17 |
18 | `.trim();
19 |
20 | function grabAstroScope(code: string) {
21 | const match = /astro-[0-9A-Za-z]+/.exec(code);
22 | if (match) {
23 | return match[0];
24 | }
25 | return null;
26 | }
27 |
28 | test('Similar components have different scoped class names', async () => {
29 | let result = await transform(FIXTURE, {
30 | normalizedFilename: '/src/pages/index.astro',
31 | });
32 | const scopeA = grabAstroScope(result.code);
33 | assert.ok(scopeA);
34 |
35 | result = await transform(FIXTURE, {
36 | normalizedFilename: '/src/pages/two.astro',
37 | });
38 |
39 | const scopeB = grabAstroScope(result.code);
40 | assert.ok(scopeB);
41 |
42 | assert.ok(scopeA !== scopeB, 'The scopes should not match for different files');
43 | });
44 |
45 | test.run();
46 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/go
3 | {
4 | "name": "Go",
5 | "build": {
6 | "dockerfile": "Dockerfile",
7 | "args": {
8 | // Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
9 | // Append -bullseye or -buster to pin to an OS version.
10 | // Use -bullseye variants on local arm64/Apple Silicon.
11 | "VARIANT": "1.19",
12 | // Options
13 | "NODE_VERSION": "16"
14 | }
15 | },
16 | "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
17 |
18 | // Configure tool-specific properties.
19 | "customizations": {
20 | "vscode": {
21 | "settings": {
22 | "go.toolsManagement.checkForUpdates": "local",
23 | "go.useLanguageServer": true,
24 | "go.gopath": "/go",
25 | "go.goroot": "/usr/local/go"
26 | },
27 | "extensions": ["golang.Go"]
28 | }
29 | },
30 |
31 | "remoteUser": "vscode"
32 | }
33 |
--------------------------------------------------------------------------------
/internal/helpers/js_comment_utils.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import (
4 | "strings"
5 | )
6 |
7 | func peekIs(input string, cur int, assert byte) bool {
8 | return cur+1 < len(input) && input[cur+1] == assert
9 | }
10 |
11 | // RemoveComments removes both block and inline comments from a string
12 | func RemoveComments(input string) string {
13 | var (
14 | sb = strings.Builder{}
15 | inComment = false
16 | )
17 | for cur := 0; cur < len(input); cur++ {
18 | if input[cur] == '/' && !inComment {
19 | if peekIs(input, cur, '*') {
20 | inComment = true
21 | cur++
22 | } else if peekIs(input, cur, '/') {
23 | // Skip until the end of line for inline comments
24 | for cur < len(input) && input[cur] != '\n' {
25 | cur++
26 | }
27 | continue
28 | }
29 | } else if input[cur] == '*' && inComment && peekIs(input, cur, '/') {
30 | inComment = false
31 | cur++
32 | continue
33 | }
34 |
35 | if !inComment {
36 | sb.WriteByte(input[cur])
37 | }
38 | }
39 |
40 | if inComment {
41 | return ""
42 | }
43 |
44 | return strings.TrimSpace(sb.String())
45 | }
46 |
--------------------------------------------------------------------------------
/packages/compiler/test/errors/client-only-unfound.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `---
6 | import * as components from '../components';
7 | const { MyComponent } = components;
8 | ---
9 |
10 |
11 | Hello world
12 |
13 |
14 |
15 |
16 | `;
17 |
18 | let result: TransformResult;
19 | test.before(async () => {
20 | result = await transform(FIXTURE, {
21 | filename: '/src/components/Cool.astro',
22 | });
23 | });
24 |
25 | test('got an error because client:only component not found import', () => {
26 | assert.ok(Array.isArray(result.diagnostics));
27 | assert.is(result.diagnostics.length, 1);
28 | assert.is(
29 | result.diagnostics[0].text,
30 | 'Unable to find matching import statement for client:only component'
31 | );
32 | assert.is(
33 | FIXTURE.split('\n')[result.diagnostics[0].location.line - 1],
34 | ' '
35 | );
36 | });
37 |
38 | test.run();
39 |
--------------------------------------------------------------------------------
/packages/compiler/test/resolve-path/preserve.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 | ---
7 | import Foo from './Foo.jsx'
8 | import Bar from './Bar.jsx'
9 | import { name } './foo.module.css'
10 | ---
11 |
12 |
13 |
14 | `;
15 |
16 | let result: TransformResult;
17 | test.before(async () => {
18 | result = await transform(FIXTURE, {
19 | resolvePath: async (s) => s,
20 | });
21 | });
22 |
23 | test('preserve path', () => {
24 | assert.match(result.code, /"client:load":true.*"client:component-path":\("\.\/Foo\.jsx"\)/);
25 | assert.match(result.code, /"client:only":"react".*"client:component-path":\("\.\/Foo\.jsx"\)/);
26 | });
27 |
28 | test('no metadata', () => {
29 | assert.not.match(result.code, /\$\$metadata/);
30 | assert.not.match(result.code, /\$\$createMetadata/);
31 | assert.not.match(result.code, /createMetadata as \$\$createMetadata/);
32 | assert.not.match(result.code, /import \* as \$\$module\d/);
33 | });
34 |
35 | test.run();
36 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/script-before-html.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Astro strips html lang tag
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
31 | `;
32 |
33 | let result: TransformResult;
34 | test.before(async () => {
35 | result = await transform(FIXTURE);
36 | });
37 |
38 | test('includes html element', () => {
39 | assert.ok(
40 | result.code.includes(''),
41 | 'Expected compile result to include html element!'
42 | );
43 | });
44 |
45 | test.run();
46 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/export.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('TypeScript props on newline', async () => {
6 | const FIXTURE = `---
7 | export type Props = BaseLayoutProps &
8 | Pick;
9 | ---
10 |
11 |
12 | `;
13 | const result = await transform(FIXTURE);
14 | assert.match(
15 | result.code,
16 | 'BaseLayoutProps &\n Pick<',
17 | 'Expected output to contain full Props export'
18 | );
19 | });
20 |
21 | test('exported type', async () => {
22 | const FIXTURE = `---
23 | // this is fine
24 | export type NumberType = number;
25 | // astro hangs because of this typedef.
26 | // comment it out and astro will work fine.
27 | export type FuncType = (x: number) => number;
28 | ---
29 |
30 | {new Date()}
31 | `;
32 | const result = await transform(FIXTURE);
33 | assert.match(
34 | result.code,
35 | 'export type NumberType = number;\nexport type FuncType = (x: number) => number',
36 | 'Expected output to contain full Props export'
37 | );
38 | });
39 |
40 | test.run();
41 |
--------------------------------------------------------------------------------
/packages/compiler/test/errors/fragment-shorthand.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `
6 |
7 | Hello world
8 |
9 |
10 | < data-test="hello">>
11 |
12 | `;
13 |
14 | let result: TransformResult;
15 | test.before(async () => {
16 | result = await transform(FIXTURE, {
17 | filename: '/src/components/fragment.astro',
18 | });
19 | });
20 |
21 | test('got a tokenizer error', () => {
22 | assert.ok(Array.isArray(result.diagnostics));
23 | assert.is(result.diagnostics.length, 1);
24 | assert.is(
25 | result.diagnostics[0].text,
26 | 'Unable to assign attributes when using <> Fragment shorthand syntax!'
27 | );
28 | const loc = result.diagnostics[0].location;
29 | assert.is(FIXTURE.split('\n')[loc.line - 1], ` < data-test="hello">>`);
30 | assert.is(
31 | FIXTURE.split('\n')[loc.line - 1].slice(loc.column - 1, loc.column - 1 + loc.length),
32 | `< data-test="hello">`
33 | );
34 | });
35 |
36 | test.run();
37 |
--------------------------------------------------------------------------------
/packages/compiler/test/styles/define-vars.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import { preprocessStyle } from '../utils.js';
5 |
6 | test('does not include define:vars in generated markup', async () => {
7 | const input = `
8 | ---
9 | let color = 'red';
10 | ---
11 |
12 |
17 |
18 | Hello world!
19 |
20 | Ahhh
21 | `;
22 | const result = await transform(input, {
23 | preprocessStyle,
24 | });
25 | assert.ok(!result.code.includes('STYLES'));
26 | assert.equal(result.css.length, 1);
27 | });
28 |
29 | test('handles style object and define:vars', async () => {
30 | const input = `
31 | ---
32 | let color = 'red';
33 | ---
34 |
35 | Hello world!
36 |
37 |
38 | `;
39 | const result = await transform(input);
40 | assert.match(result.code, `$$addAttribute([{ color: 'var(--color)' },$$definedVars], "style")`);
41 | });
42 |
43 | test.run();
44 |
--------------------------------------------------------------------------------
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/go/.devcontainer/base.Dockerfile
2 | # [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster
3 | ARG VARIANT=1-bullseye
4 | FROM mcr.microsoft.com/devcontainers/go:0-${VARIANT}
5 |
6 | # [Choice] Node.js version: lts/*, 16, 14, 12, 10
7 | ARG NODE_VERSION="lts/*"
8 | RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c ". /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
9 |
10 | # [Optional] Uncomment this section to install additional OS packages.
11 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
12 | # && apt-get -y install --no-install-recommends
13 |
14 | # [Optional] Uncomment the next line to use go get to install anything else you need
15 | # RUN go get -x
16 |
17 | # [Optional] Uncomment this line to install global node packages.
18 | RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g pnpm" 2>&1
19 |
--------------------------------------------------------------------------------
/lib/esbuild/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Evan Wallace
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/trailing-newline.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE = `{
6 | node.shouldRenderChildren() ? (
7 | // IMPORTANT - DO NOT SELF CLOSE THIS TAG. ASTRO FREAKS OUT.
8 |
9 | ) : node.shouldRenderSelf() ? (
10 | // @ts-ignore
11 | content.map((element) => {
12 | return ;
13 | })
14 | ) : node.shouldRenderTag() ? (
15 |
16 | {node.hasChildren() ? (
17 |
18 | ) : null}
19 |
20 | ) : null
21 | }
22 | `;
23 |
24 | let result: TransformResult;
25 | test.before(async () => {
26 | result = await transform(FIXTURE);
27 | });
28 |
29 | test('does not add trailing newline to rendered output', () => {
30 | assert.match(
31 | result.code,
32 | `}\`;\n}, '', undefined);`,
33 | 'Does not include a trailing newline in the render function'
34 | );
35 | });
36 |
37 | test.run();
38 |
--------------------------------------------------------------------------------
/packages/compiler/test/styles/sass.ts:
--------------------------------------------------------------------------------
1 | import { type TransformResult, transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import { preprocessStyle } from '../utils.js';
5 |
6 | const FIXTURE = `
7 | ---
8 | let value = 'world';
9 | ---
10 |
11 |
18 |
19 | Hello world!
20 |
21 | Ahhh
22 |
23 |
29 | `;
30 |
31 | let result: TransformResult;
32 | test.before(async () => {
33 | result = await transform(FIXTURE, {
34 | sourcemap: true,
35 | preprocessStyle,
36 | experimentalScriptOrder: true,
37 | });
38 | });
39 |
40 | test('transforms scss one', () => {
41 | assert.match(result.css[0], 'color:red', 'Expected "color:red" to be present.');
42 | });
43 |
44 | test('transforms scss two', () => {
45 | assert.match(
46 | result.css[result.css.length - 1],
47 | 'color:green',
48 | 'Expected "color:green" to be present.'
49 | );
50 | });
51 |
52 | test.run();
53 |
--------------------------------------------------------------------------------
/internal/xxhash/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Caleb Spare
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/internal/printer/print-css.go:
--------------------------------------------------------------------------------
1 | package printer
2 |
3 | import (
4 | "strings"
5 |
6 | . "github.com/withastro/compiler/internal"
7 | "github.com/withastro/compiler/internal/sourcemap"
8 | "github.com/withastro/compiler/internal/transform"
9 | )
10 |
11 | type PrintCSSResult struct {
12 | Output [][]byte
13 | SourceMapChunk sourcemap.Chunk
14 | }
15 |
16 | func PrintCSS(sourcetext string, doc *Node, opts transform.TransformOptions) PrintCSSResult {
17 | p := &printer{
18 | opts: opts,
19 | builder: sourcemap.MakeChunkBuilder(nil, sourcemap.GenerateLineOffsetTables(sourcetext, len(strings.Split(sourcetext, "\n")))),
20 | }
21 |
22 | result := PrintCSSResult{
23 | SourceMapChunk: p.builder.GenerateChunk(p.output),
24 | }
25 |
26 | if len(doc.Styles) > 0 {
27 | for _, style := range doc.Styles {
28 | if style.FirstChild != nil && strings.TrimSpace(style.FirstChild.Data) != "" {
29 | p.addSourceMapping(style.Loc[0])
30 | p.print(strings.TrimSpace(style.FirstChild.Data))
31 | result.Output = append(result.Output, p.output)
32 | p.output = []byte{}
33 | p.addNilSourceMapping()
34 | }
35 | }
36 | }
37 |
38 | return result
39 | }
40 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-errors/fragment-shorthand.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import type { TSXResult } from '../../types.js';
5 |
6 | const FIXTURE = `
7 |
8 | Hello world
9 |
10 |
11 | < data-test="hello">>
12 |
13 | `;
14 |
15 | let result: TSXResult;
16 | test.before(async () => {
17 | result = await convertToTSX(FIXTURE, {
18 | filename: '/src/components/fragment.astro',
19 | });
20 | });
21 |
22 | test('got a tokenizer error', () => {
23 | assert.ok(Array.isArray(result.diagnostics));
24 | assert.is(result.diagnostics.length, 1);
25 | assert.is(
26 | result.diagnostics[0].text,
27 | 'Unable to assign attributes when using <> Fragment shorthand syntax!'
28 | );
29 | const loc = result.diagnostics[0].location;
30 | assert.is(FIXTURE.split('\n')[loc.line - 1], ` < data-test="hello">>`);
31 | assert.is(
32 | FIXTURE.split('\n')[loc.line - 1].slice(loc.column - 1, loc.column - 1 + loc.length),
33 | `< data-test="hello">`
34 | );
35 | });
36 |
37 | test.run();
38 |
--------------------------------------------------------------------------------
/packages/compiler/test/js-sourcemaps/error.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testJSSourcemap } from '../utils.js';
4 |
5 | test('svelte error', async () => {
6 | const input = `---
7 | import SvelteOptionalProps from "./SvelteOptionalProps.svelte"
8 | ---
9 |
10 | `;
11 | const output = await testJSSourcemap(input, '');
12 |
13 | assert.equal(output, {
14 | line: 5,
15 | column: 1,
16 | source: 'index.astro',
17 | name: null,
18 | });
19 | });
20 |
21 | test('vue error', async () => {
22 | const input = `---
23 | import SvelteError from "./SvelteError.svelte"
24 | import VueError from "./VueError.vue"
25 | ---
26 |
27 |
28 | `;
29 | const svelte = await testJSSourcemap(input, '');
30 |
31 | assert.equal(svelte, {
32 | line: 6,
33 | column: 1,
34 | source: 'index.astro',
35 | name: null,
36 | });
37 |
38 | const vue = await testJSSourcemap(input, '');
39 |
40 | assert.equal(vue, {
41 | line: 7,
42 | column: 1,
43 | source: 'index.astro',
44 | name: null,
45 | });
46 | });
47 |
48 | test.run();
49 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/error.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('svelte error', async () => {
6 | const input = `---
7 | import SvelteOptionalProps from "./SvelteOptionalProps.svelte"
8 | ---
9 |
10 | `;
11 | const output = await testTSXSourcemap(input, '');
12 |
13 | assert.equal(output, {
14 | line: 5,
15 | column: 1,
16 | source: 'index.astro',
17 | name: null,
18 | });
19 | });
20 |
21 | test('vue error', async () => {
22 | const input = `---
23 | import SvelteError from "./SvelteError.svelte"
24 | import VueError from "./VueError.vue"
25 | ---
26 |
27 |
28 | `;
29 | const svelte = await testTSXSourcemap(input, '');
30 |
31 | assert.equal(svelte, {
32 | line: 6,
33 | column: 1,
34 | source: 'index.astro',
35 | name: null,
36 | });
37 |
38 | const vue = await testTSXSourcemap(input, '');
39 |
40 | assert.equal(vue, {
41 | line: 7,
42 | column: 1,
43 | source: 'index.astro',
44 | name: null,
45 | });
46 | });
47 |
48 | test.run();
49 |
--------------------------------------------------------------------------------
/packages/compiler/test/js-sourcemaps/hover.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testJSSourcemap } from '../utils.js';
4 |
5 | const fixture = `---
6 | const MyVariable = "Astro"
7 |
8 | /** Documentation */
9 | const MyDocumentedVariable = "Astro"
10 |
11 | /** @author Astro */
12 | const MyJSDocVariable = "Astro"
13 | ---
14 | `;
15 |
16 | test('hover I', async () => {
17 | const input = fixture;
18 | const output = await testJSSourcemap(input, 'MyVariable');
19 |
20 | assert.equal(output, {
21 | line: 2,
22 | column: 11,
23 | source: 'index.astro',
24 | name: null,
25 | });
26 | });
27 |
28 | test('hover II', async () => {
29 | const input = fixture;
30 | const output = await testJSSourcemap(input, 'MyDocumentedVariable');
31 |
32 | assert.equal(output, {
33 | line: 5,
34 | column: 11,
35 | source: 'index.astro',
36 | name: null,
37 | });
38 | });
39 |
40 | test('hover III', async () => {
41 | const input = fixture;
42 | const output = await testJSSourcemap(input, 'MyJSDocVariable');
43 |
44 | assert.equal(output, {
45 | line: 8,
46 | column: 11,
47 | source: 'index.astro',
48 | name: null,
49 | });
50 | });
51 |
52 | test.run();
53 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/hover.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | const fixture = `---
6 | const MyVariable = "Astro"
7 |
8 | /** Documentation */
9 | const MyDocumentedVariable = "Astro"
10 |
11 | /** @author Astro */
12 | const MyJSDocVariable = "Astro"
13 | ---
14 | `;
15 |
16 | test('hover I', async () => {
17 | const input = fixture;
18 | const output = await testTSXSourcemap(input, 'MyVariable');
19 |
20 | assert.equal(output, {
21 | line: 2,
22 | column: 11,
23 | source: 'index.astro',
24 | name: null,
25 | });
26 | });
27 |
28 | test('hover II', async () => {
29 | const input = fixture;
30 | const output = await testTSXSourcemap(input, 'MyDocumentedVariable');
31 |
32 | assert.equal(output, {
33 | line: 5,
34 | column: 11,
35 | source: 'index.astro',
36 | name: null,
37 | });
38 | });
39 |
40 | test('hover III', async () => {
41 | const input = fixture;
42 | const output = await testTSXSourcemap(input, 'MyJSDocVariable');
43 |
44 | assert.equal(output, {
45 | line: 8,
46 | column: 11,
47 | source: 'index.astro',
48 | name: null,
49 | });
50 | });
51 |
52 | test.run();
53 |
--------------------------------------------------------------------------------
/internal/loc/diagnostics.go:
--------------------------------------------------------------------------------
1 | package loc
2 |
3 | type DiagnosticCode int
4 |
5 | const (
6 | ERROR DiagnosticCode = 1000
7 | ERROR_UNTERMINATED_JS_COMMENT DiagnosticCode = 1001
8 | ERROR_FRAGMENT_SHORTHAND_ATTRS DiagnosticCode = 1002
9 | ERROR_UNMATCHED_IMPORT DiagnosticCode = 1003
10 | ERROR_UNSUPPORTED_SLOT_ATTRIBUTE DiagnosticCode = 1004
11 | ERROR_UNTERMINATED_STRING DiagnosticCode = 1005
12 | WARNING DiagnosticCode = 2000
13 | WARNING_UNTERMINATED_HTML_COMMENT DiagnosticCode = 2001
14 | WARNING_UNCLOSED_HTML_TAG DiagnosticCode = 2002
15 | WARNING_DEPRECATED_DIRECTIVE DiagnosticCode = 2003
16 | WARNING_IGNORED_DIRECTIVE DiagnosticCode = 2004
17 | WARNING_UNSUPPORTED_EXPRESSION DiagnosticCode = 2005
18 | WARNING_SET_WITH_CHILDREN DiagnosticCode = 2006
19 | WARNING_CANNOT_DEFINE_VARS DiagnosticCode = 2007
20 | WARNING_INVALID_SPREAD DiagnosticCode = 2008
21 | WARNING_UNEXPECTED_CHARACTER DiagnosticCode = 2009
22 | WARNING_CANNOT_RERUN DiagnosticCode = 2010
23 | INFO DiagnosticCode = 3000
24 | HINT DiagnosticCode = 4000
25 | )
26 |
--------------------------------------------------------------------------------
/packages/compiler/test/basic/expressions.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | test('Can handle < inside JSX expression', async () => {
6 | const input = `
7 | {
8 | new Array(totalPages).fill(0).map((_, index) => {
9 | const active = currentPage === index;
10 | if (
11 | totalPages > 25 &&
12 | ( index < currentPage - offset ||
13 | index > currentPage + offset)
14 | ) {
15 | return 'HAAAA';
16 | }
17 | })
18 | }
19 |
20 | `;
21 | const output = await transform(input);
22 | assert.ok(output.code, 'Expected to compile');
23 | assert.match(
24 | output.code,
25 | `new Array(totalPages).fill(0).map((_, index) => {
26 | const active = currentPage === index;
27 | if (
28 | totalPages > 25 &&
29 | ( index < currentPage - offset ||
30 | index > currentPage + offset)
31 | ) {
32 | return 'HAAAA';
33 | }
34 | })`,
35 | 'Expected expression to be compiled properly'
36 | );
37 | assert.equal(output.diagnostics.length, 0, 'Expected no diagnostics');
38 | });
39 |
40 | test.run();
41 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "root",
3 | "version": "0.0.0",
4 | "private": true,
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/withastro/compiler.git"
8 | },
9 | "scripts": {
10 | "build": "make wasm",
11 | "build:compiler": "pnpm --filter @astrojs/compiler run build",
12 | "build:all": "pnpm run build && pnpm run build:compiler",
13 | "check": "biome check",
14 | "ci": "biome ci --diagnostic-level=warn",
15 | "check:write": "biome check --write",
16 | "prerelease": "pnpm run build:compiler",
17 | "release": "changeset publish",
18 | "test": "tsx node_modules/uvu/bin.js packages test -i utils -i stress",
19 | "test:only": "tsx node_modules/uvu/bin.js packages",
20 | "test:stress": "tsx packages/compiler/test/stress/index.ts",
21 | "test:ci": "pnpm run test && pnpm run test:stress"
22 | },
23 | "packageManager": "pnpm@10.22.0",
24 | "workspaces": [
25 | "packages/*"
26 | ],
27 | "devDependencies": {
28 | "@biomejs/biome": "1.8.1",
29 | "@changesets/cli": "^2.25.0",
30 | "sass": "^1.55.0",
31 | "tsx": "^4.16.2",
32 | "typescript": "~5.5.3",
33 | "uvu": "^0.5.6"
34 | },
35 | "engines": {
36 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Empty_script.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Empty_script - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/multibyte.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('multibyte content', async () => {
6 | const input = 'ツ
';
7 |
8 | const output = await testTSXSourcemap(input, 'ツ');
9 | assert.equal(output, {
10 | source: 'index.astro',
11 | line: 1,
12 | column: 4,
13 | name: null,
14 | });
15 | });
16 |
17 | test('content after multibyte character', async () => {
18 | const input = 'ツ
foobar
';
19 |
20 | const output = await testTSXSourcemap(input, 'foobar');
21 | assert.equal(output, {
22 | source: 'index.astro',
23 | line: 1,
24 | column: 13,
25 | name: null,
26 | });
27 | });
28 |
29 | test('many characters', async () => {
30 | const input = 'こんにちは
';
31 |
32 | const output = await testTSXSourcemap(input, 'ん');
33 | assert.equal(output, {
34 | source: 'index.astro',
35 | line: 1,
36 | column: 5,
37 | name: null,
38 | });
39 | });
40 |
41 | test('many characters', async () => {
42 | const input = 'こんにちは
';
43 |
44 | const output = await testTSXSourcemap(input, 'に');
45 | assert.equal(output, {
46 | source: 'index.astro',
47 | line: 1,
48 | column: 6,
49 | name: null,
50 | });
51 | });
52 |
53 | test.run();
54 |
--------------------------------------------------------------------------------
/packages/compiler/test/styles/hash.ts:
--------------------------------------------------------------------------------
1 | import { transform } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 |
5 | const FIXTURE_A = `
6 |
9 |
10 | Hello world!
11 | `;
12 | const FIXTURE_B = `
13 |
16 |
17 | Hello world!
18 | `;
19 | const FIXTURE_C = `
20 |
23 |
24 |
25 | `;
26 | const FIXTURE_D = `
27 |
30 |
31 |
32 | `;
33 |
34 | const scopes: string[] = [];
35 | test.before(async () => {
36 | const [{ scope: a }, { scope: b }, { scope: c }, { scope: d }] = await Promise.all(
37 | [FIXTURE_A, FIXTURE_B, FIXTURE_C, FIXTURE_D].map((source) => transform(source))
38 | );
39 | scopes.push(a, b, c, d);
40 | });
41 |
42 | test('hash changes when content outside of style change', () => {
43 | const [, b, c] = scopes;
44 | assert.not.equal(b, c, 'Expected scopes to not be equal');
45 | });
46 |
47 | test('hash changes when scripts change', () => {
48 | const [, , c, d] = scopes;
49 | assert.not.equal(c, d, 'Expected scopes to not be equal');
50 | });
51 |
52 | test.run();
53 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx/comment-whitespace.ts:
--------------------------------------------------------------------------------
1 | import { convertToTSX } from '@astrojs/compiler';
2 | import { test } from 'uvu';
3 | import * as assert from 'uvu/assert';
4 | import { TSXPrefix } from '../utils.js';
5 |
6 | test('preverve whitespace around jsx comments', async () => {
7 | const input = `{/* @ts-expect-error */}
8 |
9 |
10 | {
11 | // @ts-expect-error
12 | }
13 |
14 |
15 | {
16 | /* @ts-expect-error */
17 |
18 | }
19 |
20 | {
21 | // @ts-expect-error
22 |
23 | }`;
24 | const output = `${TSXPrefix}
25 | {/* @ts-expect-error */}
26 |
27 |
28 | {
29 | // @ts-expect-error
30 | }
31 |
32 |
33 | {
34 | /* @ts-expect-error */
35 |
36 | }
37 |
38 | {
39 | // @ts-expect-error
40 |
41 | }
42 |
43 | export default function __AstroComponent_(_props: Record): any {}\n`;
44 | const { code } = await convertToTSX(input, { sourcemap: 'external' });
45 | assert.snapshot(code, output, 'expected code to match snapshot');
46 | });
47 |
48 | test.run();
49 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Self-closing_title.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Self-closing_title - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/doctype.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/doctype - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/orphan_slot.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/orphan_slot - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderSlot($$result,$$slots["default"])}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/lib/esbuild/helpers/stack.go:
--------------------------------------------------------------------------------
1 | package helpers
2 |
3 | import (
4 | "runtime/debug"
5 | "strings"
6 | )
7 |
8 | func PrettyPrintedStack() string {
9 | lines := strings.Split(strings.TrimSpace(string(debug.Stack())), "\n")
10 |
11 | // Strip the first "goroutine" line
12 | if len(lines) > 0 {
13 | if first := lines[0]; strings.HasPrefix(first, "goroutine ") && strings.HasSuffix(first, ":") {
14 | lines = lines[1:]
15 | }
16 | }
17 |
18 | sb := strings.Builder{}
19 |
20 | for _, line := range lines {
21 | // Indented lines are source locations
22 | if strings.HasPrefix(line, "\t") {
23 | line = line[1:]
24 | line = strings.TrimPrefix(line, "github.com/evanw/esbuild/")
25 | if offset := strings.LastIndex(line, " +0x"); offset != -1 {
26 | line = line[:offset]
27 | }
28 | sb.WriteString(" (")
29 | sb.WriteString(line)
30 | sb.WriteString(")")
31 | continue
32 | }
33 |
34 | // Other lines are function calls
35 | if sb.Len() > 0 {
36 | sb.WriteByte('\n')
37 | }
38 | if strings.HasSuffix(line, ")") {
39 | if paren := strings.LastIndexByte(line, '('); paren != -1 {
40 | line = line[:paren]
41 | }
42 | }
43 | if slash := strings.LastIndexByte(line, '/'); slash != -1 {
44 | line = line[slash+1:]
45 | }
46 | sb.WriteString(line)
47 | }
48 |
49 | return sb.String()
50 | }
51 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/anchor_expressions.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/anchor_expressions - 1]
3 | ## Input
4 |
5 | ```
6 | {expr}
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${expr}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/iframe.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/iframe - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Empty_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Empty_expression - 1]
3 | ## Input
4 |
5 | ```
6 | ({})
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}(${(void 0)})`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/preserve_is_inline_slot.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/preserve_is:inline_slot - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_style.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_style - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_text.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:text - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${content}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/text_after_title_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/text_after_title_expression - 1]
3 | ## Input
4 |
5 | ```
6 | a {expr} b
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`a ${expr} b`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/packages/compiler/test/tsx-sourcemaps/attributes.ts:
--------------------------------------------------------------------------------
1 | import { test } from 'uvu';
2 | import * as assert from 'uvu/assert';
3 | import { testTSXSourcemap } from '../utils.js';
4 |
5 | test('shorthand attribute', async () => {
6 | const input = '';
7 |
8 | const output = await testTSXSourcemap(input, 'name');
9 | assert.equal(output, {
10 | source: 'index.astro',
11 | line: 1,
12 | column: 6,
13 | name: null,
14 | });
15 | });
16 |
17 | test('empty quoted attribute', async () => {
18 | const input = ``;
19 |
20 | const open = await testTSXSourcemap(input, '"');
21 | assert.equal(open, {
22 | source: 'index.astro',
23 | line: 1,
24 | column: 9,
25 | name: null,
26 | });
27 | });
28 |
29 | test('template literal attribute', async () => {
30 | const input = `---
31 | ---
32 | `;
33 |
34 | const open = await testTSXSourcemap(input, 'foo');
35 | assert.equal(open, {
36 | source: 'index.astro',
37 | line: 3,
38 | column: 16,
39 | name: null,
40 | });
41 | });
42 |
43 | test('multiline quoted attribute', async () => {
44 | const input = ``;
47 |
48 | const output = await testTSXSourcemap(input, 'Z');
49 | assert.equal(output, {
50 | source: 'index.astro',
51 | line: 3,
52 | column: 1,
53 | name: null,
54 | });
55 | });
56 |
57 | test.run();
58 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_script.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_script - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/user-defined__implicit__is_printed.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/user-defined_`implicit`_is_printed - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/caption_only.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/caption_only - 1]
3 | ## Input
4 |
5 | ```
6 | Hello world!
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}Hello world!`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/is_raw.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/is:raw - 1]
3 | ## Input
4 |
5 | ```
6 | <% awesome %>
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}<% awesome %>`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/basic__no_frontmatter_.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/basic_(no_frontmatter) - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/division_inside_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/division_inside_expression - 1]
3 | ## Input
4 |
5 | ```
6 | {16 / 4}
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${16 / 4}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$unescapeHTML(content)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/trailing_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/trailing_expression - 1]
3 | ## Input
4 |
5 | ```
6 | {}
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Component',Component,{})}${(void 0)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/multibyte_characters.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/multibyte_characters - 1]
3 | ## Input
4 |
5 | ```
6 | /-/-/-/
7 | /-/-/-/
8 | こんにちは
9 | ```
10 |
11 | ## Output
12 |
13 | ```js
14 | import {
15 | Fragment,
16 | render as $$render,
17 | createAstro as $$createAstro,
18 | createComponent as $$createComponent,
19 | renderComponent as $$renderComponent,
20 | renderHead as $$renderHead,
21 | maybeRenderHead as $$maybeRenderHead,
22 | unescapeHTML as $$unescapeHTML,
23 | renderSlot as $$renderSlot,
24 | mergeSlots as $$mergeSlots,
25 | addAttribute as $$addAttribute,
26 | spreadAttributes as $$spreadAttributes,
27 | defineStyleVars as $$defineStyleVars,
28 | defineScriptVars as $$defineScriptVars,
29 | renderTransition as $$renderTransition,
30 | createTransitionScope as $$createTransitionScope,
31 | renderScript as $$renderScript,
32 | createMetadata as $$createMetadata
33 | } from "http://localhost:3000/";
34 |
35 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
36 |
37 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
38 |
39 | return $$render`${$$maybeRenderHead($$result)}こんにちは
`;
40 | }, undefined, undefined);
41 | export default $$Component;
42 | ```
43 | ---
44 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/text_after_title_expressions.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/text_after_title_expressions - 1]
3 | ## Input
4 |
5 | ```
6 | a {expr} b {expr} c
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`a ${expr} b ${expr} c`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/anchor_inside_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/anchor_inside_expression - 1]
3 | ## Input
4 |
5 | ```
6 | {true && expr}
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${true && $$render`${$$maybeRenderHead($$result)}expr`}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/preserve_is_inline_slot_II.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/preserve_is:inline_slot_II - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_slot_I.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_slot_I - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/unusual_line_terminator_II.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/unusual_line_terminator_II - 1]
3 | ## Input
4 |
5 | ```
6 | Pre-set & Time-limited
holiday campaigns
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`Pre-set & Time-limited
holiday campaigns`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/SVG_styles.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/SVG_styles - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/head_slot.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/head_slot - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderSlot($$result,$$slots["default"])}${$$renderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/noscript_only.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/noscript_only - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_script_with_quoted_attribute.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_script_with_quoted_attribute - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Empty_expression_with_whitespace.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Empty_expression_with_whitespace - 1]
3 | ## Input
4 |
5 | ```
6 | ({ })
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}(${(void 0) })`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Empty_style.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Empty_style - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | const $$definedVars = $$defineStyleVars([{ color: "Gainsboro" }]);
38 | return $$render``;
39 | }, undefined, undefined);
40 | export default $$Component;
41 | ```
42 | ---
43 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Fragment_shorthand_only.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Fragment_shorthand_only - 1]
3 | ## Input
4 |
5 | ```
6 | <>Hello>
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`Hello`,})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/basic_renderHead.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/basic_renderHead - 1]
3 | ## Input
4 |
5 | ```
6 | Ah
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`Ah${$$renderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_text_with_quoted_attribute.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:text_with_quoted_attribute - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}content`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/tr_only.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/tr_only - 1]
3 | ## Input
4 |
5 | ```
6 | | col 1 | col 2 | {foo} |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}| col 1 | col 2 | ${foo} |
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/unusual_line_terminator_I.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/unusual_line_terminator_I - 1]
3 | ## Input
4 |
5 | ```
6 | Pre-set & Time-limited \u2028holiday campaigns
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`Pre-set & Time-limited \\u2028holiday campaigns`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Empty_attribute_expression.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Empty_attribute_expression - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/attribute_with_template_literal.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/attribute_with_template_literal - 1]
3 | ## Input
4 |
5 | ```
6 | Home
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}Home`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/escaped_entity.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/escaped_entity - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/script_before_elements.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/script_before_elements - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `Here` }] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_style_with_quoted_attribute.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_style_with_quoted_attribute - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_with_quoted_attribute.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_with_quoted_attribute - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${"content"}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_IV.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_IV - 1]
3 | ## Input
4 |
5 | ```
6 | | hello world |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}| hello world |
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Fragment_literal_only.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Fragment_literal_only - 1]
3 | ## Input
4 |
5 | ```
6 | world
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render`world`,})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/class_list.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/class_list - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/component_with_only_a_script.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/component_with_only_a_script - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [{ type: 'inline', value: `console.log('hello world');` }] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render``;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_empty_tag.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_empty_tag - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$unescapeHTML(content)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_slot_II.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_slot_II - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/anchor_content.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/anchor_content - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/backtick_in_HTML_comment.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/backtick_in_HTML_comment - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/component_with_quoted_attributes.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/component_with_quoted_attributes - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Component',Component,{"is":"\"cool\""})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_on_self-closing_tag.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_on_self-closing_tag - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$unescapeHTML(content)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_slot_III.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_slot_III - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}| ${$$renderSlot($$result,$$slots["default"])} |
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_html_and_set_text.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:html_and_set:text - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$unescapeHTML(content)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_slot_V.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_slot_V - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Component_siblings_are_siblings.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Component_siblings_are_siblings - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'BaseHead',BaseHead,{})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Self-closing_title_II.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Self-closing_title_II - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/comment_only_expressions_are_removed_I.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/comment_only_expressions_are_removed_I - 1]
3 | ## Input
4 |
5 | ```
6 | {/* a comment 1 */}{/* a comment 2*/}Hello
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}Hello
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/noscript_styles.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/noscript_styles - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/set_text_on_Component.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/set:text_on_Component - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render`${content}`,})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table - 1]
3 | ## Input
4 |
5 | ```
6 | {[0,1,2].map(x => (| {x} | ))}
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${[0,1,2].map(x => ($$render`| ${x} | `))}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/table_slot_IV.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/table_slot_IV - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"])}
`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/template_literal_attribute_on_component.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/template_literal_attribute_on_component - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Component',Component,{"class":`red`})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/th_expressions.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/th_expressions - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$maybeRenderHead($$result)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/Preserve_namespaces_for_components.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/Preserve_namespaces_for_components - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderComponent($$result,'Component',Component,{"some:thing":"foobar"})}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/conditional_iframe.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/conditional_iframe - 1]
3 | ## Input
4 |
5 | ```
6 | {bool && }
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${bool && $$render`${$$maybeRenderHead($$result)}`}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/export_comments_I.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/export_comments_I - 1]
3 | ## Input
4 |
5 | ```
6 | /-/-/-/
7 | // hmm
8 | export const foo = 0
9 | /*
10 | */
11 | /-/-/-/
12 | ```
13 |
14 | ## Output
15 |
16 | ```js
17 | import {
18 | Fragment,
19 | render as $$render,
20 | createAstro as $$createAstro,
21 | createComponent as $$createComponent,
22 | renderComponent as $$renderComponent,
23 | renderHead as $$renderHead,
24 | maybeRenderHead as $$maybeRenderHead,
25 | unescapeHTML as $$unescapeHTML,
26 | renderSlot as $$renderSlot,
27 | mergeSlots as $$mergeSlots,
28 | addAttribute as $$addAttribute,
29 | spreadAttributes as $$spreadAttributes,
30 | defineStyleVars as $$defineStyleVars,
31 | defineScriptVars as $$defineScriptVars,
32 | renderTransition as $$renderTransition,
33 | createTransitionScope as $$createTransitionScope,
34 | renderScript as $$renderScript,
35 | createMetadata as $$createMetadata
36 | } from "http://localhost:3000/";
37 |
38 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
39 |
40 | export const foo = 0
41 |
42 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
43 |
44 | // hmm
45 | /*
46 | */
47 |
48 | return $$render``;
49 | }, undefined, undefined);
50 | export default $$Component;
51 | ```
52 | ---
53 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/export_member_does_not_panic.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/export_member_does_not_panic - 1]
3 | ## Input
4 |
5 | ```
6 | /-/-/-/
7 | mod.export();
8 | /-/-/-/
9 |
10 | ```
11 |
12 | ## Output
13 |
14 | ```js
15 | import {
16 | Fragment,
17 | render as $$render,
18 | createAstro as $$createAstro,
19 | createComponent as $$createComponent,
20 | renderComponent as $$renderComponent,
21 | renderHead as $$renderHead,
22 | maybeRenderHead as $$maybeRenderHead,
23 | unescapeHTML as $$unescapeHTML,
24 | renderSlot as $$renderSlot,
25 | mergeSlots as $$mergeSlots,
26 | addAttribute as $$addAttribute,
27 | spreadAttributes as $$spreadAttributes,
28 | defineStyleVars as $$defineStyleVars,
29 | defineScriptVars as $$defineScriptVars,
30 | renderTransition as $$renderTransition,
31 | createTransitionScope as $$createTransitionScope,
32 | renderScript as $$renderScript,
33 | createMetadata as $$createMetadata
34 | } from "http://localhost:3000/";
35 |
36 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
37 |
38 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
39 |
40 | mod.export();
41 |
42 | return $$render`${$$maybeRenderHead($$result)}`;
43 | }, undefined, undefined);
44 | export default $$Component;
45 | ```
46 | ---
47 |
--------------------------------------------------------------------------------
/internal/printer/__printer_js__/head_inside_slot.snap:
--------------------------------------------------------------------------------
1 |
2 | [TestPrinter/head_inside_slot - 1]
3 | ## Input
4 |
5 | ```
6 |
7 | ```
8 |
9 | ## Output
10 |
11 | ```js
12 | import {
13 | Fragment,
14 | render as $$render,
15 | createAstro as $$createAstro,
16 | createComponent as $$createComponent,
17 | renderComponent as $$renderComponent,
18 | renderHead as $$renderHead,
19 | maybeRenderHead as $$maybeRenderHead,
20 | unescapeHTML as $$unescapeHTML,
21 | renderSlot as $$renderSlot,
22 | mergeSlots as $$mergeSlots,
23 | addAttribute as $$addAttribute,
24 | spreadAttributes as $$spreadAttributes,
25 | defineStyleVars as $$defineStyleVars,
26 | defineScriptVars as $$defineScriptVars,
27 | renderTransition as $$renderTransition,
28 | createTransitionScope as $$createTransitionScope,
29 | renderScript as $$renderScript,
30 | createMetadata as $$createMetadata
31 | } from "http://localhost:3000/";
32 |
33 | export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] });
34 |
35 | const $$Component = $$createComponent(($$result, $$props, $$slots) => {
36 |
37 | return $$render`${$$renderSlot($$result,$$slots["default"],$$render`${$$renderHead($$result)}`)}`;
38 | }, undefined, undefined);
39 | export default $$Component;
40 | ```
41 | ---
42 |
--------------------------------------------------------------------------------