@zylem/editor 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/zylem-editor.d.ts +87 -57
- package/dist/zylem-editor.js +72 -10
- package/package.json +6 -5
package/dist/zylem-editor.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Component } from 'solid-js';
|
|
2
2
|
import { LucideProps } from 'lucide-solid';
|
|
3
|
+
import * as _zylem_bridge from '@zylem/bridge';
|
|
4
|
+
import { BridgeDebugTool } from '@zylem/bridge';
|
|
3
5
|
|
|
4
6
|
type EditorLauncherMode = 'floating' | 'hidden';
|
|
5
7
|
|
|
@@ -68,6 +70,8 @@ declare class ZylemEditorElement extends HTMLElement {
|
|
|
68
70
|
private _config;
|
|
69
71
|
private _initialized;
|
|
70
72
|
private controller;
|
|
73
|
+
/** Releases this element's bridge subscription (reference-counted). */
|
|
74
|
+
private releaseBridge;
|
|
71
75
|
constructor();
|
|
72
76
|
/**
|
|
73
77
|
* Set configuration for the editor.
|
|
@@ -93,6 +97,7 @@ declare class ZylemEditorElement extends HTMLElement {
|
|
|
93
97
|
*/
|
|
94
98
|
reinitialize(): void;
|
|
95
99
|
disconnectedCallback(): void;
|
|
100
|
+
private teardown;
|
|
96
101
|
}
|
|
97
102
|
/**
|
|
98
103
|
* Register the ZylemEditorElement as a custom element.
|
|
@@ -164,53 +169,11 @@ declare class EditorEventBusWrapper {
|
|
|
164
169
|
*/
|
|
165
170
|
declare const editorEvents: EditorEventBusWrapper;
|
|
166
171
|
|
|
167
|
-
/**
|
|
168
|
-
* Editor Events Module
|
|
169
|
-
*
|
|
170
|
-
* Bidirectional window CustomEvents for communication between @zylem/editor and consuming apps.
|
|
171
|
-
*
|
|
172
|
-
* EDITOR_STATE_DISPATCH: Editor sends state changes → external apps listen
|
|
173
|
-
* EDITOR_STATE_RECEIVE: External apps send updates → editor listens
|
|
174
|
-
*/
|
|
175
|
-
/**
|
|
176
|
-
* Payload structure for editor state events.
|
|
177
|
-
* Matches the nested state structure for both directions.
|
|
178
|
-
*/
|
|
179
|
-
interface EditorUpdatePayload {
|
|
180
|
-
gameState?: {
|
|
181
|
-
debugFlag?: boolean;
|
|
182
|
-
[key: string]: unknown;
|
|
183
|
-
};
|
|
184
|
-
toolbarState?: {
|
|
185
|
-
tool?: 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'none';
|
|
186
|
-
paused?: boolean;
|
|
187
|
-
};
|
|
188
|
-
[key: string]: unknown;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Event name constants
|
|
192
|
-
*/
|
|
193
|
-
declare const EDITOR_STATE_DISPATCH = "editor-state-dispatch";
|
|
194
|
-
declare const EDITOR_STATE_RECEIVE = "editor-state-receive";
|
|
195
|
-
declare const EDITOR_UPDATE_EVENT = "editor-state-dispatch";
|
|
196
|
-
/**
|
|
197
|
-
* Dispatch state changes from the editor to external consumers.
|
|
198
|
-
*
|
|
199
|
-
* @param payload - The state update payload
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* // From GameSection when debug checkbox changes
|
|
204
|
-
* dispatchEditorUpdate({ gameState: { debugFlag: true } });
|
|
205
|
-
* ```
|
|
206
|
-
*/
|
|
207
|
-
declare function dispatchEditorUpdate(payload: EditorUpdatePayload): void;
|
|
208
|
-
|
|
209
172
|
/**
|
|
210
173
|
* Entities state for the entities section.
|
|
211
174
|
* Manages debug state and entity selection/hover.
|
|
212
175
|
*/
|
|
213
|
-
type DebugTools = 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'none';
|
|
176
|
+
type DebugTools = 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'add' | 'none';
|
|
214
177
|
interface DebugState {
|
|
215
178
|
paused: boolean;
|
|
216
179
|
tool: DebugTools;
|
|
@@ -260,9 +223,11 @@ interface BaseEntityInterface {
|
|
|
260
223
|
position?: Vector3Like | undefined;
|
|
261
224
|
rotation?: Vector3Like | undefined;
|
|
262
225
|
scale?: Vector3Like | undefined;
|
|
263
|
-
/**
|
|
264
|
-
|
|
265
|
-
|
|
226
|
+
/**
|
|
227
|
+
* World-space AABB size for thumbnail rulers. Preview images themselves
|
|
228
|
+
* live in the thumbnail side-channel store, keyed by uuid, so entity state
|
|
229
|
+
* stays small enough to diff cheaply.
|
|
230
|
+
*/
|
|
266
231
|
bounds?: {
|
|
267
232
|
width: number;
|
|
268
233
|
height: number;
|
|
@@ -326,36 +291,93 @@ declare const debugStore: {
|
|
|
326
291
|
dropTargetIndex: number | null;
|
|
327
292
|
};
|
|
328
293
|
|
|
294
|
+
declare const channel: _zylem_bridge.BridgeChannel;
|
|
295
|
+
/**
|
|
296
|
+
* Subscribe the editor stores to game→editor bridge messages and hydrate
|
|
297
|
+
* from the channel's retained state.
|
|
298
|
+
*
|
|
299
|
+
* Reference-counted: the game gates expensive editor-only work (thumbnails,
|
|
300
|
+
* entity summaries) on these subscriptions existing, so the last editor to
|
|
301
|
+
* unmount must actually release them, while any editor still mounted must
|
|
302
|
+
* keep them alive.
|
|
303
|
+
*
|
|
304
|
+
* @returns A release function; safe to call more than once.
|
|
305
|
+
*/
|
|
306
|
+
declare function connectEditorBridge(): () => void;
|
|
307
|
+
/** Tear down all bridge subscriptions, ignoring the reference count. */
|
|
308
|
+
declare function disconnectEditorBridge(): void;
|
|
309
|
+
/** Toggle the game's debug mode. */
|
|
310
|
+
declare function sendDebugEnabled(enabled: boolean): void;
|
|
311
|
+
/** Switch the active editor tool in the game. */
|
|
312
|
+
declare function sendTool(tool: BridgeDebugTool): void;
|
|
313
|
+
/** Pause or resume the game loop. */
|
|
314
|
+
declare function sendPlayback(paused: boolean): void;
|
|
315
|
+
/** Select an entity in the game (null clears the selection). */
|
|
316
|
+
declare function sendEntitySelect(uuid: string | null): void;
|
|
317
|
+
/** Focus/frame the game debug camera on an entity. */
|
|
318
|
+
declare function sendEntityFocus(uuid: string): void;
|
|
319
|
+
/** Write a stage variable in the running game. */
|
|
320
|
+
declare function sendStageVariable(key: string, value: unknown): void;
|
|
321
|
+
|
|
329
322
|
/**
|
|
330
323
|
* Editor Host Helpers
|
|
331
324
|
*
|
|
332
325
|
* Reusable wiring for apps that embed the <zylem-editor> overlay next to a
|
|
333
|
-
* running Zylem game.
|
|
334
|
-
*
|
|
326
|
+
* running Zylem game. These helpers are thin wrappers over the shared
|
|
327
|
+
* `@zylem/bridge` channel: the game applies editor commands itself (via its
|
|
328
|
+
* bridge adapter), so hosts only need this module to mount the overlay,
|
|
329
|
+
* mirror editor commands into their own stores, or push state into the
|
|
330
|
+
* editor UI.
|
|
335
331
|
*/
|
|
336
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Nested state payload used by host-facing helpers.
|
|
335
|
+
* Mirrors the historical `editor-state-dispatch` window-event shape so
|
|
336
|
+
* existing hosts keep working; internally everything rides the bridge.
|
|
337
|
+
*/
|
|
338
|
+
interface EditorUpdatePayload {
|
|
339
|
+
gameState?: {
|
|
340
|
+
debugFlag?: boolean;
|
|
341
|
+
[key: string]: unknown;
|
|
342
|
+
};
|
|
343
|
+
toolbarState?: {
|
|
344
|
+
tool?: BridgeDebugTool;
|
|
345
|
+
paused?: boolean;
|
|
346
|
+
};
|
|
347
|
+
[key: string]: unknown;
|
|
348
|
+
}
|
|
337
349
|
interface EditorStateBridgeOptions {
|
|
338
350
|
/**
|
|
339
|
-
* Called after each editor
|
|
340
|
-
*
|
|
341
|
-
* stores (e.g. a SolidJS store).
|
|
351
|
+
* Called after each editor command has been sent to the game, so hosts
|
|
352
|
+
* can mirror the payload into their own stores (e.g. a SolidJS store).
|
|
342
353
|
*/
|
|
343
354
|
onStateDispatch?: (payload: EditorUpdatePayload) => void;
|
|
344
355
|
}
|
|
345
356
|
interface EditorStateBridge {
|
|
346
357
|
/** Push external app state back into the editor UI. */
|
|
347
358
|
dispatchToEditor(payload: EditorUpdatePayload): void;
|
|
348
|
-
/** Remove the
|
|
359
|
+
/** Remove the bridge subscriptions installed by this helper. */
|
|
349
360
|
dispose(): void;
|
|
350
361
|
}
|
|
351
362
|
/**
|
|
352
|
-
*
|
|
353
|
-
* Safe to call in non-browser environments (no-op).
|
|
363
|
+
* Push a state update payload into the editor UI (stores + game command).
|
|
364
|
+
* Safe to call in non-browser environments (no-op side effects only).
|
|
354
365
|
*/
|
|
355
366
|
declare function dispatchToEditor(payload: EditorUpdatePayload): void;
|
|
356
367
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
368
|
+
* Observe editor→game commands on the shared bridge.
|
|
369
|
+
*
|
|
370
|
+
* The game side applies commands itself; this helper exists so external
|
|
371
|
+
* hosts can mirror editor actions (debug toggle, tool, pause) into their own
|
|
372
|
+
* state via `onStateDispatch`.
|
|
373
|
+
*
|
|
374
|
+
* This deliberately does **not** open the editor's game→editor store
|
|
375
|
+
* subscriptions. Those are owned by `<zylem-editor>` for the duration it is
|
|
376
|
+
* mounted, and the game gates expensive work (thumbnail renders, entity
|
|
377
|
+
* summaries) on them being present. A long-lived host helper holding one open
|
|
378
|
+
* would keep that work running forever, even with no editor on screen. Hosts
|
|
379
|
+
* that render editor components without the custom element should call
|
|
380
|
+
* `connectEditorBridge()` directly and release it themselves.
|
|
359
381
|
*
|
|
360
382
|
* @example
|
|
361
383
|
* ```ts
|
|
@@ -365,6 +387,14 @@ declare function dispatchToEditor(payload: EditorUpdatePayload): void;
|
|
|
365
387
|
* ```
|
|
366
388
|
*/
|
|
367
389
|
declare function attachEditorStateBridge(options?: EditorStateBridgeOptions): EditorStateBridge;
|
|
390
|
+
/**
|
|
391
|
+
* Send an editor state payload as bridge commands to the running game.
|
|
392
|
+
*
|
|
393
|
+
* @deprecated Use the typed bridge commands (`sendDebugEnabled`, `sendTool`,
|
|
394
|
+
* `sendPlayback`) instead. Kept for hosts migrating off the old
|
|
395
|
+
* window-CustomEvent API.
|
|
396
|
+
*/
|
|
397
|
+
declare function dispatchEditorUpdate(payload: EditorUpdatePayload): void;
|
|
368
398
|
interface MountZylemEditorOptions extends EditorStateBridgeOptions {
|
|
369
399
|
/**
|
|
370
400
|
* Controls the editor's floating launcher button.
|
|
@@ -392,4 +422,4 @@ interface MountedZylemEditor extends EditorStateBridge {
|
|
|
392
422
|
*/
|
|
393
423
|
declare function mountZylemEditor(options?: MountZylemEditorOptions): MountedZylemEditor;
|
|
394
424
|
|
|
395
|
-
export {
|
|
425
|
+
export { type EditorEvent, type EditorEventType, type EditorStateBridge, type EditorStateBridgeOptions, type EditorUpdatePayload, Icon, type MountZylemEditorOptions, type MountedZylemEditor, type ZylemEditorConfig, ZylemEditorElement, attachEditorStateBridge, channel as bridgeChannel, connectEditorBridge, debugState, debugStore, disconnectEditorBridge, dispatchEditorUpdate, dispatchToEditor, editorEvents, gameState, mountZylemEditor, registerZylemEditor, sendDebugEnabled, sendEntityFocus, sendEntitySelect, sendPlayback, sendStageVariable, sendTool, stageState };
|