@microverse.ts/microverse-lua 0.2.0 → 0.3.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 CHANGED
@@ -12,7 +12,7 @@ One logical scripting universe in your process:
12
12
  - **Many** isolated **environment slots** — one per mounted script instance.
13
13
  - **One** host **surface** (declarative bridges + optional component hooks).
14
14
  - **One** host **object** (your TypeScript services).
15
- - **Per-instance capability allowlists** at mount.
15
+ - **Typed component profiles** bridges on `self.bridges` are narrowed by `YourType:extend()` in each script.
16
16
 
17
17
  ```
18
18
  ┌─────────────────────────────────────────────────────────────┐
@@ -21,10 +21,10 @@ One logical scripting universe in your process:
21
21
  │ │ Shared Wasm Lua VM │ │
22
22
  │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
23
23
  │ │ │ slot: a │ │ slot: b │ │ slot: c │ │ │
24
- │ │ │ caps: […] │ │ caps: […] │ │ caps: […] │ │ │
24
+ │ │ │ OrderEcho │ │ AuditOnly │ │ Promotions │ │ │
25
25
  │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
26
26
  │ └───────────────────────────────────────────────────────┘ │
27
- │ ▲ bridges via self.bridges (scoped per instance) │
27
+ │ ▲ self.bridges after Type:extend() (per profile) │
28
28
  └─────────────────────────────────────────────────────────────┘
29
29
  ```
30
30
 
@@ -42,12 +42,13 @@ Workspace: `"@microverse.ts/microverse-lua": "workspace:*"`.
42
42
  |------|---------|
43
43
  | **Microverse** | One shared Wasm Lua VM + catalog of script definitions + N mounted instances ([`LuaMicroverse`](src/infrastructure/facade/luaMicroverse.ts)). |
44
44
  | **Host** | Your typed services object passed to `MicroverseLua.create({ host })`. Handlers on the surface receive it; Lua never sees the raw host table. |
45
- | **Surface** | Result of `defineHostSurfaceFor<THost>().bridge(…).method(…).componentHooks(…).build()` — bridges, capability ids, and a manifest for `.d.lua`. |
46
- | **Bridge** | A named group of host methods exposed in Lua as `self.bridges.<name>:<method>(payload)`. **Not** a global in the script slot. |
47
- | **Capability** | A `domain:action` string declared on each bridge method (`requires`). Each instance mounts with an allowlist (`surface.pickCapabilities(…)`). |
48
- | **Script definition** | Catalog entry: `scriptId`, Lua source, optional `injectLuaChunks`, optional props schema / defaults. |
49
- | **Script instance** | A mounted slot: `instanceId`, `scriptId`, capabilities, props, and the active component table from `component:extend()`. |
50
- | **Component** | Lua table from `component:extend()` with `properties`, `state`, `bridges`, lifecycle (`init`, `onDestroy`, `onPropsChanged`), and domain `on*` hooks. |
45
+ | **Surface** | Result of `defineHostSurfaceFor<THost>().componentType(…).bridge(…).method(…).componentHooks(…).build()` — component types, bridges, capability ids, and a manifest for `.d.lua`. |
46
+ | **Component type** | Declared profile: props/state Zod schemas, capability set, hook subset. Lua fixes the type with `OrderEcho:extend()` `OrderEchoComponent`. |
47
+ | **Bridge** | A named group of host methods exposed in Lua as `self.bridges.<name>:<method>(payload)` when the active type’s capabilities include that method. **Not** a global in the script slot. |
48
+ | **Capability** | A `domain:action` string on each bridge method (`requires`) and on each `.componentType(…)` profile. Runtime includes only matching bridges on `self.bridges`. |
49
+ | **Script definition** | Catalog entry: `scriptId`, Lua source, optional `injectLuaChunks`, optional `profileId`, optional props schema / defaults. |
50
+ | **Script instance** | A mounted slot: `instanceId`, `scriptId`, props, and the component table from `YourType:extend()` in the script chunk. |
51
+ | **Component** | Lua table from `YourType:extend()` with typed `properties`, `state`, narrowed `bridges`, lifecycle (`init`, `onDestroy`, `onPropsChanged`), and domain `on*` hooks. |
51
52
 
52
53
  ## Engine lifecycle
53
54
 
@@ -64,7 +65,7 @@ sequenceDiagram
64
65
  App->>MV: mountScriptInstance
65
66
  MV->>Session: openSession
66
67
  Session->>VM: run shared + inject prelude chunks
67
- Session->>VM: run main chunk
68
+ Session->>VM: run main chunk (Type:extend())
68
69
  Session->>VM: setProps
69
70
  Session->>VM: invoke init
70
71
  App->>MV: emitToAllInstances
@@ -85,15 +86,15 @@ sequenceDiagram
85
86
  |-----------------|--------|
86
87
  | `MicroverseLua.create` | Create a Lua microverse (Wasm VM included). |
87
88
  | `registerScriptDefinition` | Catalog entry (source, optional preludes, props schema). |
88
- | `mountScriptInstance` | New Wasm slot for one instance (capabilities, props, audit). |
89
+ | `mountScriptInstance` | New Wasm slot for one instance (props, audit). Script must call `Type:extend()`. |
89
90
  | `unmountScriptInstance` | Tear down one instance. |
90
91
  | `emitToAllInstances` | Call `on{Kind}` on every mounted instance (component hooks). |
91
92
  | `setInstanceProps` / `patchInstanceProps` | Update host-synced props; may invoke `onPropsChanged`. |
92
93
  | `getInstanceProps` / `flushInstanceProps` | Read or flush props proxy state. |
93
94
  | `getSurfaceCapabilities` | All capability ids declared on the surface. |
94
- | `surface.pickCapabilities()` | Build an allowlist for `mountScriptInstance`. |
95
+ | `surface.getComponentType(name)` | Resolved profile (props, state, capabilities, hooks) for codegen/runtime. |
95
96
  | `dispose` | Unmount all instances. |
96
- | `defineHostSurfaceFor`, `defineHostSurface` | Fluent surface builder (`bridge` → `method` → `build`). |
97
+ | `defineHostSurfaceFor`, `defineHostSurface` | Fluent surface builder (`componentType` → `bridge` → `method` → `build`). |
97
98
 
98
99
  Re-exported from this package for convenience; lower-level session API lives in `@microverse.ts/host-surface`.
99
100
 
@@ -128,27 +129,28 @@ microverse.registerScriptDefinition({
128
129
  await microverse.mountScriptInstance({
129
130
  instanceId: 'welcome',
130
131
  scriptId: 'welcome',
131
- capabilities: surface.pickCapabilities('demo:greet'),
132
132
  });
133
133
 
134
134
  await microverse.dispose();
135
135
  ```
136
136
 
137
- > The minimal sample uses a global `greet` table for brevity. In production, use **`component:extend()`** and **`self.bridges`** (see [Lua authoring](#lua-authoring) and [Integrating in your app](#integrating-in-your-app)).
137
+ > The minimal sample uses a global `greet` table for brevity. In production, declare **`.componentType(…)`** on the surface, call **`YourType:extend()`** in Lua, and use **`self.bridges`** (see [Lua authoring](#lua-authoring) and [Integrating in your app](#integrating-in-your-app)).
138
138
 
139
139
  ## Integrating in your app
140
140
 
141
- The reference layout is [`examples/business-scripting-engine`](../../examples/business-scripting-engine). File tour: [example README](../../examples/business-scripting-engine/README.md).
141
+ The reference layout is [`examples/sorting-lab`](../../examples/sorting-lab). File tour: [example README](../../examples/sorting-lab/README.md).
142
142
 
143
143
  ### 1. Define the host
144
144
 
145
145
  Aggregate your real services into one object the surface handlers receive:
146
146
 
147
147
  ```ts
148
- // examples/business-scripting-engine/src/services/businessEngineHost.ts
149
- export type BusinessEngineHost = {
150
- readonly orders: OrdersService;
151
- readonly billing: BillingService;
148
+ // examples/sorting-lab/src/engine/sortingLabHost.ts
149
+ export type SortingLabHost = {
150
+ arrayA: number[];
151
+ arrayB: number[];
152
+ vizA: SortingVizSnapshot;
153
+ vizB: SortingVizSnapshot;
152
154
  // …
153
155
  };
154
156
  ```
@@ -160,24 +162,21 @@ Construct it in your app and pass it to `MicroverseLua.create({ host, surface })
160
162
  Declare bridges (Lua → host), Zod payloads, capabilities, and optional component hooks (host → Lua):
161
163
 
162
164
  ```ts
163
- // examples/business-scripting-engine/src/businessSurface.ts
165
+ // examples/sorting-lab/src/engine/sortingSurface.ts
164
166
  import { defineHostSurfaceFor } from '@microverse.ts/microverse-lua';
165
- import { businessComponentHooks } from './schemas/components/businessComponentHooks';
166
-
167
- export default defineHostSurfaceFor<BusinessEngineHost>()
168
- .bridge('orders')
169
- .method('get', {
170
- requires: 'orders:read',
171
- input: z.object({ orderId }),
172
- output: orderDto.optional(),
173
- handler: ({ host }, { orderId }) => host.orders.get(orderId),
174
- })
175
- // … more bridges …
176
- .componentHooks(businessComponentHooks)
167
+ import { sortingComponentHooks } from './sortingHooks';
168
+
169
+ export default defineHostSurfaceFor<SortingLabHost>()
170
+ .componentType('SortingAlgorithm', SORTING_ALGORITHM_PROFILE)
171
+ .bridge('array')
172
+ .method('length', { requires: 'array:read', /* … */ })
173
+ // viz, sort bridges …
174
+ .componentHooks(sortingComponentHooks)
177
175
  .build();
178
176
  ```
179
177
 
180
- - **`requires`** — Capability id enforced at runtime for this method.
178
+ - **`componentType`** — Props/state schemas, capability set, and hook subset for `Name:extend()`.
179
+ - **`requires`** — Capability id; only methods whose capability is in the active type appear on `self.bridges`.
181
180
  - **`handler`** — Runs in TypeScript with `{ host, script }` context.
182
181
  - **`componentHooks`** — Map of event kind → Zod object; generates `onOrderPlaced`, `MicroverseEvt_OrderPlaced`, etc. in `.d.lua`.
183
182
 
@@ -188,17 +187,17 @@ Default-export the built surface for `microverse generate-lua-defs --surface …
188
187
  A thin façade keeps app code free of microverse details:
189
188
 
190
189
  ```ts
191
- // examples/business-scripting-engine/src/BusinessScriptingEngine.ts
190
+ // examples/sorting-lab/src/engine/sortingLabEngine.ts
192
191
  this.microverse = MicroverseLua.create({ host, surface, defaultTimeoutMs: 30_000 });
193
192
 
194
193
  await this.microverse.mountScriptInstance({
195
- instanceId: 'promo-1',
196
- scriptId: 'promotions',
197
- capabilities: surface.pickCapabilities('orders:read', 'audit:record'),
198
- props: { label: 'summer-sale' },
194
+ instanceId: 'A',
195
+ scriptId: 'bubble_sort',
196
+ profileId: 'SortingAlgorithm',
197
+ props: { label: 'Bubble sort', slotSide: 'A' },
199
198
  });
200
199
 
201
- await this.microverse.emitToAllInstances('OrderPlaced', { orderId, amountCents, customerId });
200
+ await session.invokeComponentHook(luaGlobalHookName('Tick'), { step: 1 });
202
201
  ```
203
202
 
204
203
  Map your domain events to `emitToAllInstances` (see `dispatch` in the example).
@@ -217,16 +216,20 @@ Or inline strings for tests. Use **`sharedLuaChunks`** on `create` for libraries
217
216
 
218
217
  ### 5. Mount instances
219
218
 
220
- Each instance needs a **capability allowlist** only declared methods on allowed bridges are callable from Lua:
219
+ Each Lua script chooses its profile with **`YourType:extend()`** at load time. `self.bridges` only contains bridges/methods allowed by that type’s capabilities:
221
220
 
222
221
  ```ts
223
222
  await engine.mountScriptInstance({
224
223
  scriptId: 'billing_denied',
225
- capabilities: surface.pickCapabilities('billing:charge', 'audit:record'),
226
224
  props: { maxCents: 1000 },
227
225
  });
228
226
  ```
229
227
 
228
+ ```lua
229
+ -- billing_denied.lua — AuditOnly type has no billing bridge
230
+ local C = AuditOnly:extend()
231
+ ```
232
+
230
233
  Optional **`audit`** metadata is passed to script audit callbacks for observability.
231
234
 
232
235
  ### 6. Dispatch events and shut down
@@ -242,22 +245,20 @@ await engine.dispose();
242
245
 
243
246
  ### Component pattern
244
247
 
245
- Scripts use the injected **`component`** helper and implement hooks on the returned table:
248
+ Scripts call the **type singleton** declared on the surface (e.g. `OrderEcho:extend()`) and implement hooks on the returned table:
246
249
 
247
250
  ```lua
248
- -- examples/business-scripting-engine/lua/components/order_echo.lua
249
- local C = component:extend()
251
+ -- examples/sorting-lab/lua/bubble_sort.lua
252
+ local C = SortingAlgorithm:extend()
250
253
 
251
- function C:onOrderPlaced(evt)
252
- self.bridges.notifications:send({
253
- channel = "echo",
254
- message = "order:" .. evt.orderId,
255
- })
254
+ function C:onTick(_evt)
255
+ self.bridges.viz:markComparing({ a = j, b = j + 1 })
256
+ -- one compare/swap per tick …
256
257
  end
257
258
  ```
258
259
 
259
- - **`component:extend()`** — Builds the instance with `properties`, `state`, and `bridges` for this slot.
260
- - **Domain events** — Implement `onOrderPlaced`, `onInventoryLow`, matching `.componentHooks()` on the surface.
260
+ - **`OrderEcho:extend()`** — Builds the instance with typed `properties`, `state`, and narrowed `bridges` for that profile.
261
+ - **Domain events** — Implement `onOrderPlaced`, … listed in the type’s `hooks` (and in `OrderEchoComponent` in `.d.lua`).
261
262
  - **Lifecycle** — `init`, `onDestroy`, `onPropsChanged` (see `props_demo.lua`).
262
263
 
263
264
  ### Bridges (scoped, not global)
@@ -269,7 +270,7 @@ local order = self.bridges.orders:get({ orderId = evt.orderId })
269
270
  self.bridges.audit:record({ line = "seen:" .. evt.orderId })
270
271
  ```
271
272
 
272
- Bridge names match `.bridge('orders')` in TypeScript (camelCase field on `MicroverseBridges` in `.d.lua`).
273
+ Bridge names match `.bridge('orders')` in TypeScript (camelCase field on `OrderEchoBridges` / your type’s bridges class in `.d.lua`).
273
274
 
274
275
  ### Props and state
275
276
 
@@ -320,36 +321,55 @@ Generate stubs from the same surface module that drives runtime:
320
321
 
321
322
  ```bash
322
323
  pnpm add -D @microverse.ts/cli
323
- pnpm exec microverse generate-lua-defs --surface src/businessSurface.ts
324
+ pnpm exec microverse generate-lua-defs --surface src/engine/sortingSurface.ts
324
325
  ```
325
326
 
326
327
  The manifest emits **type-only** bridge classes (`---@class Orders` + `---@field get fun(…)`) so LuaLS does not treat `Orders` as a runtime global. Use:
327
328
 
328
- - `self.bridges.orders` — field name (camelCase) on `MicroverseBridges`
329
+ - `self.bridges.orders` — field name (camelCase) on `OrderEchoBridges` (per component type)
329
330
  - Types like `Orders`, `OrderDto` — PascalCase classes in the stub file
331
+ - `OrderEcho:extend()` — singleton stub per `.componentType('OrderEcho', …)`
330
332
 
331
- Point LuaLS at the generated folder:
333
+ Point LuaLS at the generated folder and list your type singletons as globals:
332
334
 
333
335
  ```json
334
336
  {
335
337
  "workspace.library": ["./generated"],
336
- "diagnostics.globals": ["component"]
338
+ "diagnostics.globals": ["OrderEcho", "AuditOnly", "Promotions"]
337
339
  }
338
340
  ```
339
341
 
340
- See [`examples/business-scripting-engine/.luarc.json`](../../examples/business-scripting-engine/.luarc.json) and [`generated/businessSurface.d.lua`](../../examples/business-scripting-engine/generated/businessSurface.d.lua).
342
+ Include both `sortingSurface.d.lua` (bridges + `*Component`) and `sortingScriptCatalog.d.lua` (per-`scriptId` aliases) when using a script catalog.
343
+
344
+ See [`examples/sorting-lab/.luarc.json`](../../examples/sorting-lab/.luarc.json) and [`generated/sortingSurface.d.lua`](../../examples/sorting-lab/generated/sortingSurface.d.lua).
345
+
346
+ **Chess duel (shared board, turn-based):** [`examples/chess-lab`](../examples/chess-lab/README.md) — two `ChessEngine` scripts compete on one `chess.js` board.
341
347
 
342
348
  Details: [`@microverse.ts/cli`](../cli/README.md), [`@microverse.ts/lua-defs`](../lua-defs/README.md).
343
349
 
350
+ ## Integrating a game engine (script profiles)
351
+
352
+ For ECS-style hosts (many entities, many scripts, YAML-driven props), use **script profiles** instead of declaring every script on the surface:
353
+
354
+ | Primitive | Role |
355
+ |-----------|------|
356
+ | `LuaScriptDefinition.profileId` | Names a profile (usually matches a `.componentType()` on the surface for bridges/codegen). |
357
+ | `mountScriptInstance({ profileId })` | Host applies the profile at `openSession` — Lua chunks can omit `Type:extend()` for runtime (keep `---@type XxxComponent` for LuaLS). |
358
+ | `HostScriptSession` + `createLuaEnvSlotKey('entity::script')` | One slot per entity+script; your subsystem owns reconcile/lifecycle. |
359
+ | `ScriptReferenceResolver` | Implement `self.references.*` wrappers (entity handles) without ECS types in microverse. |
360
+ | `buildScriptCatalogLuaDefManifest` | Emit per-`scriptId` aliases for `lua/` (see business example). |
361
+
362
+ Reference layout: [`examples/sorting-lab/src/engine/sortingScriptCatalog.ts`](../../examples/sorting-lab/src/engine/sortingScriptCatalog.ts).
363
+
344
364
  ## Security model
345
365
 
346
366
  | Layer | Behavior |
347
367
  |-------|----------|
348
- | **Capabilities** | Each bridge method declares `requires`. Calls from Lua are denied unless the instance’s allowlist includes that capability. |
349
- | **Per-instance allowlist** | `mountScriptInstance({ capabilities: surface.pickCapabilities(…) })` principle of least privilege per script. |
368
+ | **Component types** | Each `.componentType(…)` declares a capability set. `Type:extend()` mounts only matching bridges on `self.bridges`; other bridges are absent (`nil`). |
369
+ | **Bridge methods** | Each method declares `requires`; filtering happens at extend time, not per call (no `capability denied` throws). |
350
370
  | **Host isolation** | The TypeScript `host` object is not injected into Lua; only bridge tables built from the surface are visible (via `self.bridges`). |
351
371
  | **Timeouts** | `defaultTimeoutMs` or `defaultTimeout` on `create`; Wasm instruction budget in `@microverse.ts/runtime-wasm`. |
352
- | **Validation** | Zod validates bridge inputs and outputs at the TS boundary (`@microverse.ts/runtime-zod`). |
372
+ | **Validation** | Zod validates bridge inputs/outputs and instance props (per active type) at the TS boundary (`@microverse.ts/runtime-zod`). |
353
373
 
354
374
  ## Related packages
355
375
 
@@ -362,8 +382,9 @@ Details: [`@microverse.ts/cli`](../cli/README.md), [`@microverse.ts/lua-defs`](.
362
382
 
363
383
  ## Reference example
364
384
 
365
- [`examples/business-scripting-engine`](../../examples/business-scripting-engine) — orders, billing, notifications, audit, inventory, jobs, component Lua, and `BusinessScriptingEngine` wrapping this package.
385
+ [`examples/sorting-lab`](../../examples/sorting-lab) — browser sorting comparator: Wasm Lua, tick-by-tick `onTick`, dual panels, and `SortingLabEngine` wrapping this package.
366
386
 
367
387
  ```bash
368
- pnpm --filter @microverse.ts/business-scripting-engine test
388
+ pnpm --filter @microverse.ts/sorting-lab test
389
+ pnpm --filter @microverse.ts/sorting-lab dev
369
390
  ```
package/dist/index.d.ts CHANGED
@@ -4,9 +4,12 @@
4
4
  * Plug-and-play Lua scripting: **{@link MicroverseLua.create}** (built-in Wasm VM) and the fluent
5
5
  * **{@link defineHostSurfaceFor}** builder (`bridge` → `method` → `build`).
6
6
  */
7
- export { augmentHostWithCapabilityRegistry, BridgeBuilder, buildBridgeMergeEnvForHost, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, defineHostSurface, defineHostSurfaceFor, HostScriptSession, luaGlobalHookName, luaType, MICROVERSE_CAPABILITY_REGISTRY, pickSurfaceCapabilities, SurfaceBuilder, zodToLuaTypeRef, type AnyHostSurfaceMethod, type HostFnContext, type HostScriptSessionOptions, type HostSurface, type HostSurfaceCore, type HostSurfaceMethodEntry, type HostSurfaceSpec, type HostSurfaceSpecForHost, type HostComponentHooksSpec, type InferSurfaceCapabilities, type LuaDefManifestGeneratorOpts, type LuaGlobalHookName, type SchemaValidationPort, type SurfaceCapabilityString, type SurfaceMethodDef, type WithMicroverseCapabilityRegistry, type ComponentEventHookInvokeArgs, type ZodToLuaTypeRefOptions, } from '@microverse.ts/host-surface';
7
+ export { augmentHostWithCapabilityRegistry, BridgeBuilder, buildBridgeMergeEnvForProfile, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, defineHostSurface, defineHostSurfaceFor, HostScriptSession, luaGlobalHookName, luaType, MICROVERSE_CAPABILITY_REGISTRY, pickSurfaceCapabilities, SurfaceBuilder, zodToLuaTypeRef, type AnyHostSurfaceMethod, type HostFnContext, type HostScriptSessionOptions, type HostSurface, type HostSurfaceCore, type HostSurfaceMethodEntry, type HostSurfaceSpec, type HostSurfaceSpecForHost, type HostComponentHooksSpec, type InferSurfaceCapabilities, type LuaDefManifestGeneratorOpts, type LuaGlobalHookName, type SchemaValidationPort, type SurfaceCapabilityString, type SurfaceMethodDef, type WithMicroverseCapabilityRegistry, type ComponentEventHookInvokeArgs, type ZodToLuaTypeRefOptions, buildScriptCatalogLuaDefManifest, scriptCatalogComponentAlias, } from '@microverse.ts/host-surface';
8
8
  export * from '@microverse.ts/shared';
9
9
  export * from '@microverse.ts/runtime-core';
10
+ /** Commonly used script/catalog types (also available via `export *` from runtime-core). */
11
+ export type { LuaScriptDefinition, LuaScriptSource, ScriptInstanceContext, ScriptInstanceId, ScriptProfileDefInput, } from '@microverse.ts/runtime-core';
12
+ export { formatExecutionFailure } from '@microverse.ts/runtime-core';
10
13
  export * from '@microverse.ts/runtime-lua';
11
14
  export * from '@microverse.ts/runtime-wasm';
12
15
  export * from '@microverse.ts/runtime-bridge';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,iCAAiC,EACjC,aAAa,EACb,0BAA0B,EAC1B,sCAAsC,EACtC,kBAAkB,EAClB,qBAAqB,EACrB,2CAA2C,EAC3C,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,wBAAwB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AAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,4FAA4F;AAC5F,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,mCAAmC,EACxC,KAAK,uBAAuB,GAC7B,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { BridgeBuilder, HostScriptSession, HostScriptSession as HostScriptSession$1, MICROVERSE_CAPABILITY_REGISTRY, SurfaceBuilder, augmentHostWithCapabilityRegistry, buildBridgeMergeEnvForHost, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, defineHostSurface, defineHostSurfaceFor, luaGlobalHookName, luaGlobalHookName as luaGlobalHookName$1, luaType, pickSurfaceCapabilities, zodToLuaTypeRef } from "@microverse.ts/host-surface";
2
- import { createLuaEnvSlotKey, createScriptInstanceContext, fixedTimeout, mergeScriptPropertyBags, resolveLuaScriptSource } from "@microverse.ts/runtime-core";
1
+ import { BridgeBuilder, HostScriptSession, HostScriptSession as HostScriptSession$1, MICROVERSE_CAPABILITY_REGISTRY, SurfaceBuilder, augmentHostWithCapabilityRegistry, buildBridgeMergeEnvForProfile, buildScriptCatalogLuaDefManifest, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, defineHostSurface, defineHostSurfaceFor, luaGlobalHookName, luaGlobalHookName as luaGlobalHookName$1, luaType, pickSurfaceCapabilities, resolveScriptProfile, scriptCatalogComponentAlias, zodToLuaTypeRef } from "@microverse.ts/host-surface";
2
+ import { createLuaEnvSlotKey, createScriptInstanceContext, fixedTimeout, formatExecutionFailure, formatExecutionFailure as formatExecutionFailure$1, mergeScriptPropertyBags, resolveLuaScriptProfileId, resolveLuaScriptSource } from "@microverse.ts/runtime-core";
3
3
  import { createWasmMicroverseRuntime } from "@microverse.ts/runtime-wasm";
4
4
  export * from "@microverse.ts/shared";
5
5
  export * from "@microverse.ts/runtime-core";
@@ -42,7 +42,7 @@ var LuaMicroverse = class {
42
42
  hasScriptDefinition = (scriptId) => this.definitions.has(scriptId);
43
43
  getScriptDefinition = (scriptId) => this.definitions.get(scriptId);
44
44
  mountScriptInstance = async (args) => {
45
- const { instanceId, scriptId, capabilities, audit, injectLuaChunks } = args;
45
+ const { instanceId, scriptId, audit, injectLuaChunks } = args;
46
46
  if (this.instances.has(instanceId)) throw new Error(`script instance already mounted: ${instanceId}`);
47
47
  let def = this.definitions.get(scriptId);
48
48
  if (def === void 0) {
@@ -56,6 +56,13 @@ var LuaMicroverse = class {
56
56
  ...def,
57
57
  source: args.script
58
58
  };
59
+ const profileId = args.profileId ?? resolveLuaScriptProfileId(def);
60
+ let resolvedProfile;
61
+ if (def.profile !== void 0) {
62
+ const profileName = profileId ?? args.profileSingleton ?? scriptId;
63
+ resolvedProfile = resolveScriptProfile({ [profileName]: def.profile }, profileName, this.surface.getHostSurfaceSpec());
64
+ } else if (profileId !== void 0) this.surface.getComponentType(profileId);
65
+ const profileSingleton = args.profileSingleton ?? (def.profile !== void 0 && profileId !== void 0 ? profileId : void 0);
59
66
  const slotKey = createLuaEnvSlotKey(`${this.envSlotScope}:${instanceId}`);
60
67
  const scriptContext = createScriptInstanceContext({
61
68
  instanceId,
@@ -68,10 +75,11 @@ var LuaMicroverse = class {
68
75
  surface: this.surface,
69
76
  host: this.host,
70
77
  slotKey,
71
- allowedCapabilities: capabilities,
72
78
  defaultTimeout: this.defaultTimeout,
73
79
  script: scriptContext,
74
- propsSchema: def.propsSchema,
80
+ profileId: resolvedProfile?.name ?? profileId,
81
+ resolvedProfile,
82
+ profileSingleton,
75
83
  onScriptAudit: this.onScriptAudit
76
84
  });
77
85
  try {
@@ -156,7 +164,7 @@ var LuaMicroverse = class {
156
164
  }
157
165
  };
158
166
  function formatRunError(instanceId, phase, result) {
159
- return `instance "${instanceId}" failed ${phase}: ${result._tag === "err" && result.error?._tag === "AdapterError" ? result.error.message : JSON.stringify(result.error)}`;
167
+ return `instance "${instanceId}" failed ${phase}: ${formatExecutionFailure$1(result.error)}`;
160
168
  }
161
169
  function createLuaMicroverse(config) {
162
170
  return new LuaMicroverse({
@@ -185,13 +193,14 @@ function createLuaMicroverse(config) {
185
193
  * defaultTimeoutMs: 30_000,
186
194
  * });
187
195
  * microverse.registerScriptDefinition({ scriptId: 'ai', source: lua });
188
- * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai', capabilities: surface.pickCapabilities('demo:tick') });
196
+ * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai' });
197
+ * // Lua: local C = MyType:extend()
189
198
  * ```
190
199
  */
191
200
  var MicroverseLua = {
192
201
  /** Creates a {@link LuaMicroverse} with a built-in Wasm Lua runtime. */
193
202
  create: createLuaMicroverse };
194
203
  //#endregion
195
- export { BridgeBuilder, HostScriptSession, LuaMicroverse, MICROVERSE_CAPABILITY_REGISTRY, MicroverseLua, SurfaceBuilder, augmentHostWithCapabilityRegistry, buildBridgeMergeEnvForHost, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, createLuaMicroverse, defineHostSurface, defineHostSurfaceFor, luaGlobalHookName, luaType, pickSurfaceCapabilities, zodToLuaTypeRef };
204
+ export { BridgeBuilder, HostScriptSession, LuaMicroverse, MICROVERSE_CAPABILITY_REGISTRY, MicroverseLua, SurfaceBuilder, augmentHostWithCapabilityRegistry, buildBridgeMergeEnvForProfile, buildScriptCatalogLuaDefManifest, collectCapabilitiesFromHostSurfaceSpec, compileHostSurface, compileHostSurfaceFor, createBridgeDeclarationsFromHostSurfaceSpec, createLuaMicroverse, defineHostSurface, defineHostSurfaceFor, formatExecutionFailure, luaGlobalHookName, luaType, pickSurfaceCapabilities, scriptCatalogComponentAlias, zodToLuaTypeRef };
196
205
 
197
206
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/infrastructure/facade/luaMicroverse.ts","../src/infrastructure/facade/microverseLuaNamespace.ts"],"sourcesContent":["import type { z } from 'zod';\n\nimport {\n HostScriptSession,\n luaGlobalHookName,\n type HostSurface,\n type HostSurfaceCore,\n type HostComponentHooksSpec,\n} from '@microverse.ts/host-surface';\nimport type { CapabilityId } from '@microverse.ts/runtime-capabilities';\nimport {\n createLuaEnvSlotKey,\n createScriptInstanceContext,\n fixedTimeout,\n mergeScriptPropertyBags,\n resolveLuaScriptSource,\n type LuaScriptDefinition,\n type MicroverseRuntime,\n type ScriptAuditEvent,\n type ScriptPropertyBag,\n type TimeoutPolicy,\n} from '@microverse.ts/runtime-core';\nimport { createWasmMicroverseRuntime } from '@microverse.ts/runtime-wasm';\n\n/** Phantom key: optional on the host **type** so {@link InferScriptHooksFromHost} can recover hook Zod map typing. Never set at runtime. */\ndeclare const SCRIPT_HOOKS_TYPE: unique symbol;\n\nexport type TaggedLuaMicroverseHost<\n THooks extends HostComponentHooksSpec,\n TBase = unknown,\n> = TBase & { readonly [SCRIPT_HOOKS_TYPE]?: THooks };\n\nexport type InferScriptHooksFromHost<THost> = THost extends TaggedLuaMicroverseHost<infer H, unknown>\n ? H extends HostComponentHooksSpec\n ? H\n : undefined\n : undefined;\n\nexport type InferScriptHooksFromSurface<S extends HostSurfaceCore> =\n S extends HostSurfaceCore<CapabilityId> & { readonly componentHooks: infer H extends HostComponentHooksSpec }\n ? H\n : S extends HostSurface<infer H extends HostComponentHooksSpec, CapabilityId>\n ? H\n : undefined;\n\nexport type InferSurfaceCapabilitiesFromSurface<S extends HostSurfaceCore> = S extends HostSurfaceCore<\n infer C extends CapabilityId\n>\n ? C\n : CapabilityId;\n\ntype EffectiveScriptHooks<THost extends object, TSurface extends HostSurfaceCore> = [InferScriptHooksFromHost<THost>] extends [\n undefined,\n]\n ? InferScriptHooksFromSurface<TSurface>\n : InferScriptHooksFromHost<THost>;\n\nexport type LuaMicroverseConfig<\n THost extends object = object,\n THooks extends HostComponentHooksSpec | undefined = InferScriptHooksFromHost<THost>,\n TCapabilities extends CapabilityId = CapabilityId,\n> = {\n readonly host: THost;\n readonly surface: HostSurface<THooks, TCapabilities>;\n readonly envSlotScope?: string | undefined;\n readonly defaultTimeout?: TimeoutPolicy | undefined;\n readonly defaultTimeoutMs?: number | undefined;\n readonly sharedLuaChunks?: readonly string[] | undefined;\n readonly onScriptAudit?: ((event: ScriptAuditEvent) => void) | undefined;\n};\n\nfunction resolveDefaultTimeout<\n THost extends object,\n THooks extends HostComponentHooksSpec | undefined,\n TCapabilities extends CapabilityId,\n>(config: LuaMicroverseConfig<THost, THooks, TCapabilities>): TimeoutPolicy | undefined {\n if (config.defaultTimeout !== undefined) {\n return config.defaultTimeout;\n }\n if (config.defaultTimeoutMs !== undefined) {\n return fixedTimeout(config.defaultTimeoutMs);\n }\n return undefined;\n}\n\ntype EmitToAllInstancesFn<THooks extends HostComponentHooksSpec | undefined> = THooks extends HostComponentHooksSpec\n ? <const K extends keyof THooks & string>(kind: K, payload: Readonly<z.infer<THooks[K]>>) => Promise<void>\n : (\n kind: string,\n payload: Readonly<Record<string, string | number | boolean>>,\n ) => Promise<void>;\n\ntype MountedInstance = {\n readonly session: HostScriptSession<unknown, HostComponentHooksSpec | undefined>;\n};\n\nexport class LuaMicroverse<\n THost extends object = object,\n THooks extends HostComponentHooksSpec | undefined = InferScriptHooksFromHost<THost>,\n TCapabilities extends CapabilityId = CapabilityId,\n> {\n private readonly runtime: MicroverseRuntime;\n\n private readonly definitions = new Map<string, LuaScriptDefinition>();\n\n private readonly instances = new Map<string, MountedInstance>();\n\n private readonly host: THost;\n\n private readonly surface: HostSurface<THooks, TCapabilities>;\n\n private readonly envSlotScope: string;\n\n private readonly defaultTimeout: TimeoutPolicy | undefined;\n\n private readonly sharedLuaChunks: readonly string[];\n\n private readonly onScriptAudit: ((event: ScriptAuditEvent) => void) | undefined;\n\n constructor(private readonly config: LuaMicroverseConfig<THost, THooks, TCapabilities>) {\n this.host = config.host;\n this.surface = config.surface;\n this.defaultTimeout = resolveDefaultTimeout(config);\n this.sharedLuaChunks = config.sharedLuaChunks ?? [];\n this.onScriptAudit = config.onScriptAudit;\n this.runtime = createWasmMicroverseRuntime(\n this.defaultTimeout !== undefined ? { defaultTimeout: this.defaultTimeout } : {},\n );\n this.envSlotScope = config.envSlotScope ?? 'script';\n }\n\n readonly getSurfaceCapabilities = (): readonly TCapabilities[] => this.surface.capabilities;\n\n readonly registerScriptDefinition = (def: LuaScriptDefinition): void => {\n if (this.definitions.has(def.scriptId)) {\n throw new Error(`script definition already registered: ${def.scriptId}`);\n }\n this.definitions.set(def.scriptId, def);\n };\n\n readonly hasScriptDefinition = (scriptId: string): boolean => this.definitions.has(scriptId);\n\n readonly getScriptDefinition = (scriptId: string): LuaScriptDefinition | undefined =>\n this.definitions.get(scriptId);\n\n readonly mountScriptInstance = async (args: {\n readonly instanceId: string;\n readonly scriptId: string;\n readonly script?: string | undefined;\n readonly props?: ScriptPropertyBag | undefined;\n readonly capabilities: readonly TCapabilities[];\n readonly audit?: Readonly<Record<string, string | number | boolean>> | undefined;\n readonly injectLuaChunks?: readonly string[] | undefined;\n }): Promise<void> => {\n const { instanceId, scriptId, capabilities, audit, injectLuaChunks } = args;\n if (this.instances.has(instanceId)) {\n throw new Error(`script instance already mounted: ${instanceId}`);\n }\n\n let def = this.definitions.get(scriptId);\n if (def === undefined) {\n if (args.script === undefined) {\n throw new Error(`unknown scriptId \"${scriptId}\" and no inline script provided`);\n }\n def = {\n scriptId,\n source: args.script,\n };\n this.definitions.set(scriptId, def);\n } else if (args.script !== undefined) {\n def = { ...def, source: args.script };\n }\n\n const slotKey = createLuaEnvSlotKey(`${this.envSlotScope}:${instanceId}`);\n const scriptContext = createScriptInstanceContext({\n instanceId,\n scriptId,\n slotKey: String(slotKey),\n audit,\n });\n\n const session = new HostScriptSession<THost, THooks>({\n runtime: this.runtime,\n surface: this.surface,\n host: this.host,\n slotKey,\n allowedCapabilities: capabilities,\n defaultTimeout: this.defaultTimeout,\n script: scriptContext,\n propsSchema: def.propsSchema,\n onScriptAudit: this.onScriptAudit,\n });\n\n try {\n await session.openSession();\n const preludeChunks = [\n ...this.sharedLuaChunks,\n ...(def.injectLuaChunks ?? []),\n ...(injectLuaChunks ?? []),\n ];\n for (const [index, chunk] of preludeChunks.entries()) {\n const injected = await session.runChunk(chunk);\n if (injected._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, `prelude [${index}]`, injected));\n }\n }\n\n const source = await resolveLuaScriptSource(def.source);\n const loaded = await session.runChunk(source);\n if (loaded._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, 'main chunk', loaded));\n }\n\n const mergedProps = mergeScriptPropertyBags(def.defaultProps ?? {}, args.props ?? {});\n await session.setProps(mergedProps);\n const initResult = await session.invokeComponentHook('init');\n if (initResult._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, 'init hook', initResult));\n }\n\n this.instances.set(instanceId, { session });\n this.onScriptAudit?.({ kind: 'mounted', context: scriptContext });\n } catch (e) {\n await session.dispose();\n const message = e instanceof Error ? e.message : String(e);\n this.onScriptAudit?.({\n kind: 'scriptError',\n context: scriptContext,\n phase: 'mount',\n message,\n });\n throw e;\n }\n };\n\n readonly unmountScriptInstance = async (instanceId: string): Promise<void> => {\n const mounted = this.instances.get(instanceId);\n if (mounted === undefined) {\n throw new Error(`script instance not mounted: ${instanceId}`);\n }\n const ctx = mounted.session.context;\n await mounted.session.dispose();\n this.instances.delete(instanceId);\n this.onScriptAudit?.({ kind: 'unmounted', context: ctx });\n };\n\n readonly setInstanceProps = async (instanceId: string, bag: ScriptPropertyBag): Promise<void> => {\n const session = this.requireInstance(instanceId);\n await session.setProps(bag);\n };\n\n readonly patchInstanceProps = async (\n instanceId: string,\n partial: ScriptPropertyBag,\n ): Promise<void> => {\n const session = this.requireInstance(instanceId);\n await session.patchProps(partial);\n };\n\n readonly getInstanceProps = (instanceId: string): Readonly<ScriptPropertyBag> => {\n return this.requireInstance(instanceId).getProps();\n };\n\n readonly flushInstanceProps = async (instanceId: string): Promise<ScriptPropertyBag | null> => {\n return this.requireInstance(instanceId).flushDirtyProps();\n };\n\n readonly getInstance = (instanceId: string): HostScriptSession<THost, THooks> | undefined => {\n return this.instances.get(instanceId)?.session as HostScriptSession<THost, THooks> | undefined;\n };\n\n readonly emitToAllInstances = (async (\n kind: string,\n payload: Readonly<Record<string, string | number | boolean>>,\n ) => {\n const hook = luaGlobalHookName(kind);\n for (const [id, { session }] of this.instances) {\n const r = await session.invokeComponentEventHook(hook, payload);\n if (r._tag !== 'ok') {\n const detail =\n r._tag === 'err' && r.error._tag === 'AdapterError' ? r.error.message : JSON.stringify(r.error);\n throw new Error(`instance \"${id}\" failed on emit: ${detail}`);\n }\n }\n }) as EmitToAllInstancesFn<THooks>;\n\n readonly dispose = async (): Promise<void> => {\n for (const id of [...this.instances.keys()]) {\n await this.unmountScriptInstance(id);\n }\n this.instances.clear();\n };\n\n private requireInstance(instanceId: string): HostScriptSession<THost, THooks> {\n const mounted = this.instances.get(instanceId);\n if (mounted === undefined) {\n throw new Error(`script instance not mounted: ${instanceId}`);\n }\n return mounted.session as HostScriptSession<THost, THooks>;\n }\n}\n\nfunction formatRunError(\n instanceId: string,\n phase: string,\n result: { _tag: string; error?: { _tag?: string; message?: string } },\n): string {\n const detail =\n result._tag === 'err' && result.error?._tag === 'AdapterError'\n ? result.error.message\n : JSON.stringify(result.error);\n return `instance \"${instanceId}\" failed ${phase}: ${detail}`;\n}\n\nexport function createLuaMicroverse<\n THost extends object,\n const TSurface extends HostSurfaceCore<CapabilityId>,\n>(config: {\n readonly host: THost;\n readonly surface: TSurface;\n readonly envSlotScope?: string | undefined;\n readonly defaultTimeout?: TimeoutPolicy | undefined;\n readonly defaultTimeoutMs?: number | undefined;\n readonly sharedLuaChunks?: readonly string[] | undefined;\n readonly onScriptAudit?: ((event: ScriptAuditEvent) => void) | undefined;\n}): LuaMicroverse<THost, EffectiveScriptHooks<THost, TSurface>, InferSurfaceCapabilitiesFromSurface<TSurface>> {\n type H = EffectiveScriptHooks<THost, TSurface>;\n type C = InferSurfaceCapabilitiesFromSurface<TSurface>;\n return new LuaMicroverse<THost, H, C>({\n host: config.host,\n surface: config.surface as unknown as HostSurface<H, C>,\n envSlotScope: config.envSlotScope,\n defaultTimeout: config.defaultTimeout,\n defaultTimeoutMs: config.defaultTimeoutMs,\n sharedLuaChunks: config.sharedLuaChunks,\n onScriptAudit: config.onScriptAudit,\n });\n}\n","import { createLuaMicroverse } from './luaMicroverse';\n\n/**\n * Plug-and-play **Lua microverse** entry point.\n *\n * A Wasmoon-backed VM is always created for you — pass only `host`, `surface`, and optional timeouts /\n * shared Lua preludes. Define bridges with {@link defineHostSurfaceFor} (`bridge` → `method` → `build`).\n *\n * @example\n * ```ts\n * const microverse = MicroverseLua.create({\n * host: myHost,\n * surface: mySurface,\n * defaultTimeoutMs: 30_000,\n * });\n * microverse.registerScriptDefinition({ scriptId: 'ai', source: lua });\n * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai', capabilities: surface.pickCapabilities('demo:tick') });\n * ```\n */\nexport const MicroverseLua = {\n /** Creates a {@link LuaMicroverse} with a built-in Wasm Lua runtime. */\n create: createLuaMicroverse,\n} as const;\n"],"mappings":";;;;;;;;;;;AAuEA,SAAS,sBAIP,QAAsF;CACtF,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO,OAAO;CAEhB,IAAI,OAAO,qBAAqB,KAAA,GAC9B,OAAO,aAAa,OAAO,gBAAgB;AAG/C;AAaA,IAAa,gBAAb,MAIE;CAmB6B;CAlB7B;CAEA,8BAA+B,IAAI,IAAiC;CAEpE,4BAA6B,IAAI,IAA6B;CAE9D;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAY,QAA4E;EAA3D,KAAA,SAAA;EAC3B,KAAK,OAAO,OAAO;EACnB,KAAK,UAAU,OAAO;EACtB,KAAK,iBAAiB,sBAAsB,MAAM;EAClD,KAAK,kBAAkB,OAAO,mBAAmB,CAAC;EAClD,KAAK,gBAAgB,OAAO;EAC5B,KAAK,UAAU,4BACb,KAAK,mBAAmB,KAAA,IAAY,EAAE,gBAAgB,KAAK,eAAe,IAAI,CAAC,CACjF;EACA,KAAK,eAAe,OAAO,gBAAgB;CAC7C;CAEA,+BAAkE,KAAK,QAAQ;CAE/E,4BAAqC,QAAmC;EACtE,IAAI,KAAK,YAAY,IAAI,IAAI,QAAQ,GACnC,MAAM,IAAI,MAAM,yCAAyC,IAAI,UAAU;EAEzE,KAAK,YAAY,IAAI,IAAI,UAAU,GAAG;CACxC;CAEA,uBAAgC,aAA8B,KAAK,YAAY,IAAI,QAAQ;CAE3F,uBAAgC,aAC9B,KAAK,YAAY,IAAI,QAAQ;CAE/B,sBAA+B,OAAO,SAQjB;EACnB,MAAM,EAAE,YAAY,UAAU,cAAc,OAAO,oBAAoB;EACvE,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B,OAC7B,MACA,YACG;EACH,MAAM,OAAO,oBAAkB,IAAI;EACnC,KAAK,MAAM,CAAC,IAAI,EAAE,cAAc,KAAK,WAAW;GAC9C,MAAM,IAAI,MAAM,QAAQ,yBAAyB,MAAM,OAAO;GAC9D,IAAI,EAAE,SAAS,MAAM;IACnB,MAAM,SACJ,EAAE,SAAS,SAAS,EAAE,MAAM,SAAS,iBAAiB,EAAE,MAAM,UAAU,KAAK,UAAU,EAAE,KAAK;IAChG,MAAM,IAAI,MAAM,aAAa,GAAG,oBAAoB,QAAQ;GAC9D;EACF;CACF;CAEA,UAAmB,YAA2B;EAC5C,KAAK,MAAM,MAAM,CAAC,GAAG,KAAK,UAAU,KAAK,CAAC,GACxC,MAAM,KAAK,sBAAsB,EAAE;EAErC,KAAK,UAAU,MAAM;CACvB;CAEA,gBAAwB,YAAsD;EAC5E,MAAM,UAAU,KAAK,UAAU,IAAI,UAAU;EAC7C,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,gCAAgC,YAAY;EAE9D,OAAO,QAAQ;CACjB;AACF;AAEA,SAAS,eACP,YACA,OACA,QACQ;CAKR,OAAO,aAAa,WAAW,WAAW,MAAM,IAH9C,OAAO,SAAS,SAAS,OAAO,OAAO,SAAS,iBAC5C,OAAO,MAAM,UACb,KAAK,UAAU,OAAO,KAAK;AAEnC;AAEA,SAAgB,oBAGd,QAQ6G;CAG7G,OAAO,IAAI,cAA2B;EACpC,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,cAAc,OAAO;EACrB,gBAAgB,OAAO;EACvB,kBAAkB,OAAO;EACzB,iBAAiB,OAAO;EACxB,eAAe,OAAO;CACxB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;AC9TA,IAAa,gBAAgB;;AAE3B,QAAQ,oBACV"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/infrastructure/facade/luaMicroverse.ts","../src/infrastructure/facade/microverseLuaNamespace.ts"],"sourcesContent":["import type { z } from 'zod';\n\nimport {\n HostScriptSession,\n luaGlobalHookName,\n resolveScriptProfile,\n type HostSurface,\n type HostSurfaceCore,\n type HostComponentHooksSpec,\n type ResolvedScriptProfile,\n} from '@microverse.ts/host-surface';\nimport type { CapabilityId } from '@microverse.ts/runtime-capabilities';\nimport {\n createLuaEnvSlotKey,\n createScriptInstanceContext,\n fixedTimeout,\n mergeScriptPropertyBags,\n formatExecutionFailure,\n resolveLuaScriptProfileId,\n resolveLuaScriptSource,\n type ExecutionFailure,\n type LuaScriptDefinition,\n type MicroverseRuntime,\n type ScriptAuditEvent,\n type ScriptPropertyBag,\n type TimeoutPolicy,\n} from '@microverse.ts/runtime-core';\nimport { createWasmMicroverseRuntime } from '@microverse.ts/runtime-wasm';\n\n/** Phantom key: optional on the host **type** so {@link InferScriptHooksFromHost} can recover hook Zod map typing. Never set at runtime. */\ndeclare const SCRIPT_HOOKS_TYPE: unique symbol;\n\nexport type TaggedLuaMicroverseHost<\n THooks extends HostComponentHooksSpec,\n TBase = unknown,\n> = TBase & { readonly [SCRIPT_HOOKS_TYPE]?: THooks };\n\nexport type InferScriptHooksFromHost<THost> = THost extends TaggedLuaMicroverseHost<infer H, unknown>\n ? H extends HostComponentHooksSpec\n ? H\n : undefined\n : undefined;\n\nexport type InferScriptHooksFromSurface<S extends HostSurfaceCore> =\n S extends HostSurfaceCore<CapabilityId> & { readonly componentHooks: infer H extends HostComponentHooksSpec }\n ? H\n : S extends HostSurface<infer H extends HostComponentHooksSpec, CapabilityId>\n ? H\n : undefined;\n\nexport type InferSurfaceCapabilitiesFromSurface<S extends HostSurfaceCore> = S extends HostSurfaceCore<\n infer C extends CapabilityId\n>\n ? C\n : CapabilityId;\n\ntype EffectiveScriptHooks<THost extends object, TSurface extends HostSurfaceCore> = [InferScriptHooksFromHost<THost>] extends [\n undefined,\n]\n ? InferScriptHooksFromSurface<TSurface>\n : InferScriptHooksFromHost<THost>;\n\nexport type LuaMicroverseConfig<\n THost extends object = object,\n THooks extends HostComponentHooksSpec | undefined = InferScriptHooksFromHost<THost>,\n TCapabilities extends CapabilityId = CapabilityId,\n> = {\n readonly host: THost;\n readonly surface: HostSurface<THooks, TCapabilities>;\n readonly envSlotScope?: string | undefined;\n readonly defaultTimeout?: TimeoutPolicy | undefined;\n readonly defaultTimeoutMs?: number | undefined;\n readonly sharedLuaChunks?: readonly string[] | undefined;\n readonly onScriptAudit?: ((event: ScriptAuditEvent) => void) | undefined;\n};\n\nfunction resolveDefaultTimeout<\n THost extends object,\n THooks extends HostComponentHooksSpec | undefined,\n TCapabilities extends CapabilityId,\n>(config: LuaMicroverseConfig<THost, THooks, TCapabilities>): TimeoutPolicy | undefined {\n if (config.defaultTimeout !== undefined) {\n return config.defaultTimeout;\n }\n if (config.defaultTimeoutMs !== undefined) {\n return fixedTimeout(config.defaultTimeoutMs);\n }\n return undefined;\n}\n\ntype EmitToAllInstancesFn<THooks extends HostComponentHooksSpec | undefined> = THooks extends HostComponentHooksSpec\n ? <const K extends keyof THooks & string>(kind: K, payload: Readonly<z.infer<THooks[K]>>) => Promise<void>\n : (\n kind: string,\n payload: Readonly<Record<string, string | number | boolean>>,\n ) => Promise<void>;\n\ntype MountedInstance = {\n readonly session: HostScriptSession<unknown, HostComponentHooksSpec | undefined>;\n};\n\nexport class LuaMicroverse<\n THost extends object = object,\n THooks extends HostComponentHooksSpec | undefined = InferScriptHooksFromHost<THost>,\n TCapabilities extends CapabilityId = CapabilityId,\n> {\n private readonly runtime: MicroverseRuntime;\n\n private readonly definitions = new Map<string, LuaScriptDefinition>();\n\n private readonly instances = new Map<string, MountedInstance>();\n\n private readonly host: THost;\n\n private readonly surface: HostSurface<THooks, TCapabilities>;\n\n private readonly envSlotScope: string;\n\n private readonly defaultTimeout: TimeoutPolicy | undefined;\n\n private readonly sharedLuaChunks: readonly string[];\n\n private readonly onScriptAudit: ((event: ScriptAuditEvent) => void) | undefined;\n\n constructor(private readonly config: LuaMicroverseConfig<THost, THooks, TCapabilities>) {\n this.host = config.host;\n this.surface = config.surface;\n this.defaultTimeout = resolveDefaultTimeout(config);\n this.sharedLuaChunks = config.sharedLuaChunks ?? [];\n this.onScriptAudit = config.onScriptAudit;\n this.runtime = createWasmMicroverseRuntime(\n this.defaultTimeout !== undefined ? { defaultTimeout: this.defaultTimeout } : {},\n );\n this.envSlotScope = config.envSlotScope ?? 'script';\n }\n\n readonly getSurfaceCapabilities = (): readonly TCapabilities[] => this.surface.capabilities;\n\n readonly registerScriptDefinition = (def: LuaScriptDefinition): void => {\n if (this.definitions.has(def.scriptId)) {\n throw new Error(`script definition already registered: ${def.scriptId}`);\n }\n this.definitions.set(def.scriptId, def);\n };\n\n readonly hasScriptDefinition = (scriptId: string): boolean => this.definitions.has(scriptId);\n\n readonly getScriptDefinition = (scriptId: string): LuaScriptDefinition | undefined =>\n this.definitions.get(scriptId);\n\n readonly mountScriptInstance = async (args: {\n readonly instanceId: string;\n readonly scriptId: string;\n readonly script?: string | undefined;\n readonly props?: ScriptPropertyBag | undefined;\n readonly audit?: Readonly<Record<string, string | number | boolean>> | undefined;\n readonly injectLuaChunks?: readonly string[] | undefined;\n /** Overrides {@link LuaScriptDefinition.profileId} for this mount. */\n readonly profileId?: string | undefined;\n /** Lua global for `Type:extend()` when using an inline {@link LuaScriptDefinition.profile}. */\n readonly profileSingleton?: string | undefined;\n }): Promise<void> => {\n const { instanceId, scriptId, audit, injectLuaChunks } = args;\n if (this.instances.has(instanceId)) {\n throw new Error(`script instance already mounted: ${instanceId}`);\n }\n\n let def = this.definitions.get(scriptId);\n if (def === undefined) {\n if (args.script === undefined) {\n throw new Error(`unknown scriptId \"${scriptId}\" and no inline script provided`);\n }\n def = {\n scriptId,\n source: args.script,\n };\n this.definitions.set(scriptId, def);\n } else if (args.script !== undefined) {\n def = { ...def, source: args.script };\n }\n\n const profileId = args.profileId ?? resolveLuaScriptProfileId(def);\n let resolvedProfile: ResolvedScriptProfile | undefined;\n if (def.profile !== undefined) {\n const profileName = profileId ?? args.profileSingleton ?? scriptId;\n resolvedProfile = resolveScriptProfile(\n { [profileName]: def.profile },\n profileName,\n this.surface.getHostSurfaceSpec(),\n );\n } else if (profileId !== undefined) {\n this.surface.getComponentType(profileId);\n }\n\n const profileSingleton =\n args.profileSingleton ??\n (def.profile !== undefined && profileId !== undefined ? profileId : undefined);\n\n const slotKey = createLuaEnvSlotKey(`${this.envSlotScope}:${instanceId}`);\n const scriptContext = createScriptInstanceContext({\n instanceId,\n scriptId,\n slotKey: String(slotKey),\n audit,\n });\n\n const session = new HostScriptSession<THost, THooks>({\n runtime: this.runtime,\n surface: this.surface,\n host: this.host,\n slotKey,\n defaultTimeout: this.defaultTimeout,\n script: scriptContext,\n profileId: resolvedProfile?.name ?? profileId,\n resolvedProfile,\n profileSingleton,\n onScriptAudit: this.onScriptAudit,\n });\n\n try {\n await session.openSession();\n const preludeChunks = [\n ...this.sharedLuaChunks,\n ...(def.injectLuaChunks ?? []),\n ...(injectLuaChunks ?? []),\n ];\n for (const [index, chunk] of preludeChunks.entries()) {\n const injected = await session.runChunk(chunk);\n if (injected._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, `prelude [${index}]`, injected));\n }\n }\n\n const source = await resolveLuaScriptSource(def.source);\n const loaded = await session.runChunk(source);\n if (loaded._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, 'main chunk', loaded));\n }\n\n const mergedProps = mergeScriptPropertyBags(def.defaultProps ?? {}, args.props ?? {});\n await session.setProps(mergedProps);\n const initResult = await session.invokeComponentHook('init');\n if (initResult._tag !== 'ok') {\n throw new Error(formatRunError(instanceId, 'init hook', initResult));\n }\n\n this.instances.set(instanceId, { session });\n this.onScriptAudit?.({ kind: 'mounted', context: scriptContext });\n } catch (e) {\n await session.dispose();\n const message = e instanceof Error ? e.message : String(e);\n this.onScriptAudit?.({\n kind: 'scriptError',\n context: scriptContext,\n phase: 'mount',\n message,\n });\n throw e;\n }\n };\n\n readonly unmountScriptInstance = async (instanceId: string): Promise<void> => {\n const mounted = this.instances.get(instanceId);\n if (mounted === undefined) {\n throw new Error(`script instance not mounted: ${instanceId}`);\n }\n const ctx = mounted.session.context;\n await mounted.session.dispose();\n this.instances.delete(instanceId);\n this.onScriptAudit?.({ kind: 'unmounted', context: ctx });\n };\n\n readonly setInstanceProps = async (instanceId: string, bag: ScriptPropertyBag): Promise<void> => {\n const session = this.requireInstance(instanceId);\n await session.setProps(bag);\n };\n\n readonly patchInstanceProps = async (\n instanceId: string,\n partial: ScriptPropertyBag,\n ): Promise<void> => {\n const session = this.requireInstance(instanceId);\n await session.patchProps(partial);\n };\n\n readonly getInstanceProps = (instanceId: string): Readonly<ScriptPropertyBag> => {\n return this.requireInstance(instanceId).getProps();\n };\n\n readonly flushInstanceProps = async (instanceId: string): Promise<ScriptPropertyBag | null> => {\n return this.requireInstance(instanceId).flushDirtyProps();\n };\n\n readonly getInstance = (instanceId: string): HostScriptSession<THost, THooks> | undefined => {\n return this.instances.get(instanceId)?.session as HostScriptSession<THost, THooks> | undefined;\n };\n\n readonly emitToAllInstances = (async (\n kind: string,\n payload: Readonly<Record<string, string | number | boolean>>,\n ) => {\n const hook = luaGlobalHookName(kind);\n for (const [id, { session }] of this.instances) {\n const r = await session.invokeComponentEventHook(hook, payload);\n if (r._tag !== 'ok') {\n const detail =\n r._tag === 'err' && r.error._tag === 'AdapterError' ? r.error.message : JSON.stringify(r.error);\n throw new Error(`instance \"${id}\" failed on emit: ${detail}`);\n }\n }\n }) as EmitToAllInstancesFn<THooks>;\n\n readonly dispose = async (): Promise<void> => {\n for (const id of [...this.instances.keys()]) {\n await this.unmountScriptInstance(id);\n }\n this.instances.clear();\n };\n\n private requireInstance(instanceId: string): HostScriptSession<THost, THooks> {\n const mounted = this.instances.get(instanceId);\n if (mounted === undefined) {\n throw new Error(`script instance not mounted: ${instanceId}`);\n }\n return mounted.session as HostScriptSession<THost, THooks>;\n }\n}\n\nfunction formatRunError(\n instanceId: string,\n phase: string,\n result: { readonly _tag: 'err'; readonly error: ExecutionFailure },\n): string {\n return `instance \"${instanceId}\" failed ${phase}: ${formatExecutionFailure(result.error)}`;\n}\n\nexport function createLuaMicroverse<\n THost extends object,\n const TSurface extends HostSurfaceCore<CapabilityId>,\n>(config: {\n readonly host: THost;\n readonly surface: TSurface;\n readonly envSlotScope?: string | undefined;\n readonly defaultTimeout?: TimeoutPolicy | undefined;\n readonly defaultTimeoutMs?: number | undefined;\n readonly sharedLuaChunks?: readonly string[] | undefined;\n readonly onScriptAudit?: ((event: ScriptAuditEvent) => void) | undefined;\n}): LuaMicroverse<THost, EffectiveScriptHooks<THost, TSurface>, InferSurfaceCapabilitiesFromSurface<TSurface>> {\n type H = EffectiveScriptHooks<THost, TSurface>;\n type C = InferSurfaceCapabilitiesFromSurface<TSurface>;\n return new LuaMicroverse<THost, H, C>({\n host: config.host,\n surface: config.surface as unknown as HostSurface<H, C>,\n envSlotScope: config.envSlotScope,\n defaultTimeout: config.defaultTimeout,\n defaultTimeoutMs: config.defaultTimeoutMs,\n sharedLuaChunks: config.sharedLuaChunks,\n onScriptAudit: config.onScriptAudit,\n });\n}\n","import { createLuaMicroverse } from './luaMicroverse';\n\n/**\n * Plug-and-play **Lua microverse** entry point.\n *\n * A Wasmoon-backed VM is always created for you — pass only `host`, `surface`, and optional timeouts /\n * shared Lua preludes. Define bridges with {@link defineHostSurfaceFor} (`bridge` → `method` → `build`).\n *\n * @example\n * ```ts\n * const microverse = MicroverseLua.create({\n * host: myHost,\n * surface: mySurface,\n * defaultTimeoutMs: 30_000,\n * });\n * microverse.registerScriptDefinition({ scriptId: 'ai', source: lua });\n * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai' });\n * // Lua: local C = MyType:extend()\n * ```\n */\nexport const MicroverseLua = {\n /** Creates a {@link LuaMicroverse} with a built-in Wasm Lua runtime. */\n create: createLuaMicroverse,\n} as const;\n"],"mappings":";;;;;;;;;;;AA4EA,SAAS,sBAIP,QAAsF;CACtF,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO,OAAO;CAEhB,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AAI,UAAU,GAAG;CACzC;CAEA,sBAA+B,OAC7B,MACA,YACG;EACH,MAAM,OAAO,oBAAkB,IAAI;EACnC,KAAK,MAAM,CAAC,IAAI,EAAE,cAAc,KAAK,WAAW;GAC9C,MAAM,IAAI,MAAM,QAAQ,yBAAyB,MAAM,OAAO;GAC9D,IAAI,EAAE,SAAS,MAAM;IACnB,MAAM,SACJ,EAAE,SAAS,SAAS,EAAE,MAAM,SAAS,iBAAiB,EAAE,MAAM,UAAU,KAAK,UAAU,EAAE,KAAK;IAChG,MAAM,IAAI,MAAM,aAAa,GAAG,oBAAoB,QAAQ;GAC9D;EACF;CACF;CAEA,UAAmB,YAA2B;EAC5C,KAAK,MAAM,MAAM,CAAC,GAAG,KAAK,UAAU,KAAK,CAAC,GACxC,MAAM,KAAK,sBAAsB,EAAE;EAErC,KAAK,UAAU,MAAM;CACvB;CAEA,gBAAwB,YAAsD;EAC5E,MAAM,UAAU,KAAK,UAAU,IAAI,UAAU;EAC7C,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,gCAAgC,YAAY;EAE9D,OAAO,QAAQ;CACjB;AACF;AAEA,SAAS,eACP,YACA,OACA,QACQ;CACR,OAAO,aAAa,WAAW,WAAW,MAAM,IAAI,yBAAuB,OAAO,KAAK;AACzF;AAEA,SAAgB,oBAGd,QAQ6G;CAG7G,OAAO,IAAI,cAA2B;EACpC,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,cAAc,OAAO;EACrB,gBAAgB,OAAO;EACvB,kBAAkB,OAAO;EACzB,iBAAiB,OAAO;EACxB,eAAe,OAAO;CACxB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;ACnVA,IAAa,gBAAgB;;AAE3B,QAAQ,oBACV"}
@@ -46,9 +46,12 @@ export declare class LuaMicroverse<THost extends object = object, THooks extends
46
46
  readonly scriptId: string;
47
47
  readonly script?: string | undefined;
48
48
  readonly props?: ScriptPropertyBag | undefined;
49
- readonly capabilities: readonly TCapabilities[];
50
49
  readonly audit?: Readonly<Record<string, string | number | boolean>> | undefined;
51
50
  readonly injectLuaChunks?: readonly string[] | undefined;
51
+ /** Overrides {@link LuaScriptDefinition.profileId} for this mount. */
52
+ readonly profileId?: string | undefined;
53
+ /** Lua global for `Type:extend()` when using an inline {@link LuaScriptDefinition.profile}. */
54
+ readonly profileSingleton?: string | undefined;
52
55
  }) => Promise<void>;
53
56
  readonly unmountScriptInstance: (instanceId: string) => Promise<void>;
54
57
  readonly setInstanceProps: (instanceId: string, bag: ScriptPropertyBag) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"luaMicroverse.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/facade/luaMicroverse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EACL,iBAAiB,EAEjB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAML,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAGrC,4IAA4I;AAC5I,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAE/C,MAAM,MAAM,uBAAuB,CACjC,MAAM,SAAS,sBAAsB,EACrC,KAAK,GAAG,OAAO,IACb,KAAK,GAAG;IAAE,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,MAAM,MAAM,wBAAwB,CAAC,KAAK,IAAI,KAAK,SAAS,uBAAuB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,GACjG,CAAC,SAAS,sBAAsB,GAC9B,CAAC,GACD,SAAS,GACX,SAAS,CAAC;AAEd,MAAM,MAAM,2BAA2B,CAAC,CA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AC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC1E,GAAG,aAAa,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,mCAAmC,CAAC,QAAQ,CAAC,CAAC,CAY7G"}
@@ -13,7 +13,8 @@ import { createLuaMicroverse } from './luaMicroverse';
13
13
  * defaultTimeoutMs: 30_000,
14
14
  * });
15
15
  * microverse.registerScriptDefinition({ scriptId: 'ai', source: lua });
16
- * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai', capabilities: surface.pickCapabilities('demo:tick') });
16
+ * await microverse.mountScriptInstance({ instanceId: 'ai', scriptId: 'ai' });
17
+ * // Lua: local C = MyType:extend()
17
18
  * ```
18
19
  */
19
20
  export declare const MicroverseLua: {
@@ -1 +1 @@
1
- {"version":3,"file":"microverseLuaNamespace.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/facade/microverseLuaNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;IACxB,wEAAwE;;CAEhE,CAAC"}
1
+ {"version":3,"file":"microverseLuaNamespace.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/facade/microverseLuaNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;IACxB,wEAAwE;;CAEhE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microverse.ts/microverse-lua",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -30,14 +30,14 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "zod": "^3.24.0",
33
- "@microverse.ts/host-surface": "0.2.0",
34
- "@microverse.ts/runtime-bridge": "0.2.0",
35
- "@microverse.ts/runtime-capabilities": "0.2.0",
36
- "@microverse.ts/runtime-core": "0.2.0",
37
- "@microverse.ts/runtime-lua": "0.2.0",
38
- "@microverse.ts/runtime-wasm": "0.2.0",
39
- "@microverse.ts/runtime-zod": "0.2.0",
40
- "@microverse.ts/shared": "0.2.0"
33
+ "@microverse.ts/host-surface": "0.3.0",
34
+ "@microverse.ts/runtime-bridge": "0.3.0",
35
+ "@microverse.ts/runtime-capabilities": "0.3.0",
36
+ "@microverse.ts/runtime-core": "0.3.0",
37
+ "@microverse.ts/runtime-lua": "0.3.0",
38
+ "@microverse.ts/runtime-wasm": "0.3.0",
39
+ "@microverse.ts/runtime-zod": "0.3.0",
40
+ "@microverse.ts/shared": "0.3.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^5.8.3",