@weasel-js/labkit 0.7.2 → 0.8.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/LICENSE +21 -0
- package/dist/_dts/{DrawCommand-CEvS5AdV.d.ts → DrawCommand-DACv9lhe.d.ts} +34 -46
- package/dist/{chunk-5XDFILHZ.js → chunk-6V7ROR7G.js} +493 -99
- package/dist/chunk-6V7ROR7G.js.map +1 -0
- package/dist/{chunk-BG6NLMOL.js → chunk-FBZCQXI2.js} +3 -3
- package/dist/{chunk-BG6NLMOL.js.map → chunk-FBZCQXI2.js.map} +1 -1
- package/dist/{chunk-ERZQAU4N.js → chunk-OHGEOTCV.js} +3 -3
- package/dist/{chunk-ERZQAU4N.js.map → chunk-OHGEOTCV.js.map} +1 -1
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/oswald-latin-variable.woff2 +0 -0
- package/dist/index.js +3 -3
- package/dist/passthrough/weasel-canvas.d.ts +1 -1
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +237 -122
- package/dist/passthrough/weasel-ui.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/ui/layers/index.js +3 -3
- package/package.json +3 -2
- package/src/theme/base.less +3 -2
- package/dist/chunk-5XDFILHZ.js.map +0 -1
- package/src/fonts/oswald-latin-variable.woff2 +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s, p } from './chunk-
|
|
1
|
+
import { s, p } from './chunk-FBZCQXI2.js';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -157,5 +157,5 @@ function DragHandleGlyph() {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
export { LayerStack };
|
|
160
|
-
//# sourceMappingURL=chunk-
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-OHGE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,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,IAAA,EAAK,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC9B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,IAAA,EAAK,GAAE,KAAA,EAAM;AAAA,GAAA,EACjC,CAAA;AAEJ","file":"chunk-ERZQAU4N.js","sourcesContent":["import { type CSSProperties, type ReactNode, type RefCallback, useEffect, useState } from 'react';\nimport { dlog, useReorderDragList } from '../../passthrough/weasel-ui';\n\nexport interface LayerStackItem {\n /** Stable id used for keys, onRemove, onReorder. Numeric to match\n * common id-from-nextId conventions; string ids also work. */\n id: number | string;\n /** Short kind label rendered in the header when no primary select\n * is hoisted (e.g. \"shadow\", \"stroke\"). */\n kind: string;\n /** When present, hoist this select into the card header so the user\n * can switch mode/shape without expanding. */\n primaryValue?: string;\n primaryOptions?: string[];\n /** Accent CSS color used as the left border / index-badge fill. */\n accent?: string;\n /** Optional badge text rendered before the primary control\n * (e.g. tail index \"1\", \"2\", \"3\"). When omitted a drag handle\n * glyph renders in its place. */\n badge?: string;\n /** Initial expanded state. Defaults to true for newly-added items. */\n defaultExpanded?: boolean;\n}\n\nexport interface LayerStackProps {\n title: string;\n items: LayerStackItem[];\n /** Kinds the user can add via the header palette. */\n paletteKinds: string[];\n onAdd: (kind: string) => void;\n onRemove: (id: number | string) => void;\n onReorder: (orderedIds: Array<number | string>) => void;\n onPrimaryChange: (id: number | string, nextValue: string) => void;\n /** Render the body controls for each item. */\n renderBody: (item: LayerStackItem) => ReactNode;\n /** Hide the title + palette row (used when an outer wrap renders its\n * own head — see speech-balloons Tails panel). */\n hideHead?: boolean;\n}\n\nexport function LayerStack({\n title,\n items,\n paletteKinds,\n onAdd,\n onRemove,\n onReorder,\n onPrimaryChange,\n renderBody,\n hideHead,\n}: LayerStackProps) {\n const [expandedIds, setExpandedIds] = useState<Set<number | string>>(\n () => new Set(items.filter((i) => i.defaultExpanded !== false).map((i) => i.id)),\n );\n\n useEffect(() => {\n setExpandedIds((prev) => {\n let next: Set<number | string> | null = null;\n for (const item of items) {\n if (item.defaultExpanded === false) continue;\n if (prev.has(item.id)) continue;\n if (next === null) next = new Set(prev);\n next.add(item.id);\n }\n return next ?? prev;\n });\n }, [items]);\n\n const dragItems = items.map((it) => ({ id: String(it.id), label: it.kind }));\n const drag = useReorderDragList({\n items: dragItems,\n selectedIds: [],\n onReorder: (ids, targetIndex) => {\n dlog('layer-stack', 'onReorder', { ids, targetIndex });\n const orig = items.map((i) => i.id);\n const moving = new Set(ids);\n const remaining = orig.filter((id) => !moving.has(String(id)));\n const movedIds = items.map((i) => i.id).filter((id) => moving.has(String(id)));\n // weasel reports targetIndex against the original list (which includes\n // the dragged row). Each moved item that originally sat before\n // targetIndex needs to shift the insertion point left by one.\n const shift = orig.filter((id, idx) => moving.has(String(id)) && idx < targetIndex).length;\n const adjusted = targetIndex - shift;\n const out = [...remaining];\n out.splice(adjusted, 0, ...movedIds);\n onReorder(out);\n },\n });\n\n const toggleExpanded = (id: number | string) => {\n setExpandedIds((s) => {\n const n = new Set(s);\n if (n.has(id)) n.delete(id);\n else n.add(id);\n return n;\n });\n };\n\n return (\n <div className=\"lk-layer-stack\">\n {!hideHead && (\n <div className=\"lk-layer-stack__head\">\n <h2 className=\"lk-layer-stack__title\">{title}</h2>\n <div className=\"lk-layer-stack__palette\">\n {paletteKinds.map((k) => (\n <button\n key={k}\n type=\"button\"\n className=\"lk-layer-stack__add\"\n onClick={() => {\n dlog('layer-stack', 'onAdd', { kind: k });\n onAdd(k);\n }}\n aria-label={`Add ${k}`}\n >\n {k}\n </button>\n ))}\n </div>\n </div>\n )}\n <div\n className=\"lk-layer-stack__list\"\n ref={drag.containerProps.ref as RefCallback<HTMLDivElement>}\n onPointerMove={drag.containerProps.onPointerMove}\n onPointerUp={drag.containerProps.onPointerUp}\n onPointerCancel={drag.containerProps.onPointerCancel}\n >\n {items.map((item, i) => {\n const expanded = expandedIds.has(item.id);\n const draggedId = drag.state.draggedIds?.[0];\n const isDragging = draggedId === String(item.id);\n const showHintBefore = drag.state.targetIndex === i && draggedId !== String(item.id);\n const showHintAfter = drag.state.targetIndex === items.length && i === items.length - 1;\n const cardCls = [\n 'lk-layer-card',\n expanded ? 'is-expanded' : 'is-collapsed',\n isDragging ? 'is-dragging' : '',\n item.accent ? 'has-accent' : '',\n ]\n .filter(Boolean)\n .join(' ');\n const cardStyle = item.accent\n ? ({ '--lk-layer-card-accent': item.accent } as CSSProperties)\n : undefined;\n const { onPointerDown } = drag.rowProps(String(item.id), i);\n return (\n <div key={item.id} className=\"lk-layer-card-wrap\">\n {showHintBefore && <div className=\"lk-layer-stack__drop-hint\" />}\n <div className={cardCls} data-testid={`lk-layer-card-${item.id}`} style={cardStyle}>\n <div className=\"lk-layer-card__head\">\n <button\n type=\"button\"\n className=\"lk-layer-card__handle\"\n aria-label={`Drag to reorder layer ${item.id}`}\n onPointerDown={onPointerDown}\n onClick={() => toggleExpanded(item.id)}\n >\n {item.badge ?? <DragHandleGlyph />}\n </button>\n {item.primaryValue !== undefined && item.primaryOptions ? (\n <select\n className=\"lk-layer-card__primary\"\n value={item.primaryValue}\n aria-label={`Primary select for layer ${item.id}`}\n onChange={(e) => onPrimaryChange(item.id, e.target.value)}\n onClick={(e) => e.stopPropagation()}\n >\n {item.primaryOptions.map((o) => (\n <option key={o} value={o}>\n {o}\n </option>\n ))}\n </select>\n ) : (\n <span className=\"lk-layer-card__kind\">{item.kind}</span>\n )}\n <button\n type=\"button\"\n className=\"lk-layer-card__remove\"\n aria-label=\"Remove layer\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove(item.id);\n }}\n >\n ✕\n </button>\n </div>\n {expanded && <div className=\"lk-layer-card__body\">{renderBody(item)}</div>}\n </div>\n {showHintAfter && <div className=\"lk-layer-stack__drop-hint\" />}\n </div>\n );\n })}\n {items.length === 0 && (\n <div className=\"lk-layer-stack__empty\">No layers — add one above.</div>\n )}\n </div>\n </div>\n );\n}\n\nfunction DragHandleGlyph() {\n return (\n <svg width=\"12\" height=\"16\" viewBox=\"0 0 8 16\" fill=\"currentColor\" aria-hidden=\"true\">\n <circle cx=\"2\" cy=\"3\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"3\" r=\"1.1\" />\n <circle cx=\"2\" cy=\"8\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"8\" r=\"1.1\" />\n <circle cx=\"2\" cy=\"13\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"13\" r=\"1.1\" />\n </svg>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/ui/layers/LayerStack.tsx"],"names":["s"],"mappings":";;;;AAwCO,SAAS,UAAA,CAAW;AAAA,EACzB,KAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,EAAoB;AAClB,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAA;AAAA,IACpC,MAAM,IAAI,GAAA,CAAI,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,eAAA,KAAoB,KAAK,EAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,EAAE,CAAC;AAAA,GACjF;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS;AACvB,MAAA,IAAI,IAAA,GAAoC,IAAA;AACx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AAK,EA6Cf,CAAA;AAAA,UAEJ,CAAC,CAAA;AAAA,UACA,MAAM,MAAA,KAAW,CAAA,wBACf,KAAA,EAAA,EAAI,SAAA,EAAU,yBAAwB,QAAA,EAAA,iCAAA,EAA0B;AAAA;AAAA;AAAA;AAErE,GAAA,EACF,CAAA;AAEJ;AAEA,SAAS,eAAA,GAAkB;AACzB,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAM,IAAA,EAAK,MAAA,EAAO,IAAA,EAAK,OAAA,EAAQ,UAAA,EAAW,IAAA,EAAK,cAAA,EAAe,aAAA,EAAY,MAAA,EAC7E,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,YAAO,EAAA,EAAG,GAAA,EAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC7B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,IAAA,EAAK,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC9B,QAAA,EAAA,EAAO,EAAA,EAAG,KAAI,EAAA,EAAG,IAAA,EAAK,GAAE,KAAA,EAAM;AAAA,GAAA,EACjC,CAAA;AAEJ","file":"chunk-OHGEOTCV.js","sourcesContent":["import { type CSSProperties, type ReactNode, type RefCallback, useEffect, useState } from 'react';\nimport { dlog, useReorderDragList } from '../../passthrough/weasel-ui';\n\nexport interface LayerStackItem {\n /** Stable id used for keys, onRemove, onReorder. Numeric to match\n * common id-from-nextId conventions; string ids also work. */\n id: number | string;\n /** Short kind label rendered in the header when no primary select\n * is hoisted (e.g. \"shadow\", \"stroke\"). */\n kind: string;\n /** When present, hoist this select into the card header so the user\n * can switch mode/shape without expanding. */\n primaryValue?: string;\n primaryOptions?: string[];\n /** Accent CSS color used as the left border / index-badge fill. */\n accent?: string;\n /** Optional badge text rendered before the primary control\n * (e.g. tail index \"1\", \"2\", \"3\"). When omitted a drag handle\n * glyph renders in its place. */\n badge?: string;\n /** Initial expanded state. Defaults to true for newly-added items. */\n defaultExpanded?: boolean;\n}\n\nexport interface LayerStackProps {\n title: string;\n items: LayerStackItem[];\n /** Kinds the user can add via the header palette. */\n paletteKinds: string[];\n onAdd: (kind: string) => void;\n onRemove: (id: number | string) => void;\n onReorder: (orderedIds: Array<number | string>) => void;\n onPrimaryChange: (id: number | string, nextValue: string) => void;\n /** Render the body controls for each item. */\n renderBody: (item: LayerStackItem) => ReactNode;\n /** Hide the title + palette row (used when an outer wrap renders its\n * own head — see speech-balloons Tails panel). */\n hideHead?: boolean;\n}\n\nexport function LayerStack({\n title,\n items,\n paletteKinds,\n onAdd,\n onRemove,\n onReorder,\n onPrimaryChange,\n renderBody,\n hideHead,\n}: LayerStackProps) {\n const [expandedIds, setExpandedIds] = useState<Set<number | string>>(\n () => new Set(items.filter((i) => i.defaultExpanded !== false).map((i) => i.id)),\n );\n\n useEffect(() => {\n setExpandedIds((prev) => {\n let next: Set<number | string> | null = null;\n for (const item of items) {\n if (item.defaultExpanded === false) continue;\n if (prev.has(item.id)) continue;\n if (next === null) next = new Set(prev);\n next.add(item.id);\n }\n return next ?? prev;\n });\n }, [items]);\n\n const dragItems = items.map((it) => ({ id: String(it.id), label: it.kind }));\n const drag = useReorderDragList({\n items: dragItems,\n selectedIds: [],\n onReorder: (ids, targetIndex) => {\n dlog('layer-stack', 'onReorder', { ids, targetIndex });\n const orig = items.map((i) => i.id);\n const moving = new Set(ids);\n const remaining = orig.filter((id) => !moving.has(String(id)));\n const movedIds = items.map((i) => i.id).filter((id) => moving.has(String(id)));\n // weasel reports targetIndex against the original list (which includes\n // the dragged row). Each moved item that originally sat before\n // targetIndex needs to shift the insertion point left by one.\n const shift = orig.filter((id, idx) => moving.has(String(id)) && idx < targetIndex).length;\n const adjusted = targetIndex - shift;\n const out = [...remaining];\n out.splice(adjusted, 0, ...movedIds);\n onReorder(out);\n },\n });\n\n const toggleExpanded = (id: number | string) => {\n setExpandedIds((s) => {\n const n = new Set(s);\n if (n.has(id)) n.delete(id);\n else n.add(id);\n return n;\n });\n };\n\n return (\n <div className=\"lk-layer-stack\">\n {!hideHead && (\n <div className=\"lk-layer-stack__head\">\n <h2 className=\"lk-layer-stack__title\">{title}</h2>\n <div className=\"lk-layer-stack__palette\">\n {paletteKinds.map((k) => (\n <button\n key={k}\n type=\"button\"\n className=\"lk-layer-stack__add\"\n onClick={() => {\n dlog('layer-stack', 'onAdd', { kind: k });\n onAdd(k);\n }}\n aria-label={`Add ${k}`}\n >\n {k}\n </button>\n ))}\n </div>\n </div>\n )}\n <div\n className=\"lk-layer-stack__list\"\n ref={drag.containerProps.ref as RefCallback<HTMLDivElement>}\n onPointerMove={drag.containerProps.onPointerMove}\n onPointerUp={drag.containerProps.onPointerUp}\n onPointerCancel={drag.containerProps.onPointerCancel}\n >\n {items.map((item, i) => {\n const expanded = expandedIds.has(item.id);\n const draggedId = drag.state.draggedIds?.[0];\n const isDragging = draggedId === String(item.id);\n const showHintBefore = drag.state.targetIndex === i && draggedId !== String(item.id);\n const showHintAfter = drag.state.targetIndex === items.length && i === items.length - 1;\n const cardCls = [\n 'lk-layer-card',\n expanded ? 'is-expanded' : 'is-collapsed',\n isDragging ? 'is-dragging' : '',\n item.accent ? 'has-accent' : '',\n ]\n .filter(Boolean)\n .join(' ');\n const cardStyle = item.accent\n ? ({ '--lk-layer-card-accent': item.accent } as CSSProperties)\n : undefined;\n const { onPointerDown } = drag.rowProps(String(item.id), i);\n return (\n <div key={item.id} className=\"lk-layer-card-wrap\">\n {showHintBefore && <div className=\"lk-layer-stack__drop-hint\" />}\n <div className={cardCls} data-testid={`lk-layer-card-${item.id}`} style={cardStyle}>\n <div className=\"lk-layer-card__head\">\n <button\n type=\"button\"\n className=\"lk-layer-card__handle\"\n aria-label={`Drag to reorder layer ${item.id}`}\n onPointerDown={onPointerDown}\n onClick={() => toggleExpanded(item.id)}\n >\n {item.badge ?? <DragHandleGlyph />}\n </button>\n {item.primaryValue !== undefined && item.primaryOptions ? (\n <select\n className=\"lk-layer-card__primary\"\n value={item.primaryValue}\n aria-label={`Primary select for layer ${item.id}`}\n onChange={(e) => onPrimaryChange(item.id, e.target.value)}\n onClick={(e) => e.stopPropagation()}\n >\n {item.primaryOptions.map((o) => (\n <option key={o} value={o}>\n {o}\n </option>\n ))}\n </select>\n ) : (\n <span className=\"lk-layer-card__kind\">{item.kind}</span>\n )}\n <button\n type=\"button\"\n className=\"lk-layer-card__remove\"\n aria-label=\"Remove layer\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove(item.id);\n }}\n >\n ✕\n </button>\n </div>\n {expanded && <div className=\"lk-layer-card__body\">{renderBody(item)}</div>}\n </div>\n {showHintAfter && <div className=\"lk-layer-stack__drop-hint\" />}\n </div>\n );\n })}\n {items.length === 0 && (\n <div className=\"lk-layer-stack__empty\">No layers — add one above.</div>\n )}\n </div>\n </div>\n );\n}\n\nfunction DragHandleGlyph() {\n return (\n <svg width=\"12\" height=\"16\" viewBox=\"0 0 8 16\" fill=\"currentColor\" aria-hidden=\"true\">\n <circle cx=\"2\" cy=\"3\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"3\" r=\"1.1\" />\n <circle cx=\"2\" cy=\"8\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"8\" r=\"1.1\" />\n <circle cx=\"2\" cy=\"13\" r=\"1.1\" />\n <circle cx=\"6\" cy=\"13\" r=\"1.1\" />\n </svg>\n );\n}\n"]}
|
|
Binary file
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { LayerStack } from './chunk-
|
|
2
|
-
import { p, F } from './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { LayerStack } from './chunk-OHGEOTCV.js';
|
|
2
|
+
import { p, F } from './chunk-FBZCQXI2.js';
|
|
3
|
+
import './chunk-6V7ROR7G.js';
|
|
4
4
|
import { Sidebar, StatusBar, Toolbar } from './chunk-HXZHVU4G.js';
|
|
5
5
|
export { FpsMeter, ScaleIndicator, Sidebar, StatusBar, Toolbar } from './chunk-HXZHVU4G.js';
|
|
6
6
|
import { LabStoreContext, createLabStore, noneAdapter } from './chunk-SSMHPMDV.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Ref } from 'react';
|
|
3
|
-
import { N as Node, V as View, D as DrawCommand, S as Scene, B as Bounds, a as ViewportDims, P as PathDrawCommand } from '../_dts/DrawCommand-
|
|
3
|
+
import { N as Node, V as View, D as DrawCommand, S as Scene, B as Bounds, a as ViewportDims, P as PathDrawCommand } from '../_dts/DrawCommand-DACv9lhe.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `renderSceneToCanvas` — substrate for detached, read-only scene views
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { FALLBACK_FIT_VIEW, MinimapCanvas, SceneViewCanvas, buildSceneViewCommands, computeFitView2 as computeFitView, computeIndicatorCommand, renderSceneToCanvas } from '../chunk-
|
|
1
|
+
export { FALLBACK_FIT_VIEW, MinimapCanvas, SceneViewCanvas, buildSceneViewCommands, computeFitView2 as computeFitView, computeIndicatorCommand, renderSceneToCanvas } from '../chunk-6V7ROR7G.js';
|
|
2
2
|
//# sourceMappingURL=weasel-canvas.js.map
|
|
3
3
|
//# sourceMappingURL=weasel-canvas.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, CSSProperties, ButtonHTMLAttributes, ReactElement, MutableRefObject, PointerEvent as PointerEvent$1, KeyboardEvent, RefCallback } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { V as View, D as DrawCommand, O as Op, b as NodeId, c as Path, S as Scene, H as History, B as Bounds } from '../_dts/DrawCommand-DACv9lhe.js';
|
|
5
5
|
import { TextFieldProps, ValidationResult, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, NumberFieldProps as NumberFieldProps$1, SelectProps as SelectProps$1, ListBoxItemProps, ComboBoxProps as ComboBoxProps$1, SliderProps as SliderProps$1, ModalOverlayProps, DialogProps as DialogProps$1 } from 'react-aria-components';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1124,6 +1124,156 @@ interface PowerlineProps {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
declare function Powerline({ segments, startCap, size, variant, depth, gap, className, ...rest }: PowerlineProps): react_jsx_runtime.JSX.Element;
|
|
1126
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* Snapshot of modifier-key state at gesture dispatch.
|
|
1129
|
+
*
|
|
1130
|
+
* Lives in core rather than beside the gesture types that produce it because
|
|
1131
|
+
* `core/selection/chromeState.ts` reads it, and core may not import from
|
|
1132
|
+
* `interactions/`. Re-exported from `interactions/gestures/types.ts`, which
|
|
1133
|
+
* is still where gesture code names it.
|
|
1134
|
+
*/
|
|
1135
|
+
interface ModifierState {
|
|
1136
|
+
alt: boolean;
|
|
1137
|
+
shift: boolean;
|
|
1138
|
+
meta: boolean;
|
|
1139
|
+
ctrl: boolean;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* @experimental
|
|
1144
|
+
* Result of an affordance hit — what the region computed about itself.
|
|
1145
|
+
*
|
|
1146
|
+
* `initialScratch` is the payload: what the region already knows (which
|
|
1147
|
+
* corner, which target id) so the action that picks up the drag doesn't
|
|
1148
|
+
* re-derive it. `<SceneCanvas>` reads it out of the layer hit-test and packs
|
|
1149
|
+
* it into `AffordanceHit`, which flows to the matching action through
|
|
1150
|
+
* `InvocationCtx.drag.affordance`.
|
|
1151
|
+
*
|
|
1152
|
+
* This used to also carry a `drag: DragChannel` naming the handlers the
|
|
1153
|
+
* tool-routing dispatcher should wire up. Every implementation supplied a
|
|
1154
|
+
* no-op stub that claimed, because the real routing had already moved to
|
|
1155
|
+
* bindings; the field went with that dispatcher.
|
|
1156
|
+
*/
|
|
1157
|
+
interface AffordanceBinding<TScratch = unknown> {
|
|
1158
|
+
initialScratch?: TScratch;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Canvas size in CSS pixels — passed to `draw` for layers that anchor to
|
|
1163
|
+
* canvas edges (e.g. the debug overlay's layer-list panel). The GL backend
|
|
1164
|
+
* supplies it explicitly so layers don't have to know about DPR.
|
|
1165
|
+
*/
|
|
1166
|
+
interface Dims {
|
|
1167
|
+
width: number;
|
|
1168
|
+
height: number;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* A single named render sub-layer within a canvas renderer.
|
|
1172
|
+
*
|
|
1173
|
+
* @template TData - The data object passed to each draw call.
|
|
1174
|
+
*/
|
|
1175
|
+
interface RenderLayer<TData> {
|
|
1176
|
+
/** Unique identifier used in visibility maps and ordering arrays. */
|
|
1177
|
+
id: string;
|
|
1178
|
+
/** Human-readable name for UI toggles. */
|
|
1179
|
+
label: string;
|
|
1180
|
+
/**
|
|
1181
|
+
* Emit a DrawCommand tree for the GL backend to dispatch.
|
|
1182
|
+
*
|
|
1183
|
+
* For world-space layers (the default), emit commands in WORLD COORDS —
|
|
1184
|
+
* `drawLayers` automatically wraps them in `{ kind: 'group', transform:
|
|
1185
|
+
* viewToMat3(view), ... }` before handing them to the renderer. Do NOT
|
|
1186
|
+
* apply the view transform yourself.
|
|
1187
|
+
*
|
|
1188
|
+
* For screen-space layers (`space: 'screen'`), emit commands in CSS-pixel
|
|
1189
|
+
* coords directly; `drawLayers` passes them through unchanged. If part
|
|
1190
|
+
* of a screen-space layer's output needs to track the view, wrap that
|
|
1191
|
+
* subset manually with `viewToMat3(view)`.
|
|
1192
|
+
*/
|
|
1193
|
+
draw: (data: TData, view: View, dims: Dims) => DrawCommand[];
|
|
1194
|
+
/**
|
|
1195
|
+
* Whether the layer is shown when no explicit visibility entry exists.
|
|
1196
|
+
* Defaults to `true` when absent.
|
|
1197
|
+
*/
|
|
1198
|
+
defaultVisible?: boolean;
|
|
1199
|
+
/**
|
|
1200
|
+
* When true, the layer is always drawn regardless of the visibility map.
|
|
1201
|
+
* Useful for layers that must never be hidden (e.g. base grid).
|
|
1202
|
+
*/
|
|
1203
|
+
alwaysOn?: boolean;
|
|
1204
|
+
/**
|
|
1205
|
+
* Coordinate space the layer draws in.
|
|
1206
|
+
*
|
|
1207
|
+
* - `'world'` (default): the layer's `draw` returns world-space commands;
|
|
1208
|
+
* `drawLayers` wraps them in a `kind: 'group'` with `viewToMat3(view)`
|
|
1209
|
+
* automatically.
|
|
1210
|
+
* - `'screen'`: the layer's `draw` returns screen-space (CSS-pixel)
|
|
1211
|
+
* commands; `drawLayers` passes them through unchanged. World-anchored
|
|
1212
|
+
* chrome inside a screen-space layer must call `worldToScreen` or wrap
|
|
1213
|
+
* the relevant subset with `viewToMat3(view)` manually.
|
|
1214
|
+
*/
|
|
1215
|
+
space?: 'world' | 'screen';
|
|
1216
|
+
/**
|
|
1217
|
+
* Optional hit-test for **consumer-attached** layers.
|
|
1218
|
+
*
|
|
1219
|
+
* Only layers registered through `CanvasExtensionApi.registerLayer` are
|
|
1220
|
+
* hit-tested: `hitTestExtras` walks them last-registered-first on
|
|
1221
|
+
* pointerdown, and `<SceneCanvas>` folds the result into its `affordanceAt`
|
|
1222
|
+
* thunk ahead of the kit's own selection chrome. First non-null result
|
|
1223
|
+
* wins; null means "I don't claim this hit, try the next layer."
|
|
1224
|
+
*
|
|
1225
|
+
* Layers that reach the draw stack some other way — a `Tool.overlay`, an
|
|
1226
|
+
* entry in the `layers` map — are painted but never hit-tested, so defining
|
|
1227
|
+
* `hitTest` on one has no effect. (The kit's own chrome doesn't need it: it
|
|
1228
|
+
* goes through `buildAffordanceAt`.)
|
|
1229
|
+
*
|
|
1230
|
+
* Coordinates are world-space. The `data` arg is the layer's
|
|
1231
|
+
* configured data slot (same as `draw`); `view` and `dims` mirror
|
|
1232
|
+
* `draw`'s arguments.
|
|
1233
|
+
*/
|
|
1234
|
+
hitTest?: (worldX: number, worldY: number, data: TData, view: View, dims: Dims,
|
|
1235
|
+
/** Chrome-caps visibility predicate. When supplied, the layer must
|
|
1236
|
+
* not return a hit from any chrome element whose id reports
|
|
1237
|
+
* `false`. Absent → every element is hittable. */
|
|
1238
|
+
isVisible?: (id: string) => boolean) => AffordanceBinding | null;
|
|
1239
|
+
/**
|
|
1240
|
+
* Called on every pointermove when no gesture is currently captured.
|
|
1241
|
+
* Lets layers (e.g. HUD widgets) track hover state without participating
|
|
1242
|
+
* in the drag pipeline. Coords are world-space; the layer is responsible
|
|
1243
|
+
* for any further conversion (e.g. world→screen for screen-space layers)
|
|
1244
|
+
* and for its own throttling.
|
|
1245
|
+
*/
|
|
1246
|
+
onUncapturedMove?: (worldX: number, worldY: number, evt: PointerEvent, view: View, dims: Dims) => void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Called when the cursor leaves the canvas element. Lets layers clear
|
|
1249
|
+
* any hover state they're holding.
|
|
1250
|
+
*/
|
|
1251
|
+
onUncapturedLeave?: () => void;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Facts about the device the canvas is running on.
|
|
1256
|
+
*
|
|
1257
|
+
* One object, recomputed when the underlying media queries change, read by
|
|
1258
|
+
* two consumers: the chrome-caps rule layer (via `RuleCtx.device`) and the
|
|
1259
|
+
* handle-sizing constants (via `targetScale`).
|
|
1260
|
+
*
|
|
1261
|
+
* Deliberately NOT a form-factor concept. There is no `isPhone` here and
|
|
1262
|
+
* there should never be one: chrome layout is the consuming app's decision.
|
|
1263
|
+
* The kit's job is to stop assuming a mouse.
|
|
1264
|
+
*/
|
|
1265
|
+
interface DeviceProfile {
|
|
1266
|
+
/** `matchMedia('(pointer: coarse)')` — the primary pointer is imprecise. */
|
|
1267
|
+
readonly coarsePointer: boolean;
|
|
1268
|
+
/** `matchMedia('(hover: hover)')` — the primary pointer can hover. */
|
|
1269
|
+
readonly canHover: boolean;
|
|
1270
|
+
/** Live device pixel ratio. */
|
|
1271
|
+
readonly dpr: number;
|
|
1272
|
+
/** Multiplier for handle sizes and hit radii. Derived from
|
|
1273
|
+
* `coarsePointer` unless explicitly overridden. */
|
|
1274
|
+
readonly targetScale: number;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1127
1277
|
type ContainerBounds = {
|
|
1128
1278
|
x: number;
|
|
1129
1279
|
y: number;
|
|
@@ -1309,13 +1459,6 @@ interface InsertAdapter<TNode extends {
|
|
|
1309
1459
|
getSelection(): string[];
|
|
1310
1460
|
}
|
|
1311
1461
|
|
|
1312
|
-
/** Snapshot of modifier-key state at gesture dispatch. */
|
|
1313
|
-
interface ModifierState {
|
|
1314
|
-
alt: boolean;
|
|
1315
|
-
shift: boolean;
|
|
1316
|
-
meta: boolean;
|
|
1317
|
-
ctrl: boolean;
|
|
1318
|
-
}
|
|
1319
1462
|
/** Pointer position in both world and client coords. */
|
|
1320
1463
|
interface PointerState {
|
|
1321
1464
|
worldX: number;
|
|
@@ -1430,118 +1573,6 @@ interface PointSnapBehavior<TPose extends ResizePose> {
|
|
|
1430
1573
|
onMove(ctx: PointSnapContext<TPose>): PointSnapResult | null | undefined;
|
|
1431
1574
|
}
|
|
1432
1575
|
|
|
1433
|
-
/**
|
|
1434
|
-
* @experimental
|
|
1435
|
-
* Result of an affordance hit — what the region computed about itself.
|
|
1436
|
-
*
|
|
1437
|
-
* `initialScratch` is the payload: what the region already knows (which
|
|
1438
|
-
* corner, which target id) so the action that picks up the drag doesn't
|
|
1439
|
-
* re-derive it. `<SceneCanvas>` reads it out of the layer hit-test and packs
|
|
1440
|
-
* it into `AffordanceHit`, which flows to the matching action through
|
|
1441
|
-
* `InvocationCtx.drag.affordance`.
|
|
1442
|
-
*
|
|
1443
|
-
* This used to also carry a `drag: DragChannel` naming the handlers the
|
|
1444
|
-
* tool-routing dispatcher should wire up. Every implementation supplied a
|
|
1445
|
-
* no-op stub that claimed, because the real routing had already moved to
|
|
1446
|
-
* bindings; the field went with that dispatcher.
|
|
1447
|
-
*/
|
|
1448
|
-
interface AffordanceBinding<TScratch = unknown> {
|
|
1449
|
-
initialScratch?: TScratch;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
* Canvas size in CSS pixels — passed to `draw` for layers that anchor to
|
|
1454
|
-
* canvas edges (e.g. the debug overlay's layer-list panel). The GL backend
|
|
1455
|
-
* supplies it explicitly so layers don't have to know about DPR.
|
|
1456
|
-
*/
|
|
1457
|
-
interface Dims {
|
|
1458
|
-
width: number;
|
|
1459
|
-
height: number;
|
|
1460
|
-
}
|
|
1461
|
-
/**
|
|
1462
|
-
* A single named render sub-layer within a canvas renderer.
|
|
1463
|
-
*
|
|
1464
|
-
* @template TData - The data object passed to each draw call.
|
|
1465
|
-
*/
|
|
1466
|
-
interface RenderLayer<TData> {
|
|
1467
|
-
/** Unique identifier used in visibility maps and ordering arrays. */
|
|
1468
|
-
id: string;
|
|
1469
|
-
/** Human-readable name for UI toggles. */
|
|
1470
|
-
label: string;
|
|
1471
|
-
/**
|
|
1472
|
-
* Emit a DrawCommand tree for the GL backend to dispatch.
|
|
1473
|
-
*
|
|
1474
|
-
* For world-space layers (the default), emit commands in WORLD COORDS —
|
|
1475
|
-
* `drawLayers` automatically wraps them in `{ kind: 'group', transform:
|
|
1476
|
-
* viewToMat3(view), ... }` before handing them to the renderer. Do NOT
|
|
1477
|
-
* apply the view transform yourself.
|
|
1478
|
-
*
|
|
1479
|
-
* For screen-space layers (`space: 'screen'`), emit commands in CSS-pixel
|
|
1480
|
-
* coords directly; `drawLayers` passes them through unchanged. If part
|
|
1481
|
-
* of a screen-space layer's output needs to track the view, wrap that
|
|
1482
|
-
* subset manually with `viewToMat3(view)`.
|
|
1483
|
-
*/
|
|
1484
|
-
draw: (data: TData, view: View, dims: Dims) => DrawCommand[];
|
|
1485
|
-
/**
|
|
1486
|
-
* Whether the layer is shown when no explicit visibility entry exists.
|
|
1487
|
-
* Defaults to `true` when absent.
|
|
1488
|
-
*/
|
|
1489
|
-
defaultVisible?: boolean;
|
|
1490
|
-
/**
|
|
1491
|
-
* When true, the layer is always drawn regardless of the visibility map.
|
|
1492
|
-
* Useful for layers that must never be hidden (e.g. base grid).
|
|
1493
|
-
*/
|
|
1494
|
-
alwaysOn?: boolean;
|
|
1495
|
-
/**
|
|
1496
|
-
* Coordinate space the layer draws in.
|
|
1497
|
-
*
|
|
1498
|
-
* - `'world'` (default): the layer's `draw` returns world-space commands;
|
|
1499
|
-
* `drawLayers` wraps them in a `kind: 'group'` with `viewToMat3(view)`
|
|
1500
|
-
* automatically.
|
|
1501
|
-
* - `'screen'`: the layer's `draw` returns screen-space (CSS-pixel)
|
|
1502
|
-
* commands; `drawLayers` passes them through unchanged. World-anchored
|
|
1503
|
-
* chrome inside a screen-space layer must call `worldToScreen` or wrap
|
|
1504
|
-
* the relevant subset with `viewToMat3(view)` manually.
|
|
1505
|
-
*/
|
|
1506
|
-
space?: 'world' | 'screen';
|
|
1507
|
-
/**
|
|
1508
|
-
* Optional hit-test for **consumer-attached** layers.
|
|
1509
|
-
*
|
|
1510
|
-
* Only layers registered through `CanvasExtensionApi.registerLayer` are
|
|
1511
|
-
* hit-tested: `hitTestExtras` walks them last-registered-first on
|
|
1512
|
-
* pointerdown, and `<SceneCanvas>` folds the result into its `affordanceAt`
|
|
1513
|
-
* thunk ahead of the kit's own selection chrome. First non-null result
|
|
1514
|
-
* wins; null means "I don't claim this hit, try the next layer."
|
|
1515
|
-
*
|
|
1516
|
-
* Layers that reach the draw stack some other way — a `Tool.overlay`, an
|
|
1517
|
-
* entry in the `layers` map — are painted but never hit-tested, so defining
|
|
1518
|
-
* `hitTest` on one has no effect. (The kit's own chrome doesn't need it: it
|
|
1519
|
-
* goes through `buildAffordanceAt`.)
|
|
1520
|
-
*
|
|
1521
|
-
* Coordinates are world-space. The `data` arg is the layer's
|
|
1522
|
-
* configured data slot (same as `draw`); `view` and `dims` mirror
|
|
1523
|
-
* `draw`'s arguments.
|
|
1524
|
-
*/
|
|
1525
|
-
hitTest?: (worldX: number, worldY: number, data: TData, view: View, dims: Dims,
|
|
1526
|
-
/** Chrome-caps visibility predicate. When supplied, the layer must
|
|
1527
|
-
* not return a hit from any chrome element whose id reports
|
|
1528
|
-
* `false`. Absent → every element is hittable. */
|
|
1529
|
-
isVisible?: (id: string) => boolean) => AffordanceBinding | null;
|
|
1530
|
-
/**
|
|
1531
|
-
* Called on every pointermove when no gesture is currently captured.
|
|
1532
|
-
* Lets layers (e.g. HUD widgets) track hover state without participating
|
|
1533
|
-
* in the drag pipeline. Coords are world-space; the layer is responsible
|
|
1534
|
-
* for any further conversion (e.g. world→screen for screen-space layers)
|
|
1535
|
-
* and for its own throttling.
|
|
1536
|
-
*/
|
|
1537
|
-
onUncapturedMove?: (worldX: number, worldY: number, evt: PointerEvent, view: View, dims: Dims) => void;
|
|
1538
|
-
/**
|
|
1539
|
-
* Called when the cursor leaves the canvas element. Lets layers clear
|
|
1540
|
-
* any hover state they're holding.
|
|
1541
|
-
*/
|
|
1542
|
-
onUncapturedLeave?: () => void;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
1576
|
/** The full vocabulary of capability tags shipped in the default preset.
|
|
1546
1577
|
* Apps and other consumers can add their own tags; this list is what
|
|
1547
1578
|
* `weasel-modes` itself uses. */
|
|
@@ -1625,6 +1656,13 @@ interface RuleCtx {
|
|
|
1625
1656
|
* with nothing being edited should draw no anchors. Absent is treated
|
|
1626
1657
|
* as false. */
|
|
1627
1658
|
readonly editingAnchors?: boolean;
|
|
1659
|
+
/** Device facts — pointer coarseness, hover capability, density.
|
|
1660
|
+
*
|
|
1661
|
+
* Absent (legacy ctx builders) is treated as
|
|
1662
|
+
* {@link DEFAULT_DEVICE_PROFILE}: a fine pointer that can hover, at
|
|
1663
|
+
* density 1. That is what the kit assumed before this field existed, so
|
|
1664
|
+
* an absent profile is behavior-preserving by construction. */
|
|
1665
|
+
readonly device?: DeviceProfile;
|
|
1628
1666
|
}
|
|
1629
1667
|
|
|
1630
1668
|
/**
|
|
@@ -1661,6 +1699,12 @@ interface Selector {
|
|
|
1661
1699
|
* (resizable), so `{ resizable: true }` passes for legacy ctx builders
|
|
1662
1700
|
* that don't compute it. */
|
|
1663
1701
|
resizable?: boolean;
|
|
1702
|
+
/** Matches `ctx.device.coarsePointer` — the primary pointer is imprecise
|
|
1703
|
+
* (touch, most styluses). Absent device is treated as `false`. */
|
|
1704
|
+
coarsePointer?: boolean;
|
|
1705
|
+
/** Matches `ctx.device.canHover` — the primary pointer can hover. Absent
|
|
1706
|
+
* device is treated as `true`. */
|
|
1707
|
+
canHover?: boolean;
|
|
1664
1708
|
}
|
|
1665
1709
|
/**
|
|
1666
1710
|
* Composable visibility/eligibility rule. Trees of `all`/`any`/`not` nodes
|
|
@@ -1893,6 +1937,24 @@ interface PointerDownSpec {
|
|
|
1893
1937
|
mods?: ModSpec;
|
|
1894
1938
|
phase?: PhaseSpec;
|
|
1895
1939
|
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Press held past the long-press threshold without crossing the drag
|
|
1942
|
+
* threshold. Synthesized by `useGestureDispatcher` from the pointer stream.
|
|
1943
|
+
*
|
|
1944
|
+
* Fires for `touch` and `pen` pointers only. A mouse held still for half a
|
|
1945
|
+
* second is an ordinary slow click, and firing on it would produce a context
|
|
1946
|
+
* menu nobody asked for.
|
|
1947
|
+
*
|
|
1948
|
+
* When a long-press matches no binding, the dispatcher re-dispatches it as a
|
|
1949
|
+
* `contextmenu` event — so `contextMenu` bindings work under a finger with no
|
|
1950
|
+
* consumer changes, while `longPress` stays independently bindable.
|
|
1951
|
+
*/
|
|
1952
|
+
interface LongPressSpec {
|
|
1953
|
+
kind: 'longPress';
|
|
1954
|
+
target?: TargetSpec;
|
|
1955
|
+
mods?: ModSpec;
|
|
1956
|
+
phase?: PhaseSpec;
|
|
1957
|
+
}
|
|
1896
1958
|
/** Multi-touch gesture. `fingers` is the required touch count. */
|
|
1897
1959
|
interface MultiTouchSpec {
|
|
1898
1960
|
kind: 'multiTouch';
|
|
@@ -1927,9 +1989,9 @@ interface PasteSpec {
|
|
|
1927
1989
|
phase?: PhaseSpec;
|
|
1928
1990
|
}
|
|
1929
1991
|
/** The full union of supported gesture spec kinds. New invocation forms
|
|
1930
|
-
* (
|
|
1992
|
+
* (two-stage, modal-dialog) extend this union without touching
|
|
1931
1993
|
* the `Action` type. */
|
|
1932
|
-
type GestureSpec = KeySpec | KeyHeldSpec | WheelSpec | ClickSpec | DoubleClickSpec | ContextMenuSpec | DragSpec | PointerDownSpec | MultiTouchSpec | MultiTouchTapSpec | DropSpec | PasteSpec;
|
|
1994
|
+
type GestureSpec = KeySpec | KeyHeldSpec | WheelSpec | ClickSpec | DoubleClickSpec | ContextMenuSpec | DragSpec | PointerDownSpec | LongPressSpec | MultiTouchSpec | MultiTouchTapSpec | DropSpec | PasteSpec;
|
|
1933
1995
|
|
|
1934
1996
|
/** A 2D point in either world or screen coordinates. */
|
|
1935
1997
|
interface Point2 {
|
|
@@ -2287,6 +2349,36 @@ interface OngoingInvoker {
|
|
|
2287
2349
|
* the `Action` type. */
|
|
2288
2350
|
type Invoker = ImmediateInvoker | OngoingInvoker;
|
|
2289
2351
|
|
|
2352
|
+
/**
|
|
2353
|
+
* Pose composition for hierarchical scene graphs.
|
|
2354
|
+
*
|
|
2355
|
+
* As of the nesting change, `getPose(id)` on adapters returns the
|
|
2356
|
+
* **local** pose — relative to the object's direct parent. Anything in the
|
|
2357
|
+
* kit that needs to draw, hit-test, snap, or otherwise reason about world
|
|
2358
|
+
* coordinates routes through `composeWorldPose`, which walks the parent
|
|
2359
|
+
* chain and folds local poses together via a consumer-supplied `compose`.
|
|
2360
|
+
*
|
|
2361
|
+
* Pose shape is generic, so the compose strategy is too. For the common
|
|
2362
|
+
* `{x, y, width, height}` axis-aligned rect, use `composeRectPose` —
|
|
2363
|
+
* translation only, child dimensions preserved. Custom pose shapes (paths,
|
|
2364
|
+
* matrix transforms) supply their own.
|
|
2365
|
+
*
|
|
2366
|
+
* The inverse — `rebaseLocalPose` — converts a world-space pose into a
|
|
2367
|
+
* local pose under a target parent. Used when reparenting so the visual
|
|
2368
|
+
* world position of a child is preserved across the parent change.
|
|
2369
|
+
*/
|
|
2370
|
+
/** Re-exported; the declaration lives in `core/scene/types.ts`, which names
|
|
2371
|
+
* it and may not import from features. */
|
|
2372
|
+
|
|
2373
|
+
/** Consumer's pose-composition strategy for hierarchical scenes. `compose`
|
|
2374
|
+
* folds a child's pose (in parent's frame) up to the next frame; `decompose`
|
|
2375
|
+
* is its inverse. Default is IDENTITY — an absolute-pose scene where every
|
|
2376
|
+
* node already stores world coords (parent is grouping-only, no transform). */
|
|
2377
|
+
interface PoseComposition<TPose> {
|
|
2378
|
+
compose: (parent: TPose, child: TPose) => TPose;
|
|
2379
|
+
decompose: (parent: TPose, world: TPose) => TPose;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2290
2382
|
/** Boolean op identifiers — five Pathfinder primaries plus Crop. */
|
|
2291
2383
|
type BooleanOp = 'union' | 'intersect' | 'subtract' | 'exclude' | 'divide' | 'crop';
|
|
2292
2384
|
/**
|
|
@@ -2576,6 +2668,20 @@ interface SliceDep {
|
|
|
2576
2668
|
commit(a: Point2, b: Point2): void;
|
|
2577
2669
|
}
|
|
2578
2670
|
|
|
2671
|
+
/**
|
|
2672
|
+
* Clipboard dep — the imperative surface `useClipboardOps` returns.
|
|
2673
|
+
*
|
|
2674
|
+
* Consumers publish their live clipboard through `useDepSource('clipboard',
|
|
2675
|
+
* …)` from inside the `<DepRegistryProvider>` (i.e. under `<SceneCanvas>`).
|
|
2676
|
+
* The kit deliberately does not build one for them: `useClipboardOps` needs
|
|
2677
|
+
* an adapter and a selection reader that only the consumer can supply.
|
|
2678
|
+
*/
|
|
2679
|
+
interface ClipboardDep {
|
|
2680
|
+
copy(): void;
|
|
2681
|
+
paste(): void;
|
|
2682
|
+
isEmpty(): boolean;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2579
2685
|
/**
|
|
2580
2686
|
* Bridges arbitrary `TPose` shapes into the resize hook's bounds-driven math.
|
|
2581
2687
|
* The hook reads bounds via `getBounds`, runs anchor-relative math on those
|
|
@@ -3147,6 +3253,15 @@ interface DepSchema {
|
|
|
3147
3253
|
* Optional: when absent, `sliceAction` is a no-op.
|
|
3148
3254
|
*/
|
|
3149
3255
|
slice?: SliceDep;
|
|
3256
|
+
/**
|
|
3257
|
+
* Clipboard dep — the imperative surface `useClipboardOps` returns.
|
|
3258
|
+
*
|
|
3259
|
+
* Published by the consumer (`useDepSource('clipboard', …)` from under
|
|
3260
|
+
* `<SceneCanvas>`), because `useClipboardOps` needs an adapter and a
|
|
3261
|
+
* selection reader only the consumer has. Feeds `clipboard.copy` /
|
|
3262
|
+
* `clipboard.cut`; both no-op when the dep is absent.
|
|
3263
|
+
*/
|
|
3264
|
+
clipboard?: ClipboardDep;
|
|
3150
3265
|
/**
|
|
3151
3266
|
* Optional consumer commit hook. When present, `moveAction` (and other
|
|
3152
3267
|
* default actions) submit their committed ops through it instead of
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { m as ActionBar, s5 as ActionsBar, Ft as Badge, a as Button, o3 as Checkbox, p4 as ComboBox, m2 as ComboBoxItem, F as CurveEditor, l as DataGrid, c2 as Dialog, qe as EDGE_PROFILES, n as Field, u2 as Input, s2 as KeyCap, c as KeySequence, a2 as MINUS_SIGN, f3 as NumberField, s4 as OptionsBar, _ as Plot2D, n4 as PointPlotter, r as Powerline, u3 as Radio, l2 as RadioGroup, l3 as RangeSlider, p3 as Select, h as SelectItem, n2 as Sidebar, o4 as SidebarPanel, f2 as Slider, a3 as Switch, c3 as Tab, s6 as TabList, l4 as TabPanel, o6 as Tabs, s3 as ToggleBar, o5 as ToolButton, n3 as ToolGroup, _2 as ToolPalette, Re as chromaAt, u as detectPlatform, p as dlog, r2 as fieldClasses, o2 as formatNumber, d2 as formatShortcut, u4 as formatShortcutParts, o as inferKeycapKind, f as isDebugEnabled, e as keyGlyph, p2 as keySpecFromKey, d as keySpecsFromMods, Le as oklchToHex, Ie as paintGradientTrack, s as useReorderDragList } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { m as ActionBar, s5 as ActionsBar, Ft as Badge, a as Button, o3 as Checkbox, p4 as ComboBox, m2 as ComboBoxItem, F as CurveEditor, l as DataGrid, c2 as Dialog, qe as EDGE_PROFILES, n as Field, u2 as Input, s2 as KeyCap, c as KeySequence, a2 as MINUS_SIGN, f3 as NumberField, s4 as OptionsBar, _ as Plot2D, n4 as PointPlotter, r as Powerline, u3 as Radio, l2 as RadioGroup, l3 as RangeSlider, p3 as Select, h as SelectItem, n2 as Sidebar, o4 as SidebarPanel, f2 as Slider, a3 as Switch, c3 as Tab, s6 as TabList, l4 as TabPanel, o6 as Tabs, s3 as ToggleBar, o5 as ToolButton, n3 as ToolGroup, _2 as ToolPalette, Re as chromaAt, u as detectPlatform, p as dlog, r2 as fieldClasses, o2 as formatNumber, d2 as formatShortcut, u4 as formatShortcutParts, o as inferKeycapKind, f as isDebugEnabled, e as keyGlyph, p2 as keySpecFromKey, d as keySpecsFromMods, Le as oklchToHex, Ie as paintGradientTrack, s as useReorderDragList } from '../chunk-FBZCQXI2.js';
|
|
2
|
+
import '../chunk-6V7ROR7G.js';
|
|
3
3
|
//# sourceMappingURL=weasel-ui.js.map
|
|
4
4
|
//# sourceMappingURL=weasel-ui.js.map
|
package/dist/styles.css
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
@font-face {
|
|
61
61
|
font-family: 'Oswald';
|
|
62
62
|
font-style: normal;
|
|
63
|
-
font-weight:
|
|
63
|
+
font-weight: 200 700;
|
|
64
64
|
font-display: swap;
|
|
65
65
|
src: url('./fonts/oswald-latin-variable.woff2') format('woff2');
|
|
66
66
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
package/dist/ui/layers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { LayerStack } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { LayerStack } from '../../chunk-OHGEOTCV.js';
|
|
2
|
+
import '../../chunk-FBZCQXI2.js';
|
|
3
|
+
import '../../chunk-6V7ROR7G.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/labkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React widgets for building self-contained interactive lab pages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "orochi235",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"build:dts": "tsx scripts/build-dts.mts",
|
|
80
80
|
"prepublishOnly": "npm run build",
|
|
81
81
|
"build:css": "lessc src/styles.less dist/styles.css && lessc src/theme/light.less dist/theme-light.css && lessc src/theme/interstellar.less dist/theme-interstellar.css",
|
|
82
|
-
"build:fonts": "mkdir -p dist/fonts && cp
|
|
82
|
+
"build:fonts": "mkdir -p dist/fonts && cp ../theme/fonts/*.woff2 dist/fonts/",
|
|
83
83
|
"test": "vitest run",
|
|
84
84
|
"test:watch": "vitest",
|
|
85
85
|
"test:smoke:consumer": "node scripts/smoke-consumer-bundle.mjs",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"@rollup/plugin-alias": "^6.0.0",
|
|
106
106
|
"@testing-library/jest-dom": "^6.6.0",
|
|
107
107
|
"@weasel-js/modes": "*",
|
|
108
|
+
"@weasel-js/theme": "*",
|
|
108
109
|
"@weasel-js/ui": "*",
|
|
109
110
|
"less": "^4.2.0",
|
|
110
111
|
"rollup-plugin-dts": "^6.4.1",
|
package/src/theme/base.less
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
@import './tokens.less';
|
|
2
2
|
|
|
3
|
-
// Self-hosted Oswald (variable font,
|
|
3
|
+
// Self-hosted Oswald (variable font, wght axis 200–700) for the headline
|
|
4
|
+
// typeface. Sourced from @weasel-js/theme; build:fonts copies it into dist/fonts.
|
|
4
5
|
@font-face {
|
|
5
6
|
font-family: 'Oswald';
|
|
6
7
|
font-style: normal;
|
|
7
|
-
font-weight:
|
|
8
|
+
font-weight: 200 700;
|
|
8
9
|
font-display: swap;
|
|
9
10
|
// URL is resolved relative to the COMPILED stylesheet at dist/styles.css,
|
|
10
11
|
// so this points to dist/fonts/. Source-tree usage (less compilation
|