@arronqzy/vue-view 0.1.23 → 0.1.25
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 +1 -3
- package/package.json +7 -7
- package/src/index.ts +53 -1
- package/src/panel/VueViewOnlinePreview.vue +25 -0
- package/src/panel/VueViewPanel.vue +62 -2
- package/src/panel/hooks/useWorkspaceProjects.ts +209 -67
- package/src/panel/library/abuilder-storage.ts +168 -0
- package/src/panel/library/abuilder-view-handle.ts +100 -0
- package/src/panel/library/blueprint-library-sync.ts +22 -0
- package/src/panel/library/capture-preview-snapshot.ts +800 -0
- package/src/panel/library/event-subscription.ts +79 -5
- package/src/panel/library/preview-snapshot.ts +252 -0
- package/src/panel/library/workspace-project-sync.ts +7 -1
- package/src/panel/library/workspace-storage.ts +70 -3
package/README.md
CHANGED
|
@@ -49,9 +49,7 @@ import {
|
|
|
49
49
|
} from "@arronqzy/vue-view";
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
创建 / 同步发出 `workspace:add` / `workspace:sync`。`parseWorkspaceData` 的 `value` 可作 `initialWorkspace
|
|
53
|
-
|
|
54
|
-
本地保存的工作区可用 `listWorkspaceProjects` / `deleteWorkspaceProject` / `clearWorkspaceProjects`(参数为 `nameSpace`)列出和清理。其余 IndexedDB 读写与 `getPreviewSnapshot` **不导出**,缩略图只在 React 包实现。
|
|
52
|
+
创建 / 同步发出 `workspace:add` / `workspace:sync`(载荷含 `nameSpace`),删除发出 `workspace:delete`。另有 `blueprint-library:changed` / `api-collection:changed`。`parseWorkspaceData` 的 `value` 可作 `initialWorkspace`;带 `id` 时默认同步进 IndexedDB。也支持 `workspaceId` prop、`ref`(`AbuilderViewHandle`)以及 `put*` / `openWorkspace` / `getCurrentWorkspace` / `getPreviewSnapshot` 等与 React 对齐的公开 API。
|
|
55
53
|
|
|
56
54
|
## 和 React 版的差别
|
|
57
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arronqzy/vue-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Vue 3 visual view editor for Abuilder (Ant Design Vue)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"selecto": "^1.26.3",
|
|
24
24
|
"uuid": "^13.0.0",
|
|
25
25
|
"vue": "^3.5.13",
|
|
26
|
-
"@arronqzy/i18n": "0.1.17",
|
|
27
26
|
"@arronqzy/blueprint-dsl": "1.0.17",
|
|
28
|
-
"@arronqzy/
|
|
27
|
+
"@arronqzy/i18n": "0.1.17",
|
|
29
28
|
"@arronqzy/view-scene3d": "0.1.5",
|
|
30
|
-
"@arronqzy/view-table": "0.1.8",
|
|
31
29
|
"@arronqzy/vue-rx-store": "0.1.6",
|
|
32
|
-
"@arronqzy/
|
|
30
|
+
"@arronqzy/view-table": "0.1.8",
|
|
31
|
+
"@arronqzy/vue-blueprint": "0.1.19",
|
|
32
|
+
"@arronqzy/rx-store": "1.0.8"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"vue": "^3.4.0"
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"eslint": "^8.57.0",
|
|
40
40
|
"typescript": "^5.5.4",
|
|
41
41
|
"vue-tsc": "^2.2.0",
|
|
42
|
-
"@arronqzy/
|
|
43
|
-
"@arronqzy/
|
|
42
|
+
"@arronqzy/typescript-config": "1.0.0",
|
|
43
|
+
"@arronqzy/eslint-config": "0.0.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -15,10 +15,48 @@ export {
|
|
|
15
15
|
export { createWorkspaceProjectId } from "./panel/library/workspace-project-db";
|
|
16
16
|
export {
|
|
17
17
|
listWorkspaceProjects,
|
|
18
|
+
getWorkspaceProject,
|
|
19
|
+
putWorkspaceProject,
|
|
20
|
+
upsertWorkspaceProject,
|
|
18
21
|
deleteWorkspaceProject,
|
|
19
22
|
clearWorkspaceProjects,
|
|
20
23
|
} from "./panel/library/workspace-storage";
|
|
21
|
-
export type {
|
|
24
|
+
export type {
|
|
25
|
+
WorkspaceProjectListItem,
|
|
26
|
+
PutWorkspaceProjectOptions,
|
|
27
|
+
} from "./panel/library/workspace-storage";
|
|
28
|
+
export {
|
|
29
|
+
listBlueprintLibrary,
|
|
30
|
+
getBlueprintLibraryRecord,
|
|
31
|
+
putBlueprintLibraryRecord,
|
|
32
|
+
deleteBlueprintLibraryRecord,
|
|
33
|
+
clearBlueprintLibrary,
|
|
34
|
+
listExecutionRunRecords,
|
|
35
|
+
getExecutionRunRecord,
|
|
36
|
+
putExecutionRunRecord,
|
|
37
|
+
deleteExecutionRunRecord,
|
|
38
|
+
clearAllExecutionRunRecords,
|
|
39
|
+
purgeExecutionRunsOlderThan,
|
|
40
|
+
trimExecutionRunRecordsToMax,
|
|
41
|
+
readExecutionLogSettings,
|
|
42
|
+
writeExecutionLogSettings,
|
|
43
|
+
listApiCollectionRecords,
|
|
44
|
+
putApiCollection,
|
|
45
|
+
upsertApiCollectionFromJson,
|
|
46
|
+
deleteApiCollection,
|
|
47
|
+
clearApiCollections,
|
|
48
|
+
clearAbuilderStorage,
|
|
49
|
+
} from "./panel/library/abuilder-storage";
|
|
50
|
+
export type {
|
|
51
|
+
AbuilderStorageClearResult,
|
|
52
|
+
BlueprintLibraryListItem,
|
|
53
|
+
BlueprintLibraryRecord,
|
|
54
|
+
ExecutionRunRecord,
|
|
55
|
+
ExecutionLogSettings,
|
|
56
|
+
ApiCollectionRecord,
|
|
57
|
+
UpsertApiCollectionInput,
|
|
58
|
+
UpsertApiCollectionResult,
|
|
59
|
+
} from "./panel/library/abuilder-storage";
|
|
22
60
|
export {
|
|
23
61
|
addEventSubscription,
|
|
24
62
|
AbuilderEvents,
|
|
@@ -26,13 +64,27 @@ export {
|
|
|
26
64
|
export type {
|
|
27
65
|
AbuilderEventName,
|
|
28
66
|
AbuilderEventPayloadMap,
|
|
67
|
+
AddEventSubscriptionOptions,
|
|
29
68
|
WorkspaceAddEventPayload,
|
|
30
69
|
WorkspaceSyncEventPayload,
|
|
70
|
+
WorkspaceDeleteEventPayload,
|
|
71
|
+
BlueprintLibraryChangedEventPayload,
|
|
31
72
|
ApiCollectionUploadStartEventPayload,
|
|
32
73
|
ApiCollectionUploadSuccessEventPayload,
|
|
74
|
+
ApiCollectionChangedEventPayload,
|
|
33
75
|
WorkspaceData,
|
|
34
76
|
} from "./panel/library/event-subscription";
|
|
77
|
+
export {
|
|
78
|
+
getCurrentWorkspace,
|
|
79
|
+
openWorkspace,
|
|
80
|
+
createWorkspace,
|
|
81
|
+
saveWorkspace,
|
|
82
|
+
syncWorkspace,
|
|
83
|
+
} from "./panel/library/abuilder-view-handle";
|
|
84
|
+
export type { AbuilderViewHandle } from "./panel/library/abuilder-view-handle";
|
|
35
85
|
export type {
|
|
36
86
|
ParseCheckResult,
|
|
37
87
|
WorkspaceParseCheckResult,
|
|
38
88
|
} from "./panel/library/parse-workspace-data";
|
|
89
|
+
export { getPreviewSnapshot } from "./panel/library/preview-snapshot";
|
|
90
|
+
export type { GetPreviewSnapshotOptions } from "./panel/library/preview-snapshot";
|
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
resolvePreviewLayerElements,
|
|
41
41
|
} from "./utils/panelStateIO";
|
|
42
42
|
import { applyPreviewSceneFill, readOutputScale } from "./utils/outputScale";
|
|
43
|
+
import { registerPreviewSnapshotProvider } from "./library/preview-snapshot";
|
|
44
|
+
import { capturePreviewSceneElement } from "./library/capture-preview-snapshot";
|
|
43
45
|
|
|
44
46
|
const { t, locale } = useI18n();
|
|
45
47
|
useBlueprintDslLocaleSync();
|
|
@@ -292,6 +294,29 @@ onMounted(() => {
|
|
|
292
294
|
onUnmounted(() => window.removeEventListener("resize", onResize));
|
|
293
295
|
});
|
|
294
296
|
|
|
297
|
+
watch(
|
|
298
|
+
[layoutReady, sceneRef, sceneBounds, fillScale, outputScale],
|
|
299
|
+
() => {
|
|
300
|
+
if (!layoutReady.value || !sceneRef.value) {
|
|
301
|
+
registerPreviewSnapshotProvider(null);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
registerPreviewSnapshotProvider(async () => {
|
|
305
|
+
const scene = sceneRef.value;
|
|
306
|
+
if (!scene) return null;
|
|
307
|
+
const width = outputScale.value
|
|
308
|
+
? sceneBounds.value.width
|
|
309
|
+
: sceneBounds.value.width * fillScale.value.scaleX;
|
|
310
|
+
const height = outputScale.value
|
|
311
|
+
? sceneBounds.value.height
|
|
312
|
+
: sceneBounds.value.height * fillScale.value.scaleY;
|
|
313
|
+
return capturePreviewSceneElement(scene, width, height);
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
{ immediate: true }
|
|
317
|
+
);
|
|
318
|
+
onUnmounted(() => registerPreviewSnapshotProvider(null));
|
|
319
|
+
|
|
295
320
|
function noopUpdate() {}
|
|
296
321
|
function noopSelect() {}
|
|
297
322
|
</script>
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onMounted, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
registerAbuilderViewHandle,
|
|
5
|
+
type AbuilderViewHandle,
|
|
6
|
+
} from "./library/abuilder-view-handle";
|
|
7
|
+
import {
|
|
8
|
+
captureEditorPreviewSnapshot,
|
|
9
|
+
registerPreviewSnapshotProvider,
|
|
10
|
+
} from "./library/preview-snapshot";
|
|
11
|
+
import { readOutputScale } from "./utils/outputScale";
|
|
3
12
|
import type { State } from "@arronqzy/rx-store";
|
|
4
13
|
import {
|
|
5
14
|
useBlueprintDslLocaleSync,
|
|
@@ -53,6 +62,7 @@ import {
|
|
|
53
62
|
} from "./hooks/useWorkspaceProjects";
|
|
54
63
|
import type { WorkspaceProjectRecord } from "./library/workspace-project-db";
|
|
55
64
|
import { AbuilderEvents, emitAbuilderEvent } from "./library/event-subscription";
|
|
65
|
+
import { subscribeBlueprintLibraryChanged } from "./library/blueprint-library-sync";
|
|
56
66
|
import { type ViewportZoom } from "./viewportZoom";
|
|
57
67
|
import PanelCanvas from "./components/PanelCanvas.vue";
|
|
58
68
|
import ElementsLayer from "./components/ElementsLayer.vue";
|
|
@@ -89,6 +99,11 @@ const props = withDefaults(
|
|
|
89
99
|
initialZoom?: number;
|
|
90
100
|
nameSpace?: string | null;
|
|
91
101
|
initialWorkspace?: WorkspaceProjectRecord | null;
|
|
102
|
+
/**
|
|
103
|
+
* 按 IndexedDB id 打开工作区(不 remount)。
|
|
104
|
+
* 与 initialWorkspace 同时存在时:首次优先完整记录;之后 id 变化从 IndexedDB 打开。
|
|
105
|
+
*/
|
|
106
|
+
workspaceId?: string | null;
|
|
92
107
|
/** 顶栏「设置 → 关于」展示的 npm 包名 */
|
|
93
108
|
packageName?: string | null;
|
|
94
109
|
/** 顶栏「设置 → 关于」展示的包版本号 */
|
|
@@ -98,6 +113,7 @@ const props = withDefaults(
|
|
|
98
113
|
initialZoom: 1,
|
|
99
114
|
nameSpace: null,
|
|
100
115
|
initialWorkspace: null,
|
|
116
|
+
workspaceId: null,
|
|
101
117
|
packageName: null,
|
|
102
118
|
packageVersion: null,
|
|
103
119
|
}
|
|
@@ -424,6 +440,14 @@ onMounted(() => {
|
|
|
424
440
|
void refreshBlueprintLibrary();
|
|
425
441
|
});
|
|
426
442
|
|
|
443
|
+
watch(
|
|
444
|
+
() => props.nameSpace,
|
|
445
|
+
(nameSpace, _prev, onCleanup) => {
|
|
446
|
+
onCleanup(subscribeBlueprintLibraryChanged(() => void refreshBlueprintLibrary(), nameSpace));
|
|
447
|
+
},
|
|
448
|
+
{ immediate: true }
|
|
449
|
+
);
|
|
450
|
+
|
|
427
451
|
function handleWorkspaceProjectApplied(record: WorkspaceProjectRecord) {
|
|
428
452
|
workspaceBlueprintRef.value = {
|
|
429
453
|
document: record.blueprintDocument,
|
|
@@ -461,9 +485,39 @@ const workspaceProjects = useWorkspaceProjects({
|
|
|
461
485
|
panelRevision: computed(() => `${historyCursor.value}|${allElements.value.length}`),
|
|
462
486
|
onProjectApplied: handleWorkspaceProjectApplied,
|
|
463
487
|
initialWorkspace: () => props.initialWorkspace,
|
|
488
|
+
workspaceId: () => props.workspaceId,
|
|
464
489
|
nameSpace: () => props.nameSpace,
|
|
465
490
|
});
|
|
466
491
|
|
|
492
|
+
const viewHandle: AbuilderViewHandle = {
|
|
493
|
+
getNameSpace: () => props.nameSpace ?? null,
|
|
494
|
+
getCurrentWorkspace: () => workspaceProjects.getCurrentWorkspaceRecord(),
|
|
495
|
+
openWorkspace: (idOrRecord) => workspaceProjects.handleOpenProject(idOrRecord),
|
|
496
|
+
createWorkspace: () => workspaceProjects.handleCreateProject(),
|
|
497
|
+
saveWorkspace: () => workspaceProjects.handleSaveProject(),
|
|
498
|
+
syncWorkspace: () => workspaceProjects.handleSyncProject(),
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
defineExpose(viewHandle);
|
|
502
|
+
onUnmounted(registerAbuilderViewHandle(viewHandle));
|
|
503
|
+
|
|
504
|
+
watch(
|
|
505
|
+
[canvasEl, allElements, layers, activeLayerId, () => props.nameSpace],
|
|
506
|
+
() => {
|
|
507
|
+
registerPreviewSnapshotProvider(async () =>
|
|
508
|
+
captureEditorPreviewSnapshot({
|
|
509
|
+
canvasRoot: canvasEl.value,
|
|
510
|
+
allElements: allElements.value,
|
|
511
|
+
layers: layers.value,
|
|
512
|
+
activeLayerId: activeLayerId.value,
|
|
513
|
+
outputScale: readOutputScale(props.nameSpace),
|
|
514
|
+
})
|
|
515
|
+
);
|
|
516
|
+
},
|
|
517
|
+
{ immediate: true }
|
|
518
|
+
);
|
|
519
|
+
onUnmounted(() => registerPreviewSnapshotProvider(null));
|
|
520
|
+
|
|
467
521
|
const blueprintLifecycleToken = computed(() => {
|
|
468
522
|
const doc = blueprintGraph.value.document;
|
|
469
523
|
const nodes = doc.nodes;
|
|
@@ -637,7 +691,10 @@ function handleApiCollectionUploadStart(info: {
|
|
|
637
691
|
fileNames: string[];
|
|
638
692
|
count: number;
|
|
639
693
|
}) {
|
|
640
|
-
emitAbuilderEvent(AbuilderEvents.apiCollectionUploadStart,
|
|
694
|
+
emitAbuilderEvent(AbuilderEvents.apiCollectionUploadStart, {
|
|
695
|
+
...info,
|
|
696
|
+
nameSpace: props.nameSpace ?? null,
|
|
697
|
+
});
|
|
641
698
|
}
|
|
642
699
|
|
|
643
700
|
function handleApiCollectionUploadSuccess(info: {
|
|
@@ -648,7 +705,10 @@ function handleApiCollectionUploadSuccess(info: {
|
|
|
648
705
|
persistLocal: boolean;
|
|
649
706
|
}>;
|
|
650
707
|
}) {
|
|
651
|
-
emitAbuilderEvent(AbuilderEvents.apiCollectionUploadSuccess,
|
|
708
|
+
emitAbuilderEvent(AbuilderEvents.apiCollectionUploadSuccess, {
|
|
709
|
+
...info,
|
|
710
|
+
nameSpace: props.nameSpace ?? null,
|
|
711
|
+
});
|
|
652
712
|
}
|
|
653
713
|
|
|
654
714
|
function handleApiCollectionSync(record: {
|