ember-repl 3.0.0 → 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/package.json +34 -25
- 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 +7 -4
- package/src/{browser/compile/markdown-to-ember.ts → compile/formats/markdown.ts} +8 -1
- package/src/{browser/compile → compile}/formats.ts +6 -7
- 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 -172
- 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 -100
- 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,254 +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
|
-
const escapeCurlies = node => {
|
|
14
|
-
if ('value' in node && node.value) {
|
|
15
|
-
node.value = node.value.replace(/{{/g, '\\{{');
|
|
16
|
-
}
|
|
17
|
-
if ('children' in node && node.children) {
|
|
18
|
-
node.children.forEach(child => escapeCurlies(child));
|
|
19
|
-
}
|
|
20
|
-
if (!node.data) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if ('hChildren' in node.data && Array.isArray(node.data['hChildren'])) {
|
|
24
|
-
node.data['hChildren'].forEach(escapeCurlies);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function isLive(meta) {
|
|
29
|
-
return meta.includes('live');
|
|
30
|
-
}
|
|
31
|
-
function isPreview(meta) {
|
|
32
|
-
return meta.includes('preview');
|
|
33
|
-
}
|
|
34
|
-
function isBelow(meta) {
|
|
35
|
-
return meta.includes('below');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// TODO: extract and publish remark plugin
|
|
39
|
-
function liveCodeExtraction(options = {}) {
|
|
40
|
-
let {
|
|
41
|
-
copyComponent,
|
|
42
|
-
snippets,
|
|
43
|
-
demo
|
|
44
|
-
} = options;
|
|
45
|
-
let {
|
|
46
|
-
classList: snippetClasses
|
|
47
|
-
} = snippets || {};
|
|
48
|
-
let {
|
|
49
|
-
classList: demoClasses
|
|
50
|
-
} = demo || {};
|
|
51
|
-
snippetClasses ??= [];
|
|
52
|
-
demoClasses ??= [];
|
|
53
|
-
function isRelevantCode(node) {
|
|
54
|
-
if (node.type !== 'code') return false;
|
|
55
|
-
let {
|
|
56
|
-
meta,
|
|
57
|
-
lang
|
|
58
|
-
} = node;
|
|
59
|
-
meta = meta?.trim();
|
|
60
|
-
if (!meta || !lang) return false;
|
|
61
|
-
if (!meta.includes('live')) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (!ALLOWED_LANGUAGES.includes(lang)) return false;
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
let copyNode = {
|
|
68
|
-
type: 'html',
|
|
69
|
-
value: copyComponent
|
|
70
|
-
};
|
|
71
|
-
function enhance(code) {
|
|
72
|
-
code.data ??= {};
|
|
73
|
-
code.data['hProperties'] ??= {};
|
|
74
|
-
// This is secret-to-us-only API, so we don't really care about the type
|
|
75
|
-
code.data['hProperties'][GLIMDOWN_PREVIEW] = true;
|
|
76
|
-
return {
|
|
77
|
-
data: {
|
|
78
|
-
hProperties: {
|
|
79
|
-
className: snippetClasses
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
type: 'div',
|
|
83
|
-
hProperties: {
|
|
84
|
-
className: snippetClasses
|
|
85
|
-
},
|
|
86
|
-
children: [code, copyNode]
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function flatReplaceAt(array, index, replacement) {
|
|
90
|
-
array.splice(index, 1, ...replacement);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// because we mutate the tree as we iterate,
|
|
94
|
-
// we need to make sure we don't loop forever
|
|
95
|
-
const seen = new Set();
|
|
96
|
-
return function transformer(tree, file) {
|
|
97
|
-
visit(tree, ['code'], function (node, index, parent) {
|
|
98
|
-
if (parent === null || parent === undefined) return;
|
|
99
|
-
if (index === null || index === undefined) return;
|
|
100
|
-
if (!isRelevantCode(node)) {
|
|
101
|
-
let enhanced = enhance(node);
|
|
102
|
-
parent.children[index] = enhanced;
|
|
103
|
-
return 'skip';
|
|
104
|
-
}
|
|
105
|
-
if (seen.has(node)) return 'skip';
|
|
106
|
-
seen.add(node);
|
|
107
|
-
let {
|
|
108
|
-
meta,
|
|
109
|
-
lang,
|
|
110
|
-
value
|
|
111
|
-
} = node;
|
|
112
|
-
if (!meta) return 'skip';
|
|
113
|
-
if (!lang) return 'skip';
|
|
114
|
-
file.data.liveCode ??= [];
|
|
115
|
-
let code = value.trim();
|
|
116
|
-
let name = nameFor(code);
|
|
117
|
-
let invocation = invocationOf(name);
|
|
118
|
-
let shadow = options.shadowComponent;
|
|
119
|
-
let wrapInShadow = shadow && !meta?.includes('no-shadow');
|
|
120
|
-
if (wrapInShadow) {
|
|
121
|
-
invocation = `<${shadow}>${invocation}</${shadow}>`;
|
|
122
|
-
}
|
|
123
|
-
let invokeNode = {
|
|
124
|
-
type: 'html',
|
|
125
|
-
data: {
|
|
126
|
-
hProperties: {
|
|
127
|
-
[GLIMDOWN_RENDER]: true
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
value: `<div class="${demoClasses}">${invocation}</div>`
|
|
131
|
-
};
|
|
132
|
-
let wrapper = enhance(node);
|
|
133
|
-
file.data.liveCode.push({
|
|
134
|
-
lang,
|
|
135
|
-
name,
|
|
136
|
-
code
|
|
137
|
-
});
|
|
138
|
-
let live = isLive(meta);
|
|
139
|
-
let preview = isPreview(meta);
|
|
140
|
-
let below = isBelow(meta);
|
|
141
|
-
if (live && preview && below) {
|
|
142
|
-
flatReplaceAt(parent.children, index, [wrapper, invokeNode]);
|
|
143
|
-
return 'skip';
|
|
144
|
-
}
|
|
145
|
-
if (live && preview) {
|
|
146
|
-
flatReplaceAt(parent.children, index, [invokeNode, wrapper]);
|
|
147
|
-
return 'skip';
|
|
148
|
-
}
|
|
149
|
-
if (live) {
|
|
150
|
-
parent.children[index] = invokeNode;
|
|
151
|
-
return 'skip';
|
|
152
|
-
}
|
|
153
|
-
parent.children[index] = wrapper;
|
|
154
|
-
return;
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function buildCompiler(options) {
|
|
159
|
-
let compiler = unified().use(remarkParse).use(remarkGfm);
|
|
160
|
-
|
|
161
|
-
// TODO: we only want to do this when we have pre > code.
|
|
162
|
-
// code can exist inline.
|
|
163
|
-
compiler = compiler.use(liveCodeExtraction, {
|
|
164
|
-
snippets: {
|
|
165
|
-
classList: ['glimdown-snippet', 'relative']
|
|
166
|
-
},
|
|
167
|
-
demo: {
|
|
168
|
-
classList: ['glimdown-render']
|
|
169
|
-
},
|
|
170
|
-
copyComponent: options?.CopyComponent,
|
|
171
|
-
shadowComponent: options?.ShadowComponent
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* If this were "use"d after `remarkRehype`,
|
|
176
|
-
* remark is gone, and folks would need to work with rehype trees
|
|
177
|
-
*/
|
|
178
|
-
if (options.remarkPlugins) {
|
|
179
|
-
options.remarkPlugins.forEach(plugin => {
|
|
180
|
-
compiler = compiler.use(plugin);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
|
|
185
|
-
// remark rehype is needed to convert markdown to HTML
|
|
186
|
-
// However, it also changes all the nodes, so we need another pass
|
|
187
|
-
// to make sure our Glimmer-aware nodes are in tact
|
|
188
|
-
compiler = compiler.use(remarkRehype, {
|
|
189
|
-
allowDangerousHtml: true
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// Convert invocables to raw format, so Glimmer can invoke them
|
|
193
|
-
compiler = compiler.use(() => tree => {
|
|
194
|
-
visit(tree, function (node) {
|
|
195
|
-
// We rely on an implicit transformation of data.hProperties => properties
|
|
196
|
-
let properties = node.properties;
|
|
197
|
-
if (properties?.[GLIMDOWN_PREVIEW]) {
|
|
198
|
-
// Have to sanitize anything Glimmer could try to render
|
|
199
|
-
escapeCurlies(node);
|
|
200
|
-
return 'skip';
|
|
201
|
-
}
|
|
202
|
-
if (node.type === 'element' || 'tagName' in node && node.tagName === 'code') {
|
|
203
|
-
if (properties?.[GLIMDOWN_RENDER]) {
|
|
204
|
-
node.type = 'glimmer_raw';
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
escapeCurlies(node);
|
|
208
|
-
return 'skip';
|
|
209
|
-
}
|
|
210
|
-
if (node.type === 'text' || node.type === 'raw') {
|
|
211
|
-
// definitively not the better way, but this is supposed to detect "glimmer" nodes
|
|
212
|
-
if ('value' in node && typeof node.value === 'string' && node.value.match(/<\/?[_A-Z:0-9].*>/g)) {
|
|
213
|
-
node.type = 'glimmer_raw';
|
|
214
|
-
}
|
|
215
|
-
node.type = 'glimmer_raw';
|
|
216
|
-
return 'skip';
|
|
217
|
-
}
|
|
218
|
-
return;
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
compiler = compiler.use(rehypeRaw, {
|
|
222
|
-
passThrough: ['glimmer_raw', 'raw']
|
|
223
|
-
}).use(() => tree => {
|
|
224
|
-
visit(tree, 'glimmer_raw', node => {
|
|
225
|
-
node.type = 'raw';
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
// Finally convert to string! oofta!
|
|
230
|
-
compiler = compiler.use(rehypeStringify, {
|
|
231
|
-
collapseEmptyAttributes: true,
|
|
232
|
-
closeSelfClosing: true,
|
|
233
|
-
allowParseErrors: true,
|
|
234
|
-
allowDangerousCharacters: true,
|
|
235
|
-
allowDangerousHtml: true
|
|
236
|
-
});
|
|
237
|
-
return compiler;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* @internal not under semver
|
|
241
|
-
*/
|
|
242
|
-
async function parseMarkdown(input, options = {}) {
|
|
243
|
-
let markdownCompiler = buildCompiler(options);
|
|
244
|
-
let processed = await markdownCompiler.process(input);
|
|
245
|
-
let liveCode = processed.data.liveCode || [];
|
|
246
|
-
let templateOnly = processed.toString();
|
|
247
|
-
return {
|
|
248
|
-
templateOnlyGlimdown: templateOnly,
|
|
249
|
-
blocks: liveCode
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export { parseMarkdown };
|
|
254
|
-
//# sourceMappingURL=markdown-to-ember.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-to-ember.js","sources":["../../../src/browser/compile/markdown-to-ember.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\nconst escapeCurlies = (node: Text | Parent) => {\n if ('value' in node && node.value) {\n node.value = node.value.replace(/{{/g, '\\\\{{');\n }\n\n if ('children' in node && node.children) {\n node.children.forEach((child) => escapeCurlies(child as Parent));\n }\n\n if (!node.data) {\n return;\n }\n\n if ('hChildren' in node.data && Array.isArray(node.data['hChildren'])) {\n node.data['hChildren'].forEach(escapeCurlies);\n\n return;\n }\n};\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 let { 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, 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 let 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 let 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 let { meta, lang, value } = node as Code;\n\n if (!meta) return 'skip';\n if (!lang) return 'skip';\n\n file.data.liveCode ??= [];\n\n let code = value.trim();\n let name = nameFor(code);\n let invocation = invocationOf(name);\n\n let shadow = options.shadowComponent;\n\n let wrapInShadow = shadow && !meta?.includes('no-shadow');\n\n if (wrapInShadow) {\n invocation = `<${shadow}>${invocation}</${shadow}>`;\n }\n\n let invokeNode = {\n type: 'html',\n data: {\n hProperties: { [GLIMDOWN_RENDER]: true },\n },\n value: `<div class=\"${demoClasses}\">${invocation}</div>`,\n };\n\n let wrapper = enhance(node as Code);\n\n file.data.liveCode.push({\n lang,\n name,\n code,\n });\n\n let live = isLive(meta);\n let preview = isPreview(meta);\n let 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 buildCompiler(options: ParseMarkdownOptions) {\n let compiler = unified().use(remarkParse).use(remarkGfm);\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 /**\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 compiler = compiler.use(plugin) as any;\n });\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 let properties = (node as any).properties;\n\n if (properties?.[GLIMDOWN_PREVIEW]) {\n // Have to sanitize anything Glimmer could try to render\n escapeCurlies(node as Parent);\n\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 escapeCurlies(node as Parent);\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 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 // 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}\n\n/**\n * @internal not under semver\n */\nexport async function parseMarkdown(\n input: string,\n options: ParseMarkdownOptions = {}\n): Promise<LiveCodeExtraction> {\n let markdownCompiler = buildCompiler(options);\n let processed = await markdownCompiler.process(input);\n let liveCode = (processed.data as LiveData).liveCode || [];\n let templateOnly = processed.toString();\n\n return { templateOnlyGlimdown: templateOnly, blocks: liveCode };\n}\n"],"names":["GLIMDOWN_PREVIEW","Symbol","GLIMDOWN_RENDER","ALLOWED_LANGUAGES","escapeCurlies","node","value","replace","children","forEach","child","data","Array","isArray","isLive","meta","includes","isPreview","isBelow","liveCodeExtraction","options","copyComponent","snippets","demo","classList","snippetClasses","demoClasses","isRelevantCode","type","lang","trim","copyNode","enhance","code","hProperties","className","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","buildCompiler","compiler","unified","use","remarkParse","remarkGfm","CopyComponent","ShadowComponent","remarkPlugins","plugin","remarkRehype","allowDangerousHtml","properties","tagName","match","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,CAAA;AACvD,MAAMC,eAAe,GAAGD,MAAM,CAAC,qBAAqB,CAAC,CAAA;AACrD,MAAME,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAA;AAKjD,MAAMC,aAAa,GAAIC,IAAmB,IAAK;AAC7C,EAAA,IAAI,OAAO,IAAIA,IAAI,IAAIA,IAAI,CAACC,KAAK,EAAE;AACjCD,IAAAA,IAAI,CAACC,KAAK,GAAGD,IAAI,CAACC,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAChD,GAAA;AAEA,EAAA,IAAI,UAAU,IAAIF,IAAI,IAAIA,IAAI,CAACG,QAAQ,EAAE;IACvCH,IAAI,CAACG,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AA,MAAM,EAAE5C,QAAAA;GAAU,CAAA;AACjE;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { preprocess, transform } from '../gjs.js';
|
|
2
|
-
import { modules } from '../known-modules.js';
|
|
3
|
-
import { nameFor } from '../utils.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
|
-
|
|
18
|
-
// NOTE: we cannot `eval` ESM
|
|
19
|
-
compiled = proxyToSkypack(compiled, extraModules);
|
|
20
|
-
component = await evalSnippet(compiled);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
error = e;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
name,
|
|
26
|
-
component,
|
|
27
|
-
error
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function proxyToSkypack(code, extraModules) {
|
|
31
|
-
let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];
|
|
32
|
-
let origin = location.origin;
|
|
33
|
-
let result = code.replaceAll(/from ('|")([^"']+)('|")/g, (_, __, modulePath) => {
|
|
34
|
-
if (knownModules.includes(modulePath)) {
|
|
35
|
-
return `from '${origin}/${modulePath}'`;
|
|
36
|
-
}
|
|
37
|
-
return `from 'https://cdn.skypack.dev/${modulePath}'`;
|
|
38
|
-
});
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
async function evalSnippet(code) {
|
|
42
|
-
let encodedJs = encodeURIComponent(code);
|
|
43
|
-
let result = await import( /* webpackIgnore: true */`data:text/javascript;charset=utf-8,${encodedJs}`);
|
|
44
|
-
if (!result.default) {
|
|
45
|
-
throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
async function compileGJS({
|
|
50
|
-
code: input,
|
|
51
|
-
name
|
|
52
|
-
}) {
|
|
53
|
-
let preprocessed = await preprocess(input, name);
|
|
54
|
-
let result = await transform(preprocessed, name, {
|
|
55
|
-
modules: false
|
|
56
|
-
});
|
|
57
|
-
if (!result) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
let {
|
|
61
|
-
code
|
|
62
|
-
} = result;
|
|
63
|
-
return code;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { compileJS, proxyToSkypack };
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/browser/esm/index.ts"],"sourcesContent":["import { preprocess, transform } from '../gjs.ts';\nimport { modules } from '../known-modules.ts';\nimport { nameFor } from '../utils.ts';\n\nimport type { CompileResult, ExtraModules } from '../types.ts';\nimport type Component from '@glimmer/component';\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 // NOTE: we cannot `eval` ESM\n compiled = proxyToSkypack(compiled, extraModules);\n component = (await evalSnippet(compiled)) as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nexport function proxyToSkypack(code: string, extraModules?: ExtraModules) {\n let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];\n let origin = location.origin;\n\n let result = code.replaceAll(/from ('|\")([^\"']+)('|\")/g, (_, __, modulePath) => {\n if (knownModules.includes(modulePath)) {\n return `from '${origin}/${modulePath}'`;\n }\n\n return `from 'https://cdn.skypack.dev/${modulePath}'`;\n });\n\n return result;\n}\n\nasync function evalSnippet(code: string) {\n let encodedJs = encodeURIComponent(code);\n let result = await import(\n /* webpackIgnore: true */ `data:text/javascript;charset=utf-8,${encodedJs}`\n );\n\n if (!result.default) {\n throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);\n }\n\n return result as {\n default: Component;\n services?: { [key: string]: unknown };\n };\n}\n\nasync function compileGJS({ code: input, name }: Info) {\n let preprocessed = await preprocess(input, name);\n let result = await transform(preprocessed, name, {\n modules: false,\n });\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","proxyToSkypack","evalSnippet","e","knownModules","Object","keys","modules","origin","location","result","replaceAll","_","__","modulePath","includes","encodedJs","encodeURIComponent","default","input","preprocessed","preprocess","transform"],"mappings":";;;;AAaO,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;;AAEA;AACAF,IAAAA,QAAQ,GAAGG,cAAc,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAAA;AACjDG,IAAAA,SAAS,GAAI,MAAMM,WAAW,CAACJ,QAAQ,CAA8B,CAA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,EAAA,OAAOA,MAAM,CAAA;AAIf,CAAA;AAEA,eAAeX,UAAUA,CAAC;AAAEP,EAAAA,IAAI,EAAE2B,KAAK;AAAEzB,EAAAA,IAAAA;AAAW,CAAC,EAAE;EACrD,IAAI0B,YAAY,GAAG,MAAMC,UAAU,CAACF,KAAK,EAAEzB,IAAI,CAAC,CAAA;EAChD,IAAIgB,MAAM,GAAG,MAAMY,SAAS,CAACF,YAAY,EAAE1B,IAAI,EAAE;AAC/Ca,IAAAA,OAAO,EAAE,KAAA;AACX,GAAC,CAAC,CAAA;EAEF,IAAI,CAACG,MAAM,EAAE;AACX,IAAA,OAAA;AACF,GAAA;EAEA,IAAI;AAAElB,IAAAA,IAAAA;AAAK,GAAC,GAAGkB,MAAM,CAAA;AAErB,EAAA,OAAOlB,IAAI,CAAA;AACb;;;;"}
|
package/dist/browser/gjs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { importSync } from '@embroider/macros';
|
|
2
|
-
import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
|
|
3
|
-
|
|
4
|
-
const compiler = importSync('ember-source/dist/ember-template-compiler.js');
|
|
5
|
-
let processor;
|
|
6
|
-
let fetchingPromise;
|
|
7
|
-
async function preprocess(input, name) {
|
|
8
|
-
if (!fetchingPromise) {
|
|
9
|
-
fetchingPromise = import('content-tag');
|
|
10
|
-
}
|
|
11
|
-
if (!processor) {
|
|
12
|
-
let {
|
|
13
|
-
Preprocessor
|
|
14
|
-
} = await fetchingPromise;
|
|
15
|
-
processor = new Preprocessor();
|
|
16
|
-
}
|
|
17
|
-
return processor.process(input, `${name}.js`);
|
|
18
|
-
}
|
|
19
|
-
async function transform(intermediate, name, options = {}) {
|
|
20
|
-
let babel = await import('@babel/standalone');
|
|
21
|
-
return babel.transform(intermediate, {
|
|
22
|
-
filename: `${name}.js`,
|
|
23
|
-
plugins: [
|
|
24
|
-
// [babelPluginIntermediateGJS],
|
|
25
|
-
[babelPluginEmberTemplateCompilation, {
|
|
26
|
-
compiler
|
|
27
|
-
}], [babel.availablePlugins['proposal-decorators'], {
|
|
28
|
-
legacy: true
|
|
29
|
-
}], [babel.availablePlugins['proposal-class-properties']]],
|
|
30
|
-
presets: [[babel.availablePresets['env'], {
|
|
31
|
-
// false -- keeps ES Modules
|
|
32
|
-
modules: 'cjs',
|
|
33
|
-
targets: {
|
|
34
|
-
esmodules: true
|
|
35
|
-
},
|
|
36
|
-
forceAllTransforms: false,
|
|
37
|
-
...options
|
|
38
|
-
}]]
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { preprocess, transform };
|
|
43
|
-
//# sourceMappingURL=gjs.js.map
|
package/dist/browser/gjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gjs.js","sources":["../../src/browser/gjs.ts"],"sourcesContent":["import { importSync } from '@embroider/macros';\n\nimport babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\n\nimport type { Babel } from './types.ts';\n\nconst compiler = importSync('ember-source/dist/ember-template-compiler.js');\n\nlet processor: any;\nlet fetchingPromise: Promise<any>;\n\nexport async function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = import('content-tag');\n }\n\n if (!processor) {\n let { Preprocessor } = await fetchingPromise;\n\n processor = new Preprocessor();\n }\n\n return processor.process(input, `${name}.js`);\n}\n\nexport async function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n let babel = (await import('@babel/standalone')) as Babel;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n // [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compiler","importSync","processor","fetchingPromise","preprocess","input","name","Preprocessor","process","transform","intermediate","options","babel","filename","plugins","babelPluginEmberTemplateCompilation","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;AAMA,MAAMA,QAAQ,GAAGC,UAAU,CAAC,8CAA8C,CAAC,CAAA;AAE3E,IAAIC,SAAc,CAAA;AAClB,IAAIC,eAA6B,CAAA;AAE1B,eAAeC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAmB;EAC7E,IAAI,CAACH,eAAe,EAAE;AACpBA,IAAAA,eAAe,GAAG,OAAO,aAAa,CAAC,CAAA;AACzC,GAAA;EAEA,IAAI,CAACD,SAAS,EAAE;IACd,IAAI;AAAEK,MAAAA,YAAAA;KAAc,GAAG,MAAMJ,eAAe,CAAA;AAE5CD,IAAAA,SAAS,GAAG,IAAIK,YAAY,EAAE,CAAA;AAChC,GAAA;EAEA,OAAOL,SAAS,CAACM,OAAO,CAACH,KAAK,EAAG,CAAA,EAAEC,IAAK,CAAA,GAAA,CAAI,CAAC,CAAA;AAC/C,CAAA;AAEO,eAAeG,SAASA,CAC7BC,YAAoB,EACpBJ,IAAY,EACZK,OAAY,GAAG,EAAE,EACwB;AACzC,EAAA,IAAIC,KAAK,GAAI,MAAM,OAAO,mBAAmB,CAAW,CAAA;AAExD,EAAA,OAAOA,KAAK,CAACH,SAAS,CAACC,YAAY,EAAE;IACnCG,QAAQ,EAAG,CAAEP,EAAAA,IAAK,CAAI,GAAA,CAAA;AACtBQ,IAAAA,OAAO,EAAE;AACP;AACA,IAAA,CACEC,mCAAmC,EACnC;AACEf,MAAAA,QAAAA;KACD,CACF,EACD,CAACY,KAAK,CAACI,gBAAgB,CAAC,qBAAqB,CAAC,EAAE;AAAEC,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAC,EACjE,CAACL,KAAK,CAACI,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEN,KAAK,CAACO,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGZ,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
|
package/dist/browser/hbs.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { setComponentTemplate } from '@ember/component';
|
|
2
|
-
import _TO from '@ember/component/template-only';
|
|
3
|
-
import { array, concat, fn, get, hash } from '@ember/helper';
|
|
4
|
-
import { on } from '@ember/modifier';
|
|
5
|
-
import { createTemplateFactory } from '@ember/template-factory';
|
|
6
|
-
import { importSync } from '@embroider/macros';
|
|
7
|
-
import { nameFor } from './utils.js';
|
|
8
|
-
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
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
|
-
const {
|
|
16
|
-
precompileJSON
|
|
17
|
-
} = importSync('@glimmer/compiler');
|
|
18
|
-
const {
|
|
19
|
-
getTemplateLocals
|
|
20
|
-
} = importSync('@glimmer/syntax');
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* compile a template with an empty scope
|
|
24
|
-
* to use components, helpers, etc, you will need to compile with JS
|
|
25
|
-
*
|
|
26
|
-
* (templates alone do not have a way to import / define complex structures)
|
|
27
|
-
*/
|
|
28
|
-
function compileHBS(template, options = {}) {
|
|
29
|
-
let name = nameFor(template);
|
|
30
|
-
let component;
|
|
31
|
-
let error;
|
|
32
|
-
try {
|
|
33
|
-
component = setComponentTemplate(compileTemplate(template, {
|
|
34
|
-
moduleName: options.moduleName || name,
|
|
35
|
-
...options
|
|
36
|
-
}), _TO(options.moduleName || name));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
error = e;
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
name,
|
|
42
|
-
component,
|
|
43
|
-
error
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The reason why we can't use precompile directly is because of this:
|
|
48
|
-
* https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132
|
|
49
|
-
*
|
|
50
|
-
* Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.
|
|
51
|
-
* That JSON.stringify (and the lines after) prevent us from easily setting the scope function,
|
|
52
|
-
* which means that *everything* is undefined.
|
|
53
|
-
*/
|
|
54
|
-
function compileTemplate(source, {
|
|
55
|
-
moduleName,
|
|
56
|
-
scope = {}
|
|
57
|
-
}) {
|
|
58
|
-
let localScope = {
|
|
59
|
-
array,
|
|
60
|
-
concat,
|
|
61
|
-
fn,
|
|
62
|
-
get,
|
|
63
|
-
hash,
|
|
64
|
-
on,
|
|
65
|
-
...scope
|
|
66
|
-
};
|
|
67
|
-
let locals = getTemplateLocals(source);
|
|
68
|
-
let options = {
|
|
69
|
-
strictMode: true,
|
|
70
|
-
moduleName,
|
|
71
|
-
locals,
|
|
72
|
-
isProduction: false,
|
|
73
|
-
meta: {
|
|
74
|
-
moduleName
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// Copied from @glimmer/compiler/lib/compiler#precompile
|
|
79
|
-
let [block, usedLocals] = precompileJSON(source, options);
|
|
80
|
-
let usedScope = usedLocals.map(key => {
|
|
81
|
-
let value = localScope[key];
|
|
82
|
-
if (!value) {
|
|
83
|
-
throw new Error(`Attempt to use ${key} in compiled hbs, but it was not available in scope.`);
|
|
84
|
-
}
|
|
85
|
-
return value;
|
|
86
|
-
});
|
|
87
|
-
let blockJSON = JSON.stringify(block);
|
|
88
|
-
let templateJSONObject = {
|
|
89
|
-
id: moduleName,
|
|
90
|
-
block: blockJSON,
|
|
91
|
-
moduleName: moduleName ?? '(unknown template module)',
|
|
92
|
-
scope: () => usedScope,
|
|
93
|
-
isStrictMode: true
|
|
94
|
-
};
|
|
95
|
-
let factory = createTemplateFactory(templateJSONObject);
|
|
96
|
-
return factory;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { compileHBS };
|
|
100
|
-
//# sourceMappingURL=hbs.js.map
|
package/dist/browser/hbs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\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';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\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 let 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 let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let 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 let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => {\n let value = localScope[key];\n\n if (!value) {\n throw new Error(`Attempt to use ${key} in compiled hbs, but it was not available in scope.`);\n }\n\n return value;\n });\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","value","Error","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAeA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,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AI,EAAE;AAAEf,MAAAA,UAAAA;AAAW,KAAA;GACpB,CAAA;;AAED;EACA,IAAI,CAACgB,KAAK,EAAEC,UAAU,CAAC,GAAG7B,cAAc,CAACe,MAAM,EAAEV,OAAO,CAAC,CAAA;AAEzD,EAAA,IAAIyB,SAAS,GAAGD,UAAU,CAACE,GAAG,CAAEC,GAAW,IAAK;AAC9C,IAAA,IAAIC,KAAK,GAAGhB,UAAU,CAACe,GAAG,CAAC,CAAA;IAE3B,IAAI,CAACC,KAAK,EAAE;AACV,MAAA,MAAM,IAAIC,KAAK,CAAE,CAAiBF,eAAAA,EAAAA,GAAI,sDAAqD,CAAC,CAAA;AAC9F,KAAA;AAEA,IAAA,OAAOC,KAAK,CAAA;AACd,GAAC,CAAC,CAAA;AAEF,EAAA,IAAIE,SAAS,GAAGC,IAAI,CAACC,SAAS,CAACT,KAAK,CAAC,CAAA;AACrC,EAAA,IAAIU,kBAAkB,GAAG;AACvBC,IAAAA,EAAE,EAAE3B,UAAU;AACdgB,IAAAA,KAAK,EAAEO,SAAS;IAChBvB,UAAU,EAAEA,UAAU,IAAI,2BAA2B;IACrDI,KAAK,EAAEA,MAAMc,SAAS;AACtBU,IAAAA,YAAY,EAAE,IAAA;GACf,CAAA;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC,CAAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
|
package/dist/browser/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Compiled, compile } from './compile/index.js';
|
|
2
|
-
export { compileHBS } from './hbs.js';
|
|
3
|
-
export { compileJS } from './js.js';
|
|
4
|
-
export { modules as frameworkModules } from './known-modules.js';
|
|
5
|
-
export { invocationName, invocationOf, nameFor } from './utils.js';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/browser/js.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { compileJS as compileJS$2 } from './cjs/index.js';
|
|
2
|
-
import { compileJS as compileJS$1 } from './esm/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
7
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
8
|
-
*
|
|
9
|
-
* SEE: README for example usage
|
|
10
|
-
*
|
|
11
|
-
* @param {string} code: the code to be compiled
|
|
12
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
13
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
14
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
15
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
16
|
-
*
|
|
17
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
18
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
19
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
20
|
-
*/
|
|
21
|
-
function compileJS(code, extraModules, options) {
|
|
22
|
-
if (options?.skypack) {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
// if (!(window as any).webpackChunkDummy) {
|
|
25
|
-
// return {
|
|
26
|
-
// component: undefined,
|
|
27
|
-
// name: undefined,
|
|
28
|
-
// error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,
|
|
29
|
-
// };
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
return compileJS$1(code, extraModules);
|
|
33
|
-
}
|
|
34
|
-
return compileJS$2(code, extraModules);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { compileJS };
|
|
38
|
-
//# sourceMappingURL=js.js.map
|
package/dist/browser/js.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs/index.ts';\nimport { compileJS as compileESM } from './esm/index.ts';\n\nimport type { CompileResult, ExtraModules, Options } from './types.ts';\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 function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
|
|
@@ -1,48 +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
|
-
|
|
20
|
-
/**
|
|
21
|
-
* We need to import and hang on to these references so that they
|
|
22
|
-
* don't get optimized away during deploy
|
|
23
|
-
*/
|
|
24
|
-
const modules = {
|
|
25
|
-
'@ember/application': _application,
|
|
26
|
-
'@ember/array': _array,
|
|
27
|
-
'@ember/component': _EmberComponent,
|
|
28
|
-
'@ember/component/helper': _EmberComponentHelper,
|
|
29
|
-
'@ember/component/template-only': _TO,
|
|
30
|
-
'@ember/debug': _debug,
|
|
31
|
-
'@ember/destroyable': _destroyable,
|
|
32
|
-
'@ember/helper': _helpers,
|
|
33
|
-
'@ember/modifier': _modifier,
|
|
34
|
-
'@ember/object': _object,
|
|
35
|
-
'@ember/runloop': _runloop,
|
|
36
|
-
'@ember/service': _service,
|
|
37
|
-
'@ember/template-factory': {
|
|
38
|
-
createTemplateFactory
|
|
39
|
-
},
|
|
40
|
-
'@ember/utils': _utils,
|
|
41
|
-
'@ember/template': _template,
|
|
42
|
-
'@ember/owner': _owner,
|
|
43
|
-
'@glimmer/component': _GlimmerComponent,
|
|
44
|
-
'@glimmer/tracking': _tracking
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { modules };
|
|
48
|
-
//# sourceMappingURL=known-modules.js.map
|