@timeax/digital-service-engine 0.0.9 → 0.2.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
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,41 +9934,45 @@ 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
|
-
|
|
9953
|
-
}
|
|
9954
|
-
|
|
9955
|
-
|
|
9939
|
+
const fallbackIdentityRef = (0, import_react2.useRef)(
|
|
9940
|
+
`snapshot:fallback:${Math.random().toString(36).slice(2)}`
|
|
9941
|
+
);
|
|
9942
|
+
const hydratedIdentityRef = (0, import_react2.useRef)(NO_SNAPSHOT_HYDRATION_KEY);
|
|
9943
|
+
const [hydrationReady, setHydrationReady] = (0, import_react2.useState)(false);
|
|
9944
|
+
const targetHydrationIdentity = (0, import_react2.useMemo)(() => {
|
|
9945
|
+
if (!(snapshot == null ? void 0 : snapshot.props)) return NO_SNAPSHOT_HYDRATION_KEY;
|
|
9946
|
+
return getSnapshotHydrationIdentity(snapshot, fallbackIdentityRef.current);
|
|
9947
|
+
}, [snapshot]);
|
|
9948
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
9949
|
+
if (snapshot == null ? void 0 : snapshot.props) {
|
|
9950
|
+
const shouldHydrate = hydratedIdentityRef.current !== targetHydrationIdentity;
|
|
9951
|
+
if (shouldHydrate) {
|
|
9952
|
+
hydrateEditorFromSnapshot(api, snapshot);
|
|
9953
|
+
hydratedIdentityRef.current = targetHydrationIdentity;
|
|
9954
|
+
}
|
|
9955
|
+
}
|
|
9956
|
+
if (!hydrationReady) {
|
|
9957
|
+
setHydrationReady(true);
|
|
9958
|
+
}
|
|
9959
|
+
}, [api, hydrationReady, snapshot, targetHydrationIdentity]);
|
|
9960
|
+
return hydrationReady;
|
|
9961
|
+
}
|
|
9962
|
+
function getSnapshotHydrationIdentity(snapshot, fallbackIdentity) {
|
|
9963
|
+
var _a, _b, _c;
|
|
9956
9964
|
const meta = snapshot.meta;
|
|
9957
|
-
const
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
tab: (_i = snapshot.catalog.tab) != null ? _i : null,
|
|
9969
|
-
query: (_j = snapshot.catalog.query) != null ? _j : null
|
|
9970
|
-
}) : "";
|
|
9971
|
-
return [
|
|
9972
|
-
String(((_l = (_k = snapshot.props) == null ? void 0 : _k.fields) != null ? _l : []).length),
|
|
9973
|
-
String(((_n = (_m = snapshot.props) == null ? void 0 : _m.filters) != null ? _n : []).length),
|
|
9974
|
-
positionKeys,
|
|
9975
|
-
viewport,
|
|
9976
|
-
selection,
|
|
9977
|
-
catalogKey
|
|
9978
|
-
].join("::");
|
|
9965
|
+
const snapshotId = (_a = meta == null ? void 0 : meta.snapshot_id) != null ? _a : meta == null ? void 0 : meta.snapshotId;
|
|
9966
|
+
const versionId = (_b = meta == null ? void 0 : meta.version_id) != null ? _b : meta == null ? void 0 : meta.versionId;
|
|
9967
|
+
const branchId = (_c = meta == null ? void 0 : meta.branch_id) != null ? _c : meta == null ? void 0 : meta.branchId;
|
|
9968
|
+
if (snapshotId != null || versionId != null || branchId != null) {
|
|
9969
|
+
return [
|
|
9970
|
+
String(snapshotId != null ? snapshotId : ""),
|
|
9971
|
+
String(versionId != null ? versionId : ""),
|
|
9972
|
+
String(branchId != null ? branchId : "")
|
|
9973
|
+
].join("|");
|
|
9974
|
+
}
|
|
9975
|
+
return fallbackIdentity;
|
|
9979
9976
|
}
|
|
9980
9977
|
function hydrateEditorFromSnapshot(api, snapshot) {
|
|
9981
9978
|
var _a;
|
|
@@ -9991,30 +9988,66 @@ function hydrateCatalog(api, snapshot) {
|
|
|
9991
9988
|
api.editor.clearCatalog();
|
|
9992
9989
|
}
|
|
9993
9990
|
function hydrateCanvasLayout(api, canvas) {
|
|
9991
|
+
var _a;
|
|
9994
9992
|
if (!canvas) return;
|
|
9995
|
-
|
|
9993
|
+
const current = api.snapshot();
|
|
9994
|
+
if (canvas.positions && hasPositionDelta(canvas.positions, current.positions)) {
|
|
9996
9995
|
api.setPositions(canvas.positions);
|
|
9997
9996
|
}
|
|
9998
|
-
if (canvas.viewport) {
|
|
9997
|
+
if (canvas.viewport && !sameViewport(canvas.viewport, current.viewport)) {
|
|
9999
9998
|
api.setViewport(canvas.viewport);
|
|
10000
9999
|
}
|
|
10000
|
+
const currentSelection = api.getSelection().map(String);
|
|
10001
10001
|
if (canvas.selection) {
|
|
10002
10002
|
const ids = Array.isArray(canvas.selection) ? canvas.selection : Array.from(canvas.selection);
|
|
10003
10003
|
if (ids.length > 0) {
|
|
10004
|
-
|
|
10005
|
-
|
|
10004
|
+
if (!sameIdSet(ids.map(String), currentSelection)) {
|
|
10005
|
+
api.select(ids.map(String));
|
|
10006
|
+
}
|
|
10007
|
+
} else if (currentSelection.length > 0) {
|
|
10006
10008
|
api.clearSelection();
|
|
10007
10009
|
}
|
|
10008
|
-
} else {
|
|
10010
|
+
} else if (currentSelection.length > 0) {
|
|
10009
10011
|
api.clearSelection();
|
|
10010
10012
|
}
|
|
10011
|
-
if (canvas
|
|
10012
|
-
const
|
|
10013
|
-
|
|
10013
|
+
if ("highlighted" in canvas) {
|
|
10014
|
+
const highlighted = canvas.highlighted;
|
|
10015
|
+
const ids = highlighted ? Array.isArray(highlighted) ? highlighted : Array.from(highlighted) : [];
|
|
10016
|
+
const currentIds = Array.from((_a = current.highlighted) != null ? _a : []).map(String);
|
|
10017
|
+
const nextIds = ids.map(String);
|
|
10018
|
+
if (!sameIdSet(nextIds, currentIds)) {
|
|
10019
|
+
api.setHighlighted(nextIds);
|
|
10020
|
+
}
|
|
10014
10021
|
}
|
|
10015
10022
|
if ("hoverId" in canvas) {
|
|
10016
|
-
|
|
10023
|
+
const nextHoverId = canvas.hoverId;
|
|
10024
|
+
if (current.hoverId !== nextHoverId) {
|
|
10025
|
+
api.setHover(nextHoverId);
|
|
10026
|
+
}
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
function hasPositionDelta(next, current) {
|
|
10030
|
+
for (const id of Object.keys(next)) {
|
|
10031
|
+
const nextPos = next[id];
|
|
10032
|
+
const currentPos = current[id];
|
|
10033
|
+
if (!currentPos || currentPos.x !== nextPos.x || currentPos.y !== nextPos.y) {
|
|
10034
|
+
return true;
|
|
10035
|
+
}
|
|
10017
10036
|
}
|
|
10037
|
+
return false;
|
|
10038
|
+
}
|
|
10039
|
+
function sameViewport(a, b) {
|
|
10040
|
+
if (!a && !b) return true;
|
|
10041
|
+
if (!a || !b) return false;
|
|
10042
|
+
return a.x === b.x && a.y === b.y && a.zoom === b.zoom;
|
|
10043
|
+
}
|
|
10044
|
+
function sameIdSet(a, b) {
|
|
10045
|
+
if (a.length !== b.length) return false;
|
|
10046
|
+
const set = new Set(a);
|
|
10047
|
+
for (const id of b) {
|
|
10048
|
+
if (!set.has(id)) return false;
|
|
10049
|
+
}
|
|
10050
|
+
return true;
|
|
10018
10051
|
}
|
|
10019
10052
|
function WorkspaceBootScreen({
|
|
10020
10053
|
boot
|
|
@@ -12029,7 +12062,7 @@ function rafThrottle(fn, minMs = 80) {
|
|
|
12029
12062
|
});
|
|
12030
12063
|
}
|
|
12031
12064
|
var isCommentId = (id) => id.startsWith("c::");
|
|
12032
|
-
function
|
|
12065
|
+
function sameIdSet2(a, b) {
|
|
12033
12066
|
if (a.length !== b.length) return false;
|
|
12034
12067
|
const s = new Set(a);
|
|
12035
12068
|
for (const id of b) if (!s.has(id)) return false;
|
|
@@ -12218,7 +12251,7 @@ function useReactFlowAdapter(api, options = {}) {
|
|
|
12218
12251
|
const next = Array.from(keep);
|
|
12219
12252
|
const currRaw = api.getSelection();
|
|
12220
12253
|
const curr = Array.isArray(currRaw) ? currRaw : Array.from(currRaw);
|
|
12221
|
-
if (!
|
|
12254
|
+
if (!sameIdSet2(next, curr)) {
|
|
12222
12255
|
api.select(keep);
|
|
12223
12256
|
}
|
|
12224
12257
|
}
|
|
@@ -12336,7 +12369,7 @@ function useReactFlowAdapter(api, options = {}) {
|
|
|
12336
12369
|
const next = nodes.map((n) => n.id);
|
|
12337
12370
|
const currRaw = api.getSelection();
|
|
12338
12371
|
const curr = Array.isArray(currRaw) ? currRaw : Array.from(currRaw);
|
|
12339
|
-
if (
|
|
12372
|
+
if (sameIdSet2(next, curr)) return;
|
|
12340
12373
|
api.select(next);
|
|
12341
12374
|
},
|
|
12342
12375
|
[api]
|