@altopelago/aeon-wasm 0.9.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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @altopelago/aeon-wasm
2
+
3
+ Browser-facing wrapper for the Rust AEON implementation.
4
+
5
+ The TypeScript package is intentionally thin. It loads the generated `wasm-pack`
6
+ output from `pkg/` and exposes a typed async API for parity playgrounds and
7
+ browser-based conformance checks.
8
+
9
+ ```ts
10
+ import { processAeon } from '@altopelago/aeon-wasm';
11
+
12
+ const result = await processAeon('name:string = "AEON"\n', {
13
+ validationMode: 'strict',
14
+ finalizeScope: 'payload',
15
+ });
16
+
17
+ console.log(result.finalized.document);
18
+ ```
19
+
20
+ `processAeon` returns the normalized engine contract used by browser parity
21
+ tools:
22
+
23
+ - `engine`: currently `rust-wasm`
24
+ - `ok`: true when there are no errors
25
+ - `canonical.text`: canonical AEON text
26
+ - `finalized.document`: materialized JSON-compatible output, or `null`
27
+ - `events`: normalized event summaries
28
+ - `annotations`: annotation stream records
29
+ - `diagnostics.errors` and `diagnostics.warnings`
30
+
31
+ For compatibility, `errors` and `warnings` are also exposed as top-level aliases
32
+ of `diagnostics.errors` and `diagnostics.warnings`.
33
+
34
+ ## Build
35
+
36
+ Build the TypeScript wrapper:
37
+
38
+ ```sh
39
+ pnpm --filter @altopelago/aeon-wasm build
40
+ ```
41
+
42
+ Build the Rust WASM artifact:
43
+
44
+ ```sh
45
+ pnpm --filter @altopelago/aeon-wasm build:wasm
46
+ ```
47
+
48
+ `build:wasm` requires `wasm-pack` and reads the Rust crate from
49
+ `implementations/rust/crates/aeon-wasm`.
@@ -0,0 +1,73 @@
1
+ export interface ProcessOptions {
2
+ validationMode?: 'strict' | 'custom' | 'loose' | 'none';
3
+ maxSeparatorDepth?: number;
4
+ maxAttributeDepth?: number;
5
+ maxGenericDepth?: number;
6
+ materializationMode?: 'all' | 'projected';
7
+ finalizeScope?: 'payload' | 'header' | 'full';
8
+ includePaths?: string[];
9
+ }
10
+ export interface Position {
11
+ line: number;
12
+ column: number;
13
+ offset: number;
14
+ }
15
+ export interface Span {
16
+ start: Position;
17
+ end: Position;
18
+ }
19
+ export interface Diagnostic {
20
+ code: string;
21
+ path: string | null;
22
+ span: Span | null;
23
+ phase: string;
24
+ message: string;
25
+ }
26
+ export interface AnnotationTarget {
27
+ kind: 'path' | 'unbound';
28
+ path?: string;
29
+ reason?: string;
30
+ }
31
+ export interface AnnotationRecord {
32
+ kind: string;
33
+ form: string;
34
+ subtype: string | null;
35
+ raw: string;
36
+ span: Span;
37
+ target: AnnotationTarget;
38
+ }
39
+ export interface EventSummary {
40
+ path: string;
41
+ key: string;
42
+ datatype: string | null;
43
+ valueType: string;
44
+ }
45
+ export interface NormalizedCanonical {
46
+ text: string;
47
+ }
48
+ export interface NormalizedFinalized {
49
+ document: unknown | null;
50
+ }
51
+ export interface NormalizedDiagnostics {
52
+ errors: Diagnostic[];
53
+ warnings: Diagnostic[];
54
+ }
55
+ export interface ProcessResult {
56
+ engine: 'rust-wasm';
57
+ ok: boolean;
58
+ canonical: NormalizedCanonical;
59
+ finalized: NormalizedFinalized;
60
+ annotations: AnnotationRecord[];
61
+ events: EventSummary[];
62
+ diagnostics: NormalizedDiagnostics;
63
+ /** Convenience alias for diagnostics.errors. */
64
+ errors: Diagnostic[];
65
+ /** Convenience alias for diagnostics.warnings. */
66
+ warnings: Diagnostic[];
67
+ }
68
+ export interface AeonWasmRuntime {
69
+ processAeon(source: string, options?: ProcessOptions): ProcessResult;
70
+ }
71
+ export declare function loadAeonWasm(initInput?: unknown): Promise<AeonWasmRuntime>;
72
+ export declare function processAeon(source: string, options?: ProcessOptions): Promise<ProcessResult>;
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EA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CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,mBAAmB,CAAC;IAC/B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,WAAW,EAAE,qBAAqB,CAAC;IACnC,gDAAgD;IAChD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,kDAAkD;IAClD,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAWD,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;CACtE;AASD,wBAAsB,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAGhF;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAGxB"}
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ let runtimePromise;
2
+ export async function loadAeonWasm(initInput) {
3
+ runtimePromise ??= loadGeneratedModule(initInput);
4
+ return runtimePromise;
5
+ }
6
+ export async function processAeon(source, options = {}) {
7
+ const runtime = await loadAeonWasm();
8
+ return runtime.processAeon(source, options);
9
+ }
10
+ async function loadGeneratedModule(initInput) {
11
+ let module;
12
+ try {
13
+ module = await import('../pkg/aeon_wasm.js');
14
+ }
15
+ catch (error) {
16
+ throw new Error('AEON WASM package has not been built. Run `pnpm --filter @altopelago/aeon-wasm build:wasm` first.', { cause: error });
17
+ }
18
+ await module.default({
19
+ module_or_path: initInput ?? new URL('../pkg/aeon_wasm_bg.wasm', import.meta.url),
20
+ });
21
+ return {
22
+ processAeon(source, options = {}) {
23
+ return parseProcessResult(module.process_aeon(source, JSON.stringify(options)));
24
+ },
25
+ };
26
+ }
27
+ function parseProcessResult(json) {
28
+ return normalizeProcessResult(JSON.parse(json));
29
+ }
30
+ function normalizeProcessResult(raw) {
31
+ const errors = raw.errors.map(normalizeDiagnostic);
32
+ const warnings = raw.warnings.map(normalizeDiagnostic);
33
+ return {
34
+ engine: 'rust-wasm',
35
+ ok: errors.length === 0,
36
+ canonical: { text: raw.canonical },
37
+ finalized: { document: raw.finalized },
38
+ annotations: raw.annotations.map(normalizeAnnotation),
39
+ events: raw.events.map(normalizeEvent),
40
+ diagnostics: { errors, warnings },
41
+ errors,
42
+ warnings,
43
+ };
44
+ }
45
+ function normalizeDiagnostic(diagnostic) {
46
+ return {
47
+ code: diagnostic.code,
48
+ path: diagnostic.path ?? null,
49
+ span: diagnostic.span ?? null,
50
+ phase: diagnostic.phase,
51
+ message: diagnostic.message,
52
+ };
53
+ }
54
+ function normalizeAnnotation(annotation) {
55
+ return {
56
+ kind: annotation.kind,
57
+ form: annotation.form,
58
+ subtype: annotation.subtype ?? null,
59
+ raw: annotation.raw,
60
+ span: annotation.span,
61
+ target: annotation.target,
62
+ };
63
+ }
64
+ function normalizeEvent(event) {
65
+ return {
66
+ path: event.path,
67
+ key: event.key,
68
+ datatype: event.datatype ?? null,
69
+ valueType: event.valueType,
70
+ };
71
+ }
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgGA,IAAI,cAAoD,CAAC;AAEzD,MAAM,CAAC,KAAK,UAA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KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,73 @@
1
+ export interface ProcessOptions {
2
+ validationMode?: 'strict' | 'custom' | 'loose' | 'none';
3
+ maxSeparatorDepth?: number;
4
+ maxAttributeDepth?: number;
5
+ maxGenericDepth?: number;
6
+ materializationMode?: 'all' | 'projected';
7
+ finalizeScope?: 'payload' | 'header' | 'full';
8
+ includePaths?: string[];
9
+ }
10
+ export interface Position {
11
+ line: number;
12
+ column: number;
13
+ offset: number;
14
+ }
15
+ export interface Span {
16
+ start: Position;
17
+ end: Position;
18
+ }
19
+ export interface Diagnostic {
20
+ code: string;
21
+ path: string | null;
22
+ span: Span | null;
23
+ phase: string;
24
+ message: string;
25
+ }
26
+ export interface AnnotationTarget {
27
+ kind: 'path' | 'unbound';
28
+ path?: string;
29
+ reason?: string;
30
+ }
31
+ export interface AnnotationRecord {
32
+ kind: string;
33
+ form: string;
34
+ subtype: string | null;
35
+ raw: string;
36
+ span: Span;
37
+ target: AnnotationTarget;
38
+ }
39
+ export interface EventSummary {
40
+ path: string;
41
+ key: string;
42
+ datatype: string | null;
43
+ valueType: string;
44
+ }
45
+ export interface NormalizedCanonical {
46
+ text: string;
47
+ }
48
+ export interface NormalizedFinalized {
49
+ document: unknown | null;
50
+ }
51
+ export interface NormalizedDiagnostics {
52
+ errors: Diagnostic[];
53
+ warnings: Diagnostic[];
54
+ }
55
+ export interface ProcessResult {
56
+ engine: 'rust-wasm';
57
+ ok: boolean;
58
+ canonical: NormalizedCanonical;
59
+ finalized: NormalizedFinalized;
60
+ annotations: AnnotationRecord[];
61
+ events: EventSummary[];
62
+ diagnostics: NormalizedDiagnostics;
63
+ /** Convenience alias for diagnostics.errors. */
64
+ errors: Diagnostic[];
65
+ /** Convenience alias for diagnostics.warnings. */
66
+ warnings: Diagnostic[];
67
+ }
68
+ export interface AeonWasmRuntime {
69
+ processAeon(source: string, options?: ProcessOptions): ProcessResult;
70
+ }
71
+ export declare function loadAeonWasm(initInput?: unknown): Promise<AeonWasmRuntime>;
72
+ export declare function processAeon(source: string, options?: ProcessOptions): Promise<ProcessResult>;
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC;IAC1C,aAAa,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CA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onWasm(initInput) {
3
+ runtimePromise ??= loadGeneratedModule(initInput);
4
+ return runtimePromise;
5
+ }
6
+ export async function processAeon(source, options = {}) {
7
+ const runtime = await loadAeonWasm();
8
+ return runtime.processAeon(source, options);
9
+ }
10
+ async function loadGeneratedModule(initInput) {
11
+ let module;
12
+ try {
13
+ module = await import('../pkg/aeon_wasm.js');
14
+ }
15
+ catch (error) {
16
+ throw new Error('AEON WASM package has not been built. Run `pnpm --filter @altopelago/aeon-wasm build:wasm` first.', { cause: error });
17
+ }
18
+ await module.default({
19
+ module_or_path: initInput ?? new URL('../pkg/aeon_wasm_bg.wasm', import.meta.url),
20
+ });
21
+ return {
22
+ processAeon(source, options = {}) {
23
+ return parseProcessResult(module.process_aeon(source, JSON.stringify(options)));
24
+ },
25
+ };
26
+ }
27
+ function parseProcessResult(json) {
28
+ return normalizeProcessResult(JSON.parse(json));
29
+ }
30
+ function normalizeProcessResult(raw) {
31
+ const errors = raw.errors.map(normalizeDiagnostic);
32
+ const warnings = raw.warnings.map(normalizeDiagnostic);
33
+ return {
34
+ engine: 'rust-wasm',
35
+ ok: errors.length === 0,
36
+ canonical: { text: raw.canonical },
37
+ finalized: { document: raw.finalized },
38
+ annotations: raw.annotations.map(normalizeAnnotation),
39
+ events: raw.events.map(normalizeEvent),
40
+ diagnostics: { errors, warnings },
41
+ errors,
42
+ warnings,
43
+ };
44
+ }
45
+ function normalizeDiagnostic(diagnostic) {
46
+ return {
47
+ code: diagnostic.code,
48
+ path: diagnostic.path ?? null,
49
+ span: diagnostic.span ?? null,
50
+ phase: diagnostic.phase,
51
+ message: diagnostic.message,
52
+ };
53
+ }
54
+ function normalizeAnnotation(annotation) {
55
+ return {
56
+ kind: annotation.kind,
57
+ form: annotation.form,
58
+ subtype: annotation.subtype ?? null,
59
+ raw: annotation.raw,
60
+ span: annotation.span,
61
+ target: annotation.target,
62
+ };
63
+ }
64
+ function normalizeEvent(event) {
65
+ return {
66
+ path: event.path,
67
+ key: event.key,
68
+ datatype: normalizeDatatype(event.datatype ?? null),
69
+ valueType: normalizeValueType(event.valueType),
70
+ };
71
+ }
72
+ function normalizeDatatype(datatype) {
73
+ return datatype === 'switch' ? 'toggle' : datatype;
74
+ }
75
+ function normalizeValueType(valueType) {
76
+ return valueType === 'SwitchLiteral' ? 'ToggleLiteral' : valueType;
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgGA,IAAI,cAAoD,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAmB;IACpD,cAAc,KAAK,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,UAA0B,EAAE;IAE5B,MAAM,OAAO,GAAG,MAAM,YAAY,EAAE,CAAC;IACrC,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,SAAkB;IACnD,IAAI,MAA+B,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAA4B,CAAC;IAC1E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mGAAmG,EACnG,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,cAAc,EAAE,SAAS,IAAI,IAAI,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KAClF,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,CAAC,MAAc,EAAE,UAA0B,EAAE;YACtD,OAAO,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC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O,EAAE,UAAU,CAAC,OAAO,IAAI,IAAI;QACnC,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAmB;IACzC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QACnD,SAAS,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAuB;IAChD,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrD,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,OAAO,SAAS,KAAK,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@altopelago/aeon-wasm",
3
+ "version": "0.9.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "pkg",
16
+ "README.md",
17
+ "!dist/**/*.test.d.ts",
18
+ "!dist/**/*.test.d.ts.map",
19
+ "!dist/**/*.test.js",
20
+ "!dist/**/*.test.js.map"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.json",
24
+ "build:wasm": "node ./scripts/build-wasm.mjs",
25
+ "test": "node --test dist/*.test.js",
26
+ "clean": "rm -rf dist",
27
+ "typecheck": "tsc -p tsconfig.json --noEmit",
28
+ "clean:wasm": "rm -rf pkg"
29
+ }
30
+ }
@@ -0,0 +1,39 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function process_aeon(source: string, options_json: string): string;
5
+
6
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
7
+
8
+ export interface InitOutput {
9
+ readonly memory: WebAssembly.Memory;
10
+ readonly process_aeon: (a: number, b: number, c: number, d: number) => [number, number, number, number];
11
+ readonly __wbindgen_externrefs: WebAssembly.Table;
12
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
13
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
+ readonly __externref_table_dealloc: (a: number) => void;
15
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
16
+ readonly __wbindgen_start: () => void;
17
+ }
18
+
19
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
20
+
21
+ /**
22
+ * Instantiates the given `module`, which can either be bytes or
23
+ * a precompiled `WebAssembly.Module`.
24
+ *
25
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
26
+ *
27
+ * @returns {InitOutput}
28
+ */
29
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
30
+
31
+ /**
32
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
33
+ * for everything else, calls `WebAssembly.instantiate` directly.
34
+ *
35
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
36
+ *
37
+ * @returns {Promise<InitOutput>}
38
+ */
39
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,229 @@
1
+ /* @ts-self-types="./aeon_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {string} source
5
+ * @param {string} options_json
6
+ * @returns {string}
7
+ */
8
+ export function process_aeon(source, options_json) {
9
+ let deferred4_0;
10
+ let deferred4_1;
11
+ try {
12
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
13
+ const len0 = WASM_VECTOR_LEN;
14
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
15
+ const len1 = WASM_VECTOR_LEN;
16
+ const ret = wasm.process_aeon(ptr0, len0, ptr1, len1);
17
+ var ptr3 = ret[0];
18
+ var len3 = ret[1];
19
+ if (ret[3]) {
20
+ ptr3 = 0; len3 = 0;
21
+ throw takeFromExternrefTable0(ret[2]);
22
+ }
23
+ deferred4_0 = ptr3;
24
+ deferred4_1 = len3;
25
+ return getStringFromWasm0(ptr3, len3);
26
+ } finally {
27
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
28
+ }
29
+ }
30
+ function __wbg_get_imports() {
31
+ const import0 = {
32
+ __proto__: null,
33
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
34
+ // Cast intrinsic for `Ref(String) -> Externref`.
35
+ const ret = getStringFromWasm0(arg0, arg1);
36
+ return ret;
37
+ },
38
+ __wbindgen_init_externref_table: function() {
39
+ const table = wasm.__wbindgen_externrefs;
40
+ const offset = table.grow(4);
41
+ table.set(0, undefined);
42
+ table.set(offset + 0, undefined);
43
+ table.set(offset + 1, null);
44
+ table.set(offset + 2, true);
45
+ table.set(offset + 3, false);
46
+ },
47
+ };
48
+ return {
49
+ __proto__: null,
50
+ "./aeon_wasm_bg.js": import0,
51
+ };
52
+ }
53
+
54
+ function getStringFromWasm0(ptr, len) {
55
+ return decodeText(ptr >>> 0, len);
56
+ }
57
+
58
+ let cachedUint8ArrayMemory0 = null;
59
+ function getUint8ArrayMemory0() {
60
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
61
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
62
+ }
63
+ return cachedUint8ArrayMemory0;
64
+ }
65
+
66
+ function passStringToWasm0(arg, malloc, realloc) {
67
+ if (realloc === undefined) {
68
+ const buf = cachedTextEncoder.encode(arg);
69
+ const ptr = malloc(buf.length, 1) >>> 0;
70
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
71
+ WASM_VECTOR_LEN = buf.length;
72
+ return ptr;
73
+ }
74
+
75
+ let len = arg.length;
76
+ let ptr = malloc(len, 1) >>> 0;
77
+
78
+ const mem = getUint8ArrayMemory0();
79
+
80
+ let offset = 0;
81
+
82
+ for (; offset < len; offset++) {
83
+ const code = arg.charCodeAt(offset);
84
+ if (code > 0x7F) break;
85
+ mem[ptr + offset] = code;
86
+ }
87
+ if (offset !== len) {
88
+ if (offset !== 0) {
89
+ arg = arg.slice(offset);
90
+ }
91
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
92
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
93
+ const ret = cachedTextEncoder.encodeInto(arg, view);
94
+
95
+ offset += ret.written;
96
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
97
+ }
98
+
99
+ WASM_VECTOR_LEN = offset;
100
+ return ptr;
101
+ }
102
+
103
+ function takeFromExternrefTable0(idx) {
104
+ const value = wasm.__wbindgen_externrefs.get(idx);
105
+ wasm.__externref_table_dealloc(idx);
106
+ return value;
107
+ }
108
+
109
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
110
+ cachedTextDecoder.decode();
111
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
112
+ let numBytesDecoded = 0;
113
+ function decodeText(ptr, len) {
114
+ numBytesDecoded += len;
115
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
116
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
117
+ cachedTextDecoder.decode();
118
+ numBytesDecoded = len;
119
+ }
120
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
121
+ }
122
+
123
+ const cachedTextEncoder = new TextEncoder();
124
+
125
+ if (!('encodeInto' in cachedTextEncoder)) {
126
+ cachedTextEncoder.encodeInto = function (arg, view) {
127
+ const buf = cachedTextEncoder.encode(arg);
128
+ view.set(buf);
129
+ return {
130
+ read: arg.length,
131
+ written: buf.length
132
+ };
133
+ };
134
+ }
135
+
136
+ let WASM_VECTOR_LEN = 0;
137
+
138
+ let wasmModule, wasmInstance, wasm;
139
+ function __wbg_finalize_init(instance, module) {
140
+ wasmInstance = instance;
141
+ wasm = instance.exports;
142
+ wasmModule = module;
143
+ cachedUint8ArrayMemory0 = null;
144
+ wasm.__wbindgen_start();
145
+ return wasm;
146
+ }
147
+
148
+ async function __wbg_load(module, imports) {
149
+ if (typeof Response === 'function' && module instanceof Response) {
150
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
151
+ try {
152
+ return await WebAssembly.instantiateStreaming(module, imports);
153
+ } catch (e) {
154
+ const validResponse = module.ok && expectedResponseType(module.type);
155
+
156
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
157
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
158
+
159
+ } else { throw e; }
160
+ }
161
+ }
162
+
163
+ const bytes = await module.arrayBuffer();
164
+ return await WebAssembly.instantiate(bytes, imports);
165
+ } else {
166
+ const instance = await WebAssembly.instantiate(module, imports);
167
+
168
+ if (instance instanceof WebAssembly.Instance) {
169
+ return { instance, module };
170
+ } else {
171
+ return instance;
172
+ }
173
+ }
174
+
175
+ function expectedResponseType(type) {
176
+ switch (type) {
177
+ case 'basic': case 'cors': case 'default': return true;
178
+ }
179
+ return false;
180
+ }
181
+ }
182
+
183
+ function initSync(module) {
184
+ if (wasm !== undefined) return wasm;
185
+
186
+
187
+ if (module !== undefined) {
188
+ if (Object.getPrototypeOf(module) === Object.prototype) {
189
+ ({module} = module)
190
+ } else {
191
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
192
+ }
193
+ }
194
+
195
+ const imports = __wbg_get_imports();
196
+ if (!(module instanceof WebAssembly.Module)) {
197
+ module = new WebAssembly.Module(module);
198
+ }
199
+ const instance = new WebAssembly.Instance(module, imports);
200
+ return __wbg_finalize_init(instance, module);
201
+ }
202
+
203
+ async function __wbg_init(module_or_path) {
204
+ if (wasm !== undefined) return wasm;
205
+
206
+
207
+ if (module_or_path !== undefined) {
208
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
209
+ ({module_or_path} = module_or_path)
210
+ } else {
211
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
212
+ }
213
+ }
214
+
215
+ if (module_or_path === undefined) {
216
+ module_or_path = new URL('aeon_wasm_bg.wasm', import.meta.url);
217
+ }
218
+ const imports = __wbg_get_imports();
219
+
220
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
221
+ module_or_path = fetch(module_or_path);
222
+ }
223
+
224
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
225
+
226
+ return __wbg_finalize_init(instance, module);
227
+ }
228
+
229
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,10 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const process_aeon: (a: number, b: number, c: number, d: number) => [number, number, number, number];
5
+ export const __wbindgen_externrefs: WebAssembly.Table;
6
+ export const __wbindgen_malloc: (a: number, b: number) => number;
7
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
8
+ export const __externref_table_dealloc: (a: number) => void;
9
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
10
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "aeon-wasm",
3
+ "type": "module",
4
+ "version": "0.9.0",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/altopelago/Aeon"
9
+ },
10
+ "files": [
11
+ "aeon_wasm_bg.wasm",
12
+ "aeon_wasm.js",
13
+ "aeon_wasm.d.ts"
14
+ ],
15
+ "main": "aeon_wasm.js",
16
+ "types": "aeon_wasm.d.ts",
17
+ "sideEffects": [
18
+ "./snippets/*"
19
+ ]
20
+ }