ember-repl 8.0.2 → 8.1.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/declarations/compile/Compiled.d.ts +17 -0
- package/declarations/compile/Compiled.d.ts.map +1 -1
- package/declarations/compile/compile.d.ts +9 -0
- package/declarations/compile/compile.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +2 -1
- package/declarations/services/compiler.d.ts.map +1 -1
- package/dist/compile/Compiled.js +25 -4
- package/dist/compile/Compiled.js.map +1 -1
- package/dist/compile/compile.js +1 -1
- package/dist/compile/compile.js.map +1 -1
- package/dist/{plugin-DATxmrFU.js → plugin-ZDtYFKJg.js} +2 -8
- package/dist/{plugin-DATxmrFU.js.map → plugin-ZDtYFKJg.js.map} +1 -1
- package/dist/services/compiler.js +3 -2
- package/dist/services/compiler.js.map +1 -1
- package/dist/services/known-modules.js +1 -1
- package/package.json +21 -19
- package/src/compile/Compiled.ts +56 -7
- package/src/compile/compile.ts +13 -1
- package/src/index.ts +1 -0
- package/src/services/compiler.ts +6 -2
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import type { CompileState } from './state.ts';
|
|
2
2
|
import type { Format, Input } from './types.ts';
|
|
3
|
+
export interface CompiledOptions {
|
|
4
|
+
format?: Format;
|
|
5
|
+
flavor?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Arguments forwarded to the compiled component.
|
|
8
|
+
*
|
|
9
|
+
* Pass a stable object reference whose property values are reactive
|
|
10
|
+
* (e.g. a `TrackedObject` or a plain object with getters reading
|
|
11
|
+
* `@tracked` state). Property updates propagate to the rendered
|
|
12
|
+
* component without triggering a recompile.
|
|
13
|
+
*
|
|
14
|
+
* Keys must be present when compilation happens — additional keys
|
|
15
|
+
* added later will not become reactive.
|
|
16
|
+
*/
|
|
17
|
+
args?: Record<string, unknown>;
|
|
18
|
+
}
|
|
3
19
|
export declare function Compiled(markdownText: Input | (() => Input)): CompileState;
|
|
20
|
+
export declare function Compiled(markdownText: Input | (() => Input), options: CompiledOptions): CompileState;
|
|
4
21
|
export declare function Compiled(markdownText: Input | (() => Input), format?: Format, flavor?: string): CompileState;
|
|
5
22
|
export declare function Compiled(markdownText: Input | (() => Input), format: () => Format): CompileState;
|
|
6
23
|
export declare function Compiled(markdownText: Input | (() => Input), format: () => Format, flavor: () => string): CompileState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compiled.d.ts","sourceRoot":"","sources":["../../src/compile/Compiled.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Compiled.d.ts","sourceRoot":"","sources":["../../src/compile/Compiled.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,QAAQ,CAAC,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,YAAY,CAAC;AAC5E,wBAAgB,QAAQ,CACtB,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EACnC,OAAO,EAAE,eAAe,GACvB,YAAY,CAAC;AAChB,wBAAgB,QAAQ,CACtB,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EACnC,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GACd,YAAY,CAAC;AAChB,wBAAgB,QAAQ,CACtB,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EACnC,MAAM,EAAE,MAAM,MAAM,GACnB,YAAY,CAAC;AAChB,wBAAgB,QAAQ,CACtB,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EACnC,MAAM,EAAE,MAAM,MAAM,EACpB,MAAM,EAAE,MAAM,MAAM,GACnB,YAAY,CAAC"}
|
|
@@ -8,6 +8,15 @@ interface Options {
|
|
|
8
8
|
flavor?: string;
|
|
9
9
|
remarkPlugins?: unknown[];
|
|
10
10
|
rehypePlugins?: unknown[];
|
|
11
|
+
/**
|
|
12
|
+
* Arguments forwarded to the compiled component.
|
|
13
|
+
*
|
|
14
|
+
* Keys present on this object at compile time become reactive `@arg`
|
|
15
|
+
* references in the rendered component. Update the values on this object
|
|
16
|
+
* (e.g. via `@tracked` or `TrackedObject`) to propagate changes into the
|
|
17
|
+
* rendered component without recompiling.
|
|
18
|
+
*/
|
|
19
|
+
args?: Record<string, unknown>;
|
|
11
20
|
onSuccess?: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
12
21
|
onError?: (error: string) => Promise<unknown> | unknown;
|
|
13
22
|
onCompileStart?: () => Promise<unknown> | unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqC,MAAM,YAAY,CAAC;AAG7E,OAAO,KAAK,eAAe,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAiB,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,eAAO,MAAM,KAAK,4BAAmC,CAAC;AAEtD,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC;IAC1B,SAA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D;AAED,wBAAgB,OAAO,CACrB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,OAAO,GACf,YAAY,CAed"}
|
package/declarations/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { Compiled } from './compile/Compiled.ts';
|
|
|
3
3
|
export { invocationName, invocationOf, nameFor } from './compile/utils.ts';
|
|
4
4
|
export { getCompiler } from './services/compiler.ts';
|
|
5
5
|
export { setup as setupCompiler } from './setup.ts';
|
|
6
|
+
export type { CompiledOptions } from './compile/Compiled.ts';
|
|
6
7
|
export type { CompileState } from './compile/state.ts';
|
|
7
8
|
export type { Format, ModuleMap, ScopeMap } from './compile/types.ts';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAGpD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAGpD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -69,8 +69,9 @@ export default class CompilerService {
|
|
|
69
69
|
* The returned component can be invoked explicitly in the consuming project.
|
|
70
70
|
*
|
|
71
71
|
* @param {string} code the code to be compiled
|
|
72
|
+
* @param {object} [options] additional render options (e.g. `args`)
|
|
72
73
|
*/
|
|
73
|
-
compileGJS(code: string): Promise<CompileResult>;
|
|
74
|
+
compileGJS(code: string, options?: Record<string, unknown>): Promise<CompileResult>;
|
|
74
75
|
/**
|
|
75
76
|
* compile a template with an empty scope
|
|
76
77
|
* to use components, helpers, etc, you will need to compile with JS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/services/compiler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAMpC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,mBAS1C;AA8BD,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,CAAC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AAE,CAAC;KAC3B,GACA,OAAO,CAAC,aAAa,CAAC;CAG1B"}
|
package/dist/compile/Compiled.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
1
2
|
import { resourceFactory, resource } from 'ember-resources';
|
|
2
3
|
import { getCompiler } from '../services/compiler.js';
|
|
3
4
|
import { compile } from './compile.js';
|
|
@@ -5,18 +6,38 @@ import { compile } from './compile.js';
|
|
|
5
6
|
/**
|
|
6
7
|
* By default, this compiles to `glimdown`. A Markdown format which
|
|
7
8
|
* extracts `live` tagged code snippets and compiles them to components.
|
|
9
|
+
*
|
|
10
|
+
* Pass a `CompiledOptions` bag as the second argument to specify
|
|
11
|
+
* `format`, `flavor`, and `args` forwarded to the rendered component.
|
|
8
12
|
*/
|
|
9
|
-
function Compiled(markdownText,
|
|
13
|
+
function Compiled(markdownText, maybeFormatOrOptions, maybeFlavor) {
|
|
10
14
|
return resource(({
|
|
11
15
|
owner
|
|
12
16
|
}) => {
|
|
13
17
|
const input = typeof markdownText === 'function' ? markdownText() : markdownText;
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
let format;
|
|
19
|
+
let flavor;
|
|
20
|
+
let args;
|
|
21
|
+
if (typeof maybeFormatOrOptions === 'function') {
|
|
22
|
+
format = maybeFormatOrOptions();
|
|
23
|
+
} else if (typeof maybeFormatOrOptions === 'string') {
|
|
24
|
+
format = maybeFormatOrOptions;
|
|
25
|
+
} else if (maybeFormatOrOptions) {
|
|
26
|
+
format = maybeFormatOrOptions.format;
|
|
27
|
+
flavor = maybeFormatOrOptions.flavor;
|
|
28
|
+
args = maybeFormatOrOptions.args;
|
|
29
|
+
}
|
|
30
|
+
format ??= 'glimdown';
|
|
31
|
+
if (flavor === undefined) {
|
|
32
|
+
const positional = typeof maybeFlavor === 'function' ? maybeFlavor() : maybeFlavor;
|
|
33
|
+
flavor = typeof positional === 'string' ? positional : undefined;
|
|
34
|
+
}
|
|
35
|
+
assert(`second parameter to Compiled must be a format, an options bag, or a function that returns a format`, typeof format === 'string');
|
|
16
36
|
const compiler = getCompiler(owner);
|
|
17
37
|
return compile(compiler, input, {
|
|
18
38
|
format,
|
|
19
|
-
flavor
|
|
39
|
+
flavor,
|
|
40
|
+
args
|
|
20
41
|
});
|
|
21
42
|
});
|
|
22
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compiled.js","sources":["../../src/compile/Compiled.ts"],"sourcesContent":["import { resource, resourceFactory } from 'ember-resources';\n\nimport { getCompiler } from '../services/compiler.ts';\nimport { compile } from './compile.ts';\n\nimport type { CompileState } from './state.ts';\nimport type { Format, Input } from './types.ts';\n\nexport function Compiled(markdownText: Input | (() => Input)): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format?: Format,\n flavor?: string\n): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format: () => Format\n): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format: () => Format,\n flavor: () => string\n): CompileState;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n
|
|
1
|
+
{"version":3,"file":"Compiled.js","sources":["../../src/compile/Compiled.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { resource, resourceFactory } from 'ember-resources';\n\nimport { getCompiler } from '../services/compiler.ts';\nimport { compile } from './compile.ts';\n\nimport type { CompileState } from './state.ts';\nimport type { Format, Input } from './types.ts';\n\nexport interface CompiledOptions {\n format?: Format;\n flavor?: string;\n /**\n * Arguments forwarded to the compiled component.\n *\n * Pass a stable object reference whose property values are reactive\n * (e.g. a `TrackedObject` or a plain object with getters reading\n * `@tracked` state). Property updates propagate to the rendered\n * component without triggering a recompile.\n *\n * Keys must be present when compilation happens — additional keys\n * added later will not become reactive.\n */\n args?: Record<string, unknown>;\n}\n\nexport function Compiled(markdownText: Input | (() => Input)): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n options: CompiledOptions\n): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format?: Format,\n flavor?: string\n): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format: () => Format\n): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format: () => Format,\n flavor: () => string\n): CompileState;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n *\n * Pass a `CompiledOptions` bag as the second argument to specify\n * `format`, `flavor`, and `args` forwarded to the rendered component.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n maybeFormatOrOptions?: Format | (() => Format) | CompiledOptions,\n maybeFlavor?: string | (() => string)\n): CompileState {\n return resource(({ owner }) => {\n const input =\n typeof markdownText === 'function' ? markdownText() : markdownText;\n\n let format: Format | undefined;\n let flavor: string | undefined;\n let args: Record<string, unknown> | undefined;\n\n if (typeof maybeFormatOrOptions === 'function') {\n format = maybeFormatOrOptions();\n } else if (typeof maybeFormatOrOptions === 'string') {\n format = maybeFormatOrOptions;\n } else if (maybeFormatOrOptions) {\n format = maybeFormatOrOptions.format;\n flavor = maybeFormatOrOptions.flavor;\n args = maybeFormatOrOptions.args;\n }\n\n format ??= 'glimdown';\n\n if (flavor === undefined) {\n const positional =\n typeof maybeFlavor === 'function' ? maybeFlavor() : maybeFlavor;\n\n flavor = typeof positional === 'string' ? positional : undefined;\n }\n\n assert(\n `second parameter to Compiled must be a format, an options bag, or a function that returns a format`,\n typeof format === 'string'\n );\n\n const compiler = getCompiler(owner);\n\n return compile(compiler, input, {\n format,\n flavor,\n args,\n });\n });\n}\n\nresourceFactory(Compiled);\n"],"names":["Compiled","markdownText","maybeFormatOrOptions","maybeFlavor","resource","owner","input","format","flavor","args","undefined","positional","assert","compiler","getCompiler","compile","resourceFactory"],"mappings":";;;;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAQA,CACtBC,YAAmC,EACnCC,oBA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@ async function runTheCompiler({
|
|
|
42
42
|
if (options.format === 'glimdown') {
|
|
43
43
|
result = await service.compile('gmd', text, options);
|
|
44
44
|
} else if (options.format === 'gjs') {
|
|
45
|
-
result = await service.compileGJS(text);
|
|
45
|
+
result = await service.compileGJS(text, options);
|
|
46
46
|
} else if (options.format === 'hbs') {
|
|
47
47
|
result = await service.compileHBS(text, options);
|
|
48
48
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sources":["../../src/compile/compile.ts"],"sourcesContent":["import { CompileState, MissingTextState, REJECT, RESOLVE } from './state.ts';\nimport { nameFor } from './utils.ts';\n\nimport type CompilerService from '../services/compiler.ts';\nimport type { CompileResult, Format, Input } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Options {\n format: Format;\n flavor?: string;\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n onSuccess?: (component: ComponentLike) => Promise<unknown> | unknown;\n onError?: (error: string) => Promise<unknown> | unknown;\n onCompileStart?: () => Promise<unknown> | unknown;\n}\n\nexport function compile(\n service: CompilerService,\n text: Input,\n options: Options\n): CompileState {\n const data = { format: options.format };\n\n if (!text) {\n return new MissingTextState(data);\n }\n\n const id = nameFor(`${options.format}:${text}`);\n\n const state = new CompileState(data);\n\n // Fills the cache as well\n runTheCompiler({ service, text, options, state, id });\n\n return state;\n}\n\nasync function runTheCompiler({\n service,\n text,\n options,\n state,\n id,\n}: {\n service: CompilerService;\n text: string;\n options: Options;\n state: CompileState;\n id: string;\n}) {\n await options?.onCompileStart?.();\n await Promise.resolve();\n\n if (!text) {\n state[REJECT](new Error('No Input Document yet'));\n await options?.onError?.('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n // TODO: just use compile, eliminate all this branching\n if (options.format === 'glimdown') {\n result = await service.compile('gmd', text, options as any);\n } else if (options.format === 'gjs') {\n result = await service.compileGJS(text);\n } else if (options.format === 'hbs') {\n result = await service.compileHBS(text, options as any);\n } else {\n result = await service.compile(\n options.format,\n text,\n options as unknown as Record<string, unknown>\n );\n }\n\n if (result.error) {\n state[REJECT](result.error);\n await options?.onError?.(state.reason || 'Unknown Error');\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n state[RESOLVE](result.component as ComponentLike);\n\n await options?.onSuccess?.(result.component as ComponentLike);\n}\n"],"names":["CACHE","Map","compile","service","text","options","data","format","MissingTextState","id","nameFor","state","CompileState","runTheCompiler","onCompileStart","Promise","resolve","REJECT","Error","onError","result","compileGJS","compileHBS","error","reason","set","component","RESOLVE","onSuccess"],"mappings":";;;MAOaA,KAAK,GAAG,IAAIC,GAAG;
|
|
1
|
+
{"version":3,"file":"compile.js","sources":["../../src/compile/compile.ts"],"sourcesContent":["import { CompileState, MissingTextState, REJECT, RESOLVE } from './state.ts';\nimport { nameFor } from './utils.ts';\n\nimport type CompilerService from '../services/compiler.ts';\nimport type { CompileResult, Format, Input } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Options {\n format: Format;\n flavor?: string;\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n /**\n * Arguments forwarded to the compiled component.\n *\n * Keys present on this object at compile time become reactive `@arg`\n * references in the rendered component. Update the values on this object\n * (e.g. via `@tracked` or `TrackedObject`) to propagate changes into the\n * rendered component without recompiling.\n */\n args?: Record<string, unknown>;\n onSuccess?: (component: ComponentLike) => Promise<unknown> | unknown;\n onError?: (error: string) => Promise<unknown> | unknown;\n onCompileStart?: () => Promise<unknown> | unknown;\n}\n\nexport function compile(\n service: CompilerService,\n text: Input,\n options: Options\n): CompileState {\n const data = { format: options.format };\n\n if (!text) {\n return new MissingTextState(data);\n }\n\n const id = nameFor(`${options.format}:${text}`);\n\n const state = new CompileState(data);\n\n // Fills the cache as well\n runTheCompiler({ service, text, options, state, id });\n\n return state;\n}\n\nasync function runTheCompiler({\n service,\n text,\n options,\n state,\n id,\n}: {\n service: CompilerService;\n text: string;\n options: Options;\n state: CompileState;\n id: string;\n}) {\n await options?.onCompileStart?.();\n await Promise.resolve();\n\n if (!text) {\n state[REJECT](new Error('No Input Document yet'));\n await options?.onError?.('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n // TODO: just use compile, eliminate all this branching\n if (options.format === 'glimdown') {\n result = await service.compile('gmd', text, options as any);\n } else if (options.format === 'gjs') {\n result = await service.compileGJS(\n text,\n options as unknown as Record<string, unknown>\n );\n } else if (options.format === 'hbs') {\n result = await service.compileHBS(text, options as any);\n } else {\n result = await service.compile(\n options.format,\n text,\n options as unknown as Record<string, unknown>\n );\n }\n\n if (result.error) {\n state[REJECT](result.error);\n await options?.onError?.(state.reason || 'Unknown Error');\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n state[RESOLVE](result.component as ComponentLike);\n\n await options?.onSuccess?.(result.component as ComponentLike);\n}\n"],"names":["CACHE","Map","compile","service","text","options","data","format","MissingTextState","id","nameFor","state","CompileState","runTheCompiler","onCompileStart","Promise","resolve","REJECT","Error","onError","result","compileGJS","compileHBS","error","reason","set","component","RESOLVE","onSuccess"],"mappings":";;;MAOaA,KAAK,GAAG,IAAIC,GAAG;AAqBrB,SAASC,OAAOA,CACrBC,OAAwB,EACxBC,IAAW,EACXC,OAAgB,EACF;AACd,EAAA,MAAMC,IAAI,GAAG;IAAEC,MAAM,EAAEF,OAAO,CAACE;GAAQ;EAEvC,IAAI,CAACH,IAAI,EAAE;AACT,IAAA,OAAO,IAAII,gBAAgB,CAACF,IAAI,CAAC;AACnC,EAAA;EAEA,MAAMG,EAAE,GAAGC,OAAO,CAAC,CAAA,EAAGL,OAAO,CAACE,MAAM,CAAA,CAAA,EAAIH,IAAI,CAAA,CAAE,CAAC;AAE/C,EAAA,MAAMO,KAAK,GAAG,IAAIC,YAAY,CAACN,IAAI,CAAC;;AAEpC;AACAO,EAAAA,cAAc,CAAC;IAAEV,OAAO;IAAEC,IAA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O,GAAGR,KAAK,CAACa,MAAM,IAAI,eAAe,CAAC;AAEzD,IAAA;AACF,EAAA;EAEAxB,KAAK,CAACyB,GAAG,CAAChB,EAAE,EAAEW,MAAM,CAACM,SAA0B,CAAC;AAEhDf,EAAAA,KAAK,CAACgB,OAAO,CAAC,CAACP,MAAM,CAACM,SAA0B,CAAC;AAEjD,EAAA,MAAMrB,OAAO,EAAEuB,SAAS,GAAGR,MAAM,CAACM,SAA0B,CAAC;AAC/D;;;;"}
|
|
@@ -8852,13 +8852,7 @@ function buildPrecompileOptions(babel, target, state, normalizedOpts, template,
|
|
|
8852
8852
|
// we've extended meta to add jsutils, but the types in @glimmer/syntax
|
|
8853
8853
|
// don't account for extension
|
|
8854
8854
|
meta: meta,
|
|
8855
|
-
//
|
|
8856
|
-
// backward-compatible module names that don't match the real name of the
|
|
8857
|
-
// on-disk file. What's our plan for migrating people away from that?
|
|
8858
|
-
moduleName: state.filename,
|
|
8859
|
-
// This is here so it's *always* the real filename. Historically, there is
|
|
8860
|
-
// also `moduleName` but that did not match the real on-disk filename, it
|
|
8861
|
-
// was the notional runtime module name from classic ember builds.
|
|
8855
|
+
// This is here so it's *always* the real filename.
|
|
8862
8856
|
filename: state.filename,
|
|
8863
8857
|
plugins: {
|
|
8864
8858
|
// the cast is needed here only because our meta is extended. That is,
|
|
@@ -9107,4 +9101,4 @@ function name(node) {
|
|
|
9107
9101
|
var plugin = makePlugin(async options => options);
|
|
9108
9102
|
|
|
9109
9103
|
export { plugin as default, makePlugin };
|
|
9110
|
-
//# sourceMappingURL=plugin-
|
|
9104
|
+
//# sourceMappingURL=plugin-ZDtYFKJg.js.map
|