@microverse.ts/runtime-core 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/LICENSE +21 -0
- package/dist/application/ports/LoggerPort.d.ts +4 -0
- package/dist/application/ports/LoggerPort.d.ts.map +1 -0
- package/dist/application/ports/RuntimeAdapterPort.d.ts +3 -0
- package/dist/application/ports/RuntimeAdapterPort.d.ts.map +1 -0
- package/dist/application/useCases/executeScript.d.ts +13 -0
- package/dist/application/useCases/executeScript.d.ts.map +1 -0
- package/dist/domain/microverse/MicroverseId.d.ts +10 -0
- package/dist/domain/microverse/MicroverseId.d.ts.map +1 -0
- package/dist/domain/microverse/MicroverseScript.d.ts +5 -0
- package/dist/domain/microverse/MicroverseScript.d.ts.map +1 -0
- package/dist/domain/runtime/CancellationToken.d.ts +5 -0
- package/dist/domain/runtime/CancellationToken.d.ts.map +1 -0
- package/dist/domain/runtime/ExecutionContext.d.ts +7 -0
- package/dist/domain/runtime/ExecutionContext.d.ts.map +1 -0
- package/dist/domain/runtime/ExecutionFailure.d.ts +9 -0
- package/dist/domain/runtime/ExecutionFailure.d.ts.map +1 -0
- package/dist/domain/runtime/MicroverseInstanceId.d.ts +9 -0
- package/dist/domain/runtime/MicroverseInstanceId.d.ts.map +1 -0
- package/dist/domain/runtime/MicroverseRuntime.d.ts +27 -0
- package/dist/domain/runtime/MicroverseRuntime.d.ts.map +1 -0
- package/dist/domain/runtime/RunScriptInput.d.ts +14 -0
- package/dist/domain/runtime/RunScriptInput.d.ts.map +1 -0
- package/dist/domain/runtime/RunScriptResult.d.ts +5 -0
- package/dist/domain/runtime/RunScriptResult.d.ts.map +1 -0
- package/dist/domain/runtime/RuntimeAdapter.d.ts +12 -0
- package/dist/domain/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/dist/domain/runtime/TimeoutPolicy.d.ts +9 -0
- package/dist/domain/runtime/TimeoutPolicy.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/composition/IsolatedMicroverseRuntimeMap.d.ts +19 -0
- package/dist/infrastructure/composition/IsolatedMicroverseRuntimeMap.d.ts.map +1 -0
- package/dist/infrastructure/logging/ConsoleLogger.d.ts +5 -0
- package/dist/infrastructure/logging/ConsoleLogger.d.ts.map +1 -0
- package/dist/infrastructure/runtime/StubMicroverseRuntime.d.ts +18 -0
- package/dist/infrastructure/runtime/StubMicroverseRuntime.d.ts.map +1 -0
- package/dist/infrastructure/runtime/StubRuntimeAdapter.d.ts +10 -0
- package/dist/infrastructure/runtime/StubRuntimeAdapter.d.ts.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QADRAX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerPort.d.ts","sourceRoot":"","sources":["../../../src/application/ports/LoggerPort.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeAdapterPort.d.ts","sourceRoot":"","sources":["../../../src/application/ports/RuntimeAdapterPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AsyncUseCase, Result } from '@microverse.ts/shared';
|
|
2
|
+
import { LoggerPort } from '../ports/LoggerPort';
|
|
3
|
+
import { RuntimeAdapterPort } from '../ports/RuntimeAdapterPort';
|
|
4
|
+
import { ExecutionContext } from '../../domain/runtime/ExecutionContext';
|
|
5
|
+
import { ExecutionFailure } from '../../domain/runtime/ExecutionFailure';
|
|
6
|
+
import { RunScriptInput } from '../../domain/runtime/RunScriptInput';
|
|
7
|
+
import { RunScriptResult } from '../../domain/runtime/RunScriptResult';
|
|
8
|
+
export type ExecuteScriptPorts = readonly [RuntimeAdapterPort, LoggerPort];
|
|
9
|
+
/**
|
|
10
|
+
* Port tuple order: `[RuntimeAdapterPort, LoggerPort]`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const executeScript: AsyncUseCase<ExecuteScriptPorts, readonly [ExecutionContext, RunScriptInput], Result<RunScriptResult, ExecutionFailure>>;
|
|
13
|
+
//# sourceMappingURL=executeScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeScript.d.ts","sourceRoot":"","sources":["../../../src/application/useCases/executeScript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CACtC,kBAAkB,EAClB,SAAS,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAC3C,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAU1C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type MicroverseId = string & {
|
|
2
|
+
readonly __brand: 'MicroverseId';
|
|
3
|
+
};
|
|
4
|
+
export declare function createMicroverseId(value: string): MicroverseId;
|
|
5
|
+
/**
|
|
6
|
+
* Branded id for **one Lua environment slot** (`_ENV`) inside a shared Wasm VM — same value as {@link createMicroverseId},
|
|
7
|
+
* wording aimed at host/workflow code (pairs with {@link MicroverseRuntime.createMicroverse}'s `slotKey`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function createLuaEnvSlotKey(label: string): MicroverseId;
|
|
10
|
+
//# sourceMappingURL=MicroverseId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroverseId.d.ts","sourceRoot":"","sources":["../../../src/domain/microverse/MicroverseId.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAEzE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAE9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAE/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroverseScript.d.ts","sourceRoot":"","sources":["../../../src/domain/microverse/MicroverseScript.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEjF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CancellationToken.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/CancellationToken.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAEjC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MicroverseId } from '../microverse/MicroverseId';
|
|
2
|
+
import { CancellationToken } from './CancellationToken';
|
|
3
|
+
export type ExecutionContext = {
|
|
4
|
+
readonly microverseId: MicroverseId;
|
|
5
|
+
readonly cancellation: CancellationToken;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=ExecutionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/ExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionFailure.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/ExecutionFailure.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque id for one **isolated** sandbox runtime instance in the host process.
|
|
3
|
+
* Typical use: one id per entity, per script, or per worker — each maps to its own `MicroverseRuntime`.
|
|
4
|
+
*/
|
|
5
|
+
export type MicroverseInstanceId = string & {
|
|
6
|
+
readonly __brand: 'MicroverseInstanceId';
|
|
7
|
+
};
|
|
8
|
+
export declare function createMicroverseInstanceId(value: string): MicroverseInstanceId;
|
|
9
|
+
//# sourceMappingURL=MicroverseInstanceId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroverseInstanceId.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/MicroverseInstanceId.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAEzF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAE9E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Result } from '@microverse.ts/shared';
|
|
2
|
+
import { MicroverseId } from '../microverse/MicroverseId';
|
|
3
|
+
import { ExecutionFailure } from './ExecutionFailure';
|
|
4
|
+
import { RunScriptInput } from './RunScriptInput';
|
|
5
|
+
import { RunScriptResult } from './RunScriptResult';
|
|
6
|
+
import { TimeoutPolicy } from './TimeoutPolicy';
|
|
7
|
+
export type CreateMicroverseOptions = {
|
|
8
|
+
readonly defaultTimeout?: TimeoutPolicy | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Stable **Lua environment slot** id inside the shared {@link MicroverseRuntime} / Wasmoon VM (one `_ENV` per id).
|
|
11
|
+
* Build with {@link createLuaEnvSlotKey} or {@link createMicroverseId}. When omitted, a random id is generated.
|
|
12
|
+
*/
|
|
13
|
+
readonly slotKey?: MicroverseId | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type MicroverseSlot = {
|
|
16
|
+
readonly id: MicroverseId;
|
|
17
|
+
readonly run: (input: RunScriptInput) => Promise<Result<RunScriptResult, ExecutionFailure>>;
|
|
18
|
+
readonly dispose: () => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* One runtime owns **one** Wasmoon/Lua VM (when using `@microverse.ts/runtime-wasm`).
|
|
22
|
+
* Call {@link MicroverseRuntime.createMicroverse} multiple times to register **many slots** in that VM.
|
|
23
|
+
*/
|
|
24
|
+
export type MicroverseRuntime = {
|
|
25
|
+
readonly createMicroverse: (options: CreateMicroverseOptions) => Promise<MicroverseSlot>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=MicroverseRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroverseRuntime.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/MicroverseRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACpD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC5F,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MicroverseScript } from '../microverse/MicroverseScript';
|
|
2
|
+
import { TimeoutPolicy } from './TimeoutPolicy';
|
|
3
|
+
export type RunScriptInput = {
|
|
4
|
+
readonly script: MicroverseScript;
|
|
5
|
+
readonly timeout?: TimeoutPolicy | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Shallow-merged into this slot’s Lua environment **before** the chunk loads (Wasmoon path).
|
|
8
|
+
* Keys remain on `_ENV` for later `run` calls on the same slot until `disposeMicroverse` clears the slot.
|
|
9
|
+
* Typical use: one top-level global per bridge name, e.g. `{ Data: { load: (id) => ... } }` from
|
|
10
|
+
* `buildDeclarativeBridgeTable`. Other adapters may ignore this field.
|
|
11
|
+
*/
|
|
12
|
+
readonly mergeEnv?: Readonly<Record<string, unknown>> | undefined;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=RunScriptInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunScriptInput.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/RunScriptInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunScriptResult.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/RunScriptResult.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Result } from '@microverse.ts/shared';
|
|
2
|
+
import { MicroverseId } from '../microverse/MicroverseId';
|
|
3
|
+
import { ExecutionContext } from './ExecutionContext';
|
|
4
|
+
import { ExecutionFailure } from './ExecutionFailure';
|
|
5
|
+
import { RunScriptInput } from './RunScriptInput';
|
|
6
|
+
import { RunScriptResult } from './RunScriptResult';
|
|
7
|
+
export type RuntimeAdapter = {
|
|
8
|
+
readonly execute: (ctx: ExecutionContext, input: RunScriptInput) => Promise<Result<RunScriptResult, ExecutionFailure>>;
|
|
9
|
+
/** Tear down one logical slot in the shared VM (e.g. drop per-slot Lua environment). */
|
|
10
|
+
readonly disposeMicroverse?: (microverseId: MicroverseId) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=RuntimeAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/RuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAChB,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,cAAc,KAClB,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACxD,wFAAwF;IACxF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type TimeoutPolicy = {
|
|
2
|
+
readonly kind: 'none';
|
|
3
|
+
} | {
|
|
4
|
+
readonly kind: 'fixed';
|
|
5
|
+
readonly milliseconds: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const noTimeout: TimeoutPolicy;
|
|
8
|
+
export declare function fixedTimeout(milliseconds: number): TimeoutPolicy;
|
|
9
|
+
//# sourceMappingURL=TimeoutPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutPolicy.d.ts","sourceRoot":"","sources":["../../../src/domain/runtime/TimeoutPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,eAAO,MAAM,SAAS,EAAE,aAAgC,CAAC;AAEzD,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAEhE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { neverCancelledToken, type CancellationToken } from './domain/runtime/CancellationToken';
|
|
2
|
+
export type { ExecutionContext } from './domain/runtime/ExecutionContext';
|
|
3
|
+
export type { ExecutionFailure } from './domain/runtime/ExecutionFailure';
|
|
4
|
+
export type { RuntimeAdapter } from './domain/runtime/RuntimeAdapter';
|
|
5
|
+
export type { RunScriptInput } from './domain/runtime/RunScriptInput';
|
|
6
|
+
export type { RunScriptResult, MicroverseScalar } from './domain/runtime/RunScriptResult';
|
|
7
|
+
export type { CreateMicroverseOptions, MicroverseSlot, MicroverseRuntime, } from './domain/runtime/MicroverseRuntime';
|
|
8
|
+
export { createMicroverseInstanceId, type MicroverseInstanceId } from './domain/runtime/MicroverseInstanceId';
|
|
9
|
+
export { fixedTimeout, noTimeout, type TimeoutPolicy } from './domain/runtime/TimeoutPolicy';
|
|
10
|
+
export { createLuaEnvSlotKey, createMicroverseId, type MicroverseId } from './domain/microverse/MicroverseId';
|
|
11
|
+
/** Same branded string as {@link MicroverseId}; use for multi-slot APIs in host code. */
|
|
12
|
+
export type { MicroverseId as SlotKey } from './domain/microverse/MicroverseId';
|
|
13
|
+
export { createMicroverseId as createSlotKey } from './domain/microverse/MicroverseId';
|
|
14
|
+
export { createMicroverseScript, type MicroverseScript } from './domain/microverse/MicroverseScript';
|
|
15
|
+
export { ConsoleLogger } from './infrastructure/logging/ConsoleLogger';
|
|
16
|
+
export { StubRuntimeAdapter } from './infrastructure/runtime/StubRuntimeAdapter';
|
|
17
|
+
export { createStubMicroverseRuntime, StubMicroverseRuntime, type StubMicroverseRuntimeDeps, } from './infrastructure/runtime/StubMicroverseRuntime';
|
|
18
|
+
export { IsolatedMicroverseRuntimeMap } from './infrastructure/composition/IsolatedMicroverseRuntimeMap';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACjG,YAAY,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,YAAY,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC1F,YAAY,EACV,uBAAuB,EACvB,cAAc,EACd,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC9G,yFAAyF;AACzF,YAAY,EAAE,YAAY,IAAI,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { err, ok } from "@microverse.ts/shared";
|
|
2
|
+
//#region src/domain/runtime/CancellationToken.ts
|
|
3
|
+
var neverCancelledToken = { isCancelled: () => false };
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/domain/runtime/MicroverseInstanceId.ts
|
|
6
|
+
function createMicroverseInstanceId(value) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/domain/runtime/TimeoutPolicy.ts
|
|
11
|
+
var noTimeout = { kind: "none" };
|
|
12
|
+
function fixedTimeout(milliseconds) {
|
|
13
|
+
return {
|
|
14
|
+
kind: "fixed",
|
|
15
|
+
milliseconds
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/domain/microverse/MicroverseId.ts
|
|
20
|
+
function createMicroverseId(value) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Branded id for **one Lua environment slot** (`_ENV`) inside a shared Wasm VM — same value as {@link createMicroverseId},
|
|
25
|
+
* wording aimed at host/workflow code (pairs with {@link MicroverseRuntime.createMicroverse}'s `slotKey`).
|
|
26
|
+
*/
|
|
27
|
+
function createLuaEnvSlotKey(label) {
|
|
28
|
+
return createMicroverseId(label);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/domain/microverse/MicroverseScript.ts
|
|
32
|
+
function createMicroverseScript(source) {
|
|
33
|
+
return source;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/infrastructure/logging/ConsoleLogger.ts
|
|
37
|
+
var ConsoleLogger = class {
|
|
38
|
+
info = (message) => {
|
|
39
|
+
globalThis.console?.log(`[runtime-core] ${message}`);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/infrastructure/runtime/StubRuntimeAdapter.ts
|
|
44
|
+
var StubRuntimeAdapter = class {
|
|
45
|
+
execute = async (_ctx, input) => {
|
|
46
|
+
return ok({ output: `stub:${String(input.script)}` });
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/application/useCases/executeScript.ts
|
|
51
|
+
/**
|
|
52
|
+
* Port tuple order: `[RuntimeAdapterPort, LoggerPort]`.
|
|
53
|
+
*/
|
|
54
|
+
var executeScript = async (ports, ctx, input) => {
|
|
55
|
+
const [adapter, logger] = ports;
|
|
56
|
+
if (ctx.cancellation.isCancelled()) return err({ _tag: "Cancelled" });
|
|
57
|
+
logger.info("executeScript:start");
|
|
58
|
+
const result = await adapter.execute(ctx, input);
|
|
59
|
+
logger.info("executeScript:end");
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/infrastructure/runtime/StubMicroverseRuntime.ts
|
|
64
|
+
var StubMicroverseRuntime = class {
|
|
65
|
+
deps;
|
|
66
|
+
usedSlotKeys = /* @__PURE__ */ new Set();
|
|
67
|
+
constructor(deps) {
|
|
68
|
+
this.deps = deps;
|
|
69
|
+
}
|
|
70
|
+
createMicroverse = async (options) => {
|
|
71
|
+
const id = options.slotKey !== void 0 ? options.slotKey : createMicroverseId(createRandomId());
|
|
72
|
+
if (options.slotKey !== void 0) {
|
|
73
|
+
const k = String(options.slotKey);
|
|
74
|
+
if (this.usedSlotKeys.has(k)) throw new Error(`duplicate slotKey: ${k}`);
|
|
75
|
+
this.usedSlotKeys.add(k);
|
|
76
|
+
}
|
|
77
|
+
return createStubMicroverseSlot({
|
|
78
|
+
id,
|
|
79
|
+
deps: this.deps,
|
|
80
|
+
options,
|
|
81
|
+
explicitSlotKey: options.slotKey !== void 0,
|
|
82
|
+
usedSlotKeys: this.usedSlotKeys
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
function createRandomId() {
|
|
87
|
+
const g = globalThis;
|
|
88
|
+
if (g.crypto?.randomUUID) return g.crypto.randomUUID();
|
|
89
|
+
return `sandbox-${Math.random().toString(16).slice(2)}`;
|
|
90
|
+
}
|
|
91
|
+
function createStubMicroverseSlot(input) {
|
|
92
|
+
const ctx = {
|
|
93
|
+
microverseId: input.id,
|
|
94
|
+
cancellation: neverCancelledToken
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
id: input.id,
|
|
98
|
+
run: async (runInput) => {
|
|
99
|
+
const resolvedTimeout = runInput.timeout ?? input.options.defaultTimeout ?? input.deps.defaultTimeout;
|
|
100
|
+
const inputMerged = resolvedTimeout !== void 0 ? {
|
|
101
|
+
...runInput,
|
|
102
|
+
timeout: resolvedTimeout
|
|
103
|
+
} : { ...runInput };
|
|
104
|
+
return executeScript([input.deps.adapter, input.deps.logger], ctx, inputMerged);
|
|
105
|
+
},
|
|
106
|
+
dispose: async () => {
|
|
107
|
+
await input.deps.adapter.disposeMicroverse?.(input.id);
|
|
108
|
+
if (input.explicitSlotKey) input.usedSlotKeys.delete(String(input.id));
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function createStubMicroverseRuntime(deps) {
|
|
113
|
+
return new StubMicroverseRuntime(deps);
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/infrastructure/composition/IsolatedMicroverseRuntimeMap.ts
|
|
117
|
+
/**
|
|
118
|
+
* Keeps many {@link MicroverseRuntime} instances keyed by {@link MicroverseInstanceId}.
|
|
119
|
+
* Each entry is typically its own `MicroverseRuntime` (hence its own Wasmoon/Lua VM when using `@microverse.ts/runtime-wasm`).
|
|
120
|
+
*
|
|
121
|
+
* This type does **not** dispose Lua engines: call `MicroverseSlot.dispose()` on every
|
|
122
|
+
* created sandbox before `unregister`, and dispose any other host resources yourself.
|
|
123
|
+
*/
|
|
124
|
+
var IsolatedMicroverseRuntimeMap = class {
|
|
125
|
+
runtimes = /* @__PURE__ */ new Map();
|
|
126
|
+
register = (id, runtime) => {
|
|
127
|
+
if (this.runtimes.has(id)) throw new Error(`duplicate sandbox instance id: ${String(id)}`);
|
|
128
|
+
this.runtimes.set(id, runtime);
|
|
129
|
+
};
|
|
130
|
+
unregister = (id) => {
|
|
131
|
+
this.runtimes.delete(id);
|
|
132
|
+
};
|
|
133
|
+
get = (id) => this.runtimes.get(id);
|
|
134
|
+
has = (id) => this.runtimes.has(id);
|
|
135
|
+
ids = () => this.runtimes.keys();
|
|
136
|
+
clear = () => {
|
|
137
|
+
this.runtimes.clear();
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
export { ConsoleLogger, IsolatedMicroverseRuntimeMap, StubMicroverseRuntime, StubRuntimeAdapter, createLuaEnvSlotKey, createMicroverseId, createMicroverseId as createSlotKey, createMicroverseInstanceId, createMicroverseScript, createStubMicroverseRuntime, fixedTimeout, neverCancelledToken, noTimeout };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/domain/runtime/CancellationToken.ts","../src/domain/runtime/MicroverseInstanceId.ts","../src/domain/runtime/TimeoutPolicy.ts","../src/domain/microverse/MicroverseId.ts","../src/domain/microverse/MicroverseScript.ts","../src/infrastructure/logging/ConsoleLogger.ts","../src/infrastructure/runtime/StubRuntimeAdapter.ts","../src/application/useCases/executeScript.ts","../src/infrastructure/runtime/StubMicroverseRuntime.ts","../src/infrastructure/composition/IsolatedMicroverseRuntimeMap.ts"],"sourcesContent":["export type CancellationToken = {\n readonly isCancelled: () => boolean;\n};\n\nexport const neverCancelledToken: CancellationToken = {\n isCancelled: () => false,\n};\n","/**\n * Opaque id for one **isolated** sandbox runtime instance in the host process.\n * Typical use: one id per entity, per script, or per worker — each maps to its own `MicroverseRuntime`.\n */\nexport type MicroverseInstanceId = string & { readonly __brand: 'MicroverseInstanceId' };\n\nexport function createMicroverseInstanceId(value: string): MicroverseInstanceId {\n return value as MicroverseInstanceId;\n}\n","export type TimeoutPolicy =\n | { readonly kind: 'none' }\n | { readonly kind: 'fixed'; readonly milliseconds: number };\n\nexport const noTimeout: TimeoutPolicy = { kind: 'none' };\n\nexport function fixedTimeout(milliseconds: number): TimeoutPolicy {\n return { kind: 'fixed', milliseconds };\n}\n","export type MicroverseId = string & { readonly __brand: 'MicroverseId' };\n\nexport function createMicroverseId(value: string): MicroverseId {\n return value as MicroverseId;\n}\n\n/**\n * Branded id for **one Lua environment slot** (`_ENV`) inside a shared Wasm VM — same value as {@link createMicroverseId},\n * wording aimed at host/workflow code (pairs with {@link MicroverseRuntime.createMicroverse}'s `slotKey`).\n */\nexport function createLuaEnvSlotKey(label: string): MicroverseId {\n return createMicroverseId(label);\n}\n","export type MicroverseScript = string & { readonly __brand: 'MicroverseScript' };\n\nexport function createMicroverseScript(source: string): MicroverseScript {\n return source as MicroverseScript;\n}\n","import type { LoggerPort } from '../../application/ports/LoggerPort';\n\nexport class ConsoleLogger implements LoggerPort {\n readonly info = (message: string): void => {\n const g = globalThis as typeof globalThis & {\n console?: { log: (line: string) => void };\n };\n g.console?.log(`[runtime-core] ${message}`);\n };\n}\n","import { ok, type Result } from '@microverse.ts/shared';\n\nimport type { RuntimeAdapter } from '../../domain/runtime/RuntimeAdapter';\nimport type { ExecutionContext } from '../../domain/runtime/ExecutionContext';\nimport type { ExecutionFailure } from '../../domain/runtime/ExecutionFailure';\nimport type { RunScriptResult } from '../../domain/runtime/RunScriptResult';\nimport type { RunScriptInput } from '../../domain/runtime/RunScriptInput';\n\nexport class StubRuntimeAdapter implements RuntimeAdapter {\n readonly execute = async (\n _ctx: ExecutionContext,\n input: RunScriptInput,\n ): Promise<Result<RunScriptResult, ExecutionFailure>> => {\n return ok({ output: `stub:${String(input.script)}` });\n };\n}\n","import type { AsyncUseCase } from '@microverse.ts/shared';\nimport { err, type Result } from '@microverse.ts/shared';\n\nimport type { LoggerPort } from '../ports/LoggerPort';\nimport type { RuntimeAdapterPort } from '../ports/RuntimeAdapterPort';\nimport type { ExecutionContext } from '../../domain/runtime/ExecutionContext';\nimport type { ExecutionFailure } from '../../domain/runtime/ExecutionFailure';\nimport type { RunScriptInput } from '../../domain/runtime/RunScriptInput';\nimport type { RunScriptResult } from '../../domain/runtime/RunScriptResult';\n\nexport type ExecuteScriptPorts = readonly [RuntimeAdapterPort, LoggerPort];\n\n/**\n * Port tuple order: `[RuntimeAdapterPort, LoggerPort]`.\n */\nexport const executeScript: AsyncUseCase<\n ExecuteScriptPorts,\n readonly [ExecutionContext, RunScriptInput],\n Result<RunScriptResult, ExecutionFailure>\n> = async (ports, ctx, input) => {\n const [adapter, logger] = ports;\n if (ctx.cancellation.isCancelled()) {\n return err({ _tag: 'Cancelled' });\n }\n logger.info('executeScript:start');\n const result = await adapter.execute(ctx, input);\n logger.info('executeScript:end');\n return result;\n};\n","import { executeScript } from '../../application/useCases/executeScript';\nimport type { LoggerPort } from '../../application/ports/LoggerPort';\nimport type { RuntimeAdapter } from '../../domain/runtime/RuntimeAdapter';\nimport type { RunScriptInput } from '../../domain/runtime/RunScriptInput';\nimport type { CreateMicroverseOptions, MicroverseSlot, MicroverseRuntime } from '../../domain/runtime/MicroverseRuntime';\nimport { neverCancelledToken } from '../../domain/runtime/CancellationToken';\nimport type { TimeoutPolicy } from '../../domain/runtime/TimeoutPolicy';\nimport { createMicroverseId, type MicroverseId } from '../../domain/microverse/MicroverseId';\n\nexport type StubMicroverseRuntimeDeps = {\n readonly adapter: RuntimeAdapter;\n readonly logger: LoggerPort;\n /** Applied when neither {@link RunScriptInput.timeout} nor {@link CreateMicroverseOptions.defaultTimeout} is set. */\n readonly defaultTimeout?: TimeoutPolicy | undefined;\n};\n\nexport class StubMicroverseRuntime implements MicroverseRuntime {\n private readonly usedSlotKeys = new Set<string>();\n\n constructor(private readonly deps: StubMicroverseRuntimeDeps) {}\n\n readonly createMicroverse = async (options: CreateMicroverseOptions): Promise<MicroverseSlot> => {\n const id =\n options.slotKey !== undefined ? options.slotKey : createMicroverseId(createRandomId());\n if (options.slotKey !== undefined) {\n const k = String(options.slotKey);\n if (this.usedSlotKeys.has(k)) {\n throw new Error(`duplicate slotKey: ${k}`);\n }\n this.usedSlotKeys.add(k);\n }\n return createStubMicroverseSlot({\n id,\n deps: this.deps,\n options,\n explicitSlotKey: options.slotKey !== undefined,\n usedSlotKeys: this.usedSlotKeys,\n });\n };\n}\n\nfunction createRandomId(): string {\n const g = globalThis as typeof globalThis & {\n crypto?: { randomUUID?: () => string };\n };\n if (g.crypto?.randomUUID) {\n return g.crypto.randomUUID();\n }\n return `sandbox-${Math.random().toString(16).slice(2)}`;\n}\n\nfunction createStubMicroverseSlot(input: {\n readonly id: MicroverseId;\n readonly deps: StubMicroverseRuntimeDeps;\n readonly options: CreateMicroverseOptions;\n readonly explicitSlotKey: boolean;\n readonly usedSlotKeys: Set<string>;\n}): MicroverseSlot {\n const ctx = { microverseId: input.id, cancellation: neverCancelledToken };\n return {\n id: input.id,\n run: async (runInput) => {\n const resolvedTimeout =\n runInput.timeout ?? input.options.defaultTimeout ?? input.deps.defaultTimeout;\n const inputMerged: RunScriptInput =\n resolvedTimeout !== undefined ? { ...runInput, timeout: resolvedTimeout } : { ...runInput };\n return executeScript([input.deps.adapter, input.deps.logger], ctx, inputMerged);\n },\n dispose: async () => {\n await input.deps.adapter.disposeMicroverse?.(input.id);\n if (input.explicitSlotKey) {\n input.usedSlotKeys.delete(String(input.id));\n }\n },\n };\n}\n\nexport function createStubMicroverseRuntime(deps: StubMicroverseRuntimeDeps): MicroverseRuntime {\n return new StubMicroverseRuntime(deps);\n}\n","import type { MicroverseRuntime } from '../../domain/runtime/MicroverseRuntime';\nimport type { MicroverseInstanceId } from '../../domain/runtime/MicroverseInstanceId';\n\n/**\n * Keeps many {@link MicroverseRuntime} instances keyed by {@link MicroverseInstanceId}.\n * Each entry is typically its own `MicroverseRuntime` (hence its own Wasmoon/Lua VM when using `@microverse.ts/runtime-wasm`).\n *\n * This type does **not** dispose Lua engines: call `MicroverseSlot.dispose()` on every\n * created sandbox before `unregister`, and dispose any other host resources yourself.\n */\nexport class IsolatedMicroverseRuntimeMap {\n private readonly runtimes = new Map<MicroverseInstanceId, MicroverseRuntime>();\n\n readonly register = (id: MicroverseInstanceId, runtime: MicroverseRuntime): void => {\n if (this.runtimes.has(id)) {\n throw new Error(`duplicate sandbox instance id: ${String(id)}`);\n }\n this.runtimes.set(id, runtime);\n };\n\n readonly unregister = (id: MicroverseInstanceId): void => {\n this.runtimes.delete(id);\n };\n\n readonly get = (id: MicroverseInstanceId): MicroverseRuntime | undefined => this.runtimes.get(id);\n\n readonly has = (id: MicroverseInstanceId): boolean => this.runtimes.has(id);\n\n readonly ids = (): IterableIterator<MicroverseInstanceId> => this.runtimes.keys();\n\n readonly clear = (): void => {\n this.runtimes.clear();\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MicroverseRuntime } from '../../domain/runtime/MicroverseRuntime';
|
|
2
|
+
import { MicroverseInstanceId } from '../../domain/runtime/MicroverseInstanceId';
|
|
3
|
+
/**
|
|
4
|
+
* Keeps many {@link MicroverseRuntime} instances keyed by {@link MicroverseInstanceId}.
|
|
5
|
+
* Each entry is typically its own `MicroverseRuntime` (hence its own Wasmoon/Lua VM when using `@microverse.ts/runtime-wasm`).
|
|
6
|
+
*
|
|
7
|
+
* This type does **not** dispose Lua engines: call `MicroverseSlot.dispose()` on every
|
|
8
|
+
* created sandbox before `unregister`, and dispose any other host resources yourself.
|
|
9
|
+
*/
|
|
10
|
+
export declare class IsolatedMicroverseRuntimeMap {
|
|
11
|
+
private readonly runtimes;
|
|
12
|
+
readonly register: (id: MicroverseInstanceId, runtime: MicroverseRuntime) => void;
|
|
13
|
+
readonly unregister: (id: MicroverseInstanceId) => void;
|
|
14
|
+
readonly get: (id: MicroverseInstanceId) => MicroverseRuntime | undefined;
|
|
15
|
+
readonly has: (id: MicroverseInstanceId) => boolean;
|
|
16
|
+
readonly ids: () => IterableIterator<MicroverseInstanceId>;
|
|
17
|
+
readonly clear: () => void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=IsolatedMicroverseRuntimeMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IsolatedMicroverseRuntimeMap.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/composition/IsolatedMicroverseRuntimeMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF;;;;;;GAMG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsD;IAE/E,QAAQ,CAAC,QAAQ,GAAI,IAAI,oBAAoB,EAAE,SAAS,iBAAiB,KAAG,IAAI,CAK9E;IAEF,QAAQ,CAAC,UAAU,GAAI,IAAI,oBAAoB,KAAG,IAAI,CAEpD;IAEF,QAAQ,CAAC,GAAG,GAAI,IAAI,oBAAoB,KAAG,iBAAiB,GAAG,SAAS,CAA0B;IAElG,QAAQ,CAAC,GAAG,GAAI,IAAI,oBAAoB,KAAG,OAAO,CAA0B;IAE5E,QAAQ,CAAC,GAAG,QAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAyB;IAElF,QAAQ,CAAC,KAAK,QAAO,IAAI,CAEvB;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,qBAAa,aAAc,YAAW,UAAU;IAC9C,QAAQ,CAAC,IAAI,GAAI,SAAS,MAAM,KAAG,IAAI,CAKrC;CACH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LoggerPort } from '../../application/ports/LoggerPort';
|
|
2
|
+
import { RuntimeAdapter } from '../../domain/runtime/RuntimeAdapter';
|
|
3
|
+
import { CreateMicroverseOptions, MicroverseSlot, MicroverseRuntime } from '../../domain/runtime/MicroverseRuntime';
|
|
4
|
+
import { TimeoutPolicy } from '../../domain/runtime/TimeoutPolicy';
|
|
5
|
+
export type StubMicroverseRuntimeDeps = {
|
|
6
|
+
readonly adapter: RuntimeAdapter;
|
|
7
|
+
readonly logger: LoggerPort;
|
|
8
|
+
/** Applied when neither {@link RunScriptInput.timeout} nor {@link CreateMicroverseOptions.defaultTimeout} is set. */
|
|
9
|
+
readonly defaultTimeout?: TimeoutPolicy | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare class StubMicroverseRuntime implements MicroverseRuntime {
|
|
12
|
+
private readonly deps;
|
|
13
|
+
private readonly usedSlotKeys;
|
|
14
|
+
constructor(deps: StubMicroverseRuntimeDeps);
|
|
15
|
+
readonly createMicroverse: (options: CreateMicroverseOptions) => Promise<MicroverseSlot>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createStubMicroverseRuntime(deps: StubMicroverseRuntimeDeps): MicroverseRuntime;
|
|
18
|
+
//# sourceMappingURL=StubMicroverseRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StubMicroverseRuntime.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/runtime/StubMicroverseRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEzH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAGxE,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,qHAAqH;IACrH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACrD,CAAC;AAEF,qBAAa,qBAAsB,YAAW,iBAAiB;IAGjD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;gBAErB,IAAI,EAAE,yBAAyB;IAE5D,QAAQ,CAAC,gBAAgB,GAAU,SAAS,uBAAuB,KAAG,OAAO,CAAC,cAAc,CAAC,CAiB3F;CACH;AAsCD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,yBAAyB,GAAG,iBAAiB,CAE9F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Result } from '@microverse.ts/shared';
|
|
2
|
+
import { RuntimeAdapter } from '../../domain/runtime/RuntimeAdapter';
|
|
3
|
+
import { ExecutionContext } from '../../domain/runtime/ExecutionContext';
|
|
4
|
+
import { ExecutionFailure } from '../../domain/runtime/ExecutionFailure';
|
|
5
|
+
import { RunScriptResult } from '../../domain/runtime/RunScriptResult';
|
|
6
|
+
import { RunScriptInput } from '../../domain/runtime/RunScriptInput';
|
|
7
|
+
export declare class StubRuntimeAdapter implements RuntimeAdapter {
|
|
8
|
+
readonly execute: (_ctx: ExecutionContext, input: RunScriptInput) => Promise<Result<RunScriptResult, ExecutionFailure>>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=StubRuntimeAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StubRuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/runtime/StubRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,qBAAa,kBAAmB,YAAW,cAAc;IACvD,QAAQ,CAAC,OAAO,GACd,MAAM,gBAAgB,EACtB,OAAO,cAAc,KACpB,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAEnD;CACH"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microverse.ts/runtime-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/QADRAX/Microverse.ts.git",
|
|
10
|
+
"directory": "packages/runtime-core"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/QADRAX/Microverse.ts/issues",
|
|
13
|
+
"homepage": "https://github.com/QADRAX/Microverse.ts/tree/main/packages/runtime-core",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@microverse.ts/shared": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"vite": "^8.0.0",
|
|
33
|
+
"vite-plugin-dts": "^4.5.4",
|
|
34
|
+
"vitest": "^3.1.4"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}
|