@fictjs/runtime 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/advanced.cjs +79 -0
  2. package/dist/advanced.cjs.map +1 -0
  3. package/dist/advanced.d.cts +50 -0
  4. package/dist/advanced.d.ts +50 -0
  5. package/dist/advanced.js +79 -0
  6. package/dist/advanced.js.map +1 -0
  7. package/dist/chunk-624QY53A.cjs +45 -0
  8. package/dist/chunk-624QY53A.cjs.map +1 -0
  9. package/dist/chunk-F3AIYQB7.js +45 -0
  10. package/dist/chunk-F3AIYQB7.js.map +1 -0
  11. package/dist/chunk-GJTYOFMO.cjs +109 -0
  12. package/dist/chunk-GJTYOFMO.cjs.map +1 -0
  13. package/dist/chunk-IUZXKAAY.js +109 -0
  14. package/dist/chunk-IUZXKAAY.js.map +1 -0
  15. package/dist/chunk-PMF6MWEV.cjs +3301 -0
  16. package/dist/chunk-PMF6MWEV.cjs.map +1 -0
  17. package/dist/chunk-RY4WDS6R.js +3301 -0
  18. package/dist/chunk-RY4WDS6R.js.map +1 -0
  19. package/dist/context-B7UYnfzM.d.ts +153 -0
  20. package/dist/context-UXySaqI_.d.cts +153 -0
  21. package/dist/effect-Auji1rz9.d.cts +350 -0
  22. package/dist/effect-Auji1rz9.d.ts +350 -0
  23. package/dist/index.cjs +98 -3558
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +5 -1358
  26. package/dist/index.d.ts +5 -1358
  27. package/dist/index.dev.js +240 -1698
  28. package/dist/index.dev.js.map +1 -1
  29. package/dist/index.js +63 -3435
  30. package/dist/index.js.map +1 -1
  31. package/dist/internal.cjs +901 -0
  32. package/dist/internal.cjs.map +1 -0
  33. package/dist/internal.d.cts +158 -0
  34. package/dist/internal.d.ts +158 -0
  35. package/dist/internal.js +901 -0
  36. package/dist/internal.js.map +1 -0
  37. package/dist/{jsx-dev-runtime.d.ts → props-CrOMYbLv.d.cts} +107 -18
  38. package/dist/{jsx-dev-runtime.d.cts → props-ES0Ag_Wd.d.ts} +107 -18
  39. package/dist/scope-DKYzWfTn.d.cts +55 -0
  40. package/dist/scope-S6eAzBJZ.d.ts +55 -0
  41. package/package.json +11 -1
  42. package/src/advanced.ts +101 -0
  43. package/src/constants.ts +3 -26
  44. package/src/context.ts +300 -0
  45. package/src/delegated-events.ts +24 -0
  46. package/src/index.ts +41 -112
  47. package/src/internal.ts +130 -0
  48. package/src/props.ts +48 -46
  49. package/src/store.ts +47 -7
  50. package/src/versioned-signal.ts +3 -3
  51. package/dist/jsx-runtime.d.cts +0 -671
  52. package/dist/jsx-runtime.d.ts +0 -671
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/store.ts","../src/reconcile.ts","../src/list-helpers.ts"],"sourcesContent":["import { signal, batch, type SignalAccessor } from './signal'\n\nconst PROXY = Symbol('fict:store-proxy')\nconst TARGET = Symbol('fict:store-target')\nconst ITERATE_KEY = Symbol('fict:iterate')\n\n// ============================================================================\n// Store (Deep Proxy)\n// ============================================================================\n\nexport type Store<T> = T\n\n/**\n * Create a Store: a reactive proxy that allows fine-grained access and mutation.\n *\n * @param initialValue - The initial state object\n * @returns [store, setStore]\n */\nexport function createStore<T extends object>(\n initialValue: T,\n): [Store<T>, (fn: (state: T) => void | T) => void] {\n const unwrapped = unwrap(initialValue)\n const wrapped = wrap(unwrapped)\n\n function setStore(fn: (state: T) => void | T) {\n batch(() => {\n const result = fn(wrapped)\n if (result !== undefined) {\n reconcile(wrapped, result)\n }\n })\n }\n\n return [wrapped, setStore]\n}\n\n// Map of target object -> Proxy\nconst proxyCache = new WeakMap<object, any>()\n// Map of target object -> Map<key, Signal>\nconst signalCache = new WeakMap<object, Map<string | symbol, SignalAccessor<any>>>()\n\nfunction wrap<T>(value: T): T {\n if (value === null || typeof value !== 'object') return value\n if ((value as any)[PROXY]) return value\n\n if (proxyCache.has(value)) return proxyCache.get(value)\n\n const handler: ProxyHandler<any> = {\n get(target, prop, receiver) {\n if (prop === PROXY) return true\n if (prop === TARGET) return target\n\n const value = Reflect.get(target, prop, receiver)\n\n // Track property access\n track(target, prop)\n\n // Recursively wrap objects\n return wrap(value)\n },\n has(target, prop) {\n const result = Reflect.has(target, prop)\n track(target, prop)\n return result\n },\n ownKeys(target) {\n track(target, ITERATE_KEY)\n return Reflect.ownKeys(target)\n },\n getOwnPropertyDescriptor(target, prop) {\n track(target, prop)\n return Reflect.getOwnPropertyDescriptor(target, prop)\n },\n set(target, prop, value, receiver) {\n if (prop === PROXY || prop === TARGET) return false\n\n const hadKey = Object.prototype.hasOwnProperty.call(target, prop)\n const oldValue = Reflect.get(target, prop, receiver)\n if (oldValue === value) return true\n\n const result = Reflect.set(target, prop, value, receiver)\n if (result) {\n trigger(target, prop)\n if (!hadKey) {\n trigger(target, ITERATE_KEY)\n }\n }\n return result\n },\n deleteProperty(target, prop) {\n const hadKey = Object.prototype.hasOwnProperty.call(target, prop)\n const result = Reflect.deleteProperty(target, prop)\n if (result) {\n trigger(target, prop)\n if (hadKey) {\n trigger(target, ITERATE_KEY)\n }\n }\n return result\n },\n }\n\n const proxy = new Proxy(value, handler)\n proxyCache.set(value, proxy)\n return proxy as T\n}\n\nfunction unwrap<T>(value: T): T {\n if (value && typeof value === 'object' && (value as any)[PROXY]) {\n return (value as any)[TARGET]\n }\n return value\n}\n\nfunction track(target: object, prop: string | symbol) {\n let signals = signalCache.get(target)\n if (!signals) {\n signals = new Map()\n signalCache.set(target, signals)\n }\n\n let s = signals.get(prop)\n if (!s) {\n const initial =\n prop === ITERATE_KEY ? (Reflect.ownKeys(target).length as number) : getLastValue(target, prop)\n s = signal(initial)\n signals.set(prop, s)\n }\n s() // subscribe\n}\n\nfunction trigger(target: object, prop: string | symbol) {\n const signals = signalCache.get(target)\n if (signals) {\n const s = signals.get(prop)\n if (s) {\n if (prop === ITERATE_KEY) {\n s(Reflect.ownKeys(target).length)\n } else {\n s(getLastValue(target, prop)) // notify with new value\n }\n }\n }\n}\n\nfunction getLastValue(target: any, prop: string | symbol) {\n return target[prop]\n}\n\n/**\n * Reconcile a store path with a new value (shallow merge/diff)\n */\nfunction reconcile(target: any, value: any) {\n if (target === value) return\n if (value === null || typeof value !== 'object') {\n throw new Error(\n `[Fict] Cannot replace store with primitive value: ${String(\n value,\n )}. setStore should return an object/array to merge.`,\n )\n }\n\n const realTarget = unwrap(target)\n const realValue = unwrap(value)\n\n const keys = new Set([...Object.keys(realTarget), ...Object.keys(realValue)])\n for (const key of keys) {\n if (realValue[key] === undefined && realTarget[key] !== undefined) {\n // deleted\n delete target[key] // Triggers proxy trap\n } else if (realTarget[key] !== realValue[key]) {\n target[key] = realValue[key] // Triggers proxy trap\n }\n }\n\n // Fix array length if needed\n if (Array.isArray(target) && target.length !== realValue.length) {\n target.length = realValue.length\n }\n}\n\n// ============================================================================\n// Diffing Signal (for List Items)\n// ============================================================================\n\n/**\n * Creates a signal that returns a Stable Proxy.\n * Updates to the signal (via set) will diff the new value against the old value\n * and trigger property-specific updates.\n */\nexport function createDiffingSignal<T extends object>(initialValue: T) {\n let currentValue = unwrap(initialValue)\n const signals = new Map<string | symbol, SignalAccessor<any>>()\n let iterateSignal: SignalAccessor<number> | undefined\n\n const getPropSignal = (prop: string | symbol) => {\n let s = signals.get(prop)\n if (!s) {\n s = signal((currentValue as any)[prop])\n signals.set(prop, s)\n }\n return s\n }\n\n const trackIterate = () => {\n if (!iterateSignal) {\n iterateSignal = signal(Reflect.ownKeys(currentValue).length)\n }\n iterateSignal()\n }\n\n const updateIterate = (value: T) => {\n if (iterateSignal) {\n iterateSignal(Reflect.ownKeys(value).length)\n }\n }\n\n // The stable proxy we return\n const proxy = new Proxy({} as T, {\n get(_, prop) {\n if (prop === PROXY) return true\n if (prop === TARGET) return currentValue\n\n // Subscribe to property\n const s = getPropSignal(prop)\n return s()\n },\n ownKeys() {\n trackIterate()\n return Reflect.ownKeys(currentValue)\n },\n has(target, prop) {\n getPropSignal(prop)()\n return Reflect.has(currentValue, prop)\n },\n getOwnPropertyDescriptor(target, prop) {\n getPropSignal(prop)()\n return Reflect.getOwnPropertyDescriptor(currentValue, prop)\n },\n })\n\n const read = () => proxy\n\n const write = (newValue: T) => {\n const next = unwrap(newValue)\n const prev = currentValue\n currentValue = next\n\n if (prev === next) {\n // Same ref update: re-evaluate all tracked signals\n // This is necessary for in-place mutations\n for (const [prop, s] of signals) {\n const newVal = (next as any)[prop]\n s(newVal)\n }\n updateIterate(next)\n return\n }\n\n // Diff logic\n // We only trigger signals for properties that exist in our cache (tracked)\n // and have changed.\n for (const [prop, s] of signals) {\n const oldVal = (prev as any)[prop]\n const newVal = (next as any)[prop]\n if (oldVal !== newVal) {\n s(newVal)\n }\n }\n updateIterate(next)\n\n // Note: If new properties appeared that weren't tracked, we don't care\n // because no one is listening.\n // If we assume shape stability (Keyed List), this is efficient.\n }\n\n return [read, write] as const\n}\n","/**\n * Fict DOM Reconciliation\n *\n * Efficient array reconciliation algorithm based on udomdiff.\n * https://github.com/WebReflection/udomdiff\n *\n * This algorithm uses a 5-step strategy:\n * 1. Common prefix - skip matching nodes at start\n * 2. Common suffix - skip matching nodes at end\n * 3. Append - insert remaining new nodes\n * 4. Remove - remove remaining old nodes\n * 5. Swap/Map fallback - handle complex rearrangements\n *\n * Most real-world updates (95%+) use fast paths without building a Map.\n */\n\n/**\n * Reconcile two arrays of DOM nodes, efficiently updating the DOM.\n *\n * @param parentNode - The parent element containing the nodes\n * @param a - The old array of nodes (currently in DOM)\n * @param b - The new array of nodes (target state)\n *\n * **Note:** This function may mutate the input array `a` during the swap\n * optimization (step 5a). If you need to preserve the original array,\n * pass a shallow copy: `reconcileArrays(parent, [...oldNodes], newNodes)`.\n *\n * @example\n * ```ts\n * const oldNodes = [node1, node2, node3]\n * const newNodes = [node1, node4, node3] // node2 replaced with node4\n * reconcileArrays(parent, oldNodes, newNodes)\n * ```\n */\nexport default function reconcileArrays(parentNode: ParentNode, a: Node[], b: Node[]): void {\n const bLength = b.length\n let aEnd = a.length\n let bEnd = bLength\n let aStart = 0\n let bStart = 0\n const after = aEnd > 0 ? a[aEnd - 1]!.nextSibling : null\n let map: Map<Node, number> | null = null\n\n while (aStart < aEnd || bStart < bEnd) {\n // 1. Common prefix - nodes match at start\n if (a[aStart] === b[bStart]) {\n aStart++\n bStart++\n continue\n }\n\n // 2. Common suffix - nodes match at end\n while (a[aEnd - 1] === b[bEnd - 1]) {\n aEnd--\n bEnd--\n }\n\n // 3. Append - old array exhausted, insert remaining new nodes\n if (aEnd === aStart) {\n const node: Node | null =\n bEnd < bLength ? (bStart ? b[bStart - 1]!.nextSibling : (b[bEnd - bStart] ?? null)) : after\n\n const count = bEnd - bStart\n const doc = (parentNode as Node).ownerDocument\n if (count > 1 && doc) {\n const frag = doc.createDocumentFragment()\n for (let i = bStart; i < bEnd; i++) {\n frag.appendChild(b[i]!)\n }\n parentNode.insertBefore(frag, node)\n bStart = bEnd\n } else {\n while (bStart < bEnd) {\n parentNode.insertBefore(b[bStart++]!, node)\n }\n }\n }\n // 4. Remove - new array exhausted, remove remaining old nodes\n else if (bEnd === bStart) {\n while (aStart < aEnd) {\n const nodeToRemove = a[aStart]!\n if (!map || !map.has(nodeToRemove)) {\n nodeToRemove.parentNode?.removeChild(nodeToRemove)\n }\n aStart++\n }\n }\n // 5a. Swap backward - detect backward swap pattern\n else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {\n const node = a[--aEnd]!.nextSibling\n parentNode.insertBefore(b[bStart++]!, a[aStart++]!.nextSibling)\n parentNode.insertBefore(b[--bEnd]!, node)\n // Update reference in old array for potential future matches\n a[aEnd] = b[bEnd]!\n }\n // 5b. Map fallback - use Map for complex rearrangements\n else {\n // Build map on first use (lazy initialization)\n if (!map) {\n map = new Map()\n let i = bStart\n while (i < bEnd) {\n map.set(b[i]!, i++)\n }\n }\n\n const index = map.get(a[aStart]!)\n\n if (index != null) {\n if (bStart < index && index < bEnd) {\n // Check for longest increasing subsequence\n let i = aStart\n let sequence = 1\n let t: number | undefined\n\n while (++i < aEnd && i < bEnd) {\n t = map.get(a[i]!)\n if (t == null || t !== index + sequence) break\n sequence++\n }\n\n // Use optimal strategy based on sequence length\n if (sequence > index - bStart) {\n // Sequence is long enough - insert nodes before current\n const node = a[aStart]!\n while (bStart < index) {\n parentNode.insertBefore(b[bStart++]!, node)\n }\n } else {\n // Short sequence - replace\n parentNode.replaceChild(b[bStart++]!, a[aStart++]!)\n }\n } else {\n aStart++\n }\n } else {\n // Node not in new array - remove it\n const nodeToRemove = a[aStart++]!\n nodeToRemove.parentNode?.removeChild(nodeToRemove)\n }\n }\n }\n}\n\n/**\n * Simple reconciliation for keyed lists.\n * Uses the same algorithm but works with keyed blocks.\n *\n * @param parentNode - The parent element\n * @param oldNodes - Old nodes in DOM order\n * @param newNodes - New nodes in target order\n */\nexport function reconcileNodes(parentNode: ParentNode, oldNodes: Node[], newNodes: Node[]): void {\n reconcileArrays(parentNode, oldNodes, newNodes)\n}\n","/**\n * List Helpers for Compiler-Generated Fine-Grained Updates\n *\n * These helpers are used by the compiler to generate efficient keyed list rendering.\n * They provide low-level primitives for DOM node manipulation without rebuilding.\n */\n\nimport { createElement } from './dom'\nimport { createRenderEffect } from './effect'\nimport {\n createRootContext,\n destroyRoot,\n flushOnMount,\n getCurrentRoot,\n popRoot,\n pushRoot,\n type RootContext,\n} from './lifecycle'\nimport { insertNodesBefore, removeNodes, toNodeArray } from './node-ops'\nimport reconcileArrays from './reconcile'\nimport { batch } from './scheduler'\nimport { createSignal, effectScope, flush, setActiveSub, type Signal } from './signal'\nimport type { FictNode } from './types'\n\n// Re-export shared DOM helpers for compiler-generated code\nexport { insertNodesBefore, removeNodes, toNodeArray }\n\nconst isDev =\n typeof __DEV__ !== 'undefined'\n ? __DEV__\n : typeof process === 'undefined' || process.env?.NODE_ENV !== 'production'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * A keyed block represents a single item in a list with its associated DOM nodes and state\n */\ninterface KeyedBlock<T = unknown> {\n /** Unique key for this block */\n key: string | number\n /** DOM nodes belonging to this block */\n nodes: Node[]\n /** Root context for lifecycle management */\n root: RootContext\n /** Signal containing the current item value */\n item: Signal<T>\n /** Signal containing the current index */\n index: Signal<number>\n /** Last raw item value assigned to this block */\n rawItem: T\n /** Last raw index value assigned to this block */\n rawIndex: number\n}\n\n/**\n * Container for managing keyed list blocks\n */\ninterface KeyedListContainer<T = unknown> {\n /** Start marker comment node */\n startMarker: Comment\n /** End marker comment node */\n endMarker: Comment\n /** Map of key to block */\n blocks: Map<string | number, KeyedBlock<T>>\n /** Scratch map reused for the next render */\n nextBlocks: Map<string | number, KeyedBlock<T>>\n /** Current nodes in DOM order (including markers) */\n currentNodes: Node[]\n /** Next-frame node buffer to avoid reallocations */\n nextNodes: Node[]\n /** Ordered blocks in current DOM order */\n orderedBlocks: KeyedBlock<T>[]\n /** Next-frame ordered block buffer to avoid reallocations */\n nextOrderedBlocks: KeyedBlock<T>[]\n /** Track position of keys in the ordered buffer to handle duplicates */\n orderedIndexByKey: Map<string | number, number>\n /** Cleanup function */\n dispose: () => void\n}\n\n/**\n * Binding handle returned by createKeyedList for compiler-generated code\n */\nexport interface KeyedListBinding {\n /** Document fragment placeholder inserted by the compiler/runtime */\n marker: DocumentFragment\n /** Start marker comment node */\n startMarker: Comment\n /** End marker comment node */\n endMarker: Comment\n /** Flush pending items - call after markers are inserted into DOM */\n flush?: () => void\n /** Cleanup function */\n dispose: () => void\n}\n\ntype FineGrainedRenderItem<T> = (\n itemSig: Signal<T>,\n indexSig: Signal<number>,\n key: string | number,\n) => Node[]\n\n// ============================================================================\n// DOM Manipulation Primitives\n// ============================================================================\n\n/**\n * Move nodes to a position before the anchor node.\n * This is optimized to avoid unnecessary DOM operations.\n *\n * @param parent - Parent node to move nodes within\n * @param nodes - Array of nodes to move\n * @param anchor - Node to insert before (or null for end)\n */\nexport function moveNodesBefore(parent: Node, nodes: Node[], anchor: Node | null): void {\n // Insert in reverse order to maintain correct sequence\n // This way each node becomes the new anchor for the next\n for (let i = nodes.length - 1; i >= 0; i--) {\n const node = nodes[i]!\n if (!node || !(node instanceof Node)) {\n const message = isDev ? 'Invalid node in moveNodesBefore' : 'FICT:E_NODE'\n throw new Error(message)\n }\n // Only move if not already in correct position\n if (node.nextSibling !== anchor) {\n if (node.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {\n parent.ownerDocument.adoptNode(node)\n }\n try {\n parent.insertBefore(node, anchor)\n } catch (e: any) {\n if (parent.ownerDocument) {\n try {\n const clone = parent.ownerDocument.importNode(node, true)\n parent.insertBefore(clone, anchor)\n // Note: Cloning during move breaks references in KeyedBlock.nodes\n // This is a worst-case fallback for tests.\n continue\n } catch {\n // Clone fallback failed\n }\n }\n throw e\n }\n }\n anchor = node\n }\n}\n\n/**\n * Remove an array of nodes from the DOM\n *\n * @param nodes - Array of nodes to remove\n */\n// Number.MAX_SAFE_INTEGER is 2^53 - 1, but we reset earlier to avoid any precision issues\nconst MAX_SAFE_VERSION = 0x1fffffffffffff // 2^53 - 1\n\nexport function createVersionedSignalAccessor<T>(initialValue: T): Signal<T> {\n let current = initialValue\n let version = 0\n const track = createSignal(version)\n\n function accessor(value?: T): T | void {\n if (arguments.length === 0) {\n track()\n return current\n }\n current = value as T\n // This is safe because we only care about version changes, not absolute values\n version = version >= MAX_SAFE_VERSION ? 1 : version + 1\n track(version)\n }\n\n return accessor as Signal<T>\n}\n\n// ============================================================================\n// Keyed List Container\n// ============================================================================\n\n/**\n * Create a container for managing a keyed list.\n * This sets up the marker nodes and provides cleanup.\n *\n * @returns Container object with markers, blocks map, and dispose function\n */\nfunction createKeyedListContainer<T = unknown>(): KeyedListContainer<T> {\n const startMarker = document.createComment('fict:list:start')\n const endMarker = document.createComment('fict:list:end')\n\n const dispose = () => {\n // Clean up all blocks\n for (const block of container.blocks.values()) {\n destroyRoot(block.root)\n // Nodes are removed by parent disposal or specific cleanup if needed\n // But for list disposal, we just clear the container\n }\n container.blocks.clear()\n container.nextBlocks.clear()\n\n // Remove nodes (including markers)\n // Check if markers are still in DOM before using Range\n if (!startMarker.parentNode || !endMarker.parentNode) {\n // Markers already removed, nothing to do\n container.currentNodes = []\n container.nextNodes = []\n container.orderedBlocks.length = 0\n container.nextOrderedBlocks.length = 0\n container.orderedIndexByKey.clear()\n return\n }\n const range = document.createRange()\n range.setStartBefore(startMarker)\n range.setEndAfter(endMarker)\n range.deleteContents()\n\n // Clear cache\n container.currentNodes = []\n container.nextNodes = []\n container.nextBlocks.clear()\n container.orderedBlocks.length = 0\n container.nextOrderedBlocks.length = 0\n container.orderedIndexByKey.clear()\n }\n\n const container: KeyedListContainer<T> = {\n startMarker,\n endMarker,\n blocks: new Map<string | number, KeyedBlock<T>>(),\n nextBlocks: new Map<string | number, KeyedBlock<T>>(),\n currentNodes: [startMarker, endMarker],\n nextNodes: [],\n orderedBlocks: [],\n nextOrderedBlocks: [],\n orderedIndexByKey: new Map<string | number, number>(),\n dispose,\n }\n\n return container\n}\n\n// ============================================================================\n// Block Creation Helpers\n// ============================================================================\n\n/**\n * Create a new keyed block with the given render function\n *\n * @param key - Unique key for this block\n * @param item - Initial item value\n * @param index - Initial index\n * @param render - Function that creates the DOM nodes and sets up bindings\n * @returns New KeyedBlock\n */\nfunction createKeyedBlock<T>(\n key: string | number,\n item: T,\n index: number,\n render: (item: Signal<T>, index: Signal<number>, key: string | number) => Node[],\n needsIndex = true,\n hostRoot?: RootContext,\n): KeyedBlock<T> {\n // Use versioned signal for all item types; avoid diffing proxy overhead for objects\n const itemSig = createVersionedSignalAccessor(item)\n\n const indexSig = needsIndex\n ? createSignal<number>(index)\n : (((next?: number) => {\n if (arguments.length === 0) return index\n index = next as number\n return index\n }) as Signal<number>)\n const root = createRootContext(hostRoot)\n const prevRoot = pushRoot(root)\n // maintaining proper cleanup chain. The scope will be disposed when\n // the root is destroyed, ensuring nested effects are properly cleaned up.\n let nodes: Node[] = []\n let scopeDispose: (() => void) | undefined\n\n // First, isolate from parent effect to prevent child effects from being\n // purged when the outer effect (e.g., performDiff) re-runs\n const prevSub = setActiveSub(undefined)\n\n try {\n // Create an effectScope that will track all effects created during render\n scopeDispose = effectScope(() => {\n const rendered = render(itemSig, indexSig, key)\n // If render returns real DOM nodes/arrays, preserve them to avoid\n // reparenting side-effects (tests may pre-insert them).\n if (\n rendered instanceof Node ||\n (Array.isArray(rendered) && rendered.every(n => n instanceof Node))\n ) {\n nodes = toNodeArray(rendered)\n } else {\n const element = createElement(rendered as unknown as FictNode)\n nodes = toNodeArray(element)\n }\n })\n\n // Register the scope cleanup with the root so effects are cleaned up\n // when the block is destroyed\n if (scopeDispose) {\n root.cleanups.push(scopeDispose)\n }\n } finally {\n setActiveSub(prevSub)\n popRoot(prevRoot)\n }\n\n return {\n key,\n nodes,\n root,\n item: itemSig,\n index: indexSig,\n rawItem: item,\n rawIndex: index,\n }\n}\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\n/**\n * Check if a node is between two markers\n */\nexport function isNodeBetweenMarkers(\n node: Node,\n startMarker: Comment,\n endMarker: Comment,\n): boolean {\n let current: Node | null = startMarker.nextSibling\n while (current && current !== endMarker) {\n if (current === node) return true\n current = current.nextSibling\n }\n return false\n}\n\nfunction reorderBySwap<T>(\n parent: ParentNode & Node,\n first: KeyedBlock<T>,\n second: KeyedBlock<T>,\n): boolean {\n if (first === second) return false\n const firstNodes = first.nodes\n const secondNodes = second.nodes\n if (firstNodes.length === 0 || secondNodes.length === 0) return false\n const lastFirst = firstNodes[firstNodes.length - 1]!\n const lastSecond = secondNodes[secondNodes.length - 1]!\n const afterFirst = lastFirst.nextSibling\n const afterSecond = lastSecond.nextSibling\n moveNodesBefore(parent, firstNodes, afterSecond)\n moveNodesBefore(parent, secondNodes, afterFirst)\n return true\n}\n\nfunction getLISIndices(sequence: number[]): number[] {\n const predecessors = new Array<number>(sequence.length)\n const result: number[] = []\n\n for (let i = 0; i < sequence.length; i++) {\n const value = sequence[i]!\n if (value < 0) {\n predecessors[i] = -1\n continue\n }\n\n let low = 0\n let high = result.length\n while (low < high) {\n const mid = (low + high) >> 1\n if (sequence[result[mid]!]! < value) {\n low = mid + 1\n } else {\n high = mid\n }\n }\n\n predecessors[i] = low > 0 ? result[low - 1]! : -1\n if (low === result.length) {\n result.push(i)\n } else {\n result[low] = i\n }\n }\n\n const lis: number[] = new Array(result.length)\n let k = result.length > 0 ? result[result.length - 1]! : -1\n for (let i = result.length - 1; i >= 0; i--) {\n lis[i] = k\n k = predecessors[k]!\n }\n return lis\n}\n\nfunction reorderByLIS<T>(\n parent: ParentNode & Node,\n endMarker: Comment,\n prev: KeyedBlock<T>[],\n next: KeyedBlock<T>[],\n): boolean {\n const positions = new Map<KeyedBlock<T>, number>()\n for (let i = 0; i < prev.length; i++) {\n positions.set(prev[i]!, i)\n }\n\n const sequence = new Array<number>(next.length)\n for (let i = 0; i < next.length; i++) {\n const position = positions.get(next[i]!)\n if (position === undefined) return false\n sequence[i] = position\n }\n\n const lisIndices = getLISIndices(sequence)\n if (lisIndices.length === sequence.length) return true\n\n const inLIS = new Array<boolean>(sequence.length).fill(false)\n for (let i = 0; i < lisIndices.length; i++) {\n inLIS[lisIndices[i]!] = true\n }\n\n let anchor: Node | null = endMarker\n let moved = false\n for (let i = next.length - 1; i >= 0; i--) {\n const block = next[i]!\n const nodes = block.nodes\n if (nodes.length === 0) continue\n if (inLIS[i]) {\n anchor = nodes[0]!\n continue\n }\n moveNodesBefore(parent, nodes, anchor)\n anchor = nodes[0]!\n moved = true\n }\n\n return moved\n}\n\n// ============================================================================\n// High-Level List Binding (for compiler-generated code)\n// ============================================================================\n\n/**\n * Create a keyed list binding with automatic diffing and DOM updates.\n * This is used by compiler-generated code for efficient list rendering.\n *\n * @param getItems - Function that returns the current array of items\n * @param keyFn - Function to extract unique key from each item\n * @param renderItem - Function that creates DOM nodes for each item\n * @returns Binding handle with markers and dispose function\n */\nexport function createKeyedList<T>(\n getItems: () => T[],\n keyFn: (item: T, index: number) => string | number,\n renderItem: FineGrainedRenderItem<T>,\n needsIndex?: boolean,\n): KeyedListBinding {\n const resolvedNeedsIndex =\n arguments.length >= 4 ? !!needsIndex : renderItem.length > 1 /* has index param */\n return createFineGrainedKeyedList(getItems, keyFn, renderItem, resolvedNeedsIndex)\n}\n\nfunction createFineGrainedKeyedList<T>(\n getItems: () => T[],\n keyFn: (item: T, index: number) => string | number,\n renderItem: FineGrainedRenderItem<T>,\n needsIndex: boolean,\n): KeyedListBinding {\n const container = createKeyedListContainer<T>()\n const hostRoot = getCurrentRoot()\n const fragment = document.createDocumentFragment()\n fragment.append(container.startMarker, container.endMarker)\n let disposed = false\n let effectDispose: (() => void) | undefined\n let connectObserver: MutationObserver | null = null\n let effectStarted = false\n let startScheduled = false\n\n const getConnectedParent = (): (ParentNode & Node) | null => {\n const endParent = container.endMarker.parentNode\n const startParent = container.startMarker.parentNode\n if (\n endParent &&\n startParent &&\n endParent === startParent &&\n (endParent as Node).nodeType !== 11\n ) {\n return endParent as ParentNode & Node\n }\n return null\n }\n\n const performDiff = () => {\n if (disposed) return\n const parent = getConnectedParent()\n if (!parent) return\n batch(() => {\n const oldBlocks = container.blocks\n const newBlocks = container.nextBlocks\n const prevOrderedBlocks = container.orderedBlocks\n const nextOrderedBlocks = container.nextOrderedBlocks\n const orderedIndexByKey = container.orderedIndexByKey\n const newItems = getItems()\n\n if (newItems.length === 0) {\n if (oldBlocks.size > 0) {\n // Destroy all block roots first\n for (const block of oldBlocks.values()) {\n destroyRoot(block.root)\n }\n // Use Range.deleteContents for efficient bulk DOM removal\n const range = document.createRange()\n range.setStartAfter(container.startMarker)\n range.setEndBefore(container.endMarker)\n range.deleteContents()\n }\n oldBlocks.clear()\n newBlocks.clear()\n prevOrderedBlocks.length = 0\n nextOrderedBlocks.length = 0\n orderedIndexByKey.clear()\n container.currentNodes.length = 0\n container.currentNodes.push(container.startMarker, container.endMarker)\n container.nextNodes.length = 0\n return\n }\n\n const prevCount = prevOrderedBlocks.length\n if (prevCount > 0 && newItems.length === prevCount && orderedIndexByKey.size === prevCount) {\n let stableOrder = true\n const seen = new Set<string | number>()\n for (let i = 0; i < prevCount; i++) {\n const item = newItems[i]!\n const key = keyFn(item, i)\n if (seen.has(key) || prevOrderedBlocks[i]!.key !== key) {\n stableOrder = false\n break\n }\n seen.add(key)\n }\n if (stableOrder) {\n for (let i = 0; i < prevCount; i++) {\n const item = newItems[i]!\n const block = prevOrderedBlocks[i]!\n if (block.rawItem !== item) {\n block.rawItem = item\n block.item(item)\n }\n if (needsIndex && block.rawIndex !== i) {\n block.rawIndex = i\n block.index(i)\n }\n }\n return\n }\n }\n\n newBlocks.clear()\n nextOrderedBlocks.length = 0\n orderedIndexByKey.clear()\n const createdBlocks: KeyedBlock<T>[] = []\n let appendCandidate = prevCount > 0 && newItems.length >= prevCount\n const appendedBlocks: KeyedBlock<T>[] = []\n let mismatchCount = 0\n let mismatchFirst = -1\n let mismatchSecond = -1\n let hasDuplicateKey = false\n\n // Phase 1: Build new blocks map (reuse or create)\n newItems.forEach((item, index) => {\n const key = keyFn(item, index)\n // Micro-optimization: single Map.get instead of has+get\n let block = oldBlocks.get(key)\n const existed = block !== undefined\n\n if (block) {\n if (block.rawItem !== item) {\n block.rawItem = item\n block.item(item)\n }\n if (needsIndex && block.rawIndex !== index) {\n block.rawIndex = index\n block.index(index)\n }\n }\n\n if (block) {\n // Reusing existing block from oldBlocks\n newBlocks.set(key, block)\n oldBlocks.delete(key)\n } else {\n // If newBlocks already has this key (duplicate key case), clean up the previous block\n const existingBlock = newBlocks.get(key)\n if (existingBlock) {\n if (isDev) {\n console.warn(\n `[fict] Duplicate key \"${String(key)}\" detected in list rendering. ` +\n `Each item should have a unique key. The previous item with this key will be replaced.`,\n )\n }\n destroyRoot(existingBlock.root)\n removeNodes(existingBlock.nodes)\n }\n // Create new block\n block = createKeyedBlock(key, item, index, renderItem, needsIndex, hostRoot)\n createdBlocks.push(block)\n }\n\n const resolvedBlock = block\n\n newBlocks.set(key, resolvedBlock)\n\n // Micro-optimization: single Map.get instead of checking position multiple times\n const position = orderedIndexByKey.get(key)\n if (position !== undefined) {\n appendCandidate = false\n hasDuplicateKey = true\n const prior = nextOrderedBlocks[position]\n if (prior && prior !== resolvedBlock) {\n destroyRoot(prior.root)\n removeNodes(prior.nodes)\n }\n nextOrderedBlocks[position] = resolvedBlock\n } else {\n if (appendCandidate) {\n if (index < prevCount) {\n if (!prevOrderedBlocks[index] || prevOrderedBlocks[index]!.key !== key) {\n appendCandidate = false\n }\n } else if (existed) {\n appendCandidate = false\n }\n }\n const nextIndex = nextOrderedBlocks.length\n orderedIndexByKey.set(key, nextIndex)\n nextOrderedBlocks.push(resolvedBlock)\n if (\n mismatchCount < 3 &&\n (nextIndex >= prevCount || prevOrderedBlocks[nextIndex] !== resolvedBlock)\n ) {\n if (mismatchCount === 0) {\n mismatchFirst = nextIndex\n } else if (mismatchCount === 1) {\n mismatchSecond = nextIndex\n }\n mismatchCount++\n }\n }\n\n if (appendCandidate && index >= prevCount) {\n appendedBlocks.push(resolvedBlock)\n }\n })\n\n const canAppend =\n appendCandidate &&\n prevCount > 0 &&\n newItems.length > prevCount &&\n oldBlocks.size === 0 &&\n appendedBlocks.length > 0\n if (canAppend) {\n const appendedNodes: Node[] = []\n for (const block of appendedBlocks) {\n for (let i = 0; i < block.nodes.length; i++) {\n appendedNodes.push(block.nodes[i]!)\n }\n }\n if (appendedNodes.length > 0) {\n insertNodesBefore(parent, appendedNodes, container.endMarker)\n const currentNodes = container.currentNodes\n currentNodes.pop()\n for (let i = 0; i < appendedNodes.length; i++) {\n currentNodes.push(appendedNodes[i]!)\n }\n currentNodes.push(container.endMarker)\n }\n\n container.blocks = newBlocks\n container.nextBlocks = oldBlocks\n container.orderedBlocks = nextOrderedBlocks\n container.nextOrderedBlocks = prevOrderedBlocks\n for (const block of createdBlocks) {\n if (newBlocks.get(block.key) === block) {\n flushOnMount(block.root)\n }\n }\n return\n }\n\n // Phase 2: Remove old blocks that are no longer in the list\n if (oldBlocks.size > 0) {\n for (const block of oldBlocks.values()) {\n destroyRoot(block.root)\n removeNodes(block.nodes)\n }\n oldBlocks.clear()\n }\n\n const canReorderInPlace =\n createdBlocks.length === 0 &&\n oldBlocks.size === 0 &&\n nextOrderedBlocks.length === prevOrderedBlocks.length\n\n let skipReconcile = false\n let updateNodeBuffer = true\n\n if (canReorderInPlace && nextOrderedBlocks.length > 0 && !hasDuplicateKey) {\n if (mismatchCount === 0) {\n skipReconcile = true\n updateNodeBuffer = false\n } else if (\n mismatchCount === 2 &&\n prevOrderedBlocks[mismatchFirst] === nextOrderedBlocks[mismatchSecond] &&\n prevOrderedBlocks[mismatchSecond] === nextOrderedBlocks[mismatchFirst]\n ) {\n if (\n reorderBySwap(\n parent,\n prevOrderedBlocks[mismatchFirst]!,\n prevOrderedBlocks[mismatchSecond]!,\n )\n ) {\n skipReconcile = true\n }\n } else if (\n reorderByLIS(parent, container.endMarker, prevOrderedBlocks, nextOrderedBlocks)\n ) {\n skipReconcile = true\n }\n }\n\n // Phase 3: Reconcile DOM with buffered node arrays\n if (!skipReconcile && (newBlocks.size > 0 || container.currentNodes.length > 0)) {\n const prevNodes = container.currentNodes\n const nextNodes = container.nextNodes\n nextNodes.length = 0\n nextNodes.push(container.startMarker)\n\n for (let i = 0; i < nextOrderedBlocks.length; i++) {\n const nodes = nextOrderedBlocks[i]!.nodes\n for (let j = 0; j < nodes.length; j++) {\n nextNodes.push(nodes[j]!)\n }\n }\n\n nextNodes.push(container.endMarker)\n\n reconcileArrays(parent, prevNodes, nextNodes)\n\n // Swap buffers to reuse arrays on next diff\n container.currentNodes = nextNodes\n container.nextNodes = prevNodes\n } else if (skipReconcile && updateNodeBuffer) {\n const prevNodes = container.currentNodes\n const nextNodes = container.nextNodes\n nextNodes.length = 0\n nextNodes.push(container.startMarker)\n for (let i = 0; i < nextOrderedBlocks.length; i++) {\n const nodes = nextOrderedBlocks[i]!.nodes\n for (let j = 0; j < nodes.length; j++) {\n nextNodes.push(nodes[j]!)\n }\n }\n nextNodes.push(container.endMarker)\n container.currentNodes = nextNodes\n container.nextNodes = prevNodes\n }\n\n // Swap block maps for reuse\n container.blocks = newBlocks\n container.nextBlocks = oldBlocks\n container.orderedBlocks = nextOrderedBlocks\n container.nextOrderedBlocks = prevOrderedBlocks\n for (const block of createdBlocks) {\n if (newBlocks.get(block.key) === block) {\n flushOnMount(block.root)\n }\n }\n })\n }\n\n const disconnectObserver = () => {\n connectObserver?.disconnect()\n connectObserver = null\n }\n\n const ensureEffectStarted = (): boolean => {\n if (disposed || effectStarted) return effectStarted\n const parent = getConnectedParent()\n if (!parent) return false\n const start = () => {\n effectDispose = createRenderEffect(performDiff)\n effectStarted = true\n }\n if (hostRoot) {\n const prev = pushRoot(hostRoot)\n try {\n start()\n } finally {\n popRoot(prev)\n }\n } else {\n start()\n }\n return true\n }\n\n const waitForConnection = () => {\n if (connectObserver || typeof MutationObserver === 'undefined') return\n connectObserver = new MutationObserver(() => {\n if (disposed) return\n if (getConnectedParent()) {\n disconnectObserver()\n if (ensureEffectStarted()) {\n flush()\n }\n }\n })\n connectObserver.observe(document, { childList: true, subtree: true })\n }\n\n const scheduleStart = () => {\n if (startScheduled || disposed || effectStarted) return\n startScheduled = true\n const run = () => {\n startScheduled = false\n if (!ensureEffectStarted()) {\n waitForConnection()\n }\n }\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(run)\n } else {\n Promise.resolve()\n .then(run)\n .catch(() => undefined)\n }\n }\n\n scheduleStart()\n\n return {\n get marker() {\n scheduleStart()\n return fragment\n },\n startMarker: container.startMarker,\n endMarker: container.endMarker,\n // Flush pending items - call after markers are inserted into DOM\n flush: () => {\n if (disposed) return\n scheduleStart()\n if (ensureEffectStarted()) {\n flush()\n } else {\n waitForConnection()\n }\n },\n dispose: () => {\n disposed = true\n effectDispose?.()\n disconnectObserver()\n container.dispose()\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAAA,IACF,CAAC;AACD,oBAAgB,QAAQ,UAAU,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,EACtE;AAEA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,kBAAkB,YAAY,cAAe;AACjD,qBAAiB;AACjB,UAAM,MAAM,MAAM;AAChB,uBAAiB;AACjB,UAAI,CAAC,oBAAoB,GAAG;AAC1B,0BAAkB;AAAA,MACpB;AAAA,IACF;AACA,QAAI,OAAO,mBAAmB,YAAY;AACxC,qBAAe,GAAG;AAAA,IACpB,OAAO;AACL,cAAQ,QAAQ,EACb,KAAK,GAAG,EACR,MAAM,MAAM,MAAS;AAAA,IAC1B;AAAA,EACF;AAEA,gBAAc;AAEd,SAAO;AAAA,IACL,IAAI,SAAS;AACX,oBAAc;AACd,aAAO;AAAA,IACT;AAAA,IACA,aAAa,UAAU;AAAA,IACvB,WAAW,UAAU;AAAA;AAAA,IAErB,OAAO,MAAM;AACX,UAAI,SAAU;AACd,oBAAc;AACd,UAAI,oBAAoB,GAAG;AACzB,cAAM;AAAA,MACR,OAAO;AACL,0BAAkB;AAAA,MACpB;AAAA,IACF;AAAA,IACA,SAAS,MAAM;AACb,iBAAW;AACX,sBAAgB;AAChB,yBAAmB;AACnB,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AACF;","names":["unwrap","prop","value","track","batch"]}
@@ -1,22 +1,18 @@
1
- /** Fict Virtual Node - represents a component or element in the virtual tree */
2
- interface FictVNode {
3
- /** Element type: tag name, Fragment symbol, or component function */
4
- type: string | symbol | ((props: Record<string, unknown>) => FictNode);
5
- /** Props passed to the element/component */
6
- props: Record<string, unknown> | null;
7
- /** Optional key for list rendering optimization */
8
- key?: string | undefined;
9
- }
10
- /**
11
- * Fict Node - represents any renderable value
12
- * This type covers all possible values that can appear in JSX
13
- */
14
- type FictNode = FictVNode | FictNode[] | Node | string | number | boolean | null | undefined;
1
+ import { C as Cleanup, F as FictNode, D as DOMElement } from './effect-Auji1rz9.cjs';
2
+
3
+ type Memo<T> = () => T;
4
+ declare function createMemo<T>(fn: () => T): Memo<T>;
5
+
6
+ type LifecycleFn = () => void | Cleanup;
7
+ declare function onMount(fn: LifecycleFn): void;
8
+ declare function onDestroy(fn: LifecycleFn): void;
9
+ declare function onCleanup(fn: Cleanup): void;
10
+ declare function createRoot<T>(fn: () => T): {
11
+ dispose: () => void;
12
+ value: T;
13
+ };
15
14
 
16
15
  declare const Fragment: unique symbol;
17
- declare function jsx(type: string | typeof Fragment | ((props: Record<string, unknown>) => FictNode), props: Record<string, unknown>, key?: string): FictNode;
18
- declare const jsxs: typeof jsx;
19
- declare const jsxDEV: typeof jsx;
20
16
  declare namespace JSX {
21
17
  type Element = FictNode;
22
18
  interface IntrinsicElements {
@@ -668,4 +664,97 @@ interface SVGAttributes<T> extends HTMLAttributes<T> {
668
664
  vectorEffect?: string;
669
665
  }
670
666
 
671
- export { Fragment, JSX, jsx, jsxDEV, jsxs };
667
+ /**
668
+ * Fict DOM Rendering System
669
+ *
670
+ * This module provides DOM rendering capabilities with reactive bindings.
671
+ * It transforms JSX virtual nodes into actual DOM elements, automatically
672
+ * setting up reactive updates for dynamic values.
673
+ *
674
+ * Key Features:
675
+ * - Reactive text content: `{count}` updates when count changes
676
+ * - Reactive attributes: `disabled={!isValid}` updates reactively
677
+ * - Reactive children: `{show && <Modal />}` handles conditionals
678
+ * - List rendering: `{items.map(...)}` with efficient keyed updates
679
+ */
680
+
681
+ /**
682
+ * Render a Fict view into a container element.
683
+ *
684
+ * @param view - A function that returns the view to render
685
+ * @param container - The DOM container to render into
686
+ * @returns A teardown function to unmount the view
687
+ *
688
+ * @example
689
+ * ```ts
690
+ * const unmount = render(() => <App />, document.getElementById('root')!)
691
+ * // Later: unmount()
692
+ * ```
693
+ */
694
+ declare function render(view: () => FictNode, container: HTMLElement): () => void;
695
+ /**
696
+ * Create a DOM element from a Fict node.
697
+ * This is the main entry point for converting virtual nodes to real DOM.
698
+ *
699
+ * Supports:
700
+ * - Native DOM nodes (passed through)
701
+ * - Null/undefined/false (empty text node)
702
+ * - Arrays (DocumentFragment)
703
+ * - Strings/numbers (text nodes)
704
+ * - Booleans (empty text node)
705
+ * - VNodes (components or HTML elements)
706
+ * - Reactive values (functions returning any of the above)
707
+ */
708
+ declare function createElement(node: FictNode): DOMElement;
709
+ /**
710
+ * Create a template cloning factory from an HTML string.
711
+ * Used by the compiler for efficient DOM generation.
712
+ *
713
+ * @param html - The HTML string to create a template from
714
+ * @param isImportNode - Use importNode for elements like img/iframe
715
+ * @param isSVG - Whether the template is SVG content
716
+ * @param isMathML - Whether the template is MathML content
717
+ */
718
+ declare function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Node;
719
+
720
+ /**
721
+ * @internal
722
+ * Marks a zero-arg getter so props proxy can lazily evaluate it.
723
+ * Users normally never call this directly; the compiler injects it.
724
+ */
725
+ declare function __fictProp<T>(getter: () => T): () => T;
726
+ declare function createPropsProxy<T extends Record<string, unknown>>(props: T): T;
727
+ /**
728
+ * Create a rest-like props object while preserving prop getters.
729
+ * Excludes the specified keys from the returned object.
730
+ */
731
+ declare function __fictPropsRest<T extends Record<string, unknown>>(props: T, exclude: (string | number | symbol)[]): Record<string, unknown>;
732
+ /**
733
+ * Merge multiple props-like objects while preserving lazy getters.
734
+ * Later sources override earlier ones.
735
+ *
736
+ * Uses lazy lookup strategy - properties are only accessed when read,
737
+ * avoiding upfront iteration of all keys.
738
+ */
739
+ type MergeSource<T extends Record<string, unknown>> = T | (() => T);
740
+ declare function mergeProps<T extends Record<string, unknown>>(...sources: (MergeSource<T> | null | undefined)[]): Record<string, unknown>;
741
+ type PropGetter<T> = (() => T) & {
742
+ __fictProp: true;
743
+ };
744
+ /**
745
+ * Memoize a prop getter to cache expensive computations.
746
+ * Use when prop expressions involve heavy calculations or you need lazy, reactive props.
747
+ *
748
+ * @example
749
+ * ```tsx
750
+ * // Without prop - recomputes on every access
751
+ * <Child data={expensiveComputation(list, filter)} />
752
+ *
753
+ * // With prop - cached until dependencies change, auto-unwrapped by props proxy
754
+ * const memoizedData = prop(() => expensiveComputation(list, filter))
755
+ * <Child data={memoizedData} />
756
+ * ```
757
+ */
758
+ declare function prop<T>(getter: () => T): PropGetter<T>;
759
+
760
+ export { Fragment as F, JSX as J, type Memo as M, __fictProp as _, onDestroy as a, onCleanup as b, createMemo as c, createRoot as d, createElement as e, __fictPropsRest as f, createPropsProxy as g, mergeProps as m, onMount as o, prop as p, render as r, template as t };
@@ -1,22 +1,18 @@
1
- /** Fict Virtual Node - represents a component or element in the virtual tree */
2
- interface FictVNode {
3
- /** Element type: tag name, Fragment symbol, or component function */
4
- type: string | symbol | ((props: Record<string, unknown>) => FictNode);
5
- /** Props passed to the element/component */
6
- props: Record<string, unknown> | null;
7
- /** Optional key for list rendering optimization */
8
- key?: string | undefined;
9
- }
10
- /**
11
- * Fict Node - represents any renderable value
12
- * This type covers all possible values that can appear in JSX
13
- */
14
- type FictNode = FictVNode | FictNode[] | Node | string | number | boolean | null | undefined;
1
+ import { C as Cleanup, F as FictNode, D as DOMElement } from './effect-Auji1rz9.js';
2
+
3
+ type Memo<T> = () => T;
4
+ declare function createMemo<T>(fn: () => T): Memo<T>;
5
+
6
+ type LifecycleFn = () => void | Cleanup;
7
+ declare function onMount(fn: LifecycleFn): void;
8
+ declare function onDestroy(fn: LifecycleFn): void;
9
+ declare function onCleanup(fn: Cleanup): void;
10
+ declare function createRoot<T>(fn: () => T): {
11
+ dispose: () => void;
12
+ value: T;
13
+ };
15
14
 
16
15
  declare const Fragment: unique symbol;
17
- declare function jsx(type: string | typeof Fragment | ((props: Record<string, unknown>) => FictNode), props: Record<string, unknown>, key?: string): FictNode;
18
- declare const jsxs: typeof jsx;
19
- declare const jsxDEV: typeof jsx;
20
16
  declare namespace JSX {
21
17
  type Element = FictNode;
22
18
  interface IntrinsicElements {
@@ -668,4 +664,97 @@ interface SVGAttributes<T> extends HTMLAttributes<T> {
668
664
  vectorEffect?: string;
669
665
  }
670
666
 
671
- export { Fragment, JSX, jsx, jsxDEV, jsxs };
667
+ /**
668
+ * Fict DOM Rendering System
669
+ *
670
+ * This module provides DOM rendering capabilities with reactive bindings.
671
+ * It transforms JSX virtual nodes into actual DOM elements, automatically
672
+ * setting up reactive updates for dynamic values.
673
+ *
674
+ * Key Features:
675
+ * - Reactive text content: `{count}` updates when count changes
676
+ * - Reactive attributes: `disabled={!isValid}` updates reactively
677
+ * - Reactive children: `{show && <Modal />}` handles conditionals
678
+ * - List rendering: `{items.map(...)}` with efficient keyed updates
679
+ */
680
+
681
+ /**
682
+ * Render a Fict view into a container element.
683
+ *
684
+ * @param view - A function that returns the view to render
685
+ * @param container - The DOM container to render into
686
+ * @returns A teardown function to unmount the view
687
+ *
688
+ * @example
689
+ * ```ts
690
+ * const unmount = render(() => <App />, document.getElementById('root')!)
691
+ * // Later: unmount()
692
+ * ```
693
+ */
694
+ declare function render(view: () => FictNode, container: HTMLElement): () => void;
695
+ /**
696
+ * Create a DOM element from a Fict node.
697
+ * This is the main entry point for converting virtual nodes to real DOM.
698
+ *
699
+ * Supports:
700
+ * - Native DOM nodes (passed through)
701
+ * - Null/undefined/false (empty text node)
702
+ * - Arrays (DocumentFragment)
703
+ * - Strings/numbers (text nodes)
704
+ * - Booleans (empty text node)
705
+ * - VNodes (components or HTML elements)
706
+ * - Reactive values (functions returning any of the above)
707
+ */
708
+ declare function createElement(node: FictNode): DOMElement;
709
+ /**
710
+ * Create a template cloning factory from an HTML string.
711
+ * Used by the compiler for efficient DOM generation.
712
+ *
713
+ * @param html - The HTML string to create a template from
714
+ * @param isImportNode - Use importNode for elements like img/iframe
715
+ * @param isSVG - Whether the template is SVG content
716
+ * @param isMathML - Whether the template is MathML content
717
+ */
718
+ declare function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Node;
719
+
720
+ /**
721
+ * @internal
722
+ * Marks a zero-arg getter so props proxy can lazily evaluate it.
723
+ * Users normally never call this directly; the compiler injects it.
724
+ */
725
+ declare function __fictProp<T>(getter: () => T): () => T;
726
+ declare function createPropsProxy<T extends Record<string, unknown>>(props: T): T;
727
+ /**
728
+ * Create a rest-like props object while preserving prop getters.
729
+ * Excludes the specified keys from the returned object.
730
+ */
731
+ declare function __fictPropsRest<T extends Record<string, unknown>>(props: T, exclude: (string | number | symbol)[]): Record<string, unknown>;
732
+ /**
733
+ * Merge multiple props-like objects while preserving lazy getters.
734
+ * Later sources override earlier ones.
735
+ *
736
+ * Uses lazy lookup strategy - properties are only accessed when read,
737
+ * avoiding upfront iteration of all keys.
738
+ */
739
+ type MergeSource<T extends Record<string, unknown>> = T | (() => T);
740
+ declare function mergeProps<T extends Record<string, unknown>>(...sources: (MergeSource<T> | null | undefined)[]): Record<string, unknown>;
741
+ type PropGetter<T> = (() => T) & {
742
+ __fictProp: true;
743
+ };
744
+ /**
745
+ * Memoize a prop getter to cache expensive computations.
746
+ * Use when prop expressions involve heavy calculations or you need lazy, reactive props.
747
+ *
748
+ * @example
749
+ * ```tsx
750
+ * // Without prop - recomputes on every access
751
+ * <Child data={expensiveComputation(list, filter)} />
752
+ *
753
+ * // With prop - cached until dependencies change, auto-unwrapped by props proxy
754
+ * const memoizedData = prop(() => expensiveComputation(list, filter))
755
+ * <Child data={memoizedData} />
756
+ * ```
757
+ */
758
+ declare function prop<T>(getter: () => T): PropGetter<T>;
759
+
760
+ export { Fragment as F, JSX as J, type Memo as M, __fictProp as _, onDestroy as a, onCleanup as b, createMemo as c, createRoot as d, createElement as e, __fictPropsRest as f, createPropsProxy as g, mergeProps as m, onMount as o, prop as p, render as r, template as t };
@@ -0,0 +1,55 @@
1
+ import { O as MaybeReactive } from './effect-Auji1rz9.cjs';
2
+
3
+ /**
4
+ * Signal accessor - function to get/set signal value
5
+ */
6
+ interface SignalAccessor<T> {
7
+ (): T;
8
+ (value: T): void;
9
+ }
10
+ /**
11
+ * Computed accessor - function to get computed value
12
+ */
13
+ type ComputedAccessor<T> = () => T;
14
+ /**
15
+ * Effect scope disposer - function to dispose an effect scope
16
+ */
17
+ type EffectScopeDisposer = () => void;
18
+ /**
19
+ * Create a reactive signal
20
+ * @param initialValue - The initial value
21
+ * @returns A signal accessor function
22
+ */
23
+ declare function signal<T>(initialValue: T): SignalAccessor<T>;
24
+ /**
25
+ * Create a reactive effect scope
26
+ * @param fn - The scope function
27
+ * @returns An effect scope disposer function
28
+ */
29
+ declare function effectScope(fn: () => void): EffectScopeDisposer;
30
+ /**
31
+ * Create a selector signal that efficiently updates only when the selected key matches.
32
+ * Useful for large lists where only one item is selected.
33
+ *
34
+ * @param source - The source signal returning the current key
35
+ * @param equalityFn - Optional equality function
36
+ * @returns A selector function that takes a key and returns a boolean signal accessor
37
+ */
38
+ declare function createSelector<T>(source: () => T, equalityFn?: (a: T, b: T) => boolean): (key: T) => boolean;
39
+
40
+ interface ReactiveScope {
41
+ run<T>(fn: () => T): T;
42
+ stop(): void;
43
+ }
44
+ /**
45
+ * Create an explicit reactive scope that can contain effects/memos and be stopped manually.
46
+ * The scope registers with the current root for cleanup.
47
+ */
48
+ declare function createScope(): ReactiveScope;
49
+ /**
50
+ * Run a block of reactive code inside a managed scope that follows a boolean flag.
51
+ * When the flag turns false, the scope is disposed and all contained effects/memos are cleaned up.
52
+ */
53
+ declare function runInScope(flag: MaybeReactive<boolean>, fn: () => void): void;
54
+
55
+ export { type ComputedAccessor as C, type ReactiveScope as R, type SignalAccessor as S, createSelector as a, createScope as c, effectScope as e, runInScope as r, signal as s };
@@ -0,0 +1,55 @@
1
+ import { O as MaybeReactive } from './effect-Auji1rz9.js';
2
+
3
+ /**
4
+ * Signal accessor - function to get/set signal value
5
+ */
6
+ interface SignalAccessor<T> {
7
+ (): T;
8
+ (value: T): void;
9
+ }
10
+ /**
11
+ * Computed accessor - function to get computed value
12
+ */
13
+ type ComputedAccessor<T> = () => T;
14
+ /**
15
+ * Effect scope disposer - function to dispose an effect scope
16
+ */
17
+ type EffectScopeDisposer = () => void;
18
+ /**
19
+ * Create a reactive signal
20
+ * @param initialValue - The initial value
21
+ * @returns A signal accessor function
22
+ */
23
+ declare function signal<T>(initialValue: T): SignalAccessor<T>;
24
+ /**
25
+ * Create a reactive effect scope
26
+ * @param fn - The scope function
27
+ * @returns An effect scope disposer function
28
+ */
29
+ declare function effectScope(fn: () => void): EffectScopeDisposer;
30
+ /**
31
+ * Create a selector signal that efficiently updates only when the selected key matches.
32
+ * Useful for large lists where only one item is selected.
33
+ *
34
+ * @param source - The source signal returning the current key
35
+ * @param equalityFn - Optional equality function
36
+ * @returns A selector function that takes a key and returns a boolean signal accessor
37
+ */
38
+ declare function createSelector<T>(source: () => T, equalityFn?: (a: T, b: T) => boolean): (key: T) => boolean;
39
+
40
+ interface ReactiveScope {
41
+ run<T>(fn: () => T): T;
42
+ stop(): void;
43
+ }
44
+ /**
45
+ * Create an explicit reactive scope that can contain effects/memos and be stopped manually.
46
+ * The scope registers with the current root for cleanup.
47
+ */
48
+ declare function createScope(): ReactiveScope;
49
+ /**
50
+ * Run a block of reactive code inside a managed scope that follows a boolean flag.
51
+ * When the flag turns false, the scope is disposed and all contained effects/memos are cleaned up.
52
+ */
53
+ declare function runInScope(flag: MaybeReactive<boolean>, fn: () => void): void;
54
+
55
+ export { type ComputedAccessor as C, type ReactiveScope as R, type SignalAccessor as S, createSelector as a, createScope as c, effectScope as e, runInScope as r, signal as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fictjs/runtime",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Fict reactive runtime",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -30,6 +30,16 @@
30
30
  "import": "./dist/index.js",
31
31
  "require": "./dist/index.cjs"
32
32
  },
33
+ "./internal": {
34
+ "types": "./dist/internal.d.ts",
35
+ "import": "./dist/internal.js",
36
+ "require": "./dist/internal.cjs"
37
+ },
38
+ "./advanced": {
39
+ "types": "./dist/advanced.d.ts",
40
+ "import": "./dist/advanced.js",
41
+ "require": "./dist/advanced.cjs"
42
+ },
33
43
  "./jsx-runtime": {
34
44
  "types": "./dist/jsx-runtime.d.ts",
35
45
  "import": "./dist/jsx-runtime.js",
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @fileoverview Advanced APIs for Fict
3
+ *
4
+ * This module exports advanced APIs for power users and library authors.
5
+ * These APIs are stable but require deeper understanding of Fict internals.
6
+ *
7
+ * @advanced
8
+ * @packageDocumentation
9
+ */
10
+
11
+ // ============================================================================
12
+ // Reactive Scope Management
13
+ // ============================================================================
14
+
15
+ export { createScope, runInScope, type ReactiveScope } from './scope'
16
+ export { effectScope } from './signal'
17
+
18
+ // ============================================================================
19
+ // Fine-grained Subscription
20
+ // ============================================================================
21
+
22
+ export { createSelector } from './signal'
23
+
24
+ // ============================================================================
25
+ // Versioned Signal
26
+ // ============================================================================
27
+
28
+ export {
29
+ createVersionedSignal,
30
+ type VersionedSignal,
31
+ type VersionedSignalOptions,
32
+ } from './versioned-signal'
33
+
34
+ // ============================================================================
35
+ // High-Level Binding Factories
36
+ // ============================================================================
37
+
38
+ export {
39
+ createTextBinding,
40
+ createChildBinding,
41
+ createAttributeBinding,
42
+ createStyleBinding,
43
+ createClassBinding,
44
+ createShow,
45
+ } from './binding'
46
+
47
+ // ============================================================================
48
+ // Utilities
49
+ // ============================================================================
50
+
51
+ export { isReactive, unwrap } from './binding'
52
+
53
+ // ============================================================================
54
+ // Debugging & DevTools
55
+ // ============================================================================
56
+
57
+ export { getDevtoolsHook, type FictDevtoolsHook } from './devtools'
58
+ export { setCycleProtectionOptions } from './cycle-guard'
59
+
60
+ // ============================================================================
61
+ // Context API (for subtree scoping / SSR isolation / multi-instance)
62
+ // ============================================================================
63
+
64
+ export { createContext, useContext, hasContext, type Context, type ProviderProps } from './context'
65
+
66
+ // ============================================================================
67
+ // Low-level Primitives (for library authors)
68
+ // ============================================================================
69
+
70
+ export { createRenderEffect } from './effect'
71
+
72
+ // ============================================================================
73
+ // Cross-component Signal (escape hatch for scalar/lightweight values)
74
+ // ============================================================================
75
+
76
+ /**
77
+ * createSignal is an advanced/escape-hatch API for cross-component sharing
78
+ * of scalar or lightweight values. For most use cases, prefer:
79
+ *
80
+ * - $state: For component-local state (compiler-transformed, safe scoping)
81
+ * - $store: For cross-component shared state with deep reactivity
82
+ *
83
+ * Use createSignal when you need:
84
+ * - A simple scalar value shared across components
85
+ * - Library-level primitives
86
+ * - Fine-grained control over reactivity
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * // In a shared module
91
+ * export const globalCount = createSignal(0)
92
+ *
93
+ * // In any component
94
+ * function Counter() {
95
+ * return <button onClick={() => globalCount(globalCount() + 1)}>
96
+ * Count: {globalCount()}
97
+ * </button>
98
+ * }
99
+ * ```
100
+ */
101
+ export { createSignal, type Signal } from './signal'