microtags 0.0.14 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +554 -20
- package/dist/build.cjs +412 -0
- package/dist/build.cjs.map +7 -0
- package/dist/build.d.ts +17 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +395 -0
- package/dist/build.js.map +7 -0
- package/dist/builders.d.ts +70 -4
- package/dist/builders.d.ts.map +1 -1
- package/dist/{chunk-CCYWRJW6.js → chunk-46UEUDVX.js} +4 -26
- package/dist/chunk-46UEUDVX.js.map +7 -0
- package/dist/chunk-LS4L5QRD.js +26 -0
- package/dist/chunk-LS4L5QRD.js.map +7 -0
- package/dist/chunk-RKWPTT6P.js +69 -0
- package/dist/chunk-RKWPTT6P.js.map +7 -0
- package/dist/chunk-ZZ4ZLOQY.js +33 -0
- package/dist/chunk-ZZ4ZLOQY.js.map +7 -0
- package/dist/cli.cjs +536 -0
- package/dist/cli.cjs.map +7 -0
- package/dist/context.js +2 -1
- package/dist/esbuild.cjs +451 -0
- package/dist/esbuild.cjs.map +7 -0
- package/dist/esbuild.d.ts +7 -0
- package/dist/esbuild.d.ts.map +1 -0
- package/dist/esbuild.js +434 -0
- package/dist/esbuild.js.map +7 -0
- package/dist/factory.d.ts +7 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/htm.browser.cjs +591 -0
- package/dist/htm.browser.cjs.map +7 -0
- package/dist/htm.browser.d.ts +30 -0
- package/dist/htm.browser.d.ts.map +1 -0
- package/dist/htm.browser.js +498 -0
- package/dist/htm.browser.js.map +7 -0
- package/dist/htm.browser.min.js +3 -0
- package/dist/htm.browser.min.js.map +7 -0
- package/dist/htm.cjs +284 -0
- package/dist/htm.cjs.map +7 -0
- package/dist/htm.d.ts +14 -0
- package/dist/htm.d.ts.map +1 -0
- package/dist/htm.js +196 -0
- package/dist/htm.js.map +7 -0
- package/dist/htm.min.js +3 -0
- package/dist/htm.min.js.map +7 -0
- package/dist/index.cjs +125 -11
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -17
- package/dist/index.js.map +2 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +411 -26
- package/dist/preact-shared.d.ts +61 -0
- package/dist/preact-shared.d.ts.map +1 -0
- package/dist/preact.browser.d.ts +8 -0
- package/dist/preact.browser.d.ts.map +1 -0
- package/dist/preact.browser.js +45 -0
- package/dist/preact.browser.js.map +7 -0
- package/dist/preact.browser.min.js +2 -0
- package/dist/preact.browser.min.js.map +7 -0
- package/dist/preact.cjs +128 -0
- package/dist/preact.cjs.map +7 -0
- package/dist/preact.d.ts +9 -0
- package/dist/preact.d.ts.map +1 -0
- package/dist/preact.js +35 -0
- package/dist/preact.js.map +7 -0
- package/dist/render-support.cjs +86 -0
- package/dist/render-support.cjs.map +7 -0
- package/dist/render-support.d.ts +23 -0
- package/dist/render-support.d.ts.map +1 -0
- package/dist/render-support.js +12 -0
- package/dist/render-support.js.map +7 -0
- package/dist/render-support.min.js +2 -0
- package/dist/render-support.min.js.map +7 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +448 -0
- package/dist/vite.cjs.map +7 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +429 -0
- package/dist/vite.js.map +7 -0
- package/package.json +92 -13
- package/dist/chunk-CCYWRJW6.js.map +0 -7
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/reactivity.ts", "../src/util.ts", "../src/context.ts", "../src/setup-context.ts", "../src/factory.ts", "../src/builders.ts"],
|
|
4
|
-
"sourcesContent": ["export { peek, untracked } from './reactivity.js'\nexport { define } from './builders.js'\nexport type { TypedEvent } from './types.js'\n", "import {\n signal,\n effect,\n effectScope,\n setActiveSub,\n} from 'alien-signals'\nimport type { Signal } from './types.js'\n\n// Re-export alien-signals primitives under stable names for internal use.\nexport { signal, effect, effectScope }\n\n/**\n * Run fn without tracking any signals it reads.\n * Suspends the current subscriber via setActiveSub(undefined),\n * restoring it in a finally block so nested effects are unaffected.\n */\nexport function untracked<T> (fn:() => T):T {\n const prev = setActiveSub(undefined)\n try {\n return fn()\n } finally {\n setActiveSub(prev)\n }\n}\n\n/**\n * Read a signal's current value without subscribing.\n * Equivalent to untracked(() => sig()).\n */\nexport function peek<T> (sig:Signal<T>):T {\n return untracked(() => sig())\n}\n", "/**\n * Coerce a raw attribute string to a number.\n * Returns NaN if the value cannot be parsed.\n */\nexport function coerceNumber (raw:string | null):number {\n return raw === null ? NaN : Number(raw)\n}\n\n/**\n * Coerce a raw attribute string to a string.\n * Converts null to empty string.\n */\nexport function coerceString (raw:string | null):string {\n return raw ?? ''\n}\n\n/**\n * Coerce a raw attribute string to a boolean.\n * Absence (null) is false; presence of any value (including '') is true.\n */\nexport function coerceBoolean (raw:string | null):boolean {\n return raw !== null\n}\n\n/**\n * Coerce a raw attribute string to a parsed JSON value.\n * Returns undefined if the value is null or cannot be parsed.\n */\nexport function coerceJson<T = unknown> (raw:string | null):T | undefined {\n if (raw === null) return undefined\n try {\n return JSON.parse(raw) as T\n } catch {\n return undefined\n }\n}\n\n/**\n * Run every function in the list, ensuring all run even if some throw.\n * After all have run, re-throws the first error encountered.\n */\nexport function runAll (fns:(() => void)[]):void {\n let firstError:unknown\n let caught = false\n for (const fn of fns) {\n try {\n fn()\n } catch (err) {\n if (!caught) {\n firstError = err\n caught = true\n }\n }\n }\n if (caught) throw firstError\n}\n\nexport type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param {Attrs} attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "import { signal } from './reactivity.js'\nimport type { ContextToken, Signal } from './types.js'\n\n// Provider storage: element -> (contextId -> Signal)\nconst providerStorage = new WeakMap<Element, Map<symbol, Signal<unknown>>>()\n\n// Pending consumers waiting for a context by id\nconst pendingCallbacks = new Map<symbol, Set<() => void>>()\n\n/**\n * Create a new context token.\n * Each token uniquely identifies a type of shared context.\n */\nexport function createContext<T> ():ContextToken<T> {\n return { id: Symbol('microtag-context') }\n}\n\n/**\n * Provide a context value from an element to its descendants.\n * Returns a cleanup function that removes the provided value.\n */\nexport function provide<T> (\n element:Element,\n token:ContextToken<T>,\n value:T\n):() => void {\n let map = providerStorage.get(element)\n if (!map) {\n map = new Map()\n providerStorage.set(element, map)\n }\n\n const existing = map.get(token.id) as Signal<T> | undefined\n if (existing) {\n existing(value)\n } else {\n const sig = signal(value) as unknown as Signal<T>\n map.set(token.id, sig as Signal<unknown>)\n }\n\n notifyPending(token.id)\n\n return () => {\n const m = providerStorage.get(element)\n if (m) {\n m.delete(token.id)\n if (m.size === 0) providerStorage.delete(element)\n }\n }\n}\n\n/**\n * Walk up the DOM from element to find the nearest provider signal.\n * Returns the signal (not the value) so callers can subscribe to changes.\n */\nexport function resolveContextSignal<T> (\n element:Element,\n token:ContextToken<T>\n):Signal<T> | undefined {\n let current:Element | null = element.parentElement\n while (current) {\n const map = providerStorage.get(current)\n if (map && map.has(token.id)) {\n return map.get(token.id) as Signal<T>\n }\n current = current.parentElement\n }\n return undefined\n}\n\n/**\n * Register a callback to run when the given context becomes available.\n * Returns a cleanup function to unregister.\n */\nexport function onContextAvailable (\n id:symbol,\n callback:() => void\n):() => void {\n let set = pendingCallbacks.get(id)\n if (!set) {\n set = new Set()\n pendingCallbacks.set(id, set)\n }\n set.add(callback)\n return () => { pendingCallbacks.get(id)?.delete(callback) }\n}\n\nfunction notifyPending (id:symbol):void {\n const set = pendingCallbacks.get(id)\n if (set) {\n for (const cb of set) cb()\n }\n}\n", "import { effect, peek } from './reactivity.js'\nimport { resolveContextSignal } from './context.js'\nimport type {\n SetupContext,\n Signal,\n PropsSignals,\n PropDef,\n ContextToken,\n BindOptions,\n} from './types.js'\n\n/**\n * Build the ctx object passed to a component's setup() callback.\n * The cleanups array is mutated in place so factory.ts can drain it\n * on disconnect without copying.\n */\nexport function makeSetupContext<\n Props extends Record<string, PropDef> = Record<string, PropDef>,\n> (\n host:HTMLElement,\n props:PropsSignals<Props>,\n refs:Record<string, Element | Element[]>,\n contexts:Record<string, unknown>,\n cleanups:(() => void)[]\n):SetupContext<Props, any, any> {\n return {\n host,\n props,\n refs,\n contexts,\n\n peek,\n\n on (target, type, handler, options?) {\n target.addEventListener(\n type as string,\n handler as EventListener,\n options\n )\n cleanups.push(() => {\n target.removeEventListener(\n type as string,\n handler as EventListener,\n options\n )\n })\n },\n\n emit (\n nameOrEvent:Event | string,\n detail?:unknown,\n options?:Omit<CustomEventInit, 'detail'>\n ):boolean {\n const event = nameOrEvent instanceof Event ?\n nameOrEvent :\n new CustomEvent(nameOrEvent, {\n bubbles: true,\n ...options,\n detail,\n })\n return host.dispatchEvent(event)\n },\n\n effect (fn) {\n const dispose = effect(fn)\n cleanups.push(dispose)\n },\n\n bind<T> (\n source:Signal<T>,\n control:Element,\n opts?:BindOptions\n ) {\n const input = control instanceof HTMLInputElement ?\n control :\n undefined\n let prop = 'value'\n let autoEvent = 'change'\n if (input?.type === 'checkbox') {\n prop = 'checked'\n } else if (input?.type === 'number' ||\n input?.type === 'range') {\n prop = 'valueAsNumber'\n autoEvent = 'input'\n } else if (input || control instanceof HTMLTextAreaElement) {\n autoEvent = 'input'\n }\n\n const boundProp = opts?.prop ?? prop\n const event = opts ? opts.event : autoEvent\n const el = control as unknown as Record<string, unknown>\n\n if (event) {\n const handler = () => {\n const writable = source as Signal<unknown>\n writable(el[boundProp])\n }\n control.addEventListener(event, handler)\n cleanups.push(() => {\n control.removeEventListener(event, handler)\n })\n }\n\n const dispose = effect(() => {\n el[boundProp] = source()\n })\n cleanups.push(dispose)\n },\n\n onCleanup (fn) {\n cleanups.push(fn)\n },\n\n consume<T> (token:ContextToken<T>):T | undefined {\n const sig = resolveContextSignal(host, token)\n return sig ? sig() : undefined\n },\n }\n}\n", "import { signal } from './reactivity.js'\nimport { runAll } from './util.js'\nimport { makeSetupContext } from './setup-context.js'\nimport {\n resolveContextSignal,\n onContextAvailable,\n} from './context.js'\nimport type {\n PropsSignals,\n Signal,\n SetupContext,\n Coercer,\n ContextToken,\n RefDef,\n} from './types.js'\n\n/**\n * Map of prop name to coercer function.\n * The factory accepts coercers exclusively; Standard Schema support is\n * layered on top in the withProps builder (US-005).\n */\nexport type FactoryProps = Record<string, Coercer<unknown>>\n\n/**\n * The class to extend for custom elements. In the browser this is the\n * real HTMLElement; in Node (e.g. reading `.TAG` for SSR) it falls back\n * to an empty stub so the class can be defined without a DOM. The stub\n * is never instantiated or registered outside the browser.\n */\nconst HTMLElementBase = typeof HTMLElement !== 'undefined' ?\n HTMLElement :\n (class {} as unknown as typeof HTMLElement)\n\n/** Configuration passed to factory(). */\nexport interface FactoryConfig<Props extends FactoryProps = FactoryProps> {\n /** Coercer for each observed attribute / prop. */\n props:Props\n /** Attribute names to pass to observedAttributes. */\n observedAttrNames:string[]\n /** Ref definitions keyed by name. */\n refs?:Record<string, RefDef>\n /** Context tokens keyed by name. */\n contexts?:Record<string, ContextToken<unknown>>\n /** Setup callback receiving the component context. */\n setup:(ctx:SetupContext<Props, any, any>) => void\n}\n\n/**\n * Collect resolved DOM refs from within a host element.\n * Throws if any single-ref element is missing.\n */\nfunction collectRefs (\n host:HTMLElement,\n defs:Record<string, RefDef>\n):Record<string, Element|Element[]> {\n const result:Record<string, Element|Element[]> = {}\n const missing:string[] = []\n for (const [key, def] of Object.entries(defs)) {\n const sel = def.selector ?? `[data-ref=\"${key}\"]`\n if (def._microtag === 'ref:all') {\n result[key] = Array.from(host.querySelectorAll(sel))\n } else {\n const el = host.querySelector(sel)\n if (!el) {\n missing.push(key)\n } else {\n result[key] = el\n }\n }\n }\n if (missing.length > 0) {\n throw new Error(\n `${host.tagName}: missing refs: ${missing.join(', ')}`\n )\n }\n return result\n}\n\n/**\n * Create an HTMLElement subclass with the microtags lifecycle.\n * The returned class has no Shadow DOM, tracks its own prop signals,\n * and runs setup() on connect / cleanups on disconnect.\n */\nexport function factory<Props extends FactoryProps = FactoryProps> (\n config:FactoryConfig<Props>\n):typeof HTMLElement {\n const {\n props: propDefs,\n observedAttrNames,\n setup,\n refs: refDefs = {},\n contexts: ctxDefs = {},\n } = config\n\n class MicrotagElement extends HTMLElementBase {\n static get observedAttributes () { return observedAttrNames }\n\n _props:Record<string, Signal<unknown>> = {}\n _cleanups:(() => void)[] = []\n\n constructor () {\n super()\n for (const [name, coercer] of Object.entries(propDefs)) {\n this._props[name] = signal(coercer(null))\n }\n }\n\n connectedCallback () {\n // Start a fresh cleanup scope for each connection cycle.\n this._cleanups = []\n\n // Hydrate prop signals from attributes; preserve any\n // programmatically-set value when the attribute is absent.\n for (const [name, coercer] of Object.entries(propDefs)) {\n const attrVal = this.getAttribute(name)\n if (attrVal !== null) {\n (this._props[name] as Signal<unknown>)(coercer(attrVal))\n }\n }\n\n const cleanups = this._cleanups\n const props = this._props as PropsSignals<Props>\n\n // Reactive Proxy: reading a key inside a ctx.effect creates\n // a subscription to the provider's alien-signals signal.\n const contexts = new Proxy({} as Record<string, unknown>, {\n get: (_target, key) => {\n if (typeof key !== 'string') return undefined\n const token = ctxDefs[key]\n if (!token) return undefined\n const sig = resolveContextSignal(this, token)\n return sig ? sig() : undefined\n },\n has: (_target, key) => {\n if (typeof key !== 'string') return false\n return key in ctxDefs\n },\n })\n\n let setupRan = false\n // Tracks pending-context cancel functions so they are\n // removed from the global registry when setup runs or\n // when the element disconnects.\n const cancelCallbacks:(() => void)[] = []\n\n const tryRunSetup = ():void => {\n if (setupRan) return\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) return\n }\n setupRan = true\n for (const cancel of cancelCallbacks) cancel()\n cancelCallbacks.length = 0\n\n const refs = collectRefs(this, refDefs)\n const ctx = makeSetupContext(\n this, props, refs, contexts, cleanups\n )\n setup(ctx)\n }\n\n // Deferred variant: skip if element was disconnected before\n // the context became available.\n const tryRunSetupIfConnected = ():void => {\n if (!this.isConnected) return\n tryRunSetup()\n }\n\n // Register pending listeners for any missing contexts.\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) {\n const cancel = onContextAvailable(\n token.id, tryRunSetupIfConnected\n )\n cancelCallbacks.push(cancel)\n // Also cancel on disconnect so we don't leak.\n cleanups.push(cancel)\n }\n }\n\n tryRunSetup()\n }\n\n attributeChangedCallback (\n name:string,\n _old:string|null,\n next:string|null\n ) {\n const coercer = propDefs[name]\n if (coercer !== undefined && this._props[name] !== undefined) {\n (this._props[name] as Signal<unknown>)(coercer(next))\n }\n }\n\n disconnectedCallback () {\n // Snapshot and clear BEFORE running so re-entrant calls are safe\n // and the array is always empty after this returns (or throws).\n const fns = this._cleanups\n this._cleanups = []\n runAll(fns)\n }\n }\n\n return MicrotagElement\n}\n", "import type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type {\n PropDef,\n PropertyOnlyProp,\n SetupContext,\n Coercer,\n RefDef,\n SingleRefDef,\n MultipleRefDef,\n RefsMap,\n ContextToken,\n ContextsMap,\n} from './types.js'\nimport {\n coerceNumber,\n coerceString,\n coerceBoolean,\n coerceJson,\n} from './util.js'\nimport { factory } from './factory.js'\n\n/** The DSL object passed to the withProps callback. */\nexport type PropDSL = {\n number():Coercer<number>\n string():Coercer<string>\n boolean():Coercer<boolean>\n json<T>():Coercer<T | undefined>\n schema<T>(validator:StandardSchemaV1<unknown, T>):StandardSchemaV1<unknown, T>\n prop<T>(initial:T):PropertyOnlyProp<T>\n}\n\nexport const propDSL:PropDSL = {\n number: () => coerceNumber,\n string: () => coerceString,\n boolean: () => coerceBoolean,\n json: <T>() => coerceJson as Coercer<T | undefined>,\n schema: <T>(v:StandardSchemaV1<unknown, T>) => v,\n prop: <T>(initial:T):PropertyOnlyProp<T> => (\n { _microtag: 'prop', initial }\n ),\n}\n\n/**\n * DSL object passed to the withRefs callback.\n * Call `r.one()` for a single element or `r.all()` for multiple. Pass a\n * CSS selector to query by it, or omit it to match `[data-ref=\"<key>\"]`.\n *\n * Element typing:\n * - `r.one()` defaults to `HTMLElement`.\n * - `r.one<T>()` sets the type and keeps the `[data-ref]` selector.\n * - `r.one('button')` infers the type from the tag AND queries by that\n * tag, exactly like `document.querySelector('button')`.\n */\nexport type RefsDSL = {\n one<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):SingleRefDef<HTMLElementTagNameMap[K]>\n one<T extends HTMLElement = HTMLElement>(selector?:string):SingleRefDef<T>\n\n all<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):MultipleRefDef<HTMLElementTagNameMap[K]>\n all<T extends HTMLElement = HTMLElement>(selector?:string):MultipleRefDef<T>\n}\n\nexport const refsDSL:RefsDSL = {\n one: ((selector?:string):SingleRefDef => (\n { _microtag: 'ref:one', selector }\n )) as RefsDSL['one'],\n all: ((selector?:string):MultipleRefDef => (\n { _microtag: 'ref:all', selector }\n )) as RefsDSL['all'],\n}\n\n/**\n * DSL object passed to the withContexts callback.\n * Currently a no-op placeholder; the user references imported\n * context tokens directly in the returned record.\n */\nexport type ContextDSL = Record<never, never>\nconst contextDSL:ContextDSL = {}\n\n/**\n * Maps each declared ref key to its own name as a string literal. Exposed\n * as the static `refs` on a registered element so server-rendered templates\n * can fill in `data-ref` values without hardcoding the names, e.g.\n * `data-ref=\"${MyCounter.refs.dec}\"`.\n */\nexport type RefNames<RefDefs extends Record<string, RefDef>> = {\n readonly [K in keyof RefDefs]:K & string\n}\n\n/**\n * A registered custom element class that also exposes, as static members,\n * the tag name it was registered under (`TAG`) and the names of its\n * declared refs (`refs`).\n */\nexport type MicrotagElementClass<\n RefDefs extends Record<string, RefDef> = Record<never, never>\n> = typeof HTMLElement & {\n /** The custom element tag name, e.g. 'my-counter'. */\n readonly TAG:string\n /**\n * The declared ref names, each mapping to its own `data-ref` string.\n * Lets server-rendered markup reference refs by key instead of a magic\n * string: `MyCounter.refs.dec`.\n */\n readonly refs:RefNames<RefDefs>\n}\n\n/**\n * Fluent builder that accumulates props/refs/contexts config\n * before registering a custom element via `.setup()`.\n */\nexport class ComponentBuilder<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n CtxDefs extends Record<string, ContextToken<unknown>> =\n Record<never, never>,\n> {\n private readonly _coercers:Record<string, Coercer<unknown>>\n private readonly _observed:string[]\n private readonly _refDefs:Record<string, RefDef>\n private readonly _ctxDefs:Record<string, ContextToken<unknown>>\n\n constructor (\n readonly tagName:string,\n coercers:Record<string, Coercer<unknown>> = {},\n observed:string[] = [],\n refDefs:Record<string, RefDef> = {},\n ctxDefs:Record<string, ContextToken<unknown>> = {}\n ) {\n this._coercers = coercers\n this._observed = observed\n this._refDefs = refDefs\n this._ctxDefs = ctxDefs\n }\n\n /**\n * The custom element tag name, e.g. 'my-counter'. Available at every\n * point in the fluent chain since each builder method returns a new\n * builder carrying the same tag name.\n */\n get TAG ():string {\n return this.tagName\n }\n\n withProps<P extends Record<string, PropDef>> (\n fn:(p:PropDSL) => P\n ):ComponentBuilder<P, RefDefs, CtxDefs> {\n const defs = fn(propDSL)\n const coercers:Record<string, Coercer<unknown>> = {}\n const observed:string[] = []\n\n for (const [name, def] of Object.entries(defs)) {\n coercers[name] = normalizePropDef(name, def as PropDef<unknown>)\n if (!isPropOnly(def)) {\n observed.push(name)\n }\n }\n\n return new ComponentBuilder<P, RefDefs, CtxDefs>(\n this.tagName,\n coercers,\n observed,\n this._refDefs,\n this._ctxDefs\n )\n }\n\n withRefs<R extends Record<string, RefDef>> (\n fn:(r:RefsDSL) => R\n ):ComponentBuilder<Props, R, CtxDefs> {\n const defs = fn(refsDSL)\n return new ComponentBuilder<Props, R, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n defs,\n this._ctxDefs\n )\n }\n\n withContexts<C extends Record<string, ContextToken<unknown>>> (\n fn:(c:ContextDSL) => C\n ):ComponentBuilder<Props, RefDefs, C> {\n const defs = fn(contextDSL)\n return new ComponentBuilder<Props, RefDefs, C>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n defs\n )\n }\n\n setup (\n fn:(ctx:SetupContext<\n Props,\n RefsMap<RefDefs>,\n ContextsMap<CtxDefs>\n >) => void\n ):MicrotagElementClass<RefDefs> {\n const El = factory({\n props: this._coercers,\n observedAttrNames: this._observed,\n refs: this._refDefs,\n contexts: this._ctxDefs,\n setup: fn as any,\n })\n Object.defineProperty(El, 'TAG', {\n value: this.tagName,\n enumerable: true,\n })\n\n // Expose each ref key as its own `data-ref` name so server-rendered\n // markup can reference refs by key instead of a hardcoded string.\n const refNames:Record<string, string> = {}\n for (const key of Object.keys(this._refDefs)) {\n refNames[key] = key\n }\n Object.defineProperty(El, 'refs', {\n value: Object.freeze(refNames),\n enumerable: true,\n })\n\n if (typeof customElements !== 'undefined') {\n customElements.define(this.tagName, El)\n }\n return El as MicrotagElementClass<RefDefs>\n }\n}\n\n/** Create a new component builder for the given tag name. */\nexport function define (tagName:string):ComponentBuilder {\n return new ComponentBuilder(tagName)\n}\n\nfunction isPropOnly (def:unknown):def is PropertyOnlyProp<unknown> {\n return (\n typeof def === 'object' &&\n def !== null &&\n '_microtag' in def &&\n (def as { _microtag: unknown })._microtag === 'prop'\n )\n}\n\nfunction isStandardSchema (def:unknown):def is StandardSchemaV1 {\n return (\n typeof def === 'object' &&\n def !== null &&\n '~standard' in def\n )\n}\n\nfunction normalizePropDef (\n name:string,\n def:PropDef<unknown>\n):Coercer<unknown> {\n if (isPropOnly(def)) {\n return (_raw:string | null) => def.initial\n }\n if (isStandardSchema(def)) {\n const schema = def as StandardSchemaV1\n return (raw:string | null):unknown => {\n const result = schema['~standard'].validate(raw)\n if (result instanceof Promise) {\n throw new TypeError(\n `withProps: async schemas are not supported (prop \"${name}\")`\n )\n }\n if (result.issues) return undefined\n return result.value\n }\n }\n return def as Coercer<unknown>\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAKO;AAWA,SAAS,UAAc,IAAc;AACxC,QAAM,WAAO,mCAAa,MAAS;AACnC,MAAI;AACA,WAAO,GAAG;AAAA,EACd,UAAE;AACE,2CAAa,IAAI;AAAA,EACrB;AACJ;AAPgB;AAaT,SAAS,KAAS,KAAiB;AACtC,SAAO,UAAU,MAAM,IAAI,CAAC;AAChC;AAFgB;;;ACzBT,SAAS,aAAc,KAA0B;AACpD,SAAO,QAAQ,OAAO,MAAM,OAAO,GAAG;AAC1C;AAFgB;AAQT,SAAS,aAAc,KAA0B;AACpD,SAAO,OAAO;AAClB;AAFgB;AAQT,SAAS,cAAe,KAA2B;AACtD,SAAO,QAAQ;AACnB;AAFgB;AAQT,SAAS,WAAyB,KAAiC;AACtE,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI;AACA,WAAO,KAAK,MAAM,GAAG;AAAA,EACzB,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAPgB;AAaT,SAAS,OAAQ,KAAyB;AAC7C,MAAI;AACJ,MAAI,SAAS;AACb,aAAW,MAAM,KAAK;AAClB,QAAI;AACA,SAAG;AAAA,IACP,SAAS,KAAK;AACV,UAAI,CAAC,QAAQ;AACT,qBAAa;AACb,iBAAS;AAAA,MACb;AAAA,IACJ;AAAA,EACJ;AACA,MAAI,OAAQ,OAAM;AACtB;AAdgB;;;ACrChB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AAS,WAAY,KAA8C;AAC/D,SACI,OAAO,QAAQ,YACf,QAAQ,QACR,eAAe,OACd,IAA+B,cAAc;AAEtD;AAPS;AAST,SAAS,iBAAkB,KAAqC;AAC5D,SACI,OAAO,QAAQ,YACf,QAAQ,QACR,eAAe;AAEvB;AANS;AAQT,SAAS,iBACL,MACA,KACe;AACf,MAAI,WAAW,GAAG,GAAG;AACjB,WAAO,CAAC,SAAuB,IAAI;AAAA,EACvC;AACA,MAAI,iBAAiB,GAAG,GAAG;AACvB,UAAM,SAAS;AACf,WAAO,CAAC,QAA8B;AAClC,YAAM,SAAS,OAAO,WAAW,EAAE,SAAS,GAAG;AAC/C,UAAI,kBAAkB,SAAS;AAC3B,cAAM,IAAI;AAAA,UACN,qDAAqD,IAAI;AAAA,QAC7D;AAAA,MACJ;AACA,UAAI,OAAO,OAAQ,QAAO;AAC1B,aAAO,OAAO;AAAA,IAClB;AAAA,EACJ;AACA,SAAO;AACX;AArBS;",
|
|
4
|
+
"sourcesContent": ["export { peek, untracked } from './reactivity.js'\nexport { define } from './builders.js'\nexport { bindProp } from './factory.js'\nexport type { Serialized, Signal, TypedEvent } from './types.js'\nexport type {\n MicrotagElementClass,\n MicrotagHost,\n RenderContext,\n RenderFn,\n RenderOptions,\n RenderProps,\n StaticRenderFn,\n StaticRenderPartsFn,\n RenderParts,\n} from './builders.js'\n", "import {\n signal,\n effect,\n effectScope,\n setActiveSub,\n} from 'alien-signals'\nimport type { Signal } from './types.js'\n\n// Re-export alien-signals primitives under stable names for internal use.\nexport { signal, effect, effectScope }\n\n/**\n * Run fn without tracking any signals it reads.\n * Suspends the current subscriber via setActiveSub(undefined),\n * restoring it in a finally block so nested effects are unaffected.\n */\nexport function untracked<T> (fn:() => T):T {\n const prev = setActiveSub(undefined)\n try {\n return fn()\n } finally {\n setActiveSub(prev)\n }\n}\n\n/**\n * Read a signal's current value without subscribing.\n * Equivalent to untracked(() => sig()).\n */\nexport function peek<T> (sig:Signal<T>):T {\n return untracked(() => sig())\n}\n", "/**\n * Coerce a raw attribute string to a number.\n * Returns NaN if the value cannot be parsed.\n */\nexport function coerceNumber (raw:string | null):number {\n return raw === null ? NaN : Number(raw)\n}\n\n/**\n * Coerce a raw attribute string to a string.\n * Converts null to empty string.\n */\nexport function coerceString (raw:string | null):string {\n return raw ?? ''\n}\n\n/**\n * Coerce a raw attribute string to a boolean.\n * Absence (null) is false; presence of any value (including '') is true.\n */\nexport function coerceBoolean (raw:string | null):boolean {\n return raw !== null\n}\n\n/**\n * Coerce a raw attribute string to a parsed JSON value.\n * Returns undefined if the value is null or cannot be parsed.\n */\nexport function coerceJson<T = unknown> (raw:string | null):T | undefined {\n if (raw === null) return undefined\n try {\n return JSON.parse(raw) as T\n } catch {\n return undefined\n }\n}\n\n/**\n * Run every function in the list, ensuring all run even if some throw.\n * After all have run, re-throws the first error encountered.\n */\nexport function runAll (fns:(() => void)[]):void {\n let firstError:unknown\n let caught = false\n for (const fn of fns) {\n try {\n fn()\n } catch (err) {\n if (!caught) {\n firstError = err\n caught = true\n }\n }\n }\n if (caught) throw firstError\n}\n\nexport type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param {Attrs} attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "import { signal } from './reactivity.js'\nimport type { ContextToken, Signal } from './types.js'\n\n// Provider storage: element -> (contextId -> Signal)\nconst providerStorage = new WeakMap<Element, Map<symbol, Signal<unknown>>>()\n\n// Pending consumers waiting for a context by id\nconst pendingCallbacks = new Map<symbol, Set<() => void>>()\n\n/**\n * Create a new context token.\n * Each token uniquely identifies a type of shared context.\n */\nexport function createContext<T> ():ContextToken<T> {\n return { id: Symbol('microtag-context') }\n}\n\n/**\n * Provide a context value from an element to its descendants.\n * Returns a cleanup function that removes the provided value.\n */\nexport function provide<T> (\n element:Element,\n token:ContextToken<T>,\n value:T\n):() => void {\n let map = providerStorage.get(element)\n if (!map) {\n map = new Map()\n providerStorage.set(element, map)\n }\n\n const existing = map.get(token.id) as Signal<T> | undefined\n if (existing) {\n existing(value)\n } else {\n const sig = signal(value) as unknown as Signal<T>\n map.set(token.id, sig as Signal<unknown>)\n }\n\n notifyPending(token.id)\n\n return () => {\n const m = providerStorage.get(element)\n if (m) {\n m.delete(token.id)\n if (m.size === 0) providerStorage.delete(element)\n }\n }\n}\n\n/**\n * Walk up the DOM from element to find the nearest provider signal.\n * Returns the signal (not the value) so callers can subscribe to changes.\n */\nexport function resolveContextSignal<T> (\n element:Element,\n token:ContextToken<T>\n):Signal<T> | undefined {\n let current:Element | null = element.parentElement\n while (current) {\n const map = providerStorage.get(current)\n if (map && map.has(token.id)) {\n return map.get(token.id) as Signal<T>\n }\n current = current.parentElement\n }\n return undefined\n}\n\n/**\n * Register a callback to run when the given context becomes available.\n * Returns a cleanup function to unregister.\n */\nexport function onContextAvailable (\n id:symbol,\n callback:() => void\n):() => void {\n let set = pendingCallbacks.get(id)\n if (!set) {\n set = new Set()\n pendingCallbacks.set(id, set)\n }\n set.add(callback)\n return () => { pendingCallbacks.get(id)?.delete(callback) }\n}\n\nfunction notifyPending (id:symbol):void {\n const set = pendingCallbacks.get(id)\n if (set) {\n for (const cb of set) cb()\n }\n}\n", "import { effect, peek } from './reactivity.js'\nimport { resolveContextSignal } from './context.js'\nimport type {\n SetupContext,\n Signal,\n PropsSignals,\n PropDef,\n ContextToken,\n BindOptions,\n} from './types.js'\n\n/**\n * Build the ctx object passed to a component's setup() callback.\n * The cleanups array is mutated in place so factory.ts can drain it\n * on disconnect without copying.\n */\nexport function makeSetupContext<\n Props extends Record<string, PropDef> = Record<string, PropDef>,\n> (\n host:HTMLElement,\n props:PropsSignals<Props>,\n refs:Record<string, Element | Element[]>,\n contexts:Record<string, unknown>,\n cleanups:(() => void)[]\n):SetupContext<Props, any, any> {\n return {\n host,\n props,\n refs,\n contexts,\n\n peek,\n\n on (target, type, handler, options?) {\n target.addEventListener(\n type as string,\n handler as EventListener,\n options\n )\n cleanups.push(() => {\n target.removeEventListener(\n type as string,\n handler as EventListener,\n options\n )\n })\n },\n\n emit (\n nameOrEvent:Event | string,\n detail?:unknown,\n options?:Omit<CustomEventInit, 'detail'>\n ):boolean {\n const event = nameOrEvent instanceof Event ?\n nameOrEvent :\n new CustomEvent(nameOrEvent, {\n bubbles: true,\n ...options,\n detail,\n })\n return host.dispatchEvent(event)\n },\n\n effect (fn) {\n const dispose = effect(fn)\n cleanups.push(dispose)\n },\n\n bind<T> (\n source:Signal<T>,\n control:Element,\n opts?:BindOptions\n ) {\n const input = control instanceof HTMLInputElement ?\n control :\n undefined\n let prop = 'value'\n let autoEvent = 'change'\n if (input?.type === 'checkbox') {\n prop = 'checked'\n } else if (input?.type === 'number' ||\n input?.type === 'range') {\n prop = 'valueAsNumber'\n autoEvent = 'input'\n } else if (input || control instanceof HTMLTextAreaElement) {\n autoEvent = 'input'\n }\n\n const boundProp = opts?.prop ?? prop\n const event = opts ? opts.event : autoEvent\n const el = control as unknown as Record<string, unknown>\n\n if (event) {\n const handler = () => {\n const writable = source as Signal<unknown>\n writable(el[boundProp])\n }\n control.addEventListener(event, handler)\n cleanups.push(() => {\n control.removeEventListener(event, handler)\n })\n }\n\n const dispose = effect(() => {\n el[boundProp] = source()\n })\n cleanups.push(dispose)\n },\n\n onCleanup (fn) {\n cleanups.push(fn)\n },\n\n consume<T> (token:ContextToken<T>):T | undefined {\n const sig = resolveContextSignal(host, token)\n return sig ? sig() : undefined\n },\n }\n}\n", "import { signal } from './reactivity.js'\nimport { runAll } from './util.js'\nimport { makeSetupContext } from './setup-context.js'\nimport {\n resolveContextSignal,\n onContextAvailable,\n} from './context.js'\nimport type {\n PropsSignals,\n Signal,\n SetupContext,\n Coercer,\n ContextToken,\n RefDef,\n} from './types.js'\n\n/**\n * Map of prop name to coercer function.\n * The factory accepts coercers exclusively; Standard Schema support is\n * layered on top in the withProps builder (US-005).\n */\nexport type FactoryProps = Record<string, Coercer<unknown>>\n\n/**\n * The class to extend for custom elements. In the browser this is the\n * real HTMLElement; in Node (e.g. reading `.TAG` for SSR) it falls back\n * to an empty stub so the class can be defined without a DOM. The stub\n * is never instantiated or registered outside the browser.\n */\nconst HTMLElementBase = typeof HTMLElement !== 'undefined' ?\n HTMLElement :\n (class {} as unknown as typeof HTMLElement)\n\n/** Configuration passed to factory(). */\nexport interface FactoryConfig<Props extends FactoryProps = FactoryProps> {\n /** Coercer for each observed attribute / prop. */\n props:Props\n /** Attribute names to pass to observedAttributes. */\n observedAttrNames:string[]\n /** Ref definitions keyed by name. */\n refs?:Record<string, RefDef>\n /** Context tokens keyed by name. */\n contexts?:Record<string, ContextToken<unknown>>\n /** Setup callback receiving the component context. */\n setup:(ctx:SetupContext<Props, any, any>) => void\n}\n\n/**\n * Collect resolved DOM refs from within a host element.\n * Throws if any single-ref element is missing.\n */\nfunction collectRefs (\n host:HTMLElement,\n defs:Record<string, RefDef>\n):Record<string, Element|Element[]> {\n const result:Record<string, Element|Element[]> = {}\n const missing:string[] = []\n for (const [key, def] of Object.entries(defs)) {\n const sel = def.selector ?? `[data-ref=\"${key}\"]`\n if (def._microtag === 'ref:all') {\n result[key] = Array.from(host.querySelectorAll(sel))\n } else {\n const el = host.querySelector(sel)\n if (!el) {\n missing.push(key)\n } else {\n result[key] = el\n }\n }\n }\n if (missing.length > 0) {\n throw new Error(\n `${host.tagName}: missing refs: ${missing.join(', ')}`\n )\n }\n return result\n}\n\n/**\n * Create an HTMLElement subclass with the microtags lifecycle.\n * The returned class has no Shadow DOM, tracks its own prop signals,\n * and runs setup() on connect / cleanups a microtask after disconnect.\n */\nexport function factory<Props extends FactoryProps = FactoryProps> (\n config:FactoryConfig<Props>\n):typeof HTMLElement {\n const {\n props: propDefs,\n observedAttrNames,\n setup,\n refs: refDefs = {},\n contexts: ctxDefs = {},\n } = config\n\n class MicrotagElement extends HTMLElementBase {\n static get observedAttributes () { return observedAttrNames }\n\n _props:Record<string, Signal<unknown>> = {}\n // Per prop: the external signal assigned to the accessor, if any.\n _bound:Record<string, Signal<Signal<unknown>|undefined>> = {}\n _cleanups:(() => void)[] = []\n // Connected and set up, not yet torn down.\n _live = false\n\n constructor () {\n super()\n for (const [name, coercer] of Object.entries(propDefs)) {\n const own = signal(coercer(null))\n const bound = signal<Signal<unknown>|undefined>(undefined)\n this._bound[name] = bound\n // Reads go through the bound signal when one is set,\n // so setup's prop signal tracks it. A bound prop is\n // owned by the parent, so writing it here throws.\n this._props[name] = ((...args:unknown[]) => {\n const ext = bound()\n if (!args.length) return ext ? ext() : own()\n if (ext) {\n throw new Error(`${this.localName}: prop \"${name}\"` +\n ' is bound and read-only; emit an event instead')\n }\n own(args[0])\n }) as Signal<unknown>\n // Pick up a property set before the upgrade; it\n // shadows the prototype accessor until removed.\n if (Object.prototype.hasOwnProperty.call(this, name)) {\n const pre = (this as any)[name]\n delete (this as any)[name]\n ;(this as any)[name] = pre\n }\n }\n }\n\n connectedCallback () {\n // Back before the queued teardown ran: this was a move.\n if (this._live) return\n this._live = true\n // Start a fresh cleanup scope for each connection cycle.\n this._cleanups = []\n\n // Hydrate prop signals from attributes; preserve any\n // programmatically-set value when the attribute is absent.\n for (const [name, coercer] of Object.entries(propDefs)) {\n const attrVal = this.getAttribute(name)\n if (attrVal !== null && !this._bound[name]()) {\n (this._props[name] as Signal<unknown>)(coercer(attrVal))\n }\n }\n\n const cleanups = this._cleanups\n const props = this._props as PropsSignals<Props>\n\n // Reactive Proxy: reading a key inside a ctx.effect creates\n // a subscription to the provider's alien-signals signal.\n const contexts = new Proxy({} as Record<string, unknown>, {\n get: (_target, key) => {\n if (typeof key !== 'string') return undefined\n const token = ctxDefs[key]\n if (!token) return undefined\n const sig = resolveContextSignal(this, token)\n return sig ? sig() : undefined\n },\n has: (_target, key) => {\n if (typeof key !== 'string') return false\n return key in ctxDefs\n },\n })\n\n let setupRan = false\n // Tracks pending-context cancel functions so they are\n // removed from the global registry when setup runs or\n // when the element disconnects.\n const cancelCallbacks:(() => void)[] = []\n\n const tryRunSetup = ():void => {\n if (setupRan) return\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) return\n }\n setupRan = true\n for (const cancel of cancelCallbacks) cancel()\n cancelCallbacks.length = 0\n\n const refs = collectRefs(this, refDefs)\n const ctx = makeSetupContext(\n this, props, refs, contexts, cleanups\n )\n setup(ctx)\n }\n\n // Deferred variant: skip if element was disconnected before\n // the context became available.\n const tryRunSetupIfConnected = ():void => {\n if (!this.isConnected) return\n tryRunSetup()\n }\n\n // Register pending listeners for any missing contexts.\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) {\n const cancel = onContextAvailable(\n token.id, tryRunSetupIfConnected\n )\n cancelCallbacks.push(cancel)\n // Also cancel on disconnect so we don't leak.\n cleanups.push(cancel)\n }\n }\n\n tryRunSetup()\n }\n\n attributeChangedCallback (\n name:string,\n _old:string|null,\n next:string|null\n ) {\n const coercer = propDefs[name]\n if (\n coercer !== undefined &&\n this._props[name] !== undefined &&\n !this._bound[name]()\n ) {\n (this._props[name] as Signal<unknown>)(coercer(next))\n }\n }\n\n // A DOM move (`moveBefore`) keeps the host set up\n connectedMoveCallback () {}\n\n // Teardown waits a microtask, so a host removed and re-inserted\n // in the same tick (`insertBefore` without `moveBefore`) keeps\n // its setup.\n disconnectedCallback () {\n queueMicrotask(() => {\n if (this.isConnected || !this._live) return\n this._live = false\n // Snapshot and clear BEFORE running so re-entrant calls\n // are safe and the array is empty after this throws.\n const fns = this._cleanups\n this._cleanups = []\n runAll(fns)\n })\n }\n }\n\n // One accessor per prop. A function value is taken to be a signal\n // and bound; anything else unbinds and writes the prop.\n for (const name of Object.keys(propDefs)) {\n Object.defineProperty(MicrotagElement.prototype, name, {\n get (this:MicrotagElement) { return this._props[name]() },\n set (this:MicrotagElement, v:unknown) {\n if (typeof v === 'function') {\n this._bound[name](v as Signal<unknown>)\n } else {\n this._bound[name](undefined)\n this._props[name](v)\n }\n },\n configurable: true,\n })\n }\n\n return MicrotagElement\n}\n\n/**\n * Bind a signal (or computed) to a declared prop of a host, so the prop\n * reads through to it. Same as assigning the signal to the accessor,\n * but typed: the signal's value must match the prop's type.\n */\nexport const bindProp = <\n H extends HTMLElement,\n K extends Exclude<keyof H, keyof HTMLElement>,\n> (host:H, name:K, source:() => H[K]):void => {\n (host as any)[name] = source\n}\n", "import type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type { Markup } from './htm.js'\nimport type { Markup as BrowserMarkup } from './htm.browser.js'\nimport type {\n PropDef,\n PropType,\n PropertyOnlyProp,\n SetupContext,\n Coercer,\n RefDef,\n SingleRefDef,\n MultipleRefDef,\n RefsMap,\n ContextToken,\n ContextsMap,\n} from './types.js'\nimport {\n coerceNumber,\n coerceString,\n coerceBoolean,\n coerceJson,\n} from './util.js'\nimport { factory } from './factory.js'\n// The serializer kind is decided here, by coercer identity, so the\n// server render support module never compares coercers from another\n// copy of the package.\nexport type PropKind =\n 'prop-only' | 'schema' | 'boolean' | 'json' | 'coercer'\n\nexport interface PropMeta {\n kind:PropKind\n coercer:Coercer<unknown>\n}\n\n/**\n * What a `render` static hands the server render support module: tag,\n * prop metadata, ref names and the render function. This shape is a\n * contract between package copies; changing it needs a new symbol key.\n */\nexport interface RenderRecord {\n t:string\n m:Record<string, PropMeta>\n r:Record<string, string>\n f:RenderFn<any, any>\n}\n\n/** The DSL object passed to the withProps callback. */\nexport type PropDSL = {\n number():Coercer<number>\n string():Coercer<string>\n boolean():Coercer<boolean>\n json<T>():Coercer<T | undefined>\n schema<T>(validator:StandardSchemaV1<unknown, T>):StandardSchemaV1<unknown, T>\n prop<T>(initial:T):PropertyOnlyProp<T>\n}\n\nexport const propDSL:PropDSL = {\n number: () => coerceNumber,\n string: () => coerceString,\n boolean: () => coerceBoolean,\n json: <T>() => coerceJson as Coercer<T | undefined>,\n schema: <T>(v:StandardSchemaV1<unknown, T>) => v,\n prop: <T>(initial:T):PropertyOnlyProp<T> => (\n { _microtag: 'prop', initial }\n ),\n}\n\n/**\n * DSL object passed to the withRefs callback.\n * Call `r.one()` for a single element or `r.all()` for multiple. Pass a\n * CSS selector to query by it, or omit it to match `[data-ref=\"<key>\"]`.\n *\n * Element typing:\n * - `r.one()` defaults to `HTMLElement`.\n * - `r.one<T>()` sets the type and keeps the `[data-ref]` selector.\n * - `r.one('button')` infers the type from the tag AND queries by that\n * tag, exactly like `document.querySelector('button')`.\n */\nexport type RefsDSL = {\n one<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):SingleRefDef<HTMLElementTagNameMap[K]>\n one<T extends HTMLElement = HTMLElement>(selector?:string):SingleRefDef<T>\n\n all<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):MultipleRefDef<HTMLElementTagNameMap[K]>\n all<T extends HTMLElement = HTMLElement>(selector?:string):MultipleRefDef<T>\n}\n\nexport const refsDSL:RefsDSL = {\n one: ((selector?:string):SingleRefDef => (\n { _microtag: 'ref:one', selector }\n )) as RefsDSL['one'],\n all: ((selector?:string):MultipleRefDef => (\n { _microtag: 'ref:all', selector }\n )) as RefsDSL['all'],\n}\n\n/**\n * DSL object passed to the withContexts callback.\n * Currently a no-op placeholder; the user references imported\n * context tokens directly in the returned record.\n */\nexport type ContextDSL = Record<never, never>\nconst contextDSL:ContextDSL = {}\n\n/**\n * Maps each declared ref key to its own name as a string literal. Exposed\n * as the static `refs` on a registered element so server-rendered templates\n * can fill in `data-ref` values without hardcoding the names, e.g.\n * `data-ref=\"${MyCounter.refs.dec}\"`.\n */\nexport type RefNames<RefDefs extends Record<string, RefDef>> = {\n readonly [K in keyof RefDefs]:K & string\n}\n\n/** Plain values for props (not signals) in the render context. */\nexport type RenderProps<Defs extends Record<string, PropDef>> = {\n [K in keyof Defs]:PropType<Defs[K]>\n}\n\nexport interface RenderContext<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> {\n props:RenderProps<Props>\n refs:RefNames<RefDefs>\n TAG:string\n children:string\n attrs:Record<string, string>\n}\n\nexport type RenderFn<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> = (\n ctx:RenderContext<Props, RefDefs>\n) => string | Markup | BrowserMarkup\n\nexport interface RenderOptions {\n client?:boolean\n}\n\nexport type StaticRenderFn<\n Props extends Record<string, PropDef>,\n> = (\n props:RenderProps<Props>,\n options?:{ children?:string; attrs?:Record<string, string> }\n) => string\n\n/**\n * A component's server render as parts: the host tag name, its\n * serialized host attributes (declared props first, then extra attrs,\n * unescaped; a true boolean is the empty string) and the inner HTML.\n */\nexport interface RenderParts {\n tag:string\n attrs:Record<string, string>\n html:string\n}\n\nexport type StaticRenderPartsFn<\n Props extends Record<string, PropDef>,\n> = (\n props:RenderProps<Props>,\n options?:{ children?:string; attrs?:Record<string, string> }\n) => RenderParts\n\n/**\n * A host element: an `HTMLElement` with a property accessor for each\n * declared prop, typed as the prop's value. A signal bound with\n * `bindProp` makes the prop read through to it.\n */\nexport type MicrotagHost<\n Props extends Record<string, PropDef> = Record<never, never>,\n> = HTMLElement & RenderProps<Props>\n\n/**\n * A registered custom element class that also exposes, as static members,\n * the tag name it was registered under (`TAG`) and the names of its\n * declared refs (`refs`).\n */\nexport type MicrotagElementClass<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> = {\n new ():MicrotagHost<Props>\n readonly prototype:MicrotagHost<Props>\n /** The custom element tag name, e.g. 'my-counter'. */\n readonly TAG:string\n /**\n * The declared ref names, each mapping to its own `data-ref` string.\n * Lets server-rendered markup reference refs by key instead of a magic\n * string: `MyCounter.refs.dec`.\n */\n readonly refs:RefNames<RefDefs>\n readonly render:StaticRenderFn<Props>\n readonly renderParts:StaticRenderPartsFn<Props>\n readonly props:readonly (keyof Props & string)[]\n}\n\n/**\n * Fluent builder that accumulates props/refs/contexts config\n * before registering a custom element via `.setup()`.\n */\nexport class ComponentBuilder<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n CtxDefs extends Record<string, ContextToken<unknown>> = Record<never, never>,\n> {\n private readonly _coercers:Record<string, Coercer<unknown>>\n private readonly _observed:string[]\n private readonly _propNames:string[]\n private readonly _propMetas:Record<string, PropMeta>\n private readonly _refDefs:Record<string, RefDef>\n private readonly _ctxDefs:Record<string, ContextToken<unknown>>\n private readonly _renderFn?:RenderFn<Props, RefDefs>\n\n constructor (\n readonly tagName:string,\n coercers:Record<string, Coercer<unknown>> = {},\n observed:string[] = [],\n refDefs:Record<string, RefDef> = {},\n ctxDefs:Record<string, ContextToken<unknown>> = {},\n propNames:string[] = [],\n propMetas:Record<string, PropMeta> = {},\n renderFn?:RenderFn<any, any>,\n ) {\n this._coercers = coercers\n this._observed = observed\n this._propNames = propNames\n this._propMetas = propMetas\n this._refDefs = refDefs\n this._ctxDefs = ctxDefs\n this._renderFn = renderFn as\n RenderFn<Props, RefDefs> | undefined\n }\n\n /**\n * The custom element tag name, e.g. 'my-counter'. Available at every\n * point in the fluent chain since each builder method returns a new\n * builder carrying the same tag name.\n */\n get TAG ():string {\n return this.tagName\n }\n\n withProps<P extends Record<string, PropDef>> (\n fn:(p:PropDSL) => P\n ):ComponentBuilder<P, RefDefs, CtxDefs> {\n const defs = fn(propDSL)\n const coercers:Record<string, Coercer<unknown>> = {}\n const observed:string[] = []\n const propNames:string[] = []\n const propMetas:Record<string, PropMeta> = {}\n\n for (const [name, def] of Object.entries(defs)) {\n const coercer = normalizePropDef(\n name,\n def as PropDef<unknown>\n )\n coercers[name] = coercer\n propNames.push(name)\n\n const kind = isPropOnly(def) ?\n 'prop-only' as const :\n isStandardSchema(def) ?\n 'schema' as const :\n coercer === coerceBoolean ?\n 'boolean' as const :\n coercer === coerceJson ?\n 'json' as const :\n 'coercer' as const\n\n propMetas[name] = { kind, coercer }\n\n if (!isPropOnly(def)) {\n observed.push(name)\n }\n }\n\n return new ComponentBuilder<P, RefDefs, CtxDefs>(\n this.tagName,\n coercers,\n observed,\n this._refDefs,\n this._ctxDefs,\n propNames,\n propMetas,\n )\n }\n\n withRefs<R extends Record<string, RefDef>> (\n fn:(r:RefsDSL) => R\n ):ComponentBuilder<Props, R, CtxDefs> {\n const defs = fn(refsDSL)\n return new ComponentBuilder<Props, R, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n defs,\n this._ctxDefs,\n this._propNames,\n this._propMetas,\n this._renderFn,\n )\n }\n\n withContexts<C extends Record<string, ContextToken<unknown>>> (\n fn:(c:ContextDSL) => C\n ):ComponentBuilder<Props, RefDefs, C> {\n const defs = fn(contextDSL)\n return new ComponentBuilder<Props, RefDefs, C>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n defs,\n this._propNames,\n this._propMetas,\n this._renderFn,\n )\n }\n\n render (\n fn:RenderFn<Props, RefDefs>,\n _options?:RenderOptions\n ):ComponentBuilder<Props, RefDefs, CtxDefs> {\n return new ComponentBuilder<Props, RefDefs, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n this._ctxDefs,\n this._propNames,\n this._propMetas,\n fn,\n )\n }\n\n setup (\n fn:(ctx:SetupContext<\n Props,\n RefsMap<RefDefs>,\n ContextsMap<CtxDefs>\n >) => void\n ):MicrotagElementClass<Props, RefDefs> {\n const El = factory({\n props: this._coercers,\n observedAttrNames: this._observed,\n refs: this._refDefs,\n contexts: this._ctxDefs,\n setup: fn as any,\n })\n Object.defineProperty(El, 'TAG', {\n value: this.tagName,\n enumerable: true,\n })\n\n const refNames:Record<string, string> = {}\n for (const key of Object.keys(this._refDefs)) {\n refNames[key] = key\n }\n Object.defineProperty(El, 'refs', {\n value: Object.freeze(refNames),\n enumerable: true,\n })\n\n Object.defineProperty(El, 'props', {\n value: Object.freeze([...this._propNames]),\n enumerable: true,\n })\n\n if (this._renderFn) {\n const rec:RenderRecord = {\n t: this.tagName,\n m: this._propMetas,\n r: Object.freeze({ ...refNames }),\n f: this._renderFn,\n }\n // One helper per registry key, so both statics share the\n // lookup and the error.\n const link = (k:string) => (p:unknown, o:unknown) => {\n const f = (globalThis as any)[Symbol.for('microtags.' + k)]\n if (!f) {\n throw new Error(\n `microtags: ${k} needs \"microtags/render-support\"`\n )\n }\n return f(rec, p, o)\n }\n Object.defineProperties(El, {\n render: { value: link('render'), enumerable: true },\n renderParts: {\n value: link('renderParts'),\n enumerable: true,\n },\n })\n }\n\n if (typeof customElements !== 'undefined') {\n customElements.define(this.tagName, El)\n }\n return El as unknown as MicrotagElementClass<Props, RefDefs>\n }\n}\n\n/** Create a new component builder for the given tag name. */\nexport function define (tagName:string):ComponentBuilder {\n return new ComponentBuilder(tagName)\n}\n\nfunction isPropOnly (def:unknown):def is PropertyOnlyProp<unknown> {\n return (\n typeof def === 'object' &&\n def !== null &&\n '_microtag' in def &&\n (def as { _microtag: unknown })._microtag === 'prop'\n )\n}\n\nfunction isStandardSchema (def:unknown):def is StandardSchemaV1 {\n return (\n typeof def === 'object' &&\n def !== null &&\n '~standard' in def\n )\n}\n\nfunction normalizePropDef (\n name:string,\n def:PropDef<unknown>\n):Coercer<unknown> {\n if (isPropOnly(def)) {\n return (_raw:string | null) => def.initial\n }\n if (isStandardSchema(def)) {\n const schema = def as StandardSchemaV1\n return (raw:string | null):unknown => {\n const result = schema['~standard'].validate(raw)\n if (result instanceof Promise) {\n throw new TypeError(\n `withProps: async schemas are not supported (prop \"${name}\")`\n )\n }\n if (result.issues) return undefined\n return result.value\n }\n }\n return def as Coercer<unknown>\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;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f,QAAQ,QACR,eAAe,OACd,IAA+B,cAAc;AAEtD;AAPS;AAST,SAAS,iBAAkB,KAAqC;AAC5D,SACI,OAAO,QAAQ,YACf,QAAQ,QACR,eAAe;AAEvB;AANS;AAQT,SAAS,iBACL,MACA,KACe;AACf,MAAI,WAAW,GAAG,GAAG;AACjB,WAAO,CAAC,SAAuB,IAAI;AAAA,EACvC;AACA,MAAI,iBAAiB,GAAG,GAAG;AACvB,UAAM,SAAS;AACf,WAAO,CAAC,QAA8B;AAClC,YAAM,SAAS,OAAO,WAAW,EAAE,SAAS,GAAG;AAC/C,UAAI,kBAAkB,SAAS;AAC3B,cAAM,IAAI;AAAA,UACN,qDAAqD,IAAI;AAAA,QAC7D;AAAA,MACJ;AACA,UAAI,OAAO,OAAQ,QAAO;AAC1B,aAAO,OAAO;AAAA,IAClB;AAAA,EACJ;AACA,SAAO;AACX;AArBS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { peek, untracked } from './reactivity.js';
|
|
2
2
|
export { define } from './builders.js';
|
|
3
|
-
export
|
|
3
|
+
export { bindProp } from './factory.js';
|
|
4
|
+
export type { Serialized, Signal, TypedEvent } from './types.js';
|
|
5
|
+
export type { MicrotagElementClass, MicrotagHost, RenderContext, RenderFn, RenderOptions, RenderProps, StaticRenderFn, StaticRenderPartsFn, RenderParts, } from './builders.js';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAChE,YAAY,EACR,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,WAAW,GACd,MAAM,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
effect,
|
|
3
2
|
onContextAvailable,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
signal,
|
|
7
|
-
untracked
|
|
8
|
-
} from "./chunk-CCYWRJW6.js";
|
|
3
|
+
resolveContextSignal
|
|
4
|
+
} from "./chunk-46UEUDVX.js";
|
|
9
5
|
import {
|
|
10
6
|
coerceBoolean,
|
|
11
7
|
coerceJson,
|
|
@@ -13,6 +9,12 @@ import {
|
|
|
13
9
|
coerceString,
|
|
14
10
|
runAll
|
|
15
11
|
} from "./chunk-FZKCMDSS.js";
|
|
12
|
+
import {
|
|
13
|
+
effect,
|
|
14
|
+
peek,
|
|
15
|
+
signal,
|
|
16
|
+
untracked
|
|
17
|
+
} from "./chunk-ZZ4ZLOQY.js";
|
|
16
18
|
import {
|
|
17
19
|
__name
|
|
18
20
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -135,18 +137,39 @@ function factory(config) {
|
|
|
135
137
|
return observedAttrNames;
|
|
136
138
|
}
|
|
137
139
|
_props = {};
|
|
140
|
+
// Per prop: the external signal assigned to the accessor, if any.
|
|
141
|
+
_bound = {};
|
|
138
142
|
_cleanups = [];
|
|
143
|
+
// Connected and set up, not yet torn down.
|
|
144
|
+
_live = false;
|
|
139
145
|
constructor() {
|
|
140
146
|
super();
|
|
141
147
|
for (const [name, coercer] of Object.entries(propDefs)) {
|
|
142
|
-
|
|
148
|
+
const own = signal(coercer(null));
|
|
149
|
+
const bound = signal(void 0);
|
|
150
|
+
this._bound[name] = bound;
|
|
151
|
+
this._props[name] = ((...args) => {
|
|
152
|
+
const ext = bound();
|
|
153
|
+
if (!args.length) return ext ? ext() : own();
|
|
154
|
+
if (ext) {
|
|
155
|
+
throw new Error(`${this.localName}: prop "${name}" is bound and read-only; emit an event instead`);
|
|
156
|
+
}
|
|
157
|
+
own(args[0]);
|
|
158
|
+
});
|
|
159
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
160
|
+
const pre = this[name];
|
|
161
|
+
delete this[name];
|
|
162
|
+
this[name] = pre;
|
|
163
|
+
}
|
|
143
164
|
}
|
|
144
165
|
}
|
|
145
166
|
connectedCallback() {
|
|
167
|
+
if (this._live) return;
|
|
168
|
+
this._live = true;
|
|
146
169
|
this._cleanups = [];
|
|
147
170
|
for (const [name, coercer] of Object.entries(propDefs)) {
|
|
148
171
|
const attrVal = this.getAttribute(name);
|
|
149
|
-
if (attrVal !== null) {
|
|
172
|
+
if (attrVal !== null && !this._bound[name]()) {
|
|
150
173
|
this._props[name](coercer(attrVal));
|
|
151
174
|
}
|
|
152
175
|
}
|
|
@@ -203,19 +226,48 @@ function factory(config) {
|
|
|
203
226
|
}
|
|
204
227
|
attributeChangedCallback(name, _old, next) {
|
|
205
228
|
const coercer = propDefs[name];
|
|
206
|
-
if (coercer !== void 0 && this._props[name] !== void 0) {
|
|
229
|
+
if (coercer !== void 0 && this._props[name] !== void 0 && !this._bound[name]()) {
|
|
207
230
|
this._props[name](coercer(next));
|
|
208
231
|
}
|
|
209
232
|
}
|
|
233
|
+
// A DOM move (`moveBefore`) keeps the host set up
|
|
234
|
+
connectedMoveCallback() {
|
|
235
|
+
}
|
|
236
|
+
// Teardown waits a microtask, so a host removed and re-inserted
|
|
237
|
+
// in the same tick (`insertBefore` without `moveBefore`) keeps
|
|
238
|
+
// its setup.
|
|
210
239
|
disconnectedCallback() {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
240
|
+
queueMicrotask(() => {
|
|
241
|
+
if (this.isConnected || !this._live) return;
|
|
242
|
+
this._live = false;
|
|
243
|
+
const fns = this._cleanups;
|
|
244
|
+
this._cleanups = [];
|
|
245
|
+
runAll(fns);
|
|
246
|
+
});
|
|
214
247
|
}
|
|
215
248
|
}
|
|
249
|
+
for (const name of Object.keys(propDefs)) {
|
|
250
|
+
Object.defineProperty(MicrotagElement.prototype, name, {
|
|
251
|
+
get() {
|
|
252
|
+
return this._props[name]();
|
|
253
|
+
},
|
|
254
|
+
set(v) {
|
|
255
|
+
if (typeof v === "function") {
|
|
256
|
+
this._bound[name](v);
|
|
257
|
+
} else {
|
|
258
|
+
this._bound[name](void 0);
|
|
259
|
+
this._props[name](v);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
configurable: true
|
|
263
|
+
});
|
|
264
|
+
}
|
|
216
265
|
return MicrotagElement;
|
|
217
266
|
}
|
|
218
267
|
__name(factory, "factory");
|
|
268
|
+
var bindProp = /* @__PURE__ */ __name((host, name, source) => {
|
|
269
|
+
host[name] = source;
|
|
270
|
+
}, "bindProp");
|
|
219
271
|
|
|
220
272
|
// src/builders.ts
|
|
221
273
|
var propDSL = {
|
|
@@ -232,12 +284,15 @@ var refsDSL = {
|
|
|
232
284
|
};
|
|
233
285
|
var contextDSL = {};
|
|
234
286
|
var ComponentBuilder = class _ComponentBuilder {
|
|
235
|
-
constructor(tagName, coercers = {}, observed = [], refDefs = {}, ctxDefs = {}) {
|
|
287
|
+
constructor(tagName, coercers = {}, observed = [], refDefs = {}, ctxDefs = {}, propNames = [], propMetas = {}, renderFn) {
|
|
236
288
|
this.tagName = tagName;
|
|
237
289
|
this._coercers = coercers;
|
|
238
290
|
this._observed = observed;
|
|
291
|
+
this._propNames = propNames;
|
|
292
|
+
this._propMetas = propMetas;
|
|
239
293
|
this._refDefs = refDefs;
|
|
240
294
|
this._ctxDefs = ctxDefs;
|
|
295
|
+
this._renderFn = renderFn;
|
|
241
296
|
}
|
|
242
297
|
tagName;
|
|
243
298
|
static {
|
|
@@ -245,8 +300,11 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
245
300
|
}
|
|
246
301
|
_coercers;
|
|
247
302
|
_observed;
|
|
303
|
+
_propNames;
|
|
304
|
+
_propMetas;
|
|
248
305
|
_refDefs;
|
|
249
306
|
_ctxDefs;
|
|
307
|
+
_renderFn;
|
|
250
308
|
/**
|
|
251
309
|
* The custom element tag name, e.g. 'my-counter'. Available at every
|
|
252
310
|
* point in the fluent chain since each builder method returns a new
|
|
@@ -259,8 +317,17 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
259
317
|
const defs = fn(propDSL);
|
|
260
318
|
const coercers = {};
|
|
261
319
|
const observed = [];
|
|
320
|
+
const propNames = [];
|
|
321
|
+
const propMetas = {};
|
|
262
322
|
for (const [name, def] of Object.entries(defs)) {
|
|
263
|
-
|
|
323
|
+
const coercer = normalizePropDef(
|
|
324
|
+
name,
|
|
325
|
+
def
|
|
326
|
+
);
|
|
327
|
+
coercers[name] = coercer;
|
|
328
|
+
propNames.push(name);
|
|
329
|
+
const kind = isPropOnly(def) ? "prop-only" : isStandardSchema(def) ? "schema" : coercer === coerceBoolean ? "boolean" : coercer === coerceJson ? "json" : "coercer";
|
|
330
|
+
propMetas[name] = { kind, coercer };
|
|
264
331
|
if (!isPropOnly(def)) {
|
|
265
332
|
observed.push(name);
|
|
266
333
|
}
|
|
@@ -270,7 +337,9 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
270
337
|
coercers,
|
|
271
338
|
observed,
|
|
272
339
|
this._refDefs,
|
|
273
|
-
this._ctxDefs
|
|
340
|
+
this._ctxDefs,
|
|
341
|
+
propNames,
|
|
342
|
+
propMetas
|
|
274
343
|
);
|
|
275
344
|
}
|
|
276
345
|
withRefs(fn) {
|
|
@@ -280,7 +349,10 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
280
349
|
this._coercers,
|
|
281
350
|
this._observed,
|
|
282
351
|
defs,
|
|
283
|
-
this._ctxDefs
|
|
352
|
+
this._ctxDefs,
|
|
353
|
+
this._propNames,
|
|
354
|
+
this._propMetas,
|
|
355
|
+
this._renderFn
|
|
284
356
|
);
|
|
285
357
|
}
|
|
286
358
|
withContexts(fn) {
|
|
@@ -290,7 +362,22 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
290
362
|
this._coercers,
|
|
291
363
|
this._observed,
|
|
292
364
|
this._refDefs,
|
|
293
|
-
defs
|
|
365
|
+
defs,
|
|
366
|
+
this._propNames,
|
|
367
|
+
this._propMetas,
|
|
368
|
+
this._renderFn
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
render(fn, _options) {
|
|
372
|
+
return new _ComponentBuilder(
|
|
373
|
+
this.tagName,
|
|
374
|
+
this._coercers,
|
|
375
|
+
this._observed,
|
|
376
|
+
this._refDefs,
|
|
377
|
+
this._ctxDefs,
|
|
378
|
+
this._propNames,
|
|
379
|
+
this._propMetas,
|
|
380
|
+
fn
|
|
294
381
|
);
|
|
295
382
|
}
|
|
296
383
|
setup(fn) {
|
|
@@ -313,6 +400,34 @@ var ComponentBuilder = class _ComponentBuilder {
|
|
|
313
400
|
value: Object.freeze(refNames),
|
|
314
401
|
enumerable: true
|
|
315
402
|
});
|
|
403
|
+
Object.defineProperty(El, "props", {
|
|
404
|
+
value: Object.freeze([...this._propNames]),
|
|
405
|
+
enumerable: true
|
|
406
|
+
});
|
|
407
|
+
if (this._renderFn) {
|
|
408
|
+
const rec = {
|
|
409
|
+
t: this.tagName,
|
|
410
|
+
m: this._propMetas,
|
|
411
|
+
r: Object.freeze({ ...refNames }),
|
|
412
|
+
f: this._renderFn
|
|
413
|
+
};
|
|
414
|
+
const link = /* @__PURE__ */ __name((k) => (p, o) => {
|
|
415
|
+
const f = globalThis[/* @__PURE__ */ Symbol.for("microtags." + k)];
|
|
416
|
+
if (!f) {
|
|
417
|
+
throw new Error(
|
|
418
|
+
`microtags: ${k} needs "microtags/render-support"`
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
return f(rec, p, o);
|
|
422
|
+
}, "link");
|
|
423
|
+
Object.defineProperties(El, {
|
|
424
|
+
render: { value: link("render"), enumerable: true },
|
|
425
|
+
renderParts: {
|
|
426
|
+
value: link("renderParts"),
|
|
427
|
+
enumerable: true
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
316
431
|
if (typeof customElements !== "undefined") {
|
|
317
432
|
customElements.define(this.tagName, El);
|
|
318
433
|
}
|
|
@@ -352,6 +467,7 @@ function normalizePropDef(name, def) {
|
|
|
352
467
|
}
|
|
353
468
|
__name(normalizePropDef, "normalizePropDef");
|
|
354
469
|
export {
|
|
470
|
+
bindProp,
|
|
355
471
|
define,
|
|
356
472
|
peek,
|
|
357
473
|
untracked
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/setup-context.ts", "../src/factory.ts", "../src/builders.ts"],
|
|
4
|
-
"sourcesContent": ["import { effect, peek } from './reactivity.js'\nimport { resolveContextSignal } from './context.js'\nimport type {\n SetupContext,\n Signal,\n PropsSignals,\n PropDef,\n ContextToken,\n BindOptions,\n} from './types.js'\n\n/**\n * Build the ctx object passed to a component's setup() callback.\n * The cleanups array is mutated in place so factory.ts can drain it\n * on disconnect without copying.\n */\nexport function makeSetupContext<\n Props extends Record<string, PropDef> = Record<string, PropDef>,\n> (\n host:HTMLElement,\n props:PropsSignals<Props>,\n refs:Record<string, Element | Element[]>,\n contexts:Record<string, unknown>,\n cleanups:(() => void)[]\n):SetupContext<Props, any, any> {\n return {\n host,\n props,\n refs,\n contexts,\n\n peek,\n\n on (target, type, handler, options?) {\n target.addEventListener(\n type as string,\n handler as EventListener,\n options\n )\n cleanups.push(() => {\n target.removeEventListener(\n type as string,\n handler as EventListener,\n options\n )\n })\n },\n\n emit (\n nameOrEvent:Event | string,\n detail?:unknown,\n options?:Omit<CustomEventInit, 'detail'>\n ):boolean {\n const event = nameOrEvent instanceof Event ?\n nameOrEvent :\n new CustomEvent(nameOrEvent, {\n bubbles: true,\n ...options,\n detail,\n })\n return host.dispatchEvent(event)\n },\n\n effect (fn) {\n const dispose = effect(fn)\n cleanups.push(dispose)\n },\n\n bind<T> (\n source:Signal<T>,\n control:Element,\n opts?:BindOptions\n ) {\n const input = control instanceof HTMLInputElement ?\n control :\n undefined\n let prop = 'value'\n let autoEvent = 'change'\n if (input?.type === 'checkbox') {\n prop = 'checked'\n } else if (input?.type === 'number' ||\n input?.type === 'range') {\n prop = 'valueAsNumber'\n autoEvent = 'input'\n } else if (input || control instanceof HTMLTextAreaElement) {\n autoEvent = 'input'\n }\n\n const boundProp = opts?.prop ?? prop\n const event = opts ? opts.event : autoEvent\n const el = control as unknown as Record<string, unknown>\n\n if (event) {\n const handler = () => {\n const writable = source as Signal<unknown>\n writable(el[boundProp])\n }\n control.addEventListener(event, handler)\n cleanups.push(() => {\n control.removeEventListener(event, handler)\n })\n }\n\n const dispose = effect(() => {\n el[boundProp] = source()\n })\n cleanups.push(dispose)\n },\n\n onCleanup (fn) {\n cleanups.push(fn)\n },\n\n consume<T> (token:ContextToken<T>):T | undefined {\n const sig = resolveContextSignal(host, token)\n return sig ? sig() : undefined\n },\n }\n}\n", "import { signal } from './reactivity.js'\nimport { runAll } from './util.js'\nimport { makeSetupContext } from './setup-context.js'\nimport {\n resolveContextSignal,\n onContextAvailable,\n} from './context.js'\nimport type {\n PropsSignals,\n Signal,\n SetupContext,\n Coercer,\n ContextToken,\n RefDef,\n} from './types.js'\n\n/**\n * Map of prop name to coercer function.\n * The factory accepts coercers exclusively; Standard Schema support is\n * layered on top in the withProps builder (US-005).\n */\nexport type FactoryProps = Record<string, Coercer<unknown>>\n\n/**\n * The class to extend for custom elements. In the browser this is the\n * real HTMLElement; in Node (e.g. reading `.TAG` for SSR) it falls back\n * to an empty stub so the class can be defined without a DOM. The stub\n * is never instantiated or registered outside the browser.\n */\nconst HTMLElementBase = typeof HTMLElement !== 'undefined' ?\n HTMLElement :\n (class {} as unknown as typeof HTMLElement)\n\n/** Configuration passed to factory(). */\nexport interface FactoryConfig<Props extends FactoryProps = FactoryProps> {\n /** Coercer for each observed attribute / prop. */\n props:Props\n /** Attribute names to pass to observedAttributes. */\n observedAttrNames:string[]\n /** Ref definitions keyed by name. */\n refs?:Record<string, RefDef>\n /** Context tokens keyed by name. */\n contexts?:Record<string, ContextToken<unknown>>\n /** Setup callback receiving the component context. */\n setup:(ctx:SetupContext<Props, any, any>) => void\n}\n\n/**\n * Collect resolved DOM refs from within a host element.\n * Throws if any single-ref element is missing.\n */\nfunction collectRefs (\n host:HTMLElement,\n defs:Record<string, RefDef>\n):Record<string, Element|Element[]> {\n const result:Record<string, Element|Element[]> = {}\n const missing:string[] = []\n for (const [key, def] of Object.entries(defs)) {\n const sel = def.selector ?? `[data-ref=\"${key}\"]`\n if (def._microtag === 'ref:all') {\n result[key] = Array.from(host.querySelectorAll(sel))\n } else {\n const el = host.querySelector(sel)\n if (!el) {\n missing.push(key)\n } else {\n result[key] = el\n }\n }\n }\n if (missing.length > 0) {\n throw new Error(\n `${host.tagName}: missing refs: ${missing.join(', ')}`\n )\n }\n return result\n}\n\n/**\n * Create an HTMLElement subclass with the microtags lifecycle.\n * The returned class has no Shadow DOM, tracks its own prop signals,\n * and runs setup() on connect / cleanups on disconnect.\n */\nexport function factory<Props extends FactoryProps = FactoryProps> (\n config:FactoryConfig<Props>\n):typeof HTMLElement {\n const {\n props: propDefs,\n observedAttrNames,\n setup,\n refs: refDefs = {},\n contexts: ctxDefs = {},\n } = config\n\n class MicrotagElement extends HTMLElementBase {\n static get observedAttributes () { return observedAttrNames }\n\n _props:Record<string, Signal<unknown>> = {}\n _cleanups:(() => void)[] = []\n\n constructor () {\n super()\n for (const [name, coercer] of Object.entries(propDefs)) {\n this._props[name] = signal(coercer(null))\n }\n }\n\n connectedCallback () {\n // Start a fresh cleanup scope for each connection cycle.\n this._cleanups = []\n\n // Hydrate prop signals from attributes; preserve any\n // programmatically-set value when the attribute is absent.\n for (const [name, coercer] of Object.entries(propDefs)) {\n const attrVal = this.getAttribute(name)\n if (attrVal !== null) {\n (this._props[name] as Signal<unknown>)(coercer(attrVal))\n }\n }\n\n const cleanups = this._cleanups\n const props = this._props as PropsSignals<Props>\n\n // Reactive Proxy: reading a key inside a ctx.effect creates\n // a subscription to the provider's alien-signals signal.\n const contexts = new Proxy({} as Record<string, unknown>, {\n get: (_target, key) => {\n if (typeof key !== 'string') return undefined\n const token = ctxDefs[key]\n if (!token) return undefined\n const sig = resolveContextSignal(this, token)\n return sig ? sig() : undefined\n },\n has: (_target, key) => {\n if (typeof key !== 'string') return false\n return key in ctxDefs\n },\n })\n\n let setupRan = false\n // Tracks pending-context cancel functions so they are\n // removed from the global registry when setup runs or\n // when the element disconnects.\n const cancelCallbacks:(() => void)[] = []\n\n const tryRunSetup = ():void => {\n if (setupRan) return\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) return\n }\n setupRan = true\n for (const cancel of cancelCallbacks) cancel()\n cancelCallbacks.length = 0\n\n const refs = collectRefs(this, refDefs)\n const ctx = makeSetupContext(\n this, props, refs, contexts, cleanups\n )\n setup(ctx)\n }\n\n // Deferred variant: skip if element was disconnected before\n // the context became available.\n const tryRunSetupIfConnected = ():void => {\n if (!this.isConnected) return\n tryRunSetup()\n }\n\n // Register pending listeners for any missing contexts.\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) {\n const cancel = onContextAvailable(\n token.id, tryRunSetupIfConnected\n )\n cancelCallbacks.push(cancel)\n // Also cancel on disconnect so we don't leak.\n cleanups.push(cancel)\n }\n }\n\n tryRunSetup()\n }\n\n attributeChangedCallback (\n name:string,\n _old:string|null,\n next:string|null\n ) {\n const coercer = propDefs[name]\n if (coercer !== undefined && this._props[name] !== undefined) {\n (this._props[name] as Signal<unknown>)(coercer(next))\n }\n }\n\n disconnectedCallback () {\n // Snapshot and clear BEFORE running so re-entrant calls are safe\n // and the array is always empty after this returns (or throws).\n const fns = this._cleanups\n this._cleanups = []\n runAll(fns)\n }\n }\n\n return MicrotagElement\n}\n", "import type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type {\n PropDef,\n PropertyOnlyProp,\n SetupContext,\n Coercer,\n RefDef,\n SingleRefDef,\n MultipleRefDef,\n RefsMap,\n ContextToken,\n ContextsMap,\n} from './types.js'\nimport {\n coerceNumber,\n coerceString,\n coerceBoolean,\n coerceJson,\n} from './util.js'\nimport { factory } from './factory.js'\n\n/** The DSL object passed to the withProps callback. */\nexport type PropDSL = {\n number():Coercer<number>\n string():Coercer<string>\n boolean():Coercer<boolean>\n json<T>():Coercer<T | undefined>\n schema<T>(validator:StandardSchemaV1<unknown, T>):StandardSchemaV1<unknown, T>\n prop<T>(initial:T):PropertyOnlyProp<T>\n}\n\nexport const propDSL:PropDSL = {\n number: () => coerceNumber,\n string: () => coerceString,\n boolean: () => coerceBoolean,\n json: <T>() => coerceJson as Coercer<T | undefined>,\n schema: <T>(v:StandardSchemaV1<unknown, T>) => v,\n prop: <T>(initial:T):PropertyOnlyProp<T> => (\n { _microtag: 'prop', initial }\n ),\n}\n\n/**\n * DSL object passed to the withRefs callback.\n * Call `r.one()` for a single element or `r.all()` for multiple. Pass a\n * CSS selector to query by it, or omit it to match `[data-ref=\"<key>\"]`.\n *\n * Element typing:\n * - `r.one()` defaults to `HTMLElement`.\n * - `r.one<T>()` sets the type and keeps the `[data-ref]` selector.\n * - `r.one('button')` infers the type from the tag AND queries by that\n * tag, exactly like `document.querySelector('button')`.\n */\nexport type RefsDSL = {\n one<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):SingleRefDef<HTMLElementTagNameMap[K]>\n one<T extends HTMLElement = HTMLElement>(selector?:string):SingleRefDef<T>\n\n all<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):MultipleRefDef<HTMLElementTagNameMap[K]>\n all<T extends HTMLElement = HTMLElement>(selector?:string):MultipleRefDef<T>\n}\n\nexport const refsDSL:RefsDSL = {\n one: ((selector?:string):SingleRefDef => (\n { _microtag: 'ref:one', selector }\n )) as RefsDSL['one'],\n all: ((selector?:string):MultipleRefDef => (\n { _microtag: 'ref:all', selector }\n )) as RefsDSL['all'],\n}\n\n/**\n * DSL object passed to the withContexts callback.\n * Currently a no-op placeholder; the user references imported\n * context tokens directly in the returned record.\n */\nexport type ContextDSL = Record<never, never>\nconst contextDSL:ContextDSL = {}\n\n/**\n * Maps each declared ref key to its own name as a string literal. Exposed\n * as the static `refs` on a registered element so server-rendered templates\n * can fill in `data-ref` values without hardcoding the names, e.g.\n * `data-ref=\"${MyCounter.refs.dec}\"`.\n */\nexport type RefNames<RefDefs extends Record<string, RefDef>> = {\n readonly [K in keyof RefDefs]:K & string\n}\n\n/**\n * A registered custom element class that also exposes, as static members,\n * the tag name it was registered under (`TAG`) and the names of its\n * declared refs (`refs`).\n */\nexport type MicrotagElementClass<\n RefDefs extends Record<string, RefDef> = Record<never, never>\n> = typeof HTMLElement & {\n /** The custom element tag name, e.g. 'my-counter'. */\n readonly TAG:string\n /**\n * The declared ref names, each mapping to its own `data-ref` string.\n * Lets server-rendered markup reference refs by key instead of a magic\n * string: `MyCounter.refs.dec`.\n */\n readonly refs:RefNames<RefDefs>\n}\n\n/**\n * Fluent builder that accumulates props/refs/contexts config\n * before registering a custom element via `.setup()`.\n */\nexport class ComponentBuilder<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n CtxDefs extends Record<string, ContextToken<unknown>> =\n Record<never, never>,\n> {\n private readonly _coercers:Record<string, Coercer<unknown>>\n private readonly _observed:string[]\n private readonly _refDefs:Record<string, RefDef>\n private readonly _ctxDefs:Record<string, ContextToken<unknown>>\n\n constructor (\n readonly tagName:string,\n coercers:Record<string, Coercer<unknown>> = {},\n observed:string[] = [],\n refDefs:Record<string, RefDef> = {},\n ctxDefs:Record<string, ContextToken<unknown>> = {}\n ) {\n this._coercers = coercers\n this._observed = observed\n this._refDefs = refDefs\n this._ctxDefs = ctxDefs\n }\n\n /**\n * The custom element tag name, e.g. 'my-counter'. Available at every\n * point in the fluent chain since each builder method returns a new\n * builder carrying the same tag name.\n */\n get TAG ():string {\n return this.tagName\n }\n\n withProps<P extends Record<string, PropDef>> (\n fn:(p:PropDSL) => P\n ):ComponentBuilder<P, RefDefs, CtxDefs> {\n const defs = fn(propDSL)\n const coercers:Record<string, Coercer<unknown>> = {}\n const observed:string[] = []\n\n for (const [name, def] of Object.entries(defs)) {\n coercers[name] = normalizePropDef(name, def as PropDef<unknown>)\n if (!isPropOnly(def)) {\n observed.push(name)\n }\n }\n\n return new ComponentBuilder<P, RefDefs, CtxDefs>(\n this.tagName,\n coercers,\n observed,\n this._refDefs,\n this._ctxDefs\n )\n }\n\n withRefs<R extends Record<string, RefDef>> (\n fn:(r:RefsDSL) => R\n ):ComponentBuilder<Props, R, CtxDefs> {\n const defs = fn(refsDSL)\n return new ComponentBuilder<Props, R, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n defs,\n this._ctxDefs\n )\n }\n\n withContexts<C extends Record<string, ContextToken<unknown>>> (\n fn:(c:ContextDSL) => C\n ):ComponentBuilder<Props, RefDefs, C> {\n const defs = fn(contextDSL)\n return new ComponentBuilder<Props, RefDefs, C>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n defs\n )\n }\n\n setup (\n fn:(ctx:SetupContext<\n Props,\n RefsMap<RefDefs>,\n ContextsMap<CtxDefs>\n >) => void\n ):MicrotagElementClass<RefDefs> {\n const El = factory({\n props: this._coercers,\n observedAttrNames: this._observed,\n refs: this._refDefs,\n contexts: this._ctxDefs,\n setup: fn as any,\n })\n Object.defineProperty(El, 'TAG', {\n value: this.tagName,\n enumerable: true,\n })\n\n // Expose each ref key as its own `data-ref` name so server-rendered\n // markup can reference refs by key instead of a hardcoded string.\n const refNames:Record<string, string> = {}\n for (const key of Object.keys(this._refDefs)) {\n refNames[key] = key\n }\n Object.defineProperty(El, 'refs', {\n value: Object.freeze(refNames),\n enumerable: true,\n })\n\n if (typeof customElements !== 'undefined') {\n customElements.define(this.tagName, El)\n }\n return El as MicrotagElementClass<RefDefs>\n }\n}\n\n/** Create a new component builder for the given tag name. */\nexport function define (tagName:string):ComponentBuilder {\n return new ComponentBuilder(tagName)\n}\n\nfunction isPropOnly (def:unknown):def is PropertyOnlyProp<unknown> {\n return (\n typeof def === 'object' &&\n def !== null &&\n '_microtag' in def &&\n (def as { _microtag: unknown })._microtag === 'prop'\n )\n}\n\nfunction isStandardSchema (def:unknown):def is StandardSchemaV1 {\n return (\n typeof def === 'object' &&\n def !== null &&\n '~standard' in def\n )\n}\n\nfunction normalizePropDef (\n name:string,\n def:PropDef<unknown>\n):Coercer<unknown> {\n if (isPropOnly(def)) {\n return (_raw:string | null) => def.initial\n }\n if (isStandardSchema(def)) {\n const schema = def as StandardSchemaV1\n return (raw:string | null):unknown => {\n const result = schema['~standard'].validate(raw)\n if (result instanceof Promise) {\n throw new TypeError(\n `withProps: async schemas are not supported (prop \"${name}\")`\n )\n }\n if (result.issues) return undefined\n return result.value\n }\n }\n return def as Coercer<unknown>\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { effect, peek } from './reactivity.js'\nimport { resolveContextSignal } from './context.js'\nimport type {\n SetupContext,\n Signal,\n PropsSignals,\n PropDef,\n ContextToken,\n BindOptions,\n} from './types.js'\n\n/**\n * Build the ctx object passed to a component's setup() callback.\n * The cleanups array is mutated in place so factory.ts can drain it\n * on disconnect without copying.\n */\nexport function makeSetupContext<\n Props extends Record<string, PropDef> = Record<string, PropDef>,\n> (\n host:HTMLElement,\n props:PropsSignals<Props>,\n refs:Record<string, Element | Element[]>,\n contexts:Record<string, unknown>,\n cleanups:(() => void)[]\n):SetupContext<Props, any, any> {\n return {\n host,\n props,\n refs,\n contexts,\n\n peek,\n\n on (target, type, handler, options?) {\n target.addEventListener(\n type as string,\n handler as EventListener,\n options\n )\n cleanups.push(() => {\n target.removeEventListener(\n type as string,\n handler as EventListener,\n options\n )\n })\n },\n\n emit (\n nameOrEvent:Event | string,\n detail?:unknown,\n options?:Omit<CustomEventInit, 'detail'>\n ):boolean {\n const event = nameOrEvent instanceof Event ?\n nameOrEvent :\n new CustomEvent(nameOrEvent, {\n bubbles: true,\n ...options,\n detail,\n })\n return host.dispatchEvent(event)\n },\n\n effect (fn) {\n const dispose = effect(fn)\n cleanups.push(dispose)\n },\n\n bind<T> (\n source:Signal<T>,\n control:Element,\n opts?:BindOptions\n ) {\n const input = control instanceof HTMLInputElement ?\n control :\n undefined\n let prop = 'value'\n let autoEvent = 'change'\n if (input?.type === 'checkbox') {\n prop = 'checked'\n } else if (input?.type === 'number' ||\n input?.type === 'range') {\n prop = 'valueAsNumber'\n autoEvent = 'input'\n } else if (input || control instanceof HTMLTextAreaElement) {\n autoEvent = 'input'\n }\n\n const boundProp = opts?.prop ?? prop\n const event = opts ? opts.event : autoEvent\n const el = control as unknown as Record<string, unknown>\n\n if (event) {\n const handler = () => {\n const writable = source as Signal<unknown>\n writable(el[boundProp])\n }\n control.addEventListener(event, handler)\n cleanups.push(() => {\n control.removeEventListener(event, handler)\n })\n }\n\n const dispose = effect(() => {\n el[boundProp] = source()\n })\n cleanups.push(dispose)\n },\n\n onCleanup (fn) {\n cleanups.push(fn)\n },\n\n consume<T> (token:ContextToken<T>):T | undefined {\n const sig = resolveContextSignal(host, token)\n return sig ? sig() : undefined\n },\n }\n}\n", "import { signal } from './reactivity.js'\nimport { runAll } from './util.js'\nimport { makeSetupContext } from './setup-context.js'\nimport {\n resolveContextSignal,\n onContextAvailable,\n} from './context.js'\nimport type {\n PropsSignals,\n Signal,\n SetupContext,\n Coercer,\n ContextToken,\n RefDef,\n} from './types.js'\n\n/**\n * Map of prop name to coercer function.\n * The factory accepts coercers exclusively; Standard Schema support is\n * layered on top in the withProps builder (US-005).\n */\nexport type FactoryProps = Record<string, Coercer<unknown>>\n\n/**\n * The class to extend for custom elements. In the browser this is the\n * real HTMLElement; in Node (e.g. reading `.TAG` for SSR) it falls back\n * to an empty stub so the class can be defined without a DOM. The stub\n * is never instantiated or registered outside the browser.\n */\nconst HTMLElementBase = typeof HTMLElement !== 'undefined' ?\n HTMLElement :\n (class {} as unknown as typeof HTMLElement)\n\n/** Configuration passed to factory(). */\nexport interface FactoryConfig<Props extends FactoryProps = FactoryProps> {\n /** Coercer for each observed attribute / prop. */\n props:Props\n /** Attribute names to pass to observedAttributes. */\n observedAttrNames:string[]\n /** Ref definitions keyed by name. */\n refs?:Record<string, RefDef>\n /** Context tokens keyed by name. */\n contexts?:Record<string, ContextToken<unknown>>\n /** Setup callback receiving the component context. */\n setup:(ctx:SetupContext<Props, any, any>) => void\n}\n\n/**\n * Collect resolved DOM refs from within a host element.\n * Throws if any single-ref element is missing.\n */\nfunction collectRefs (\n host:HTMLElement,\n defs:Record<string, RefDef>\n):Record<string, Element|Element[]> {\n const result:Record<string, Element|Element[]> = {}\n const missing:string[] = []\n for (const [key, def] of Object.entries(defs)) {\n const sel = def.selector ?? `[data-ref=\"${key}\"]`\n if (def._microtag === 'ref:all') {\n result[key] = Array.from(host.querySelectorAll(sel))\n } else {\n const el = host.querySelector(sel)\n if (!el) {\n missing.push(key)\n } else {\n result[key] = el\n }\n }\n }\n if (missing.length > 0) {\n throw new Error(\n `${host.tagName}: missing refs: ${missing.join(', ')}`\n )\n }\n return result\n}\n\n/**\n * Create an HTMLElement subclass with the microtags lifecycle.\n * The returned class has no Shadow DOM, tracks its own prop signals,\n * and runs setup() on connect / cleanups a microtask after disconnect.\n */\nexport function factory<Props extends FactoryProps = FactoryProps> (\n config:FactoryConfig<Props>\n):typeof HTMLElement {\n const {\n props: propDefs,\n observedAttrNames,\n setup,\n refs: refDefs = {},\n contexts: ctxDefs = {},\n } = config\n\n class MicrotagElement extends HTMLElementBase {\n static get observedAttributes () { return observedAttrNames }\n\n _props:Record<string, Signal<unknown>> = {}\n // Per prop: the external signal assigned to the accessor, if any.\n _bound:Record<string, Signal<Signal<unknown>|undefined>> = {}\n _cleanups:(() => void)[] = []\n // Connected and set up, not yet torn down.\n _live = false\n\n constructor () {\n super()\n for (const [name, coercer] of Object.entries(propDefs)) {\n const own = signal(coercer(null))\n const bound = signal<Signal<unknown>|undefined>(undefined)\n this._bound[name] = bound\n // Reads go through the bound signal when one is set,\n // so setup's prop signal tracks it. A bound prop is\n // owned by the parent, so writing it here throws.\n this._props[name] = ((...args:unknown[]) => {\n const ext = bound()\n if (!args.length) return ext ? ext() : own()\n if (ext) {\n throw new Error(`${this.localName}: prop \"${name}\"` +\n ' is bound and read-only; emit an event instead')\n }\n own(args[0])\n }) as Signal<unknown>\n // Pick up a property set before the upgrade; it\n // shadows the prototype accessor until removed.\n if (Object.prototype.hasOwnProperty.call(this, name)) {\n const pre = (this as any)[name]\n delete (this as any)[name]\n ;(this as any)[name] = pre\n }\n }\n }\n\n connectedCallback () {\n // Back before the queued teardown ran: this was a move.\n if (this._live) return\n this._live = true\n // Start a fresh cleanup scope for each connection cycle.\n this._cleanups = []\n\n // Hydrate prop signals from attributes; preserve any\n // programmatically-set value when the attribute is absent.\n for (const [name, coercer] of Object.entries(propDefs)) {\n const attrVal = this.getAttribute(name)\n if (attrVal !== null && !this._bound[name]()) {\n (this._props[name] as Signal<unknown>)(coercer(attrVal))\n }\n }\n\n const cleanups = this._cleanups\n const props = this._props as PropsSignals<Props>\n\n // Reactive Proxy: reading a key inside a ctx.effect creates\n // a subscription to the provider's alien-signals signal.\n const contexts = new Proxy({} as Record<string, unknown>, {\n get: (_target, key) => {\n if (typeof key !== 'string') return undefined\n const token = ctxDefs[key]\n if (!token) return undefined\n const sig = resolveContextSignal(this, token)\n return sig ? sig() : undefined\n },\n has: (_target, key) => {\n if (typeof key !== 'string') return false\n return key in ctxDefs\n },\n })\n\n let setupRan = false\n // Tracks pending-context cancel functions so they are\n // removed from the global registry when setup runs or\n // when the element disconnects.\n const cancelCallbacks:(() => void)[] = []\n\n const tryRunSetup = ():void => {\n if (setupRan) return\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) return\n }\n setupRan = true\n for (const cancel of cancelCallbacks) cancel()\n cancelCallbacks.length = 0\n\n const refs = collectRefs(this, refDefs)\n const ctx = makeSetupContext(\n this, props, refs, contexts, cleanups\n )\n setup(ctx)\n }\n\n // Deferred variant: skip if element was disconnected before\n // the context became available.\n const tryRunSetupIfConnected = ():void => {\n if (!this.isConnected) return\n tryRunSetup()\n }\n\n // Register pending listeners for any missing contexts.\n for (const token of Object.values(ctxDefs)) {\n if (!resolveContextSignal(this, token)) {\n const cancel = onContextAvailable(\n token.id, tryRunSetupIfConnected\n )\n cancelCallbacks.push(cancel)\n // Also cancel on disconnect so we don't leak.\n cleanups.push(cancel)\n }\n }\n\n tryRunSetup()\n }\n\n attributeChangedCallback (\n name:string,\n _old:string|null,\n next:string|null\n ) {\n const coercer = propDefs[name]\n if (\n coercer !== undefined &&\n this._props[name] !== undefined &&\n !this._bound[name]()\n ) {\n (this._props[name] as Signal<unknown>)(coercer(next))\n }\n }\n\n // A DOM move (`moveBefore`) keeps the host set up\n connectedMoveCallback () {}\n\n // Teardown waits a microtask, so a host removed and re-inserted\n // in the same tick (`insertBefore` without `moveBefore`) keeps\n // its setup.\n disconnectedCallback () {\n queueMicrotask(() => {\n if (this.isConnected || !this._live) return\n this._live = false\n // Snapshot and clear BEFORE running so re-entrant calls\n // are safe and the array is empty after this throws.\n const fns = this._cleanups\n this._cleanups = []\n runAll(fns)\n })\n }\n }\n\n // One accessor per prop. A function value is taken to be a signal\n // and bound; anything else unbinds and writes the prop.\n for (const name of Object.keys(propDefs)) {\n Object.defineProperty(MicrotagElement.prototype, name, {\n get (this:MicrotagElement) { return this._props[name]() },\n set (this:MicrotagElement, v:unknown) {\n if (typeof v === 'function') {\n this._bound[name](v as Signal<unknown>)\n } else {\n this._bound[name](undefined)\n this._props[name](v)\n }\n },\n configurable: true,\n })\n }\n\n return MicrotagElement\n}\n\n/**\n * Bind a signal (or computed) to a declared prop of a host, so the prop\n * reads through to it. Same as assigning the signal to the accessor,\n * but typed: the signal's value must match the prop's type.\n */\nexport const bindProp = <\n H extends HTMLElement,\n K extends Exclude<keyof H, keyof HTMLElement>,\n> (host:H, name:K, source:() => H[K]):void => {\n (host as any)[name] = source\n}\n", "import type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type { Markup } from './htm.js'\nimport type { Markup as BrowserMarkup } from './htm.browser.js'\nimport type {\n PropDef,\n PropType,\n PropertyOnlyProp,\n SetupContext,\n Coercer,\n RefDef,\n SingleRefDef,\n MultipleRefDef,\n RefsMap,\n ContextToken,\n ContextsMap,\n} from './types.js'\nimport {\n coerceNumber,\n coerceString,\n coerceBoolean,\n coerceJson,\n} from './util.js'\nimport { factory } from './factory.js'\n// The serializer kind is decided here, by coercer identity, so the\n// server render support module never compares coercers from another\n// copy of the package.\nexport type PropKind =\n 'prop-only' | 'schema' | 'boolean' | 'json' | 'coercer'\n\nexport interface PropMeta {\n kind:PropKind\n coercer:Coercer<unknown>\n}\n\n/**\n * What a `render` static hands the server render support module: tag,\n * prop metadata, ref names and the render function. This shape is a\n * contract between package copies; changing it needs a new symbol key.\n */\nexport interface RenderRecord {\n t:string\n m:Record<string, PropMeta>\n r:Record<string, string>\n f:RenderFn<any, any>\n}\n\n/** The DSL object passed to the withProps callback. */\nexport type PropDSL = {\n number():Coercer<number>\n string():Coercer<string>\n boolean():Coercer<boolean>\n json<T>():Coercer<T | undefined>\n schema<T>(validator:StandardSchemaV1<unknown, T>):StandardSchemaV1<unknown, T>\n prop<T>(initial:T):PropertyOnlyProp<T>\n}\n\nexport const propDSL:PropDSL = {\n number: () => coerceNumber,\n string: () => coerceString,\n boolean: () => coerceBoolean,\n json: <T>() => coerceJson as Coercer<T | undefined>,\n schema: <T>(v:StandardSchemaV1<unknown, T>) => v,\n prop: <T>(initial:T):PropertyOnlyProp<T> => (\n { _microtag: 'prop', initial }\n ),\n}\n\n/**\n * DSL object passed to the withRefs callback.\n * Call `r.one()` for a single element or `r.all()` for multiple. Pass a\n * CSS selector to query by it, or omit it to match `[data-ref=\"<key>\"]`.\n *\n * Element typing:\n * - `r.one()` defaults to `HTMLElement`.\n * - `r.one<T>()` sets the type and keeps the `[data-ref]` selector.\n * - `r.one('button')` infers the type from the tag AND queries by that\n * tag, exactly like `document.querySelector('button')`.\n */\nexport type RefsDSL = {\n one<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):SingleRefDef<HTMLElementTagNameMap[K]>\n one<T extends HTMLElement = HTMLElement>(selector?:string):SingleRefDef<T>\n\n all<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):MultipleRefDef<HTMLElementTagNameMap[K]>\n all<T extends HTMLElement = HTMLElement>(selector?:string):MultipleRefDef<T>\n}\n\nexport const refsDSL:RefsDSL = {\n one: ((selector?:string):SingleRefDef => (\n { _microtag: 'ref:one', selector }\n )) as RefsDSL['one'],\n all: ((selector?:string):MultipleRefDef => (\n { _microtag: 'ref:all', selector }\n )) as RefsDSL['all'],\n}\n\n/**\n * DSL object passed to the withContexts callback.\n * Currently a no-op placeholder; the user references imported\n * context tokens directly in the returned record.\n */\nexport type ContextDSL = Record<never, never>\nconst contextDSL:ContextDSL = {}\n\n/**\n * Maps each declared ref key to its own name as a string literal. Exposed\n * as the static `refs` on a registered element so server-rendered templates\n * can fill in `data-ref` values without hardcoding the names, e.g.\n * `data-ref=\"${MyCounter.refs.dec}\"`.\n */\nexport type RefNames<RefDefs extends Record<string, RefDef>> = {\n readonly [K in keyof RefDefs]:K & string\n}\n\n/** Plain values for props (not signals) in the render context. */\nexport type RenderProps<Defs extends Record<string, PropDef>> = {\n [K in keyof Defs]:PropType<Defs[K]>\n}\n\nexport interface RenderContext<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> {\n props:RenderProps<Props>\n refs:RefNames<RefDefs>\n TAG:string\n children:string\n attrs:Record<string, string>\n}\n\nexport type RenderFn<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> = (\n ctx:RenderContext<Props, RefDefs>\n) => string | Markup | BrowserMarkup\n\nexport interface RenderOptions {\n client?:boolean\n}\n\nexport type StaticRenderFn<\n Props extends Record<string, PropDef>,\n> = (\n props:RenderProps<Props>,\n options?:{ children?:string; attrs?:Record<string, string> }\n) => string\n\n/**\n * A component's server render as parts: the host tag name, its\n * serialized host attributes (declared props first, then extra attrs,\n * unescaped; a true boolean is the empty string) and the inner HTML.\n */\nexport interface RenderParts {\n tag:string\n attrs:Record<string, string>\n html:string\n}\n\nexport type StaticRenderPartsFn<\n Props extends Record<string, PropDef>,\n> = (\n props:RenderProps<Props>,\n options?:{ children?:string; attrs?:Record<string, string> }\n) => RenderParts\n\n/**\n * A host element: an `HTMLElement` with a property accessor for each\n * declared prop, typed as the prop's value. A signal bound with\n * `bindProp` makes the prop read through to it.\n */\nexport type MicrotagHost<\n Props extends Record<string, PropDef> = Record<never, never>,\n> = HTMLElement & RenderProps<Props>\n\n/**\n * A registered custom element class that also exposes, as static members,\n * the tag name it was registered under (`TAG`) and the names of its\n * declared refs (`refs`).\n */\nexport type MicrotagElementClass<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n> = {\n new ():MicrotagHost<Props>\n readonly prototype:MicrotagHost<Props>\n /** The custom element tag name, e.g. 'my-counter'. */\n readonly TAG:string\n /**\n * The declared ref names, each mapping to its own `data-ref` string.\n * Lets server-rendered markup reference refs by key instead of a magic\n * string: `MyCounter.refs.dec`.\n */\n readonly refs:RefNames<RefDefs>\n readonly render:StaticRenderFn<Props>\n readonly renderParts:StaticRenderPartsFn<Props>\n readonly props:readonly (keyof Props & string)[]\n}\n\n/**\n * Fluent builder that accumulates props/refs/contexts config\n * before registering a custom element via `.setup()`.\n */\nexport class ComponentBuilder<\n Props extends Record<string, PropDef> = Record<never, never>,\n RefDefs extends Record<string, RefDef> = Record<never, never>,\n CtxDefs extends Record<string, ContextToken<unknown>> = Record<never, never>,\n> {\n private readonly _coercers:Record<string, Coercer<unknown>>\n private readonly _observed:string[]\n private readonly _propNames:string[]\n private readonly _propMetas:Record<string, PropMeta>\n private readonly _refDefs:Record<string, RefDef>\n private readonly _ctxDefs:Record<string, ContextToken<unknown>>\n private readonly _renderFn?:RenderFn<Props, RefDefs>\n\n constructor (\n readonly tagName:string,\n coercers:Record<string, Coercer<unknown>> = {},\n observed:string[] = [],\n refDefs:Record<string, RefDef> = {},\n ctxDefs:Record<string, ContextToken<unknown>> = {},\n propNames:string[] = [],\n propMetas:Record<string, PropMeta> = {},\n renderFn?:RenderFn<any, any>,\n ) {\n this._coercers = coercers\n this._observed = observed\n this._propNames = propNames\n this._propMetas = propMetas\n this._refDefs = refDefs\n this._ctxDefs = ctxDefs\n this._renderFn = renderFn as\n RenderFn<Props, RefDefs> | undefined\n }\n\n /**\n * The custom element tag name, e.g. 'my-counter'. Available at every\n * point in the fluent chain since each builder method returns a new\n * builder carrying the same tag name.\n */\n get TAG ():string {\n return this.tagName\n }\n\n withProps<P extends Record<string, PropDef>> (\n fn:(p:PropDSL) => P\n ):ComponentBuilder<P, RefDefs, CtxDefs> {\n const defs = fn(propDSL)\n const coercers:Record<string, Coercer<unknown>> = {}\n const observed:string[] = []\n const propNames:string[] = []\n const propMetas:Record<string, PropMeta> = {}\n\n for (const [name, def] of Object.entries(defs)) {\n const coercer = normalizePropDef(\n name,\n def as PropDef<unknown>\n )\n coercers[name] = coercer\n propNames.push(name)\n\n const kind = isPropOnly(def) ?\n 'prop-only' as const :\n isStandardSchema(def) ?\n 'schema' as const :\n coercer === coerceBoolean ?\n 'boolean' as const :\n coercer === coerceJson ?\n 'json' as const :\n 'coercer' as const\n\n propMetas[name] = { kind, coercer }\n\n if (!isPropOnly(def)) {\n observed.push(name)\n }\n }\n\n return new ComponentBuilder<P, RefDefs, CtxDefs>(\n this.tagName,\n coercers,\n observed,\n this._refDefs,\n this._ctxDefs,\n propNames,\n propMetas,\n )\n }\n\n withRefs<R extends Record<string, RefDef>> (\n fn:(r:RefsDSL) => R\n ):ComponentBuilder<Props, R, CtxDefs> {\n const defs = fn(refsDSL)\n return new ComponentBuilder<Props, R, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n defs,\n this._ctxDefs,\n this._propNames,\n this._propMetas,\n this._renderFn,\n )\n }\n\n withContexts<C extends Record<string, ContextToken<unknown>>> (\n fn:(c:ContextDSL) => C\n ):ComponentBuilder<Props, RefDefs, C> {\n const defs = fn(contextDSL)\n return new ComponentBuilder<Props, RefDefs, C>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n defs,\n this._propNames,\n this._propMetas,\n this._renderFn,\n )\n }\n\n render (\n fn:RenderFn<Props, RefDefs>,\n _options?:RenderOptions\n ):ComponentBuilder<Props, RefDefs, CtxDefs> {\n return new ComponentBuilder<Props, RefDefs, CtxDefs>(\n this.tagName,\n this._coercers,\n this._observed,\n this._refDefs,\n this._ctxDefs,\n this._propNames,\n this._propMetas,\n fn,\n )\n }\n\n setup (\n fn:(ctx:SetupContext<\n Props,\n RefsMap<RefDefs>,\n ContextsMap<CtxDefs>\n >) => void\n ):MicrotagElementClass<Props, RefDefs> {\n const El = factory({\n props: this._coercers,\n observedAttrNames: this._observed,\n refs: this._refDefs,\n contexts: this._ctxDefs,\n setup: fn as any,\n })\n Object.defineProperty(El, 'TAG', {\n value: this.tagName,\n enumerable: true,\n })\n\n const refNames:Record<string, string> = {}\n for (const key of Object.keys(this._refDefs)) {\n refNames[key] = key\n }\n Object.defineProperty(El, 'refs', {\n value: Object.freeze(refNames),\n enumerable: true,\n })\n\n Object.defineProperty(El, 'props', {\n value: Object.freeze([...this._propNames]),\n enumerable: true,\n })\n\n if (this._renderFn) {\n const rec:RenderRecord = {\n t: this.tagName,\n m: this._propMetas,\n r: Object.freeze({ ...refNames }),\n f: this._renderFn,\n }\n // One helper per registry key, so both statics share the\n // lookup and the error.\n const link = (k:string) => (p:unknown, o:unknown) => {\n const f = (globalThis as any)[Symbol.for('microtags.' + k)]\n if (!f) {\n throw new Error(\n `microtags: ${k} needs \"microtags/render-support\"`\n )\n }\n return f(rec, p, o)\n }\n Object.defineProperties(El, {\n render: { value: link('render'), enumerable: true },\n renderParts: {\n value: link('renderParts'),\n enumerable: true,\n },\n })\n }\n\n if (typeof customElements !== 'undefined') {\n customElements.define(this.tagName, El)\n }\n return El as unknown as MicrotagElementClass<Props, RefDefs>\n }\n}\n\n/** Create a new component builder for the given tag name. */\nexport function define (tagName:string):ComponentBuilder {\n return new ComponentBuilder(tagName)\n}\n\nfunction isPropOnly (def:unknown):def is PropertyOnlyProp<unknown> {\n return (\n typeof def === 'object' &&\n def !== null &&\n '_microtag' in def &&\n (def as { _microtag: unknown })._microtag === 'prop'\n )\n}\n\nfunction isStandardSchema (def:unknown):def is StandardSchemaV1 {\n return (\n typeof def === 'object' &&\n def !== null &&\n '~standard' in def\n )\n}\n\nfunction normalizePropDef (\n name:string,\n def:PropDef<unknown>\n):Coercer<unknown> {\n if (isPropOnly(def)) {\n return (_raw:string | null) => def.initial\n }\n if (isStandardSchema(def)) {\n const schema = def as StandardSchemaV1\n return (raw:string | null):unknown => {\n const result = schema['~standard'].validate(raw)\n if (result instanceof Promise) {\n throw new TypeError(\n `withProps: async schemas are not supported (prop \"${name}\")`\n )\n }\n if (result.issues) return undefined\n return result.value\n }\n }\n return def as Coercer<unknown>\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAgBO,SAAS,iBAGZ,MACA,OACA,MACA,UACA,UAC4B;AAC5B,SAAO;AAAA,IACH;AAAA,IACA;AAAA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