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
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Code} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Check whether the character code represents an ASCII alpha (`a` through `z`,
|
|
7
|
+
* case insensitive).
|
|
8
|
+
*
|
|
9
|
+
* An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.
|
|
10
|
+
*
|
|
11
|
+
* An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)
|
|
12
|
+
* to U+005A (`Z`).
|
|
13
|
+
*
|
|
14
|
+
* An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)
|
|
15
|
+
* to U+007A (`z`).
|
|
16
|
+
*
|
|
17
|
+
* @param code
|
|
18
|
+
* Code.
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
* Whether it matches.
|
|
21
|
+
*/
|
|
22
|
+
const asciiAlpha = regexCheck(/[A-Za-z]/);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Check whether the character code represents an ASCII alphanumeric (`a`
|
|
26
|
+
* through `z`, case insensitive, or `0` through `9`).
|
|
27
|
+
*
|
|
28
|
+
* An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha
|
|
29
|
+
* (see `asciiAlpha`).
|
|
30
|
+
*
|
|
31
|
+
* @param code
|
|
32
|
+
* Code.
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
* Whether it matches.
|
|
35
|
+
*/
|
|
36
|
+
const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check whether the character code represents an ASCII atext.
|
|
40
|
+
*
|
|
41
|
+
* atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in
|
|
42
|
+
* the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),
|
|
43
|
+
* U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F
|
|
44
|
+
* SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E
|
|
45
|
+
* CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE
|
|
46
|
+
* (`{`) to U+007E TILDE (`~`).
|
|
47
|
+
*
|
|
48
|
+
* See:
|
|
49
|
+
* **\[RFC5322]**:
|
|
50
|
+
* [Internet Message Format](https://tools.ietf.org/html/rfc5322).
|
|
51
|
+
* P. Resnick.
|
|
52
|
+
* IETF.
|
|
53
|
+
*
|
|
54
|
+
* @param code
|
|
55
|
+
* Code.
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
* Whether it matches.
|
|
58
|
+
*/
|
|
59
|
+
const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check whether a character code is an ASCII control character.
|
|
63
|
+
*
|
|
64
|
+
* An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
|
|
65
|
+
* to U+001F (US), or U+007F (DEL).
|
|
66
|
+
*
|
|
67
|
+
* @param {Code} code
|
|
68
|
+
* Code.
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
* Whether it matches.
|
|
71
|
+
*/
|
|
72
|
+
function asciiControl(code) {
|
|
73
|
+
return (
|
|
74
|
+
// Special whitespace codes (which have negative values), C0 and Control
|
|
75
|
+
// character DEL
|
|
76
|
+
code !== null && (code < 32 || code === 127)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check whether the character code represents an ASCII digit (`0` through `9`).
|
|
82
|
+
*
|
|
83
|
+
* An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to
|
|
84
|
+
* U+0039 (`9`).
|
|
85
|
+
*
|
|
86
|
+
* @param code
|
|
87
|
+
* Code.
|
|
88
|
+
* @returns {boolean}
|
|
89
|
+
* Whether it matches.
|
|
90
|
+
*/
|
|
91
|
+
const asciiDigit = regexCheck(/\d/);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check whether the character code represents an ASCII hex digit (`a` through
|
|
95
|
+
* `f`, case insensitive, or `0` through `9`).
|
|
96
|
+
*
|
|
97
|
+
* An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex
|
|
98
|
+
* digit, or an ASCII lower hex digit.
|
|
99
|
+
*
|
|
100
|
+
* An **ASCII upper hex digit** is a character in the inclusive range U+0041
|
|
101
|
+
* (`A`) to U+0046 (`F`).
|
|
102
|
+
*
|
|
103
|
+
* An **ASCII lower hex digit** is a character in the inclusive range U+0061
|
|
104
|
+
* (`a`) to U+0066 (`f`).
|
|
105
|
+
*
|
|
106
|
+
* @param code
|
|
107
|
+
* Code.
|
|
108
|
+
* @returns {boolean}
|
|
109
|
+
* Whether it matches.
|
|
110
|
+
*/
|
|
111
|
+
const asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check whether the character code represents ASCII punctuation.
|
|
115
|
+
*
|
|
116
|
+
* An **ASCII punctuation** is a character in the inclusive ranges U+0021
|
|
117
|
+
* EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT
|
|
118
|
+
* SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT
|
|
119
|
+
* (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).
|
|
120
|
+
*
|
|
121
|
+
* @param code
|
|
122
|
+
* Code.
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
* Whether it matches.
|
|
125
|
+
*/
|
|
126
|
+
const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check whether a character code is a markdown line ending.
|
|
130
|
+
*
|
|
131
|
+
* A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
|
|
132
|
+
* LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
|
|
133
|
+
*
|
|
134
|
+
* In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
|
|
135
|
+
* RETURN (CR) are replaced by these virtual characters depending on whether
|
|
136
|
+
* they occurred together.
|
|
137
|
+
*
|
|
138
|
+
* @param {Code} code
|
|
139
|
+
* Code.
|
|
140
|
+
* @returns {boolean}
|
|
141
|
+
* Whether it matches.
|
|
142
|
+
*/
|
|
143
|
+
function markdownLineEnding(code) {
|
|
144
|
+
return code !== null && code < -2;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Check whether a character code is a markdown line ending (see
|
|
149
|
+
* `markdownLineEnding`) or markdown space (see `markdownSpace`).
|
|
150
|
+
*
|
|
151
|
+
* @param {Code} code
|
|
152
|
+
* Code.
|
|
153
|
+
* @returns {boolean}
|
|
154
|
+
* Whether it matches.
|
|
155
|
+
*/
|
|
156
|
+
function markdownLineEndingOrSpace(code) {
|
|
157
|
+
return code !== null && (code < 0 || code === 32);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Check whether a character code is a markdown space.
|
|
162
|
+
*
|
|
163
|
+
* A **markdown space** is the concrete character U+0020 SPACE (SP) and the
|
|
164
|
+
* virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
|
|
165
|
+
*
|
|
166
|
+
* In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
|
|
167
|
+
* replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
|
|
168
|
+
* SPACE (VS) characters, depending on the column at which the tab occurred.
|
|
169
|
+
*
|
|
170
|
+
* @param {Code} code
|
|
171
|
+
* Code.
|
|
172
|
+
* @returns {boolean}
|
|
173
|
+
* Whether it matches.
|
|
174
|
+
*/
|
|
175
|
+
function markdownSpace(code) {
|
|
176
|
+
return code === -2 || code === -1 || code === 32;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Size note: removing ASCII from the regex and using `asciiPunctuation` here
|
|
180
|
+
// In fact adds to the bundle size.
|
|
181
|
+
/**
|
|
182
|
+
* Check whether the character code represents Unicode punctuation.
|
|
183
|
+
*
|
|
184
|
+
* A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,
|
|
185
|
+
* Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`
|
|
186
|
+
* (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`
|
|
187
|
+
* (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII
|
|
188
|
+
* punctuation (see `asciiPunctuation`).
|
|
189
|
+
*
|
|
190
|
+
* See:
|
|
191
|
+
* **\[UNICODE]**:
|
|
192
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
193
|
+
* Unicode Consortium.
|
|
194
|
+
*
|
|
195
|
+
* @param code
|
|
196
|
+
* Code.
|
|
197
|
+
* @returns
|
|
198
|
+
* Whether it matches.
|
|
199
|
+
*/
|
|
200
|
+
const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check whether the character code represents Unicode whitespace.
|
|
204
|
+
*
|
|
205
|
+
* Note that this does handle micromark specific markdown whitespace characters.
|
|
206
|
+
* See `markdownLineEndingOrSpace` to check that.
|
|
207
|
+
*
|
|
208
|
+
* A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,
|
|
209
|
+
* Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),
|
|
210
|
+
* U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**).
|
|
211
|
+
*
|
|
212
|
+
* See:
|
|
213
|
+
* **\[UNICODE]**:
|
|
214
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
215
|
+
* Unicode Consortium.
|
|
216
|
+
*
|
|
217
|
+
* @param code
|
|
218
|
+
* Code.
|
|
219
|
+
* @returns
|
|
220
|
+
* Whether it matches.
|
|
221
|
+
*/
|
|
222
|
+
const unicodeWhitespace = regexCheck(/\s/);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Create a code check from a regex.
|
|
226
|
+
*
|
|
227
|
+
* @param {RegExp} regex
|
|
228
|
+
* Expression.
|
|
229
|
+
* @returns {(code: Code) => boolean}
|
|
230
|
+
* Check.
|
|
231
|
+
*/
|
|
232
|
+
function regexCheck(regex) {
|
|
233
|
+
return check;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Check whether a code matches the bound regex.
|
|
237
|
+
*
|
|
238
|
+
* @param {Code} code
|
|
239
|
+
* Character code.
|
|
240
|
+
* @returns {boolean}
|
|
241
|
+
* Whether the character code matches the bound regex.
|
|
242
|
+
*/
|
|
243
|
+
function check(code) {
|
|
244
|
+
return code !== null && code > -1 && regex.test(String.fromCharCode(code));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { unicodePunctuation as a, asciiAlphanumeric as b, asciiAlpha as c, asciiControl as d, markdownLineEnding as e, markdownSpace as f, asciiAtext as g, asciiPunctuation as h, asciiHexDigit as i, asciiDigit as j, markdownLineEndingOrSpace as m, unicodeWhitespace as u };
|
|
249
|
+
//# sourceMappingURL=index-ZyJlPFQY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-ZyJlPFQY.js","sources":["../../../node_modules/.pnpm/micromark-util-character@2.1.1/node_modules/micromark-util-character/index.js"],"sourcesContent":["/**\n * @import {Code} from 'micromark-util-types'\n */\n\n/**\n * Check whether the character code represents an ASCII alpha (`a` through `z`,\n * case insensitive).\n *\n * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.\n *\n * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)\n * to U+005A (`Z`).\n *\n * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)\n * to U+007A (`z`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlpha = regexCheck(/[A-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII alphanumeric (`a`\n * through `z`, case insensitive, or `0` through `9`).\n *\n * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha\n * (see `asciiAlpha`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAlphanumeric = regexCheck(/[\\dA-Za-z]/);\n\n/**\n * Check whether the character code represents an ASCII atext.\n *\n * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in\n * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),\n * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F\n * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E\n * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE\n * (`{`) to U+007E TILDE (`~`).\n *\n * See:\n * **\\[RFC5322]**:\n * [Internet Message Format](https://tools.ietf.org/html/rfc5322).\n * P. Resnick.\n * IETF.\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiAtext = regexCheck(/[#-'*+\\--9=?A-Z^-~]/);\n\n/**\n * Check whether a character code is an ASCII control character.\n *\n * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)\n * to U+001F (US), or U+007F (DEL).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function asciiControl(code) {\n return (\n // Special whitespace codes (which have negative values), C0 and Control\n // character DEL\n code !== null && (code < 32 || code === 127)\n );\n}\n\n/**\n * Check whether the character code represents an ASCII digit (`0` through `9`).\n *\n * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to\n * U+0039 (`9`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiDigit = regexCheck(/\\d/);\n\n/**\n * Check whether the character code represents an ASCII hex digit (`a` through\n * `f`, case insensitive, or `0` through `9`).\n *\n * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex\n * digit, or an ASCII lower hex digit.\n *\n * An **ASCII upper hex digit** is a character in the inclusive range U+0041\n * (`A`) to U+0046 (`F`).\n *\n * An **ASCII lower hex digit** is a character in the inclusive range U+0061\n * (`a`) to U+0066 (`f`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiHexDigit = regexCheck(/[\\dA-Fa-f]/);\n\n/**\n * Check whether the character code represents ASCII punctuation.\n *\n * An **ASCII punctuation** is a character in the inclusive ranges U+0021\n * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT\n * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT\n * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).\n *\n * @param code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);\n\n/**\n * Check whether a character code is a markdown line ending.\n *\n * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN\n * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).\n *\n * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE\n * RETURN (CR) are replaced by these virtual characters depending on whether\n * they occurred together.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEnding(code) {\n return code !== null && code < -2;\n}\n\n/**\n * Check whether a character code is a markdown line ending (see\n * `markdownLineEnding`) or markdown space (see `markdownSpace`).\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownLineEndingOrSpace(code) {\n return code !== null && (code < 0 || code === 32);\n}\n\n/**\n * Check whether a character code is a markdown space.\n *\n * A **markdown space** is the concrete character U+0020 SPACE (SP) and the\n * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).\n *\n * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is\n * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL\n * SPACE (VS) characters, depending on the column at which the tab occurred.\n *\n * @param {Code} code\n * Code.\n * @returns {boolean}\n * Whether it matches.\n */\nexport function markdownSpace(code) {\n return code === -2 || code === -1 || code === 32;\n}\n\n// Size note: removing ASCII from the regex and using `asciiPunctuation` here\n// In fact adds to the bundle size.\n/**\n * Check whether the character code represents Unicode punctuation.\n *\n * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,\n * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`\n * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`\n * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII\n * punctuation (see `asciiPunctuation`).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodePunctuation = regexCheck(/\\p{P}|\\p{S}/u);\n\n/**\n * Check whether the character code represents Unicode whitespace.\n *\n * Note that this does handle micromark specific markdown whitespace characters.\n * See `markdownLineEndingOrSpace` to check that.\n *\n * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,\n * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),\n * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\\[UNICODE]**).\n *\n * See:\n * **\\[UNICODE]**:\n * [The Unicode Standard](https://www.unicode.org/versions/).\n * Unicode Consortium.\n *\n * @param code\n * Code.\n * @returns\n * Whether it matches.\n */\nexport const unicodeWhitespace = regexCheck(/\\s/);\n\n/**\n * Create a code check from a regex.\n *\n * @param {RegExp} regex\n * Expression.\n * @returns {(code: Code) => boolean}\n * Check.\n */\nfunction regexCheck(regex) {\n return check;\n\n /**\n * Check whether a code matches the bound regex.\n *\n * @param {Code} code\n * Character code.\n * @returns {boolean}\n * Whether the character code matches the bound regex.\n */\n function check(code) {\n return code !== null && code > -1 && regex.test(String.fromCharCode(code));\n }\n}"],"names":["asciiAlpha","regexCheck","asciiAlphanumeric","asciiAtext","asciiControl","code","asciiDigit","asciiHexDigit","asciiPunctuation","markdownLineEnding","markdownLineEndingOrSpace","markdownSpace","unicodePunctuation","unicodeWhitespace","regex","check","test","String","fromCharCode"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaA,UAAU,GAAGC,UAAU,CAAC,UAAU;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,iBAAiB,GAAGD,UAAU,CAAC,YAAY;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaE,UAAU,GAAGF,UAAU,CAAC,qBAAqB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAACC,IAAI,EAAE;AACjC,EAAA;AACE;AACA;IACAA,IAAI,KAAK,IAAI,KAAKA,IAAI,GAAG,EAAE,IAAIA,IAAI,KAAK,GAAG;AAAC;AAEhD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,UAAU,GAAGL,UAAU,CAAC,IAAI;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaM,aAAa,GAAGN,UAAU,CAAC,YAAY;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaO,gBAAgB,GAAGP,UAAU,CAAC,gBAAgB;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,kBAAkBA,CAACJ,IAAI,EAAE;AACvC,EAAA,OAAOA,IAAI,KAAK,IAAI,IAAIA,IAAI,GAAG,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,yBAAyBA,CAACL,IAAI,EAAE;EAC9C,OAAOA,IAAI,KAAK,IAAI,KAAKA,IAAI,GAAG,CAAC,IAAIA,IAAI,KAAK,EAAE,CAAC;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,aAAaA,CAACN,IAAI,EAAE;AAClC,EAAA,OAAOA,IAAI,KAAK,EAAE,IAAIA,IAAI,KAAK,EAAE,IAAIA,IAAI,KAAK,EAAE;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaO,kBAAkB,GAAGX,UAAU,CAAC,cAAc;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaY,iBAAiB,GAAGZ,UAAU,CAAC,IAAI;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAUA,CAACa,KAAK,EAAE;AACzB,EAAA,OAAOC,KAAK;;AAEZ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAASA,KAAKA,CAACV,IAAI,EAAE;AACnB,IAAA,OAAOA,IAAI,KAAK,IAAI,IAAIA,IAAI,GAAG,EAAE,IAAIS,KAAK,CAACE,IAAI,CAACC,MAAM,CAACC,YAAY,CAACb,IAAI,CAAC,CAAC;AAC5E,EAAA;AACF;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count how often a character (or substring) is used in a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} value
|
|
5
|
+
* Value to search in.
|
|
6
|
+
* @param {string} character
|
|
7
|
+
* Character (or substring) to look for.
|
|
8
|
+
* @return {number}
|
|
9
|
+
* Number of times `character` occurred in `value`.
|
|
10
|
+
*/
|
|
11
|
+
function ccount(value, character) {
|
|
12
|
+
const source = String(value);
|
|
13
|
+
if (typeof character !== 'string') {
|
|
14
|
+
throw new TypeError('Expected character');
|
|
15
|
+
}
|
|
16
|
+
let count = 0;
|
|
17
|
+
let index = source.indexOf(character);
|
|
18
|
+
while (index !== -1) {
|
|
19
|
+
count++;
|
|
20
|
+
index = source.indexOf(character, index + character.length);
|
|
21
|
+
}
|
|
22
|
+
return count;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { ccount as c };
|
|
26
|
+
//# sourceMappingURL=index-k6CfLgeq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-k6CfLgeq.js","sources":["../../../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js"],"sourcesContent":["/**\n * Count how often a character (or substring) is used in a string.\n *\n * @param {string} value\n * Value to search in.\n * @param {string} character\n * Character (or substring) to look for.\n * @return {number}\n * Number of times `character` occurred in `value`.\n */\nexport function ccount(value, character) {\n const source = String(value)\n\n if (typeof character !== 'string') {\n throw new TypeError('Expected character')\n }\n\n let count = 0\n let index = source.indexOf(character)\n\n while (index !== -1) {\n count++\n index = source.indexOf(character, index + character.length)\n }\n\n return count\n}\n"],"names":["ccount","value","character","source","String","TypeError","count","index","indexOf","length"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAMA,CAACC,KAAK,EAAEC,SAAS,EAAE;AACvC,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAACH,KAAK,CAAC;AAE5B,EAAA,IAAI,OAAOC,SAAS,KAAK,QAAQ,EAAE;AACjC,IAAA,MAAM,IAAIG,SAAS,CAAC,oBAAoB,CAAC;AAC3C,EAAA;EAEA,IAAIC,KAAK,GAAG,CAAC;AACb,EAAA,IAAIC,KAAK,GAAGJ,MAAM,CAACK,OAAO,CAACN,SAAS,CAAC;AAErC,EAAA,OAAOK,KAAK,KAAK,EAAE,EAAE;AACnBD,IAAAA,KAAK,EAAE;AACPC,IAAAA,KAAK,GAAGJ,MAAM,CAACK,OAAO,CAACN,SAAS,EAAEK,KAAK,GAAGL,SAAS,CAACO,MAAM,CAAC;AAC7D,EAAA;AAEA,EAAA,OAAOH,KAAK;AACd;;;;","x_google_ignoreList":[0]}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { compile } from './compile/compile.js';
|
|
2
|
+
export { Compiled } from './compile/Compiled.js';
|
|
2
3
|
export { invocationName, invocationOf, nameFor } from './compile/utils.js';
|
|
4
|
+
export { getCompiler } from './services/compiler.js';
|
|
5
|
+
export { setup as setupCompiler } from './setup.js';
|
|
3
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { tracked } from '@glimmer/tracking';
|
|
2
|
+
import { setComponentTemplate } from '@ember/component';
|
|
3
|
+
import templateOnly from '@ember/component/template-only';
|
|
4
|
+
import { assert } from '@ember/debug';
|
|
5
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
6
|
+
import { hash, get, fn, concat, array } from '@ember/helper';
|
|
7
|
+
import { on } from '@ember/modifier';
|
|
8
|
+
import { getOwner } from '@ember/owner';
|
|
9
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
|
+
import { waitFor } from '@ember/test-waiters';
|
|
11
|
+
import { createStore } from 'ember-primitives/store';
|
|
12
|
+
import { resource } from 'ember-resources';
|
|
13
|
+
import { Compiler } from 'repl-sdk';
|
|
14
|
+
import { nameFor } from '../compile/utils.js';
|
|
15
|
+
import { modules } from './known-modules.js';
|
|
16
|
+
import { g, i, n } from 'decorator-transforms/runtime-esm';
|
|
17
|
+
import { v as visit } from '../index-CCcIVEUK.js';
|
|
18
|
+
|
|
19
|
+
/* eslint-disable getter-return */
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
function getCompiler(context) {
|
|
23
|
+
const owner = getOwner(context) ?? context;
|
|
24
|
+
assert(`Missing owner. Cannot use ember-repl's compiler without an owner.`, owner);
|
|
25
|
+
return createStore(owner, CompilerService);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Old way to make static components, because
|
|
30
|
+
* https://github.com/emberjs/ember.js/issues/20913
|
|
31
|
+
*
|
|
32
|
+
* The runtime compiler doesn't allow you to catch compiler errors.
|
|
33
|
+
* This particular component doesn't need to be runtime anyway.
|
|
34
|
+
*/
|
|
35
|
+
function rendersElement(x) {
|
|
36
|
+
const render = resource(({
|
|
37
|
+
on
|
|
38
|
+
}) => {
|
|
39
|
+
on.cleanup(() => {
|
|
40
|
+
x.destroy();
|
|
41
|
+
});
|
|
42
|
+
return x.element;
|
|
43
|
+
});
|
|
44
|
+
return setComponentTemplate(precompileTemplate(`{{render}}`, {
|
|
45
|
+
strictMode: true,
|
|
46
|
+
scope: () => ({
|
|
47
|
+
render
|
|
48
|
+
})
|
|
49
|
+
}), templateOnly());
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Standard for the REPL, not real apps.
|
|
53
|
+
* HBS isn't used in real apps (that are fully up to date)
|
|
54
|
+
*/
|
|
55
|
+
const standardScope = {
|
|
56
|
+
// These are only added here because it's convenient for hbs
|
|
57
|
+
// to have them
|
|
58
|
+
array,
|
|
59
|
+
concat,
|
|
60
|
+
fn,
|
|
61
|
+
get,
|
|
62
|
+
hash,
|
|
63
|
+
on,
|
|
64
|
+
// The default available scope for gjs:
|
|
65
|
+
//
|
|
66
|
+
// We don't use gjs transpilation here, because hbs transpilation
|
|
67
|
+
// doesn't need to go through the babel infra, so it's faster this way,
|
|
68
|
+
// even though it's more "verbose" and could get out of sync from the
|
|
69
|
+
// implementations / source-of-truth.
|
|
70
|
+
//
|
|
71
|
+
// https://github.com/emberjs/babel-plugin-ember-template-compilation/blob/main/src/scope-locals.ts#L16
|
|
72
|
+
//
|
|
73
|
+
// ////////////////
|
|
74
|
+
// namespaces
|
|
75
|
+
// ////////////////
|
|
76
|
+
// TC39
|
|
77
|
+
globalThis,
|
|
78
|
+
Atomics,
|
|
79
|
+
JSON,
|
|
80
|
+
Math,
|
|
81
|
+
Reflect,
|
|
82
|
+
// WHATWG
|
|
83
|
+
localStorage,
|
|
84
|
+
sessionStorage,
|
|
85
|
+
URL,
|
|
86
|
+
// ////////////////
|
|
87
|
+
// functions / utilities
|
|
88
|
+
// ////////////////
|
|
89
|
+
// TC39
|
|
90
|
+
isNaN,
|
|
91
|
+
isFinite,
|
|
92
|
+
parseInt,
|
|
93
|
+
parseFloat,
|
|
94
|
+
decodeURI,
|
|
95
|
+
decodeURIComponent,
|
|
96
|
+
encodeURI,
|
|
97
|
+
encodeURIComponent,
|
|
98
|
+
// WHATWG
|
|
99
|
+
postMessage,
|
|
100
|
+
structuredClone,
|
|
101
|
+
// ////////////////
|
|
102
|
+
// new-less Constructors (still functions)
|
|
103
|
+
// ////////////////
|
|
104
|
+
// TC39
|
|
105
|
+
Array,
|
|
106
|
+
// different behavior from (array)
|
|
107
|
+
BigInt,
|
|
108
|
+
Boolean,
|
|
109
|
+
Date,
|
|
110
|
+
Number,
|
|
111
|
+
Object,
|
|
112
|
+
// different behavior from (hash)
|
|
113
|
+
String,
|
|
114
|
+
// ////////////////
|
|
115
|
+
// Values
|
|
116
|
+
// ////////////////
|
|
117
|
+
// TC39
|
|
118
|
+
Infinity,
|
|
119
|
+
NaN,
|
|
120
|
+
// WHATWG
|
|
121
|
+
isSecureContext
|
|
122
|
+
};
|
|
123
|
+
class CompilerService {
|
|
124
|
+
#compiler;
|
|
125
|
+
constructor() {
|
|
126
|
+
const global = getGlobal();
|
|
127
|
+
global.REPL ||= {};
|
|
128
|
+
if (global.REPL.compiler) {
|
|
129
|
+
return global.REPL.compiler;
|
|
130
|
+
}
|
|
131
|
+
global.REPL.compiler = this;
|
|
132
|
+
registerDestructor(this, () => {
|
|
133
|
+
delete global.REPL?.compiler;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
static {
|
|
137
|
+
g(this.prototype, "messages", [tracked], function () {
|
|
138
|
+
return [];
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
#messages = (i(this, "messages"), void 0);
|
|
142
|
+
get lastInfo() {
|
|
143
|
+
const m = this.messages;
|
|
144
|
+
for (let i = m.length - 1; i >= 0; i--) {
|
|
145
|
+
const current = m[i];
|
|
146
|
+
if (current?.type === 'info') return current;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
get lastError() {
|
|
150
|
+
const m = this.messages;
|
|
151
|
+
for (let i = m.length - 1; i >= 0; i--) {
|
|
152
|
+
const current = m[i];
|
|
153
|
+
if (current?.type === 'error') return current;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {ModuleMap} [ extraModules ]: map of import paths to modules.
|
|
159
|
+
* These modules are useful if you need to document a library or a any design system or a styleguide or
|
|
160
|
+
* if there are additional modules that could be imported in the passed `code`.
|
|
161
|
+
* @param {object} [options] optional compiler options for each format/flavor
|
|
162
|
+
*
|
|
163
|
+
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
164
|
+
* are not provided by extraModules will be searched on npm to see if a package
|
|
165
|
+
* needs to be downloaded before running the `code` / invoking the component
|
|
166
|
+
*/
|
|
167
|
+
setup = (extraModules = {}, options = {}) => {
|
|
168
|
+
const localModules = modules(extraModules);
|
|
169
|
+
this.#compiler = new Compiler({
|
|
170
|
+
logging: location.search.includes('debug'),
|
|
171
|
+
resolve: {
|
|
172
|
+
...localModules
|
|
173
|
+
},
|
|
174
|
+
on: {
|
|
175
|
+
log: (type, message) => {
|
|
176
|
+
this.messages.push({
|
|
177
|
+
type,
|
|
178
|
+
message
|
|
179
|
+
});
|
|
180
|
+
// Waiting on better array primitive
|
|
181
|
+
// eslint-disable-next-line no-self-assign
|
|
182
|
+
this.messages = this.messages;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
options: {
|
|
186
|
+
...options,
|
|
187
|
+
gjs: {
|
|
188
|
+
// owner: getOwner(this),
|
|
189
|
+
owner: {
|
|
190
|
+
lookup: () => {},
|
|
191
|
+
resolveRegistration: () => {}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
gmd: {
|
|
195
|
+
...(options.gmd ?? {}),
|
|
196
|
+
scope: {
|
|
197
|
+
...standardScope,
|
|
198
|
+
...(options.gmd?.scope ?? {})
|
|
199
|
+
},
|
|
200
|
+
remarkPlugins: [function defaultHbsToEmber() {
|
|
201
|
+
return function transformer(tree) {
|
|
202
|
+
visit(tree, 'code', node => {
|
|
203
|
+
if (node.lang === 'hbs') {
|
|
204
|
+
if (!node.meta) {
|
|
205
|
+
node.meta = 'ember';
|
|
206
|
+
} else {
|
|
207
|
+
node.meta += ' ember';
|
|
208
|
+
}
|
|
209
|
+
return node;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return tree;
|
|
213
|
+
};
|
|
214
|
+
}, ...(options.gmd?.remarkPlugins ?? [])]
|
|
215
|
+
},
|
|
216
|
+
hbs: {
|
|
217
|
+
ember: {
|
|
218
|
+
...(options.hbs ?? {}),
|
|
219
|
+
scope: {
|
|
220
|
+
...standardScope,
|
|
221
|
+
...(options.hbs?.scope ?? {})
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
get compiler() {
|
|
229
|
+
/**
|
|
230
|
+
* This is useful for our own testing.
|
|
231
|
+
* not sure if this would be a footgun for consumers' usage
|
|
232
|
+
*/
|
|
233
|
+
if (!this.#compiler) {
|
|
234
|
+
this.setup();
|
|
235
|
+
}
|
|
236
|
+
assert(`Expected a compiled to be setup on the compiler service. Use \`compiler.setup()\` first.`, this.#compiler);
|
|
237
|
+
return this.#compiler;
|
|
238
|
+
}
|
|
239
|
+
async createEditor(element, options) {
|
|
240
|
+
return this.compiler.createEditor(element, options);
|
|
241
|
+
}
|
|
242
|
+
async #compile(ext, text, options) {
|
|
243
|
+
/**
|
|
244
|
+
* Protect from accidental backtracking-render assertions
|
|
245
|
+
* (infinite loop protection)
|
|
246
|
+
*
|
|
247
|
+
* This function doesn't ready any tracked data, so we don't need to
|
|
248
|
+
* worry about invalidation or anything.
|
|
249
|
+
*/
|
|
250
|
+
await Promise.resolve();
|
|
251
|
+
this.messages = [];
|
|
252
|
+
return this.compiler.compile(ext, text, options ?? {});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @public
|
|
257
|
+
*
|
|
258
|
+
* Defers to the underlying repl-SDK and gives us a component we can render.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} ext the ext/format to be compiled
|
|
261
|
+
* @param {string} text the code to be compiled using the configured compiler for the ext
|
|
262
|
+
*/
|
|
263
|
+
async compile(ext, text, options) {
|
|
264
|
+
const name = nameFor(text);
|
|
265
|
+
let component;
|
|
266
|
+
let error;
|
|
267
|
+
try {
|
|
268
|
+
if (ext === 'hbs') {
|
|
269
|
+
/**
|
|
270
|
+
* Are there other hbs-using frameworks?
|
|
271
|
+
*/
|
|
272
|
+
options ||= {};
|
|
273
|
+
options.flavor = 'ember';
|
|
274
|
+
}
|
|
275
|
+
const result = await this.#compile(ext, text, options);
|
|
276
|
+
component = rendersElement(result);
|
|
277
|
+
} catch (e) {
|
|
278
|
+
// Put a breakpoint here to debug
|
|
279
|
+
// debugger;
|
|
280
|
+
console.error(e);
|
|
281
|
+
error = e;
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
name,
|
|
285
|
+
component,
|
|
286
|
+
error
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @public
|
|
292
|
+
*
|
|
293
|
+
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
294
|
+
* The returned component can be invoked explicitly in the consuming project.
|
|
295
|
+
*
|
|
296
|
+
* @param {string} code the code to be compiled
|
|
297
|
+
*/
|
|
298
|
+
static {
|
|
299
|
+
n(this.prototype, "compile", [waitFor]);
|
|
300
|
+
}
|
|
301
|
+
compileGJS(code) {
|
|
302
|
+
return this.compile('gjs', code);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* compile a template with an empty scope
|
|
307
|
+
* to use components, helpers, etc, you will need to compile with JS
|
|
308
|
+
*
|
|
309
|
+
* (templates alone do not have a way to import / define complex structures)
|
|
310
|
+
*/
|
|
311
|
+
async compileHBS(source, options = {}) {
|
|
312
|
+
return this.compile('hbs', source, options);
|
|
313
|
+
}
|
|
314
|
+
static {
|
|
315
|
+
n(this.prototype, "compileHBS", [waitFor]);
|
|
316
|
+
}
|
|
317
|
+
compileMD(source, options) {
|
|
318
|
+
return this.compile('md', source, options);
|
|
319
|
+
}
|
|
320
|
+
static {
|
|
321
|
+
n(this.prototype, "compileMD", [waitFor]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function getGlobal() {
|
|
325
|
+
return globalThis;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export { CompilerService as default, getCompiler };
|
|
329
|
+
//# sourceMappingURL=compiler.js.map
|