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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-repl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -18,37 +18,38 @@
|
|
|
18
18
|
"declarations/test-support/index.d.ts"
|
|
19
19
|
],
|
|
20
20
|
"markdown/parse": [
|
|
21
|
-
"./declarations/
|
|
21
|
+
"./declarations/compile/markdown-to-ember.d.ts"
|
|
22
22
|
],
|
|
23
23
|
"*": [
|
|
24
|
-
"declarations
|
|
25
|
-
"declarations
|
|
24
|
+
"declarations/*",
|
|
25
|
+
"declarations/*/index.d.ts"
|
|
26
26
|
]
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"types": "./declarations/
|
|
32
|
-
"default": "./dist/
|
|
31
|
+
"types": "./declarations/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
"types": "./declarations/
|
|
36
|
-
"default": "./dist/
|
|
34
|
+
"./formats/markdown": {
|
|
35
|
+
"types": "./declarations/compile/formats/markdown.d.ts",
|
|
36
|
+
"default": "./dist/compile/formats/markdown.js"
|
|
37
37
|
},
|
|
38
|
-
"./
|
|
39
|
-
"types": "./declarations/
|
|
40
|
-
"default": "./dist/
|
|
38
|
+
"./formats/hbs": {
|
|
39
|
+
"types": "./declarations/compile/formats/hbs.d.ts",
|
|
40
|
+
"default": "./dist/compile/formats/hbs.js"
|
|
41
41
|
},
|
|
42
|
-
"./
|
|
43
|
-
"
|
|
42
|
+
"./formats/gjs": {
|
|
43
|
+
"types": "./declarations/compile/formats/gjs/index.d.ts",
|
|
44
|
+
"default": "./dist/compile/formats/gjs/index.js"
|
|
44
45
|
},
|
|
45
46
|
"./test-support": {
|
|
46
47
|
"types": "./declarations/test-support/index.d.ts",
|
|
47
48
|
"default": "./dist/test-support/index.js"
|
|
48
49
|
},
|
|
49
50
|
"./__PRIVATE__DO_NOT_USE__": {
|
|
50
|
-
"types": "./declarations/
|
|
51
|
-
"default": "./dist/
|
|
51
|
+
"types": "./declarations/__PRIVATE__.d.ts",
|
|
52
|
+
"default": "./dist/__PRIVATE__.js"
|
|
52
53
|
},
|
|
53
54
|
"./addon-main.js": "./addon-main.cjs"
|
|
54
55
|
},
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"addon-main.cjs"
|
|
60
61
|
],
|
|
61
62
|
"dependencies": {
|
|
63
|
+
"ember-resources": ">= 6.4.2",
|
|
62
64
|
"@babel/helper-plugin-utils": "^7.22.5",
|
|
63
65
|
"@babel/standalone": "^7.23.10",
|
|
64
66
|
"@embroider/addon-shim": "1.8.7",
|
|
@@ -125,6 +127,7 @@
|
|
|
125
127
|
"eslint-plugin-ember": "^12.0.0",
|
|
126
128
|
"eslint-plugin-node": "^11.1.0",
|
|
127
129
|
"eslint-plugin-prettier": "^5.1.3",
|
|
130
|
+
"execa": "^8.0.1",
|
|
128
131
|
"prettier": "^3.2.5",
|
|
129
132
|
"prettier-plugin-ember-template-tag": "^2.0.0",
|
|
130
133
|
"publint": "^0.2.6",
|
|
@@ -146,12 +149,20 @@
|
|
|
146
149
|
"app-js": {}
|
|
147
150
|
},
|
|
148
151
|
"peerDependencies": {
|
|
149
|
-
"@glimmer/compiler": ">= 0.86.0",
|
|
150
|
-
"@glimmer/component": "^1.1.2",
|
|
151
|
-
"@glimmer/syntax": ">= 0.86.0",
|
|
152
152
|
"@glint/template": ">= 1.3.0",
|
|
153
|
-
"
|
|
154
|
-
"
|
|
153
|
+
"@glimmer/compiler": ">= 0.86.0",
|
|
154
|
+
"@glimmer/syntax": ">= 0.86.0"
|
|
155
|
+
},
|
|
156
|
+
"peerDependenciesMeta": {
|
|
157
|
+
"@glint/template": {
|
|
158
|
+
"optional": true
|
|
159
|
+
},
|
|
160
|
+
"@glimmer/compiler": {
|
|
161
|
+
"optional": true
|
|
162
|
+
},
|
|
163
|
+
"@glimmer/syntax": {
|
|
164
|
+
"optional": true
|
|
165
|
+
}
|
|
155
166
|
},
|
|
156
167
|
"engines": {
|
|
157
168
|
"node": ">= v16",
|
|
@@ -159,8 +170,7 @@
|
|
|
159
170
|
"yarn": "use pnpm"
|
|
160
171
|
},
|
|
161
172
|
"scripts": {
|
|
162
|
-
"build": "
|
|
163
|
-
"build:js": "rollup --config",
|
|
173
|
+
"build": "rollup --config",
|
|
164
174
|
"lint:types": "tsc --noEmit",
|
|
165
175
|
"lint:fix": "pnpm -w exec lint fix",
|
|
166
176
|
"start": "rollup --config --watch",
|
|
@@ -171,7 +181,6 @@
|
|
|
171
181
|
"lint:hbs": "pnpm -w exec lint hbs",
|
|
172
182
|
"lint:hbs:fix": "pnpm -w exec lint hbs:fix",
|
|
173
183
|
"lint:prettier:fix": "pnpm -w exec lint prettier:fix",
|
|
174
|
-
"lint:prettier": "pnpm -w exec lint prettier"
|
|
175
|
-
"build:types": "tsc --emitDeclarationOnly --noEmit false"
|
|
184
|
+
"lint:prettier": "pnpm -w exec lint prettier"
|
|
176
185
|
}
|
|
177
186
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { modules } from '
|
|
2
|
+
import { modules } from './known-modules.ts';
|
|
3
3
|
|
|
4
|
-
import type { ExtraModules } from '../types.ts';
|
|
5
4
|
import type Component from '@glimmer/component';
|
|
6
5
|
|
|
7
6
|
export function evalSnippet(
|
|
8
7
|
compiled: string,
|
|
9
|
-
extraModules:
|
|
8
|
+
extraModules: Record<string, unknown /* imported module */> = {}
|
|
10
9
|
): {
|
|
11
10
|
default: Component;
|
|
12
11
|
services?: { [key: string]: unknown };
|
|
@@ -21,7 +20,6 @@ export function evalSnippet(
|
|
|
21
20
|
return preConfigured || window.require(moduleName);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
// https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts
|
|
25
23
|
eval(compiled);
|
|
26
24
|
|
|
27
25
|
return Object.assign(exports, { require }) as {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { importSync } from '@embroider/macros';
|
|
2
|
+
|
|
3
|
+
import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
|
|
4
|
+
|
|
5
|
+
import { nameFor } from '../../utils.ts';
|
|
6
|
+
import { evalSnippet } from './eval.ts';
|
|
7
|
+
|
|
8
|
+
import type { CompileResult } from '../../types.ts';
|
|
9
|
+
import type { ComponentLike } from '@glint/template';
|
|
10
|
+
|
|
11
|
+
export interface Info {
|
|
12
|
+
code: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
19
|
+
* The returned component can be invoked explicitly in the consuming project.
|
|
20
|
+
*
|
|
21
|
+
* SEE: README for example usage
|
|
22
|
+
*
|
|
23
|
+
* @param {string} code: the code to be compiled
|
|
24
|
+
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
25
|
+
* for classic ember projects, but for strict static ember projects, extraModules
|
|
26
|
+
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
27
|
+
* if there are additional modules that could be imported in the passed `code`.
|
|
28
|
+
*
|
|
29
|
+
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
30
|
+
* are not provided by extraModules will be searched on npm to see if a package
|
|
31
|
+
* needs to be downloaded before running the `code` / invoking the component
|
|
32
|
+
*/
|
|
33
|
+
export async function compileJS(
|
|
34
|
+
code: string,
|
|
35
|
+
extraModules?: Record<string, unknown>
|
|
36
|
+
): Promise<CompileResult> {
|
|
37
|
+
let name = nameFor(code);
|
|
38
|
+
let component: undefined | ComponentLike;
|
|
39
|
+
let error: undefined | Error;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
let compiled = await transpile({ code: code, name });
|
|
43
|
+
|
|
44
|
+
if (!compiled) {
|
|
45
|
+
throw new Error(`Compiled output is missing`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
error = e as Error | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { name, component, error };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function transpile({ code: input, name }: Info) {
|
|
57
|
+
let preprocessed = await preprocess(input, name);
|
|
58
|
+
let result = await transform(preprocessed, name);
|
|
59
|
+
|
|
60
|
+
if (!result) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let { code } = result;
|
|
65
|
+
|
|
66
|
+
return code;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
import type { Babel } from './babel.ts';
|
|
70
|
+
|
|
71
|
+
const compiler = importSync('ember-source/dist/ember-template-compiler.js');
|
|
72
|
+
|
|
73
|
+
let processor: any;
|
|
74
|
+
let fetchingPromise: Promise<any>;
|
|
75
|
+
|
|
76
|
+
async function preprocess(input: string, name: string): Promise<string> {
|
|
77
|
+
if (!fetchingPromise) {
|
|
78
|
+
fetchingPromise = import('content-tag');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!processor) {
|
|
82
|
+
let { Preprocessor } = await fetchingPromise;
|
|
83
|
+
|
|
84
|
+
processor = new Preprocessor();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return processor.process(input, `${name}.js`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function transform(
|
|
91
|
+
intermediate: string,
|
|
92
|
+
name: string,
|
|
93
|
+
options: any = {}
|
|
94
|
+
): Promise<ReturnType<Babel['transform']>> {
|
|
95
|
+
let babel = (await import('@babel/standalone')) as Babel;
|
|
96
|
+
|
|
97
|
+
return babel.transform(intermediate, {
|
|
98
|
+
filename: `${name}.js`,
|
|
99
|
+
plugins: [
|
|
100
|
+
// [babelPluginIntermediateGJS],
|
|
101
|
+
[
|
|
102
|
+
babelPluginEmberTemplateCompilation,
|
|
103
|
+
{
|
|
104
|
+
compiler,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
[babel.availablePlugins['proposal-decorators'], { legacy: true }],
|
|
108
|
+
[babel.availablePlugins['proposal-class-properties']],
|
|
109
|
+
],
|
|
110
|
+
presets: [
|
|
111
|
+
[
|
|
112
|
+
babel.availablePresets['env'],
|
|
113
|
+
{
|
|
114
|
+
// false -- keeps ES Modules
|
|
115
|
+
modules: 'cjs',
|
|
116
|
+
targets: { esmodules: true },
|
|
117
|
+
forceAllTransforms: false,
|
|
118
|
+
...options,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -11,9 +11,9 @@ import { on } from '@ember/modifier';
|
|
|
11
11
|
import { createTemplateFactory } from '@ember/template-factory';
|
|
12
12
|
import { importSync } from '@embroider/macros';
|
|
13
13
|
|
|
14
|
-
import { nameFor } from '
|
|
14
|
+
import { nameFor } from '../utils.ts';
|
|
15
15
|
|
|
16
|
-
import type { CompileResult } from '
|
|
16
|
+
import type { CompileResult } from '../types.ts';
|
|
17
17
|
import type { ComponentLike } from '@glint/template';
|
|
18
18
|
|
|
19
19
|
// These things are pre-bundled in the old system.
|
|
@@ -79,7 +79,10 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
|
|
|
79
79
|
let value = localScope[key];
|
|
80
80
|
|
|
81
81
|
if (!value) {
|
|
82
|
-
throw new Error(
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Attempt to use ${key} in compiled hbs, but it was not available in scope. ` +
|
|
84
|
+
`Available scope includes: ${Object.keys(localScope)}`
|
|
85
|
+
);
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
return value;
|
|
@@ -89,7 +92,7 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
|
|
|
89
92
|
let templateJSONObject = {
|
|
90
93
|
id: moduleName,
|
|
91
94
|
block: blockJSON,
|
|
92
|
-
moduleName: moduleName ?? '(
|
|
95
|
+
moduleName: moduleName ?? '(dynamically compiled component)',
|
|
93
96
|
scope: () => usedScope,
|
|
94
97
|
isStrictMode: true,
|
|
95
98
|
};
|
|
@@ -8,7 +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 '
|
|
11
|
+
import type { UnifiedPlugin } from '../types.ts';
|
|
12
12
|
import type { Node } from 'hast';
|
|
13
13
|
import type { Code, Text } from 'mdast';
|
|
14
14
|
import type { Parent } from 'unist';
|
|
@@ -294,6 +294,12 @@ function buildCompiler(options: ParseMarkdownOptions) {
|
|
|
294
294
|
});
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
+
if (options.rehypePlugins) {
|
|
298
|
+
options.rehypePlugins.forEach((plugin) => {
|
|
299
|
+
compiler = compiler.use(plugin) as any;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
297
303
|
compiler = compiler.use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] }).use(() => (tree) => {
|
|
298
304
|
visit(tree, 'glimmer_raw', (node: Node) => {
|
|
299
305
|
node.type = 'raw';
|
|
@@ -316,6 +322,7 @@ interface ParseMarkdownOptions {
|
|
|
316
322
|
CopyComponent?: string;
|
|
317
323
|
ShadowComponent?: string;
|
|
318
324
|
remarkPlugins?: UnifiedPlugin[];
|
|
325
|
+
rehypePlugins?: UnifiedPlugin[];
|
|
319
326
|
}
|
|
320
327
|
|
|
321
328
|
/**
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { invocationName } from '
|
|
1
|
+
import { invocationName } from './utils.ts';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
3
|
+
import type { ExtractedCode } from './formats/markdown.ts';
|
|
4
|
+
import type { CompileResult, UnifiedPlugin } from './types.ts';
|
|
6
5
|
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
7
6
|
|
|
8
7
|
async function compileGJSArray(js: { code: string }[], importMap?: EvalImportMap) {
|
|
@@ -20,7 +19,7 @@ export async function compileGJS(
|
|
|
20
19
|
importMap?: EvalImportMap
|
|
21
20
|
): Promise<CompileResult> {
|
|
22
21
|
try {
|
|
23
|
-
let { compileJS } = await import('
|
|
22
|
+
let { compileJS } = await import('./formats/gjs/index.ts');
|
|
24
23
|
|
|
25
24
|
return await compileJS(gjsInput, importMap);
|
|
26
25
|
} catch (error) {
|
|
@@ -36,7 +35,7 @@ export async function compileHBS(
|
|
|
36
35
|
}
|
|
37
36
|
): Promise<CompileResult> {
|
|
38
37
|
try {
|
|
39
|
-
let { compileHBS } = await import('
|
|
38
|
+
let { compileHBS } = await import('./formats/hbs.ts');
|
|
40
39
|
|
|
41
40
|
return compileHBS(hbsInput, options);
|
|
42
41
|
} catch (error) {
|
|
@@ -110,7 +109,7 @@ export async function compileMD(
|
|
|
110
109
|
* compiled rootTemplate can invoke them
|
|
111
110
|
*/
|
|
112
111
|
try {
|
|
113
|
-
let { parseMarkdown } = await import('./markdown
|
|
112
|
+
let { parseMarkdown } = await import('./formats/markdown.ts');
|
|
114
113
|
let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {
|
|
115
114
|
CopyComponent: options?.CopyComponent,
|
|
116
115
|
ShadowComponent: options?.ShadowComponent,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { cell, resource, resourceFactory } from 'ember-resources';
|
|
2
2
|
|
|
3
|
-
import { nameFor } from '../utils.ts';
|
|
4
3
|
import {
|
|
5
4
|
compileGJS as processGJS,
|
|
6
5
|
compileHBS as processHBS,
|
|
7
6
|
compileMD as processMD,
|
|
8
7
|
} from './formats.ts';
|
|
8
|
+
import { nameFor } from './utils.ts';
|
|
9
9
|
|
|
10
|
-
import type { CompileResult } from '
|
|
11
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
10
|
+
import type { CompileResult, UnifiedPlugin } from './types.ts';
|
|
12
11
|
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
13
12
|
import type { ComponentLike } from '@glint/template';
|
|
14
13
|
type Format = 'glimdown' | 'gjs' | 'hbs';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentLike } from '@glint/template';
|
|
2
|
+
import type { Plugin } from 'unified';
|
|
3
|
+
|
|
4
|
+
export interface EvalImportMap {
|
|
5
|
+
[moduleName: string]: ScopeMap;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ScopeMap {
|
|
9
|
+
[localName: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
|
|
13
|
+
|
|
14
|
+
export interface CompileResult {
|
|
15
|
+
component?: ComponentLike;
|
|
16
|
+
error?: Error;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Options = {
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
* @deprecated do not use - not under semver
|
|
24
|
+
*/
|
|
25
|
+
skypack?: boolean;
|
|
26
|
+
};
|
package/src/index.ts
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__PRIVATE__.d.ts","sourceRoot":"","sources":["../../src/browser/__PRIVATE__.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ExtraModules } from '../types.ts';
|
|
2
|
-
import type Component from '@glimmer/component';
|
|
3
|
-
export declare function evalSnippet(compiled: string, extraModules?: ExtraModules): {
|
|
4
|
-
default: Component;
|
|
5
|
-
services?: {
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=eval.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/browser/cjs/eval.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAEhD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,YAAiB,GAC9B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvC,CAmBA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/cjs/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAkBjG"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CompileResult } from '../types.ts';
|
|
2
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
3
|
-
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
4
|
-
export declare function compileGJS(gjsInput: string, importMap?: EvalImportMap): Promise<CompileResult>;
|
|
5
|
-
export declare function compileHBS(hbsInput: string, options?: {
|
|
6
|
-
moduleName?: string;
|
|
7
|
-
scope?: Record<string, unknown>;
|
|
8
|
-
}): Promise<CompileResult>;
|
|
9
|
-
export declare function compileMD(glimdownInput: string, options?: {
|
|
10
|
-
importMap?: EvalImportMap;
|
|
11
|
-
topLevelScope?: ScopeMap;
|
|
12
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
13
|
-
CopyComponent?: string;
|
|
14
|
-
ShadowComponent?: string;
|
|
15
|
-
}): Promise<CompileResult & {
|
|
16
|
-
rootTemplate?: string;
|
|
17
|
-
}>;
|
|
18
|
-
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/formats.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAY1D,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,aAAa,CAAC,CAQxB;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,GACA,OAAO,CAAC,aAAa,CAAC,CAQxB;AA2CD,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACA,OAAO,CAAC,aAAa,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiFpD"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
2
|
-
import type { EvalImportMap, ScopeMap } from './types.ts';
|
|
3
|
-
import type { ComponentLike } from '@glint/template';
|
|
4
|
-
type Format = 'glimdown' | 'gjs' | 'hbs';
|
|
5
|
-
export declare const CACHE: Map<string, ComponentLike>;
|
|
6
|
-
interface Events {
|
|
7
|
-
onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
8
|
-
onError: (error: string) => Promise<unknown> | unknown;
|
|
9
|
-
onCompileStart: () => Promise<unknown> | unknown;
|
|
10
|
-
}
|
|
11
|
-
interface Scope {
|
|
12
|
-
importMap?: EvalImportMap;
|
|
13
|
-
}
|
|
14
|
-
interface GlimdownOptions extends Scope, Events {
|
|
15
|
-
format: 'glimdown';
|
|
16
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
17
|
-
CopyComponent?: string;
|
|
18
|
-
ShadowComponent?: string;
|
|
19
|
-
topLevelScope?: ScopeMap;
|
|
20
|
-
}
|
|
21
|
-
interface GJSOptions extends Scope, Events {
|
|
22
|
-
format: 'gjs';
|
|
23
|
-
}
|
|
24
|
-
interface HBSOptions extends Scope, Events {
|
|
25
|
-
format: 'hbs';
|
|
26
|
-
topLevelScope?: ScopeMap;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Compile GitHub-flavored Markdown with GJS support
|
|
30
|
-
* and optionally render gjs-snippets via a `live` meta tag
|
|
31
|
-
* on the code fences.
|
|
32
|
-
*/
|
|
33
|
-
export declare function compile(text: string, options: GlimdownOptions): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Compile GJS
|
|
36
|
-
*/
|
|
37
|
-
export declare function compile(text: string, options: GJSOptions): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Compile a stateless component using just the template
|
|
40
|
-
*/
|
|
41
|
-
export declare function compile(text: string, options: HBSOptions): Promise<void>;
|
|
42
|
-
type Input = string | undefined | null;
|
|
43
|
-
type ExtraOptions = {
|
|
44
|
-
format: 'glimdown';
|
|
45
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
46
|
-
importMap?: EvalImportMap;
|
|
47
|
-
CopyComponent?: string;
|
|
48
|
-
ShadowComponent?: string;
|
|
49
|
-
topLevelScope?: ScopeMap;
|
|
50
|
-
} | {
|
|
51
|
-
format: 'hbs';
|
|
52
|
-
topLevelScope?: ScopeMap;
|
|
53
|
-
} | {
|
|
54
|
-
format: 'gjs';
|
|
55
|
-
importMap?: EvalImportMap;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export interface Value {
|
|
61
|
-
isReady: boolean;
|
|
62
|
-
error: string | null;
|
|
63
|
-
component: ComponentLike;
|
|
64
|
-
}
|
|
65
|
-
export declare function Compiled(markdownText: Input | (() => Input)): Value;
|
|
66
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: Format): Value;
|
|
67
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;
|
|
68
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
|
|
69
|
-
export declare function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OA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,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,YAAY,GAAG,KAAK,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { UnifiedPlugin } from './types.ts';
|
|
2
|
-
export interface ExtractedCode {
|
|
3
|
-
name: string;
|
|
4
|
-
code: string;
|
|
5
|
-
lang: string;
|
|
6
|
-
}
|
|
7
|
-
export interface LiveCodeExtraction {
|
|
8
|
-
templateOnlyGlimdown: string;
|
|
9
|
-
blocks: ExtractedCode[];
|
|
10
|
-
}
|
|
11
|
-
interface ParseMarkdownOptions {
|
|
12
|
-
CopyComponent?: string;
|
|
13
|
-
ShadowComponent?: string;
|
|
14
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @internal not under semver
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseMarkdown(input: string, options?: ParseMarkdownOptions): Promise<LiveCodeExtraction>;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=markdown-to-ember.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-to-ember.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/markdown-to-ember.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAMhD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAiSD,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/browser/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CompileResult, ExtraModules } from '../types.ts';
|
|
2
|
-
export interface Info {
|
|
3
|
-
code: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
|
|
7
|
-
export declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/esm/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI/D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAoBjG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,UAavE"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Babel } from './types.ts';
|
|
2
|
-
export declare function preprocess(input: string, name: string): Promise<string>;
|
|
3
|
-
export declare function transform(intermediate: string, name: string, options?: any): Promise<ReturnType<Babel['transform']>>;
|
|
4
|
-
//# sourceMappingURL=gjs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gjs.d.ts","sourceRoot":"","sources":["../../src/browser/gjs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAOxC,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY7E;AAED,wBAAsB,SAAS,CAC7B,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CA6BzC"}
|