flexium 0.8.15 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/{DrawText-CeXBL8Ev.d.ts → DrawText-Bvzl40Vi.d.ts} +1 -1
  2. package/dist/{DrawText-JB58mpQT.d.cts → DrawText-CJikXQjL.d.cts} +1 -1
  3. package/dist/advanced.d.cts +3 -1
  4. package/dist/advanced.d.ts +3 -1
  5. package/dist/advanced.js +1 -1
  6. package/dist/advanced.mjs +1 -1
  7. package/dist/advanced.mjs.map +1 -1
  8. package/dist/canvas.d.cts +5 -3
  9. package/dist/canvas.d.ts +5 -3
  10. package/dist/canvas.js +1 -1
  11. package/dist/canvas.mjs +1 -1
  12. package/dist/chunk-6RV7ARJT.mjs +3 -0
  13. package/dist/chunk-6RV7ARJT.mjs.map +1 -0
  14. package/dist/{chunk-CNY6FPKJ.js → chunk-CBO2X74Q.js} +2 -2
  15. package/dist/{chunk-CZYIK6FD.mjs.map → chunk-CBO2X74Q.js.map} +1 -1
  16. package/dist/chunk-GFL4VRAO.mjs +3 -0
  17. package/dist/chunk-GFL4VRAO.mjs.map +1 -0
  18. package/dist/{chunk-MLZTCKTH.mjs → chunk-GQKN4NPW.mjs} +2 -2
  19. package/dist/{chunk-MLZTCKTH.mjs.map → chunk-GQKN4NPW.mjs.map} +1 -1
  20. package/dist/{chunk-CZYIK6FD.mjs → chunk-JDTJFAXO.mjs} +2 -2
  21. package/dist/chunk-JDTJFAXO.mjs.map +1 -0
  22. package/dist/{chunk-ZNPYN2TZ.mjs → chunk-LXXN76HJ.mjs} +2 -2
  23. package/dist/{chunk-ZNPYN2TZ.mjs.map → chunk-LXXN76HJ.mjs.map} +1 -1
  24. package/dist/chunk-MKE3KA43.js +3 -0
  25. package/dist/chunk-MKE3KA43.js.map +1 -0
  26. package/dist/{chunk-DOGIWSDA.js → chunk-PDOEMOWN.js} +2 -2
  27. package/dist/{chunk-DOGIWSDA.js.map → chunk-PDOEMOWN.js.map} +1 -1
  28. package/dist/{chunk-GDBJ322I.js → chunk-RIVNKTUR.js} +2 -2
  29. package/dist/{chunk-GDBJ322I.js.map → chunk-RIVNKTUR.js.map} +1 -1
  30. package/dist/chunk-TQLZ7UZX.js +2 -0
  31. package/dist/chunk-TQLZ7UZX.js.map +1 -0
  32. package/dist/chunk-WEYAKKNF.js +3 -0
  33. package/dist/chunk-WEYAKKNF.js.map +1 -0
  34. package/dist/chunk-WO6NQ3KR.mjs +3 -0
  35. package/dist/chunk-WO6NQ3KR.mjs.map +1 -0
  36. package/dist/chunk-Y4DUMNIW.mjs +2 -0
  37. package/dist/chunk-Y4DUMNIW.mjs.map +1 -0
  38. package/dist/chunk-ZG3LULLU.js +3 -0
  39. package/dist/chunk-ZG3LULLU.js.map +1 -0
  40. package/dist/components-D4WeooPi.d.ts +126 -0
  41. package/dist/components-DZy2r6m5.d.cts +126 -0
  42. package/dist/core.d.cts +159 -15
  43. package/dist/core.d.ts +159 -15
  44. package/dist/core.js +1 -1
  45. package/dist/core.mjs +1 -1
  46. package/dist/dom.d.cts +2 -3
  47. package/dist/dom.d.ts +2 -3
  48. package/dist/dom.js +1 -1
  49. package/dist/dom.js.map +1 -1
  50. package/dist/dom.mjs +1 -1
  51. package/dist/dom.mjs.map +1 -1
  52. package/dist/effect-BlnnM1t5.d.cts +20 -0
  53. package/dist/effect-BlnnM1t5.d.ts +20 -0
  54. package/dist/index.d.cts +2 -2
  55. package/dist/index.d.ts +2 -2
  56. package/dist/index.js +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.mjs +1 -1
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/interactive.d.cts +1 -1
  61. package/dist/interactive.d.ts +1 -1
  62. package/dist/interactive.js +1 -1
  63. package/dist/interactive.mjs +1 -1
  64. package/dist/interactive.mjs.map +1 -1
  65. package/dist/metafile-cjs.json +1 -1
  66. package/dist/metafile-esm.json +1 -1
  67. package/dist/owner-Ce7KCWzi.d.cts +34 -0
  68. package/dist/owner-Ce7KCWzi.d.ts +34 -0
  69. package/dist/{portal-DBwz7gD0.d.ts → portal-C3ESJhlv.d.ts} +1 -1
  70. package/dist/{portal-BpcIlK9y.d.cts → portal-CAEbiMUZ.d.cts} +1 -1
  71. package/dist/primitives/motion.js +1 -1
  72. package/dist/primitives/motion.mjs +1 -1
  73. package/dist/primitives/ui.d.cts +1 -1
  74. package/dist/primitives/ui.d.ts +1 -1
  75. package/dist/primitives/ui.js +1 -1
  76. package/dist/primitives/ui.mjs +1 -1
  77. package/dist/primitives/ui.mjs.map +1 -1
  78. package/dist/primitives.d.cts +6 -4
  79. package/dist/primitives.d.ts +6 -4
  80. package/dist/primitives.js +1 -1
  81. package/dist/primitives.mjs +1 -1
  82. package/dist/router.d.cts +11 -120
  83. package/dist/router.d.ts +11 -120
  84. package/dist/router.js +1 -1
  85. package/dist/router.mjs +1 -1
  86. package/dist/scheduler-Z4QqUDjF.d.cts +25 -0
  87. package/dist/scheduler-Z4QqUDjF.d.ts +25 -0
  88. package/dist/server.js +1 -1
  89. package/dist/server.mjs +1 -1
  90. package/dist/signal-AXKUQJVA.js +2 -0
  91. package/dist/{signal-XZXQ4VYQ.js.map → signal-AXKUQJVA.js.map} +1 -1
  92. package/dist/signal-Dxh9PsKr.d.cts +69 -0
  93. package/dist/signal-Dxh9PsKr.d.ts +69 -0
  94. package/dist/signal-HM2LG5YL.mjs +2 -0
  95. package/dist/{signal-PWBIM6JV.mjs.map → signal-HM2LG5YL.mjs.map} +1 -1
  96. package/dist/test-exports.d.cts +29 -8
  97. package/dist/test-exports.d.ts +29 -8
  98. package/dist/test-exports.js +1 -1
  99. package/dist/test-exports.mjs +1 -1
  100. package/package.json +1 -1
  101. package/dist/chunk-2MVKTSFR.mjs +0 -3
  102. package/dist/chunk-2MVKTSFR.mjs.map +0 -1
  103. package/dist/chunk-2U4DW375.mjs +0 -2
  104. package/dist/chunk-2U4DW375.mjs.map +0 -1
  105. package/dist/chunk-5S3ZQ2LB.mjs +0 -3
  106. package/dist/chunk-5S3ZQ2LB.mjs.map +0 -1
  107. package/dist/chunk-CNY6FPKJ.js.map +0 -1
  108. package/dist/chunk-EX2GURH5.mjs +0 -3
  109. package/dist/chunk-EX2GURH5.mjs.map +0 -1
  110. package/dist/chunk-I7UCVARB.js +0 -2
  111. package/dist/chunk-I7UCVARB.js.map +0 -1
  112. package/dist/chunk-REETNY2Z.js +0 -3
  113. package/dist/chunk-REETNY2Z.js.map +0 -1
  114. package/dist/chunk-ROYFUJN5.js +0 -3
  115. package/dist/chunk-ROYFUJN5.js.map +0 -1
  116. package/dist/chunk-V4K6WOXN.js +0 -3
  117. package/dist/chunk-V4K6WOXN.js.map +0 -1
  118. package/dist/signal-PWBIM6JV.mjs +0 -2
  119. package/dist/signal-XZXQ4VYQ.js +0 -2
  120. package/dist/signal-mNtlF8-v.d.cts +0 -158
  121. package/dist/signal-mNtlF8-v.d.ts +0 -158
  122. package/dist/state-kK9sQh9s.d.cts +0 -73
  123. package/dist/state-kK9sQh9s.d.ts +0 -73
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/state.ts"],"names":["STATE_SIGNAL","toStateObject","res","actions","s","toComputedStateObject","comp","toSignalStateObject","sig","globalStateRegistry","DEV_WARNING_THRESHOLD","hasWarnedAboutSize","currentComponent","setCurrentComponent","instance","createComponentInstance","resetHookIndex","keyCache","serializeKey","key","cached","serialized","error","checkRegistrySize","isStateValue","value","getStateSignal","stateValue","equals","isTruthy","createStateProxy","target","PEEK_PROP","VALUE_OF_PROP","TO_STRING_PROP","TO_JSON_PROP","TO_PRIMITIVE_SYMBOL","_target","prop","_hint","currentValue","propValue","desc","state","initialValueOrFetcher","options","params","hookIndex","savedComponent","result","isAsync","isComputed","proxy","refetch","statusComputed","computed","errorComputed","statusValue","errorValue","newValue","originalFn","fn","resActions","createResource","val","testResult","signal","serializedKey","_state","ref","initialValue"],"mappings":"yCAMO,IAAMA,CAAAA,CAAe,MAA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port type { Signal, Computed, Resource } from './signal'\n\n/** Symbol to identify StateProxy and access underlying signal */\n// Use Symbol.for() to ensure the symbol is shared across module boundaries\n// This is important for Vite dev mode where modules may be loaded separately\nexport const STATE_SIGNAL = Symbol.for('flexium.stateSignal')\n\n/** Internal state object that may be a Signal, Computed, or Resource */\ninterface StateObject {\n value: unknown\n peek: () => unknown\n loading?: boolean\n error?: unknown\n state?: 'unresolved' | 'pending' | 'ready' | 'refreshing' | 'errored'\n latest?: unknown\n\n _stateActions?: StateActions\n _signal?: Signal<unknown> | Computed<unknown> | Resource<unknown>\n _isComputed?: boolean\n}\n\n/** Actions available for state mutation */\ninterface StateActions {\n mutate?: (value: unknown) => void\n refetch?: () => void\n}\n\n/**\n * Type-safe helper to wrap Resource as StateObject.\n * Consolidates unsafe type assertions in one place.\n * @internal\n */\nfunction toStateObject<T>(\n res: Resource<T>,\n actions: { mutate: (v: T | undefined) => void; refetch: () => void }\n): StateObject {\n const s = res as unknown as StateObject\n s._signal = res as Resource<unknown>\n s._stateActions = actions as StateActions\n return s\n}\n\n/**\n * Type-safe helper to create a computed StateObject.\n * @internal\n */\nfunction toComputedStateObject<T>(comp: Computed<T>): StateObject {\n return {\n value: undefined,\n peek: comp.peek,\n _signal: comp as Computed<unknown>,\n _isComputed: true,\n }\n}\n\n/**\n * Type-safe helper to wrap Signal as StateObject.\n * @internal\n */\nfunction toSignalStateObject<T>(sig: Signal<T>): StateObject {\n const s = sig as unknown as StateObject\n s._signal = sig as Signal<unknown>\n return s\n}\n\n// Global registry for keyed states\nconst globalStateRegistry = new Map<string, StateObject>()\n\n// Dev mode warning thresholds\nconst DEV_WARNING_THRESHOLD = 10000\nlet hasWarnedAboutSize = false\n\n// ============================================================================\n// Component Hook System - enables state() inside components\n// ============================================================================\n\ninterface ComponentInstance {\n id: symbol\n hookIndex: number\n hooks: unknown[]\n}\n\nlet currentComponent: ComponentInstance | null = null\n\n/**\n * Set the current component context for hook tracking.\n * Called by the renderer before executing a component function.\n * @internal\n */\nexport function setCurrentComponent(instance: ComponentInstance | null): void {\n currentComponent = instance\n}\n\n/**\n * Get the current component context.\n * @internal\n */\nexport function getCurrentComponent(): ComponentInstance | null {\n return currentComponent\n}\n\n/**\n * Create a new component instance for hook tracking.\n * @internal\n */\nexport function createComponentInstance(): ComponentInstance {\n return {\n id: Symbol('component'),\n hookIndex: 0,\n hooks: [],\n }\n}\n\n/**\n * Reset hook index for re-renders.\n * @internal\n */\nexport function resetHookIndex(instance: ComponentInstance): void {\n instance.hookIndex = 0\n}\n\n/** Key type - string or array of serializable values */\nexport type StateKey = string | readonly (string | number | boolean | null | undefined | object)[]\n\n// Cache for array key serialization to avoid repeated JSON.stringify calls\nconst keyCache = new WeakMap<readonly unknown[], string>()\n\n/**\n * Serialize a key to a string for registry lookup.\n * Arrays are JSON-stringified for consistent comparison.\n * Uses WeakMap cache to avoid repeated serialization of array keys.\n */\nfunction serializeKey(key: StateKey): string {\n if (typeof key === 'string') {\n return key\n }\n\n // Check cache first for array keys\n const cached = keyCache.get(key)\n if (cached !== undefined) {\n return cached\n }\n\n try {\n const serialized = JSON.stringify(key)\n keyCache.set(key, serialized)\n return serialized\n } catch (error) {\n // Handle circular references or other serialization errors\n console.warn('[Flexium] Failed to serialize state key, using fallback:', error)\n const fallback = String(key)\n return fallback\n }\n}\n\n/**\n * Check global state registry size and warn in development mode.\n * Does not enforce hard limits - use state.delete() or state.clear() for cleanup.\n * @internal\n */\nfunction checkRegistrySize(): void {\n const isDev = typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n if (\n isDev &&\n !hasWarnedAboutSize &&\n globalStateRegistry.size >= DEV_WARNING_THRESHOLD\n ) {\n hasWarnedAboutSize = true\n console.warn(\n `[Flexium] Global state registry has ${globalStateRegistry.size} entries. ` +\n `Consider using state.delete(key) to clean up unused states, ` +\n `or state.clear() to reset all global states.`\n )\n }\n}\n\n/** Action function type for state mutation */\nexport type StateAction<T> = (newValue: T | ((prev: T) => T)) => void\n\n/**\n * StateValue type - a value-like proxy that behaves like T.\n * Can be used directly in expressions and JSX.\n */\nexport type StateValue<T> = T & (() => T) & { peek(): T }\n\n/**\n * Check if a value is a StateValue (created by the state() API).\n * Useful for type guards and runtime detection of reactive state.\n * @internal\n * @param value - The value to check\n * @returns true if the value is a StateValue proxy, false otherwise\n *\n * @example\n * ```tsx\n * const count = state(0)\n * isStateValue(count) // true\n * isStateValue(5) // false\n * ```\n */\nexport function isStateValue(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n STATE_SIGNAL in value\n )\n}\n\n/**\n * Get the underlying signal from a StateValue proxy.\n * Used internally for reactive binding detection and DOM updates.\n * @internal\n * @param stateValue - The StateValue proxy to extract the signal from\n * @returns The underlying Signal if stateValue is a StateValue, null otherwise\n *\n * @example\n * ```tsx\n * const count = state(0)\n * const signal = getStateSignal(count) // Returns the internal Signal<number>\n * ```\n */\nexport function getStateSignal(stateValue: unknown): Signal<unknown> | null {\n if (isStateValue(stateValue)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (stateValue as any)[STATE_SIGNAL]\n }\n return null\n}\n\n/**\n * Compare a StateValue with a primitive value safely.\n * Handles Proxy comparison automatically by extracting the underlying value.\n * \n * @param stateValue - The StateValue to compare\n * @param value - The value to compare against\n * @returns true if the StateValue's underlying value equals the comparison value\n * \n * @example\n * ```tsx\n * const [count, setCount] = state(0)\n * \n * // ✅ Safe comparison using helper\n * if (equals(count, 5)) {\n * console.log('Count is 5')\n * }\n * \n * // ❌ Direct comparison (always false)\n * if (count === 5) { ... }\n * ```\n */\nexport function equals<T>(stateValue: StateValue<T>, value: T): boolean {\n if (!isStateValue(stateValue)) {\n return false\n }\n const actualValue = stateValue.peek()\n return actualValue === value\n}\n\n/**\n * Check if a StateValue is truthy.\n * Useful for boolean checks without explicit conversion.\n * \n * @param stateValue - The StateValue to check\n * @returns true if the underlying value is truthy\n * \n * @example\n * ```tsx\n * const [user, setUser] = state<User | null>(null)\n * \n * // ✅ Safe boolean check\n * if (isTruthy(user)) {\n * console.log('User exists:', user.name)\n * }\n * \n * // ❌ Direct check (always true for Proxy)\n * if (user) { ... }\n * ```\n */\nexport function isTruthy<T>(stateValue: StateValue<T>): boolean {\n if (!isStateValue(stateValue)) {\n return false\n }\n return Boolean(stateValue.peek())\n}\n\n/**\n * Create a reactive proxy that behaves like a value but stays reactive.\n * The proxy is also callable - calling it returns the current value.\n * This ensures compatibility with code expecting getter functions.\n * \n * Performance optimization: Cache value and type checks to avoid repeated sig.value calls.\n */\nfunction createStateProxy<T>(sig: Signal<T> | Computed<T>): StateValue<T> {\n // Use an arrow function as the target so the proxy is callable but has no prototype\n // This prevents invariant violations in ownKeys trap\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const target = () => sig.value\n\n // Performance: Cache common property accessors to avoid repeated lookups\n const PEEK_PROP = 'peek'\n const VALUE_OF_PROP = 'valueOf'\n const TO_STRING_PROP = 'toString'\n const TO_JSON_PROP = 'toJSON'\n const TO_PRIMITIVE_SYMBOL = Symbol.toPrimitive\n\n const proxy = new Proxy(target, {\n // Make the proxy callable - returns current value\n apply() {\n return sig.value\n },\n\n get(_target, prop) {\n // Return underlying signal for reactive binding detection\n if (prop === STATE_SIGNAL) {\n return sig\n }\n\n // Allow direct access to peek() without tracking\n if (prop === PEEK_PROP) {\n return sig.peek\n }\n\n // Symbol.toPrimitive - called for +, -, ==, template literals, etc.\n if (prop === TO_PRIMITIVE_SYMBOL) {\n return (_hint: string) => sig.value\n }\n\n // valueOf - called for numeric operations\n if (prop === VALUE_OF_PROP) {\n return () => {\n // Optional dev mode warning for comparison operations\n // Note: This is intentionally minimal to avoid performance overhead\n // Full comparison detection would require stack trace analysis\n const isDev = typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n if (isDev && \n typeof process !== 'undefined' && process.env?.FLEXIUM_WARN_COMPARISON === 'true') {\n // Only warn if explicitly enabled via environment variable\n // Most users should rely on ESLint rules instead\n }\n return sig.value\n }\n }\n\n // toString - called for string concatenation\n if (prop === TO_STRING_PROP) {\n return () => String(sig.value)\n }\n\n // toJSON - called for JSON.stringify\n if (prop === TO_JSON_PROP) {\n return () => sig.value\n }\n\n // Performance: Read value once and cache type check result\n // For object/array values, access properties on current value\n // Note: accessing sig.value here tracks the signal in any enclosing effect\n const currentValue = sig.value\n\n // Performance: Early return for null (most common non-object case)\n if (currentValue === null) {\n return undefined\n }\n\n // Performance: Type check once\n const isObject = typeof currentValue === 'object'\n if (isObject) {\n const obj = currentValue as Record<string | symbol, unknown>\n const propValue = obj[prop]\n // If it's a function (like array methods), bind it to the current value\n if (typeof propValue === 'function') {\n return propValue.bind(currentValue)\n }\n return propValue\n }\n\n return undefined\n },\n\n // For property checks (like 'length' in array)\n has(_target, prop) {\n if (prop === STATE_SIGNAL) return true\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return false\n // Performance: Type check once\n return typeof currentValue === 'object' && prop in (currentValue as object)\n },\n\n // For Object.keys, for...in loops\n ownKeys(_target) {\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return []\n // Performance: Type check once\n if (typeof currentValue === 'object') {\n return Reflect.ownKeys(currentValue as object)\n }\n return []\n },\n\n getOwnPropertyDescriptor(_target, prop) {\n if (prop === STATE_SIGNAL) {\n return { configurable: true, enumerable: false, value: sig }\n }\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return undefined\n // Performance: Type check once\n if (typeof currentValue === 'object') {\n const desc = Object.getOwnPropertyDescriptor(currentValue as object, prop)\n if (desc) {\n // Make it configurable to satisfy Proxy invariants\n return { ...desc, configurable: true }\n }\n }\n return undefined\n },\n })\n\n return proxy as StateValue<T>\n}\n\n/** Async state status */\nexport type AsyncStatus = 'idle' | 'loading' | 'success' | 'error'\n\n/** Options for state() */\nexport interface StateOptions<P = unknown> {\n /**\n * Key for global state sharing. Can be a string or array.\n * Array keys are useful for hierarchical namespacing.\n * @example\n * state('light', { key: 'theme' })\n * state(null, { key: ['user', 'profile', userId] })\n */\n key?: StateKey\n /**\n * Parameters to pass to the function (for computed/async state).\n * Improves DX by making dependencies explicit.\n * @example\n * state(\n * async ({ userId }) => fetch(`/api/users/${userId}`),\n * { key: ['user', userId], params: { userId } }\n * )\n */\n params?: P\n}\n\n/**\n * Unified State API\n *\n * One function for all reactive state needs - always returns an array for consistency:\n * 1. Simple state: const [count, setCount] = state(0)\n * 2. Derived state: const [doubled] = state(() => count * 2)\n * 3. Async state: const [data, refetch, status, error] = state(async () => fetch(...))\n * 4. Global state: const [theme, setTheme] = state('light', { key: 'theme' })\n * 5. With params: const [user] = state(async (p) => fetch(`/api/${p.id}`), { params: { id } })\n *\n * @example\n * ```tsx\n * function Counter() {\n * const [count, setCount] = state(0)\n * const [doubled] = state(() => count * 2)\n * return <Button onPress={() => setCount(count + 1)}>{doubled}</Button>\n * }\n * ```\n */\n// Static methods interface for the state function\ninterface StateFunction {\n // Overloads\n <T>(initialValue: T, options?: StateOptions): [StateValue<T>, StateAction<T>]\n <T, P>(computeFn: (params: P) => T, options: StateOptions<P> & { params: P }): [StateValue<T>]\n <T>(computeFn: () => T, options?: StateOptions): [StateValue<T>]\n <T, P>(fetcher: (params: P) => Promise<T>, options: StateOptions<P> & { params: P }): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n <T>(fetcher: () => Promise<T>, options?: StateOptions): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\n /** Delete a specific global state by key */\n delete: (key: StateKey) => boolean\n /** Clear all global states */\n clear: () => void\n /** Check if a global state exists */\n has: (key: StateKey) => boolean\n /** Current number of global states */\n readonly size: number\n}\n\n// Overload 1: Value → [StateValue, Setter]\nfunction state<T>(\n initialValue: T,\n options?: StateOptions\n): [StateValue<T>, StateAction<T>]\n\n// Overload 2: Sync function with params → [StateValue] (derived, no setter)\nfunction state<T, P>(\n computeFn: (params: P) => T,\n options: StateOptions<P> & { params: P }\n): [StateValue<T>]\n\n// Overload 3: Sync function without params → [StateValue] (derived, no setter)\nfunction state<T>(\n computeFn: () => T,\n options?: StateOptions\n): [StateValue<T>]\n\n// Overload 4: Async function with params → [StateValue, refetch, status, error]\nfunction state<T, P>(\n fetcher: (params: P) => Promise<T>,\n options: StateOptions<P> & { params: P }\n): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\n// Overload 5: Async function without params → [StateValue, refetch, status, error]\nfunction state<T>(\n fetcher: () => Promise<T>,\n options?: StateOptions\n): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\nfunction state<T, P = unknown>(\n initialValueOrFetcher: T | ((params?: P) => T) | ((params?: P) => Promise<T>),\n options?: StateOptions<P>\n): [StateValue<T>] | [StateValue<T>, StateAction<T>] | [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>] {\n const key = options?.key ? serializeKey(options.key) : undefined\n const params = options?.params\n\n // 0. Hook System - reuse state from previous render if inside a component\n if (currentComponent && !key) {\n const comp = currentComponent\n const hookIndex = comp.hookIndex++\n\n // Return existing hook if available\n if (hookIndex < comp.hooks.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return comp.hooks[hookIndex] as any\n }\n\n // Create new state and store in hooks array\n // Temporarily clear currentComponent to avoid infinite recursion\n const savedComponent = currentComponent\n currentComponent = null\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = state(initialValueOrFetcher as any, options as any)\n currentComponent = savedComponent\n\n comp.hooks.push(result)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return result as any\n }\n\n // 1. Check Global Registry for keyed state\n if (key && globalStateRegistry.has(key)) {\n const cached = globalStateRegistry.get(key)!\n const isAsync = 'loading' in cached && cached._stateActions?.refetch !== undefined\n const isComputed = cached._isComputed\n\n const proxy = createStateProxy(cached._signal as Signal<T>)\n\n if (isComputed) {\n return [proxy] as [StateValue<T>]\n }\n\n if (isAsync) {\n const refetch = cached._stateActions?.refetch || (() => { })\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (cached.error) return 'error'\n if (cached.loading) return 'loading'\n if (cached.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => cached.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n return [proxy, refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n const setter: StateAction<T> = (newValue) => {\n if (typeof newValue === 'function') {\n cached.value = (newValue as (prev: T) => T)(cached.peek() as T)\n } else {\n cached.value = newValue\n }\n }\n return [proxy, setter] as [StateValue<T>, StateAction<T>]\n }\n\n // 2. Handle function input (computed or async)\n if (typeof initialValueOrFetcher === 'function') {\n const originalFn = initialValueOrFetcher as (params?: P) => T | Promise<T>\n // Wrap function to inject params if provided\n const fn = params !== undefined\n ? () => originalFn(params)\n : originalFn as () => T | Promise<T>\n\n // Try to detect if it's async by checking constructor name\n // This handles `async () => ...` functions\n const isAsyncFn = originalFn.constructor.name === 'AsyncFunction'\n\n if (isAsyncFn) {\n // Async function → Resource\n const [res, resActions] = createResource(fn, async (val) => val)\n const s = toStateObject(res, resActions)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(s._signal as Signal<T>)\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (s.error) return 'error'\n if (s.loading) return 'loading'\n if (s.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => s.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n\n return [proxy, resActions.refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n // Sync function → Computed\n // First, try running to check if it returns a Promise (for non-async functions that return Promise)\n let testResult: T | Promise<T>\n try {\n testResult = fn()\n } catch {\n // If it throws during initial call, treat as computed (will throw on access)\n const comp = computed(fn as () => T)\n const s = toComputedStateObject(comp)\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n return [createStateProxy(comp)] as [StateValue<T>]\n }\n\n if (testResult instanceof Promise) {\n // It's a Promise-returning function → Resource\n const [res, resActions] = createResource(fn, async (val) => val)\n const s = toStateObject(res, resActions)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(s._signal as Signal<T>)\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (s.error) return 'error'\n if (s.loading) return 'loading'\n if (s.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => s.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n\n return [proxy, resActions.refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n // Sync function → Computed (memoized derived value)\n const comp = computed(fn as () => T)\n const s = toComputedStateObject(comp)\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n return [createStateProxy(comp)] as [StateValue<T>]\n }\n\n // 3. Plain value → Signal with setter\n const sig = signal<T>(initialValueOrFetcher)\n const s = toSignalStateObject(sig)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(sig)\n const setter: StateAction<T> = (newValue) => {\n if (typeof newValue === 'function') {\n sig.value = (newValue as (prev: T) => T)(sig.peek())\n } else {\n sig.value = newValue\n }\n }\n\n return [proxy, setter] as [StateValue<T>, StateAction<T>]\n}\n\n/**\n * Delete a specific global state by key\n * @param key - The key of the state to delete\n * @returns true if the state was deleted, false if it didn't exist\n *\n * @example\n * ```ts\n * state.delete('theme')\n * state.delete(['user', 'profile', userId])\n * ```\n */\nstate.delete = function (key: StateKey): boolean {\n const serializedKey = serializeKey(key)\n return globalStateRegistry.delete(serializedKey)\n}\n\n/**\n * Clear all global states (useful for testing or resetting app)\n *\n * @example\n * ```ts\n * state.clear()\n * ```\n */\nstate.clear = function (): void {\n globalStateRegistry.clear()\n hasWarnedAboutSize = false\n}\n\n/**\n * Check if a global state exists\n * @param key - The key to check\n * @returns true if the state exists\n *\n * @example\n * ```ts\n * if (state.has('theme')) { ... }\n * ```\n */\nstate.has = function (key: StateKey): boolean {\n const serializedKey = serializeKey(key)\n return globalStateRegistry.has(serializedKey)\n}\n\n/**\n * Get the current number of global states\n */\nObject.defineProperty(state, 'size', {\n get: () => globalStateRegistry.size,\n enumerable: true,\n})\n\n// Export with proper typing (cast to include static methods)\nconst _state = state as StateFunction\nexport { _state as state }\n\n/**\n * Ref object type for DOM element references\n */\nexport interface RefObject<T> {\n current: T | null\n}\n\n/**\n * Create a ref object to hold a reference to a DOM element.\n * Use with the `ref` prop on JSX elements.\n *\n * @param initialValue - Initial value (typically null)\n * @returns A ref object with a `current` property\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const inputRef = ref<HTMLInputElement>(null)\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onclick={focusInput}>Focus</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function ref<T>(initialValue: T | null): RefObject<T> {\n return { current: initialValue }\n}\n\n/**\n * Type helper for creating state with explicit type inference.\n * Useful when TypeScript inference fails or you want clearer types.\n * \n * @param initial - Initial value\n * @returns Tuple of [StateValue, StateAction]\n * \n * @example\n * ```tsx\n * // Better type inference in some cases\n * const [user, setUser] = createState<User | null>(null)\n * ```\n */\nexport function createState<T>(initial: T): [StateValue<T>, StateAction<T>] {\n return state(initial)\n}\n\n/**\n * Type helper for creating computed state with explicit type inference.\n * Useful when TypeScript inference fails or you want clearer types.\n * \n * @param fn - Computed function\n * @returns Tuple of [StateValue]\n * \n * @example\n * ```tsx\n * // Better type inference in some cases\n * const [total] = createComputed(() => items.reduce((sum, item) => sum + item.price, 0))\n * ```\n */\nexport function createComputed<T>(fn: () => T): [StateValue<T>] {\n // Use the imported computed from signal.ts, not state() to avoid recursion\n const comp = computed(fn)\n const s = toComputedStateObject(comp)\n return [createStateProxy(comp)] as [StateValue<T>]\n}\n"]}
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunkCBO2X74Q_js=require('./chunk-CBO2X74Q.js'),chunkQ7IWDVJ4_js=require('./chunk-Q7IWDVJ4.js'),chunkMKE3KA43_js=require('./chunk-MKE3KA43.js');function F(){let t=()=>({pathname:"/",search:"",hash:"",query:{}}),e=()=>typeof window>"u"?t():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:$(window.location.search)},r=chunkMKE3KA43_js.k(e()),n=c=>{if(!(typeof window>"u")){if(N(c)){console.error("[Flexium Router] Blocked navigation to unsafe path:",c);return}window.history.pushState({},"",c),r.value=e();}},a=()=>{try{r.value=e();}catch(c){console.error("[Flexium Router] Error handling popstate:",c);}};return typeof window<"u"&&window.addEventListener("popstate",a),[r,n,()=>{typeof window<"u"&&window.removeEventListener("popstate",a);}]}function N(t){let e=t.trim().toLowerCase();return ["javascript:","data:","vbscript:","file:"].some(n=>e.startsWith(n))}function j(t){return t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"")}var O=new Set(["__proto__","constructor","prototype"]);function $(t){let e=new URLSearchParams(t),r=Object.create(null);return e.forEach((n,a)=>{let i=j(a),c=j(n);i&&!O.has(i)&&(r[i]=c);}),r}function B(t,e){let r=[],n=e.replace(/:([^/]+)/g,(l,h)=>(r.push(h),"([^/]+)")),a=new RegExp(`^${n}$`),i=t.match(a);if(!i)return {matches:false,params:{}};let c={};return i.slice(1).forEach((l,h)=>{c[r[h]]=l;}),{matches:true,params:c}}function k(t){let e=[],r=Array.isArray(t)?t:[t];for(let n of r){if(!chunkQ7IWDVJ4_js.c(n))continue;let{path:a,index:i,component:c,beforeEnter:l}=n.props,h=n.children;if(!c&&!h){console.warn(`[Flexium Router] Route "${a||"(index)"}" has no component and no children. Skipping.`);continue}let R={path:a||"",index:!!i,component:c||(()=>null),children:h?k(h):[],beforeEnter:l};e.push(R);}return e}function D(t,e){for(let r of t){let n=S(r,e,"");if(n)return n}return null}function S(t,e,r){let n=r;t.path&&(n=r.replace(/\/$/,"")+"/"+t.path.replace(/^\//,""));let a=t.children.length===0,i=A(n,!a),c=e.match(i);if(c){let[l,...h]=c,R=M(n,h),o={route:t,params:R,pathname:l};if(a)return l===e?[o]:null;for(let f of t.children){let u=S(f,e,n);if(u)return [o,...u]}if(l===e){let f=t.children.find(u=>u.index);return f?[o,{route:f,params:{},pathname:l}]:[o]}}return null}function A(t,e){let r=t.replace(/:([^/]+)/g,()=>"([^/]+)");return r==="/"&&e?new RegExp("^"):new RegExp(`^${r}${e?"(?:/|$)":"$"}`)}function M(t,e){let r={},n=0;return t.replace(/:([^/]+)/g,(a,i)=>(r[i]=e[n++],"")),r}var v=chunkCBO2X74Q_js.a(null),y=chunkCBO2X74Q_js.a(0);function V(){let t=chunkCBO2X74Q_js.b(v);if(!t)throw new Error("router() must be called within a <Router> component");return t}function et(t){let[e,r]=F(),n=Array.isArray(t.children)?t.children:[t.children],a=[],i=[];for(let o of n)chunkQ7IWDVJ4_js.c(o)&&typeof o.type=="function"&&o.type===z?i.push(o):a.push(o);let c=k(i),l=chunkMKE3KA43_js.l(()=>{let o=e();return D(c,o.pathname)||[]}),h=chunkMKE3KA43_js.l(()=>{let o=l();return o.length>0?o[o.length-1].params:{}}),R=new Proxy({location:e,params:h,navigate:r,matches:l},{get(o,f){let u=o[f];if(f==="location"||f==="params"||f==="matches"){let p=u,_=()=>p.value;return new Proxy(_,{apply(){return p.value},get(b,s){if(s==="value")return p.value;if(s==="peek")return p.peek;if(s===Symbol.toPrimitive||s==="toString"||s==="valueOf")return ()=>p.value;let d=p[s];if(typeof d=="function")return d.bind(p);let g=p.value;if(g!==null&&typeof g=="object"){let C=g[s];return typeof C=="function"?C.bind(g):C}return d},has(b,s){if(s==="value"||s==="peek")return true;let d=p.value;return d!==null&&typeof d=="object"?s in d:s in p},ownKeys(b){let s=p.value;return s!==null&&typeof s=="object"?Reflect.ownKeys(s):[]},getOwnPropertyDescriptor(b,s){let d=p.value;if(d!==null&&typeof d=="object"){let g=Object.getOwnPropertyDescriptor(d,s);if(g)return {...g,configurable:true}}}})}return u}});return ()=>{let o=l(),f=null;if(o.length>0){let u=o[0];u.route.beforeEnter?u.route.beforeEnter(u.params)!==false&&(f=chunkQ7IWDVJ4_js.a(y.Provider,{value:1},[chunkQ7IWDVJ4_js.a("div",{key:u.route.path,style:{display:"contents"}},[chunkQ7IWDVJ4_js.a(u.route.component,{params:u.params})])])):f=chunkQ7IWDVJ4_js.a(y.Provider,{value:1},[chunkQ7IWDVJ4_js.a("div",{key:u.route.path,style:{display:"contents"}},[chunkQ7IWDVJ4_js.a(u.route.component,{params:u.params})])]);}return chunkQ7IWDVJ4_js.a(v.Provider,{value:R},[...a,chunkQ7IWDVJ4_js.a("main",{id:"main"},[f])])}}function z(t){return null}function nt(){let t=chunkCBO2X74Q_js.b(v),e=chunkCBO2X74Q_js.b(y);return t?()=>{let r=t.matches();if(e>=r.length)return null;let n=r[e];if(n.route.beforeEnter&&n.route.beforeEnter(n.params)===false)return null;let a=n.route.component;return chunkQ7IWDVJ4_js.a(y.Provider,{value:e+1},[chunkQ7IWDVJ4_js.a(a,{params:n.params})])}:null}function rt(t){let e=V(),r=n=>{n.preventDefault(),e.navigate(t.to);};return chunkQ7IWDVJ4_js.a("a",{href:t.to,class:t.class,onclick:r},t.children)}
2
+ exports.a=F;exports.b=N;exports.c=j;exports.d=B;exports.e=k;exports.f=D;exports.g=V;exports.h=et;exports.i=z;exports.j=nt;exports.k=rt;//# sourceMappingURL=chunk-ZG3LULLU.js.map
3
+ //# sourceMappingURL=chunk-ZG3LULLU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/core.ts","../src/router/utils.ts","../src/router/context.ts","../src/router/components.ts"],"names":["createLocation","getDefaultLoc","getLoc","parseQuery","loc","signal","navigate","path","isUnsafePath","handlePopState","error","normalizedPath","protocol","sanitizeQueryValue","value","DANGEROUS_KEYS","search","params","query","key","sanitizedKey","sanitizedValue","matchPath","pathname","routePath","paramNames","regexPath","_","paramName","regex","match","index","createRoutesFromChildren","children","routes","childArray","child","isFNode","component","beforeEnter","nestedChildren","route","matchRoutes","location","result","matchRouteBranch","parentPath","fullPath","isLeaf","matcher","compilePath","matchedPath","paramValues","paramsObj","extractParams","currentMatch","childMatches","indexRoute","c","prefix","values","i","RouterCtx","createContext","RouteDepthCtx","router","ctx","context","Router","props","nonRouteChildren","routeChildren","Route","matches","computed","m","routerContext","target","prop","_target","innerProp","signalProp","currentValue","objProp","desc","ms","matchedContent","rootMatch","f","_props","Outlet","depth","Component","Link","r","handleClick","e"],"mappings":"iKA8BO,SAASA,CAAAA,EAAyE,CAEvF,IAAMC,CAAAA,CAAgB,KAAiB,CACrC,QAAA,CAAU,GAAA,CACV,MAAA,CAAQ,EAAA,CACR,IAAA,CAAM,EAAA,CACN,KAAA,CAAO,EACT,CAAA,CAAA,CAEMC,CAAAA,CAAS,IACT,OAAO,MAAA,CAAW,GAAA,CACbD,CAAAA,GAEF,CACL,QAAA,CAAU,MAAA,CAAO,QAAA,CAAS,QAAA,CAC1B,MAAA,CAAQ,MAAA,CAAO,QAAA,CAAS,OACxB,IAAA,CAAM,MAAA,CAAO,QAAA,CAAS,IAAA,CACtB,KAAA,CAAOE,CAAAA,CAAW,MAAA,CAAO,QAAA,CAAS,MAAM,CAC1C,CAAA,CAGIC,CAAAA,CAAMC,kBAAAA,CAAOH,CAAAA,EAAQ,CAAA,CAErBI,CAAAA,CAAYC,GAAiB,CAEjC,GAAI,EAAA,OAAO,MAAA,CAAW,GAAA,CAAA,CAGtB,CAAA,GAAIC,CAAAA,CAAaD,C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,OAAA,CAAS0B,CACX,CAAA,CACA1B,CAAAA,CAAM,QACR,CACF","file":"chunk-ZG3LULLU.js","sourcesContent":["/**\n * Router Core Module\n *\n * Provides core routing functionality including location management,\n * path matching, and navigation.\n */\n\nimport { signal, Signal } from '../core/signal'\nimport { Location } from './types'\n\n/**\n * Creates a reactive location signal and navigate function.\n *\n * The location signal automatically updates when:\n * - navigate() is called\n * - Browser back/forward buttons are used (popstate event)\n *\n * @returns Tuple of [location signal, navigate function, cleanup function]\n *\n * @example\n * ```tsx\n * const [location, navigate, cleanup] = createLocation();\n * // Access current path\n * console.log(location().pathname);\n * // Navigate to new path\n * navigate('/users/123');\n * // Cleanup when done (removes popstate listener)\n * cleanup();\n * ```\n */\nexport function createLocation(): [Signal<Location>, (path: string) => void, () => void] {\n // SSR guard: return safe defaults on server\n const getDefaultLoc = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n })\n\n const getLoc = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLoc()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n }\n\n const loc = signal(getLoc())\n\n const navigate = (path: string) => {\n // SSR guard\n if (typeof window === 'undefined') return\n\n // Security: Validate path to prevent javascript: and other dangerous protocols\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n loc.value = getLoc()\n }\n\n // SSR guard for popstate listener\n const handlePopState = () => {\n try {\n loc.value = getLoc()\n } catch (error) {\n console.error('[Flexium Router] Error handling popstate:', error)\n }\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('popstate', handlePopState)\n }\n\n // Cleanup function to remove listener\n const cleanup = () => {\n if (typeof window !== 'undefined') {\n window.removeEventListener('popstate', handlePopState)\n }\n }\n\n return [loc, navigate, cleanup]\n}\n\n/**\n * Check if a path contains unsafe protocols (XSS prevention)\n * @param path - Path to validate\n * @returns true if path is unsafe\n */\nexport function isUnsafePath(path: string): boolean {\n const normalizedPath = path.trim().toLowerCase()\n const unsafeProtocols = ['javascript:', 'data:', 'vbscript:', 'file:']\n return unsafeProtocols.some(protocol => normalizedPath.startsWith(protocol))\n}\n\n/**\n * Sanitize query parameter value to prevent XSS\n * @param value - Query parameter value\n * @returns Sanitized value\n */\nexport function sanitizeQueryValue(value: string): string {\n // Remove potential script tags and event handlers\n return value\n .replace(/<[^>]*>/g, '') // Remove HTML tags\n .replace(/javascript:/gi, '') // Remove javascript: protocol\n .replace(/on\\w+\\s*=/gi, '') // Remove event handlers like onclick=\n}\n\n/**\n * Parses URL search string into key-value object\n * @param search - URL search string (e.g., \"?foo=bar&baz=qux\")\n * @returns Object with query parameters\n */\n// Dangerous keys that could lead to prototype pollution\nconst DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype'])\n\nfunction parseQuery(search: string): Record<string, string> {\n const params = new URLSearchParams(search)\n // Use Object.create(null) to prevent prototype pollution\n const query: Record<string, string> = Object.create(null)\n params.forEach((value, key) => {\n // Sanitize both key and value to prevent XSS\n const sanitizedKey = sanitizeQueryValue(key)\n const sanitizedValue = sanitizeQueryValue(value)\n // Block dangerous keys to prevent prototype pollution\n if (sanitizedKey && !DANGEROUS_KEYS.has(sanitizedKey)) {\n query[sanitizedKey] = sanitizedValue\n }\n })\n return query\n}\n\n/**\n * Matches a pathname against a route pattern.\n *\n * Supports dynamic segments with `:param` syntax.\n *\n * @param pathname - Current URL pathname (e.g., \"/users/123\")\n * @param routePath - Route pattern (e.g., \"/users/:id\")\n * @returns Object with `matches` boolean and extracted `params`\n *\n * @example\n * ```tsx\n * const result = matchPath('/users/123', '/users/:id');\n * // { matches: true, params: { id: '123' } }\n * ```\n */\nexport function matchPath(\n pathname: string,\n routePath: string\n): { matches: boolean; params: Record<string, string> } {\n const paramNames: string[] = []\n const regexPath = routePath.replace(/:([^/]+)/g, (_, paramName) => {\n paramNames.push(paramName)\n return '([^/]+)'\n })\n\n const regex = new RegExp(`^${regexPath}$`)\n const match = pathname.match(regex)\n\n if (!match) {\n return { matches: false, params: {} }\n }\n\n const params: Record<string, string> = {}\n match.slice(1).forEach((value, index) => {\n params[paramNames[index]] = value\n })\n\n return { matches: true, params }\n}\n","import { RouteDef, RouteMatch } from './types'\nimport type { FNodeChild } from '../core/renderer'\nimport { isFNode } from '../renderers/dom/f'\n\n/**\n * Flatten the children of <Router> or <Route> into a route configuration tree.\n * Note: This assumes `children` are FNodes representing <Route> components.\n */\nexport function createRoutesFromChildren(children: FNodeChild): RouteDef[] {\n const routes: RouteDef[] = []\n\n const childArray = Array.isArray(children) ? children : [children]\n\n for (const child of childArray) {\n if (!isFNode(child)) {\n continue\n }\n\n const { path, index, component, beforeEnter } = child.props as {\n path?: string\n index?: boolean\n component?: Function\n beforeEnter?: (\n params: Record<string, string>\n ) => boolean | Promise<boolean>\n }\n const nestedChildren = child.children\n\n // Skip routes without a component (unless they have children as layout routes)\n if (!component && !nestedChildren) {\n console.warn(\n `[Flexium Router] Route \"${path || '(index)'}\" has no component and no children. Skipping.`\n )\n continue\n }\n\n const route: RouteDef = {\n path: path || '',\n index: !!index,\n component: component || (() => null),\n children: nestedChildren ? createRoutesFromChildren(nestedChildren) : [],\n beforeEnter,\n }\n\n routes.push(route)\n }\n\n return routes\n}\n\n/**\n * Match a URL against a route tree.\n * Returns an array of matches (from root to leaf).\n */\nexport function matchRoutes(\n routes: RouteDef[],\n location: string\n): RouteMatch[] | null {\n for (const route of routes) {\n const result = matchRouteBranch(route, location, '')\n if (result) return result\n }\n return null\n}\n\nfunction matchRouteBranch(\n route: RouteDef,\n location: string,\n parentPath: string\n): RouteMatch[] | null {\n let fullPath = parentPath\n if (route.path) {\n fullPath =\n parentPath.replace(/\\/$/, '') + '/' + route.path.replace(/^\\//, '')\n }\n\n const isLeaf = route.children.length === 0\n const matcher = compilePath(fullPath, !isLeaf)\n const match = location.match(matcher)\n\n if (match) {\n const [matchedPath, ...paramValues] = match\n const paramsObj = extractParams(fullPath, paramValues)\n\n const currentMatch: RouteMatch = {\n route,\n params: paramsObj,\n pathname: matchedPath,\n }\n\n if (isLeaf) {\n // Exact match required for leaf\n if (matchedPath === location) return [currentMatch]\n return null\n }\n\n // Has children: try to match one of them\n // If no children match, and this route is an index route?\n // Or if this route matches partially, maybe an index child matches the rest?\n\n for (const child of route.children) {\n const childMatches = matchRouteBranch(child, location, fullPath)\n if (childMatches) {\n return [currentMatch, ...childMatches]\n }\n }\n\n // If no children matched, but we matched exactly this layout route?\n // E.g. /users matches /users layout, and maybe it renders index?\n if (matchedPath === location) {\n // Check for index route\n const indexRoute = route.children.find((c) => c.index)\n if (indexRoute) {\n return [\n currentMatch,\n { route: indexRoute, params: {}, pathname: matchedPath },\n ]\n }\n // Just the layout? Maybe.\n return [currentMatch]\n }\n }\n\n return null\n}\n\nfunction compilePath(path: string, prefix: boolean): RegExp {\n const regexPath = path.replace(/:([^/]+)/g, () => '([^/]+)')\n\n // If path is exactly \"/\", and we want prefix matching, it should match everything\n if (regexPath === '/' && prefix) {\n return new RegExp('^')\n }\n\n // If prefix matching allowed, ensure we match segment boundary\n return new RegExp(`^${regexPath}${prefix ? '(?:/|$)' : '$'}`)\n}\n\nfunction extractParams(path: string, values: string[]): Record<string, string> {\n const params: Record<string, string> = {}\n let i = 0\n // Re-parse to find param names... inefficient but works\n path.replace(/:([^/]+)/g, (_, paramName) => {\n params[paramName] = values[i++]\n return ''\n })\n return params\n}\n","import { createContext } from '../core/context'\nimport { RouterContext } from './types'\n\n// Global Router Context\nexport const RouterCtx = createContext<RouterContext | null>(null)\n\n// Current Route Depth Context (for Outlet)\n// Stores the index of the current match in the `matches` array\nexport const RouteDepthCtx = createContext<number>(0)\n","import { computed, type Signal, type Computed } from '../core/signal'\nimport { createLocation } from './core'\nimport { createRoutesFromChildren, matchRoutes } from './utils'\nimport { LinkProps, RouteProps, RouterContext } from './types'\nimport { f, isFNode } from '../renderers/dom/f'\nimport { RouterCtx, RouteDepthCtx } from './context'\nimport { context } from '../core/context'\nimport type { FNodeChild } from '../core/renderer'\n\n/**\n * Get the current router context.\n * Must be called within a <Router> component.\n *\n * @example\n * ```tsx\n * const r = router()\n * r.navigate('/dashboard')\n * ```\n */\nexport function router(): RouterContext {\n const ctx = context(RouterCtx)\n if (!ctx) {\n throw new Error('router() must be called within a <Router> component')\n }\n return ctx\n}\n\nexport function Router(props: { children: FNodeChild }) {\n const [location, navigate] = createLocation()\n\n // Separate Route children from non-Route children (like Nav, etc.)\n const childArray = Array.isArray(props.children) ? props.children : [props.children]\n const nonRouteChildren: FNodeChild[] = []\n const routeChildren: FNodeChild[] = []\n\n for (const child of childArray) {\n if (isFNode(child) && typeof child.type === 'function' && child.type === Route) {\n routeChildren.push(child)\n } else {\n nonRouteChildren.push(child)\n }\n }\n\n // Parse route configuration from Route children only\n const routes = createRoutesFromChildren(routeChildren)\n\n // Compute matches\n const matches = computed(() => {\n const loc = location()\n return matchRoutes(routes, loc.pathname) || []\n })\n\n const params = computed(() => {\n const m = matches()\n if (m.length > 0) {\n return m[m.length - 1].params\n }\n return {}\n })\n\n // Create routerContext as a stable object\n // The signals (location, params, matches) are already reactive\n // We create a proxy to ensure property access is properly tracked\n // When accessing location, params, or matches, automatically read the signal's value\n // to register subscriptions (similar to how state() proxy works)\n const routerContext: RouterContext = new Proxy({\n location,\n params,\n navigate,\n matches,\n }, {\n get(target, prop) {\n const value = target[prop as keyof RouterContext]\n \n // For signal/computed properties (location, params, matches),\n // return a proxy that automatically reads the signal's value when properties are accessed\n // This makes router() work like state() - property access triggers tracking\n if (prop === 'location' || prop === 'params' || prop === 'matches') {\n const signal = value as Signal<unknown> | Computed<unknown>\n \n // Create a callable target function (like state proxy does)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const target = () => signal.value\n \n // Return a proxy that wraps the signal and automatically reads its value\n // when properties are accessed, ensuring subscriptions are registered\n // This follows the same pattern as state() proxy for consistency\n return new Proxy(target, {\n // Make the proxy callable - returns current value\n apply() {\n return signal.value\n },\n \n get(_target, innerProp) {\n // Accessing .value triggers subscription registration via signal's value getter\n if (innerProp === 'value') {\n return signal.value\n }\n \n // Allow direct access to peek() without tracking\n if (innerProp === 'peek') {\n return signal.peek\n }\n \n // Calling as function also triggers subscription\n if (innerProp === Symbol.toPrimitive || innerProp === 'toString' || innerProp === 'valueOf') {\n return () => signal.value\n }\n \n // For other signal properties (set, etc.), access them normally\n const signalProp = (signal as any)[innerProp]\n if (typeof signalProp === 'function') {\n return signalProp.bind(signal)\n }\n \n // If the signal's value is an object, access its properties\n // This enables r.location.pathname and r.params.id to work and register subscriptions\n // Note: accessing signal.value here tracks the signal in any enclosing effect\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n const obj = currentValue as Record<string | symbol, unknown>\n const objProp = obj[innerProp]\n // If it's a function (like array methods), bind it to the current value\n if (typeof objProp === 'function') {\n return objProp.bind(currentValue)\n }\n return objProp\n }\n \n return signalProp\n },\n \n // For property checks (like 'id' in params)\n has(_target, innerProp) {\n if (innerProp === 'value' || innerProp === 'peek') return true\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n return innerProp in (currentValue as object)\n }\n return innerProp in signal\n },\n \n // For Object.keys, for...in loops\n ownKeys(_target) {\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n return Reflect.ownKeys(currentValue as object)\n }\n return []\n },\n \n getOwnPropertyDescriptor(_target, innerProp) {\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n const desc = Object.getOwnPropertyDescriptor(currentValue as object, innerProp)\n if (desc) {\n return { ...desc, configurable: true }\n }\n }\n return undefined\n }\n })\n }\n \n // For navigate, return as-is\n return value\n }\n }) as RouterContext\n\n return () => {\n const ms = matches()\n\n // Matched route component (or null if no match)\n let matchedContent: FNodeChild = null\n if (ms.length > 0) {\n const rootMatch = ms[0]\n\n // Check beforeEnter guard\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, { value: 1 }, [\n f('div', { key: rootMatch.route.path, style: { display: 'contents' } }, [\n f(rootMatch.route.component, { params: rootMatch.params }),\n ]),\n ])\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, { value: 1 }, [\n f('div', { key: rootMatch.route.path, style: { display: 'contents' } }, [\n f(rootMatch.route.component, { params: rootMatch.params }),\n ]),\n ])\n }\n }\n\n // Render non-Route children (like Nav) and the matched route wrapped in main\n return f(RouterCtx.Provider, { value: routerContext }, [\n ...nonRouteChildren,\n f('main', { id: 'main' }, [matchedContent]),\n ])\n }\n}\n\n/**\n * Route configuration component.\n * Doesn't render anything directly; used by Router to build the route tree.\n */\nexport function Route(_props: RouteProps) {\n return null\n}\n\n/**\n * Renders the child route content.\n */\nexport function Outlet() {\n const router = context(RouterCtx)\n const depth = context(RouteDepthCtx) // Default 0\n\n // Safety check\n if (!router) return null\n\n return () => {\n const ms = router.matches()\n\n // Check if we have a match at this depth\n if (depth >= ms.length) return null\n\n const match = ms[depth]\n\n // Check beforeEnter guard\n if (match.route.beforeEnter) {\n const result = match.route.beforeEnter(match.params)\n if (result === false) return null\n }\n\n const Component = match.route.component\n\n // Render component and provide next depth\n return f(RouteDepthCtx.Provider, { value: depth + 1 }, [\n f(Component, { params: match.params }),\n ])\n }\n}\n\nexport function Link(props: LinkProps) {\n const r = router()\n\n const handleClick = (e: Event) => {\n e.preventDefault()\n r.navigate(props.to)\n }\n\n return f(\n 'a',\n {\n href: props.to,\n class: props.class,\n onclick: handleClick,\n },\n props.children\n )\n}\n"]}
@@ -0,0 +1,126 @@
1
+ import { S as Signal, C as Computed } from './signal-Dxh9PsKr.js';
2
+ import { a as FNodeChild, F as FNode } from './renderer-DSLb-FGg.js';
3
+
4
+ interface Location {
5
+ pathname: string;
6
+ search: string;
7
+ hash: string;
8
+ query: Record<string, string>;
9
+ }
10
+ interface RouterContext {
11
+ location: Signal<Location> | Computed<Location>;
12
+ params: Signal<Record<string, string>> | Computed<Record<string, string>>;
13
+ navigate: (path: string) => void;
14
+ matches: Signal<RouteMatch[]> | Computed<RouteMatch[]>;
15
+ }
16
+ interface RouteProps {
17
+ path?: string;
18
+ index?: boolean;
19
+ component: Function;
20
+ children?: FNodeChild;
21
+ beforeEnter?: (params: Record<string, string>) => boolean | Promise<boolean>;
22
+ }
23
+ interface RouteMatch {
24
+ route: RouteDef;
25
+ params: Record<string, string>;
26
+ pathname: string;
27
+ }
28
+ interface RouteDef {
29
+ path: string;
30
+ index: boolean;
31
+ component: Function;
32
+ children: RouteDef[];
33
+ beforeEnter?: (params: Record<string, string>) => boolean | Promise<boolean>;
34
+ }
35
+ interface LinkProps {
36
+ to: string;
37
+ class?: string;
38
+ children?: FNodeChild;
39
+ }
40
+
41
+ /**
42
+ * Router Core Module
43
+ *
44
+ * Provides core routing functionality including location management,
45
+ * path matching, and navigation.
46
+ */
47
+
48
+ /**
49
+ * Creates a reactive location signal and navigate function.
50
+ *
51
+ * The location signal automatically updates when:
52
+ * - navigate() is called
53
+ * - Browser back/forward buttons are used (popstate event)
54
+ *
55
+ * @returns Tuple of [location signal, navigate function, cleanup function]
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * const [location, navigate, cleanup] = createLocation();
60
+ * // Access current path
61
+ * console.log(location().pathname);
62
+ * // Navigate to new path
63
+ * navigate('/users/123');
64
+ * // Cleanup when done (removes popstate listener)
65
+ * cleanup();
66
+ * ```
67
+ */
68
+ declare function createLocation(): [Signal<Location>, (path: string) => void, () => void];
69
+ /**
70
+ * Check if a path contains unsafe protocols (XSS prevention)
71
+ * @param path - Path to validate
72
+ * @returns true if path is unsafe
73
+ */
74
+ declare function isUnsafePath(path: string): boolean;
75
+ /**
76
+ * Sanitize query parameter value to prevent XSS
77
+ * @param value - Query parameter value
78
+ * @returns Sanitized value
79
+ */
80
+ declare function sanitizeQueryValue(value: string): string;
81
+ /**
82
+ * Matches a pathname against a route pattern.
83
+ *
84
+ * Supports dynamic segments with `:param` syntax.
85
+ *
86
+ * @param pathname - Current URL pathname (e.g., "/users/123")
87
+ * @param routePath - Route pattern (e.g., "/users/:id")
88
+ * @returns Object with `matches` boolean and extracted `params`
89
+ *
90
+ * @example
91
+ * ```tsx
92
+ * const result = matchPath('/users/123', '/users/:id');
93
+ * // { matches: true, params: { id: '123' } }
94
+ * ```
95
+ */
96
+ declare function matchPath(pathname: string, routePath: string): {
97
+ matches: boolean;
98
+ params: Record<string, string>;
99
+ };
100
+
101
+ /**
102
+ * Get the current router context.
103
+ * Must be called within a <Router> component.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * const r = router()
108
+ * r.navigate('/dashboard')
109
+ * ```
110
+ */
111
+ declare function router(): RouterContext;
112
+ declare function Router(props: {
113
+ children: FNodeChild;
114
+ }): () => FNode;
115
+ /**
116
+ * Route configuration component.
117
+ * Doesn't render anything directly; used by Router to build the route tree.
118
+ */
119
+ declare function Route(_props: RouteProps): null;
120
+ /**
121
+ * Renders the child route content.
122
+ */
123
+ declare function Outlet(): (() => FNode | null) | null;
124
+ declare function Link(props: LinkProps): FNode;
125
+
126
+ export { type Location as L, Outlet as O, type RouteDef as R, type RouteMatch as a, type RouterContext as b, type RouteProps as c, type LinkProps as d, createLocation as e, Router as f, Route as g, Link as h, isUnsafePath as i, matchPath as m, router as r, sanitizeQueryValue as s };
@@ -0,0 +1,126 @@
1
+ import { S as Signal, C as Computed } from './signal-Dxh9PsKr.cjs';
2
+ import { a as FNodeChild, F as FNode } from './renderer-DSLb-FGg.cjs';
3
+
4
+ interface Location {
5
+ pathname: string;
6
+ search: string;
7
+ hash: string;
8
+ query: Record<string, string>;
9
+ }
10
+ interface RouterContext {
11
+ location: Signal<Location> | Computed<Location>;
12
+ params: Signal<Record<string, string>> | Computed<Record<string, string>>;
13
+ navigate: (path: string) => void;
14
+ matches: Signal<RouteMatch[]> | Computed<RouteMatch[]>;
15
+ }
16
+ interface RouteProps {
17
+ path?: string;
18
+ index?: boolean;
19
+ component: Function;
20
+ children?: FNodeChild;
21
+ beforeEnter?: (params: Record<string, string>) => boolean | Promise<boolean>;
22
+ }
23
+ interface RouteMatch {
24
+ route: RouteDef;
25
+ params: Record<string, string>;
26
+ pathname: string;
27
+ }
28
+ interface RouteDef {
29
+ path: string;
30
+ index: boolean;
31
+ component: Function;
32
+ children: RouteDef[];
33
+ beforeEnter?: (params: Record<string, string>) => boolean | Promise<boolean>;
34
+ }
35
+ interface LinkProps {
36
+ to: string;
37
+ class?: string;
38
+ children?: FNodeChild;
39
+ }
40
+
41
+ /**
42
+ * Router Core Module
43
+ *
44
+ * Provides core routing functionality including location management,
45
+ * path matching, and navigation.
46
+ */
47
+
48
+ /**
49
+ * Creates a reactive location signal and navigate function.
50
+ *
51
+ * The location signal automatically updates when:
52
+ * - navigate() is called
53
+ * - Browser back/forward buttons are used (popstate event)
54
+ *
55
+ * @returns Tuple of [location signal, navigate function, cleanup function]
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * const [location, navigate, cleanup] = createLocation();
60
+ * // Access current path
61
+ * console.log(location().pathname);
62
+ * // Navigate to new path
63
+ * navigate('/users/123');
64
+ * // Cleanup when done (removes popstate listener)
65
+ * cleanup();
66
+ * ```
67
+ */
68
+ declare function createLocation(): [Signal<Location>, (path: string) => void, () => void];
69
+ /**
70
+ * Check if a path contains unsafe protocols (XSS prevention)
71
+ * @param path - Path to validate
72
+ * @returns true if path is unsafe
73
+ */
74
+ declare function isUnsafePath(path: string): boolean;
75
+ /**
76
+ * Sanitize query parameter value to prevent XSS
77
+ * @param value - Query parameter value
78
+ * @returns Sanitized value
79
+ */
80
+ declare function sanitizeQueryValue(value: string): string;
81
+ /**
82
+ * Matches a pathname against a route pattern.
83
+ *
84
+ * Supports dynamic segments with `:param` syntax.
85
+ *
86
+ * @param pathname - Current URL pathname (e.g., "/users/123")
87
+ * @param routePath - Route pattern (e.g., "/users/:id")
88
+ * @returns Object with `matches` boolean and extracted `params`
89
+ *
90
+ * @example
91
+ * ```tsx
92
+ * const result = matchPath('/users/123', '/users/:id');
93
+ * // { matches: true, params: { id: '123' } }
94
+ * ```
95
+ */
96
+ declare function matchPath(pathname: string, routePath: string): {
97
+ matches: boolean;
98
+ params: Record<string, string>;
99
+ };
100
+
101
+ /**
102
+ * Get the current router context.
103
+ * Must be called within a <Router> component.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * const r = router()
108
+ * r.navigate('/dashboard')
109
+ * ```
110
+ */
111
+ declare function router(): RouterContext;
112
+ declare function Router(props: {
113
+ children: FNodeChild;
114
+ }): () => FNode;
115
+ /**
116
+ * Route configuration component.
117
+ * Doesn't render anything directly; used by Router to build the route tree.
118
+ */
119
+ declare function Route(_props: RouteProps): null;
120
+ /**
121
+ * Renders the child route content.
122
+ */
123
+ declare function Outlet(): (() => FNode | null) | null;
124
+ declare function Link(props: LinkProps): FNode;
125
+
126
+ export { type Location as L, Outlet as O, type RouteDef as R, type RouteMatch as a, type RouterContext as b, type RouteProps as c, type LinkProps as d, createLocation as e, Router as f, Route as g, Link as h, isUnsafePath as i, matchPath as m, router as r, sanitizeQueryValue as s };
package/dist/core.d.cts CHANGED
@@ -1,24 +1,168 @@
1
- export { A as AsyncStatus, S as StateAction, b as StateKey, c as StateOptions, a as StateValue, _ as state } from './state-kK9sQh9s.cjs';
2
- export { d as batch, e as effect, o as onCleanup, b as onMount, r as root, u as untrack } from './signal-mNtlF8-v.cjs';
3
- import { a as FNodeChild } from './renderer-DSLb-FGg.cjs';
1
+ export { e as effect } from './effect-BlnnM1t5.cjs';
4
2
 
5
- interface Context<T> {
6
- id: symbol;
7
- Provider: (props: {
8
- value: T;
9
- children: FNodeChild;
10
- }) => FNodeChild;
11
- defaultValue: T;
3
+ /** Key type - string or array of serializable values */
4
+ type StateKey = string | readonly (string | number | boolean | null | undefined | object)[];
5
+ /** Action function type for state mutation */
6
+ type StateAction<T> = (newValue: T | ((prev: T) => T)) => void;
7
+ /**
8
+ * StateValue type - a value-like proxy that behaves like T.
9
+ * Can be used directly in expressions and JSX.
10
+ */
11
+ type StateValue<T> = T & (() => T) & {
12
+ peek(): T;
13
+ };
14
+ /**
15
+ * Check if a value is a StateValue (created by the state() API).
16
+ * Useful for type guards and runtime detection of reactive state.
17
+ * @internal
18
+ * @param value - The value to check
19
+ * @returns true if the value is a StateValue proxy, false otherwise
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * const count = state(0)
24
+ * isStateValue(count) // true
25
+ * isStateValue(5) // false
26
+ * ```
27
+ */
28
+ declare function isStateValue(value: unknown): boolean;
29
+ /**
30
+ * Compare a StateValue with a primitive value safely.
31
+ * Handles Proxy comparison automatically by extracting the underlying value.
32
+ *
33
+ * @param stateValue - The StateValue to compare
34
+ * @param value - The value to compare against
35
+ * @returns true if the StateValue's underlying value equals the comparison value
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * const [count, setCount] = state(0)
40
+ *
41
+ * // ✅ Safe comparison using helper
42
+ * if (equals(count, 5)) {
43
+ * console.log('Count is 5')
44
+ * }
45
+ *
46
+ * // ❌ Direct comparison (always false)
47
+ * if (count === 5) { ... }
48
+ * ```
49
+ */
50
+ declare function equals<T>(stateValue: StateValue<T>, value: T): boolean;
51
+ /**
52
+ * Check if a StateValue is truthy.
53
+ * Useful for boolean checks without explicit conversion.
54
+ *
55
+ * @param stateValue - The StateValue to check
56
+ * @returns true if the underlying value is truthy
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * const [user, setUser] = state<User | null>(null)
61
+ *
62
+ * // ✅ Safe boolean check
63
+ * if (isTruthy(user)) {
64
+ * console.log('User exists:', user.name)
65
+ * }
66
+ *
67
+ * // ❌ Direct check (always true for Proxy)
68
+ * if (user) { ... }
69
+ * ```
70
+ */
71
+ declare function isTruthy<T>(stateValue: StateValue<T>): boolean;
72
+ /** Async state status */
73
+ type AsyncStatus = 'idle' | 'loading' | 'success' | 'error';
74
+ /** Options for state() */
75
+ interface StateOptions<P = unknown> {
76
+ /**
77
+ * Key for global state sharing. Can be a string or array.
78
+ * Array keys are useful for hierarchical namespacing.
79
+ * @example
80
+ * state('light', { key: 'theme' })
81
+ * state(null, { key: ['user', 'profile', userId] })
82
+ */
83
+ key?: StateKey;
84
+ /**
85
+ * Parameters to pass to the function (for computed/async state).
86
+ * Improves DX by making dependencies explicit.
87
+ * @example
88
+ * state(
89
+ * async ({ userId }) => fetch(`/api/users/${userId}`),
90
+ * { key: ['user', userId], params: { userId } }
91
+ * )
92
+ */
93
+ params?: P;
94
+ }
95
+ /**
96
+ * Unified State API
97
+ *
98
+ * One function for all reactive state needs - always returns an array for consistency:
99
+ * 1. Simple state: const [count, setCount] = state(0)
100
+ * 2. Derived state: const [doubled] = state(() => count * 2)
101
+ * 3. Async state: const [data, refetch, status, error] = state(async () => fetch(...))
102
+ * 4. Global state: const [theme, setTheme] = state('light', { key: 'theme' })
103
+ * 5. With params: const [user] = state(async (p) => fetch(`/api/${p.id}`), { params: { id } })
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * function Counter() {
108
+ * const [count, setCount] = state(0)
109
+ * const [doubled] = state(() => count * 2)
110
+ * return <Button onPress={() => setCount(count + 1)}>{doubled}</Button>
111
+ * }
112
+ * ```
113
+ */
114
+ interface StateFunction {
115
+ <T>(initialValue: T, options?: StateOptions): [StateValue<T>, StateAction<T>];
116
+ <T, P>(computeFn: (params: P) => T, options: StateOptions<P> & {
117
+ params: P;
118
+ }): [StateValue<T>];
119
+ <T>(computeFn: () => T, options?: StateOptions): [StateValue<T>];
120
+ <T, P>(fetcher: (params: P) => Promise<T>, options: StateOptions<P> & {
121
+ params: P;
122
+ }): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
123
+ <T>(fetcher: () => Promise<T>, options?: StateOptions): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
124
+ /** Delete a specific global state by key */
125
+ delete: (key: StateKey) => boolean;
126
+ /** Clear all global states */
127
+ clear: () => void;
128
+ /** Check if a global state exists */
129
+ has: (key: StateKey) => boolean;
130
+ /** Current number of global states */
131
+ readonly size: number;
132
+ }
133
+ declare const _state: StateFunction;
134
+
135
+ /**
136
+ * Ref object type for DOM element references
137
+ */
138
+ interface RefObject<T> {
139
+ current: T | null;
12
140
  }
13
- declare function createContext<T>(defaultValue: T): Context<T>;
14
141
  /**
15
- * Get the current value from a context.
142
+ * Create a ref object to hold a reference to a DOM element.
143
+ * Use with the `ref` prop on JSX elements.
144
+ *
145
+ * @param initialValue - Initial value (typically null)
146
+ * @returns A ref object with a `current` property
16
147
  *
17
148
  * @example
18
149
  * ```tsx
19
- * const theme = context(ThemeContext)
150
+ * function MyComponent() {
151
+ * const inputRef = ref<HTMLInputElement>(null)
152
+ *
153
+ * const focusInput = () => {
154
+ * inputRef.current?.focus()
155
+ * }
156
+ *
157
+ * return (
158
+ * <div>
159
+ * <input ref={inputRef} type="text" />
160
+ * <button onclick={focusInput}>Focus</button>
161
+ * </div>
162
+ * )
163
+ * }
20
164
  * ```
21
165
  */
22
- declare function context<T>(ctx: Context<T>): T;
166
+ declare function ref<T>(initialValue: T | null): RefObject<T>;
23
167
 
24
- export { type Context, context, createContext };
168
+ export { type AsyncStatus, type RefObject, type StateAction, type StateKey, type StateOptions, type StateValue, equals, isStateValue, isTruthy, ref, _state as state };