tune-sdk 0.1.2 → 0.1.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/tune.js +550 -278
- package/dist/tune.mjs +41 -3
- package/package.json +1 -1
package/dist/tune.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $roles, fs, assert, util;
|
|
1
|
+
var $roles, fs, path, assert, util;
|
|
2
2
|
|
|
3
3
|
function extend() {
|
|
4
4
|
var _i;
|
|
@@ -74,28 +74,41 @@ var dJSON = (() => {
|
|
|
74
74
|
for (var u in r) N(e, u, {
|
|
75
75
|
get: r[u],
|
|
76
76
|
enumerable: !0
|
|
77
|
-
})
|
|
77
|
+
});
|
|
78
78
|
},
|
|
79
79
|
j = (e, r, u, t) => {
|
|
80
|
-
if (r && typeof r == "object" || typeof r == "function")
|
|
81
|
-
for (let i of xe(r))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
if ((r && typeof r == "object") || typeof r == "function")
|
|
81
|
+
for (let i of xe(r))
|
|
82
|
+
!ge.call(e, i) &&
|
|
83
|
+
i !== u &&
|
|
84
|
+
N(e, i, {
|
|
85
|
+
get: () => r[i],
|
|
86
|
+
enumerable: !(t = ye(r, i)) || t.enumerable,
|
|
87
|
+
});
|
|
88
|
+
return e;
|
|
86
89
|
},
|
|
87
90
|
U = (e, r, u) => (j(e, r, "default"), u && j(u, r, "default")),
|
|
88
|
-
H = (e, r, u) => (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
H = (e, r, u) => (
|
|
92
|
+
(u = e != null ? de(Ee(e)) : {}),
|
|
93
|
+
j(
|
|
94
|
+
r || !e || !e.__esModule ?
|
|
95
|
+
N(u, "default", {
|
|
96
|
+
value: e,
|
|
97
|
+
enumerable: !0
|
|
98
|
+
}) :
|
|
99
|
+
u,
|
|
100
|
+
e,
|
|
101
|
+
)
|
|
102
|
+
),
|
|
103
|
+
Fe = (e) => j(N({}, "__esModule", {
|
|
93
104
|
value: !0
|
|
94
105
|
}), e);
|
|
95
106
|
var P = c((We, D) => {
|
|
96
107
|
typeof D == "object" && typeof D.exports == "object" && (D.exports = Y);
|
|
97
108
|
Y.defunct = function(e) {
|
|
98
|
-
throw new Error(
|
|
109
|
+
throw new Error(
|
|
110
|
+
"Unexpected character at index " + (this.index - 1) + ": " + e,
|
|
111
|
+
);
|
|
99
112
|
};
|
|
100
113
|
|
|
101
114
|
function Y(e) {
|
|
@@ -103,55 +116,88 @@ var dJSON = (() => {
|
|
|
103
116
|
var r = [],
|
|
104
117
|
u = [],
|
|
105
118
|
t = 0;
|
|
106
|
-
this.state = 0,
|
|
119
|
+
(this.state = 0),
|
|
120
|
+
(this.index = 0),
|
|
121
|
+
(this.input = ""),
|
|
122
|
+
(this.addRule = function(n, v, x) {
|
|
107
123
|
var y = n.global;
|
|
108
124
|
if (!y) {
|
|
109
125
|
var E = "g";
|
|
110
|
-
n.multiline && (E += "m"),
|
|
126
|
+
n.multiline && (E += "m"),
|
|
127
|
+
n.ignoreCase && (E += "i"),
|
|
128
|
+
(n = new RegExp(n.source, E));
|
|
111
129
|
}
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
return (
|
|
131
|
+
Object.prototype.toString.call(x) !== "[object Array]" && (x = [0]),
|
|
132
|
+
u.push({
|
|
133
|
+
pattern: n,
|
|
134
|
+
global: y,
|
|
135
|
+
action: v,
|
|
136
|
+
start: x
|
|
137
|
+
}),
|
|
138
|
+
this
|
|
139
|
+
);
|
|
140
|
+
}),
|
|
141
|
+
(this.setInput = function(n) {
|
|
142
|
+
return (
|
|
143
|
+
(t = 0),
|
|
144
|
+
(this.state = 0),
|
|
145
|
+
(this.index = 0),
|
|
146
|
+
(r.length = 0),
|
|
147
|
+
(this.input = n),
|
|
148
|
+
this
|
|
149
|
+
);
|
|
150
|
+
}),
|
|
151
|
+
(this.lex = function() {
|
|
121
152
|
if (r.length) return r.shift();
|
|
122
153
|
for (this.reject = !0; this.index <= this.input.length;) {
|
|
123
|
-
for (
|
|
154
|
+
for (
|
|
155
|
+
var n = i.call(this).splice(t), v = this.index; n.length && this.reject;
|
|
156
|
+
|
|
157
|
+
) {
|
|
124
158
|
var x = n.shift(),
|
|
125
159
|
y = x.result,
|
|
126
160
|
E = x.length;
|
|
127
|
-
this.index += E, this.reject = !1, t++;
|
|
161
|
+
(this.index += E), (this.reject = !1), t++;
|
|
128
162
|
var f = x.action.apply(this, y);
|
|
129
163
|
if (this.reject) this.index = y.index;
|
|
130
|
-
else if (typeof f < "u")
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
164
|
+
else if (typeof f < "u")
|
|
165
|
+
switch (Object.prototype.toString.call(f)) {
|
|
166
|
+
case "[object Array]":
|
|
167
|
+
(r = f.slice(1)), (f = f[0]);
|
|
168
|
+
default:
|
|
169
|
+
return E && (t = 0), f;
|
|
170
|
+
}
|
|
136
171
|
}
|
|
137
172
|
var F = this.input;
|
|
138
173
|
if (v < F.length)
|
|
139
174
|
if (this.reject) {
|
|
140
175
|
t = 0;
|
|
141
176
|
var f = e.call(this, F.charAt(this.index++));
|
|
142
|
-
if (typeof f < "u")
|
|
143
|
-
|
|
177
|
+
if (typeof f < "u")
|
|
178
|
+
return Object.prototype.toString.call(f) === "[object Array]" ?
|
|
179
|
+
((r = f.slice(1)), f[0]) :
|
|
180
|
+
f;
|
|
181
|
+
} else this.index !== v && (t = 0), (this.reject = !0);
|
|
144
182
|
else if (n.length) this.reject = !0;
|
|
145
|
-
else break
|
|
183
|
+
else break;
|
|
146
184
|
}
|
|
147
|
-
};
|
|
185
|
+
});
|
|
148
186
|
|
|
149
187
|
function i() {
|
|
150
|
-
for (
|
|
188
|
+
for (
|
|
189
|
+
var n = [],
|
|
190
|
+
v = 0,
|
|
191
|
+
x = this.state,
|
|
192
|
+
y = this.index,
|
|
193
|
+
E = this.input,
|
|
194
|
+
f = 0,
|
|
195
|
+
F = u.length; f < F; f++
|
|
196
|
+
) {
|
|
151
197
|
var h = u[f],
|
|
152
198
|
T = h.start,
|
|
153
199
|
p = T.length;
|
|
154
|
-
if (!p || T.indexOf(x) >= 0 || x % 2 && p === 1 && !T[0]) {
|
|
200
|
+
if (!p || T.indexOf(x) >= 0 || (x % 2 && p === 1 && !T[0])) {
|
|
155
201
|
var o = h.pattern;
|
|
156
202
|
o.lastIndex = y;
|
|
157
203
|
var s = o.exec(E);
|
|
@@ -159,53 +205,67 @@ var dJSON = (() => {
|
|
|
159
205
|
var d = n.push({
|
|
160
206
|
result: s,
|
|
161
207
|
action: h.action,
|
|
162
|
-
length: s[0].length
|
|
208
|
+
length: s[0].length,
|
|
163
209
|
});
|
|
164
210
|
for (h.global && (v = d); --d > v;) {
|
|
165
211
|
var a = d - 1;
|
|
166
212
|
if (n[d].length > n[a].length) {
|
|
167
213
|
var _ = n[d];
|
|
168
|
-
n[d] = n[a], n[a] = _
|
|
214
|
+
(n[d] = n[a]), (n[a] = _);
|
|
169
215
|
}
|
|
170
216
|
}
|
|
171
217
|
}
|
|
172
218
|
}
|
|
173
219
|
}
|
|
174
|
-
return n
|
|
220
|
+
return n;
|
|
175
221
|
}
|
|
176
222
|
}
|
|
177
223
|
});
|
|
178
224
|
var k = c(() => {
|
|
179
|
-
String.fromCodePoint ||
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (!
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
225
|
+
String.fromCodePoint ||
|
|
226
|
+
(function() {
|
|
227
|
+
var e = (function() {
|
|
228
|
+
try {
|
|
229
|
+
var i = {},
|
|
230
|
+
n = Object.defineProperty,
|
|
231
|
+
v = n(i, i, i) && n;
|
|
232
|
+
} catch {}
|
|
233
|
+
return v;
|
|
234
|
+
})(),
|
|
235
|
+
r = String.fromCharCode,
|
|
236
|
+
u = Math.floor,
|
|
237
|
+
t = function(i) {
|
|
238
|
+
var n = 16384,
|
|
239
|
+
v = [],
|
|
240
|
+
x,
|
|
241
|
+
y,
|
|
242
|
+
E = -1,
|
|
243
|
+
f = arguments.length;
|
|
244
|
+
if (!f) return "";
|
|
245
|
+
for (var F = ""; ++E < f;) {
|
|
246
|
+
var h = Number(arguments[E]);
|
|
247
|
+
if (!isFinite(h) || h < 0 || h > 1114111 || u(h) != h)
|
|
248
|
+
throw RangeError("Invalid code point: " + h);
|
|
249
|
+
h <= 65535 ?
|
|
250
|
+
v.push(h) :
|
|
251
|
+
((h -= 65536),
|
|
252
|
+
(x = (h >> 10) + 55296),
|
|
253
|
+
(y = (h % 1024) + 56320),
|
|
254
|
+
v.push(x, y)),
|
|
255
|
+
(E + 1 == f || v.length > n) &&
|
|
256
|
+
((F += r.apply(null, v)), (v.length = 0));
|
|
257
|
+
}
|
|
258
|
+
return F;
|
|
259
|
+
};
|
|
260
|
+
e
|
|
261
|
+
?
|
|
262
|
+
e(String, "fromCodePoint", {
|
|
263
|
+
value: t,
|
|
264
|
+
configurable: !0,
|
|
265
|
+
writable: !0,
|
|
266
|
+
}) :
|
|
267
|
+
(String.fromCodePoint = t);
|
|
268
|
+
})();
|
|
209
269
|
});
|
|
210
270
|
var re = c((V, ee) => {
|
|
211
271
|
"use strict";
|
|
@@ -214,7 +274,8 @@ var dJSON = (() => {
|
|
|
214
274
|
});
|
|
215
275
|
V.default = void 0;
|
|
216
276
|
k();
|
|
217
|
-
var Le =
|
|
277
|
+
var Le =
|
|
278
|
+
/\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\\U([0-9A-Fa-f]{8})/g,
|
|
218
279
|
Re = {
|
|
219
280
|
0: "\0",
|
|
220
281
|
b: "\b",
|
|
@@ -226,88 +287,142 @@ var dJSON = (() => {
|
|
|
226
287
|
v: "\v",
|
|
227
288
|
"'": "'",
|
|
228
289
|
'"': '"',
|
|
229
|
-
"\\": "\\"
|
|
290
|
+
"\\": "\\",
|
|
230
291
|
},
|
|
231
292
|
K = function(r) {
|
|
232
|
-
return String.fromCodePoint(parseInt(r, 16))
|
|
293
|
+
return String.fromCodePoint(parseInt(r, 16));
|
|
233
294
|
},
|
|
234
295
|
we = function(r) {
|
|
235
|
-
return String.fromCodePoint(parseInt(r, 8))
|
|
296
|
+
return String.fromCodePoint(parseInt(r, 8));
|
|
236
297
|
},
|
|
237
298
|
_e = function(r) {
|
|
238
299
|
return r.replace(Le, function(u, t, i, n, v, x, y, E) {
|
|
239
|
-
return i !== void 0 ?
|
|
240
|
-
|
|
300
|
+
return i !== void 0 ?
|
|
301
|
+
K(i) :
|
|
302
|
+
n !== void 0 ?
|
|
303
|
+
K(n) :
|
|
304
|
+
v !== void 0 ?
|
|
305
|
+
K(v) :
|
|
306
|
+
x !== void 0 ?
|
|
307
|
+
we(x) :
|
|
308
|
+
E !== void 0 ?
|
|
309
|
+
K(E) :
|
|
310
|
+
Re[y];
|
|
311
|
+
});
|
|
241
312
|
};
|
|
242
313
|
V.default = _e;
|
|
243
|
-
ee.exports = V.default
|
|
314
|
+
ee.exports = V.default;
|
|
244
315
|
});
|
|
245
|
-
var ue = c(J => {
|
|
316
|
+
var ue = c((J) => {
|
|
246
317
|
(function(e) {
|
|
247
318
|
var r = String.fromCharCode;
|
|
248
319
|
|
|
249
320
|
function u(p) {
|
|
250
|
-
for (var o = [], s = 0, d = p.length, a, _; s < d;)
|
|
251
|
-
|
|
321
|
+
for (var o = [], s = 0, d = p.length, a, _; s < d;)
|
|
322
|
+
(a = p.charCodeAt(s++)),
|
|
323
|
+
a >= 55296 && a <= 56319 && s < d ?
|
|
324
|
+
((_ = p.charCodeAt(s++)),
|
|
325
|
+
(_ & 64512) == 56320 ?
|
|
326
|
+
o.push(((a & 1023) << 10) + (_ & 1023) + 65536) :
|
|
327
|
+
(o.push(a), s--)) :
|
|
328
|
+
o.push(a);
|
|
329
|
+
return o;
|
|
252
330
|
}
|
|
253
331
|
|
|
254
332
|
function t(p) {
|
|
255
|
-
for (var o = p.length, s = -1, d, a = ""; ++s < o;)
|
|
256
|
-
|
|
333
|
+
for (var o = p.length, s = -1, d, a = ""; ++s < o;)
|
|
334
|
+
(d = p[s]),
|
|
335
|
+
d > 65535 &&
|
|
336
|
+
((d -= 65536),
|
|
337
|
+
(a += r(((d >>> 10) & 1023) | 55296)),
|
|
338
|
+
(d = 56320 | (d & 1023))),
|
|
339
|
+
(a += r(d));
|
|
340
|
+
return a;
|
|
257
341
|
}
|
|
258
342
|
|
|
259
343
|
function i(p) {
|
|
260
|
-
if (p >= 55296 && p <= 57343)
|
|
344
|
+
if (p >= 55296 && p <= 57343)
|
|
345
|
+
throw Error(
|
|
346
|
+
"Lone surrogate U+" +
|
|
347
|
+
p.toString(16).toUpperCase() +
|
|
348
|
+
" is not a scalar value",
|
|
349
|
+
);
|
|
261
350
|
}
|
|
262
351
|
|
|
263
352
|
function n(p, o) {
|
|
264
|
-
return r(p >> o & 63 | 128)
|
|
353
|
+
return r(((p >> o) & 63) | 128);
|
|
265
354
|
}
|
|
266
355
|
|
|
267
356
|
function v(p) {
|
|
268
357
|
if (!(p & 4294967168)) return r(p);
|
|
269
358
|
var o = "";
|
|
270
|
-
return
|
|
359
|
+
return (
|
|
360
|
+
p & 4294965248 ?
|
|
361
|
+
p & 4294901760 ?
|
|
362
|
+
p & 4292870144 ||
|
|
363
|
+
((o = r(((p >> 18) & 7) | 240)),
|
|
364
|
+
(o += n(p, 12)),
|
|
365
|
+
(o += n(p, 6))) :
|
|
366
|
+
(i(p), (o = r(((p >> 12) & 15) | 224)), (o += n(p, 6))) :
|
|
367
|
+
(o = r(((p >> 6) & 31) | 192)),
|
|
368
|
+
(o += r((p & 63) | 128)),
|
|
369
|
+
o
|
|
370
|
+
);
|
|
271
371
|
}
|
|
272
372
|
|
|
273
373
|
function x(p) {
|
|
274
|
-
for (var o = u(p), s = o.length, d = -1, a, _ = ""; ++d < s;)
|
|
275
|
-
|
|
374
|
+
for (var o = u(p), s = o.length, d = -1, a, _ = ""; ++d < s;)
|
|
375
|
+
(a = o[d]), (_ += v(a));
|
|
376
|
+
return _;
|
|
276
377
|
}
|
|
277
378
|
|
|
278
379
|
function y() {
|
|
279
380
|
if (h >= F) throw Error("Invalid byte index");
|
|
280
381
|
var p = f[h] & 255;
|
|
281
|
-
if (h++, (p & 192) == 128) return p & 63;
|
|
282
|
-
throw Error("Invalid continuation byte")
|
|
382
|
+
if ((h++, (p & 192) == 128)) return p & 63;
|
|
383
|
+
throw Error("Invalid continuation byte");
|
|
283
384
|
}
|
|
284
385
|
|
|
285
386
|
function E() {
|
|
286
387
|
var p, o, s, d, a;
|
|
287
388
|
if (h > F) throw Error("Invalid byte index");
|
|
288
389
|
if (h == F) return !1;
|
|
289
|
-
if (p = f[h] & 255, h++, !(p & 128)) return p;
|
|
390
|
+
if (((p = f[h] & 255), h++, !(p & 128))) return p;
|
|
290
391
|
if ((p & 224) == 192) {
|
|
291
|
-
if (o = y(), a = (p & 31) << 6 | o, a >= 128) return a;
|
|
292
|
-
throw Error("Invalid continuation byte")
|
|
392
|
+
if (((o = y()), (a = ((p & 31) << 6) | o), a >= 128)) return a;
|
|
393
|
+
throw Error("Invalid continuation byte");
|
|
293
394
|
}
|
|
294
395
|
if ((p & 240) == 224) {
|
|
295
|
-
if (
|
|
296
|
-
|
|
396
|
+
if (
|
|
397
|
+
((o = y()),
|
|
398
|
+
(s = y()),
|
|
399
|
+
(a = ((p & 15) << 12) | (o << 6) | s),
|
|
400
|
+
a >= 2048)
|
|
401
|
+
)
|
|
402
|
+
return i(a), a;
|
|
403
|
+
throw Error("Invalid continuation byte");
|
|
297
404
|
}
|
|
298
|
-
if (
|
|
299
|
-
|
|
405
|
+
if (
|
|
406
|
+
(p & 248) == 240 &&
|
|
407
|
+
((o = y()),
|
|
408
|
+
(s = y()),
|
|
409
|
+
(d = y()),
|
|
410
|
+
(a = ((p & 7) << 18) | (o << 12) | (s << 6) | d),
|
|
411
|
+
a >= 65536 && a <= 1114111)
|
|
412
|
+
)
|
|
413
|
+
return a;
|
|
414
|
+
throw Error("Invalid UTF-8 detected");
|
|
300
415
|
}
|
|
301
416
|
var f, F, h;
|
|
302
417
|
|
|
303
418
|
function T(p) {
|
|
304
|
-
f = u(p), F = f.length, h = 0;
|
|
419
|
+
(f = u(p)), (F = f.length), (h = 0);
|
|
305
420
|
for (var o = [], s;
|
|
306
421
|
(s = E()) !== !1;) o.push(s);
|
|
307
|
-
return t(o)
|
|
422
|
+
return t(o);
|
|
308
423
|
}
|
|
309
|
-
e.version = "3.0.0", e.encode = x, e.decode = T
|
|
310
|
-
})(typeof J > "u" ? J.utf8 = {} : J)
|
|
424
|
+
(e.version = "3.0.0"), (e.encode = x), (e.decode = T);
|
|
425
|
+
})(typeof J > "u" ? (J.utf8 = {}) : J);
|
|
311
426
|
});
|
|
312
427
|
var pe = c((Pe, G) => {
|
|
313
428
|
"use strict";
|
|
@@ -332,75 +447,124 @@ var dJSON = (() => {
|
|
|
332
447
|
[/\s*}\s*/, Oe],
|
|
333
448
|
[/\s*\[\s*/, Ve],
|
|
334
449
|
[/\s*\]\s*/, Xe],
|
|
335
|
-
[/\s*\.\s*/, Be]
|
|
450
|
+
[/\s*\.\s*/, Be],
|
|
336
451
|
];
|
|
337
452
|
|
|
338
453
|
function ne(e) {
|
|
339
|
-
return e = e.replace(/\\\//, "/"), Se(e)
|
|
454
|
+
return (e = e.replace(/\\\//, "/")), Se(e);
|
|
340
455
|
}
|
|
341
456
|
|
|
342
457
|
function Ne(e) {
|
|
343
|
-
let r = new Ce,
|
|
458
|
+
let r = new Ce(),
|
|
344
459
|
u = 0,
|
|
345
460
|
t = 0;
|
|
346
|
-
return
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
461
|
+
return (
|
|
462
|
+
r.addRule(
|
|
463
|
+
/"((?:\\.|[^"])*?)($|")/,
|
|
464
|
+
(i, n) => (
|
|
465
|
+
(u += i.length), {
|
|
466
|
+
type: le,
|
|
467
|
+
value: ne(n),
|
|
468
|
+
row: t,
|
|
469
|
+
col: u,
|
|
470
|
+
single: !1
|
|
471
|
+
}
|
|
472
|
+
),
|
|
473
|
+
),
|
|
474
|
+
r.addRule(
|
|
475
|
+
/'((?:\\.|[^'])*?)($|'|(",?[ \t]*\n))/,
|
|
476
|
+
(i, n) => (
|
|
477
|
+
(u += i.length), {
|
|
478
|
+
type: le,
|
|
479
|
+
value: ne(n),
|
|
480
|
+
row: t,
|
|
481
|
+
col: u,
|
|
482
|
+
single: !0
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
),
|
|
486
|
+
r.addRule(
|
|
487
|
+
/[\-0-9]*\.[0-9]*([eE][\+\-]?)?[0-9]*(?:\s*)/,
|
|
488
|
+
(i) => (
|
|
489
|
+
(u += i.length), {
|
|
490
|
+
type: te,
|
|
491
|
+
value: parseFloat(i),
|
|
492
|
+
row: t,
|
|
493
|
+
col: u
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
),
|
|
497
|
+
r.addRule(
|
|
498
|
+
/\-?[0-9]+([eE][\+\-]?)[0-9]*(?:\s*)/,
|
|
499
|
+
(i) => (
|
|
500
|
+
(u += i.length), {
|
|
501
|
+
type: te,
|
|
502
|
+
value: parseFloat(i),
|
|
503
|
+
row: t,
|
|
504
|
+
col: u
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
),
|
|
508
|
+
r.addRule(
|
|
509
|
+
/\-?[0-9]+(?:\s*)/,
|
|
510
|
+
(i) => (
|
|
511
|
+
(u += i.length), {
|
|
512
|
+
type: ce,
|
|
513
|
+
value: parseInt(i),
|
|
514
|
+
row: t,
|
|
515
|
+
col: u
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
),
|
|
519
|
+
je.forEach((i) => {
|
|
520
|
+
r.addRule(
|
|
521
|
+
i[0],
|
|
522
|
+
(n) => ((u += n.length), {
|
|
523
|
+
type: i[1],
|
|
524
|
+
value: n,
|
|
525
|
+
row: t,
|
|
526
|
+
col: u
|
|
527
|
+
}),
|
|
528
|
+
);
|
|
529
|
+
}),
|
|
530
|
+
r.addRule(/\s/, (i) => {
|
|
531
|
+
i ==
|
|
532
|
+
`
|
|
533
|
+
` ?
|
|
534
|
+
((u = 0), t++) :
|
|
535
|
+
(u += i.length);
|
|
536
|
+
}),
|
|
537
|
+
r.addRule(
|
|
538
|
+
/\S[ \t]*/,
|
|
539
|
+
(i) => ((u += i.length), {
|
|
540
|
+
type: me,
|
|
541
|
+
value: i,
|
|
542
|
+
row: t,
|
|
543
|
+
col: u
|
|
544
|
+
}),
|
|
545
|
+
),
|
|
546
|
+
r.setInput(e),
|
|
547
|
+
r
|
|
548
|
+
);
|
|
389
549
|
}
|
|
390
550
|
G.exports.lexString = ie;
|
|
391
551
|
|
|
392
552
|
function ie(e, r) {
|
|
393
553
|
let u = Ne(e),
|
|
394
554
|
t = "";
|
|
395
|
-
for (;
|
|
555
|
+
for (;
|
|
556
|
+
(t = u.lex());) r(t);
|
|
396
557
|
}
|
|
397
558
|
G.exports.getAllTokens = Ue;
|
|
398
559
|
|
|
399
560
|
function Ue(e) {
|
|
400
561
|
let r = [];
|
|
401
|
-
return
|
|
402
|
-
|
|
403
|
-
|
|
562
|
+
return (
|
|
563
|
+
ie(e, function(t) {
|
|
564
|
+
r.push(t);
|
|
565
|
+
}),
|
|
566
|
+
r
|
|
567
|
+
);
|
|
404
568
|
}
|
|
405
569
|
});
|
|
406
570
|
var he = c((ke, fe) => {
|
|
@@ -428,21 +592,24 @@ var dJSON = (() => {
|
|
|
428
592
|
O = -4;
|
|
429
593
|
|
|
430
594
|
function ae(e) {
|
|
431
|
-
e.peek == null &&
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
595
|
+
e.peek == null &&
|
|
596
|
+
Object.defineProperty(e, "peek", {
|
|
597
|
+
enumerable: !1,
|
|
598
|
+
value: function() {
|
|
599
|
+
return this[this.length - 1];
|
|
600
|
+
},
|
|
601
|
+
}),
|
|
602
|
+
e.last == null &&
|
|
603
|
+
Object.defineProperty(e, "last", {
|
|
604
|
+
enumerable: !1,
|
|
605
|
+
value: function(r) {
|
|
606
|
+
return this[this.length - (1 + r)];
|
|
607
|
+
},
|
|
608
|
+
});
|
|
442
609
|
}
|
|
443
610
|
|
|
444
611
|
function l(e, r) {
|
|
445
|
-
return e && e.hasOwnProperty("type") && e.type == r
|
|
612
|
+
return e && e.hasOwnProperty("type") && e.type == r;
|
|
446
613
|
}
|
|
447
614
|
fe.exports.parse = qe;
|
|
448
615
|
|
|
@@ -451,83 +618,121 @@ var dJSON = (() => {
|
|
|
451
618
|
t = [];
|
|
452
619
|
ae(u), ae(t);
|
|
453
620
|
let i = function(n) {
|
|
454
|
-
t.push(n)
|
|
621
|
+
t.push(n);
|
|
455
622
|
};
|
|
456
|
-
De.lexString(e, i),
|
|
457
|
-
type
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
623
|
+
De.lexString(e, i),
|
|
624
|
+
t[0].type == O &&
|
|
625
|
+
t.last(0).type != A &&
|
|
626
|
+
t.push({
|
|
627
|
+
type: A,
|
|
628
|
+
value: "]",
|
|
629
|
+
row: -1,
|
|
630
|
+
col: -1
|
|
631
|
+
}),
|
|
632
|
+
t[0].type == $ &&
|
|
633
|
+
t.last(0).type != I &&
|
|
634
|
+
t.push({
|
|
635
|
+
type: I,
|
|
636
|
+
value: "}",
|
|
637
|
+
row: -1,
|
|
638
|
+
col: -1
|
|
639
|
+
});
|
|
467
640
|
for (let n = 0; n < t.length; n++)
|
|
468
641
|
for ("" + t[n].type, u.push(t[n]); w(u););
|
|
469
|
-
return
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
642
|
+
return (
|
|
643
|
+
u.length == 1 &&
|
|
644
|
+
u[0].type == X &&
|
|
645
|
+
(u = [{
|
|
646
|
+
type: S,
|
|
647
|
+
value: u[0].value
|
|
648
|
+
}]),
|
|
649
|
+
Q(u[0], r)
|
|
650
|
+
);
|
|
473
651
|
}
|
|
474
652
|
|
|
475
653
|
function w(e) {
|
|
476
654
|
let r = e.pop();
|
|
477
655
|
switch (r.type) {
|
|
478
656
|
case b:
|
|
479
|
-
if (r.value.trim() == "true")
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
657
|
+
if (r.value.trim() == "true")
|
|
658
|
+
return e.push({
|
|
659
|
+
type: Z,
|
|
660
|
+
value: "true"
|
|
661
|
+
}), !0;
|
|
662
|
+
if (r.value.trim() == "false")
|
|
663
|
+
return e.push({
|
|
664
|
+
type: Z,
|
|
665
|
+
value: "false"
|
|
666
|
+
}), !0;
|
|
667
|
+
if (r.value.trim() == "null")
|
|
668
|
+
return e.push({
|
|
669
|
+
type: g,
|
|
670
|
+
value: null
|
|
671
|
+
}), !0;
|
|
491
672
|
break;
|
|
492
673
|
case Me:
|
|
493
|
-
return l(e.peek(), b) ?
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
674
|
+
return l(e.peek(), b) ?
|
|
675
|
+
((e.peek().value += r.value), !0) :
|
|
676
|
+
(e.push({
|
|
677
|
+
type: b,
|
|
678
|
+
value: r.value
|
|
679
|
+
}), !0);
|
|
497
680
|
case oe:
|
|
498
|
-
return l(r, oe) && l(e.peek(), b) ?
|
|
681
|
+
return l(r, oe) && l(e.peek(), b) ?
|
|
682
|
+
((e.peek().value += r.value), !0) :
|
|
683
|
+
((r.type = g), e.push(r), !0);
|
|
499
684
|
case Je:
|
|
500
|
-
return r.type = g, r.value = r.value, e.push(r), !0;
|
|
685
|
+
return (r.type = g), (r.value = r.value), e.push(r), !0;
|
|
501
686
|
case Z:
|
|
502
|
-
return
|
|
687
|
+
return (
|
|
688
|
+
(r.type = g),
|
|
689
|
+
r.value == "true" ? (r.value = !0) : (r.value = !1),
|
|
690
|
+
e.push(r),
|
|
691
|
+
!0
|
|
692
|
+
);
|
|
503
693
|
case Ke:
|
|
504
|
-
return r.type = g, e.push(r), !0;
|
|
694
|
+
return (r.type = g), e.push(r), !0;
|
|
505
695
|
case g:
|
|
506
|
-
if (l(e.peek(), L)) return r.type = q, e.pop(), e.push(r), !0;
|
|
507
|
-
if (l(e.peek(), m)) return r.type = M, e.pop(), e.push(r), !0;
|
|
696
|
+
if (l(e.peek(), L)) return (r.type = q), e.pop(), e.push(r), !0;
|
|
697
|
+
if (l(e.peek(), m)) return (r.type = M), e.pop(), e.push(r), !0;
|
|
508
698
|
if (l(e.peek(), b) && l(e.last(1), g)) {
|
|
509
699
|
let u = e.pop();
|
|
510
|
-
return
|
|
700
|
+
return (
|
|
701
|
+
(e.peek().value += '"' + u.value + '"'),
|
|
702
|
+
(e.peek().value += r.value),
|
|
703
|
+
!0
|
|
704
|
+
);
|
|
511
705
|
}
|
|
512
706
|
if (l(e.peek(), b) && l(e.last(1), C)) {
|
|
513
707
|
let u = e.pop(),
|
|
514
708
|
t = e.peek().value.pop();
|
|
515
|
-
return
|
|
709
|
+
return (
|
|
710
|
+
(t += '"' + u.value + '"'),
|
|
711
|
+
(t += r.value),
|
|
712
|
+
e.peek().value.push(t),
|
|
713
|
+
!0
|
|
714
|
+
);
|
|
516
715
|
}
|
|
517
716
|
if (l(e.peek(), b) && l(e.last(1), X)) {
|
|
518
717
|
let u = e.pop(),
|
|
519
718
|
t = e.peek().value.pop(),
|
|
520
719
|
i = r.single ? "'" : '"';
|
|
521
|
-
return
|
|
720
|
+
return (
|
|
721
|
+
(t.value += i + u.value + i),
|
|
722
|
+
(t.value += r.value),
|
|
723
|
+
e.peek().value.push(t),
|
|
724
|
+
!0
|
|
725
|
+
);
|
|
522
726
|
}
|
|
523
727
|
if (l(e.peek(), b)) {
|
|
524
728
|
let u = e.pop().value;
|
|
525
|
-
return r.value = u + r.value, e.push(r), !0
|
|
729
|
+
return (r.value = u + r.value), e.push(r), !0;
|
|
526
730
|
}
|
|
527
731
|
break;
|
|
528
732
|
case R:
|
|
529
|
-
if (l(r, R) && l(e.peek(), L))
|
|
530
|
-
|
|
733
|
+
if (l(r, R) && l(e.peek(), L))
|
|
734
|
+
return (r.type = q), e.pop(), e.push(r), !0;
|
|
735
|
+
if (l(e.peek(), m)) return (r.type = M), e.pop(), e.push(r), !0;
|
|
531
736
|
break;
|
|
532
737
|
case S:
|
|
533
738
|
if (l(e.peek(), L)) {
|
|
@@ -535,14 +740,14 @@ var dJSON = (() => {
|
|
|
535
740
|
type: q,
|
|
536
741
|
value: r
|
|
537
742
|
};
|
|
538
|
-
return e.pop(), e.push(u), !0
|
|
743
|
+
return e.pop(), e.push(u), !0;
|
|
539
744
|
}
|
|
540
745
|
if (l(e.peek(), m)) {
|
|
541
746
|
let u = {
|
|
542
747
|
type: M,
|
|
543
748
|
value: r
|
|
544
749
|
};
|
|
545
|
-
return e.pop(), e.push(u), !0
|
|
750
|
+
return e.pop(), e.push(u), !0;
|
|
546
751
|
}
|
|
547
752
|
if (l(e.peek(), b)) {
|
|
548
753
|
let u = e.pop();
|
|
@@ -550,25 +755,30 @@ var dJSON = (() => {
|
|
|
550
755
|
type: W,
|
|
551
756
|
key: u.value.trim(),
|
|
552
757
|
value: r
|
|
553
|
-
}), !0
|
|
758
|
+
}), !0;
|
|
554
759
|
}
|
|
555
760
|
break;
|
|
556
761
|
case q:
|
|
557
|
-
return l(e.peek(), C) ?
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
762
|
+
return l(e.peek(), C) ?
|
|
763
|
+
(e.peek().value.push(r.value), !0) :
|
|
764
|
+
(e.push({
|
|
765
|
+
type: C,
|
|
766
|
+
value: [r.value]
|
|
767
|
+
}), !0);
|
|
561
768
|
case C:
|
|
562
|
-
if (l(e.peek(), g))
|
|
563
|
-
|
|
564
|
-
if (l(e.peek(),
|
|
769
|
+
if (l(e.peek(), g))
|
|
770
|
+
return r.value.unshift(e.peek().value), e.pop(), e.push(r), !0;
|
|
771
|
+
if (l(e.peek(), R))
|
|
772
|
+
return r.value.unshift(e.peek().value), e.pop(), e.push(r), !0;
|
|
773
|
+
if (l(e.peek(), S))
|
|
774
|
+
return r.value.unshift(e.peek()), e.pop(), e.push(r), !0;
|
|
565
775
|
if (l(e.peek(), b) && (e.last(1), L)) {
|
|
566
776
|
let u = e.pop();
|
|
567
777
|
for (e.push({
|
|
568
778
|
type: g,
|
|
569
779
|
value: u.value
|
|
570
780
|
}), "" + u.value; w(e););
|
|
571
|
-
return e.push(r), !0
|
|
781
|
+
return e.push(r), !0;
|
|
572
782
|
}
|
|
573
783
|
if (l(e.peek(), C)) return e.peek().value.push(r.value[0]), !0;
|
|
574
784
|
break;
|
|
@@ -579,18 +789,26 @@ var dJSON = (() => {
|
|
|
579
789
|
type: W,
|
|
580
790
|
key: u.value,
|
|
581
791
|
value: r.value
|
|
582
|
-
}), !0
|
|
792
|
+
}), !0;
|
|
583
793
|
}
|
|
584
|
-
throw new Error(
|
|
794
|
+
throw new Error(
|
|
795
|
+
"Got a :value that can't be handled at line " + r.row + ":" + r.col,
|
|
796
|
+
);
|
|
585
797
|
case W:
|
|
586
|
-
return l(e.last(0), L) && l(e.last(1), X) ?
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
798
|
+
return l(e.last(0), L) && l(e.last(1), X) ?
|
|
799
|
+
(e.last(1).value.push(r), e.pop(), !0) :
|
|
800
|
+
(e.push({
|
|
801
|
+
type: X,
|
|
802
|
+
value: [r]
|
|
803
|
+
}), !0);
|
|
590
804
|
case X:
|
|
591
|
-
if (l(e.peek(), X))
|
|
592
|
-
|
|
593
|
-
|
|
805
|
+
if (l(e.peek(), X))
|
|
806
|
+
return (
|
|
807
|
+
r.value.forEach(function(u) {
|
|
808
|
+
e.peek().value.push(u);
|
|
809
|
+
}),
|
|
810
|
+
!0
|
|
811
|
+
);
|
|
594
812
|
break;
|
|
595
813
|
case A:
|
|
596
814
|
if (l(e.peek(), C) && l(e.last(1), O)) {
|
|
@@ -598,32 +816,33 @@ var dJSON = (() => {
|
|
|
598
816
|
return e.pop(), e.push({
|
|
599
817
|
type: R,
|
|
600
818
|
value: u.value
|
|
601
|
-
}), !0
|
|
819
|
+
}), !0;
|
|
602
820
|
}
|
|
603
821
|
if (l(e.peek(), R) && l(e.last(1), O)) {
|
|
604
822
|
let u = e.pop();
|
|
605
823
|
return e.pop(), e.push({
|
|
606
824
|
type: R,
|
|
607
825
|
value: [u.value]
|
|
608
|
-
}), !0
|
|
826
|
+
}), !0;
|
|
609
827
|
}
|
|
610
|
-
if (l(e.peek(), O))
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
828
|
+
if (l(e.peek(), O))
|
|
829
|
+
return e.pop(), e.push({
|
|
830
|
+
type: R,
|
|
831
|
+
value: []
|
|
832
|
+
}), !0;
|
|
614
833
|
if (l(e.peek(), g) && l(e.last(1), O)) {
|
|
615
834
|
let u = e.pop().value;
|
|
616
835
|
return e.pop(), e.push({
|
|
617
836
|
type: R,
|
|
618
837
|
value: [u]
|
|
619
|
-
}), !0
|
|
838
|
+
}), !0;
|
|
620
839
|
}
|
|
621
840
|
if (l(e.peek(), S) && l(e.last(1), O)) {
|
|
622
841
|
let u = e.pop();
|
|
623
842
|
return e.pop(), e.push({
|
|
624
843
|
type: R,
|
|
625
844
|
value: [u]
|
|
626
|
-
}), !0
|
|
845
|
+
}), !0;
|
|
627
846
|
}
|
|
628
847
|
if (l(e.peek(), b) && l(e.last(1), L)) {
|
|
629
848
|
let u = e.pop();
|
|
@@ -633,27 +852,33 @@ var dJSON = (() => {
|
|
|
633
852
|
}), "" + u.value; w(e););
|
|
634
853
|
return e.push({
|
|
635
854
|
type: A
|
|
636
|
-
}), !0
|
|
855
|
+
}), !0;
|
|
637
856
|
}
|
|
638
|
-
if (
|
|
639
|
-
|
|
857
|
+
if (
|
|
858
|
+
l(e.peek(), L) &&
|
|
859
|
+
(l(e.last(1), b) || l(e.last(1), S) || l(e.last(1), g))
|
|
860
|
+
) {
|
|
861
|
+
for (
|
|
862
|
+
e.pop(), e.push({
|
|
640
863
|
type: A,
|
|
641
864
|
value: "]"
|
|
642
|
-
}), "" + JSON.stringify(e); w(e);
|
|
643
|
-
|
|
865
|
+
}), "" + JSON.stringify(e); w(e);
|
|
866
|
+
|
|
867
|
+
);
|
|
868
|
+
return !0;
|
|
644
869
|
}
|
|
645
870
|
if (l(e.peek(), b) && l(e.last(1), O)) {
|
|
646
871
|
let u = e.pop();
|
|
647
872
|
return e.pop(), e.push({
|
|
648
873
|
type: R,
|
|
649
874
|
value: [u.value]
|
|
650
|
-
}), !0
|
|
875
|
+
}), !0;
|
|
651
876
|
}
|
|
652
877
|
if (l(e.peek(), L) && l(e.last(1), C)) {
|
|
653
878
|
for (e.pop(), e.push({
|
|
654
879
|
type: A
|
|
655
880
|
}), "" + JSON.stringify(e); w(e););
|
|
656
|
-
return !0
|
|
881
|
+
return !0;
|
|
657
882
|
}
|
|
658
883
|
break;
|
|
659
884
|
case I:
|
|
@@ -662,12 +887,13 @@ var dJSON = (() => {
|
|
|
662
887
|
return e.pop(), e.push({
|
|
663
888
|
type: S,
|
|
664
889
|
value: u.value
|
|
665
|
-
}), !0
|
|
890
|
+
}), !0;
|
|
666
891
|
}
|
|
667
|
-
if (l(e.peek(), $))
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
892
|
+
if (l(e.peek(), $))
|
|
893
|
+
return e.pop(), e.push({
|
|
894
|
+
type: S,
|
|
895
|
+
value: null
|
|
896
|
+
}), !0;
|
|
671
897
|
if (l(e.peek(), b) && l(e.last(1), m)) {
|
|
672
898
|
let u = e.pop();
|
|
673
899
|
for (e.push({
|
|
@@ -676,7 +902,7 @@ var dJSON = (() => {
|
|
|
676
902
|
}), "" + u.value; w(e););
|
|
677
903
|
return e.push({
|
|
678
904
|
type: I
|
|
679
|
-
}), !0
|
|
905
|
+
}), !0;
|
|
680
906
|
}
|
|
681
907
|
if (l(e.peek(), m)) {
|
|
682
908
|
for (e.push({
|
|
@@ -685,12 +911,14 @@ var dJSON = (() => {
|
|
|
685
911
|
}); w(e););
|
|
686
912
|
return e.push({
|
|
687
913
|
type: I
|
|
688
|
-
}), !0
|
|
914
|
+
}), !0;
|
|
689
915
|
}
|
|
690
916
|
if (l(e.peek(), L)) return e.pop(), e.push({
|
|
691
917
|
type: I
|
|
692
918
|
}), !0;
|
|
693
|
-
throw new Error(
|
|
919
|
+
throw new Error(
|
|
920
|
+
"Found } that I can't handle at line " + r.row + ":" + r.col,
|
|
921
|
+
);
|
|
694
922
|
case L:
|
|
695
923
|
if (l(e.peek(), L)) return !0;
|
|
696
924
|
if (l(e.peek(), b)) {
|
|
@@ -699,17 +927,17 @@ var dJSON = (() => {
|
|
|
699
927
|
type: g,
|
|
700
928
|
value: u.value
|
|
701
929
|
}); w(e););
|
|
702
|
-
return e.push(r), !0
|
|
930
|
+
return e.push(r), !0;
|
|
703
931
|
}
|
|
704
932
|
if (l(e.peek(), m)) {
|
|
705
933
|
for (e.push({
|
|
706
934
|
type: g,
|
|
707
935
|
value: null
|
|
708
936
|
}); w(e););
|
|
709
|
-
return e.push(r), !0
|
|
937
|
+
return e.push(r), !0;
|
|
710
938
|
}
|
|
711
939
|
}
|
|
712
|
-
return e.push(r), !1
|
|
940
|
+
return e.push(r), !1;
|
|
713
941
|
}
|
|
714
942
|
|
|
715
943
|
function Q(e, r) {
|
|
@@ -718,20 +946,23 @@ var dJSON = (() => {
|
|
|
718
946
|
if (Array.isArray(e)) {
|
|
719
947
|
let t = [];
|
|
720
948
|
for (; e.length > 0;) t.unshift(Q(e.pop()));
|
|
721
|
-
return t
|
|
949
|
+
return t;
|
|
722
950
|
}
|
|
723
951
|
if (l(e, S)) {
|
|
724
952
|
let t = {};
|
|
725
|
-
return e.value === null ?
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
953
|
+
return e.value === null ?
|
|
954
|
+
{} :
|
|
955
|
+
(e.value.forEach(function(i) {
|
|
956
|
+
let n = i.key,
|
|
957
|
+
v = Q(i.value);
|
|
958
|
+
r && n in t ? (t[n] = {
|
|
959
|
+
value: t[n],
|
|
960
|
+
next: v
|
|
961
|
+
}) : (t[n] = v);
|
|
962
|
+
}),
|
|
963
|
+
t);
|
|
733
964
|
}
|
|
734
|
-
return l(e, R) ? Q(e.value) : e.value
|
|
965
|
+
return l(e, R) ? Q(e.value) : e.value;
|
|
735
966
|
}
|
|
736
967
|
});
|
|
737
968
|
var z = c((er, ve) => {
|
|
@@ -742,16 +973,24 @@ var dJSON = (() => {
|
|
|
742
973
|
function Ye(e, r) {
|
|
743
974
|
let u = !0,
|
|
744
975
|
t = !1;
|
|
745
|
-
r &&
|
|
976
|
+
r &&
|
|
977
|
+
("fallback" in r && r[u] === !1 && (u = !1),
|
|
978
|
+
(t = "duplicateKeys" in r && r.duplicateKeys === !0));
|
|
746
979
|
try {
|
|
747
|
-
return Qe.parse(e, t)
|
|
980
|
+
return Qe.parse(e, t);
|
|
748
981
|
} catch (i) {
|
|
749
982
|
if (u === !1) throw i;
|
|
750
983
|
try {
|
|
751
984
|
let n = JSON.parse(e);
|
|
752
|
-
return
|
|
985
|
+
return (
|
|
986
|
+
console.warn(
|
|
987
|
+
"dirty-json got valid JSON that failed with the custom parser. We're returning the valid JSON, but please file a bug report here: https://github.com/RyanMarcus/dirty-json/issues -- the JSON that caused the failure was: " +
|
|
988
|
+
e,
|
|
989
|
+
),
|
|
990
|
+
n
|
|
991
|
+
);
|
|
753
992
|
} catch {
|
|
754
|
-
throw i
|
|
993
|
+
throw i;
|
|
755
994
|
}
|
|
756
995
|
}
|
|
757
996
|
}
|
|
@@ -795,9 +1034,30 @@ Context.prototype.use = (function(middleware) {
|
|
|
795
1034
|
return ((middleware.name === "write") ? this.ws.push(middleware) : this.ms.push(middleware));
|
|
796
1035
|
});
|
|
797
1036
|
Context.prototype.resolve = (async function(name, args, ms) {
|
|
1037
|
+
var res;
|
|
798
1038
|
ms = ms || this.ms;
|
|
799
1039
|
if (!ms.length) return;
|
|
800
|
-
|
|
1040
|
+
var res;
|
|
1041
|
+
res = ms[0](name, this, args, this.resolve.bind(this, name, args, ms.slice(1)));
|
|
1042
|
+
res = await res;
|
|
1043
|
+
if (!res) return res;
|
|
1044
|
+
if ((typeof res !== "object")) throw Error(tpl("resolved '@{name}' node must be 'object' but got '{res}'", {
|
|
1045
|
+
name: name,
|
|
1046
|
+
res: typeof res
|
|
1047
|
+
}));
|
|
1048
|
+
if (!res.type) throw Error(tpl("resolved '@{name}' node must have a 'type' property", {
|
|
1049
|
+
name: name
|
|
1050
|
+
}));
|
|
1051
|
+
return res;
|
|
1052
|
+
});
|
|
1053
|
+
Context.prototype.text2run = (async function(text, opts) {
|
|
1054
|
+
return text2run(text, this, opts);
|
|
1055
|
+
});
|
|
1056
|
+
Context.prototype.text2ast = (async function(text) {
|
|
1057
|
+
return text2ast(text, this);
|
|
1058
|
+
});
|
|
1059
|
+
Context.prototype.text2paylod = (async function(text) {
|
|
1060
|
+
return text2payload(text, this);
|
|
801
1061
|
});
|
|
802
1062
|
Context.prototype.read = (async function(name, args) {
|
|
803
1063
|
var resolved, _ref;
|
|
@@ -821,7 +1081,8 @@ Context.prototype.exec = (async function(name, args) {
|
|
|
821
1081
|
}
|
|
822
1082
|
return _ref;
|
|
823
1083
|
});
|
|
824
|
-
Context.prototype.write = (async function(name, args
|
|
1084
|
+
Context.prototype.write = (async function(name, args) {
|
|
1085
|
+
var ws;
|
|
825
1086
|
ws = ws || this.ws;
|
|
826
1087
|
if (!ws.length) return;
|
|
827
1088
|
return ws[0](name, args, this, this.write.bind(this, name, args, ws.slice(1)));
|
|
@@ -1098,7 +1359,7 @@ async function text2ast(text, ctx) {
|
|
|
1098
1359
|
ctx = makeContext(ctx);
|
|
1099
1360
|
nodeStack = nodeStack || [];
|
|
1100
1361
|
var re;
|
|
1101
|
-
re = /(?<prefix1>@{1,2})\{(?<name1>[
|
|
1362
|
+
re = /(?<prefix1>@{1,2})\{(?<name1>(?:\\\}|[^}])+)\}|(?<prefix>@{1,2})(?<name>[\S]+)|(?<role>^(?:s|system|u|user|a|assistant|tc|tool_call|tr|tool_result|c|comment|au|audio|err|error))\s*(?<roleName>\([^\)]+\))?\s*:/gm;
|
|
1102
1363
|
var nodes;
|
|
1103
1364
|
nodes = [];
|
|
1104
1365
|
var index;
|
|
@@ -1144,6 +1405,7 @@ async function text2ast(text, ctx) {
|
|
|
1144
1405
|
args = undefined;
|
|
1145
1406
|
proc = undefined;
|
|
1146
1407
|
(function(it) {
|
|
1408
|
+
it = it.replace(/\\\}/g, "}");
|
|
1147
1409
|
it = it.split("|");
|
|
1148
1410
|
it = it.map((function(it) {
|
|
1149
1411
|
return it.trim();
|
|
@@ -1176,7 +1438,7 @@ async function text2ast(text, ctx) {
|
|
|
1176
1438
|
var pname;
|
|
1177
1439
|
pname = pargs.shift();
|
|
1178
1440
|
var p;
|
|
1179
|
-
p = await ctx.resolve(pname);
|
|
1441
|
+
p = await ctx.resolve(pname, "processor");
|
|
1180
1442
|
if (!p) throw new TuneError(("'" + pname + "' processor not found"), filename, row, col);
|
|
1181
1443
|
if ((typeof p.exec !== "function")) throw new TuneError(("'" + pname + "' does not have exec function"), filename, row, col);
|
|
1182
1444
|
try {
|
|
@@ -1589,6 +1851,15 @@ TunePromise.prototype.catch = (function(onRejected) {
|
|
|
1589
1851
|
TunePromise.prototype.finally = (function(onFinally) {
|
|
1590
1852
|
return this.promise.finally(onFinally);
|
|
1591
1853
|
});
|
|
1854
|
+
fs = require('fs');
|
|
1855
|
+
path = require('path');
|
|
1856
|
+
|
|
1857
|
+
function log() {
|
|
1858
|
+
var _i;
|
|
1859
|
+
var msgs = 1 <= arguments.length ? [].slice.call(arguments, 0, _i = arguments.length - 0) : (_i = 0, []);
|
|
1860
|
+
return fs.appendFileSync(path.join(process.cwd(), "tune.log"), msgs.join(" ") + "\n");
|
|
1861
|
+
}
|
|
1862
|
+
log;
|
|
1592
1863
|
|
|
1593
1864
|
function text2run(text, ctx, opts) {
|
|
1594
1865
|
var msgs, stopVal, stream, ires, ierr, ifinish, resolve, reject, p;
|
|
@@ -1674,9 +1945,9 @@ function text2run(text, ctx, opts) {
|
|
|
1674
1945
|
ctype = res.headers.get("content-type");
|
|
1675
1946
|
if ((!stream || ctype.includes("application/json"))) {
|
|
1676
1947
|
res = await res.json();
|
|
1677
|
-
if (((((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res.error !== "undefined") && (res.error !== null) && !Number.isNaN(res.error)) ? res.error : undefined) || (res.object === "error"))) {
|
|
1948
|
+
if (((((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res[0] !== "undefined") && (res[0] !== null) && !Number.isNaN(res[0]) && (typeof res[0].error !== "undefined") && (res[0].error !== null) && !Number.isNaN(res[0].error)) ? res[0].error : (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res.error !== "undefined") && (res.error !== null) && !Number.isNaN(res.error)) ? res.error : undefined)) || (res.object === "error"))) {
|
|
1678
1949
|
var err;
|
|
1679
|
-
err = new TuneError(tpl("{type: }{message}", (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res.error !== "undefined") && (res.error !== null) && !Number.isNaN(res.error)) ? res.error : (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res)) ? res : undefined))));
|
|
1950
|
+
err = new TuneError(tpl("{type: }{message}", (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res[0] !== "undefined") && (res[0] !== null) && !Number.isNaN(res[0]) && (typeof res[0].error !== "undefined") && (res[0].error !== null) && !Number.isNaN(res[0].error)) ? res[0].error : (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res) && (typeof res.error !== "undefined") && (res.error !== null) && !Number.isNaN(res.error)) ? res.error : (((typeof res !== "undefined") && (res !== null) && !Number.isNaN(res)) ? res : undefined)))));
|
|
1680
1951
|
err.stack = TuneError.ctx2stack(ctx);
|
|
1681
1952
|
throw err;
|
|
1682
1953
|
}
|
|
@@ -1717,7 +1988,7 @@ function text2run(text, ctx, opts) {
|
|
|
1717
1988
|
return ((item === '[DONE]') ? item : JSON.parse(item));
|
|
1718
1989
|
}));
|
|
1719
1990
|
it = it.reduce((function(msg, chunk) {
|
|
1720
|
-
var delta, tc;
|
|
1991
|
+
var delta, tc, tcIdx;
|
|
1721
1992
|
if ((chunk === "[DONE]")) return msg;
|
|
1722
1993
|
var delta;
|
|
1723
1994
|
delta = (((typeof chunk !== "undefined") && (chunk !== null) && !Number.isNaN(chunk) && (typeof chunk.choices !== "undefined") && (chunk.choices !== null) && !Number.isNaN(chunk.choices) && (typeof chunk.choices[0] !== "undefined") && (chunk.choices[0] !== null) && !Number.isNaN(chunk.choices[0]) && (typeof chunk.choices[0].delta !== "undefined") && (chunk.choices[0].delta !== null) && !Number.isNaN(chunk.choices[0].delta)) ? chunk.choices[0].delta : (((typeof {} !== "undefined") && ({} !== null) && !Number.isNaN({})) ? {} : undefined));
|
|
@@ -1733,13 +2004,14 @@ function text2run(text, ctx, opts) {
|
|
|
1733
2004
|
} else if (delta.tool_calls) {
|
|
1734
2005
|
msg.tool_calls = msg.tool_calls || [];
|
|
1735
2006
|
tc = delta.tool_calls[0];
|
|
1736
|
-
|
|
1737
|
-
msg.tool_calls[
|
|
2007
|
+
tcIdx = tc.index || 0;
|
|
2008
|
+
msg.tool_calls[tcIdx] = msg.tool_calls[tcIdx] || tc;
|
|
2009
|
+
msg.tool_calls[tcIdx].function.arguments += tc.function.arguments;
|
|
1738
2010
|
}
|
|
1739
2011
|
return msg;
|
|
1740
2012
|
}), {
|
|
1741
2013
|
role: "assistant",
|
|
1742
|
-
content:
|
|
2014
|
+
content: ""
|
|
1743
2015
|
});
|
|
1744
2016
|
it = (ires = {
|
|
1745
2017
|
value: msgs.concat(Array(it))
|
package/dist/tune.mjs
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
|
-
import { createRequire } from
|
|
1
|
+
import { createRequire } from "module";
|
|
2
2
|
const require = createRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const {
|
|
5
|
+
makeContext,
|
|
6
|
+
text2roles,
|
|
7
|
+
roles2text,
|
|
8
|
+
text2call,
|
|
9
|
+
text2ast,
|
|
10
|
+
ast2payload,
|
|
11
|
+
toolCall,
|
|
12
|
+
text2run,
|
|
13
|
+
msg2text,
|
|
14
|
+
msg2role,
|
|
15
|
+
text2cut,
|
|
16
|
+
TuneError,
|
|
17
|
+
text2cut,
|
|
18
|
+
text2payload,
|
|
19
|
+
payload2http,
|
|
20
|
+
envmd,
|
|
21
|
+
unescape,
|
|
22
|
+
escape,
|
|
23
|
+
} = require("./tune.js");
|
|
24
|
+
export {
|
|
25
|
+
makeContext,
|
|
26
|
+
text2roles,
|
|
27
|
+
roles2text,
|
|
28
|
+
text2call,
|
|
29
|
+
text2ast,
|
|
30
|
+
ast2payload,
|
|
31
|
+
toolCall,
|
|
32
|
+
text2run,
|
|
33
|
+
msg2text,
|
|
34
|
+
msg2role,
|
|
35
|
+
text2cut,
|
|
36
|
+
TuneError,
|
|
37
|
+
text2cut,
|
|
38
|
+
text2payload,
|
|
39
|
+
payload2http,
|
|
40
|
+
envmd,
|
|
41
|
+
unescape,
|
|
42
|
+
escape,
|
|
43
|
+
};
|