@sylwellsoftware/fray 0.2.0 → 0.4.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.
Files changed (59) hide show
  1. package/README.md +139 -13
  2. package/dist/Components/Placeholder.d.ts +1 -1
  3. package/dist/Components/Placeholder.d.ts.map +1 -1
  4. package/dist/Components/component.d.ts +5 -0
  5. package/dist/Components/component.d.ts.map +1 -1
  6. package/dist/Components/controlUtils.d.ts.map +1 -1
  7. package/dist/Components/data/filterState.d.ts +38 -0
  8. package/dist/Components/data/filterState.d.ts.map +1 -0
  9. package/dist/Components/data/listview/listview.d.ts +16 -5
  10. package/dist/Components/data/listview/listview.d.ts.map +1 -1
  11. package/dist/Components/data/selectionhandler.d.ts +24 -5
  12. package/dist/Components/data/selectionhandler.d.ts.map +1 -1
  13. package/dist/Components/data/table/DataTable.d.ts +36 -30
  14. package/dist/Components/data/table/DataTable.d.ts.map +1 -1
  15. package/dist/Components/data/table/FilterPanel.d.ts +8 -1
  16. package/dist/Components/data/table/FilterPanel.d.ts.map +1 -1
  17. package/dist/Components/data/table/TableHeaderCell.d.ts.map +1 -1
  18. package/dist/Components/data/table/tableDataSource.d.ts +49 -0
  19. package/dist/Components/data/table/tableDataSource.d.ts.map +1 -0
  20. package/dist/Components/data/table/tableQuery.d.ts +6 -2
  21. package/dist/Components/data/table/tableQuery.d.ts.map +1 -1
  22. package/dist/Components/data/treeview/treeModel.d.ts +23 -0
  23. package/dist/Components/data/treeview/treeModel.d.ts.map +1 -0
  24. package/dist/Components/data/treeview/treeview.d.ts +1 -1
  25. package/dist/Components/data/treeview/treeview.d.ts.map +1 -1
  26. package/dist/Components/dialog/dialog.d.ts +1 -1
  27. package/dist/Components/dialog/dialog.d.ts.map +1 -1
  28. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts +1 -1
  29. package/dist/Components/lineinputs/checkbox/Checkbox.d.ts.map +1 -1
  30. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts +2 -2
  31. package/dist/Components/lineinputs/checkbox/QuadCheckbox.d.ts.map +1 -1
  32. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts +2 -2
  33. package/dist/Components/lineinputs/checkbox/TriCheckbox.d.ts.map +1 -1
  34. package/dist/index.d.ts +15 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +2680 -726
  37. package/dist/index.js.map +1 -1
  38. package/dist/{jsx-dev-runtime-DukiDpV9.js → jsx-dev-runtime-pzseD2Sz.js} +527 -414
  39. package/dist/jsx-dev-runtime-pzseD2Sz.js.map +1 -0
  40. package/dist/jsx-dev-runtime.js +3 -3
  41. package/dist/jsx-runtime.js +2 -2
  42. package/dist/runtime.d.ts +4 -0
  43. package/dist/runtime.d.ts.map +1 -1
  44. package/dist/services.d.ts +45 -0
  45. package/dist/services.d.ts.map +1 -0
  46. package/dist/util/filterMode.d.ts +6 -4
  47. package/dist/util/filterMode.d.ts.map +1 -1
  48. package/package.json +4 -9
  49. package/styles/structural.css +9 -3
  50. package/themes/README.md +1 -1
  51. package/themes/minimal/theme.css +1 -1
  52. package/EXPERIMENTAL.md +0 -75
  53. package/dist/button-CqDGmkBt.js +0 -212
  54. package/dist/button-CqDGmkBt.js.map +0 -1
  55. package/dist/experimental.d.ts +0 -16
  56. package/dist/experimental.d.ts.map +0 -1
  57. package/dist/experimental.js +0 -1399
  58. package/dist/experimental.js.map +0 -1
  59. package/dist/jsx-dev-runtime-DukiDpV9.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime-pzseD2Sz.js","sources":["../src/styling/baseStyleDefinitions.ts","../src/styling/styleRegistry.ts","../src/services.ts","../src/runtime.ts","../src/Components/component.ts","../src/jsx-runtime.ts"],"sourcesContent":["export type CSSDeclarations = Record<string, string>\nexport type CSSVariantMap = Record<string, CSSDeclarations>\nexport type BaseStyleDefinition = Record<string, string | CSSVariantMap>\n\nexport const baseStyleDefinitions = {\n after: {\n content: '\"\"',\n display: 'block',\n position: 'absolute',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%',\n 'pointer-events': 'none',\n },\n\n inputline: {\n display: 'flex',\n 'flex-flow': 'row nowrap',\n position: 'relative',\n 'line-height': 'var(--fray-line-height, 1.25)',\n 'font-size': 'var(--fray-font-size, var(--ui-font-size))',\n 'min-height': 'var(--fray-control-min-height, 2rem)',\n color: 'var(--fray-ui-color, var(--ui-text-color))',\n 'border-radius': 'var(--fray-radius-md, var(--ui-border-radius))',\n 'box-sizing': 'border-box',\n },\n\n input: {\n background: 'var(--fray-input-background, var(--ui-input-bg))',\n color: 'var(--fray-input-color, var(--fray-ui-color, var(--ui-text-color)))',\n padding: 'var(--ui-padding-v, 0.25rem) var(--ui-padding-h, 0.5rem)',\n 'pointer-events': 'all',\n border: 'var(--fray-input-border, var(--ui-input-border))',\n width: 'var(--input-width, 15rem)',\n 'box-shadow': 'var(--fray-input-shadow, var(--input-shadow, none))',\n 'box-sizing': 'border-box',\n 'white-space': 'nowrap',\n variants: {\n ':focus-visible': {\n outline: '2px solid transparent',\n 'outline-offset': '1px',\n 'border-color': 'var(--fray-color-focus, var(--ui-accent-color))',\n 'box-shadow': 'var(--fray-focus-ring, 0 0 0 2px var(--ui-accent-color-highlight))',\n },\n ':disabled': {\n background: 'var(--fray-input-background-disabled, var(--ui-input-bg-disabled))',\n 'border-color': 'var(--fray-color-border, var(--ui-input-border-disabled))',\n color: 'var(--fray-input-color-disabled, var(--ui-input-text-color-disabled))',\n cursor: 'not-allowed',\n },\n },\n },\n\n inputlike: {\n background: 'var(--fray-input-background, var(--ui-input-bg))',\n color: 'var(--fray-input-color, var(--fray-ui-color, var(--ui-text-color)))',\n padding: 'var(--ui-padding-v, 0.25rem) var(--ui-padding-h, 0.5rem)',\n 'pointer-events': 'all',\n border: 'var(--fray-input-border, var(--ui-input-border))',\n 'box-shadow': 'var(--fray-input-shadow, var(--input-shadow, none))',\n 'box-sizing': 'border-box',\n 'white-space': 'nowrap',\n 'border-radius': 'var(--fray-radius-md, var(--ui-border-radius))',\n },\n\n labeledinput: {\n display: 'flex',\n 'flex-flow': 'row nowrap',\n 'align-items': 'center',\n gap: '.5em',\n },\n\n label: {\n color: 'var(--fray-ui-color, var(--ui-text-color))',\n 'font-size': 'var(--fray-font-size, var(--ui-font-size))',\n },\n\n disabled: {\n 'border-color': 'var(--fray-color-border, var(--ui-input-border-disabled))',\n color: 'var(--fray-input-color-disabled, var(--ui-input-text-color-disabled))',\n },\n\n error: {\n color: 'var(--fray-color-error, var(--error-color))',\n },\n\n working: {\n display: 'inline',\n position: 'absolute',\n 'z-index': '1',\n margin: 'auto',\n animation: 'fray-placeholder-progress 0.8s linear infinite',\n 'background-repeat': 'repeat',\n 'background-size': '2rem 2rem',\n 'background-image': 'var(--fray-working-background-image)',\n border: '0 solid transparent',\n 'border-radius': 'inherit',\n 'box-sizing': 'border-box',\n },\n\n panel: {\n background: 'var(--fray-panel-background, var(--panel-bg))',\n border: 'var(--fray-panel-border, var(--panel-border))',\n 'border-radius': 'var(--fray-panel-radius, var(--panel-radius))',\n 'box-shadow': 'var(--fray-panel-shadow, var(--panel-shadow))',\n color: 'var(--fray-panel-color, var(--panel-color))',\n },\n\n sectionheader: {\n 'box-shadow': 'var(--fray-section-header-shadow, var(--fray-header-shadow, var(--sectionheader-shadow)))',\n background: 'var(--fray-section-header-background, var(--fray-header-background, var(--sectionheader-bg)))',\n color: 'var(--fray-section-header-color, var(--fray-header-color, var(--sectionheader-color)))',\n border: 'var(--fray-section-header-border, var(--fray-header-border, 0 solid transparent))',\n },\n\n uiline: {\n 'box-sizing': 'border-box',\n 'line-height': 'var(--fray-line-height, 1.25)',\n 'font-size': 'var(--fray-font-size, var(--ui-font-size))',\n 'min-height': 'var(--fray-control-min-height, 2rem)',\n color: 'var(--fray-ui-color, var(--ui-text-color))',\n padding: 'var(--ui-padding-v, 0.25rem) var(--ui-padding-h, 0.5rem)',\n 'border-radius': 'var(--fray-radius-md, var(--ui-border-radius))',\n cursor: 'pointer',\n 'user-select': 'none',\n },\n\n noselect: {\n 'user-select': 'var(--noselect-user-select)',\n 'cursor': 'var(--noselect-cursor)',\n },\n\n button: {\n 'box-sizing': 'border-box',\n background: 'var(--fray-button-background, var(--button-background))',\n border: 'var(--fray-button-border, var(--button-border))',\n 'box-shadow': 'var(--fray-button-shadow, var(--button-shadow))',\n color: 'var(--fray-button-color, var(--button-color))',\n cursor: 'default',\n 'user-select': 'none',\n variants: {\n ':hover': {\n background: 'var(--fray-button-background-hover, var(--button-background-hover))',\n 'box-shadow': 'var(--fray-button-shadow, var(--button-shadow))',\n },\n ':focus-visible': {\n outline: '2px solid transparent',\n 'outline-offset': '1px',\n border: '1px solid var(--fray-color-focus, var(--ui-accent-color))',\n 'box-shadow': 'var(--fray-focus-ring, 0 0 0 2px var(--ui-accent-color-highlight))',\n },\n ':disabled': {\n background: 'var(--fray-button-background-disabled, var(--button-background-disabled))',\n border: 'var(--button-border-disabled, var(--fray-button-border))',\n color: 'var(--fray-input-color-disabled, var(--ui-input-text-color-disabled))',\n cursor: 'not-allowed',\n 'pointer-events': 'none',\n },\n },\n },\n\n toolbar: {\n background: 'var(--fray-toolbar-background, var(--toolbar-bg))',\n border: 'var(--fray-toolbar-border, var(--toolbar-border))',\n 'border-radius': 'var(--toolbar-radius, var(--fray-radius-md))',\n 'box-shadow': 'var(--fray-toolbar-shadow, var(--toolbar-shadow))',\n color: 'var(--fray-toolbar-color, var(--toolbar-color))',\n },\n\n} satisfies Record<string, BaseStyleDefinition>\n\nexport type BaseStyleName = keyof typeof baseStyleDefinitions\n","import {\n baseStyleDefinitions,\n} from './baseStyleDefinitions.js'\nimport type {\n BaseStyleDefinition,\n BaseStyleName,\n CSSDeclarations,\n CSSVariantMap,\n} from './baseStyleDefinitions.js'\n\nconst STYLE_ATTRIBUTE = 'data-fray-structural-styles'\nlet nextRegistryId = 1\n\n/** Application-scoped structural-style collection and injection. */\nexport class StyleRegistry {\n readonly id: string\n private readonly cssFragments = new Set<string>()\n private readonly baseStyleMap = new Map<BaseStyleName, Set<string>>()\n\n constructor(id: string = `runtime-${nextRegistryId++}`) {\n if (typeof id !== 'string') throw new TypeError('StyleRegistry id must be a string')\n this.id = id\n }\n\n registerCSS(css: string): this {\n if (typeof css !== 'string') throw new TypeError('Component CSS must be a string')\n if (css.trim().length > 0) this.cssFragments.add(css.trim())\n return this\n }\n\n registerBaseStyle(selector: string, styleNames: string | readonly string[]): this {\n if (typeof selector !== 'string' || selector.trim().length === 0) {\n throw new TypeError('Base style selector must be a non-empty string')\n }\n const names = typeof styleNames === 'string' ? [styleNames] : styleNames\n if (!Array.isArray(names)) {\n throw new TypeError('Base style names must be a string or array')\n }\n\n for (const name of names) {\n if (!Object.hasOwn(baseStyleDefinitions, name)) {\n throw new Error(`Unknown Fray base style: ${String(name)}`)\n }\n const styleName = name as BaseStyleName\n const selectors = this.baseStyleMap.get(styleName) ?? new Set<string>()\n selectors.add(selector.trim())\n this.baseStyleMap.set(styleName, selectors)\n }\n return this\n }\n\n generateRootCSS(): string {\n return `*, *::before, *::after {\n box-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n scroll-behavior: auto !important;\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n }\n}\n\n@media (forced-colors: active) {\n :focus-visible {\n outline: 2px solid Highlight !important;\n outline-offset: 2px !important;\n }\n}`\n }\n\n generateBaseStyleCSS(): string {\n let generated = ''\n for (const [name, selectors] of this.baseStyleMap) {\n const {properties, variants} = splitDefinition(baseStyleDefinitions[name])\n const selectorList = [...selectors]\n generated += renderRule(name, selectorList, properties)\n for (const [variant, variantProperties] of Object.entries(variants)) {\n generated += renderRule(\n `${name}${variant}`,\n selectorList.map((selector) => appendVariant(selector, variant)),\n variantProperties,\n )\n }\n }\n return generated.trim()\n }\n\n generateCSS(): string {\n return [\n this.generateRootCSS(),\n this.generateBaseStyleCSS(),\n [...this.cssFragments].join('\\n\\n'),\n ].filter(Boolean).join('\\n\\n')\n }\n\n injectAll(targetDocument: Document = globalThis.document): HTMLStyleElement {\n if (targetDocument?.head == null) {\n throw new TypeError('StyleRegistry.injectAll requires a document with a head')\n }\n const selector = `style[${STYLE_ATTRIBUTE}=\"${escapeAttributeValue(this.id)}\"]`\n let style = targetDocument.head.querySelector<HTMLStyleElement>(selector)\n if (style == null) {\n style = targetDocument.createElement('style')\n style.setAttribute(STYLE_ATTRIBUTE, this.id)\n targetDocument.head.prepend(style)\n }\n const css = this.generateCSS()\n if (style.textContent !== css) style.textContent = css\n return style\n }\n\n reset(): void {\n this.cssFragments.clear()\n this.baseStyleMap.clear()\n }\n}\n\n/** Create an isolated registry for a configured Fray application runtime. */\nexport function createStyleRegistry(): StyleRegistry {\n return new StyleRegistry()\n}\n\n/** Backward-compatible structural styles for the default Fray runtime. */\nexport const styleRegistry = new StyleRegistry('')\n\nfunction splitDefinition(definition: BaseStyleDefinition): {\n properties: CSSDeclarations\n variants: CSSVariantMap\n} {\n const properties: CSSDeclarations = {}\n let variants: CSSVariantMap = {}\n for (const [property, value] of Object.entries(definition)) {\n if (property === 'variants') {\n if (typeof value !== 'object') {\n throw new TypeError('Base style variants must be declaration maps')\n }\n variants = value\n } else if (typeof value === 'string') {\n properties[property] = value\n } else {\n throw new TypeError(`Base style property ${property} must be a string`)\n }\n }\n return {properties, variants}\n}\n\nfunction renderRule(\n label: string,\n selectors: string[],\n properties: CSSDeclarations,\n): string {\n if (selectors.length === 0 || Object.keys(properties).length === 0) return ''\n const declarations = Object.entries(properties)\n .map(([property, value]) => ` ${property}: ${value};`)\n .join('\\n')\n return `/* ${label} */\\n${selectors.join(',\\n')} {\\n${declarations}\\n}\\n\\n`\n}\n\nfunction appendVariant(selector: string, variant: string): string {\n const pseudoElement = selector.indexOf('::')\n if (pseudoElement < 0) return `${selector}${variant}`\n return `${selector.slice(0, pseudoElement)}${variant}${selector.slice(pseudoElement)}`\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"')\n}\n","declare const serviceType: unique symbol\ndeclare const serviceProviderType: unique symbol\n\n/** Typed identity for one application service contract. */\nexport interface ServiceKey<TService> {\n readonly name: string\n readonly [serviceType]: TService\n}\n\n/** Read-only service access exposed to service factories. */\nexport interface ServiceResolver {\n has(key: ServiceKey<unknown>): boolean\n require<TService>(key: ServiceKey<TService>): TService\n}\n\nexport type ServiceFactory<TService> = (services: ServiceResolver) => TService\n\n/** Immutable registration for a lazily created, scope-shared service. */\nexport interface ServiceProvider<TService> {\n readonly key: ServiceKey<TService>\n readonly create: ServiceFactory<TService>\n readonly [serviceProviderType]: true\n}\n\nconst serviceKeys = new WeakSet<object>()\nconst serviceProviders = new WeakSet<object>()\n\n/** Declare a typed service identity without selecting an implementation. */\nexport function defineService<TService>(name: string): ServiceKey<TService> {\n if (typeof name !== 'string' || name.trim() === '') {\n throw new TypeError('Service name must be a non-empty string')\n }\n const key = Object.freeze({name: name.trim()}) as ServiceKey<TService>\n serviceKeys.add(key)\n return key\n}\n\n/** Select the factory for a service in one application composition root. */\nexport function provideService<TService>(\n key: ServiceKey<TService>,\n create: ServiceFactory<TService>,\n): ServiceProvider<TService> {\n assertServiceKey(key)\n if (typeof create !== 'function') {\n throw new TypeError(`Service provider \"${key.name}\" requires a factory function`)\n }\n const provider = Object.freeze({key, create}) as ServiceProvider<TService>\n serviceProviders.add(provider)\n return provider\n}\n\n/**\n * Explicit application service scope.\n *\n * Providers are fixed at construction. Each service is created lazily at most\n * once, shared inside this scope, and disposed in reverse creation order.\n */\nexport class ServiceScope implements ServiceResolver {\n private readonly providers = new Map<ServiceKey<unknown>, ServiceProvider<unknown>>()\n private readonly instances = new Map<ServiceKey<unknown>, unknown>()\n private readonly creationOrder: ServiceKey<unknown>[] = []\n private readonly resolving: ServiceKey<unknown>[] = []\n private disposed = false\n\n constructor(providers: readonly ServiceProvider<unknown>[] = []) {\n if (!Array.isArray(providers)) {\n throw new TypeError('ServiceScope providers must be an array')\n }\n for (const provider of providers) {\n assertServiceProvider(provider)\n if (this.providers.has(provider.key)) {\n throw new Error(`Service \"${provider.key.name}\" is registered more than once`)\n }\n this.providers.set(provider.key, provider)\n }\n }\n\n get isDisposed(): boolean {\n return this.disposed\n }\n\n has(key: ServiceKey<unknown>): boolean {\n this.assertActive()\n assertServiceKey(key)\n return this.providers.has(key)\n }\n\n require<TService>(key: ServiceKey<TService>): TService {\n this.assertActive()\n assertServiceKey(key)\n if (this.instances.has(key)) return this.instances.get(key) as TService\n\n const provider = this.providers.get(key) as ServiceProvider<TService> | undefined\n if (provider == null) throw new Error(`Service \"${key.name}\" is not registered`)\n\n const cycleStart = this.resolving.indexOf(key)\n if (cycleStart >= 0) {\n const cycle = [...this.resolving.slice(cycleStart), key]\n .map((entry) => entry.name)\n .join(' -> ')\n throw new Error(`Circular service dependency: ${cycle}`)\n }\n\n this.resolving.push(key)\n try {\n const instance = provider.create(this)\n this.instances.set(key, instance)\n this.creationOrder.push(key)\n return instance\n } finally {\n this.resolving.pop()\n }\n }\n\n dispose(): void {\n if (this.disposed) return\n this.disposed = true\n const errors: unknown[] = []\n for (const key of [...this.creationOrder].reverse()) {\n const instance = this.instances.get(key)\n try {\n const dispose = readDispose(instance)\n if (dispose != null) dispose.call(instance)\n } catch (error) {\n errors.push(error)\n }\n }\n this.instances.clear()\n this.creationOrder.length = 0\n this.resolving.length = 0\n if (errors.length === 1) throw errors[0]\n if (errors.length > 1) {\n throw new AggregateError(errors, 'Several services failed during disposal')\n }\n }\n\n private assertActive(): void {\n if (this.disposed) throw new Error('ServiceScope has been disposed')\n }\n}\n\nexport function createServiceScope(\n providers: readonly ServiceProvider<unknown>[] = [],\n): ServiceScope {\n return new ServiceScope(providers)\n}\n\nfunction isServiceKey(value: unknown): value is ServiceKey<unknown> {\n return value != null\n && (typeof value === 'object' || typeof value === 'function')\n && serviceKeys.has(value as object)\n}\n\nfunction assertServiceKey(value: unknown): asserts value is ServiceKey<unknown> {\n if (!isServiceKey(value)) throw new TypeError('Expected a service key created by defineService()')\n}\n\nfunction assertServiceProvider(\n value: unknown,\n): asserts value is ServiceProvider<unknown> {\n if (value == null\n || (typeof value !== 'object' && typeof value !== 'function')\n || !serviceProviders.has(value as object)) {\n throw new TypeError('Expected a service provider created by provideService()')\n }\n}\n\nfunction readDispose(value: unknown): (() => void) | null {\n if (value == null || (typeof value !== 'object' && typeof value !== 'function')) return null\n const dispose = Reflect.get(value, 'dispose')\n return typeof dispose === 'function' ? dispose as () => void : null\n}\n","import type {\n Component,\n ComponentDependency,\n} from './Components/component.js'\nimport {\n createStyleRegistry,\n styleRegistry,\n} from './styling/styleRegistry.js'\nimport type {StyleRegistry} from './styling/styleRegistry.js'\nimport {ServiceScope, createServiceScope} from './services.js'\n\nconst RESERVED_CUSTOM_ELEMENT_NAMES = new Set([\n 'annotation-xml',\n 'color-profile',\n 'font-face',\n 'font-face-src',\n 'font-face-uri',\n 'font-face-format',\n 'font-face-name',\n 'missing-glyph',\n])\n\nexport interface FrayElementNameOptions {\n /** Namespace prepended to component host names. Defaults to `fray`. */\n prefix?: string | null\n /** Complete standards-valid tag names keyed by stable component host name. */\n overrides?: Readonly<Record<string, string>>\n}\n\nexport interface FrayRuntimeOptions {\n elementNames?: FrayElementNameOptions\n /** Service scope inherited by every component created or mounted here. */\n services?: ServiceScope\n}\n\n/** Immutable application scope for element naming and structural styles. */\nexport class FrayRuntime {\n readonly elementPrefix: string | null\n readonly elementNameOverrides: Readonly<Record<string, string>>\n readonly styleRegistry: StyleRegistry\n readonly services: ServiceScope\n\n constructor(\n options: FrayRuntimeOptions = {},\n registry: StyleRegistry = createStyleRegistry(),\n ) {\n if (options == null || typeof options !== 'object' || Array.isArray(options)) {\n throw new TypeError('FrayRuntime options must be an object')\n }\n const elementNames = options.elementNames ?? {}\n if (elementNames == null\n || typeof elementNames !== 'object'\n || Array.isArray(elementNames)) {\n throw new TypeError('Fray elementNames must be an object')\n }\n const prefix = elementNames.prefix === undefined ? 'fray' : elementNames.prefix\n if (prefix !== null) assertNamePart(prefix, 'Fray element prefix')\n\n const overrides = elementNames.overrides ?? {}\n if (overrides == null || typeof overrides !== 'object' || Array.isArray(overrides)) {\n throw new TypeError('Fray element-name overrides must be an object')\n }\n for (const [componentName, tagName] of Object.entries(overrides)) {\n assertNamePart(componentName, 'Fray component host name')\n assertCustomElementName(tagName)\n }\n\n this.elementPrefix = prefix\n this.elementNameOverrides = Object.freeze({...overrides})\n this.styleRegistry = registry\n this.services = options.services ?? createServiceScope()\n if (!(this.services instanceof ServiceScope)) {\n throw new TypeError('Fray services must be a ServiceScope')\n }\n }\n\n resolveElementName(hostName: string, standaloneHostName: string | null = null): string {\n assertNamePart(hostName, 'Fray component host name')\n const override = this.elementNameOverrides[hostName]\n const resolved = override\n ?? (this.elementPrefix == null\n ? standaloneHostName ?? hostName\n : `${this.elementPrefix}-${hostName}`)\n assertCustomElementName(resolved)\n return resolved\n }\n\n resolveHostSelector(\n selector: string,\n hostName: string,\n standaloneHostName: string | null = null,\n ): string {\n if (typeof selector !== 'string') throw new TypeError('Host selector must be a string')\n return selector.replaceAll('&', this.resolveElementName(hostName, standaloneHostName))\n }\n\n resolveHostCSS(\n cssText: string,\n hostName: string,\n standaloneHostName: string | null = null,\n ): string {\n if (typeof cssText !== 'string') throw new TypeError('Host CSS must be a string')\n return cssText.replaceAll('&', this.resolveElementName(hostName, standaloneHostName))\n }\n\n create<TArgs extends unknown[], TComponent extends Component>(\n componentType: new(...args: TArgs) => TComponent,\n ...args: TArgs\n ): TComponent {\n const component = new componentType(...args)\n component._setRuntime(this)\n return component\n }\n\n mount<TComponent extends Component>(\n component: TComponent,\n parent: ParentNode,\n before: Node | null = null,\n ): TComponent {\n component._setRuntime(this)\n component.mount(parent, before)\n return component\n }\n\n registerStyles(dependency: ComponentDependency): this {\n if (dependency == null || typeof dependency.registerStyles !== 'function') {\n throw new TypeError('registerStyles requires a Fray component dependency')\n }\n dependency.registerStyles(this)\n return this\n }\n\n injectStyles(targetDocument: Document = globalThis.document): HTMLStyleElement {\n return this.styleRegistry.injectAll(targetDocument)\n }\n}\n\nexport function createFrayRuntime(options: FrayRuntimeOptions = {}): FrayRuntime {\n return new FrayRuntime(options)\n}\n\n/** Runtime used by Component.new(), direct mount(), and the legacy styleRegistry export. */\nexport const defaultFrayRuntime = new FrayRuntime({}, styleRegistry)\n\nfunction assertNamePart(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value)) {\n throw new TypeError(`${label} must be a lowercase kebab-case name`)\n }\n}\n\nfunction assertCustomElementName(value: unknown): asserts value is string {\n assertNamePart(value, 'Fray element name')\n if (!value.includes('-') || RESERVED_CUSTOM_ELEMENT_NAMES.has(value)) {\n throw new TypeError(`Fray element name must be a non-reserved name containing a hyphen: ${value}`)\n }\n}\n","import type {\n EventBubble,\n FetchStateValue,\n ReadableEmitter,\n} from '@sylwellsoftware/glue'\n\nimport {FrayRuntime, defaultFrayRuntime} from '../runtime.js'\nimport type {ServiceKey} from '../services.js'\n\nexport const Fragment = Symbol.for('@sylwellsoftware/fray.Fragment')\n\nexport type Key = string | number\n\nexport interface ComponentProps {\n key?: Key | null\n children?: FrayChild | readonly FrayChild[]\n class?: string | null\n className?: string | null\n [name: string]: unknown\n}\n\nexport type Ref<TNode extends Node = Node> =\n | ((value: TNode | null) => void)\n | {current: TNode | null}\n\nexport type FunctionComponent<TProps extends ComponentProps = ComponentProps> = (\n props: TProps,\n) => FrayChild\n\nexport type ComponentConstructor<\n TProps extends ComponentProps = ComponentProps,\n TInstance extends Component<TProps> = Component<TProps>,\n> = new(props: TProps) => TInstance\n\ntype AnyComponentConstructor = new(props?: never) => Component\ntype ConcreteComponentConstructor = new(...args: never[]) => Component\n\nexport type VNodeType<TProps extends ComponentProps = ComponentProps> =\n | string\n | typeof Fragment\n | ComponentConstructor<TProps>\n | FunctionComponent<TProps>\n\nexport interface VNode<TProps extends ComponentProps = ComponentProps> {\n readonly type: string | typeof Fragment | Function\n readonly key: Key | null\n readonly props: TProps & {children: NormalizedChild[]}\n}\n\nexport type FrayChild =\n | string\n | number\n | boolean\n | null\n | undefined\n | VNode\n | Component\n | ReadableEmitter<FrayChild, unknown>\n | readonly FrayChild[]\n\ntype NormalizedChild = string | number | VNode | Component | ReadableEmitter<FrayChild, unknown>\n\ndeclare const liveBindingBrand: unique symbol\n\n/** Explicitly subscribe a DOM or component property to an emitter's current value. */\nexport interface LiveBinding<TValue> {\n readonly emitter: ReadableEmitter<TValue, unknown>\n readonly [liveBindingBrand]: true\n}\n\n/** Minimal writable Glue contract used by native `bind:value` and `bind:checked`. */\nexport interface WritableEmitter<TValue, TError = unknown>\nextends ReadableEmitter<TValue, TError> {\n set(value: TValue, eventOrCause?: unknown): unknown\n}\n\nexport interface EmitterSnapshot<TValue, TError = unknown> {\n readonly value: TValue\n readonly fetchState: FetchStateValue\n readonly error: TError | null\n}\n\nexport type TemplateProps<TProps extends ComponentProps> = {\n [TName in keyof TProps]: TName extends 'key' | 'children'\n ? TProps[TName]\n : TProps[TName] | LiveBinding<Exclude<TProps[TName], undefined>>\n}\n\nexport type BaseStyleNames = string | readonly string[]\nexport type BaseStyles =\n | Readonly<Record<string, BaseStyleNames>>\n | ReadonlyArray<readonly [string, BaseStyleNames]>\n\nexport interface ComponentDependency {\n registerStyles(runtime?: FrayRuntime, seen?: Set<ComponentDependency>): void\n}\n\ninterface Watchable {\n subscribe(\n listener: (notification: {event: EventBubble<unknown> | null}) => void,\n options?: {emitCurrent?: boolean},\n ): () => void\n}\n\nconst liveBindingValues = new WeakSet<object>()\n\nconst BOOLEAN_ATTRIBUTES = new Set([\n 'allowFullScreen',\n 'async',\n 'autoFocus',\n 'autoPlay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formNoValidate',\n 'hidden',\n 'inert',\n 'loop',\n 'multiple',\n 'muted',\n 'noModule',\n 'noValidate',\n 'open',\n 'playsInline',\n 'readOnly',\n 'required',\n 'reversed',\n 'selected',\n])\n\nconst PROPERTY_PROPS = new Set([\n 'checked',\n 'defaultChecked',\n 'defaultValue',\n 'disabled',\n 'indeterminate',\n 'multiple',\n 'muted',\n 'readOnly',\n 'required',\n 'selected',\n 'selectedIndex',\n 'tabIndex',\n 'value',\n])\n\n/** Mark an emitter as a one-way live value for a DOM or component property. */\nexport function live<TValue>(emitter: ReadableEmitter<TValue, unknown>): LiveBinding<TValue> {\n assertReadableEmitter(emitter, 'live')\n const binding = Object.freeze({emitter}) as LiveBinding<TValue>\n liveBindingValues.add(binding)\n return binding\n}\n\n/** Build a Fray virtual node. */\nexport function h<TProps extends ComponentProps = ComponentProps>(\n type: VNodeType<TProps>,\n props: TemplateProps<TProps> | null = null,\n ...children: FrayChild[]\n): VNode<TProps> {\n const suppliedProps = props ?? {} as TemplateProps<TProps>\n if (typeof suppliedProps !== 'object' || Array.isArray(suppliedProps)) {\n throw new TypeError('VNode props must be an object or null')\n }\n const {\n children: propChildren,\n key = null,\n ...restProps\n } = suppliedProps\n return {\n type,\n key,\n props: {\n ...restProps,\n children: normalizeChildren([propChildren, children]),\n } as TProps & {children: NormalizedChild[]},\n }\n}\n\ntype LiveValue<TValue> = TValue | LiveBinding<Exclude<TValue, undefined>>\n\ntype AriaAttributes = {\n [TName in `aria-${string}`]?: LiveValue<string | number | boolean | null | undefined>\n}\n\ntype DataAttributes = {\n [TName in `data-${string}`]?: LiveValue<string | number | boolean | null | undefined>\n}\n\ninterface DOMEvents<TElement extends HTMLElement> {\n onClick?: ((event: MouseEvent & {currentTarget: TElement}) => void) | undefined\n onInput?: ((event: InputEvent & {currentTarget: TElement}) => void) | undefined\n onChange?: ((event: Event & {currentTarget: TElement}) => void) | undefined\n onKeyDown?: ((event: KeyboardEvent & {currentTarget: TElement}) => void) | undefined\n onKeyUp?: ((event: KeyboardEvent & {currentTarget: TElement}) => void) | undefined\n onFocus?: ((event: FocusEvent & {currentTarget: TElement}) => void) | undefined\n onBlur?: ((event: FocusEvent & {currentTarget: TElement}) => void) | undefined\n}\n\ntype FrayDOMProps<TElement extends HTMLElement> =\nOmit<ComponentProps, 'class' | 'className'>\n& DOMEvents<TElement>\n& AriaAttributes\n& DataAttributes\n& {\n class?: LiveValue<string | undefined>\n className?: LiveValue<string | undefined>\n for?: string | undefined\n htmlFor?: string | undefined\n ref?: Ref<TElement> | undefined\n style?: LiveValue<string | Record<string, string | number | null | undefined> | undefined>\n}\n\ntype LiveDOMProperties<TElement extends HTMLElement> = {\n [TName in keyof Omit<TElement, keyof ComponentProps | 'style' | 'children'>]?:\n LiveValue<TElement[TName] | undefined>\n}\n\ntype NativeValueBinding<TElement extends HTMLElement> =\n TElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement\n ? {'bind:value'?: WritableEmitter<string> | undefined}\n : {}\n\ntype NativeCheckedBinding<TElement extends HTMLElement> =\n TElement extends HTMLInputElement\n ? {'bind:checked'?: WritableEmitter<boolean> | undefined}\n : {}\n\nexport type FrayIntrinsicElements = {\n [TTag in keyof HTMLElementTagNameMap]: FrayDOMProps<HTMLElementTagNameMap[TTag]>\n & LiveDOMProperties<HTMLElementTagNameMap[TTag]>\n & NativeValueBinding<HTMLElementTagNameMap[TTag]>\n & NativeCheckedBinding<HTMLElementTagNameMap[TTag]>\n}\n\n/** Classic JSX type namespace for consumers configured with `jsxFactory: \"h\"`. */\nexport namespace h {\n export namespace JSX {\n export type Element = VNode | Component\n export interface ElementClass extends Component {}\n export interface ElementAttributesProperty {\n props: {}\n }\n export interface ElementChildrenAttribute {\n children: {}\n }\n export interface IntrinsicAttributes {\n key?: Key\n }\n export type LibraryManagedAttributes<_TComponent, TProps extends ComponentProps> =\n TemplateProps<TProps>\n export type IntrinsicElements = FrayIntrinsicElements\n }\n}\n\nexport function css(strings: TemplateStringsArray, ...values: unknown[]): string {\n return strings.reduce((result, string, index) =>\n result + string + String(values[index] ?? ''), '')\n}\n\nexport class Component<TProps extends ComponentProps = ComponentProps> {\n static dependencies: ComponentDependency[] = []\n static requiredServices: readonly ServiceKey<unknown>[] = []\n static css = ''\n static hostName: string | null = null\n static standaloneHostName: string | null = null\n\n static new<TConstructor extends ConcreteComponentConstructor>(\n this: TConstructor,\n ...args: ConstructorParameters<TConstructor>\n ): InstanceType<TConstructor> {\n const instance = new this(...args)\n if (!(instance instanceof Component)) {\n throw new TypeError('Component.new() requires a Component constructor')\n }\n return instance.mount() as InstanceType<TConstructor>\n }\n\n static get baseStyles(): unknown {\n return {}\n }\n\n static registerStyles(\n this: ComponentDependency & {\n css?: string\n baseStyles?: unknown\n dependencies?: ComponentDependency[]\n hostName?: string | null\n standaloneHostName?: string | null\n },\n runtime: FrayRuntime = defaultFrayRuntime,\n seen: Set<ComponentDependency> = new Set(),\n ): void {\n if (seen.has(this)) return\n seen.add(this)\n\n const hostName = this.hostName ?? null\n const standaloneHostName = this.standaloneHostName ?? null\n if (this.css) {\n runtime.styleRegistry.registerCSS(hostName == null\n ? this.css\n : runtime.resolveHostCSS(this.css, hostName, standaloneHostName))\n }\n const baseStyles = normalizeBaseStyles(this.baseStyles)\n for (const [selector, styleNames] of baseStyles) {\n runtime.styleRegistry.registerBaseStyle(hostName == null\n ? selector\n : runtime.resolveHostSelector(selector, hostName, standaloneHostName), styleNames)\n }\n for (const dependency of this.dependencies ?? []) {\n dependency.registerStyles(runtime, seen)\n }\n }\n\n props: TProps\n dom: ChildNode | null = null\n /** @internal */\n _rendered: RenderRecord | null = null\n /** @internal */\n readonly _childComponents = new Set<Component>()\n private initialized = false\n private mounted = false\n private destroyed = false\n private updating = false\n private updateRequested = false\n private readonly cleanupFunctions = new Set<() => void>()\n private readonly watched = new Map<Watchable, () => void>()\n private readonly renderReadSubscriptions = new Map<Watchable, () => void>()\n private collectingRenderReads: Set<Watchable> | null = null\n /** @internal */\n _runtime: FrayRuntime = defaultFrayRuntime\n\n constructor(props: TProps = {} as TProps) {\n if (props == null || typeof props !== 'object' || Array.isArray(props)) {\n throw new TypeError(`${this.constructor.name} props must be an object`)\n }\n this.props = props\n }\n\n /** One-time setup hook. Constructors must not subscribe or render. */\n initialize(): void {}\n\n render(): FrayChild {\n throw new Error(`${this.constructor.name} must implement render()`)\n }\n\n /** Render this component's configured custom host element. */\n protected host(props: ComponentProps | null = null, ...children: FrayChild[]): VNode {\n const componentType = this.constructor as typeof Component\n const hostName = componentType.hostName\n if (hostName == null) {\n throw new Error(`${this.constructor.name} does not declare a custom host name`)\n }\n return h(this._runtime.resolveElementName(\n hostName,\n componentType.standaloneHostName,\n ), {\n ...props,\n 'data-fray-component': hostName,\n }, ...children)\n }\n\n /** JSX component for this instance's runtime-configured custom host. */\n protected readonly Host: (props: ComponentProps) => VNode = ({\n children = [],\n ...props\n }) => this.host(props, children)\n\n /** @internal Assign an immutable application runtime before initialization or mounting. */\n _setRuntime(runtime: FrayRuntime): this {\n if (!(runtime instanceof FrayRuntime)) {\n throw new TypeError('Component runtime must be a FrayRuntime')\n }\n if (runtime === this._runtime) return this\n if (this.initialized || this.mounted || this._rendered != null) {\n throw new Error('Cannot change a component runtime after initialization')\n }\n this._runtime = runtime\n return this\n }\n\n mount(parent: ParentNode | null = null, before: Node | null = null): this {\n if (this.destroyed) throw new Error('Cannot mount a destroyed component')\n let mountedNow = false\n if (!this.initialized) {\n this.validateRequiredServices()\n this.initialized = true\n this.initialize()\n }\n if (!this.mounted) {\n this.mounted = true\n this.update()\n mountedNow = true\n }\n if (parent != null) {\n assertParentNode(parent)\n insertRecord(parent, this._rendered, before)\n }\n if (mountedNow) this.afterMount(this.dom)\n return this\n }\n\n attachTo(parent: ParentNode): this {\n this.mount(parent)\n return this\n }\n\n update(_event?: unknown): this {\n if (this.destroyed) return this\n if (!this.mounted) return this.mount()\n if (this.updating) {\n this.updateRequested = true\n return this\n }\n\n this.updating = true\n try {\n do {\n this.updateRequested = false\n const nextReads = new Set<Watchable>()\n this.collectingRenderReads = nextReads\n let nextVNode: NormalizedChild\n try {\n nextVNode = normalizeRoot(this.render())\n } finally {\n this.collectingRenderReads = null\n }\n this._rendered = patchRoot(this._rendered, nextVNode, this)\n this.dom = firstNode(this._rendered)\n this.reconcileRenderReads(nextReads)\n this.afterUpdate(this.dom)\n } while (this.updateRequested && !this.destroyed)\n } finally {\n this.updating = false\n }\n return this\n }\n\n setProps(nextProps: TProps): this {\n if (nextProps == null || typeof nextProps !== 'object' || Array.isArray(nextProps)) {\n throw new TypeError(`${this.constructor.name} props must be an object`)\n }\n this.props = nextProps\n if (this.mounted) this.update()\n return this\n }\n\n afterMount(_dom: ChildNode | null): void {}\n afterUpdate(_dom: ChildNode | null): void {}\n\n watch(...observables: Watchable[]): this {\n for (const observable of observables) {\n if (observable == null || typeof observable.subscribe !== 'function') {\n throw new TypeError('watch requires emitter-like values')\n }\n if (this.watched.has(observable)) continue\n const unsubscribe = observable.subscribe(({event}) => {\n if (this.mounted && !this.destroyed) this.update(event)\n }, {emitCurrent: false})\n this.watched.set(observable, unsubscribe)\n this.onCleanup(() => {\n unsubscribe()\n this.watched.delete(observable)\n })\n }\n return this\n }\n\n watchFutureValues(...observables: Watchable[]): this {\n return this.watch(...observables)\n }\n\n /** Read an emitter during render and rerender when that dependency changes. */\n read<TValue, TError>(emitter: ReadableEmitter<TValue, TError>): TValue {\n this.trackRenderRead(emitter)\n return emitter.get()\n }\n\n /** Read a Glue value, fetch state, and error as one tracked render dependency. */\n snapshot<TValue, TError>(\n emitter: ReadableEmitter<TValue, TError>,\n ): EmitterSnapshot<TValue, TError> {\n this.trackRenderRead(emitter)\n return Object.freeze({\n value: emitter.get(),\n fetchState: emitter.getFetchState(),\n error: emitter.getError(),\n })\n }\n\n onCleanup(cleanup: () => void): () => void {\n if (typeof cleanup !== 'function') throw new TypeError('cleanup must be a function')\n if (this.destroyed) {\n cleanup()\n return () => {}\n }\n this.cleanupFunctions.add(cleanup)\n let active = true\n return () => {\n if (!active) return\n active = false\n this.cleanupFunctions.delete(cleanup)\n cleanup()\n }\n }\n\n /** Resolve one explicitly declared application service from this component's runtime. */\n protected requireService<TService>(key: ServiceKey<TService>): TService {\n if (!this.initialized) {\n throw new Error('Components may resolve services during initialize() or later')\n }\n const componentType = this.constructor as typeof Component\n if (!componentType.requiredServices.includes(key)) {\n throw new Error(\n `${componentType.name} must declare service \"${key.name}\" in requiredServices`,\n )\n }\n return this._runtime.services.require(key)\n }\n\n listen<TEvent extends Event = Event>(\n target: EventTarget,\n type: string,\n listener: (event: TEvent) => void,\n options?: boolean | AddEventListenerOptions,\n ): this {\n if (target == null || typeof target.addEventListener !== 'function') {\n throw new TypeError('listen target must be an EventTarget')\n }\n const eventListener = listener as EventListener\n target.addEventListener(type, eventListener, options)\n this.onCleanup(() => target.removeEventListener(type, eventListener, options))\n return this\n }\n\n registerChild<TComponent extends Component>(component: TComponent): TComponent {\n if (!(component instanceof Component)) {\n throw new TypeError('registerChild requires a Component')\n }\n this._childComponents.add(component)\n return component\n }\n\n destroy(): void {\n if (this.destroyed) return\n this.destroyed = true\n this.mounted = false\n\n for (const cleanup of [...this.cleanupFunctions]) cleanup()\n this.cleanupFunctions.clear()\n this.watched.clear()\n for (const unsubscribe of this.renderReadSubscriptions.values()) unsubscribe()\n this.renderReadSubscriptions.clear()\n this.collectingRenderReads = null\n\n if (this._rendered) disposeRecord(this._rendered, true)\n this._rendered = null\n this.dom = null\n this._childComponents.clear()\n this.onDestroy()\n }\n\n private validateRequiredServices(): void {\n const componentType = this.constructor as typeof Component\n for (const key of componentType.requiredServices) {\n if (!this._runtime.services.has(key)) {\n throw new Error(`${componentType.name} requires unregistered service \"${key.name}\"`)\n }\n }\n }\n\n onDestroy(): void {}\n\n private trackRenderRead(emitter: ReadableEmitter<unknown, unknown>): void {\n assertReadableEmitter(emitter, 'Component.read')\n if (this.collectingRenderReads == null) {\n throw new Error('Component.read() and snapshot() may only be called during render()')\n }\n this.collectingRenderReads.add(emitter)\n }\n\n private reconcileRenderReads(nextReads: Set<Watchable>): void {\n for (const [emitter, unsubscribe] of this.renderReadSubscriptions) {\n if (nextReads.has(emitter)) continue\n unsubscribe()\n this.renderReadSubscriptions.delete(emitter)\n }\n for (const emitter of nextReads) {\n if (this.watched.has(emitter) || this.renderReadSubscriptions.has(emitter)) continue\n const unsubscribe = emitter.subscribe(({event}) => {\n if (this.mounted && !this.destroyed) this.update(event)\n }, {emitCurrent: false})\n this.renderReadSubscriptions.set(emitter, unsubscribe)\n }\n }\n}\n\ninterface RecordBase {\n readonly kind: string\n key: Key | null\n owner: Component\n}\n\ninterface TextRecord extends RecordBase {\n readonly kind: 'text'\n value: string | number\n node: Text\n}\n\ninterface EmitterRecord extends RecordBase {\n readonly kind: 'emitter'\n source: ReadableEmitter<FrayChild, unknown>\n start: Comment\n end: Comment\n child: RenderRecord\n unsubscribe: () => void\n}\n\ninterface LivePropRecord {\n source: ReadableEmitter<unknown, unknown>\n value: unknown\n unsubscribe: () => void\n}\n\ninterface NativeBindingRecord extends LivePropRecord {\n eventName: 'input' | 'change'\n listener: EventListener\n}\n\ninterface ElementRecord extends RecordBase {\n readonly kind: 'element'\n type: string\n node: HTMLElement\n props: ComponentProps\n listeners: Map<string, EventListener>\n liveProps: Map<string, LivePropRecord>\n nativeBindings: Map<string, NativeBindingRecord>\n ref: Ref<HTMLElement> | null\n children: RenderRecord[]\n}\n\ninterface FragmentRecord extends RecordBase {\n readonly kind: 'fragment'\n type: typeof Fragment\n start: Comment\n end: Comment\n children: RenderRecord[]\n}\n\ninterface ComponentRecord extends RecordBase {\n readonly kind: 'component'\n type: Function\n instance: Component\n prebuilt: boolean\n props: ComponentProps\n liveProps: Map<string, LivePropRecord>\n}\n\ninterface FunctionRecord extends RecordBase {\n readonly kind: 'function'\n type: FunctionComponent\n props: ComponentProps\n sourceProps: ComponentProps\n liveProps: Map<string, LivePropRecord>\n child: RenderRecord\n}\n\ntype RenderRecord =\n | TextRecord\n | EmitterRecord\n | ElementRecord\n | FragmentRecord\n | ComponentRecord\n | FunctionRecord\n\nfunction normalizeRoot(value: FrayChild): NormalizedChild {\n if (Array.isArray(value)) return h(Fragment, null, value)\n if (value == null || typeof value === 'boolean') return h(Fragment)\n return value as NormalizedChild\n}\n\nfunction normalizeChildren(values: FrayChild | readonly FrayChild[]): NormalizedChild[] {\n const normalized: NormalizedChild[] = []\n const visit = (value: FrayChild): void => {\n if (Array.isArray(value)) {\n for (const child of value) visit(child)\n } else if (value != null && typeof value !== 'boolean') {\n normalized.push(value as NormalizedChild)\n }\n }\n visit(values)\n return normalized\n}\n\nfunction createRecord(value: NormalizedChild, owner: Component): RenderRecord {\n if (typeof value === 'string' || typeof value === 'number') {\n return {\n kind: 'text',\n key: null,\n value,\n node: document.createTextNode(String(value)),\n owner,\n }\n }\n\n if (isReadableEmitter(value)) {\n const start = document.createComment('fray-emitter-start')\n const end = document.createComment('fray-emitter-end')\n const current = value.get()\n if (Object.is(current, value)) {\n throw new TypeError('A Fray emitter child cannot render itself')\n }\n const fragment = document.createDocumentFragment()\n fragment.append(start, end)\n const child = createRecord(normalizeRoot(current), owner)\n insertRecord(fragment, child, end)\n const record: EmitterRecord = {\n kind: 'emitter',\n key: null,\n source: value,\n start,\n end,\n child,\n unsubscribe: () => {},\n owner,\n }\n record.unsubscribe = value.subscribe(({value: nextValue}) => {\n if (Object.is(nextValue, value)) {\n throw new TypeError('A Fray emitter child cannot render itself')\n }\n record.child = patchRoot(record.child, normalizeRoot(nextValue), owner)\n }, {emitCurrent: false})\n return record\n }\n\n if (value instanceof Component) {\n value._setRuntime(owner._runtime)\n value.mount()\n owner.registerChild(value)\n return {\n kind: 'component',\n key: readKey(value.props),\n type: value.constructor,\n instance: value,\n prebuilt: true,\n props: value.props,\n liveProps: new Map(),\n owner,\n }\n }\n\n if (!isVNode(value)) {\n throw new TypeError(`Invalid Fray child: ${describeValue(value)}`)\n }\n\n const {type, key = null, props} = value\n if (type === Fragment) {\n const start = document.createComment('fray-fragment-start')\n const end = document.createComment('fray-fragment-end')\n const record: FragmentRecord = {\n kind: 'fragment',\n key,\n type,\n start,\n end,\n children: [],\n owner,\n }\n const fragment = document.createDocumentFragment()\n fragment.append(start, end)\n record.children = patchChildren(\n fragment,\n [],\n props.children,\n owner,\n end,\n start,\n )\n return record\n }\n\n if (typeof type === 'string') {\n const node = document.createElement(type)\n const record: ElementRecord = {\n kind: 'element',\n key,\n type,\n node,\n props: {},\n listeners: new Map(),\n liveProps: new Map(),\n nativeBindings: new Map(),\n ref: null,\n children: [],\n owner,\n }\n patchElementProps(record, props)\n record.children = patchChildren(node, [], props.children, owner)\n return record\n }\n\n if (isComponentClass(type)) {\n const sourceProps = props as ComponentProps\n const resolvedProps = resolveLivePropValues(sourceProps)\n const instance = new type(resolvedProps as never)\n instance._setRuntime(owner._runtime)\n const record: ComponentRecord = {\n kind: 'component',\n key,\n type,\n instance,\n prebuilt: false,\n props: resolvedProps,\n liveProps: new Map(),\n owner,\n }\n subscribeComponentLiveProps(record, sourceProps)\n instance.mount()\n owner.registerChild(instance)\n return record\n }\n\n if (typeof type === 'function') {\n const functionType = type as FunctionComponent\n const sourceProps = props as ComponentProps\n const functionProps = resolveLivePropValues(sourceProps)\n const rendered = normalizeRoot(functionType(functionProps))\n const record: FunctionRecord = {\n kind: 'function',\n key,\n type: functionType,\n props: functionProps,\n sourceProps,\n liveProps: new Map(),\n child: createRecord(rendered, owner),\n owner,\n }\n subscribeFunctionLiveProps(record)\n return record\n }\n\n throw new TypeError(`Unsupported vnode type: ${describeValue(type)}`)\n}\n\nfunction patchRoot(\n previous: RenderRecord | null,\n value: NormalizedChild,\n owner: Component,\n): RenderRecord {\n if (previous == null) return createRecord(value, owner)\n if (isCompatible(previous, value)) return patchCompatible(previous, value, owner)\n\n const next = createRecord(value, owner)\n const anchor = firstNode(previous)\n const parent = anchor?.parentNode ?? null\n if (parent) insertRecord(parent, next, anchor)\n disposeRecord(previous, true)\n return next\n}\n\nfunction patchCompatible(\n record: RenderRecord,\n value: NormalizedChild,\n owner: Component,\n): RenderRecord {\n if (record.kind === 'text') {\n if (typeof value !== 'string' && typeof value !== 'number') return record\n if (!Object.is(record.value, value)) {\n record.value = value\n record.node.data = String(value)\n }\n return record\n }\n\n if (record.kind === 'emitter') {\n if (!isReadableEmitter(value) || record.source !== value) return record\n return record\n }\n\n if (record.kind === 'component') {\n if (value instanceof Component) return record\n if (isVNode(value)) patchComponentLiveProps(record, value.props)\n return record\n }\n\n if (!isVNode(value)) return record\n\n if (record.kind === 'function') {\n patchFunctionLiveProps(record, value.props)\n return record\n }\n\n if (record.kind === 'fragment') {\n record.children = patchChildren(\n record.start.parentNode,\n record.children,\n value.props.children,\n owner,\n record.end,\n record.start,\n )\n return record\n }\n\n patchElementProps(record, value.props)\n record.children = patchChildren(\n record.node,\n record.children,\n value.props.children,\n owner,\n )\n return record\n}\n\nfunction resolveLivePropValues(sourceProps: ComponentProps): ComponentProps {\n return Object.fromEntries(Object.entries(sourceProps).map(([key, value]) => [\n key,\n isLiveBinding(value) ? value.emitter.get() : value,\n ]))\n}\n\nfunction subscribeComponentLiveProps(\n record: ComponentRecord,\n sourceProps: ComponentProps,\n): void {\n reconcileLiveProps(record.liveProps, sourceProps, (key, value) => {\n record.props = {...record.props, [key]: value}\n record.instance.setProps(record.props)\n })\n record.props = resolvedLiveProps(record.liveProps, sourceProps)\n record.instance.setProps(record.props)\n}\n\nfunction patchComponentLiveProps(record: ComponentRecord, sourceProps: ComponentProps): void {\n subscribeComponentLiveProps(record, sourceProps)\n}\n\nfunction subscribeFunctionLiveProps(record: FunctionRecord): void {\n reconcileLiveProps(record.liveProps, record.sourceProps, (key, value) => {\n record.props = {...record.props, [key]: value}\n rerenderFunctionRecord(record)\n })\n record.props = resolvedLiveProps(record.liveProps, record.sourceProps)\n}\n\nfunction patchFunctionLiveProps(record: FunctionRecord, sourceProps: ComponentProps): void {\n record.sourceProps = sourceProps\n reconcileLiveProps(record.liveProps, sourceProps, (key, value) => {\n record.props = {...record.props, [key]: value}\n rerenderFunctionRecord(record)\n })\n record.props = resolvedLiveProps(record.liveProps, sourceProps)\n rerenderFunctionRecord(record)\n}\n\nfunction rerenderFunctionRecord(record: FunctionRecord): void {\n const rendered = normalizeRoot(record.type(record.props))\n record.child = patchRoot(record.child, rendered, record.owner)\n}\n\nfunction reconcileLiveProps(\n subscriptions: Map<string, LivePropRecord>,\n sourceProps: ComponentProps,\n onValue: (key: string, value: unknown) => void,\n): void {\n for (const [key, existing] of subscriptions) {\n const next = sourceProps[key]\n if (isLiveBinding(next) && next.emitter === existing.source) continue\n existing.unsubscribe()\n subscriptions.delete(key)\n }\n\n for (const [key, value] of Object.entries(sourceProps)) {\n if (!isLiveBinding(value) || subscriptions.has(key)) continue\n const liveProp: LivePropRecord = {\n source: value.emitter,\n value: value.emitter.get(),\n unsubscribe: () => {},\n }\n liveProp.unsubscribe = value.emitter.subscribe(({value: nextValue}) => {\n if (subscriptions.get(key) !== liveProp) return\n liveProp.value = nextValue\n onValue(key, nextValue)\n }, {emitCurrent: false})\n subscriptions.set(key, liveProp)\n }\n}\n\nfunction resolvedLiveProps(\n subscriptions: Map<string, LivePropRecord>,\n sourceProps: ComponentProps,\n): ComponentProps {\n return Object.fromEntries(Object.entries(sourceProps).map(([key, value]) => [\n key,\n isLiveBinding(value) ? subscriptions.get(key)?.value ?? value.emitter.get() : value,\n ]))\n}\n\nfunction patchChildren(\n parent: ParentNode | null,\n previous: RenderRecord[],\n values: FrayChild | readonly FrayChild[],\n owner: Component,\n end: Node | null = null,\n start: Node | null = null,\n): RenderRecord[] {\n if (parent == null) throw new Error('Cannot patch a detached fragment range')\n const nextValues = normalizeChildren(values)\n const keyed = new Map<Key, RenderRecord>()\n const unkeyed: RenderRecord[] = []\n for (const record of previous) {\n if (record.key == null) unkeyed.push(record)\n else if (!keyed.has(record.key)) keyed.set(record.key, record)\n }\n\n const seenKeys = new Set<Key>()\n const retained = new Set<RenderRecord>()\n const nextRecords: RenderRecord[] = []\n let unkeyedIndex = 0\n\n for (const value of nextValues) {\n const key = valueKey(value)\n if (key != null) {\n if (seenKeys.has(key)) throw new Error(`Duplicate sibling key: ${String(key)}`)\n seenKeys.add(key)\n }\n const candidate = key == null\n ? unkeyed[unkeyedIndex++]\n : keyed.get(key)\n if (candidate && isCompatible(candidate, value)) {\n retained.add(candidate)\n nextRecords.push(patchCompatible(candidate, value, owner))\n } else {\n nextRecords.push(createRecord(value, owner))\n }\n }\n\n for (const record of previous) {\n if (!retained.has(record)) disposeRecord(record, true)\n }\n\n let cursor = start ? start.nextSibling : parent.firstChild\n for (const record of nextRecords) {\n for (const node of recordNodes(record)) {\n if (node === cursor) {\n cursor = cursor.nextSibling\n } else {\n parent.insertBefore(node, cursor ?? end)\n cursor = node.nextSibling\n }\n }\n }\n\n return nextRecords\n}\n\nfunction patchElementProps(record: ElementRecord, nextProps: ComponentProps): void {\n const {children: _nextChildren, ...next} = nextProps\n const previous = record.props\n const keys = new Set([...Object.keys(previous), ...Object.keys(next)])\n\n for (const property of ['value', 'checked'] as const) {\n if (Object.hasOwn(next, property) && Object.hasOwn(next, `bind:${property}`)) {\n throw new Error(`${property} and bind:${property} cannot be used together`)\n }\n }\n\n for (const key of keys) {\n const previousValue = previous[key]\n const nextValue = next[key]\n if (isNativeBindingProp(key)) {\n patchNativeBinding(record, key, nextValue)\n } else if (key === 'ref') {\n if (previousValue !== nextValue) patchRef(record, nextValue)\n } else if (isEventProp(key)) {\n patchEvent(record, key, nextValue)\n } else if (isLiveBinding(nextValue)) {\n patchLiveElementProp(record, key, nextValue)\n } else {\n const previousLive = record.liveProps.get(key)\n if (previousLive) {\n previousLive.unsubscribe()\n record.liveProps.delete(key)\n }\n const previousResolved = previousLive?.value ?? previousValue\n if (!Object.is(previousResolved, nextValue)) {\n patchDOMProp(record.node, key, previousResolved, nextValue)\n }\n }\n }\n record.props = {...next}\n}\n\nfunction patchLiveElementProp(\n record: ElementRecord,\n key: string,\n binding: LiveBinding<unknown>,\n): void {\n const existing = record.liveProps.get(key)\n if (existing?.source === binding.emitter) return\n\n existing?.unsubscribe()\n const value = binding.emitter.get()\n patchDOMProp(record.node, key, existing?.value ?? record.props[key], value)\n const liveProp: LivePropRecord = {\n source: binding.emitter,\n value,\n unsubscribe: () => {},\n }\n liveProp.unsubscribe = binding.emitter.subscribe(({value: nextValue}) => {\n const previousValue = liveProp.value\n liveProp.value = nextValue\n if (!Object.is(previousValue, nextValue)) {\n patchDOMProp(record.node, key, previousValue, nextValue)\n }\n }, {emitCurrent: false})\n record.liveProps.set(key, liveProp)\n}\n\nfunction patchNativeBinding(\n record: ElementRecord,\n key: 'bind:value' | 'bind:checked',\n next: unknown,\n): void {\n const property = key.slice(5) as 'value' | 'checked'\n const existing = record.nativeBindings.get(key)\n if (next == null) {\n if (existing) {\n existing.unsubscribe()\n record.node.removeEventListener(existing.eventName, existing.listener)\n record.nativeBindings.delete(key)\n patchDOMProp(record.node, property, existing.value, undefined)\n }\n return\n }\n assertWritableEmitter(next, key)\n if (existing?.source === next) return\n\n if (existing) {\n existing.unsubscribe()\n record.node.removeEventListener(existing.eventName, existing.listener)\n }\n assertNativeBindingTarget(record.node, property)\n const eventName = nativeBindingEvent(record.node, property)\n const value = next.get()\n patchDOMProp(record.node, property, existing?.value, value)\n const listener: EventListener = () => {\n next.set(Reflect.get(record.node, property), `${key} changed`)\n }\n const binding: NativeBindingRecord = {\n source: next,\n value,\n eventName,\n listener,\n unsubscribe: () => {},\n }\n binding.unsubscribe = next.subscribe(({value: nextValue}) => {\n const previousValue = binding.value\n binding.value = nextValue\n if (!Object.is(previousValue, nextValue)) {\n patchDOMProp(record.node, property, previousValue, nextValue)\n }\n }, {emitCurrent: false})\n record.node.addEventListener(eventName, listener)\n record.nativeBindings.set(key, binding)\n}\n\nfunction patchEvent(record: ElementRecord, key: string, next: unknown): void {\n const eventName = key.slice(2).toLowerCase()\n const registered = record.listeners.get(key)\n if (registered && registered !== next) {\n record.node.removeEventListener(eventName, registered)\n record.listeners.delete(key)\n }\n if (next != null && typeof next !== 'function') {\n throw new TypeError(`${key} must be a function or null`)\n }\n if (typeof next === 'function' && registered !== next) {\n const listener = next as EventListener\n record.node.addEventListener(eventName, listener)\n record.listeners.set(key, listener)\n }\n}\n\nfunction patchRef(record: ElementRecord, next: unknown): void {\n applyRef(record.ref, null)\n if (next != null && typeof next !== 'function' && typeof next !== 'object') {\n throw new TypeError('ref must be a function, object, or null')\n }\n record.ref = next as Ref<HTMLElement> | null\n applyRef(record.ref, record.node)\n}\n\nfunction patchDOMProp(\n node: HTMLElement,\n key: string,\n previous: unknown,\n next: unknown,\n): void {\n if (key === 'class' || key === 'className') {\n setAttribute(node, 'class', next)\n return\n }\n if (key === 'for' || key === 'htmlFor') {\n setAttribute(node, 'for', next)\n return\n }\n if (key === 'dataset') {\n patchDataset(node, previous, next)\n return\n }\n if (key === 'style') {\n patchStyle(node, previous, next)\n return\n }\n if (key === 'dangerouslySetInnerHTML') {\n throw new Error('dangerouslySetInnerHTML is not supported')\n }\n\n const property = normalizePropertyName(key)\n if (BOOLEAN_ATTRIBUTES.has(property)) {\n const enabled = Boolean(next)\n if (property in node) Reflect.set(node, property, enabled)\n node.toggleAttribute(normalizeAttributeName(key), enabled)\n return\n }\n if (PROPERTY_PROPS.has(property) && property in node) {\n const value = next ?? (property === 'value' ? '' : false)\n if (!Object.is(Reflect.get(node, property), value)) Reflect.set(node, property, value)\n if (next == null) node.removeAttribute(normalizeAttributeName(key))\n return\n }\n\n setAttribute(node, normalizeAttributeName(key), next)\n}\n\nfunction patchDataset(node: HTMLElement, previous: unknown, next: unknown): void {\n const oldValues = toPropertyRecord(previous, 'dataset')\n const newValues = toPropertyRecord(next, 'dataset')\n for (const key of new Set([...Object.keys(oldValues), ...Object.keys(newValues)])) {\n const value = newValues[key]\n if (value == null) delete node.dataset[key]\n else node.dataset[key] = String(value)\n }\n}\n\nfunction patchStyle(node: HTMLElement, previous: unknown, next: unknown): void {\n if (typeof next === 'string') {\n node.style.cssText = next\n return\n }\n const oldValues = typeof previous === 'string'\n ? {}\n : toPropertyRecord(previous, 'style')\n const newValues = toPropertyRecord(next, 'style')\n if (typeof previous === 'string') node.style.cssText = ''\n for (const key of new Set([...Object.keys(oldValues), ...Object.keys(newValues)])) {\n const value = newValues[key]\n if (key.startsWith('--')) {\n if (value == null) node.style.removeProperty(key)\n else node.style.setProperty(key, String(value))\n } else {\n Reflect.set(node.style, key, value == null ? '' : String(value))\n }\n }\n}\n\nfunction toPropertyRecord(value: unknown, label: string): Record<string, unknown> {\n if (value == null) return {}\n if (typeof value !== 'object' || Array.isArray(value)) {\n throw new TypeError(`${label} must be an object or null`)\n }\n return value as Record<string, unknown>\n}\n\nfunction setAttribute(node: HTMLElement, name: string, value: unknown): void {\n if (value == null || value === false) node.removeAttribute(name)\n else if (value === true) node.setAttribute(name, '')\n else node.setAttribute(name, String(value))\n}\n\nfunction normalizePropertyName(key: string): string {\n if (key === 'readonly') return 'readOnly'\n if (key === 'autofocus') return 'autoFocus'\n return key\n}\n\nfunction normalizeAttributeName(key: string): string {\n if (key === 'className') return 'class'\n if (key === 'htmlFor') return 'for'\n if (/^aria[A-Z]/.test(key)) return camelToKebab(key)\n if (/^data[A-Z]/.test(key)) return camelToKebab(key)\n return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)\n}\n\nfunction camelToKebab(value: string): string {\n return value.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)\n}\n\nfunction applyRef<TNode extends Node>(ref: Ref<TNode> | null, value: TNode | null): void {\n if (ref == null) return\n if (typeof ref === 'function') ref(value)\n else ref.current = value\n}\n\nfunction disposeRecord(record: RenderRecord, removeNodes: boolean): void {\n if (record.kind === 'emitter') {\n record.unsubscribe()\n disposeRecord(record.child, false)\n if (removeNodes) {\n for (const node of recordNodes(record)) node.remove()\n }\n return\n }\n if (record.kind === 'component') {\n for (const binding of record.liveProps.values()) binding.unsubscribe()\n record.liveProps.clear()\n record.owner._childComponents.delete(record.instance)\n record.instance.destroy()\n return\n }\n if (record.kind === 'function') {\n for (const binding of record.liveProps.values()) binding.unsubscribe()\n record.liveProps.clear()\n disposeRecord(record.child, removeNodes)\n return\n }\n if (record.kind === 'element') {\n applyRef(record.ref, null)\n for (const [key, listener] of record.listeners) {\n record.node.removeEventListener(key.slice(2).toLowerCase(), listener)\n }\n record.listeners.clear()\n for (const binding of record.liveProps.values()) binding.unsubscribe()\n record.liveProps.clear()\n for (const binding of record.nativeBindings.values()) {\n binding.unsubscribe()\n record.node.removeEventListener(binding.eventName, binding.listener)\n }\n record.nativeBindings.clear()\n for (const child of record.children) disposeRecord(child, false)\n if (removeNodes) record.node.remove()\n return\n }\n if (record.kind === 'fragment') {\n for (const child of record.children) disposeRecord(child, false)\n if (removeNodes) {\n for (const node of recordNodes(record)) node.remove()\n }\n return\n }\n if (removeNodes) record.node.remove()\n}\n\nfunction insertRecord(parent: ParentNode, record: RenderRecord | null, before: Node | null = null): void {\n if (record == null) return\n for (const node of recordNodes(record)) parent.insertBefore(node, before)\n}\n\nfunction recordNodes(record: RenderRecord | null): ChildNode[] {\n if (record == null) return []\n if (record.kind === 'text' || record.kind === 'element') return [record.node]\n if (record.kind === 'component') return recordNodes(record.instance._rendered)\n if (record.kind === 'function') return recordNodes(record.child)\n\n const nodes: ChildNode[] = []\n let node: ChildNode | null = record.start\n while (node) {\n nodes.push(node)\n if (node === record.end) break\n node = node.nextSibling\n }\n return nodes\n}\n\nfunction firstNode(record: RenderRecord | null): ChildNode | null {\n return recordNodes(record)[0] ?? null\n}\n\nfunction valueKey(value: NormalizedChild): Key | null {\n if (value instanceof Component) return readKey(value.props)\n return isVNode(value) ? value.key : null\n}\n\nfunction readKey(props: ComponentProps): Key | null {\n const key = props.key\n return typeof key === 'string' || typeof key === 'number' ? key : null\n}\n\nfunction isCompatible(record: RenderRecord, value: NormalizedChild): boolean {\n if (record.kind === 'text') {\n return typeof value === 'string' || typeof value === 'number'\n }\n if (record.kind === 'emitter') {\n return isReadableEmitter(value) && record.source === value\n }\n if (record.kind === 'component') {\n if (value instanceof Component) return record.instance === value\n return isVNode(value)\n && isComponentClass(value.type)\n && record.type === value.type\n && record.key === valueKey(value)\n }\n if (record.kind === 'function') {\n return isVNode(value)\n && record.type === value.type\n && record.key === valueKey(value)\n }\n if (record.kind === 'fragment') {\n return isVNode(value)\n && value.type === Fragment\n && record.key === valueKey(value)\n }\n return isVNode(value)\n && typeof value.type === 'string'\n && record.type === value.type\n && record.key === valueKey(value)\n}\n\nexport function isVNode(value: unknown): value is VNode {\n return value != null\n && typeof value === 'object'\n && Object.hasOwn(value, 'type')\n}\n\nfunction isComponentClass(value: unknown): value is AnyComponentConstructor {\n return typeof value === 'function'\n && (value === Component || value.prototype instanceof Component)\n}\n\nfunction isEventProp(key: string): boolean {\n return /^on[A-Z]/.test(key)\n}\n\nfunction isNativeBindingProp(key: string): key is 'bind:value' | 'bind:checked' {\n return key === 'bind:value' || key === 'bind:checked'\n}\n\nfunction isLiveBinding(value: unknown): value is LiveBinding<unknown> {\n return value != null\n && typeof value === 'object'\n && liveBindingValues.has(value)\n}\n\nfunction isReadableEmitter(value: unknown): value is ReadableEmitter<FrayChild, unknown> {\n if ((typeof value !== 'object' || value == null) && typeof value !== 'function') return false\n return typeof Reflect.get(value, 'get') === 'function'\n && typeof Reflect.get(value, 'getFetchState') === 'function'\n && typeof Reflect.get(value, 'getError') === 'function'\n && typeof Reflect.get(value, 'subscribe') === 'function'\n}\n\nfunction assertReadableEmitter(\n value: unknown,\n label: string,\n): asserts value is ReadableEmitter<unknown, unknown> {\n if (!isReadableEmitter(value)) throw new TypeError(`${label} requires a readable emitter`)\n}\n\nfunction assertWritableEmitter(\n value: unknown,\n label: string,\n): asserts value is WritableEmitter<unknown, unknown> {\n assertReadableEmitter(value, label)\n if (typeof Reflect.get(value, 'set') !== 'function') {\n throw new TypeError(`${label} requires a writable emitter`)\n }\n}\n\nfunction assertNativeBindingTarget(\n node: HTMLElement,\n property: 'value' | 'checked',\n): void {\n const tagName = node.localName\n const valid = property === 'checked'\n ? tagName === 'input'\n : tagName === 'input' || tagName === 'textarea' || tagName === 'select'\n if (!valid) throw new TypeError(`bind:${property} is not supported on ${tagName}`)\n}\n\nfunction nativeBindingEvent(\n node: HTMLElement,\n property: 'value' | 'checked',\n): 'input' | 'change' {\n return property === 'value' && node.localName !== 'select' ? 'input' : 'change'\n}\n\nfunction assertParentNode(value: unknown): asserts value is ParentNode {\n if (value == null\n || (typeof value !== 'object' && typeof value !== 'function')\n || typeof Reflect.get(value, 'insertBefore') !== 'function') {\n throw new TypeError('Component parent must be a DOM ParentNode')\n }\n}\n\nfunction describeValue(value: unknown): string {\n try {\n return String(value)\n } catch {\n return Object.prototype.toString.call(value)\n }\n}\n\nfunction normalizeBaseStyles(value: unknown): Array<[string, BaseStyleNames]> {\n if (value == null) return []\n if (Array.isArray(value)) {\n return value.map((entry) => {\n if (!Array.isArray(entry) || entry.length < 2 || typeof entry[0] !== 'string') {\n throw new TypeError('Component baseStyles entries must be selector/style tuples')\n }\n const names = entry[1]\n if (typeof names !== 'string'\n && (!Array.isArray(names) || names.some((name) => typeof name !== 'string'))) {\n throw new TypeError('Component base style names must be strings')\n }\n return [entry[0], names as BaseStyleNames]\n })\n }\n if (typeof value !== 'object') {\n throw new TypeError('Component baseStyles must be an object or tuple array')\n }\n return Object.entries(value).map(([selector, names]) => [\n selector,\n names as BaseStyleNames,\n ])\n}\n","import {\n Component,\n Fragment,\n h,\n} from './Components/component.js'\nimport type {\n ComponentProps,\n FrayIntrinsicElements,\n FrayChild,\n Key,\n TemplateProps,\n VNode,\n VNodeType,\n} from './Components/component.js'\n\nexport {Fragment}\n\nexport function jsx<TProps extends ComponentProps>(\n type: VNodeType<TProps>,\n props: TemplateProps<TProps> | null,\n key?: Key,\n): VNode<TProps> {\n const nextProps: TemplateProps<TProps> = props == null\n ? {} as TemplateProps<TProps>\n : {...props}\n if (key !== undefined) nextProps.key = key\n return h(type, nextProps)\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n/** Preserve an explicitly constructed component instance in a vnode tree. */\nexport function createPrebuiltElement<TComponent extends Component>(\n component: TComponent,\n): TComponent {\n if (!(component instanceof Component)) {\n throw new TypeError('createPrebuiltElement requires a Component instance')\n }\n return component\n}\n\nexport namespace JSX {\n export type Element = VNode | Component\n export interface ElementClass extends Component {}\n export interface ElementAttributesProperty {\n props: {}\n }\n export interface ElementChildrenAttribute {\n children: {}\n }\n export interface IntrinsicAttributes {\n key?: Key\n }\n export type LibraryManagedAttributes<_TComponent, TProps extends ComponentProps> =\n TemplateProps<TProps>\n export type IntrinsicElements = FrayIntrinsicElements\n}\n\n// Used by declaration consumers that construct children without JSX.\nexport type JSXChild = FrayChild\n"],"names":["baseStyleDefinitions","STYLE_ATTRIBUTE","nextRegistryId","StyleRegistry","id","__publicField","css","selector","styleNames","names","name","styleName","selectors","generated","properties","variants","splitDefinition","selectorList","renderRule","variant","variantProperties","appendVariant","targetDocument","escapeAttributeValue","style","createStyleRegistry","styleRegistry","definition","property","value","label","declarations","pseudoElement","serviceKeys","serviceProviders","defineService","key","provideService","create","assertServiceKey","provider","ServiceScope","providers","assertServiceProvider","cycleStart","cycle","entry","instance","errors","dispose","readDispose","error","createServiceScope","isServiceKey","RESERVED_CUSTOM_ELEMENT_NAMES","FrayRuntime","options","registry","elementNames","prefix","assertNamePart","overrides","componentName","tagName","assertCustomElementName","hostName","standaloneHostName","resolved","cssText","componentType","args","component","parent","before","dependency","createFrayRuntime","defaultFrayRuntime","Fragment","liveBindingValues","BOOLEAN_ATTRIBUTES","PROPERTY_PROPS","live","emitter","assertReadableEmitter","binding","h","type","props","children","suppliedProps","propChildren","restProps","normalizeChildren","strings","values","result","string","index","_Component","runtime","seen","baseStyles","normalizeBaseStyles","mountedNow","assertParentNode","insertRecord","_event","nextReads","nextVNode","normalizeRoot","patchRoot","firstNode","nextProps","_dom","observables","observable","unsubscribe","event","cleanup","active","target","listener","eventListener","disposeRecord","Component","normalized","visit","child","createRecord","owner","isReadableEmitter","start","end","current","fragment","record","nextValue","readKey","isVNode","describeValue","patchChildren","node","patchElementProps","isComponentClass","sourceProps","resolvedProps","resolveLivePropValues","subscribeComponentLiveProps","functionType","functionProps","rendered","subscribeFunctionLiveProps","previous","isCompatible","patchCompatible","next","anchor","patchComponentLiveProps","patchFunctionLiveProps","isLiveBinding","reconcileLiveProps","resolvedLiveProps","rerenderFunctionRecord","subscriptions","onValue","existing","liveProp","_a","nextValues","keyed","unkeyed","seenKeys","retained","nextRecords","unkeyedIndex","valueKey","candidate","cursor","recordNodes","_nextChildren","keys","previousValue","isNativeBindingProp","patchNativeBinding","patchRef","isEventProp","patchEvent","patchLiveElementProp","previousLive","previousResolved","patchDOMProp","assertWritableEmitter","assertNativeBindingTarget","eventName","nativeBindingEvent","registered","applyRef","setAttribute","patchDataset","patchStyle","normalizePropertyName","enabled","normalizeAttributeName","oldValues","toPropertyRecord","newValues","camelToKebab","letter","ref","removeNodes","nodes","jsx","jsxs","jsxDEV","createPrebuiltElement"],"mappings":";;;AAIO,MAAMA,IAAuB;AAAA,EAChC,OAAO;AAAA,IACH,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IACV,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,kBAAkB;AAAA,EAAA;AAAA,EAGtB,WAAW;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,UAAU;AAAA,IACV,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,IACd,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAAA;AAAA,EAGlB,OAAO;AAAA,IACH,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,eAAe;AAAA,IACf,UAAU;AAAA,MACN,kBAAkB;AAAA,QACd,SAAS;AAAA,QACT,kBAAkB;AAAA,QAClB,gBAAg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Q;AACJ,WAAO,OAAO,UAAU,SAAS,KAAKA,CAAK;AAAA,EAC/C;AACJ;AAEA,SAASyE,GAAoBzE,GAAiD;AAC1E,MAAIA,KAAS,KAAM,QAAO,CAAA;AAC1B,MAAI,MAAM,QAAQA,CAAK;AACnB,WAAOA,EAAM,IAAI,CAACiB,MAAU;AACxB,UAAI,CAAC,MAAM,QAAQA,CAAK,KAAKA,EAAM,SAAS,KAAK,OAAOA,EAAM,CAAC,KAAM;AACjE,cAAM,IAAI,UAAU,4DAA4D;AAEpF,YAAMrC,IAAQqC,EAAM,CAAC;AACrB,UAAI,OAAOrC,KAAU,aACb,CAAC,MAAM,QAAQA,CAAK,KAAKA,EAAM,KAAK,CAACC,MAAS,OAAOA,KAAS,QAAQ;AAC1E,cAAM,IAAI,UAAU,4CAA4C;AAEpE,aAAO,CAACoC,EAAM,CAAC,GAAGrC,CAAuB;AAAA,IAC7C,CAAC;AAEL,MAAI,OAAOoB,KAAU;AACjB,UAAM,IAAI,UAAU,uDAAuD;AAE/E,SAAO,OAAO,QAAQA,CAAK,EAAE,IAAI,CAAC,CAACtB,GAAUE,CAAK,MAAM;AAAA,IACpDF;AAAA,IACAE;AAAA,EAAA,CACH;AACL;ACt+CO,SAAS0M,GACZ7H,GACAC,GACAnD,GACa;AACb,QAAM4E,IAAmCzB,KAAS,OAC5C,CAAA,IACA,EAAC,GAAGA,EAAA;AACV,SAAInD,MAAQ,WAAW4E,EAAU,MAAM5E,IAChCiD,EAAEC,GAAM0B,CAAS;AAC5B;AAEO,MAAMoG,KAAOD,IACPE,KAASF;AAGf,SAASG,GACZ/I,GACU;AACV,MAAI,EAAEA,aAAqBqD;AACvB,UAAM,IAAI,UAAU,qDAAqD;AAE7E,SAAOrD;AACX;"}
@@ -1,6 +1,6 @@
1
- import { F as s, g as e } from "./jsx-dev-runtime-DukiDpV9.js";
1
+ import { F as r, m as s } from "./jsx-dev-runtime-pzseD2Sz.js";
2
2
  export {
3
- s as Fragment,
4
- e as jsxDEV
3
+ r as Fragment,
4
+ s as jsxDEV
5
5
  };
6
6
  //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -1,9 +1,9 @@
1
- import { F as e, k as r, j as t, g as j, a as x } from "./jsx-dev-runtime-DukiDpV9.js";
1
+ import { F as e, o as r, j as t, m as j, a as m } from "./jsx-dev-runtime-pzseD2Sz.js";
2
2
  export {
3
3
  e as Fragment,
4
4
  r as createPrebuiltElement,
5
5
  t as jsx,
6
6
  j as jsxDEV,
7
- x as jsxs
7
+ m as jsxs
8
8
  };
9
9
  //# sourceMappingURL=jsx-runtime.js.map
package/dist/runtime.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Component, ComponentDependency } from './Components/component.js';
2
2
  import type { StyleRegistry } from './styling/styleRegistry.js';
3
+ import { ServiceScope } from './services.js';
3
4
  export interface FrayElementNameOptions {
4
5
  /** Namespace prepended to component host names. Defaults to `fray`. */
5
6
  prefix?: string | null;
@@ -8,12 +9,15 @@ export interface FrayElementNameOptions {
8
9
  }
9
10
  export interface FrayRuntimeOptions {
10
11
  elementNames?: FrayElementNameOptions;
12
+ /** Service scope inherited by every component created or mounted here. */
13
+ services?: ServiceScope;
11
14
  }
12
15
  /** Immutable application scope for element naming and structural styles. */
13
16
  export declare class FrayRuntime {
14
17
  readonly elementPrefix: string | null;
15
18
  readonly elementNameOverrides: Readonly<Record<string, string>>;
16
19
  readonly styleRegistry: StyleRegistry;
20
+ readonly services: ServiceScope;
17
21
  constructor(options?: FrayRuntimeOptions, registry?: StyleRegistry);
18
22
  resolveElementName(hostName: string, standaloneHostName?: string | null): string;
19
23
  resolveHostSelector(selector: string, hostName: string, standaloneHostName?: string | null): string;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,mBAAmB,EACtB,MAAM,2BAA2B,CAAA;AAKlC,OAAO,KAAK,EAAC,aAAa,EAAC,M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QAAQ,EAAE,MAAM,EAChB,kBAAkB,GAAE,MAAM,GAAG,IAAW,GACzC,MAAM;IAKT,cAAc,CACV,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,kBAAkB,GAAE,MAAM,GAAG,IAAW,GACzC,MAAM;IAKT,MAAM,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,UAAU,SAAS,SAAS,EACxD,aAAa,EAAE,KAAI,GAAG,IAAI,EAAE,KAAK,KAAK,UAAU,EAChD,GAAG,IAAI,EAAE,KAAK,GACf,UAAU;IAMb,KAAK,CAAC,UAAU,SAAS,SAAS,EAC9B,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,EAClB,MAAM,GAAE,IAAI,GAAG,IAAW,GAC3B,UAAU;IAMb,cAAc,CAAC,UAAU,EAAE,mBAAmB,GAAG,IAAI;IAQrD,YAAY,CAAC,cAAc,GAAE,QAA8B,GAAG,gBAAgB;CAGjF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAE/E;AAED,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,aAAqC,CAAA"}
@@ -0,0 +1,45 @@
1
+ declare const serviceType: unique symbol;
2
+ declare const serviceProviderType: unique symbol;
3
+ /** Typed identity for one application service contract. */
4
+ export interface ServiceKey<TService> {
5
+ readonly name: string;
6
+ readonly [serviceType]: TService;
7
+ }
8
+ /** Read-only service access exposed to service factories. */
9
+ export interface ServiceResolver {
10
+ has(key: ServiceKey<unknown>): boolean;
11
+ require<TService>(key: ServiceKey<TService>): TService;
12
+ }
13
+ export type ServiceFactory<TService> = (services: ServiceResolver) => TService;
14
+ /** Immutable registration for a lazily created, scope-shared service. */
15
+ export interface ServiceProvider<TService> {
16
+ readonly key: ServiceKey<TService>;
17
+ readonly create: ServiceFactory<TService>;
18
+ readonly [serviceProviderType]: true;
19
+ }
20
+ /** Declare a typed service identity without selecting an implementation. */
21
+ export declare function defineService<TService>(name: string): ServiceKey<TService>;
22
+ /** Select the factory for a service in one application composition root. */
23
+ export declare function provideService<TService>(key: ServiceKey<TService>, create: ServiceFactory<TService>): ServiceProvider<TService>;
24
+ /**
25
+ * Explicit application service scope.
26
+ *
27
+ * Providers are fixed at construction. Each service is created lazily at most
28
+ * once, shared inside this scope, and disposed in reverse creation order.
29
+ */
30
+ export declare class ServiceScope implements ServiceResolver {
31
+ private readonly providers;
32
+ private readonly instances;
33
+ private readonly creationOrder;
34
+ private readonly resolving;
35
+ private disposed;
36
+ constructor(providers?: readonly ServiceProvider<unknown>[]);
37
+ get isDisposed(): boolean;
38
+ has(key: ServiceKey<unknown>): boolean;
39
+ require<TService>(key: ServiceKey<TService>): TService;
40
+ dispose(): void;
41
+ private assertActive;
42
+ }
43
+ export declare function createServiceScope(providers?: readonly ServiceProvider<unknown>[]): ServiceScope;
44
+ export {};
45
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAA;AACxC,OAAO,CAAC,MAAM,mBAAmB,EAAE,OAAO,MAAM,CAAA;AAEhD,2DAA2D;AAC3D,MAAM,WAAW,UAAU,CAAC,QAAQ;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAA;CACnC;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC5B,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IACtC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;CACzD;AAED,MAAM,MAAM,cAAc,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,KAAK,QAAQ,CAAA;AAE9E,yEAAyE;AACzE,M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/** Deny mode: Excludes items that match the filter. */
4
- readonly Deny: "!";
4
+ readonly Deny: "deny";
5
5
  /** Require mode: Includes only items that match the filter. */
6
- readonly Require: "_";
6
+ readonly Require: "require";
7
7
  /** Prefer mode: If there are any filter options that are set to Prefer, at least one of the preferred filter options must match. Otherwise, it is treated as Neutral. */
8
- readonly Prefer: "";
8
+ readonly Prefer: "prefer";
9
9
  /** Neutral mode: Does not affect the inclusion or exclusion of items. */
10
- readonly Neutral: "";
10
+ readonly Neutral: "neutral";
11
11
  };
12
12
  export type FilterModeValue = typeof FilterMode[keyof typeof FilterMode];
13
+ /** Return whether a value is one of Fray's semantic filter modes. */
14
+ export declare function isFilterMode(value: unknown): value is FilterModeValue;
13
15
  //# sourceMappingURL=filterMode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterMode.d.ts","sourceRoot":"","sources":["../../src/util/filterMode.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,UAAU;IACnB,uDAAuD;;IAEvD,+DAA+D;;IAE/D,yKAAyK;;IAEzK,yEAAyE;;CAEnE,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA"}
1
+ {"version":3,"file":"filterMode.d.ts","sourceRoot":"","sources":["../../src/util/filterMode.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,UAAU;IACnB,uDAAuD;;IAEvD,+DAA+D;;IAE/D,yKAAyK;;IAEzK,yEAAyE;;CAEnE,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA;AAExE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAErE"}
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "type": "module",
3
3
  "name": "@sylwellsoftware/fray",
4
4
  "private": false,
5
- "version": "0.2.0",
6
- "description": "Experimental browser-only TypeScript component runtime, JSX controls, and semantic themes.",
5
+ "version": "0.4.0",
6
+ "description": "Browser-only TypeScript component runtime, JSX controls, and semantic themes.",
7
7
  "license": "Apache-2.0",
8
8
  "author": {
9
9
  "name": "Sylwell Software",
@@ -36,10 +36,6 @@
36
36
  "types": "./dist/index.d.ts",
37
37
  "import": "./dist/index.js"
38
38
  },
39
- "./experimental": {
40
- "types": "./dist/experimental.d.ts",
41
- "import": "./dist/experimental.js"
42
- },
43
39
  "./jsx-runtime": {
44
40
  "types": "./dist/jsx-runtime.d.ts",
45
41
  "import": "./dist/jsx-runtime.js"
@@ -59,7 +55,6 @@
59
55
  "styles",
60
56
  "themes",
61
57
  "colors",
62
- "EXPERIMENTAL.md",
63
58
  "LICENSE",
64
59
  "NOTICE"
65
60
  ],
@@ -69,11 +64,11 @@
69
64
  "./themes/**/*.css"
70
65
  ],
71
66
  "peerDependencies": {
72
- "@sylwellsoftware/glue": "^0.2.0"
67
+ "@sylwellsoftware/glue": "^0.4.0"
73
68
  },
74
69
  "devDependencies": {
75
70
  "vite": "^6.3.5",
76
- "@sylwellsoftware/glue": "^0.2.0"
71
+ "@sylwellsoftware/glue": "^0.4.0"
77
72
  },
78
73
  "engines": {
79
74
  "node": ">=22",
@@ -323,6 +323,11 @@ fray-data-table {
323
323
  border-collapse: collapse;
324
324
  }
325
325
 
326
+ fray-data-table thead:has([data-fray-component="filter-panel"]) {
327
+ position: relative;
328
+ z-index: 1100;
329
+ }
330
+
326
331
  fray-data-table th,
327
332
  fray-data-table td {
328
333
  padding: var(--ui-padding-v) var(--ui-padding-h);
@@ -408,9 +413,9 @@ th[data-fray-component="table-header-cell"] {
408
413
  }
409
414
 
410
415
  fray-filter-panel {
411
- position: absolute;
412
- z-index: 1000;
413
- inset-block-start: 100%;
416
+ position: fixed;
417
+ z-index: 1100;
418
+ inset-block-start: 0;
414
419
  inset-inline-end: 0;
415
420
  display: flex;
416
421
  min-width: 12rem;
@@ -422,6 +427,7 @@ fray-filter-panel {
422
427
  border: var(--panel-border);
423
428
  border-radius: var(--panel-radius);
424
429
  box-shadow: var(--panel-shadow);
430
+ overflow-y: auto;
425
431
  }
426
432
 
427
433
  div[data-fray-component="description-item"] {
package/themes/README.md CHANGED
@@ -80,5 +80,5 @@ practical; translucent white/black lighting used to construct a treatment is
80
80
  permitted in `theme.css`.
81
81
 
82
82
  The top-level `themes/light.css` and `themes/dark.css` exports are retained as
83
- alpha compatibility bundles. New integrations should use the separated paths
83
+ legacy compatibility bundles. New integrations should use the separated paths
84
84
  above.
@@ -74,7 +74,7 @@
74
74
  --fray-progress-value-background: var(--fray-color-primary);
75
75
  --fray-working-background-image: linear-gradient(-45deg, transparent 25%, color-mix(in srgb, var(--fray-color-highlight) 35%, transparent) 25% 50%, transparent 50% 75%, color-mix(in srgb, var(--fray-color-highlight) 35%, transparent) 75%);
76
76
 
77
- /* Alpha compatibility aliases; new components should use --fray-* names. */
77
+ /* Legacy compatibility aliases; new components should use --fray-* names. */
78
78
  --base-font-size: var(--fray-font-size);
79
79
  --ui-font-size: var(--fray-font-size);
80
80
  --ui-padding: var(--fray-space-sm);
package/EXPERIMENTAL.md DELETED
@@ -1,75 +0,0 @@
1
- # Fray experimental data APIs
2
-
3
- Everything imported from `@sylwellsoftware/fray/experimental` is outside Fray's stable
4
- alpha compatibility surface. It may change in any `0.x` release without a
5
- deprecation window. The stable package root does not export these symbols.
6
-
7
- `TreeView` is a controlled, single-select ARIA tree. Stable node keys reconcile
8
- selection and expansion across data replacement. Arrow keys navigate and
9
- expand/collapse, Home/End jump, Enter/Space select, and printable keys perform
10
- type-ahead. `TreeItem` supplies an optional declarative node form. The initial
11
- contract does not include virtualization, multi-selection, editing, or drag
12
- reordering.
13
-
14
- `Dialog` wraps the native modal element with a controlled boolean emitter,
15
- label/description relationships, cancel handling, initial focus, focus
16
- restoration, and deterministic cleanup. Applications provide actions and own
17
- all async work; the dialog does not infer promise or confirmation policy.
18
-
19
- ## Current behavior
20
-
21
- `ListView` and `DataTable` use stable item/row keys and expose their selected
22
- items through writable emitters. Single selection replaces the prior item.
23
- Multi-selection supports Control/Command toggles, Shift ranges, primary-button
24
- drag ranges, arrow/Home/End focus movement, and Space/Enter selection. A data
25
- refresh reconciles selected keys to the new row objects.
26
-
27
- `DataTable` requires an explicit `mode`:
28
-
29
- - `local` accepts an array or emitter, and performs sorting/filtering in the
30
- browser;
31
- - `remote` accepts a query emitter/handler or REST configuration, and sends
32
- sort/filter arguments through the documented table serializer.
33
-
34
- Filter state lives in the table's `filtersEmitter`, so opening a panel,
35
- changing a filter, rerendering, and refreshing data do not reset it. Remote
36
- tables distinguish these states:
37
-
38
- - initial/loading with no rows: status plus placeholder rows;
39
- - loading with retained rows: busy status plus the partial/previous rows;
40
- - ready with no rows: the configured empty message;
41
- - error with retained rows: an alert plus those rows;
42
- - error with no rows: an alert without a misleading empty message;
43
- - retryable query: a native Retry button that calls `query.retry()`.
44
-
45
- Pagination is not built in. A remote query may implement pagination arguments,
46
- but Fray does not currently supply pagination controls or a page model.
47
-
48
- ## Measured alpha boundary
49
-
50
- The alpha regression boundary is **1,000 rows with four to six simple columns
51
- on a modern desktop browser**. Larger datasets, expensive custom cell
52
- renderers, and mobile devices are not covered; paginate or filter them before
53
- rendering.
54
-
55
- The browser fixture measures a 1,000-row/four-column local table using stable
56
- keys. It times initial DOM creation, a full data refresh, numeric sorting, a
57
- filter that retains 500 rows, and one selection update. On the 2026-09-01 local
58
- arm64 macOS verification host with Playwright 1.62.1, the results were:
59
-
60
- | Engine | Initial | Rerender | Sort | Filter | Selection |
61
- | --- | ---: | ---: | ---: | ---: | ---: |
62
- | Chromium | 19.0 ms | 9.3 ms | 9.2 ms | 6.0 ms | 20.9 ms |
63
- | Firefox | 62.0 ms | 16.0 ms | 14.0 ms | 11.0 ms | 32.0 ms |
64
- | WebKit | 18.0 ms | 12.0 ms | 22.0 ms | 6.0 ms | 4.0 ms |
65
-
66
- These are synchronous headless-browser regression measurements, not a promise
67
- of end-to-end frame or device performance. The automated budget allows two
68
- seconds for initial creation and one second for each subsequent operation to
69
- remain robust on slower verification hosts while still catching a material
70
- regression.
71
-
72
- Virtualization is deliberately deferred: the measured boundary does not
73
- justify its lifecycle, focus, and accessibility complexity. Revisit it only
74
- with a demonstrated consumer above 1,000 rows and browser measurements showing
75
- that server-side pagination/filtering is insufficient.