@invana/canvas-core 0.0.18 → 0.0.20
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/{index-CZuSgBOJ.d.ts → index-zLHS9XBy.d.ts} +21 -0
- package/dist/index.d.ts +239 -65
- package/dist/index.js +86 -15
- package/dist/index.js.map +1 -1
- package/dist/specs/index.d.ts +1 -1
- package/dist/specs/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5329,7 +5329,7 @@ function defaultCanvasView() {
|
|
|
5329
5329
|
layoutPreset: null,
|
|
5330
5330
|
templates: [],
|
|
5331
5331
|
theme: {},
|
|
5332
|
-
|
|
5332
|
+
toolbars: {}
|
|
5333
5333
|
},
|
|
5334
5334
|
interaction: {
|
|
5335
5335
|
selection: /* @__PURE__ */ new Set(),
|
|
@@ -5521,24 +5521,24 @@ function createActions(view, layer, events) {
|
|
|
5521
5521
|
}),
|
|
5522
5522
|
remove: (id) => v("view:template:remove", (s) => void (s.definition.templates = s.definition.templates.filter((t) => t.id !== id)))
|
|
5523
5523
|
},
|
|
5524
|
-
// ── VIEW ·
|
|
5525
|
-
|
|
5524
|
+
// ── VIEW · toolbars (floating chrome over the canvas) ───────────────
|
|
5525
|
+
toolbars: {
|
|
5526
5526
|
/** Add (or replace) the panel `id`. */
|
|
5527
|
-
add: (id, spec) => v("view:
|
|
5527
|
+
add: (id, spec) => v("view:toolbar:add", (s) => void (s.definition.toolbars[id] = spec)),
|
|
5528
5528
|
/** Shallow-merge `patch` into panel `id` (`items` replaces). No-op when absent. */
|
|
5529
|
-
update: (id, patch) => v("view:
|
|
5530
|
-
const cur = s.definition.
|
|
5531
|
-
if (cur) s.definition.
|
|
5529
|
+
update: (id, patch) => v("view:toolbar:update", (s) => {
|
|
5530
|
+
const cur = s.definition.toolbars[id];
|
|
5531
|
+
if (cur) s.definition.toolbars[id] = { ...cur, ...patch };
|
|
5532
5532
|
}),
|
|
5533
|
-
show: (id) => v("view:
|
|
5534
|
-
const cur = s.definition.
|
|
5535
|
-
if (cur) s.definition.
|
|
5533
|
+
show: (id) => v("view:toolbar:show", (s) => {
|
|
5534
|
+
const cur = s.definition.toolbars[id];
|
|
5535
|
+
if (cur) s.definition.toolbars[id] = { ...cur, visible: true };
|
|
5536
5536
|
}),
|
|
5537
|
-
hide: (id) => v("view:
|
|
5538
|
-
const cur = s.definition.
|
|
5539
|
-
if (cur) s.definition.
|
|
5537
|
+
hide: (id) => v("view:toolbar:hide", (s) => {
|
|
5538
|
+
const cur = s.definition.toolbars[id];
|
|
5539
|
+
if (cur) s.definition.toolbars[id] = { ...cur, visible: false };
|
|
5540
5540
|
}),
|
|
5541
|
-
remove: (id) => v("view:
|
|
5541
|
+
remove: (id) => v("view:toolbar:remove", (s) => void delete s.definition.toolbars[id])
|
|
5542
5542
|
},
|
|
5543
5543
|
// ── VIEW · theme ──────────────────────────────────────────────────────────
|
|
5544
5544
|
theme: {
|
|
@@ -5592,6 +5592,77 @@ function createActions(view, layer, events) {
|
|
|
5592
5592
|
};
|
|
5593
5593
|
}
|
|
5594
5594
|
|
|
5595
|
+
// src/state/view/mergeItems.ts
|
|
5596
|
+
var PLACEMENT = /* @__PURE__ */ new Set(["before", "after"]);
|
|
5597
|
+
function keyOf(entry) {
|
|
5598
|
+
return typeof entry === "string" ? entry : entry.key;
|
|
5599
|
+
}
|
|
5600
|
+
function withoutPlacement(item) {
|
|
5601
|
+
if (!("before" in item) && !("after" in item)) return item;
|
|
5602
|
+
return Object.fromEntries(Object.entries(item).filter(([k]) => !PLACEMENT.has(k)));
|
|
5603
|
+
}
|
|
5604
|
+
function identify(entries) {
|
|
5605
|
+
const seen = /* @__PURE__ */ new Map();
|
|
5606
|
+
return entries.map((entry) => {
|
|
5607
|
+
const key = keyOf(entry);
|
|
5608
|
+
if (key !== void 0) return key;
|
|
5609
|
+
const type = entry.type ?? "";
|
|
5610
|
+
const n2 = seen.get(type) ?? 0;
|
|
5611
|
+
seen.set(type, n2 + 1);
|
|
5612
|
+
return `${type}#${n2}`;
|
|
5613
|
+
});
|
|
5614
|
+
}
|
|
5615
|
+
function place(slots, slot, before, after) {
|
|
5616
|
+
const anchor = before ?? after;
|
|
5617
|
+
const at = anchor === void 0 ? -1 : slots.findIndex((s) => s.id === anchor);
|
|
5618
|
+
if (at < 0) slots.push(slot);
|
|
5619
|
+
else slots.splice(before !== void 0 ? at : at + 1, 0, slot);
|
|
5620
|
+
}
|
|
5621
|
+
function resolveEntry(entry, resolve) {
|
|
5622
|
+
if (typeof entry === "string") return resolve(entry);
|
|
5623
|
+
if (entry.type !== void 0) return entry;
|
|
5624
|
+
const base = resolve(entry.key);
|
|
5625
|
+
return base ? { ...base, ...entry, type: base.type } : void 0;
|
|
5626
|
+
}
|
|
5627
|
+
function mergeItems(defaults, overrides, resolve) {
|
|
5628
|
+
const defaultIds = identify(defaults);
|
|
5629
|
+
const slots = defaults.map((item, i) => ({ id: defaultIds[i], item }));
|
|
5630
|
+
const overrideIds = identify(overrides);
|
|
5631
|
+
overrides.forEach((override, i) => {
|
|
5632
|
+
const id = overrideIds[i];
|
|
5633
|
+
const at = slots.findIndex((s) => s.id === id);
|
|
5634
|
+
const patch = typeof override === "string" ? void 0 : override;
|
|
5635
|
+
if (patch?.hidden === true) {
|
|
5636
|
+
if (at >= 0) slots.splice(at, 1);
|
|
5637
|
+
return;
|
|
5638
|
+
}
|
|
5639
|
+
const before = patch?.before;
|
|
5640
|
+
const after = patch?.after;
|
|
5641
|
+
if (at < 0) {
|
|
5642
|
+
place(slots, { id, item: patch ? withoutPlacement(patch) : override }, before, after);
|
|
5643
|
+
return;
|
|
5644
|
+
}
|
|
5645
|
+
const current = slots[at];
|
|
5646
|
+
const merged = patch ? withoutPlacement(typeof current.item === "string" ? { ...patch, key: current.item } : { ...current.item, ...patch }) : current.item;
|
|
5647
|
+
if (typeof merged !== "string" && typeof current.item !== "string" && merged.type === void 0) {
|
|
5648
|
+
merged.type = current.item.type;
|
|
5649
|
+
}
|
|
5650
|
+
if (before === void 0 && after === void 0) {
|
|
5651
|
+
slots[at] = { id, item: merged };
|
|
5652
|
+
return;
|
|
5653
|
+
}
|
|
5654
|
+
slots.splice(at, 1);
|
|
5655
|
+
place(slots, { id, item: merged }, before, after);
|
|
5656
|
+
});
|
|
5657
|
+
if (!resolve) return slots.map((s) => s.item);
|
|
5658
|
+
const out = [];
|
|
5659
|
+
for (const s of slots) {
|
|
5660
|
+
const item = resolveEntry(s.item, resolve);
|
|
5661
|
+
if (item) out.push(item);
|
|
5662
|
+
}
|
|
5663
|
+
return out;
|
|
5664
|
+
}
|
|
5665
|
+
|
|
5595
5666
|
// src/state/events/CanvasEvent.ts
|
|
5596
5667
|
var CANVAS_SOURCE = { kind: "canvas", id: "canvas" };
|
|
5597
5668
|
|
|
@@ -6270,6 +6341,6 @@ var LayerData = class {
|
|
|
6270
6341
|
}
|
|
6271
6342
|
};
|
|
6272
6343
|
|
|
6273
|
-
export { Behaviour, BehaviourRegistry, CANVAS_SOURCE, Camera, CanvasEventBus, CanvasThemeState, ColumnStore, CommandRegistry, DEFAULT_ENDPOINT_BADGE_GAP_PX, DEFAULT_POSITION_TRANSITION_MS, DefaultGestureArbiter, DirtyBatcher, EASING_NAMES, EventEmitter, HeadlessCameraBinding, HeadlessElementRenderer, HeadlessRenderer, HeadlessSurface, INHERIT, LOOP_CURVE_PRESETS, Layer, LayerData, LayerRegistry, Layout, LayoutRegistry, NODE_FLAG, SourceEmitter, SpecProjector, SpecStore, Tween, animatePositions, attrs, bezierPathStyle, boundaryAnchor, boundsOfArc, boundsOfCircle, boundsOfComposite, boundsOfCompositeRoot, boundsOfEllipse, boundsOfPath, boundsOfPolygon, boundsOfRect, boundsOfRegularPolygon, boundsOfSpec, boundsOfStar, bumpHorizontalPathStyle, bumpRadialPathStyle, bumpVerticalPathStyle, bundlePathStyle, centerAnchor, collapsedSpec, collapsedTabbedRect, compositeRootOffset, connectorGeometryKey, connectorToSvg, containsArc, containsCircle, containsComposite, containsEllipse, containsPath, containsPolygon, containsRect, containsRegularPolygon, containsSpec, containsStar, containsTabbedRect, createActions, defaultCanvasView, defaultEqual, distanceToOutlineSq, distanceToPolylineSq, distanceToSegmentSq, easeInOutCubic, easeInOutSine, easeOutCubic, easeOutQuad, edgePortAnchor, erRouter, esc, fillPaint, fitSpecToContent, fitTabbedRectToContent, hasSilhouetteFill, hexToCss, isInherit, linear, loopCurvePathStyle, loopPolylinePathStyle, manhattanRouter, metroRouter, normalPathStyle, offsetPolygon, oneSideRouter, originToBadgeLocal, orthRouter, pathBounds, pathToSvgD, perpendicularAnchor, pointInPolygon, pointsAttr, polygonBounds, polygonContainsInflated, quadraticPathStyle, rayPolygonIntersection, regularPolygonVertices, resolveBadgePosition, resolveCompositeRoot, resolveConnectorBadgePosition, resolveEasing, resolveLabelScale, resolveThemed, roundedPathStyle, roundedPolygonOutline, samplePath, samplePathAt, scaleArc, scaleCircle, scaleEllipse, scalePath, scalePolygon, scaleRect, scaleRegularPolygon, scaleSpec, scaleStar, scaleTabbedRect, scheduleFlush, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, splinePathStyle, starVertices, stepRadialPathStyle, straightRouter, strokeBandOf, strokePaint, n as svgNum, tabbedRectBounds, tabbedRectFoldLine, tabbedRectGeometry, tabbedRectOutline, tabbedRectTabBox, tabbedRectTabWidth, tangentAt, textContent, trimPathEnds, verticesOfRegularPolygon, verticesOfStar };
|
|
6344
|
+
export { Behaviour, BehaviourRegistry, CANVAS_SOURCE, Camera, CanvasEventBus, CanvasThemeState, ColumnStore, CommandRegistry, DEFAULT_ENDPOINT_BADGE_GAP_PX, DEFAULT_POSITION_TRANSITION_MS, DefaultGestureArbiter, DirtyBatcher, EASING_NAMES, EventEmitter, HeadlessCameraBinding, HeadlessElementRenderer, HeadlessRenderer, HeadlessSurface, INHERIT, LOOP_CURVE_PRESETS, Layer, LayerData, LayerRegistry, Layout, LayoutRegistry, NODE_FLAG, SourceEmitter, SpecProjector, SpecStore, Tween, animatePositions, attrs, bezierPathStyle, boundaryAnchor, boundsOfArc, boundsOfCircle, boundsOfComposite, boundsOfCompositeRoot, boundsOfEllipse, boundsOfPath, boundsOfPolygon, boundsOfRect, boundsOfRegularPolygon, boundsOfSpec, boundsOfStar, bumpHorizontalPathStyle, bumpRadialPathStyle, bumpVerticalPathStyle, bundlePathStyle, centerAnchor, collapsedSpec, collapsedTabbedRect, compositeRootOffset, connectorGeometryKey, connectorToSvg, containsArc, containsCircle, containsComposite, containsEllipse, containsPath, containsPolygon, containsRect, containsRegularPolygon, containsSpec, containsStar, containsTabbedRect, createActions, defaultCanvasView, defaultEqual, distanceToOutlineSq, distanceToPolylineSq, distanceToSegmentSq, easeInOutCubic, easeInOutSine, easeOutCubic, easeOutQuad, edgePortAnchor, erRouter, esc, fillPaint, fitSpecToContent, fitTabbedRectToContent, hasSilhouetteFill, hexToCss, isInherit, linear, loopCurvePathStyle, loopPolylinePathStyle, manhattanRouter, mergeItems, metroRouter, normalPathStyle, offsetPolygon, oneSideRouter, originToBadgeLocal, orthRouter, pathBounds, pathToSvgD, perpendicularAnchor, pointInPolygon, pointsAttr, polygonBounds, polygonContainsInflated, quadraticPathStyle, rayPolygonIntersection, regularPolygonVertices, resolveBadgePosition, resolveCompositeRoot, resolveConnectorBadgePosition, resolveEasing, resolveLabelScale, resolveThemed, roundedPathStyle, roundedPolygonOutline, samplePath, samplePathAt, scaleArc, scaleCircle, scaleEllipse, scalePath, scalePolygon, scaleRect, scaleRegularPolygon, scaleSpec, scaleStar, scaleTabbedRect, scheduleFlush, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, splinePathStyle, starVertices, stepRadialPathStyle, straightRouter, strokeBandOf, strokePaint, n as svgNum, tabbedRectBounds, tabbedRectFoldLine, tabbedRectGeometry, tabbedRectOutline, tabbedRectTabBox, tabbedRectTabWidth, tangentAt, textContent, trimPathEnds, verticesOfRegularPolygon, verticesOfStar };
|
|
6274
6345
|
//# sourceMappingURL=index.js.map
|
|
6275
6346
|
//# sourceMappingURL=index.js.map
|