@al8b/vm 0.1.0

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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @al8b/vm
2
+
3
+ Execution wrapper around LootiScript for L8B. It exposes the VM class, context builders, host meta functions, and the subset of language primitives the runtime legitimately needs.
4
+
5
+ ## Public API
6
+
7
+ - `L8BVM`
8
+ - `createVMContext`
9
+ - `createMetaFunctions`
10
+ - `setupArrayExtensions`
11
+ - Re-exported language primitives: `Random`, `Routine`
12
+ - Types: `ErrorInfo`, `GlobalAPI`, `MetaFunctions`, `PlayerAPI`, `SystemAPI`, `VMContext`, `VMWarnings`, `WarningInfo`
13
+
14
+ ## Notes
15
+
16
+ - `StorageService` is intentionally not re-exported here; import it from `@al8b/io` directly.
17
+ - Used by `@al8b/runtime` as the host-facing VM boundary.
18
+
19
+ ## Scripts
20
+
21
+ ```bash
22
+ bun run build
23
+ bun run test
24
+ bun run clean
25
+ ```
@@ -0,0 +1,16 @@
1
+ import { MetaFunctions, GlobalAPI, VMContext } from './types/index.mjs';
2
+
3
+ /**
4
+ * VM Context creation utilities
5
+ */
6
+
7
+ /**
8
+ * Create meta functions (built-in functions)
9
+ */
10
+ declare function createMetaFunctions(customPrint?: (text: any) => void): MetaFunctions;
11
+ /**
12
+ * Create VM context
13
+ */
14
+ declare function createVMContext(meta: Partial<MetaFunctions>, global: Partial<GlobalAPI>): VMContext;
15
+
16
+ export { createMetaFunctions, createVMContext };
@@ -0,0 +1,16 @@
1
+ import { MetaFunctions, GlobalAPI, VMContext } from './types/index.js';
2
+
3
+ /**
4
+ * VM Context creation utilities
5
+ */
6
+
7
+ /**
8
+ * Create meta functions (built-in functions)
9
+ */
10
+ declare function createMetaFunctions(customPrint?: (text: any) => void): MetaFunctions;
11
+ /**
12
+ * Create VM context
13
+ */
14
+ declare function createVMContext(meta: Partial<MetaFunctions>, global: Partial<GlobalAPI>): VMContext;
15
+
16
+ export { createMetaFunctions, createVMContext };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/context.ts
22
+ var context_exports = {};
23
+ __export(context_exports, {
24
+ createMetaFunctions: () => createMetaFunctions,
25
+ createVMContext: () => createVMContext
26
+ });
27
+ module.exports = __toCommonJS(context_exports);
28
+ var import_lootiscript = require("@al8b/lootiscript");
29
+ var _baseMeta = {
30
+ round: /* @__PURE__ */ __name((x) => Math.round(x), "round"),
31
+ floor: /* @__PURE__ */ __name((x) => Math.floor(x), "floor"),
32
+ ceil: /* @__PURE__ */ __name((x) => Math.ceil(x), "ceil"),
33
+ abs: /* @__PURE__ */ __name((x) => Math.abs(x), "abs"),
34
+ min: /* @__PURE__ */ __name((x, y) => Math.min(x, y), "min"),
35
+ max: /* @__PURE__ */ __name((x, y) => Math.max(x, y), "max"),
36
+ sqrt: /* @__PURE__ */ __name((x) => Math.sqrt(x), "sqrt"),
37
+ pow: /* @__PURE__ */ __name((x, y) => x ** y, "pow"),
38
+ sin: /* @__PURE__ */ __name((x) => Math.sin(x), "sin"),
39
+ cos: /* @__PURE__ */ __name((x) => Math.cos(x), "cos"),
40
+ tan: /* @__PURE__ */ __name((x) => Math.tan(x), "tan"),
41
+ asin: /* @__PURE__ */ __name((x) => Math.asin(x), "asin"),
42
+ acos: /* @__PURE__ */ __name((x) => Math.acos(x), "acos"),
43
+ atan: /* @__PURE__ */ __name((x) => Math.atan(x), "atan"),
44
+ atan2: /* @__PURE__ */ __name((y, x) => Math.atan2(y, x), "atan2"),
45
+ sind: /* @__PURE__ */ __name((x) => Math.sin(x / 180 * Math.PI), "sind"),
46
+ cosd: /* @__PURE__ */ __name((x) => Math.cos(x / 180 * Math.PI), "cosd"),
47
+ tand: /* @__PURE__ */ __name((x) => Math.tan(x / 180 * Math.PI), "tand"),
48
+ asind: /* @__PURE__ */ __name((x) => Math.asin(x) * 180 / Math.PI, "asind"),
49
+ acosd: /* @__PURE__ */ __name((x) => Math.acos(x) * 180 / Math.PI, "acosd"),
50
+ atand: /* @__PURE__ */ __name((x) => Math.atan(x) * 180 / Math.PI, "atand"),
51
+ atan2d: /* @__PURE__ */ __name((y, x) => Math.atan2(y, x) * 180 / Math.PI, "atan2d"),
52
+ log: /* @__PURE__ */ __name((x) => Math.log(x), "log"),
53
+ exp: /* @__PURE__ */ __name((x) => Math.exp(x), "exp"),
54
+ random: new import_lootiscript.Random(0),
55
+ PI: Math.PI,
56
+ true: 1,
57
+ false: 0
58
+ };
59
+ var _defaultPrint = /* @__PURE__ */ __name((text) => console.log(text), "_defaultPrint");
60
+ function createMetaFunctions(customPrint) {
61
+ return {
62
+ ..._baseMeta,
63
+ print: customPrint ?? _defaultPrint
64
+ };
65
+ }
66
+ __name(createMetaFunctions, "createMetaFunctions");
67
+ function createVMContext(meta, global) {
68
+ const fullMeta = {
69
+ ..._baseMeta,
70
+ print: meta.print ?? _defaultPrint,
71
+ ...meta
72
+ };
73
+ return {
74
+ meta: fullMeta,
75
+ global,
76
+ local: global,
77
+ object: global,
78
+ breakable: 0,
79
+ continuable: 0,
80
+ returnable: 0,
81
+ stack_size: 0,
82
+ timeout: Date.now() + 3e3,
83
+ warnings: {
84
+ using_undefined_variable: {},
85
+ assigning_field_to_undefined: {},
86
+ invoking_non_function: {},
87
+ assigning_api_variable: {},
88
+ assignment_as_condition: {}
89
+ }
90
+ };
91
+ }
92
+ __name(createVMContext, "createVMContext");
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ createMetaFunctions,
96
+ createVMContext
97
+ });
98
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts"],"sourcesContent":["/**\n * VM Context creation utilities\n */\n\nimport { Random } from \"@al8b/lootiscript\";\nimport type { GlobalAPI, MetaFunctions, VMContext } from \"./types\";\n\n// Shared math lambdas — allocated once, reused across all VM instances\nconst _baseMeta = {\n\tround: (x: number) => Math.round(x),\n\tfloor: (x: number) => Math.floor(x),\n\tceil: (x: number) => Math.ceil(x),\n\tabs: (x: number) => Math.abs(x),\n\tmin: (x: number, y: number) => Math.min(x, y),\n\tmax: (x: number, y: number) => Math.max(x, y),\n\tsqrt: (x: number) => Math.sqrt(x),\n\tpow: (x: number, y: number) => x ** y,\n\tsin: (x: number) => Math.sin(x),\n\tcos: (x: number) => Math.cos(x),\n\ttan: (x: number) => Math.tan(x),\n\tasin: (x: number) => Math.asin(x),\n\tacos: (x: number) => Math.acos(x),\n\tatan: (x: number) => Math.atan(x),\n\tatan2: (y: number, x: number) => Math.atan2(y, x),\n\tsind: (x: number) => Math.sin((x / 180) * Math.PI),\n\tcosd: (x: number) => Math.cos((x / 180) * Math.PI),\n\ttand: (x: number) => Math.tan((x / 180) * Math.PI),\n\tasind: (x: number) => (Math.asin(x) * 180) / Math.PI,\n\tacosd: (x: number) => (Math.acos(x) * 180) / Math.PI,\n\tatand: (x: number) => (Math.atan(x) * 180) / Math.PI,\n\tatan2d: (y: number, x: number) => (Math.atan2(y, x) * 180) / Math.PI,\n\tlog: (x: number) => Math.log(x),\n\texp: (x: number) => Math.exp(x),\n\trandom: new Random(0),\n\tPI: Math.PI,\n\ttrue: 1 as const,\n\tfalse: 0 as const,\n};\n\nconst _defaultPrint = (text: any) => console.log(text);\n\n/**\n * Create meta functions (built-in functions)\n */\nexport function createMetaFunctions(customPrint?: (text: any) => void): MetaFunctions {\n\treturn {\n\t\t..._baseMeta,\n\t\tprint: customPrint ?? _defaultPrint,\n\t};\n}\n\n/**\n * Create VM context\n */\nexport function createVMContext(meta: Partial<MetaFunctions>, global: Partial<GlobalAPI>): VMContext {\n\tconst fullMeta: MetaFunctions = {\n\t\t..._baseMeta,\n\t\tprint: meta.print ?? _defaultPrint,\n\t\t...meta,\n\t};\n\n\treturn {\n\t\tmeta: fullMeta as MetaFunctions,\n\t\tglobal: global as GlobalAPI,\n\t\tlocal: global,\n\t\tobject: global,\n\t\tbreakable: 0,\n\t\tcontinuable: 0,\n\t\treturnable: 0,\n\t\tstack_size: 0,\n\t\ttimeout: Date.now() + 3000,\n\t\twarnings: {\n\t\t\tusing_undefined_variable: {},\n\t\t\tassigning_field_to_undefined: {},\n\t\t\tinvoking_non_function: {},\n\t\t\tassigning_api_variable: {},\n\t\t\tassignment_as_condition: {},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAIA,yBAAuB;AAIvB,IAAMA,YAAY;EACjBC,OAAO,wBAACC,MAAcC,KAAKF,MAAMC,CAAAA,GAA1B;EACPE,OAAO,wBAACF,MAAcC,KAAKC,MAAMF,CAAAA,GAA1B;EACPG,MAAM,wBAACH,MAAcC,KAAKE,KAAKH,CAAAA,GAAzB;EACNI,KAAK,wBAACJ,MAAcC,KAAKG,IAAIJ,CAAAA,GAAxB;EACLK,KAAK,wBAACL,GAAWM,MAAcL,KAAKI,IAAIL,GAAGM,CAAAA,GAAtC;EACLC,KAAK,wBAACP,GAAWM,MAAcL,KAAKM,IAAIP,GAAGM,CAAAA,GAAtC;EACLE,MAAM,wBAACR,MAAcC,KAAKO,KAAKR,CAAAA,GAAzB;EACNS,KAAK,w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wBAACC,SAAcC,QAAQR,IAAIO,IAAAA,GAA3B;AAKf,SAASE,oBAAoBC,aAAiC;AACpE,SAAO;IACN,GAAGrC;IACHsC,OAAOD,eAAeJ;EACvB;AACD;AALgBG;AAUT,SAASG,gBAAgBC,MAA8BC,QAA0B;AACvF,QAAMC,WAA0B;IAC/B,GAAG1C;IACHsC,OAAOE,KAAKF,SAASL;IACrB,GAAGO;EACJ;AAEA,SAAO;IACNA,MAAME;IACND;IACAE,OAAOF;IACPG,QAAQH;IACRI,WAAW;IACXC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,SAASC,KAAKC,IAAG,IAAK;IACtBC,UAAU;MACTC,0BAA0B,CAAC;MAC3BC,8BAA8B,CAAC;MAC/BC,uBAAuB,CAAC;MACxBC,wBAAwB,CAAC;MACzBC,yBAAyB,CAAC;IAC3B;EACD;AACD;AAzBgBlB;","names":["_baseMeta","round","x","Math","floor","ceil","abs","min","y","max","sqrt","pow","sin","cos","tan","asin","acos","atan","atan2","sind","PI","cosd","tand","asind","acosd","atand","atan2d","log","exp","random","Random","true","false","_defaultPrint","text","console","createMetaFunctions","customPrint","print","createVMContext","meta","global","fullMeta","local","object","breakable","continuable","returnable","stack_size","timeout","Date","now","warnings","using_undefined_variable","assigning_field_to_undefined","invoking_non_function","assigning_api_variable","assignment_as_condition"]}
@@ -0,0 +1,74 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/context.ts
5
+ import { Random } from "@al8b/lootiscript";
6
+ var _baseMeta = {
7
+ round: /* @__PURE__ */ __name((x) => Math.round(x), "round"),
8
+ floor: /* @__PURE__ */ __name((x) => Math.floor(x), "floor"),
9
+ ceil: /* @__PURE__ */ __name((x) => Math.ceil(x), "ceil"),
10
+ abs: /* @__PURE__ */ __name((x) => Math.abs(x), "abs"),
11
+ min: /* @__PURE__ */ __name((x, y) => Math.min(x, y), "min"),
12
+ max: /* @__PURE__ */ __name((x, y) => Math.max(x, y), "max"),
13
+ sqrt: /* @__PURE__ */ __name((x) => Math.sqrt(x), "sqrt"),
14
+ pow: /* @__PURE__ */ __name((x, y) => x ** y, "pow"),
15
+ sin: /* @__PURE__ */ __name((x) => Math.sin(x), "sin"),
16
+ cos: /* @__PURE__ */ __name((x) => Math.cos(x), "cos"),
17
+ tan: /* @__PURE__ */ __name((x) => Math.tan(x), "tan"),
18
+ asin: /* @__PURE__ */ __name((x) => Math.asin(x), "asin"),
19
+ acos: /* @__PURE__ */ __name((x) => Math.acos(x), "acos"),
20
+ atan: /* @__PURE__ */ __name((x) => Math.atan(x), "atan"),
21
+ atan2: /* @__PURE__ */ __name((y, x) => Math.atan2(y, x), "atan2"),
22
+ sind: /* @__PURE__ */ __name((x) => Math.sin(x / 180 * Math.PI), "sind"),
23
+ cosd: /* @__PURE__ */ __name((x) => Math.cos(x / 180 * Math.PI), "cosd"),
24
+ tand: /* @__PURE__ */ __name((x) => Math.tan(x / 180 * Math.PI), "tand"),
25
+ asind: /* @__PURE__ */ __name((x) => Math.asin(x) * 180 / Math.PI, "asind"),
26
+ acosd: /* @__PURE__ */ __name((x) => Math.acos(x) * 180 / Math.PI, "acosd"),
27
+ atand: /* @__PURE__ */ __name((x) => Math.atan(x) * 180 / Math.PI, "atand"),
28
+ atan2d: /* @__PURE__ */ __name((y, x) => Math.atan2(y, x) * 180 / Math.PI, "atan2d"),
29
+ log: /* @__PURE__ */ __name((x) => Math.log(x), "log"),
30
+ exp: /* @__PURE__ */ __name((x) => Math.exp(x), "exp"),
31
+ random: new Random(0),
32
+ PI: Math.PI,
33
+ true: 1,
34
+ false: 0
35
+ };
36
+ var _defaultPrint = /* @__PURE__ */ __name((text) => console.log(text), "_defaultPrint");
37
+ function createMetaFunctions(customPrint) {
38
+ return {
39
+ ..._baseMeta,
40
+ print: customPrint ?? _defaultPrint
41
+ };
42
+ }
43
+ __name(createMetaFunctions, "createMetaFunctions");
44
+ function createVMContext(meta, global) {
45
+ const fullMeta = {
46
+ ..._baseMeta,
47
+ print: meta.print ?? _defaultPrint,
48
+ ...meta
49
+ };
50
+ return {
51
+ meta: fullMeta,
52
+ global,
53
+ local: global,
54
+ object: global,
55
+ breakable: 0,
56
+ continuable: 0,
57
+ returnable: 0,
58
+ stack_size: 0,
59
+ timeout: Date.now() + 3e3,
60
+ warnings: {
61
+ using_undefined_variable: {},
62
+ assigning_field_to_undefined: {},
63
+ invoking_non_function: {},
64
+ assigning_api_variable: {},
65
+ assignment_as_condition: {}
66
+ }
67
+ };
68
+ }
69
+ __name(createVMContext, "createVMContext");
70
+ export {
71
+ createMetaFunctions,
72
+ createVMContext
73
+ };
74
+ //# sourceMappingURL=context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts"],"sourcesContent":["/**\n * VM Context creation utilities\n */\n\nimport { Random } from \"@al8b/lootiscript\";\nimport type { GlobalAPI, MetaFunctions, VMContext } from \"./types\";\n\n// Shared math lambdas — allocated once, reused across all VM instances\nconst _baseMeta = {\n\tround: (x: number) => Math.round(x),\n\tfloor: (x: number) => Math.floor(x),\n\tceil: (x: number) => Math.ceil(x),\n\tabs: (x: number) => Math.abs(x),\n\tmin: (x: number, y: number) => Math.min(x, y),\n\tmax: (x: number, y: number) => Math.max(x, y),\n\tsqrt: (x: number) => Math.sqrt(x),\n\tpow: (x: number, y: number) => x ** y,\n\tsin: (x: number) => Math.sin(x),\n\tcos: (x: number) => Math.cos(x),\n\ttan: (x: number) => Math.tan(x),\n\tasin: (x: number) => Math.asin(x),\n\tacos: (x: number) => Math.acos(x),\n\tatan: (x: number) => Math.atan(x),\n\tatan2: (y: number, x: number) => Math.atan2(y, x),\n\tsind: (x: number) => Math.sin((x / 180) * Math.PI),\n\tcosd: (x: number) => Math.cos((x / 180) * Math.PI),\n\ttand: (x: number) => Math.tan((x / 180) * Math.PI),\n\tasind: (x: number) => (Math.asin(x) * 180) / Math.PI,\n\tacosd: (x: number) => (Math.acos(x) * 180) / Math.PI,\n\tatand: (x: number) => (Math.atan(x) * 180) / Math.PI,\n\tatan2d: (y: number, x: number) => (Math.atan2(y, x) * 180) / Math.PI,\n\tlog: (x: number) => Math.log(x),\n\texp: (x: number) => Math.exp(x),\n\trandom: new Random(0),\n\tPI: Math.PI,\n\ttrue: 1 as const,\n\tfalse: 0 as const,\n};\n\nconst _defaultPrint = (text: any) => console.log(text);\n\n/**\n * Create meta functions (built-in functions)\n */\nexport function createMetaFunctions(customPrint?: (text: any) => void): MetaFunctions {\n\treturn {\n\t\t..._baseMeta,\n\t\tprint: customPrint ?? _defaultPrint,\n\t};\n}\n\n/**\n * Create VM context\n */\nexport function createVMContext(meta: Partial<MetaFunctions>, global: Partial<GlobalAPI>): VMContext {\n\tconst fullMeta: MetaFunctions = {\n\t\t..._baseMeta,\n\t\tprint: meta.print ?? _defaultPrint,\n\t\t...meta,\n\t};\n\n\treturn {\n\t\tmeta: fullMeta as MetaFunctions,\n\t\tglobal: global as GlobalAPI,\n\t\tlocal: global,\n\t\tobject: global,\n\t\tbreakable: 0,\n\t\tcontinuable: 0,\n\t\treturnable: 0,\n\t\tstack_size: 0,\n\t\ttimeout: Date.now() + 3000,\n\t\twarnings: {\n\t\t\tusing_undefined_variable: {},\n\t\t\tassigning_field_to_undefined: {},\n\t\t\tinvoking_non_function: {},\n\t\t\tassigning_api_variable: {},\n\t\t\tassignment_as_condition: {},\n\t\t},\n\t};\n}\n"],"mappings":";;;;AAIA,SAASA,cAAc;AAIvB,IAAMC,YAAY;EACjBC,OAAO,wBAACC,MAAcC,KAAKF,MAAMC,CAAAA,GAA1B;EACPE,OAAO,wBAACF,MAAcC,KAAKC,MAAMF,CAAAA,GAA1B;EACPG,MAAM,wBAACH,MAAcC,KAAKE,KAAKH,CAAAA,GAAzB;EACNI,KAAK,wBAACJ,MAAcC,KAAKG,IAAIJ,CAAAA,GAAxB;EACLK,KAAK,wBAACL,GAAWM,MAAcL,KAAKI,IAAIL,GAAGM,CAAAA,GAAtC;EACLC,KAAK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1B,CAAAA,GAAxB;EACL2B,QAAQ,IAAIC,OAAO,CAAA;EACnBV,IAAIjB,KAAKiB;EACTW,MAAM;EACNC,OAAO;AACR;AAEA,IAAMC,gBAAgB,wBAACC,SAAcC,QAAQR,IAAIO,IAAAA,GAA3B;AAKf,SAASE,oBAAoBC,aAAiC;AACpE,SAAO;IACN,GAAGrC;IACHsC,OAAOD,eAAeJ;EACvB;AACD;AALgBG;AAUT,SAASG,gBAAgBC,MAA8BC,QAA0B;AACvF,QAAMC,WAA0B;IAC/B,GAAG1C;IACHsC,OAAOE,KAAKF,SAASL;IACrB,GAAGO;EACJ;AAEA,SAAO;IACNA,MAAME;IACND;IACAE,OAAOF;IACPG,QAAQH;IACRI,WAAW;IACXC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,SAASC,KAAKC,IAAG,IAAK;IACtBC,UAAU;MACTC,0BAA0B,CAAC;MAC3BC,8BAA8B,CAAC;MAC/BC,uBAAuB,CAAC;MACxBC,wBAAwB,CAAC;MACzBC,yBAAyB,CAAC;IAC3B;EACD;AACD;AAzBgBlB;","names":["Random","_baseMeta","round","x","Math","floor","ceil","abs","min","y","max","sqrt","pow","sin","cos","tan","asin","acos","atan","atan2","sind","PI","cosd","tand","asind","acosd","atand","atan2d","log","exp","random","Random","true","false","_defaultPrint","text","console","createMetaFunctions","customPrint","print","createVMContext","meta","global","fullMeta","local","object","breakable","continuable","returnable","stack_size","timeout","Date","now","warnings","using_undefined_variable","assigning_field_to_undefined","invoking_non_function","assigning_api_variable","assignment_as_condition"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Array extensions
3
+ */
4
+ /**
5
+ * Setup array extensions
6
+ */
7
+ declare function setupArrayExtensions(): void;
8
+ declare global {
9
+ interface Array<T> {
10
+ insert(element: T): T;
11
+ insertAt(element: T, index: number): T;
12
+ remove(index: number): T | 0;
13
+ removeElement(element: T): T | 0;
14
+ contains(element: T): 0 | 1;
15
+ sortList(fn?: (a: T, b: T) => number): T[];
16
+ }
17
+ }
18
+
19
+ export { setupArrayExtensions };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Array extensions
3
+ */
4
+ /**
5
+ * Setup array extensions
6
+ */
7
+ declare function setupArrayExtensions(): void;
8
+ declare global {
9
+ interface Array<T> {
10
+ insert(element: T): T;
11
+ insertAt(element: T, index: number): T;
12
+ remove(index: number): T | 0;
13
+ removeElement(element: T): T | 0;
14
+ contains(element: T): 0 | 1;
15
+ sortList(fn?: (a: T, b: T) => number): T[];
16
+ }
17
+ }
18
+
19
+ export { setupArrayExtensions };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/extensions.ts
22
+ var extensions_exports = {};
23
+ __export(extensions_exports, {
24
+ setupArrayExtensions: () => setupArrayExtensions
25
+ });
26
+ module.exports = __toCommonJS(extensions_exports);
27
+ function setupArrayExtensions() {
28
+ if (!Array.prototype.insert) {
29
+ Array.prototype.insert = function(element) {
30
+ this.splice(0, 0, element);
31
+ return element;
32
+ };
33
+ }
34
+ if (!Array.prototype.insertAt) {
35
+ Array.prototype.insertAt = function(element, index) {
36
+ if (index >= 0 && index < this.length) {
37
+ this.splice(index, 0, element);
38
+ } else {
39
+ this.push(element);
40
+ }
41
+ return element;
42
+ };
43
+ }
44
+ if (!Array.prototype.remove) {
45
+ Array.prototype.remove = function(index) {
46
+ if (index >= 0 && index < this.length) {
47
+ return this.splice(index, 1)[0];
48
+ }
49
+ return 0;
50
+ };
51
+ }
52
+ if (!Array.prototype.removeElement) {
53
+ Array.prototype.removeElement = function(element) {
54
+ const index = this.indexOf(element);
55
+ if (index >= 0) {
56
+ return this.splice(index, 1)[0];
57
+ }
58
+ return 0;
59
+ };
60
+ }
61
+ if (!Array.prototype.contains) {
62
+ Array.prototype.contains = function(element) {
63
+ return this.indexOf(element) >= 0 ? 1 : 0;
64
+ };
65
+ }
66
+ if (!Array.prototype.sortList) {
67
+ Array.prototype.sortList = function(fn) {
68
+ if (fn) {
69
+ return this.sort(fn);
70
+ }
71
+ return this.sort();
72
+ };
73
+ }
74
+ }
75
+ __name(setupArrayExtensions, "setupArrayExtensions");
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ setupArrayExtensions
79
+ });
80
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extensions.ts"],"sourcesContent":["/**\n * Array extensions\n */\n\n/**\n * Setup array extensions\n */\nexport function setupArrayExtensions(): void {\n\t// Insert element at beginning of array (returns the inserted element)\n\tif (!Array.prototype.insert) {\n\t\tArray.prototype.insert = function (element: any) {\n\t\t\tthis.splice(0, 0, element);\n\t\t\treturn element;\n\t\t};\n\t}\n\n\t// Insert element at specific index (returns the inserted element)\n\tif (!Array.prototype.insertAt) {\n\t\tArray.prototype.insertAt = function (element: any, index: number) {\n\t\t\tif (index >= 0 && index < this.length) {\n\t\t\t\tthis.splice(index, 0, element);\n\t\t\t} else {\n\t\t\t\tthis.push(element);\n\t\t\t}\n\t\t\treturn element;\n\t\t};\n\t}\n\n\t// Remove element at index (returns removed element or 0 if out of bounds)\n\tif (!Array.prototype.remove) {\n\t\tArray.prototype.remove = function (index: number) {\n\t\t\tif (index >= 0 && index < this.length) {\n\t\t\t\treturn this.splice(index, 1)[0];\n\t\t\t}\n\t\t\treturn 0;\n\t\t};\n\t}\n\n\t// Remove first occurrence of element (returns removed element or 0 if not found)\n\tif (!Array.prototype.removeElement) {\n\t\tArray.prototype.removeElement = function (element: any) {\n\t\t\tconst index = this.indexOf(element);\n\t\t\tif (index >= 0) {\n\t\t\t\treturn this.splice(index, 1)[0];\n\t\t\t}\n\t\t\treturn 0;\n\t\t};\n\t}\n\n\t// Check if array contains element (returns 1 if found, 0 if not found)\n\tif (!Array.prototype.contains) {\n\t\tArray.prototype.contains = function (element: any) {\n\t\t\treturn this.indexOf(element) >= 0 ? 1 : 0;\n\t\t};\n\t}\n\n\t// Sort array with optional comparator function\n\tif (!Array.prototype.sortList) {\n\t\tArray.prototype.sortList = function (fn?: (a: any, b: any) => number) {\n\t\t\tif (fn) {\n\t\t\t\treturn this.sort(fn);\n\t\t\t}\n\t\t\treturn this.sort();\n\t\t};\n\t}\n}\n\n// TypeScript type declarations for Array prototype extensions\ndeclare global {\n\tinterface Array<T> {\n\t\tinsert(element: T): T;\n\t\tinsertAt(element: T, index: number): T;\n\t\tremove(index: number): T | 0;\n\t\tremoveElement(element: T): T | 0;\n\t\tcontains(element: T): 0 | 1;\n\t\tsortList(fn?: (a: T, b: T) => number): T[];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAOO,SAASA,uBAAAA;AAEf,MAAI,CAACC,MAAMC,UAAUC,QAAQ;AAC5BF,UAAMC,UAAUC,SAAS,SAAUC,SAAY;AAC9C,WAAKC,OAAO,GAAG,GAAGD,OAAAA;AAClB,aAAOA;IACR;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUI,UAAU;AAC9BL,UAAMC,UAAUI,WAAW,SAAUF,SAAcG,OAAa;AAC/D,UAAIA,SAAS,KAAKA,QAAQ,KAAKC,QAAQ;AACtC,aAAKH,OAAOE,OAAO,GAAGH,OAAAA;MACvB,OAAO;AACN,aAAKK,KAAKL,OAAAA;MACX;AACA,aAAOA;IACR;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUQ,QAAQ;AAC5BT,UAAMC,UAAUQ,SAAS,SAAUH,OAAa;AAC/C,UAAIA,SAAS,KAAKA,QAAQ,KAAKC,QAAQ;AACtC,eAAO,KAAKH,OAAOE,OAAO,CAAA,EAAG,CAAA;MAC9B;AACA,aAAO;IACR;EACD;AAGA,MAAI,CAACN,MAAMC,UAAUS,eAAe;AACnCV,UAAMC,UAAUS,gBAAgB,SAAUP,SAAY;AACrD,YAAMG,QAAQ,KAAKK,QAAQR,OAAAA;AAC3B,UAAIG,SAAS,GAAG;AACf,eAAO,KAAKF,OAAOE,OAAO,CAAA,EAAG,CAAA;MAC9B;AACA,aAAO;IACR;EACD;AAGA,MAAI,CAACN,MAAMC,UAAUW,UAAU;AAC9BZ,UAAMC,UAAUW,WAAW,SAAUT,SAAY;AAChD,aAAO,KAAKQ,QAAQR,OAAAA,KAAY,IAAI,IAAI;IACzC;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUY,UAAU;AAC9Bb,UAAMC,UAAUY,WAAW,SAAUC,IAA+B;AACnE,UAAIA,IAAI;AACP,eAAO,KAAKC,KAAKD,EAAAA;MAClB;AACA,aAAO,KAAKC,KAAI;IACjB;EACD;AACD;AA1DgBhB;","names":["setupArrayExtensions","Array","prototype","insert","element","splice","insertAt","index","length","push","remove","removeElement","indexOf","contains","sortList","fn","sort"]}
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/extensions.ts
5
+ function setupArrayExtensions() {
6
+ if (!Array.prototype.insert) {
7
+ Array.prototype.insert = function(element) {
8
+ this.splice(0, 0, element);
9
+ return element;
10
+ };
11
+ }
12
+ if (!Array.prototype.insertAt) {
13
+ Array.prototype.insertAt = function(element, index) {
14
+ if (index >= 0 && index < this.length) {
15
+ this.splice(index, 0, element);
16
+ } else {
17
+ this.push(element);
18
+ }
19
+ return element;
20
+ };
21
+ }
22
+ if (!Array.prototype.remove) {
23
+ Array.prototype.remove = function(index) {
24
+ if (index >= 0 && index < this.length) {
25
+ return this.splice(index, 1)[0];
26
+ }
27
+ return 0;
28
+ };
29
+ }
30
+ if (!Array.prototype.removeElement) {
31
+ Array.prototype.removeElement = function(element) {
32
+ const index = this.indexOf(element);
33
+ if (index >= 0) {
34
+ return this.splice(index, 1)[0];
35
+ }
36
+ return 0;
37
+ };
38
+ }
39
+ if (!Array.prototype.contains) {
40
+ Array.prototype.contains = function(element) {
41
+ return this.indexOf(element) >= 0 ? 1 : 0;
42
+ };
43
+ }
44
+ if (!Array.prototype.sortList) {
45
+ Array.prototype.sortList = function(fn) {
46
+ if (fn) {
47
+ return this.sort(fn);
48
+ }
49
+ return this.sort();
50
+ };
51
+ }
52
+ }
53
+ __name(setupArrayExtensions, "setupArrayExtensions");
54
+ export {
55
+ setupArrayExtensions
56
+ };
57
+ //# sourceMappingURL=extensions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extensions.ts"],"sourcesContent":["/**\n * Array extensions\n */\n\n/**\n * Setup array extensions\n */\nexport function setupArrayExtensions(): void {\n\t// Insert element at beginning of array (returns the inserted element)\n\tif (!Array.prototype.insert) {\n\t\tArray.prototype.insert = function (element: any) {\n\t\t\tthis.splice(0, 0, element);\n\t\t\treturn element;\n\t\t};\n\t}\n\n\t// Insert element at specific index (returns the inserted element)\n\tif (!Array.prototype.insertAt) {\n\t\tArray.prototype.insertAt = function (element: any, index: number) {\n\t\t\tif (index >= 0 && index < this.length) {\n\t\t\t\tthis.splice(index, 0, element);\n\t\t\t} else {\n\t\t\t\tthis.push(element);\n\t\t\t}\n\t\t\treturn element;\n\t\t};\n\t}\n\n\t// Remove element at index (returns removed element or 0 if out of bounds)\n\tif (!Array.prototype.remove) {\n\t\tArray.prototype.remove = function (index: number) {\n\t\t\tif (index >= 0 && index < this.length) {\n\t\t\t\treturn this.splice(index, 1)[0];\n\t\t\t}\n\t\t\treturn 0;\n\t\t};\n\t}\n\n\t// Remove first occurrence of element (returns removed element or 0 if not found)\n\tif (!Array.prototype.removeElement) {\n\t\tArray.prototype.removeElement = function (element: any) {\n\t\t\tconst index = this.indexOf(element);\n\t\t\tif (index >= 0) {\n\t\t\t\treturn this.splice(index, 1)[0];\n\t\t\t}\n\t\t\treturn 0;\n\t\t};\n\t}\n\n\t// Check if array contains element (returns 1 if found, 0 if not found)\n\tif (!Array.prototype.contains) {\n\t\tArray.prototype.contains = function (element: any) {\n\t\t\treturn this.indexOf(element) >= 0 ? 1 : 0;\n\t\t};\n\t}\n\n\t// Sort array with optional comparator function\n\tif (!Array.prototype.sortList) {\n\t\tArray.prototype.sortList = function (fn?: (a: any, b: any) => number) {\n\t\t\tif (fn) {\n\t\t\t\treturn this.sort(fn);\n\t\t\t}\n\t\t\treturn this.sort();\n\t\t};\n\t}\n}\n\n// TypeScript type declarations for Array prototype extensions\ndeclare global {\n\tinterface Array<T> {\n\t\tinsert(element: T): T;\n\t\tinsertAt(element: T, index: number): T;\n\t\tremove(index: number): T | 0;\n\t\tremoveElement(element: T): T | 0;\n\t\tcontains(element: T): 0 | 1;\n\t\tsortList(fn?: (a: T, b: T) => number): T[];\n\t}\n}\n"],"mappings":";;;;AAOO,SAASA,uBAAAA;AAEf,MAAI,CAACC,MAAMC,UAAUC,QAAQ;AAC5BF,UAAMC,UAAUC,SAAS,SAAUC,SAAY;AAC9C,WAAKC,OAAO,GAAG,GAAGD,OAAAA;AAClB,aAAOA;IACR;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUI,UAAU;AAC9BL,UAAMC,UAAUI,WAAW,SAAUF,SAAcG,OAAa;AAC/D,UAAIA,SAAS,KAAKA,QAAQ,KAAKC,QAAQ;AACtC,aAAKH,OAAOE,OAAO,GAAGH,OAAAA;MACvB,OAAO;AACN,aAAKK,KAAKL,OAAAA;MACX;AACA,aAAOA;IACR;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUQ,QAAQ;AAC5BT,UAAMC,UAAUQ,SAAS,SAAUH,OAAa;AAC/C,UAAIA,SAAS,KAAKA,QAAQ,KAAKC,QAAQ;AACtC,eAAO,KAAKH,OAAOE,OAAO,CAAA,EAAG,CAAA;MAC9B;AACA,aAAO;IACR;EACD;AAGA,MAAI,CAACN,MAAMC,UAAUS,eAAe;AACnCV,UAAMC,UAAUS,gBAAgB,SAAUP,SAAY;AACrD,YAAMG,QAAQ,KAAKK,QAAQR,OAAAA;AAC3B,UAAIG,SAAS,GAAG;AACf,eAAO,KAAKF,OAAOE,OAAO,CAAA,EAAG,CAAA;MAC9B;AACA,aAAO;IACR;EACD;AAGA,MAAI,CAACN,MAAMC,UAAUW,UAAU;AAC9BZ,UAAMC,UAAUW,WAAW,SAAUT,SAAY;AAChD,aAAO,KAAKQ,QAAQR,OAAAA,KAAY,IAAI,IAAI;IACzC;EACD;AAGA,MAAI,CAACH,MAAMC,UAAUY,UAAU;AAC9Bb,UAAMC,UAAUY,WAAW,SAAUC,IAA+B;AACnE,UAAIA,IAAI;AACP,eAAO,KAAKC,KAAKD,EAAAA;MAClB;AACA,aAAO,KAAKC,KAAI;IACjB;EACD;AACD;AA1DgBhB;","names":["setupArrayExtensions","Array","prototype","insert","element","splice","insertAt","index","length","push","remove","removeElement","indexOf","contains","sortList","fn","sort"]}
@@ -0,0 +1,6 @@
1
+ export { createMetaFunctions, createVMContext } from './context.mjs';
2
+ export { setupArrayExtensions } from './extensions.mjs';
3
+ export { L8BVM } from './l8bvm.mjs';
4
+ export { ErrorInfo, GlobalAPI, MetaFunctions, PlayerAPI, SystemAPI, VMContext, VMWarnings, WarningInfo } from './types/index.mjs';
5
+ export { Random, Routine } from '@al8b/lootiscript';
6
+ import '@al8b/io';
@@ -0,0 +1,6 @@
1
+ export { createMetaFunctions, createVMContext } from './context.js';
2
+ export { setupArrayExtensions } from './extensions.js';
3
+ export { L8BVM } from './l8bvm.js';
4
+ export { ErrorInfo, GlobalAPI, MetaFunctions, PlayerAPI, SystemAPI, VMContext, VMWarnings, WarningInfo } from './types/index.js';
5
+ export { Random, Routine } from '@al8b/lootiscript';
6
+ import '@al8b/io';