@invana/canvas-core 0.0.12 → 0.0.13
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.d.ts +60 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -545,6 +545,65 @@ interface ThemeState {
|
|
|
545
545
|
/** Store + broadcast a resolved theme (emits `theme:change`). */
|
|
546
546
|
set(theme: ResolvedTheme): void;
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* The **inherit sentinel** — the value a themed colour option carries to mean
|
|
550
|
+
* *"resolve me from the active theme's palette"* rather than pinning a colour.
|
|
551
|
+
*
|
|
552
|
+
* It exists because a single-tier option has no other way to say it. An option
|
|
553
|
+
* that is simply absent falls back to a hardcoded default; an option holding a
|
|
554
|
+
* colour pins that colour. `'inherit'` is the third state, and it is the one
|
|
555
|
+
* that should usually be the *default*:
|
|
556
|
+
*
|
|
557
|
+
* | Value | Meaning |
|
|
558
|
+
* |---|---|
|
|
559
|
+
* | `'inherit'` | Follow the palette role the surface declares. Recolours on every `theme:change` |
|
|
560
|
+
* | `0x0f172a` / `'#0f172a'` | Pinned by the author. The theme never touches it |
|
|
561
|
+
*
|
|
562
|
+
* **Config vocabulary, never spec vocabulary.** `'inherit'` is legal in a
|
|
563
|
+
* serialisable *option* and is resolved — via {@link resolveThemed} — at the
|
|
564
|
+
* moment a surface paints. It must never reach a renderer spec: the renderer
|
|
565
|
+
* sees numbers, always.
|
|
566
|
+
*
|
|
567
|
+
* Cascading surfaces don't need it. Where a value already resolves through
|
|
568
|
+
* tiers (a graph node's style: layer template → per-type binding → per-node →
|
|
569
|
+
* state), **absence already means inherit**, exactly as in CSS, and the theme
|
|
570
|
+
* belongs in a tier *below* the author rather than in a sentinel.
|
|
571
|
+
*
|
|
572
|
+
* @see rfc:feat-2026-09-11-a-colour-is-either-themed-or-manual-never-both
|
|
573
|
+
*/
|
|
574
|
+
declare const INHERIT = "inherit";
|
|
575
|
+
/** The literal type of {@link INHERIT}. */
|
|
576
|
+
type Inherit = typeof INHERIT;
|
|
577
|
+
/**
|
|
578
|
+
* A themed option: either a concrete value of `T` (pinned by the author) or
|
|
579
|
+
* {@link INHERIT} (resolved from the palette). Resolve with
|
|
580
|
+
* {@link resolveThemed}.
|
|
581
|
+
*/
|
|
582
|
+
type Themed<T> = T | Inherit;
|
|
583
|
+
/** Narrow a themed option to the {@link INHERIT} sentinel. */
|
|
584
|
+
declare function isInherit(value: unknown): value is Inherit;
|
|
585
|
+
/**
|
|
586
|
+
* Resolve a themed colour option against a published palette.
|
|
587
|
+
*
|
|
588
|
+
* A concrete value passes through untouched — an author-set colour always wins
|
|
589
|
+
* over the theme, and keeps winning across theme switches. {@link INHERIT}
|
|
590
|
+
* reads the first of `roles` the palette actually carries, falling back to
|
|
591
|
+
* `fallback` when no theme has been published yet or the palette omits every
|
|
592
|
+
* role (which is what the single-layer `ThemeBehaviour` shorthand's empty
|
|
593
|
+
* palette does).
|
|
594
|
+
*
|
|
595
|
+
* @param value The option as authored — a colour, or {@link INHERIT}.
|
|
596
|
+
* @param palette The active `ResolvedTheme.palette`, or `null` before the first publish.
|
|
597
|
+
* @param roles Role name, or names tried in order (e.g. `['divider', 'stroke']`).
|
|
598
|
+
* @param fallback Used when `value` is `'inherit'` and no role resolves.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* // `backgroundColor` defaults to 'inherit' → follows the theme's `surface`
|
|
603
|
+
* const fill = resolveThemed(opts.backgroundColor, theme?.palette, 'surface', '#f8fafc');
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
declare function resolveThemed<T>(value: Themed<T>, palette: Readonly<Record<string, number>> | null | undefined, roles: string | readonly string[], fallback: T): T | number;
|
|
548
607
|
|
|
549
608
|
/** Who emitted an event. */
|
|
550
609
|
type EventSourceKind = 'canvas' | 'layer' | 'behaviour' | 'layout' | 'store' | 'data';
|
|
@@ -4060,4 +4119,4 @@ interface Selected<U> {
|
|
|
4060
4119
|
*/
|
|
4061
4120
|
declare function select<T, U>(store: ReactiveStore<T>, selector: (state: T) => U, isEqual?: (a: U, b: U) => boolean): Selected<U>;
|
|
4062
4121
|
|
|
4063
|
-
export { type AnnotationRecord, BadgeOptions, BadgePlacement, BaseConnectorSpec, BaseShapeSpec, Behaviour, type BehaviourOptions, BehaviourRegistry, type BehaviourRegistryOptions, CANVAS_SOURCE, Camera, type CameraChangeKind, type CameraInputConfig, type CameraInputModifier, type CameraOptions, type CameraTransform, type CameraTransformValue, type CanvasActions, type CanvasContext, type CanvasEvent, CanvasEventBus, type CanvasGlobalEvents, type CanvasSceneOptions, type CanvasStore, CanvasThemeState, type CanvasView, type ColumnArray, type ColumnSchema, ColumnStore, type ColumnStoreOptions, type ColumnType, type ColumnValue, type CustomElementCtor, DEFAULT_ENDPOINT_BADGE_GAP_PX, DEFAULT_POSITION_TRANSITION_MS, type DataSource, DecorationSpec, type DeepPartial, DefaultGestureArbiter, DirtyBatcher, type DirtySnapshot, EASING_NAMES, type Easing, type EasingName, type EdgeRecord, EffectSpec, ElementEventMap, EventEmitter, EventMap, type EventSource, type EventSourceKind, FlushMode, type FramePhase, type FramePhaseTimings, type FrameStats, type FrameTick, type GestureArbiter, type GestureClaimOptions, type GraphInput, type GroupRecord, HeadlessCameraBinding, HeadlessElementRenderer, HeadlessRenderer, HeadlessSurface, HitResult, IAnchor, type IBehaviour, type ICameraBinding, type IElementRenderer, type ILayer, type IOverlayDevice, IPathStyle, type IRenderer, IRouter, type ISurface, type ISurfaceHost, type IntentLogEntry, type InteractionKind, type KindDelta, LOOP_CURVE_PRESETS, LabelContent, LabelWrap, Layer, LayerData, type LayerFlush, type LayerOptions, LayerRegistry, type LayerRegistryOptions, Layout, type LayoutEndReason, type LayoutEvents, type LayoutOptions, LayoutRegistry, type LayoutRegistryOptions, Listener, type LoopCurvePresetName, type MountedDecoration, NODE_FLAG, type NodeDelta, type NodeRecord, type OverlayFill, type OverlayFillLike, type OverlaySpace, type OverlayStroke, type Patch, Path, type PinchInputOptions, Point, type PosSchema, type PositionTransition, type PositionTransitionOptions, type QueryStatus, type ReactiveStore, type Recipe, Rect, type RenderPreference, type RendererBackend, type RendererCapabilities, type RendererInitOptions, type RendererMountOptions, type ResolvedTheme, type RowOf, type Selected, ShapeFill, ShapeStroke, SourceEmitter, SpecFlush, type SpecProjectionTarget, SpecProjector, type SpecProjectorOptions, SpecStore, type StateCell, type StoreChange, type SurfaceBackdrop, type SurfaceOptions, type SurfaceSpace, type Tap, type TapOptions, type ThemeKind, type ThemeMode, type ThemeState, Tween, type TweenOptions, type Update, Vec2, type WheelInputOptions, animatePositions, attrs, bezierPathStyle, boundaryAnchor, bumpHorizontalPathStyle, bumpRadialPathStyle, bundlePathStyle, centerAnchor, connectorToSvg, createActions, defaultCanvasView, defaultEqual, distanceToPolylineSq, easeInOutCubic, easeInOutSine, easeOutCubic, easeOutQuad, edgePortAnchor, erRouter, esc, fillPaint, hexToCss, linear, loopCurvePathStyle, loopPolylinePathStyle, manhattanRouter, metroRouter, normalPathStyle, oneSideRouter, originToBadgeLocal, orthRouter, pathBounds, pathToSvgD, perpendicularAnchor, pointsAttr, quadraticPathStyle, resolveBadgePosition, resolveConnectorBadgePosition, resolveEasing, roundedPathStyle, samplePath, samplePathAt, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, stepRadialPathStyle, straightRouter, strokePaint, n as svgNum, tangentAt, textContent, trimPathEnds };
|
|
4122
|
+
export { type AnnotationRecord, BadgeOptions, BadgePlacement, BaseConnectorSpec, BaseShapeSpec, Behaviour, type BehaviourOptions, BehaviourRegistry, type BehaviourRegistryOptions, CANVAS_SOURCE, Camera, type CameraChangeKind, type CameraInputConfig, type CameraInputModifier, type CameraOptions, type CameraTransform, type CameraTransformValue, type CanvasActions, type CanvasContext, type CanvasEvent, CanvasEventBus, type CanvasGlobalEvents, type CanvasSceneOptions, type CanvasStore, CanvasThemeState, type CanvasView, type ColumnArray, type ColumnSchema, ColumnStore, type ColumnStoreOptions, type ColumnType, type ColumnValue, type CustomElementCtor, DEFAULT_ENDPOINT_BADGE_GAP_PX, DEFAULT_POSITION_TRANSITION_MS, type DataSource, DecorationSpec, type DeepPartial, DefaultGestureArbiter, DirtyBatcher, type DirtySnapshot, EASING_NAMES, type Easing, type EasingName, type EdgeRecord, EffectSpec, ElementEventMap, EventEmitter, EventMap, type EventSource, type EventSourceKind, FlushMode, type FramePhase, type FramePhaseTimings, type FrameStats, type FrameTick, type GestureArbiter, type GestureClaimOptions, type GraphInput, type GroupRecord, HeadlessCameraBinding, HeadlessElementRenderer, HeadlessRenderer, HeadlessSurface, HitResult, IAnchor, type IBehaviour, type ICameraBinding, type IElementRenderer, type ILayer, INHERIT, type IOverlayDevice, IPathStyle, type IRenderer, IRouter, type ISurface, type ISurfaceHost, type Inherit, type IntentLogEntry, type InteractionKind, type KindDelta, LOOP_CURVE_PRESETS, LabelContent, LabelWrap, Layer, LayerData, type LayerFlush, type LayerOptions, LayerRegistry, type LayerRegistryOptions, Layout, type LayoutEndReason, type LayoutEvents, type LayoutOptions, LayoutRegistry, type LayoutRegistryOptions, Listener, type LoopCurvePresetName, type MountedDecoration, NODE_FLAG, type NodeDelta, type NodeRecord, type OverlayFill, type OverlayFillLike, type OverlaySpace, type OverlayStroke, type Patch, Path, type PinchInputOptions, Point, type PosSchema, type PositionTransition, type PositionTransitionOptions, type QueryStatus, type ReactiveStore, type Recipe, Rect, type RenderPreference, type RendererBackend, type RendererCapabilities, type RendererInitOptions, type RendererMountOptions, type ResolvedTheme, type RowOf, type Selected, ShapeFill, ShapeStroke, SourceEmitter, SpecFlush, type SpecProjectionTarget, SpecProjector, type SpecProjectorOptions, SpecStore, type StateCell, type StoreChange, type SurfaceBackdrop, type SurfaceOptions, type SurfaceSpace, type Tap, type TapOptions, type ThemeKind, type ThemeMode, type ThemeState, type Themed, Tween, type TweenOptions, type Update, Vec2, type WheelInputOptions, animatePositions, attrs, bezierPathStyle, boundaryAnchor, bumpHorizontalPathStyle, bumpRadialPathStyle, bundlePathStyle, centerAnchor, connectorToSvg, createActions, defaultCanvasView, defaultEqual, distanceToPolylineSq, easeInOutCubic, easeInOutSine, easeOutCubic, easeOutQuad, edgePortAnchor, erRouter, esc, fillPaint, hexToCss, isInherit, linear, loopCurvePathStyle, loopPolylinePathStyle, manhattanRouter, metroRouter, normalPathStyle, oneSideRouter, originToBadgeLocal, orthRouter, pathBounds, pathToSvgD, perpendicularAnchor, pointsAttr, quadraticPathStyle, resolveBadgePosition, resolveConnectorBadgePosition, resolveEasing, resolveThemed, roundedPathStyle, samplePath, samplePathAt, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, stepRadialPathStyle, straightRouter, strokePaint, n as svgNum, tangentAt, textContent, trimPathEnds };
|
package/dist/index.js
CHANGED
|
@@ -5041,6 +5041,22 @@ var CanvasThemeState = class {
|
|
|
5041
5041
|
}
|
|
5042
5042
|
};
|
|
5043
5043
|
|
|
5044
|
+
// src/state/theme/types.ts
|
|
5045
|
+
var INHERIT = "inherit";
|
|
5046
|
+
function isInherit(value) {
|
|
5047
|
+
return value === INHERIT;
|
|
5048
|
+
}
|
|
5049
|
+
function resolveThemed(value, palette, roles, fallback) {
|
|
5050
|
+
if (!isInherit(value)) return value;
|
|
5051
|
+
if (palette) {
|
|
5052
|
+
for (const role of typeof roles === "string" ? [roles] : roles) {
|
|
5053
|
+
const resolved = palette[role];
|
|
5054
|
+
if (resolved !== void 0) return resolved;
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
5057
|
+
return fallback;
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5044
5060
|
// src/state/data/ColumnStore.ts
|
|
5045
5061
|
var TYPED_ARRAY_CTOR = {
|
|
5046
5062
|
i8: Int8Array,
|
|
@@ -5630,6 +5646,6 @@ var LayerData = class {
|
|
|
5630
5646
|
}
|
|
5631
5647
|
};
|
|
5632
5648
|
|
|
5633
|
-
export { Behaviour, BehaviourRegistry, CANVAS_SOURCE, Camera, CanvasEventBus, CanvasThemeState, ColumnStore, DEFAULT_ENDPOINT_BADGE_GAP_PX, DEFAULT_POSITION_TRANSITION_MS, DefaultGestureArbiter, DirtyBatcher, EASING_NAMES, EventEmitter, HeadlessCameraBinding, HeadlessElementRenderer, HeadlessRenderer, HeadlessSurface, 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, 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, linear, loopCurvePathStyle, loopPolylinePathStyle, manhattanRouter, metroRouter, normalPathStyle, offsetPolygon, oneSideRouter, originToBadgeLocal, orthRouter, pathBounds, pathToSvgD, perpendicularAnchor, pointInPolygon, pointsAttr, polygonBounds, polygonContainsInflated, quadraticPathStyle, rayPolygonIntersection, regularPolygonVertices, resolveBadgePosition, resolveCompositeRoot, resolveConnectorBadgePosition, resolveEasing, roundedPathStyle, roundedPolygonOutline, samplePath, samplePathAt, scaleArc, scaleCircle, scaleEllipse, scalePath, scalePolygon, scaleRect, scaleRegularPolygon, scaleSpec, scaleStar, scaleTabbedRect, scheduleFlush, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, starVertices, stepRadialPathStyle, straightRouter, strokeBandOf, strokePaint, n as svgNum, tabbedRectBounds, tabbedRectFoldLine, tabbedRectGeometry, tabbedRectOutline, tabbedRectTabBox, tabbedRectTabWidth, tangentAt, textContent, trimPathEnds, verticesOfRegularPolygon, verticesOfStar };
|
|
5649
|
+
export { Behaviour, BehaviourRegistry, CANVAS_SOURCE, Camera, CanvasEventBus, CanvasThemeState, ColumnStore, 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, 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, resolveThemed, roundedPathStyle, roundedPolygonOutline, samplePath, samplePathAt, scaleArc, scaleCircle, scaleEllipse, scalePath, scalePolygon, scaleRect, scaleRegularPolygon, scaleSpec, scaleStar, scaleTabbedRect, scheduleFlush, select, shallowEqual, shapeSpecToSvg, silhouettePortAnchor, smoothPathStyle, starVertices, stepRadialPathStyle, straightRouter, strokeBandOf, strokePaint, n as svgNum, tabbedRectBounds, tabbedRectFoldLine, tabbedRectGeometry, tabbedRectOutline, tabbedRectTabBox, tabbedRectTabWidth, tangentAt, textContent, trimPathEnds, verticesOfRegularPolygon, verticesOfStar };
|
|
5634
5650
|
//# sourceMappingURL=index.js.map
|
|
5635
5651
|
//# sourceMappingURL=index.js.map
|