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,482 @@
|
|
|
1
|
+
import { m as markdownLineEndingOrSpace, u as unicodeWhitespace, a as unicodePunctuation, f as markdownSpace, e as markdownLineEnding } from './index-ZyJlPFQY.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalize an identifier (as found in references, definitions).
|
|
5
|
+
*
|
|
6
|
+
* Collapses markdown whitespace, trim, and then lower- and uppercase.
|
|
7
|
+
*
|
|
8
|
+
* Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their
|
|
9
|
+
* lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different
|
|
10
|
+
* uppercase character (U+0398 (`Θ`)).
|
|
11
|
+
* So, to get a canonical form, we perform both lower- and uppercase.
|
|
12
|
+
*
|
|
13
|
+
* Using uppercase last makes sure keys will never interact with default
|
|
14
|
+
* prototypal values (such as `constructor`): nothing in the prototype of
|
|
15
|
+
* `Object` is uppercase.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} value
|
|
18
|
+
* Identifier to normalize.
|
|
19
|
+
* @returns {string}
|
|
20
|
+
* Normalized identifier.
|
|
21
|
+
*/
|
|
22
|
+
function normalizeIdentifier(value) {
|
|
23
|
+
return value
|
|
24
|
+
// Collapse markdown whitespace.
|
|
25
|
+
.replace(/[\t\n\r ]+/g, " ")
|
|
26
|
+
// Trim.
|
|
27
|
+
.replace(/^ | $/g, '')
|
|
28
|
+
// Some characters are considered “uppercase”, but if their lowercase
|
|
29
|
+
// counterpart is uppercased will result in a different uppercase
|
|
30
|
+
// character.
|
|
31
|
+
// Hence, to get that form, we perform both lower- and uppercase.
|
|
32
|
+
// Upper case makes sure keys will not interact with default prototypal
|
|
33
|
+
// methods: no method is uppercase.
|
|
34
|
+
.toLowerCase().toUpperCase();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @import {Code} from 'micromark-util-types'
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Classify whether a code represents whitespace, punctuation, or something
|
|
43
|
+
* else.
|
|
44
|
+
*
|
|
45
|
+
* Used for attention (emphasis, strong), whose sequences can open or close
|
|
46
|
+
* based on the class of surrounding characters.
|
|
47
|
+
*
|
|
48
|
+
* > 👉 **Note**: eof (`null`) is seen as whitespace.
|
|
49
|
+
*
|
|
50
|
+
* @param {Code} code
|
|
51
|
+
* Code.
|
|
52
|
+
* @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
|
|
53
|
+
* Group.
|
|
54
|
+
*/
|
|
55
|
+
function classifyCharacter(code) {
|
|
56
|
+
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
if (unicodePunctuation(code)) {
|
|
60
|
+
return 2;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {import('mdast').Nodes} Nodes
|
|
66
|
+
*
|
|
67
|
+
* @typedef Options
|
|
68
|
+
* Configuration (optional).
|
|
69
|
+
* @property {boolean | null | undefined} [includeImageAlt=true]
|
|
70
|
+
* Whether to use `alt` for `image`s (default: `true`).
|
|
71
|
+
* @property {boolean | null | undefined} [includeHtml=true]
|
|
72
|
+
* Whether to use `value` of HTML (default: `true`).
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/** @type {Options} */
|
|
76
|
+
const emptyOptions = {};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get the text content of a node or list of nodes.
|
|
80
|
+
*
|
|
81
|
+
* Prefers the node’s plain-text fields, otherwise serializes its children,
|
|
82
|
+
* and if the given value is an array, serialize the nodes in it.
|
|
83
|
+
*
|
|
84
|
+
* @param {unknown} [value]
|
|
85
|
+
* Thing to serialize, typically `Node`.
|
|
86
|
+
* @param {Options | null | undefined} [options]
|
|
87
|
+
* Configuration (optional).
|
|
88
|
+
* @returns {string}
|
|
89
|
+
* Serialized `value`.
|
|
90
|
+
*/
|
|
91
|
+
function toString(value, options) {
|
|
92
|
+
const settings = emptyOptions;
|
|
93
|
+
const includeImageAlt = typeof settings.includeImageAlt === 'boolean' ? settings.includeImageAlt : true;
|
|
94
|
+
const includeHtml = typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true;
|
|
95
|
+
return one(value, includeImageAlt, includeHtml);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* One node or several nodes.
|
|
100
|
+
*
|
|
101
|
+
* @param {unknown} value
|
|
102
|
+
* Thing to serialize.
|
|
103
|
+
* @param {boolean} includeImageAlt
|
|
104
|
+
* Include image `alt`s.
|
|
105
|
+
* @param {boolean} includeHtml
|
|
106
|
+
* Include HTML.
|
|
107
|
+
* @returns {string}
|
|
108
|
+
* Serialized node.
|
|
109
|
+
*/
|
|
110
|
+
function one(value, includeImageAlt, includeHtml) {
|
|
111
|
+
if (node(value)) {
|
|
112
|
+
if ('value' in value) {
|
|
113
|
+
return value.type === 'html' && !includeHtml ? '' : value.value;
|
|
114
|
+
}
|
|
115
|
+
if (includeImageAlt && 'alt' in value && value.alt) {
|
|
116
|
+
return value.alt;
|
|
117
|
+
}
|
|
118
|
+
if ('children' in value) {
|
|
119
|
+
return all(value.children, includeImageAlt, includeHtml);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
return all(value, includeImageAlt, includeHtml);
|
|
124
|
+
}
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Serialize a list of nodes.
|
|
130
|
+
*
|
|
131
|
+
* @param {Array<unknown>} values
|
|
132
|
+
* Thing to serialize.
|
|
133
|
+
* @param {boolean} includeImageAlt
|
|
134
|
+
* Include image `alt`s.
|
|
135
|
+
* @param {boolean} includeHtml
|
|
136
|
+
* Include HTML.
|
|
137
|
+
* @returns {string}
|
|
138
|
+
* Serialized nodes.
|
|
139
|
+
*/
|
|
140
|
+
function all(values, includeImageAlt, includeHtml) {
|
|
141
|
+
/** @type {Array<string>} */
|
|
142
|
+
const result = [];
|
|
143
|
+
let index = -1;
|
|
144
|
+
while (++index < values.length) {
|
|
145
|
+
result[index] = one(values[index], includeImageAlt, includeHtml);
|
|
146
|
+
}
|
|
147
|
+
return result.join('');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Check if `value` looks like a node.
|
|
152
|
+
*
|
|
153
|
+
* @param {unknown} value
|
|
154
|
+
* Thing.
|
|
155
|
+
* @returns {value is Nodes}
|
|
156
|
+
* Whether `value` is a node.
|
|
157
|
+
*/
|
|
158
|
+
function node(value) {
|
|
159
|
+
return Boolean(value && typeof value === 'object');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Like `Array#splice`, but smarter for giant arrays.
|
|
164
|
+
*
|
|
165
|
+
* `Array#splice` takes all items to be inserted as individual argument which
|
|
166
|
+
* causes a stack overflow in V8 when trying to insert 100k items for instance.
|
|
167
|
+
*
|
|
168
|
+
* Otherwise, this does not return the removed items, and takes `items` as an
|
|
169
|
+
* array instead of rest parameters.
|
|
170
|
+
*
|
|
171
|
+
* @template {unknown} T
|
|
172
|
+
* Item type.
|
|
173
|
+
* @param {Array<T>} list
|
|
174
|
+
* List to operate on.
|
|
175
|
+
* @param {number} start
|
|
176
|
+
* Index to remove/insert at (can be negative).
|
|
177
|
+
* @param {number} remove
|
|
178
|
+
* Number of items to remove.
|
|
179
|
+
* @param {Array<T>} items
|
|
180
|
+
* Items to inject into `list`.
|
|
181
|
+
* @returns {undefined}
|
|
182
|
+
* Nothing.
|
|
183
|
+
*/
|
|
184
|
+
function splice(list, start, remove, items) {
|
|
185
|
+
const end = list.length;
|
|
186
|
+
let chunkStart = 0;
|
|
187
|
+
/** @type {Array<unknown>} */
|
|
188
|
+
let parameters;
|
|
189
|
+
|
|
190
|
+
// Make start between zero and `end` (included).
|
|
191
|
+
if (start < 0) {
|
|
192
|
+
start = -start > end ? 0 : end + start;
|
|
193
|
+
} else {
|
|
194
|
+
start = start > end ? end : start;
|
|
195
|
+
}
|
|
196
|
+
remove = remove > 0 ? remove : 0;
|
|
197
|
+
|
|
198
|
+
// No need to chunk the items if there’s only a couple (10k) items.
|
|
199
|
+
if (items.length < 10000) {
|
|
200
|
+
parameters = Array.from(items);
|
|
201
|
+
parameters.unshift(start, remove);
|
|
202
|
+
// @ts-expect-error Hush, it’s fine.
|
|
203
|
+
list.splice(...parameters);
|
|
204
|
+
} else {
|
|
205
|
+
// Delete `remove` items starting from `start`
|
|
206
|
+
if (remove) list.splice(start, remove);
|
|
207
|
+
|
|
208
|
+
// Insert the items in chunks to not cause stack overflows.
|
|
209
|
+
while (chunkStart < items.length) {
|
|
210
|
+
parameters = items.slice(chunkStart, chunkStart + 10000);
|
|
211
|
+
parameters.unshift(start, 0);
|
|
212
|
+
// @ts-expect-error Hush, it’s fine.
|
|
213
|
+
list.splice(...parameters);
|
|
214
|
+
chunkStart += 10000;
|
|
215
|
+
start += 10000;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Append `items` (an array) at the end of `list` (another array).
|
|
222
|
+
* When `list` was empty, returns `items` instead.
|
|
223
|
+
*
|
|
224
|
+
* This prevents a potentially expensive operation when `list` is empty,
|
|
225
|
+
* and adds items in batches to prevent V8 from hanging.
|
|
226
|
+
*
|
|
227
|
+
* @template {unknown} T
|
|
228
|
+
* Item type.
|
|
229
|
+
* @param {Array<T>} list
|
|
230
|
+
* List to operate on.
|
|
231
|
+
* @param {Array<T>} items
|
|
232
|
+
* Items to add to `list`.
|
|
233
|
+
* @returns {Array<T>}
|
|
234
|
+
* Either `list` or `items`.
|
|
235
|
+
*/
|
|
236
|
+
function push(list, items) {
|
|
237
|
+
if (list.length > 0) {
|
|
238
|
+
splice(list, list.length, 0, items);
|
|
239
|
+
return list;
|
|
240
|
+
}
|
|
241
|
+
return items;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @import {
|
|
246
|
+
* Extension,
|
|
247
|
+
* Handles,
|
|
248
|
+
* HtmlExtension,
|
|
249
|
+
* NormalizedExtension
|
|
250
|
+
* } from 'micromark-util-types'
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
const hasOwnProperty = {}.hasOwnProperty;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Combine multiple syntax extensions into one.
|
|
257
|
+
*
|
|
258
|
+
* @param {ReadonlyArray<Extension>} extensions
|
|
259
|
+
* List of syntax extensions.
|
|
260
|
+
* @returns {NormalizedExtension}
|
|
261
|
+
* A single combined extension.
|
|
262
|
+
*/
|
|
263
|
+
function combineExtensions(extensions) {
|
|
264
|
+
/** @type {NormalizedExtension} */
|
|
265
|
+
const all = {};
|
|
266
|
+
let index = -1;
|
|
267
|
+
while (++index < extensions.length) {
|
|
268
|
+
syntaxExtension(all, extensions[index]);
|
|
269
|
+
}
|
|
270
|
+
return all;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Merge `extension` into `all`.
|
|
275
|
+
*
|
|
276
|
+
* @param {NormalizedExtension} all
|
|
277
|
+
* Extension to merge into.
|
|
278
|
+
* @param {Extension} extension
|
|
279
|
+
* Extension to merge.
|
|
280
|
+
* @returns {undefined}
|
|
281
|
+
* Nothing.
|
|
282
|
+
*/
|
|
283
|
+
function syntaxExtension(all, extension) {
|
|
284
|
+
/** @type {keyof Extension} */
|
|
285
|
+
let hook;
|
|
286
|
+
for (hook in extension) {
|
|
287
|
+
const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined;
|
|
288
|
+
/** @type {Record<string, unknown>} */
|
|
289
|
+
const left = maybe || (all[hook] = {});
|
|
290
|
+
/** @type {Record<string, unknown> | undefined} */
|
|
291
|
+
const right = extension[hook];
|
|
292
|
+
/** @type {string} */
|
|
293
|
+
let code;
|
|
294
|
+
if (right) {
|
|
295
|
+
for (code in right) {
|
|
296
|
+
if (!hasOwnProperty.call(left, code)) left[code] = [];
|
|
297
|
+
const value = right[code];
|
|
298
|
+
constructs(
|
|
299
|
+
// @ts-expect-error Looks like a list.
|
|
300
|
+
left[code], Array.isArray(value) ? value : value ? [value] : []);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Merge `list` into `existing` (both lists of constructs).
|
|
308
|
+
* Mutates `existing`.
|
|
309
|
+
*
|
|
310
|
+
* @param {Array<unknown>} existing
|
|
311
|
+
* List of constructs to merge into.
|
|
312
|
+
* @param {Array<unknown>} list
|
|
313
|
+
* List of constructs to merge.
|
|
314
|
+
* @returns {undefined}
|
|
315
|
+
* Nothing.
|
|
316
|
+
*/
|
|
317
|
+
function constructs(existing, list) {
|
|
318
|
+
let index = -1;
|
|
319
|
+
/** @type {Array<unknown>} */
|
|
320
|
+
const before = [];
|
|
321
|
+
while (++index < list.length) {
|
|
322
|
+
(list[index].add === 'after' ? existing : before).push(list[index]);
|
|
323
|
+
}
|
|
324
|
+
splice(existing, 0, 0, before);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @import {Event, Resolver, TokenizeContext} from 'micromark-util-types'
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Call all `resolveAll`s.
|
|
333
|
+
*
|
|
334
|
+
* @param {ReadonlyArray<{resolveAll?: Resolver | undefined}>} constructs
|
|
335
|
+
* List of constructs, optionally with `resolveAll`s.
|
|
336
|
+
* @param {Array<Event>} events
|
|
337
|
+
* List of events.
|
|
338
|
+
* @param {TokenizeContext} context
|
|
339
|
+
* Context used by `tokenize`.
|
|
340
|
+
* @returns {Array<Event>}
|
|
341
|
+
* Changed events.
|
|
342
|
+
*/
|
|
343
|
+
function resolveAll(constructs, events, context) {
|
|
344
|
+
/** @type {Array<Resolver>} */
|
|
345
|
+
const called = [];
|
|
346
|
+
let index = -1;
|
|
347
|
+
while (++index < constructs.length) {
|
|
348
|
+
const resolve = constructs[index].resolveAll;
|
|
349
|
+
if (resolve && !called.includes(resolve)) {
|
|
350
|
+
events = resolve(events, context);
|
|
351
|
+
called.push(resolve);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return events;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @import {Effects, State, TokenType} from 'micromark-util-types'
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Parse spaces and tabs.
|
|
366
|
+
*
|
|
367
|
+
* There is no `nok` parameter:
|
|
368
|
+
*
|
|
369
|
+
* * spaces in markdown are often optional, in which case this factory can be
|
|
370
|
+
* used and `ok` will be switched to whether spaces were found or not
|
|
371
|
+
* * one line ending or space can be detected with `markdownSpace(code)` right
|
|
372
|
+
* before using `factorySpace`
|
|
373
|
+
*
|
|
374
|
+
* ###### Examples
|
|
375
|
+
*
|
|
376
|
+
* Where `␉` represents a tab (plus how much it expands) and `␠` represents a
|
|
377
|
+
* single space.
|
|
378
|
+
*
|
|
379
|
+
* ```markdown
|
|
380
|
+
* ␉
|
|
381
|
+
* ␠␠␠␠
|
|
382
|
+
* ␉␠
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
385
|
+
* @param {Effects} effects
|
|
386
|
+
* Context.
|
|
387
|
+
* @param {State} ok
|
|
388
|
+
* State switched to when successful.
|
|
389
|
+
* @param {TokenType} type
|
|
390
|
+
* Type (`' \t'`).
|
|
391
|
+
* @param {number | undefined} [max=Infinity]
|
|
392
|
+
* Max (exclusive).
|
|
393
|
+
* @returns {State}
|
|
394
|
+
* Start state.
|
|
395
|
+
*/
|
|
396
|
+
function factorySpace(effects, ok, type, max) {
|
|
397
|
+
const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
|
|
398
|
+
let size = 0;
|
|
399
|
+
return start;
|
|
400
|
+
|
|
401
|
+
/** @type {State} */
|
|
402
|
+
function start(code) {
|
|
403
|
+
if (markdownSpace(code)) {
|
|
404
|
+
effects.enter(type);
|
|
405
|
+
return prefix(code);
|
|
406
|
+
}
|
|
407
|
+
return ok(code);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** @type {State} */
|
|
411
|
+
function prefix(code) {
|
|
412
|
+
if (markdownSpace(code) && size++ < limit) {
|
|
413
|
+
effects.consume(code);
|
|
414
|
+
return prefix;
|
|
415
|
+
}
|
|
416
|
+
effects.exit(type);
|
|
417
|
+
return ok(code);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* @import {
|
|
423
|
+
* Construct,
|
|
424
|
+
* State,
|
|
425
|
+
* TokenizeContext,
|
|
426
|
+
* Tokenizer
|
|
427
|
+
* } from 'micromark-util-types'
|
|
428
|
+
*/
|
|
429
|
+
|
|
430
|
+
/** @type {Construct} */
|
|
431
|
+
const blankLine = {
|
|
432
|
+
partial: true,
|
|
433
|
+
tokenize: tokenizeBlankLine
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @this {TokenizeContext}
|
|
438
|
+
* Context.
|
|
439
|
+
* @type {Tokenizer}
|
|
440
|
+
*/
|
|
441
|
+
function tokenizeBlankLine(effects, ok, nok) {
|
|
442
|
+
return start;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Start of blank line.
|
|
446
|
+
*
|
|
447
|
+
* > 👉 **Note**: `␠` represents a space character.
|
|
448
|
+
*
|
|
449
|
+
* ```markdown
|
|
450
|
+
* > | ␠␠␊
|
|
451
|
+
* ^
|
|
452
|
+
* > | ␊
|
|
453
|
+
* ^
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @type {State}
|
|
457
|
+
*/
|
|
458
|
+
function start(code) {
|
|
459
|
+
return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* At eof/eol, after optional whitespace.
|
|
464
|
+
*
|
|
465
|
+
* > 👉 **Note**: `␠` represents a space character.
|
|
466
|
+
*
|
|
467
|
+
* ```markdown
|
|
468
|
+
* > | ␠␠␊
|
|
469
|
+
* ^
|
|
470
|
+
* > | ␊
|
|
471
|
+
* ^
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* @type {State}
|
|
475
|
+
*/
|
|
476
|
+
function after(code) {
|
|
477
|
+
return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export { combineExtensions as a, blankLine as b, classifyCharacter as c, factorySpace as f, normalizeIdentifier as n, push as p, resolveAll as r, splice as s, toString as t };
|
|
482
|
+
//# sourceMappingURL=blank-line-Bzg2Qt4K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blank-line-Bzg2Qt4K.js","sources":["../../../node_modules/.pnpm/micromark-util-normalize-identifier@2.0.1/node_modules/micromark-util-normalize-identifier/index.js","../../../node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/index.js","../../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js","../../../node_modules/.pnpm/micromark-util-chunked@2.0.1/node_modules/micromark-util-chunked/index.js","../../../node_modules/.pnpm/micromark-util-combine-extensions@2.0.1/node_modules/micromark-util-combine-extensions/index.js","../../../node_modules/.pnpm/micromark-util-resolve-all@2.0.1/node_modules/micromark-util-resolve-all/index.js","../../../node_modules/.pnpm/micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.js","../../../node_modules/.pnpm/micromark-core-commonmark@2.0.3/node_modules/micromark-core-commonmark/lib/blank-line.js"],"sourcesContent":["/**\n * Normalize an identifier (as found in references, definitions).\n *\n * Collapses markdown whitespace, trim, and then lower- and uppercase.\n *\n * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their\n * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different\n * uppercase character (U+0398 (`Θ`)).\n * So, to get a canonical form, we perform both lower- and uppercase.\n *\n * Using uppercase last makes sure keys will never interact with default\n * prototypal values (such as `constructor`): nothing in the prototype of\n * `Object` is uppercase.\n *\n * @param {string} value\n * Identifier to normalize.\n * @returns {string}\n * Normalized identifier.\n */\nexport function normalizeIdentifier(value) {\n return value\n // Collapse markdown whitespace.\n .replace(/[\\t\\n\\r ]+/g, \" \")\n // Trim.\n .replace(/^ | $/g, '')\n // Some characters are considered “uppercase”, but if their lowercase\n // counterpart is uppercased will result in a different uppercase\n // character.\n // Hence, to get that form, we perform both lower- and uppercase.\n // Upper case makes sure keys will not interact with default prototypal\n // methods: no method is uppercase.\n .toLowerCase().toUpperCase();\n}","/**\n * @import {Code} from 'micromark-util-types'\n */\n\nimport { markdownLineEndingOrSpace, unicodePunctuation, unicodeWhitespace } from 'micromark-util-character';\n/**\n * Classify whether a code represents whitespace, punctuation, or something\n * else.\n *\n * Used for attention (emphasis, strong), whose sequences can open or close\n * based on the class of surrounding characters.\n *\n * > 👉 **Note**: eof (`null`) is seen as whitespace.\n *\n * @param {Code} code\n * Code.\n * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}\n * Group.\n */\nexport function classifyCharacter(code) {\n if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {\n return 1;\n }\n if (unicodePunctuation(code)) {\n return 2;\n }\n}","/**\n * @typedef {import('mdast').Nodes} Nodes\n *\n * @typedef Options\n * Configuration (optional).\n * @property {boolean | null | undefined} [includeImageAlt=true]\n * Whether to use `alt` for `image`s (default: `true`).\n * @property {boolean | null | undefined} [includeHtml=true]\n * Whether to use `value` of HTML (default: `true`).\n */\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Get the text content of a node or list of nodes.\n *\n * Prefers the node’s plain-text fields, otherwise serializes its children,\n * and if the given value is an array, serialize the nodes in it.\n *\n * @param {unknown} [value]\n * Thing to serialize, typically `Node`.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {string}\n * Serialized `value`.\n */\nexport function toString(value, options) {\n const settings = options || emptyOptions\n const includeImageAlt =\n typeof settings.includeImageAlt === 'boolean'\n ? settings.includeImageAlt\n : true\n const includeHtml =\n typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true\n\n return one(value, includeImageAlt, includeHtml)\n}\n\n/**\n * One node or several nodes.\n *\n * @param {unknown} value\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized node.\n */\nfunction one(value, includeImageAlt, includeHtml) {\n if (node(value)) {\n if ('value' in value) {\n return value.type === 'html' && !includeHtml ? '' : value.value\n }\n\n if (includeImageAlt && 'alt' in value && value.alt) {\n return value.alt\n }\n\n if ('children' in value) {\n return all(value.children, includeImageAlt, includeHtml)\n }\n }\n\n if (Array.isArray(value)) {\n return all(value, includeImageAlt, includeHtml)\n }\n\n return ''\n}\n\n/**\n * Serialize a list of nodes.\n *\n * @param {Array<unknown>} values\n * Thing to serialize.\n * @param {boolean} includeImageAlt\n * Include image `alt`s.\n * @param {boolean} includeHtml\n * Include HTML.\n * @returns {string}\n * Serialized nodes.\n */\nfunction all(values, includeImageAlt, includeHtml) {\n /** @type {Array<string>} */\n const result = []\n let index = -1\n\n while (++index < values.length) {\n result[index] = one(values[index], includeImageAlt, includeHtml)\n }\n\n return result.join('')\n}\n\n/**\n * Check if `value` looks like a node.\n *\n * @param {unknown} value\n * Thing.\n * @returns {value is Nodes}\n * Whether `value` is a node.\n */\nfunction node(value) {\n return Boolean(value && typeof value === 'object')\n}\n","/**\n * Like `Array#splice`, but smarter for giant arrays.\n *\n * `Array#splice` takes all items to be inserted as individual argument which\n * causes a stack overflow in V8 when trying to insert 100k items for instance.\n *\n * Otherwise, this does not return the removed items, and takes `items` as an\n * array instead of rest parameters.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {number} start\n * Index to remove/insert at (can be negative).\n * @param {number} remove\n * Number of items to remove.\n * @param {Array<T>} items\n * Items to inject into `list`.\n * @returns {undefined}\n * Nothing.\n */\nexport function splice(list, start, remove, items) {\n const end = list.length;\n let chunkStart = 0;\n /** @type {Array<unknown>} */\n let parameters;\n\n // Make start between zero and `end` (included).\n if (start < 0) {\n start = -start > end ? 0 : end + start;\n } else {\n start = start > end ? end : start;\n }\n remove = remove > 0 ? remove : 0;\n\n // No need to chunk the items if there’s only a couple (10k) items.\n if (items.length < 10000) {\n parameters = Array.from(items);\n parameters.unshift(start, remove);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n } else {\n // Delete `remove` items starting from `start`\n if (remove) list.splice(start, remove);\n\n // Insert the items in chunks to not cause stack overflows.\n while (chunkStart < items.length) {\n parameters = items.slice(chunkStart, chunkStart + 10000);\n parameters.unshift(start, 0);\n // @ts-expect-error Hush, it’s fine.\n list.splice(...parameters);\n chunkStart += 10000;\n start += 10000;\n }\n }\n}\n\n/**\n * Append `items` (an array) at the end of `list` (another array).\n * When `list` was empty, returns `items` instead.\n *\n * This prevents a potentially expensive operation when `list` is empty,\n * and adds items in batches to prevent V8 from hanging.\n *\n * @template {unknown} T\n * Item type.\n * @param {Array<T>} list\n * List to operate on.\n * @param {Array<T>} items\n * Items to add to `list`.\n * @returns {Array<T>}\n * Either `list` or `items`.\n */\nexport function push(list, items) {\n if (list.length > 0) {\n splice(list, list.length, 0, items);\n return list;\n }\n return items;\n}","/**\n * @import {\n * Extension,\n * Handles,\n * HtmlExtension,\n * NormalizedExtension\n * } from 'micromark-util-types'\n */\n\nimport {splice} from 'micromark-util-chunked'\n\nconst hasOwnProperty = {}.hasOwnProperty\n\n/**\n * Combine multiple syntax extensions into one.\n *\n * @param {ReadonlyArray<Extension>} extensions\n * List of syntax extensions.\n * @returns {NormalizedExtension}\n * A single combined extension.\n */\nexport function combineExtensions(extensions) {\n /** @type {NormalizedExtension} */\n const all = {}\n let index = -1\n\n while (++index < extensions.length) {\n syntaxExtension(all, extensions[index])\n }\n\n return all\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {NormalizedExtension} all\n * Extension to merge into.\n * @param {Extension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction syntaxExtension(all, extension) {\n /** @type {keyof Extension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n /** @type {Record<string, unknown>} */\n const left = maybe || (all[hook] = {})\n /** @type {Record<string, unknown> | undefined} */\n const right = extension[hook]\n /** @type {string} */\n let code\n\n if (right) {\n for (code in right) {\n if (!hasOwnProperty.call(left, code)) left[code] = []\n const value = right[code]\n constructs(\n // @ts-expect-error Looks like a list.\n left[code],\n Array.isArray(value) ? value : value ? [value] : []\n )\n }\n }\n }\n}\n\n/**\n * Merge `list` into `existing` (both lists of constructs).\n * Mutates `existing`.\n *\n * @param {Array<unknown>} existing\n * List of constructs to merge into.\n * @param {Array<unknown>} list\n * List of constructs to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction constructs(existing, list) {\n let index = -1\n /** @type {Array<unknown>} */\n const before = []\n\n while (++index < list.length) {\n // @ts-expect-error Looks like an object.\n ;(list[index].add === 'after' ? existing : before).push(list[index])\n }\n\n splice(existing, 0, 0, before)\n}\n\n/**\n * Combine multiple HTML extensions into one.\n *\n * @param {ReadonlyArray<HtmlExtension>} htmlExtensions\n * List of HTML extensions.\n * @returns {HtmlExtension}\n * Single combined HTML extension.\n */\nexport function combineHtmlExtensions(htmlExtensions) {\n /** @type {HtmlExtension} */\n const handlers = {}\n let index = -1\n\n while (++index < htmlExtensions.length) {\n htmlExtension(handlers, htmlExtensions[index])\n }\n\n return handlers\n}\n\n/**\n * Merge `extension` into `all`.\n *\n * @param {HtmlExtension} all\n * Extension to merge into.\n * @param {HtmlExtension} extension\n * Extension to merge.\n * @returns {undefined}\n * Nothing.\n */\nfunction htmlExtension(all, extension) {\n /** @type {keyof HtmlExtension} */\n let hook\n\n for (hook in extension) {\n const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined\n const left = maybe || (all[hook] = {})\n const right = extension[hook]\n /** @type {keyof Handles} */\n let type\n\n if (right) {\n for (type in right) {\n // @ts-expect-error assume document vs regular handler are managed correctly.\n left[type] = right[type]\n }\n }\n }\n}\n","/**\n * @import {Event, Resolver, TokenizeContext} from 'micromark-util-types'\n */\n\n/**\n * Call all `resolveAll`s.\n *\n * @param {ReadonlyArray<{resolveAll?: Resolver | undefined}>} constructs\n * List of constructs, optionally with `resolveAll`s.\n * @param {Array<Event>} events\n * List of events.\n * @param {TokenizeContext} context\n * Context used by `tokenize`.\n * @returns {Array<Event>}\n * Changed events.\n */\nexport function resolveAll(constructs, events, context) {\n /** @type {Array<Resolver>} */\n const called = []\n let index = -1\n\n while (++index < constructs.length) {\n const resolve = constructs[index].resolveAll\n\n if (resolve && !called.includes(resolve)) {\n events = resolve(events, context)\n called.push(resolve)\n }\n }\n\n return events\n}\n","/**\n * @import {Effects, State, TokenType} from 'micromark-util-types'\n */\n\nimport { markdownSpace } from 'micromark-util-character';\n\n// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.\n\n/**\n * Parse spaces and tabs.\n *\n * There is no `nok` parameter:\n *\n * * spaces in markdown are often optional, in which case this factory can be\n * used and `ok` will be switched to whether spaces were found or not\n * * one line ending or space can be detected with `markdownSpace(code)` right\n * before using `factorySpace`\n *\n * ###### Examples\n *\n * Where `␉` represents a tab (plus how much it expands) and `␠` represents a\n * single space.\n *\n * ```markdown\n * ␉\n * ␠␠␠␠\n * ␉␠\n * ```\n *\n * @param {Effects} effects\n * Context.\n * @param {State} ok\n * State switched to when successful.\n * @param {TokenType} type\n * Type (`' \\t'`).\n * @param {number | undefined} [max=Infinity]\n * Max (exclusive).\n * @returns {State}\n * Start state.\n */\nexport function factorySpace(effects, ok, type, max) {\n const limit = max ? max - 1 : Number.POSITIVE_INFINITY;\n let size = 0;\n return start;\n\n /** @type {State} */\n function start(code) {\n if (markdownSpace(code)) {\n effects.enter(type);\n return prefix(code);\n }\n return ok(code);\n }\n\n /** @type {State} */\n function prefix(code) {\n if (markdownSpace(code) && size++ < limit) {\n effects.consume(code);\n return prefix;\n }\n effects.exit(type);\n return ok(code);\n }\n}","/**\n * @import {\n * Construct,\n * State,\n * TokenizeContext,\n * Tokenizer\n * } from 'micromark-util-types'\n */\n\nimport { factorySpace } from 'micromark-factory-space';\nimport { markdownLineEnding, markdownSpace } from 'micromark-util-character';\n/** @type {Construct} */\nexport const blankLine = {\n partial: true,\n tokenize: tokenizeBlankLine\n};\n\n/**\n * @this {TokenizeContext}\n * Context.\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLine(effects, ok, nok) {\n return start;\n\n /**\n * Start of blank line.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n return markdownSpace(code) ? factorySpace(effects, after, \"linePrefix\")(code) : after(code);\n }\n\n /**\n * At eof/eol, after optional whitespace.\n *\n * > 👉 **Note**: `␠` represents a space character.\n *\n * ```markdown\n * > | ␠␠␊\n * ^\n * > | ␊\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return code === null || markdownLineEnding(code) ? ok(code) : nok(code);\n }\n}"],"names":["normalizeIdentifier","value","replace","toLowerCase","toUpperCase","classifyCharacter","code","markdownLineEndingOrSpace","unicodeWhitespace","unicodePunctuation","emptyOptions","toString","options","settings","includeImageAlt","includeHtml","one","node","type","alt","all","children","Array","isArray","values","result","index","length","join","Boolean","splice","list","start","remove","items","end","chunkStart","parameters","from","unshift","slice","push","hasOwnProperty","combineExtensions","extensions","syntaxExtension","extension","hook","maybe","call","undefined","left","right","constructs","existing","before","add","resolveAll","events","context","called","resolve","includes","factorySpace","effects","ok","max","limit","Number","POSITIVE_INFINITY","size","markdownSpace","enter","prefix","consume","exit","blankLine","partial","tokenize","tokenizeBlankLine","nok","after","markdownLineEnding"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAACC,KAAK,EAAE;EACzC,OAAOA;AACP;AAAA,GACCC,OAAO,CAAC,aAAa,EAAE,GAAG;AAC3B;AAAA,GACCA,OAAO,CAAC,QAAQ,EAAE,EAAE;AACrB;AACA;AACA;AACA;AACA;AACA;AAAA,GACCC,WAAW,EAAE,CAACC,WAAW,EAAE;AAC9B;;AChCA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,IAAI,EAAE;AACtC,EAAA,IAAIA,IAAI,KAAK,IAAI,IAAIC,yBAAyB,CAACD,IAAI,CAA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C3C,EAAA,OAAOhD,KAAK;;AAEZ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAASA,KAAKA,CAAC1B,IAAI,EAAE;IACnB,OAAOiE,aAAa,CAACjE,IAAI,CAAC,GAAGyD,YAAY,CAACC,OAAO,EAAEiB,KAAK,EAAE,YAAY,CAAC,CAAC3E,IAAI,CAAC,GAAG2E,KAAK,CAAC3E,IAAI,CAAC;AAC7F,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAAS2E,KAAKA,CAAC3E,IAAI,EAAE;AACnB,IAAA,OAAOA,IAAI,KAAK,IAAI,IAAI4E,kBAAkB,CAAC5E,IAAI,CAAC,GAAG2D,EAAE,CAAC3D,IAAI,CAAC,GAAG0E,GAAG,CAAC1E,IAAI,CAAC;AACzE,EAAA;AACF;;;;","x_google_ignoreList":[0,1,2,3,4,5,6,7]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resourceFactory, resource } from 'ember-resources';
|
|
2
|
+
import { getCompiler } from '../services/compiler.js';
|
|
3
|
+
import { compile } from './compile.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* By default, this compiles to `glimdown`. A Markdown format which
|
|
7
|
+
* extracts `live` tagged code snippets and compiles them to components.
|
|
8
|
+
*/
|
|
9
|
+
function Compiled(markdownText, maybeFormat, maybeFlavor) {
|
|
10
|
+
return resource(({
|
|
11
|
+
owner
|
|
12
|
+
}) => {
|
|
13
|
+
const input = typeof markdownText === 'function' ? markdownText() : markdownText;
|
|
14
|
+
const format = typeof maybeFormat === 'function' ? maybeFormat() : maybeFormat || 'glimdown';
|
|
15
|
+
const flavor = typeof maybeFlavor === 'function' ? maybeFlavor() : maybeFlavor;
|
|
16
|
+
const compiler = getCompiler(owner);
|
|
17
|
+
return compile(compiler, input, {
|
|
18
|
+
format,
|
|
19
|
+
flavor
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
resourceFactory(Compiled);
|
|
24
|
+
|
|
25
|
+
export { Compiled };
|
|
26
|
+
//# sourceMappingURL=Compiled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Compiled.js","sources":["../../src/compile/Compiled.ts"],"sourcesContent":["import { resource, resourceFactory } from 'ember-resources';\n\nimport { getCompiler } from '../services/compiler.ts';\nimport { compile } from './compile.ts';\n\nimport type { CompileState } from './state.ts';\nimport type { Format, Input } from './types.ts';\n\nexport function Compiled(markdownText: Input | (() => Input)): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format?: Format,\n flavor?: string\n): CompileState;\nexport function Compiled(markdownText: Input | (() => Input), format: () => Format): CompileState;\nexport function Compiled(\n markdownText: Input | (() => Input),\n format: () => Format,\n flavor: () => string\n): CompileState;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n maybeFormat?: Format | (() => Format),\n maybeFlavor?: string | (() => string)\n): CompileState {\n return resource(({ owner }) => {\n const input = typeof markdownText === 'function' ? markdownText() : markdownText;\n const format = typeof maybeFormat === 'function' ? maybeFormat() : maybeFormat || 'glimdown';\n const flavor = typeof maybeFlavor === 'function' ? maybeFlavor() : maybeFlavor;\n\n const compiler = getCompiler(owner);\n\n return compile(compiler, input, {\n format,\n flavor,\n });\n });\n}\n\nresourceFactory(Compiled);\n"],"names":["Compiled","markdownText","maybeFormat","maybeFlavor","resource","owner","input","format","flavor","compiler","getCompiler","compile","resourceFactory"],"mappings":";;;;AAqBA;AACA;AACA;AACA;AACO,SAASA,QAAQA,CACtBC,YAAmC,EACnCC,WAAqC,EACrCC,WAAqC,EACvB;EACd,OAAOC,QAAQ,CAAC,CAAC;AAAEC,IAAAA;AAAM,GAAC,KAAK;IAC7B,MAAMC,KAAK,GAAG,OAAOL,YAAY,KAAK,UAAU,GAAGA,YAAY,EAAE,GAAGA,YAAY;AAChF,IAAA,MAAMM,MAAM,GAAG,OAAOL,WAAW,KAAK,UAAU,GAAGA,WAAW,EAAE,GAAGA,WAAW,IAAI,UAAU;IAC5F,MAAMM,MAAM,GAAG,OAAOL,WAAW,KAAK,UAAU,GAAGA,WAAW,EAAE,GAAGA,WAAW;AAE9E,IAAA,MAAMM,QAAQ,GAAGC,WAAW,CAACL,KAAK,CAAC;AAEnC,IAAA,OAAOM,OAAO,CAACF,QAAQ,EAAEH,KAAK,EAAE;MAC9BC,MAAM;AACNC,MAAAA;AACF,KAAC,CAAC;AACJ,EAAA,CAAC,CAAC;AACJ;AAEAI,eAAe,CAACZ,QAAQ,CAAC;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MissingTextState, CompileState, REJECT, RESOLVE } from './state.js';
|
|
2
|
+
import { nameFor } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const CACHE = new Map();
|
|
5
|
+
function compile(service, text, options) {
|
|
6
|
+
const data = {
|
|
7
|
+
format: options.format
|
|
8
|
+
};
|
|
9
|
+
if (!text) {
|
|
10
|
+
return new MissingTextState(data);
|
|
11
|
+
}
|
|
12
|
+
const id = nameFor(`${options.format}:${text}`);
|
|
13
|
+
const state = new CompileState(data);
|
|
14
|
+
|
|
15
|
+
// Fills the cache as well
|
|
16
|
+
runTheCompiler({
|
|
17
|
+
service,
|
|
18
|
+
text,
|
|
19
|
+
options,
|
|
20
|
+
state,
|
|
21
|
+
id
|
|
22
|
+
});
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
async function runTheCompiler({
|
|
26
|
+
service,
|
|
27
|
+
text,
|
|
28
|
+
options,
|
|
29
|
+
state,
|
|
30
|
+
id
|
|
31
|
+
}) {
|
|
32
|
+
await options?.onCompileStart?.();
|
|
33
|
+
await Promise.resolve();
|
|
34
|
+
if (!text) {
|
|
35
|
+
state[REJECT](new Error('No Input Document yet'));
|
|
36
|
+
await options?.onError?.('No Input Document yet');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let result;
|
|
40
|
+
|
|
41
|
+
// TODO: just use compile, eliminate all this branching
|
|
42
|
+
if (options.format === 'glimdown') {
|
|
43
|
+
result = await service.compile('gmd', text, options);
|
|
44
|
+
} else if (options.format === 'gjs') {
|
|
45
|
+
result = await service.compileGJS(text);
|
|
46
|
+
} else if (options.format === 'hbs') {
|
|
47
|
+
result = await service.compileHBS(text, options);
|
|
48
|
+
} else {
|
|
49
|
+
result = await service.compile(options.format, text, options);
|
|
50
|
+
}
|
|
51
|
+
if (result.error) {
|
|
52
|
+
state[REJECT](result.error);
|
|
53
|
+
await options?.onError?.(state.reason || 'Unknown Error');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
CACHE.set(id, result.component);
|
|
57
|
+
state[RESOLVE](result.component);
|
|
58
|
+
await options?.onSuccess?.(result.component);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { CACHE, compile };
|
|
62
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sources":["../../src/compile/compile.ts"],"sourcesContent":["import { CompileState, MissingTextState, REJECT, RESOLVE } from './state.ts';\nimport { nameFor } from './utils.ts';\n\nimport type CompilerService from '../services/compiler.ts';\nimport type { CompileResult, Format, Input } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Options {\n format: Format;\n flavor?: string;\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n onSuccess?: (component: ComponentLike) => Promise<unknown> | unknown;\n onError?: (error: string) => Promise<unknown> | unknown;\n onCompileStart?: () => Promise<unknown> | unknown;\n}\n\nexport function compile(service: CompilerService, text: Input, options: Options): CompileState {\n const data = { format: options.format };\n\n if (!text) {\n return new MissingTextState(data);\n }\n\n const id = nameFor(`${options.format}:${text}`);\n\n const state = new CompileState(data);\n\n // Fills the cache as well\n runTheCompiler({ service, text, options, state, id });\n\n return state;\n}\n\nasync function runTheCompiler({\n service,\n text,\n options,\n state,\n id,\n}: {\n service: CompilerService;\n text: string;\n options: Options;\n state: CompileState;\n id: string;\n}) {\n await options?.onCompileStart?.();\n await Promise.resolve();\n\n if (!text) {\n state[REJECT](new Error('No Input Document yet'));\n await options?.onError?.('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n // TODO: just use compile, eliminate all this branching\n if (options.format === 'glimdown') {\n result = await service.compile('gmd', text, options as any);\n } else if (options.format === 'gjs') {\n result = await service.compileGJS(text);\n } else if (options.format === 'hbs') {\n result = await service.compileHBS(text, options as any);\n } else {\n result = await service.compile(\n options.format,\n text,\n options as unknown as Record<string, unknown>\n );\n }\n\n if (result.error) {\n state[REJECT](result.error);\n await options?.onError?.(state.reason || 'Unknown Error');\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n state[RESOLVE](result.component as ComponentLike);\n\n await options?.onSuccess?.(result.component as ComponentLike);\n}\n"],"names":["CACHE","Map","compile","service","text","options","data","format","MissingTextState","id","nameFor","state","CompileState","runTheCompiler","onCompileStart","Promise","resolve","REJECT","Error","onError","result","compileGJS","compileHBS","error","reason","set","component","RESOLVE","onSuccess"],"mappings":";;;MAOaA,KAAK,GAAG,IAAIC,GAAG;AAYrB,SAASC,OAAOA,CAACC,OAAwB,EAAEC,IAAW,EAAEC,OAAgB,EAAgB;AAC7F,EAAA,MAAMC,IAAI,GAAG;IAAEC,MAAM,EAAEF,OAAO,CAACE;GAAQ;EAEvC,IAAI,CAACH,IAAI,EAAE;AACT,IAAA,OAAO,IAAII,gBAAgB,CAACF,IAAI,CAAC;AACnC,EAAA;EAEA,MAAMG,EAAE,GAAGC,OAAO,CAAC,CAAA,EAAGL,OAAO,CAACE,MAAM,CAAA,CAAA,EAAIH,IAAI,CAAA,CAAE,CAAC;AAE/C,EAAA,MAAMO,KAAK,GAAG,IAAIC,YAAY,CAACN,IAAI,C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