@askrjs/askr 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -10
- package/dist/chunk-KR6HG7HF.js +38 -0
- package/dist/chunk-KR6HG7HF.js.map +1 -0
- package/dist/{chunk-L7RL4LYV.js → chunk-MIPES65F.js} +1486 -1905
- package/dist/chunk-MIPES65F.js.map +1 -0
- package/dist/{chunk-HIWJVOS4.js → chunk-PFOLLB6A.js} +38 -17
- package/dist/chunk-PFOLLB6A.js.map +1 -0
- package/dist/chunk-QECQ2TF6.js +28 -0
- package/dist/chunk-QECQ2TF6.js.map +1 -0
- package/dist/{chunk-UUM5W2RM.js → chunk-RJWOOUYV.js} +2 -2
- package/dist/chunk-RJWOOUYV.js.map +1 -0
- package/dist/index.cjs +1760 -1972
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -40
- package/dist/index.d.ts +52 -40
- package/dist/index.js +226 -52
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.cjs +9 -3
- package/dist/jsx/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.d.cts +4 -9
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -9
- package/dist/jsx/jsx-dev-runtime.js +10 -4
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.cjs +14 -5
- package/dist/jsx/jsx-runtime.cjs.map +1 -1
- package/dist/jsx/jsx-runtime.d.cts +9 -6
- package/dist/jsx/jsx-runtime.d.ts +9 -6
- package/dist/jsx/jsx-runtime.js +6 -2
- package/dist/{navigate-NLQOZQGM.js → navigate-SDZNA2ZE.js} +5 -5
- package/dist/{route-TVYWYCEJ.js → route-P5YQBT4T.js} +4 -4
- package/dist/{ssr-4ELUFK65.js → ssr-65K3IJ6B.js} +9 -5
- package/dist/{types-DUDmnzD8.d.cts → types-DLTViI21.d.cts} +15 -3
- package/dist/{types-DUDmnzD8.d.ts → types-DLTViI21.d.ts} +15 -3
- package/package.json +5 -3
- package/src/jsx/index.ts +4 -0
- package/src/jsx/jsx-dev-runtime.ts +7 -10
- package/src/jsx/jsx-runtime.ts +23 -11
- package/src/jsx/types.ts +22 -3
- package/src/jsx/utils.ts +19 -0
- package/dist/chunk-4CV4JOE5.js +0 -27
- package/dist/chunk-HIWJVOS4.js.map +0 -1
- package/dist/chunk-L7RL4LYV.js.map +0 -1
- package/dist/chunk-UUM5W2RM.js.map +0 -1
- package/dist/chunk-YNH3D4KW.js +0 -29
- package/dist/chunk-YNH3D4KW.js.map +0 -1
- package/dist/ssr-4ELUFK65.js.map +0 -1
- package/src/jsx/react-jsx-runtime.d.ts +0 -0
- /package/dist/{chunk-4CV4JOE5.js.map → navigate-SDZNA2ZE.js.map} +0 -0
- /package/dist/{navigate-NLQOZQGM.js.map → route-P5YQBT4T.js.map} +0 -0
- /package/dist/{route-TVYWYCEJ.js.map → ssr-65K3IJ6B.js.map} +0 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/state.ts","../src/index.ts","../src/runtime/operations.ts","../src/runtime/resource_cell.ts","../src/app/createApp.ts","../src/router/layouts.ts","../src/components/Link.tsx"],"sourcesContent":["/**\n * State primitive for Askr components\n * Optimized for minimal overhead and fast updates\n *\n * INVARIANTS ENFORCED:\n * - state() only callable during component render (currentInstance exists)\n * - state() called at top-level only (indices must be monotonically increasing)\n * - state values persist across re-renders (stored in stateValues array)\n * - state.set() cannot be called during render (causes infinite loops)\n * - state.set() always enqueues through scheduler (never direct mutation)\n * - state.set() callback (notifyUpdate) always available\n */\n\nimport { globalScheduler } from './scheduler';\nimport {\n getCurrentInstance,\n getNextStateIndex,\n type ComponentInstance,\n} from './component';\nimport { invariant } from '../dev/invariant';\nimport { isBulkCommitActive } from './fastlane';\n\n/**\n * State value holder - callable to read, has set method to update\n * @example\n * const count = state(0);\n * count(); // read: 0\n * count.set(1); // write: triggers re-render\n */\nexport interface State<T> {\n (): T;\n set(value: T): void;\n _hasBeenRead?: boolean; // Internal: track if state has been read during render\n _readers?: Map<ComponentInstance, number>; // Internal: map of readers -> last committed token\n}\n\n/**\n * Creates a local state value for a component\n * Optimized for:\n * - O(1) read performance\n * - Minimal allocation per state\n * - Fast scheduler integration\n *\n * IMPORTANT: state() must be called during component render execution.\n * It captures the current component instance from context.\n * Calling outside a component function will throw an error.\n *\n * @example\n * ```ts\n * // ✅ Correct: called during render\n * export function Counter() {\n * const count = state(0);\n * return { type: 'button', children: [count()] };\n * }\n *\n * // ❌ Wrong: called outside component\n * const count = state(0);\n * export function BadComponent() {\n * return { type: 'div' };\n * }\n * ```\n */\nexport function state<T>(initialValue: T): State<T> {\n // INVARIANT: state() must be called during component render\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'state() can only be called during component render execution. ' +\n 'Move state() calls to the top level of your component function.'\n );\n }\n\n const index = getNextStateIndex();\n const stateValues = instance.stateValues;\n\n // INVARIANT: Detect conditional state() calls by validating index order\n // If indices go backward, state() was called conditionally\n if (index < instance.stateIndexCheck) {\n throw new Error(\n `State index violation: state() call at index ${index}, ` +\n `but previously saw index ${instance.stateIndexCheck}. ` +\n `This happens when state() is called conditionally (inside if/for/etc). ` +\n `Move all state() calls to the top level of your component function, ` +\n `before any conditionals.`\n );\n }\n\n // INVARIANT: stateIndexCheck advances monotonically\n invariant(\n index >= instance.stateIndexCheck,\n '[State] State indices must increase monotonically'\n );\n instance.stateIndexCheck = index;\n\n // INVARIANT: On subsequent renders, validate that state calls happen in same order\n if (instance.firstRenderComplete) {\n // Check if this index was expected based on first render\n if (!instance.expectedStateIndices.includes(index)) {\n throw new Error(\n `Hook order violation: state() called at index ${index}, ` +\n `but this index was not in the first render's sequence [${instance.expectedStateIndices.join(', ')}]. ` +\n `This usually means state() is inside a conditional or loop. ` +\n `Move all state() calls to the top level of your component function.`\n );\n }\n } else {\n // First render - record this index in the expected sequence\n instance.expectedStateIndices.push(index);\n }\n\n // INVARIANT: Reuse existing state if it exists (fast path on re-renders)\n // This ensures state identity and persistence and enforces ownership stability\n if (stateValues[index]) {\n const existing = stateValues[index] as State<T> & {\n _owner?: ComponentInstance;\n };\n // Ownership must be stable: the state cell belongs to the instance that\n // created it and must never change. This checks for accidental reuse.\n if (existing._owner !== instance) {\n throw new Error(\n `State ownership violation: state() called at index ${index} is owned by a different component instance. ` +\n `State ownership is positional and immutable.`\n );\n }\n return existing as State<T>;\n }\n\n // Create new state (slow path, only on first render) — delegated to helper\n const cell = createStateCell(initialValue, instance);\n\n // INVARIANT: Store state in instance for persistence across renders\n stateValues[index] = cell;\n\n return cell;\n}\n\n/**\n * Internal helper: create the backing state cell (value + readers + set semantics)\n * This extraction makes it easier to later split hook wiring from storage.\n */\nfunction createStateCell<T>(\n initialValue: T,\n instance: ComponentInstance\n): State<T> {\n let value = initialValue;\n\n // Per-state reader map: component -> last-committed render token\n const readers = new Map<ComponentInstance, number>();\n\n // Use a function as the state object (callable directly)\n function read(): T {\n (read as State<T>)._hasBeenRead = true;\n\n // Record that the current instance read this state during its in-progress render\n const inst = getCurrentInstance();\n if (inst && inst._currentRenderToken !== undefined) {\n if (!inst._pendingReadStates) inst._pendingReadStates = new Set();\n inst._pendingReadStates.add(read as State<T>);\n }\n\n return value;\n }\n\n // Attach the readers map to the callable so other runtime parts can access it\n (read as State<T>)._readers = readers;\n\n // Record explicit ownership of this state cell. Ownership is the component\n // instance that created the state cell and must never change for the life\n // of the cell. We expose this for runtime invariant checks/tests.\n (read as unknown as { _owner?: ComponentInstance })._owner = instance;\n\n // Attach set method directly to function\n read.set = (newValue: T): void => {\n // INVARIANT: State cannot be mutated during component render\n // (when currentInstance is non-null). It must be scheduled for consistency.\n // NOTE: Skip invariant checks in production for graceful degradation\n const currentInst = getCurrentInstance();\n if (currentInst !== null && process.env.NODE_ENV !== 'production') {\n throw new Error(\n `[Askr] state.set() cannot be called during component render. ` +\n `State mutations during render break the actor model and cause infinite loops. ` +\n `Move state updates to event handlers or use conditional rendering instead.`\n );\n }\n\n // PRODUCTION FALLBACK: Skip state updates during render to prevent infinite loops\n if (currentInst !== null && process.env.NODE_ENV === 'production') {\n return;\n }\n\n // Skip work if value didn't change\n if (Object.is(value, newValue)) return;\n\n // If a bulk commit is active, update backing value only and DO NOT notify or enqueue.\n // Bulk commits must be side-effect silent with respect to runtime notifications.\n if (isBulkCommitActive()) {\n // In bulk commit mode we must be side-effect free: update backing\n // value only and do not notify, enqueue, or log.\n value = newValue;\n return;\n }\n\n // INVARIANT: Update the value\n value = newValue;\n\n // notifyUpdate may be temporarily unavailable (e.g. during hydration).\n // We intentionally avoid logging here to keep the state mutation path\n // side-effect free. The scheduler will process updates when the system\n // is stable.\n\n // After value change, notify only components that *read* this state in their last committed render\n const readersMap = (read as State<T>)._readers as\n | Map<ComponentInstance, number>\n | undefined;\n if (readersMap) {\n for (const [subInst, token] of readersMap) {\n // Only notify if the component's last committed render token matches the token recorded\n // when it last read this state. This ensures we only wake components that actually\n // observed the state in their most recent render.\n if (subInst.lastRenderToken !== token) continue;\n if (!subInst.hasPendingUpdate) {\n // Log enqueue decision for subInst\n\n subInst.hasPendingUpdate = true;\n const subTask = subInst._pendingFlushTask;\n if (subTask) globalScheduler.enqueue(subTask);\n else\n globalScheduler.enqueue(() => {\n subInst.hasPendingUpdate = false;\n subInst.notifyUpdate?.();\n });\n }\n }\n }\n\n // OPTIMIZATION: Batch state updates from the same component within the same event loop tick\n // Only enqueue the owner component if it actually read this state during its last committed render\n const readersMapForOwner = readersMap;\n const ownerRecordedToken = readersMapForOwner?.get(instance);\n const ownerShouldEnqueue =\n // Normal case: owner read this state in last committed render\n ownerRecordedToken !== undefined &&\n instance.lastRenderToken === ownerRecordedToken;\n\n if (ownerShouldEnqueue && !instance.hasPendingUpdate) {\n instance.hasPendingUpdate = true;\n // INVARIANT: All state updates go through scheduler\n // Use prebound task to avoid allocating a closure per update\n // Fallback to a safe closure if the prebound task is not present\n const task = instance._pendingFlushTask;\n if (task) globalScheduler.enqueue(task);\n else\n globalScheduler.enqueue(() => {\n instance.hasPendingUpdate = false;\n instance.notifyUpdate?.();\n });\n }\n };\n\n return read as State<T>;\n}\n","/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { getSignal } from './runtime/component';\nexport { scheduleEventHandler } from './runtime/scheduler';\n\n// Context (spec-defined, currently stubbed)\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Bindings (spec-defined, currently stubbed)\nexport { resource } from './runtime/operations';\nexport type { DataResult } from './runtime/operations';\n\n// App bootstrap (explicit startup APIs)\nexport {\n createApp,\n createIsland,\n createSPA,\n hydrateSPA,\n cleanupApp,\n hasApp,\n} from './app/createApp';\nexport type {\n IslandConfig,\n SPAConfig,\n HydrateSPAConfig,\n} from './app/createApp';\n\n// Routing\n// Public render-time accessor: route() (also supports route registration when called with args)\nexport {\n route,\n setServerLocation,\n type RouteSnapshot,\n type RouteMatch,\n} from './router/route';\nexport { layout } from './router/layouts';\n// Keep route registration utilities available under a distinct name to avoid\n// collision with the render-time accessor.\nexport {\n clearRoutes,\n getRoutes,\n getNamespaceRoutes,\n unloadNamespace,\n getLoadedNamespaces,\n} from './router/route';\nexport { navigate } from './router/navigate';\nexport type { Route, RouteHandler } from './router/route';\n\n// Components\nexport { Link } from './components/Link';\nexport type { LinkProps } from './components/Link';\n\n// Standard library helpers are unstable and not re-exported from core.\n\n// SSR - Server-side rendering (sync-only APIs)\nexport {\n renderToStringSync,\n renderToStringSyncForUrl,\n renderToString,\n renderToStream,\n collectResources,\n resolveResources,\n} from './ssr';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx/jsx-runtime';\n\n// Expose common APIs to globalThis for test-suite compatibility (legacy test patterns)\n// These are safe to export globally and make migrating tests simpler.\nimport { route, getRoutes } from './router/route';\nimport { navigate } from './router/navigate';\nimport {\n createApp,\n createIsland,\n createSPA,\n hydrateSPA,\n} from './app/createApp';\n\nif (typeof globalThis !== 'undefined') {\n const g = globalThis as unknown as Record<string, unknown>;\n if (!g.createApp) g.createApp = createApp;\n if (!g.createIsland) g.createIsland = createIsland;\n if (!g.createSPA) g.createSPA = createSPA;\n if (!g.hydrateSPA) g.hydrateSPA = hydrateSPA;\n if (!g.route) g.route = route;\n if (!g.getRoutes) g.getRoutes = getRoutes;\n if (!g.navigate) g.navigate = navigate;\n}\n\n// Public types\nexport type { Props } from './shared/types';\n","import {\n getCurrentComponentInstance,\n registerMountOperation,\n type ComponentInstance,\n} from './component';\nimport { getCurrentContextFrame } from './context';\nimport { ResourceCell } from './resource_cell';\nimport { state } from './state';\nimport { getDeriveCache } from '../shared/derive_cache';\nimport {\n getCurrentSSRContext,\n throwSSRDataMissing,\n SSRDataMissingError,\n} from '../ssr/context';\nimport { getCurrentRenderData, getNextKey } from '../ssr/data';\n\n// Memoization cache for derive() (centralized)\n\nexport interface DataResult<T> {\n value: T | null;\n pending: boolean;\n error: Error | null;\n refresh(): void;\n}\n\n/**\n * Resource primitive — simple, deterministic async primitive\n * Usage: resource(fn, deps)\n * - fn receives { signal }\n * - captures execution context once at creation (synchronous step only)\n * - executes at most once per generation; stale async results are ignored\n * - refresh() cancels in-flight execution, increments generation and re-runs\n * - exposes { value, pending, error, refresh }\n * - during SSR, async results are disallowed and will throw synchronously\n */\nexport function resource<T>(\n fn: (opts: { signal: AbortSignal }) => Promise<T> | T,\n deps: unknown[] = []\n): DataResult<T> {\n const instance = getCurrentComponentInstance();\n // Create a non-null alias early so it can be used in nested closures\n // without TypeScript complaining about possible null access.\n const inst = instance as ComponentInstance;\n\n if (!instance) {\n // If we're in a synchronous SSR render that has resolved data, use it.\n const renderData = getCurrentRenderData();\n if (renderData) {\n const key = getNextKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n const val = renderData[key] as T;\n return {\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n } as DataResult<T>;\n }\n\n // If we are in an SSR render pass without supplied data, throw for clarity.\n const ssrCtx = getCurrentSSRContext();\n if (ssrCtx) {\n throwSSRDataMissing();\n }\n\n // No active component instance and not in SSR render with data. Return a\n // pending snapshot for non-SSR usage (e.g., runtime usage outside render).\n return {\n value: null,\n pending: true,\n error: null,\n refresh: () => {},\n } as DataResult<T>;\n }\n\n // Internal ResourceCell — pure state machine now moved to its own module\n // to keep component wiring separate and ensure no component access here.\n // (See ./resource_cell.ts)\n\n // If we're in a synchronous SSR render that was supplied resolved data, use it\n const renderData = getCurrentRenderData();\n if (renderData) {\n // Deterministic key generation: the collection step and render step use\n // the same incremental key generation to align resources.\n const key = getNextKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n\n // Commit synchronous value from render data and return a stable snapshot\n const val = renderData[key] as T;\n\n const holder = state<{ cell?: ResourceCell<T>; snapshot: DataResult<T> }>({\n cell: undefined,\n snapshot: {\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n },\n });\n\n const h = holder();\n h.snapshot.value = val;\n h.snapshot.pending = false;\n h.snapshot.error = null;\n holder.set(h);\n return h.snapshot;\n }\n\n // Persist a holder so the snapshot identity is stable across renders.\n const holder = state<{ cell?: ResourceCell<T>; snapshot: DataResult<T> }>({\n cell: undefined,\n snapshot: {\n value: null,\n pending: true,\n error: null,\n refresh: () => {},\n },\n });\n\n const h = holder();\n\n // Initialize cell on first call\n if (!h.cell) {\n const frame = getCurrentContextFrame();\n const cell = new ResourceCell<T>(fn, deps, frame);\n h.cell = cell;\n h.snapshot = cell.snapshot as DataResult<T>;\n\n // Subscribe and schedule component updates when cell changes\n const unsubscribe = cell.subscribe(() => {\n const cur = holder();\n cur.snapshot.value = cell.snapshot.value;\n cur.snapshot.pending = cell.snapshot.pending;\n cur.snapshot.error = cell.snapshot.error;\n holder.set(cur);\n try {\n inst._enqueueRun?.();\n } catch {\n // ignore\n }\n });\n\n // Cleanup on unmount\n inst.cleanupFns.push(() => {\n unsubscribe();\n cell.abort();\n });\n\n // Start immediately (not tied to mount timing); SSR will throw if async\n try {\n // Avoid notifying subscribers synchronously during render — update\n // holder.snapshot in-place instead to prevent state.set() during render.\n cell.start(inst.ssr ?? false, false);\n // If the run completed synchronously, reflect the result into the holder\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n // Do not call holder.set() here — we are still in render; the host\n // component will read the snapshot immediately.\n }\n } catch (err) {\n if (err instanceof SSRDataMissingError) throw err;\n // Synchronous error — reflect into snapshot\n cell.error = err as Error;\n cell.pending = false;\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n // Do not call holder.set() here for the same reason as above\n }\n }\n\n const cell = h.cell!;\n\n // Detect dependency changes and refresh immediately\n const depsChanged =\n !cell.deps ||\n cell.deps.length !== deps.length ||\n cell.deps.some((d, i) => d !== deps[i]);\n\n if (depsChanged) {\n cell.deps = deps.slice();\n cell.generation++;\n cell.pending = true;\n cell.error = null;\n try {\n cell.start(inst.ssr ?? false, false);\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n } catch (err) {\n if (err instanceof SSRDataMissingError) throw err;\n cell.error = err as Error;\n cell.pending = false;\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n }\n\n // Return the stable snapshot object owned by the cell\n return h.snapshot;\n}\n\nexport function derive<TIn, TOut>(\n source:\n | { value: TIn | null; pending?: boolean; error?: Error | null }\n | TIn\n | (() => TIn),\n map: (value: TIn) => TOut\n): TOut | null {\n // Extract the actual value\n let value: TIn;\n if (typeof source === 'function' && !('value' in source)) {\n // It's a function (not a binding object with value property)\n value = (source as () => TIn)();\n } else {\n value = (source as { value?: TIn | null })?.value ?? (source as TIn);\n }\n if (value == null) return null;\n\n // Get or create memoization cache for this component\n const instance = getCurrentComponentInstance();\n if (!instance) {\n // No component context - just compute eagerly\n return map(value as TIn);\n }\n\n // Get or create the cache map for this component\n const cache = getDeriveCache(instance);\n\n // Check if we already have a cached result for this source value\n if (cache.has(value)) {\n return cache.get(value) as TOut;\n }\n\n // Compute and cache the result\n const result = map(value as TIn);\n cache.set(value, result);\n return result;\n}\n\nexport function on(\n target: EventTarget,\n event: string,\n handler: EventListener\n): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the listener to be attached on mount. If the owner is not the\n // root app instance, fail loudly to prevent silent no-op behavior.\n registerMountOperation(() => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] on() may only be used in root components');\n }\n target.addEventListener(event, handler);\n // Return cleanup function\n return () => {\n target.removeEventListener(event, handler);\n };\n });\n}\n\nexport function timer(intervalMs: number, fn: () => void): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the timer to be started on mount. Fail loudly when used outside\n // of the root component to avoid silent no-ops.\n registerMountOperation(() => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] timer() may only be used in root components');\n }\n const id = setInterval(fn, intervalMs);\n // Return cleanup function\n return () => {\n clearInterval(id);\n };\n });\n}\n\nexport function stream<T>(\n _source: unknown,\n _options?: Record<string, unknown>\n): { value: T | null; pending: boolean; error: Error | null } {\n // Stub implementation: no-op.\n return { value: null, pending: true, error: null };\n}\n\nexport function task(\n fn: () => void | (() => void) | Promise<void | (() => void)>\n): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the task to run on mount. Fail loudly when used outside the root\n // component so callers get immediate feedback rather than silent no-op.\n registerMountOperation(async () => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] task() may only be used in root components');\n }\n // Execute the task (may be async) and return its cleanup\n return await fn();\n });\n}\n\n/**\n * Capture the result of a synchronous expression at call time and return a\n * thunk that returns the captured value later. This is a low-level helper for\n * cases where async continuations need to observe a snapshot of values at the\n * moment scheduling occurred.\n *\n * Usage (public API):\n * const snapshot = capture(() => someState());\n * Promise.resolve().then(() => { use(snapshot()); });\n */\nexport function capture<T>(fn: () => T): () => T {\n const value = fn();\n return () => value;\n}\n","import { withAsyncResourceContext, type ContextFrame } from './context';\nimport { logger } from '../dev/logger';\nimport { throwSSRDataMissing } from '../ssr/context';\n\n/**\n * Pure, component-agnostic ResourceCell state machine.\n * - Holds value/pending/error/generation/controller\n * - Exposes a stable `snapshot` object: { value, pending, error, refresh }\n * - Uses `withAsyncResourceContext` to bind the synchronous execution step\n * to a captured frame. Continuations after await do not see the frame.\n */\nexport class ResourceCell<U> {\n value: U | null = null;\n pending = true;\n error: Error | null = null;\n generation = 0;\n controller: AbortController | null = null;\n deps: unknown[] | null = null;\n resourceFrame: ContextFrame | null = null;\n\n private subscribers = new Set<() => void>();\n\n readonly snapshot: {\n value: U | null;\n pending: boolean;\n error: Error | null;\n refresh: () => void;\n };\n\n private readonly fn: (opts: { signal: AbortSignal }) => Promise<U> | U;\n\n constructor(\n fn: (opts: { signal: AbortSignal }) => Promise<U> | U,\n deps: unknown[] | null,\n resourceFrame: ContextFrame | null\n ) {\n this.fn = fn;\n this.deps = deps ? deps.slice() : null;\n this.resourceFrame = resourceFrame;\n this.snapshot = {\n value: null,\n pending: true,\n error: null,\n refresh: () => this.refresh(),\n };\n }\n\n subscribe(cb: () => void): () => void {\n this.subscribers.add(cb);\n return () => this.subscribers.delete(cb);\n }\n\n private notifySubscribers() {\n this.snapshot.value = this.value;\n this.snapshot.pending = this.pending;\n this.snapshot.error = this.error;\n for (const cb of this.subscribers) cb();\n }\n\n start(ssr = false, notify = true) {\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n this.pending = true;\n this.error = null;\n if (notify) this.notifySubscribers();\n\n let result: Promise<U> | U;\n try {\n // Execute only the synchronous step inside the frozen resource frame.\n result = withAsyncResourceContext(this.resourceFrame, () =>\n this.fn({ signal: controller.signal })\n );\n } catch (err) {\n this.pending = false;\n this.error = err as Error;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (!(result instanceof Promise)) {\n this.value = result as U;\n this.pending = false;\n this.error = null;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (ssr) {\n // During SSR async results are disallowed\n throwSSRDataMissing();\n }\n\n (result as Promise<U>)\n .then((val) => {\n if (this.generation !== generation) return;\n if (this.controller !== controller) return;\n this.value = val;\n this.pending = false;\n this.error = null;\n this.notifySubscribers();\n })\n .catch((err) => {\n if (this.generation !== generation) return;\n this.pending = false;\n this.error = err as Error;\n try {\n logger.error('[Askr] Async resource error:', err);\n } catch {\n /* ignore logging errors */\n }\n this.notifySubscribers();\n });\n }\n\n refresh() {\n this.generation++;\n this.controller?.abort();\n this.start();\n }\n\n abort() {\n this.controller?.abort();\n }\n}\n","/**\n * App bootstrap and mount\n */\n\nimport {\n createComponentInstance,\n mountComponent,\n cleanupComponent,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component';\nimport { globalScheduler } from '../runtime/scheduler';\nimport { logger } from '../dev/logger';\nimport { removeAllListeners } from '../renderer/dom';\nimport { registerAppInstance, initializeNavigation } from '../router/navigate';\n\nlet componentIdCounter = 0;\n\n// Track instances by root element to support multiple createApp calls on same root\nconst instancesByRoot = new WeakMap<Element, ComponentInstance>();\n\n// Symbol for storing cleanup on elements\nconst CLEANUP_SYMBOL = Symbol.for('__tempoCleanup__');\n\n// Type for elements that have cleanup functions attached\ninterface ElementWithCleanup extends Element {\n [CLEANUP_SYMBOL]?: () => void;\n}\n\nexport interface AppConfig {\n root: Element | string;\n component: ComponentFunction;\n}\n\n/**\n * Bootstrap and mount app on client\n * Supports both sync and async components\n *\n * If createApp is called multiple times on the same root, the existing instance\n * is reused and its component function is updated. This ensures:\n * - Generation tokens work correctly (old async renders don't overwrite new ones)\n * - State is preserved across updates (if desired)\n * - DOM is diffed/updated rather than replaced\n */\n// Backcompat wrapper for test-suite migration and user feedback.\n// If called with `routes` a hard error is thrown to encourage migration to\n// `createSPA`/`hydrateSPA`. Otherwise, delegate to `createIsland` to preserve\n// legacy single-root enhancement behavior during the migration period.\nexport function createApp(config: AppConfig | SPAConfig): void {\n if (!config || typeof config !== 'object') {\n throw new Error('createApp requires a config object');\n }\n // Routed apps must use createSPA/hydrateSPA explicitly\n if ('routes' in config) {\n throw new Error(\n 'The `createApp` API is removed. Use `createSPA({ root, routes })` for routed apps, or `hydrateSPA({ root, routes })` for SSR hydration.'\n );\n }\n // Treat remaining calls as islands for backwards compatibility during tests\n // and guide users to use `createIsland` in migration docs/tests.\n const appCfg = config as AppConfig;\n createIsland({\n root: appCfg.root,\n component: appCfg.component,\n });\n}\n\nfunction attachCleanupForRoot(\n rootElement: Element,\n instance: ComponentInstance\n) {\n (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL] = () => {\n removeAllListeners(rootElement);\n cleanupComponent(instance as ComponentInstance);\n };\n\n try {\n const descriptor =\n Object.getOwnPropertyDescriptor(rootElement, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(rootElement),\n 'innerHTML'\n ) ||\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(rootElement, 'innerHTML', {\n get: descriptor.get\n ? function (this: Element) {\n return descriptor.get!.call(this);\n }\n : undefined,\n set: function (this: Element, value: string) {\n if (value === '' && instancesByRoot.get(this) === instance) {\n removeAllListeners(rootElement);\n cleanupComponent(instance as ComponentInstance);\n }\n if (descriptor.set) {\n return descriptor.set.call(this, value);\n }\n },\n configurable: true,\n });\n }\n } catch {\n // If Object.defineProperty fails, ignore\n }\n}\n\nfunction mountOrUpdate(rootElement: Element, componentFn: ComponentFunction) {\n // Clean up existing cleanup function before mounting new one\n const existingCleanup = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n if (existingCleanup) existingCleanup();\n\n let instance = instancesByRoot.get(rootElement);\n\n if (instance) {\n removeAllListeners(rootElement);\n cleanupComponent(instance);\n\n instance.fn = componentFn;\n instance.evaluationGeneration++;\n instance.mounted = false;\n instance.expectedStateIndices = [];\n instance.firstRenderComplete = false;\n instance.isRoot = true;\n } else {\n const componentId = String(++componentIdCounter);\n instance = createComponentInstance(\n componentId,\n componentFn,\n {},\n rootElement\n );\n instancesByRoot.set(rootElement, instance);\n instance.isRoot = true;\n }\n\n attachCleanupForRoot(rootElement, instance);\n mountComponent(instance);\n globalScheduler.flush();\n}\n\n// New strongly-typed init functions\nimport type { Route } from '../router/route';\n\nexport type IslandConfig = {\n root: Element | string;\n component: ComponentFunction;\n // Explicitly disallow routes on islands at type level\n routes?: never;\n};\n\nexport type SPAConfig = {\n root: Element | string;\n routes: Route[]; // routes are required\n component?: never;\n};\n\nexport type HydrateSPAConfig = {\n root: Element | string;\n routes: Route[];\n};\n\n/**\n * createIsland: Enhances existing DOM (no router, mounts once)\n */\nexport function createIsland(config: IslandConfig): void {\n if (!config || typeof config !== 'object') {\n throw new Error('createIsland requires a config object');\n }\n if (typeof config.component !== 'function') {\n throw new Error('createIsland: component must be a function');\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Islands must not initialize router or routes\n if ('routes' in config) {\n throw new Error(\n 'createIsland does not accept routes; use createSPA for routed apps'\n );\n }\n\n mountOrUpdate(rootElement, config.component);\n}\n\n/**\n * createSPA: Initializes router and mounts the app with provided route table\n */\nexport async function createSPA(config: SPAConfig): Promise<void> {\n if (!config || typeof config !== 'object') {\n throw new Error('createSPA requires a config object');\n }\n if (!Array.isArray(config.routes) || config.routes.length === 0) {\n throw new Error(\n 'createSPA requires a route table. If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Register routes at startup (clear previous registrations to avoid surprises)\n const { clearRoutes, route, lockRouteRegistration, resolveRoute } =\n await import('../router/route');\n\n clearRoutes();\n for (const r of config.routes) {\n // Using typed Route from router; allow handler functions\n route(r.path, r.handler, r.namespace);\n }\n // Lock registration in production to prevent late registration surprises\n if (process.env.NODE_ENV === 'production') lockRouteRegistration();\n\n // Mount the currently-resolved route handler (if any)\n const path = typeof window !== 'undefined' ? window.location.pathname : '/';\n const resolved = resolveRoute(path);\n if (!resolved) {\n // If no route currently matches, mount an empty placeholder and continue.\n // This supports cases where routes are registered but the current URL is\n // not one of them (common in router tests that navigate programmatically).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `createSPA: no route found for current path (${path}). Mounting empty placeholder; navigation will activate routes when requested.`\n );\n }\n\n // Mount a no-op component until navigation occurs\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }));\n\n // Still register app instance and initialize navigation so future navigations work\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n return;\n }\n\n // Mount resolved handler as the root component\n // Convert resolved.handler to a ComponentFunction-compatible shape\n mountOrUpdate(rootElement, resolved.handler as ComponentFunction);\n\n // Register for navigation and wire up history handling\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n}\n\n/**\n * hydrateSPA: Hydrate server-rendered HTML with explicit routes\n */\nexport async function hydrateSPA(config: HydrateSPAConfig): Promise<void> {\n if (!config || typeof config !== 'object') {\n throw new Error('hydrateSPA requires a config object');\n }\n if (!Array.isArray(config.routes) || config.routes.length === 0) {\n throw new Error(\n 'hydrateSPA requires a route table. If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Capture server HTML for mismatch detection\n const serverHTML = rootElement.innerHTML;\n\n // Register routes for hydration and set server location for deterministic route()\n const {\n clearRoutes,\n route,\n setServerLocation,\n lockRouteRegistration,\n resolveRoute,\n } = await import('../router/route');\n\n clearRoutes();\n for (const r of config.routes) {\n route(r.path, r.handler, r.namespace);\n }\n // Set server location so route() reflects server URL during SSR checks\n const path = typeof window !== 'undefined' ? window.location.pathname : '/';\n setServerLocation(path);\n if (process.env.NODE_ENV === 'production') lockRouteRegistration();\n\n // Resolve handler for current path\n const resolved = resolveRoute(path);\n if (!resolved) {\n throw new Error(`hydrateSPA: no route found for current path (${path}).`);\n }\n\n // Synchronously render expected HTML using SSR helper\n const { renderToStringSync } = await import('../ssr');\n // renderToStringSync takes a zero-arg component factory; wrap the handler to pass params\n const expectedHTML = renderToStringSync(() => {\n const out = resolved.handler(resolved.params);\n return (out ?? {\n type: 'div',\n children: [],\n }) as ReturnType<ComponentFunction>;\n });\n\n // Prefer a DOM-based comparison to avoid false positives from attribute order\n // or whitespace differences between server and expected HTML.\n const serverContainer = document.createElement('div');\n serverContainer.innerHTML = serverHTML;\n const expectedContainer = document.createElement('div');\n expectedContainer.innerHTML = expectedHTML;\n\n if (!serverContainer.isEqualNode(expectedContainer)) {\n throw new Error(\n '[Askr] Hydration mismatch detected. Server HTML does not match expected server-render output.'\n );\n }\n\n // Proceed to mount the client SPA (this will attach listeners and start navigation)\n // Reuse createSPA path but we already registered routes and set server location, so just mount\n // Mount resolved handler\n mountOrUpdate(rootElement, resolved.handler as ComponentFunction);\n\n // Register navigation and instance\n const { registerAppInstance, initializeNavigation } =\n await import('../router/navigate');\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n}\n\nexport async function hydrate(_config: AppConfig): Promise<void> {\n throw new Error(\n 'The legacy `hydrate` API is removed. Use `hydrateSPA({ root, routes })` for SSR hydration with an explicit route table.'\n );\n}\n\n/**\n * Cleanup an app mounted on a root element (element or id).\n * Safe to call multiple times — no-op when nothing is mounted.\n */\nexport function cleanupApp(root: Element | string): void {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return;\n\n const cleanupFn = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n if (typeof cleanupFn === 'function') {\n cleanupFn();\n }\n\n instancesByRoot.delete(rootElement);\n}\n\n/**\n * Check whether an app is mounted on the given root\n */\nexport function hasApp(root: Element | string): boolean {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return false;\n return instancesByRoot.has(rootElement);\n}\n","/**\n * Small layout helper (centralized)\n * Usage: const parent = layout(ParentLayout); route('/parent', () => parent(<Child />));\n *\n * A layout is simply a component that receives `children`.\n * This helper intentionally avoids vnode inspection, heuristics, or double-invocation.\n * Prefer boring, explicit code over cleverness.\n *\n * Example:\n * const Parent = ({ children }: { children?: unknown }) => <div class=\"parent\">{children}</div>;\n * const parent = layout(Parent);\n * route('/parent', () => parent(<div class=\"child\">C</div>));\n */\nexport type Component<P = object> = (\n props: P & { children?: unknown }\n) => unknown;\n\nexport function layout<P>(Layout: Component<P>) {\n return (children?: unknown) =>\n Layout({ children } as P & { children?: unknown });\n}\n","/**\n * Link component for client-side navigation\n */\n\nimport { navigate } from '../router/navigate';\nimport type { JSXElement } from '../jsx/types';\n\nexport interface LinkProps {\n href: string;\n children?: unknown;\n}\n\n/**\n * Link component that prevents default navigation and uses navigate()\n * Provides declarative way to navigate between routes\n *\n * Respects:\n * - Middle-click (opens in new tab)\n * - Ctrl/Cmd+click (opens in new tab)\n * - Shift+click (opens in new window)\n * - Right-click context menu\n */\nexport function Link({ href, children }: LinkProps): JSXElement {\n return {\n type: 'a',\n props: {\n href,\n children,\n onClick: (e: Event) => {\n const event = e as MouseEvent;\n\n // Only handle left-click without modifiers\n // Default button to 0 if undefined (for mock events in tests)\n const button = event.button ?? 0;\n if (\n button !== 0 || // not left-click\n event.ctrlKey || // Ctrl/Cmd+click\n event.metaKey || // Cmd on Mac\n event.shiftKey || // Shift+click\n event.altKey // Alt+click\n ) {\n return; // Let browser handle it (new tab, etc.)\n }\n\n event.preventDefault();\n navigate(href);\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA;AAKA;AACA;AA0CO,SAAS,MAAS,cAA2B;AAElD,QAAM,WAAW,mBAAmB;AACpC,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,QAAQ,kBAAkB;AAChC,QAAM,cAAc,SAAS;AAI7B,MAAI,QAAQ,SAAS,iBAAiB;AACpC,UAAM,IAAI;AAAA,MACR,gDAAgD,KAAK,8BACvB,SAAS,eAAe;AAAA,IAIxD;AAAA,EACF;AAGA;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EACF;AACA,WAAS,kBAAkB;AAG3B,MAAI,SAAS,qBAAqB;AAEhC,QAAI,CAAC,SAAS,qBAAqB,SAAS,KAAK,GAAG;AAClD,YAAM,IAAI;AAAA,QACR,iDAAiD,KAAK,4DACM,SAAS,qBAAqB,KAAK,IAAI,CAAC;AAAA,MAGtG;AAAA,IACF;AAAA,EACF,OAAO;AAEL,aAAS,qBAAqB,KAAK,KAAK;AAAA,EAC1C;AAIA,MAAI,YAAY,KAAK,GAAG;AACtB,UAAM,WAAW,YAAY,KAAK;AAKlC,QAAI,SAAS,WAAW,UAAU;AAChC,YAAM,IAAI;AAAA,QACR,sDAAsD,KAAK;AAAA,MAE7D;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,QAAM,OAAO,gBAAgB,cAAc,QAAQ;AAGnD,cAAY,KAAK,IAAI;AAErB,SAAO;AACT;AAMA,SAAS,gBACP,cACA,UACU;AACV,MAAI,QAAQ;AAGZ,QAAM,UAA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AAE,aAAc,GAAE,eAAe;AACtC,MAAI,CAAC,EAAE,UAAW,GAAE,YAAY;AAChC,MAAI,CAAC,EAAE,WAAY,GAAE,aAAa;AAClC,MAAI,CAAC,EAAE,MAAO,GAAE,QAAQ;AACxB,MAAI,CAAC,EAAE,UAAW,GAAE,YAAY;AAChC,MAAI,CAAC,EAAE,SAAU,GAAE,WAAW;AAChC;","names":["renderData","holder","h","cell","clearRoutes","route","instance","setServerLocation","renderToStringSync","registerAppInstance","initializeNavigation"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtime/state.ts","../src/index.ts","../src/runtime/operations.ts","../src/runtime/resource_cell.ts","../src/shared/derive_cache.ts","../src/boot/index.ts","../src/components/Link.tsx","../src/foundations/layout.ts","../src/foundations/slot.ts","../src/jsx/index.ts","../src/jsx/utils.ts","../src/foundations/portal.ts"],"sourcesContent":["/**\n * State primitive for Askr components\n * Optimized for minimal overhead and fast updates\n *\n * INVARIANTS ENFORCED:\n * - state() only callable during component render (currentInstance exists)\n * - state() called at top-level only (indices must be monotonically increasing)\n * - state values persist across re-renders (stored in stateValues array)\n * - state.set() cannot be called during render (causes infinite loops)\n * - state.set() always enqueues through scheduler (never direct mutation)\n * - state.set() callback (notifyUpdate) always available\n */\n\nimport { globalScheduler } from './scheduler';\nimport {\n getCurrentInstance,\n getNextStateIndex,\n type ComponentInstance,\n} from './component';\nimport { invariant } from '../dev/invariant';\nimport { isBulkCommitActive } from './fastlane-shared';\n\n/**\n * State value holder - callable to read, has set method to update\n * @example\n * const count = state(0);\n * count(); // read: 0\n * count.set(1); // write: triggers re-render\n */\nexport interface State<T> {\n (): T;\n set(value: T): void;\n set(updater: (prev: T) => T): void;\n _hasBeenRead?: boolean; // Internal: track if state has been read during render\n _readers?: Map<ComponentInstance, number>; // Internal: map of readers -> last committed token\n}\n\n/**\n * Creates a local state value for a component\n * Optimized for:\n * - O(1) read performance\n * - Minimal allocation per state\n * - Fast scheduler integration\n *\n * IMPORTANT: state() must be called during component render execution.\n * It captures the current component instance from context.\n * Calling outside a component function will throw an error.\n *\n * @example\n * ```ts\n * // ✅ Correct: called during render\n * export function Counter() {\n * const count = state(0);\n * return { type: 'button', children: [count()] };\n * }\n *\n * // ❌ Wrong: called outside component\n * const count = state(0);\n * export function BadComponent() {\n * return { type: 'div' };\n * }\n * ```\n */\nexport function state<T>(initialValue: T): State<T> {\n // INVARIANT: state() must be called during component render\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'state() can only be called during component render execution. ' +\n 'Move state() calls to the top level of your component function.'\n );\n }\n\n const index = getNextStateIndex();\n const stateValues = instance.stateValues;\n\n // INVARIANT: Detect conditional state() calls by validating index order\n // If indices go backward, state() was called conditionally\n if (index < instance.stateIndexCheck) {\n throw new Error(\n `State index violation: state() call at index ${index}, ` +\n `but previously saw index ${instance.stateIndexCheck}. ` +\n `This happens when state() is called conditionally (inside if/for/etc). ` +\n `Move all state() calls to the top level of your component function, ` +\n `before any conditionals.`\n );\n }\n\n // INVARIANT: stateIndexCheck advances monotonically\n invariant(\n index >= instance.stateIndexCheck,\n '[State] State indices must increase monotonically'\n );\n instance.stateIndexCheck = index;\n\n // INVARIANT: On subsequent renders, validate that state calls happen in same order\n if (instance.firstRenderComplete) {\n // Check if this index was expected based on first render\n if (!instance.expectedStateIndices.includes(index)) {\n throw new Error(\n `Hook order violation: state() called at index ${index}, ` +\n `but this index was not in the first render's sequence [${instance.expectedStateIndices.join(', ')}]. ` +\n `This usually means state() is inside a conditional or loop. ` +\n `Move all state() calls to the top level of your component function.`\n );\n }\n } else {\n // First render - record this index in the expected sequence\n instance.expectedStateIndices.push(index);\n }\n\n // INVARIANT: Reuse existing state if it exists (fast path on re-renders)\n // This ensures state identity and persistence and enforces ownership stability\n if (stateValues[index]) {\n const existing = stateValues[index] as State<T> & {\n _owner?: ComponentInstance;\n };\n // Ownership must be stable: the state cell belongs to the instance that\n // created it and must never change. This checks for accidental reuse.\n if (existing._owner !== instance) {\n throw new Error(\n `State ownership violation: state() called at index ${index} is owned by a different component instance. ` +\n `State ownership is positional and immutable.`\n );\n }\n return existing as State<T>;\n }\n\n // Create new state (slow path, only on first render) — delegated to helper\n const cell = createStateCell(initialValue, instance);\n\n // INVARIANT: Store state in instance for persistence across renders\n stateValues[index] = cell;\n\n return cell;\n}\n\n/**\n * Internal helper: create the backing state cell (value + readers + set semantics)\n * This extraction makes it easier to later split hook wiring from storage.\n */\nfunction createStateCell<T>(\n initialValue: T,\n instance: ComponentInstance\n): State<T> {\n let value = initialValue;\n\n // Per-state reader map: component -> last-committed render token\n const readers = new Map<ComponentInstance, number>();\n\n // Use a function as the state object (callable directly)\n function read(): T {\n (read as State<T>)._hasBeenRead = true;\n\n // Record that the current instance read this state during its in-progress render\n const inst = getCurrentInstance();\n if (inst && inst._currentRenderToken !== undefined) {\n if (!inst._pendingReadStates) inst._pendingReadStates = new Set();\n inst._pendingReadStates.add(read as State<T>);\n }\n\n return value;\n }\n\n // Attach the readers map to the callable so other runtime parts can access it\n (read as State<T>)._readers = readers;\n\n // Record explicit ownership of this state cell. Ownership is the component\n // instance that created the state cell and must never change for the life\n // of the cell. We expose this for runtime invariant checks/tests.\n (read as State<T> & { _owner?: ComponentInstance })._owner = instance;\n\n // Attach set method directly to function\n read.set = (newValueOrUpdater: T | ((prev: T) => T)): void => {\n // INVARIANT: State cannot be mutated during component render\n // (when currentInstance is non-null). It must be scheduled for consistency.\n // NOTE: Skip invariant checks in production for graceful degradation\n const currentInst = getCurrentInstance();\n if (currentInst !== null && process.env.NODE_ENV !== 'production') {\n throw new Error(\n `[Askr] state.set() cannot be called during component render. ` +\n `State mutations during render break the actor model and cause infinite loops. ` +\n `Move state updates to event handlers or use conditional rendering instead.`\n );\n }\n\n // PRODUCTION FALLBACK: Skip state updates during render to prevent infinite loops\n if (currentInst !== null && process.env.NODE_ENV === 'production') {\n return;\n }\n\n // Compute new value if an updater was provided\n let newValue: T;\n if (typeof newValueOrUpdater === 'function') {\n // Note: function-valued state cannot be set directly via a function argument;\n // such an argument is treated as a functional updater (this follows the common\n // convention from other libraries). If you need to store a function as state,\n // wrap it in an object.\n const updater = newValueOrUpdater as (prev: T) => T;\n newValue = updater(value);\n } else {\n newValue = newValueOrUpdater as T;\n }\n\n // Skip work if value didn't change\n if (Object.is(value, newValue)) return;\n\n // If a bulk commit is active, update backing value only and DO NOT notify or enqueue.\n // Bulk commits must be side-effect silent with respect to runtime notifications.\n if (isBulkCommitActive()) {\n // In bulk commit mode we must be side-effect free: update backing\n // value only and do not notify, enqueue, or log.\n value = newValue;\n return;\n }\n\n // INVARIANT: Update the value\n value = newValue;\n\n // notifyUpdate may be temporarily unavailable (e.g. during hydration).\n // We intentionally avoid logging here to keep the state mutation path\n // side-effect free. The scheduler will process updates when the system\n // is stable.\n\n // After value change, notify only components that *read* this state in their last committed render\n const readersMap = (read as State<T>)._readers as\n | Map<ComponentInstance, number>\n | undefined;\n if (readersMap) {\n for (const [subInst, token] of readersMap) {\n // Only notify if the component's last committed render token matches the token recorded\n // when it last read this state. This ensures we only wake components that actually\n // observed the state in their most recent render.\n if (subInst.lastRenderToken !== token) continue;\n if (!subInst.hasPendingUpdate) {\n // Log enqueue decision for subInst\n\n subInst.hasPendingUpdate = true;\n const subTask = subInst._pendingFlushTask;\n if (subTask) globalScheduler.enqueue(subTask);\n else\n globalScheduler.enqueue(() => {\n subInst.hasPendingUpdate = false;\n subInst.notifyUpdate?.();\n });\n }\n }\n }\n\n // OPTIMIZATION: Batch state updates from the same component within the same event loop tick\n // Only enqueue the owner component if it actually read this state during its last committed render\n const readersMapForOwner = readersMap;\n const ownerRecordedToken = readersMapForOwner?.get(instance);\n const ownerShouldEnqueue =\n // Normal case: owner read this state in last committed render\n ownerRecordedToken !== undefined &&\n instance.lastRenderToken === ownerRecordedToken;\n\n if (ownerShouldEnqueue && !instance.hasPendingUpdate) {\n instance.hasPendingUpdate = true;\n // INVARIANT: All state updates go through scheduler\n // Use prebound task to avoid allocating a closure per update\n // Fallback to a safe closure if the prebound task is not present\n const task = instance._pendingFlushTask;\n if (task) globalScheduler.enqueue(task);\n else\n globalScheduler.enqueue(() => {\n instance.hasPendingUpdate = false;\n instance.notifyUpdate?.();\n });\n }\n };\n\n return read as State<T>;\n}\n","/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { getSignal } from './runtime/component';\nexport { scheduleEventHandler } from './runtime/scheduler';\n\n// Context (spec-defined, currently stubbed)\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Bindings (spec-defined, currently stubbed)\nexport { resource, task, derive } from './runtime/operations';\nexport type { DataResult } from './runtime/operations';\n\n// App bootstrap (explicit startup APIs)\nexport {\n createIsland,\n createSPA,\n hydrateSPA,\n cleanupApp,\n hasApp,\n} from './boot';\nexport type { IslandConfig, SPAConfig, HydrateSPAConfig } from './boot';\n\n// Routing\n// Public render-time accessor: route() (also supports route registration when called with args)\nexport {\n route,\n setServerLocation,\n type RouteSnapshot,\n type RouteMatch,\n} from './router/route';\n\n// Keep route registration utilities available under a distinct name to avoid\n// collision with the render-time accessor.\nexport {\n clearRoutes,\n getRoutes,\n getNamespaceRoutes,\n unloadNamespace,\n getLoadedNamespaces,\n} from './router/route';\nexport { navigate } from './router/navigate';\nexport type { Route, RouteHandler } from './router/route';\n\n// Components\nexport { Link } from './components/Link';\nexport type { LinkProps } from './components/Link';\n\n// Foundations (public convenience exports)\nexport { layout } from './foundations/layout';\nexport type { LayoutComponent } from './foundations/layout';\nexport { Slot } from './foundations/slot';\nexport type { SlotProps } from './foundations/slot';\nexport { definePortal } from './foundations/portal';\nexport type { Portal } from './foundations/portal';\n\n// Standard library helpers are unstable and not re-exported from core.\n\n// SSR - Server-side rendering (sync-only APIs)\nexport {\n renderToStringSync,\n renderToStringSyncForUrl,\n renderToString,\n renderToStream,\n collectResources,\n resolveResources,\n} from './ssr';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx/jsx-runtime';\n\n// Expose common APIs to globalThis for test-suite compatibility (legacy test patterns)\n// These are safe to export globally and make migrating tests simpler.\nimport { route, getRoutes } from './router/route';\nimport { navigate } from './router/navigate';\nimport { createIsland, createSPA, hydrateSPA } from './boot';\n\n// Ensure fastlane bridge is initialized for environments (tests/global access)\n// This file exports a side-effectful module that attaches helpers to globalThis.\nimport './runtime/fastlane';\n\nif (typeof globalThis !== 'undefined') {\n const g = globalThis as Record<string, unknown>;\n if (!g.createIsland) g.createIsland = createIsland;\n if (!g.createSPA) g.createSPA = createSPA;\n if (!g.hydrateSPA) g.hydrateSPA = hydrateSPA;\n if (!g.route) g.route = route;\n if (!g.getRoutes) g.getRoutes = getRoutes;\n if (!g.navigate) g.navigate = navigate;\n}\n\n// Public types\nexport type { Props } from './shared/types';\n","import {\n getCurrentComponentInstance,\n registerMountOperation,\n type ComponentInstance,\n} from './component';\nimport { getCurrentContextFrame } from './context';\nimport { ResourceCell } from './resource_cell';\nimport { state } from './state';\nimport { getDeriveCache } from '../shared/derive_cache';\nimport {\n getCurrentSSRContext,\n throwSSRDataMissing,\n SSRDataMissingError,\n} from '../ssr/context';\nimport { getCurrentRenderData, getNextKey } from '../ssr/data';\n\n// Memoization cache for derive() (centralized)\n\nexport interface DataResult<T> {\n value: T | null;\n pending: boolean;\n error: Error | null;\n refresh(): void;\n}\n\n/**\n * Resource primitive — simple, deterministic async primitive\n * Usage: resource(fn, deps)\n * - fn receives { signal }\n * - captures execution context once at creation (synchronous step only)\n * - executes at most once per generation; stale async results are ignored\n * - refresh() cancels in-flight execution, increments generation and re-runs\n * - exposes { value, pending, error, refresh }\n * - during SSR, async results are disallowed and will throw synchronously\n */\nexport function resource<T>(\n fn: (opts: { signal: AbortSignal }) => Promise<T> | T,\n deps: unknown[] = []\n): DataResult<T> {\n const instance = getCurrentComponentInstance();\n // Create a non-null alias early so it can be used in nested closures\n // without TypeScript complaining about possible null access.\n const inst = instance as ComponentInstance;\n\n if (!instance) {\n // If we're in a synchronous SSR render that has resolved data, use it.\n const renderData = getCurrentRenderData();\n if (renderData) {\n const key = getNextKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n const val = renderData[key] as T;\n return {\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n } as DataResult<T>;\n }\n\n // If we are in an SSR render pass without supplied data, throw for clarity.\n const ssrCtx = getCurrentSSRContext();\n if (ssrCtx) {\n throwSSRDataMissing();\n }\n\n // No active component instance and not in SSR render with data. Return a\n // pending snapshot for non-SSR usage (e.g., runtime usage outside render).\n return {\n value: null,\n pending: true,\n error: null,\n refresh: () => {},\n } as DataResult<T>;\n }\n\n // Internal ResourceCell — pure state machine now moved to its own module\n // to keep component wiring separate and ensure no component access here.\n // (See ./resource_cell.ts)\n\n // If we're in a synchronous SSR render that was supplied resolved data, use it\n const renderData = getCurrentRenderData();\n if (renderData) {\n // Deterministic key generation: the collection step and render step use\n // the same incremental key generation to align resources.\n const key = getNextKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n\n // Commit synchronous value from render data and return a stable snapshot\n const val = renderData[key] as T;\n\n const holder = state<{ cell?: ResourceCell<T>; snapshot: DataResult<T> }>({\n cell: undefined,\n snapshot: {\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n },\n });\n\n const h = holder();\n h.snapshot.value = val;\n h.snapshot.pending = false;\n h.snapshot.error = null;\n holder.set(h);\n return h.snapshot;\n }\n\n // Persist a holder so the snapshot identity is stable across renders.\n const holder = state<{ cell?: ResourceCell<T>; snapshot: DataResult<T> }>({\n cell: undefined,\n snapshot: {\n value: null,\n pending: true,\n error: null,\n refresh: () => {},\n },\n });\n\n const h = holder();\n\n // Initialize cell on first call\n if (!h.cell) {\n const frame = getCurrentContextFrame();\n const cell = new ResourceCell<T>(fn, deps, frame);\n // Attach debug label (component name) for richer logs\n cell.ownerName = inst.fn?.name || '<anonymous>';\n h.cell = cell;\n h.snapshot = cell.snapshot as DataResult<T>;\n\n // Subscribe and schedule component updates when cell changes\n const unsubscribe = cell.subscribe(() => {\n const cur = holder();\n cur.snapshot.value = cell.snapshot.value;\n cur.snapshot.pending = cell.snapshot.pending;\n cur.snapshot.error = cell.snapshot.error;\n holder.set(cur);\n try {\n inst._enqueueRun?.();\n } catch {\n // ignore\n }\n });\n\n // Cleanup on unmount\n inst.cleanupFns.push(() => {\n unsubscribe();\n cell.abort();\n });\n\n // Start immediately (not tied to mount timing); SSR will throw if async\n try {\n // Avoid notifying subscribers synchronously during render — update\n // holder.snapshot in-place instead to prevent state.set() during render.\n cell.start(inst.ssr ?? false, false);\n // If the run completed synchronously, reflect the result into the holder\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n // Do not call holder.set() here — we are still in render; the host\n // component will read the snapshot immediately.\n }\n } catch (err) {\n if (err instanceof SSRDataMissingError) throw err;\n // Synchronous error — reflect into snapshot\n cell.error = err as Error;\n cell.pending = false;\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n // Do not call holder.set() here for the same reason as above\n }\n }\n\n const cell = h.cell!;\n\n // Detect dependency changes and refresh immediately\n const depsChanged =\n !cell.deps ||\n cell.deps.length !== deps.length ||\n cell.deps.some((d, i) => d !== deps[i]);\n\n if (depsChanged) {\n cell.deps = deps.slice();\n cell.generation++;\n cell.pending = true;\n cell.error = null;\n try {\n cell.start(inst.ssr ?? false, false);\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n } catch (err) {\n if (err instanceof SSRDataMissingError) throw err;\n cell.error = err as Error;\n cell.pending = false;\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n }\n\n // Return the stable snapshot object owned by the cell\n return h.snapshot;\n}\n\n// Short-form overload: accept a single function that returns the derived value\nexport function derive<TOut>(fn: () => TOut): TOut | null;\n\nexport function derive<TIn, TOut>(\n source:\n | { value: TIn | null; pending?: boolean; error?: Error | null }\n | TIn\n | (() => TIn),\n map?: (value: TIn) => TOut\n): TOut | null {\n // Short-form: derive(() => someExpression)\n if (map === undefined && typeof source === 'function') {\n const value = (source as () => TOut)();\n if (value == null) return null;\n\n const instance = getCurrentComponentInstance();\n if (!instance) {\n return value as TOut;\n }\n\n const cache = getDeriveCache(instance);\n if (cache.has(value as unknown)) return cache.get(value as unknown) as TOut;\n\n cache.set(value as unknown, value as unknown);\n return value as TOut;\n }\n\n // Normal form: derive(source, map)\n // Extract the actual value\n let value: TIn;\n if (typeof source === 'function' && !('value' in source)) {\n // It's a function (not a binding object with value property)\n value = (source as () => TIn)();\n } else {\n value = (source as { value?: TIn | null })?.value ?? (source as TIn);\n }\n if (value == null) return null;\n\n // Get or create memoization cache for this component\n const instance = getCurrentComponentInstance();\n if (!instance) {\n // No component context - just compute eagerly\n return (map as (v: TIn) => TOut)(value as TIn);\n }\n\n // Get or create the cache map for this component\n const cache = getDeriveCache(instance);\n\n // Check if we already have a cached result for this source value\n if (cache.has(value as unknown)) {\n return cache.get(value as unknown) as TOut;\n }\n\n // Compute and cache the result\n const result = (map as (v: TIn) => TOut)(value as TIn);\n cache.set(value as unknown, result as unknown);\n return result;\n}\n\nexport function on(\n target: EventTarget,\n event: string,\n handler: EventListener\n): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the listener to be attached on mount. If the owner is not the\n // root app instance, fail loudly to prevent silent no-op behavior.\n registerMountOperation(() => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] on() may only be used in root components');\n }\n target.addEventListener(event, handler);\n // Return cleanup function\n return () => {\n target.removeEventListener(event, handler);\n };\n });\n}\n\nexport function timer(intervalMs: number, fn: () => void): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the timer to be started on mount. Fail loudly when used outside\n // of the root component to avoid silent no-ops.\n registerMountOperation(() => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] timer() may only be used in root components');\n }\n const id = setInterval(fn, intervalMs);\n // Return cleanup function\n return () => {\n clearInterval(id);\n };\n });\n}\n\nexport function stream<T>(\n _source: unknown,\n _options?: Record<string, unknown>\n): { value: T | null; pending: boolean; error: Error | null } {\n // Stub implementation: no-op.\n return { value: null, pending: true, error: null };\n}\n\nexport function task(\n fn: () => void | (() => void) | Promise<void | (() => void)>\n): void {\n const ownerIsRoot = getCurrentComponentInstance()?.isRoot ?? false;\n // Register the task to run on mount. Fail loudly when used outside the root\n // component so callers get immediate feedback rather than silent no-op.\n registerMountOperation(async () => {\n if (!ownerIsRoot) {\n throw new Error('[Askr] task() may only be used in root components');\n }\n // Execute the task (may be async) and return its cleanup\n return await fn();\n });\n}\n\n/**\n * Capture the result of a synchronous expression at call time and return a\n * thunk that returns the captured value later. This is a low-level helper for\n * cases where async continuations need to observe a snapshot of values at the\n * moment scheduling occurred.\n *\n * Usage (public API):\n * const snapshot = capture(() => someState());\n * Promise.resolve().then(() => { use(snapshot()); });\n */\nexport function capture<T>(fn: () => T): () => T {\n const value = fn();\n return () => value;\n}\n","import { withAsyncResourceContext, type ContextFrame } from './context';\nimport { logger } from '../dev/logger';\nimport { throwSSRDataMissing } from '../ssr/context';\n\n/**\n * Pure, component-agnostic ResourceCell state machine.\n * - Holds value/pending/error/generation/controller\n * - Exposes a stable `snapshot` object: { value, pending, error, refresh }\n * - Uses `withAsyncResourceContext` to bind the synchronous execution step\n * to a captured frame. Continuations after await do not see the frame.\n */\nexport class ResourceCell<U> {\n value: U | null = null;\n pending = true;\n error: Error | null = null;\n generation = 0;\n controller: AbortController | null = null;\n deps: unknown[] | null = null;\n resourceFrame: ContextFrame | null = null;\n\n // Optional debug label set by caller (component name) to improve logs\n ownerName?: string;\n\n private subscribers = new Set<() => void>();\n\n readonly snapshot: {\n value: U | null;\n pending: boolean;\n error: Error | null;\n refresh: () => void;\n };\n\n private readonly fn: (opts: { signal: AbortSignal }) => Promise<U> | U;\n\n constructor(\n fn: (opts: { signal: AbortSignal }) => Promise<U> | U,\n deps: unknown[] | null,\n resourceFrame: ContextFrame | null\n ) {\n this.fn = fn;\n this.deps = deps ? deps.slice() : null;\n this.resourceFrame = resourceFrame;\n this.snapshot = {\n value: null,\n pending: true,\n error: null,\n refresh: () => this.refresh(),\n };\n }\n\n subscribe(cb: () => void): () => void {\n this.subscribers.add(cb);\n return () => this.subscribers.delete(cb);\n }\n\n private notifySubscribers() {\n this.snapshot.value = this.value;\n this.snapshot.pending = this.pending;\n this.snapshot.error = this.error;\n for (const cb of this.subscribers) cb();\n }\n\n start(ssr = false, notify = true) {\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n this.pending = true;\n this.error = null;\n if (notify) this.notifySubscribers();\n\n let result: Promise<U> | U;\n try {\n // Execute only the synchronous step inside the frozen resource frame.\n result = withAsyncResourceContext(this.resourceFrame, () =>\n this.fn({ signal: controller.signal })\n );\n } catch (err) {\n this.pending = false;\n this.error = err as Error;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (!(result instanceof Promise)) {\n this.value = result as U;\n this.pending = false;\n this.error = null;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (ssr) {\n // During SSR async results are disallowed\n throwSSRDataMissing();\n }\n\n (result as Promise<U>)\n .then((val) => {\n if (this.generation !== generation) return;\n if (this.controller !== controller) return;\n this.value = val;\n this.pending = false;\n this.error = null;\n this.notifySubscribers();\n })\n .catch((err) => {\n if (this.generation !== generation) return;\n this.pending = false;\n this.error = err as Error;\n try {\n if (this.ownerName) {\n logger.error(\n `[Askr] Async resource error in ${this.ownerName}:`,\n err\n );\n } else {\n logger.error('[Askr] Async resource error:', err);\n }\n } catch {\n /* ignore logging errors */\n }\n this.notifySubscribers();\n });\n }\n\n refresh() {\n this.generation++;\n this.controller?.abort();\n this.start();\n }\n\n abort() {\n this.controller?.abort();\n }\n}\n","// Centralized memoization cache for derive()\n// Maps (component_instance) -> Map<source_value, result>\nconst deriveCacheMap = new WeakMap<{ id: string }, Map<unknown, unknown>>();\n\nexport function getDeriveCache(instance: {\n id: string;\n}): Map<unknown, unknown> {\n let cache = deriveCacheMap.get(instance);\n if (!cache) {\n cache = new Map();\n deriveCacheMap.set(instance, cache);\n }\n return cache;\n}\n","/**\n * App bootstrap and mount\n */\n\nimport {\n createComponentInstance,\n mountComponent,\n cleanupComponent,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component';\nimport { globalScheduler } from '../runtime/scheduler';\nimport { logger } from '../dev/logger';\nimport { registerAppInstance, initializeNavigation } from '../router/navigate';\n\nlet componentIdCounter = 0;\n\n// Track instances by root element to support multiple createIsland calls on same root\nconst instancesByRoot = new WeakMap<Element, ComponentInstance>();\n\n// Symbol for storing cleanup on elements\nconst CLEANUP_SYMBOL = Symbol.for('__tempoCleanup__');\n\n// Type for elements that have cleanup functions attached\ninterface ElementWithCleanup extends Element {\n [CLEANUP_SYMBOL]?: () => void;\n}\n\nexport interface AppConfig {\n root: Element | string;\n component: ComponentFunction;\n // Opt-in: surface cleanup errors during teardown for this app instance\n cleanupStrict?: boolean;\n}\n\nfunction attachCleanupForRoot(\n rootElement: Element,\n instance: ComponentInstance\n) {\n (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL] = () => {\n // Attempt to remove listeners and cleanup instances under the root.\n // In non-strict mode we preserve previous behavior by swallowing errors\n // (but logging in dev); in strict mode we aggregate and re-throw.\n const errors: unknown[] = [];\n try {\n removeAllListeners(rootElement);\n } catch (e) {\n errors.push(e);\n }\n\n // Manually traverse descendants and attempt to cleanup their instances.\n // Avoids import cycles by using local traversal and existing cleanupComponent.\n try {\n const descendants = rootElement.querySelectorAll('*');\n for (const d of Array.from(descendants)) {\n try {\n const inst = (d as Element & { __ASKR_INSTANCE?: ComponentInstance })\n .__ASKR_INSTANCE;\n if (inst) {\n try {\n cleanupComponent(inst);\n } catch (err) {\n errors.push(err);\n }\n try {\n delete (d as Element & { __ASKR_INSTANCE?: ComponentInstance })\n .__ASKR_INSTANCE;\n } catch (err) {\n errors.push(err);\n }\n }\n } catch (err) {\n errors.push(err);\n }\n }\n } catch (e) {\n errors.push(e);\n }\n\n try {\n cleanupComponent(instance as ComponentInstance);\n } catch (e) {\n errors.push(e);\n }\n\n if (errors.length > 0) {\n if (instance.cleanupStrict) {\n throw new AggregateError(errors, `cleanup failed for app root`);\n } else if (process.env.NODE_ENV !== 'production') {\n for (const err of errors) logger.warn('[Askr] cleanup error:', err);\n }\n }\n };\n\n try {\n const descriptor =\n Object.getOwnPropertyDescriptor(rootElement, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(rootElement),\n 'innerHTML'\n ) ||\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(rootElement, 'innerHTML', {\n get: descriptor.get\n ? function (this: Element) {\n return descriptor.get!.call(this);\n }\n : undefined,\n set: function (this: Element, value: string) {\n if (value === '' && instancesByRoot.get(this) === instance) {\n try {\n removeAllListeners(rootElement);\n } catch (e) {\n if (instance.cleanupStrict) throw e;\n if (process.env.NODE_ENV !== 'production')\n logger.warn('[Askr] cleanup error:', e);\n }\n\n try {\n cleanupComponent(instance as ComponentInstance);\n } catch (e) {\n if (instance.cleanupStrict) throw e;\n if (process.env.NODE_ENV !== 'production')\n logger.warn('[Askr] cleanup error:', e);\n }\n }\n if (descriptor.set) {\n return descriptor.set.call(this, value);\n }\n },\n configurable: true,\n });\n }\n } catch {\n // If Object.defineProperty fails, ignore\n }\n}\n\n/**\n * Explicitly teardown an app mounted on `root` if present. This is the\n * recommended API for deterministic cleanup rather than relying on overriding\n * `innerHTML` setter behavior.\n */\nexport function teardownApp(_root: Element | string) {\n throw new Error(\n 'The `teardownApp` alias has been removed. Use `cleanupApp(root)` instead.'\n );\n}\n\nfunction mountOrUpdate(\n rootElement: Element,\n componentFn: ComponentFunction,\n options?: { cleanupStrict?: boolean }\n) {\n // Clean up existing cleanup function before mounting new one\n const existingCleanup = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n if (existingCleanup) existingCleanup();\n\n let instance = instancesByRoot.get(rootElement);\n\n if (instance) {\n removeAllListeners(rootElement);\n try {\n cleanupComponent(instance);\n } catch (e) {\n // If previous cleanup threw in strict mode, log but continue mounting new instance\n if (process.env.NODE_ENV !== 'production')\n logger.warn('[Askr] prior cleanup threw:', e);\n }\n\n instance.fn = componentFn;\n instance.evaluationGeneration++;\n instance.mounted = false;\n instance.expectedStateIndices = [];\n instance.firstRenderComplete = false;\n instance.isRoot = true;\n // Update strict flag if provided\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n } else {\n const componentId = String(++componentIdCounter);\n instance = createComponentInstance(\n componentId,\n componentFn,\n {},\n rootElement\n );\n instancesByRoot.set(rootElement, instance);\n instance.isRoot = true;\n // Initialize strict flag from options\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n }\n\n attachCleanupForRoot(rootElement, instance);\n mountComponent(instance);\n globalScheduler.flush();\n}\n\n// New strongly-typed init functions\nimport type { Route } from '../router/route';\nimport { removeAllListeners } from '../renderer';\n\nexport type IslandConfig = {\n root: Element | string;\n component: ComponentFunction;\n // Optional: surface cleanup errors during teardown for this island\n cleanupStrict?: boolean;\n // Explicitly disallow routes on islands at type level\n routes?: never;\n};\n\nexport type SPAConfig = {\n root: Element | string;\n routes: Route[]; // routes are required\n // Optional: surface cleanup errors during teardown for this SPA\n cleanupStrict?: boolean;\n component?: never;\n};\n\nexport type HydrateSPAConfig = {\n root: Element | string;\n routes: Route[];\n // Optional: surface cleanup errors during teardown for this SPA\n cleanupStrict?: boolean;\n};\n\n/**\n * createIsland: Enhances existing DOM (no router, mounts once)\n */\nexport function createIsland(config: IslandConfig): void {\n if (!config || typeof config !== 'object') {\n throw new Error('createIsland requires a config object');\n }\n if (typeof config.component !== 'function') {\n throw new Error('createIsland: component must be a function');\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Islands must not initialize router or routes\n if ('routes' in config) {\n throw new Error(\n 'createIsland does not accept routes; use createSPA for routed apps'\n );\n }\n\n mountOrUpdate(rootElement, config.component, {\n cleanupStrict: config.cleanupStrict,\n });\n}\n\n/**\n * createSPA: Initializes router and mounts the app with provided route table\n */\nexport async function createSPA(config: SPAConfig): Promise<void> {\n if (!config || typeof config !== 'object') {\n throw new Error('createSPA requires a config object');\n }\n if (!Array.isArray(config.routes) || config.routes.length === 0) {\n throw new Error(\n 'createSPA requires a route table. If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Register routes at startup (clear previous registrations to avoid surprises)\n const { clearRoutes, route, lockRouteRegistration, resolveRoute } =\n await import('../router/route');\n\n clearRoutes();\n for (const r of config.routes) {\n // Using typed Route from router; allow handler functions\n route(r.path, r.handler, r.namespace);\n }\n // Lock registration in production to prevent late registration surprises\n if (process.env.NODE_ENV === 'production') lockRouteRegistration();\n\n // Mount the currently-resolved route handler (if any)\n const path = typeof window !== 'undefined' ? window.location.pathname : '/';\n const resolved = resolveRoute(path);\n if (!resolved) {\n // If no route currently matches, mount an empty placeholder and continue.\n // This supports cases where routes are registered but the current URL is\n // not one of them (common in router tests that navigate programmatically).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `createSPA: no route found for current path (${path}). Mounting empty placeholder; navigation will activate routes when requested.`\n );\n }\n\n // Mount a no-op component until navigation occurs\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }), {\n cleanupStrict: false,\n });\n\n // Still register app instance and initialize navigation so future navigations work\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n return;\n }\n\n // Mount resolved handler as the root component\n // Convert resolved.handler to a ComponentFunction-compatible shape\n mountOrUpdate(rootElement, resolved.handler as ComponentFunction, {\n cleanupStrict: false,\n });\n\n // Register for navigation and wire up history handling\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n}\n\n/**\n * hydrateSPA: Hydrate server-rendered HTML with explicit routes\n */\nexport async function hydrateSPA(config: HydrateSPAConfig): Promise<void> {\n if (!config || typeof config !== 'object') {\n throw new Error('hydrateSPA requires a config object');\n }\n if (!Array.isArray(config.routes) || config.routes.length === 0) {\n throw new Error(\n 'hydrateSPA requires a route table. If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Capture server HTML for mismatch detection\n const serverHTML = rootElement.innerHTML;\n\n // Register routes for hydration and set server location for deterministic route()\n const {\n clearRoutes,\n route,\n setServerLocation,\n lockRouteRegistration,\n resolveRoute,\n } = await import('../router/route');\n\n clearRoutes();\n for (const r of config.routes) {\n route(r.path, r.handler, r.namespace);\n }\n // Set server location so route() reflects server URL during SSR checks\n const path = typeof window !== 'undefined' ? window.location.pathname : '/';\n setServerLocation(path);\n if (process.env.NODE_ENV === 'production') lockRouteRegistration();\n\n // Resolve handler for current path\n const resolved = resolveRoute(path);\n if (!resolved) {\n throw new Error(`hydrateSPA: no route found for current path (${path}).`);\n }\n\n // Synchronously render expected HTML using SSR helper\n const { renderToStringSync } = await import('../ssr');\n // renderToStringSync takes a zero-arg component factory; wrap the handler to pass params\n const expectedHTML = renderToStringSync(() => {\n const out = resolved.handler(resolved.params);\n return (out ?? {\n type: 'div',\n children: [],\n }) as ReturnType<ComponentFunction>;\n });\n\n // Prefer a DOM-based comparison to avoid false positives from attribute order\n // or whitespace differences between server and expected HTML.\n const serverContainer = document.createElement('div');\n serverContainer.innerHTML = serverHTML;\n const expectedContainer = document.createElement('div');\n expectedContainer.innerHTML = expectedHTML;\n\n if (!serverContainer.isEqualNode(expectedContainer)) {\n throw new Error(\n '[Askr] Hydration mismatch detected. Server HTML does not match expected server-render output.'\n );\n }\n\n // Proceed to mount the client SPA (this will attach listeners and start navigation)\n // Reuse createSPA path but we already registered routes and set server location, so just mount\n // Mount resolved handler\n mountOrUpdate(rootElement, resolved.handler as ComponentFunction, {\n cleanupStrict: false,\n });\n\n // Register navigation and instance\n const { registerAppInstance, initializeNavigation } =\n await import('../router/navigate');\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path);\n initializeNavigation();\n}\n\nexport async function hydrate(_config: AppConfig): Promise<void> {\n throw new Error(\n 'The legacy `hydrate` API is removed. Use `hydrateSPA({ root, routes })` for SSR hydration with an explicit route table.'\n );\n}\n\n/**\n * Cleanup an app mounted on a root element (element or id).\n * Safe to call multiple times — no-op when nothing is mounted.\n */\nexport function cleanupApp(root: Element | string): void {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return;\n\n const cleanupFn = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n if (typeof cleanupFn === 'function') {\n cleanupFn();\n }\n\n instancesByRoot.delete(rootElement);\n}\n\n/**\n * Check whether an app is mounted on the given root\n */\nexport function hasApp(root: Element | string): boolean {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return false;\n return instancesByRoot.has(rootElement);\n}\n","/**\n * Link component for client-side navigation\n */\n\nimport { navigate } from '../router/navigate';\nexport interface LinkProps {\n href: string;\n children?: unknown;\n}\n\n/**\n * Link component that prevents default navigation and uses navigate()\n * Provides declarative way to navigate between routes\n *\n * Respects:\n * - Middle-click (opens in new tab)\n * - Ctrl/Cmd+click (opens in new tab)\n * - Shift+click (opens in new window)\n * - Right-click context menu\n */\nexport function Link({ href, children }: LinkProps): unknown {\n return {\n type: 'a',\n props: {\n href,\n children,\n onClick: (e: Event) => {\n const event = e as MouseEvent;\n\n // Only handle left-click without modifiers\n // Default button to 0 if undefined (for mock events in tests)\n const button = event.button ?? 0;\n if (\n button !== 0 || // not left-click\n event.ctrlKey || // Ctrl/Cmd+click\n event.metaKey || // Cmd on Mac\n event.shiftKey || // Shift+click\n event.altKey // Alt+click\n ) {\n return; // Let browser handle it (new tab, etc.)\n }\n\n event.preventDefault();\n navigate(href);\n },\n },\n };\n}\n","/**\n * Layout helper.\n *\n * A layout is just a normal component that wraps children.\n * Persistence and reuse are handled by the runtime via component identity.\n *\n * This helper exists purely for readability and convention.\n */\n\nexport type LayoutComponent<P = object> = (\n props: P & { children?: unknown }\n) => unknown;\n\nexport function layout<P = object>(Layout: LayoutComponent<P>) {\n return (children?: unknown, props?: P) =>\n Layout({ ...(props as P), children });\n}\n","import { logger } from '../dev/logger';\nimport { Fragment, cloneElement, isElement } from '../jsx';\n\nexport type SlotProps =\n | {\n asChild: true;\n children: unknown;\n [key: string]: unknown;\n }\n | {\n asChild?: false;\n children?: unknown;\n };\n\nexport function Slot(props: SlotProps) {\n if (props.asChild) {\n const { children, ...rest } = props;\n\n if (isElement(children)) {\n return cloneElement(children, rest);\n }\n\n logger.warn('<Slot asChild> expects a single JSX element child.');\n\n return null;\n }\n\n // Structural no-op: Slot does not introduce DOM\n // Return a vnode object for the fragment to avoid using JSX in a .ts file.\n return { type: Fragment, props: { children: props.children } } as unknown;\n}\n","export { Fragment, ELEMENT_TYPE } from './types';\nexport type { JSXElement } from './types';\n\nexport { isElement, cloneElement } from './utils';\n","import { ELEMENT_TYPE, JSXElement } from './types';\n\nexport function isElement(value: unknown): value is JSXElement {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as JSXElement).$$typeof === ELEMENT_TYPE\n );\n}\n\nexport function cloneElement(\n element: JSXElement,\n props: Record<string, unknown>\n): JSXElement {\n return {\n ...element,\n props: { ...element.props, ...props },\n };\n}\n","/**\n * Portal / Host primitive.\n *\n * A portal is a named render slot within the existing tree.\n * It does NOT create a second tree or touch the DOM directly.\n */\n\nexport interface Portal<T = unknown> {\n /** Mount point — rendered exactly once */\n (): unknown;\n\n /** Render content into the portal */\n render(props: { children?: T }): unknown;\n}\n\nexport function definePortal<T = unknown>(): Portal<T> {\n // Runtime-provided slot implementation\n const slot = createPortalSlot<T>();\n\n function PortalHost() {\n return slot.read();\n }\n\n PortalHost.render = function PortalRender(props: { children?: T }) {\n slot.write(props.children);\n return null;\n };\n\n return PortalHost as Portal<T>;\n}\n\n/**\n * NOTE:\n * createPortalSlot is a runtime primitive.\n * It owns scheduling, consistency, and SSR behavior.\n */\ndeclare function createPortalSlot<T>(): {\n read(): unknown;\n write(value: T | undefined): void;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA;AAKA;AACA;AA2CO,SAAS,MAAS,cAA2B;AAElD,QAAM,WAAW,mBAAmB;AACpC,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,QAAQ,kBAAkB;AAChC,QAAM,cAAc,SAAS;AAI7B,MAAI,QAAQ,SAAS,iBAAiB;AACpC,UAAM,IAAI;AAAA,MACR,gDAAgD,KAAK,8BACvB,SAAS,eAAe;AAAA,IAIxD;AAAA,EACF;AAGA;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EACF;AACA,WAAS,kBAAkB;AAG3B,MAAI,SAAS,qBAAqB;AAEhC,QAAI,CAAC,SAAS,qBAAqB,SAAS,KAAK,GAAG;AAClD,YAAM,IAAI;AAAA,QACR,iDAAiD,KAAK,4DACM,SAAS,qBAAqB,KA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D,QAAM,OAAO,iBAAoB;AAEjC,WAAS,aAAa;AACpB,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,aAAW,SAAS,SAAS,aAAa,OAAyB;AACjE,SAAK,MAAM,MAAM,QAAQ;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AV+CA;AAYA,IAAI,OAAO,eAAe,aAAa;AACrC,QAAM,IAAI;AACV,MAAI,CAAC,EAAE,aAAc,GAAE,eAAe;AACtC,MAAI,CAAC,EAAE,UAAW,GAAE,YAAY;AAChC,MAAI,CAAC,EAAE,WAAY,GAAE,aAAa;AAClC,MAAI,CAAC,EAAE,MAAO,GAAE,QAAQ;AACxB,MAAI,CAAC,EAAE,UAAW,GAAE,YAAY;AAChC,MAAI,CAAC,EAAE,SAAU,GAAE,WAAW;AAChC;","names":["task","renderData","holder","h","cell","value","instance","cache","clearRoutes","route","instance","setServerLocation","renderToStringSync","registerAppInstance","initializeNavigation"]}
|
|
@@ -24,14 +24,20 @@ __export(jsx_dev_runtime_exports, {
|
|
|
24
24
|
jsxDEV: () => jsxDEV
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
27
|
+
|
|
28
|
+
// src/jsx/types.ts
|
|
29
|
+
var ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("askr.element");
|
|
30
|
+
var Fragment = /* @__PURE__ */ Symbol.for("askr.fragment");
|
|
31
|
+
|
|
32
|
+
// src/jsx/jsx-dev-runtime.ts
|
|
27
33
|
function jsxDEV(type, props, key) {
|
|
28
34
|
return {
|
|
35
|
+
$$typeof: ELEMENT_TYPE,
|
|
29
36
|
type,
|
|
30
|
-
props: props
|
|
31
|
-
key
|
|
37
|
+
props: props ?? {},
|
|
38
|
+
key: key ?? null
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
|
-
var Fragment = /* @__PURE__ */ Symbol("Fragment");
|
|
35
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
42
|
0 && (module.exports = {
|
|
37
43
|
Fragment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same as production runtime
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-dev-runtime.ts","../../src/jsx/types.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\n\nimport './types';\nimport { ELEMENT_TYPE, Fragment, JSXElement } from './types';\n\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement {\n return {\n $$typeof: ELEMENT_TYPE,\n type,\n props: props ?? {},\n key: key ?? null,\n };\n}\n\n// Re-export Fragment for JSX\nexport { Fragment };\n","/**\n * JSX type definitions\n *\n * These define the canonical JSX element shape used by:\n * - jsx-runtime\n * - jsx-dev-runtime\n * - Slot / cloneElement\n * - the reconciler\n */\n\nimport type { Props } from '../shared/types';\n\nexport const ELEMENT_TYPE = Symbol.for('askr.element');\nexport const Fragment = Symbol.for('askr.fragment');\n\nexport interface JSXElement {\n /** Internal element marker (optional for plain vnode objects) */\n $$typeof?: symbol;\n\n /** Element type: string, component, Fragment, etc */\n type: unknown;\n\n /** Props bag */\n props: Props;\n\n /** Optional key (normalized by runtime) */\n key?: string | number | null;\n}\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n // Components must be synchronous\n type Element = JSXElement;\n\n interface IntrinsicElements {\n [elem: string]: Props;\n }\n\n interface ElementAttributesProperty {\n props: Props;\n }\n }\n}\n\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,eAAe,uBAAO,IAAI,cAAc;AAC9C,IAAM,WAAW,uBAAO,IAAI,eAAe;;;ADL3C,SAAS,OACd,MACA,OACA,KACY;AACZ,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,OAAO,SAAS,CAAC;AAAA,IACjB,KAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import '../types-
|
|
1
|
+
import { J as JSXElement } from '../types-DLTViI21.cjs';
|
|
2
|
+
export { F as Fragment } from '../types-DLTViI21.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* JSX dev runtime factory
|
|
5
|
-
* Same as production runtime
|
|
6
|
+
* Same element shape as production runtime, with room for dev warnings.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
interface JSXElement {
|
|
9
|
-
type: unknown;
|
|
10
|
-
props: Record<string, unknown>;
|
|
11
|
-
key?: string | number;
|
|
12
|
-
}
|
|
13
9
|
declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
14
|
-
declare const Fragment: unique symbol;
|
|
15
10
|
|
|
16
|
-
export {
|
|
11
|
+
export { jsxDEV };
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import '../types-
|
|
1
|
+
import { J as JSXElement } from '../types-DLTViI21.js';
|
|
2
|
+
export { F as Fragment } from '../types-DLTViI21.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* JSX dev runtime factory
|
|
5
|
-
* Same as production runtime
|
|
6
|
+
* Same element shape as production runtime, with room for dev warnings.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
interface JSXElement {
|
|
9
|
-
type: unknown;
|
|
10
|
-
props: Record<string, unknown>;
|
|
11
|
-
key?: string | number;
|
|
12
|
-
}
|
|
13
9
|
declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
14
|
-
declare const Fragment: unique symbol;
|
|
15
10
|
|
|
16
|
-
export {
|
|
11
|
+
export { jsxDEV };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
ELEMENT_TYPE,
|
|
3
|
+
Fragment,
|
|
4
|
+
init_types
|
|
5
|
+
} from "../chunk-QECQ2TF6.js";
|
|
2
6
|
|
|
3
7
|
// src/jsx/jsx-dev-runtime.ts
|
|
8
|
+
init_types();
|
|
9
|
+
init_types();
|
|
4
10
|
function jsxDEV(type, props, key) {
|
|
5
11
|
return {
|
|
12
|
+
$$typeof: ELEMENT_TYPE,
|
|
6
13
|
type,
|
|
7
|
-
props: props
|
|
8
|
-
key
|
|
14
|
+
props: props ?? {},
|
|
15
|
+
key: key ?? null
|
|
9
16
|
};
|
|
10
17
|
}
|
|
11
|
-
var Fragment = /* @__PURE__ */ Symbol("Fragment");
|
|
12
18
|
export {
|
|
13
19
|
Fragment,
|
|
14
20
|
jsxDEV
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same as production runtime
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\n\nimport './types';\nimport { ELEMENT_TYPE, Fragment, JSXElement } from './types';\n\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement {\n return {\n $$typeof: ELEMENT_TYPE,\n type,\n props: props ?? {},\n key: key ?? null,\n };\n}\n\n// Re-export Fragment for JSX\nexport { Fragment };\n"],"mappings":";;;;;;;AAKA;AACA;AAEO,SAAS,OACd,MACA,OACA,KACY;AACZ,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,OAAO,SAAS,CAAC;AAAA,IACjB,KAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/dist/jsx/jsx-runtime.cjs
CHANGED
|
@@ -20,26 +20,35 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/jsx/jsx-runtime.ts
|
|
21
21
|
var jsx_runtime_exports = {};
|
|
22
22
|
__export(jsx_runtime_exports, {
|
|
23
|
+
ELEMENT_TYPE: () => ELEMENT_TYPE,
|
|
23
24
|
Fragment: () => Fragment,
|
|
24
25
|
jsx: () => jsx,
|
|
26
|
+
jsxDEV: () => jsxDEV,
|
|
25
27
|
jsxs: () => jsxs
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(jsx_runtime_exports);
|
|
28
|
-
|
|
30
|
+
var ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("askr.element");
|
|
31
|
+
var Fragment = /* @__PURE__ */ Symbol.for("askr.fragment");
|
|
32
|
+
function jsxDEV(type, props, key) {
|
|
29
33
|
return {
|
|
34
|
+
$$typeof: ELEMENT_TYPE,
|
|
30
35
|
type,
|
|
31
|
-
props: props
|
|
32
|
-
key
|
|
36
|
+
props: props ?? {},
|
|
37
|
+
key: key ?? null
|
|
33
38
|
};
|
|
34
39
|
}
|
|
40
|
+
function jsx(type, props, key) {
|
|
41
|
+
return jsxDEV(type, props, key);
|
|
42
|
+
}
|
|
35
43
|
function jsxs(type, props, key) {
|
|
36
|
-
return
|
|
44
|
+
return jsxDEV(type, props, key);
|
|
37
45
|
}
|
|
38
|
-
var Fragment = /* @__PURE__ */ Symbol.for("@askrjs/askr.Fragment");
|
|
39
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
47
|
0 && (module.exports = {
|
|
48
|
+
ELEMENT_TYPE,
|
|
41
49
|
Fragment,
|
|
42
50
|
jsx,
|
|
51
|
+
jsxDEV,
|
|
43
52
|
jsxs
|
|
44
53
|
});
|
|
45
54
|
//# sourceMappingURL=jsx-runtime.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime\n * Same shape as production runtime, with room for dev warnings.\n */\n\nimport './types';\n\nexport const ELEMENT_TYPE = Symbol.for('askr.element');\nexport const Fragment = Symbol.for('askr.fragment');\n\nexport interface JSXElement {\n $$typeof: symbol;\n type: unknown;\n props: Record<string, unknown>;\n key: string | number | null;\n}\n\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement {\n return {\n $$typeof: ELEMENT_TYPE,\n type,\n props: props ?? {},\n key: key ?? null,\n };\n}\n\n// Production-style helpers: alias to the DEV factory for now\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n return jsxDEV(type, props, key);\n}\n\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n return jsxDEV(type, props, key);\n}\n\n// `Fragment` is already exported above.\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,IAAM,eAAe,uBAAO,IAAI,cAAc;AAC9C,IAAM,WAAW,uBAAO,IAAI,eAAe;AAS3C,SAAS,OACd,MACA,OACA,KACY;AACZ,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,OAAO,SAAS,CAAC;AAAA,IACjB,KAAK,OAAO;AAAA,EACd;AACF;AAGO,SAAS,IACd,MACA,OACA,KACA;AACA,SAAO,OAAO,MAAM,OAAO,GAAG;AAChC;AAEO,SAAS,KACd,MACA,OACA,KACA;AACA,SAAO,OAAO,MAAM,OAAO,GAAG;AAChC;","names":[]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import '../types-
|
|
1
|
+
import '../types-DLTViI21.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* JSX runtime
|
|
5
|
-
*
|
|
4
|
+
* JSX dev runtime
|
|
5
|
+
* Same shape as production runtime, with room for dev warnings.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
declare const ELEMENT_TYPE: unique symbol;
|
|
9
|
+
declare const Fragment: unique symbol;
|
|
8
10
|
interface JSXElement {
|
|
11
|
+
$$typeof: symbol;
|
|
9
12
|
type: unknown;
|
|
10
13
|
props: Record<string, unknown>;
|
|
11
|
-
key
|
|
14
|
+
key: string | number | null;
|
|
12
15
|
}
|
|
16
|
+
declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
13
17
|
declare function jsx(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
14
18
|
declare function jsxs(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
15
|
-
declare const Fragment: unique symbol;
|
|
16
19
|
|
|
17
|
-
export { Fragment, type JSXElement, jsx, jsxs };
|
|
20
|
+
export { ELEMENT_TYPE, Fragment, type JSXElement, jsx, jsxDEV, jsxs };
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import '../types-
|
|
1
|
+
import '../types-DLTViI21.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* JSX runtime
|
|
5
|
-
*
|
|
4
|
+
* JSX dev runtime
|
|
5
|
+
* Same shape as production runtime, with room for dev warnings.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
declare const ELEMENT_TYPE: unique symbol;
|
|
9
|
+
declare const Fragment: unique symbol;
|
|
8
10
|
interface JSXElement {
|
|
11
|
+
$$typeof: symbol;
|
|
9
12
|
type: unknown;
|
|
10
13
|
props: Record<string, unknown>;
|
|
11
|
-
key
|
|
14
|
+
key: string | number | null;
|
|
12
15
|
}
|
|
16
|
+
declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
13
17
|
declare function jsx(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
14
18
|
declare function jsxs(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
|
|
15
|
-
declare const Fragment: unique symbol;
|
|
16
19
|
|
|
17
|
-
export { Fragment, type JSXElement, jsx, jsxs };
|
|
20
|
+
export { ELEMENT_TYPE, Fragment, type JSXElement, jsx, jsxDEV, jsxs };
|
package/dist/jsx/jsx-runtime.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ELEMENT_TYPE,
|
|
2
3
|
Fragment,
|
|
3
4
|
init_jsx_runtime,
|
|
4
5
|
jsx,
|
|
6
|
+
jsxDEV,
|
|
5
7
|
jsxs
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-KR6HG7HF.js";
|
|
9
|
+
import "../chunk-QECQ2TF6.js";
|
|
8
10
|
init_jsx_runtime();
|
|
9
11
|
export {
|
|
12
|
+
ELEMENT_TYPE,
|
|
10
13
|
Fragment,
|
|
11
14
|
jsx,
|
|
15
|
+
jsxDEV,
|
|
12
16
|
jsxs
|
|
13
17
|
};
|
|
14
18
|
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
initializeNavigation,
|
|
4
4
|
navigate,
|
|
5
5
|
registerAppInstance
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-RJWOOUYV.js";
|
|
7
|
+
import "./chunk-MIPES65F.js";
|
|
8
|
+
import "./chunk-KR6HG7HF.js";
|
|
9
|
+
import "./chunk-QECQ2TF6.js";
|
|
10
10
|
export {
|
|
11
11
|
cleanupNavigation,
|
|
12
12
|
initializeNavigation,
|
|
13
13
|
navigate,
|
|
14
14
|
registerAppInstance
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=navigate-
|
|
16
|
+
//# sourceMappingURL=navigate-SDZNA2ZE.js.map
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
route,
|
|
12
12
|
setServerLocation,
|
|
13
13
|
unloadNamespace
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-MIPES65F.js";
|
|
15
|
+
import "./chunk-KR6HG7HF.js";
|
|
16
|
+
import "./chunk-QECQ2TF6.js";
|
|
17
17
|
export {
|
|
18
18
|
_lockRouteRegistrationForTests,
|
|
19
19
|
_unlockRouteRegistrationForTests,
|
|
@@ -28,4 +28,4 @@ export {
|
|
|
28
28
|
setServerLocation,
|
|
29
29
|
unloadNamespace
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=route-
|
|
31
|
+
//# sourceMappingURL=route-P5YQBT4T.js.map
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SSRDataMissingError,
|
|
3
3
|
collectResources,
|
|
4
|
+
popSSRStrictPurityGuard,
|
|
5
|
+
pushSSRStrictPurityGuard,
|
|
4
6
|
renderToStream,
|
|
5
7
|
renderToString,
|
|
6
8
|
renderToStringSync,
|
|
7
9
|
renderToStringSyncForUrl,
|
|
8
10
|
resolvePlan,
|
|
9
11
|
resolveResources
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-PFOLLB6A.js";
|
|
13
|
+
import "./chunk-MIPES65F.js";
|
|
14
|
+
import "./chunk-KR6HG7HF.js";
|
|
15
|
+
import "./chunk-QECQ2TF6.js";
|
|
14
16
|
export {
|
|
15
17
|
SSRDataMissingError,
|
|
16
18
|
collectResources,
|
|
19
|
+
popSSRStrictPurityGuard,
|
|
20
|
+
pushSSRStrictPurityGuard,
|
|
17
21
|
renderToStream,
|
|
18
22
|
renderToString,
|
|
19
23
|
renderToStringSync,
|
|
@@ -21,4 +25,4 @@ export {
|
|
|
21
25
|
resolvePlan,
|
|
22
26
|
resolveResources
|
|
23
27
|
};
|
|
24
|
-
//# sourceMappingURL=ssr-
|
|
28
|
+
//# sourceMappingURL=ssr-65K3IJ6B.js.map
|