ember-repl 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +2 -404
- package/config/.try.mjs +87 -0
- package/config/addon-main.cjs +7 -0
- package/config/attw.json +7 -0
- package/config/babel.publish.config.cjs +29 -0
- package/config/ember-cli-update.json +21 -0
- package/config/rollup.config.mjs +44 -0
- package/config/testem.cjs +35 -0
- package/config/tsconfig.publish.json +18 -0
- package/config/vite.config.mjs +36 -0
- package/declarations/compile/Compiled.d.ts +7 -0
- package/declarations/compile/Compiled.d.ts.map +1 -0
- package/declarations/compile/compile.d.ts +17 -0
- package/declarations/compile/compile.d.ts.map +1 -0
- package/declarations/compile/state.d.ts +43 -0
- package/declarations/compile/state.d.ts.map +1 -0
- package/declarations/compile/types.d.ts +5 -12
- package/declarations/compile/types.d.ts.map +1 -1
- package/declarations/index.d.ts +6 -2
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +94 -0
- package/declarations/services/compiler.d.ts.map +1 -0
- package/declarations/services/known-modules.d.ts +7 -0
- package/declarations/services/known-modules.d.ts.map +1 -0
- package/declarations/setup.d.ts +7 -0
- package/declarations/setup.d.ts.map +1 -0
- package/declarations/test-support.d.ts +20 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
- package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
- package/dist/babel-8wMrbxkT.js +110427 -0
- package/dist/babel-8wMrbxkT.js.map +1 -0
- package/dist/blank-line-Bzg2Qt4K.js +482 -0
- package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
- package/dist/compile/Compiled.js +26 -0
- package/dist/compile/Compiled.js.map +1 -0
- package/dist/compile/compile.js +62 -0
- package/dist/compile/compile.js.map +1 -0
- package/dist/compile/state.js +75 -0
- package/dist/compile/state.js.map +1 -0
- package/dist/compile/utils.js +213 -2
- package/dist/compile/utils.js.map +1 -1
- package/dist/default-CoqAuVeH.js +4 -0
- package/dist/default-CoqAuVeH.js.map +1 -0
- package/dist/index-BTx1k6gT.js +323 -0
- package/dist/index-BTx1k6gT.js.map +1 -0
- package/dist/index-Bxzjtr16.js +87 -0
- package/dist/index-Bxzjtr16.js.map +1 -0
- package/dist/index-C371bO_b.js +1553 -0
- package/dist/index-C371bO_b.js.map +1 -0
- package/dist/index-C4AyeeIa.js +5721 -0
- package/dist/index-C4AyeeIa.js.map +1 -0
- package/dist/index-C8S2G0FH.js +1953 -0
- package/dist/index-C8S2G0FH.js.map +1 -0
- package/dist/index-CCcIVEUK.js +409 -0
- package/dist/index-CCcIVEUK.js.map +1 -0
- package/dist/index-CDSIcg03.js +9070 -0
- package/dist/index-CDSIcg03.js.map +1 -0
- package/dist/index-D8szzCn3.js +2 -0
- package/dist/index-D8szzCn3.js.map +1 -0
- package/dist/index-DBBNT106.js +2644 -0
- package/dist/index-DBBNT106.js.map +1 -0
- package/dist/index-DP_Su7Zc.js +362 -0
- package/dist/index-DP_Su7Zc.js.map +1 -0
- package/dist/index-DejgrVqh.js +11299 -0
- package/dist/index-DejgrVqh.js.map +1 -0
- package/dist/index-Dr5iYoKt.js +1551 -0
- package/dist/index-Dr5iYoKt.js.map +1 -0
- package/dist/index-DxolpiGq.js +3336 -0
- package/dist/index-DxolpiGq.js.map +1 -0
- package/dist/index-ZyJlPFQY.js +249 -0
- package/dist/index-ZyJlPFQY.js.map +1 -0
- package/dist/index-k6CfLgeq.js +26 -0
- package/dist/index-k6CfLgeq.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/services/compiler.js +329 -0
- package/dist/services/compiler.js.map +1 -0
- package/dist/services/known-modules.js +123 -0
- package/dist/services/known-modules.js.map +1 -0
- package/dist/setup.js +15 -0
- package/dist/setup.js.map +1 -0
- package/dist/test-support.js +33 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +117 -138
- package/src/compile/Compiled.ts +45 -0
- package/src/compile/compile.ts +89 -0
- package/src/compile/state.ts +88 -0
- package/src/compile/types.ts +14 -13
- package/src/index.ts +6 -2
- package/src/services/compiler.ts +401 -0
- package/src/services/known-modules.ts +130 -0
- package/src/setup.ts +26 -0
- package/src/test-support.ts +64 -0
- package/addon-main.cjs +0 -5
- package/declarations/__PRIVATE__.d.ts +0 -2
- package/declarations/__PRIVATE__.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/babel.d.ts +0 -7
- package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/eval.d.ts +0 -8
- package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/index.d.ts +0 -24
- package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/known-modules.d.ts +0 -48
- package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
- package/declarations/compile/formats/hbs.d.ts +0 -17
- package/declarations/compile/formats/hbs.d.ts.map +0 -1
- package/declarations/compile/formats/markdown.d.ts +0 -22
- package/declarations/compile/formats/markdown.d.ts.map +0 -1
- package/declarations/compile/formats.d.ts +0 -17
- package/declarations/compile/formats.d.ts.map +0 -1
- package/declarations/compile/index.d.ts +0 -80
- package/declarations/compile/index.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -2
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/__PRIVATE__.js +0 -2
- package/dist/__PRIVATE__.js.map +0 -1
- package/dist/compile/formats/gjs/babel.js +0 -2
- package/dist/compile/formats/gjs/babel.js.map +0 -1
- package/dist/compile/formats/gjs/eval.js +0 -19
- package/dist/compile/formats/gjs/eval.js.map +0 -1
- package/dist/compile/formats/gjs/index.js +0 -122
- package/dist/compile/formats/gjs/index.js.map +0 -1
- package/dist/compile/formats/gjs/known-modules.js +0 -52
- package/dist/compile/formats/gjs/known-modules.js.map +0 -1
- package/dist/compile/formats/hbs.js +0 -93
- package/dist/compile/formats/hbs.js.map +0 -1
- package/dist/compile/formats/markdown.js +0 -266
- package/dist/compile/formats/markdown.js.map +0 -1
- package/dist/compile/formats.js +0 -173
- package/dist/compile/formats.js.map +0 -1
- package/dist/compile/index.js +0 -113
- package/dist/compile/index.js.map +0 -1
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/__PRIVATE__.ts +0 -1
- package/src/compile/formats/gjs/babel.ts +0 -7
- package/src/compile/formats/gjs/eval.ts +0 -29
- package/src/compile/formats/gjs/index.ts +0 -153
- package/src/compile/formats/gjs/known-modules.ts +0 -49
- package/src/compile/formats/hbs.ts +0 -100
- package/src/compile/formats/markdown.ts +0 -345
- package/src/compile/formats.ts +0 -178
- package/src/compile/index.ts +0 -219
- package/src/test-support/index.ts +0 -5
package/src/compile/index.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { cell, resource, resourceFactory } from 'ember-resources';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
compileGJS as processGJS,
|
|
5
|
-
compileHBS as processHBS,
|
|
6
|
-
compileMD as processMD,
|
|
7
|
-
} from './formats.ts';
|
|
8
|
-
import { nameFor } from './utils.ts';
|
|
9
|
-
|
|
10
|
-
import type { CompileResult, EvalImportMap, ScopeMap, UnifiedPlugin } from './types.ts';
|
|
11
|
-
import type { ComponentLike } from '@glint/template';
|
|
12
|
-
|
|
13
|
-
type Format = 'glimdown' | 'gjs' | 'hbs';
|
|
14
|
-
|
|
15
|
-
export const CACHE = new Map<string, ComponentLike>();
|
|
16
|
-
|
|
17
|
-
interface Events {
|
|
18
|
-
onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
|
|
19
|
-
onError: (error: string) => Promise<unknown> | unknown;
|
|
20
|
-
onCompileStart: () => Promise<unknown> | unknown;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface Scope {
|
|
24
|
-
importMap?: EvalImportMap;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
|
|
28
|
-
|
|
29
|
-
interface GlimdownOptions extends Scope, Events {
|
|
30
|
-
format: 'glimdown';
|
|
31
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
32
|
-
rehypePlugins?: UnifiedPlugin[];
|
|
33
|
-
CopyComponent?: string;
|
|
34
|
-
ShadowComponent?: string;
|
|
35
|
-
topLevelScope?: ScopeMap;
|
|
36
|
-
}
|
|
37
|
-
interface GJSOptions extends Scope, Events {
|
|
38
|
-
format: 'gjs';
|
|
39
|
-
|
|
40
|
-
// Make overloads easier?
|
|
41
|
-
remarkPlugins?: never;
|
|
42
|
-
rehypePlugins?: never;
|
|
43
|
-
CopyComponent?: never;
|
|
44
|
-
ShadowComponent?: never;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface HBSOptions extends Scope, Events {
|
|
48
|
-
format: 'hbs';
|
|
49
|
-
topLevelScope?: ScopeMap;
|
|
50
|
-
|
|
51
|
-
// Make overloads easier?
|
|
52
|
-
remarkPlugins?: never;
|
|
53
|
-
rehypePlugins?: never;
|
|
54
|
-
CopyComponent?: never;
|
|
55
|
-
ShadowComponent?: never;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Compile GitHub-flavored Markdown with GJS support
|
|
60
|
-
* and optionally render gjs-snippets via a `live` meta tag
|
|
61
|
-
* on the code fences.
|
|
62
|
-
*/
|
|
63
|
-
export async function compile(text: string, options: GlimdownOptions): Promise<void>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Compile GJS
|
|
67
|
-
*/
|
|
68
|
-
export async function compile(text: string, options: GJSOptions): Promise<void>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Compile a stateless component using just the template
|
|
72
|
-
*/
|
|
73
|
-
export async function compile(text: string, options: HBSOptions): Promise<void>;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* This compileMD is a more robust version of the raw compiling used in "formats".
|
|
77
|
-
* This function manages cache, and has events for folks building UIs to hook in to
|
|
78
|
-
*/
|
|
79
|
-
export async function compile(
|
|
80
|
-
text: string,
|
|
81
|
-
options: GlimdownOptions | GJSOptions | HBSOptions
|
|
82
|
-
): Promise<void> {
|
|
83
|
-
const { onSuccess, onError, onCompileStart } = options;
|
|
84
|
-
const id = nameFor(`${options.format}:${text}`);
|
|
85
|
-
|
|
86
|
-
const existing = CACHE.get(id);
|
|
87
|
-
|
|
88
|
-
if (existing) {
|
|
89
|
-
onSuccess(existing);
|
|
90
|
-
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (!SUPPORTED_FORMATS.includes(options.format)) {
|
|
95
|
-
await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
|
|
96
|
-
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
await onCompileStart();
|
|
101
|
-
|
|
102
|
-
if (!text) {
|
|
103
|
-
await onError('No Input Document yet');
|
|
104
|
-
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let result: CompileResult;
|
|
109
|
-
|
|
110
|
-
if (options.format === 'glimdown') {
|
|
111
|
-
result = await processMD(text, options);
|
|
112
|
-
} else if (options.format === 'gjs') {
|
|
113
|
-
result = await processGJS(text, options.importMap);
|
|
114
|
-
} else if (options.format === 'hbs') {
|
|
115
|
-
result = await processHBS(text, {
|
|
116
|
-
scope: options.topLevelScope,
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
await onError(
|
|
120
|
-
`Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (result.error) {
|
|
127
|
-
await onError(result.error.message || `${result.error}`);
|
|
128
|
-
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
CACHE.set(id, result.component as ComponentLike);
|
|
133
|
-
|
|
134
|
-
await onSuccess(result.component as ComponentLike);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
type Input = string | undefined | null;
|
|
138
|
-
|
|
139
|
-
type ExtraOptions =
|
|
140
|
-
| {
|
|
141
|
-
format: 'glimdown';
|
|
142
|
-
remarkPlugins?: UnifiedPlugin[];
|
|
143
|
-
rehypePlugins?: UnifiedPlugin[];
|
|
144
|
-
importMap?: EvalImportMap;
|
|
145
|
-
CopyComponent?: string;
|
|
146
|
-
ShadowComponent?: string;
|
|
147
|
-
topLevelScope?: ScopeMap;
|
|
148
|
-
}
|
|
149
|
-
| {
|
|
150
|
-
format: 'hbs';
|
|
151
|
-
topLevelScope?: ScopeMap;
|
|
152
|
-
}
|
|
153
|
-
| {
|
|
154
|
-
format: 'gjs';
|
|
155
|
-
importMap?: EvalImportMap;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @internal
|
|
160
|
-
*/
|
|
161
|
-
export interface Value {
|
|
162
|
-
isReady: boolean;
|
|
163
|
-
error: string | null;
|
|
164
|
-
component: ComponentLike;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export function Compiled(markdownText: Input | (() => Input)): Value;
|
|
168
|
-
export function Compiled(markdownText: Input | (() => Input), options?: Format): Value;
|
|
169
|
-
export function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;
|
|
170
|
-
export function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
|
|
171
|
-
export function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* By default, this compiles to `glimdown`. A Markdown format which
|
|
175
|
-
* extracts `live` tagged code snippets and compiles them to components.
|
|
176
|
-
*/
|
|
177
|
-
export function Compiled(
|
|
178
|
-
markdownText: Input | (() => Input),
|
|
179
|
-
maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)
|
|
180
|
-
): Value {
|
|
181
|
-
return resource(() => {
|
|
182
|
-
const maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;
|
|
183
|
-
const format =
|
|
184
|
-
(typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';
|
|
185
|
-
const options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};
|
|
186
|
-
|
|
187
|
-
const input = typeof markdownText === 'function' ? markdownText() : markdownText;
|
|
188
|
-
const ready = cell(false);
|
|
189
|
-
const error = cell<string | null>();
|
|
190
|
-
const result = cell<ComponentLike>();
|
|
191
|
-
|
|
192
|
-
if (input) {
|
|
193
|
-
compile(input, {
|
|
194
|
-
// narrowing is hard here, but this is an implementation detail
|
|
195
|
-
format: format as any,
|
|
196
|
-
onSuccess: async (component) => {
|
|
197
|
-
result.current = component;
|
|
198
|
-
ready.set(true);
|
|
199
|
-
error.set(null);
|
|
200
|
-
},
|
|
201
|
-
onError: async (e) => {
|
|
202
|
-
error.set(e);
|
|
203
|
-
},
|
|
204
|
-
onCompileStart: async () => {
|
|
205
|
-
ready.set(false);
|
|
206
|
-
},
|
|
207
|
-
...options,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return () => ({
|
|
212
|
-
isReady: ready.current,
|
|
213
|
-
error: error.current,
|
|
214
|
-
component: result.current,
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
resourceFactory(Compiled);
|