@mica-js/editor 0.15.1 → 0.16.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/dist/fused-runtime.d.ts +7 -0
- package/dist/fused-runtime.js +1 -1
- package/dist/fused.d.ts +2 -0
- package/dist/fused.js +25 -3
- package/dist/fused.js.map +1 -1
- package/dist/{runtime-DuxZ_yVl.js → runtime-DuYOb1Tc.js} +77 -24
- package/dist/runtime-DuYOb1Tc.js.map +1 -0
- package/dist/workers-CazFr0iO.js +34 -0
- package/dist/{workers-BpHcfNEu.js.map → workers-CazFr0iO.js.map} +1 -1
- package/package.json +5 -5
- package/dist/runtime-DuxZ_yVl.js.map +0 -1
- package/dist/workers-BpHcfNEu.js +0 -34
package/dist/fused-runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeviceLock } from '@mica-js/document/fused';
|
|
2
2
|
import { DeviceRegistry } from '@mica-js/document/fused';
|
|
3
|
+
import { DiskWriter } from '@mica-js/sdk/fused';
|
|
3
4
|
import { Event as Event_2 } from '@mica-js/core/lifecycle';
|
|
4
5
|
import { WidgetAudioState as FusedAudioState } from '@mica-js/widget/audio-guest';
|
|
5
6
|
import { FusedDocument } from '@mica-js/document/fused';
|
|
@@ -228,6 +229,7 @@ export declare interface IFusedConnectionOptions {
|
|
|
228
229
|
/** Element that hosts the two hidden sandbox iframes. */
|
|
229
230
|
readonly container?: HTMLElement;
|
|
230
231
|
readonly resolveResource?: ResourceResolver;
|
|
232
|
+
readonly writeDisk?: DiskWriter;
|
|
231
233
|
readonly programs?: ProgramSources;
|
|
232
234
|
readonly onDiagnostic?: (diagnostic: RuntimeDiagnostic, source: FusedLogSource) => void;
|
|
233
235
|
readonly observability?: IFusedObservabilityOptions;
|
|
@@ -397,6 +399,7 @@ export declare interface IFusedHostPackageService {
|
|
|
397
399
|
/** Host resources the simulation guest reaches during preparation (RFC 0020 / RFC 0026). */
|
|
398
400
|
export declare interface IFusedHostResourceService {
|
|
399
401
|
readResource(request: ResourceRequest): Promise<Uint8Array>;
|
|
402
|
+
writeDisk(assetId: string, bytes: Uint8Array): Promise<void>;
|
|
400
403
|
resolveProgramProject(projectId: string, target: ProgramTarget): Promise<ProgramArtifact>;
|
|
401
404
|
}
|
|
402
405
|
|
|
@@ -434,6 +437,8 @@ export declare interface IFusedInvalidateEvent {
|
|
|
434
437
|
/** Request that creates the models of one run session. */
|
|
435
438
|
export declare interface IFusedLoadRequest {
|
|
436
439
|
readonly observation?: IFusedObservation;
|
|
440
|
+
readonly preparationId?: number;
|
|
441
|
+
readonly writableDisks?: boolean;
|
|
437
442
|
readonly document: FusedDocument;
|
|
438
443
|
/** Fixed positive step of every advance, in picoseconds. */
|
|
439
444
|
readonly step: TimePs;
|
|
@@ -542,6 +547,7 @@ export declare interface IFusedPackageFilesWire {
|
|
|
542
547
|
/** Preparation request of the simulation guest: verify packages and describe the scene. */
|
|
543
548
|
export declare interface IFusedPrepareRequest {
|
|
544
549
|
readonly observation?: IFusedObservation;
|
|
550
|
+
readonly preparationId?: number;
|
|
545
551
|
readonly document: FusedDocument;
|
|
546
552
|
readonly mode: FusedDisplayMode;
|
|
547
553
|
readonly deviceState?: readonly IFusedDeviceStateImage[];
|
|
@@ -626,6 +632,7 @@ export declare interface IFusedRuntimeOptions {
|
|
|
626
632
|
readonly mode?: FusedDisplayMode;
|
|
627
633
|
/** Explicit resolver of `file` and `store` property resources (RFC 0020). */
|
|
628
634
|
readonly resolveResource?: ResourceResolver;
|
|
635
|
+
readonly writeDisk?: DiskWriter;
|
|
629
636
|
/** Firmware project service of the editor (RFC 0026). */
|
|
630
637
|
readonly programs?: ProgramSources;
|
|
631
638
|
/** Receives every freshly rendered overlay, already keyed by instance. */
|
package/dist/fused-runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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-
|
|
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-DuYOb1Tc.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
|
@@ -131,6 +131,8 @@ export declare interface IAssetInfo {
|
|
|
131
131
|
export declare interface IAssetProvider {
|
|
132
132
|
select(request: IAssetRequest): Promise<IAssetInfo | undefined>;
|
|
133
133
|
read(assetId: string, signal: AbortSignal): Promise<Uint8Array>;
|
|
134
|
+
/** Returns a writable handle for the same project asset that `read` resolves. */
|
|
135
|
+
getFileHandle?(assetId: string): Promise<Pick<FileSystemFileHandle, 'createWritable'>>;
|
|
134
136
|
/**
|
|
135
137
|
* 写入用户上传的文件并返回可直接绑定的资产。宿主决定命名与替换规则;
|
|
136
138
|
* 未实现时属性面板不提供上传入口。
|
package/dist/fused.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as planPolylineSegmentDrag, n as orthogonalWaypoints, t as extendWirePath } from "./wire-JZIiIOI0.js";
|
|
2
2
|
import { Z as isHtmlViewError, _ as resolveTheme, a as createHtmlViewHost, f as WORKBENCH_DARK_COLORS, g as readCanvasTheme, h as normalizeTheme, m as WORKBENCH_THEME_CSS_VARIABLES, p as WORKBENCH_LIGHT_COLORS, v as themeStyle } from "./html-B0pN-5Mx.js";
|
|
3
|
-
import { a as createFusedRuntime, d as loggedStartupFailures, f as summarizeStartup, m as writeWorkbenchConsole, p as writeFusedLog } from "./runtime-
|
|
3
|
+
import { a as createFusedRuntime, d as loggedStartupFailures, f as summarizeStartup, m as writeWorkbenchConsole, p as writeFusedLog } from "./runtime-DuYOb1Tc.js";
|
|
4
4
|
import { DisposableStore, Emitter } from "@mica-js/core/lifecycle";
|
|
5
5
|
import { projectOnSegment } from "@mica-js/document/schematic";
|
|
6
6
|
import { timePs } from "@mica-js/core";
|
|
@@ -3379,6 +3379,22 @@ function createSimulationControl(onDidChangeStatus) {
|
|
|
3379
3379
|
};
|
|
3380
3380
|
}
|
|
3381
3381
|
//#endregion
|
|
3382
|
+
//#region src/fused/providers/disk.ts
|
|
3383
|
+
function createAssetDiskWriter(provider) {
|
|
3384
|
+
const getFileHandle = provider?.getFileHandle?.bind(provider);
|
|
3385
|
+
if (getFileHandle === void 0) return void 0;
|
|
3386
|
+
return async (assetId, bytes) => {
|
|
3387
|
+
const stream = await (await getFileHandle(assetId)).createWritable({ keepExistingData: false });
|
|
3388
|
+
try {
|
|
3389
|
+
await stream.write(bytes.slice());
|
|
3390
|
+
await stream.close();
|
|
3391
|
+
} catch (cause) {
|
|
3392
|
+
await stream.abort(cause).catch(() => void 0);
|
|
3393
|
+
throw cause;
|
|
3394
|
+
}
|
|
3395
|
+
};
|
|
3396
|
+
}
|
|
3397
|
+
//#endregion
|
|
3382
3398
|
//#region src/fused/parts/activity-bar-part.tsx
|
|
3383
3399
|
function Icon({ name }) {
|
|
3384
3400
|
return /* @__PURE__ */ jsx("span", {
|
|
@@ -4762,6 +4778,7 @@ function assetRequestAccept(descriptor, memory) {
|
|
|
4762
4778
|
}
|
|
4763
4779
|
/** 上传前按属性声明的格式快速拒绝,避免为不支持的文件打开写入流程。 */
|
|
4764
4780
|
function resourceAcceptsFile(descriptor, memory, name) {
|
|
4781
|
+
if (descriptor.type === "disk") return name.trim().length > 0;
|
|
4765
4782
|
const extension = name.split(".").at(-1)?.toLowerCase() ?? "";
|
|
4766
4783
|
if (extension === "" || extension === name.toLowerCase()) return false;
|
|
4767
4784
|
const formats = assetRequestFormats(descriptor, memory) ?? (descriptor.type === "image" ? IMAGE_EXTENSIONS : void 0);
|
|
@@ -5148,7 +5165,7 @@ function ResourceField(props) {
|
|
|
5148
5165
|
}),
|
|
5149
5166
|
children: "从项目选择…"
|
|
5150
5167
|
}),
|
|
5151
|
-
/* @__PURE__ */ jsx("button", {
|
|
5168
|
+
descriptor.type !== "disk" && /* @__PURE__ */ jsx("button", {
|
|
5152
5169
|
onClick: () => {
|
|
5153
5170
|
setMenu(false);
|
|
5154
5171
|
setPackagePicker(true);
|
|
@@ -5171,7 +5188,7 @@ function ResourceField(props) {
|
|
|
5171
5188
|
})
|
|
5172
5189
|
]
|
|
5173
5190
|
}),
|
|
5174
|
-
packagePicker && /* @__PURE__ */ jsxs("div", {
|
|
5191
|
+
descriptor.type !== "disk" && packagePicker && /* @__PURE__ */ jsxs("div", {
|
|
5175
5192
|
className: "mica-wb-resource-control",
|
|
5176
5193
|
children: [
|
|
5177
5194
|
/* @__PURE__ */ jsxs("select", {
|
|
@@ -5312,6 +5329,7 @@ function PropertyField(props) {
|
|
|
5312
5329
|
"program",
|
|
5313
5330
|
"image",
|
|
5314
5331
|
"binary",
|
|
5332
|
+
"disk",
|
|
5315
5333
|
"firmware"
|
|
5316
5334
|
].includes(descriptor.type)) return /* @__PURE__ */ jsx(ResourceField, {
|
|
5317
5335
|
name: props.name,
|
|
@@ -5378,6 +5396,7 @@ function PropertyField(props) {
|
|
|
5378
5396
|
"program",
|
|
5379
5397
|
"image",
|
|
5380
5398
|
"binary",
|
|
5399
|
+
"disk",
|
|
5381
5400
|
"firmware"
|
|
5382
5401
|
].includes(descriptor.type) && /* @__PURE__ */ jsx("button", {
|
|
5383
5402
|
title: "恢复默认值",
|
|
@@ -6913,6 +6932,7 @@ async function createWorkbench(options) {
|
|
|
6913
6932
|
const manifest = devices.get(instance.device)?.manifest;
|
|
6914
6933
|
return manifest?.view2d?.entry !== void 0 || Object.values(manifest?.properties ?? {}).some((property) => property.type === "program");
|
|
6915
6934
|
})) return void 0;
|
|
6935
|
+
const writeDisk = createAssetDiskWriter(options.assetProvider);
|
|
6916
6936
|
const result = await createFusedRuntime({
|
|
6917
6937
|
observability,
|
|
6918
6938
|
...requestedAt === void 0 ? {} : { requestedAt },
|
|
@@ -6930,6 +6950,7 @@ async function createWorkbench(options) {
|
|
|
6930
6950
|
if (request.reference.mode !== "asset" || options.assetProvider === void 0) throw new Error("No asset provider is configured");
|
|
6931
6951
|
return options.assetProvider.read(request.reference.assetId, abort.signal);
|
|
6932
6952
|
},
|
|
6953
|
+
...writeDisk === void 0 ? {} : { writeDisk },
|
|
6933
6954
|
onDiagnostic: (diagnostic) => {
|
|
6934
6955
|
if (generation !== runtimeGeneration) return;
|
|
6935
6956
|
report({
|
|
@@ -7594,6 +7615,7 @@ async function createWorkbench(options) {
|
|
|
7594
7615
|
if (descriptor === void 0 || ![
|
|
7595
7616
|
"image",
|
|
7596
7617
|
"binary",
|
|
7618
|
+
"disk",
|
|
7597
7619
|
"firmware",
|
|
7598
7620
|
"program"
|
|
7599
7621
|
].includes(descriptor.type)) throw new Error("Unknown resource property");
|