ember-repl 3.0.0-beta.5 → 3.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/browser/__PRIVATE__.d.ts +2 -0
- package/declarations/browser/__PRIVATE__.d.ts.map +1 -0
- package/declarations/browser/compile/formats.d.ts +2 -0
- package/declarations/browser/compile/formats.d.ts.map +1 -1
- package/declarations/browser/compile/index.d.ts +31 -7
- package/declarations/browser/compile/index.d.ts.map +1 -1
- package/declarations/browser/compile/markdown-to-ember.d.ts +2 -0
- package/declarations/browser/compile/markdown-to-ember.d.ts.map +1 -1
- package/declarations/browser/compile/types.d.ts +2 -0
- package/declarations/browser/compile/types.d.ts.map +1 -1
- package/declarations/browser/gjs.d.ts +1 -1
- package/declarations/browser/gjs.d.ts.map +1 -1
- package/declarations/browser/known-modules.d.ts +4 -0
- package/declarations/browser/known-modules.d.ts.map +1 -1
- package/dist/browser/__PRIVATE__.js +2 -0
- package/dist/browser/__PRIVATE__.js.map +1 -0
- package/dist/browser/cjs/index.js +1 -1
- package/dist/browser/cjs/index.js.map +1 -1
- package/dist/browser/compile/formats.js +2 -1
- package/dist/browser/compile/formats.js.map +1 -1
- package/dist/browser/compile/index.js +28 -14
- package/dist/browser/compile/index.js.map +1 -1
- package/dist/browser/compile/markdown-to-ember.js +26 -8
- package/dist/browser/compile/markdown-to-ember.js.map +1 -1
- package/dist/browser/compile/types.js +1 -1
- package/dist/browser/esm/index.js +1 -1
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/gjs.js +12 -13
- package/dist/browser/gjs.js.map +1 -1
- package/dist/browser/known-modules.js +4 -4
- package/dist/browser/known-modules.js.map +1 -1
- package/package.json +59 -54
- package/src/browser/__PRIVATE__.ts +1 -0
- package/src/browser/cjs/index.ts +1 -1
- package/src/browser/compile/formats.ts +3 -0
- package/src/browser/compile/index.ts +58 -24
- package/src/browser/compile/markdown-to-ember.ts +91 -76
- package/src/browser/compile/types.ts +4 -0
- package/src/browser/esm/index.ts +1 -1
- package/src/browser/gjs.ts +13 -15
- package/src/browser/known-modules.ts +4 -2
- package/declarations/browser/eti/babel-plugin.d.ts +0 -54
- package/declarations/browser/eti/babel-plugin.d.ts.map +0 -1
- package/declarations/browser/eti/debug.d.ts +0 -2
- package/declarations/browser/eti/debug.d.ts.map +0 -1
- package/declarations/browser/eti/parse-templates.d.ts +0 -56
- package/declarations/browser/eti/parse-templates.d.ts.map +0 -1
- package/declarations/browser/eti/preprocess.d.ts +0 -58
- package/declarations/browser/eti/preprocess.d.ts.map +0 -1
- package/declarations/browser/eti/template-tag-transform.d.ts +0 -15
- package/declarations/browser/eti/template-tag-transform.d.ts.map +0 -1
- package/declarations/browser/eti/util.d.ts +0 -14
- package/declarations/browser/eti/util.d.ts.map +0 -1
- package/dist/browser/eti/babel-plugin.js +0 -95
- package/dist/browser/eti/babel-plugin.js.map +0 -1
- package/dist/browser/eti/debug.js +0 -9
- package/dist/browser/eti/debug.js.map +0 -1
- package/dist/browser/eti/parse-templates.js +0 -181
- package/dist/browser/eti/parse-templates.js.map +0 -1
- package/dist/browser/eti/preprocess.js +0 -106
- package/dist/browser/eti/preprocess.js.map +0 -1
- package/dist/browser/eti/template-tag-transform.js +0 -46
- package/dist/browser/eti/template-tag-transform.js.map +0 -1
- package/dist/browser/eti/util.js +0 -39
- package/dist/browser/eti/util.js.map +0 -1
- package/src/browser/eti/babel-plugin.ts +0 -105
- package/src/browser/eti/debug.ts +0 -7
- package/src/browser/eti/parse-templates.ts +0 -284
- package/src/browser/eti/preprocess.ts +0 -187
- package/src/browser/eti/template-tag-transform.ts +0 -100
- package/src/browser/eti/util.ts +0 -72
package/dist/browser/gjs.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { importSync } from '@embroider/macros';
|
|
2
2
|
import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
|
|
3
|
-
import
|
|
4
|
-
import { preprocessEmbeddedTemplates } from './eti/preprocess.js';
|
|
5
|
-
import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util.js';
|
|
3
|
+
import { createPreprocessor } from 'content-tag/standalone';
|
|
6
4
|
|
|
7
5
|
const compiler = importSync('ember-source/dist/ember-template-compiler.js');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
return preprocessed.output;
|
|
6
|
+
let processor;
|
|
7
|
+
let fetchingPromise;
|
|
8
|
+
async function preprocess(input, name) {
|
|
9
|
+
if (!fetchingPromise) {
|
|
10
|
+
fetchingPromise = createPreprocessor();
|
|
11
|
+
}
|
|
12
|
+
processor = await fetchingPromise;
|
|
13
|
+
return processor.process(input, `${name}.js`);
|
|
17
14
|
}
|
|
18
15
|
async function transform(intermediate, name, options = {}) {
|
|
19
16
|
let babel = await import('@babel/standalone');
|
|
20
17
|
return babel.transform(intermediate, {
|
|
21
18
|
filename: `${name}.js`,
|
|
22
|
-
plugins: [
|
|
19
|
+
plugins: [
|
|
20
|
+
// [babelPluginIntermediateGJS],
|
|
21
|
+
[babelPluginEmberTemplateCompilation, {
|
|
23
22
|
compiler
|
|
24
23
|
}], [babel.availablePlugins['proposal-decorators'], {
|
|
25
24
|
legacy: true
|
package/dist/browser/gjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\
|
|
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\nimport { createPreprocessor } from 'content-tag/standalone';\n\nlet processor;\nlet fetchingPromise: Promise<any>;\n\nexport async function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = createPreprocessor();\n }\n\n processor = await fetchingPromise;\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","createPreprocessor","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;AAI3E,IAAIC,SAAS,CAAA;AACb,IAAIC,eAA6B,CAAA;AAE1B,eAAeC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAmB;EAC7E,IAAI,CAACH,eAAe,EAAE;IACpBA,eAAe,GAAGI,kBAAkB,EAAE,CAAA;AACxC,GAAA;EAEAL,SAAS,GAAG,MAAMC,eAAe,CAAA;EAEjC,OAAOD,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;;;;"}
|
|
@@ -9,8 +9,10 @@ import * as _destroyable from '@ember/destroyable';
|
|
|
9
9
|
import * as _helpers from '@ember/helper';
|
|
10
10
|
import * as _modifier from '@ember/modifier';
|
|
11
11
|
import * as _object from '@ember/object';
|
|
12
|
+
import * as _owner from '@ember/owner';
|
|
12
13
|
import * as _runloop from '@ember/runloop';
|
|
13
14
|
import * as _service from '@ember/service';
|
|
15
|
+
import * as _template from '@ember/template';
|
|
14
16
|
import { createTemplateFactory } from '@ember/template-factory';
|
|
15
17
|
import * as _utils from '@ember/utils';
|
|
16
18
|
|
|
@@ -18,8 +20,6 @@ import * as _utils from '@ember/utils';
|
|
|
18
20
|
* We need to import and hang on to these references so that they
|
|
19
21
|
* don't get optimized away during deploy
|
|
20
22
|
*/
|
|
21
|
-
// import * as _owner from '@ember/owner';
|
|
22
|
-
|
|
23
23
|
const modules = {
|
|
24
24
|
'@ember/application': _application,
|
|
25
25
|
'@ember/array': _array,
|
|
@@ -36,8 +36,8 @@ const modules = {
|
|
|
36
36
|
createTemplateFactory
|
|
37
37
|
},
|
|
38
38
|
'@ember/utils': _utils,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
'@ember/template': _template,
|
|
40
|
+
'@ember/owner': _owner,
|
|
41
41
|
'@glimmer/component': _GlimmerComponent,
|
|
42
42
|
'@glimmer/tracking': _tracking
|
|
43
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"known-modules.js","sources":["../../src/browser/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 _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 _runloop from '@ember/runloop';\nimport * as _service from '@ember/service';\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
|
|
1
|
+
{"version":3,"file":"known-modules.js","sources":["../../src/browser/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 _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\nexport const modules = {\n '@ember/application': _application,\n '@ember/array': _array,\n '@ember/component': _EmberComponent,\n '@ember/component/template-only': _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};\n"],"names":["modules","_application","_array","_EmberComponent","_TO","_debug","_destroyable","_helpers","_modifier","_object","_runloop","_service","createTemplateFactory","_utils","_template","_owner","_GlimmerComponent","_tracking"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAqBO,MAAMA,OAAO,GAAG;AACrB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,kBAAkB,EAAEC,eAAe;AACnC,EAAA,gCAAgC,EAAEC,GAAG;AACrC,EAAA,cAAc,EAAEC,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,qBAAAA;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,SAAAA;AACvB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-repl",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.7",
|
|
4
4
|
"description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./declarations/test-support/index.d.ts",
|
|
47
47
|
"default": "./dist/test-support/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./__PRIVATE__DO_NOT_USE__": {
|
|
50
|
+
"types": "./declarations/browser/__PRIVATE__.d.ts",
|
|
51
|
+
"default": "./dist/browser/__PRIVATE__.js"
|
|
52
|
+
},
|
|
49
53
|
"./addon-main.js": "./addon-main.cjs"
|
|
50
54
|
},
|
|
51
55
|
"files": [
|
|
@@ -56,16 +60,17 @@
|
|
|
56
60
|
],
|
|
57
61
|
"dependencies": {
|
|
58
62
|
"@babel/helper-plugin-utils": "^7.22.5",
|
|
59
|
-
"@babel/standalone": "^7.
|
|
60
|
-
"@embroider/addon-shim": "1.8.
|
|
61
|
-
"@embroider/macros": "1.13.
|
|
62
|
-
"babel-import-util": "^
|
|
63
|
-
"babel-plugin-ember-template-compilation": "^2.2.
|
|
63
|
+
"@babel/standalone": "^7.23.4",
|
|
64
|
+
"@embroider/addon-shim": "1.8.7",
|
|
65
|
+
"@embroider/macros": "1.13.3",
|
|
66
|
+
"babel-import-util": "^2.0.1",
|
|
67
|
+
"babel-plugin-ember-template-compilation": "^2.2.1",
|
|
64
68
|
"broccoli-file-creator": "^2.1.1",
|
|
65
|
-
"change-case": "^
|
|
69
|
+
"change-case": "^5.2.0",
|
|
66
70
|
"common-tags": "^1.8.2",
|
|
71
|
+
"content-tag": "github:NullVoxPopuli/content-tag#browser-support-dist",
|
|
67
72
|
"line-column": "^1.0.2",
|
|
68
|
-
"magic-string": "^0.30.
|
|
73
|
+
"magic-string": "^0.30.5",
|
|
69
74
|
"mdast": "^3.0.0",
|
|
70
75
|
"parse-static-imports": "^1.1.0",
|
|
71
76
|
"rehype-raw": "^6.1.1",
|
|
@@ -75,56 +80,56 @@
|
|
|
75
80
|
"remark-rehype": "^10.1.0",
|
|
76
81
|
"unified": "^10.1.2",
|
|
77
82
|
"unist-util-visit": "^5.0.0",
|
|
78
|
-
"uuid": "^9.0.
|
|
83
|
+
"uuid": "^9.0.1",
|
|
79
84
|
"vfile": "^6.0.1"
|
|
80
85
|
},
|
|
81
86
|
"devDependencies": {
|
|
82
|
-
"@babel/core": "^7.
|
|
83
|
-
"@babel/preset-typescript": "^7.
|
|
84
|
-
"@babel/types": "^7.
|
|
85
|
-
"@ember/test-helpers": "^3.2.
|
|
86
|
-
"@ember/test-waiters": "^3.0
|
|
87
|
-
"@embroider/addon-dev": "4.1.
|
|
88
|
-
"@glimmer/compiler": "^0.
|
|
87
|
+
"@babel/core": "^7.23.3",
|
|
88
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
89
|
+
"@babel/types": "^7.23.4",
|
|
90
|
+
"@ember/test-helpers": "^3.2.1",
|
|
91
|
+
"@ember/test-waiters": "^3.1.0",
|
|
92
|
+
"@embroider/addon-dev": "4.1.2",
|
|
93
|
+
"@glimmer/compiler": "^0.85.13",
|
|
89
94
|
"@glimmer/component": "^1.1.2",
|
|
90
|
-
"@glimmer/interfaces": "^0.
|
|
91
|
-
"@glimmer/reference": "^0.
|
|
92
|
-
"@glimmer/syntax": "^0.
|
|
95
|
+
"@glimmer/interfaces": "^0.85.13",
|
|
96
|
+
"@glimmer/reference": "^0.85.13",
|
|
97
|
+
"@glimmer/syntax": "^0.85.13",
|
|
93
98
|
"@glimmer/tracking": "^1.1.2",
|
|
94
|
-
"@glimmer/util": "^0.
|
|
95
|
-
"@glint/core": "^1.1
|
|
96
|
-
"@glint/environment-ember-loose": "^1.1
|
|
97
|
-
"@glint/environment-ember-template-imports": "^1.1
|
|
98
|
-
"@glint/template": "^1.1
|
|
99
|
+
"@glimmer/util": "^0.85.13",
|
|
100
|
+
"@glint/core": "^1.2.1",
|
|
101
|
+
"@glint/environment-ember-loose": "^1.2.1",
|
|
102
|
+
"@glint/environment-ember-template-imports": "^1.2.1",
|
|
103
|
+
"@glint/template": "^1.2.1",
|
|
99
104
|
"@nullvoxpopuli/eslint-configs": "^3.2.2",
|
|
100
|
-
"@rollup/plugin-babel": "^6.0.
|
|
101
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
102
|
-
"@tsconfig/ember": "^3.0.
|
|
103
|
-
"@types/babel__core": "^7.20.
|
|
104
|
-
"@types/babel__standalone": "^7.1.
|
|
105
|
-
"@types/babel__traverse": "^7.20.
|
|
106
|
-
"@types/hast": "^3.0.
|
|
107
|
-
"@types/mdast": "^4.0.
|
|
108
|
-
"@types/unist": "^3.0.
|
|
109
|
-
"@types/uuid": "^9.0.
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
111
|
-
"@typescript-eslint/parser": "^6.
|
|
112
|
-
"concurrently": "^8.2.
|
|
113
|
-
"ember-resources": "^6.4.
|
|
114
|
-
"ember-source": "^5.
|
|
105
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
106
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
107
|
+
"@tsconfig/ember": "^3.0.2",
|
|
108
|
+
"@types/babel__core": "^7.20.4",
|
|
109
|
+
"@types/babel__standalone": "^7.1.7",
|
|
110
|
+
"@types/babel__traverse": "^7.20.4",
|
|
111
|
+
"@types/hast": "^3.0.3",
|
|
112
|
+
"@types/mdast": "^4.0.3",
|
|
113
|
+
"@types/unist": "^3.0.2",
|
|
114
|
+
"@types/uuid": "^9.0.7",
|
|
115
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
116
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
117
|
+
"concurrently": "^8.2.2",
|
|
118
|
+
"ember-resources": "^6.4.2",
|
|
119
|
+
"ember-source": "^5.4.0",
|
|
115
120
|
"ember-template-imports": "^3.4.2",
|
|
116
|
-
"ember-template-lint": "^5.
|
|
117
|
-
"eslint": "^8.
|
|
118
|
-
"eslint-plugin-ember": "^11.
|
|
121
|
+
"ember-template-lint": "^5.12.0",
|
|
122
|
+
"eslint": "^8.53.0",
|
|
123
|
+
"eslint-plugin-ember": "^11.11.1",
|
|
119
124
|
"eslint-plugin-node": "^11.1.0",
|
|
120
|
-
"eslint-plugin-prettier": "^5.0.
|
|
121
|
-
"prettier": "^3.0.
|
|
122
|
-
"prettier-plugin-ember-template-tag": "^1.0
|
|
123
|
-
"publint": "^0.2.
|
|
124
|
-
"rollup": "~
|
|
125
|
-
"rollup-plugin-copy": "^3.
|
|
125
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
126
|
+
"prettier": "^3.0.3",
|
|
127
|
+
"prettier-plugin-ember-template-tag": "^1.1.0",
|
|
128
|
+
"publint": "^0.2.5",
|
|
129
|
+
"rollup": "~4.5.0",
|
|
130
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
126
131
|
"rollup-plugin-glimmer-template-tag": "^0.4.1",
|
|
127
|
-
"typescript": "^5.
|
|
132
|
+
"typescript": "^5.2.2",
|
|
128
133
|
"@nullvoxpopuli/limber-untyped": "0.0.0"
|
|
129
134
|
},
|
|
130
135
|
"volta": {
|
|
@@ -140,12 +145,12 @@
|
|
|
140
145
|
"app-js": {}
|
|
141
146
|
},
|
|
142
147
|
"peerDependencies": {
|
|
143
|
-
"@glimmer/compiler": "^0.
|
|
148
|
+
"@glimmer/compiler": "^0.85.13",
|
|
144
149
|
"@glimmer/component": "^1.1.2",
|
|
145
|
-
"@glimmer/syntax": "^0.
|
|
146
|
-
"@glint/template": "^1.1
|
|
147
|
-
"ember-resources": "^6.4.
|
|
148
|
-
"ember-source": "^5.
|
|
150
|
+
"@glimmer/syntax": "^0.85.13",
|
|
151
|
+
"@glint/template": "^1.2.1",
|
|
152
|
+
"ember-resources": "^6.4.2",
|
|
153
|
+
"ember-source": "^5.4.0"
|
|
149
154
|
},
|
|
150
155
|
"engines": {
|
|
151
156
|
"node": ">= v16",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CACHE } from './compile/index.ts';
|
package/src/browser/cjs/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ export async function compileJS(code: string, extraModules?: ExtraModules): Prom
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async function compileGJS({ code: input, name }: Info) {
|
|
34
|
-
let preprocessed = preprocess(input, name);
|
|
34
|
+
let preprocessed = await preprocess(input, name);
|
|
35
35
|
let result = await transform(preprocessed, name);
|
|
36
36
|
|
|
37
37
|
if (!result) {
|
|
@@ -2,6 +2,7 @@ import { invocationName } from '../utils.ts';
|
|
|
2
2
|
|
|
3
3
|
import type { CompileResult } from '../types.ts';
|
|
4
4
|
import type { ExtractedCode } from './markdown-to-ember.ts';
|
|
5
|
+
import type { UnifiedPlugin } from './types.ts';
|
|
5
6
|
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
6
7
|
|
|
7
8
|
async function compileAll(js: { code: string }[], importMap?: EvalImportMap) {
|
|
@@ -86,6 +87,7 @@ export async function compileMD(
|
|
|
86
87
|
options?: {
|
|
87
88
|
importMap?: EvalImportMap;
|
|
88
89
|
topLevelScope?: ScopeMap;
|
|
90
|
+
remarkPlugins?: UnifiedPlugin[];
|
|
89
91
|
CopyComponent?: string;
|
|
90
92
|
ShadowComponent?: string;
|
|
91
93
|
}
|
|
@@ -110,6 +112,7 @@ export async function compileMD(
|
|
|
110
112
|
let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {
|
|
111
113
|
CopyComponent: options?.CopyComponent,
|
|
112
114
|
ShadowComponent: options?.ShadowComponent,
|
|
115
|
+
remarkPlugins: options?.remarkPlugins,
|
|
113
116
|
});
|
|
114
117
|
|
|
115
118
|
rootTemplate = templateOnlyGlimdown;
|
|
@@ -8,37 +8,67 @@ import {
|
|
|
8
8
|
} from './formats.ts';
|
|
9
9
|
|
|
10
10
|
import type { CompileResult } from '../types.ts';
|
|
11
|
+
import type { UnifiedPlugin } from './types.ts';
|
|
11
12
|
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
12
13
|
import type { ComponentLike } from '@glint/template';
|
|
13
14
|
type Format = 'glimdown' | 'gjs' | 'hbs';
|
|
14
15
|
|
|
15
16
|
export const CACHE = new Map<string, ComponentLike>();
|
|
16
17
|
|
|
18
|
+
interface Events {
|
|
19
|
+
onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
20
|
+
onError: (error: string) => Promise<unknown> | unknown;
|
|
21
|
+
onCompileStart: () => Promise<unknown> | unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface Scope {
|
|
25
|
+
importMap?: EvalImportMap;
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
|
|
18
29
|
|
|
30
|
+
interface GlimdownOptions extends Scope, Events {
|
|
31
|
+
format: 'glimdown';
|
|
32
|
+
remarkPlugins?: UnifiedPlugin[];
|
|
33
|
+
CopyComponent?: string;
|
|
34
|
+
ShadowComponent?: string;
|
|
35
|
+
topLevelScope?: ScopeMap;
|
|
36
|
+
}
|
|
37
|
+
interface GJSOptions extends Scope, Events {
|
|
38
|
+
format: 'gjs';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface HBSOptions extends Scope, Events {
|
|
42
|
+
format: 'hbs';
|
|
43
|
+
topLevelScope?: ScopeMap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Compile GitHub-flavored Markdown with GJS support
|
|
48
|
+
* and optionally render gjs-snippets via a `live` meta tag
|
|
49
|
+
* on the code fences.
|
|
50
|
+
*/
|
|
51
|
+
export async function compile(text: string, options: GlimdownOptions): Promise<void>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Compile GJS
|
|
55
|
+
*/
|
|
56
|
+
export async function compile(text: string, options: GJSOptions): Promise<void>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Compile a stateless component using just the template
|
|
60
|
+
*/
|
|
61
|
+
export async function compile(text: string, options: HBSOptions): Promise<void>;
|
|
62
|
+
|
|
19
63
|
/**
|
|
20
64
|
* This compileMD is a more robust version of the raw compiling used in "formats".
|
|
21
65
|
* This function manages cache, and has events for folks building UIs to hook in to
|
|
22
66
|
*/
|
|
23
67
|
export async function compile(
|
|
24
68
|
text: string,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
onError,
|
|
29
|
-
onCompileStart,
|
|
30
|
-
...options
|
|
31
|
-
}: {
|
|
32
|
-
format: Format;
|
|
33
|
-
onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
34
|
-
onError: (error: string) => Promise<unknown> | unknown;
|
|
35
|
-
onCompileStart: () => Promise<unknown> | unknown;
|
|
36
|
-
importMap?: EvalImportMap;
|
|
37
|
-
CopyComponent?: string;
|
|
38
|
-
ShadowComponent?: string;
|
|
39
|
-
topLevelScope?: ScopeMap;
|
|
40
|
-
}
|
|
41
|
-
) {
|
|
69
|
+
options: GlimdownOptions | GJSOptions | HBSOptions
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
let { onSuccess, onError, onCompileStart } = options;
|
|
42
72
|
let id = nameFor(text);
|
|
43
73
|
|
|
44
74
|
let existing = CACHE.get(id);
|
|
@@ -49,8 +79,8 @@ export async function compile(
|
|
|
49
79
|
return;
|
|
50
80
|
}
|
|
51
81
|
|
|
52
|
-
if (!SUPPORTED_FORMATS.includes(format)) {
|
|
53
|
-
await onError(`Unsupported format: ${format}. Supported formats: ${SUPPORTED_FORMATS}`);
|
|
82
|
+
if (!SUPPORTED_FORMATS.includes(options.format)) {
|
|
83
|
+
await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
|
|
54
84
|
|
|
55
85
|
return;
|
|
56
86
|
}
|
|
@@ -65,16 +95,18 @@ export async function compile(
|
|
|
65
95
|
|
|
66
96
|
let result: CompileResult;
|
|
67
97
|
|
|
68
|
-
if (format === 'glimdown') {
|
|
98
|
+
if (options.format === 'glimdown') {
|
|
69
99
|
result = await processMD(text, options);
|
|
70
|
-
} else if (format === 'gjs') {
|
|
100
|
+
} else if (options.format === 'gjs') {
|
|
71
101
|
result = await processGJS(text, options.importMap);
|
|
72
|
-
} else if (format === 'hbs') {
|
|
102
|
+
} else if (options.format === 'hbs') {
|
|
73
103
|
result = await processHBS(text, {
|
|
74
104
|
scope: options.topLevelScope,
|
|
75
105
|
});
|
|
76
106
|
} else {
|
|
77
|
-
await onError(
|
|
107
|
+
await onError(
|
|
108
|
+
`Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`
|
|
109
|
+
);
|
|
78
110
|
|
|
79
111
|
return;
|
|
80
112
|
}
|
|
@@ -95,6 +127,7 @@ type Input = string | undefined | null;
|
|
|
95
127
|
type ExtraOptions =
|
|
96
128
|
| {
|
|
97
129
|
format: 'glimdown';
|
|
130
|
+
remarkPlugins?: UnifiedPlugin[];
|
|
98
131
|
importMap?: EvalImportMap;
|
|
99
132
|
CopyComponent?: string;
|
|
100
133
|
ShadowComponent?: string;
|
|
@@ -144,7 +177,8 @@ export function buildCompiler(
|
|
|
144
177
|
|
|
145
178
|
if (input) {
|
|
146
179
|
compile(input, {
|
|
147
|
-
|
|
180
|
+
// narrowing is hard here, but this is an implementation detail
|
|
181
|
+
format: format as any,
|
|
148
182
|
onSuccess: async (component) => {
|
|
149
183
|
result.current = component;
|
|
150
184
|
ready.set(true);
|
|
@@ -8,6 +8,7 @@ import { visit } from 'unist-util-visit';
|
|
|
8
8
|
|
|
9
9
|
import { invocationOf, nameFor } from '../utils.ts';
|
|
10
10
|
|
|
11
|
+
import type { UnifiedPlugin } from './types.ts';
|
|
11
12
|
import type { Node } from 'hast';
|
|
12
13
|
import type { Code, Text } from 'mdast';
|
|
13
14
|
import type { Parent } from 'unist';
|
|
@@ -218,89 +219,103 @@ function liveCodeExtraction(options: Options = {}) {
|
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
function buildCompiler(options: ParseMarkdownOptions) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// definitively not the better way, but this is supposed to detect "glimmer" nodes
|
|
269
|
-
if (
|
|
270
|
-
'value' in node &&
|
|
271
|
-
typeof node.value === 'string' &&
|
|
272
|
-
node.value.match(/<\/?[_A-Z:0-9].*>/g)
|
|
273
|
-
) {
|
|
274
|
-
node.type = 'glimmer_raw';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
node.type = 'glimmer_raw';
|
|
278
|
-
|
|
279
|
-
return 'skip';
|
|
280
|
-
}
|
|
222
|
+
let compiler = unified().use(remarkParse).use(remarkGfm);
|
|
223
|
+
|
|
224
|
+
// TODO: we only want to do this when we have pre > code.
|
|
225
|
+
// code can exist inline.
|
|
226
|
+
compiler = compiler.use(liveCodeExtraction, {
|
|
227
|
+
snippets: {
|
|
228
|
+
classList: ['glimdown-snippet', 'relative'],
|
|
229
|
+
},
|
|
230
|
+
demo: {
|
|
231
|
+
classList: ['glimdown-render'],
|
|
232
|
+
},
|
|
233
|
+
copyComponent: options?.CopyComponent,
|
|
234
|
+
shadowComponent: options?.ShadowComponent,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* If this were "use"d after `remarkRehype`,
|
|
239
|
+
* remark is gone, and folks would need to work with rehype trees
|
|
240
|
+
*/
|
|
241
|
+
if (options.remarkPlugins) {
|
|
242
|
+
options.remarkPlugins.forEach((plugin) => {
|
|
243
|
+
compiler = compiler.use(plugin) as any;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
|
|
248
|
+
// remark rehype is needed to convert markdown to HTML
|
|
249
|
+
// However, it also changes all the nodes, so we need another pass
|
|
250
|
+
// to make sure our Glimmer-aware nodes are in tact
|
|
251
|
+
compiler = compiler.use(remarkRehype, { allowDangerousHtml: true });
|
|
252
|
+
|
|
253
|
+
// Convert invocables to raw format, so Glimmer can invoke them
|
|
254
|
+
compiler = compiler.use(() => (tree: Node) => {
|
|
255
|
+
visit(tree, function (node) {
|
|
256
|
+
// We rely on an implicit transformation of data.hProperties => properties
|
|
257
|
+
let properties = (node as any).properties;
|
|
258
|
+
|
|
259
|
+
if (properties?.[GLIMDOWN_PREVIEW]) {
|
|
260
|
+
// Have to sanitize anything Glimmer could try to render
|
|
261
|
+
escapeCurlies(node as Parent);
|
|
262
|
+
|
|
263
|
+
return 'skip';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (node.type === 'element' || ('tagName' in node && node.tagName === 'code')) {
|
|
267
|
+
if (properties?.[GLIMDOWN_RENDER]) {
|
|
268
|
+
node.type = 'glimmer_raw';
|
|
281
269
|
|
|
282
270
|
return;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
escapeCurlies(node as Parent);
|
|
274
|
+
|
|
275
|
+
return 'skip';
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (node.type === 'text' || node.type === 'raw') {
|
|
279
|
+
// definitively not the better way, but this is supposed to detect "glimmer" nodes
|
|
280
|
+
if (
|
|
281
|
+
'value' in node &&
|
|
282
|
+
typeof node.value === 'string' &&
|
|
283
|
+
node.value.match(/<\/?[_A-Z:0-9].*>/g)
|
|
284
|
+
) {
|
|
285
|
+
node.type = 'glimmer_raw';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
node.type = 'glimmer_raw';
|
|
289
|
+
|
|
290
|
+
return 'skip';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return;
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
compiler = compiler.use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] }).use(() => (tree) => {
|
|
298
|
+
visit(tree, 'glimmer_raw', (node: Node) => {
|
|
299
|
+
node.type = 'raw';
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Finally convert to string! oofta!
|
|
304
|
+
compiler = compiler.use(rehypeStringify, {
|
|
305
|
+
collapseEmptyAttributes: true,
|
|
306
|
+
closeSelfClosing: true,
|
|
307
|
+
allowParseErrors: true,
|
|
308
|
+
allowDangerousCharacters: true,
|
|
309
|
+
allowDangerousHtml: true,
|
|
310
|
+
}) as any;
|
|
311
|
+
|
|
312
|
+
return compiler as ReturnType<typeof unified>;
|
|
299
313
|
}
|
|
300
314
|
|
|
301
315
|
interface ParseMarkdownOptions {
|
|
302
316
|
CopyComponent?: string;
|
|
303
317
|
ShadowComponent?: string;
|
|
318
|
+
remarkPlugins?: UnifiedPlugin[];
|
|
304
319
|
}
|
|
305
320
|
|
|
306
321
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type Plugin } from 'unified';
|
|
2
|
+
|
|
1
3
|
export interface EvalImportMap {
|
|
2
4
|
[moduleName: string]: ScopeMap;
|
|
3
5
|
}
|
|
@@ -5,3 +7,5 @@ export interface EvalImportMap {
|
|
|
5
7
|
export interface ScopeMap {
|
|
6
8
|
[localName: string]: unknown;
|
|
7
9
|
}
|
|
10
|
+
|
|
11
|
+
export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
|