@timeax/digital-service-engine 0.0.9 → 0.1.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/workspace/index.cjs +101 -43
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.js +111 -51
- package/dist/workspace/index.js.map +1 -1
- package/package.json +1 -1
package/dist/workspace/index.cjs
CHANGED
|
@@ -1367,7 +1367,6 @@ function useLivePolling(params) {
|
|
|
1367
1367
|
live,
|
|
1368
1368
|
workspaceId,
|
|
1369
1369
|
actor,
|
|
1370
|
-
hasAnyData,
|
|
1371
1370
|
getCurrentBranchId,
|
|
1372
1371
|
refreshAll,
|
|
1373
1372
|
refreshBranchContext,
|
|
@@ -1474,11 +1473,6 @@ function useLivePolling(params) {
|
|
|
1474
1473
|
disconnect2();
|
|
1475
1474
|
if (live.mode === "off") {
|
|
1476
1475
|
setStatus({ connected: false });
|
|
1477
|
-
if (!hasAnyData) {
|
|
1478
|
-
void (async () => {
|
|
1479
|
-
await refreshAll({ strict: false });
|
|
1480
|
-
})();
|
|
1481
|
-
}
|
|
1482
1476
|
return;
|
|
1483
1477
|
}
|
|
1484
1478
|
const adapter = resolveAdapter();
|
|
@@ -1514,7 +1508,6 @@ function useLivePolling(params) {
|
|
|
1514
1508
|
}, [
|
|
1515
1509
|
disconnect2,
|
|
1516
1510
|
live.mode,
|
|
1517
|
-
hasAnyData,
|
|
1518
1511
|
refreshAll,
|
|
1519
1512
|
resolveAdapter,
|
|
1520
1513
|
ctx,
|
|
@@ -9912,8 +9905,8 @@ function CanvasProviderOwned({
|
|
|
9912
9905
|
canvasOpts,
|
|
9913
9906
|
builderOpts
|
|
9914
9907
|
);
|
|
9915
|
-
useHydrateEditorSnapshot(api, initialSnapshot);
|
|
9916
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Ctx.Provider, { value: api, children });
|
|
9908
|
+
const hydrationReady = useHydrateEditorSnapshot(api, initialSnapshot);
|
|
9909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Ctx.Provider, { value: api, children: hydrationReady ? children : null });
|
|
9917
9910
|
}
|
|
9918
9911
|
function useCanvasAPI() {
|
|
9919
9912
|
const api = (0, import_react2.useContext)(Ctx);
|
|
@@ -9941,42 +9934,71 @@ function useCanvasFromBuilder(builder, opts) {
|
|
|
9941
9934
|
function useCanvasFromExisting(api) {
|
|
9942
9935
|
return api;
|
|
9943
9936
|
}
|
|
9937
|
+
var NO_SNAPSHOT_HYDRATION_KEY = "__no_snapshot__";
|
|
9944
9938
|
function useHydrateEditorSnapshot(api, snapshot) {
|
|
9945
|
-
const
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9939
|
+
const targetHydrationKey = (0, import_react2.useMemo)(() => {
|
|
9940
|
+
if (!(snapshot == null ? void 0 : snapshot.props)) return NO_SNAPSHOT_HYDRATION_KEY;
|
|
9941
|
+
return getSnapshotHydrationKey(snapshot);
|
|
9942
|
+
}, [snapshot]);
|
|
9943
|
+
const [hydratedKey, setHydratedKey] = (0, import_react2.useState)(
|
|
9944
|
+
NO_SNAPSHOT_HYDRATION_KEY
|
|
9945
|
+
);
|
|
9946
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
9947
|
+
if (hydratedKey === targetHydrationKey) return;
|
|
9948
|
+
if (snapshot == null ? void 0 : snapshot.props) {
|
|
9949
|
+
hydrateEditorFromSnapshot(api, snapshot);
|
|
9950
|
+
}
|
|
9951
|
+
setHydratedKey(targetHydrationKey);
|
|
9952
|
+
}, [api, hydratedKey, snapshot, targetHydrationKey]);
|
|
9953
|
+
return hydratedKey === targetHydrationKey;
|
|
9953
9954
|
}
|
|
9954
9955
|
function getSnapshotHydrationKey(snapshot) {
|
|
9955
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
9956
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9956
9957
|
const meta = snapshot.meta;
|
|
9957
|
-
const
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9958
|
+
const metaKey = [
|
|
9959
|
+
(_b = (_a = meta == null ? void 0 : meta.snapshot_id) != null ? _a : meta == null ? void 0 : meta.snapshotId) != null ? _b : "",
|
|
9960
|
+
(_d = (_c = meta == null ? void 0 : meta.version_id) != null ? _c : meta == null ? void 0 : meta.versionId) != null ? _d : "",
|
|
9961
|
+
(_f = (_e = meta == null ? void 0 : meta.branch_id) != null ? _e : meta == null ? void 0 : meta.branchId) != null ? _f : ""
|
|
9962
|
+
].join("|");
|
|
9963
|
+
const layout = (_g = snapshot.layout) == null ? void 0 : _g.canvas;
|
|
9962
9964
|
const positionKeys = (layout == null ? void 0 : layout.positions) ? Object.keys(layout.positions).sort().join("|") : "";
|
|
9963
9965
|
const viewport = (layout == null ? void 0 : layout.viewport) ? `${layout.viewport.x}:${layout.viewport.y}:${layout.viewport.zoom}` : "";
|
|
9964
9966
|
const selection = (layout == null ? void 0 : layout.selection) ? Array.from(layout.selection).sort().join("|") : "";
|
|
9965
|
-
const catalogKey = snapshot.catalog
|
|
9966
|
-
opened: (_g = snapshot.catalog.opened) != null ? _g : null,
|
|
9967
|
-
mode: (_h = snapshot.catalog.mode) != null ? _h : null,
|
|
9968
|
-
tab: (_i = snapshot.catalog.tab) != null ? _i : null,
|
|
9969
|
-
query: (_j = snapshot.catalog.query) != null ? _j : null
|
|
9970
|
-
}) : "";
|
|
9967
|
+
const catalogKey = serializeForHydration(snapshot.catalog);
|
|
9971
9968
|
return [
|
|
9972
|
-
|
|
9973
|
-
String(((
|
|
9969
|
+
metaKey,
|
|
9970
|
+
String(((_i = (_h = snapshot.props) == null ? void 0 : _h.fields) != null ? _i : []).length),
|
|
9971
|
+
String(((_k = (_j = snapshot.props) == null ? void 0 : _j.filters) != null ? _k : []).length),
|
|
9974
9972
|
positionKeys,
|
|
9975
9973
|
viewport,
|
|
9976
9974
|
selection,
|
|
9977
9975
|
catalogKey
|
|
9978
9976
|
].join("::");
|
|
9979
9977
|
}
|
|
9978
|
+
function serializeForHydration(value) {
|
|
9979
|
+
if (value == null) return "";
|
|
9980
|
+
try {
|
|
9981
|
+
return JSON.stringify(sortForHydration(value));
|
|
9982
|
+
} catch {
|
|
9983
|
+
return "__unserializable__";
|
|
9984
|
+
}
|
|
9985
|
+
}
|
|
9986
|
+
function sortForHydration(value) {
|
|
9987
|
+
if (Array.isArray(value)) {
|
|
9988
|
+
return value.map((entry) => sortForHydration(entry));
|
|
9989
|
+
}
|
|
9990
|
+
if (value && typeof value === "object") {
|
|
9991
|
+
const entries = Object.entries(value).sort(
|
|
9992
|
+
([a], [b]) => a.localeCompare(b)
|
|
9993
|
+
);
|
|
9994
|
+
const next = {};
|
|
9995
|
+
for (const [key, entry] of entries) {
|
|
9996
|
+
next[key] = sortForHydration(entry);
|
|
9997
|
+
}
|
|
9998
|
+
return next;
|
|
9999
|
+
}
|
|
10000
|
+
return value;
|
|
10001
|
+
}
|
|
9980
10002
|
function hydrateEditorFromSnapshot(api, snapshot) {
|
|
9981
10003
|
var _a;
|
|
9982
10004
|
api.refreshGraph();
|
|
@@ -9991,30 +10013,66 @@ function hydrateCatalog(api, snapshot) {
|
|
|
9991
10013
|
api.editor.clearCatalog();
|
|
9992
10014
|
}
|
|
9993
10015
|
function hydrateCanvasLayout(api, canvas) {
|
|
10016
|
+
var _a;
|
|
9994
10017
|
if (!canvas) return;
|
|
9995
|
-
|
|
10018
|
+
const current = api.snapshot();
|
|
10019
|
+
if (canvas.positions && hasPositionDelta(canvas.positions, current.positions)) {
|
|
9996
10020
|
api.setPositions(canvas.positions);
|
|
9997
10021
|
}
|
|
9998
|
-
if (canvas.viewport) {
|
|
10022
|
+
if (canvas.viewport && !sameViewport(canvas.viewport, current.viewport)) {
|
|
9999
10023
|
api.setViewport(canvas.viewport);
|
|
10000
10024
|
}
|
|
10025
|
+
const currentSelection = api.getSelection().map(String);
|
|
10001
10026
|
if (canvas.selection) {
|
|
10002
10027
|
const ids = Array.isArray(canvas.selection) ? canvas.selection : Array.from(canvas.selection);
|
|
10003
10028
|
if (ids.length > 0) {
|
|
10004
|
-
|
|
10005
|
-
|
|
10029
|
+
if (!sameIdSet(ids.map(String), currentSelection)) {
|
|
10030
|
+
api.select(ids.map(String));
|
|
10031
|
+
}
|
|
10032
|
+
} else if (currentSelection.length > 0) {
|
|
10006
10033
|
api.clearSelection();
|
|
10007
10034
|
}
|
|
10008
|
-
} else {
|
|
10035
|
+
} else if (currentSelection.length > 0) {
|
|
10009
10036
|
api.clearSelection();
|
|
10010
10037
|
}
|
|
10011
|
-
if (canvas
|
|
10012
|
-
const
|
|
10013
|
-
|
|
10038
|
+
if ("highlighted" in canvas) {
|
|
10039
|
+
const highlighted = canvas.highlighted;
|
|
10040
|
+
const ids = highlighted ? Array.isArray(highlighted) ? highlighted : Array.from(highlighted) : [];
|
|
10041
|
+
const currentIds = Array.from((_a = current.highlighted) != null ? _a : []).map(String);
|
|
10042
|
+
const nextIds = ids.map(String);
|
|
10043
|
+
if (!sameIdSet(nextIds, currentIds)) {
|
|
10044
|
+
api.setHighlighted(nextIds);
|
|
10045
|
+
}
|
|
10014
10046
|
}
|
|
10015
10047
|
if ("hoverId" in canvas) {
|
|
10016
|
-
|
|
10048
|
+
const nextHoverId = canvas.hoverId;
|
|
10049
|
+
if (current.hoverId !== nextHoverId) {
|
|
10050
|
+
api.setHover(nextHoverId);
|
|
10051
|
+
}
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
function hasPositionDelta(next, current) {
|
|
10055
|
+
for (const id of Object.keys(next)) {
|
|
10056
|
+
const nextPos = next[id];
|
|
10057
|
+
const currentPos = current[id];
|
|
10058
|
+
if (!currentPos || currentPos.x !== nextPos.x || currentPos.y !== nextPos.y) {
|
|
10059
|
+
return true;
|
|
10060
|
+
}
|
|
10061
|
+
}
|
|
10062
|
+
return false;
|
|
10063
|
+
}
|
|
10064
|
+
function sameViewport(a, b) {
|
|
10065
|
+
if (!a && !b) return true;
|
|
10066
|
+
if (!a || !b) return false;
|
|
10067
|
+
return a.x === b.x && a.y === b.y && a.zoom === b.zoom;
|
|
10068
|
+
}
|
|
10069
|
+
function sameIdSet(a, b) {
|
|
10070
|
+
if (a.length !== b.length) return false;
|
|
10071
|
+
const set = new Set(a);
|
|
10072
|
+
for (const id of b) {
|
|
10073
|
+
if (!set.has(id)) return false;
|
|
10017
10074
|
}
|
|
10075
|
+
return true;
|
|
10018
10076
|
}
|
|
10019
10077
|
function WorkspaceBootScreen({
|
|
10020
10078
|
boot
|
|
@@ -12029,7 +12087,7 @@ function rafThrottle(fn, minMs = 80) {
|
|
|
12029
12087
|
});
|
|
12030
12088
|
}
|
|
12031
12089
|
var isCommentId = (id) => id.startsWith("c::");
|
|
12032
|
-
function
|
|
12090
|
+
function sameIdSet2(a, b) {
|
|
12033
12091
|
if (a.length !== b.length) return false;
|
|
12034
12092
|
const s = new Set(a);
|
|
12035
12093
|
for (const id of b) if (!s.has(id)) return false;
|
|
@@ -12218,7 +12276,7 @@ function useReactFlowAdapter(api, options = {}) {
|
|
|
12218
12276
|
const next = Array.from(keep);
|
|
12219
12277
|
const currRaw = api.getSelection();
|
|
12220
12278
|
const curr = Array.isArray(currRaw) ? currRaw : Array.from(currRaw);
|
|
12221
|
-
if (!
|
|
12279
|
+
if (!sameIdSet2(next, curr)) {
|
|
12222
12280
|
api.select(keep);
|
|
12223
12281
|
}
|
|
12224
12282
|
}
|
|
@@ -12336,7 +12394,7 @@ function useReactFlowAdapter(api, options = {}) {
|
|
|
12336
12394
|
const next = nodes.map((n) => n.id);
|
|
12337
12395
|
const currRaw = api.getSelection();
|
|
12338
12396
|
const curr = Array.isArray(currRaw) ? currRaw : Array.from(currRaw);
|
|
12339
|
-
if (
|
|
12397
|
+
if (sameIdSet2(next, curr)) return;
|
|
12340
12398
|
api.select(next);
|
|
12341
12399
|
},
|
|
12342
12400
|
[api]
|