@pyscript/core 0.6.9 → 0.6.10

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 (82) hide show
  1. package/dist/codemirror-CAEZ6Sg7.js +2 -0
  2. package/dist/{codemirror-1dOfKU91.js.map → codemirror-CAEZ6Sg7.js.map} +1 -1
  3. package/dist/codemirror_commands-BPM8HxXO.js +2 -0
  4. package/dist/{codemirror_commands-CKMxnUcp.js.map → codemirror_commands-BPM8HxXO.js.map} +1 -1
  5. package/dist/codemirror_lang-python-DvjhpaK2.js +2 -0
  6. package/dist/{codemirror_lang-python-D9DYtDWr.js.map → codemirror_lang-python-DvjhpaK2.js.map} +1 -1
  7. package/dist/codemirror_language-4kk4Aqm3.js +2 -0
  8. package/dist/{codemirror_language-B5lTPv2c.js.map → codemirror_language-4kk4Aqm3.js.map} +1 -1
  9. package/dist/codemirror_state-1d1uncXx.js +2 -0
  10. package/dist/{codemirror_state-n1sFh2hh.js.map → codemirror_state-1d1uncXx.js.map} +1 -1
  11. package/dist/codemirror_view-aIuSN42d.js +2 -0
  12. package/dist/{codemirror_view-1a1gCrKZ.js.map → codemirror_view-aIuSN42d.js.map} +1 -1
  13. package/dist/core-Djc_-F2E.js +2 -0
  14. package/dist/core-Djc_-F2E.js.map +1 -0
  15. package/dist/core.css +1 -75
  16. package/dist/core.js +1 -1
  17. package/dist/deprecations-manager-CJPk1tJA.js +2 -0
  18. package/dist/{deprecations-manager-Cf_aFUPK.js.map → deprecations-manager-CJPk1tJA.js.map} +1 -1
  19. package/dist/donkey-B8oMxGx2.js +2 -0
  20. package/dist/{donkey-Cc8svH2Q.js.map → donkey-B8oMxGx2.js.map} +1 -1
  21. package/dist/error-B9FssCEE.js +2 -0
  22. package/dist/error-B9FssCEE.js.map +1 -0
  23. package/dist/index-DqgFLybq.js +2 -0
  24. package/dist/{index-BVFrv_QY.js.map → index-DqgFLybq.js.map} +1 -1
  25. package/dist/mpy-DHvNziqy.js +2 -0
  26. package/dist/{mpy-CQiuZcjW.js.map → mpy-DHvNziqy.js.map} +1 -1
  27. package/dist/py-C5GQdsZt.js +2 -0
  28. package/dist/{py-BgH4mprx.js.map → py-C5GQdsZt.js.map} +1 -1
  29. package/dist/py-editor-Bux-ztRb.js +2 -0
  30. package/dist/{py-editor-Dzsa3rsF.js.map → py-editor-Bux-ztRb.js.map} +1 -1
  31. package/dist/py-terminal-SqxsB6JH.js +2 -0
  32. package/dist/{py-terminal-BX_wPoTi.js.map → py-terminal-SqxsB6JH.js.map} +1 -1
  33. package/dist/storage.js +1 -421
  34. package/dist/storage.js.map +1 -1
  35. package/dist/toml-CvAfdf9_.js +3 -0
  36. package/dist/toml-CvAfdf9_.js.map +1 -0
  37. package/dist/toml-DiUM0_qs.js +3 -0
  38. package/dist/{toml-CkEFU7ly.js.map → toml-DiUM0_qs.js.map} +1 -1
  39. package/dist/xterm-BY7uk_OU.js +2 -0
  40. package/dist/xterm-BY7uk_OU.js.map +1 -0
  41. package/dist/xterm-readline-CZfBw7ic.js +2 -0
  42. package/dist/xterm-readline-CZfBw7ic.js.map +1 -0
  43. package/dist/xterm_addon-fit--gyF3PcZ.js +2 -0
  44. package/dist/xterm_addon-fit--gyF3PcZ.js.map +1 -0
  45. package/dist/xterm_addon-web-links-Cnej-nJ6.js +2 -0
  46. package/dist/xterm_addon-web-links-Cnej-nJ6.js.map +1 -0
  47. package/dist/zip-Bf48tRr5.js +2 -0
  48. package/dist/zip-Bf48tRr5.js.map +1 -0
  49. package/package.json +1 -1
  50. package/src/core.js +2 -2
  51. package/src/plugins/error.js +1 -1
  52. package/src/stdlib/pyscript.js +13 -13
  53. package/dist/codemirror-1dOfKU91.js +0 -1832
  54. package/dist/codemirror_commands-CKMxnUcp.js +0 -1714
  55. package/dist/codemirror_lang-python-D9DYtDWr.js +0 -2462
  56. package/dist/codemirror_language-B5lTPv2c.js +0 -5337
  57. package/dist/codemirror_state-n1sFh2hh.js +0 -3930
  58. package/dist/codemirror_view-1a1gCrKZ.js +0 -11428
  59. package/dist/core-D2ytnMSk.js +0 -4349
  60. package/dist/core-D2ytnMSk.js.map +0 -1
  61. package/dist/deprecations-manager-Cf_aFUPK.js +0 -29
  62. package/dist/donkey-Cc8svH2Q.js +0 -170
  63. package/dist/error-DWoeKPDI.js +0 -59
  64. package/dist/error-DWoeKPDI.js.map +0 -1
  65. package/dist/index-BVFrv_QY.js +0 -1911
  66. package/dist/mpy-CQiuZcjW.js +0 -255
  67. package/dist/py-BgH4mprx.js +0 -182
  68. package/dist/py-editor-Dzsa3rsF.js +0 -433
  69. package/dist/py-terminal-BX_wPoTi.js +0 -61
  70. package/dist/toml-CkEFU7ly.js +0 -103
  71. package/dist/toml-DTuPg5as.js +0 -5
  72. package/dist/toml-DTuPg5as.js.map +0 -1
  73. package/dist/xterm-eU6F6YKE.js +0 -10
  74. package/dist/xterm-eU6F6YKE.js.map +0 -1
  75. package/dist/xterm-readline-C7HDczqS.js +0 -501
  76. package/dist/xterm-readline-C7HDczqS.js.map +0 -1
  77. package/dist/xterm_addon-fit-Cotzxdkz.js +0 -10
  78. package/dist/xterm_addon-fit-Cotzxdkz.js.map +0 -1
  79. package/dist/xterm_addon-web-links-DoNfCjeX.js +0 -10
  80. package/dist/xterm_addon-web-links-DoNfCjeX.js.map +0 -1
  81. package/dist/zip-Cj6c-tjp.js +0 -13
  82. package/dist/zip-Cj6c-tjp.js.map +0 -1
@@ -1,433 +0,0 @@
1
- import { T as TYPES, X as XWorker, d as defineProperties, a as dedent, r as relative_url, o as offline_interpreter, H as Hook, s as stdlib } from './core-D2ytnMSk.js';
2
- import { notify } from './error-DWoeKPDI.js';
3
-
4
- // PyScript py-editor plugin
5
-
6
- const RUN_BUTTON = `<svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>`;
7
-
8
- let id = 0;
9
- const getID = (type) => `${type}-editor-${id++}`;
10
-
11
- const envs = new Map();
12
- const configs = new Map();
13
-
14
- const hooks = {
15
- worker: {
16
- codeBeforeRun: () => stdlib,
17
- // works on both Pyodide and MicroPython
18
- onReady: ({ runAsync, io }, { sync }) => {
19
- io.stdout = io.buffered(sync.write);
20
- io.stderr = io.buffered(sync.writeErr);
21
- sync.revoke();
22
- sync.runAsync = runAsync;
23
- },
24
- },
25
- };
26
-
27
- const validate = (config, result) => {
28
- if (typeof result === "boolean") throw `Invalid source: ${config}`;
29
- return result;
30
- };
31
-
32
- async function execute({ currentTarget }) {
33
- const { env, pySrc, outDiv } = this;
34
- const hasRunButton = !!currentTarget;
35
-
36
- if (hasRunButton) {
37
- currentTarget.disabled = true;
38
- outDiv.innerHTML = "";
39
- }
40
-
41
- if (!envs.has(env)) {
42
- const srcLink = URL.createObjectURL(new Blob([""]));
43
- const details = {
44
- type: this.interpreter,
45
- serviceWorker: this.serviceWorker,
46
- };
47
- const { config } = this;
48
- if (config) {
49
- // verify that config can be parsed and used
50
- try {
51
- details.configURL = relative_url(config);
52
- if (config.endsWith(".toml")) {
53
- const [{ parse }, toml] = await Promise.all([
54
- import(
55
- /* webpackIgnore: true */ './toml-DTuPg5as.js'
56
- ),
57
- fetch(config).then((r) => r.ok && r.text()),
58
- ]);
59
- details.config = parse(validate(config, toml));
60
- } else if (config.endsWith(".json")) {
61
- const json = await fetch(config).then(
62
- (r) => r.ok && r.json(),
63
- );
64
- details.config = validate(config, json);
65
- } else {
66
- details.configURL = relative_url("./config.txt");
67
- details.config = JSON.parse(config);
68
- }
69
- details.version = offline_interpreter(details.config);
70
- } catch (error) {
71
- notify(error);
72
- return;
73
- }
74
- } else {
75
- details.config = {};
76
- }
77
-
78
- const xworker = XWorker.call(new Hook(null, hooks), srcLink, details);
79
-
80
- // expose xworker like in terminal or other workers to allow
81
- // creation and destruction of editors on the fly
82
- if (hasRunButton) {
83
- for (const type of TYPES.keys()) {
84
- const editor = currentTarget.closest(`.${type}-editor-box`);
85
- const script = editor?.parentNode?.previousElementSibling;
86
- if (script) {
87
- defineProperties(script, { xworker: { value: xworker } });
88
- break;
89
- }
90
- }
91
- }
92
-
93
- const { sync } = xworker;
94
- const { promise, resolve } = Promise.withResolvers();
95
- envs.set(env, promise);
96
- sync.revoke = () => {
97
- URL.revokeObjectURL(srcLink);
98
- resolve(xworker);
99
- };
100
- }
101
-
102
- // wait for the env then set the target div
103
- // before executing the current code
104
- return envs.get(env).then((xworker) => {
105
- xworker.onerror = ({ error }) => {
106
- if (hasRunButton) {
107
- outDiv.insertAdjacentHTML(
108
- "beforeend",
109
- `<span style='color:red'>${
110
- error.message || error
111
- }</span>\n`,
112
- );
113
- }
114
- console.error(error);
115
- };
116
-
117
- const enable = () => {
118
- if (hasRunButton) currentTarget.disabled = false;
119
- };
120
- const { sync } = xworker;
121
- sync.write = (str) => {
122
- if (hasRunButton) outDiv.innerText += `${str}\n`;
123
- else console.log(str);
124
- };
125
- sync.writeErr = (str) => {
126
- if (hasRunButton) {
127
- outDiv.insertAdjacentHTML(
128
- "beforeend",
129
- `<span style='color:red'>${str}</span>\n`,
130
- );
131
- } else {
132
- notify(str);
133
- console.error(str);
134
- }
135
- };
136
- sync.runAsync(pySrc).then(enable, enable);
137
- });
138
- }
139
-
140
- const makeRunButton = (handler, type) => {
141
- const runButton = document.createElement("button");
142
- runButton.className = `absolute ${type}-editor-run-button`;
143
- runButton.innerHTML = RUN_BUTTON;
144
- runButton.setAttribute("aria-label", "Python Script Run Button");
145
- runButton.addEventListener("click", async (event) => {
146
- runButton.blur();
147
- await handler.handleEvent(event);
148
- });
149
- return runButton;
150
- };
151
-
152
- const makeEditorDiv = (handler, type) => {
153
- const editorDiv = document.createElement("div");
154
- editorDiv.className = `${type}-editor-input`;
155
- editorDiv.setAttribute("aria-label", "Python Script Area");
156
-
157
- const runButton = makeRunButton(handler, type);
158
- const editorShadowContainer = document.createElement("div");
159
-
160
- // avoid outer elements intercepting key events (reveal as example)
161
- editorShadowContainer.addEventListener("keydown", (event) => {
162
- event.stopPropagation();
163
- });
164
-
165
- editorDiv.append(runButton, editorShadowContainer);
166
-
167
- return editorDiv;
168
- };
169
-
170
- const makeOutDiv = (type) => {
171
- const outDiv = document.createElement("div");
172
- outDiv.className = `${type}-editor-output`;
173
- outDiv.id = `${getID(type)}-output`;
174
- return outDiv;
175
- };
176
-
177
- const makeBoxDiv = (handler, type) => {
178
- const boxDiv = document.createElement("div");
179
- boxDiv.className = `${type}-editor-box`;
180
-
181
- const editorDiv = makeEditorDiv(handler, type);
182
- const outDiv = makeOutDiv(type);
183
- boxDiv.append(editorDiv, outDiv);
184
-
185
- return [boxDiv, outDiv, editorDiv.querySelector("button")];
186
- };
187
-
188
- const init = async (script, type, interpreter) => {
189
- const [
190
- { basicSetup, EditorView },
191
- { Compartment },
192
- { python },
193
- { indentUnit },
194
- { keymap },
195
- { defaultKeymap, indentWithTab },
196
- ] = await Promise.all([
197
- import(/* webpackIgnore: true */ './codemirror-1dOfKU91.js'),
198
- import(/* webpackIgnore: true */ './codemirror_state-n1sFh2hh.js'),
199
- import(
200
- /* webpackIgnore: true */ './codemirror_lang-python-D9DYtDWr.js'
201
- ),
202
- import(/* webpackIgnore: true */ './codemirror_language-B5lTPv2c.js').then(function (n) { return n.x; }),
203
- import(/* webpackIgnore: true */ './codemirror_view-1a1gCrKZ.js').then(function (n) { return n.q; }),
204
- import(/* webpackIgnore: true */ './codemirror_commands-CKMxnUcp.js'),
205
- ]);
206
-
207
- let isSetup = script.hasAttribute("setup");
208
- const hasConfig = script.hasAttribute("config");
209
- const serviceWorker = script.getAttribute("service-worker");
210
- const env = `${interpreter}-${script.getAttribute("env") || getID(type)}`;
211
-
212
- // helps preventing too lazy ServiceWorker initialization on button run
213
- if (serviceWorker) {
214
- new XWorker("data:application/javascript,postMessage(0)", {
215
- type: "dummy",
216
- serviceWorker,
217
- }).onmessage = ({ target }) => target.terminate();
218
- }
219
-
220
- if (hasConfig && configs.has(env)) {
221
- throw new SyntaxError(
222
- configs.get(env)
223
- ? `duplicated config for env: ${env}`
224
- : `unable to add a config to the env: ${env}`,
225
- );
226
- }
227
-
228
- configs.set(env, hasConfig);
229
-
230
- let source = script.textContent;
231
-
232
- // verify the src points to a valid file that can be parsed
233
- const { src } = script;
234
- if (src) {
235
- try {
236
- source = validate(
237
- src,
238
- await fetch(src).then((b) => b.ok && b.text()),
239
- );
240
- } catch (error) {
241
- notify(error);
242
- return;
243
- }
244
- }
245
-
246
- const context = {
247
- // allow the listener to be overridden at distance
248
- handleEvent: execute,
249
- serviceWorker,
250
- interpreter,
251
- env,
252
- config: hasConfig && script.getAttribute("config"),
253
- get pySrc() {
254
- return isSetup ? source : editor.state.doc.toString();
255
- },
256
- get outDiv() {
257
- return isSetup ? null : outDiv;
258
- },
259
- };
260
-
261
- let target;
262
- defineProperties(script, {
263
- target: { get: () => target },
264
- handleEvent: {
265
- get: () => context.handleEvent,
266
- set: (callback) => {
267
- // do not bother with logic if it was set back as its original handler
268
- if (callback === execute) context.handleEvent = execute;
269
- // in every other case be sure that if the listener override returned
270
- // `false` nothing happens, otherwise keep doing what it always did
271
- else {
272
- context.handleEvent = async (event) => {
273
- // trap the currentTarget ASAP (if any)
274
- // otherwise it gets lost asynchronously
275
- const { currentTarget } = event;
276
- // augment a code snapshot before invoking the override
277
- defineProperties(event, {
278
- code: { value: context.pySrc },
279
- });
280
- // avoid executing the default handler if the override returned `false`
281
- if ((await callback(event)) !== false)
282
- await execute.call(context, { currentTarget });
283
- };
284
- }
285
- },
286
- },
287
- code: {
288
- get: () => context.pySrc,
289
- set: (insert) => {
290
- if (isSetup) return;
291
- editor.update([
292
- editor.state.update({
293
- changes: {
294
- from: 0,
295
- to: editor.state.doc.length,
296
- insert,
297
- },
298
- }),
299
- ]);
300
- },
301
- },
302
- process: {
303
- /**
304
- * Simulate a setup node overriding the source to evaluate.
305
- * @param {string} code the Python code to evaluate.
306
- * @param {boolean} asRunButtonAction invoke the `Run` button handler.
307
- * @returns {Promise<...>} fulfill once code has been evaluated.
308
- */
309
- value(code, asRunButtonAction = false) {
310
- if (asRunButtonAction) return listener();
311
- const wasSetup = isSetup;
312
- const wasSource = source;
313
- isSetup = true;
314
- source = code;
315
- const restore = () => {
316
- isSetup = wasSetup;
317
- source = wasSource;
318
- };
319
- return context
320
- .handleEvent({ currentTarget: null })
321
- .then(restore, restore);
322
- },
323
- },
324
- });
325
-
326
- const notifyEditor = () => {
327
- const event = new Event(`${type}-editor`, { bubbles: true });
328
- script.dispatchEvent(event);
329
- };
330
-
331
- if (isSetup) {
332
- await context.handleEvent({ currentTarget: null });
333
- notifyEditor();
334
- return;
335
- }
336
-
337
- const selector = script.getAttribute("target");
338
-
339
- if (selector) {
340
- target =
341
- document.getElementById(selector) ||
342
- document.querySelector(selector);
343
- if (!target) throw new Error(`Unknown target ${selector}`);
344
- } else {
345
- target = document.createElement(`${type}-editor`);
346
- target.style.display = "block";
347
- script.after(target);
348
- }
349
-
350
- if (!target.id) target.id = getID(type);
351
- if (!target.hasAttribute("exec-id")) target.setAttribute("exec-id", 0);
352
- if (!target.hasAttribute("root")) target.setAttribute("root", target.id);
353
-
354
- // @see https://github.com/JeffersGlass/mkdocs-pyscript/blob/main/mkdocs_pyscript/js/makeblocks.js
355
- const [boxDiv, outDiv, runButton] = makeBoxDiv(context, type);
356
- boxDiv.dataset.env = script.hasAttribute("env") ? env : interpreter;
357
-
358
- const inputChild = boxDiv.querySelector(`.${type}-editor-input > div`);
359
- const parent = inputChild.attachShadow({ mode: "open" });
360
- // avoid inheriting styles from the outer component
361
- parent.innerHTML = `<style> :host { all: initial; }</style>`;
362
-
363
- target.appendChild(boxDiv);
364
-
365
- const doc = dedent(script.textContent).trim();
366
-
367
- // preserve user indentation, if any
368
- const indentation = /^([ \t]+)/m.test(doc) ? RegExp.$1 : " ";
369
-
370
- const listener = () => runButton.click();
371
- const editor = new EditorView({
372
- extensions: [
373
- indentUnit.of(indentation),
374
- new Compartment().of(python()),
375
- keymap.of([
376
- ...defaultKeymap,
377
- { key: "Ctrl-Enter", run: listener, preventDefault: true },
378
- { key: "Cmd-Enter", run: listener, preventDefault: true },
379
- { key: "Shift-Enter", run: listener, preventDefault: true },
380
- // @see https://codemirror.net/examples/tab/
381
- indentWithTab,
382
- ]),
383
- basicSetup,
384
- ],
385
- foldGutter: true,
386
- gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
387
- parent,
388
- doc,
389
- });
390
-
391
- editor.focus();
392
- notifyEditor();
393
- };
394
-
395
- // avoid too greedy MutationObserver operations at distance
396
- let timeout = 0;
397
-
398
- // avoid delayed initialization
399
- let queue = Promise.resolve();
400
-
401
- // reset interval value then check for new scripts
402
- const resetTimeout = () => {
403
- timeout = 0;
404
- pyEditor();
405
- };
406
-
407
- // triggered both ASAP on the living DOM and via MutationObserver later
408
- const pyEditor = () => {
409
- if (timeout) return;
410
- timeout = setTimeout(resetTimeout, 250);
411
- for (const [type, interpreter] of TYPES) {
412
- const selector = `script[type="${type}-editor"]`;
413
- for (const script of document.querySelectorAll(selector)) {
414
- // avoid any further bootstrap by changing the type as active
415
- script.type += "-active";
416
- // don't await in here or multiple calls might happen
417
- // while the first script is being initialized
418
- queue = queue.then(() => init(script, type, interpreter));
419
- }
420
- }
421
- return queue;
422
- };
423
-
424
- new MutationObserver(pyEditor).observe(document, {
425
- childList: true,
426
- subtree: true,
427
- });
428
-
429
- // try to check the current document ASAP
430
- var pyEditor$1 = pyEditor();
431
-
432
- export { pyEditor$1 as default };
433
- //# sourceMappingURL=py-editor-Dzsa3rsF.js.map
@@ -1,61 +0,0 @@
1
- import { T as TYPES, c as customObserver, r as relative_url } from './core-D2ytnMSk.js';
2
- import { notify } from './error-DWoeKPDI.js';
3
-
4
- // PyScript py-terminal plugin
5
-
6
- // will contain all valid selectors
7
- const SELECTORS = [];
8
-
9
- // avoid processing same elements twice
10
- const processed = new WeakSet();
11
-
12
- // show the error on main and
13
- // stops the module from keep executing
14
- const notifyAndThrow = (message) => {
15
- notify(message);
16
- throw new Error(message);
17
- };
18
-
19
- const onceOnMain = ({ attributes: { worker } }) => !worker;
20
-
21
- let addStyle = true;
22
-
23
- for (const type of TYPES.keys()) {
24
- const selector = `script[type="${type}"][terminal],${type}-script[terminal]`;
25
- SELECTORS.push(selector);
26
- customObserver.set(selector, async (element) => {
27
- // we currently support only one terminal on main as in "classic"
28
- const terminals = document.querySelectorAll(SELECTORS.join(","));
29
- if ([].filter.call(terminals, onceOnMain).length > 1)
30
- notifyAndThrow("You can use at most 1 main terminal");
31
-
32
- // import styles lazily
33
- if (addStyle) {
34
- addStyle = false;
35
- document.head.append(
36
- Object.assign(document.createElement("link"), {
37
- rel: "stylesheet",
38
- href: relative_url("./xterm.css", import.meta.url),
39
- }),
40
- );
41
- }
42
-
43
- if (processed.has(element)) return;
44
- processed.add(element);
45
-
46
- const bootstrap = (module) => module.default(element);
47
-
48
- // we can't be smart with template literals for the dynamic import
49
- // or bundlers are incapable of producing multiple files around
50
- if (type === "mpy") {
51
- await import(/* webpackIgnore: true */ './mpy-CQiuZcjW.js').then(
52
- bootstrap,
53
- );
54
- } else {
55
- await import(/* webpackIgnore: true */ './py-BgH4mprx.js').then(
56
- bootstrap,
57
- );
58
- }
59
- });
60
- }
61
- //# sourceMappingURL=py-terminal-BX_wPoTi.js.map
@@ -1,103 +0,0 @@
1
- /* c8 ignore start */
2
- /*! (c) Andrea Giammarchi - ISC */
3
-
4
- const {isArray} = Array;
5
- const {parse: jsonParse} = JSON;
6
-
7
- /** @typedef {{s: string[], d: Date[]}} Foreign foreign strings and dates */
8
-
9
- /**
10
- * Transform quoted keys into regular keys.
11
- * @param {string} str the key to eventually normalize
12
- * @param {Foreign} foreign foreign strings and dates
13
- * @returns
14
- */
15
- const getKey = (str, {s}) => str.replace(/"s(\d+)"/g, (_, $1) => s[$1]);
16
-
17
- /**
18
- * Given a `'string'` or a `"string"` returns a JSON compatible string.
19
- * @param {string} str a TOML entry to parse
20
- * @param {Foreign} foreign foreign strings and dates
21
- * @returns {string}
22
- */
23
- const getValue = (str, foreign) => jsonParse(
24
- str.replace(/(\S+?)\s*=/g, '"$1":'),
25
- (_, value) => typeof value === 'string' ?
26
- foreign[value[0]][value.slice(1)] :
27
- value
28
- );
29
-
30
- /**
31
- * Crawl the `json` object via the given array of keys and handle array entries.
32
- * @param {string[]} keys a path with all keys to reach the entry
33
- * @param {Foreign} foreign foreign strings and dates
34
- * @param {object} entry the root entry of the TOML
35
- * @param {boolean} asArray handle array entries
36
- * @returns {object} the current entry to handle
37
- */
38
- const getPath = (keys, foreign, entry, asArray) => {
39
- for (let i = 0, {length} = keys, last = length - 1; i < length; i++) {
40
- const key = getKey(keys[i], foreign);
41
- entry = entry[key] || (entry[key] = (asArray && (i === last) ? [] : {}));
42
- if (isArray(entry)) {
43
- if ((i === last) || !entry.length)
44
- entry.push({});
45
- entry = entry.at(-1);
46
- }
47
- }
48
- return entry;
49
- };
50
-
51
- /**
52
- * Given a TOML text, removes stirngs and dates for easier parsing +
53
- * remove multi-line arrays to not need evaluation.
54
- * @param {string} toml the TOML text to map
55
- * @param {string[]} strings mapped strings
56
- * @param {Date[]} dates mapped Dates
57
- * @returns {[string, Foreign]}
58
- */
59
- const mapForeign = (toml, strings, dates) => [
60
- toml
61
- // map strings in the TOML
62
- .replace(
63
- /(["'])(?:(?=(\\?))\2.)*?\1/g,
64
- value => `"s${strings.push(value.slice(1, -1)) - 1}"`
65
- )
66
- // map dates in the TOML
67
- .replace(
68
- /\d{2,}([:-]\d{2}){2}([ T:-][\dZ:-]+)?/g,
69
- value => `"d${dates.push(new Date(value)) - 1}"`
70
- )
71
- // avoid multi-line array entries
72
- .replace(/,\s*[\r\n]+/g, ', ')
73
- .replace(/\[\s*[\r\n]+/g, '[')
74
- .replace(/[\r\n]+\s*]/g, ']'),
75
- {s: strings, d: dates}
76
- ];
77
-
78
- /**
79
- * Given a simple subset of a TOML file, returns its JS equivalent.
80
- * @param {string} toml the TOML text to parse
81
- * @returns {object} the TOML equivalent as JSON serializable
82
- */
83
- const parse = toml => {
84
- const [text, foreign] = mapForeign(toml, [], []);
85
- const json = {};
86
- let entry = json;
87
- for (let line of text.split(/[\r\n]+/)) {
88
- if ((line = line.trim()) && !line.startsWith('#')) {
89
- if (/^(\[+)(.*?)\]+/.test(line))
90
- entry = getPath(RegExp.$2.trim().split('.'), foreign, json, RegExp.$1 !== '[');
91
- else if (/^(\S+?)\s*=([^#]+)/.test(line)) {
92
- const {$1: key, $2: value} = RegExp;
93
- entry[getKey(key, foreign)] = getValue(value.trim(), foreign);
94
- }
95
- }
96
- }
97
- return json;
98
- };
99
-
100
- /* c8 ignore stop */
101
-
102
- export { parse };
103
- //# sourceMappingURL=toml-CkEFU7ly.js.map
@@ -1,5 +0,0 @@
1
- const{SyntaxError:r,parse:t}=function(){function r(t,e,n,u){this.message=t,this.expected=e,this.found=n,this.location=u,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,r);}return function(r,t){function e(){this.constructor=r;}e.prototype=t.prototype,r.prototype=new e;}(r,Error),r.buildMessage=function(r,t){var e={literal:function(r){return '"'+u(r.text)+'"'},class:function(r){var t,e="";for(t=0;t<r.parts.length;t++)e+=r.parts[t]instanceof Array?o(r.parts[t][0])+"-"+o(r.parts[t][1]):o(r.parts[t]);return "["+(r.inverted?"^":"")+e+"]"},any:function(r){return "any character"},end:function(r){return "end of input"},other:function(r){return r.description}};function n(r){return r.charCodeAt(0).toString(16).toUpperCase()}function u(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(r){return "\\x0"+n(r)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(r){return "\\x"+n(r)}))}function o(r){return r.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(r){return "\\x0"+n(r)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(r){return "\\x"+n(r)}))}return "Expected "+function(r){var t,n,u,o=new Array(r.length);for(t=0;t<r.length;t++)o[t]=(u=r[t],e[u.type](u));if(o.sort(),o.length>0){for(t=1,n=1;t<o.length;t++)o[t-1]!==o[t]&&(o[n]=o[t],n++);o.length=n;}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(r)+" but "+function(r){return r?'"'+u(r)+'"':"end of input"}(t)+" found."},{SyntaxError:r,parse:function(t,e){e=void 0!==e?e:{};var n,u,o,a,i,c,f,s,l,h,p={},v={Expressions:Zt},d=Zt,g=function(){return pe},A=function(r){ve=h(pe,!0,r);},C=function(r){ve=h(pe,!1,r);},b=function(r){l(ve.table,r[0]),ve.table[r[0]]=r[1];},y=Mt("Newline"),m="\n",x=jt("\n",!1),S="\r\n",F=jt("\r\n",!1),w=Mt("Whitespace"),E=/^[ \t]/,T=Ht([" ","\t"],!1,!1),D=Mt("Comment"),j="#",H=jt("#",!1),M={type:"any"},O="=",_=jt("=",!1),N=function(r,t){return [r,t.value]},Z=function(){return Tt()},I=Mt('[a-z], [A-Z], [0-9], "-", "_"'),R=/^[a-zA-Z0-9\-_]/,U=Ht([["a","z"],["A","Z"],["0","9"],"-","_"],!1,!1),z=function(r){return r.join("")},Q=Mt("DoubleQuote"),Y='"',k=jt('"',!1),B=Mt("SingleQuote"),J="'",P=jt("'",!1),V=Mt("ThreeDoubleQuotes"),W='"""',q=jt('"""',!1),G=Mt("ThreeSingleQuotes"),K="'''",L=jt("'''",!1),X=function(r){return {type:"String",value:r.join("")}},$=Mt("NormalCharacter"),rr=/^[^\0-\x1F"\\]/,tr=Ht([["\0",""],'"',"\\"],!0,!1),er="u",nr=jt("u",!1),ur="U",or=jt("U",!1),ar=function(){var r=Tt();return r.length<=2?f(r[1]):s(parseInt(r.substr(2),16))},ir=Mt('"b", "f", "n", "r", "t"'),cr=/^[bfnrt]/,fr=Ht(["b","f","n","r","t"],!1,!1),sr=Mt("Backslash"),lr="\\",hr=jt("\\",!1),pr=Mt("FourHexadecimalDigits"),vr=Mt("EightHexadecimalDigits"),dr=/^[0-9A-Fa-f]/,gr=Ht([["0","9"],["A","F"],["a","f"]],!1,!1),Ar=function(){var r=Tt();return {type:"String",value:r.substr(1,r.length-2)}},Cr=/^[^\0-\x08\n-\x1F']/,br=Ht([["\0","\b"],["\n",""],"'"],!0,!1),yr=function(){return ""},mr=/^[^\0-\x1F\\]/,xr=Ht([["\0",""],"\\"],!0,!1),Sr=Mt("AnyCharacter"),Fr=/^[^\0-\x08\n-\x1F]/,wr=Ht([["\0","\b"],["\n",""]],!0,!1),Er="true",Tr=jt("true",!1),Dr=function(){return {type:"Boolean",value:!0}},jr="false",Hr=jt("false",!1),Mr=function(){return {type:"Boolean",value:!1}},Or=function(){var r=Tt(),t=parseFloat(r.replace(/_/g,""));return o(t)||Dt(r+"is not a 64-bit floating-point number."),{type:"Float",value:t}},_r=".",Nr=jt(".",!1),Zr="_",Ir=jt("_",!1),Rr="e",Ur=jt("e",!1),zr="E",Qr=jt("E",!1),Yr=function(){var r=Tt();/^[-+]?0./.test(r)&&Dt("integer must not contain leading zeros");var t=r.replace(/_/g,""),e=!1;if("-"===t[0]){var n="-9223372036854775808";(t.length>20||20===t.length&&t>n)&&(e=!0);}else {"+"===t[0]&&(t=t.substr(1));var u="9223372036854775807";(t.length>19||19===t.length&&t>u)&&(e=!0);}return e&&Dt(r+" is not a 64-bit signed integer."),t=parseInt(t,10),o(t)||Dt(r+" is not a 64-bit signed integer."),{type:"Integer",value:t}},kr="+",Br=jt("+",!1),Jr="-",Pr=jt("-",!1),Vr=/^[0-9]/,Wr=Ht([["0","9"]],!1,!1),qr="T",Gr=jt("T",!1),Kr=function(){var r=Tt(),t=new Date(r);return o(t.getTime())||Dt("Date-time "+r+" is invalid. It does not conform to RFC 3339 or this is a browser-specific problem."),{type:"DateTime",value:t}},Lr=Mt("FullDate (YYYY-mm-dd)"),Xr=":",$r=jt(":",!1),rt=Mt("Hour (HH)"),tt=Mt("Minute (MM)"),et=Mt("Second (SS)"),nt=Mt("TimeOffset (Z or +/-HH:MM)"),ut="Z",ot=jt("Z",!1),at="[",it=jt("[",!1),ct=",",ft=jt(",",!1),st="]",lt=jt("]",!1),ht=function(r){for(var t={type:"Array",value:r?r[0]:[]},e=0,n=t.value,u=n.length;e<u;e++)n[e]=n[e].value;return t},pt=function(r,t){var e=[r];if(t)for(var n=r.type,u=0,o=t[3],a=o.length;u<a;u++)n!==o[u].type&&Dt(c(o[u].value)+' should be of type "'+n+'".'),e.push(o[u]);return e},vt="{",dt=jt("{",!1),gt="}",At=jt("}",!1),Ct=function(r){var t={};if(r){t[r[0][0]]=r[0][1];for(var e=0,n=r[1],u=n.length;e<u;e++){var o=n[e][3];l(t,o[0]),t[o[0]]=o[1];}}return {type:"InlineTable",value:t}},bt=function(r){return r},yt=function(r,t){for(var e=[r],n=0,u=t.length;n<u;n++)e.push(t[n][3]);return e},mt=0,xt=0,St=[{line:1,column:1}],Ft=0,wt=[],Et=0;if("startRule"in e){if(!(e.startRule in v))throw new Error("Can't start parsing from rule \""+e.startRule+'".');d=v[e.startRule];}function Tt(){return t.substring(xt,mt)}function Dt(t,e){throw function(t,e){return new r(t,null,null,e)}(t,e=void 0!==e?e:_t(xt,mt))}function jt(r,t){return {type:"literal",text:r,ignoreCase:t}}function Ht(r,t,e){return {type:"class",parts:r,inverted:t,ignoreCase:e}}function Mt(r){return {type:"other",description:r}}function Ot(r){var e,n=St[r];if(n)return n;for(e=r-1;!St[e];)e--;for(n={line:(n=St[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return St[r]=n,n}function _t(r,t){var e=Ot(r),n=Ot(t);return {start:{offset:r,line:e.line,column:e.column},end:{offset:t,line:n.line,column:n.column}}}function Nt(r){mt<Ft||(mt>Ft&&(Ft=mt,wt=[]),wt.push(r));}function Zt(){var r,e,n,u,o,a,i,c;for(r=mt,e=[],(n=Rt())===p&&(n=It())===p&&(n=Ut());n!==p;)e.push(n),(n=Rt())===p&&(n=It())===p&&(n=Ut());if(e!==p){if(n=mt,u=function(){var r,e;r=mt,e=function(){var r,e,n,u;r=mt,91===t.charCodeAt(mt)?(e=at,mt++):(e=p,0===Et&&Nt(it));e!==p&&(n=fe())!==p?(93===t.charCodeAt(mt)?(u=st,mt++):(u=p,0===Et&&Nt(lt)),u!==p?(xt=r,r=e=bt(n)):(mt=r,r=p)):(mt=r,r=p);return r}(),e!==p&&(xt=r,e=A(e));r=e,r===p&&(r=mt,(e=fe())!==p&&(xt=r,e=C(e)),(r=e)===p&&(r=mt,(e=zt())!==p&&(xt=r,e=b(e)),r=e));return r}(),u!==p){for(o=[],(a=Rt())===p&&(a=Ut());a!==p;)o.push(a),(a=Rt())===p&&(a=Ut());o!==p?(a=mt,(i=It())!==p&&(c=Zt())!==p?a=i=[i,c]:(mt=a,a=p),a===p&&(a=null),a!==p?n=u=[u,o,a]:(mt=n,n=p)):(mt=n,n=p);}else mt=n,n=p;n===p&&(n=null),n!==p?(xt=r,r=e=g()):(mt=r,r=p);}else mt=r,r=p;return r}function It(){var r;return Et++,10===t.charCodeAt(mt)?(r=m,mt++):(r=p,0===Et&&Nt(x)),r===p&&(t.substr(mt,2)===S?(r=S,mt+=2):(r=p,0===Et&&Nt(F))),Et--,r===p&&0===Et&&Nt(y),r}function Rt(){var r;return Et++,E.test(t.charAt(mt))?(r=t.charAt(mt),mt++):(r=p,0===Et&&Nt(T)),Et--,r===p&&0===Et&&Nt(w),r}function Ut(){var r,e,n,u,o,a;if(Et++,r=mt,35===t.charCodeAt(mt)?(e=j,mt++):(e=p,0===Et&&Nt(H)),e!==p){for(n=[],u=mt,o=mt,Et++,a=It(),Et--,a===p?o=void 0:(mt=o,o=p),o!==p?(t.length>mt?(a=t.charAt(mt),mt++):(a=p,0===Et&&Nt(M)),a!==p?u=o=[o,a]:(mt=u,u=p)):(mt=u,u=p);u!==p;)n.push(u),u=mt,o=mt,Et++,a=It(),Et--,a===p?o=void 0:(mt=o,o=p),o!==p?(t.length>mt?(a=t.charAt(mt),mt++):(a=p,0===Et&&Nt(M)),a!==p?u=o=[o,a]:(mt=u,u=p)):(mt=u,u=p);n!==p?r=e=[e,n]:(mt=r,r=p);}else mt=r,r=p;return Et--,r===p&&(e=p,0===Et&&Nt(D)),r}function zt(){var r,e,n,u,o,a;if(r=mt,(e=Qt())!==p){for(n=[],u=Rt();u!==p;)n.push(u),u=Rt();if(n!==p)if(61===t.charCodeAt(mt)?(u=O,mt++):(u=p,0===Et&&Nt(_)),u!==p){for(o=[],a=Rt();a!==p;)o.push(a),a=Rt();o!==p&&(a=Vt())!==p?(xt=r,r=e=N(e,a)):(mt=r,r=p);}else mt=r,r=p;else mt=r,r=p;}else mt=r,r=p;return r}function Qt(){var r;return (r=function(){var r,t,e;if(r=mt,t=[],(e=Yt())!==p)for(;e!==p;)t.push(e),e=Yt();else t=p;t!==p&&(xt=r,t=Z());return r=t,r}())===p&&(r=function(){var r,t,e;if(r=mt,kt()!==p){if(t=[],(e=Wt())!==p)for(;e!==p;)t.push(e),e=Wt();else t=p;t!==p&&(e=kt())!==p?(xt=r,r=z(t)):(mt=r,r=p);}else mt=r,r=p;return r}()),r}function Yt(){var r;return Et++,R.test(t.charAt(mt))?(r=t.charAt(mt),mt++):(r=p,0===Et&&Nt(U)),Et--,r===p&&0===Et&&Nt(I),r}function kt(){var r;return Et++,34===t.charCodeAt(mt)?(r=Y,mt++):(r=p,0===Et&&Nt(k)),Et--,r===p&&0===Et&&Nt(Q),r}function Bt(){var r;return Et++,39===t.charCodeAt(mt)?(r=J,mt++):(r=p,0===Et&&Nt(P)),Et--,r===p&&0===Et&&Nt(B),r}function Jt(){var r;return Et++,t.substr(mt,3)===W?(r=W,mt+=3):(r=p,0===Et&&Nt(q)),Et--,r===p&&0===Et&&Nt(V),r}function Pt(){var r;return Et++,t.substr(mt,3)===K?(r=K,mt+=3):(r=p,0===Et&&Nt(L)),Et--,r===p&&0===Et&&Nt(G),r}function Vt(){var r;return (r=function(){var r;r=function(){var r,t,e,n;if(r=mt,Jt()!==p)if((t=It())===p&&(t=null),t!==p){for(e=[],n=Xt();n!==p;)e.push(n),n=Xt();e!==p&&(n=Jt())!==p?(xt=r,r=X(e)):(mt=r,r=p);}else mt=r,r=p;else mt=r,r=p;return r}(),r===p&&(r=function(){var r,t,e;if(r=mt,kt()!==p){for(t=[],e=Wt();e!==p;)t.push(e),e=Wt();t!==p&&(e=kt())!==p?(xt=r,r=X(t)):(mt=r,r=p);}else mt=r,r=p;return r}())===p&&(r=function(){var r,t,e,n;if(r=mt,Pt()!==p)if((t=It())===p&&(t=null),t!==p){for(e=[],n=$t();n!==p;)e.push(n),n=$t();e!==p&&(n=Pt())!==p?(xt=r,r=X(e)):(mt=r,r=p);}else mt=r,r=p;else mt=r,r=p;return r}())===p&&(r=function(){var r,t,e;if(r=mt,Bt()!==p){for(t=[],e=Lt();e!==p;)t.push(e),e=Lt();t!==p&&(e=Bt())!==p?(xt=r,r=Ar()):(mt=r,r=p);}else mt=r,r=p;return r}());return r}())===p&&(r=function(){var r,e;r=mt,t.substr(mt,4)===Er?(e=Er,mt+=4):(e=p,0===Et&&Nt(Tr));e!==p&&(xt=r,e=Dr());r=e,r===p&&(r=mt,t.substr(mt,5)===jr?(e=jr,mt+=5):(e=p,0===Et&&Nt(Hr)),e!==p&&(xt=r,e=Mr()),r=e);return r}())===p&&(r=function(){var r,e,n,u;r=mt,e=function(){var r,e,n,u,o,a;Et++,r=mt,e=function(){var r,t,e,n,u;r=mt,(t=ue())!==p&&(e=ue())!==p&&(n=ue())!==p&&(u=ue())!==p?r=t=[t,e,n,u]:(mt=r,r=p);return r}(),e!==p?(45===t.charCodeAt(mt)?(n=Jr,mt++):(n=p,0===Et&&Nt(Pr)),n!==p?(u=function(){var r,t,e;r=mt,t=ue(),t!==p&&(e=ue())!==p?r=t=[t,e]:(mt=r,r=p);return r}(),u!==p?(45===t.charCodeAt(mt)?(o=Jr,mt++):(o=p,0===Et&&Nt(Pr)),o!==p?(a=function(){var r,t,e;r=mt,t=ue(),t!==p&&(e=ue())!==p?r=t=[t,e]:(mt=r,r=p);return r}(),a!==p?r=e=[e,n,u,o,a]:(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p);Et--,r===p&&(e=p,0===Et&&Nt(Lr));return r}(),e!==p?(84===t.charCodeAt(mt)?(n=qr,mt++):(n=p,0===Et&&Nt(Gr)),n!==p?(u=function(){var r,e,n;r=mt,e=function(){var r,e,n,u,o,a,i;r=mt,e=oe(),e!==p?(58===t.charCodeAt(mt)?(n=Xr,mt++):(n=p,0===Et&&Nt($r)),n!==p&&(u=ae())!==p?(58===t.charCodeAt(mt)?(o=Xr,mt++):(o=p,0===Et&&Nt($r)),o!==p?(a=function(){var r,t,e;Et++,r=mt,t=ue(),t!==p&&(e=ue())!==p?r=t=[t,e]:(mt=r,r=p);Et--,r===p&&(t=p,0===Et&&Nt(et));return r}(),a!==p?(i=function(){var r,e,n,u;r=mt,46===t.charCodeAt(mt)?(e=_r,mt++):(e=p,0===Et&&Nt(Nr));if(e!==p){if(n=[],(u=ue())!==p)for(;u!==p;)n.push(u),u=ue();else n=p;n!==p?r=e=[e,n]:(mt=r,r=p);}else mt=r,r=p;return r}(),i===p&&(i=null),i!==p?r=e=[e,n,u,o,a,i]:(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p);return r}(),e!==p?(n=function(){var r,e,n,u,o;Et++,90===t.charCodeAt(mt)?(r=ut,mt++):(r=p,0===Et&&Nt(ot));r===p&&(r=mt,(e=ee())!==p&&(n=oe())!==p?(58===t.charCodeAt(mt)?(u=Xr,mt++):(u=p,0===Et&&Nt($r)),u!==p&&(o=ae())!==p?r=e=[e,n,u,o]:(mt=r,r=p)):(mt=r,r=p));Et--,r===p&&(e=p,0===Et&&Nt(nt));return r}(),n!==p?r=e=[e,n]:(mt=r,r=p)):(mt=r,r=p);return r}(),u!==p?(xt=r,r=e=Kr()):(mt=r,r=p)):(mt=r,r=p)):(mt=r,r=p);return r}())===p&&(r=function(){var r,e,n,u;r=mt,te()!==p?(e=mt,n=function(){var r,e,n,u,o,a,i;r=mt,46===t.charCodeAt(mt)?(e=_r,mt++):(e=p,0===Et&&Nt(Nr));if(e!==p)if((n=ue())!==p){for(u=[],o=mt,95===t.charCodeAt(mt)?(a=Zr,mt++):(a=p,0===Et&&Nt(Ir)),a===p&&(a=null),a!==p&&(i=ue())!==p?o=a=[a,i]:(mt=o,o=p);o!==p;)u.push(o),o=mt,95===t.charCodeAt(mt)?(a=Zr,mt++):(a=p,0===Et&&Nt(Ir)),a===p&&(a=null),a!==p&&(i=ue())!==p?o=a=[a,i]:(mt=o,o=p);u!==p?r=e=[e,n,u]:(mt=r,r=p);}else mt=r,r=p;else mt=r,r=p;return r}(),n!==p?((u=re())===p&&(u=null),u!==p?e=n=[n,u]:(mt=e,e=p)):(mt=e,e=p),e===p&&(e=re()),e!==p?(xt=r,r=Or()):(mt=r,r=p)):(mt=r,r=p);return r}())===p&&(r=te())===p&&(r=function(){var r,e,n,u,o,a,i,c,f,s;r=mt,91===t.charCodeAt(mt)?(e=at,mt++):(e=p,0===Et&&Nt(it));if(e!==p){for(n=[],u=ce();u!==p;)n.push(u),u=ce();if(n!==p){if(u=mt,(o=ie())!==p){for(a=[],i=ce();i!==p;)a.push(i),i=ce();if(a!==p){if(i=mt,44===t.charCodeAt(mt)?(c=ct,mt++):(c=p,0===Et&&Nt(ft)),c!==p){for(f=[],s=ce();s!==p;)f.push(s),s=ce();f!==p?i=c=[c,f]:(mt=i,i=p);}else mt=i,i=p;i===p&&(i=null),i!==p?u=o=[o,a,i]:(mt=u,u=p);}else mt=u,u=p;}else mt=u,u=p;u===p&&(u=null),u!==p?(93===t.charCodeAt(mt)?(o=st,mt++):(o=p,0===Et&&Nt(lt)),o!==p?(xt=r,r=e=ht(u)):(mt=r,r=p)):(mt=r,r=p);}else mt=r,r=p;}else mt=r,r=p;return r}())===p&&(r=function(){var r,e,n,u,o,a,i,c,f,s,l;r=mt,123===t.charCodeAt(mt)?(e=vt,mt++):(e=p,0===Et&&Nt(dt));if(e!==p){for(n=[],u=Rt();u!==p;)n.push(u),u=Rt();if(n!==p){if(u=mt,(o=zt())!==p){for(a=[],i=mt,c=[],f=Rt();f!==p;)c.push(f),f=Rt();if(c!==p)if(44===t.charCodeAt(mt)?(f=ct,mt++):(f=p,0===Et&&Nt(ft)),f!==p){for(s=[],l=Rt();l!==p;)s.push(l),l=Rt();s!==p&&(l=zt())!==p?i=c=[c,f,s,l]:(mt=i,i=p);}else mt=i,i=p;else mt=i,i=p;for(;i!==p;){for(a.push(i),i=mt,c=[],f=Rt();f!==p;)c.push(f),f=Rt();if(c!==p)if(44===t.charCodeAt(mt)?(f=ct,mt++):(f=p,0===Et&&Nt(ft)),f!==p){for(s=[],l=Rt();l!==p;)s.push(l),l=Rt();s!==p&&(l=zt())!==p?i=c=[c,f,s,l]:(mt=i,i=p);}else mt=i,i=p;else mt=i,i=p;}if(a!==p){for(i=[],c=Rt();c!==p;)i.push(c),c=Rt();i!==p?u=o=[o,a,i]:(mt=u,u=p);}else mt=u,u=p;}else mt=u,u=p;u===p&&(u=null),u!==p?(125===t.charCodeAt(mt)?(o=gt,mt++):(o=p,0===Et&&Nt(At)),o!==p?(xt=r,r=e=Ct(u)):(mt=r,r=p)):(mt=r,r=p);}else mt=r,r=p;}else mt=r,r=p;return r}()),r}function Wt(){var r;return (r=function(){var r,e,n;Et++,r=mt,e=mt,Et++,n=It(),Et--,n===p?e=void 0:(mt=e,e=p);e!==p?(rr.test(t.charAt(mt))?(n=t.charAt(mt),mt++):(n=p,0===Et&&Nt(tr)),n!==p?(xt=r,r=e=Z()):(mt=r,r=p)):(mt=r,r=p);Et--,r===p&&(e=p,0===Et&&Nt($));return r}())===p&&(r=qt()),r}function qt(){var r,e,n,u;return r=mt,Gt()!==p?(e=function(){var r;Et++,cr.test(t.charAt(mt))?(r=t.charAt(mt),mt++):(r=p,0===Et&&Nt(fr));Et--,r===p&&0===Et&&Nt(ir);return r}(),e===p&&(e=kt())===p&&(e=Gt())===p&&(e=mt,117===t.charCodeAt(mt)?(n=er,mt++):(n=p,0===Et&&Nt(nr)),n!==p?(u=function(){var r,t,e,n,u;Et++,r=mt,t=Kt(),t!==p&&(e=Kt())!==p&&(n=Kt())!==p&&(u=Kt())!==p?r=t=[t,e,n,u]:(mt=r,r=p);Et--,r===p&&(t=p,0===Et&&Nt(pr));return r}(),u!==p?e=n=[n,u]:(mt=e,e=p)):(mt=e,e=p),e===p&&(e=mt,85===t.charCodeAt(mt)?(n=ur,mt++):(n=p,0===Et&&Nt(or)),n!==p?(u=function(){var r,t,e,n,u,o,a,i,c;Et++,r=mt,t=Kt(),t!==p&&(e=Kt())!==p&&(n=Kt())!==p&&(u=Kt())!==p&&(o=Kt())!==p&&(a=Kt())!==p&&(i=Kt())!==p&&(c=Kt())!==p?r=t=[t,e,n,u,o,a,i,c]:(mt=r,r=p);Et--,r===p&&(t=p,0===Et&&Nt(vr));return r}(),u!==p?e=n=[n,u]:(mt=e,e=p)):(mt=e,e=p))),e!==p?(xt=r,r=ar()):(mt=r,r=p)):(mt=r,r=p),r}function Gt(){var r;return Et++,92===t.charCodeAt(mt)?(r=lr,mt++):(r=p,0===Et&&Nt(hr)),Et--,r===p&&0===Et&&Nt(sr),r}function Kt(){var r;return dr.test(t.charAt(mt))?(r=t.charAt(mt),mt++):(r=p,0===Et&&Nt(gr)),r}function Lt(){var r,e,n;return Et++,r=mt,e=mt,Et++,n=It(),Et--,n===p?e=void 0:(mt=e,e=p),e!==p?(Cr.test(t.charAt(mt))?(n=t.charAt(mt),mt++):(n=p,0===Et&&Nt(br)),n!==p?r=e=[e,n]:(mt=r,r=p)):(mt=r,r=p),Et--,r===p&&(e=p,0===Et&&Nt($)),r}function Xt(){var r,e,n;if(r=function(){var r,e,n;r=mt,e=mt,Et++,n=Jt(),Et--,n===p?e=void 0:(mt=e,e=p);e!==p?(n=function(){var r,e,n;Et++,r=mt,e=mt,Et++,n=It(),Et--,n===p?e=void 0:(mt=e,e=p);e!==p?(mr.test(t.charAt(mt))?(n=t.charAt(mt),mt++):(n=p,0===Et&&Nt(xr)),n!==p?r=e=[e,n]:(mt=r,r=p)):(mt=r,r=p);Et--,r===p&&(e=p,0===Et&&Nt($));return r}(),n!==p?(xt=r,r=e=Z()):(mt=r,r=p)):(mt=r,r=p);r===p&&(r=qt());return r}(),r===p){if(r=mt,Gt()!==p)if(It()!==p){for(e=[],(n=Rt())===p&&(n=It());n!==p;)e.push(n),(n=Rt())===p&&(n=It());e!==p?(xt=r,r=yr()):(mt=r,r=p);}else mt=r,r=p;else mt=r,r=p;r===p&&(r=It());}return r}function $t(){var r,e,n;return r=mt,e=mt,Et++,t.substr(mt,3)===K?(n=K,mt+=3):(n=p,0===Et&&Nt(L)),Et--,n===p?e=void 0:(mt=e,e=p),e!==p?(n=function(){var r,e,n;Et++,r=mt,e=mt,Et++,n=It(),Et--,n===p?e=void 0:(mt=e,e=p);e!==p?(Fr.test(t.charAt(mt))?(n=t.charAt(mt),mt++):(n=p,0===Et&&Nt(wr)),n!==p?r=e=[e,n]:(mt=r,r=p)):(mt=r,r=p);Et--,r===p&&(e=p,0===Et&&Nt(Sr));return r}(),n!==p?(xt=r,r=e=Z()):(mt=r,r=p)):(mt=r,r=p),r===p&&(r=It()),r}function re(){var r,e,n,u;return r=mt,101===t.charCodeAt(mt)?(e=Rr,mt++):(e=p,0===Et&&Nt(Ur)),e===p&&(69===t.charCodeAt(mt)?(e=zr,mt++):(e=p,0===Et&&Nt(Qr))),e!==p?((n=ee())===p&&(n=null),n!==p&&(u=ne())!==p?r=e=[e,n,u]:(mt=r,r=p)):(mt=r,r=p),r}function te(){var r,t;return r=mt,(t=ee())===p&&(t=null),t!==p&&ne()!==p?(xt=r,r=t=Yr()):(mt=r,r=p),r}function ee(){var r;return 43===t.charCodeAt(mt)?(r=kr,mt++):(r=p,0===Et&&Nt(Br)),r===p&&(45===t.charCodeAt(mt)?(r=Jr,mt++):(r=p,0===Et&&Nt(Pr))),r}function ne(){var r,e,n,u,o,a;if(r=mt,(e=ue())!==p){for(n=[],u=mt,95===t.charCodeAt(mt)?(o=Zr,mt++):(o=p,0===Et&&Nt(Ir)),o===p&&(o=null),o!==p&&(a=ue())!==p?u=o=[o,a]:(mt=u,u=p);u!==p;)n.push(u),u=mt,95===t.charCodeAt(mt)?(o=Zr,mt++):(o=p,0===Et&&Nt(Ir)),o===p&&(o=null),o!==p&&(a=ue())!==p?u=o=[o,a]:(mt=u,u=p);n!==p?r=e=[e,n]:(mt=r,r=p);}else mt=r,r=p;return r}function ue(){var r;return Vr.test(t.charAt(mt))?(r=t.charAt(mt),mt++):(r=p,0===Et&&Nt(Wr)),r}function oe(){var r,t,e;return Et++,r=mt,(t=ue())!==p&&(e=ue())!==p?r=t=[t,e]:(mt=r,r=p),Et--,r===p&&(t=p,0===Et&&Nt(rt)),r}function ae(){var r,t,e;return Et++,r=mt,(t=ue())!==p&&(e=ue())!==p?r=t=[t,e]:(mt=r,r=p),Et--,r===p&&(t=p,0===Et&&Nt(tt)),r}function ie(){var r,e,n,u,o,a,i;if(r=mt,(e=Vt())!==p){for(n=mt,u=[],o=ce();o!==p;)u.push(o),o=ce();if(u!==p)if(44===t.charCodeAt(mt)?(o=ct,mt++):(o=p,0===Et&&Nt(ft)),o!==p){for(a=[],i=ce();i!==p;)a.push(i),i=ce();a!==p&&(i=ie())!==p?n=u=[u,o,a,i]:(mt=n,n=p);}else mt=n,n=p;else mt=n,n=p;n===p&&(n=null),n!==p?(xt=r,r=e=pt(e,n)):(mt=r,r=p);}else mt=r,r=p;return r}function ce(){var r;return (r=Rt())===p&&(r=It())===p&&(r=Ut()),r}function fe(){var r,e,n,u,o,a,i,c,f,s;if(r=mt,91===t.charCodeAt(mt)?(e=at,mt++):(e=p,0===Et&&Nt(it)),e!==p){for(n=[],u=Rt();u!==p;)n.push(u),u=Rt();if(n!==p)if((u=Qt())!==p){for(o=[],a=mt,i=[],c=Rt();c!==p;)i.push(c),c=Rt();if(i!==p)if(46===t.charCodeAt(mt)?(c=_r,mt++):(c=p,0===Et&&Nt(Nr)),c!==p){for(f=[],s=Rt();s!==p;)f.push(s),s=Rt();f!==p&&(s=Qt())!==p?a=i=[i,c,f,s]:(mt=a,a=p);}else mt=a,a=p;else mt=a,a=p;for(;a!==p;){for(o.push(a),a=mt,i=[],c=Rt();c!==p;)i.push(c),c=Rt();if(i!==p)if(46===t.charCodeAt(mt)?(c=_r,mt++):(c=p,0===Et&&Nt(Nr)),c!==p){for(f=[],s=Rt();s!==p;)f.push(s),s=Rt();f!==p&&(s=Qt())!==p?a=i=[i,c,f,s]:(mt=a,a=p);}else mt=a,a=p;else mt=a,a=p;}if(o!==p){for(a=[],i=Rt();i!==p;)a.push(i),i=Rt();a!==p?(93===t.charCodeAt(mt)?(i=st,mt++):(i=p,0===Et&&Nt(lt)),i!==p?(xt=r,r=e=yt(u,o)):(mt=r,r=p)):(mt=r,r=p);}else mt=r,r=p;}else mt=r,r=p;else mt=r,r=p;}else mt=r,r=p;return r}u=function(r){return "Value for "+r+" should not be redefined in the same table."},o=Number.isFinite||function(r){return "number"==typeof r&&isFinite(r)},a=Array.isArray||function(r){return "[object Array]"===Object.prototype.toString.call(r)},i=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},c="object"==typeof JSON&&JSON?JSON.stringify:function(r){return '"'+String(r).replace(/[\x00-\x1F"\\]/g,(function(r){switch(r){case'"':case"\\":return "\\"+r;case"\t":return "\\t";case"\n":return "\\n";case"\r":return "\\r";case"\b":return "\\b";case"\f":return "\\f";default:var t=r.charCodeAt(0).toString(16);return "\\u"+"0000".substr(t.length)+t}}))+'"'},f=function(r){switch(r){case'"':case"\\":return r;case"t":return "\t";case"n":return "\n";case"r":return "\r";case"b":return "\b";case"f":return "\f";default:Dt(c(r)+" cannot be escaped.");}},s=function(r){if((!o(r)||r<0||r>1114111)&&Dt("U+"+r.toString(16)+" is not a valid Unicode code point."),String.fromCodePoint)return String.fromCodePoint(r);var t="";return r>65535&&(r-=65536,t+=String.fromCharCode(r>>>10&1023|55296),r=56320|1023&r),t+=String.fromCharCode(r)},l=function(r,t){i(r,t)&&Dt(u(c(t)));},h=function(r,t,e){for(var n="",o=0,f=e.length;o<f;o++){var s=e[o];if(n+=(n?".":"")+c(s),i(r,s))if(t)if(a(r[s]))if(Ae[n]||Dt(u(n)),o+1===f){l={};r[s].push(l),r=l;}else n+="."+c(r[s].length-1),r=r[s][r[s].length-1];else de[n]||Dt(u(n)),r=r[s];else a(r[s])?(Ae[n]&&o+1!==f||Dt(u(n)),n+="."+c(r[s].length-1),r=r[s][r[s].length-1]):(de[n]||Dt(u(n)),r=r[s]);else if(t&&o+1===f){var l={};r[s]=[l],r=l,Ae[n]=!0;}else r=r[s]={},de[n]=!0;}return t?Ae[n]||Dt(u(n)):((ge[n]||Ae[n])&&Dt(u(n)),ge[n]=!0),{table:r,path:e}};var se,le,he,pe={},ve={table:pe,path:[]},de={},ge={},Ae={};if((n=d())!==p&&mt===t.length)return n;throw n!==p&&mt<t.length&&Nt({type:"end"}),se=wt,le=Ft<t.length?t.charAt(Ft):null,he=Ft<t.length?_t(Ft,Ft+1):_t(Ft,Ft),new r(r.buildMessage(se,le),se,le,he)}}}();
2
- /*! (c) Jak Wings - MIT */class e extends SyntaxError{constructor(r,{offset:t,line:e,column:n}){super(r),this.offset=t,this.line=e,this.column=n;}}const n=n=>{try{return t(n)}catch(t){throw t instanceof r?(t.line=t.location.start.line,t.column=t.location.start.column,t.offset=t.location.start.offset,new e(t.message,t.location.start)):t}};
3
-
4
- export { e as SyntaxError, n as parse };
5
- //# sourceMappingURL=toml-DTuPg5as.js.map