diff --git a/README.md b/README.md index a03ca4a..baa4be5 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,44 @@ MediaWiki extension for using model-viewer to display and annotate 3D models ## Metadata -Model-viewer configurations and annotations can be added as a json string in the file's description. +Model-viewer configurations and annotations can be added as TOML in the file's description. ### Viewer Configuration -Configuration of the model-viewer instance is contained in the `viewerConfig` object. +Configuration of the model-viewer instance is contained in the `[viewerConfig]` object. This object can contain any number of child objects each of which describes a different possible configuration. Each configuration can have properties matching the any of the attributes of the model-viewer element except for `src`, `class`, `interpolation-delay`, and `interaction-prompt`. +If adding a poster image, the value of the `poster` property must be the name of an image in the Wiki's File namespace (without the namespace header, e.g., `"My poster.jpg"`). ### Annotations -Annotations can be configured using the `annotations` object. +Annotations can be configured using the `[annotations]` object. This object can contain any number of child objects each of which describes a different possible annotation. -The label for each annotation is the name of the child object. Each object has two required properties and two optional properties. +The label for each annotation is the name of the child object (`[annotations."Label here"]`). Each object has two required properties and three optional properties. | Property | Required | Description | Example | |----------|----------|-------------|---------| -| `data-position` | Yes | String containing the X, Y, and Z coordinates of the annotation. | "0.02297m -0.02544m 0.01780m" | -| `data-normal` | Yes | String containing the X, Y, and Z coordinates of the normal vector of the annotation. | "0.78966m -0.53116m 0.30709m" | -| `data-orbit` | No | String containing the orbit vector of the camera to view annotation. | "2.31rad 2.01rad 0.65m" | -| `data-target` | No | String containing the X, Y, and Z coordinates of the camera target to view annotation. | "-0.01029m 0.00071m 0.01138m" | +| **data-position** | Yes | String containing the X, Y, and Z coordinates of the annotation. | "0.02297m -0.02544m 0.01780m" | +| **data-normal** | Yes | String containing the X, Y, and Z coordinates of the normal vector of the annotation. | "0.78966m -0.53116m 0.30709m" | +| **data-orbit** | No | String containing the orbit vector of the camera to view annotation. | "2.31rad 2.01rad 0.65m" | +| **data-target** | No | String containing the X, Y, and Z coordinates of the camera target to view annotation. | "-0.01029m 0.00071m 0.01138m" | +| **field-of-view** | No | String containing the angle of the field of view in degrees. | "35.25deg" | ### Annotation sets Annotations sets are specific subsets of the listed annotations that can be shown on the model. -They are configured using the `annotationSets` object. -This object can contain any number of child objects each of which contains an array of strings matching the names of the annotation to be included. +They are configured using the `[annotationSets]` object. +This object can contain any number properties each of which contains an array of strings matching the names of the annotation to be included. +The property name is used as the annotation set identifier. By default, all annotations are rendered on a model. + +## Linking + +When adding the model file to a page, use the standard `[[File:Model name.glb]]` internal file link. +The link supports three optional properties. + +| Property | Description | Default | +|----------|-------------|---------| +| **view** | Use one of the non-default configurations specified in the `[viewerConfig]` object. | default viewer configuration | +| **set** | Display only the annotations listed in the specified annotation set from the `[annotationSets]` object. | show all annotations | +| **transform** | Reorder the displayed annotations. Can be either *rand* or *alpha*. | annotations are numbered in the order they are listed in the `[annotations]` object | \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..677166a --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "devium/toml": "*" + } +} diff --git a/extension.json b/extension.json index da100b1..c62deee 100644 --- a/extension.json +++ b/extension.json @@ -74,6 +74,7 @@ ], "packageFiles": [ "glmv-prev.js", + "mini-st.js", "glmv-mvconfig.js", "glmv-hs.js" ] diff --git a/includes/GlModelHooks.php b/includes/GlModelHooks.php index 1ab8bbe..82d4c40 100644 --- a/includes/GlModelHooks.php +++ b/includes/GlModelHooks.php @@ -44,7 +44,7 @@ class GlModelHooks { } /** - * Render the config json in a
tag
+ * Render the config toml in a tag
*
* @param $input The text inside the custom tag
* @param array $args Any attributes given in the tag
@@ -170,15 +170,8 @@ class GlModelHooks {
$uploadFormObj->mComment .= <<
- {
- "viewerConfig": {
- "default": {
- "camera-controls": true
- }
- },
- "annotations": {},
- "annotationSets": {}
- }
+ [viewerConfig.default]
+ camera-controls = true
CONF;
}
diff --git a/includes/GlModelTransformOutput.php b/includes/GlModelTransformOutput.php
index d8ca64e..87e57af 100644
--- a/includes/GlModelTransformOutput.php
+++ b/includes/GlModelTransformOutput.php
@@ -1,6 +1,9 @@
file->getDescriptionText();
preg_match('/([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
- $metadata = json_decode($modelDescript[1], true);
+ $metadata = toml_decode($modelDescript[1], true);
if ($this->thumb) {
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;
diff --git a/modules/glmv-hs.js b/modules/glmv-hs.js
index 1fced07..4eee269 100644
--- a/modules/glmv-hs.js
+++ b/modules/glmv-hs.js
@@ -1,3 +1,5 @@
+const TOML = require('./mini-st.js')
+
let deleteHotspot = null
let grabHotspot = null
@@ -34,7 +36,7 @@ clickAddHotspot = function(e) {
hsOutput['data-target'] = `${targetObj.x.toFixed(5)}m ${targetObj.y.toFixed(5)}m ${targetObj.z.toFixed(5)}m`
hsOutput['field-of-view'] = Number.parseFloat(targetModel.getFieldOfView()).toFixed(5) + 'deg'
mvconfig.annotations['Hotspot ' + (Object.keys(mvconfig.annotations).length + 1)] = hsOutput
- let newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(mvconfig, null, 2)}\n$2`)
+ let newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${TOML.stringify(mvconfig, null, 2)}\n$2`)
$('#wpTextbox1').val(newText)
}
readMvconfig()
@@ -147,7 +149,7 @@ releaseAnnotation = function(e) {
"data-target": newTarg,
"field-of-view": newFov
}
- const newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(mvconfig, null, 2)}\n$2`)
+ const newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${TOML.stringify(mvconfig, null, 2)}\n$2`)
$('#wpTextbox1').val(newText)
}
grabHotspot = null
diff --git a/modules/glmv-mvconfig.js b/modules/glmv-mvconfig.js
index 32e598c..adda7b1 100644
--- a/modules/glmv-mvconfig.js
+++ b/modules/glmv-mvconfig.js
@@ -1,3 +1,5 @@
+const TOML = require('./mini-st.js')
+
/**
* Convert text in the preview text editor to js object
*
@@ -6,7 +8,7 @@
extractMvconfig = function() {
const editText = $('#wpTextbox1').val()
const extractConfig = editText.match(/([\S\s]*?)<\/mvconfig>/)
- let mvconfig = (extractConfig.length >= 2) ? JSON.parse(extractConfig[1]) : {viewerConfig: {}, annotations: {}, annotationSets: {}}
+ let mvconfig = (extractConfig.length >= 2) ? TOML.parse(extractConfig[1]) : {viewerConfig: {}, annotations: {}, annotationSets: {}}
if (mvconfig.viewerConfig === undefined) {
mvconfig.viewerConfig = {
default: {
@@ -24,7 +26,7 @@ extractMvconfig = function() {
}
/**
- * Reads the json string in the edit panel
+ * Reads the TOML string in the edit panel
* and updates hotspot elements and menu settings
*
* @return {bool|object} arrays of view and set names on successful read and update false on failure
@@ -90,8 +92,8 @@ readMvconfig = function() {
}
/**
- * Parses the current hotspots into json object
- * and writes the json string to the edit panel
+ * Parses the current hotspots into TOML object
+ * and writes the TOML string to the edit panel
*
* @return {bool} true on successful write to edit panel
*/
@@ -109,7 +111,7 @@ writeMvconfig = function () {
if (Object.keys(annotationsObj).length === 0) return false
const [currentText, mvconfig] = extractMvconfig()
mvconfig.annotations = annotationsObj
- const newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(mvconfig, null, 2)}\n$2`)
+ const newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${TOML.stringify(mvconfig, null, 2)}\n$2`)
$('#wpTextbox1').val(newText)
return true
}
@@ -158,7 +160,7 @@ toggleCameraControl = function(view) {
} else {
delete mvconfig.viewerConfig[currentView]['camera-controls']
}
- const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
+ const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${TOML.stringify(mvconfig, null, 2)}\n`)
$('#wpTextbox1').val(textUpdate)
return newControl
}
@@ -172,7 +174,7 @@ addAnnotationSet = function(newSet) {
const mView = $('model-viewer')[0]
let [currentText, mvconfig] = extractMvconfig()
mvconfig.annotationSets[newSet] = []
- const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
+ const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${TOML.stringify(mvconfig, null, 2)}\n`)
$('#wpTextbox1').val(textUpdate)
selectAnnotationSet(newSet)
}
@@ -186,7 +188,7 @@ addViewConfig = function(newView) {
const mView = $('model-viewer')[0]
let [currentText, mvconfig] = extractMvconfig()
mvconfig.viewerConfig[newView] = { "camera-controls": true }
- const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
+ const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${TOML.stringify(mvconfig, null, 2)}\n`)
$('#wpTextbox1').val(textUpdate)
selectViewConfig(newView)
}
@@ -255,7 +257,7 @@ writeCameraOrbit = function() {
mvconfig.viewerConfig.default['camera-orbit'] = newOrbit
mvconfig.viewerConfig.default['camera-target'] = newTarget
mvconfig.viewerConfig.default['field-of-view'] = newField
- const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
+ const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${TOML.stringify(mvconfig, null, 2)}\n`)
$('#wpTextbox1').val(textUpdate)
}
@@ -277,6 +279,6 @@ writeCameraLimit = function(axis, limit) {
oldOrbitVals[valueIndex] = newOrbitVals[valueIndex]
mvconfig.viewerConfig.default[`${limit}-camera-orbit`] = oldOrbitVals.join(' ')
mView.setAttribute(`${limit}-camera-orbit`, oldOrbitVals.join(' '))
- const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
+ const textUpdate = currentText.replace(/(?<=)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${TOML.stringify(mvconfig, null, 2)}\n`)
$('#wpTextbox1').val(textUpdate)
}
\ No newline at end of file
diff --git a/modules/mini-st.js b/modules/mini-st.js
new file mode 100644
index 0000000..e9c6617
--- /dev/null
+++ b/modules/mini-st.js
@@ -0,0 +1,1150 @@
+/******/ const TOML = (() => { // webpackBootstrap
+/******/ "use strict";
+/******/ /* webpack/runtime/compat */
+/******/
+/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
+/******/
+/************************************************************************/
+var __webpack_exports__ = {};
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/error.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+function getLineColFromPtr(string, ptr) {
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
+ return [lines.length, lines.pop().length + 1];
+}
+function makeCodeBlock(string, line, column) {
+ let lines = string.split(/\r\n|\n|\r/g);
+ let codeblock = '';
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
+ for (let i = line - 1; i <= line + 1; i++) {
+ let l = lines[i - 1];
+ if (!l)
+ continue;
+ codeblock += i.toString().padEnd(numberLen, ' ');
+ codeblock += ': ';
+ codeblock += l;
+ codeblock += '\n';
+ if (i === line) {
+ codeblock += ' '.repeat(numberLen + column + 2);
+ codeblock += '^\n';
+ }
+ }
+ return codeblock;
+}
+class TomlError extends Error {
+ line;
+ column;
+ codeblock;
+ constructor(message, options) {
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
+ const codeblock = makeCodeBlock(options.toml, line, column);
+ super(`Invalid TOML document: ${message}\n\n${codeblock}`, options);
+ this.line = line;
+ this.column = column;
+ this.codeblock = codeblock;
+ }
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/util.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function indexOfNewline(str, start = 0, end = str.length) {
+ let idx = str.indexOf('\n', start);
+ if (str[idx - 1] === '\r')
+ idx--;
+ return idx <= end ? idx : -1;
+}
+function skipComment(str, ptr) {
+ for (let i = ptr; i < str.length; i++) {
+ let c = str[i];
+ if (c === '\n')
+ return i;
+ if (c === '\r' && str[i + 1] === '\n')
+ return i + 1;
+ if ((c < '\x20' && c !== '\t') || c === '\x7f') {
+ throw new TomlError('control characters are not allowed in comments', {
+ toml: str,
+ ptr: ptr,
+ });
+ }
+ }
+ return str.length;
+}
+function skipVoid(str, ptr, banNewLines, banComments) {
+ let c;
+ while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n')))
+ ptr++;
+ return banComments || c !== '#'
+ ? ptr
+ : skipVoid(str, skipComment(str, ptr), banNewLines);
+}
+function skipUntil(str, ptr, sep, end, banNewLines = false) {
+ if (!end) {
+ ptr = indexOfNewline(str, ptr);
+ return ptr < 0 ? str.length : ptr;
+ }
+ for (let i = ptr; i < str.length; i++) {
+ let c = str[i];
+ if (c === '#') {
+ i = indexOfNewline(str, i);
+ }
+ else if (c === sep) {
+ return i + 1;
+ }
+ else if (c === end || (banNewLines && (c === '\n' || (c === '\r' && str[i + 1] === '\n')))) {
+ return i;
+ }
+ }
+ throw new TomlError('cannot find end of structure', {
+ toml: str,
+ ptr: ptr
+ });
+}
+function getStringEnd(str, seek) {
+ let first = str[seek];
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2]
+ ? str.slice(seek, seek + 3)
+ : first;
+ seek += target.length - 1;
+ do
+ seek = str.indexOf(target, ++seek);
+ while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && (str[seek - 2] !== '\\' || str[seek - 3] === '\\'));
+ if (seek > -1) {
+ seek += target.length;
+ if (target.length > 1) {
+ if (str[seek] === first)
+ seek++;
+ if (str[seek] === first)
+ seek++;
+ }
+ }
+ return seek;
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/date.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
+class TomlDate extends Date {
+ #hasDate = false;
+ #hasTime = false;
+ #offset = null;
+ constructor(date) {
+ let hasDate = true;
+ let hasTime = true;
+ let offset = 'Z';
+ if (typeof date === 'string') {
+ let match = date.match(DATE_TIME_RE);
+ if (match) {
+ if (!match[1]) {
+ hasDate = false;
+ date = `0000-01-01T${date}`;
+ }
+ hasTime = !!match[2];
+ // Make sure to use T instead of a space. Breaks in case of extreme values otherwise.
+ hasTime && date[10] === ' ' && (date = date.replace(' ', 'T'));
+ // Do not allow rollover hours.
+ if (match[2] && +match[2] > 23) {
+ date = '';
+ }
+ else {
+ offset = match[3] || null;
+ date = date.toUpperCase();
+ if (!offset && hasTime)
+ date += 'Z';
+ }
+ }
+ else {
+ date = '';
+ }
+ }
+ super(date);
+ if (!isNaN(this.getTime())) {
+ this.#hasDate = hasDate;
+ this.#hasTime = hasTime;
+ this.#offset = offset;
+ }
+ }
+ isDateTime() {
+ return this.#hasDate && this.#hasTime;
+ }
+ isLocal() {
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
+ }
+ isDate() {
+ return this.#hasDate && !this.#hasTime;
+ }
+ isTime() {
+ return this.#hasTime && !this.#hasDate;
+ }
+ isValid() {
+ return this.#hasDate || this.#hasTime;
+ }
+ toISOString() {
+ let iso = super.toISOString();
+ // Local Date
+ if (this.isDate())
+ return iso.slice(0, 10);
+ // Local Time
+ if (this.isTime())
+ return iso.slice(11, 23);
+ // Local DateTime
+ if (this.#offset === null)
+ return iso.slice(0, -1);
+ // Offset DateTime
+ if (this.#offset === 'Z')
+ return iso;
+ // This part is quite annoying: JS strips the original timezone from the ISO string representation
+ // Instead of using a "modified" date and "Z", we restore the representation "as authored"
+ let offset = (+(this.#offset.slice(1, 3)) * 60) + +(this.#offset.slice(4, 6));
+ offset = this.#offset[0] === '-' ? offset : -offset;
+ let offsetDate = new Date(this.getTime() - (offset * 60e3));
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
+ }
+ static wrapAsOffsetDateTime(jsDate, offset = 'Z') {
+ let date = new TomlDate(jsDate);
+ date.#offset = offset;
+ return date;
+ }
+ static wrapAsLocalDateTime(jsDate) {
+ let date = new TomlDate(jsDate);
+ date.#offset = null;
+ return date;
+ }
+ static wrapAsLocalDate(jsDate) {
+ let date = new TomlDate(jsDate);
+ date.#hasTime = false;
+ date.#offset = null;
+ return date;
+ }
+ static wrapAsLocalTime(jsDate) {
+ let date = new TomlDate(jsDate);
+ date.#hasDate = false;
+ date.#offset = null;
+ return date;
+ }
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/primitive.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
+let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
+let LEADING_ZERO = /^[+-]?0[0-9_]/;
+let ESCAPE_REGEX = /^[0-9a-f]{4,8}$/i;
+let ESC_MAP = {
+ b: '\b',
+ t: '\t',
+ n: '\n',
+ f: '\f',
+ r: '\r',
+ '"': '"',
+ '\\': '\\',
+};
+function parseString(str, ptr = 0, endPtr = str.length) {
+ let isLiteral = str[ptr] === "'";
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
+ if (isMultiline) {
+ endPtr -= 2;
+ if (str[ptr += 2] === '\r')
+ ptr++;
+ if (str[ptr] === '\n')
+ ptr++;
+ }
+ let tmp = 0;
+ let isEscape;
+ let parsed = '';
+ let sliceStart = ptr;
+ while (ptr < endPtr - 1) {
+ let c = str[ptr++];
+ if (c === '\n' || (c === '\r' && str[ptr] === '\n')) {
+ if (!isMultiline) {
+ throw new TomlError('newlines are not allowed in strings', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ }
+ else if ((c < '\x20' && c !== '\t') || c === '\x7f') {
+ throw new TomlError('control characters are not allowed in strings', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ if (isEscape) {
+ isEscape = false;
+ if (c === 'u' || c === 'U') {
+ // Unicode escape
+ let code = str.slice(ptr, (ptr += (c === 'u' ? 4 : 8)));
+ if (!ESCAPE_REGEX.test(code)) {
+ throw new TomlError('invalid unicode escape', {
+ toml: str,
+ ptr: tmp
+ });
+ }
+ try {
+ parsed += String.fromCodePoint(parseInt(code, 16));
+ }
+ catch {
+ throw new TomlError('invalid unicode escape', {
+ toml: str,
+ ptr: tmp
+ });
+ }
+ }
+ else if (isMultiline && (c === '\n' || c === ' ' || c === '\t' || c === '\r')) {
+ // Multiline escape
+ ptr = skipVoid(str, ptr - 1, true);
+ if (str[ptr] !== '\n' && str[ptr] !== '\r') {
+ throw new TomlError('invalid escape: only line-ending whitespace may be escaped', {
+ toml: str,
+ ptr: tmp
+ });
+ }
+ ptr = skipVoid(str, ptr);
+ }
+ else if (c in ESC_MAP) {
+ // Classic escape
+ parsed += ESC_MAP[c];
+ }
+ else {
+ throw new TomlError('unrecognized escape sequence', {
+ toml: str,
+ ptr: tmp
+ });
+ }
+ sliceStart = ptr;
+ }
+ else if (!isLiteral && c === '\\') {
+ tmp = ptr - 1;
+ isEscape = true;
+ parsed += str.slice(sliceStart, tmp);
+ }
+ }
+ return parsed + str.slice(sliceStart, endPtr - 1);
+}
+function parseValue(value, toml, ptr) {
+ // Constant values
+ if (value === 'true')
+ return true;
+ if (value === 'false')
+ return false;
+ if (value === '-inf')
+ return -Infinity;
+ if (value === 'inf' || value === '+inf')
+ return Infinity;
+ if (value === 'nan' || value === '+nan' || value === '-nan')
+ return NaN;
+ if (value === '-0')
+ return 0; // Avoid FP representation of -0
+ // Numbers
+ let isInt;
+ if ((isInt = INT_REGEX.test(value)) || FLOAT_REGEX.test(value)) {
+ if (LEADING_ZERO.test(value)) {
+ throw new TomlError('leading zeroes are not allowed', {
+ toml: toml,
+ ptr: ptr
+ });
+ }
+ let numeric = +(value.replace(/_/g, ''));
+ if (isNaN(numeric)) {
+ throw new TomlError('invalid number', {
+ toml: toml,
+ ptr: ptr
+ });
+ }
+ if (isInt && !Number.isSafeInteger(numeric)) {
+ throw new TomlError('integer value cannot be represented losslessly', {
+ toml: toml,
+ ptr: ptr
+ });
+ }
+ return numeric;
+ }
+ let date = new TomlDate(value);
+ if (!date.isValid()) {
+ throw new TomlError('invalid value', {
+ toml: toml,
+ ptr: ptr
+ });
+ }
+ return date;
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/extract.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+
+function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
+ let value = str.slice(startPtr, endPtr);
+ let commentIdx = value.indexOf('#');
+ if (commentIdx > -1) {
+ // The call to skipComment allows to "validate" the comment
+ // (absence of control characters)
+ skipComment(str, commentIdx);
+ value = value.slice(0, commentIdx);
+ }
+ let trimmed = value.trimEnd();
+ if (!allowNewLines) {
+ let newlineIdx = value.indexOf('\n', trimmed.length);
+ if (newlineIdx > -1) {
+ throw new TomlError('newlines are not allowed in inline tables', {
+ toml: str,
+ ptr: startPtr + newlineIdx
+ });
+ }
+ }
+ return [trimmed, commentIdx];
+}
+function extractValue(str, ptr, end, depth = -1) {
+ if (depth === 0) {
+ throw new TomlError('document contains excessively nested structures. aborting.', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ let c = str[ptr];
+ if (c === '[' || c === '{') {
+ let [value, endPtr] = c === '['
+ ? parseArray(str, ptr, depth)
+ : parseInlineTable(str, ptr, depth);
+ let newPtr = end ? skipUntil(str, endPtr, ',', end) : endPtr;
+ if (endPtr - newPtr && end === '}') {
+ let nextNewLine = indexOfNewline(str, endPtr, newPtr);
+ if (nextNewLine > -1) {
+ throw new TomlError('newlines are not allowed in inline tables', {
+ toml: str,
+ ptr: nextNewLine
+ });
+ }
+ }
+ return [value, newPtr];
+ }
+ let endPtr;
+ if (c === '"' || c === "'") {
+ endPtr = getStringEnd(str, ptr);
+ let parsed = parseString(str, ptr, endPtr);
+ if (end) {
+ endPtr = skipVoid(str, endPtr, end !== ']');
+ if (str[endPtr] && str[endPtr] !== ',' && str[endPtr] !== end && str[endPtr] !== '\n' && str[endPtr] !== '\r') {
+ throw new TomlError('unexpected character encountered', {
+ toml: str,
+ ptr: endPtr,
+ });
+ }
+ endPtr += (+(str[endPtr] === ','));
+ }
+ return [parsed, endPtr];
+ }
+ endPtr = skipUntil(str, ptr, ',', end);
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (+(str[endPtr - 1] === ',')), end === ']');
+ if (!slice[0]) {
+ throw new TomlError('incomplete key-value declaration: no value specified', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ if (end && slice[1] > -1) {
+ endPtr = skipVoid(str, ptr + slice[1]);
+ endPtr += +(str[endPtr] === ',');
+ }
+ return [
+ parseValue(slice[0], str, ptr),
+ endPtr,
+ ];
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/struct.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+
+let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
+function parseKey(str, ptr, end = '=') {
+ let dot = ptr - 1;
+ let parsed = [];
+ let endPtr = str.indexOf(end, ptr);
+ if (endPtr < 0) {
+ throw new TomlError('incomplete key-value: cannot find end of key', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ do {
+ let c = str[ptr = ++dot];
+ // If it's whitespace, ignore
+ if (c !== ' ' && c !== '\t') {
+ // If it's a string
+ if (c === '"' || c === "'") {
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
+ throw new TomlError('multiline strings are not allowed in keys', {
+ toml: str,
+ ptr: ptr,
+ });
+ }
+ let eos = getStringEnd(str, ptr);
+ if (eos < 0) {
+ throw new TomlError('unfinished string encountered', {
+ toml: str,
+ ptr: ptr,
+ });
+ }
+ dot = str.indexOf('.', eos);
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
+ let newLine = indexOfNewline(strEnd);
+ if (newLine > -1) {
+ throw new TomlError('newlines are not allowed in keys', {
+ toml: str,
+ ptr: ptr + dot + newLine,
+ });
+ }
+ if (strEnd.trimStart()) {
+ throw new TomlError('found extra tokens after the string part', {
+ toml: str,
+ ptr: eos,
+ });
+ }
+ if (endPtr < eos) {
+ endPtr = str.indexOf(end, eos);
+ if (endPtr < 0) {
+ throw new TomlError('incomplete key-value: cannot find end of key', {
+ toml: str,
+ ptr: ptr,
+ });
+ }
+ }
+ parsed.push(parseString(str, ptr, eos));
+ }
+ else {
+ // Normal raw key part consumption and validation
+ dot = str.indexOf('.', ptr);
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
+ if (!KEY_PART_RE.test(part)) {
+ throw new TomlError('only letter, numbers, dashes and underscores are allowed in keys', {
+ toml: str,
+ ptr: ptr,
+ });
+ }
+ parsed.push(part.trimEnd());
+ }
+ }
+ // Until there's no more dot
+ } while (dot + 1 && dot < endPtr);
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
+}
+function parseInlineTable(str, ptr, depth = -1) {
+ let res = {};
+ let seen = new Set();
+ let c;
+ let comma = 0;
+ ptr++;
+ while ((c = str[ptr++]) !== '}' && c) {
+ if (c === '\n') {
+ throw new TomlError('newlines are not allowed in inline tables', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ else if (c === '#') {
+ throw new TomlError('inline tables cannot contain comments', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ else if (c === ',') {
+ throw new TomlError('expected key-value, found comma', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ else if (c !== ' ' && c !== '\t') {
+ let k;
+ let t = res;
+ let hasOwn = false;
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
+ for (let i = 0; i < key.length; i++) {
+ if (i)
+ t = hasOwn ? t[k] : (t[k] = {});
+ k = key[i];
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== 'object' || seen.has(t[k]))) {
+ throw new TomlError('trying to redefine an already defined value', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ if (!hasOwn && k === '__proto__') {
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
+ }
+ }
+ if (hasOwn) {
+ throw new TomlError('trying to redefine an already defined value', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}', depth - 1);
+ seen.add(value);
+ t[k] = value;
+ ptr = valueEndPtr;
+ comma = str[ptr - 1] === ',' ? ptr - 1 : 0;
+ }
+ }
+ if (comma) {
+ throw new TomlError('trailing commas are not allowed in inline tables', {
+ toml: str,
+ ptr: comma
+ });
+ }
+ if (!c) {
+ throw new TomlError('unfinished table encountered', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ return [res, ptr];
+}
+function parseArray(str, ptr, depth = -1) {
+ let res = [];
+ let c;
+ ptr++;
+ while ((c = str[ptr++]) !== ']' && c) {
+ if (c === ',') {
+ throw new TomlError('expected value, found comma', {
+ toml: str,
+ ptr: ptr - 1
+ });
+ }
+ else if (c === '#')
+ ptr = skipComment(str, ptr);
+ else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r') {
+ let e = extractValue(str, ptr - 1, ']', depth - 1);
+ res.push(e[0]);
+ ptr = e[1];
+ }
+ }
+ if (!c) {
+ throw new TomlError('unfinished array encountered', {
+ toml: str,
+ ptr: ptr
+ });
+ }
+ return [res, ptr];
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/parse.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+
+function peekTable(key, table, meta, type) {
+ let t = table;
+ let m = meta;
+ let k;
+ let hasOwn = false;
+ let state;
+ for (let i = 0; i < key.length; i++) {
+ if (i) {
+ t = hasOwn ? t[k] : (t[k] = {});
+ m = (state = m[k]).c;
+ if (type === 0 /* Type.DOTTED */ && (state.t === 1 /* Type.EXPLICIT */ || state.t === 2 /* Type.ARRAY */)) {
+ return null;
+ }
+ if (state.t === 2 /* Type.ARRAY */) {
+ let l = t.length - 1;
+ t = t[l];
+ m = m[l].c;
+ }
+ }
+ k = key[i];
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 /* Type.DOTTED */ && m[k]?.d) {
+ return null;
+ }
+ if (!hasOwn) {
+ if (k === '__proto__') {
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
+ }
+ m[k] = {
+ t: i < key.length - 1 && type === 2 /* Type.ARRAY */
+ ? 3 /* Type.ARRAY_DOTTED */
+ : type,
+ d: false,
+ i: 0,
+ c: {},
+ };
+ }
+ }
+ state = m[k];
+ if (state.t !== type && !(type === 1 /* Type.EXPLICIT */ && state.t === 3 /* Type.ARRAY_DOTTED */)) {
+ // Bad key type!
+ return null;
+ }
+ if (type === 2 /* Type.ARRAY */) {
+ if (!state.d) {
+ state.d = true;
+ t[k] = [];
+ }
+ t[k].push(t = {});
+ state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: {} });
+ }
+ if (state.d) {
+ // Redefining a table!
+ return null;
+ }
+ state.d = true;
+ if (type === 1 /* Type.EXPLICIT */) {
+ t = hasOwn ? t[k] : (t[k] = {});
+ }
+ else if (type === 0 /* Type.DOTTED */ && hasOwn) {
+ return null;
+ }
+ return [k, t, state.c];
+}
+function parse(toml, opts) {
+ let maxDepth = opts?.maxDepth ?? 1000;
+ let res = {};
+ let meta = {};
+ let tbl = res;
+ let m = meta;
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
+ if (toml[ptr] === '[') {
+ let isTableArray = toml[++ptr] === '[';
+ let k = parseKey(toml, ptr += +isTableArray, ']');
+ if (isTableArray) {
+ if (toml[k[1] - 1] !== ']') {
+ throw new TomlError('expected end of table declaration', {
+ toml: toml,
+ ptr: k[1] - 1,
+ });
+ }
+ k[1]++;
+ }
+ let p = peekTable(k[0], res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
+ if (!p) {
+ throw new TomlError('trying to redefine an already defined table or value', {
+ toml: toml,
+ ptr: ptr,
+ });
+ }
+ m = p[2];
+ tbl = p[1];
+ ptr = k[1];
+ }
+ else {
+ let k = parseKey(toml, ptr);
+ let p = peekTable(k[0], tbl, m, 0 /* Type.DOTTED */);
+ if (!p) {
+ throw new TomlError('trying to redefine an already defined table or value', {
+ toml: toml,
+ ptr: ptr,
+ });
+ }
+ let v = extractValue(toml, k[1], void 0, maxDepth);
+ p[1][p[0]] = v[0];
+ ptr = v[1];
+ }
+ ptr = skipVoid(toml, ptr, true);
+ if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') {
+ throw new TomlError('each key-value declaration must be followed by an end-of-line', {
+ toml: toml,
+ ptr: ptr
+ });
+ }
+ ptr = skipVoid(toml, ptr);
+ }
+ return res;
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/stringify.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+let BARE_KEY = /^[a-z0-9-_]+$/i;
+function extendedTypeOf(obj) {
+ let type = typeof obj;
+ if (type === 'object') {
+ if (Array.isArray(obj))
+ return 'array';
+ if (obj instanceof Date)
+ return 'date';
+ }
+ return type;
+}
+function isArrayOfTables(obj) {
+ for (let i = 0; i < obj.length; i++) {
+ if (extendedTypeOf(obj[i]) !== 'object')
+ return false;
+ }
+ return obj.length != 0;
+}
+function formatString(s) {
+ return JSON.stringify(s).replace(/\x7f/g, '\\u007f');
+}
+function stringifyValue(val, type, depth) {
+ if (depth === 0) {
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
+ }
+ if (type === 'number') {
+ if (isNaN(val))
+ return 'nan';
+ if (val === Infinity)
+ return 'inf';
+ if (val === -Infinity)
+ return '-inf';
+ return val.toString();
+ }
+ if (type === 'bigint' || type === 'boolean') {
+ return val.toString();
+ }
+ if (type === 'string') {
+ return formatString(val);
+ }
+ if (type === 'date') {
+ if (isNaN(val.getTime())) {
+ throw new TypeError('cannot serialize invalid date');
+ }
+ return val.toISOString();
+ }
+ if (type === 'object') {
+ return stringifyInlineTable(val, depth);
+ }
+ if (type === 'array') {
+ return stringifyArray(val, depth);
+ }
+}
+function stringifyInlineTable(obj, depth) {
+ let keys = Object.keys(obj);
+ if (keys.length === 0)
+ return '{}';
+ let res = '{ ';
+ for (let i = 0; i < keys.length; i++) {
+ let k = keys[i];
+ if (i)
+ res += ', ';
+ res += BARE_KEY.test(k) ? k : formatString(k);
+ res += ' = ';
+ res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1);
+ }
+ return res + ' }';
+}
+function stringifyArray(array, depth) {
+ if (array.length === 0)
+ return '[]';
+ let res = '[ ';
+ for (let i = 0; i < array.length; i++) {
+ if (i)
+ res += ', ';
+ if (array[i] === null || array[i] === void 0) {
+ throw new TypeError('arrays cannot contain null or undefined values');
+ }
+ res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1);
+ }
+ return res + ' ]';
+}
+function stringifyArrayTable(array, key, depth) {
+ if (depth === 0) {
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
+ }
+ let res = '';
+ for (let i = 0; i < array.length; i++) {
+ res += `[[${key}]]\n`;
+ res += stringifyTable(array[i], key, depth);
+ res += '\n\n';
+ }
+ return res;
+}
+function stringifyTable(obj, prefix, depth) {
+ if (depth === 0) {
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
+ }
+ let preamble = '';
+ let tables = '';
+ let keys = Object.keys(obj);
+ for (let i = 0; i < keys.length; i++) {
+ let k = keys[i];
+ if (obj[k] !== null && obj[k] !== void 0) {
+ let type = extendedTypeOf(obj[k]);
+ if (type === 'symbol' || type === 'function') {
+ throw new TypeError(`cannot serialize values of type '${type}'`);
+ }
+ let key = BARE_KEY.test(k) ? k : formatString(k);
+ if (type === 'array' && isArrayOfTables(obj[k])) {
+ tables += stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1);
+ }
+ else if (type === 'object') {
+ let tblKey = prefix ? `${prefix}.${key}` : key;
+ tables += `[${tblKey}]\n`;
+ tables += stringifyTable(obj[k], tblKey, depth - 1);
+ tables += '\n\n';
+ }
+ else {
+ preamble += key;
+ preamble += ' = ';
+ preamble += stringifyValue(obj[k], type, depth);
+ preamble += '\n';
+ }
+ }
+ }
+ return `${preamble}\n${tables}`.trim();
+}
+function stringify(obj, opts) {
+ if (extendedTypeOf(obj) !== 'object') {
+ throw new TypeError('stringify can only be called with an object');
+ }
+ let maxDepth = opts?.maxDepth ?? 1000;
+ return stringifyTable(obj, '', maxDepth);
+}
+
+;// CONCATENATED MODULE: ./node_modules/smol-toml/dist/index.js
+/*!
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+
+/* harmony default export */ const dist = ({ parse: parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError });
+
+return { parse: parse, stringify: stringify, TomlDate: TomlDate, TomlError: TomlError }
+
+;// CONCATENATED MODULE: ./index.js
+
+/******/ })();
+
+module.exports = TOML;