@el-j/magic-helix-core 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-B88j4AyE.js +13 -0
- package/dist/index-B88j4AyE.js.map +1 -0
- package/dist/index-CY-pQbuu.cjs +2 -0
- package/dist/index-CY-pQbuu.cjs.map +1 -0
- package/dist/index.cjs +75 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2234 -51
- package/dist/index.mjs.map +1 -1
- package/dist/pattern-combiner.d.ts +1 -1
- package/dist/plugin-loader.d.ts +7 -1
- package/package.json +4 -4
- package/dist/BasePlugin-6wv0hYJ9.js +0 -98
- package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
- package/dist/BasePlugin-odQJAKA-.cjs +0 -2
- package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
- package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
- package/dist/builtin-plugins/csharp/index.d.ts +0 -20
- package/dist/builtin-plugins/go/index.d.ts +0 -23
- package/dist/builtin-plugins/index.d.ts +0 -15
- package/dist/builtin-plugins/java/index.d.ts +0 -22
- package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
- package/dist/builtin-plugins/php/index.d.ts +0 -20
- package/dist/builtin-plugins/python/index.d.ts +0 -27
- package/dist/builtin-plugins/ruby/index.d.ts +0 -20
- package/dist/builtin-plugins/rust/index.d.ts +0 -53
- package/dist/builtin-plugins/swift/index.d.ts +0 -22
- package/dist/default_templates/angular/angular-core.md +0 -19
- package/dist/default_templates/architecture/codeowners.md +0 -123
- package/dist/default_templates/architecture/monorepo.md +0 -146
- package/dist/default_templates/architecture/nx.md +0 -122
- package/dist/default_templates/architecture/turborepo.md +0 -114
- package/dist/default_templates/ci/github-actions.md +0 -268
- package/dist/default_templates/ci/gitlab-ci.md +0 -330
- package/dist/default_templates/containers/docker-multistage.md +0 -120
- package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
- package/dist/default_templates/devops/docker-compose.md +0 -111
- package/dist/default_templates/devops/docker-dockerfile.md +0 -94
- package/dist/default_templates/devops/github-actions.md +0 -160
- package/dist/default_templates/devops/gitlab-ci.md +0 -210
- package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
- package/dist/default_templates/dotnet/framework-blazor.md +0 -271
- package/dist/default_templates/dotnet/lang-csharp.md +0 -162
- package/dist/default_templates/generic/lang-typescript.md +0 -11
- package/dist/default_templates/generic/state-redux.md +0 -21
- package/dist/default_templates/generic/state-rxjs.md +0 -6
- package/dist/default_templates/generic/style-mui.md +0 -23
- package/dist/default_templates/generic/style-tailwind.md +0 -6
- package/dist/default_templates/generic/test-cypress.md +0 -21
- package/dist/default_templates/generic/test-jest.md +0 -20
- package/dist/default_templates/generic/test-playwright.md +0 -21
- package/dist/default_templates/generic/test-vitest.md +0 -6
- package/dist/default_templates/go/lang-go.md +0 -571
- package/dist/default_templates/java/build-gradle.md +0 -102
- package/dist/default_templates/java/build-maven.md +0 -86
- package/dist/default_templates/java/framework-spring-boot.md +0 -179
- package/dist/default_templates/java/lang-java.md +0 -78
- package/dist/default_templates/java/lang-kotlin.md +0 -88
- package/dist/default_templates/meta/magic-helix-meta.md +0 -213
- package/dist/default_templates/meta/meta-debug.md +0 -459
- package/dist/default_templates/meta/meta-implement.md +0 -450
- package/dist/default_templates/meta/meta-roadmap.md +0 -265
- package/dist/default_templates/nestjs/nestjs-core.md +0 -7
- package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
- package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
- package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
- package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
- package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
- package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
- package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
- package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
- package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
- package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
- package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
- package/dist/default_templates/patterns/environment/ide-features.md +0 -17
- package/dist/default_templates/patterns/environment/os-commands.md +0 -17
- package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
- package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
- package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
- package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
- package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
- package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
- package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
- package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
- package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
- package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
- package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
- package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
- package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
- package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
- package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
- package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
- package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
- package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
- package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
- package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
- package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
- package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
- package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
- package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
- package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
- package/dist/default_templates/php/framework-laravel.md +0 -112
- package/dist/default_templates/php/lang-php.md +0 -94
- package/dist/default_templates/python/lang-python.md +0 -508
- package/dist/default_templates/react/react-core.md +0 -677
- package/dist/default_templates/react/react-zustand.md +0 -7
- package/dist/default_templates/ruby/framework-rails.md +0 -309
- package/dist/default_templates/ruby/framework-sinatra.md +0 -227
- package/dist/default_templates/ruby/lang-ruby.md +0 -216
- package/dist/default_templates/rust/lang-rust.md +0 -89
- package/dist/default_templates/swift/framework-vapor.md +0 -352
- package/dist/default_templates/swift/lang-swift.md +0 -291
- package/dist/default_templates/vue/style-primevue.md +0 -6
- package/dist/default_templates/vue/style-quasar.md +0 -22
- package/dist/default_templates/vue/vue-core.md +0 -28
- package/dist/default_templates/vue/vue-pinia.md +0 -5
- package/dist/index-AkVwRl-r.js +0 -92
- package/dist/index-AkVwRl-r.js.map +0 -1
- package/dist/index-B6BeG1yT.cjs +0 -68
- package/dist/index-B6BeG1yT.cjs.map +0 -1
- package/dist/index-B8pyjKdF.js +0 -94
- package/dist/index-B8pyjKdF.js.map +0 -1
- package/dist/index-B_6W_RnJ.cjs +0 -76
- package/dist/index-B_6W_RnJ.cjs.map +0 -1
- package/dist/index-Bg8DD8ku.js +0 -216
- package/dist/index-Bg8DD8ku.js.map +0 -1
- package/dist/index-BkJhe5Af.js +0 -1748
- package/dist/index-BkJhe5Af.js.map +0 -1
- package/dist/index-Bv4Q1Pr7.cjs +0 -33
- package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
- package/dist/index-CN8J45Nc.cjs +0 -24
- package/dist/index-CN8J45Nc.cjs.map +0 -1
- package/dist/index-CPbv2Od1.js +0 -62
- package/dist/index-CPbv2Od1.js.map +0 -1
- package/dist/index-Cf-MC6Al.js +0 -63
- package/dist/index-Cf-MC6Al.js.map +0 -1
- package/dist/index-DDPXXXDy.cjs +0 -19
- package/dist/index-DDPXXXDy.cjs.map +0 -1
- package/dist/index-DO30AzDe.cjs +0 -19
- package/dist/index-DO30AzDe.cjs.map +0 -1
- package/dist/index-Dm37u5ut.js +0 -2128
- package/dist/index-Dm37u5ut.js.map +0 -1
- package/dist/index-DqHvgoXJ.cjs +0 -19
- package/dist/index-DqHvgoXJ.cjs.map +0 -1
- package/dist/index-J1qAfsnO.cjs +0 -2
- package/dist/index-J1qAfsnO.cjs.map +0 -1
- package/dist/index-Jz0HYZ7B.js +0 -13
- package/dist/index-Jz0HYZ7B.js.map +0 -1
- package/dist/index-K39pdw94.cjs +0 -31
- package/dist/index-K39pdw94.cjs.map +0 -1
- package/dist/index-L3IVvhd1.cjs +0 -89
- package/dist/index-L3IVvhd1.cjs.map +0 -1
- package/dist/index-OT2XAJkc.js +0 -117
- package/dist/index-OT2XAJkc.js.map +0 -1
- package/dist/index-TPAX4XKg.cjs +0 -30
- package/dist/index-TPAX4XKg.cjs.map +0 -1
- package/dist/index-WmVSB57y.js +0 -107
- package/dist/index-WmVSB57y.js.map +0 -1
- package/dist/index-mYXvc3Fs.js +0 -68
- package/dist/index-mYXvc3Fs.js.map +0 -1
package/dist/index-BkJhe5Af.js
DELETED
|
@@ -1,1748 +0,0 @@
|
|
|
1
|
-
import { _ as __viteBrowserExternal } from "./index-Dm37u5ut.js";
|
|
2
|
-
import { B as BasePlugin } from "./BasePlugin-6wv0hYJ9.js";
|
|
3
|
-
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
|
-
function getAugmentedNamespace(t) {
|
|
5
|
-
if (Object.prototype.hasOwnProperty.call(t, "__esModule")) return t;
|
|
6
|
-
var r = t.default;
|
|
7
|
-
if (typeof r == "function") {
|
|
8
|
-
var a = function e() {
|
|
9
|
-
var i = !1;
|
|
10
|
-
try {
|
|
11
|
-
i = this instanceof e;
|
|
12
|
-
} catch {
|
|
13
|
-
}
|
|
14
|
-
return i ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
a.prototype = r.prototype;
|
|
17
|
-
} else a = {};
|
|
18
|
-
return Object.defineProperty(a, "__esModule", { value: !0 }), Object.keys(t).forEach(function(e) {
|
|
19
|
-
var i = Object.getOwnPropertyDescriptor(t, e);
|
|
20
|
-
Object.defineProperty(a, e, i.get ? i : {
|
|
21
|
-
enumerable: !0,
|
|
22
|
-
get: function() {
|
|
23
|
-
return t[e];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}), a;
|
|
27
|
-
}
|
|
28
|
-
var toml = {}, parse = { exports: {} }, tomlParser = { exports: {} }, parser, hasRequiredParser;
|
|
29
|
-
function requireParser() {
|
|
30
|
-
if (hasRequiredParser) return parser;
|
|
31
|
-
hasRequiredParser = 1;
|
|
32
|
-
const t = 1114112;
|
|
33
|
-
class r extends Error {
|
|
34
|
-
/* istanbul ignore next */
|
|
35
|
-
constructor(n, o, c) {
|
|
36
|
-
super("[ParserError] " + n, o, c), this.name = "ParserError", this.code = "ParserError", Error.captureStackTrace && Error.captureStackTrace(this, r);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
class a {
|
|
40
|
-
constructor(n) {
|
|
41
|
-
this.parser = n, this.buf = "", this.returned = null, this.result = null, this.resultTable = null, this.resultArr = null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class e {
|
|
45
|
-
constructor() {
|
|
46
|
-
this.pos = 0, this.col = 0, this.line = 0, this.obj = {}, this.ctx = this.obj, this.stack = [], this._buf = "", this.char = null, this.ii = 0, this.state = new a(this.parseStart);
|
|
47
|
-
}
|
|
48
|
-
parse(n) {
|
|
49
|
-
if (n.length === 0 || n.length == null) return;
|
|
50
|
-
this._buf = String(n), this.ii = -1, this.char = -1;
|
|
51
|
-
let o;
|
|
52
|
-
for (; o === !1 || this.nextChar(); )
|
|
53
|
-
o = this.runOne();
|
|
54
|
-
this._buf = null;
|
|
55
|
-
}
|
|
56
|
-
nextChar() {
|
|
57
|
-
return this.char === 10 && (++this.line, this.col = -1), ++this.ii, this.char = this._buf.codePointAt(this.ii), ++this.pos, ++this.col, this.haveBuffer();
|
|
58
|
-
}
|
|
59
|
-
haveBuffer() {
|
|
60
|
-
return this.ii < this._buf.length;
|
|
61
|
-
}
|
|
62
|
-
runOne() {
|
|
63
|
-
return this.state.parser.call(this, this.state.returned);
|
|
64
|
-
}
|
|
65
|
-
finish() {
|
|
66
|
-
this.char = t;
|
|
67
|
-
let n;
|
|
68
|
-
do
|
|
69
|
-
n = this.state.parser, this.runOne();
|
|
70
|
-
while (this.state.parser !== n);
|
|
71
|
-
return this.ctx = null, this.state = null, this._buf = null, this.obj;
|
|
72
|
-
}
|
|
73
|
-
next(n) {
|
|
74
|
-
if (typeof n != "function") throw new r("Tried to set state to non-existent state: " + JSON.stringify(n));
|
|
75
|
-
this.state.parser = n;
|
|
76
|
-
}
|
|
77
|
-
goto(n) {
|
|
78
|
-
return this.next(n), this.runOne();
|
|
79
|
-
}
|
|
80
|
-
call(n, o) {
|
|
81
|
-
o && this.next(o), this.stack.push(this.state), this.state = new a(n);
|
|
82
|
-
}
|
|
83
|
-
callNow(n, o) {
|
|
84
|
-
return this.call(n, o), this.runOne();
|
|
85
|
-
}
|
|
86
|
-
return(n) {
|
|
87
|
-
if (this.stack.length === 0) throw this.error(new r("Stack underflow"));
|
|
88
|
-
n === void 0 && (n = this.state.buf), this.state = this.stack.pop(), this.state.returned = n;
|
|
89
|
-
}
|
|
90
|
-
returnNow(n) {
|
|
91
|
-
return this.return(n), this.runOne();
|
|
92
|
-
}
|
|
93
|
-
consume() {
|
|
94
|
-
if (this.char === t) throw this.error(new r("Unexpected end-of-buffer"));
|
|
95
|
-
this.state.buf += this._buf[this.ii];
|
|
96
|
-
}
|
|
97
|
-
error(n) {
|
|
98
|
-
return n.line = this.line, n.col = this.col, n.pos = this.pos, n;
|
|
99
|
-
}
|
|
100
|
-
/* istanbul ignore next */
|
|
101
|
-
parseStart() {
|
|
102
|
-
throw new r("Must declare a parseStart method");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return e.END = t, e.Error = r, parser = e, parser;
|
|
106
|
-
}
|
|
107
|
-
var createDatetime, hasRequiredCreateDatetime;
|
|
108
|
-
function requireCreateDatetime() {
|
|
109
|
-
return hasRequiredCreateDatetime || (hasRequiredCreateDatetime = 1, createDatetime = (t) => {
|
|
110
|
-
const r = new Date(t);
|
|
111
|
-
if (isNaN(r))
|
|
112
|
-
throw new TypeError("Invalid Datetime");
|
|
113
|
-
return r;
|
|
114
|
-
}), createDatetime;
|
|
115
|
-
}
|
|
116
|
-
var formatNum, hasRequiredFormatNum;
|
|
117
|
-
function requireFormatNum() {
|
|
118
|
-
return hasRequiredFormatNum || (hasRequiredFormatNum = 1, formatNum = (t, r) => {
|
|
119
|
-
for (r = String(r); r.length < t; ) r = "0" + r;
|
|
120
|
-
return r;
|
|
121
|
-
}), formatNum;
|
|
122
|
-
}
|
|
123
|
-
var createDatetimeFloat, hasRequiredCreateDatetimeFloat;
|
|
124
|
-
function requireCreateDatetimeFloat() {
|
|
125
|
-
if (hasRequiredCreateDatetimeFloat) return createDatetimeFloat;
|
|
126
|
-
hasRequiredCreateDatetimeFloat = 1;
|
|
127
|
-
const t = requireFormatNum();
|
|
128
|
-
class r extends Date {
|
|
129
|
-
constructor(e) {
|
|
130
|
-
super(e + "Z"), this.isFloating = !0;
|
|
131
|
-
}
|
|
132
|
-
toISOString() {
|
|
133
|
-
const e = `${this.getUTCFullYear()}-${t(2, this.getUTCMonth() + 1)}-${t(2, this.getUTCDate())}`, i = `${t(2, this.getUTCHours())}:${t(2, this.getUTCMinutes())}:${t(2, this.getUTCSeconds())}.${t(3, this.getUTCMilliseconds())}`;
|
|
134
|
-
return `${e}T${i}`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return createDatetimeFloat = (a) => {
|
|
138
|
-
const e = new r(a);
|
|
139
|
-
if (isNaN(e))
|
|
140
|
-
throw new TypeError("Invalid Datetime");
|
|
141
|
-
return e;
|
|
142
|
-
}, createDatetimeFloat;
|
|
143
|
-
}
|
|
144
|
-
var createDate, hasRequiredCreateDate;
|
|
145
|
-
function requireCreateDate() {
|
|
146
|
-
if (hasRequiredCreateDate) return createDate;
|
|
147
|
-
hasRequiredCreateDate = 1;
|
|
148
|
-
const t = requireFormatNum(), r = commonjsGlobal.Date;
|
|
149
|
-
class a extends r {
|
|
150
|
-
constructor(i) {
|
|
151
|
-
super(i), this.isDate = !0;
|
|
152
|
-
}
|
|
153
|
-
toISOString() {
|
|
154
|
-
return `${this.getUTCFullYear()}-${t(2, this.getUTCMonth() + 1)}-${t(2, this.getUTCDate())}`;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return createDate = (e) => {
|
|
158
|
-
const i = new a(e);
|
|
159
|
-
if (isNaN(i))
|
|
160
|
-
throw new TypeError("Invalid Datetime");
|
|
161
|
-
return i;
|
|
162
|
-
}, createDate;
|
|
163
|
-
}
|
|
164
|
-
var createTime, hasRequiredCreateTime;
|
|
165
|
-
function requireCreateTime() {
|
|
166
|
-
if (hasRequiredCreateTime) return createTime;
|
|
167
|
-
hasRequiredCreateTime = 1;
|
|
168
|
-
const t = requireFormatNum();
|
|
169
|
-
class r extends Date {
|
|
170
|
-
constructor(e) {
|
|
171
|
-
super(`0000-01-01T${e}Z`), this.isTime = !0;
|
|
172
|
-
}
|
|
173
|
-
toISOString() {
|
|
174
|
-
return `${t(2, this.getUTCHours())}:${t(2, this.getUTCMinutes())}:${t(2, this.getUTCSeconds())}.${t(3, this.getUTCMilliseconds())}`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return createTime = (a) => {
|
|
178
|
-
const e = new r(a);
|
|
179
|
-
if (isNaN(e))
|
|
180
|
-
throw new TypeError("Invalid Datetime");
|
|
181
|
-
return e;
|
|
182
|
-
}, createTime;
|
|
183
|
-
}
|
|
184
|
-
var hasRequiredTomlParser;
|
|
185
|
-
function requireTomlParser() {
|
|
186
|
-
if (hasRequiredTomlParser) return tomlParser.exports;
|
|
187
|
-
hasRequiredTomlParser = 1, tomlParser.exports = makeParserClass(requireParser()), tomlParser.exports.makeParserClass = makeParserClass;
|
|
188
|
-
class TomlError extends Error {
|
|
189
|
-
constructor(r) {
|
|
190
|
-
super(r), this.name = "TomlError", Error.captureStackTrace && Error.captureStackTrace(this, TomlError), this.fromTOML = !0, this.wrapped = null;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
TomlError.wrap = (t) => {
|
|
194
|
-
const r = new TomlError(t.message);
|
|
195
|
-
return r.code = t.code, r.wrapped = t, r;
|
|
196
|
-
}, tomlParser.exports.TomlError = TomlError;
|
|
197
|
-
const createDateTime = requireCreateDatetime(), createDateTimeFloat = requireCreateDatetimeFloat(), createDate = requireCreateDate(), createTime = requireCreateTime(), CTRL_I = 9, CTRL_J = 10, CTRL_M = 13, CTRL_CHAR_BOUNDARY = 31, CHAR_SP = 32, CHAR_QUOT = 34, CHAR_NUM = 35, CHAR_APOS = 39, CHAR_PLUS = 43, CHAR_COMMA = 44, CHAR_HYPHEN = 45, CHAR_PERIOD = 46, CHAR_0 = 48, CHAR_1 = 49, CHAR_7 = 55, CHAR_9 = 57, CHAR_COLON = 58, CHAR_EQUALS = 61, CHAR_A = 65, CHAR_E = 69, CHAR_F = 70, CHAR_T = 84, CHAR_U = 85, CHAR_Z = 90, CHAR_LOWBAR = 95, CHAR_a = 97, CHAR_b = 98, CHAR_e = 101, CHAR_f = 102, CHAR_i = 105, CHAR_l = 108, CHAR_n = 110, CHAR_o = 111, CHAR_r = 114, CHAR_s = 115, CHAR_t = 116, CHAR_u = 117, CHAR_x = 120, CHAR_z = 122, CHAR_LCUB = 123, CHAR_RCUB = 125, CHAR_LSQB = 91, CHAR_BSOL = 92, CHAR_RSQB = 93, CHAR_DEL = 127, SURROGATE_FIRST = 55296, SURROGATE_LAST = 57343, escapes = {
|
|
198
|
-
[CHAR_b]: "\b",
|
|
199
|
-
[CHAR_t]: " ",
|
|
200
|
-
[CHAR_n]: `
|
|
201
|
-
`,
|
|
202
|
-
[CHAR_f]: "\f",
|
|
203
|
-
[CHAR_r]: "\r",
|
|
204
|
-
[CHAR_QUOT]: '"',
|
|
205
|
-
[CHAR_BSOL]: "\\"
|
|
206
|
-
};
|
|
207
|
-
function isDigit(t) {
|
|
208
|
-
return t >= CHAR_0 && t <= CHAR_9;
|
|
209
|
-
}
|
|
210
|
-
function isHexit(t) {
|
|
211
|
-
return t >= CHAR_A && t <= CHAR_F || t >= CHAR_a && t <= CHAR_f || t >= CHAR_0 && t <= CHAR_9;
|
|
212
|
-
}
|
|
213
|
-
function isBit(t) {
|
|
214
|
-
return t === CHAR_1 || t === CHAR_0;
|
|
215
|
-
}
|
|
216
|
-
function isOctit(t) {
|
|
217
|
-
return t >= CHAR_0 && t <= CHAR_7;
|
|
218
|
-
}
|
|
219
|
-
function isAlphaNumQuoteHyphen(t) {
|
|
220
|
-
return t >= CHAR_A && t <= CHAR_Z || t >= CHAR_a && t <= CHAR_z || t >= CHAR_0 && t <= CHAR_9 || t === CHAR_APOS || t === CHAR_QUOT || t === CHAR_LOWBAR || t === CHAR_HYPHEN;
|
|
221
|
-
}
|
|
222
|
-
function isAlphaNumHyphen(t) {
|
|
223
|
-
return t >= CHAR_A && t <= CHAR_Z || t >= CHAR_a && t <= CHAR_z || t >= CHAR_0 && t <= CHAR_9 || t === CHAR_LOWBAR || t === CHAR_HYPHEN;
|
|
224
|
-
}
|
|
225
|
-
const _type = /* @__PURE__ */ Symbol("type"), _declared = /* @__PURE__ */ Symbol("declared"), hasOwnProperty = Object.prototype.hasOwnProperty, defineProperty = Object.defineProperty, descriptor = { configurable: !0, enumerable: !0, writable: !0, value: void 0 };
|
|
226
|
-
function hasKey(t, r) {
|
|
227
|
-
return hasOwnProperty.call(t, r) ? !0 : (r === "__proto__" && defineProperty(t, "__proto__", descriptor), !1);
|
|
228
|
-
}
|
|
229
|
-
const INLINE_TABLE = /* @__PURE__ */ Symbol("inline-table");
|
|
230
|
-
function InlineTable() {
|
|
231
|
-
return Object.defineProperties({}, {
|
|
232
|
-
[_type]: { value: INLINE_TABLE }
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
function isInlineTable(t) {
|
|
236
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === INLINE_TABLE;
|
|
237
|
-
}
|
|
238
|
-
const TABLE = /* @__PURE__ */ Symbol("table");
|
|
239
|
-
function Table() {
|
|
240
|
-
return Object.defineProperties({}, {
|
|
241
|
-
[_type]: { value: TABLE },
|
|
242
|
-
[_declared]: { value: !1, writable: !0 }
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
function isTable(t) {
|
|
246
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === TABLE;
|
|
247
|
-
}
|
|
248
|
-
const _contentType = /* @__PURE__ */ Symbol("content-type"), INLINE_LIST = /* @__PURE__ */ Symbol("inline-list");
|
|
249
|
-
function InlineList(t) {
|
|
250
|
-
return Object.defineProperties([], {
|
|
251
|
-
[_type]: { value: INLINE_LIST },
|
|
252
|
-
[_contentType]: { value: t }
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
function isInlineList(t) {
|
|
256
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === INLINE_LIST;
|
|
257
|
-
}
|
|
258
|
-
const LIST = /* @__PURE__ */ Symbol("list");
|
|
259
|
-
function List() {
|
|
260
|
-
return Object.defineProperties([], {
|
|
261
|
-
[_type]: { value: LIST }
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
function isList(t) {
|
|
265
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === LIST;
|
|
266
|
-
}
|
|
267
|
-
let _custom;
|
|
268
|
-
try {
|
|
269
|
-
const utilInspect = eval("require('util').inspect");
|
|
270
|
-
_custom = utilInspect.custom;
|
|
271
|
-
} catch (t) {
|
|
272
|
-
}
|
|
273
|
-
const _inspect = _custom || "inspect";
|
|
274
|
-
class BoxedBigInt {
|
|
275
|
-
constructor(r) {
|
|
276
|
-
try {
|
|
277
|
-
this.value = commonjsGlobal.BigInt.asIntN(64, r);
|
|
278
|
-
} catch {
|
|
279
|
-
this.value = null;
|
|
280
|
-
}
|
|
281
|
-
Object.defineProperty(this, _type, { value: INTEGER });
|
|
282
|
-
}
|
|
283
|
-
isNaN() {
|
|
284
|
-
return this.value === null;
|
|
285
|
-
}
|
|
286
|
-
/* istanbul ignore next */
|
|
287
|
-
toString() {
|
|
288
|
-
return String(this.value);
|
|
289
|
-
}
|
|
290
|
-
/* istanbul ignore next */
|
|
291
|
-
[_inspect]() {
|
|
292
|
-
return `[BigInt: ${this.toString()}]}`;
|
|
293
|
-
}
|
|
294
|
-
valueOf() {
|
|
295
|
-
return this.value;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const INTEGER = /* @__PURE__ */ Symbol("integer");
|
|
299
|
-
function Integer(t) {
|
|
300
|
-
let r = Number(t);
|
|
301
|
-
return Object.is(r, -0) && (r = 0), commonjsGlobal.BigInt && !Number.isSafeInteger(r) ? new BoxedBigInt(t) : Object.defineProperties(new Number(r), {
|
|
302
|
-
isNaN: { value: function() {
|
|
303
|
-
return isNaN(this);
|
|
304
|
-
} },
|
|
305
|
-
[_type]: { value: INTEGER },
|
|
306
|
-
[_inspect]: { value: () => `[Integer: ${t}]` }
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
function isInteger(t) {
|
|
310
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === INTEGER;
|
|
311
|
-
}
|
|
312
|
-
const FLOAT = /* @__PURE__ */ Symbol("float");
|
|
313
|
-
function Float(t) {
|
|
314
|
-
return Object.defineProperties(new Number(t), {
|
|
315
|
-
[_type]: { value: FLOAT },
|
|
316
|
-
[_inspect]: { value: () => `[Float: ${t}]` }
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
function isFloat(t) {
|
|
320
|
-
return t === null || typeof t != "object" ? !1 : t[_type] === FLOAT;
|
|
321
|
-
}
|
|
322
|
-
function tomlType(t) {
|
|
323
|
-
const r = typeof t;
|
|
324
|
-
if (r === "object") {
|
|
325
|
-
if (t === null) return "null";
|
|
326
|
-
if (t instanceof Date) return "datetime";
|
|
327
|
-
if (_type in t)
|
|
328
|
-
switch (t[_type]) {
|
|
329
|
-
case INLINE_TABLE:
|
|
330
|
-
return "inline-table";
|
|
331
|
-
case INLINE_LIST:
|
|
332
|
-
return "inline-list";
|
|
333
|
-
/* istanbul ignore next */
|
|
334
|
-
case TABLE:
|
|
335
|
-
return "table";
|
|
336
|
-
/* istanbul ignore next */
|
|
337
|
-
case LIST:
|
|
338
|
-
return "list";
|
|
339
|
-
case FLOAT:
|
|
340
|
-
return "float";
|
|
341
|
-
case INTEGER:
|
|
342
|
-
return "integer";
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return r;
|
|
346
|
-
}
|
|
347
|
-
function makeParserClass(t) {
|
|
348
|
-
class r extends t {
|
|
349
|
-
constructor() {
|
|
350
|
-
super(), this.ctx = this.obj = Table();
|
|
351
|
-
}
|
|
352
|
-
/* MATCH HELPER */
|
|
353
|
-
atEndOfWord() {
|
|
354
|
-
return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
|
|
355
|
-
}
|
|
356
|
-
atEndOfLine() {
|
|
357
|
-
return this.char === t.END || this.char === CTRL_J || this.char === CTRL_M;
|
|
358
|
-
}
|
|
359
|
-
parseStart() {
|
|
360
|
-
if (this.char === t.END)
|
|
361
|
-
return null;
|
|
362
|
-
if (this.char === CHAR_LSQB)
|
|
363
|
-
return this.call(this.parseTableOrList);
|
|
364
|
-
if (this.char === CHAR_NUM)
|
|
365
|
-
return this.call(this.parseComment);
|
|
366
|
-
if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M)
|
|
367
|
-
return null;
|
|
368
|
-
if (isAlphaNumQuoteHyphen(this.char))
|
|
369
|
-
return this.callNow(this.parseAssignStatement);
|
|
370
|
-
throw this.error(new TomlError(`Unknown character "${this.char}"`));
|
|
371
|
-
}
|
|
372
|
-
// HELPER, this strips any whitespace and comments to the end of the line
|
|
373
|
-
// then RETURNS. Last state in a production.
|
|
374
|
-
parseWhitespaceToEOL() {
|
|
375
|
-
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M)
|
|
376
|
-
return null;
|
|
377
|
-
if (this.char === CHAR_NUM)
|
|
378
|
-
return this.goto(this.parseComment);
|
|
379
|
-
if (this.char === t.END || this.char === CTRL_J)
|
|
380
|
-
return this.return();
|
|
381
|
-
throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line"));
|
|
382
|
-
}
|
|
383
|
-
/* ASSIGNMENT: key = value */
|
|
384
|
-
parseAssignStatement() {
|
|
385
|
-
return this.callNow(this.parseAssign, this.recordAssignStatement);
|
|
386
|
-
}
|
|
387
|
-
recordAssignStatement(e) {
|
|
388
|
-
let i = this.ctx, n = e.key.pop();
|
|
389
|
-
for (let o of e.key) {
|
|
390
|
-
if (hasKey(i, o) && !isTable(i[o]))
|
|
391
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
392
|
-
i = i[o] = i[o] || Table();
|
|
393
|
-
}
|
|
394
|
-
if (hasKey(i, n))
|
|
395
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
396
|
-
return i[_declared] = !0, isInteger(e.value) || isFloat(e.value) ? i[n] = e.value.valueOf() : i[n] = e.value, this.goto(this.parseWhitespaceToEOL);
|
|
397
|
-
}
|
|
398
|
-
/* ASSSIGNMENT expression, key = value possibly inside an inline table */
|
|
399
|
-
parseAssign() {
|
|
400
|
-
return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
|
401
|
-
}
|
|
402
|
-
recordAssignKeyword(e) {
|
|
403
|
-
return this.state.resultTable ? this.state.resultTable.push(e) : this.state.resultTable = [e], this.goto(this.parseAssignKeywordPreDot);
|
|
404
|
-
}
|
|
405
|
-
parseAssignKeywordPreDot() {
|
|
406
|
-
if (this.char === CHAR_PERIOD)
|
|
407
|
-
return this.next(this.parseAssignKeywordPostDot);
|
|
408
|
-
if (this.char !== CHAR_SP && this.char !== CTRL_I)
|
|
409
|
-
return this.goto(this.parseAssignEqual);
|
|
410
|
-
}
|
|
411
|
-
parseAssignKeywordPostDot() {
|
|
412
|
-
if (this.char !== CHAR_SP && this.char !== CTRL_I)
|
|
413
|
-
return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
|
414
|
-
}
|
|
415
|
-
parseAssignEqual() {
|
|
416
|
-
if (this.char === CHAR_EQUALS)
|
|
417
|
-
return this.next(this.parseAssignPreValue);
|
|
418
|
-
throw this.error(new TomlError('Invalid character, expected "="'));
|
|
419
|
-
}
|
|
420
|
-
parseAssignPreValue() {
|
|
421
|
-
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseValue, this.recordAssignValue);
|
|
422
|
-
}
|
|
423
|
-
recordAssignValue(e) {
|
|
424
|
-
return this.returnNow({ key: this.state.resultTable, value: e });
|
|
425
|
-
}
|
|
426
|
-
/* COMMENTS: #...eol */
|
|
427
|
-
parseComment() {
|
|
428
|
-
do {
|
|
429
|
-
if (this.char === t.END || this.char === CTRL_J)
|
|
430
|
-
return this.return();
|
|
431
|
-
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)
|
|
432
|
-
throw this.errorControlCharIn("comments");
|
|
433
|
-
} while (this.nextChar());
|
|
434
|
-
}
|
|
435
|
-
/* TABLES AND LISTS, [foo] and [[foo]] */
|
|
436
|
-
parseTableOrList() {
|
|
437
|
-
if (this.char === CHAR_LSQB)
|
|
438
|
-
this.next(this.parseList);
|
|
439
|
-
else
|
|
440
|
-
return this.goto(this.parseTable);
|
|
441
|
-
}
|
|
442
|
-
/* TABLE [foo.bar.baz] */
|
|
443
|
-
parseTable() {
|
|
444
|
-
return this.ctx = this.obj, this.goto(this.parseTableNext);
|
|
445
|
-
}
|
|
446
|
-
parseTableNext() {
|
|
447
|
-
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseTableMore);
|
|
448
|
-
}
|
|
449
|
-
parseTableMore(e) {
|
|
450
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
451
|
-
return null;
|
|
452
|
-
if (this.char === CHAR_RSQB) {
|
|
453
|
-
if (hasKey(this.ctx, e) && (!isTable(this.ctx[e]) || this.ctx[e][_declared]))
|
|
454
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
455
|
-
return this.ctx = this.ctx[e] = this.ctx[e] || Table(), this.ctx[_declared] = !0, this.next(this.parseWhitespaceToEOL);
|
|
456
|
-
} else if (this.char === CHAR_PERIOD) {
|
|
457
|
-
if (!hasKey(this.ctx, e))
|
|
458
|
-
this.ctx = this.ctx[e] = Table();
|
|
459
|
-
else if (isTable(this.ctx[e]))
|
|
460
|
-
this.ctx = this.ctx[e];
|
|
461
|
-
else if (isList(this.ctx[e]))
|
|
462
|
-
this.ctx = this.ctx[e][this.ctx[e].length - 1];
|
|
463
|
-
else
|
|
464
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
465
|
-
return this.next(this.parseTableNext);
|
|
466
|
-
} else
|
|
467
|
-
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
468
|
-
}
|
|
469
|
-
/* LIST [[a.b.c]] */
|
|
470
|
-
parseList() {
|
|
471
|
-
return this.ctx = this.obj, this.goto(this.parseListNext);
|
|
472
|
-
}
|
|
473
|
-
parseListNext() {
|
|
474
|
-
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseListMore);
|
|
475
|
-
}
|
|
476
|
-
parseListMore(e) {
|
|
477
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
478
|
-
return null;
|
|
479
|
-
if (this.char === CHAR_RSQB) {
|
|
480
|
-
if (hasKey(this.ctx, e) || (this.ctx[e] = List()), isInlineList(this.ctx[e]))
|
|
481
|
-
throw this.error(new TomlError("Can't extend an inline array"));
|
|
482
|
-
if (isList(this.ctx[e])) {
|
|
483
|
-
const i = Table();
|
|
484
|
-
this.ctx[e].push(i), this.ctx = i;
|
|
485
|
-
} else
|
|
486
|
-
throw this.error(new TomlError("Can't redefine an existing key"));
|
|
487
|
-
return this.next(this.parseListEnd);
|
|
488
|
-
} else if (this.char === CHAR_PERIOD) {
|
|
489
|
-
if (!hasKey(this.ctx, e))
|
|
490
|
-
this.ctx = this.ctx[e] = Table();
|
|
491
|
-
else {
|
|
492
|
-
if (isInlineList(this.ctx[e]))
|
|
493
|
-
throw this.error(new TomlError("Can't extend an inline array"));
|
|
494
|
-
if (isInlineTable(this.ctx[e]))
|
|
495
|
-
throw this.error(new TomlError("Can't extend an inline table"));
|
|
496
|
-
if (isList(this.ctx[e]))
|
|
497
|
-
this.ctx = this.ctx[e][this.ctx[e].length - 1];
|
|
498
|
-
else if (isTable(this.ctx[e]))
|
|
499
|
-
this.ctx = this.ctx[e];
|
|
500
|
-
else
|
|
501
|
-
throw this.error(new TomlError("Can't redefine an existing key"));
|
|
502
|
-
}
|
|
503
|
-
return this.next(this.parseListNext);
|
|
504
|
-
} else
|
|
505
|
-
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
506
|
-
}
|
|
507
|
-
parseListEnd(e) {
|
|
508
|
-
if (this.char === CHAR_RSQB)
|
|
509
|
-
return this.next(this.parseWhitespaceToEOL);
|
|
510
|
-
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
511
|
-
}
|
|
512
|
-
/* VALUE string, number, boolean, inline list, inline object */
|
|
513
|
-
parseValue() {
|
|
514
|
-
if (this.char === t.END)
|
|
515
|
-
throw this.error(new TomlError("Key without value"));
|
|
516
|
-
if (this.char === CHAR_QUOT)
|
|
517
|
-
return this.next(this.parseDoubleString);
|
|
518
|
-
if (this.char === CHAR_APOS)
|
|
519
|
-
return this.next(this.parseSingleString);
|
|
520
|
-
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
521
|
-
return this.goto(this.parseNumberSign);
|
|
522
|
-
if (this.char === CHAR_i)
|
|
523
|
-
return this.next(this.parseInf);
|
|
524
|
-
if (this.char === CHAR_n)
|
|
525
|
-
return this.next(this.parseNan);
|
|
526
|
-
if (isDigit(this.char))
|
|
527
|
-
return this.goto(this.parseNumberOrDateTime);
|
|
528
|
-
if (this.char === CHAR_t || this.char === CHAR_f)
|
|
529
|
-
return this.goto(this.parseBoolean);
|
|
530
|
-
if (this.char === CHAR_LSQB)
|
|
531
|
-
return this.call(this.parseInlineList, this.recordValue);
|
|
532
|
-
if (this.char === CHAR_LCUB)
|
|
533
|
-
return this.call(this.parseInlineTable, this.recordValue);
|
|
534
|
-
throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table"));
|
|
535
|
-
}
|
|
536
|
-
recordValue(e) {
|
|
537
|
-
return this.returnNow(e);
|
|
538
|
-
}
|
|
539
|
-
parseInf() {
|
|
540
|
-
if (this.char === CHAR_n)
|
|
541
|
-
return this.next(this.parseInf2);
|
|
542
|
-
throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
|
543
|
-
}
|
|
544
|
-
parseInf2() {
|
|
545
|
-
if (this.char === CHAR_f)
|
|
546
|
-
return this.state.buf === "-" ? this.return(-1 / 0) : this.return(1 / 0);
|
|
547
|
-
throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
|
548
|
-
}
|
|
549
|
-
parseNan() {
|
|
550
|
-
if (this.char === CHAR_a)
|
|
551
|
-
return this.next(this.parseNan2);
|
|
552
|
-
throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
|
553
|
-
}
|
|
554
|
-
parseNan2() {
|
|
555
|
-
if (this.char === CHAR_n)
|
|
556
|
-
return this.return(NaN);
|
|
557
|
-
throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
|
558
|
-
}
|
|
559
|
-
/* KEYS, barewords or basic, literal, or dotted */
|
|
560
|
-
parseKeyword() {
|
|
561
|
-
return this.char === CHAR_QUOT ? this.next(this.parseBasicString) : this.char === CHAR_APOS ? this.next(this.parseLiteralString) : this.goto(this.parseBareKey);
|
|
562
|
-
}
|
|
563
|
-
/* KEYS: barewords */
|
|
564
|
-
parseBareKey() {
|
|
565
|
-
do {
|
|
566
|
-
if (this.char === t.END)
|
|
567
|
-
throw this.error(new TomlError("Key ended without value"));
|
|
568
|
-
if (isAlphaNumHyphen(this.char))
|
|
569
|
-
this.consume();
|
|
570
|
-
else {
|
|
571
|
-
if (this.state.buf.length === 0)
|
|
572
|
-
throw this.error(new TomlError("Empty bare keys are not allowed"));
|
|
573
|
-
return this.returnNow();
|
|
574
|
-
}
|
|
575
|
-
} while (this.nextChar());
|
|
576
|
-
}
|
|
577
|
-
/* STRINGS, single quoted (literal) */
|
|
578
|
-
parseSingleString() {
|
|
579
|
-
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiStringMaybe) : this.goto(this.parseLiteralString);
|
|
580
|
-
}
|
|
581
|
-
parseLiteralString() {
|
|
582
|
-
do {
|
|
583
|
-
if (this.char === CHAR_APOS)
|
|
584
|
-
return this.return();
|
|
585
|
-
if (this.atEndOfLine())
|
|
586
|
-
throw this.error(new TomlError("Unterminated string"));
|
|
587
|
-
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)
|
|
588
|
-
throw this.errorControlCharIn("strings");
|
|
589
|
-
this.consume();
|
|
590
|
-
} while (this.nextChar());
|
|
591
|
-
}
|
|
592
|
-
parseLiteralMultiStringMaybe() {
|
|
593
|
-
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiString) : this.returnNow();
|
|
594
|
-
}
|
|
595
|
-
parseLiteralMultiString() {
|
|
596
|
-
return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseLiteralMultiStringContent) : this.goto(this.parseLiteralMultiStringContent);
|
|
597
|
-
}
|
|
598
|
-
parseLiteralMultiStringContent() {
|
|
599
|
-
do {
|
|
600
|
-
if (this.char === CHAR_APOS)
|
|
601
|
-
return this.next(this.parseLiteralMultiEnd);
|
|
602
|
-
if (this.char === t.END)
|
|
603
|
-
throw this.error(new TomlError("Unterminated multi-line string"));
|
|
604
|
-
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)
|
|
605
|
-
throw this.errorControlCharIn("strings");
|
|
606
|
-
this.consume();
|
|
607
|
-
} while (this.nextChar());
|
|
608
|
-
}
|
|
609
|
-
parseLiteralMultiEnd() {
|
|
610
|
-
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiEnd2) : (this.state.buf += "'", this.goto(this.parseLiteralMultiStringContent));
|
|
611
|
-
}
|
|
612
|
-
parseLiteralMultiEnd2() {
|
|
613
|
-
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiEnd3) : (this.state.buf += "''", this.goto(this.parseLiteralMultiStringContent));
|
|
614
|
-
}
|
|
615
|
-
parseLiteralMultiEnd3() {
|
|
616
|
-
return this.char === CHAR_APOS ? (this.state.buf += "'", this.next(this.parseLiteralMultiEnd4)) : this.returnNow();
|
|
617
|
-
}
|
|
618
|
-
parseLiteralMultiEnd4() {
|
|
619
|
-
return this.char === CHAR_APOS ? (this.state.buf += "'", this.return()) : this.returnNow();
|
|
620
|
-
}
|
|
621
|
-
/* STRINGS double quoted */
|
|
622
|
-
parseDoubleString() {
|
|
623
|
-
return this.char === CHAR_QUOT ? this.next(this.parseMultiStringMaybe) : this.goto(this.parseBasicString);
|
|
624
|
-
}
|
|
625
|
-
parseBasicString() {
|
|
626
|
-
do {
|
|
627
|
-
if (this.char === CHAR_BSOL)
|
|
628
|
-
return this.call(this.parseEscape, this.recordEscapeReplacement);
|
|
629
|
-
if (this.char === CHAR_QUOT)
|
|
630
|
-
return this.return();
|
|
631
|
-
if (this.atEndOfLine())
|
|
632
|
-
throw this.error(new TomlError("Unterminated string"));
|
|
633
|
-
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)
|
|
634
|
-
throw this.errorControlCharIn("strings");
|
|
635
|
-
this.consume();
|
|
636
|
-
} while (this.nextChar());
|
|
637
|
-
}
|
|
638
|
-
recordEscapeReplacement(e) {
|
|
639
|
-
return this.state.buf += e, this.goto(this.parseBasicString);
|
|
640
|
-
}
|
|
641
|
-
parseMultiStringMaybe() {
|
|
642
|
-
return this.char === CHAR_QUOT ? this.next(this.parseMultiString) : this.returnNow();
|
|
643
|
-
}
|
|
644
|
-
parseMultiString() {
|
|
645
|
-
return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseMultiStringContent) : this.goto(this.parseMultiStringContent);
|
|
646
|
-
}
|
|
647
|
-
parseMultiStringContent() {
|
|
648
|
-
do {
|
|
649
|
-
if (this.char === CHAR_BSOL)
|
|
650
|
-
return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
|
|
651
|
-
if (this.char === CHAR_QUOT)
|
|
652
|
-
return this.next(this.parseMultiEnd);
|
|
653
|
-
if (this.char === t.END)
|
|
654
|
-
throw this.error(new TomlError("Unterminated multi-line string"));
|
|
655
|
-
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)
|
|
656
|
-
throw this.errorControlCharIn("strings");
|
|
657
|
-
this.consume();
|
|
658
|
-
} while (this.nextChar());
|
|
659
|
-
}
|
|
660
|
-
errorControlCharIn(e) {
|
|
661
|
-
let i = "\\u00";
|
|
662
|
-
return this.char < 16 && (i += "0"), i += this.char.toString(16), this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in ${e}, use ${i} instead`));
|
|
663
|
-
}
|
|
664
|
-
recordMultiEscapeReplacement(e) {
|
|
665
|
-
return this.state.buf += e, this.goto(this.parseMultiStringContent);
|
|
666
|
-
}
|
|
667
|
-
parseMultiEnd() {
|
|
668
|
-
return this.char === CHAR_QUOT ? this.next(this.parseMultiEnd2) : (this.state.buf += '"', this.goto(this.parseMultiStringContent));
|
|
669
|
-
}
|
|
670
|
-
parseMultiEnd2() {
|
|
671
|
-
return this.char === CHAR_QUOT ? this.next(this.parseMultiEnd3) : (this.state.buf += '""', this.goto(this.parseMultiStringContent));
|
|
672
|
-
}
|
|
673
|
-
parseMultiEnd3() {
|
|
674
|
-
return this.char === CHAR_QUOT ? (this.state.buf += '"', this.next(this.parseMultiEnd4)) : this.returnNow();
|
|
675
|
-
}
|
|
676
|
-
parseMultiEnd4() {
|
|
677
|
-
return this.char === CHAR_QUOT ? (this.state.buf += '"', this.return()) : this.returnNow();
|
|
678
|
-
}
|
|
679
|
-
parseMultiEscape() {
|
|
680
|
-
return this.char === CTRL_M || this.char === CTRL_J ? this.next(this.parseMultiTrim) : this.char === CHAR_SP || this.char === CTRL_I ? this.next(this.parsePreMultiTrim) : this.goto(this.parseEscape);
|
|
681
|
-
}
|
|
682
|
-
parsePreMultiTrim() {
|
|
683
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
684
|
-
return null;
|
|
685
|
-
if (this.char === CTRL_M || this.char === CTRL_J)
|
|
686
|
-
return this.next(this.parseMultiTrim);
|
|
687
|
-
throw this.error(new TomlError("Can't escape whitespace"));
|
|
688
|
-
}
|
|
689
|
-
parseMultiTrim() {
|
|
690
|
-
return this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M ? null : this.returnNow();
|
|
691
|
-
}
|
|
692
|
-
parseEscape() {
|
|
693
|
-
if (this.char in escapes)
|
|
694
|
-
return this.return(escapes[this.char]);
|
|
695
|
-
if (this.char === CHAR_u)
|
|
696
|
-
return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
|
|
697
|
-
if (this.char === CHAR_U)
|
|
698
|
-
return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
|
|
699
|
-
throw this.error(new TomlError("Unknown escape character: " + this.char));
|
|
700
|
-
}
|
|
701
|
-
parseUnicodeReturn(e) {
|
|
702
|
-
try {
|
|
703
|
-
const i = parseInt(e, 16);
|
|
704
|
-
if (i >= SURROGATE_FIRST && i <= SURROGATE_LAST)
|
|
705
|
-
throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved"));
|
|
706
|
-
return this.returnNow(String.fromCodePoint(i));
|
|
707
|
-
} catch (i) {
|
|
708
|
-
throw this.error(TomlError.wrap(i));
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
parseSmallUnicode() {
|
|
712
|
-
if (isHexit(this.char)) {
|
|
713
|
-
if (this.consume(), this.state.buf.length >= 4) return this.return();
|
|
714
|
-
} else
|
|
715
|
-
throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
|
|
716
|
-
}
|
|
717
|
-
parseLargeUnicode() {
|
|
718
|
-
if (isHexit(this.char)) {
|
|
719
|
-
if (this.consume(), this.state.buf.length >= 8) return this.return();
|
|
720
|
-
} else
|
|
721
|
-
throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
|
|
722
|
-
}
|
|
723
|
-
/* NUMBERS */
|
|
724
|
-
parseNumberSign() {
|
|
725
|
-
return this.consume(), this.next(this.parseMaybeSignedInfOrNan);
|
|
726
|
-
}
|
|
727
|
-
parseMaybeSignedInfOrNan() {
|
|
728
|
-
return this.char === CHAR_i ? this.next(this.parseInf) : this.char === CHAR_n ? this.next(this.parseNan) : this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
|
|
729
|
-
}
|
|
730
|
-
parseNumberIntegerStart() {
|
|
731
|
-
return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberIntegerExponentOrDecimal)) : this.goto(this.parseNumberInteger);
|
|
732
|
-
}
|
|
733
|
-
parseNumberIntegerExponentOrDecimal() {
|
|
734
|
-
return this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Integer(this.state.buf));
|
|
735
|
-
}
|
|
736
|
-
parseNumberInteger() {
|
|
737
|
-
if (isDigit(this.char))
|
|
738
|
-
this.consume();
|
|
739
|
-
else {
|
|
740
|
-
if (this.char === CHAR_LOWBAR)
|
|
741
|
-
return this.call(this.parseNoUnder);
|
|
742
|
-
if (this.char === CHAR_E || this.char === CHAR_e)
|
|
743
|
-
return this.consume(), this.next(this.parseNumberExponentSign);
|
|
744
|
-
if (this.char === CHAR_PERIOD)
|
|
745
|
-
return this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat);
|
|
746
|
-
{
|
|
747
|
-
const e = Integer(this.state.buf);
|
|
748
|
-
if (e.isNaN())
|
|
749
|
-
throw this.error(new TomlError("Invalid number"));
|
|
750
|
-
return this.returnNow(e);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
parseNoUnder() {
|
|
755
|
-
if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e)
|
|
756
|
-
throw this.error(new TomlError("Unexpected character, expected digit"));
|
|
757
|
-
if (this.atEndOfWord())
|
|
758
|
-
throw this.error(new TomlError("Incomplete number"));
|
|
759
|
-
return this.returnNow();
|
|
760
|
-
}
|
|
761
|
-
parseNoUnderHexOctBinLiteral() {
|
|
762
|
-
if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD)
|
|
763
|
-
throw this.error(new TomlError("Unexpected character, expected digit"));
|
|
764
|
-
if (this.atEndOfWord())
|
|
765
|
-
throw this.error(new TomlError("Incomplete number"));
|
|
766
|
-
return this.returnNow();
|
|
767
|
-
}
|
|
768
|
-
parseNumberFloat() {
|
|
769
|
-
if (this.char === CHAR_LOWBAR)
|
|
770
|
-
return this.call(this.parseNoUnder, this.parseNumberFloat);
|
|
771
|
-
if (isDigit(this.char))
|
|
772
|
-
this.consume();
|
|
773
|
-
else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Float(this.state.buf));
|
|
774
|
-
}
|
|
775
|
-
parseNumberExponentSign() {
|
|
776
|
-
if (isDigit(this.char))
|
|
777
|
-
return this.goto(this.parseNumberExponent);
|
|
778
|
-
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
779
|
-
this.consume(), this.call(this.parseNoUnder, this.parseNumberExponent);
|
|
780
|
-
else
|
|
781
|
-
throw this.error(new TomlError("Unexpected character, expected -, + or digit"));
|
|
782
|
-
}
|
|
783
|
-
parseNumberExponent() {
|
|
784
|
-
if (isDigit(this.char))
|
|
785
|
-
this.consume();
|
|
786
|
-
else return this.char === CHAR_LOWBAR ? this.call(this.parseNoUnder) : this.returnNow(Float(this.state.buf));
|
|
787
|
-
}
|
|
788
|
-
/* NUMBERS or DATETIMES */
|
|
789
|
-
parseNumberOrDateTime() {
|
|
790
|
-
return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberBaseOrDateTime)) : this.goto(this.parseNumberOrDateTimeOnly);
|
|
791
|
-
}
|
|
792
|
-
parseNumberOrDateTimeOnly() {
|
|
793
|
-
if (this.char === CHAR_LOWBAR)
|
|
794
|
-
return this.call(this.parseNoUnder, this.parseNumberInteger);
|
|
795
|
-
if (isDigit(this.char))
|
|
796
|
-
this.consume(), this.state.buf.length > 4 && this.next(this.parseNumberInteger);
|
|
797
|
-
else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_HYPHEN ? this.goto(this.parseDateTime) : this.char === CHAR_COLON ? this.goto(this.parseOnlyTimeHour) : this.returnNow(Integer(this.state.buf));
|
|
798
|
-
}
|
|
799
|
-
parseDateTimeOnly() {
|
|
800
|
-
if (this.state.buf.length < 4) {
|
|
801
|
-
if (isDigit(this.char))
|
|
802
|
-
return this.consume();
|
|
803
|
-
if (this.char === CHAR_COLON)
|
|
804
|
-
return this.goto(this.parseOnlyTimeHour);
|
|
805
|
-
throw this.error(new TomlError("Expected digit while parsing year part of a date"));
|
|
806
|
-
} else {
|
|
807
|
-
if (this.char === CHAR_HYPHEN)
|
|
808
|
-
return this.goto(this.parseDateTime);
|
|
809
|
-
throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date"));
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
parseNumberBaseOrDateTime() {
|
|
813
|
-
return this.char === CHAR_b ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin)) : this.char === CHAR_o ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct)) : this.char === CHAR_x ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex)) : this.char === CHAR_PERIOD ? this.goto(this.parseNumberInteger) : isDigit(this.char) ? this.goto(this.parseDateTimeOnly) : this.returnNow(Integer(this.state.buf));
|
|
814
|
-
}
|
|
815
|
-
parseIntegerHex() {
|
|
816
|
-
if (isHexit(this.char))
|
|
817
|
-
this.consume();
|
|
818
|
-
else {
|
|
819
|
-
if (this.char === CHAR_LOWBAR)
|
|
820
|
-
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
821
|
-
{
|
|
822
|
-
const e = Integer(this.state.buf);
|
|
823
|
-
if (e.isNaN())
|
|
824
|
-
throw this.error(new TomlError("Invalid number"));
|
|
825
|
-
return this.returnNow(e);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
parseIntegerOct() {
|
|
830
|
-
if (isOctit(this.char))
|
|
831
|
-
this.consume();
|
|
832
|
-
else {
|
|
833
|
-
if (this.char === CHAR_LOWBAR)
|
|
834
|
-
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
835
|
-
{
|
|
836
|
-
const e = Integer(this.state.buf);
|
|
837
|
-
if (e.isNaN())
|
|
838
|
-
throw this.error(new TomlError("Invalid number"));
|
|
839
|
-
return this.returnNow(e);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
parseIntegerBin() {
|
|
844
|
-
if (isBit(this.char))
|
|
845
|
-
this.consume();
|
|
846
|
-
else {
|
|
847
|
-
if (this.char === CHAR_LOWBAR)
|
|
848
|
-
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
849
|
-
{
|
|
850
|
-
const e = Integer(this.state.buf);
|
|
851
|
-
if (e.isNaN())
|
|
852
|
-
throw this.error(new TomlError("Invalid number"));
|
|
853
|
-
return this.returnNow(e);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
/* DATETIME */
|
|
858
|
-
parseDateTime() {
|
|
859
|
-
if (this.state.buf.length < 4)
|
|
860
|
-
throw this.error(new TomlError("Years less than 1000 must be zero padded to four characters"));
|
|
861
|
-
return this.state.result = this.state.buf, this.state.buf = "", this.next(this.parseDateMonth);
|
|
862
|
-
}
|
|
863
|
-
parseDateMonth() {
|
|
864
|
-
if (this.char === CHAR_HYPHEN) {
|
|
865
|
-
if (this.state.buf.length < 2)
|
|
866
|
-
throw this.error(new TomlError("Months less than 10 must be zero padded to two characters"));
|
|
867
|
-
return this.state.result += "-" + this.state.buf, this.state.buf = "", this.next(this.parseDateDay);
|
|
868
|
-
} else if (isDigit(this.char))
|
|
869
|
-
this.consume();
|
|
870
|
-
else
|
|
871
|
-
throw this.error(new TomlError("Incomplete datetime"));
|
|
872
|
-
}
|
|
873
|
-
parseDateDay() {
|
|
874
|
-
if (this.char === CHAR_T || this.char === CHAR_SP) {
|
|
875
|
-
if (this.state.buf.length < 2)
|
|
876
|
-
throw this.error(new TomlError("Days less than 10 must be zero padded to two characters"));
|
|
877
|
-
return this.state.result += "-" + this.state.buf, this.state.buf = "", this.next(this.parseStartTimeHour);
|
|
878
|
-
} else {
|
|
879
|
-
if (this.atEndOfWord())
|
|
880
|
-
return this.returnNow(createDate(this.state.result + "-" + this.state.buf));
|
|
881
|
-
if (isDigit(this.char))
|
|
882
|
-
this.consume();
|
|
883
|
-
else
|
|
884
|
-
throw this.error(new TomlError("Incomplete datetime"));
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
parseStartTimeHour() {
|
|
888
|
-
return this.atEndOfWord() ? this.returnNow(createDate(this.state.result)) : this.goto(this.parseTimeHour);
|
|
889
|
-
}
|
|
890
|
-
parseTimeHour() {
|
|
891
|
-
if (this.char === CHAR_COLON) {
|
|
892
|
-
if (this.state.buf.length < 2)
|
|
893
|
-
throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
|
|
894
|
-
return this.state.result += "T" + this.state.buf, this.state.buf = "", this.next(this.parseTimeMin);
|
|
895
|
-
} else if (isDigit(this.char))
|
|
896
|
-
this.consume();
|
|
897
|
-
else
|
|
898
|
-
throw this.error(new TomlError("Incomplete datetime"));
|
|
899
|
-
}
|
|
900
|
-
parseTimeMin() {
|
|
901
|
-
if (this.state.buf.length < 2 && isDigit(this.char))
|
|
902
|
-
this.consume();
|
|
903
|
-
else {
|
|
904
|
-
if (this.state.buf.length === 2 && this.char === CHAR_COLON)
|
|
905
|
-
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseTimeSec);
|
|
906
|
-
throw this.error(new TomlError("Incomplete datetime"));
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
parseTimeSec() {
|
|
910
|
-
if (isDigit(this.char)) {
|
|
911
|
-
if (this.consume(), this.state.buf.length === 2)
|
|
912
|
-
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseTimeZoneOrFraction);
|
|
913
|
-
} else
|
|
914
|
-
throw this.error(new TomlError("Incomplete datetime"));
|
|
915
|
-
}
|
|
916
|
-
parseOnlyTimeHour() {
|
|
917
|
-
if (this.char === CHAR_COLON) {
|
|
918
|
-
if (this.state.buf.length < 2)
|
|
919
|
-
throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
|
|
920
|
-
return this.state.result = this.state.buf, this.state.buf = "", this.next(this.parseOnlyTimeMin);
|
|
921
|
-
} else
|
|
922
|
-
throw this.error(new TomlError("Incomplete time"));
|
|
923
|
-
}
|
|
924
|
-
parseOnlyTimeMin() {
|
|
925
|
-
if (this.state.buf.length < 2 && isDigit(this.char))
|
|
926
|
-
this.consume();
|
|
927
|
-
else {
|
|
928
|
-
if (this.state.buf.length === 2 && this.char === CHAR_COLON)
|
|
929
|
-
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseOnlyTimeSec);
|
|
930
|
-
throw this.error(new TomlError("Incomplete time"));
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
parseOnlyTimeSec() {
|
|
934
|
-
if (isDigit(this.char)) {
|
|
935
|
-
if (this.consume(), this.state.buf.length === 2)
|
|
936
|
-
return this.next(this.parseOnlyTimeFractionMaybe);
|
|
937
|
-
} else
|
|
938
|
-
throw this.error(new TomlError("Incomplete time"));
|
|
939
|
-
}
|
|
940
|
-
parseOnlyTimeFractionMaybe() {
|
|
941
|
-
if (this.state.result += ":" + this.state.buf, this.char === CHAR_PERIOD)
|
|
942
|
-
this.state.buf = "", this.next(this.parseOnlyTimeFraction);
|
|
943
|
-
else
|
|
944
|
-
return this.return(createTime(this.state.result));
|
|
945
|
-
}
|
|
946
|
-
parseOnlyTimeFraction() {
|
|
947
|
-
if (isDigit(this.char))
|
|
948
|
-
this.consume();
|
|
949
|
-
else if (this.atEndOfWord()) {
|
|
950
|
-
if (this.state.buf.length === 0) throw this.error(new TomlError("Expected digit in milliseconds"));
|
|
951
|
-
return this.returnNow(createTime(this.state.result + "." + this.state.buf));
|
|
952
|
-
} else
|
|
953
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
954
|
-
}
|
|
955
|
-
parseTimeZoneOrFraction() {
|
|
956
|
-
if (this.char === CHAR_PERIOD)
|
|
957
|
-
this.consume(), this.next(this.parseDateTimeFraction);
|
|
958
|
-
else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
959
|
-
this.consume(), this.next(this.parseTimeZoneHour);
|
|
960
|
-
else {
|
|
961
|
-
if (this.char === CHAR_Z)
|
|
962
|
-
return this.consume(), this.return(createDateTime(this.state.result + this.state.buf));
|
|
963
|
-
if (this.atEndOfWord())
|
|
964
|
-
return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
|
|
965
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
parseDateTimeFraction() {
|
|
969
|
-
if (isDigit(this.char))
|
|
970
|
-
this.consume();
|
|
971
|
-
else {
|
|
972
|
-
if (this.state.buf.length === 1)
|
|
973
|
-
throw this.error(new TomlError("Expected digit in milliseconds"));
|
|
974
|
-
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
975
|
-
this.consume(), this.next(this.parseTimeZoneHour);
|
|
976
|
-
else {
|
|
977
|
-
if (this.char === CHAR_Z)
|
|
978
|
-
return this.consume(), this.return(createDateTime(this.state.result + this.state.buf));
|
|
979
|
-
if (this.atEndOfWord())
|
|
980
|
-
return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
|
|
981
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
parseTimeZoneHour() {
|
|
986
|
-
if (isDigit(this.char)) {
|
|
987
|
-
if (this.consume(), /\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
|
|
988
|
-
} else
|
|
989
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
|
|
990
|
-
}
|
|
991
|
-
parseTimeZoneSep() {
|
|
992
|
-
if (this.char === CHAR_COLON)
|
|
993
|
-
this.consume(), this.next(this.parseTimeZoneMin);
|
|
994
|
-
else
|
|
995
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected colon"));
|
|
996
|
-
}
|
|
997
|
-
parseTimeZoneMin() {
|
|
998
|
-
if (isDigit(this.char)) {
|
|
999
|
-
if (this.consume(), /\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf));
|
|
1000
|
-
} else
|
|
1001
|
-
throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
|
|
1002
|
-
}
|
|
1003
|
-
/* BOOLEAN */
|
|
1004
|
-
parseBoolean() {
|
|
1005
|
-
if (this.char === CHAR_t)
|
|
1006
|
-
return this.consume(), this.next(this.parseTrue_r);
|
|
1007
|
-
if (this.char === CHAR_f)
|
|
1008
|
-
return this.consume(), this.next(this.parseFalse_a);
|
|
1009
|
-
}
|
|
1010
|
-
parseTrue_r() {
|
|
1011
|
-
if (this.char === CHAR_r)
|
|
1012
|
-
return this.consume(), this.next(this.parseTrue_u);
|
|
1013
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1014
|
-
}
|
|
1015
|
-
parseTrue_u() {
|
|
1016
|
-
if (this.char === CHAR_u)
|
|
1017
|
-
return this.consume(), this.next(this.parseTrue_e);
|
|
1018
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1019
|
-
}
|
|
1020
|
-
parseTrue_e() {
|
|
1021
|
-
if (this.char === CHAR_e)
|
|
1022
|
-
return this.return(!0);
|
|
1023
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1024
|
-
}
|
|
1025
|
-
parseFalse_a() {
|
|
1026
|
-
if (this.char === CHAR_a)
|
|
1027
|
-
return this.consume(), this.next(this.parseFalse_l);
|
|
1028
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1029
|
-
}
|
|
1030
|
-
parseFalse_l() {
|
|
1031
|
-
if (this.char === CHAR_l)
|
|
1032
|
-
return this.consume(), this.next(this.parseFalse_s);
|
|
1033
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1034
|
-
}
|
|
1035
|
-
parseFalse_s() {
|
|
1036
|
-
if (this.char === CHAR_s)
|
|
1037
|
-
return this.consume(), this.next(this.parseFalse_e);
|
|
1038
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1039
|
-
}
|
|
1040
|
-
parseFalse_e() {
|
|
1041
|
-
if (this.char === CHAR_e)
|
|
1042
|
-
return this.return(!1);
|
|
1043
|
-
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1044
|
-
}
|
|
1045
|
-
/* INLINE LISTS */
|
|
1046
|
-
parseInlineList() {
|
|
1047
|
-
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J)
|
|
1048
|
-
return null;
|
|
1049
|
-
if (this.char === t.END)
|
|
1050
|
-
throw this.error(new TomlError("Unterminated inline array"));
|
|
1051
|
-
return this.char === CHAR_NUM ? this.call(this.parseComment) : this.char === CHAR_RSQB ? this.return(this.state.resultArr || InlineList()) : this.callNow(this.parseValue, this.recordInlineListValue);
|
|
1052
|
-
}
|
|
1053
|
-
recordInlineListValue(e) {
|
|
1054
|
-
return this.state.resultArr || (this.state.resultArr = InlineList(tomlType(e))), isFloat(e) || isInteger(e) ? this.state.resultArr.push(e.valueOf()) : this.state.resultArr.push(e), this.goto(this.parseInlineListNext);
|
|
1055
|
-
}
|
|
1056
|
-
parseInlineListNext() {
|
|
1057
|
-
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J)
|
|
1058
|
-
return null;
|
|
1059
|
-
if (this.char === CHAR_NUM)
|
|
1060
|
-
return this.call(this.parseComment);
|
|
1061
|
-
if (this.char === CHAR_COMMA)
|
|
1062
|
-
return this.next(this.parseInlineList);
|
|
1063
|
-
if (this.char === CHAR_RSQB)
|
|
1064
|
-
return this.goto(this.parseInlineList);
|
|
1065
|
-
throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
|
|
1066
|
-
}
|
|
1067
|
-
/* INLINE TABLE */
|
|
1068
|
-
parseInlineTable() {
|
|
1069
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
1070
|
-
return null;
|
|
1071
|
-
if (this.char === t.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M)
|
|
1072
|
-
throw this.error(new TomlError("Unterminated inline array"));
|
|
1073
|
-
return this.char === CHAR_RCUB ? this.return(this.state.resultTable || InlineTable()) : (this.state.resultTable || (this.state.resultTable = InlineTable()), this.callNow(this.parseAssign, this.recordInlineTableValue));
|
|
1074
|
-
}
|
|
1075
|
-
recordInlineTableValue(e) {
|
|
1076
|
-
let i = this.state.resultTable, n = e.key.pop();
|
|
1077
|
-
for (let o of e.key) {
|
|
1078
|
-
if (hasKey(i, o) && (!isTable(i[o]) || i[o][_declared]))
|
|
1079
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
1080
|
-
i = i[o] = i[o] || Table();
|
|
1081
|
-
}
|
|
1082
|
-
if (hasKey(i, n))
|
|
1083
|
-
throw this.error(new TomlError("Can't redefine existing key"));
|
|
1084
|
-
return isInteger(e.value) || isFloat(e.value) ? i[n] = e.value.valueOf() : i[n] = e.value, this.goto(this.parseInlineTableNext);
|
|
1085
|
-
}
|
|
1086
|
-
parseInlineTableNext() {
|
|
1087
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
1088
|
-
return null;
|
|
1089
|
-
if (this.char === t.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M)
|
|
1090
|
-
throw this.error(new TomlError("Unterminated inline array"));
|
|
1091
|
-
if (this.char === CHAR_COMMA)
|
|
1092
|
-
return this.next(this.parseInlineTablePostComma);
|
|
1093
|
-
if (this.char === CHAR_RCUB)
|
|
1094
|
-
return this.goto(this.parseInlineTable);
|
|
1095
|
-
throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
|
|
1096
|
-
}
|
|
1097
|
-
parseInlineTablePostComma() {
|
|
1098
|
-
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
1099
|
-
return null;
|
|
1100
|
-
if (this.char === t.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M)
|
|
1101
|
-
throw this.error(new TomlError("Unterminated inline array"));
|
|
1102
|
-
if (this.char === CHAR_COMMA)
|
|
1103
|
-
throw this.error(new TomlError("Empty elements in inline tables are not permitted"));
|
|
1104
|
-
if (this.char === CHAR_RCUB)
|
|
1105
|
-
throw this.error(new TomlError("Trailing commas in inline tables are not permitted"));
|
|
1106
|
-
return this.goto(this.parseInlineTable);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
return r;
|
|
1110
|
-
}
|
|
1111
|
-
return tomlParser.exports;
|
|
1112
|
-
}
|
|
1113
|
-
var parsePrettyError, hasRequiredParsePrettyError;
|
|
1114
|
-
function requireParsePrettyError() {
|
|
1115
|
-
if (hasRequiredParsePrettyError) return parsePrettyError;
|
|
1116
|
-
hasRequiredParsePrettyError = 1, parsePrettyError = t;
|
|
1117
|
-
function t(r, a) {
|
|
1118
|
-
if (r.pos == null || r.line == null) return r;
|
|
1119
|
-
let e = r.message;
|
|
1120
|
-
if (e += ` at row ${r.line + 1}, col ${r.col + 1}, pos ${r.pos}:
|
|
1121
|
-
`, a && a.split) {
|
|
1122
|
-
const i = a.split(/\n/), n = String(Math.min(i.length, r.line + 3)).length;
|
|
1123
|
-
let o = " ";
|
|
1124
|
-
for (; o.length < n; ) o += " ";
|
|
1125
|
-
for (let c = Math.max(0, r.line - 1); c < Math.min(i.length, r.line + 2); ++c) {
|
|
1126
|
-
let f = String(c + 1);
|
|
1127
|
-
if (f.length < n && (f = " " + f), r.line === c) {
|
|
1128
|
-
e += f + "> " + i[c] + `
|
|
1129
|
-
`, e += o + " ";
|
|
1130
|
-
for (let u = 0; u < r.col; ++u)
|
|
1131
|
-
e += " ";
|
|
1132
|
-
e += `^
|
|
1133
|
-
`;
|
|
1134
|
-
} else
|
|
1135
|
-
e += f + ": " + i[c] + `
|
|
1136
|
-
`;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
return r.message = e + `
|
|
1140
|
-
`, r;
|
|
1141
|
-
}
|
|
1142
|
-
return parsePrettyError;
|
|
1143
|
-
}
|
|
1144
|
-
var parseString_1, hasRequiredParseString;
|
|
1145
|
-
function requireParseString() {
|
|
1146
|
-
if (hasRequiredParseString) return parseString_1;
|
|
1147
|
-
hasRequiredParseString = 1, parseString_1 = a;
|
|
1148
|
-
const t = requireTomlParser(), r = requireParsePrettyError();
|
|
1149
|
-
function a(e) {
|
|
1150
|
-
commonjsGlobal.Buffer && commonjsGlobal.Buffer.isBuffer(e) && (e = e.toString("utf8"));
|
|
1151
|
-
const i = new t();
|
|
1152
|
-
try {
|
|
1153
|
-
return i.parse(e), i.finish();
|
|
1154
|
-
} catch (n) {
|
|
1155
|
-
throw r(n, e);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
return parseString_1;
|
|
1159
|
-
}
|
|
1160
|
-
var parseAsync_1, hasRequiredParseAsync;
|
|
1161
|
-
function requireParseAsync() {
|
|
1162
|
-
if (hasRequiredParseAsync) return parseAsync_1;
|
|
1163
|
-
hasRequiredParseAsync = 1, parseAsync_1 = a;
|
|
1164
|
-
const t = requireTomlParser(), r = requireParsePrettyError();
|
|
1165
|
-
function a(e, i) {
|
|
1166
|
-
i || (i = {});
|
|
1167
|
-
const n = 0, o = i.blocksize || 40960, c = new t();
|
|
1168
|
-
return new Promise((u, d) => {
|
|
1169
|
-
setImmediate(f, n, o, u, d);
|
|
1170
|
-
});
|
|
1171
|
-
function f(u, d, R, g) {
|
|
1172
|
-
if (u >= e.length)
|
|
1173
|
-
try {
|
|
1174
|
-
return R(c.finish());
|
|
1175
|
-
} catch (w) {
|
|
1176
|
-
return g(r(w, e));
|
|
1177
|
-
}
|
|
1178
|
-
try {
|
|
1179
|
-
c.parse(e.slice(u, u + d)), setImmediate(f, u + d, d, R, g);
|
|
1180
|
-
} catch (w) {
|
|
1181
|
-
g(r(w, e));
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
return parseAsync_1;
|
|
1186
|
-
}
|
|
1187
|
-
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal);
|
|
1188
|
-
var parseStream_1, hasRequiredParseStream;
|
|
1189
|
-
function requireParseStream() {
|
|
1190
|
-
if (hasRequiredParseStream) return parseStream_1;
|
|
1191
|
-
hasRequiredParseStream = 1, parseStream_1 = a;
|
|
1192
|
-
const t = require$$0, r = requireTomlParser();
|
|
1193
|
-
function a(n) {
|
|
1194
|
-
return n ? e(n) : i();
|
|
1195
|
-
}
|
|
1196
|
-
function e(n) {
|
|
1197
|
-
const o = new r();
|
|
1198
|
-
return n.setEncoding("utf8"), new Promise((c, f) => {
|
|
1199
|
-
let u, d = !1, R = !1;
|
|
1200
|
-
function g() {
|
|
1201
|
-
if (d = !0, !u)
|
|
1202
|
-
try {
|
|
1203
|
-
c(o.finish());
|
|
1204
|
-
} catch (T) {
|
|
1205
|
-
f(T);
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function w(T) {
|
|
1209
|
-
R = !0, f(T);
|
|
1210
|
-
}
|
|
1211
|
-
n.once("end", g), n.once("error", w), x();
|
|
1212
|
-
function x() {
|
|
1213
|
-
u = !0;
|
|
1214
|
-
let T;
|
|
1215
|
-
for (; (T = n.read()) !== null; )
|
|
1216
|
-
try {
|
|
1217
|
-
o.parse(T);
|
|
1218
|
-
} catch (E) {
|
|
1219
|
-
return w(E);
|
|
1220
|
-
}
|
|
1221
|
-
if (u = !1, d) return g();
|
|
1222
|
-
R || n.once("readable", x);
|
|
1223
|
-
}
|
|
1224
|
-
});
|
|
1225
|
-
}
|
|
1226
|
-
function i() {
|
|
1227
|
-
const n = new r();
|
|
1228
|
-
return new t.Transform({
|
|
1229
|
-
objectMode: !0,
|
|
1230
|
-
transform(o, c, f) {
|
|
1231
|
-
try {
|
|
1232
|
-
n.parse(o.toString(c));
|
|
1233
|
-
} catch (u) {
|
|
1234
|
-
this.emit("error", u);
|
|
1235
|
-
}
|
|
1236
|
-
f();
|
|
1237
|
-
},
|
|
1238
|
-
flush(o) {
|
|
1239
|
-
try {
|
|
1240
|
-
this.push(n.finish());
|
|
1241
|
-
} catch (c) {
|
|
1242
|
-
this.emit("error", c);
|
|
1243
|
-
}
|
|
1244
|
-
o();
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
return parseStream_1;
|
|
1249
|
-
}
|
|
1250
|
-
var hasRequiredParse;
|
|
1251
|
-
function requireParse() {
|
|
1252
|
-
return hasRequiredParse || (hasRequiredParse = 1, parse.exports = requireParseString(), parse.exports.async = requireParseAsync(), parse.exports.stream = requireParseStream(), parse.exports.prettyError = requireParsePrettyError()), parse.exports;
|
|
1253
|
-
}
|
|
1254
|
-
var stringify = { exports: {} }, hasRequiredStringify;
|
|
1255
|
-
function requireStringify() {
|
|
1256
|
-
if (hasRequiredStringify) return stringify.exports;
|
|
1257
|
-
hasRequiredStringify = 1, stringify.exports = t, stringify.exports.value = T;
|
|
1258
|
-
function t(s) {
|
|
1259
|
-
if (s === null) throw r("null");
|
|
1260
|
-
if (s === void 0) throw r("undefined");
|
|
1261
|
-
if (typeof s != "object") throw r(typeof s);
|
|
1262
|
-
if (typeof s.toJSON == "function" && (s = s.toJSON()), s == null) return null;
|
|
1263
|
-
const h = c(s);
|
|
1264
|
-
if (h !== "table") throw r(h);
|
|
1265
|
-
return n("", "", s);
|
|
1266
|
-
}
|
|
1267
|
-
function r(s) {
|
|
1268
|
-
return new Error("Can only stringify objects, not " + s);
|
|
1269
|
-
}
|
|
1270
|
-
function a(s) {
|
|
1271
|
-
return Object.keys(s).filter((h) => o(s[h]));
|
|
1272
|
-
}
|
|
1273
|
-
function e(s) {
|
|
1274
|
-
return Object.keys(s).filter((h) => !o(s[h]));
|
|
1275
|
-
}
|
|
1276
|
-
function i(s) {
|
|
1277
|
-
let h = Array.isArray(s) ? [] : Object.prototype.hasOwnProperty.call(s, "__proto__") ? { ["__proto__"]: void 0 } : {};
|
|
1278
|
-
for (let l of Object.keys(s))
|
|
1279
|
-
s[l] && typeof s[l].toJSON == "function" && !("toISOString" in s[l]) ? h[l] = s[l].toJSON() : h[l] = s[l];
|
|
1280
|
-
return h;
|
|
1281
|
-
}
|
|
1282
|
-
function n(s, h, l) {
|
|
1283
|
-
l = i(l);
|
|
1284
|
-
let m, _;
|
|
1285
|
-
m = a(l), _ = e(l);
|
|
1286
|
-
const A = [], b = h || "";
|
|
1287
|
-
m.forEach((H) => {
|
|
1288
|
-
var S = c(l[H]);
|
|
1289
|
-
S !== "undefined" && S !== "null" && A.push(b + f(H) + " = " + x(l[H], !0));
|
|
1290
|
-
}), A.length > 0 && A.push("");
|
|
1291
|
-
const N = s && m.length > 0 ? h + " " : "";
|
|
1292
|
-
return _.forEach((H) => {
|
|
1293
|
-
A.push(D(s, N, H, l[H]));
|
|
1294
|
-
}), A.join(`
|
|
1295
|
-
`);
|
|
1296
|
-
}
|
|
1297
|
-
function o(s) {
|
|
1298
|
-
switch (c(s)) {
|
|
1299
|
-
case "undefined":
|
|
1300
|
-
case "null":
|
|
1301
|
-
case "integer":
|
|
1302
|
-
case "nan":
|
|
1303
|
-
case "float":
|
|
1304
|
-
case "boolean":
|
|
1305
|
-
case "string":
|
|
1306
|
-
case "datetime":
|
|
1307
|
-
return !0;
|
|
1308
|
-
case "array":
|
|
1309
|
-
return s.length === 0 || c(s[0]) !== "table";
|
|
1310
|
-
case "table":
|
|
1311
|
-
return Object.keys(s).length === 0;
|
|
1312
|
-
/* istanbul ignore next */
|
|
1313
|
-
default:
|
|
1314
|
-
return !1;
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
function c(s) {
|
|
1318
|
-
return s === void 0 ? "undefined" : s === null ? "null" : typeof s == "bigint" || Number.isInteger(s) && !Object.is(s, -0) ? "integer" : typeof s == "number" ? "float" : typeof s == "boolean" ? "boolean" : typeof s == "string" ? "string" : "toISOString" in s ? isNaN(s) ? "undefined" : "datetime" : Array.isArray(s) ? "array" : "table";
|
|
1319
|
-
}
|
|
1320
|
-
function f(s) {
|
|
1321
|
-
const h = String(s);
|
|
1322
|
-
return /^[-A-Za-z0-9_]+$/.test(h) ? h : u(h);
|
|
1323
|
-
}
|
|
1324
|
-
function u(s) {
|
|
1325
|
-
return '"' + g(s).replace(/"/g, '\\"') + '"';
|
|
1326
|
-
}
|
|
1327
|
-
function d(s) {
|
|
1328
|
-
return "'" + s + "'";
|
|
1329
|
-
}
|
|
1330
|
-
function R(s, h) {
|
|
1331
|
-
for (; h.length < s; ) h = "0" + h;
|
|
1332
|
-
return h;
|
|
1333
|
-
}
|
|
1334
|
-
function g(s) {
|
|
1335
|
-
return s.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/([\u0000-\u001f\u007f])/, (h) => "\\u" + R(4, h.codePointAt(0).toString(16)));
|
|
1336
|
-
}
|
|
1337
|
-
function w(s) {
|
|
1338
|
-
let h = s.split(/\n/).map((l) => g(l).replace(/"(?="")/g, '\\"')).join(`
|
|
1339
|
-
`);
|
|
1340
|
-
return h.slice(-1) === '"' && (h += `\\
|
|
1341
|
-
`), `"""
|
|
1342
|
-
` + h + '"""';
|
|
1343
|
-
}
|
|
1344
|
-
function x(s, h) {
|
|
1345
|
-
let l = c(s);
|
|
1346
|
-
return l === "string" && (h && /\n/.test(s) ? l = "string-multiline" : !/[\b\t\n\f\r']/.test(s) && /"/.test(s) && (l = "string-literal")), T(s, l);
|
|
1347
|
-
}
|
|
1348
|
-
function T(s, h) {
|
|
1349
|
-
switch (h || (h = c(s)), h) {
|
|
1350
|
-
case "string-multiline":
|
|
1351
|
-
return w(s);
|
|
1352
|
-
case "string":
|
|
1353
|
-
return u(s);
|
|
1354
|
-
case "string-literal":
|
|
1355
|
-
return d(s);
|
|
1356
|
-
case "integer":
|
|
1357
|
-
return E(s);
|
|
1358
|
-
case "float":
|
|
1359
|
-
return y(s);
|
|
1360
|
-
case "boolean":
|
|
1361
|
-
return p(s);
|
|
1362
|
-
case "datetime":
|
|
1363
|
-
return L(s);
|
|
1364
|
-
case "array":
|
|
1365
|
-
return O(s.filter((l) => c(l) !== "null" && c(l) !== "undefined" && c(l) !== "nan"));
|
|
1366
|
-
case "table":
|
|
1367
|
-
return I(s);
|
|
1368
|
-
/* istanbul ignore next */
|
|
1369
|
-
default:
|
|
1370
|
-
throw r(h);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
function E(s) {
|
|
1374
|
-
return String(s).replace(/\B(?=(\d{3})+(?!\d))/g, "_");
|
|
1375
|
-
}
|
|
1376
|
-
function y(s) {
|
|
1377
|
-
if (s === 1 / 0)
|
|
1378
|
-
return "inf";
|
|
1379
|
-
if (s === -1 / 0)
|
|
1380
|
-
return "-inf";
|
|
1381
|
-
if (Object.is(s, NaN))
|
|
1382
|
-
return "nan";
|
|
1383
|
-
if (Object.is(s, -0))
|
|
1384
|
-
return "-0.0";
|
|
1385
|
-
const [h, l] = String(s).split(".");
|
|
1386
|
-
return E(h) + "." + l;
|
|
1387
|
-
}
|
|
1388
|
-
function p(s) {
|
|
1389
|
-
return String(s);
|
|
1390
|
-
}
|
|
1391
|
-
function L(s) {
|
|
1392
|
-
return s.toISOString();
|
|
1393
|
-
}
|
|
1394
|
-
function O(s) {
|
|
1395
|
-
s = i(s);
|
|
1396
|
-
let h = "[";
|
|
1397
|
-
const l = s.map((m) => T(m));
|
|
1398
|
-
return l.join(", ").length > 60 || /\n/.test(l) ? h += `
|
|
1399
|
-
` + l.join(`,
|
|
1400
|
-
`) + `
|
|
1401
|
-
` : h += " " + l.join(", ") + (l.length > 0 ? " " : ""), h + "]";
|
|
1402
|
-
}
|
|
1403
|
-
function I(s) {
|
|
1404
|
-
s = i(s);
|
|
1405
|
-
const h = [];
|
|
1406
|
-
return Object.keys(s).forEach((l) => {
|
|
1407
|
-
h.push(f(l) + " = " + x(s[l], !1));
|
|
1408
|
-
}), "{ " + h.join(", ") + (h.length > 0 ? " " : "") + "}";
|
|
1409
|
-
}
|
|
1410
|
-
function D(s, h, l, m) {
|
|
1411
|
-
const _ = c(m);
|
|
1412
|
-
if (_ === "array")
|
|
1413
|
-
return P(s, h, l, m);
|
|
1414
|
-
if (_ === "table")
|
|
1415
|
-
return M(s, h, l, m);
|
|
1416
|
-
throw r(_);
|
|
1417
|
-
}
|
|
1418
|
-
function P(s, h, l, m) {
|
|
1419
|
-
m = i(m);
|
|
1420
|
-
const _ = c(m[0]);
|
|
1421
|
-
if (_ !== "table") throw r(_);
|
|
1422
|
-
const A = s + f(l);
|
|
1423
|
-
let b = "";
|
|
1424
|
-
return m.forEach((N) => {
|
|
1425
|
-
b.length > 0 && (b += `
|
|
1426
|
-
`), b += h + "[[" + A + `]]
|
|
1427
|
-
`, b += n(A + ".", h, N);
|
|
1428
|
-
}), b;
|
|
1429
|
-
}
|
|
1430
|
-
function M(s, h, l, m) {
|
|
1431
|
-
const _ = s + f(l);
|
|
1432
|
-
let A = "";
|
|
1433
|
-
return a(m).length > 0 && (A += h + "[" + _ + `]
|
|
1434
|
-
`), A + n(_ + ".", h, m);
|
|
1435
|
-
}
|
|
1436
|
-
return stringify.exports;
|
|
1437
|
-
}
|
|
1438
|
-
var hasRequiredToml;
|
|
1439
|
-
function requireToml() {
|
|
1440
|
-
return hasRequiredToml || (hasRequiredToml = 1, toml.parse = requireParse(), toml.stringify = requireStringify()), toml;
|
|
1441
|
-
}
|
|
1442
|
-
var tomlExports = requireToml();
|
|
1443
|
-
const C = class C extends BasePlugin {
|
|
1444
|
-
constructor() {
|
|
1445
|
-
super(...arguments), this.name = "rust", this.displayName = "Rust", this.version = "3.1.0", this.priority = 80;
|
|
1446
|
-
}
|
|
1447
|
-
async detect(r) {
|
|
1448
|
-
if (!this.fileExists(r, "Cargo.toml"))
|
|
1449
|
-
return null;
|
|
1450
|
-
const a = this.readFile(r, "Cargo.toml");
|
|
1451
|
-
if (!a)
|
|
1452
|
-
return {
|
|
1453
|
-
language: "Rust",
|
|
1454
|
-
name: this.getProjectName(r),
|
|
1455
|
-
dependencies: {},
|
|
1456
|
-
manifestFile: "Cargo.toml",
|
|
1457
|
-
projectPath: r,
|
|
1458
|
-
tags: ["lang-rust"]
|
|
1459
|
-
};
|
|
1460
|
-
const e = this.parseManifest(a), i = e ? this.extractDependenciesFromManifest(e) : this.extractDependenciesFromText(a), n = this.extractWorkspaceMembers(e, a), o = await this.computeProjectTags(
|
|
1461
|
-
r,
|
|
1462
|
-
i,
|
|
1463
|
-
e,
|
|
1464
|
-
a
|
|
1465
|
-
);
|
|
1466
|
-
return {
|
|
1467
|
-
language: "Rust",
|
|
1468
|
-
name: e?.package?.name || this.extractNameFromContent(a) || this.getProjectName(r),
|
|
1469
|
-
description: e?.package?.description || this.extractDescriptionFromContent(a),
|
|
1470
|
-
dependencies: i,
|
|
1471
|
-
manifestFile: "Cargo.toml",
|
|
1472
|
-
projectPath: r,
|
|
1473
|
-
workspaceMembers: n.length > 0 ? n : void 0,
|
|
1474
|
-
tags: o.length > 0 ? o : void 0,
|
|
1475
|
-
keywords: e?.package?.keywords,
|
|
1476
|
-
categories: e?.package?.categories
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
getTemplates() {
|
|
1480
|
-
return [
|
|
1481
|
-
{
|
|
1482
|
-
name: "rust-core",
|
|
1483
|
-
tags: ["lang-rust"],
|
|
1484
|
-
content: `# Rust Development Guidelines
|
|
1485
|
-
|
|
1486
|
-
This project uses Rust.
|
|
1487
|
-
|
|
1488
|
-
## Project Structure
|
|
1489
|
-
- Follow Cargo conventions
|
|
1490
|
-
- Organize code with modules and crates
|
|
1491
|
-
- Prefer workspace members for shared libraries
|
|
1492
|
-
|
|
1493
|
-
## Tooling
|
|
1494
|
-
- Run \`cargo fmt\` and \`cargo clippy\` before committing
|
|
1495
|
-
- Enable \`deny(warnings)\` in CI for regression catch
|
|
1496
|
-
- Keep the MSRV documented in README or \`rust-toolchain.toml\`
|
|
1497
|
-
|
|
1498
|
-
## Safety & Ownership
|
|
1499
|
-
- Embrace ownership and borrowing to prevent data races
|
|
1500
|
-
- Minimize \`unsafe\` blocks and document why they're required
|
|
1501
|
-
- Handle \`Result\`/\`Option\` exhaustively with meaningful errors
|
|
1502
|
-
|
|
1503
|
-
## Testing
|
|
1504
|
-
- Cover critical code paths with unit tests in-module
|
|
1505
|
-
- Add integration tests under \`tests/\`
|
|
1506
|
-
- Use property tests or fuzzing for complex parsing logic
|
|
1507
|
-
|
|
1508
|
-
## Dependencies
|
|
1509
|
-
- Keep Cargo.lock committed for binaries
|
|
1510
|
-
- Audit crates with \`cargo audit\`
|
|
1511
|
-
- Prefer feature flags over forked crates when possible`
|
|
1512
|
-
},
|
|
1513
|
-
{
|
|
1514
|
-
name: "rust-embedded-core",
|
|
1515
|
-
tags: ["rust-embedded"],
|
|
1516
|
-
content: `# Embedded & Hardware Rust Guidelines
|
|
1517
|
-
|
|
1518
|
-
This project targets hardware/embedded environments.
|
|
1519
|
-
|
|
1520
|
-
## Build & Profiles
|
|
1521
|
-
- Define \`[profile.dev]\` / \`[profile.release]\` tweaks for probe-run
|
|
1522
|
-
- Track linker scripts such as \`memory.x\` inside version control
|
|
1523
|
-
- Pin the toolchain with \`rust-toolchain.toml\` to keep firmware reproducible
|
|
1524
|
-
|
|
1525
|
-
## Runtime Constraints
|
|
1526
|
-
- Prefer \`#![no_std]\` libraries and audit for heap allocations
|
|
1527
|
-
- Use \`heapless\` or ring buffers instead of Vec when RAM is limited
|
|
1528
|
-
- Tune interrupt priorities and minimize busy waits
|
|
1529
|
-
|
|
1530
|
-
## HAL & Drivers
|
|
1531
|
-
- Adhere to \`embedded-hal\` traits for portability
|
|
1532
|
-
- Isolate board support packages under \`boards/<target>\`
|
|
1533
|
-
- Document pin mappings and peripheral ownership
|
|
1534
|
-
|
|
1535
|
-
## Observability
|
|
1536
|
-
- Route logs through \`defmt\` or RTT instead of printf polling
|
|
1537
|
-
- Keep probe-run + probe-rs configs under \`.cargo/config.toml\`
|
|
1538
|
-
- Include instructions for flashing + debugging (UF2, JLink, etc.)
|
|
1539
|
-
|
|
1540
|
-
## Testing on Hardware
|
|
1541
|
-
- Maintain hardware-in-the-loop smoke tests
|
|
1542
|
-
- Provide mocks for driver crates to unblock CI
|
|
1543
|
-
- Capture oscilloscope/logic-analyzer traces for tricky regressions`
|
|
1544
|
-
},
|
|
1545
|
-
{
|
|
1546
|
-
name: "hardware2rust-profile",
|
|
1547
|
-
tags: ["hardware2rust"],
|
|
1548
|
-
content: `# hardware2rust Project Notes
|
|
1549
|
-
|
|
1550
|
-
These guidelines focus on packages aligned with the hardware2rust stack.
|
|
1551
|
-
|
|
1552
|
-
## Package Layout
|
|
1553
|
-
- Keep reusable primitives in \`crates/core\` and board-specific glue in \`crates/boards/<target>\`
|
|
1554
|
-
- Expose ergonomic builder APIs for configuring buses, clocks, and peripherals
|
|
1555
|
-
- Document supported targets (nRF, RP2040, ESP) in README badges
|
|
1556
|
-
|
|
1557
|
-
## Feature Flags
|
|
1558
|
-
- Mirror hardware variants with Cargo features (e.g. \`rtic\`, \`defmt\`, \`probe-run\`)
|
|
1559
|
-
- Ensure mutually exclusive features guard incompatible HAL implementations
|
|
1560
|
-
|
|
1561
|
-
## Developer Experience
|
|
1562
|
-
- Ship ready-to-flash examples under \`examples/\` (blinky, I2C scanner, sensor demos)
|
|
1563
|
-
- Provide VS Code + probe-rs launch.json snippets for teammates
|
|
1564
|
-
- Keep CI workflows building representative targets to catch regressions early`
|
|
1565
|
-
}
|
|
1566
|
-
];
|
|
1567
|
-
}
|
|
1568
|
-
getDependencyTagMap() {
|
|
1569
|
-
return {
|
|
1570
|
-
tokio: "rust-async",
|
|
1571
|
-
"actix-web": "rust-actix",
|
|
1572
|
-
rocket: "rust-rocket",
|
|
1573
|
-
serde: "serde",
|
|
1574
|
-
"embedded-hal": "rust-embedded",
|
|
1575
|
-
"embedded-hal-async": "rust-embedded",
|
|
1576
|
-
"cortex-m": "rust-embedded",
|
|
1577
|
-
"cortex-m-rt": "rust-embedded",
|
|
1578
|
-
"cortex-m-rtic": "rust-embedded",
|
|
1579
|
-
rtic: "rust-embedded",
|
|
1580
|
-
hardware2rust: "hardware2rust",
|
|
1581
|
-
"probe-run": "rust-embedded",
|
|
1582
|
-
"probe-rs": "rust-embedded",
|
|
1583
|
-
defmt: "rust-embedded",
|
|
1584
|
-
heapless: "rust-embedded",
|
|
1585
|
-
"rp2040-hal": "rust-embedded",
|
|
1586
|
-
"nrf52840-hal": "rust-embedded",
|
|
1587
|
-
"stm32f4xx-hal": "rust-embedded",
|
|
1588
|
-
"esp-idf-hal": "rust-embedded"
|
|
1589
|
-
};
|
|
1590
|
-
}
|
|
1591
|
-
parseManifest(r) {
|
|
1592
|
-
try {
|
|
1593
|
-
return tomlExports.parse(r);
|
|
1594
|
-
} catch {
|
|
1595
|
-
return null;
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
extractDependenciesFromManifest(r) {
|
|
1599
|
-
const a = {};
|
|
1600
|
-
if (this.collectDependencies(r.dependencies, a), this.collectDependencies(r["dev-dependencies"], a), this.collectDependencies(r["build-dependencies"], a), this.collectDependencies(r.workspace?.dependencies, a), r.target)
|
|
1601
|
-
for (const e of Object.values(r.target))
|
|
1602
|
-
e && (this.collectDependencies(e.dependencies, a), this.collectDependencies(e["dev-dependencies"], a), this.collectDependencies(e["build-dependencies"], a));
|
|
1603
|
-
return a;
|
|
1604
|
-
}
|
|
1605
|
-
collectDependencies(r, a) {
|
|
1606
|
-
if (r)
|
|
1607
|
-
for (const [e, i] of Object.entries(r))
|
|
1608
|
-
a[e] = this.normalizeDependencyVersion(i);
|
|
1609
|
-
}
|
|
1610
|
-
normalizeDependencyVersion(r) {
|
|
1611
|
-
if (typeof r == "string" || typeof r == "number")
|
|
1612
|
-
return String(r);
|
|
1613
|
-
if (typeof r == "boolean")
|
|
1614
|
-
return r ? "*" : "disabled";
|
|
1615
|
-
if (r && typeof r == "object") {
|
|
1616
|
-
const a = r, e = a.version;
|
|
1617
|
-
if (typeof e == "string")
|
|
1618
|
-
return e;
|
|
1619
|
-
const i = a.git;
|
|
1620
|
-
if (typeof i == "string") {
|
|
1621
|
-
const o = a.rev;
|
|
1622
|
-
return typeof o == "string" ? `git:${i}#${o}` : `git:${i}`;
|
|
1623
|
-
}
|
|
1624
|
-
const n = a.path;
|
|
1625
|
-
if (typeof n == "string")
|
|
1626
|
-
return `path:${n}`;
|
|
1627
|
-
}
|
|
1628
|
-
return "*";
|
|
1629
|
-
}
|
|
1630
|
-
extractWorkspaceMembers(r, a) {
|
|
1631
|
-
return r?.workspace?.members?.length ? r.workspace.members.map((e) => e.trim()).filter(Boolean) : this.fallbackWorkspaceMembers(a);
|
|
1632
|
-
}
|
|
1633
|
-
fallbackWorkspaceMembers(r) {
|
|
1634
|
-
const a = r.match(
|
|
1635
|
-
/\[workspace\][\s\S]*?members\s*=\s*\[([\s\S]*?)\]/
|
|
1636
|
-
);
|
|
1637
|
-
return a ? a[1].split(",").map((e) => e.trim().replace(/['"]/g, "")).filter(Boolean) : [];
|
|
1638
|
-
}
|
|
1639
|
-
extractDependenciesFromText(r) {
|
|
1640
|
-
const a = {}, e = [
|
|
1641
|
-
"dependencies",
|
|
1642
|
-
"dev-dependencies",
|
|
1643
|
-
"build-dependencies",
|
|
1644
|
-
"workspace.dependencies"
|
|
1645
|
-
];
|
|
1646
|
-
for (const i of e) {
|
|
1647
|
-
const n = this.extractSection(r, i);
|
|
1648
|
-
n && this.parseDependencyLines(n, a);
|
|
1649
|
-
}
|
|
1650
|
-
return a;
|
|
1651
|
-
}
|
|
1652
|
-
extractSection(r, a) {
|
|
1653
|
-
const e = a.replace(".", "\\."), n = new RegExp(`\\[${e}\\]([\\s\\S]*?)(?:\\n\\[|$)`, "i").exec(r);
|
|
1654
|
-
return n ? n[1] : null;
|
|
1655
|
-
}
|
|
1656
|
-
parseDependencyLines(r, a) {
|
|
1657
|
-
const e = r.split(`
|
|
1658
|
-
`);
|
|
1659
|
-
for (const i of e) {
|
|
1660
|
-
const n = i.trim();
|
|
1661
|
-
if (!n || n.startsWith("#"))
|
|
1662
|
-
continue;
|
|
1663
|
-
const o = n.match(/^([A-Za-z0-9_-]+)\s*=\s*(.+)$/);
|
|
1664
|
-
if (!o)
|
|
1665
|
-
continue;
|
|
1666
|
-
const [, c, f] = o, u = f.trim();
|
|
1667
|
-
if (u.startsWith("{")) {
|
|
1668
|
-
const d = u.match(/version\s*=\s*"([^"]+)"/), R = u.match(/git\s*=\s*"([^"]+)"/), g = u.match(/path\s*=\s*"([^"]+)"/);
|
|
1669
|
-
a[c] = d?.[1] || (R ? `git:${R}` : g ? `path:${g}` : "*");
|
|
1670
|
-
} else
|
|
1671
|
-
a[c] = u.replace(/"/g, "");
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
extractNameFromContent(r) {
|
|
1675
|
-
return r.match(/\[package\][\s\S]*?name\s*=\s*"([^"]+)"/)?.[1];
|
|
1676
|
-
}
|
|
1677
|
-
extractDescriptionFromContent(r) {
|
|
1678
|
-
return r.match(
|
|
1679
|
-
/\[package\][\s\S]*?description\s*=\s*"([^"]+)"/
|
|
1680
|
-
)?.[1];
|
|
1681
|
-
}
|
|
1682
|
-
async computeProjectTags(r, a, e, i) {
|
|
1683
|
-
const n = /* @__PURE__ */ new Set(["lang-rust"]), o = Object.keys(a).map((p) => p.toLowerCase()), c = o.some(
|
|
1684
|
-
(p) => C.EMBEDDED_DEPENDENCIES.has(p)
|
|
1685
|
-
), f = (e?.package?.keywords ?? []).map(
|
|
1686
|
-
(p) => p.toLowerCase()
|
|
1687
|
-
), u = (e?.package?.categories ?? []).map(
|
|
1688
|
-
(p) => p.toLowerCase()
|
|
1689
|
-
), d = f.some(
|
|
1690
|
-
(p) => C.EMBEDDED_KEYWORDS.has(p)
|
|
1691
|
-
), R = u.some(
|
|
1692
|
-
(p) => C.EMBEDDED_KEYWORDS.has(p)
|
|
1693
|
-
), g = C.MEMORY_LAYOUT_FILES.some(
|
|
1694
|
-
(p) => this.fileExists(r, p)
|
|
1695
|
-
), w = C.CARGO_CONFIG_FILES.some(
|
|
1696
|
-
(p) => this.fileExists(r, p)
|
|
1697
|
-
), x = e?.package?.name?.toLowerCase() ?? "", T = i.toLowerCase(), E = C.HARDWARE_NAME_HINTS.some(
|
|
1698
|
-
(p) => x.includes(p) || T.includes(p)
|
|
1699
|
-
), y = x.includes("hardware2rust") || o.some((p) => p.includes("hardware2rust"));
|
|
1700
|
-
return (c || d || R || g || w || E) && n.add("rust-embedded"), y && n.add("hardware2rust"), Array.from(n);
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
C.EMBEDDED_DEPENDENCIES = new Set(
|
|
1704
|
-
[
|
|
1705
|
-
"hardware2rust",
|
|
1706
|
-
"embedded-hal",
|
|
1707
|
-
"embedded-hal-async",
|
|
1708
|
-
"cortex-m",
|
|
1709
|
-
"cortex-m-rt",
|
|
1710
|
-
"cortex-m-rtic",
|
|
1711
|
-
"rtic",
|
|
1712
|
-
"nrf52840-hal",
|
|
1713
|
-
"atsamd-hal",
|
|
1714
|
-
"stm32f4xx-hal",
|
|
1715
|
-
"stm32h7xx-hal",
|
|
1716
|
-
"esp-idf-hal",
|
|
1717
|
-
"esp-hal",
|
|
1718
|
-
"rp2040-hal",
|
|
1719
|
-
"probe-run",
|
|
1720
|
-
"probe-rs",
|
|
1721
|
-
"defmt",
|
|
1722
|
-
"heapless",
|
|
1723
|
-
"microbit",
|
|
1724
|
-
"drone-core"
|
|
1725
|
-
].map((r) => r.toLowerCase())
|
|
1726
|
-
), C.EMBEDDED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1727
|
-
"embedded",
|
|
1728
|
-
"hardware",
|
|
1729
|
-
"no_std",
|
|
1730
|
-
"nostd",
|
|
1731
|
-
"microcontroller",
|
|
1732
|
-
"firmware",
|
|
1733
|
-
"hal",
|
|
1734
|
-
"baremetal",
|
|
1735
|
-
"bare-metal"
|
|
1736
|
-
]), C.HARDWARE_NAME_HINTS = [
|
|
1737
|
-
"hardware",
|
|
1738
|
-
"hardware2rust",
|
|
1739
|
-
"embedded"
|
|
1740
|
-
], C.CARGO_CONFIG_FILES = [
|
|
1741
|
-
".cargo/config",
|
|
1742
|
-
".cargo/config.toml"
|
|
1743
|
-
], C.MEMORY_LAYOUT_FILES = ["memory.x", "memory.x.in"];
|
|
1744
|
-
let RustPlugin = C;
|
|
1745
|
-
export {
|
|
1746
|
-
RustPlugin
|
|
1747
|
-
};
|
|
1748
|
-
//# sourceMappingURL=index-BkJhe5Af.js.map
|