ember-repl 3.0.0-beta.8 → 4.0.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 +1 -1
- package/package.json +48 -41
- package/src/compile/formats/gjs/babel.ts +7 -0
- package/src/{browser/cjs → compile/formats/gjs}/eval.ts +2 -4
- package/src/compile/formats/gjs/index.ts +123 -0
- package/src/{browser → compile/formats}/hbs.ts +15 -4
- package/src/{browser/compile/markdown-to-ember.ts → compile/formats/markdown.ts} +8 -1
- package/src/{browser/compile → compile}/formats.ts +14 -13
- package/src/{browser/compile → compile}/index.ts +2 -3
- package/src/compile/types.ts +26 -0
- package/src/index.ts +5 -0
- package/src/test-support/index.ts +1 -1
- package/declarations/browser/__PRIVATE__.d.ts +0 -2
- package/declarations/browser/__PRIVATE__.d.ts.map +0 -1
- package/declarations/browser/cjs/eval.d.ts +0 -9
- package/declarations/browser/cjs/eval.d.ts.map +0 -1
- package/declarations/browser/cjs/index.d.ts +0 -7
- package/declarations/browser/cjs/index.d.ts.map +0 -1
- package/declarations/browser/compile/formats.d.ts +0 -18
- package/declarations/browser/compile/formats.d.ts.map +0 -1
- package/declarations/browser/compile/index.d.ts +0 -71
- package/declarations/browser/compile/index.d.ts.map +0 -1
- package/declarations/browser/compile/markdown-to-ember.d.ts +0 -21
- package/declarations/browser/compile/markdown-to-ember.d.ts.map +0 -1
- package/declarations/browser/compile/types.d.ts +0 -9
- package/declarations/browser/compile/types.d.ts.map +0 -1
- package/declarations/browser/esm/index.d.ts +0 -8
- package/declarations/browser/esm/index.d.ts.map +0 -1
- package/declarations/browser/gjs.d.ts +0 -4
- package/declarations/browser/gjs.d.ts.map +0 -1
- package/declarations/browser/hbs.d.ts +0 -17
- package/declarations/browser/hbs.d.ts.map +0 -1
- package/declarations/browser/index.d.ts +0 -7
- package/declarations/browser/index.d.ts.map +0 -1
- package/declarations/browser/js.d.ts +0 -20
- package/declarations/browser/js.d.ts.map +0 -1
- package/declarations/browser/known-modules.d.ts +0 -65
- package/declarations/browser/known-modules.d.ts.map +0 -1
- package/declarations/browser/types.d.ts +0 -21
- package/declarations/browser/types.d.ts.map +0 -1
- package/declarations/browser/utils.d.ts +0 -19
- package/declarations/browser/utils.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -2
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/browser/__PRIVATE__.js +0 -2
- package/dist/browser/__PRIVATE__.js.map +0 -1
- package/dist/browser/cjs/eval.js +0 -22
- package/dist/browser/cjs/eval.js.map +0 -1
- package/dist/browser/cjs/index.js +0 -43
- package/dist/browser/cjs/index.js.map +0 -1
- package/dist/browser/compile/formats.js +0 -171
- package/dist/browser/compile/formats.js.map +0 -1
- package/dist/browser/compile/index.js +0 -113
- package/dist/browser/compile/index.js.map +0 -1
- package/dist/browser/compile/markdown-to-ember.js +0 -254
- package/dist/browser/compile/markdown-to-ember.js.map +0 -1
- package/dist/browser/compile/types.js +0 -2
- package/dist/browser/compile/types.js.map +0 -1
- package/dist/browser/esm/index.js +0 -67
- package/dist/browser/esm/index.js.map +0 -1
- package/dist/browser/gjs.js +0 -43
- package/dist/browser/gjs.js.map +0 -1
- package/dist/browser/hbs.js +0 -94
- package/dist/browser/hbs.js.map +0 -1
- package/dist/browser/index.js +0 -6
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/js.js +0 -38
- package/dist/browser/js.js.map +0 -1
- package/dist/browser/known-modules.js +0 -48
- package/dist/browser/known-modules.js.map +0 -1
- package/dist/browser/types.js +0 -2
- package/dist/browser/types.js.map +0 -1
- package/dist/browser/utils.js +0 -46
- package/dist/browser/utils.js.map +0 -1
- package/dist/build/ember-cli.cjs +0 -36
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/browser/cjs/index.ts +0 -44
- package/src/browser/compile/types.ts +0 -11
- package/src/browser/esm/index.ts +0 -80
- package/src/browser/gjs.ts +0 -59
- package/src/browser/index.ts +0 -8
- package/src/browser/js.ts +0 -42
- package/src/browser/types.ts +0 -24
- package/src/build/ember-cli.cjs +0 -36
- /package/src/{browser/__PRIVATE__.ts → __PRIVATE__.ts} +0 -0
- /package/src/{browser → compile/formats/gjs}/known-modules.ts +0 -0
- /package/src/{browser → compile}/utils.ts +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
2
|
-
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
3
|
-
import type { ComponentLike } from '@glint/template';
|
|
4
|
-
type Format = 'glimdown' | 'gjs' | 'hbs';
|
|
5
|
-
export declare const CACHE: Map<string, ComponentLike>;
|
|
6
|
-
interface Events {
|
|
7
|
-
onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
8
|
-
onError: (error: string) => Promise<unknown> | unknown;
|
|
9
|
-
onCompileStart: () => Promise<unknown> | unknown;
|
|
10
|
-
}
|
|
11
|
-
interface Scope {
|
|
12
|
-
importMap?: EvalImportMap;
|
|
13
|
-
}
|
|
14
|
-
interface GlimdownOptions extends Scope, Events {
|
|
15
|
-
format: 'glimdown';
|
|
16
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
17
|
-
CopyComponent?: string;
|
|
18
|
-
ShadowComponent?: string;
|
|
19
|
-
topLevelScope?: ScopeMap;
|
|
20
|
-
}
|
|
21
|
-
interface GJSOptions extends Scope, Events {
|
|
22
|
-
format: 'gjs';
|
|
23
|
-
}
|
|
24
|
-
interface HBSOptions extends Scope, Events {
|
|
25
|
-
format: 'hbs';
|
|
26
|
-
topLevelScope?: ScopeMap;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Compile GitHub-flavored Markdown with GJS support
|
|
30
|
-
* and optionally render gjs-snippets via a `live` meta tag
|
|
31
|
-
* on the code fences.
|
|
32
|
-
*/
|
|
33
|
-
export declare function compile(text: string, options: GlimdownOptions): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Compile GJS
|
|
36
|
-
*/
|
|
37
|
-
export declare function compile(text: string, options: GJSOptions): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Compile a stateless component using just the template
|
|
40
|
-
*/
|
|
41
|
-
export declare function compile(text: string, options: HBSOptions): Promise<void>;
|
|
42
|
-
type Input = string | undefined | null;
|
|
43
|
-
type ExtraOptions = {
|
|
44
|
-
format: 'glimdown';
|
|
45
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
46
|
-
importMap?: EvalImportMap;
|
|
47
|
-
CopyComponent?: string;
|
|
48
|
-
ShadowComponent?: string;
|
|
49
|
-
topLevelScope?: ScopeMap;
|
|
50
|
-
} | {
|
|
51
|
-
format: 'hbs';
|
|
52
|
-
topLevelScope?: ScopeMap;
|
|
53
|
-
} | {
|
|
54
|
-
format: 'gjs';
|
|
55
|
-
importMap?: EvalImportMap;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export interface Value {
|
|
61
|
-
isReady: boolean;
|
|
62
|
-
error: string | null;
|
|
63
|
-
component: ComponentLike;
|
|
64
|
-
}
|
|
65
|
-
export declare function Compiled(markdownText: Input | (() => Input)): Value;
|
|
66
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: Format): Value;
|
|
67
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;
|
|
68
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
|
|
69
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;A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,GAAG,KAAK,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
2
|
-
export interface ExtractedCode {
|
|
3
|
-
name: string;
|
|
4
|
-
code: string;
|
|
5
|
-
lang: string;
|
|
6
|
-
}
|
|
7
|
-
export interface LiveCodeExtraction {
|
|
8
|
-
templateOnlyGlimdown: string;
|
|
9
|
-
blocks: ExtractedCode[];
|
|
10
|
-
}
|
|
11
|
-
interface ParseMarkdownOptions {
|
|
12
|
-
CopyComponent?: string;
|
|
13
|
-
ShadowComponent?: string;
|
|
14
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @internal not under semver
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseMarkdown(input: string, options?: ParseMarkdownOptions): Promise<LiveCodeExtraction>;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=markdown-to-ember.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-to-ember.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/markdown-to-ember.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAMhD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAiSD,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CompileResult, ExtraModules } from '../types.ts';
|
|
2
|
-
export interface Info {
|
|
3
|
-
code: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
|
|
7
|
-
export declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/esm/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI/D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAoBjG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,UAavE"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Babel } from './types.ts';
|
|
2
|
-
export declare function preprocess(input: string, name: string): Promise<string>;
|
|
3
|
-
export declare function transform(intermediate: string, name: string, options?: any): Promise<ReturnType<Babel['transform']>>;
|
|
4
|
-
//# sourceMappingURL=gjs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gjs.d.ts","sourceRoot":"","sources":["../../src/browser/gjs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAOxC,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY7E;AAED,wBAAsB,SAAS,CAC7B,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CA6BzC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CompileResult } from './types.ts';
|
|
2
|
-
/**
|
|
3
|
-
* compile a template with an empty scope
|
|
4
|
-
* to use components, helpers, etc, you will need to compile with JS
|
|
5
|
-
*
|
|
6
|
-
* (templates alone do not have a way to import / define complex structures)
|
|
7
|
-
*/
|
|
8
|
-
export declare function compileHBS(template: string, options?: CompileTemplateOptions): CompileResult;
|
|
9
|
-
interface CompileTemplateOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Used for debug viewing
|
|
12
|
-
*/
|
|
13
|
-
moduleName?: string;
|
|
14
|
-
scope?: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=hbs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hbs.d.ts","sourceRoot":"","sources":["../../src/browser/hbs.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQhD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,aAAa,CAehG;AAED,UAAU,sBAAsB;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { compile, Compiled } from './compile/index.ts';
|
|
2
|
-
export { compileHBS } from './hbs.ts';
|
|
3
|
-
export { compileJS } from './js.ts';
|
|
4
|
-
export { modules as frameworkModules } from './known-modules.ts';
|
|
5
|
-
export { invocationName, invocationOf, nameFor } from './utils.ts';
|
|
6
|
-
export type { CompileResult } from './types';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGnE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CompileResult, ExtraModules, Options } from './types.ts';
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
5
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
6
|
-
*
|
|
7
|
-
* SEE: README for example usage
|
|
8
|
-
*
|
|
9
|
-
* @param {string} code: the code to be compiled
|
|
10
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
11
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
12
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
13
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
14
|
-
*
|
|
15
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
16
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
17
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
18
|
-
*/
|
|
19
|
-
export declare function compileJS(code: string, extraModules?: ExtraModules, options?: Options): Promise<CompileResult>;
|
|
20
|
-
//# sourceMappingURL=js.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/browser/js.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,YAAY,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,aAAa,CAAC,CAexB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/// <reference types="ember-source/types/stable/@glimmer/tracking" />
|
|
2
|
-
/// <reference types="ember-source/types/stable/@ember/application" />
|
|
3
|
-
/// <reference types="ember-source/types/stable/@ember/array" />
|
|
4
|
-
/// <reference types="ember-source/types/stable/@ember/component" />
|
|
5
|
-
/// <reference types="ember-source/types/stable/@ember/component/helper" />
|
|
6
|
-
/// <reference types="ember-source/types/stable/@ember/debug" />
|
|
7
|
-
/// <reference types="ember-source/types/stable/@ember/destroyable" />
|
|
8
|
-
/// <reference types="ember-source/types/stable/@ember/helper" />
|
|
9
|
-
/// <reference types="ember-source/types/stable/@ember/modifier" />
|
|
10
|
-
/// <reference types="ember-source/types/stable/@ember/object" />
|
|
11
|
-
/// <reference types="ember-source/types/stable/@ember/owner" />
|
|
12
|
-
/// <reference types="ember-source/types/stable/@ember/controller/owner-ext" />
|
|
13
|
-
/// <reference types="ember-source/types/stable/@ember/routing/owner-ext" />
|
|
14
|
-
/// <reference types="ember-source/types/stable/@ember/service/owner-ext" />
|
|
15
|
-
/// <reference types="ember-source/types/stable/@ember/runloop" />
|
|
16
|
-
/// <reference types="ember-source/types/stable/@ember/service" />
|
|
17
|
-
/// <reference types="ember-source/types/stable/@ember/routing/service-ext" />
|
|
18
|
-
/// <reference types="ember-source/types/stable/@ember/template" />
|
|
19
|
-
/// <reference types="ember-source/types/stable/@ember/template-factory" />
|
|
20
|
-
/// <reference types="ember-source/types/stable/@ember/utils" />
|
|
21
|
-
/// <reference types="ember-source/types/stable/@ember/component/template-only" />
|
|
22
|
-
/**
|
|
23
|
-
* We need to import and hang on to these references so that they
|
|
24
|
-
* don't get optimized away during deploy
|
|
25
|
-
*/
|
|
26
|
-
import _GlimmerComponent from '@glimmer/component';
|
|
27
|
-
import * as _tracking from '@glimmer/tracking';
|
|
28
|
-
import * as _application from '@ember/application';
|
|
29
|
-
import * as _array from '@ember/array';
|
|
30
|
-
import * as _EmberComponent from '@ember/component';
|
|
31
|
-
import * as _EmberComponentHelper from '@ember/component/helper';
|
|
32
|
-
import * as _debug from '@ember/debug';
|
|
33
|
-
import * as _destroyable from '@ember/destroyable';
|
|
34
|
-
import * as _helpers from '@ember/helper';
|
|
35
|
-
import * as _modifier from '@ember/modifier';
|
|
36
|
-
import * as _object from '@ember/object';
|
|
37
|
-
import * as _owner from '@ember/owner';
|
|
38
|
-
import * as _runloop from '@ember/runloop';
|
|
39
|
-
import * as _service from '@ember/service';
|
|
40
|
-
import * as _template from '@ember/template';
|
|
41
|
-
import { createTemplateFactory } from '@ember/template-factory';
|
|
42
|
-
import * as _utils from '@ember/utils';
|
|
43
|
-
export declare const modules: {
|
|
44
|
-
'@ember/application': typeof _application;
|
|
45
|
-
'@ember/array': typeof _array;
|
|
46
|
-
'@ember/component': typeof _EmberComponent;
|
|
47
|
-
'@ember/component/helper': typeof _EmberComponentHelper;
|
|
48
|
-
'@ember/component/template-only': <S>(moduleName?: string | undefined, name?: string | undefined) => import("@ember/component/template-only").TemplateOnlyComponent<S>;
|
|
49
|
-
'@ember/debug': typeof _debug;
|
|
50
|
-
'@ember/destroyable': typeof _destroyable;
|
|
51
|
-
'@ember/helper': typeof _helpers;
|
|
52
|
-
'@ember/modifier': typeof _modifier;
|
|
53
|
-
'@ember/object': typeof _object;
|
|
54
|
-
'@ember/runloop': typeof _runloop;
|
|
55
|
-
'@ember/service': typeof _service;
|
|
56
|
-
'@ember/template-factory': {
|
|
57
|
-
createTemplateFactory: typeof createTemplateFactory;
|
|
58
|
-
};
|
|
59
|
-
'@ember/utils': typeof _utils;
|
|
60
|
-
'@ember/template': typeof _template;
|
|
61
|
-
'@ember/owner': typeof _owner;
|
|
62
|
-
'@glimmer/component': typeof _GlimmerComponent;
|
|
63
|
-
'@glimmer/tracking': typeof _tracking;
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=known-modules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known-modules.d.ts","sourceRoot":"","sources":["../../src/browser/known-modules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,eAAe,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAEvC,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
|
|
2
|
-
import type { ComponentLike } from '@glint/template';
|
|
3
|
-
export interface CompileResult {
|
|
4
|
-
component?: ComponentLike;
|
|
5
|
-
error?: Error;
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Babel {
|
|
9
|
-
availablePlugins: typeof availablePlugins;
|
|
10
|
-
availablePresets: typeof availablePresets;
|
|
11
|
-
transform: typeof transform;
|
|
12
|
-
}
|
|
13
|
-
export type Options = {
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
* @deprecated do not use - not under semver
|
|
17
|
-
*/
|
|
18
|
-
skypack?: boolean;
|
|
19
|
-
};
|
|
20
|
-
export type ExtraModules = Record<string, unknown>;
|
|
21
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/browser/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,SAAS,EAAE,OAAO,SAAS,CAAC;CAC7B;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For any given code block, a reasonably stable name can be
|
|
3
|
-
* generated.
|
|
4
|
-
* This can help with cacheing previously compiled components,
|
|
5
|
-
* and generally allowing a consumer to derive "known references" to user-input
|
|
6
|
-
*/
|
|
7
|
-
export declare function nameFor(code: string, prefix?: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the text for invoking a component with a given name.
|
|
10
|
-
* It is assumed the component takes no arguments, as would be the
|
|
11
|
-
* case in REPLs / Playgrounds for the "root" component.
|
|
12
|
-
*/
|
|
13
|
-
export declare function invocationOf(name: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)
|
|
16
|
-
* inflection does not support hyphens
|
|
17
|
-
*/
|
|
18
|
-
export declare function invocationName(name: string): string;
|
|
19
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/browser/utils.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAiB,UAI5D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAWxC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,UAE1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-support/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,SAEhC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__PRIVATE__.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/browser/cjs/eval.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { modules } from '../known-modules.js';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
function evalSnippet(compiled, extraModules = {}) {
|
|
5
|
-
const exports = {};
|
|
6
|
-
function require(moduleName) {
|
|
7
|
-
let preConfigured = modules[moduleName] || extraModules[moduleName];
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
return preConfigured || window.require(moduleName);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts
|
|
15
|
-
eval(compiled);
|
|
16
|
-
return Object.assign(exports, {
|
|
17
|
-
require
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { evalSnippet };
|
|
22
|
-
//# sourceMappingURL=eval.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eval.js","sources":["../../../src/browser/cjs/eval.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { modules } from '../known-modules.ts';\n\nimport type { ExtraModules } from '../types.ts';\nimport type Component from '@glimmer/component';\n\nexport function evalSnippet(\n compiled: string,\n extraModules: ExtraModules = {}\n): {\n default: Component;\n services?: { [key: string]: unknown };\n} {\n const exports = {};\n\n function require(moduleName: keyof typeof modules): unknown {\n let preConfigured = modules[moduleName] || extraModules[moduleName];\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return preConfigured || window.require(moduleName);\n }\n\n // https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts\n eval(compiled);\n\n return Object.assign(exports, { require }) as {\n default: Component;\n services?: { [key: string]: unknown };\n require: unknown;\n };\n}\n"],"names":["evalSnippet","compiled","extraModules","exports","require","moduleName","preConfigured","modules","window","eval","Object","assign"],"mappings":";;AAAA;AAMO,SAASA,WAAWA,CACzBC,QAAgB,EAChBC,YAA0B,GAAG,EAAE,EAI/B;EACA,MAAMC,OAAO,GAAG,EAAE,CAAA;EAElB,SAASC,OAAOA,CAACC,UAAgC,EAAW;IAC1D,IAAIC,aAAa,GAAGC,OAAO,CAACF,UAAU,CAAC,IAAIH,YAAY,CAACG,UAAU,CAAC,CAAA;;AAEnE;AACA;AACA,IAAA,OAAOC,aAAa,IAAIE,MAAM,CAACJ,OAAO,CAACC,UAAU,CAAC,CAAA;AACpD,GAAA;;AAEA;EACAI,IAAI,CAACR,QAAQ,CAAC,CAAA;AAEd,EAAA,OAAOS,MAAM,CAACC,MAAM,CAACR,OAAO,EAAE;AAAEC,IAAAA,OAAAA;AAAQ,GAAC,CAAC,CAAA;AAK5C;;;;"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { preprocess, transform } from '../gjs.js';
|
|
2
|
-
import { nameFor } from '../utils.js';
|
|
3
|
-
import { evalSnippet } from './eval.js';
|
|
4
|
-
|
|
5
|
-
async function compileJS(code, extraModules) {
|
|
6
|
-
let name = nameFor(code);
|
|
7
|
-
let component;
|
|
8
|
-
let error;
|
|
9
|
-
try {
|
|
10
|
-
let compiled = await compileGJS({
|
|
11
|
-
code: code,
|
|
12
|
-
name
|
|
13
|
-
});
|
|
14
|
-
if (!compiled) {
|
|
15
|
-
throw new Error(`Compiled output is missing`);
|
|
16
|
-
}
|
|
17
|
-
component = evalSnippet(compiled, extraModules).default;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
error = e;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
name,
|
|
23
|
-
component,
|
|
24
|
-
error
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async function compileGJS({
|
|
28
|
-
code: input,
|
|
29
|
-
name
|
|
30
|
-
}) {
|
|
31
|
-
let preprocessed = await preprocess(input, name);
|
|
32
|
-
let result = await transform(preprocessed, name);
|
|
33
|
-
if (!result) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
let {
|
|
37
|
-
code
|
|
38
|
-
} = result;
|
|
39
|
-
return code;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { compileJS };
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/browser/cjs/index.ts"],"sourcesContent":["import { preprocess, transform } from '../gjs.ts';\nimport { nameFor } from '../utils.ts';\nimport { evalSnippet } from './eval.ts';\n\nimport type { CompileResult, ExtraModules } from '../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\nexport async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await compileGJS({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nasync function compileGJS({ code: input, name }: Info) {\n let preprocessed = await preprocess(input, name);\n let result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","compileGJS","Error","evalSnippet","default","e","input","preprocessed","preprocess","result","transform"],"mappings":";;;;AAYO,eAAeA,SAASA,CAACC,IAAY,EAAEC,YAA2B,EAA0B;AACjG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,IAAI,CAAC,CAAA;AACxB,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,UAAU,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAEE,MAAAA,IAAAA;AAAK,KAAC,CAAC,CAAA;IAErD,IAAI,CAACI,QAAQ,EAAE;AACb,MAAA,MAAM,IAAIE,KAAK,CAAE,CAAA,0BAAA,CAA2B,CAAC,CAAA;AAC/C,KAAA;IAEAJ,SAAS,GAAGK,WAAW,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAACS,OAAmC,CAAA;GACpF,CAAC,OAAOC,CAAC,EAAE;AACVN,IAAAA,KAAK,GAAGM,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAET,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAEA,eAAeE,UAAUA,CAAC;AAAEP,EAAAA,IAAI,EAAEY,KAAK;AAAEV,EAAAA,IAAAA;AAAW,CAAC,EAAE;EACrD,IAAIW,YAAY,GAAG,MAAMC,UAAU,CAACF,KAAK,EAAEV,IAAI,CAAC,CAAA;EAChD,IAAIa,MAAM,GAAG,MAAMC,SAAS,CAACH,YAAY,EAAEX,IAAI,CAAC,CAAA;EAEhD,IAAI,CAACa,MAAM,EAAE;AACX,IAAA,OAAA;AACF,GAAA;EAEA,IAAI;AAAEf,IAAAA,IAAAA;AAAK,GAAC,GAAGe,MAAM,CAAA;AAErB,EAAA,OAAOf,IAAI,CAAA;AACb;;;;"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { invocationName } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
async function compileAll(js, importMap) {
|
|
4
|
-
let modules = await Promise.all(js.map(async ({
|
|
5
|
-
code
|
|
6
|
-
}) => {
|
|
7
|
-
return await compileGJS(code, importMap);
|
|
8
|
-
}));
|
|
9
|
-
return modules;
|
|
10
|
-
}
|
|
11
|
-
async function compileGJS(gjsInput, importMap) {
|
|
12
|
-
try {
|
|
13
|
-
let {
|
|
14
|
-
compileJS
|
|
15
|
-
} = await import('../js.js');
|
|
16
|
-
return await compileJS(gjsInput, importMap);
|
|
17
|
-
} catch (error) {
|
|
18
|
-
return {
|
|
19
|
-
error: error,
|
|
20
|
-
name: 'unknown'
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function compileHBS(hbsInput, options) {
|
|
25
|
-
try {
|
|
26
|
-
let {
|
|
27
|
-
compileHBS
|
|
28
|
-
} = await import('../hbs.js');
|
|
29
|
-
return compileHBS(hbsInput, options);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return {
|
|
32
|
-
error: error,
|
|
33
|
-
name: 'unknown'
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function extractScope(liveCode, importMap) {
|
|
38
|
-
let scope = [];
|
|
39
|
-
let hbs = liveCode.filter(code => code.lang === 'hbs');
|
|
40
|
-
let js = liveCode.filter(code => ['js', 'gjs'].includes(code.lang));
|
|
41
|
-
if (js.length > 0) {
|
|
42
|
-
let compiled = await compileAll(js, importMap);
|
|
43
|
-
await Promise.all(compiled.map(async info => {
|
|
44
|
-
// using web worker + import maps is not available yet (need firefox support)
|
|
45
|
-
// (and to somehow be able to point at npm)
|
|
46
|
-
//
|
|
47
|
-
// if ('importPath' in info) {
|
|
48
|
-
// return scope.push({
|
|
49
|
-
// moduleName: name,
|
|
50
|
-
// component: await import(/* webpackIgnore: true */ info.importPath),
|
|
51
|
-
// });
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
return scope.push(info);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
for (let {
|
|
58
|
-
code
|
|
59
|
-
} of hbs) {
|
|
60
|
-
let compiled = await compileHBS(code);
|
|
61
|
-
scope.push(compiled);
|
|
62
|
-
}
|
|
63
|
-
return scope;
|
|
64
|
-
}
|
|
65
|
-
async function compileMD(glimdownInput, options) {
|
|
66
|
-
let importMap = options?.importMap;
|
|
67
|
-
let topLevelScope = options?.topLevelScope ?? {};
|
|
68
|
-
let rootTemplate;
|
|
69
|
-
let liveCode;
|
|
70
|
-
let scope = [];
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Step 1: Convert Markdown To HTML (Ember).
|
|
74
|
-
*
|
|
75
|
-
* The remark plugin, remark-code-extra also extracts
|
|
76
|
-
* and transforms the code blocks we care about.
|
|
77
|
-
*
|
|
78
|
-
* These blocks will be compiled through babel and eval'd so the
|
|
79
|
-
* compiled rootTemplate can invoke them
|
|
80
|
-
*/
|
|
81
|
-
try {
|
|
82
|
-
let {
|
|
83
|
-
parseMarkdown
|
|
84
|
-
} = await import('./markdown-to-ember.js');
|
|
85
|
-
let {
|
|
86
|
-
templateOnlyGlimdown,
|
|
87
|
-
blocks
|
|
88
|
-
} = await parseMarkdown(glimdownInput, {
|
|
89
|
-
CopyComponent: options?.CopyComponent,
|
|
90
|
-
ShadowComponent: options?.ShadowComponent,
|
|
91
|
-
remarkPlugins: options?.remarkPlugins
|
|
92
|
-
});
|
|
93
|
-
rootTemplate = templateOnlyGlimdown;
|
|
94
|
-
liveCode = blocks;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
return {
|
|
97
|
-
error: error,
|
|
98
|
-
name: 'unknown'
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Step 2: Compile the live code samples
|
|
104
|
-
*/
|
|
105
|
-
if (liveCode.length > 0) {
|
|
106
|
-
try {
|
|
107
|
-
scope = await extractScope(liveCode, importMap);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.info({
|
|
110
|
-
scope
|
|
111
|
-
});
|
|
112
|
-
console.error(error);
|
|
113
|
-
return {
|
|
114
|
-
error: error,
|
|
115
|
-
rootTemplate,
|
|
116
|
-
name: 'unknown'
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Make sure non of our snippets errored
|
|
123
|
-
*
|
|
124
|
-
* TODO: for these errors, report them differently so that we
|
|
125
|
-
* can render the 'Ember' and still highlight the correct line?
|
|
126
|
-
* or maybe there is a way to highlight in the editor instead?
|
|
127
|
-
*/
|
|
128
|
-
for (let {
|
|
129
|
-
error,
|
|
130
|
-
component
|
|
131
|
-
} of scope) {
|
|
132
|
-
if (!component) {
|
|
133
|
-
if (error) {
|
|
134
|
-
return {
|
|
135
|
-
error,
|
|
136
|
-
rootTemplate,
|
|
137
|
-
name: 'unknown'
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Step 4: Compile the Ember Template
|
|
145
|
-
*/
|
|
146
|
-
try {
|
|
147
|
-
let localScope = scope.reduce((accum, {
|
|
148
|
-
component,
|
|
149
|
-
name
|
|
150
|
-
}) => {
|
|
151
|
-
accum[invocationName(name)] = component;
|
|
152
|
-
return accum;
|
|
153
|
-
}, {});
|
|
154
|
-
return await compileHBS(rootTemplate, {
|
|
155
|
-
moduleName: 'DynamicRootTemplate',
|
|
156
|
-
scope: {
|
|
157
|
-
...topLevelScope,
|
|
158
|
-
...localScope
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
} catch (error) {
|
|
162
|
-
return {
|
|
163
|
-
error: error,
|
|
164
|
-
rootTemplate,
|
|
165
|
-
name: 'unknown'
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export { compileGJS, compileHBS, compileMD };
|
|
171
|
-
//# sourceMappingURL=formats.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formats.js","sources":["../../../src/browser/compile/formats.ts"],"sourcesContent":["import { invocationName } from '../utils.ts';\n\nimport type { CompileResult } from '../types.ts';\nimport type { ExtractedCode } from './markdown-to-ember.ts';\nimport type { UnifiedPlugin } from './types.ts';\nimport type { EvalImportMap, ScopeMap } from './types.ts';\n\nasync function compileAll(js: { code: string }[], importMap?: EvalImportMap) {\n let modules = await Promise.all(\n js.map(async ({ code }) => {\n return await compileGJS(code, importMap);\n })\n );\n\n return modules;\n}\n\nexport async function compileGJS(\n gjsInput: string,\n importMap?: EvalImportMap\n): Promise<CompileResult> {\n try {\n let { compileJS } = await import('../js.ts');\n\n return await compileJS(gjsInput, importMap);\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n}\n\nexport async function compileHBS(\n hbsInput: string,\n options?: {\n moduleName?: string;\n scope?: Record<string, unknown>;\n }\n): Promise<CompileResult> {\n try {\n let { compileHBS } = await import('../hbs.ts');\n\n return compileHBS(hbsInput, options);\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n}\n\nasync function extractScope(\n liveCode: ExtractedCode[],\n importMap?: EvalImportMap\n): Promise<CompileResult[]> {\n let scope: CompileResult[] = [];\n\n let hbs = liveCode.filter((code) => code.lang === 'hbs');\n let js = liveCode.filter((code) => ['js', 'gjs'].includes(code.lang));\n\n if (js.length > 0) {\n let compiled = await compileAll(js, importMap);\n\n await Promise.all(\n compiled.map(async (info) => {\n // using web worker + import maps is not available yet (need firefox support)\n // (and to somehow be able to point at npm)\n //\n // if ('importPath' in info) {\n // return scope.push({\n // moduleName: name,\n // component: await import(/* webpackIgnore: true */ info.importPath),\n // });\n // }\n\n return scope.push(info);\n })\n );\n }\n\n for (let { code } of hbs) {\n let compiled = await compileHBS(code);\n\n scope.push(compiled);\n }\n\n return scope;\n}\n\nexport async function compileMD(\n glimdownInput: string,\n options?: {\n importMap?: EvalImportMap;\n topLevelScope?: ScopeMap;\n remarkPlugins?: UnifiedPlugin[];\n CopyComponent?: string;\n ShadowComponent?: string;\n }\n): Promise<CompileResult & { rootTemplate?: string }> {\n let importMap = options?.importMap;\n let topLevelScope = options?.topLevelScope ?? {};\n let rootTemplate: string;\n let liveCode: ExtractedCode[];\n let scope: CompileResult[] = [];\n\n /**\n * Step 1: Convert Markdown To HTML (Ember).\n *\n * The remark plugin, remark-code-extra also extracts\n * and transforms the code blocks we care about.\n *\n * These blocks will be compiled through babel and eval'd so the\n * compiled rootTemplate can invoke them\n */\n try {\n let { parseMarkdown } = await import('./markdown-to-ember.ts');\n let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {\n CopyComponent: options?.CopyComponent,\n ShadowComponent: options?.ShadowComponent,\n remarkPlugins: options?.remarkPlugins,\n });\n\n rootTemplate = templateOnlyGlimdown;\n liveCode = blocks;\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n\n /**\n * Step 2: Compile the live code samples\n */\n if (liveCode.length > 0) {\n try {\n scope = await extractScope(liveCode, importMap);\n } catch (error) {\n console.info({ scope });\n console.error(error);\n\n return { error: error as Error, rootTemplate, name: 'unknown' };\n }\n }\n\n /**\n * Make sure non of our snippets errored\n *\n * TODO: for these errors, report them differently so that we\n * can render the 'Ember' and still highlight the correct line?\n * or maybe there is a way to highlight in the editor instead?\n */\n for (let { error, component } of scope) {\n if (!component) {\n if (error) {\n return { error, rootTemplate, name: 'unknown' };\n }\n }\n }\n\n /**\n * Step 4: Compile the Ember Template\n */\n try {\n let localScope = scope.reduce(\n (accum, { component, name }) => {\n accum[invocationName(name)] = component;\n\n return accum;\n },\n {} as Record<string, unknown>\n );\n\n return await compileHBS(rootTemplate, {\n moduleName: 'DynamicRootTemplate',\n scope: {\n ...topLevelScope,\n ...localScope,\n },\n });\n } catch (error) {\n return { error: error as Error, rootTemplate, name: 'unknown' };\n }\n}\n"],"names":["compileAll","js","importMap","modules","Promise","all","map","code","compileGJS","gjsInput","compileJS","error","name","compileHBS","hbsInput","options","extractScope","liveCode","scope","hbs","filter","lang","includes","length","compiled","info","push","compileMD","glimdownInput","topLevelScope","rootTemplate","parseMarkdown","templateOnlyGlimdown","blocks","CopyComponent","ShadowComponent","remarkPlugins","console","component","localScope","reduce","accum","invocationName","moduleName"],"mappings":";;AAOA,eAAeA,UAAUA,CAACC,EAAsB,EAAEC,SAAyB,EAAE;EAC3E,IAAIC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BJ,EAAE,CAACK,GAAG,CAAC,OAAO;AAAEC,IAAAA,IAAAA;AAAK,GAAC,KAAK;AACzB,IAAA,OAAO,MAAMC,UAAU,CAACD,IAAI,EAAEL,SAAS,CAAC,CAAA;AAC1C,GAAC,CACH,CAAC,CAAA;AAED,EAAA,OAAOC,OAAO,CAAA;AAChB,CAAA;AAEO,eAAeK,UAAUA,CAC9BC,QAAgB,EAChBP,SAAyB,EACD;EACxB,IAAI;IACF,IAAI;AAAEQ,MAAAA,SAAAA;AAAU,KAAC,GAAG,MAAM,OAAO,UAAU,CAAC,CAAA;AAE5C,IAAA,OAAO,MAAMA,SAAS,CAACD,QAAQ,EAAEP,SAAS,CAAC,CAAA;GAC5C,CAAC,OAAOS,KAAK,EAAE;IACd,OAAO;AAAEA,MAAAA,KAAK,EAAEA,KAAc;AAAEC,MAAAA,IAAI,EAAE,SAAA;KAAW,CAAA;AACnD,GAAA;AACF,CAAA;AAEO,eAAeC,UAAUA,CAC9BC,QAAgB,EAChBC,OAGC,EACuB;EACxB,IAAI;IACF,IAAI;AAAEF,MAAAA,UAAAA;AAAW,KAAC,GAAG,MAAM,OAAO,WAAW,CAAC,CAAA;AAE9C,IAAA,OAAOA,UAAU,CAACC,QAAQ,EAAEC,OAAO,CAAC,CAAA;GACrC,CAAC,OAAOJ,KAAK,EAAE;IACd,OAAO;AAAEA,MAAAA,KAAK,EAAEA,KAAc;AAAEC,MAAAA,IAAI,EAAE,SAAA;KAAW,CAAA;AACnD,GAAA;AACF,CAAA;AAEA,e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