ember-repl 6.0.0 → 7.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/LICENSE.md +1 -1
- package/README.md +2 -404
- package/config/.try.mjs +87 -0
- package/config/addon-main.cjs +7 -0
- package/config/attw.json +7 -0
- package/config/babel.publish.config.cjs +29 -0
- package/config/ember-cli-update.json +21 -0
- package/config/rollup.config.mjs +44 -0
- package/config/testem.cjs +35 -0
- package/config/tsconfig.publish.json +18 -0
- package/config/vite.config.mjs +36 -0
- package/declarations/compile/Compiled.d.ts +7 -0
- package/declarations/compile/Compiled.d.ts.map +1 -0
- package/declarations/compile/compile.d.ts +17 -0
- package/declarations/compile/compile.d.ts.map +1 -0
- package/declarations/compile/state.d.ts +43 -0
- package/declarations/compile/state.d.ts.map +1 -0
- package/declarations/compile/types.d.ts +5 -12
- package/declarations/compile/types.d.ts.map +1 -1
- package/declarations/index.d.ts +6 -2
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +94 -0
- package/declarations/services/compiler.d.ts.map +1 -0
- package/declarations/services/known-modules.d.ts +7 -0
- package/declarations/services/known-modules.d.ts.map +1 -0
- package/declarations/setup.d.ts +7 -0
- package/declarations/setup.d.ts.map +1 -0
- package/declarations/test-support.d.ts +20 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
- package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
- package/dist/babel-8wMrbxkT.js +110427 -0
- package/dist/babel-8wMrbxkT.js.map +1 -0
- package/dist/blank-line-Bzg2Qt4K.js +482 -0
- package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
- package/dist/compile/Compiled.js +26 -0
- package/dist/compile/Compiled.js.map +1 -0
- package/dist/compile/compile.js +62 -0
- package/dist/compile/compile.js.map +1 -0
- package/dist/compile/state.js +75 -0
- package/dist/compile/state.js.map +1 -0
- package/dist/compile/utils.js +213 -2
- package/dist/compile/utils.js.map +1 -1
- package/dist/default-CoqAuVeH.js +4 -0
- package/dist/default-CoqAuVeH.js.map +1 -0
- package/dist/index-BTx1k6gT.js +323 -0
- package/dist/index-BTx1k6gT.js.map +1 -0
- package/dist/index-Bxzjtr16.js +87 -0
- package/dist/index-Bxzjtr16.js.map +1 -0
- package/dist/index-C371bO_b.js +1553 -0
- package/dist/index-C371bO_b.js.map +1 -0
- package/dist/index-C4AyeeIa.js +5721 -0
- package/dist/index-C4AyeeIa.js.map +1 -0
- package/dist/index-C8S2G0FH.js +1953 -0
- package/dist/index-C8S2G0FH.js.map +1 -0
- package/dist/index-CCcIVEUK.js +409 -0
- package/dist/index-CCcIVEUK.js.map +1 -0
- package/dist/index-CDSIcg03.js +9070 -0
- package/dist/index-CDSIcg03.js.map +1 -0
- package/dist/index-D8szzCn3.js +2 -0
- package/dist/index-D8szzCn3.js.map +1 -0
- package/dist/index-DBBNT106.js +2644 -0
- package/dist/index-DBBNT106.js.map +1 -0
- package/dist/index-DP_Su7Zc.js +362 -0
- package/dist/index-DP_Su7Zc.js.map +1 -0
- package/dist/index-DejgrVqh.js +11299 -0
- package/dist/index-DejgrVqh.js.map +1 -0
- package/dist/index-Dr5iYoKt.js +1551 -0
- package/dist/index-Dr5iYoKt.js.map +1 -0
- package/dist/index-DxolpiGq.js +3336 -0
- package/dist/index-DxolpiGq.js.map +1 -0
- package/dist/index-ZyJlPFQY.js +249 -0
- package/dist/index-ZyJlPFQY.js.map +1 -0
- package/dist/index-k6CfLgeq.js +26 -0
- package/dist/index-k6CfLgeq.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/services/compiler.js +329 -0
- package/dist/services/compiler.js.map +1 -0
- package/dist/services/known-modules.js +123 -0
- package/dist/services/known-modules.js.map +1 -0
- package/dist/setup.js +15 -0
- package/dist/setup.js.map +1 -0
- package/dist/test-support.js +33 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +117 -138
- package/src/compile/Compiled.ts +45 -0
- package/src/compile/compile.ts +89 -0
- package/src/compile/state.ts +88 -0
- package/src/compile/types.ts +14 -13
- package/src/index.ts +6 -2
- package/src/services/compiler.ts +401 -0
- package/src/services/known-modules.ts +130 -0
- package/src/setup.ts +26 -0
- package/src/test-support.ts +64 -0
- package/addon-main.cjs +0 -5
- package/declarations/__PRIVATE__.d.ts +0 -2
- package/declarations/__PRIVATE__.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/babel.d.ts +0 -7
- package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/eval.d.ts +0 -8
- package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/index.d.ts +0 -24
- package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/known-modules.d.ts +0 -48
- package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
- package/declarations/compile/formats/hbs.d.ts +0 -17
- package/declarations/compile/formats/hbs.d.ts.map +0 -1
- package/declarations/compile/formats/markdown.d.ts +0 -22
- package/declarations/compile/formats/markdown.d.ts.map +0 -1
- package/declarations/compile/formats.d.ts +0 -17
- package/declarations/compile/formats.d.ts.map +0 -1
- package/declarations/compile/index.d.ts +0 -80
- package/declarations/compile/index.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/__PRIVATE__.js +0 -2
- package/dist/__PRIVATE__.js.map +0 -1
- package/dist/compile/formats/gjs/babel.js +0 -2
- package/dist/compile/formats/gjs/babel.js.map +0 -1
- package/dist/compile/formats/gjs/eval.js +0 -19
- package/dist/compile/formats/gjs/eval.js.map +0 -1
- package/dist/compile/formats/gjs/index.js +0 -122
- package/dist/compile/formats/gjs/index.js.map +0 -1
- package/dist/compile/formats/gjs/known-modules.js +0 -52
- package/dist/compile/formats/gjs/known-modules.js.map +0 -1
- package/dist/compile/formats/hbs.js +0 -93
- package/dist/compile/formats/hbs.js.map +0 -1
- package/dist/compile/formats/markdown.js +0 -266
- package/dist/compile/formats/markdown.js.map +0 -1
- package/dist/compile/formats.js +0 -173
- package/dist/compile/formats.js.map +0 -1
- package/dist/compile/index.js +0 -113
- package/dist/compile/index.js.map +0 -1
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/__PRIVATE__.ts +0 -1
- package/src/compile/formats/gjs/babel.ts +0 -7
- package/src/compile/formats/gjs/eval.ts +0 -29
- package/src/compile/formats/gjs/index.ts +0 -153
- package/src/compile/formats/gjs/known-modules.ts +0 -49
- package/src/compile/formats/hbs.ts +0 -100
- package/src/compile/formats/markdown.ts +0 -345
- package/src/compile/formats.ts +0 -178
- package/src/compile/index.ts +0 -219
- package/src/test-support/index.ts +0 -5
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as compiler from 'ember-source/dist/ember-template-compiler.js';
|
|
2
|
-
import { nameFor } from '../../utils.js';
|
|
3
|
-
import { evalSnippet } from './eval.js';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
10
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
11
|
-
*
|
|
12
|
-
* SEE: README for example usage
|
|
13
|
-
*
|
|
14
|
-
* @param {string} code: the code to be compiled
|
|
15
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
16
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
17
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
18
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
19
|
-
*
|
|
20
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
21
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
22
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
23
|
-
*/
|
|
24
|
-
async function compileJS(code, extraModules) {
|
|
25
|
-
const name = nameFor(code);
|
|
26
|
-
let component;
|
|
27
|
-
let error;
|
|
28
|
-
try {
|
|
29
|
-
const compiled = await transpile({
|
|
30
|
-
code: code,
|
|
31
|
-
name
|
|
32
|
-
});
|
|
33
|
-
if (!compiled) {
|
|
34
|
-
throw new Error(`Compiled output is missing`);
|
|
35
|
-
}
|
|
36
|
-
component = evalSnippet(compiled, extraModules).default;
|
|
37
|
-
} catch (e) {
|
|
38
|
-
error = e;
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
name,
|
|
42
|
-
component,
|
|
43
|
-
error
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
async function transpile({
|
|
47
|
-
code: input,
|
|
48
|
-
name
|
|
49
|
-
}) {
|
|
50
|
-
const preprocessed = await preprocess(input, name);
|
|
51
|
-
const result = await transform(preprocessed, name);
|
|
52
|
-
if (!result) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const {
|
|
56
|
-
code
|
|
57
|
-
} = result;
|
|
58
|
-
return code;
|
|
59
|
-
}
|
|
60
|
-
let processor;
|
|
61
|
-
let fetchingPromise;
|
|
62
|
-
async function preprocess(input, name) {
|
|
63
|
-
if (!fetchingPromise) {
|
|
64
|
-
fetchingPromise = import('content-tag');
|
|
65
|
-
}
|
|
66
|
-
if (!processor) {
|
|
67
|
-
const {
|
|
68
|
-
Preprocessor
|
|
69
|
-
} = await fetchingPromise;
|
|
70
|
-
processor = new Preprocessor();
|
|
71
|
-
}
|
|
72
|
-
const {
|
|
73
|
-
code /* map */
|
|
74
|
-
} = processor.process(input, {
|
|
75
|
-
filename: `${name}.js`,
|
|
76
|
-
inline_source_map: true
|
|
77
|
-
});
|
|
78
|
-
return code;
|
|
79
|
-
}
|
|
80
|
-
async function transform(intermediate, name) {
|
|
81
|
-
const [
|
|
82
|
-
// _parser, _traverse, _generator,
|
|
83
|
-
_decoratorTransforms, _emberTemplateCompilation] = await Promise.all([
|
|
84
|
-
// @babel/* doesn't have the greatest ESM compat yet
|
|
85
|
-
// https://github.com/babel/babel/issues/14314#issuecomment-1054505190
|
|
86
|
-
//
|
|
87
|
-
// babel-standalone is so easy...
|
|
88
|
-
// import('@babel/parser'),
|
|
89
|
-
// import('@babel/traverse'),
|
|
90
|
-
// import('@babel/generator'),
|
|
91
|
-
import('decorator-transforms'), import('babel-plugin-ember-template-compilation')]);
|
|
92
|
-
|
|
93
|
-
// These libraries are compiled incorrectly for cjs<->ESM compat
|
|
94
|
-
const decoratorTransforms = 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;
|
|
95
|
-
const emberTemplateCompilation = 'default' in _emberTemplateCompilation ? _emberTemplateCompilation.default : _emberTemplateCompilation;
|
|
96
|
-
|
|
97
|
-
// so we have to use the default export (which is all the exports)
|
|
98
|
-
const maybeBabel = await import('@babel/standalone');
|
|
99
|
-
// Handle difference between vite and webpack in consuming projects...
|
|
100
|
-
const babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
|
|
101
|
-
return babel.transform(intermediate, {
|
|
102
|
-
filename: `${name}.js`,
|
|
103
|
-
plugins: [[emberTemplateCompilation, {
|
|
104
|
-
compiler
|
|
105
|
-
}], [
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
107
|
-
// @ts-ignore - we don't care about types here..
|
|
108
|
-
decoratorTransforms, {
|
|
109
|
-
runtime: {
|
|
110
|
-
import: 'decorator-transforms/runtime'
|
|
111
|
-
}
|
|
112
|
-
}],
|
|
113
|
-
// Womp.
|
|
114
|
-
// See this exploration into true ESM:
|
|
115
|
-
// https://github.com/NullVoxPopuli/limber/pull/1805
|
|
116
|
-
[babel.availablePlugins['transform-modules-commonjs']]],
|
|
117
|
-
presets: []
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { compileJS };
|
|
122
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as compiler from 'ember-source/dist/ember-template-compiler.js';\n\nimport { nameFor } from '../../utils.ts';\nimport { evalSnippet } from './eval.ts';\n\nimport type { CompileResult } from '../../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport async function compileJS(\n code: string,\n extraModules?: Record<string, unknown>\n): Promise<CompileResult> {\n const name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n const compiled = await transpile({ 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 transpile({ code: input, name }: Info) {\n const preprocessed = await preprocess(input, name);\n const result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n const { code } = result;\n\n return code;\n}\n\nimport type { Babel } from './babel.ts';\n\nlet processor: any;\nlet fetchingPromise: Promise<any>;\n\nasync function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = import('content-tag');\n }\n\n if (!processor) {\n const { Preprocessor } = await fetchingPromise;\n\n processor = new Preprocessor();\n }\n\n const { code /* map */ } = processor.process(input, {\n filename: `${name}.js`,\n inline_source_map: true,\n });\n\n return code;\n}\n\nasync function transform(\n intermediate: string,\n name: string\n): Promise<ReturnType<Babel['transform']>> {\n const [\n // _parser, _traverse, _generator,\n _decoratorTransforms,\n _emberTemplateCompilation,\n ] = await Promise.all([\n // @babel/* doesn't have the greatest ESM compat yet\n // https://github.com/babel/babel/issues/14314#issuecomment-1054505190\n //\n // babel-standalone is so easy...\n // import('@babel/parser'),\n // import('@babel/traverse'),\n // import('@babel/generator'),\n import('decorator-transforms'),\n import('babel-plugin-ember-template-compilation'),\n ]);\n\n // These libraries are compiled incorrectly for cjs<->ESM compat\n const decoratorTransforms =\n 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;\n\n const emberTemplateCompilation =\n 'default' in _emberTemplateCompilation\n ? _emberTemplateCompilation.default\n : _emberTemplateCompilation;\n\n // so we have to use the default export (which is all the exports)\n const maybeBabel = (await import('@babel/standalone')) as any;\n // Handle difference between vite and webpack in consuming projects...\n const babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [\n emberTemplateCompilation,\n {\n compiler,\n },\n ],\n [\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - we don't care about types here..\n decoratorTransforms,\n {\n runtime: {\n import: 'decorator-transforms/runtime',\n },\n },\n ],\n // Womp.\n // See this exploration into true ESM:\n // https://github.com/NullVoxPopuli/limber/pull/1805\n [babel.availablePlugins['transform-modules-commonjs']],\n ],\n presets: [],\n });\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","transpile","Error","evalSnippet","default","e","input","preprocessed","preprocess","result","transform","processor","fetchingPromise","Preprocessor","process","filename","inline_source_map","intermediate","_decoratorTransforms","_emberTemplateCompilation","Promise","all","decoratorTransforms","emberTemplateCompilation","maybeBabel","babel","plugins","compiler","runtime","import","availablePlugins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AAA,OAAO,EAAE;AACPC,QAAAA,MAAM,EAAE;AACV;AACF,KAAC,CACF;AACD;AACA;AACA;AACA,IAAA,CAACJ,KAAK,CAACK,gBAAgB,CAAC,4BAA4B,CAAC,CAAC,CACvD;AACDC,IAAAA,OAAO,EAAE;AACX,GAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import _GlimmerComponent from '@glimmer/component';
|
|
2
|
-
import * as _tracking from '@glimmer/tracking';
|
|
3
|
-
import * as _application from '@ember/application';
|
|
4
|
-
import * as _array from '@ember/array';
|
|
5
|
-
import * as _EmberComponent from '@ember/component';
|
|
6
|
-
import * as _EmberComponentHelper from '@ember/component/helper';
|
|
7
|
-
import _TO from '@ember/component/template-only';
|
|
8
|
-
import * as _debug from '@ember/debug';
|
|
9
|
-
import * as _destroyable from '@ember/destroyable';
|
|
10
|
-
import * as _helpers from '@ember/helper';
|
|
11
|
-
import * as _modifier from '@ember/modifier';
|
|
12
|
-
import * as _object from '@ember/object';
|
|
13
|
-
import * as _owner from '@ember/owner';
|
|
14
|
-
import * as _runloop from '@ember/runloop';
|
|
15
|
-
import * as _service from '@ember/service';
|
|
16
|
-
import * as _template from '@ember/template';
|
|
17
|
-
import { createTemplateFactory } from '@ember/template-factory';
|
|
18
|
-
import * as _utils from '@ember/utils';
|
|
19
|
-
import * as _decoratorsRuntime from 'decorator-transforms/runtime';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* We need to import and hang on to these references so that they
|
|
23
|
-
* don't get optimized away during deploy
|
|
24
|
-
*/
|
|
25
|
-
const modules = {
|
|
26
|
-
'@ember/application': _application,
|
|
27
|
-
'@ember/array': _array,
|
|
28
|
-
'@ember/component': _EmberComponent,
|
|
29
|
-
'@ember/component/helper': _EmberComponentHelper,
|
|
30
|
-
'@ember/component/template-only': Object.assign(_TO, {
|
|
31
|
-
default: _TO
|
|
32
|
-
}),
|
|
33
|
-
'@ember/debug': _debug,
|
|
34
|
-
'@ember/destroyable': _destroyable,
|
|
35
|
-
'@ember/helper': _helpers,
|
|
36
|
-
'@ember/modifier': _modifier,
|
|
37
|
-
'@ember/object': _object,
|
|
38
|
-
'@ember/runloop': _runloop,
|
|
39
|
-
'@ember/service': _service,
|
|
40
|
-
'@ember/template-factory': {
|
|
41
|
-
createTemplateFactory
|
|
42
|
-
},
|
|
43
|
-
'@ember/utils': _utils,
|
|
44
|
-
'@ember/template': _template,
|
|
45
|
-
'@ember/owner': _owner,
|
|
46
|
-
'@glimmer/component': _GlimmerComponent,
|
|
47
|
-
'@glimmer/tracking': _tracking,
|
|
48
|
-
'decorator-transforms/runtime': _decoratorsRuntime
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { modules };
|
|
52
|
-
//# sourceMappingURL=known-modules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known-modules.js","sources":["../../../../src/compile/formats/gjs/known-modules.ts"],"sourcesContent":["/**\n * We need to import and hang on to these references so that they\n * don't get optimized away during deploy\n */\nimport _GlimmerComponent from '@glimmer/component';\nimport * as _tracking from '@glimmer/tracking';\nimport * as _application from '@ember/application';\nimport * as _array from '@ember/array';\nimport * as _EmberComponent from '@ember/component';\nimport * as _EmberComponentHelper from '@ember/component/helper';\nimport _TO from '@ember/component/template-only';\nimport * as _debug from '@ember/debug';\nimport * as _destroyable from '@ember/destroyable';\nimport * as _helpers from '@ember/helper';\nimport * as _modifier from '@ember/modifier';\nimport * as _object from '@ember/object';\nimport * as _owner from '@ember/owner';\nimport * as _runloop from '@ember/runloop';\nimport * as _service from '@ember/service';\nimport * as _template from '@ember/template';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport * as _utils from '@ember/utils';\n\nimport * as _decoratorsRuntime from 'decorator-transforms/runtime';\n\nexport const modules = {\n '@ember/application': _application,\n '@ember/array': _array,\n '@ember/component': _EmberComponent,\n '@ember/component/helper': _EmberComponentHelper,\n '@ember/component/template-only': Object.assign(_TO, { default: _TO }),\n '@ember/debug': _debug,\n '@ember/destroyable': _destroyable,\n '@ember/helper': _helpers,\n '@ember/modifier': _modifier,\n '@ember/object': _object,\n '@ember/runloop': _runloop,\n '@ember/service': _service,\n '@ember/template-factory': { createTemplateFactory },\n '@ember/utils': _utils,\n '@ember/template': _template,\n '@ember/owner': _owner,\n\n '@glimmer/component': _GlimmerComponent,\n '@glimmer/tracking': _tracking,\n 'decorator-transforms/runtime': _decoratorsRuntime,\n};\n"],"names":["modules","_application","_array","_EmberComponent","_EmberComponentHelper","Object","assign","_TO","default","_debug","_destroyable","_helpers","_modifier","_object","_runloop","_service","createTemplateFactory","_utils","_template","_owner","_GlimmerComponent","_tracking","_decoratorsRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAwBO,MAAMA,OAAO,GAAG;AACrB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,kBAAkB,EAAEC,eAAe;AACnC,EAAA,yBAAyB,EAAEC,qBAAqB;AAChD,EAAA,gCAAgC,EAAEC,MAAM,CAACC,MAAM,CAACC,GAAG,EAAE;AAAEC,IAAAA,OAAO,EAAED;AAAI,GAAC,CAAC;AACtE,EAAA,cAAc,EAAEE,MAAM;AACtB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,eAAe,EAAEC,QAAQ;AACzB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,eAAe,EAAEC,OAAO;AACxB,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,yBAAyB,EAAE;AAAEC,IAAAA;GAAuB;AACpD,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,cAAc,EAAEC,MAAM;AAEtB,EAAA,oBAAoB,EAAEC,iBAAiB;AACvC,EAAA,mBAAmB,EAAEC,SAAS;AAC9B,EAAA,8BAA8B,EAAEC;AAClC;;;;"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { precompileJSON } from '@glimmer/compiler';
|
|
2
|
-
import { getTemplateLocals } from '@glimmer/syntax';
|
|
3
|
-
import { setComponentTemplate } from '@ember/component';
|
|
4
|
-
import _TO from '@ember/component/template-only';
|
|
5
|
-
import { array, concat, fn, get, hash } from '@ember/helper';
|
|
6
|
-
import { on } from '@ember/modifier';
|
|
7
|
-
import { createTemplateFactory } from '@ember/template-factory';
|
|
8
|
-
import { nameFor } from '../utils.js';
|
|
9
|
-
|
|
10
|
-
// import { precompileJSON } from '@glimmer/compiler';
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
// These things are pre-bundled in the old system.
|
|
14
|
-
// ember-template-compiler defines them in AMD/requirejs
|
|
15
|
-
/**
|
|
16
|
-
* compile a template with an empty scope
|
|
17
|
-
* to use components, helpers, etc, you will need to compile with JS
|
|
18
|
-
*
|
|
19
|
-
* (templates alone do not have a way to import / define complex structures)
|
|
20
|
-
*/
|
|
21
|
-
function compileHBS(template, options = {}) {
|
|
22
|
-
const name = nameFor(template);
|
|
23
|
-
let component;
|
|
24
|
-
let error;
|
|
25
|
-
try {
|
|
26
|
-
component = setComponentTemplate(compileTemplate(template, {
|
|
27
|
-
moduleName: options.moduleName || name,
|
|
28
|
-
...options
|
|
29
|
-
}), _TO(options.moduleName || name));
|
|
30
|
-
} catch (e) {
|
|
31
|
-
error = e;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
name,
|
|
35
|
-
component,
|
|
36
|
-
error
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The reason why we can't use precompile directly is because of this:
|
|
41
|
-
* https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132
|
|
42
|
-
*
|
|
43
|
-
* Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.
|
|
44
|
-
* That JSON.stringify (and the lines after) prevent us from easily setting the scope function,
|
|
45
|
-
* which means that *everything* is undefined.
|
|
46
|
-
*/
|
|
47
|
-
function compileTemplate(source, {
|
|
48
|
-
moduleName,
|
|
49
|
-
scope = {}
|
|
50
|
-
}) {
|
|
51
|
-
const localScope = {
|
|
52
|
-
array,
|
|
53
|
-
concat,
|
|
54
|
-
fn,
|
|
55
|
-
get,
|
|
56
|
-
hash,
|
|
57
|
-
on,
|
|
58
|
-
...scope
|
|
59
|
-
};
|
|
60
|
-
const locals = getTemplateLocals(source);
|
|
61
|
-
const options = {
|
|
62
|
-
strictMode: true,
|
|
63
|
-
moduleName,
|
|
64
|
-
locals,
|
|
65
|
-
isProduction: false,
|
|
66
|
-
meta: {
|
|
67
|
-
moduleName
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// Copied from @glimmer/compiler/lib/compiler#precompile
|
|
72
|
-
const [block, usedLocals] = precompileJSON(source, options);
|
|
73
|
-
const usedScope = usedLocals.map(key => {
|
|
74
|
-
const value = localScope[key];
|
|
75
|
-
if (!value) {
|
|
76
|
-
throw new Error(`Attempt to use ${key} in compiled hbs, but it was not available in scope. ` + `Available scope includes: ${Object.keys(localScope)}`);
|
|
77
|
-
}
|
|
78
|
-
return value;
|
|
79
|
-
});
|
|
80
|
-
const blockJSON = JSON.stringify(block);
|
|
81
|
-
const templateJSONObject = {
|
|
82
|
-
id: moduleName,
|
|
83
|
-
block: blockJSON,
|
|
84
|
-
moduleName: moduleName ?? '(dynamically compiled component)',
|
|
85
|
-
scope: () => usedScope,
|
|
86
|
-
isStrictMode: true
|
|
87
|
-
};
|
|
88
|
-
const factory = createTemplateFactory(templateJSONObject);
|
|
89
|
-
return factory;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { compileHBS };
|
|
93
|
-
//# sourceMappingURL=hbs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hbs.js","sources":["../../../src/compile/formats/hbs.ts"],"sourcesContent":["// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nimport { precompileJSON } from '@glimmer/compiler';\nimport { getTemplateLocals } from '@glimmer/syntax';\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\n\nimport { nameFor } from '../utils.ts';\n\nimport type { CompileResult } from '../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {\n const name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: options.moduleName || name, ...options }),\n templateOnlyComponent(options.moduleName || name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n const localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n const locals = getTemplateLocals(source);\n\n const options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n const [block, usedLocals] = precompileJSON(source, options);\n\n const usedScope = usedLocals.map((key: string) => {\n const value = localScope[key];\n\n if (!value) {\n throw new Error(\n `Attempt to use ${key} in compiled hbs, but it was not available in scope. ` +\n `Available scope includes: ${Object.keys(localScope)}`\n );\n }\n\n return value;\n });\n\n const blockJSON = JSON.stringify(block);\n const templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(dynamically compiled component)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n const factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","getTemplateLocals","strictMode","isProduction","meta","block","usedLocals","precompileJSON","usedScope","map","key","value","Error","Object","keys","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,MAAMC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC;AAC9B,EAAA,IAAII,SAAoC;AACxC,EAAA,IAAIC,KAAwB;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEP,OAAO,CAACO,UAAU,IAAIN,IAAI;MAAE,GAAGD;KAAS,CAAC,EACjFQ,GAAqB,CAACR,OAAO,CAACO,UAAU,IAAIN,IAAI,CAClD,CAAkB;GACnB,CAAC,OAAOQ,CAAC,EAAE;AACVL,IAAAA,KAAK,GAAGK,CAA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EA,UAAU,IAAI,kCAAkC;IAC5DI,KAAK,EAAEA,MAAMgB,SAAS;AACtBY,IAAAA,YAAY,EAAE;GACf;AAED,EAAA,MAAMC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC;AAEzD,EAAA,OAAOG,OAAO;AAChB;;;;"}
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import rehypeRaw from 'rehype-raw';
|
|
2
|
-
import rehypeStringify from 'rehype-stringify';
|
|
3
|
-
import remarkGfm from 'remark-gfm';
|
|
4
|
-
import remarkParse from 'remark-parse';
|
|
5
|
-
import remarkRehype from 'remark-rehype';
|
|
6
|
-
import { unified } from 'unified';
|
|
7
|
-
import { visit } from 'unist-util-visit';
|
|
8
|
-
import { nameFor, invocationOf } from '../utils.js';
|
|
9
|
-
|
|
10
|
-
const GLIMDOWN_PREVIEW = Symbol('__GLIMDOWN_PREVIEW__');
|
|
11
|
-
const GLIMDOWN_RENDER = Symbol('__GLIMDOWN_RENDER__');
|
|
12
|
-
const ALLOWED_LANGUAGES = ['gjs', 'hbs'];
|
|
13
|
-
function isLive(meta) {
|
|
14
|
-
return meta.includes('live');
|
|
15
|
-
}
|
|
16
|
-
function isPreview(meta) {
|
|
17
|
-
return meta.includes('preview');
|
|
18
|
-
}
|
|
19
|
-
function isBelow(meta) {
|
|
20
|
-
return meta.includes('below');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// TODO: extract and publish remark plugin
|
|
24
|
-
function liveCodeExtraction(options = {}) {
|
|
25
|
-
const {
|
|
26
|
-
copyComponent,
|
|
27
|
-
snippets,
|
|
28
|
-
demo
|
|
29
|
-
} = options;
|
|
30
|
-
let {
|
|
31
|
-
classList: snippetClasses
|
|
32
|
-
} = snippets || {};
|
|
33
|
-
let {
|
|
34
|
-
classList: demoClasses
|
|
35
|
-
} = demo || {};
|
|
36
|
-
snippetClasses ??= [];
|
|
37
|
-
demoClasses ??= [];
|
|
38
|
-
function isRelevantCode(node) {
|
|
39
|
-
if (node.type !== 'code') return false;
|
|
40
|
-
let {
|
|
41
|
-
meta
|
|
42
|
-
} = node;
|
|
43
|
-
const {
|
|
44
|
-
lang
|
|
45
|
-
} = node;
|
|
46
|
-
meta = meta?.trim();
|
|
47
|
-
if (!meta || !lang) return false;
|
|
48
|
-
if (!meta.includes('live')) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (!ALLOWED_LANGUAGES.includes(lang)) return false;
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
const copyNode = {
|
|
55
|
-
type: 'html',
|
|
56
|
-
value: copyComponent
|
|
57
|
-
};
|
|
58
|
-
function enhance(code) {
|
|
59
|
-
code.data ??= {};
|
|
60
|
-
code.data['hProperties'] ??= {};
|
|
61
|
-
// This is secret-to-us-only API, so we don't really care about the type
|
|
62
|
-
code.data['hProperties'][GLIMDOWN_PREVIEW] = true;
|
|
63
|
-
return {
|
|
64
|
-
data: {
|
|
65
|
-
hProperties: {
|
|
66
|
-
className: snippetClasses
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
type: 'div',
|
|
70
|
-
hProperties: {
|
|
71
|
-
className: snippetClasses
|
|
72
|
-
},
|
|
73
|
-
children: [code, copyNode]
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function flatReplaceAt(array, index, replacement) {
|
|
77
|
-
array.splice(index, 1, ...replacement);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// because we mutate the tree as we iterate,
|
|
81
|
-
// we need to make sure we don't loop forever
|
|
82
|
-
const seen = new Set();
|
|
83
|
-
return function transformer(tree, file) {
|
|
84
|
-
visit(tree, ['code'], function (node, index, parent) {
|
|
85
|
-
if (parent === null || parent === undefined) return;
|
|
86
|
-
if (index === null || index === undefined) return;
|
|
87
|
-
if (!isRelevantCode(node)) {
|
|
88
|
-
const enhanced = enhance(node);
|
|
89
|
-
parent.children[index] = enhanced;
|
|
90
|
-
return 'skip';
|
|
91
|
-
}
|
|
92
|
-
if (seen.has(node)) return 'skip';
|
|
93
|
-
seen.add(node);
|
|
94
|
-
const {
|
|
95
|
-
meta,
|
|
96
|
-
lang,
|
|
97
|
-
value
|
|
98
|
-
} = node;
|
|
99
|
-
if (!meta) return 'skip';
|
|
100
|
-
if (!lang) return 'skip';
|
|
101
|
-
file.data.liveCode ??= [];
|
|
102
|
-
const code = value.trim();
|
|
103
|
-
const name = nameFor(code);
|
|
104
|
-
let invocation = invocationOf(name);
|
|
105
|
-
const shadow = options.shadowComponent;
|
|
106
|
-
const wrapInShadow = shadow && !meta?.includes('no-shadow');
|
|
107
|
-
if (wrapInShadow) {
|
|
108
|
-
invocation = `<${shadow}>${invocation}</${shadow}>`;
|
|
109
|
-
}
|
|
110
|
-
const invokeNode = {
|
|
111
|
-
type: 'html',
|
|
112
|
-
data: {
|
|
113
|
-
hProperties: {
|
|
114
|
-
[GLIMDOWN_RENDER]: true
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
value: `<div class="${demoClasses}">${invocation}</div>`
|
|
118
|
-
};
|
|
119
|
-
const wrapper = enhance(node);
|
|
120
|
-
file.data.liveCode.push({
|
|
121
|
-
lang,
|
|
122
|
-
name,
|
|
123
|
-
code
|
|
124
|
-
});
|
|
125
|
-
const live = isLive(meta);
|
|
126
|
-
const preview = isPreview(meta);
|
|
127
|
-
const below = isBelow(meta);
|
|
128
|
-
if (live && preview && below) {
|
|
129
|
-
flatReplaceAt(parent.children, index, [wrapper, invokeNode]);
|
|
130
|
-
return 'skip';
|
|
131
|
-
}
|
|
132
|
-
if (live && preview) {
|
|
133
|
-
flatReplaceAt(parent.children, index, [invokeNode, wrapper]);
|
|
134
|
-
return 'skip';
|
|
135
|
-
}
|
|
136
|
-
if (live) {
|
|
137
|
-
parent.children[index] = invokeNode;
|
|
138
|
-
return 'skip';
|
|
139
|
-
}
|
|
140
|
-
parent.children[index] = wrapper;
|
|
141
|
-
return;
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function sanitizeForGlimmer(/* options */
|
|
146
|
-
) {
|
|
147
|
-
return tree => {
|
|
148
|
-
visit(tree, 'element', node => {
|
|
149
|
-
if ('tagName' in node) {
|
|
150
|
-
if (!['pre', 'code'].includes(node.tagName)) return;
|
|
151
|
-
visit(node, 'text', textNode => {
|
|
152
|
-
if ('value' in textNode && textNode.value) {
|
|
153
|
-
textNode.value = textNode.value.replace(/{{/g, '\\{{');
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return 'skip';
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function buildCompiler(options) {
|
|
162
|
-
let compiler = unified().use(remarkParse).use(remarkGfm);
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* If this were "use"d after `remarkRehype`,
|
|
166
|
-
* remark is gone, and folks would need to work with rehype trees
|
|
167
|
-
*/
|
|
168
|
-
if (options.remarkPlugins) {
|
|
169
|
-
options.remarkPlugins.forEach(plugin => {
|
|
170
|
-
// Arrays are how plugins are passed options (for some reason?)
|
|
171
|
-
// why not just invoke the the function?
|
|
172
|
-
const p = Array.isArray(plugin) ? plugin : [plugin];
|
|
173
|
-
compiler = compiler.use(...p);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// TODO: we only want to do this when we have pre > code.
|
|
178
|
-
// code can exist inline.
|
|
179
|
-
compiler = compiler.use(liveCodeExtraction, {
|
|
180
|
-
snippets: {
|
|
181
|
-
classList: ['glimdown-snippet', 'relative']
|
|
182
|
-
},
|
|
183
|
-
demo: {
|
|
184
|
-
classList: ['glimdown-render']
|
|
185
|
-
},
|
|
186
|
-
copyComponent: options?.CopyComponent,
|
|
187
|
-
shadowComponent: options?.ShadowComponent
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
|
|
191
|
-
// remark rehype is needed to convert markdown to HTML
|
|
192
|
-
// However, it also changes all the nodes, so we need another pass
|
|
193
|
-
// to make sure our Glimmer-aware nodes are in tact
|
|
194
|
-
compiler = compiler.use(remarkRehype, {
|
|
195
|
-
allowDangerousHtml: true
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Convert invocables to raw format, so Glimmer can invoke them
|
|
199
|
-
compiler = compiler.use(() => tree => {
|
|
200
|
-
visit(tree, function (node) {
|
|
201
|
-
// We rely on an implicit transformation of data.hProperties => properties
|
|
202
|
-
const properties = node.properties;
|
|
203
|
-
if (properties?.[GLIMDOWN_PREVIEW]) {
|
|
204
|
-
return 'skip';
|
|
205
|
-
}
|
|
206
|
-
if (node.type === 'element' || 'tagName' in node && node.tagName === 'code') {
|
|
207
|
-
if (properties?.[GLIMDOWN_RENDER]) {
|
|
208
|
-
node.type = 'glimmer_raw';
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
return 'skip';
|
|
212
|
-
}
|
|
213
|
-
if (node.type === 'text' || node.type === 'raw') {
|
|
214
|
-
// definitively not the better way, but this is supposed to detect "glimmer" nodes
|
|
215
|
-
if ('value' in node && typeof node.value === 'string' && node.value.match(/<\/?[_A-Z:0-9].*>/g)) {
|
|
216
|
-
node.type = 'glimmer_raw';
|
|
217
|
-
}
|
|
218
|
-
node.type = 'glimmer_raw';
|
|
219
|
-
return 'skip';
|
|
220
|
-
}
|
|
221
|
-
return;
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
if (options.rehypePlugins) {
|
|
225
|
-
options.rehypePlugins.forEach(plugin => {
|
|
226
|
-
// Arrays are how plugins are passed options (for some reason?)
|
|
227
|
-
// why not just invoke the the function?
|
|
228
|
-
const p = Array.isArray(plugin) ? plugin : [plugin];
|
|
229
|
-
compiler = compiler.use(...p);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
compiler = compiler.use(rehypeRaw, {
|
|
233
|
-
passThrough: ['glimmer_raw', 'raw']
|
|
234
|
-
}).use(() => tree => {
|
|
235
|
-
visit(tree, 'glimmer_raw', node => {
|
|
236
|
-
node.type = 'raw';
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
compiler = compiler.use(sanitizeForGlimmer);
|
|
240
|
-
|
|
241
|
-
// Finally convert to string! oofta!
|
|
242
|
-
compiler = compiler.use(rehypeStringify, {
|
|
243
|
-
collapseEmptyAttributes: true,
|
|
244
|
-
closeSelfClosing: true,
|
|
245
|
-
allowParseErrors: true,
|
|
246
|
-
allowDangerousCharacters: true,
|
|
247
|
-
allowDangerousHtml: true
|
|
248
|
-
});
|
|
249
|
-
return compiler;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* @internal not under semver
|
|
253
|
-
*/
|
|
254
|
-
async function parseMarkdown(input, options = {}) {
|
|
255
|
-
const markdownCompiler = buildCompiler(options);
|
|
256
|
-
const processed = await markdownCompiler.process(input);
|
|
257
|
-
const liveCode = processed.data.liveCode || [];
|
|
258
|
-
const templateOnly = processed.toString();
|
|
259
|
-
return {
|
|
260
|
-
templateOnlyGlimdown: templateOnly,
|
|
261
|
-
blocks: liveCode
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export { parseMarkdown };
|
|
266
|
-
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sources":["../../../src/compile/formats/markdown.ts"],"sourcesContent":["import rehypeRaw from 'rehype-raw';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { invocationOf, nameFor } from '../utils.ts';\n\nimport type { UnifiedPlugin } from '../types.ts';\nimport type { Node } from 'hast';\nimport type { Code, Text } from 'mdast';\nimport type { Parent } from 'unist';\nimport type { VFile } from 'vfile';\n\nexport interface ExtractedCode {\n name: string;\n code: string;\n lang: string;\n}\n\nexport interface LiveCodeExtraction {\n templateOnlyGlimdown: string;\n blocks: ExtractedCode[];\n}\ntype LiveData = {\n liveCode?: ExtractedCode[];\n};\ntype VFileWithMeta = VFile & {\n data: LiveData;\n};\n\ninterface Options {\n snippets?: {\n classList?: string[];\n };\n demo?: {\n classList?: string[];\n };\n copyComponent?: string;\n shadowComponent?: string;\n}\n\nconst GLIMDOWN_PREVIEW = Symbol('__GLIMDOWN_PREVIEW__');\nconst GLIMDOWN_RENDER = Symbol('__GLIMDOWN_RENDER__');\nconst ALLOWED_LANGUAGES = ['gjs', 'hbs'] as const;\n\ntype AllowedLanguage = (typeof ALLOWED_LANGUAGES)[number];\ntype RelevantCode = Omit<Code, 'lang'> & { lang: AllowedLanguage };\n\nfunction isLive(meta: string) {\n return meta.includes('live');\n}\n\nfunction isPreview(meta: string) {\n return meta.includes('preview');\n}\n\nfunction isBelow(meta: string) {\n return meta.includes('below');\n}\n\n// TODO: extract and publish remark plugin\nfunction liveCodeExtraction(options: Options = {}) {\n const { copyComponent, snippets, demo } = options;\n let { classList: snippetClasses } = snippets || {};\n let { classList: demoClasses } = demo || {};\n\n snippetClasses ??= [];\n demoClasses ??= [];\n\n function isRelevantCode(node: Code): node is RelevantCode {\n if (node.type !== 'code') return false;\n\n let { meta } = node;\n const { lang } = node;\n\n meta = meta?.trim();\n\n if (!meta || !lang) return false;\n\n if (!meta.includes('live')) {\n return false;\n }\n\n if (!(ALLOWED_LANGUAGES as unknown as string[]).includes(lang)) return false;\n\n return true;\n }\n\n const copyNode = {\n type: 'html',\n value: copyComponent,\n };\n\n function enhance(code: Code) {\n code.data ??= {};\n (code.data as any)['hProperties'] ??= {};\n // This is secret-to-us-only API, so we don't really care about the type\n (code.data as any)['hProperties'][GLIMDOWN_PREVIEW] = true;\n\n return {\n data: {\n hProperties: { className: snippetClasses },\n },\n type: 'div',\n hProperties: { className: snippetClasses },\n children: [code, copyNode],\n };\n }\n\n function flatReplaceAt<T>(array: T[], index: number, replacement: T[]) {\n array.splice(index, 1, ...replacement);\n }\n\n // because we mutate the tree as we iterate,\n // we need to make sure we don't loop forever\n const seen = new Set();\n\n return function transformer(tree: Parent, file: VFileWithMeta) {\n visit(tree, ['code'], function (node, index, parent) {\n if (parent === null || parent === undefined) return;\n if (index === null || index === undefined) return;\n\n if (!isRelevantCode(node as Code)) {\n const enhanced = enhance(node as Code);\n\n parent.children[index] = enhanced;\n\n return 'skip';\n }\n\n if (seen.has(node)) return 'skip';\n\n seen.add(node);\n\n const { meta, lang, value } = node as Code;\n\n if (!meta) return 'skip';\n if (!lang) return 'skip';\n\n file.data.liveCode ??= [];\n\n const code = value.trim();\n const name = nameFor(code);\n let invocation = invocationOf(name);\n\n const shadow = options.shadowComponent;\n\n const wrapInShadow = shadow && !meta?.includes('no-shadow');\n\n if (wrapInShadow) {\n invocation = `<${shadow}>${invocation}</${shadow}>`;\n }\n\n const invokeNode = {\n type: 'html',\n data: {\n hProperties: { [GLIMDOWN_RENDER]: true },\n },\n value: `<div class=\"${demoClasses}\">${invocation}</div>`,\n };\n\n const wrapper = enhance(node as Code);\n\n file.data.liveCode.push({\n lang,\n name,\n code,\n });\n\n const live = isLive(meta);\n const preview = isPreview(meta);\n const below = isBelow(meta);\n\n if (live && preview && below) {\n flatReplaceAt(parent.children, index, [wrapper, invokeNode]);\n\n return 'skip';\n }\n\n if (live && preview) {\n flatReplaceAt(parent.children, index, [invokeNode, wrapper]);\n\n return 'skip';\n }\n\n if (live) {\n parent.children[index] = invokeNode;\n\n return 'skip';\n }\n\n parent.children[index] = wrapper;\n\n return;\n });\n };\n}\n\nfunction sanitizeForGlimmer(/* options */) {\n return (tree: Parent) => {\n visit(tree, 'element', (node: Parent) => {\n if ('tagName' in node) {\n if (!['pre', 'code'].includes(node.tagName as string)) return;\n\n visit(node, 'text', (textNode: Text) => {\n if ('value' in textNode && textNode.value) {\n textNode.value = textNode.value.replace(/{{/g, '\\\\{{');\n }\n });\n\n return 'skip';\n }\n });\n };\n}\n\nfunction buildCompiler(options: ParseMarkdownOptions) {\n let compiler = unified().use(remarkParse).use(remarkGfm);\n\n /**\n * If this were \"use\"d after `remarkRehype`,\n * remark is gone, and folks would need to work with rehype trees\n */\n if (options.remarkPlugins) {\n options.remarkPlugins.forEach((plugin) => {\n // Arrays are how plugins are passed options (for some reason?)\n // why not just invoke the the function?\n const p = Array.isArray(plugin) ? plugin : [plugin];\n\n compiler = compiler.use(...(p as [any]));\n });\n }\n\n // TODO: we only want to do this when we have pre > code.\n // code can exist inline.\n compiler = compiler.use(liveCodeExtraction, {\n snippets: {\n classList: ['glimdown-snippet', 'relative'],\n },\n demo: {\n classList: ['glimdown-render'],\n },\n copyComponent: options?.CopyComponent,\n shadowComponent: options?.ShadowComponent,\n });\n\n // .use(() => (tree) => visit(tree, (node) => console.log('i', node)))\n // remark rehype is needed to convert markdown to HTML\n // However, it also changes all the nodes, so we need another pass\n // to make sure our Glimmer-aware nodes are in tact\n compiler = compiler.use(remarkRehype, { allowDangerousHtml: true });\n\n // Convert invocables to raw format, so Glimmer can invoke them\n compiler = compiler.use(() => (tree: Node) => {\n visit(tree, function (node) {\n // We rely on an implicit transformation of data.hProperties => properties\n const properties = (node as any).properties;\n\n if (properties?.[GLIMDOWN_PREVIEW]) {\n return 'skip';\n }\n\n if (node.type === 'element' || ('tagName' in node && node.tagName === 'code')) {\n if (properties?.[GLIMDOWN_RENDER]) {\n node.type = 'glimmer_raw';\n\n return;\n }\n\n return 'skip';\n }\n\n if (node.type === 'text' || node.type === 'raw') {\n // definitively not the better way, but this is supposed to detect \"glimmer\" nodes\n if (\n 'value' in node &&\n typeof node.value === 'string' &&\n node.value.match(/<\\/?[_A-Z:0-9].*>/g)\n ) {\n node.type = 'glimmer_raw';\n }\n\n node.type = 'glimmer_raw';\n\n return 'skip';\n }\n\n return;\n });\n });\n\n if (options.rehypePlugins) {\n options.rehypePlugins.forEach((plugin) => {\n // Arrays are how plugins are passed options (for some reason?)\n // why not just invoke the the function?\n const p = Array.isArray(plugin) ? plugin : [plugin];\n\n compiler = compiler.use(...(p as [any]));\n });\n }\n\n compiler = compiler.use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] }).use(() => (tree) => {\n visit(tree, 'glimmer_raw', (node: Node) => {\n node.type = 'raw';\n });\n });\n\n compiler = compiler.use(sanitizeForGlimmer);\n\n // Finally convert to string! oofta!\n compiler = compiler.use(rehypeStringify, {\n collapseEmptyAttributes: true,\n closeSelfClosing: true,\n allowParseErrors: true,\n allowDangerousCharacters: true,\n allowDangerousHtml: true,\n }) as any;\n\n return compiler as ReturnType<typeof unified>;\n}\n\ninterface ParseMarkdownOptions {\n CopyComponent?: string;\n ShadowComponent?: string;\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n}\n\n/**\n * @internal not under semver\n */\nexport async function parseMarkdown(\n input: string,\n options: ParseMarkdownOptions = {}\n): Promise<LiveCodeExtraction> {\n const markdownCompiler = buildCompiler(options);\n const processed = await markdownCompiler.process(input);\n const liveCode = (processed.data as LiveData).liveCode || [];\n const templateOnly = processed.toString();\n\n return { templateOnlyGlimdown: templateOnly, blocks: liveCode };\n}\n"],"names":["GLIMDOWN_PREVIEW","Symbol","GLIMDOWN_RENDER","ALLOWED_LANGUAGES","isLive","meta","includes","isPreview","isBelow","liveCodeExtraction","options","copyComponent","snippets","demo","classList","snippetClasses","demoClasses","isRelevantCode","node","type","lang","trim","copyNode","value","enhance","code","data","hProperties","className","children","flatReplaceAt","array","index","replacement","splice","seen","Set","transformer","tree","file","visit","parent","undefined","enhanced","has","add","liveCode","name","nameFor","invocation","invocationOf","shadow","shadowComponent","wrapInShadow","invokeNode","wrapper","push","live","preview","below","sanitizeForGlimmer","tagName","textNode","replace","buildCompiler","compiler","unified","use","remarkParse","remarkGfm","remarkPlugins","forEach","plugin","p","Array","isArray","CopyComponent","ShadowComponent","remarkRehype","allowDangerousHtml","properties","match","rehypePlugins","rehypeRaw","passThrough","rehypeStringify","collapseEmptyAttributes","closeSelfClosing","allowParseErrors","allowDangerousCharacters","parseMarkdown","input","markdownCompiler","processed","process","templateOnly","toString","templateOnlyGlimdown","blocks"],"mappings":";;;;;;;;;AA4CA,MAAMA,gBAAgB,GAAGC,MAAM,CAAC,sBAAsB,CAAC;AACvD,MAAMC,eAAe,GAAGD,MAAM,CAAC,qBAAqB,CAAC;AACrD,MAAME,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU;AAKjD,SAASC,MAAMA,CAACC,IAAY,EAAE;AAC5B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,MAAM,CAAC;AAC9B;AAEA,SAASC,SAASA,CAACF,IAAY,EAAE;AAC/B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC;AACjC;AAEA,SAASE,OAAOA,CAACH,IAAY,EAAE;AAC7B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,OAAO,CAAC;AAC/B;;AAEA;AACA,SAASG,kBAAkBA,CAACC,OAAgB,GAAG,EAAE,EAAE;EACjD,MAAM;IAAEC,aAAa;IAAEC,QAAQ;AAAEC,IAAAA;AAAK,GAAC,GAAGH,OAAO;EACjD,IAAI;AAAEI,IAAAA,SAAS,EAAEC;AAAe,GAAC,GAAGH,QAAQ,IAAI,EAAE;EAClD,IAAI;AAAEE,IAAAA,SAAS,EAAEE;AAAY,GAAC,GAAGH,IAAI,IAAI,EAAE;AAE3CE,EAAAA,cAAc,KAAK,EAAE;AACrBC,EAAAA,WAAW,KAAK,EAAE;EAElB,SAASC,cAAcA,CAACC,IAAU,EAAwB;AACxD,IAAA,IAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE,OAAO,KAAK;IAEtC,IAAI;AAAEd,MAAAA;AAAK,KAAC,GAAGa,IAAI;IACnB,MAAM;AAAEE,MAAAA;AAAK,KAAC,GAAGF,IAAI;AAErBb,IAAAA,IAAI,GAAGA,IAAI,EAAEgB,IAAI,EAAE;AAEnB,IAAA,IAAI,CAAChB,IAAI,IAAI,CAACe,IAAI,E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