@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.3

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +13 -13
  3. package/dist/index.js +141 -141
  4. package/dist/index10.js +70 -110
  5. package/dist/index11.js +135 -168
  6. package/dist/index12.js +83 -74
  7. package/dist/index13.js +13 -134
  8. package/dist/index14.js +13 -146
  9. package/dist/index15.js +303 -15
  10. package/dist/index16.js +69 -14
  11. package/dist/index17.js +26 -295
  12. package/dist/index18.js +2 -2
  13. package/dist/index19.js +355 -24
  14. package/dist/index20.js +25 -264
  15. package/dist/index21.js +85 -68
  16. package/dist/index22.js +97 -353
  17. package/dist/index23.js +66 -84
  18. package/dist/index24.js +12 -36
  19. package/dist/index25.js +53 -92
  20. package/dist/index26.js +132 -96
  21. package/dist/index27.js +59 -126
  22. package/dist/index28.js +37 -53
  23. package/dist/index29.js +19 -62
  24. package/dist/index3.js +165 -60
  25. package/dist/index30.js +9 -37
  26. package/dist/index31.js +143 -19
  27. package/dist/index32.js +264 -11
  28. package/dist/index33.js +92 -9
  29. package/dist/index34.js +63 -16
  30. package/dist/index35.js +4 -58
  31. package/dist/index36.js +123 -15
  32. package/dist/index37.js +305 -42
  33. package/dist/index38.js +487 -4
  34. package/dist/index39.js +37 -112
  35. package/dist/index4.js +10 -86
  36. package/dist/index40.js +653 -301
  37. package/dist/index41.js +4 -487
  38. package/dist/index42.js +4 -48
  39. package/dist/index43.js +206 -642
  40. package/dist/index44.js +82 -4
  41. package/dist/index45.js +17 -4
  42. package/dist/index46.js +57 -237
  43. package/dist/index47.js +15 -82
  44. package/dist/index48.js +190 -274
  45. package/dist/index49.js +281 -1497
  46. package/dist/index5.js +132 -10
  47. package/dist/index50.js +1502 -5
  48. package/dist/index51.js +5 -1561
  49. package/dist/index52.js +1551 -192
  50. package/dist/index53.js +1 -1
  51. package/dist/index54.js +84 -21
  52. package/dist/index55.js +246 -10
  53. package/dist/index56.js +3 -7
  54. package/dist/index57.js +1231 -7
  55. package/dist/index58.js +731 -11
  56. package/dist/index59.js +21 -19
  57. package/dist/index6.js +48 -131
  58. package/dist/index60.js +10 -25
  59. package/dist/index61.js +6 -83
  60. package/dist/index62.js +7 -245
  61. package/dist/index63.js +11 -1229
  62. package/dist/index64.js +17 -732
  63. package/dist/index65.js +25 -3
  64. package/dist/index66.js +53 -1059
  65. package/dist/index67.js +1059 -53
  66. package/dist/index69.js +90 -3
  67. package/dist/index7.js +228 -409
  68. package/dist/index70.js +3 -90
  69. package/dist/index8.js +111 -45
  70. package/dist/index9.js +409 -228
  71. package/package.json +54 -80
package/dist/index66.js CHANGED
@@ -1,1063 +1,57 @@
1
- var re, ve;
2
- function zt() {
3
- if (ve) return re;
4
- ve = 1;
5
- function ce(e) {
6
- return e instanceof Map ? e.clear = e.delete = e.set = function() {
7
- throw new Error("map is read-only");
8
- } : e instanceof Set && (e.add = e.clear = e.delete = function() {
9
- throw new Error("set is read-only");
10
- }), Object.freeze(e), Object.getOwnPropertyNames(e).forEach((t) => {
11
- const i = e[t], u = typeof i;
12
- (u === "object" || u === "function") && !Object.isFrozen(i) && ce(i);
13
- }), e;
14
- }
15
- class oe {
16
- /**
17
- * @param {CompiledMode} mode
18
- */
19
- constructor(t) {
20
- t.data === void 0 && (t.data = {}), this.data = t.data, this.isMatchIgnored = !1;
21
- }
22
- ignoreMatch() {
23
- this.isMatchIgnored = !0;
24
- }
25
- }
26
- function ae(e) {
27
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
28
- }
29
- function T(e, ...t) {
30
- const i = /* @__PURE__ */ Object.create(null);
31
- for (const u in e)
32
- i[u] = e[u];
33
- return t.forEach(function(u) {
34
- for (const b in u)
35
- i[b] = u[b];
36
- }), /** @type {T} */
37
- i;
38
- }
39
- const Ce = "</span>", le = (e) => !!e.scope, Le = (e, { prefix: t }) => {
40
- if (e.startsWith("language:"))
41
- return e.replace("language:", "language-");
42
- if (e.includes(".")) {
43
- const i = e.split(".");
44
- return [
45
- `${t}${i.shift()}`,
46
- ...i.map((u, b) => `${u}${"_".repeat(b + 1)}`)
47
- ].join(" ");
48
- }
49
- return `${t}${e}`;
50
- };
51
- class He {
52
- /**
53
- * Creates a new HTMLRenderer
54
- *
55
- * @param {Tree} parseTree - the parse tree (must support `walk` API)
56
- * @param {{classPrefix: string}} options
57
- */
58
- constructor(t, i) {
59
- this.buffer = "", this.classPrefix = i.classPrefix, t.walk(this);
60
- }
61
- /**
62
- * Adds texts to the output stream
63
- *
64
- * @param {string} text */
65
- addText(t) {
66
- this.buffer += ae(t);
67
- }
68
- /**
69
- * Adds a node open to the output stream (if needed)
70
- *
71
- * @param {Node} node */
72
- openNode(t) {
73
- if (!le(t)) return;
74
- const i = Le(
75
- t.scope,
76
- { prefix: this.classPrefix }
77
- );
78
- this.span(i);
79
- }
80
- /**
81
- * Adds a node close to the output stream (if needed)
82
- *
83
- * @param {Node} node */
84
- closeNode(t) {
85
- le(t) && (this.buffer += Ce);
86
- }
87
- /**
88
- * returns the accumulated buffer
89
- */
90
- value() {
91
- return this.buffer;
92
- }
93
- // helpers
94
- /**
95
- * Builds a span element
96
- *
97
- * @param {string} className */
98
- span(t) {
99
- this.buffer += `<span class="${t}">`;
100
- }
101
- }
102
- const ue = (e = {}) => {
103
- const t = { children: [] };
104
- return Object.assign(t, e), t;
105
- };
106
- class Z {
107
- constructor() {
108
- this.rootNode = ue(), this.stack = [this.rootNode];
109
- }
110
- get top() {
111
- return this.stack[this.stack.length - 1];
112
- }
113
- get root() {
114
- return this.rootNode;
115
- }
116
- /** @param {Node} node */
117
- add(t) {
118
- this.top.children.push(t);
119
- }
120
- /** @param {string} scope */
121
- openNode(t) {
122
- const i = ue({ scope: t });
123
- this.add(i), this.stack.push(i);
124
- }
125
- closeNode() {
126
- if (this.stack.length > 1)
127
- return this.stack.pop();
128
- }
129
- closeAllNodes() {
130
- for (; this.closeNode(); ) ;
131
- }
132
- toJSON() {
133
- return JSON.stringify(this.rootNode, null, 4);
134
- }
135
- /**
136
- * @typedef { import("./html_renderer").Renderer } Renderer
137
- * @param {Renderer} builder
138
- */
139
- walk(t) {
140
- return this.constructor._walk(t, this.rootNode);
141
- }
142
- /**
143
- * @param {Renderer} builder
144
- * @param {Node} node
145
- */
146
- static _walk(t, i) {
147
- return typeof i == "string" ? t.addText(i) : i.children && (t.openNode(i), i.children.forEach((u) => this._walk(t, u)), t.closeNode(i)), t;
148
- }
149
- /**
150
- * @param {Node} node
151
- */
152
- static _collapse(t) {
153
- typeof t != "string" && t.children && (t.children.every((i) => typeof i == "string") ? t.children = [t.children.join("")] : t.children.forEach((i) => {
154
- Z._collapse(i);
155
- }));
156
- }
157
- }
158
- class Pe extends Z {
159
- /**
160
- * @param {*} options
161
- */
162
- constructor(t) {
163
- super(), this.options = t;
164
- }
165
- /**
166
- * @param {string} text
167
- */
168
- addText(t) {
169
- t !== "" && this.add(t);
170
- }
171
- /** @param {string} scope */
172
- startScope(t) {
173
- this.openNode(t);
174
- }
175
- endScope() {
176
- this.closeNode();
177
- }
178
- /**
179
- * @param {Emitter & {root: DataNode}} emitter
180
- * @param {string} name
181
- */
182
- __addSublanguage(t, i) {
183
- const u = t.root;
184
- i && (u.scope = `language:${i}`), this.add(u);
185
- }
186
- toHTML() {
187
- return new He(this, this.options).value();
188
- }
189
- finalize() {
190
- return this.closeAllNodes(), !0;
191
- }
192
- }
193
- function P(e) {
194
- return e ? typeof e == "string" ? e : e.source : null;
195
- }
196
- function fe(e) {
197
- return D("(?=", e, ")");
198
- }
199
- function je(e) {
200
- return D("(?:", e, ")*");
201
- }
202
- function Ue(e) {
203
- return D("(?:", e, ")?");
204
- }
205
- function D(...e) {
206
- return e.map((i) => P(i)).join("");
207
- }
208
- function $e(e) {
209
- const t = e[e.length - 1];
210
- return typeof t == "object" && t.constructor === Object ? (e.splice(e.length - 1, 1), t) : {};
211
- }
212
- function q(...e) {
213
- return "(" + ($e(e).capture ? "" : "?:") + e.map((u) => P(u)).join("|") + ")";
214
- }
215
- function ge(e) {
216
- return new RegExp(e.toString() + "|").exec("").length - 1;
217
- }
218
- function Ge(e, t) {
219
- const i = e && e.exec(t);
220
- return i && i.index === 0;
221
- }
222
- const We = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
223
- function J(e, { joinWith: t }) {
224
- let i = 0;
225
- return e.map((u) => {
226
- i += 1;
227
- const b = i;
228
- let _ = P(u), c = "";
229
- for (; _.length > 0; ) {
230
- const r = We.exec(_);
231
- if (!r) {
232
- c += _;
233
- break;
234
- }
235
- c += _.substring(0, r.index), _ = _.substring(r.index + r[0].length), r[0][0] === "\\" && r[1] ? c += "\\" + String(Number(r[1]) + b) : (c += r[0], r[0] === "(" && i++);
236
- }
237
- return c;
238
- }).map((u) => `(${u})`).join(t);
239
- }
240
- const Ke = /\b\B/, he = "[a-zA-Z]\\w*", V = "[a-zA-Z_]\\w*", pe = "\\b\\d+(\\.\\d+)?", de = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", Ee = "\\b(0b[01]+)", ze = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", Fe = (e = {}) => {
241
- const t = /^#![ ]*\//;
242
- return e.binary && (e.begin = D(
243
- t,
244
- /.*\b/,
245
- e.binary,
246
- /\b.*/
247
- )), T({
248
- scope: "meta",
249
- begin: t,
250
- end: /$/,
251
- relevance: 0,
252
- /** @type {ModeCallback} */
253
- "on:begin": (i, u) => {
254
- i.index !== 0 && u.ignoreMatch();
255
- }
256
- }, e);
257
- }, j = {
258
- begin: "\\\\[\\s\\S]",
259
- relevance: 0
260
- }, Xe = {
261
- scope: "string",
262
- begin: "'",
263
- end: "'",
264
- illegal: "\\n",
265
- contains: [j]
266
- }, Ye = {
267
- scope: "string",
268
- begin: '"',
269
- end: '"',
270
- illegal: "\\n",
271
- contains: [j]
272
- }, Ze = {
273
- begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
274
- }, $ = function(e, t, i = {}) {
275
- const u = T(
276
- {
277
- scope: "comment",
278
- begin: e,
279
- end: t,
280
- contains: []
281
- },
282
- i
283
- );
284
- u.contains.push({
285
- scope: "doctag",
286
- // hack to avoid the space from being included. the space is necessary to
287
- // match here to prevent the plain text rule below from gobbling up doctags
288
- begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
289
- end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
290
- excludeBegin: !0,
291
- relevance: 0
292
- });
293
- const b = q(
294
- // list of common 1 and 2 letter words in English
295
- "I",
296
- "a",
297
- "is",
298
- "so",
299
- "us",
300
- "to",
301
- "at",
302
- "if",
303
- "in",
304
- "it",
305
- "on",
306
- // note: this is not an exhaustive list of contractions, just popular ones
307
- /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
308
- // contractions - can't we'd they're let's, etc
309
- /[A-Za-z]+[-][a-z]+/,
310
- // `no-way`, etc.
311
- /[A-Za-z][a-z]{2,}/
312
- // allow capitalized words at beginning of sentences
313
- );
314
- return u.contains.push(
315
- {
316
- // TODO: how to include ", (, ) without breaking grammars that use these for
317
- // comment delimiters?
318
- // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
319
- // ---
320
- // this tries to find sequences of 3 english words in a row (without any
321
- // "programming" type syntax) this gives us a strong signal that we've
322
- // TRULY found a comment - vs perhaps scanning with the wrong language.
323
- // It's possible to find something that LOOKS like the start of the
324
- // comment - but then if there is no readable text - good chance it is a
325
- // false match and not a comment.
326
- //
327
- // for a visual example please see:
328
- // https://github.com/highlightjs/highlight.js/issues/2827
329
- begin: D(
330
- /[ ]+/,
331
- // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
332
- "(",
333
- b,
334
- /[.]?[:]?([.][ ]|[ ])/,
335
- "){3}"
336
- )
337
- // look for 3 words in a row
338
- }
339
- ), u;
340
- }, qe = $("//", "$"), Je = $("/\\*", "\\*/"), Ve = $("#", "$"), Qe = {
341
- scope: "number",
342
- begin: pe,
343
- relevance: 0
344
- }, me = {
345
- scope: "number",
346
- begin: de,
347
- relevance: 0
348
- }, et = {
349
- scope: "number",
350
- begin: Ee,
351
- relevance: 0
352
- }, tt = {
353
- scope: "regexp",
354
- begin: /\/(?=[^/\n]*\/)/,
355
- end: /\/[gimuy]*/,
356
- contains: [
357
- j,
358
- {
359
- begin: /\[/,
360
- end: /\]/,
361
- relevance: 0,
362
- contains: [j]
363
- }
364
- ]
365
- }, nt = {
366
- scope: "title",
367
- begin: he,
368
- relevance: 0
369
- }, it = {
370
- scope: "title",
371
- begin: V,
372
- relevance: 0
373
- }, st = {
374
- // excludes method names from keyword processing
375
- begin: "\\.\\s*" + V,
376
- relevance: 0
1
+ import { keyName as c, base as n } from "./index69.js";
2
+ const d = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), y = typeof navigator < "u" && /Win/.test(navigator.platform);
3
+ function h(e) {
4
+ let r = e.split(/-(?!$)/), t = r[r.length - 1];
5
+ t == "Space" && (t = " ");
6
+ let i, f, o, a;
7
+ for (let l = 0; l < r.length - 1; l++) {
8
+ let s = r[l];
9
+ if (/^(cmd|meta|m)$/i.test(s))
10
+ a = !0;
11
+ else if (/^a(lt)?$/i.test(s))
12
+ i = !0;
13
+ else if (/^(c|ctrl|control)$/i.test(s))
14
+ f = !0;
15
+ else if (/^s(hift)?$/i.test(s))
16
+ o = !0;
17
+ else if (/^mod$/i.test(s))
18
+ d ? a = !0 : f = !0;
19
+ else
20
+ throw new Error("Unrecognized modifier name: " + s);
21
+ }
22
+ return i && (t = "Alt-" + t), f && (t = "Ctrl-" + t), a && (t = "Meta-" + t), o && (t = "Shift-" + t), t;
23
+ }
24
+ function m(e) {
25
+ let r = /* @__PURE__ */ Object.create(null);
26
+ for (let t in e)
27
+ r[h(t)] = e[t];
28
+ return r;
29
+ }
30
+ function u(e, r, t = !0) {
31
+ return r.altKey && (e = "Alt-" + e), r.ctrlKey && (e = "Ctrl-" + e), r.metaKey && (e = "Meta-" + e), t && r.shiftKey && (e = "Shift-" + e), e;
32
+ }
33
+ function K(e) {
34
+ let r = m(e);
35
+ return function(t, i) {
36
+ let f = c(i), o, a = r[u(f, i)];
37
+ if (a && a(t.state, t.dispatch, t))
38
+ return !0;
39
+ if (f.length == 1 && f != " ") {
40
+ if (i.shiftKey) {
41
+ let l = r[u(f, i, !1)];
42
+ if (l && l(t.state, t.dispatch, t))
43
+ return !0;
44
+ }
45
+ if ((i.altKey || i.metaKey || i.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
46
+ !(y && i.ctrlKey && i.altKey) && (o = n[i.keyCode]) && o != f) {
47
+ let l = r[u(o, i)];
48
+ if (l && l(t.state, t.dispatch, t))
49
+ return !0;
50
+ }
51
+ }
52
+ return !1;
377
53
  };
378
- var G = /* @__PURE__ */ Object.freeze({
379
- __proto__: null,
380
- APOS_STRING_MODE: Xe,
381
- BACKSLASH_ESCAPE: j,
382
- BINARY_NUMBER_MODE: et,
383
- BINARY_NUMBER_RE: Ee,
384
- COMMENT: $,
385
- C_BLOCK_COMMENT_MODE: Je,
386
- C_LINE_COMMENT_MODE: qe,
387
- C_NUMBER_MODE: me,
388
- C_NUMBER_RE: de,
389
- END_SAME_AS_BEGIN: function(e) {
390
- return Object.assign(
391
- e,
392
- {
393
- /** @type {ModeCallback} */
394
- "on:begin": (t, i) => {
395
- i.data._beginMatch = t[1];
396
- },
397
- /** @type {ModeCallback} */
398
- "on:end": (t, i) => {
399
- i.data._beginMatch !== t[1] && i.ignoreMatch();
400
- }
401
- }
402
- );
403
- },
404
- HASH_COMMENT_MODE: Ve,
405
- IDENT_RE: he,
406
- MATCH_NOTHING_RE: Ke,
407
- METHOD_GUARD: st,
408
- NUMBER_MODE: Qe,
409
- NUMBER_RE: pe,
410
- PHRASAL_WORDS_MODE: Ze,
411
- QUOTE_STRING_MODE: Ye,
412
- REGEXP_MODE: tt,
413
- RE_STARTERS_RE: ze,
414
- SHEBANG: Fe,
415
- TITLE_MODE: nt,
416
- UNDERSCORE_IDENT_RE: V,
417
- UNDERSCORE_TITLE_MODE: it
418
- });
419
- function rt(e, t) {
420
- e.input[e.index - 1] === "." && t.ignoreMatch();
421
- }
422
- function ct(e, t) {
423
- e.className !== void 0 && (e.scope = e.className, delete e.className);
424
- }
425
- function ot(e, t) {
426
- t && e.beginKeywords && (e.begin = "\\b(" + e.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", e.__beforeBegin = rt, e.keywords = e.keywords || e.beginKeywords, delete e.beginKeywords, e.relevance === void 0 && (e.relevance = 0));
427
- }
428
- function at(e, t) {
429
- Array.isArray(e.illegal) && (e.illegal = q(...e.illegal));
430
- }
431
- function lt(e, t) {
432
- if (e.match) {
433
- if (e.begin || e.end) throw new Error("begin & end are not supported with match");
434
- e.begin = e.match, delete e.match;
435
- }
436
- }
437
- function ut(e, t) {
438
- e.relevance === void 0 && (e.relevance = 1);
439
- }
440
- const ft = (e, t) => {
441
- if (!e.beforeMatch) return;
442
- if (e.starts) throw new Error("beforeMatch cannot be used with starts");
443
- const i = Object.assign({}, e);
444
- Object.keys(e).forEach((u) => {
445
- delete e[u];
446
- }), e.keywords = i.keywords, e.begin = D(i.beforeMatch, fe(i.begin)), e.starts = {
447
- relevance: 0,
448
- contains: [
449
- Object.assign(i, { endsParent: !0 })
450
- ]
451
- }, e.relevance = 0, delete i.beforeMatch;
452
- }, gt = [
453
- "of",
454
- "and",
455
- "for",
456
- "in",
457
- "not",
458
- "or",
459
- "if",
460
- "then",
461
- "parent",
462
- // common variable name
463
- "list",
464
- // common variable name
465
- "value"
466
- // common variable name
467
- ], ht = "keyword";
468
- function be(e, t, i = ht) {
469
- const u = /* @__PURE__ */ Object.create(null);
470
- return typeof e == "string" ? b(i, e.split(" ")) : Array.isArray(e) ? b(i, e) : Object.keys(e).forEach(function(_) {
471
- Object.assign(
472
- u,
473
- be(e[_], t, _)
474
- );
475
- }), u;
476
- function b(_, c) {
477
- t && (c = c.map((r) => r.toLowerCase())), c.forEach(function(r) {
478
- const l = r.split("|");
479
- u[l[0]] = [_, pt(l[0], l[1])];
480
- });
481
- }
482
- }
483
- function pt(e, t) {
484
- return t ? Number(t) : dt(e) ? 0 : 1;
485
- }
486
- function dt(e) {
487
- return gt.includes(e.toLowerCase());
488
- }
489
- const _e = {}, v = (e) => {
490
- console.error(e);
491
- }, Me = (e, ...t) => {
492
- console.log(`WARN: ${e}`, ...t);
493
- }, L = (e, t) => {
494
- _e[`${e}/${t}`] || (console.log(`Deprecated as of ${e}. ${t}`), _e[`${e}/${t}`] = !0);
495
- }, W = new Error();
496
- function we(e, t, { key: i }) {
497
- let u = 0;
498
- const b = e[i], _ = {}, c = {};
499
- for (let r = 1; r <= t.length; r++)
500
- c[r + u] = b[r], _[r + u] = !0, u += ge(t[r - 1]);
501
- e[i] = c, e[i]._emit = _, e[i]._multi = !0;
502
- }
503
- function Et(e) {
504
- if (Array.isArray(e.begin)) {
505
- if (e.skip || e.excludeBegin || e.returnBegin)
506
- throw v("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), W;
507
- if (typeof e.beginScope != "object" || e.beginScope === null)
508
- throw v("beginScope must be object"), W;
509
- we(e, e.begin, { key: "beginScope" }), e.begin = J(e.begin, { joinWith: "" });
510
- }
511
- }
512
- function bt(e) {
513
- if (Array.isArray(e.end)) {
514
- if (e.skip || e.excludeEnd || e.returnEnd)
515
- throw v("skip, excludeEnd, returnEnd not compatible with endScope: {}"), W;
516
- if (typeof e.endScope != "object" || e.endScope === null)
517
- throw v("endScope must be object"), W;
518
- we(e, e.end, { key: "endScope" }), e.end = J(e.end, { joinWith: "" });
519
- }
520
- }
521
- function _t(e) {
522
- e.scope && typeof e.scope == "object" && e.scope !== null && (e.beginScope = e.scope, delete e.scope);
523
- }
524
- function Mt(e) {
525
- _t(e), typeof e.beginScope == "string" && (e.beginScope = { _wrap: e.beginScope }), typeof e.endScope == "string" && (e.endScope = { _wrap: e.endScope }), Et(e), bt(e);
526
- }
527
- function wt(e) {
528
- function t(c, r) {
529
- return new RegExp(
530
- P(c),
531
- "m" + (e.case_insensitive ? "i" : "") + (e.unicodeRegex ? "u" : "") + (r ? "g" : "")
532
- );
533
- }
534
- class i {
535
- constructor() {
536
- this.matchIndexes = {}, this.regexes = [], this.matchAt = 1, this.position = 0;
537
- }
538
- // @ts-ignore
539
- addRule(r, l) {
540
- l.position = this.position++, this.matchIndexes[this.matchAt] = l, this.regexes.push([l, r]), this.matchAt += ge(r) + 1;
541
- }
542
- compile() {
543
- this.regexes.length === 0 && (this.exec = () => null);
544
- const r = this.regexes.map((l) => l[1]);
545
- this.matcherRe = t(J(r, { joinWith: "|" }), !0), this.lastIndex = 0;
546
- }
547
- /** @param {string} s */
548
- exec(r) {
549
- this.matcherRe.lastIndex = this.lastIndex;
550
- const l = this.matcherRe.exec(r);
551
- if (!l)
552
- return null;
553
- const x = l.findIndex((U, m) => m > 0 && U !== void 0), M = this.matchIndexes[x];
554
- return l.splice(0, x), Object.assign(l, M);
555
- }
556
- }
557
- class u {
558
- constructor() {
559
- this.rules = [], this.multiRegexes = [], this.count = 0, this.lastIndex = 0, this.regexIndex = 0;
560
- }
561
- // @ts-ignore
562
- getMatcher(r) {
563
- if (this.multiRegexes[r]) return this.multiRegexes[r];
564
- const l = new i();
565
- return this.rules.slice(r).forEach(([x, M]) => l.addRule(x, M)), l.compile(), this.multiRegexes[r] = l, l;
566
- }
567
- resumingScanAtSamePosition() {
568
- return this.regexIndex !== 0;
569
- }
570
- considerAll() {
571
- this.regexIndex = 0;
572
- }
573
- // @ts-ignore
574
- addRule(r, l) {
575
- this.rules.push([r, l]), l.type === "begin" && this.count++;
576
- }
577
- /** @param {string} s */
578
- exec(r) {
579
- const l = this.getMatcher(this.regexIndex);
580
- l.lastIndex = this.lastIndex;
581
- let x = l.exec(r);
582
- if (this.resumingScanAtSamePosition() && !(x && x.index === this.lastIndex)) {
583
- const M = this.getMatcher(0);
584
- M.lastIndex = this.lastIndex + 1, x = M.exec(r);
585
- }
586
- return x && (this.regexIndex += x.position + 1, this.regexIndex === this.count && this.considerAll()), x;
587
- }
588
- }
589
- function b(c) {
590
- const r = new u();
591
- return c.contains.forEach((l) => r.addRule(l.begin, { rule: l, type: "begin" })), c.terminatorEnd && r.addRule(c.terminatorEnd, { type: "end" }), c.illegal && r.addRule(c.illegal, { type: "illegal" }), r;
592
- }
593
- function _(c, r) {
594
- const l = (
595
- /** @type CompiledMode */
596
- c
597
- );
598
- if (c.isCompiled) return l;
599
- [
600
- ct,
601
- // do this early so compiler extensions generally don't have to worry about
602
- // the distinction between match/begin
603
- lt,
604
- Mt,
605
- ft
606
- ].forEach((M) => M(c, r)), e.compilerExtensions.forEach((M) => M(c, r)), c.__beforeBegin = null, [
607
- ot,
608
- // do this later so compiler extensions that come earlier have access to the
609
- // raw array if they wanted to perhaps manipulate it, etc.
610
- at,
611
- // default to 1 relevance if not specified
612
- ut
613
- ].forEach((M) => M(c, r)), c.isCompiled = !0;
614
- let x = null;
615
- return typeof c.keywords == "object" && c.keywords.$pattern && (c.keywords = Object.assign({}, c.keywords), x = c.keywords.$pattern, delete c.keywords.$pattern), x = x || /\w+/, c.keywords && (c.keywords = be(c.keywords, e.case_insensitive)), l.keywordPatternRe = t(x, !0), r && (c.begin || (c.begin = /\B|\b/), l.beginRe = t(l.begin), !c.end && !c.endsWithParent && (c.end = /\B|\b/), c.end && (l.endRe = t(l.end)), l.terminatorEnd = P(l.end) || "", c.endsWithParent && r.terminatorEnd && (l.terminatorEnd += (c.end ? "|" : "") + r.terminatorEnd)), c.illegal && (l.illegalRe = t(
616
- /** @type {RegExp | string} */
617
- c.illegal
618
- )), c.contains || (c.contains = []), c.contains = [].concat(...c.contains.map(function(M) {
619
- return xt(M === "self" ? c : M);
620
- })), c.contains.forEach(function(M) {
621
- _(
622
- /** @type Mode */
623
- M,
624
- l
625
- );
626
- }), c.starts && _(c.starts, r), l.matcher = b(l), l;
627
- }
628
- if (e.compilerExtensions || (e.compilerExtensions = []), e.contains && e.contains.includes("self"))
629
- throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
630
- return e.classNameAliases = T(e.classNameAliases || {}), _(
631
- /** @type Mode */
632
- e
633
- );
634
- }
635
- function xe(e) {
636
- return e ? e.endsWithParent || xe(e.starts) : !1;
637
- }
638
- function xt(e) {
639
- return e.variants && !e.cachedVariants && (e.cachedVariants = e.variants.map(function(t) {
640
- return T(e, { variants: null }, t);
641
- })), e.cachedVariants ? e.cachedVariants : xe(e) ? T(e, { starts: e.starts ? T(e.starts) : null }) : Object.isFrozen(e) ? T(e) : e;
642
- }
643
- var Ot = "11.11.1";
644
- class Rt extends Error {
645
- constructor(t, i) {
646
- super(t), this.name = "HTMLInjectionError", this.html = i;
647
- }
648
- }
649
- const Q = ae, Oe = T, Re = /* @__PURE__ */ Symbol("nomatch"), yt = 7, ye = function(e) {
650
- const t = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), u = [];
651
- let b = !0;
652
- const _ = "Could not find the language '{}', did you forget to load/include a language module?", c = { disableAutodetect: !0, name: "Plain text", contains: [] };
653
- let r = {
654
- ignoreUnescapedHTML: !1,
655
- throwUnescapedHTML: !1,
656
- noHighlightRe: /^(no-?highlight)$/i,
657
- languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
658
- classPrefix: "hljs-",
659
- cssSelector: "pre code",
660
- languages: null,
661
- // beta configuration options, subject to change, welcome to discuss
662
- // https://github.com/highlightjs/highlight.js/issues/1086
663
- __emitter: Pe
664
- };
665
- function l(n) {
666
- return r.noHighlightRe.test(n);
667
- }
668
- function x(n) {
669
- let a = n.className + " ";
670
- a += n.parentNode ? n.parentNode.className : "";
671
- const h = r.languageDetectRe.exec(a);
672
- if (h) {
673
- const d = I(h[1]);
674
- return d || (Me(_.replace("{}", h[1])), Me("Falling back to no-highlight mode for this block.", n)), d ? h[1] : "no-highlight";
675
- }
676
- return a.split(/\s+/).find((d) => l(d) || I(d));
677
- }
678
- function M(n, a, h) {
679
- let d = "", w = "";
680
- typeof a == "object" ? (d = n, h = a.ignoreIllegals, w = a.language) : (L("10.7.0", "highlight(lang, code, ...args) has been deprecated."), L("10.7.0", `Please use highlight(code, options) instead.
681
- https://github.com/highlightjs/highlight.js/issues/2277`), w = n, d = a), h === void 0 && (h = !0);
682
- const S = {
683
- code: d,
684
- language: w
685
- };
686
- z("before:highlight", S);
687
- const B = S.result ? S.result : U(S.language, S.code, h);
688
- return B.code = S.code, z("after:highlight", B), B;
689
- }
690
- function U(n, a, h, d) {
691
- const w = /* @__PURE__ */ Object.create(null);
692
- function S(s, o) {
693
- return s.keywords[o];
694
- }
695
- function B() {
696
- if (!f.keywords) {
697
- O.addText(E);
698
- return;
699
- }
700
- let s = 0;
701
- f.keywordPatternRe.lastIndex = 0;
702
- let o = f.keywordPatternRe.exec(E), g = "";
703
- for (; o; ) {
704
- g += E.substring(s, o.index);
705
- const p = A.case_insensitive ? o[0].toLowerCase() : o[0], R = S(f, p);
706
- if (R) {
707
- const [k, Gt] = R;
708
- if (O.addText(g), g = "", w[p] = (w[p] || 0) + 1, w[p] <= yt && (Y += Gt), k.startsWith("_"))
709
- g += o[0];
710
- else {
711
- const Wt = A.classNameAliases[k] || k;
712
- N(o[0], Wt);
713
- }
714
- } else
715
- g += o[0];
716
- s = f.keywordPatternRe.lastIndex, o = f.keywordPatternRe.exec(E);
717
- }
718
- g += E.substring(s), O.addText(g);
719
- }
720
- function F() {
721
- if (E === "") return;
722
- let s = null;
723
- if (typeof f.subLanguage == "string") {
724
- if (!t[f.subLanguage]) {
725
- O.addText(E);
726
- return;
727
- }
728
- s = U(f.subLanguage, E, !0, De[f.subLanguage]), De[f.subLanguage] = /** @type {CompiledMode} */
729
- s._top;
730
- } else
731
- s = ee(E, f.subLanguage.length ? f.subLanguage : null);
732
- f.relevance > 0 && (Y += s.relevance), O.__addSublanguage(s._emitter, s.language);
733
- }
734
- function y() {
735
- f.subLanguage != null ? F() : B(), E = "";
736
- }
737
- function N(s, o) {
738
- s !== "" && (O.startScope(o), O.addText(s), O.endScope());
739
- }
740
- function ke(s, o) {
741
- let g = 1;
742
- const p = o.length - 1;
743
- for (; g <= p; ) {
744
- if (!s._emit[g]) {
745
- g++;
746
- continue;
747
- }
748
- const R = A.classNameAliases[s[g]] || s[g], k = o[g];
749
- R ? N(k, R) : (E = k, B(), E = ""), g++;
750
- }
751
- }
752
- function Te(s, o) {
753
- return s.scope && typeof s.scope == "string" && O.openNode(A.classNameAliases[s.scope] || s.scope), s.beginScope && (s.beginScope._wrap ? (N(E, A.classNameAliases[s.beginScope._wrap] || s.beginScope._wrap), E = "") : s.beginScope._multi && (ke(s.beginScope, o), E = "")), f = Object.create(s, { parent: { value: f } }), f;
754
- }
755
- function Ie(s, o, g) {
756
- let p = Ge(s.endRe, g);
757
- if (p) {
758
- if (s["on:end"]) {
759
- const R = new oe(s);
760
- s["on:end"](o, R), R.isMatchIgnored && (p = !1);
761
- }
762
- if (p) {
763
- for (; s.endsParent && s.parent; )
764
- s = s.parent;
765
- return s;
766
- }
767
- }
768
- if (s.endsWithParent)
769
- return Ie(s.parent, o, g);
770
- }
771
- function Ht(s) {
772
- return f.matcher.regexIndex === 0 ? (E += s[0], 1) : (se = !0, 0);
773
- }
774
- function Pt(s) {
775
- const o = s[0], g = s.rule, p = new oe(g), R = [g.__beforeBegin, g["on:begin"]];
776
- for (const k of R)
777
- if (k && (k(s, p), p.isMatchIgnored))
778
- return Ht(o);
779
- return g.skip ? E += o : (g.excludeBegin && (E += o), y(), !g.returnBegin && !g.excludeBegin && (E = o)), Te(g, s), g.returnBegin ? 0 : o.length;
780
- }
781
- function jt(s) {
782
- const o = s[0], g = a.substring(s.index), p = Ie(f, s, g);
783
- if (!p)
784
- return Re;
785
- const R = f;
786
- f.endScope && f.endScope._wrap ? (y(), N(o, f.endScope._wrap)) : f.endScope && f.endScope._multi ? (y(), ke(f.endScope, s)) : R.skip ? E += o : (R.returnEnd || R.excludeEnd || (E += o), y(), R.excludeEnd && (E = o));
787
- do
788
- f.scope && O.closeNode(), !f.skip && !f.subLanguage && (Y += f.relevance), f = f.parent;
789
- while (f !== p.parent);
790
- return p.starts && Te(p.starts, s), R.returnEnd ? 0 : o.length;
791
- }
792
- function Ut() {
793
- const s = [];
794
- for (let o = f; o !== A; o = o.parent)
795
- o.scope && s.unshift(o.scope);
796
- s.forEach((o) => O.openNode(o));
797
- }
798
- let X = {};
799
- function Be(s, o) {
800
- const g = o && o[0];
801
- if (E += s, g == null)
802
- return y(), 0;
803
- if (X.type === "begin" && o.type === "end" && X.index === o.index && g === "") {
804
- if (E += a.slice(o.index, o.index + 1), !b) {
805
- const p = new Error(`0 width match regex (${n})`);
806
- throw p.languageName = n, p.badRule = X.rule, p;
807
- }
808
- return 1;
809
- }
810
- if (X = o, o.type === "begin")
811
- return Pt(o);
812
- if (o.type === "illegal" && !h) {
813
- const p = new Error('Illegal lexeme "' + g + '" for mode "' + (f.scope || "<unnamed>") + '"');
814
- throw p.mode = f, p;
815
- } else if (o.type === "end") {
816
- const p = jt(o);
817
- if (p !== Re)
818
- return p;
819
- }
820
- if (o.type === "illegal" && g === "")
821
- return E += `
822
- `, 1;
823
- if (ie > 1e5 && ie > o.index * 3)
824
- throw new Error("potential infinite loop, way more iterations than matches");
825
- return E += g, g.length;
826
- }
827
- const A = I(n);
828
- if (!A)
829
- throw v(_.replace("{}", n)), new Error('Unknown language: "' + n + '"');
830
- const $t = wt(A);
831
- let ne = "", f = d || $t;
832
- const De = {}, O = new r.__emitter(r);
833
- Ut();
834
- let E = "", Y = 0, C = 0, ie = 0, se = !1;
835
- try {
836
- if (A.__emitTokens)
837
- A.__emitTokens(a, O);
838
- else {
839
- for (f.matcher.considerAll(); ; ) {
840
- ie++, se ? se = !1 : f.matcher.considerAll(), f.matcher.lastIndex = C;
841
- const s = f.matcher.exec(a);
842
- if (!s) break;
843
- const o = a.substring(C, s.index), g = Be(o, s);
844
- C = s.index + g;
845
- }
846
- Be(a.substring(C));
847
- }
848
- return O.finalize(), ne = O.toHTML(), {
849
- language: n,
850
- value: ne,
851
- relevance: Y,
852
- illegal: !1,
853
- _emitter: O,
854
- _top: f
855
- };
856
- } catch (s) {
857
- if (s.message && s.message.includes("Illegal"))
858
- return {
859
- language: n,
860
- value: Q(a),
861
- illegal: !0,
862
- relevance: 0,
863
- _illegalBy: {
864
- message: s.message,
865
- index: C,
866
- context: a.slice(C - 100, C + 100),
867
- mode: s.mode,
868
- resultSoFar: ne
869
- },
870
- _emitter: O
871
- };
872
- if (b)
873
- return {
874
- language: n,
875
- value: Q(a),
876
- illegal: !1,
877
- relevance: 0,
878
- errorRaised: s,
879
- _emitter: O,
880
- _top: f
881
- };
882
- throw s;
883
- }
884
- }
885
- function m(n) {
886
- const a = {
887
- value: Q(n),
888
- illegal: !1,
889
- relevance: 0,
890
- _top: c,
891
- _emitter: new r.__emitter(r)
892
- };
893
- return a._emitter.addText(n), a;
894
- }
895
- function ee(n, a) {
896
- a = a || r.languages || Object.keys(t);
897
- const h = m(n), d = a.filter(I).filter(Ae).map(
898
- (y) => U(y, n, !1)
899
- );
900
- d.unshift(h);
901
- const w = d.sort((y, N) => {
902
- if (y.relevance !== N.relevance) return N.relevance - y.relevance;
903
- if (y.language && N.language) {
904
- if (I(y.language).supersetOf === N.language)
905
- return 1;
906
- if (I(N.language).supersetOf === y.language)
907
- return -1;
908
- }
909
- return 0;
910
- }), [S, B] = w, F = S;
911
- return F.secondBest = B, F;
912
- }
913
- function St(n, a, h) {
914
- const d = a && i[a] || h;
915
- n.classList.add("hljs"), n.classList.add(`language-${d}`);
916
- }
917
- function te(n) {
918
- let a = null;
919
- const h = x(n);
920
- if (l(h)) return;
921
- if (z(
922
- "before:highlightElement",
923
- { el: n, language: h }
924
- ), n.dataset.highlighted) {
925
- console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", n);
926
- return;
927
- }
928
- if (n.children.length > 0 && (r.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(n)), r.throwUnescapedHTML))
929
- throw new Rt(
930
- "One of your code blocks includes unescaped HTML.",
931
- n.innerHTML
932
- );
933
- a = n;
934
- const d = a.textContent, w = h ? M(d, { language: h, ignoreIllegals: !0 }) : ee(d);
935
- n.innerHTML = w.value, n.dataset.highlighted = "yes", St(n, h, w.language), n.result = {
936
- language: w.language,
937
- // TODO: remove with version 11.0
938
- re: w.relevance,
939
- relevance: w.relevance
940
- }, w.secondBest && (n.secondBest = {
941
- language: w.secondBest.language,
942
- relevance: w.secondBest.relevance
943
- }), z("after:highlightElement", { el: n, result: w, text: d });
944
- }
945
- function Nt(n) {
946
- r = Oe(r, n);
947
- }
948
- const At = () => {
949
- K(), L("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
950
- };
951
- function kt() {
952
- K(), L("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
953
- }
954
- let Se = !1;
955
- function K() {
956
- function n() {
957
- K();
958
- }
959
- if (document.readyState === "loading") {
960
- Se || window.addEventListener("DOMContentLoaded", n, !1), Se = !0;
961
- return;
962
- }
963
- document.querySelectorAll(r.cssSelector).forEach(te);
964
- }
965
- function Tt(n, a) {
966
- let h = null;
967
- try {
968
- h = a(e);
969
- } catch (d) {
970
- if (v("Language definition for '{}' could not be registered.".replace("{}", n)), b)
971
- v(d);
972
- else
973
- throw d;
974
- h = c;
975
- }
976
- h.name || (h.name = n), t[n] = h, h.rawDefinition = a.bind(null, e), h.aliases && Ne(h.aliases, { languageName: n });
977
- }
978
- function It(n) {
979
- delete t[n];
980
- for (const a of Object.keys(i))
981
- i[a] === n && delete i[a];
982
- }
983
- function Bt() {
984
- return Object.keys(t);
985
- }
986
- function I(n) {
987
- return n = (n || "").toLowerCase(), t[n] || t[i[n]];
988
- }
989
- function Ne(n, { languageName: a }) {
990
- typeof n == "string" && (n = [n]), n.forEach((h) => {
991
- i[h.toLowerCase()] = a;
992
- });
993
- }
994
- function Ae(n) {
995
- const a = I(n);
996
- return a && !a.disableAutodetect;
997
- }
998
- function Dt(n) {
999
- n["before:highlightBlock"] && !n["before:highlightElement"] && (n["before:highlightElement"] = (a) => {
1000
- n["before:highlightBlock"](
1001
- Object.assign({ block: a.el }, a)
1002
- );
1003
- }), n["after:highlightBlock"] && !n["after:highlightElement"] && (n["after:highlightElement"] = (a) => {
1004
- n["after:highlightBlock"](
1005
- Object.assign({ block: a.el }, a)
1006
- );
1007
- });
1008
- }
1009
- function vt(n) {
1010
- Dt(n), u.push(n);
1011
- }
1012
- function Ct(n) {
1013
- const a = u.indexOf(n);
1014
- a !== -1 && u.splice(a, 1);
1015
- }
1016
- function z(n, a) {
1017
- const h = n;
1018
- u.forEach(function(d) {
1019
- d[h] && d[h](a);
1020
- });
1021
- }
1022
- function Lt(n) {
1023
- return L("10.7.0", "highlightBlock will be removed entirely in v12.0"), L("10.7.0", "Please use highlightElement now."), te(n);
1024
- }
1025
- Object.assign(e, {
1026
- highlight: M,
1027
- highlightAuto: ee,
1028
- highlightAll: K,
1029
- highlightElement: te,
1030
- // TODO: Remove with v12 API
1031
- highlightBlock: Lt,
1032
- configure: Nt,
1033
- initHighlighting: At,
1034
- initHighlightingOnLoad: kt,
1035
- registerLanguage: Tt,
1036
- unregisterLanguage: It,
1037
- listLanguages: Bt,
1038
- getLanguage: I,
1039
- registerAliases: Ne,
1040
- autoDetection: Ae,
1041
- inherit: Oe,
1042
- addPlugin: vt,
1043
- removePlugin: Ct
1044
- }), e.debugMode = function() {
1045
- b = !1;
1046
- }, e.safeMode = function() {
1047
- b = !0;
1048
- }, e.versionString = Ot, e.regex = {
1049
- concat: D,
1050
- lookahead: fe,
1051
- either: q,
1052
- optional: Ue,
1053
- anyNumberOfTimes: je
1054
- };
1055
- for (const n in G)
1056
- typeof G[n] == "object" && ce(G[n]);
1057
- return Object.assign(e, G), e;
1058
- }, H = ye({});
1059
- return H.newInstance = () => ye({}), re = H, H.HighlightJS = H, H.default = H, re;
1060
54
  }
1061
55
  export {
1062
- zt as __require
56
+ K as keydownHandler
1063
57
  };