@mica-js/editor 0.13.0 → 0.15.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 +11 -3
- package/dist/fused-html.d.ts +10 -42
- package/dist/fused-html.js +1 -1
- package/dist/fused-runtime.d.ts +125 -3
- package/dist/fused-runtime.js +2 -2
- package/dist/fused.d.ts +92 -0
- package/dist/fused.js +265 -98
- package/dist/fused.js.map +1 -1
- package/dist/{html-HXwZq1my.js → html-B0pN-5Mx.js} +31 -71
- package/dist/html-B0pN-5Mx.js.map +1 -0
- package/dist/{runtime-hyeAcSP7.js → runtime-DuxZ_yVl.js} +699 -82
- package/dist/runtime-DuxZ_yVl.js.map +1 -0
- package/dist/style.css +54 -19
- package/dist/view-environment/environment-sw.js +78 -160
- package/dist/view-environment/environment.js +227 -130
- package/dist/{wire-BDHL5Aj9.js → wire-Di4FVpnu.js} +11 -4
- package/dist/wire-Di4FVpnu.js.map +1 -0
- package/dist/workers-BpHcfNEu.js +34 -0
- package/dist/{workers-Og_Z_xzw.js.map → workers-BpHcfNEu.js.map} +1 -1
- package/package.json +2 -2
- package/dist/html-HXwZq1my.js.map +0 -1
- package/dist/runtime-hyeAcSP7.js.map +0 -1
- package/dist/wire-BDHL5Aj9.js.map +0 -1
- package/dist/workers-Og_Z_xzw.js +0 -34
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
`@mica-js/editor/fused` 提供 React 19 工作台,直接编辑融合 `.sch` v2 文档。器件底图、逐引脚接线与动态覆盖共用实例坐标;主线程处理文档和交互,模型与 `view2d.js` 分别运行在现有 `SandboxWorker` 中。进入「运行」自动启动,切回「编辑」释放运行会话,下次运行从初态开始。暂停与继续只作为宿主 API 提供,工具条不显示相应控件:`workbench.executeCommand('simulation.pause')` 在仿真端确认后停止推进,保留模型、视图和订阅,实例音频随之暂停;`workbench.executeCommand('simulation.resume')` 在同一会话上继续。两个命令都串行于模式切换,编辑模式下拒绝,已处于目标状态时不重复操作。`getState().simulationStatus` 与 `onDidChangeState` 报告运行会话的实际状态,编辑模式下为 `undefined`。
|
|
8
8
|
|
|
9
|
+
仿真处于 `starting` 时,画布覆盖黑色半透明遮罩,背景模糊并提高饱和度,中央显示白色加载动画和「仿真启动中…」。启用减少动态效果时隐藏动画,保留遮罩和文字提示。
|
|
10
|
+
|
|
9
11
|
```typescript
|
|
10
12
|
import { createWorkbench } from '@mica-js/editor/fused';
|
|
11
13
|
import '@mica-js/editor/fused/style.css';
|
|
@@ -35,6 +37,10 @@ await workbench.dispose();
|
|
|
35
37
|
|
|
36
38
|
宿主直接传入 `FusedDocument`,自行维护项目身份和存储。`getDocument()` / `onDidChangeContent` 提供当前快照;可选的 `saveDocument(snapshot)` 完成后标记对应版本已保存,缺失时 `save()` 明确拒绝。器件 Provider 返回锁定发布版本的 `PackageFiles`,工作台校验文件清单和摘要。
|
|
37
39
|
|
|
40
|
+
「问题」面板显示诊断及其技术详情,宿主可用 `onDidReportDiagnostic` 收集诊断。工作台界面发起的操作失败时,`onDidFailOperation(({ operation, code, error }) => …)` 在操作结束后通知宿主,由宿主决定如何提示用户。工具条的「运行」「停止」「重启」分别使用 `simulation.start`、`simulation.stop`、`simulation.restart`,扩展工具条操作使用贡献项 ID。宿主直接调用 `setMode()`、`save()` 或 `executeCommand()` 时,通过返回的 Promise 处理失败。运行中进入 `faulted` 状态可通过 `onDidChangeState` 观察。
|
|
41
|
+
|
|
42
|
+
`deviceStateProvider` 可持久化指定器件的二进制运行状态。`bindings` 按器件 ID 和锁定版本选择启动属性、查询方法与变化事件。启动时优先装载 `read` 返回的映像,缺失时使用电路配置。宿主用文档作用域与状态槽键定位 `read` / `write`,写入确认后运行时才视为已保存。工作台在停止、重启和关闭时等待保存,失败后可重试。预热不访问此存储。
|
|
43
|
+
|
|
38
44
|
`assetProvider.select({ kind, formats, signal })` 打开宿主资产库 UI,返回 `{ id, name }` 或以 `undefined` 取消;`name` 包含文件扩展名。`read(id, signal)` 返回二进制,编辑器不枚举资产。普通资源仅支持 `asset` / `package`;`program` 另支持 `project`,使用 `programs.projects.select({ ...target, templateIds }, signal)` 选择项目、`resolve(id, target, signal?)` 取得程序产物。项目选择能力可省略,已有引用仍可解析;程序文件集资产使用 ZIP,校验解包后交给模型只读访问。
|
|
39
45
|
|
|
40
46
|
属性字段以单行显示来源图标、引用名称和默认标记,通过同行图标打开来源菜单或内存装载设置浮层;新内容读取校验成功后才提交,取消和失败保留原值。项目选择的请求包含 `templateIds`,按属性的 `templates` 顺序传递,未声明时为空数组;宿主负责模板展示与项目创建,编辑器只保存返回的项目引用。内置资源从当前器件包选择,项目可独立打开。宿主接口合同见 [RFC 0028](../../docs/rfc/0028-workbench-host-resources.md)。
|
|
@@ -43,9 +49,11 @@ await workbench.dispose();
|
|
|
43
49
|
|
|
44
50
|
`accessProvider.evaluateDocument` 分别决定编辑和运行权限,`canAddDevice` 决定能否新增指定发布版本。新增、属性修改、通用事务、粘贴、撤销重做与保存均经过文档会话授权。宿主可将包含付费器件的文档整体设为只读,并通过 `onDidChange` 通知授权变化;持久化服务仍应验证最终写入。只读文档中的面板位置调整仅保留在当前工作台会话。
|
|
45
51
|
|
|
46
|
-
器件声明的 HTML Views 在 Run 中开放。侧栏属性固定在顶部,HTML Views 支持折叠、排序、调整高度与浮动;浮动面板可拖动四条边与四个角调整尺寸,最小 180×100,键盘方向键每次调整 10px、按住 Shift 调整 40px
|
|
52
|
+
器件声明的 HTML Views 在 Run 中开放。侧栏属性固定在顶部,HTML Views 支持折叠、排序、调整高度与浮动;浮动面板可拖动四条边与四个角调整尺寸,最小 180×100,键盘方向键每次调整 10px、按住 Shift 调整 40px。浮动面板的标题栏提供停靠按钮,将视图放回所属实例的侧栏。停靠切换保留同一 iframe 与同一套订阅;折叠只隐藏页面,不卸载。运行结束释放这些环境。
|
|
53
|
+
|
|
54
|
+
每个视图环境由同源的 `index.html`(可信外层页)和 `content.html`(内层沙箱)组成,与工作台跨源隔离。编辑器通过控制端口向外层提供主题、生命周期和经过验证的包资源读取,内层通过专用端口直连编辑器的器件 API。内层 bootstrap 安装 `acquireDeviceViewApi`、监听器和包资源授权后,外层写入作者文档,两层页面身份保持稳定。作者侧通过一次性的 `acquireDeviceViewApi` 使用器件 API。
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
包资源 Worker 每次读取时连接当前外层页,外层只为经过登记的页面客户端读取锁定包中声明的文件。视图持有资源授权,Worker 退出后可在下一次读取时重新启动。视图释放时撤销授权和模型订阅。作者文档的跳转或重新加载会报告 `view/execution-failed`。
|
|
49
57
|
|
|
50
58
|
工作台主题以计算后的颜色转发给每个环境:`--mica-*` 变量与 `color-scheme` 在任意作者脚本执行前注入内层文档根,之后主题或系统明暗变化就地更新同一文档根,不重载 frame,也不丢失作者输入、模型会话或文档历史。加载期的底色也不会白闪:加载中的视图由容器槽位绘制当前视图背景(`panel.background`,即 `--mica-panel`,同时保留既有加载提示),owner 在加载期间保持透明,frame 在作者文档写入并应用主题前保持隐藏(`visibility`,不卸载、不重建,脚本照常运行),因此浏览器为未着色子文档绘制的白色画布不会被看到;环境报告就绪后 owner 取得当前主题底色并显示 frame。这条链路由 `setTheme` / 主题中继实时重绘,所以外层模块或内层 bootstrap 被延迟时切换主题,显示的始终是最新颜色而不是首次快照。没有转发主题的独立宿主使用完整暗色默认值,示例监视器的 `body` 也使用同一 `--mica-panel`,作者样式加载前后底色一致。
|
|
51
59
|
|
|
@@ -53,7 +61,7 @@ await workbench.dispose();
|
|
|
53
61
|
|
|
54
62
|
### 主题与颜色 Token
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
信息容器固定在活动栏首位。当前模式只有属性视图时,容器头部合并为“属性”及其操作,内容始终展开,保留收起整个侧栏的操作;包含器件视图时,头部显示“信息”,各视图保留自己的标题并支持折叠。最后一个展开的视图填满剩余高度,其后的折叠标题随之推到底部,保持视图顺序;空间不足时在容器内滚动。归属浮动且未打开的视图在头部显示入口。折叠、停靠和浮动均不改变可用视图的计数;属性视图固定在首位。
|
|
57
65
|
|
|
58
66
|
电源、接地端子和网络标签的符号、文字与默认偏移使用场景单位,已放置内容与幽灵预览均随画布缩放。导线预览、提交和器件移动使用共用的正交路由;端子、网标与器件放置一次后返回选择工具,Esc 取消放置且不写入文档。新建电源符号默认使用 `VCC` 网名与 `3.3 V` 电压,幽灵预览显示同一默认值;接地符号固定 `0 V` 且不保存网名。点击端子符号或网名只选择对象,点击其接线锚点才进入画线状态。拖动独立网标时连接端与名称一起移动,附着导线的折点随节点重排;命名引脚或共享节点的网标只移动名称,连接端留在原处。属性面板对选中的电压参考显示类型与连接端,并可直接修改角度、电压与网名,接地符号固定 `0 V` 且不提供电压和网名编辑;普通网标可直接修改网名;导线与连接节点显示只读身份。
|
|
59
67
|
|
package/dist/fused-html.d.ts
CHANGED
|
@@ -105,13 +105,10 @@ declare type FusedViewInputType = 'pointerdown' | 'pointerup' | 'pointermove';
|
|
|
105
105
|
/** Acknowledgement the environment posts back once it owns the transferred port. */
|
|
106
106
|
export declare const HTML_VIEW_ACK = "mica:view:ack";
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
export declare const
|
|
108
|
+
/** The asset worker requests a port for one package fetch. */
|
|
109
|
+
export declare const HTML_VIEW_ASSET_READ = "mica:view:asset-read";
|
|
110
110
|
|
|
111
|
-
/**
|
|
112
|
-
export declare const HTML_VIEW_ASSETS_ACK = "mica:view:assets-ack";
|
|
113
|
-
|
|
114
|
-
/** Control message the inner frame posts into the asset worker to authorize its own requests. */
|
|
111
|
+
/** Control message the inner frame sends through the asset worker to authorize its requests. */
|
|
115
112
|
export declare const HTML_VIEW_ATTACH = "mica:view:attach";
|
|
116
113
|
|
|
117
114
|
/** Acknowledgement of {@link HTML_VIEW_ATTACH}; only then may the author document load. */
|
|
@@ -269,6 +266,8 @@ declare interface IFusedDisplayLayout {
|
|
|
269
266
|
|
|
270
267
|
/** Request that mounts presentation for one mode. */
|
|
271
268
|
declare interface IFusedDisplayPrepareInput {
|
|
269
|
+
/** Optional request time in the host's Performance timeline. */
|
|
270
|
+
readonly requestedAt?: number;
|
|
272
271
|
/**
|
|
273
272
|
* `run` mounts models first and hands every presentation its model client; `edit` releases the
|
|
274
273
|
* models and prepares the same instances without a model.
|
|
@@ -290,10 +289,10 @@ declare interface IFusedFirmwareSnapshot {
|
|
|
290
289
|
readonly segments: readonly IFusedFirmwareSegment[];
|
|
291
290
|
}
|
|
292
291
|
|
|
293
|
-
/** Package bytes the
|
|
292
|
+
/** Package bytes the trusted outer frame answers one asset request with. */
|
|
294
293
|
export declare interface IFusedHtmlAssetService {
|
|
295
|
-
/** Reads
|
|
296
|
-
read(path: string): Promise<Uint8Array>;
|
|
294
|
+
/** Reads a verified package file for this fetch, or returns undefined for an unauthorized client. */
|
|
295
|
+
read(path: string): Promise<Uint8Array | undefined>;
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
/**
|
|
@@ -307,14 +306,9 @@ export declare interface IFusedHtmlContentViewService {
|
|
|
307
306
|
view(): Promise<IHtmlViewContent>;
|
|
308
307
|
}
|
|
309
308
|
|
|
310
|
-
/**
|
|
311
|
-
* Lifecycle capabilities of the trusted outer frame, served directly by the editor.
|
|
312
|
-
*
|
|
313
|
-
* This lane carries no model call and no author resource read: the outer loads the view, relays the
|
|
314
|
-
* theme, reports failures and hands the two dedicated ports on.
|
|
315
|
-
*/
|
|
309
|
+
/** Lifecycle and verified package reads of the trusted outer frame. */
|
|
316
310
|
export declare interface IFusedHtmlHostControlService {
|
|
317
|
-
/** Reads one declared package file of this view
|
|
311
|
+
/** Reads one declared package file of this view, including the entry document. */
|
|
318
312
|
readAsset(path: string): Promise<Uint8Array>;
|
|
319
313
|
/** Computed theme of the workbench at this moment. */
|
|
320
314
|
getTheme(): Promise<IHtmlViewTheme>;
|
|
@@ -326,13 +320,6 @@ export declare interface IFusedHtmlHostControlService {
|
|
|
326
320
|
reportFailure(code: string, message: string): Promise<void>;
|
|
327
321
|
/** Announces that the environment goes away without an editor request. */
|
|
328
322
|
closed(): void;
|
|
329
|
-
/**
|
|
330
|
-
* Grants the dedicated package lane of this view's asset worker, once.
|
|
331
|
-
*
|
|
332
|
-
* The port is transferred into the worker straight from the outer frame, so no author document
|
|
333
|
-
* and no editor page ever holds it; the grant token decides which clients it serves.
|
|
334
|
-
*/
|
|
335
|
-
assetPort(): Promise<MessagePort>;
|
|
336
323
|
/**
|
|
337
324
|
* Grants the dedicated author lane of this view's inner frame, once.
|
|
338
325
|
*
|
|
@@ -503,25 +490,6 @@ export declare interface IHtmlViewAckMessage {
|
|
|
503
490
|
readonly token: string;
|
|
504
491
|
}
|
|
505
492
|
|
|
506
|
-
export declare interface IHtmlViewAssetAckMessage {
|
|
507
|
-
readonly type: typeof HTML_VIEW_ASSETS_ACK;
|
|
508
|
-
readonly token: string;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Grant of the package asset worker: the prefix it serves plus two ports.
|
|
513
|
-
*
|
|
514
|
-
* The first port is the dedicated package lane of the editor, the second one is where the worker
|
|
515
|
-
* acknowledges the grant. The environment page that installs the grant is the only client the
|
|
516
|
-
* registry admits, and it never answers a package read itself.
|
|
517
|
-
*/
|
|
518
|
-
export declare interface IHtmlViewAssetGrantMessage {
|
|
519
|
-
readonly type: typeof HTML_VIEW_ASSETS;
|
|
520
|
-
readonly token: string;
|
|
521
|
-
/** URL pathname of the package asset root this worker serves. */
|
|
522
|
-
readonly root: string;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
493
|
export declare interface IHtmlViewAttachAckMessage {
|
|
526
494
|
readonly type: typeof HTML_VIEW_ATTACH_ACK;
|
|
527
495
|
readonly token: string;
|
package/dist/fused-html.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { y as ASSET_ROOT_DIRECTORY, s as DEFAULT_HTML_VIEW_THEME, b as ENVIRONMENT_BOOTSTRAP_FILE, x as ENVIRONMENT_CONTENT_DOCUMENT_FILE, S as ENVIRONMENT_CONTENT_FILE, C as ENVIRONMENT_DOCUMENT_FILE, w as ENVIRONMENT_WORKER_FILE, L as HTML_VIEW_ACK, R as
|
|
1
|
+
export { y as ASSET_ROOT_DIRECTORY, s as DEFAULT_HTML_VIEW_THEME, b as ENVIRONMENT_BOOTSTRAP_FILE, x as ENVIRONMENT_CONTENT_DOCUMENT_FILE, S as ENVIRONMENT_CONTENT_FILE, C as ENVIRONMENT_DOCUMENT_FILE, w as ENVIRONMENT_WORKER_FILE, L as HTML_VIEW_ACK, R as HTML_VIEW_ASSET_READ, z as HTML_VIEW_ATTACH, B as HTML_VIEW_ATTACH_ACK, V as HTML_VIEW_CHILD_CONNECT, H as HTML_VIEW_CHILD_HELLO, U as HTML_VIEW_CHILD_PREPARED, W as HTML_VIEW_CONNECT, T as HTML_VIEW_CONTENT_POLICY, E as HTML_VIEW_ENVIRONMENT_POLICY, G as HTML_VIEW_FRAME_PARAM, K as HtmlViewError, N as VIEW_ENV_LABEL, c as applyHtmlViewTheme, t as assertAssetPath, D as assetRootUrl, O as authorBaseUrl, n as createDeviceViewSession, a as createHtmlViewHost, r as createHtmlViewRuntimeSource, k as decodeDocument, q as fusedHtmlAssetService, J as fusedHtmlContentViewService, Y as fusedHtmlHostControlService, X as fusedHtmlHostService, P as htmlEnvironmentUrl, i as htmlViewDeviceDeclaration, o as htmlViewKey, l as htmlViewThemeCss, u as htmlViewThemeEquals, Z as isHtmlViewError, A as mimeTypeOf, F as newHtmlEnvironmentId, d as normalizeHtmlViewTheme, I as parseHtmlViewBase, j as resolveAssetRequest, M as withHtmlDocumentPreamble } from "./html-B0pN-5Mx.js";
|
package/dist/fused-runtime.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { WidgetAudioOptions as IFusedAudioOptions } from '@mica-js/widget/audio-
|
|
|
9
9
|
import { WidgetAudioStreamOptions as IFusedAudioStreamOptions } from '@mica-js/widget/audio-guest';
|
|
10
10
|
import { WidgetAudioTone as IFusedAudioTone } from '@mica-js/widget/audio-guest';
|
|
11
11
|
import { WidgetAudioToneOptions as IFusedAudioToneOptions } from '@mica-js/widget/audio-guest';
|
|
12
|
+
import { LogLevel } from '@mica-js/core/logging';
|
|
13
|
+
import { LogRecord } from '@mica-js/core/logging';
|
|
12
14
|
import { MemoryProgram } from '@mica-js/sdk/fused';
|
|
13
15
|
import { ModelEvent } from '@mica-js/sdk/fused';
|
|
14
16
|
import { PackageFile } from '@mica-js/document/fused';
|
|
@@ -24,6 +26,7 @@ import { RpcEndpoint } from '@mica-js/core/rpc';
|
|
|
24
26
|
import { RpcProxy } from '@mica-js/core/rpc';
|
|
25
27
|
import { RpcServiceId } from '@mica-js/core/rpc';
|
|
26
28
|
import { RuntimeDiagnostic } from '@mica-js/sdk/fused';
|
|
29
|
+
import { SandboxWorkerError } from '@mica-js/sandbox';
|
|
27
30
|
import { TimePs } from '@mica-js/core';
|
|
28
31
|
import { Value } from '@mica-js/document/fused';
|
|
29
32
|
import { WidgetAudioApi } from '@mica-js/widget/audio-guest';
|
|
@@ -96,6 +99,8 @@ export declare const fusedHostPackageService: RpcServiceId<IFusedHostPackageServ
|
|
|
96
99
|
/** Wire name of the host resource access of the simulation guest. */
|
|
97
100
|
export declare const fusedHostResourceService: RpcServiceId<IFusedHostResourceService>;
|
|
98
101
|
|
|
102
|
+
export declare type FusedLogSource = 'workbench' | 'simulation' | 'display' | 'widget' | 'audio';
|
|
103
|
+
|
|
99
104
|
/** Wire name of the model lane the simulation guest serves. */
|
|
100
105
|
export declare const fusedModelChannelService: RpcServiceId<IFusedModelChannelService>;
|
|
101
106
|
|
|
@@ -131,6 +136,10 @@ export declare type FusedSimulationPacing = 'realtime' | 'unlimited';
|
|
|
131
136
|
/** Wire name of the simulation guest. */
|
|
132
137
|
export declare const fusedSimulationService: RpcServiceId<IFusedSimulationService>;
|
|
133
138
|
|
|
139
|
+
export declare type FusedStartupKind = 'start' | 'resume' | 'restart';
|
|
140
|
+
|
|
141
|
+
export declare type FusedStartupOutcome = 'success' | 'failure' | 'cancelled';
|
|
142
|
+
|
|
134
143
|
export declare type FusedSurfaceFactory = (width: number, height: number) => IFusedOverlaySurface;
|
|
135
144
|
|
|
136
145
|
/** Default export of a `view2d.entry` module. */
|
|
@@ -138,6 +147,34 @@ export declare type FusedView2DFactory = (context: IFusedView2DContext) => IFuse
|
|
|
138
147
|
|
|
139
148
|
export declare type FusedViewInputType = 'pointerdown' | 'pointerup' | 'pointermove';
|
|
140
149
|
|
|
150
|
+
export declare type FusedWarmupProgress = 'not-started' | 'partial' | 'completed';
|
|
151
|
+
|
|
152
|
+
declare interface IDeviceStateBinding {
|
|
153
|
+
readonly device: string;
|
|
154
|
+
readonly version: string;
|
|
155
|
+
readonly slot: string;
|
|
156
|
+
readonly formatVersion: number;
|
|
157
|
+
readonly byteLength: number;
|
|
158
|
+
readonly property: string;
|
|
159
|
+
readonly method: string;
|
|
160
|
+
readonly event: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The caller scopes these keys to its account/workspace and stable document ID. */
|
|
164
|
+
declare interface IDeviceStateKey {
|
|
165
|
+
readonly instanceId: string;
|
|
166
|
+
readonly device: string;
|
|
167
|
+
readonly slot: string;
|
|
168
|
+
readonly formatVersion: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare interface IDeviceStateProvider {
|
|
172
|
+
readonly bindings: readonly IDeviceStateBinding[];
|
|
173
|
+
read(key: IDeviceStateKey, signal: AbortSignal): Promise<Uint8Array | undefined>;
|
|
174
|
+
/** Atomically replace the slot. Resolve only after the write has committed. */
|
|
175
|
+
write(key: IDeviceStateKey, image: Uint8Array, signal: AbortSignal): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
|
|
141
178
|
/** Audio handles belong to one instance generation, including while its body is hidden. */
|
|
142
179
|
export declare interface IFusedAudio extends Omit<WidgetAudioApi, 'onStateChange' | 'createStream'> {
|
|
143
180
|
readonly onDidChangeState: Event_2<FusedAudioState>;
|
|
@@ -159,6 +196,12 @@ export { IFusedAudioTone }
|
|
|
159
196
|
|
|
160
197
|
export { IFusedAudioToneOptions }
|
|
161
198
|
|
|
199
|
+
declare interface IFusedBootCompletion {
|
|
200
|
+
readonly runId: string;
|
|
201
|
+
readonly outcome: FusedStartupOutcome;
|
|
202
|
+
readonly warmup?: FusedWarmupProgress;
|
|
203
|
+
}
|
|
204
|
+
|
|
162
205
|
export declare interface IFusedBridgeErrorOptions {
|
|
163
206
|
readonly instanceId?: string;
|
|
164
207
|
readonly details?: Value;
|
|
@@ -186,7 +229,19 @@ export declare interface IFusedConnectionOptions {
|
|
|
186
229
|
readonly container?: HTMLElement;
|
|
187
230
|
readonly resolveResource?: ResourceResolver;
|
|
188
231
|
readonly programs?: ProgramSources;
|
|
189
|
-
readonly onDiagnostic?: (diagnostic: RuntimeDiagnostic) => void;
|
|
232
|
+
readonly onDiagnostic?: (diagnostic: RuntimeDiagnostic, source: FusedLogSource) => void;
|
|
233
|
+
readonly observability?: IFusedObservabilityOptions;
|
|
234
|
+
readonly onDisconnect?: (source: 'simulation' | 'display') => void;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** A configured slot and, if available, its persisted startup bytes. */
|
|
238
|
+
declare interface IFusedDeviceStateImage {
|
|
239
|
+
readonly instanceId: string;
|
|
240
|
+
readonly property: string;
|
|
241
|
+
readonly method: string;
|
|
242
|
+
readonly event: string;
|
|
243
|
+
readonly byteLength: number;
|
|
244
|
+
readonly image?: Uint8Array;
|
|
190
245
|
}
|
|
191
246
|
|
|
192
247
|
/** 2D presentation surface the editor drives (RFC 0022). */
|
|
@@ -258,6 +313,8 @@ export declare interface IFusedDisplayLayout {
|
|
|
258
313
|
|
|
259
314
|
/** Request that mounts presentation for one mode. */
|
|
260
315
|
export declare interface IFusedDisplayPrepareInput {
|
|
316
|
+
/** Optional request time in the host's Performance timeline. */
|
|
317
|
+
readonly requestedAt?: number;
|
|
261
318
|
/**
|
|
262
319
|
* `run` mounts models first and hands every presentation its model client; `edit` releases the
|
|
263
320
|
* models and prepares the same instances without a model.
|
|
@@ -376,12 +433,21 @@ export declare interface IFusedInvalidateEvent {
|
|
|
376
433
|
|
|
377
434
|
/** Request that creates the models of one run session. */
|
|
378
435
|
export declare interface IFusedLoadRequest {
|
|
436
|
+
readonly observation?: IFusedObservation;
|
|
379
437
|
readonly document: FusedDocument;
|
|
380
438
|
/** Fixed positive step of every advance, in picoseconds. */
|
|
381
439
|
readonly step: TimePs;
|
|
382
440
|
readonly simulationPacing?: FusedSimulationPacing;
|
|
383
441
|
/** Explicit simulator batch-execution switch; omitted uses the board default. */
|
|
384
442
|
readonly batchExecution?: boolean;
|
|
443
|
+
readonly deviceState?: readonly IFusedDeviceStateImage[];
|
|
444
|
+
readonly stateGeneration?: number;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export declare interface IFusedLogRecord extends LogRecord {
|
|
448
|
+
readonly source: FusedLogSource;
|
|
449
|
+
/** Workbench receive time, in Unix epoch milliseconds. */
|
|
450
|
+
readonly receivedAt: number;
|
|
385
451
|
}
|
|
386
452
|
|
|
387
453
|
/** Model lane served by the simulation guest to the display guest over the direct port. */
|
|
@@ -427,6 +493,7 @@ export declare interface IFusedModelEventWire {
|
|
|
427
493
|
readonly instanceId: string;
|
|
428
494
|
readonly event: string;
|
|
429
495
|
readonly payload: ModelEvent<Value>;
|
|
496
|
+
readonly stateGeneration?: number;
|
|
430
497
|
}
|
|
431
498
|
|
|
432
499
|
/** Model event lane served by the display guest to the simulation guest. */
|
|
@@ -434,6 +501,23 @@ export declare interface IFusedModelSinkService {
|
|
|
434
501
|
deliver(event: IFusedModelEventWire): void;
|
|
435
502
|
}
|
|
436
503
|
|
|
504
|
+
export declare interface IFusedObservabilityOptions {
|
|
505
|
+
/** Defaults to info. A workbench writes to its Console when no sink is supplied. */
|
|
506
|
+
readonly logLevel?: LogLevel;
|
|
507
|
+
readonly onLog?: (record: IFusedLogRecord) => void;
|
|
508
|
+
/** Enables User Timing and startup sampling. Defaults to false. */
|
|
509
|
+
readonly performance?: boolean;
|
|
510
|
+
readonly onSample?: (sample: IFusedStartupSample) => void;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
declare interface IFusedObservation {
|
|
514
|
+
readonly debug: boolean;
|
|
515
|
+
readonly performance: boolean;
|
|
516
|
+
readonly runId?: string;
|
|
517
|
+
readonly sessionId?: string;
|
|
518
|
+
readonly kind?: FusedStartupKind;
|
|
519
|
+
}
|
|
520
|
+
|
|
437
521
|
/** Rendered overlay of one instance; the bitmap lives in the host after the transfer. */
|
|
438
522
|
export declare interface IFusedOverlayFrame extends IFusedDisplayLayout {
|
|
439
523
|
readonly instanceId: string;
|
|
@@ -457,12 +541,18 @@ export declare interface IFusedPackageFilesWire {
|
|
|
457
541
|
|
|
458
542
|
/** Preparation request of the simulation guest: verify packages and describe the scene. */
|
|
459
543
|
export declare interface IFusedPrepareRequest {
|
|
544
|
+
readonly observation?: IFusedObservation;
|
|
460
545
|
readonly document: FusedDocument;
|
|
461
546
|
readonly mode: FusedDisplayMode;
|
|
547
|
+
readonly deviceState?: readonly IFusedDeviceStateImage[];
|
|
462
548
|
}
|
|
463
549
|
|
|
464
550
|
export declare interface IFusedPrepareResult {
|
|
465
551
|
readonly instances: readonly IFusedInstancePresentation[];
|
|
552
|
+
readonly deviceState?: readonly {
|
|
553
|
+
readonly instanceId: string;
|
|
554
|
+
readonly image: Uint8Array;
|
|
555
|
+
}[];
|
|
466
556
|
}
|
|
467
557
|
|
|
468
558
|
declare interface IFusedProgramFilesSnapshot {
|
|
@@ -516,6 +606,10 @@ export declare interface IFusedRuntime {
|
|
|
516
606
|
}
|
|
517
607
|
|
|
518
608
|
export declare interface IFusedRuntimeOptions {
|
|
609
|
+
readonly observability?: IFusedObservabilityOptions;
|
|
610
|
+
/** Optional request time for an initial run, in the host's Performance timeline. */
|
|
611
|
+
readonly requestedAt?: number;
|
|
612
|
+
readonly deviceStateProvider?: IDeviceStateProvider;
|
|
519
613
|
/** Caller-owned browser context; resume it directly within a user gesture for autoplay. */
|
|
520
614
|
readonly audio?: IFusedAudioOptions;
|
|
521
615
|
/** Fused `.sch` version 2 document; the simulation guest snapshots it. */
|
|
@@ -582,7 +676,7 @@ export declare interface IFusedSimulationService {
|
|
|
582
676
|
*/
|
|
583
677
|
warmup(request: IFusedWarmupRequest): Promise<void>;
|
|
584
678
|
step(): Promise<IFusedSessionState>;
|
|
585
|
-
resume(): Promise<void>;
|
|
679
|
+
resume(observation?: IFusedObservation): Promise<void>;
|
|
586
680
|
/** Stops advancement synchronously; the RPC result acknowledges the paused state. */
|
|
587
681
|
pause(): void;
|
|
588
682
|
reset(): Promise<void>;
|
|
@@ -597,12 +691,38 @@ export declare interface IFusedSimulationService {
|
|
|
597
691
|
invalidatePrograms(projectId?: string, fingerprint?: string): Promise<void>;
|
|
598
692
|
call(instanceId: string, method: string, params: Value): Promise<Value>;
|
|
599
693
|
getState(): IFusedSessionState;
|
|
600
|
-
onDidChangeState(listener: (state: IFusedSessionState) => void): () => void;
|
|
694
|
+
onDidChangeState(listener: (state: IFusedSessionState, boot?: IFusedBootCompletion) => void): () => void;
|
|
601
695
|
onDidReportDiagnostic(listener: (diagnostic: RuntimeDiagnostic) => void): () => void;
|
|
602
696
|
/** Every model event of the session, in production order. */
|
|
603
697
|
onDidModelEvent(listener: (event: IFusedModelEventWire) => void): () => void;
|
|
604
698
|
}
|
|
605
699
|
|
|
700
|
+
export declare interface IFusedStartupSample {
|
|
701
|
+
readonly phase: 'device-package' | 'simulation-load' | 'first-step' | 'workbench-startup';
|
|
702
|
+
readonly outcome: FusedStartupOutcome;
|
|
703
|
+
readonly durationMs: number;
|
|
704
|
+
readonly runId?: string;
|
|
705
|
+
readonly sessionId?: string;
|
|
706
|
+
readonly kind?: FusedStartupKind;
|
|
707
|
+
readonly warmup?: FusedWarmupProgress;
|
|
708
|
+
readonly packageId?: string;
|
|
709
|
+
readonly version?: string;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export declare interface IFusedStartupSummary {
|
|
713
|
+
readonly phase: IFusedStartupSample['phase'];
|
|
714
|
+
readonly kind?: FusedStartupKind;
|
|
715
|
+
readonly warmup?: FusedWarmupProgress;
|
|
716
|
+
readonly packageId?: string;
|
|
717
|
+
readonly version?: string;
|
|
718
|
+
readonly count: number;
|
|
719
|
+
readonly failed: number;
|
|
720
|
+
readonly cancelled: number;
|
|
721
|
+
readonly p50Ms: number | null;
|
|
722
|
+
readonly p95Ms: number | null;
|
|
723
|
+
readonly maxMs: number | null;
|
|
724
|
+
}
|
|
725
|
+
|
|
606
726
|
/** Object a `view2d.entry` default factory returns (RFC 0022). */
|
|
607
727
|
export declare interface IFusedView2D {
|
|
608
728
|
initialize?(): void | Promise<void>;
|
|
@@ -670,6 +790,7 @@ export declare interface IFusedViewSessionOptions {
|
|
|
670
790
|
|
|
671
791
|
/** Request that prepares the boot path ahead of a run session. */
|
|
672
792
|
declare interface IFusedWarmupRequest {
|
|
793
|
+
readonly observation?: IFusedObservation;
|
|
673
794
|
readonly document: FusedDocument;
|
|
674
795
|
/** Fixed positive step of every advance, in picoseconds. */
|
|
675
796
|
readonly step: TimePs;
|
|
@@ -681,6 +802,7 @@ declare interface IFusedWarmupRequest {
|
|
|
681
802
|
export declare interface IFusedWorker {
|
|
682
803
|
readonly state: 'ready' | 'terminated';
|
|
683
804
|
readonly ready: Promise<void>;
|
|
805
|
+
onError?(listener: (error: SandboxWorkerError) => void): () => void;
|
|
684
806
|
postMessage(message: unknown, options?: readonly Transferable[]): void;
|
|
685
807
|
terminate(reason?: string): Promise<void>;
|
|
686
808
|
}
|
package/dist/fused-runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as toWireFailure, i as isFusedBridgeError, n as FusedBridgeError, o as mapWireFailure, r as fromWireFailure, t as FUSED_WIRE_FAILURE } from "./wire-
|
|
2
|
-
import {
|
|
1
|
+
import { c as toWireFailure, i as isFusedBridgeError, n as FusedBridgeError, o as mapWireFailure, r as fromWireFailure, t as FUSED_WIRE_FAILURE } from "./wire-Di4FVpnu.js";
|
|
2
|
+
import { S as fusedSimulationService, _ as fusedDisplayService, a as createFusedRuntime, b as fusedModelChannelService, c as createModelEventRouter, g as packageLockKey, h as createHostPackageGateway, i as startFusedSimulationGuest, l as createFusedDisplay, n as startFusedDisplayGuest, o as createHostModelRouter, r as createViewSession, s as channelKey, t as loadFusedWorkerFactories, u as connectFusedWorkbench, v as fusedHostPackageService, x as fusedModelSinkService, y as fusedHostResourceService } from "./runtime-DuxZ_yVl.js";
|
|
3
3
|
export { FUSED_WIRE_FAILURE, FusedBridgeError, channelKey, connectFusedWorkbench, createFusedDisplay, createFusedRuntime, createHostModelRouter, createHostPackageGateway, createModelEventRouter, createViewSession, fromWireFailure, fusedDisplayService, fusedHostPackageService, fusedHostResourceService, fusedModelChannelService, fusedModelSinkService, fusedSimulationService, isFusedBridgeError, loadFusedWorkerFactories, mapWireFailure, packageLockKey, startFusedDisplayGuest, startFusedSimulationGuest, toWireFailure };
|
package/dist/fused.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { WidgetAudioStreamOptions as IFusedAudioStreamOptions } from '@mica-js/w
|
|
|
13
13
|
import { WidgetAudioTone as IFusedAudioTone } from '@mica-js/widget/audio-guest';
|
|
14
14
|
import { WidgetAudioToneOptions as IFusedAudioToneOptions } from '@mica-js/widget/audio-guest';
|
|
15
15
|
import { InstanceViewLayout } from '@mica-js/document/fused';
|
|
16
|
+
import { LogLevel } from '@mica-js/core/logging';
|
|
17
|
+
import { LogRecord } from '@mica-js/core/logging';
|
|
16
18
|
import { Placement2D } from '@mica-js/document/fused';
|
|
17
19
|
import { Point2D } from '@mica-js/document/fused';
|
|
18
20
|
import { ProgramFile } from '@mica-js/sdk/fused';
|
|
@@ -94,6 +96,8 @@ export { FusedAudioState }
|
|
|
94
96
|
|
|
95
97
|
export { FusedDocument }
|
|
96
98
|
|
|
99
|
+
export declare type FusedLogSource = 'workbench' | 'simulation' | 'display' | 'widget' | 'audio';
|
|
100
|
+
|
|
97
101
|
/** Read-only plain property snapshot handed to a 2D presentation. */
|
|
98
102
|
declare type FusedPresentationProps = Readonly<Record<string, FusedPresentationValue>>;
|
|
99
103
|
|
|
@@ -112,6 +116,12 @@ declare type FusedSessionStatus = 'idle' | 'starting' | 'paused' | 'running' | '
|
|
|
112
116
|
/** Wall-clock pacing of continuous simulation in the editor worker. */
|
|
113
117
|
export declare type FusedSimulationPacing = 'realtime' | 'unlimited';
|
|
114
118
|
|
|
119
|
+
export declare type FusedStartupKind = 'start' | 'resume' | 'restart';
|
|
120
|
+
|
|
121
|
+
export declare type FusedStartupOutcome = 'success' | 'failure' | 'cancelled';
|
|
122
|
+
|
|
123
|
+
export declare type FusedWarmupProgress = 'not-started' | 'partial' | 'completed';
|
|
124
|
+
|
|
115
125
|
export declare interface IAssetInfo {
|
|
116
126
|
readonly id: string;
|
|
117
127
|
/** File name including its extension; used to identify program formats. */
|
|
@@ -261,6 +271,32 @@ export declare interface IDeviceAdditionContext extends IDocumentAccessContext {
|
|
|
261
271
|
|
|
262
272
|
export { IDeviceProvider }
|
|
263
273
|
|
|
274
|
+
export declare interface IDeviceStateBinding {
|
|
275
|
+
readonly device: string;
|
|
276
|
+
readonly version: string;
|
|
277
|
+
readonly slot: string;
|
|
278
|
+
readonly formatVersion: number;
|
|
279
|
+
readonly byteLength: number;
|
|
280
|
+
readonly property: string;
|
|
281
|
+
readonly method: string;
|
|
282
|
+
readonly event: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** The caller scopes these keys to its account/workspace and stable document ID. */
|
|
286
|
+
export declare interface IDeviceStateKey {
|
|
287
|
+
readonly instanceId: string;
|
|
288
|
+
readonly device: string;
|
|
289
|
+
readonly slot: string;
|
|
290
|
+
readonly formatVersion: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export declare interface IDeviceStateProvider {
|
|
294
|
+
readonly bindings: readonly IDeviceStateBinding[];
|
|
295
|
+
read(key: IDeviceStateKey, signal: AbortSignal): Promise<Uint8Array | undefined>;
|
|
296
|
+
/** Atomically replace the slot. Resolve only after the write has committed. */
|
|
297
|
+
write(key: IDeviceStateKey, image: Uint8Array, signal: AbortSignal): Promise<void>;
|
|
298
|
+
}
|
|
299
|
+
|
|
264
300
|
export declare interface IDocumentAccess {
|
|
265
301
|
readonly edit: AccessDecision;
|
|
266
302
|
readonly run: AccessDecision;
|
|
@@ -341,11 +377,52 @@ declare interface IFusedInstancePresentation {
|
|
|
341
377
|
readonly events: readonly string[];
|
|
342
378
|
}
|
|
343
379
|
|
|
380
|
+
export declare interface IFusedLogRecord extends LogRecord {
|
|
381
|
+
readonly source: FusedLogSource;
|
|
382
|
+
/** Workbench receive time, in Unix epoch milliseconds. */
|
|
383
|
+
readonly receivedAt: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export declare interface IFusedObservabilityOptions {
|
|
387
|
+
/** Defaults to info. A workbench writes to its Console when no sink is supplied. */
|
|
388
|
+
readonly logLevel?: LogLevel;
|
|
389
|
+
readonly onLog?: (record: IFusedLogRecord) => void;
|
|
390
|
+
/** Enables User Timing and startup sampling. Defaults to false. */
|
|
391
|
+
readonly performance?: boolean;
|
|
392
|
+
readonly onSample?: (sample: IFusedStartupSample) => void;
|
|
393
|
+
}
|
|
394
|
+
|
|
344
395
|
declare interface IFusedProgramFilesSnapshot {
|
|
345
396
|
readonly kind: 'filesystem';
|
|
346
397
|
readonly files: readonly ProgramFile[];
|
|
347
398
|
}
|
|
348
399
|
|
|
400
|
+
export declare interface IFusedStartupSample {
|
|
401
|
+
readonly phase: 'device-package' | 'simulation-load' | 'first-step' | 'workbench-startup';
|
|
402
|
+
readonly outcome: FusedStartupOutcome;
|
|
403
|
+
readonly durationMs: number;
|
|
404
|
+
readonly runId?: string;
|
|
405
|
+
readonly sessionId?: string;
|
|
406
|
+
readonly kind?: FusedStartupKind;
|
|
407
|
+
readonly warmup?: FusedWarmupProgress;
|
|
408
|
+
readonly packageId?: string;
|
|
409
|
+
readonly version?: string;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export declare interface IFusedStartupSummary {
|
|
413
|
+
readonly phase: IFusedStartupSample['phase'];
|
|
414
|
+
readonly kind?: FusedStartupKind;
|
|
415
|
+
readonly warmup?: FusedWarmupProgress;
|
|
416
|
+
readonly packageId?: string;
|
|
417
|
+
readonly version?: string;
|
|
418
|
+
readonly count: number;
|
|
419
|
+
readonly failed: number;
|
|
420
|
+
readonly cancelled: number;
|
|
421
|
+
readonly p50Ms: number | null;
|
|
422
|
+
readonly p95Ms: number | null;
|
|
423
|
+
readonly maxMs: number | null;
|
|
424
|
+
}
|
|
425
|
+
|
|
349
426
|
declare interface IFusedTextTarget {
|
|
350
427
|
readonly kind: 'designator' | 'label' | 'reference';
|
|
351
428
|
readonly id: string;
|
|
@@ -357,11 +434,15 @@ export declare interface IResolvedWorkbenchTheme {
|
|
|
357
434
|
}
|
|
358
435
|
|
|
359
436
|
export declare interface IWorkbench {
|
|
437
|
+
/** Startup distributions over the most recent retained samples. */
|
|
438
|
+
getStartupPerformance(): readonly IFusedStartupSummary[];
|
|
360
439
|
readonly contextKeys: IContextKeyService;
|
|
361
440
|
readonly onDidChangeContent: Event_2<FusedDocument>;
|
|
362
441
|
readonly onDidChangeSelection: Event_2<readonly IWorkbenchTarget[]>;
|
|
363
442
|
readonly onDidChangeState: Event_2<IWorkbenchState>;
|
|
364
443
|
readonly onDidReportDiagnostic: Event_2<IWorkbenchDiagnostic>;
|
|
444
|
+
/** Reports failed workbench UI operations. Direct API calls reject their own promises. */
|
|
445
|
+
readonly onDidFailOperation: Event_2<IWorkbenchOperationFailure>;
|
|
365
446
|
readonly onDidRequestOpenProject: Event_2<{
|
|
366
447
|
readonly projectId: string;
|
|
367
448
|
}>;
|
|
@@ -527,7 +608,16 @@ export declare interface IWorkbenchExtensionContext {
|
|
|
527
608
|
readonly signal: AbortSignal;
|
|
528
609
|
}
|
|
529
610
|
|
|
611
|
+
export declare interface IWorkbenchOperationFailure {
|
|
612
|
+
/** Identifier of the UI operation, e.g. `simulation.start` or a toolbar contribution ID. */
|
|
613
|
+
readonly operation: string;
|
|
614
|
+
readonly code: string;
|
|
615
|
+
readonly error: unknown;
|
|
616
|
+
}
|
|
617
|
+
|
|
530
618
|
export declare interface IWorkbenchOptions {
|
|
619
|
+
readonly observability?: IFusedObservabilityOptions;
|
|
620
|
+
readonly deviceStateProvider?: IDeviceStateProvider;
|
|
531
621
|
/** Caller-owned browser context, automatically resumed on document-wide user gestures. */
|
|
532
622
|
readonly audio?: IFusedAudioOptions;
|
|
533
623
|
readonly container: HTMLElement;
|
|
@@ -535,6 +625,8 @@ export declare interface IWorkbenchOptions {
|
|
|
535
625
|
readonly saveDocument?: (document: FusedDocument) => Promise<void>;
|
|
536
626
|
readonly assetProvider?: IAssetProvider;
|
|
537
627
|
readonly deviceProvider: IDeviceProvider;
|
|
628
|
+
/** Defaults to `compatible` when the device provider supports version resolution. */
|
|
629
|
+
readonly deviceVersionPolicy?: 'compatible' | 'locked';
|
|
538
630
|
readonly programs?: ProgramSources;
|
|
539
631
|
readonly accessProvider?: IWorkbenchAccessProvider;
|
|
540
632
|
readonly viewBaseUrlTemplate: string;
|