@ifc-lite/sandbox 1.7.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/LICENSE +373 -0
- package/dist/bridge-schema.d.ts +57 -0
- package/dist/bridge-schema.d.ts.map +1 -0
- package/dist/bridge-schema.js +474 -0
- package/dist/bridge-schema.js.map +1 -0
- package/dist/bridge.d.ts +23 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +37 -0
- package/dist/bridge.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox.d.ts +41 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +135 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/transpile.d.ts +8 -0
- package/dist/transpile.d.ts.map +1 -0
- package/dist/transpile.js +149 -0
- package/dist/transpile.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BimContext } from '@ifc-lite/sdk';
|
|
2
|
+
import type { SandboxConfig, ScriptResult, LogEntry } from './types.js';
|
|
3
|
+
export declare class Sandbox {
|
|
4
|
+
private sdk;
|
|
5
|
+
private runtime;
|
|
6
|
+
private vm;
|
|
7
|
+
private logs;
|
|
8
|
+
private config;
|
|
9
|
+
/** Mutable start time — updated by eval(), read by interrupt handler */
|
|
10
|
+
private evalStartTime;
|
|
11
|
+
constructor(sdk: BimContext, config?: SandboxConfig);
|
|
12
|
+
/** Initialize the sandbox (loads WASM module if not cached) */
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute a script in the sandbox.
|
|
16
|
+
*
|
|
17
|
+
* Supports both JavaScript and TypeScript (TypeScript is type-stripped before execution).
|
|
18
|
+
*/
|
|
19
|
+
eval(code: string, options?: {
|
|
20
|
+
filename?: string;
|
|
21
|
+
typescript?: boolean;
|
|
22
|
+
}): Promise<ScriptResult>;
|
|
23
|
+
/** Dispose the sandbox and free WASM memory */
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
/** Error thrown when a sandboxed script fails */
|
|
27
|
+
export declare class ScriptError extends Error {
|
|
28
|
+
readonly logs: LogEntry[];
|
|
29
|
+
readonly durationMs: number;
|
|
30
|
+
constructor(message: string, logs: LogEntry[], durationMs: number);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create and initialize a sandbox.
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
* const sandbox = await createSandbox(bim, { permissions: { mutate: true } })
|
|
37
|
+
* const result = await sandbox.eval('bim.query.byType("IfcWall")')
|
|
38
|
+
* sandbox.dispose()
|
|
39
|
+
*/
|
|
40
|
+
export declare function createSandbox(sdk: BimContext, config?: SandboxConfig): Promise<Sandbox>;
|
|
41
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAexE,qBAAa,OAAO;IAShB,OAAO,CAAC,GAAG;IARb,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,EAAE,CAA+B;IACzC,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,MAAM,CAA0B;IACxC,wEAAwE;IACxE,OAAO,CAAC,aAAa,CAAK;gBAGhB,GAAG,EAAE,UAAU,EACvB,MAAM,GAAE,aAAkB;IAQ5B,+DAA+D;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IA4CtG,+CAA+C;IAC/C,OAAO,IAAI,IAAI;CAYhB;AAED,iDAAiD;AACjD,qBAAa,WAAY,SAAQ,KAAK;aAGlB,IAAI,EAAE,QAAQ,EAAE;aAChB,UAAU,EAAE,MAAM;gBAFlC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,QAAQ,EAAE,EAChB,UAAU,EAAE,MAAM;CAKrC;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,UAAU,EACf,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC,CAIlB"}
|
package/dist/sandbox.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Sandbox — QuickJS-in-WASM script execution environment.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - One WASM module loaded per app lifetime (shared across sandboxes)
|
|
9
|
+
* - Each sandbox creates a fresh QuickJS context (cheap — a few KB)
|
|
10
|
+
* - The `bim` API is built inside the context via bridge.ts
|
|
11
|
+
* - Scripts run synchronously inside QuickJS
|
|
12
|
+
* - Memory and CPU limits enforced per-context
|
|
13
|
+
* - TypeScript is transpiled to JS before execution (type-stripping)
|
|
14
|
+
*/
|
|
15
|
+
import { getQuickJS } from 'quickjs-emscripten';
|
|
16
|
+
import { DEFAULT_LIMITS, DEFAULT_PERMISSIONS } from './types.js';
|
|
17
|
+
import { buildBridge } from './bridge.js';
|
|
18
|
+
import { transpileTypeScript } from './transpile.js';
|
|
19
|
+
/** Cached WASM module promise — deduplicates concurrent init calls */
|
|
20
|
+
let modulePromise = null;
|
|
21
|
+
function getModule() {
|
|
22
|
+
if (!modulePromise) {
|
|
23
|
+
modulePromise = getQuickJS();
|
|
24
|
+
}
|
|
25
|
+
return modulePromise;
|
|
26
|
+
}
|
|
27
|
+
export class Sandbox {
|
|
28
|
+
sdk;
|
|
29
|
+
runtime = null;
|
|
30
|
+
vm = null;
|
|
31
|
+
logs = [];
|
|
32
|
+
config;
|
|
33
|
+
/** Mutable start time — updated by eval(), read by interrupt handler */
|
|
34
|
+
evalStartTime = 0;
|
|
35
|
+
constructor(sdk, config = {}) {
|
|
36
|
+
this.sdk = sdk;
|
|
37
|
+
this.config = {
|
|
38
|
+
permissions: { ...DEFAULT_PERMISSIONS, ...config.permissions },
|
|
39
|
+
limits: { ...DEFAULT_LIMITS, ...config.limits },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Initialize the sandbox (loads WASM module if not cached) */
|
|
43
|
+
async init() {
|
|
44
|
+
const module = await getModule();
|
|
45
|
+
this.runtime = module.newRuntime();
|
|
46
|
+
// Apply resource limits
|
|
47
|
+
this.runtime.setMemoryLimit(this.config.limits.memoryBytes ?? DEFAULT_LIMITS.memoryBytes);
|
|
48
|
+
this.runtime.setMaxStackSize(this.config.limits.maxStackBytes ?? DEFAULT_LIMITS.maxStackBytes);
|
|
49
|
+
// CPU limit via interrupt handler — reads instance field set by eval()
|
|
50
|
+
const timeoutMs = this.config.limits.timeoutMs ?? DEFAULT_LIMITS.timeoutMs;
|
|
51
|
+
this.runtime.setInterruptHandler(() => {
|
|
52
|
+
if (this.evalStartTime > 0 && Date.now() - this.evalStartTime > timeoutMs) {
|
|
53
|
+
return true; // Interrupt execution
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
});
|
|
57
|
+
this.vm = this.runtime.newContext();
|
|
58
|
+
// Build the bim API inside the sandbox
|
|
59
|
+
const { logs } = buildBridge(this.vm, this.sdk, this.config.permissions);
|
|
60
|
+
this.logs = logs;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Execute a script in the sandbox.
|
|
64
|
+
*
|
|
65
|
+
* Supports both JavaScript and TypeScript (TypeScript is type-stripped before execution).
|
|
66
|
+
*/
|
|
67
|
+
async eval(code, options) {
|
|
68
|
+
if (!this.vm) {
|
|
69
|
+
throw new Error('Sandbox not initialized. Call init() first.');
|
|
70
|
+
}
|
|
71
|
+
// Clear previous logs
|
|
72
|
+
this.logs.length = 0;
|
|
73
|
+
// Transpile TypeScript — always strip types for safety.
|
|
74
|
+
// The transpiler is a no-op for plain JavaScript, and the heuristic
|
|
75
|
+
// looksLikeTypeScript missed patterns like Record<string, number>.
|
|
76
|
+
let jsCode = code;
|
|
77
|
+
if (options?.typescript !== false) {
|
|
78
|
+
jsCode = await transpileTypeScript(code);
|
|
79
|
+
}
|
|
80
|
+
this.evalStartTime = Date.now();
|
|
81
|
+
const result = this.vm.evalCode(jsCode, options?.filename ?? 'script.js');
|
|
82
|
+
const durationMs = Date.now() - this.evalStartTime;
|
|
83
|
+
this.evalStartTime = 0;
|
|
84
|
+
if (result.error) {
|
|
85
|
+
const errorData = this.vm.dump(result.error);
|
|
86
|
+
result.error.dispose();
|
|
87
|
+
throw new ScriptError(typeof errorData === 'object' && errorData !== null && 'message' in errorData
|
|
88
|
+
? String(errorData.message)
|
|
89
|
+
: String(errorData), this.logs, durationMs);
|
|
90
|
+
}
|
|
91
|
+
const value = this.vm.dump(result.value);
|
|
92
|
+
result.value.dispose();
|
|
93
|
+
return {
|
|
94
|
+
value,
|
|
95
|
+
logs: [...this.logs],
|
|
96
|
+
durationMs,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Dispose the sandbox and free WASM memory */
|
|
100
|
+
dispose() {
|
|
101
|
+
if (this.vm) {
|
|
102
|
+
this.vm.dispose();
|
|
103
|
+
this.vm = null;
|
|
104
|
+
}
|
|
105
|
+
if (this.runtime) {
|
|
106
|
+
this.runtime.dispose();
|
|
107
|
+
this.runtime = null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Error thrown when a sandboxed script fails */
|
|
112
|
+
export class ScriptError extends Error {
|
|
113
|
+
logs;
|
|
114
|
+
durationMs;
|
|
115
|
+
constructor(message, logs, durationMs) {
|
|
116
|
+
super(message);
|
|
117
|
+
this.logs = logs;
|
|
118
|
+
this.durationMs = durationMs;
|
|
119
|
+
this.name = 'ScriptError';
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create and initialize a sandbox.
|
|
124
|
+
*
|
|
125
|
+
* Usage:
|
|
126
|
+
* const sandbox = await createSandbox(bim, { permissions: { mutate: true } })
|
|
127
|
+
* const result = await sandbox.eval('bim.query.byType("IfcWall")')
|
|
128
|
+
* sandbox.dispose()
|
|
129
|
+
*/
|
|
130
|
+
export async function createSandbox(sdk, config) {
|
|
131
|
+
const sandbox = new Sandbox(sdk, config);
|
|
132
|
+
await sandbox.init();
|
|
133
|
+
return sandbox;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAoE,MAAM,oBAAoB,CAAC;AAGlH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,sEAAsE;AACtE,IAAI,aAAa,GAAsC,IAAI,CAAC;AAE5D,SAAS,SAAS;IAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,U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sB;IAEtB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACrB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Transpile TypeScript to JavaScript by stripping types, then strip imports */
|
|
2
|
+
export declare function transpileTypeScript(code: string): Promise<string>;
|
|
3
|
+
/**
|
|
4
|
+
* Regex-based type stripping — removes TypeScript-only syntax.
|
|
5
|
+
* Not a full parser, but handles patterns commonly used in BIM scripts.
|
|
6
|
+
*/
|
|
7
|
+
export declare function naiveTypeStrip(code: string): string;
|
|
8
|
+
//# sourceMappingURL=transpile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../src/transpile.ts"],"names":[],"mappings":"AAgEA,gFAAgF;AAChF,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBvE;AAiCD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BnD"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
let esbuildReady = null;
|
|
5
|
+
/**
|
|
6
|
+
* Lazy-load and initialize esbuild-wasm.
|
|
7
|
+
* First script run pays the ~10MB WASM download; subsequent runs are instant.
|
|
8
|
+
* Returns null if unavailable (WASM blocked, CDN down, etc.).
|
|
9
|
+
*/
|
|
10
|
+
function getEsbuild() {
|
|
11
|
+
if (esbuildReady)
|
|
12
|
+
return esbuildReady;
|
|
13
|
+
esbuildReady = (async () => {
|
|
14
|
+
try {
|
|
15
|
+
// Dynamic import — Vite code-splits esbuild-wasm into a separate chunk
|
|
16
|
+
const mod = await import('esbuild-wasm');
|
|
17
|
+
const esbuild = (mod.default ?? mod);
|
|
18
|
+
// Resolve WASM binary URL
|
|
19
|
+
let wasmURL;
|
|
20
|
+
try {
|
|
21
|
+
// Vite: import the .wasm as a URL asset (works in dev + production)
|
|
22
|
+
// @ts-expect-error — Vite-specific ?url suffix for asset imports
|
|
23
|
+
const wasmMod = await import('esbuild-wasm/esbuild.wasm?url');
|
|
24
|
+
wasmURL = wasmMod.default;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Fallback: CDN (version-pinned to match installed package)
|
|
28
|
+
wasmURL = `https://unpkg.com/esbuild-wasm@0.27.3/esbuild.wasm`;
|
|
29
|
+
}
|
|
30
|
+
await esbuild.initialize({ wasmURL, worker: false });
|
|
31
|
+
return esbuild;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
return esbuildReady;
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Public API
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/** Transpile TypeScript to JavaScript by stripping types, then strip imports */
|
|
43
|
+
export async function transpileTypeScript(code) {
|
|
44
|
+
let js;
|
|
45
|
+
try {
|
|
46
|
+
const esbuild = await getEsbuild();
|
|
47
|
+
if (esbuild) {
|
|
48
|
+
const result = await esbuild.transform(code, {
|
|
49
|
+
loader: 'ts',
|
|
50
|
+
target: 'es2022',
|
|
51
|
+
});
|
|
52
|
+
js = result.code;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
js = naiveTypeStrip(code);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
js = naiveTypeStrip(code);
|
|
60
|
+
}
|
|
61
|
+
// Strip import/export statements — QuickJS has no module system
|
|
62
|
+
return stripModuleSyntax(js);
|
|
63
|
+
}
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Module syntax stripping
|
|
66
|
+
// ============================================================================
|
|
67
|
+
/**
|
|
68
|
+
* Strip import/export statements from JavaScript code.
|
|
69
|
+
* QuickJS doesn't support ES modules, so scripts access the SDK via
|
|
70
|
+
* the global `bim` object built by the bridge.
|
|
71
|
+
*/
|
|
72
|
+
function stripModuleSyntax(code) {
|
|
73
|
+
let result = code;
|
|
74
|
+
// Remove import statements: import ... from '...' or import '...'
|
|
75
|
+
result = result.replace(/^\s*import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*(?:\{[^}]*\}|\*\s+as\s+\w+|\w+))*\s+from\s+)?['"][^'"]*['"];?\s*$/gm, '');
|
|
76
|
+
// Remove export keywords (keep the declaration): export const/function/class → const/function/class
|
|
77
|
+
result = result.replace(/^\s*export\s+(default\s+)?(const|let|var|function|class|async\s+function)\s/gm, '$2 ');
|
|
78
|
+
// Remove bare "export default" expression statements
|
|
79
|
+
result = result.replace(/^\s*export\s+default\s+/gm, '');
|
|
80
|
+
// Remove export { ... } and export { ... } from '...'
|
|
81
|
+
result = result.replace(/^\s*export\s+\{[^}]*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?\s*$/gm, '');
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Naive type stripping (fallback when esbuild-wasm unavailable)
|
|
86
|
+
// ============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Regex-based type stripping — removes TypeScript-only syntax.
|
|
89
|
+
* Not a full parser, but handles patterns commonly used in BIM scripts.
|
|
90
|
+
*/
|
|
91
|
+
export function naiveTypeStrip(code) {
|
|
92
|
+
let result = code;
|
|
93
|
+
// Remove interface declarations (including multiline)
|
|
94
|
+
result = result.replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[^}]*\}/gm, '');
|
|
95
|
+
// Remove type alias declarations
|
|
96
|
+
result = result.replace(/^\s*(?:export\s+)?type\s+\w+\s*=\s*[^;]+;/gm, '');
|
|
97
|
+
// Strip variable type annotations using balanced-bracket scanner.
|
|
98
|
+
// Handles: const x: [string, number][] = ..., const y: Array<{ a: T; b: U }> = ...
|
|
99
|
+
result = stripVariableAnnotations(result);
|
|
100
|
+
// Remove function parameter type annotations: (x: TYPE, y: TYPE)
|
|
101
|
+
result = result.replace(/(\w+)\s*:\s*(?:string|number|boolean|void|any|unknown|never|null|undefined|Record<[^>]+>|Array<[^>]+>|Map<[^>]+>|Set<[^>]+>|\[[^\]]*\](?:\[\])?|\w+(?:\[\])?(?:\s*\|\s*(?:string|number|boolean|null|undefined|\w+))*)\s*(?=[,)])/g, '$1');
|
|
102
|
+
// Remove function return type annotations: ): Type {
|
|
103
|
+
result = result.replace(/\):\s*[^{]+\{/g, ') {');
|
|
104
|
+
// Remove `as Type` casts — but not import aliases like `import { Foo as Bar }`
|
|
105
|
+
result = result.replace(/(?<![{,]\s*\w+\s)\s+as\s+\w+(?:\[\])?/g, '');
|
|
106
|
+
// Remove generic type parameters: <T>, <T extends U>
|
|
107
|
+
result = result.replace(/<\w+(?:\s+extends\s+\w+)?>/g, '');
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Strip type annotations from variable declarations using bracket-depth tracking.
|
|
112
|
+
* Handles complex types like `Array<{ a: T; b: U }>` that contain semicolons
|
|
113
|
+
* inside nested brackets — a simple regex `[^=;]*` would fail on these.
|
|
114
|
+
*/
|
|
115
|
+
function stripVariableAnnotations(code) {
|
|
116
|
+
const lines = code.split('\n');
|
|
117
|
+
for (let li = 0; li < lines.length; li++) {
|
|
118
|
+
const line = lines[li];
|
|
119
|
+
// Match: const/let/var NAME:
|
|
120
|
+
const m = line.match(/^(\s*(?:const|let|var)\s+\w+)\s*:\s*/);
|
|
121
|
+
if (!m)
|
|
122
|
+
continue;
|
|
123
|
+
const prefix = m[1];
|
|
124
|
+
let i = m[0].length;
|
|
125
|
+
let depth = 0;
|
|
126
|
+
let found = false;
|
|
127
|
+
// Scan through the type annotation, tracking bracket nesting
|
|
128
|
+
while (i < line.length) {
|
|
129
|
+
const ch = line[i];
|
|
130
|
+
if (ch === '<' || ch === '{' || ch === '(' || ch === '[')
|
|
131
|
+
depth++;
|
|
132
|
+
else if (ch === '>' || ch === '}' || ch === ')' || ch === ']')
|
|
133
|
+
depth--;
|
|
134
|
+
else if (ch === '=' && depth === 0) {
|
|
135
|
+
// Found assignment at depth 0 — strip the type annotation
|
|
136
|
+
lines[li] = prefix + ' ' + line.substring(i);
|
|
137
|
+
found = true;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
i++;
|
|
141
|
+
}
|
|
142
|
+
// If no '=' found, this is an uninitialized variable: `let x: Type`
|
|
143
|
+
if (!found) {
|
|
144
|
+
lines[li] = prefix;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return lines.join('\n');
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=transpile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../src/transpile.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAsB/D,IAAI,YAAY,GAAuC,IAAI,CAAC;AAE5D;;;;GAIG;AACH,SAAS,UAAU;IACjB,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;QACzB,IAAI,CAAC;YACH,uEAAuE;YACvE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;YACzC,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAgB,CAAC;YAEpD,0BAA0B;YAC1B,IAAI,OAA2B,CAAC;YAChC,IAAI,CAAC;gBACH,oEAAoE;gBACpE,iEAAiE;gBACjE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;gBAC9D,OAAO,GAAI,OAA+B,CAAC,OAAO,C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,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for @ifc-lite/sandbox
|
|
3
|
+
*/
|
|
4
|
+
/** Permission configuration — controls which SDK APIs are accessible */
|
|
5
|
+
export interface SandboxPermissions {
|
|
6
|
+
/** Allow bim.model.* (model loading/management) */
|
|
7
|
+
model?: boolean;
|
|
8
|
+
/** Allow bim.query.* (entity queries) */
|
|
9
|
+
query?: boolean;
|
|
10
|
+
/** Allow bim.viewer.* (renderer control, colors, visibility) */
|
|
11
|
+
viewer?: boolean;
|
|
12
|
+
/** Allow bim.mutate.* (property editing) */
|
|
13
|
+
mutate?: boolean;
|
|
14
|
+
/** Allow bim.lens.* (lens definitions) */
|
|
15
|
+
lens?: boolean;
|
|
16
|
+
/** Allow bim.export.* (data export) */
|
|
17
|
+
export?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Resource limits for sandbox execution */
|
|
20
|
+
export interface SandboxLimits {
|
|
21
|
+
/** Maximum heap memory in bytes (default: 64MB) */
|
|
22
|
+
memoryBytes?: number;
|
|
23
|
+
/** Maximum execution time in milliseconds (default: 30000) */
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
/** Maximum stack size in bytes (default: 512KB) */
|
|
26
|
+
maxStackBytes?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Configuration for creating a sandbox */
|
|
29
|
+
export interface SandboxConfig {
|
|
30
|
+
/** Permission configuration */
|
|
31
|
+
permissions?: SandboxPermissions;
|
|
32
|
+
/** Resource limits */
|
|
33
|
+
limits?: SandboxLimits;
|
|
34
|
+
}
|
|
35
|
+
/** Result of script execution */
|
|
36
|
+
export interface ScriptResult {
|
|
37
|
+
/** Return value (JSON-serializable) */
|
|
38
|
+
value: unknown;
|
|
39
|
+
/** Console output captured during execution */
|
|
40
|
+
logs: LogEntry[];
|
|
41
|
+
/** Execution time in milliseconds */
|
|
42
|
+
durationMs: number;
|
|
43
|
+
}
|
|
44
|
+
/** A captured console log entry */
|
|
45
|
+
export interface LogEntry {
|
|
46
|
+
level: 'log' | 'warn' | 'error' | 'info';
|
|
47
|
+
args: unknown[];
|
|
48
|
+
timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
/** Default permissions — read-only access */
|
|
51
|
+
export declare const DEFAULT_PERMISSIONS: Required<SandboxPermissions>;
|
|
52
|
+
/** Default resource limits */
|
|
53
|
+
export declare const DEFAULT_LIMITS: Required<SandboxLimits>;
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uCAAuC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,sBAAsB;IACtB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACzC,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,kBAAkB,CAO5D,CAAC;AAEF,8BAA8B;AAC9B,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,aAAa,CAIlD,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/** Default permissions — read-only access */
|
|
5
|
+
export const DEFAULT_PERMISSIONS = {
|
|
6
|
+
model: true,
|
|
7
|
+
query: true,
|
|
8
|
+
viewer: true,
|
|
9
|
+
mutate: false, // Read-only by default
|
|
10
|
+
lens: true,
|
|
11
|
+
export: true,
|
|
12
|
+
};
|
|
13
|
+
/** Default resource limits */
|
|
14
|
+
export const DEFAULT_LIMITS = {
|
|
15
|
+
memoryBytes: 64 * 1024 * 1024, // 64 MB
|
|
16
|
+
timeoutMs: 30_000, // 30 seconds
|
|
17
|
+
maxStackBytes: 512 * 1024, // 512 KB
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAyD/D,6CAA6C;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAiC;IAC/D,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK,EAAK,uBAAuB;IACzC,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,8BAA8B;AAC9B,MAAM,CAAC,MAAM,cAAc,GAA4B;IACrD,WAAW,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAM,QAAQ;IAC3C,SAAS,EAAE,MAAM,EAAoB,aAAa;IAClD,aAAa,EAAE,GAAG,GAAG,IAAI,EAAY,SAAS;CAC/C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ifc-lite/sandbox",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"description": "QuickJS-in-WASM sandboxed script execution for ifc-lite",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./schema": {
|
|
14
|
+
"import": "./dist/bridge-schema.js",
|
|
15
|
+
"types": "./dist/bridge-schema.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"esbuild-wasm": "^0.27.3",
|
|
20
|
+
"quickjs-emscripten": "^0.31.0",
|
|
21
|
+
"@ifc-lite/sdk": "^1.7.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.3.0",
|
|
25
|
+
"vitest": "^1.6.0"
|
|
26
|
+
},
|
|
27
|
+
"license": "MPL-2.0",
|
|
28
|
+
"author": "Louis True",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/louistrue/ifc-lite.git",
|
|
32
|
+
"directory": "packages/sandbox"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://louistrue.github.io/ifc-lite/",
|
|
35
|
+
"bugs": "https://github.com/louistrue/ifc-lite/issues",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"ifc",
|
|
38
|
+
"bim",
|
|
39
|
+
"sandbox",
|
|
40
|
+
"quickjs",
|
|
41
|
+
"wasm",
|
|
42
|
+
"scripting"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc",
|
|
53
|
+
"dev": "tsc --watch",
|
|
54
|
+
"test": "vitest run"
|
|
55
|
+
}
|
|
56
|
+
}
|