@weasel-js/labkit 1.4.0-pre.0 → 1.4.0-pre.1
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/README.md +226 -55
- package/dist/_dts/{CanvasStackContext-DtAn_3O-.d.ts → CanvasStackContext-LnCfqNBA.d.ts} +1 -1
- package/dist/_dts/{frac-Cp3NivlC.d.ts → frac-C-2c72Ij.d.ts} +9 -2
- package/dist/canvas/index.d.ts +73 -7
- package/dist/canvas/index.js +2 -2
- package/dist/chrome/index.d.ts +2 -2
- package/dist/chrome/index.js +5 -5
- package/dist/{chunk-LITE5YFB.js → chunk-6OEYTYML.js} +6 -6
- package/dist/{chunk-LITE5YFB.js.map → chunk-6OEYTYML.js.map} +1 -1
- package/dist/{chunk-JDDIZSLL.js → chunk-AE5CNVRU.js} +3 -3
- package/dist/{chunk-JDDIZSLL.js.map → chunk-AE5CNVRU.js.map} +1 -1
- package/dist/{chunk-EQIB2PGC.js → chunk-E2UQVZ44.js} +3 -3
- package/dist/{chunk-EQIB2PGC.js.map → chunk-E2UQVZ44.js.map} +1 -1
- package/dist/{chunk-4EY67BKJ.js → chunk-ESIQNQ6K.js} +3 -3
- package/dist/{chunk-4EY67BKJ.js.map → chunk-ESIQNQ6K.js.map} +1 -1
- package/dist/{chunk-6JMU56CU.js → chunk-HHGVISVZ.js} +4 -4
- package/dist/{chunk-6JMU56CU.js.map → chunk-HHGVISVZ.js.map} +1 -1
- package/dist/{chunk-3ZELRRBV.js → chunk-HMFODCOX.js} +86 -6
- package/dist/chunk-HMFODCOX.js.map +1 -0
- package/dist/{chunk-ROQDRXKW.js → chunk-L5QJOOLV.js} +126 -12
- package/dist/chunk-L5QJOOLV.js.map +1 -0
- package/dist/{chunk-5TCEVMPI.js → chunk-M75ZU6ZZ.js} +3 -3
- package/dist/{chunk-5TCEVMPI.js.map → chunk-M75ZU6ZZ.js.map} +1 -1
- package/dist/{chunk-3P5TTTA7.js → chunk-QB5SM4BM.js} +3 -3
- package/dist/{chunk-3P5TTTA7.js.map → chunk-QB5SM4BM.js.map} +1 -1
- package/dist/{chunk-HEORBLVT.js → chunk-RBGKL7NF.js} +3 -3
- package/dist/{chunk-HEORBLVT.js.map → chunk-RBGKL7NF.js.map} +1 -1
- package/dist/{chunk-YQJNT4XQ.js → chunk-TO2FUOKF.js} +4 -4
- package/dist/{chunk-YQJNT4XQ.js.map → chunk-TO2FUOKF.js.map} +1 -1
- package/dist/controls/index.js +3 -3
- package/dist/dragdrop/index.d.ts +1 -1
- package/dist/dragdrop/index.js +2 -2
- package/dist/index.d.ts +7 -52
- package/dist/index.js +49 -101
- package/dist/index.js.map +1 -1
- package/dist/layers/index.d.ts +2 -2
- package/dist/layers/index.js +3 -3
- package/dist/loupe/index.d.ts +3 -3
- package/dist/loupe/index.js +2 -2
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.js +2 -2
- package/dist/primitives/index.js +4 -4
- package/dist/surface/index.js +2 -2
- package/dist/ui/layers/index.js +2 -2
- package/dist/undo/index.d.ts +1 -1
- package/package.json +7 -7
- package/src/annotations/store.test.ts +72 -0
- package/src/annotations/store.ts +30 -0
- package/src/annotations/types.ts +9 -2
- package/src/canvas/index.ts +11 -0
- package/src/index.test.ts +1 -0
- package/src/index.ts +13 -9
- package/dist/chunk-3ZELRRBV.js.map +0 -1
- package/dist/chunk-ROQDRXKW.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S2, b3, O2, N, M, k2, E, j2, w, A2 } from './chunk-
|
|
2
|
-
import { isBuiltinToolPref } from './chunk-
|
|
1
|
+
import { S2, b3, O2, N, M, k2, E, j2, w, A2 } from './chunk-RBGKL7NF.js';
|
|
2
|
+
import { isBuiltinToolPref } from './chunk-L5QJOOLV.js';
|
|
3
3
|
import { useMemo, useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -289,5 +289,5 @@ function DebouncedTextRow({
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
export { ControlPanel, fromConfigFields, isLeafVisible };
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
293
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
//# sourceMappingURL=chunk-TO2FUOKF.js.map
|
|
293
|
+
//# sourceMappingURL=chunk-TO2FUOKF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/fromConfigField.ts","../src/config/visible.ts","../src/controls/ControlPanel.tsx"],"names":["S","b","value","j","k","O","A"],"mappings":";;;;;;AAOA,SAAS,OAAO,KAAA,EAA+B;AAC7C,EAAA,MAAM,OAAO,EAAE,IAAA,EAAM,KAAA,CAAM,KAAA,EAAO,aAAa,EAAA,EAAG;AAClD,EAAA,QAAQ,MAAM,IAAA;AAAM,IAClB,KAAK,QAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,IAAA;AAAA,QACH,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS,QAAA;AAAA,QACT,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,MAAM,KAAA,CAAM;AAAA,OACd;AAAA,IACF,KAAK,QAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,IAAA;AAAA,QACH,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS,OAAA;AAAA,QACT,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,MAAM,KAAA,CAAM;AAAA,OACd;AAAA,IACF,KAAK,UAAA;AACH,MAAA,OAAO,EAAE,GAAG,IAAA,EAAM,IAAA,EAAM,SAAA,EAAW,SAAS,UAAA,EAAW;AAAA,IACzD,KAAK,QAAA;AACH,MAAA,OAAO,EAAE,GAAG,IAAA,EAAM,MAAM,MAAA,EAAQ,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,IACzD,KA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M,YAAA,GAAe,OAAO,KAAK,CAAA;AAEjC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAAA,KAAU,aAAa,OAAA,EAAS;AAClC,MAAA,YAAA,CAAa,OAAA,GAAU,KAAA;AACvB,MAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAChB;AAAA,EACF,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,SAAA;AAAA,IACE,MAAM,MAAM;AACV,MAAA,IAAI,KAAA,CAAM,OAAA,EAAS,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA;AAAC,GACH;AAEA,EAAA,uBACE,GAAA;AAAA,IAACC,EAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA,EAAO,KAAA;AAAA,MACP,WAAA,EAAa,KAAA,CAAc,IAAA,EAAM,aAAa,CAAA;AAAA,MAC9C,SAAA,EAAW,KAAA,CAAc,IAAA,EAAM,WAAW,CAAA;AAAA,MAC1C,QAAA,EAAU,CAAC,IAAA,KAAS;AAClB,QAAA,QAAA,CAAS,IAAI,CAAA;AACb,QAAA,IAAI,KAAA,CAAM,OAAA,EAAS,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC7C,QAAA,MAAM,SAAS,MAAM;AACnB,UAAA,YAAA,CAAa,OAAA,GAAU,IAAA;AACvB,UAAA,KAAA,CAAM,IAAI,CAAA;AAAA,QACZ,CAAA;AACA,QAAA,IAAI,UAAA,KAAe,GAAG,MAAA,EAAO;AAAA,aACxB,KAAA,CAAM,OAAA,GAAU,UAAA,CAAW,MAAA,EAAQ,UAAU,CAAA;AAAA,MACpD;AAAA;AAAA,GACF;AAEJ","file":"chunk-YQJNT4XQ.js","sourcesContent":["import type { PrefLeaf } from '@weasel-js/ui';\nimport type { ConfigField } from '../controls/types';\nimport type { LeafPatch, ResolvedConfig } from './types';\n\n/** One `ConfigField` as the `Pref*` vocabulary spells it. The two describe the\n * same thing; `ConfigField` just keys on the control where `PrefLeaf`\n * separates the value's kind from how it is presented. */\nfunction toLeaf(field: ConfigField): LeafPatch {\n const base = { name: field.label, description: '' };\n switch (field.type) {\n case 'slider':\n return {\n ...base,\n kind: 'number',\n control: 'slider',\n min: field.min,\n max: field.max,\n step: field.step,\n };\n case 'number':\n return {\n ...base,\n kind: 'number',\n control: 'input',\n min: field.min,\n max: field.max,\n step: field.step,\n };\n case 'checkbox':\n return { ...base, kind: 'boolean', control: 'checkbox' };\n case 'select':\n return { ...base, kind: 'enum', options: field.options };\n case 'text':\n return {\n ...base,\n kind: 'string',\n placeholder: field.placeholder,\n maxLength: field.maxLength,\n debounceMs: field.debounceMs,\n };\n case 'color':\n return { ...base, kind: 'color' };\n default:\n // A schema can arrive from outside TypeScript. Carry the kind through\n // so a lab-supplied renderer can still claim it.\n return { ...base, kind: (field as ConfigField).type };\n }\n}\n\n/**\n * Adapt a legacy `configSchema(): ConfigField[]` into the resolved shape, so\n * both instrument paths reach one renderer.\n *\n * Rules do not run here: a hand-written `ConfigField` already states its label\n * and control, which is everything the rule chain would have inferred.\n */\nexport function fromConfigFields(fields: readonly ConfigField[]): ResolvedConfig {\n const children: Record<string, PrefLeaf> = {};\n for (const field of fields) {\n const patch = toLeaf(field);\n for (const key of Object.keys(patch)) {\n if ((patch as Record<string, unknown>)[key] === undefined) {\n delete (patch as Record<string, unknown>)[key];\n }\n }\n children[field.key] = { ...patch, default: field.default } as PrefLeaf;\n }\n return {\n group: { name: '', children },\n sections: [],\n showIf: new Map(),\n renderers: {},\n };\n}\n","import type { ResolvedConfig } from './types';\n\n/**\n * Whether a leaf's row should be drawn right now.\n *\n * `hidden` is the leaf's own static flag; `showIf` is the schema's predicate\n * over the live config. Both are presentational — a hidden leaf keeps its\n * value and the instrument still reads it.\n */\nexport function isLeafVisible(\n resolved: ResolvedConfig,\n path: string,\n config: Record<string, unknown>,\n showHidden = false,\n): boolean {\n const leaf = resolved.group.children[path];\n if (leaf && 'hidden' in leaf && leaf.hidden === true && !showHidden) return false;\n const predicate = resolved.showIf.get(path);\n return predicate ? predicate(config) : true;\n}\n","import { isBuiltinToolPref } from '@weasel-js/core';\nimport {\n CheckboxRow,\n ColorRow,\n NumberRow,\n type PrefLeaf,\n PropertyGroup,\n PropertyList,\n PropertyRow,\n type PropertyRowLayout,\n SelectRow,\n SliderRow,\n TextRow,\n ToggleRow,\n} from '@weasel-js/ui';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { fromConfigFields } from '../config/fromConfigField';\nimport type { ControlRenderer, ResolvedConfig } from '../config/types';\nimport { isLeafVisible } from '../config/visible';\nimport type { ConfigField } from './types';\n\n/** How a panel packs its rows into the two-column property grid.\n * - `'auto'`: narrow controls (numbers, checkboxes, dropdowns, colours) sit\n * two per row; the ones that need the width — text, sliders, segmented\n * toggles — span it.\n * - `'pairs'`: every row pairs. A control that needs the full width says so\n * itself, with `<PropertyRow span>`.\n * - `'one-up'`: one control per row, colours excepted.\n */\nexport type ControlPack = 'auto' | 'pairs' | 'one-up';\n\nexport interface ControlPanelProps<TC extends Record<string, unknown>> {\n /** The instrument's resolved config schema. */\n schema?: ResolvedConfig;\n /** @deprecated Pass `schema`. A field list is adapted into one internally. */\n fields?: ConfigField[];\n config: TC;\n setConfig: (key: keyof TC, value: unknown) => void;\n /**\n * Control overrides and app-defined kinds, PrefsForm-style. Keys are config\n * paths (checked first) or leaf kinds. A renderer returning `null` collapses\n * the row; entries override the built-in rows on collision.\n */\n renderers?: Record<string, ControlRenderer>;\n /** How rows pack into the two-column grid. Defaults to `'pairs'`. */\n pack?: ControlPack;\n /** Where a row's label sits relative to its control. Defaults to `'block'`\n * — above it, which is what leaves a paired row room for its value. */\n layout?: PropertyRowLayout;\n /** Draw leaves marked `hidden`. */\n showHidden?: boolean;\n className?: string;\n}\n\n/** Render an instrument's config schema as a stack of controls, each writing\n * back through `setConfig`. Built on the property rows, so a lab's controls\n * are the same aligned, themed rows the rest of the kit uses. */\nexport function ControlPanel<TC extends Record<string, unknown>>({\n schema,\n fields,\n config,\n setConfig,\n renderers,\n pack = 'pairs',\n layout = 'block',\n showHidden = false,\n className,\n}: ControlPanelProps<TC>) {\n const resolved = useMemo(() => schema ?? fromConfigFields(fields ?? []), [schema, fields]);\n\n const paths = Object.keys(resolved.group.children);\n const sectioned = new Set(resolved.sections.flatMap((s) => s.paths));\n const loose = paths.filter((p) => !sectioned.has(p));\n\n const row = (path: string): ReactNode => (\n <ControlRow\n key={path}\n path={path}\n resolved={resolved}\n config={config}\n setConfig={setConfig}\n renderers={renderers}\n pack={pack}\n layout={layout}\n showHidden={showHidden}\n />\n );\n\n const gridPack = pack === 'one-up' ? 'auto-color' : 'pairs';\n return (\n <PropertyList\n pack={gridPack}\n className={className ? `lk-control-panel ${className}` : 'lk-control-panel'}\n >\n {loose.map(row)}\n {resolved.sections.map((section) => (\n <PropertyGroup key={section.label} title={section.label} pack={gridPack}>\n {section.paths.map(row)}\n </PropertyGroup>\n ))}\n </PropertyList>\n );\n}\n\ninterface ControlRowProps<TC extends Record<string, unknown>> {\n path: string;\n resolved: ResolvedConfig;\n config: TC;\n setConfig: (key: keyof TC, value: unknown) => void;\n renderers?: Record<string, ControlRenderer>;\n pack: ControlPack;\n layout: PropertyRowLayout;\n showHidden: boolean;\n}\n\n/** Reads a labkit-only extra off a leaf. `PrefLeaf` has no field for these,\n * and extra keys survive the resolve pass at runtime. */\nfunction extra<T>(leaf: PrefLeaf, key: string): T | undefined {\n return (leaf as unknown as Record<string, T | undefined>)[key];\n}\n\nfunction ControlRow<TC extends Record<string, unknown>>({\n path,\n resolved,\n config,\n setConfig,\n renderers,\n pack,\n layout,\n showHidden,\n}: ControlRowProps<TC>) {\n const leaf = resolved.group.children[path] as PrefLeaf | undefined;\n if (!leaf || !('kind' in leaf)) return null;\n if (!isLeafVisible(resolved, path, config as Record<string, unknown>, showHidden)) return null;\n\n const write = (value: unknown): void => setConfig(path as keyof TC, value);\n const fallback = extra<unknown>(leaf, 'default');\n const value = config[path] ?? fallback;\n\n // Most specific wins, and within a tier the lab's entry beats the\n // instrument's: controls[path] -> node .render -> controls[kind] -> built-in.\n const custom = renderers?.[path] ?? resolved.renderers[path] ?? renderers?.[leaf.kind];\n // A custom row places itself like any other; one that needs the full width\n // says so with `<PropertyRow span>`, which is the same opt-out a built-in has.\n if (custom) return custom({ path, pref: leaf, value, setValue: write });\n\n const label = leaf.name;\n const description = leaf.description;\n const read = <T,>(): T => value as T;\n // `auto` gives the whole width to the controls that read badly at half of a\n // sidebar's: free text, a slider track, a segmented toggle. `pairs` doesn't.\n const wide = pack === 'auto';\n\n if (!isBuiltinToolPref(leaf))\n return <UnwiredRow label={label} kind={leaf.kind} description={description} />;\n\n switch (leaf.kind) {\n case 'number': {\n const min = extra<number>(leaf, 'min');\n const max = extra<number>(leaf, 'max');\n const step = extra<number>(leaf, 'step');\n if (extra<string>(leaf, 'control') === 'slider' && min !== undefined && max !== undefined) {\n return (\n <SliderRow\n label={label}\n value={read<number>()}\n min={min}\n max={max}\n step={step}\n onChange={write}\n layout={layout}\n span={wide}\n description={description}\n />\n );\n }\n // NumberRow commits every keystroke and does not clamp, so the bounds a\n // schema declares are enforced here — an instrument should never be\n // handed a config value outside the range it asked for.\n const lo = min ?? Number.NEGATIVE_INFINITY;\n const hi = max ?? Number.POSITIVE_INFINITY;\n return (\n <NumberRow\n label={label}\n value={read<number>()}\n min={min}\n max={max}\n step={step}\n onChange={(n) => write(Math.min(hi, Math.max(lo, n)))}\n layout={layout}\n description={description}\n />\n );\n }\n case 'boolean':\n return (\n <CheckboxRow\n label={label}\n value={read<boolean>()}\n onChange={write}\n description={description}\n />\n );\n case 'enum': {\n const options = extra<readonly { value: string; label: string }[]>(leaf, 'options') ?? [];\n const segmented = extra<string>(leaf, 'control') === 'radio';\n const Row = segmented ? ToggleRow : SelectRow;\n return (\n <Row\n label={label}\n value={read<string>()}\n options={options}\n onChange={write}\n layout={layout}\n span={segmented && wide}\n description={description}\n />\n );\n }\n case 'string':\n return (\n <DebouncedTextRow\n leaf={leaf}\n label={label}\n value={read<string>()}\n write={write}\n layout={layout}\n span={wide}\n description={description}\n />\n );\n case 'color':\n return (\n <ColorRow label={label} value={read<string>()} onChange={write} description={description} />\n );\n case 'paint':\n case 'object':\n // Declined: a hex swatch would write a solid over a gradient, and a flat\n // row would write one field into a half-built object. Override with\n // `render` to edit either.\n return <UnwiredRow label={label} kind={leaf.kind} description={description} />;\n default: {\n // Not reachable while every built-in kind has an arm — and a new kind\n // that lacks one is a compile error here, never a blank row.\n const _exhaustive: never = leaf;\n throw new Error(\n `ControlPanel: no control for built-in pref kind \"${(_exhaustive as { kind: string }).kind}\"`,\n );\n }\n }\n}\n\n/** A leaf this panel has no control for is named rather than dropped: a silent\n * gap reads as \"this control does not exist\". */\nfunction UnwiredRow({\n label,\n kind,\n description,\n}: {\n label: string;\n kind: string;\n description?: string;\n}) {\n return (\n <PropertyRow label={label} description={description}>\n <span className=\"lk-control-panel__unknown\">no control for “{kind}”</span>\n </PropertyRow>\n );\n}\n\n/** Text writes are debounced so typing does not re-run the instrument on every\n * keystroke, which means the row is locally controlled between commits and has\n * to notice when the config changes underneath it. */\nfunction DebouncedTextRow({\n leaf,\n label,\n value,\n write,\n layout,\n span,\n description,\n}: {\n leaf: PrefLeaf;\n label: string;\n value: string;\n write: (value: unknown) => void;\n layout?: PropertyRowLayout;\n span?: boolean;\n description?: string;\n}) {\n const debounceMs = extra<number>(leaf, 'debounceMs') ?? 150;\n const [local, setLocal] = useState(value);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const lastExternal = useRef(value);\n\n useEffect(() => {\n if (value !== lastExternal.current) {\n lastExternal.current = value;\n setLocal(value);\n }\n }, [value]);\n\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current);\n },\n [],\n );\n\n return (\n <TextRow\n label={label}\n layout={layout}\n span={span}\n description={description}\n value={local}\n placeholder={extra<string>(leaf, 'placeholder')}\n maxLength={extra<number>(leaf, 'maxLength')}\n onChange={(next) => {\n setLocal(next);\n if (timer.current) clearTimeout(timer.current);\n const commit = () => {\n lastExternal.current = next;\n write(next);\n };\n if (debounceMs === 0) commit();\n else timer.current = setTimeout(commit, debounceMs);\n }}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/config/fromConfigField.ts","../src/config/visible.ts","../src/controls/ControlPanel.tsx"],"names":["S","b","value","j","k","O","A"],"mappings":";;;;;;AAOA,SAAS,OAAO,KAAA,EAA+B;AAC7C,EAAA,MAAM,OAAO,EAAE,IAAA,EAAM,KAAA,CAAM,KAAA,EAAO,aAAa,EAAA,EAAG;AAClD,EAAA,QAAQ,MAAM,IAAA;AAAM,IAClB,KAAK,QAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,IAAA;AAAA,QACH,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS,QAAA;AAAA,QACT,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,MAAM,KAAA,CAAM;AAAA,OACd;AAAA,IACF,KAAK,QAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,IAAA;AAAA,QACH,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS,OAAA;AAAA,QACT,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,MAAM,KAAA,CAAM;AAAA,OACd;AAAA,IACF,KAAK,UAAA;AACH,MAAA,OAAO,EAAE,GAAG,IAAA,EAAM,IAAA,EAAM,SAAA,EAAW,SAAS,UAAA,EAAW;AAAA,IACzD,KAAK,QAAA;AACH,MAAA,OAAO,EAAE,GAAG,IAAA,EAAM,MAAM,MAAA,EAAQ,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,IACzD,KAAK,MAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,IAAA;AAAA,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U,MAAM;AACd,IAAA,IAAI,KAAA,KAAU,aAAa,OAAA,EAAS;AAClC,MAAA,YAAA,CAAa,OAAA,GAAU,KAAA;AACvB,MAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAChB;AAAA,EACF,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,SAAA;AAAA,IACE,MAAM,MAAM;AACV,MAAA,IAAI,KAAA,CAAM,OAAA,EAAS,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA;AAAC,GACH;AAEA,EAAA,uBACE,GAAA;AAAA,IAACC,EAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA,EAAO,KAAA;AAAA,MACP,WAAA,EAAa,KAAA,CAAc,IAAA,EAAM,aAAa,CAAA;AAAA,MAC9C,SAAA,EAAW,KAAA,CAAc,IAAA,EAAM,WAAW,CAAA;AAAA,MAC1C,QAAA,EAAU,CAAC,IAAA,KAAS;AAClB,QAAA,QAAA,CAAS,IAAI,CAAA;AACb,QAAA,IAAI,KAAA,CAAM,OAAA,EAAS,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC7C,QAAA,MAAM,SAAS,MAAM;AACnB,UAAA,YAAA,CAAa,OAAA,GAAU,IAAA;AACvB,UAAA,KAAA,CAAM,IAAI,CAAA;AAAA,QACZ,CAAA;AACA,QAAA,IAAI,UAAA,KAAe,GAAG,MAAA,EAAO;AAAA,aACxB,KAAA,CAAM,OAAA,GAAU,UAAA,CAAW,MAAA,EAAQ,UAAU,CAAA;AAAA,MACpD;AAAA;AAAA,GACF;AAEJ","file":"chunk-TO2FUOKF.js","sourcesContent":["import type { PrefLeaf } from '@weasel-js/ui';\nimport type { ConfigField } from '../controls/types';\nimport type { LeafPatch, ResolvedConfig } from './types';\n\n/** One `ConfigField` as the `Pref*` vocabulary spells it. The two describe the\n * same thing; `ConfigField` just keys on the control where `PrefLeaf`\n * separates the value's kind from how it is presented. */\nfunction toLeaf(field: ConfigField): LeafPatch {\n const base = { name: field.label, description: '' };\n switch (field.type) {\n case 'slider':\n return {\n ...base,\n kind: 'number',\n control: 'slider',\n min: field.min,\n max: field.max,\n step: field.step,\n };\n case 'number':\n return {\n ...base,\n kind: 'number',\n control: 'input',\n min: field.min,\n max: field.max,\n step: field.step,\n };\n case 'checkbox':\n return { ...base, kind: 'boolean', control: 'checkbox' };\n case 'select':\n return { ...base, kind: 'enum', options: field.options };\n case 'text':\n return {\n ...base,\n kind: 'string',\n placeholder: field.placeholder,\n maxLength: field.maxLength,\n debounceMs: field.debounceMs,\n };\n case 'color':\n return { ...base, kind: 'color' };\n default:\n // A schema can arrive from outside TypeScript. Carry the kind through\n // so a lab-supplied renderer can still claim it.\n return { ...base, kind: (field as ConfigField).type };\n }\n}\n\n/**\n * Adapt a legacy `configSchema(): ConfigField[]` into the resolved shape, so\n * both instrument paths reach one renderer.\n *\n * Rules do not run here: a hand-written `ConfigField` already states its label\n * and control, which is everything the rule chain would have inferred.\n */\nexport function fromConfigFields(fields: readonly ConfigField[]): ResolvedConfig {\n const children: Record<string, PrefLeaf> = {};\n for (const field of fields) {\n const patch = toLeaf(field);\n for (const key of Object.keys(patch)) {\n if ((patch as Record<string, unknown>)[key] === undefined) {\n delete (patch as Record<string, unknown>)[key];\n }\n }\n children[field.key] = { ...patch, default: field.default } as PrefLeaf;\n }\n return {\n group: { name: '', children },\n sections: [],\n showIf: new Map(),\n renderers: {},\n };\n}\n","import type { ResolvedConfig } from './types';\n\n/**\n * Whether a leaf's row should be drawn right now.\n *\n * `hidden` is the leaf's own static flag; `showIf` is the schema's predicate\n * over the live config. Both are presentational — a hidden leaf keeps its\n * value and the instrument still reads it.\n */\nexport function isLeafVisible(\n resolved: ResolvedConfig,\n path: string,\n config: Record<string, unknown>,\n showHidden = false,\n): boolean {\n const leaf = resolved.group.children[path];\n if (leaf && 'hidden' in leaf && leaf.hidden === true && !showHidden) return false;\n const predicate = resolved.showIf.get(path);\n return predicate ? predicate(config) : true;\n}\n","import { isBuiltinToolPref } from '@weasel-js/core';\nimport {\n CheckboxRow,\n ColorRow,\n NumberRow,\n type PrefLeaf,\n PropertyGroup,\n PropertyList,\n PropertyRow,\n type PropertyRowLayout,\n SelectRow,\n SliderRow,\n TextRow,\n ToggleRow,\n} from '@weasel-js/ui';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { fromConfigFields } from '../config/fromConfigField';\nimport type { ControlRenderer, ResolvedConfig } from '../config/types';\nimport { isLeafVisible } from '../config/visible';\nimport type { ConfigField } from './types';\n\n/** How a panel packs its rows into the two-column property grid.\n * - `'auto'`: narrow controls (numbers, checkboxes, dropdowns, colours) sit\n * two per row; the ones that need the width — text, sliders, segmented\n * toggles — span it.\n * - `'pairs'`: every row pairs. A control that needs the full width says so\n * itself, with `<PropertyRow span>`.\n * - `'one-up'`: one control per row, colours excepted.\n */\nexport type ControlPack = 'auto' | 'pairs' | 'one-up';\n\nexport interface ControlPanelProps<TC extends Record<string, unknown>> {\n /** The instrument's resolved config schema. */\n schema?: ResolvedConfig;\n /** @deprecated Pass `schema`. A field list is adapted into one internally. */\n fields?: ConfigField[];\n config: TC;\n setConfig: (key: keyof TC, value: unknown) => void;\n /**\n * Control overrides and app-defined kinds, PrefsForm-style. Keys are config\n * paths (checked first) or leaf kinds. A renderer returning `null` collapses\n * the row; entries override the built-in rows on collision.\n */\n renderers?: Record<string, ControlRenderer>;\n /** How rows pack into the two-column grid. Defaults to `'pairs'`. */\n pack?: ControlPack;\n /** Where a row's label sits relative to its control. Defaults to `'block'`\n * — above it, which is what leaves a paired row room for its value. */\n layout?: PropertyRowLayout;\n /** Draw leaves marked `hidden`. */\n showHidden?: boolean;\n className?: string;\n}\n\n/** Render an instrument's config schema as a stack of controls, each writing\n * back through `setConfig`. Built on the property rows, so a lab's controls\n * are the same aligned, themed rows the rest of the kit uses. */\nexport function ControlPanel<TC extends Record<string, unknown>>({\n schema,\n fields,\n config,\n setConfig,\n renderers,\n pack = 'pairs',\n layout = 'block',\n showHidden = false,\n className,\n}: ControlPanelProps<TC>) {\n const resolved = useMemo(() => schema ?? fromConfigFields(fields ?? []), [schema, fields]);\n\n const paths = Object.keys(resolved.group.children);\n const sectioned = new Set(resolved.sections.flatMap((s) => s.paths));\n const loose = paths.filter((p) => !sectioned.has(p));\n\n const row = (path: string): ReactNode => (\n <ControlRow\n key={path}\n path={path}\n resolved={resolved}\n config={config}\n setConfig={setConfig}\n renderers={renderers}\n pack={pack}\n layout={layout}\n showHidden={showHidden}\n />\n );\n\n const gridPack = pack === 'one-up' ? 'auto-color' : 'pairs';\n return (\n <PropertyList\n pack={gridPack}\n className={className ? `lk-control-panel ${className}` : 'lk-control-panel'}\n >\n {loose.map(row)}\n {resolved.sections.map((section) => (\n <PropertyGroup key={section.label} title={section.label} pack={gridPack}>\n {section.paths.map(row)}\n </PropertyGroup>\n ))}\n </PropertyList>\n );\n}\n\ninterface ControlRowProps<TC extends Record<string, unknown>> {\n path: string;\n resolved: ResolvedConfig;\n config: TC;\n setConfig: (key: keyof TC, value: unknown) => void;\n renderers?: Record<string, ControlRenderer>;\n pack: ControlPack;\n layout: PropertyRowLayout;\n showHidden: boolean;\n}\n\n/** Reads a labkit-only extra off a leaf. `PrefLeaf` has no field for these,\n * and extra keys survive the resolve pass at runtime. */\nfunction extra<T>(leaf: PrefLeaf, key: string): T | undefined {\n return (leaf as unknown as Record<string, T | undefined>)[key];\n}\n\nfunction ControlRow<TC extends Record<string, unknown>>({\n path,\n resolved,\n config,\n setConfig,\n renderers,\n pack,\n layout,\n showHidden,\n}: ControlRowProps<TC>) {\n const leaf = resolved.group.children[path] as PrefLeaf | undefined;\n if (!leaf || !('kind' in leaf)) return null;\n if (!isLeafVisible(resolved, path, config as Record<string, unknown>, showHidden)) return null;\n\n const write = (value: unknown): void => setConfig(path as keyof TC, value);\n const fallback = extra<unknown>(leaf, 'default');\n const value = config[path] ?? fallback;\n\n // Most specific wins, and within a tier the lab's entry beats the\n // instrument's: controls[path] -> node .render -> controls[kind] -> built-in.\n const custom = renderers?.[path] ?? resolved.renderers[path] ?? renderers?.[leaf.kind];\n // A custom row places itself like any other; one that needs the full width\n // says so with `<PropertyRow span>`, which is the same opt-out a built-in has.\n if (custom) return custom({ path, pref: leaf, value, setValue: write });\n\n const label = leaf.name;\n const description = leaf.description;\n const read = <T,>(): T => value as T;\n // `auto` gives the whole width to the controls that read badly at half of a\n // sidebar's: free text, a slider track, a segmented toggle. `pairs` doesn't.\n const wide = pack === 'auto';\n\n if (!isBuiltinToolPref(leaf))\n return <UnwiredRow label={label} kind={leaf.kind} description={description} />;\n\n switch (leaf.kind) {\n case 'number': {\n const min = extra<number>(leaf, 'min');\n const max = extra<number>(leaf, 'max');\n const step = extra<number>(leaf, 'step');\n if (extra<string>(leaf, 'control') === 'slider' && min !== undefined && max !== undefined) {\n return (\n <SliderRow\n label={label}\n value={read<number>()}\n min={min}\n max={max}\n step={step}\n onChange={write}\n layout={layout}\n span={wide}\n description={description}\n />\n );\n }\n // NumberRow commits every keystroke and does not clamp, so the bounds a\n // schema declares are enforced here — an instrument should never be\n // handed a config value outside the range it asked for.\n const lo = min ?? Number.NEGATIVE_INFINITY;\n const hi = max ?? Number.POSITIVE_INFINITY;\n return (\n <NumberRow\n label={label}\n value={read<number>()}\n min={min}\n max={max}\n step={step}\n onChange={(n) => write(Math.min(hi, Math.max(lo, n)))}\n layout={layout}\n description={description}\n />\n );\n }\n case 'boolean':\n return (\n <CheckboxRow\n label={label}\n value={read<boolean>()}\n onChange={write}\n description={description}\n />\n );\n case 'enum': {\n const options = extra<readonly { value: string; label: string }[]>(leaf, 'options') ?? [];\n const segmented = extra<string>(leaf, 'control') === 'radio';\n const Row = segmented ? ToggleRow : SelectRow;\n return (\n <Row\n label={label}\n value={read<string>()}\n options={options}\n onChange={write}\n layout={layout}\n span={segmented && wide}\n description={description}\n />\n );\n }\n case 'string':\n return (\n <DebouncedTextRow\n leaf={leaf}\n label={label}\n value={read<string>()}\n write={write}\n layout={layout}\n span={wide}\n description={description}\n />\n );\n case 'color':\n return (\n <ColorRow label={label} value={read<string>()} onChange={write} description={description} />\n );\n case 'paint':\n case 'object':\n // Declined: a hex swatch would write a solid over a gradient, and a flat\n // row would write one field into a half-built object. Override with\n // `render` to edit either.\n return <UnwiredRow label={label} kind={leaf.kind} description={description} />;\n default: {\n // Not reachable while every built-in kind has an arm — and a new kind\n // that lacks one is a compile error here, never a blank row.\n const _exhaustive: never = leaf;\n throw new Error(\n `ControlPanel: no control for built-in pref kind \"${(_exhaustive as { kind: string }).kind}\"`,\n );\n }\n }\n}\n\n/** A leaf this panel has no control for is named rather than dropped: a silent\n * gap reads as \"this control does not exist\". */\nfunction UnwiredRow({\n label,\n kind,\n description,\n}: {\n label: string;\n kind: string;\n description?: string;\n}) {\n return (\n <PropertyRow label={label} description={description}>\n <span className=\"lk-control-panel__unknown\">no control for “{kind}”</span>\n </PropertyRow>\n );\n}\n\n/** Text writes are debounced so typing does not re-run the instrument on every\n * keystroke, which means the row is locally controlled between commits and has\n * to notice when the config changes underneath it. */\nfunction DebouncedTextRow({\n leaf,\n label,\n value,\n write,\n layout,\n span,\n description,\n}: {\n leaf: PrefLeaf;\n label: string;\n value: string;\n write: (value: unknown) => void;\n layout?: PropertyRowLayout;\n span?: boolean;\n description?: string;\n}) {\n const debounceMs = extra<number>(leaf, 'debounceMs') ?? 150;\n const [local, setLocal] = useState(value);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const lastExternal = useRef(value);\n\n useEffect(() => {\n if (value !== lastExternal.current) {\n lastExternal.current = value;\n setLocal(value);\n }\n }, [value]);\n\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current);\n },\n [],\n );\n\n return (\n <TextRow\n label={label}\n layout={layout}\n span={span}\n description={description}\n value={local}\n placeholder={extra<string>(leaf, 'placeholder')}\n maxLength={extra<number>(leaf, 'maxLength')}\n onChange={(next) => {\n setLocal(next);\n if (timer.current) clearTimeout(timer.current);\n const commit = () => {\n lastExternal.current = next;\n write(next);\n };\n if (debounceMs === 0) commit();\n else timer.current = setTimeout(commit, debounceMs);\n }}\n />\n );\n}\n"]}
|
package/dist/controls/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ControlPanel } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ControlPanel } from '../chunk-TO2FUOKF.js';
|
|
2
|
+
import '../chunk-RBGKL7NF.js';
|
|
3
|
+
import '../chunk-L5QJOOLV.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/dragdrop/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PaletteItem, a as Point, D as DragFeedback, b as DragDropCapability, V as ViewTransform, c as WorldSpec } from '../_dts/frac-
|
|
1
|
+
import { P as PaletteItem, a as Point, D as DragFeedback, b as DragDropCapability, V as ViewTransform, c as WorldSpec } from '../_dts/frac-C-2c72Ij.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { RefObject, ReactPortal } from 'react';
|
|
4
4
|
import '../_dts/types-D6s4b7if.js';
|
package/dist/dragdrop/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DragGhost, DragOverlay, Palette, useDragDrop } from '../chunk-
|
|
1
|
+
export { DragGhost, DragOverlay, Palette, useDragDrop } from '../chunk-M75ZU6ZZ.js';
|
|
2
2
|
import '../chunk-2AYGEN57.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-L5QJOOLV.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { LayerStack, LayerStackItem, LayerStackProps } from './ui/layers/index.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { ReactNode
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
5
|
export { C as CheckboxRow, a as CheckboxRowProps, b as ColorRow, c as ColorRowProps, d as ControlPanel, N as NumberRow, e as NumberRowProps, P as PropertyList, f as PropertyListPack, g as PropertyListProps, h as PropertyOption, i as PropertyPanel, j as PropertyPanelProps, k as PropertyRow, l as PropertyRowLayout, m as PropertyRowProps, n as PropertyRowVariant, o as PropertySpan, p as PropertySpanProps, S as SelectRow, q as SelectRowProps, r as SliderRow, s as SliderRowProps, T as TextRow, t as TextRowProps, u as ToggleRow, v as ToggleRowProps } from './_dts/index-BDVzvRzQ.js';
|
|
6
6
|
import { N as Node, P as Path } from './_dts/types-C-gh9Ap-.js';
|
|
7
7
|
import { F as FillStyle, S as Stroke, D as DrawCommand, V as View, T as TextStyle } from './_dts/DrawCommand-B3bskUsC.js';
|
|
8
|
-
import { d as WorldRect, A as AnnotationData, e as AnnotationMeaning, M as MarkScene, C as CaptureSource, f as CaptureOptions, g as CaptureResult, h as AnnotationTarget, i as AnnotationsApi, j as AnnotationsCapability, T as TrialTool, k as AnnotationKind, V as ViewTransform, I as Instrument, l as InstrumentList, m as TrialContribution } from './_dts/frac-
|
|
9
|
-
export { n as Annotation, o as AnnotationInit, p as AnnotationPatch, q as AnnotationQuery, r as AnnotationStatus, s as AnnotationStoreOptions, t as AnnotationTargetInfo, u as CanvasCapability, v as CanvasLayer, w as CaptureDeps, x as DEFAULT_FRAME, b as DragDropCapability, D as DragFeedback, F as FracPoint, y as FracRect, H as HitResult, z as IconComponent, L as LOUPE_DEFAULTS, B as LayerCapability, E as LayerDescriptor, G as LoupeCapability, J as LoupeDeclaration, K as LoupeRenderArgs, P as PaletteItem, a as Point, R as RenderContext, N as ResolvedLoupe, S as SerializedAnnotations, O as SidebarSection, Q as StatusReadout, U as SystemEvent, X as ToolCapability, Y as ToolItem, Z as ToolbarItem, _ as TrialChromeContext, $ as TrialRegion, a0 as UndoCapability, a1 as ViewportControl, a2 as ViewportSize, W as WorldFrame, c as WorldSpec, a3 as annotationsFromJSON, a4 as applyCamera, a5 as createAnnotationScene, a6 as createAnnotationStore, a7 as fracContains, a8 as fracIntersects, a9 as fracToWorld, aa as resolveFrame, ab as resolveLoupe, ac as roundFrac, ad as worldToFrac } from './_dts/frac-
|
|
8
|
+
import { d as WorldRect, A as AnnotationData, e as AnnotationMeaning, M as MarkScene, C as CaptureSource, f as CaptureOptions, g as CaptureResult, h as AnnotationTarget, i as AnnotationsApi, j as AnnotationsCapability, T as TrialTool, k as AnnotationKind, V as ViewTransform, I as Instrument, l as InstrumentList, m as TrialContribution } from './_dts/frac-C-2c72Ij.js';
|
|
9
|
+
export { n as Annotation, o as AnnotationInit, p as AnnotationPatch, q as AnnotationQuery, r as AnnotationStatus, s as AnnotationStoreOptions, t as AnnotationTargetInfo, u as CanvasCapability, v as CanvasLayer, w as CaptureDeps, x as DEFAULT_FRAME, b as DragDropCapability, D as DragFeedback, F as FracPoint, y as FracRect, H as HitResult, z as IconComponent, L as LOUPE_DEFAULTS, B as LayerCapability, E as LayerDescriptor, G as LoupeCapability, J as LoupeDeclaration, K as LoupeRenderArgs, P as PaletteItem, a as Point, R as RenderContext, N as ResolvedLoupe, S as SerializedAnnotations, O as SidebarSection, Q as StatusReadout, U as SystemEvent, X as ToolCapability, Y as ToolItem, Z as ToolbarItem, _ as TrialChromeContext, $ as TrialRegion, a0 as UndoCapability, a1 as ViewportControl, a2 as ViewportSize, W as WorldFrame, c as WorldSpec, a3 as annotationsFromJSON, a4 as applyCamera, a5 as createAnnotationScene, a6 as createAnnotationStore, a7 as fracContains, a8 as fracIntersects, a9 as fracToWorld, aa as resolveFrame, ab as resolveLoupe, ac as roundFrac, ad as worldToFrac } from './_dts/frac-C-2c72Ij.js';
|
|
10
10
|
import { B as BuiltinShapeToolId } from './_dts/shapeKinds-Cx_rxwsa.js';
|
|
11
|
-
export { CanvasStack, CanvasStackProps, ZoomAtOptions, centerOn, screenToWorld, worldToScreen, zoomAt } from './canvas/index.js';
|
|
12
|
-
export { C as CanvasLayerDescriptor, a as CanvasStackContext, b as CanvasStackContextValue, c as CanvasStackSurface } from './_dts/CanvasStackContext-
|
|
11
|
+
export { CanvasStack, CanvasStackProps, OrbitHandlers, OrbitView, PITCH_LIMIT, PanZoomHandlers, UseOrbitOptions, UsePanZoomOptions, Vec3, ZoomAtOptions, centerOn, clampPitch, orbitAfterDrag, orbitAfterWheel, screenToWorld, useOrbit, usePanZoom, worldToScreen, wrapYaw, zoomAt } from './canvas/index.js';
|
|
12
|
+
export { C as CanvasLayerDescriptor, a as CanvasStackContext, b as CanvasStackContextValue, c as CanvasStackSurface } from './_dts/CanvasStackContext-LnCfqNBA.js';
|
|
13
13
|
export { PaletteRegion, PaletteRegionProps, SidebarRegion, SidebarRegionProps, StatusRegion, StatusRegionProps, TitleBarRegion, TitleBarRegionProps, ToolbarRegion, ToolbarRegionProps, ViewportRegion, ViewportRegionProps, builtinContributions, mergeContributions, suppressContributions } from './chrome/index.js';
|
|
14
14
|
import { T as ToolPrefLeaf } from './_dts/PrefsForm-BkUJZx0A.js';
|
|
15
15
|
import { b as ConfigNode, A as Annotations, N as NodeOptions, c as ControlRenderer, d as ConfigOption, a as ConfigSchema, I as InferConfig, C as ConfigField, R as ResolvedConfig, e as ConfigRule, L as LeafPatch, f as ConfigRuleContext } from './_dts/types-D6s4b7if.js';
|
|
@@ -645,51 +645,6 @@ declare function fromWeaselView(v: View): ViewTransform;
|
|
|
645
645
|
*/
|
|
646
646
|
declare function fitView(content: ContentSize, pane: PaneSize): ViewTransform;
|
|
647
647
|
|
|
648
|
-
/** A point in the space the instrument works in. */
|
|
649
|
-
interface Vec3 {
|
|
650
|
-
x: number;
|
|
651
|
-
y: number;
|
|
652
|
-
z: number;
|
|
653
|
-
}
|
|
654
|
-
/** An orbit camera as a trial view: where it looks from, and what it looks at.
|
|
655
|
-
* labkit does not turn this into a matrix — the host's renderer does. */
|
|
656
|
-
interface OrbitView {
|
|
657
|
-
yaw: number;
|
|
658
|
-
pitch: number;
|
|
659
|
-
distance: number;
|
|
660
|
-
target: Vec3;
|
|
661
|
-
}
|
|
662
|
-
/** Just short of the pole. At exactly ±PI/2 the azimuth is undefined and the
|
|
663
|
-
* camera rolls, which reads as the model jumping rather than as a limit. */
|
|
664
|
-
declare const PITCH_LIMIT: number;
|
|
665
|
-
declare function clampPitch(pitch: number): number;
|
|
666
|
-
declare function wrapYaw(yaw: number): number;
|
|
667
|
-
/** The view a drag of (dx, dy) from `start` produces. Absolute against the drag
|
|
668
|
-
* start, so it can be re-applied any number of times without compounding. */
|
|
669
|
-
declare function orbitAfterDrag(start: OrbitView, dx: number, dy: number): OrbitView;
|
|
670
|
-
/** Multiplicative, so one notch covers the same proportion of the distance
|
|
671
|
-
* whether the camera is near or far. */
|
|
672
|
-
declare function orbitAfterWheel(view: OrbitView, deltaY: number, minDistance: number, maxDistance: number): OrbitView;
|
|
673
|
-
interface UseOrbitOptions {
|
|
674
|
-
view: OrbitView;
|
|
675
|
-
onViewChange: (v: OrbitView) => void;
|
|
676
|
-
/** Restored on double-click. Defaults to the view the hook first saw. */
|
|
677
|
-
home?: OrbitView;
|
|
678
|
-
minDistance?: number;
|
|
679
|
-
maxDistance?: number;
|
|
680
|
-
}
|
|
681
|
-
interface OrbitHandlers {
|
|
682
|
-
onWheel: (e: WheelEvent<HTMLElement>) => void;
|
|
683
|
-
onPointerDown: (e: PointerEvent<HTMLElement>) => void;
|
|
684
|
-
onPointerMove: (e: PointerEvent<HTMLElement>) => void;
|
|
685
|
-
onPointerUp: (e: PointerEvent<HTMLElement>) => void;
|
|
686
|
-
onDoubleClick: () => void;
|
|
687
|
-
isDragging: () => boolean;
|
|
688
|
-
}
|
|
689
|
-
/** Pointer gestures over an orbit view: drag to turn, wheel or pinch to dolly,
|
|
690
|
-
* double-click to go home. The 3D peer of `usePanZoom`. */
|
|
691
|
-
declare function useOrbit({ view, onViewChange, home, minDistance, maxDistance, }: UseOrbitOptions): OrbitHandlers;
|
|
692
|
-
|
|
693
648
|
/** Shared chaining surface. Every method clones, so a node can be reused as a
|
|
694
649
|
* base for several leaves without one bleeding into the next. */
|
|
695
650
|
declare abstract class BaseNode<T> implements ConfigNode<T> {
|
|
@@ -1153,5 +1108,5 @@ declare function resetTrial(trials: TrialRecord[], id: string, instruments: Inst
|
|
|
1153
1108
|
*/
|
|
1154
1109
|
declare function reorderTrials(trials: TrialRecord[], ids: readonly string[]): TrialRecord[];
|
|
1155
1110
|
|
|
1156
|
-
export { ANNOTATION_TOOLS, ANNOTATION_WEASEL_TOOLS, AnnotationData, AnnotationKind, AnnotationMeaning, AnnotationOverlay, AnnotationTarget, AnnotationTargets, Annotations, AnnotationsApi, AnnotationsCapability, AnnotationsContext, CaptureOptions, CaptureResult, CaptureSource, ConfigField, ConfigNode, ConfigOption, ConfigRule, ConfigRuleContext, ConfigSchema, ControlRenderer, CurveField, DEFAULT_VIEW, EffectCard, EffectCardList, ExportMenu, InferConfig, Instrument, InstrumentList, JobHandle, Lab, LabContext, LabMode, LabPalette, LabShell, LeafPatch, MarkList, MarkScene, NodeOptions,
|
|
1157
|
-
export type { AnnotationOverlayProps, AnnotationTargetsProps, AnnotationToolInfo, CaptureArgs, CapturePlan, ComposeSvgArgs, ContentSize, CurveFieldProps, CurveMark, EffectCardListItem, EffectCardListProps, EffectCardProps, InstrumentSpec, LabContextValue, LabPaletteProps, LabProps, LabShellProps, MarkDrawOptions, MarkListProps, MarkStyle,
|
|
1111
|
+
export { ANNOTATION_TOOLS, ANNOTATION_WEASEL_TOOLS, AnnotationData, AnnotationKind, AnnotationMeaning, AnnotationOverlay, AnnotationTarget, AnnotationTargets, Annotations, AnnotationsApi, AnnotationsCapability, AnnotationsContext, CaptureOptions, CaptureResult, CaptureSource, ConfigField, ConfigNode, ConfigOption, ConfigRule, ConfigRuleContext, ConfigSchema, ControlRenderer, CurveField, DEFAULT_VIEW, EffectCard, EffectCardList, ExportMenu, InferConfig, Instrument, InstrumentList, JobHandle, Lab, LabContext, LabMode, LabPalette, LabShell, LeafPatch, MarkList, MarkScene, NodeOptions, PropertyGroup, ResolvedConfig, SavedSnapshot, StorageAdapter, Subpanel, Trial, TrialChrome, TrialContribution, TrialRecord, TrialTool, ViewTransform, Workspace, WorldRect, addTrial, annotationToolInfo, applyRules, as2DView, builtinRules, capturePlan, captureTarget, cloneTrial, closeTrial, composeCaptureSvg, createMarkDrawOne, defineInstrument, f, fitView, fromConfigFields, fromWeaselView, interstellarTheme, isLeafVisible, isStale, markCommands, markSvgNodes, reorderTrials, resetTrial, resolveConfigSchema, resolveMarkStyle, seenFrom, titleCase, toWeaselView, useAnnotations, useAnnotationsOptional, useConfigSchema, useLabContext, validateConfigSchema };
|
|
1112
|
+
export type { AnnotationOverlayProps, AnnotationTargetsProps, AnnotationToolInfo, CaptureArgs, CapturePlan, ComposeSvgArgs, ContentSize, CurveFieldProps, CurveMark, EffectCardListItem, EffectCardListProps, EffectCardProps, InstrumentSpec, LabContextValue, LabPaletteProps, LabProps, LabShellProps, MarkDrawOptions, MarkListProps, MarkStyle, PaintableMark, PaneSize, PanelDescriptor, PropertyGroupProps, SubpanelProps, TrialChromeProps, TrialLayout, TrialProps, UndoBindings, ValidationResult, ViewTransform2D, WorkspaceProps };
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { createEventBus, pushSnapshot, redo, undo } from './chunk-RL2LOLNI.js';
|
|
2
2
|
export { clearUndo, createEventBus, emptyStack, pushSnapshot, redo, undo } from './chunk-RL2LOLNI.js';
|
|
3
|
-
import { useDragDrop, DragOverlay, Palette } from './chunk-
|
|
4
|
-
import { useSurfaceOptional, useSurfaceCanvas, useTiledSurface, SurfaceContext, SurfaceCanvasContext } from './chunk-
|
|
5
|
-
export { SurfaceCanvasContext, SurfaceContext, composeRects, rectsEqual, toDeviceRect, useSurface, useSurfaceCanvas, useSurfaceOptional, useSurfaceTile, useTiledSurface } from './chunk-
|
|
3
|
+
import { useDragDrop, DragOverlay, Palette } from './chunk-M75ZU6ZZ.js';
|
|
4
|
+
import { useSurfaceOptional, useSurfaceCanvas, useTiledSurface, SurfaceContext, SurfaceCanvasContext } from './chunk-ESIQNQ6K.js';
|
|
5
|
+
export { SurfaceCanvasContext, SurfaceContext, composeRects, rectsEqual, toDeviceRect, useSurface, useSurfaceCanvas, useSurfaceOptional, useSurfaceTile, useTiledSurface } from './chunk-ESIQNQ6K.js';
|
|
6
6
|
import { useJob } from './chunk-LN6JDUGB.js';
|
|
7
7
|
export { useJob } from './chunk-LN6JDUGB.js';
|
|
8
|
-
import { ANNOTATION_WEASEL_TOOLS, annotationToolInfo, suppressContributions, mergeContributions, builtinContributions, TitleBarRegion, ToolbarRegion, PaletteRegion, SidebarRegion, ViewportRegion, StatusRegion, AnnotationsContext } from './chunk-
|
|
9
|
-
export { ANNOTATION_TOOLS, ANNOTATION_WEASEL_TOOLS, AnnotationsContext, ExportMenu, MarkList, PaletteRegion, SidebarRegion, StatusRegion, TitleBarRegion, ToolbarRegion, ViewportRegion, annotationToolInfo, builtinContributions, mergeContributions, suppressContributions, useAnnotations, useAnnotationsOptional } from './chunk-
|
|
10
|
-
import { JobProgress } from './chunk-
|
|
11
|
-
export { FloatingPanel, JobProgress, Legend, Sidebar } from './chunk-
|
|
12
|
-
export { FpsMeter, ScaleIndicator, StatusBar, Toolbar, ZoomControl } from './chunk-
|
|
8
|
+
import { ANNOTATION_WEASEL_TOOLS, annotationToolInfo, suppressContributions, mergeContributions, builtinContributions, TitleBarRegion, ToolbarRegion, PaletteRegion, SidebarRegion, ViewportRegion, StatusRegion, AnnotationsContext } from './chunk-6OEYTYML.js';
|
|
9
|
+
export { ANNOTATION_TOOLS, ANNOTATION_WEASEL_TOOLS, AnnotationsContext, ExportMenu, MarkList, PaletteRegion, SidebarRegion, StatusRegion, TitleBarRegion, ToolbarRegion, ViewportRegion, annotationToolInfo, builtinContributions, mergeContributions, suppressContributions, useAnnotations, useAnnotationsOptional } from './chunk-6OEYTYML.js';
|
|
10
|
+
import { JobProgress } from './chunk-QB5SM4BM.js';
|
|
11
|
+
export { FloatingPanel, JobProgress, Legend, Sidebar } from './chunk-QB5SM4BM.js';
|
|
12
|
+
export { FpsMeter, ScaleIndicator, StatusBar, Toolbar, ZoomControl } from './chunk-HHGVISVZ.js';
|
|
13
13
|
import { LabStoreContext, TrialIdProvider, createLabStore, panelKey, noneAdapter } from './chunk-XJ6N32QP.js';
|
|
14
14
|
export { CURRENT_DOCUMENT_VERSION, LabStoreContext, LabStoreProvider, TrialIdContext, TrialIdProvider, createMemoryAdapter, dockPanel, labDocumentKey, localStorageAdapter, noneAdapter, panelKey, quarantineKey, sessionStorageAdapter, undockPanel, urlHashAdapter, useLabStore, useTrialId, useTrialState } from './chunk-XJ6N32QP.js';
|
|
15
|
-
import { fromConfigFields } from './chunk-
|
|
16
|
-
export { ControlPanel, fromConfigFields, isLeafVisible } from './chunk-
|
|
17
|
-
import { CanvasStack } from './chunk-
|
|
18
|
-
export { CanvasStack } from './chunk-
|
|
19
|
-
import { LayerList } from './chunk-
|
|
20
|
-
export { LayerList } from './chunk-
|
|
15
|
+
import { fromConfigFields } from './chunk-TO2FUOKF.js';
|
|
16
|
+
export { ControlPanel, fromConfigFields, isLeafVisible } from './chunk-TO2FUOKF.js';
|
|
17
|
+
import { CanvasStack } from './chunk-HMFODCOX.js';
|
|
18
|
+
export { CanvasStack, PITCH_LIMIT, clampPitch, orbitAfterDrag, orbitAfterWheel, useOrbit, usePanZoom, wrapYaw } from './chunk-HMFODCOX.js';
|
|
19
|
+
import { LayerList } from './chunk-AE5CNVRU.js';
|
|
20
|
+
export { LayerList } from './chunk-AE5CNVRU.js';
|
|
21
21
|
import './chunk-SBXNQW4G.js';
|
|
22
|
-
import { C, p, r2 } from './chunk-
|
|
23
|
-
export { k2 as CheckboxRow, O2 as ColorRow, m2 as CurveField, _3 as EffectCard, y2 as EffectCardList, c3 as LayerStack, j2 as NumberRow, b3 as PropertyGroup, S2 as PropertyList, x3 as PropertyPanel, w as PropertyRow, C2 as PropertySpan, M as SelectRow, E as SliderRow, g as Subpanel, A2 as TextRow, N as ToggleRow } from './chunk-
|
|
24
|
-
import { resolveLoupe, TrialLoupe } from './chunk-
|
|
25
|
-
export { CanvasLoupe, DomLoupe, LOUPE_DEFAULTS, LoupeBubble, TrialLoupe, drawCanvasLens, lensCamera, lensSourceRect, resolveLoupe, sampleStack, useLoupe } from './chunk-
|
|
22
|
+
import { C, p, r2 } from './chunk-RBGKL7NF.js';
|
|
23
|
+
export { k2 as CheckboxRow, O2 as ColorRow, m2 as CurveField, _3 as EffectCard, y2 as EffectCardList, c3 as LayerStack, j2 as NumberRow, b3 as PropertyGroup, S2 as PropertyList, x3 as PropertyPanel, w as PropertyRow, C2 as PropertySpan, M as SelectRow, E as SliderRow, g as Subpanel, A2 as TextRow, N as ToggleRow } from './chunk-RBGKL7NF.js';
|
|
24
|
+
import { resolveLoupe, TrialLoupe } from './chunk-E2UQVZ44.js';
|
|
25
|
+
export { CanvasLoupe, DomLoupe, LOUPE_DEFAULTS, LoupeBubble, TrialLoupe, drawCanvasLens, lensCamera, lensSourceRect, resolveLoupe, sampleStack, useLoupe } from './chunk-E2UQVZ44.js';
|
|
26
26
|
export { centerOn, zoomAt } from './chunk-CTRKTLYZ.js';
|
|
27
27
|
import { applyCamera } from './chunk-2AYGEN57.js';
|
|
28
28
|
export { DEFAULT_FRAME, applyCamera, resolveFrame, screenToWorld, worldToScreen } from './chunk-2AYGEN57.js';
|
|
29
29
|
export { CanvasStackContext } from './chunk-CQLQPQ4P.js';
|
|
30
|
-
import { textCommand, linePath, markerDrawCommands, ellipsePath, rectPath, createScene, asNodeId as asNodeId$1, WeaselProvider, SceneCanvas, sceneFromJSON, PathBuilder, renderSceneToPixels, useActiveToolContext, resolveStrokeWidth, getMarker, getPaintKind, boundsOfPath, tileGeometry, PATH_M, PATH_L, PATH_C, PATH_Q, PATH_Z, SCRIPT_METRICS } from './chunk-
|
|
31
|
-
import { createContext, useState, useRef, useEffect,
|
|
30
|
+
import { textCommand, linePath, markerDrawCommands, ellipsePath, rectPath, createScene, asNodeId as asNodeId$1, WeaselProvider, SceneCanvas, sceneFromJSON, PathBuilder, renderSceneToPixels, useActiveToolContext, resolveStrokeWidth, getMarker, getPaintKind, boundsOfPath, tileGeometry, PATH_M, PATH_L, PATH_C, PATH_Q, PATH_Z, SCRIPT_METRICS } from './chunk-L5QJOOLV.js';
|
|
31
|
+
import { createContext, useState, useRef, useEffect, useContext, useMemo, Children, useLayoutEffect, useCallback, useSyncExternalStore } from 'react';
|
|
32
32
|
import { createPortal } from 'react-dom';
|
|
33
33
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
34
34
|
import { useStore } from 'zustand/react';
|
|
@@ -1153,6 +1153,34 @@ function createAnnotationStore(opts) {
|
|
|
1153
1153
|
redo() {
|
|
1154
1154
|
return history.redo(historySceneAt);
|
|
1155
1155
|
},
|
|
1156
|
+
selection() {
|
|
1157
|
+
const out = [];
|
|
1158
|
+
for (const target of liveTargets()) {
|
|
1159
|
+
const scene = scenes.get(target);
|
|
1160
|
+
if (!scene) continue;
|
|
1161
|
+
for (const node of scene.getSelection()) {
|
|
1162
|
+
if (scene.get(node)) out.push(`${target}/${String(node)}`);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return out;
|
|
1166
|
+
},
|
|
1167
|
+
setSelection(ids) {
|
|
1168
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
1169
|
+
for (const id of ids) {
|
|
1170
|
+
const found = nodeOf(id);
|
|
1171
|
+
if (!found) continue;
|
|
1172
|
+
const node = String(found.node.id);
|
|
1173
|
+
const on = wanted.get(found.target);
|
|
1174
|
+
if (!on) wanted.set(found.target, [node]);
|
|
1175
|
+
else if (!on.includes(node)) on.push(node);
|
|
1176
|
+
}
|
|
1177
|
+
for (const [target, scene] of scenes) {
|
|
1178
|
+
const next = wanted.get(target) ?? [];
|
|
1179
|
+
const now = scene.getSelection();
|
|
1180
|
+
if (now.length === next.length && next.every((n, i) => String(now[i]) === n)) continue;
|
|
1181
|
+
scene.setSelection(next.map(asNodeId$1));
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1156
1184
|
subscribe(fn) {
|
|
1157
1185
|
subs.add(fn);
|
|
1158
1186
|
return () => {
|
|
@@ -1396,86 +1424,6 @@ function AnnotationTargets({
|
|
|
1396
1424
|
t.id
|
|
1397
1425
|
)) });
|
|
1398
1426
|
}
|
|
1399
|
-
var PITCH_LIMIT = Math.PI / 2 - 0.01;
|
|
1400
|
-
var YAW_PER_PX = 8e-3;
|
|
1401
|
-
var PITCH_PER_PX = 8e-3;
|
|
1402
|
-
var DISTANCE_PER_NOTCH = 15e-4;
|
|
1403
|
-
var DRAG_THRESHOLD = 3;
|
|
1404
|
-
function clampPitch(pitch) {
|
|
1405
|
-
return Math.min(PITCH_LIMIT, Math.max(-PITCH_LIMIT, pitch));
|
|
1406
|
-
}
|
|
1407
|
-
function wrapYaw(yaw) {
|
|
1408
|
-
const wrapped = ((yaw + Math.PI) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI) - Math.PI;
|
|
1409
|
-
return wrapped === -Math.PI ? Math.PI : wrapped;
|
|
1410
|
-
}
|
|
1411
|
-
function orbitAfterDrag(start, dx, dy) {
|
|
1412
|
-
return {
|
|
1413
|
-
...start,
|
|
1414
|
-
yaw: wrapYaw(start.yaw + dx * YAW_PER_PX),
|
|
1415
|
-
pitch: clampPitch(start.pitch + dy * PITCH_PER_PX)
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
function orbitAfterWheel(view, deltaY, minDistance, maxDistance) {
|
|
1419
|
-
const factor = Math.exp(deltaY * DISTANCE_PER_NOTCH);
|
|
1420
|
-
return {
|
|
1421
|
-
...view,
|
|
1422
|
-
distance: Math.min(maxDistance, Math.max(minDistance, view.distance * factor))
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
function useOrbit({
|
|
1426
|
-
view,
|
|
1427
|
-
onViewChange,
|
|
1428
|
-
home,
|
|
1429
|
-
minDistance = 0.1,
|
|
1430
|
-
maxDistance = 1e3
|
|
1431
|
-
}) {
|
|
1432
|
-
const dragRef = useRef(null);
|
|
1433
|
-
const viewRef = useRef(view);
|
|
1434
|
-
viewRef.current = view;
|
|
1435
|
-
const homeRef = useRef(home ?? view);
|
|
1436
|
-
if (home) homeRef.current = home;
|
|
1437
|
-
const onWheel = useCallback(
|
|
1438
|
-
(e) => {
|
|
1439
|
-
e.preventDefault();
|
|
1440
|
-
onViewChange(orbitAfterWheel(viewRef.current, e.deltaY, minDistance, maxDistance));
|
|
1441
|
-
},
|
|
1442
|
-
[onViewChange, minDistance, maxDistance]
|
|
1443
|
-
);
|
|
1444
|
-
const onPointerDown = useCallback((e) => {
|
|
1445
|
-
if (e.button !== 0) return;
|
|
1446
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1447
|
-
dragRef.current = {
|
|
1448
|
-
pointerId: e.pointerId,
|
|
1449
|
-
startX: e.clientX,
|
|
1450
|
-
startY: e.clientY,
|
|
1451
|
-
startView: viewRef.current,
|
|
1452
|
-
moved: false
|
|
1453
|
-
};
|
|
1454
|
-
}, []);
|
|
1455
|
-
const onPointerMove = useCallback(
|
|
1456
|
-
(e) => {
|
|
1457
|
-
const drag = dragRef.current;
|
|
1458
|
-
if (!drag || drag.pointerId !== e.pointerId) return;
|
|
1459
|
-
const dx = e.clientX - drag.startX;
|
|
1460
|
-
const dy = e.clientY - drag.startY;
|
|
1461
|
-
if (!drag.moved && Math.hypot(dx, dy) < DRAG_THRESHOLD) return;
|
|
1462
|
-
drag.moved = true;
|
|
1463
|
-
onViewChange(orbitAfterDrag(drag.startView, dx, dy));
|
|
1464
|
-
},
|
|
1465
|
-
[onViewChange]
|
|
1466
|
-
);
|
|
1467
|
-
const onPointerUp = useCallback((e) => {
|
|
1468
|
-
const drag = dragRef.current;
|
|
1469
|
-
if (!drag || drag.pointerId !== e.pointerId) return;
|
|
1470
|
-
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1471
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1472
|
-
}
|
|
1473
|
-
dragRef.current = null;
|
|
1474
|
-
}, []);
|
|
1475
|
-
const onDoubleClick = useCallback(() => onViewChange(homeRef.current), [onViewChange]);
|
|
1476
|
-
const isDragging = useCallback(() => dragRef.current?.moved === true, []);
|
|
1477
|
-
return { onWheel, onPointerDown, onPointerMove, onPointerUp, onDoubleClick, isDragging };
|
|
1478
|
-
}
|
|
1479
1427
|
|
|
1480
1428
|
// src/config/builder.ts
|
|
1481
1429
|
var BaseNode = class {
|
|
@@ -3746,6 +3694,6 @@ function Lab({
|
|
|
3746
3694
|
) }) });
|
|
3747
3695
|
}
|
|
3748
3696
|
|
|
3749
|
-
export { AnnotationOverlay, AnnotationTargets, DEFAULT_VIEW, Lab, LabContext, LabPalette, LabShell,
|
|
3697
|
+
export { AnnotationOverlay, AnnotationTargets, DEFAULT_VIEW, Lab, LabContext, LabPalette, LabShell, Trial, TrialChrome, Workspace, addTrial, annotationsFromJSON, applyRules, as2DView, builtinRules, capturePlan, captureTarget, cloneTrial, closeTrial, composeCaptureSvg, createAnnotationScene, createAnnotationStore, createMarkDrawOne, defineInstrument, f, fitView, fracContains, fracIntersects, fracToWorld, fromWeaselView, interstellarTheme, isStale, markCommands, markSvgNodes, reorderTrials, resetTrial, resolveConfigSchema, resolveMarkStyle, roundFrac, seenFrom, titleCase, toWeaselView, useConfigSchema, useLabContext, validateConfigSchema, worldToFrac };
|
|
3750
3698
|
//# sourceMappingURL=index.js.map
|
|
3751
3699
|
//# sourceMappingURL=index.js.map
|