@mirascript/mirascript 0.1.17 → 0.1.19
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/{chunk-JG3D67GF.js → chunk-5AEWM4W6.js} +30 -12
- package/dist/{chunk-JG3D67GF.js.map → chunk-5AEWM4W6.js.map} +1 -1
- package/dist/{chunk-W2I5XPIE.js → chunk-BFSB6SQK.js} +204 -61
- package/dist/chunk-BFSB6SQK.js.map +6 -0
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/index.js +11 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/compiler/diagnostic.d.ts.map +1 -1
- package/dist/compiler/worker.js +1 -1
- package/dist/index.js +2 -2
- package/dist/subtle.js +2 -2
- package/dist/vm/checkpoint.d.ts.map +1 -1
- package/dist/vm/lib/global/debug.d.ts +17 -1
- package/dist/vm/lib/global/debug.d.ts.map +1 -1
- package/dist/vm/lib/global/json.d.ts.map +1 -1
- package/dist/vm/lib/global/math-const.d.ts +24 -2
- package/dist/vm/lib/global/math-const.d.ts.map +1 -1
- package/dist/vm/lib/helpers.d.ts +7 -3
- package/dist/vm/lib/helpers.d.ts.map +1 -1
- package/dist/vm/lib/index.d.ts.map +1 -1
- package/dist/vm/lib/loader.d.ts +12 -5
- package/dist/vm/lib/loader.d.ts.map +1 -1
- package/dist/vm/types/context.d.ts +3 -2
- package/dist/vm/types/context.d.ts.map +1 -1
- package/dist/vm/types/extern.d.ts +1 -1
- package/dist/vm/types/extern.d.ts.map +1 -1
- package/dist/vm/types/module.d.ts +1 -1
- package/dist/vm/types/module.d.ts.map +1 -1
- package/dist/vm/types/wrapper.d.ts +4 -2
- package/dist/vm/types/wrapper.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cli/execute.ts +10 -10
- package/src/compiler/diagnostic.ts +29 -11
- package/src/vm/checkpoint.ts +19 -10
- package/src/vm/lib/global/debug.ts +84 -7
- package/src/vm/lib/global/json.ts +3 -4
- package/src/vm/lib/global/math-const.ts +34 -2
- package/src/vm/lib/helpers.ts +9 -10
- package/src/vm/lib/index.ts +7 -3
- package/src/vm/lib/loader.ts +56 -19
- package/src/vm/types/context.ts +21 -6
- package/src/vm/types/extern.ts +1 -1
- package/src/vm/types/module.ts +1 -1
- package/src/vm/types/wrapper.ts +7 -3
- package/dist/chunk-W2I5XPIE.js.map +0 -6
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
parseDiagnostics,
|
|
46
46
|
toString,
|
|
47
47
|
values
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-5AEWM4W6.js";
|
|
49
49
|
|
|
50
50
|
// src/helpers/convert/index.ts
|
|
51
51
|
var convert_exports = {};
|
|
@@ -555,13 +555,17 @@ var VmWrapper = class {
|
|
|
555
555
|
constructor(value) {
|
|
556
556
|
this.value = value;
|
|
557
557
|
}
|
|
558
|
+
/** 描述键对应的值 */
|
|
559
|
+
describe(key) {
|
|
560
|
+
return void 0;
|
|
561
|
+
}
|
|
558
562
|
/** Convert the object to JSON */
|
|
559
563
|
toJSON() {
|
|
560
564
|
return void 0;
|
|
561
565
|
}
|
|
562
566
|
/** 转为字符串 */
|
|
563
567
|
toString(useBraces) {
|
|
564
|
-
const { type, describe } = this;
|
|
568
|
+
const { type, tag: describe } = this;
|
|
565
569
|
if (!describe) return `<${type}>`;
|
|
566
570
|
return `<${type} ${describe}>`;
|
|
567
571
|
}
|
|
@@ -736,7 +740,7 @@ var VmExtern = class extends VmWrapper {
|
|
|
736
740
|
return "extern";
|
|
737
741
|
}
|
|
738
742
|
/** @inheritdoc */
|
|
739
|
-
get
|
|
743
|
+
get tag() {
|
|
740
744
|
const tag = ObjectToString.call(this.value).slice(8, -1);
|
|
741
745
|
if (isArray(this.value)) {
|
|
742
746
|
return `${tag}(${this.value.length})`;
|
|
@@ -773,21 +777,26 @@ var VmExtern = class extends VmWrapper {
|
|
|
773
777
|
Object.defineProperty(VmExtern.prototype, kVmExtern, { value: true });
|
|
774
778
|
|
|
775
779
|
// src/vm/checkpoint.ts
|
|
780
|
+
var { now } = Date;
|
|
781
|
+
var TIME_ORIGIN = now() - 1e3 * 3600 * 24;
|
|
782
|
+
var timestamp = () => now() - TIME_ORIGIN;
|
|
776
783
|
var MAX_DEPTH = 128;
|
|
784
|
+
var CP_UNSET = -1;
|
|
785
|
+
var CP_DEFAULT_TIMEOUT = 100;
|
|
777
786
|
var cpDepth = 0;
|
|
778
|
-
var cp =
|
|
779
|
-
var cpTimeout =
|
|
787
|
+
var cp = CP_UNSET;
|
|
788
|
+
var cpTimeout = CP_DEFAULT_TIMEOUT;
|
|
780
789
|
function Cp() {
|
|
781
|
-
if (
|
|
782
|
-
cp =
|
|
783
|
-
} else if (
|
|
790
|
+
if (cp === CP_UNSET) {
|
|
791
|
+
cp = timestamp();
|
|
792
|
+
} else if (timestamp() - cp > cpTimeout) {
|
|
784
793
|
throw new RangeError("Execution timeout");
|
|
785
794
|
}
|
|
786
795
|
}
|
|
787
796
|
function CpEnter() {
|
|
788
797
|
cpDepth++;
|
|
789
798
|
if (cpDepth <= 1) {
|
|
790
|
-
cp =
|
|
799
|
+
cp = timestamp();
|
|
791
800
|
cpDepth = 1;
|
|
792
801
|
} else if (cpDepth > MAX_DEPTH) {
|
|
793
802
|
throw new RangeError("Maximum call depth exceeded");
|
|
@@ -798,17 +807,17 @@ function CpEnter() {
|
|
|
798
807
|
function CpExit() {
|
|
799
808
|
cpDepth--;
|
|
800
809
|
if (cpDepth < 1) {
|
|
801
|
-
cp =
|
|
810
|
+
cp = CP_UNSET;
|
|
802
811
|
cpDepth = 0;
|
|
803
812
|
} else {
|
|
804
813
|
Cp();
|
|
805
814
|
}
|
|
806
815
|
}
|
|
807
|
-
function configCheckpoint(timeout =
|
|
808
|
-
if (typeof timeout !== "number" || timeout <= 0 ||
|
|
816
|
+
function configCheckpoint(timeout = CP_DEFAULT_TIMEOUT) {
|
|
817
|
+
if (typeof timeout !== "number" || timeout <= 0 || isNaN(timeout)) {
|
|
809
818
|
throw new RangeError("Invalid timeout value");
|
|
810
819
|
}
|
|
811
|
-
cpTimeout = timeout;
|
|
820
|
+
cpTimeout = Math.ceil(timeout);
|
|
812
821
|
}
|
|
813
822
|
|
|
814
823
|
// src/vm/types/function.ts
|
|
@@ -851,11 +860,12 @@ function VmFunction(fn, option = {}) {
|
|
|
851
860
|
// src/vm/types/context.ts
|
|
852
861
|
var { freeze } = Object;
|
|
853
862
|
var VM_SHARED_CONTEXT = create(null);
|
|
863
|
+
var VM_SHARED_CONTEXT_DESCRIPTIONS = create(null);
|
|
854
864
|
var VM_SHARED_CONTEXT_KEYS = null;
|
|
855
865
|
function globalVarNotFound(name) {
|
|
856
866
|
throw new VmError(`Global variable '${name}' is not defined.`, null);
|
|
857
867
|
}
|
|
858
|
-
function defineVmContextValue(name, value, override = false) {
|
|
868
|
+
function defineVmContextValue(name, value, override = false, description = void 0) {
|
|
859
869
|
if (!override && name in VM_SHARED_CONTEXT) throw new Error(`Global variable '${name}' is already defined.`);
|
|
860
870
|
let v;
|
|
861
871
|
if (typeof value == "function") {
|
|
@@ -867,6 +877,7 @@ function defineVmContextValue(name, value, override = false) {
|
|
|
867
877
|
v = value;
|
|
868
878
|
}
|
|
869
879
|
VM_SHARED_CONTEXT[name] = v ?? null;
|
|
880
|
+
if (description) VM_SHARED_CONTEXT_DESCRIPTIONS[name] = description;
|
|
870
881
|
VM_SHARED_CONTEXT_KEYS = null;
|
|
871
882
|
}
|
|
872
883
|
var DefaultVmContext = freeze({
|
|
@@ -885,14 +896,18 @@ var DefaultVmContext = freeze({
|
|
|
885
896
|
/** @inheritdoc */
|
|
886
897
|
has(key) {
|
|
887
898
|
return key in VM_SHARED_CONTEXT;
|
|
899
|
+
},
|
|
900
|
+
/** @inheritdoc */
|
|
901
|
+
describe(key) {
|
|
902
|
+
return VM_SHARED_CONTEXT_DESCRIPTIONS[key];
|
|
888
903
|
}
|
|
889
904
|
});
|
|
890
905
|
var _a;
|
|
891
906
|
_a = kVmContext;
|
|
892
907
|
var ValueVmContext = class {
|
|
893
|
-
constructor(env,
|
|
908
|
+
constructor(env, describer) {
|
|
894
909
|
this.env = env;
|
|
895
|
-
this.
|
|
910
|
+
this.describer = describer;
|
|
896
911
|
this[_a] = true;
|
|
897
912
|
this.cachedKeys = null;
|
|
898
913
|
}
|
|
@@ -915,14 +930,19 @@ var ValueVmContext = class {
|
|
|
915
930
|
has(key) {
|
|
916
931
|
return key in this.env;
|
|
917
932
|
}
|
|
933
|
+
/** @inheritdoc */
|
|
934
|
+
describe(key) {
|
|
935
|
+
if (this.describer != null && hasOwn(this.env, key)) return this.describer(key);
|
|
936
|
+
return VM_SHARED_CONTEXT_DESCRIPTIONS[key];
|
|
937
|
+
}
|
|
918
938
|
};
|
|
919
939
|
var _a2;
|
|
920
940
|
_a2 = kVmContext;
|
|
921
941
|
var FactoryVmContext = class {
|
|
922
|
-
constructor(getter, enumerator,
|
|
942
|
+
constructor(getter, enumerator, describer) {
|
|
923
943
|
this.getter = getter;
|
|
924
944
|
this.enumerator = enumerator;
|
|
925
|
-
this.
|
|
945
|
+
this.describer = describer;
|
|
926
946
|
this[_a2] = true;
|
|
927
947
|
}
|
|
928
948
|
/** @inheritdoc */
|
|
@@ -940,6 +960,11 @@ var FactoryVmContext = class {
|
|
|
940
960
|
has(key) {
|
|
941
961
|
return this.getter(key) !== void 0 || DefaultVmContext.has(key);
|
|
942
962
|
}
|
|
963
|
+
/** @inheritdoc */
|
|
964
|
+
describe(key) {
|
|
965
|
+
if (this.describer != null && this.getter(key) !== void 0) return this.describer(key);
|
|
966
|
+
return VM_SHARED_CONTEXT_DESCRIPTIONS[key];
|
|
967
|
+
}
|
|
943
968
|
};
|
|
944
969
|
function createVmContext(...args) {
|
|
945
970
|
if (args[0] == null && args[1] == null) {
|
|
@@ -1257,7 +1282,7 @@ var VmModule = class extends VmWrapper {
|
|
|
1257
1282
|
return "module";
|
|
1258
1283
|
}
|
|
1259
1284
|
/** @inheritdoc */
|
|
1260
|
-
get
|
|
1285
|
+
get tag() {
|
|
1261
1286
|
return this.name;
|
|
1262
1287
|
}
|
|
1263
1288
|
};
|
|
@@ -1266,8 +1291,14 @@ Object.defineProperty(VmModule.prototype, kVmModule, { value: true });
|
|
|
1266
1291
|
// src/vm/lib/global/index.ts
|
|
1267
1292
|
var global_exports = {};
|
|
1268
1293
|
__export(global_exports, {
|
|
1269
|
-
|
|
1270
|
-
|
|
1294
|
+
E: () => E,
|
|
1295
|
+
LN10: () => LN10,
|
|
1296
|
+
LN2: () => LN2,
|
|
1297
|
+
LOG10E: () => LOG10E,
|
|
1298
|
+
LOG2E: () => LOG2E,
|
|
1299
|
+
PI: () => PI,
|
|
1300
|
+
SQRT1_2: () => SQRT1_2,
|
|
1301
|
+
SQRT2: () => SQRT2,
|
|
1271
1302
|
abs: () => abs2,
|
|
1272
1303
|
acos: () => acos,
|
|
1273
1304
|
acosh: () => acosh,
|
|
@@ -1498,10 +1529,9 @@ function map(data, mapper) {
|
|
|
1498
1529
|
return fromEntries(e);
|
|
1499
1530
|
}
|
|
1500
1531
|
}
|
|
1501
|
-
function VmLib(
|
|
1502
|
-
if (
|
|
1503
|
-
|
|
1504
|
-
const ret = fn;
|
|
1532
|
+
function VmLib(value, option, properties) {
|
|
1533
|
+
if (isVmFunction(value)) throw new TypeError("Cannot create VmLib from a VmFunction");
|
|
1534
|
+
const ret = typeof value == "function" ? value : { value };
|
|
1505
1535
|
Object.assign(ret, properties);
|
|
1506
1536
|
ret.params = option.params;
|
|
1507
1537
|
ret.paramsType = option.paramsType;
|
|
@@ -1568,7 +1598,38 @@ var product = VmLib(
|
|
|
1568
1598
|
);
|
|
1569
1599
|
|
|
1570
1600
|
// src/vm/lib/global/math-const.ts
|
|
1571
|
-
var
|
|
1601
|
+
var PI = VmLib(Math.PI, {
|
|
1602
|
+
summary: "圆周率",
|
|
1603
|
+
returnsType: "number"
|
|
1604
|
+
});
|
|
1605
|
+
var E = VmLib(Math.E, {
|
|
1606
|
+
summary: "自然对数的底数",
|
|
1607
|
+
returnsType: "number"
|
|
1608
|
+
});
|
|
1609
|
+
var SQRT1_2 = VmLib(Math.SQRT1_2, {
|
|
1610
|
+
summary: "1 的平方根除以 2",
|
|
1611
|
+
returnsType: "number"
|
|
1612
|
+
});
|
|
1613
|
+
var SQRT2 = VmLib(Math.SQRT2, {
|
|
1614
|
+
summary: "2 的平方根",
|
|
1615
|
+
returnsType: "number"
|
|
1616
|
+
});
|
|
1617
|
+
var LN2 = VmLib(Math.LN2, {
|
|
1618
|
+
summary: "2 的自然对数",
|
|
1619
|
+
returnsType: "number"
|
|
1620
|
+
});
|
|
1621
|
+
var LN10 = VmLib(Math.LN10, {
|
|
1622
|
+
summary: "10 的自然对数",
|
|
1623
|
+
returnsType: "number"
|
|
1624
|
+
});
|
|
1625
|
+
var LOG2E = VmLib(Math.LOG2E, {
|
|
1626
|
+
summary: "e 以 2 为底的对数",
|
|
1627
|
+
returnsType: "number"
|
|
1628
|
+
});
|
|
1629
|
+
var LOG10E = VmLib(Math.LOG10E, {
|
|
1630
|
+
summary: "e 以 10 为底的对数",
|
|
1631
|
+
returnsType: "number"
|
|
1632
|
+
});
|
|
1572
1633
|
|
|
1573
1634
|
// src/vm/lib/global/math-unary.ts
|
|
1574
1635
|
function build2(f) {
|
|
@@ -2469,9 +2530,63 @@ var repeat = VmLib(
|
|
|
2469
2530
|
|
|
2470
2531
|
// src/vm/lib/global/debug.ts
|
|
2471
2532
|
import supportsColor from "supports-color";
|
|
2533
|
+
function defaultSerializer(arg, format2) {
|
|
2534
|
+
return null;
|
|
2535
|
+
}
|
|
2536
|
+
function serializeValue(arg, format2, serializer) {
|
|
2537
|
+
if (serializer == null || serializer === defaultSerializer) {
|
|
2538
|
+
return defaultSerializer(arg, format2);
|
|
2539
|
+
}
|
|
2540
|
+
try {
|
|
2541
|
+
return serializer(arg, format2);
|
|
2542
|
+
} catch {
|
|
2543
|
+
return defaultSerializer(arg, format2);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2472
2546
|
var debug_print = VmLib(
|
|
2473
2547
|
(...args) => {
|
|
2474
|
-
|
|
2548
|
+
const { serializer } = debug_print;
|
|
2549
|
+
if (args.length <= 1 || typeof args[0] != "string" || !args[0].includes("%")) {
|
|
2550
|
+
console.log(...debug_print.prefix, ...args.map((v) => serializeValue(v, "", serializer) ?? v));
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
const [prefix, ...additional] = debug_print.prefix;
|
|
2554
|
+
const [arg0, ...argsRest] = args;
|
|
2555
|
+
const format2 = `${prefix || ""} ${arg0}`;
|
|
2556
|
+
const values4 = [...additional, ...argsRest];
|
|
2557
|
+
const parts = format2.split(/(%[%\w])/g);
|
|
2558
|
+
const messageToConsole = [];
|
|
2559
|
+
const valuesToConsole = [];
|
|
2560
|
+
let valIndex = 0;
|
|
2561
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2562
|
+
if (i % 2 === 0) {
|
|
2563
|
+
messageToConsole.push(parts[i]);
|
|
2564
|
+
continue;
|
|
2565
|
+
}
|
|
2566
|
+
const specifier = parts[i];
|
|
2567
|
+
if (specifier === "%%") {
|
|
2568
|
+
messageToConsole.push("%");
|
|
2569
|
+
} else {
|
|
2570
|
+
if (valIndex >= values4.length) {
|
|
2571
|
+
messageToConsole.push(specifier);
|
|
2572
|
+
continue;
|
|
2573
|
+
}
|
|
2574
|
+
const arg = values4[valIndex++];
|
|
2575
|
+
const f = serializeValue(arg, specifier, serializer);
|
|
2576
|
+
if (f != null) {
|
|
2577
|
+
messageToConsole.push("%s");
|
|
2578
|
+
valuesToConsole.push(f);
|
|
2579
|
+
} else {
|
|
2580
|
+
messageToConsole.push(specifier);
|
|
2581
|
+
valuesToConsole.push(arg);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
if (valIndex < values4.length) {
|
|
2586
|
+
const remaining = values4.slice(valIndex);
|
|
2587
|
+
valuesToConsole.push(...remaining.map((v) => serializeValue(v, "", serializer) ?? v));
|
|
2588
|
+
}
|
|
2589
|
+
console.log(messageToConsole.join(""), ...valuesToConsole);
|
|
2475
2590
|
},
|
|
2476
2591
|
{
|
|
2477
2592
|
summary: "打印调试信息到控制台",
|
|
@@ -2481,13 +2596,14 @@ var debug_print = VmLib(
|
|
|
2481
2596
|
examples: ['debug_print("value:", 42);']
|
|
2482
2597
|
},
|
|
2483
2598
|
{
|
|
2484
|
-
prefix: ["MiraScript"]
|
|
2599
|
+
prefix: ["MiraScript"],
|
|
2600
|
+
serializer: defaultSerializer
|
|
2485
2601
|
}
|
|
2486
2602
|
);
|
|
2487
2603
|
var panic = VmLib(
|
|
2488
2604
|
(message) => {
|
|
2489
2605
|
if (message === void 0) console.error(...panic.prefix);
|
|
2490
|
-
else console.error(...panic.prefix, message);
|
|
2606
|
+
else console.error(...panic.prefix, serializeValue(message, "", panic.serializer));
|
|
2491
2607
|
const mgsStr = toString(message, null);
|
|
2492
2608
|
const error = !mgsStr ? "panic" : "panic: " + mgsStr;
|
|
2493
2609
|
throw new VmError(error, void 0);
|
|
@@ -2500,14 +2616,16 @@ var panic = VmLib(
|
|
|
2500
2616
|
examples: ['panic("boom");']
|
|
2501
2617
|
},
|
|
2502
2618
|
{
|
|
2503
|
-
prefix: ["MiraScript"]
|
|
2619
|
+
prefix: ["MiraScript"],
|
|
2620
|
+
serializer: defaultSerializer
|
|
2504
2621
|
}
|
|
2505
2622
|
);
|
|
2506
2623
|
if (typeof location != "undefined") {
|
|
2507
|
-
const badge = "%cMiraScript";
|
|
2624
|
+
const badge = "%cMiraScript%c";
|
|
2508
2625
|
const common = "display: inline-block; padding: 1px 4px; border-radius: 3px;";
|
|
2509
|
-
|
|
2510
|
-
|
|
2626
|
+
const reset = "";
|
|
2627
|
+
debug_print.prefix = [badge, `${common} background: #007acc; color: #fff;`, reset];
|
|
2628
|
+
panic.prefix = [badge, `${common} background: #d23d3d; color: #fff;`, reset];
|
|
2511
2629
|
} else {
|
|
2512
2630
|
if (supportsColor.stdout) {
|
|
2513
2631
|
debug_print.prefix = ["\x1B[44;37m MiraScript \x1B[0m"];
|
|
@@ -2542,10 +2660,9 @@ var to_json = VmLib(
|
|
|
2542
2660
|
);
|
|
2543
2661
|
var from_json = VmLib(
|
|
2544
2662
|
(json, fallback) => {
|
|
2545
|
-
|
|
2546
|
-
if (typeof json != "string") return json;
|
|
2663
|
+
const j = expectString("json", json);
|
|
2547
2664
|
try {
|
|
2548
|
-
return parse(
|
|
2665
|
+
return parse(j);
|
|
2549
2666
|
} catch (ex) {
|
|
2550
2667
|
if (fallback !== void 0) return fallback;
|
|
2551
2668
|
rethrowError("Invalid JSON", ex, null);
|
|
@@ -2782,9 +2899,9 @@ var getTimestamp = (datetime, fallback) => {
|
|
|
2782
2899
|
};
|
|
2783
2900
|
var to_timestamp = VmLib(
|
|
2784
2901
|
(datetime, fallback) => {
|
|
2785
|
-
const
|
|
2786
|
-
if (
|
|
2787
|
-
return
|
|
2902
|
+
const timestamp2 = getTimestamp(datetime, fallback !== void 0);
|
|
2903
|
+
if (timestamp2 == null) return fallback;
|
|
2904
|
+
return timestamp2;
|
|
2788
2905
|
},
|
|
2789
2906
|
{
|
|
2790
2907
|
summary: "将数据转换为 Unix 毫秒时间戳",
|
|
@@ -2799,10 +2916,10 @@ var to_timestamp = VmLib(
|
|
|
2799
2916
|
);
|
|
2800
2917
|
var to_datetime = VmLib(
|
|
2801
2918
|
(datetime, offset, fallback) => {
|
|
2802
|
-
const
|
|
2803
|
-
if (
|
|
2919
|
+
const timestamp2 = getTimestamp(datetime, fallback !== void 0);
|
|
2920
|
+
if (timestamp2 == null) return fallback;
|
|
2804
2921
|
const o = expectNumberRange("offset", offset ?? 0, -24, 24);
|
|
2805
|
-
const dateOffset = new Date(
|
|
2922
|
+
const dateOffset = new Date(timestamp2 + o * 1e3 * 60 * 60);
|
|
2806
2923
|
return {
|
|
2807
2924
|
year: dateOffset.getUTCFullYear(),
|
|
2808
2925
|
month: dateOffset.getUTCMonth() + 1,
|
|
@@ -2838,9 +2955,9 @@ to_datetime(0)
|
|
|
2838
2955
|
);
|
|
2839
2956
|
var to_iso8601 = VmLib(
|
|
2840
2957
|
(datetime, fallback) => {
|
|
2841
|
-
const
|
|
2842
|
-
if (
|
|
2843
|
-
return new Date(
|
|
2958
|
+
const timestamp2 = getTimestamp(datetime, fallback !== void 0);
|
|
2959
|
+
if (timestamp2 == null) return fallback;
|
|
2960
|
+
return new Date(timestamp2).toISOString();
|
|
2844
2961
|
},
|
|
2845
2962
|
{
|
|
2846
2963
|
summary: "将数据转换为 ISO 8601 格式的字符串",
|
|
@@ -3359,39 +3476,64 @@ var diagonal = VmLib(
|
|
|
3359
3476
|
);
|
|
3360
3477
|
|
|
3361
3478
|
// src/vm/lib/loader.ts
|
|
3479
|
+
var VmBuiltinModule = class extends VmModule {
|
|
3480
|
+
constructor(name, value, descriptions) {
|
|
3481
|
+
super(name, value);
|
|
3482
|
+
this.descriptions = descriptions;
|
|
3483
|
+
}
|
|
3484
|
+
/** @inheritdoc */
|
|
3485
|
+
describe(key) {
|
|
3486
|
+
return this.descriptions[key];
|
|
3487
|
+
}
|
|
3488
|
+
};
|
|
3362
3489
|
function wrapEntry(name, value, module) {
|
|
3363
|
-
if (
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
});
|
|
3490
|
+
if (isVmModule(value)) {
|
|
3491
|
+
return [value, void 0];
|
|
3492
|
+
}
|
|
3493
|
+
if (typeof value != "function") {
|
|
3494
|
+
if (value == null || typeof value != "object" || !("value" in value)) {
|
|
3495
|
+
throw new TypeError(`Cannot wrap non-function, non-const value: ${name} in module ${module}`);
|
|
3369
3496
|
}
|
|
3370
|
-
return
|
|
3497
|
+
return [value.value, value.summary || void 0];
|
|
3498
|
+
}
|
|
3499
|
+
if (value.name !== name) {
|
|
3500
|
+
defineProperty(value, "name", {
|
|
3501
|
+
value: name,
|
|
3502
|
+
configurable: true
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
return [
|
|
3506
|
+
VmFunction(value, {
|
|
3371
3507
|
isLib: true,
|
|
3372
3508
|
injectCp: true,
|
|
3373
3509
|
fullName: `${module}.${name}`,
|
|
3374
3510
|
...value
|
|
3375
|
-
})
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
}
|
|
3511
|
+
}),
|
|
3512
|
+
value.summary || void 0
|
|
3513
|
+
];
|
|
3379
3514
|
}
|
|
3380
3515
|
function createModule(name, lib2) {
|
|
3381
3516
|
const mod = create(null);
|
|
3517
|
+
const descriptions = create(null);
|
|
3382
3518
|
for (const [key, value] of entries(lib2)) {
|
|
3383
|
-
|
|
3519
|
+
const [wrappedValue, description] = wrapEntry(key, value, name);
|
|
3520
|
+
mod[key] = wrappedValue;
|
|
3521
|
+
descriptions[key] = description;
|
|
3384
3522
|
}
|
|
3385
|
-
return new
|
|
3523
|
+
return new VmBuiltinModule(name, mod, descriptions);
|
|
3386
3524
|
}
|
|
3387
3525
|
|
|
3388
3526
|
// src/vm/lib/index.ts
|
|
3389
3527
|
for (const [name, value] of entries(global_exports)) {
|
|
3390
|
-
|
|
3528
|
+
const [wrappedValue, description] = wrapEntry(name, value, "global");
|
|
3529
|
+
VM_SHARED_CONTEXT[name] = wrappedValue;
|
|
3530
|
+
VM_SHARED_CONTEXT_DESCRIPTIONS[name] = description;
|
|
3391
3531
|
}
|
|
3392
3532
|
for (const [name, value] of entries(mod_exports)) {
|
|
3393
3533
|
const mod = createModule(name, value);
|
|
3394
|
-
|
|
3534
|
+
const [wrappedValue, description] = wrapEntry(name, mod, "global");
|
|
3535
|
+
VM_SHARED_CONTEXT[name] = wrappedValue;
|
|
3536
|
+
VM_SHARED_CONTEXT_DESCRIPTIONS[name] = description;
|
|
3395
3537
|
}
|
|
3396
3538
|
var lib = Object.freeze(Object.assign(create(null), global_exports, mod_exports));
|
|
3397
3539
|
|
|
@@ -3411,6 +3553,7 @@ export {
|
|
|
3411
3553
|
compileSync,
|
|
3412
3554
|
VmModule,
|
|
3413
3555
|
debug_print,
|
|
3556
|
+
panic,
|
|
3414
3557
|
lib
|
|
3415
3558
|
};
|
|
3416
|
-
//# sourceMappingURL=chunk-
|
|
3559
|
+
//# sourceMappingURL=chunk-BFSB6SQK.js.map
|