@astrojs/compiler 0.11.0-next.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,30 @@
1
1
  # @astrojs/compiler
2
2
 
3
- ## 0.11.0-next.0
3
+ ## 0.11.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 083d604: Do not render implicit tags created during the parsing process
8
- - d188c74: Remove "as" option, treats all documents as fragments that generate no implicit tags
9
- - c4b6b05: Add `parse` function which generates an AST
10
- - d84c3a2: Adds support for `Astro.self` (as accepted in the [Recursive Components RFC](https://github.com/withastro/rfcs/blob/main/active-rfcs/0000-recursive-components.md)).
7
+ - f5d4006: Switch from TinyGo to Go's built-in WASM output. While this is an unfortunate size increase for our `.wasm` file, it should also be significantly more stable and cut down on hard-to-reproduce bugs.
8
+
9
+ Please see https://github.com/withastro/compiler/pull/291 for more details.
10
+
11
+ ## 0.11.0-next--wasm.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 9212ccc: Switch from TinyGo to Go's built-in WASM output. While this is an unfortunate size increase for our `WASM` file, it should also be significantly more stable and cut down on hard-to-reproduce bugs.
16
+
17
+ Please see https://github.com/withastro/compiler/pull/291 for more details.
18
+
19
+ ## 0.10.2
20
+
21
+ ### Patch Changes
22
+
23
+ - 7f7c65c: Fix conditional rendering for special elements like `iframe` and `noscript`
24
+ - 9d789c9: Fix handling of nested template literals inside of expressions
25
+ - 5fa9e53: Fix handling of special characters inside of expressions
26
+ - 8aaa956: Formalize support for magic `data-astro-raw` attribute with new, official `is:raw` directive
27
+ - c698350: Improve MathML support. `{}` inside of `<math>` is now treated as raw text rather than an expression construct.
11
28
 
12
29
  ## 0.10.1
13
30
 
package/README.md CHANGED
@@ -12,15 +12,7 @@ npm install @astrojs/compiler
12
12
 
13
13
  ## Usage
14
14
 
15
- _Note: Public APIs are likely to change before 1.0! Use at your own discretion._
16
-
17
- #### Transform `.astro` to valid TypeScript
18
-
19
- The Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.
20
-
21
- **Some notes**...
22
- - TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.
23
- - `.astro` files rely on a server implementation exposed as `astro/internal` in the Node ecosystem. Other runtimes currently need to bring their own rendering implementation and reference it via `internalURL`. This is a pain point we're looking into fixing.
15
+ _Note: API will change before 1.0! Use at your own discretion._
24
16
 
25
17
  ```js
26
18
  import { transform } from '@astrojs/compiler';
@@ -33,31 +25,6 @@ const result = await transform(source, {
33
25
  });
34
26
  ```
35
27
 
36
- #### Parse `.astro` and return an AST
37
-
38
- The Astro compiler can emit an AST using the `parse` method.
39
-
40
- **Some notes**...
41
- - Position data is currently incomplete and in some cases incorrect. We're working on it!
42
- - A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.
43
- - The `@astrojs/compiler/utils` entrypoint exposes a `walk` function that can be used to traverse the AST. It also exposes the `is` helper which can be used as guards to derive the proper types for each `node`.
44
-
45
- ```js
46
- import { parse } from '@astrojs/compiler';
47
- import { walk, is } from '@astrojs/compiler/utils';
48
-
49
- const result = await parse(source, {
50
- position: false, // defaults to `true`
51
- });
52
-
53
- walk(result.ast, (node) => {
54
- // `tag` nodes are `element` | `custom-element` | `component`
55
- if (is.tag(node)) {
56
- console.log(node.name);
57
- }
58
- })
59
- ```
60
-
61
28
  ## Contributing
62
29
 
63
30
  [CONTRIBUTING.md](./CONTRIBUTING.md)
package/astro.wasm CHANGED
Binary file
@@ -1,4 +1,3 @@
1
1
  import type * as types from '../shared/types';
2
2
  export declare const transform: typeof types.transform;
3
- export declare const parse: typeof types.parse;
4
3
  export declare const initialize: typeof types.initialize;
package/browser/index.js CHANGED
@@ -2,9 +2,6 @@ import Go from './wasm_exec.js';
2
2
  export const transform = (input, options) => {
3
3
  return ensureServiceIsRunning().transform(input, options);
4
4
  };
5
- export const parse = (input, options) => {
6
- return ensureServiceIsRunning().parse(input, options);
7
- };
8
5
  let initializePromise;
9
6
  let longLivedService;
10
7
  export const initialize = (options) => {
@@ -46,15 +43,8 @@ const startRunningService = async (wasmURL) => {
46
43
  const go = new Go();
47
44
  const wasm = await instantiateWASM(wasmURL, go.importObject);
48
45
  go.run(wasm.instance);
49
- const apiKeys = new Set(['transform', 'parse']);
50
- const service = Object.create(null);
51
- for (const key of apiKeys.values()) {
52
- const globalKey = `__astro_${key}`;
53
- service[key] = globalThis[globalKey];
54
- delete globalThis[globalKey];
55
- }
46
+ const service = globalThis['@astrojs/compiler'];
56
47
  longLivedService = {
57
48
  transform: (input, options) => new Promise((resolve) => resolve(service.transform(input, options || {}))),
58
- parse: (input, options) => new Promise((resolve) => resolve(service.parse(input, options || {}))).then((result) => ({ ...result, ast: JSON.parse(result.ast) })),
59
49
  };
60
50
  };
@@ -1,5 +1,33 @@
1
1
  export default class Go {
2
- importObject: Record<string, any>;
2
+ importObject: {
3
+ go: {
4
+ 'runtime.wasmExit': (sp: any) => void;
5
+ 'runtime.wasmWrite': (sp: any) => void;
6
+ 'runtime.resetMemoryDataView': (sp: any) => void;
7
+ 'runtime.nanotime1': (sp: any) => void;
8
+ 'runtime.walltime': (sp: any) => void;
9
+ 'runtime.scheduleTimeoutEvent': (sp: any) => void;
10
+ 'runtime.clearTimeoutEvent': (sp: any) => void;
11
+ 'runtime.getRandomData': (sp: any) => void;
12
+ 'syscall/js.finalizeRef': (sp: any) => void;
13
+ 'syscall/js.stringVal': (sp: any) => void;
14
+ 'syscall/js.valueGet': (sp: any) => void;
15
+ 'syscall/js.valueSet': (sp: any) => void;
16
+ 'syscall/js.valueDelete': (sp: any) => void;
17
+ 'syscall/js.valueIndex': (sp: any) => void;
18
+ 'syscall/js.valueSetIndex': (sp: any) => void;
19
+ 'syscall/js.valueCall': (sp: any) => void;
20
+ 'syscall/js.valueInvoke': (sp: any) => void;
21
+ 'syscall/js.valueNew': (sp: any) => void;
22
+ 'syscall/js.valueLength': (sp: any) => void;
23
+ 'syscall/js.valuePrepareString': (sp: any) => void;
24
+ 'syscall/js.valueLoadString': (sp: any) => void;
25
+ 'syscall/js.valueInstanceOf': (sp: any) => void;
26
+ 'syscall/js.copyBytesToGo': (sp: any) => void;
27
+ 'syscall/js.copyBytesToJS': (sp: any) => void;
28
+ debug: (value: any) => void;
29
+ };
30
+ };
3
31
  constructor();
4
32
  run(instance: any): Promise<void>;
5
33
  private _resume;