@shane_il/pulse 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect.d.ts +1 -0
- package/dist/devtools/core.d.ts +47 -0
- package/dist/devtools/index.d.ts +9 -0
- package/dist/devtools/panel/actions-tab.d.ts +10 -0
- package/dist/devtools/panel/components-tab.d.ts +5 -0
- package/dist/devtools/panel/panel.d.ts +24 -0
- package/dist/devtools/panel/stores-tab.d.ts +7 -0
- package/dist/devtools/panel/styles.d.ts +41 -0
- package/dist/devtools/time-travel.d.ts +11 -0
- package/dist/devtools.cjs +2 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.js +1147 -0
- package/dist/devtools.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/middleware.d.ts +26 -0
- package/dist/pulse.cjs +1 -1
- package/dist/pulse.cjs.map +1 -1
- package/dist/pulse.js +381 -325
- package/dist/pulse.js.map +1 -1
- package/dist/store.d.ts +4 -0
- package/package.json +8 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools.js","sources":["../src/scheduler.ts","../src/connect.ts","../src/store.ts","../src/middleware.ts","../src/devtools/core.ts","../src/vnode.ts","../src/createElement.ts","../src/diff.ts","../src/patch.ts","../src/render.ts","../src/devtools/time-travel.ts","../src/devtools/panel/styles.ts","../src/devtools/panel/stores-tab.ts","../src/devtools/panel/actions-tab.ts","../src/devtools/panel/components-tab.ts","../src/devtools/panel/panel.ts","../src/devtools/index.ts"],"sourcesContent":["let pending = false;\nconst queue = new Set<() => void>();\n\nexport function scheduleUpdate(callback: () => void): void {\n queue.add(callback);\n if (!pending) {\n pending = true;\n queueMicrotask(flush);\n }\n}\n\nfunction flush(): void {\n const batch = [...queue];\n queue.clear();\n pending = false;\n for (const callback of batch) {\n callback();\n }\n}\n\nexport function flushSync(): void {\n const batch = [...queue];\n queue.clear();\n pending = false;\n for (const callback of batch) {\n callback();\n }\n}\n","import { scheduleUpdate } from './scheduler';\nimport type { VNode, Bindings, Lifecycle, ComponentFunction } from './vnode';\n\nexport const CONNECTED: unique symbol = Symbol('PULSE_CONNECTED');\n\n// Pluggable devtools hooks — stored on globalThis so separate bundles\n// (pulse core vs devtools) share the same hook storage.\ninterface ComponentHooks {\n onMount: ((instance: any) => void) | null;\n onUnmount: ((instance: any) => void) | null;\n}\n\nconst G = globalThis as any;\nif (!G.__PULSE_HOOKS__) {\n G.__PULSE_HOOKS__ = { onMount: null, onUnmount: null };\n}\nconst hooks: ComponentHooks = G.__PULSE_HOOKS__;\n\nexport function __setComponentHooks(\n onMount: ((instance: ComponentInstance) => void) | null,\n onUnmount: ((instance: ComponentInstance) => void) | null,\n): void {\n hooks.onMount = onMount;\n hooks.onUnmount = onUnmount;\n}\n\nexport function connect(\n bindings: Bindings | null | undefined,\n lifecycle?: Lifecycle,\n) {\n return function wrapComponent(Component: ComponentFunction) {\n const b = bindings || {};\n\n function ConnectedComponent(props: Record<string, any>): VNode | null {\n const selectedProps: Record<string, any> = {};\n for (const propName in b) {\n const { store, selector } = b[propName];\n selectedProps[propName] = selector(store.getState());\n }\n return Component({ ...selectedProps, ...props });\n }\n\n (ConnectedComponent as any)[CONNECTED] = true;\n (ConnectedComponent as any)._bindings = b;\n (ConnectedComponent as any)._innerComponent = Component;\n if (lifecycle) (ConnectedComponent as any)._lifecycle = lifecycle;\n ConnectedComponent.displayName =\n `Connected(${(Component as any).displayName || Component.name || 'Anonymous'})`;\n\n return ConnectedComponent;\n };\n}\n\nexport class ComponentInstance {\n connectedFn: ComponentFunction;\n props: Record<string, any>;\n prevSelected: Record<string, any>;\n unsubscribers: (() => void)[];\n lastVTree: VNode | null;\n parentDom: Node | null;\n _renderCallback: (() => void) | null;\n _mountCleanup: (() => void) | null;\n\n constructor(connectedFn: ComponentFunction, props: Record<string, any>) {\n this.connectedFn = connectedFn;\n this.props = props;\n this.prevSelected = {};\n this.unsubscribers = [];\n this.lastVTree = null;\n this.parentDom = null;\n this._renderCallback = null;\n this._mountCleanup = null;\n }\n\n mount(parentDom: Node, renderCallback: () => void): void {\n this.parentDom = parentDom;\n this._renderCallback = renderCallback;\n\n const bindings: Bindings = (this.connectedFn as any)._bindings;\n\n for (const propName in bindings) {\n const { store, selector } = bindings[propName];\n this.prevSelected[propName] = selector(store.getState());\n }\n\n for (const propName in bindings) {\n const { store } = bindings[propName];\n const unsub = store.subscribe(() => {\n this._onStoreChange();\n });\n this.unsubscribers.push(unsub);\n }\n\n // Lifecycle: call onMount after subscriptions are live\n const lifecycle: Lifecycle | undefined = (this.connectedFn as any)._lifecycle;\n if (lifecycle?.onMount) {\n const cleanup = lifecycle.onMount({\n dom: this.lastVTree?._dom,\n props: this.props,\n });\n if (typeof cleanup === 'function') {\n this._mountCleanup = cleanup;\n }\n }\n\n // Devtools hook\n if (hooks.onMount) hooks.onMount(this);\n }\n\n _onStoreChange(): void {\n const bindings: Bindings = (this.connectedFn as any)._bindings;\n let changed = false;\n\n for (const propName in bindings) {\n const { store, selector } = bindings[propName];\n const newValue = selector(store.getState());\n if (!shallowEqual(newValue, this.prevSelected[propName])) {\n changed = true;\n break;\n }\n }\n\n if (changed) {\n scheduleUpdate(this._renderCallback!);\n }\n }\n\n updateSelected(): void {\n const bindings: Bindings = (this.connectedFn as any)._bindings;\n for (const propName in bindings) {\n const { store, selector } = bindings[propName];\n this.prevSelected[propName] = selector(store.getState());\n }\n }\n\n unmount(): void {\n // Devtools hook\n if (hooks.onUnmount) hooks.onUnmount(this);\n\n // Lifecycle: cleanup from onMount, then onDestroy\n if (this._mountCleanup) {\n this._mountCleanup();\n this._mountCleanup = null;\n }\n const lifecycle: Lifecycle | undefined = (this.connectedFn as any)._lifecycle;\n if (lifecycle?.onDestroy) {\n lifecycle.onDestroy({ props: this.props });\n }\n\n for (const unsub of this.unsubscribers) {\n unsub();\n }\n this.unsubscribers = [];\n this._renderCallback = null;\n }\n}\n\nexport function shallowEqual(a: any, b: any): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n if (a === null || b === null) return false;\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {\n return false;\n }\n }\n return true;\n}\n","import type { Middleware, DispatchContext } from './middleware';\n\nexport interface StoreActions<S> {\n [actionName: string]: (state: S, payload?: any) => S;\n}\n\nexport interface StoreConfig<S> {\n state: S;\n actions: StoreActions<S>;\n name?: string;\n middleware?: Middleware<S>[];\n}\n\nexport interface SelectorBinding<S, R> {\n store: Store<S>;\n selector: (state: S) => R;\n}\n\nexport interface Store<S> {\n readonly name?: string;\n getState(): S;\n dispatch(actionName: string, payload?: any): void;\n subscribe(listener: (state: S) => void): () => void;\n select<R>(selectorFn: (state: S) => R): SelectorBinding<S, R>;\n}\n\nexport function createStore<S>(config: StoreConfig<S>): Store<S> {\n let state: S = config.state;\n const actions = config.actions;\n const listeners = new Set<(state: S) => void>();\n const mw = config.middleware;\n\n function getState(): S {\n return state;\n }\n\n function notify(): void {\n for (const listener of listeners) {\n listener(state);\n }\n }\n\n // Fast path: no middleware — same hot path as before\n function dispatchSimple(actionName: string, payload?: any): void {\n const action = actions[actionName];\n if (!action) {\n throw new Error(`[pulse] Unknown action: \"${actionName}\"`);\n }\n const nextState = action(state, payload);\n if (nextState === state) return;\n state = nextState;\n notify();\n }\n\n // Middleware path: build onion chain per dispatch\n function dispatchWithMiddleware(actionName: string, payload?: any): void {\n // __devtools_replace__ is a reserved action for time-travel\n if (actionName === '__devtools_replace__') {\n state = payload as S;\n notify();\n return;\n }\n\n const action = actions[actionName];\n if (!action) {\n throw new Error(`[pulse] Unknown action: \"${actionName}\"`);\n }\n\n const ctx: DispatchContext<S> = {\n store: storeObj,\n actionName,\n payload,\n prevState: state,\n nextState: undefined,\n };\n\n let idx = 0;\n function next(): void {\n if (idx < mw!.length) {\n const fn = mw![idx++];\n fn(ctx, next);\n } else {\n // Core action at the center of the onion\n const nextState = action(ctx.prevState, ctx.payload);\n ctx.nextState = nextState;\n if (nextState !== state) {\n state = nextState;\n notify();\n }\n }\n }\n\n next();\n }\n\n const dispatch = mw && mw.length > 0 ? dispatchWithMiddleware : dispatchSimple;\n\n function subscribe(listener: (state: S) => void): () => void {\n listeners.add(listener);\n return () => { listeners.delete(listener); };\n }\n\n function select<R>(selectorFn: (state: S) => R): SelectorBinding<S, R> {\n return { store: storeObj, selector: selectorFn };\n }\n\n const storeObj: Store<S> = {\n getState,\n dispatch,\n subscribe,\n select,\n };\n\n if (config.name) {\n (storeObj as any).name = config.name;\n }\n\n return storeObj;\n}\n","import type { Store } from './store';\n\nexport interface DispatchContext<S = any> {\n store: Store<S>;\n actionName: string;\n payload: any;\n prevState: S;\n nextState: S | undefined;\n}\n\nexport type Middleware<S = any> = (ctx: DispatchContext<S>, next: () => void) => void;\n\nexport interface ActionEntry {\n actionName: string;\n payload: any;\n prevState: any;\n nextState: any;\n timestamp: number;\n}\n\n/**\n * Logger middleware — logs action dispatches with prev/next state.\n */\nexport function logger(): Middleware {\n return (ctx, next) => {\n const label = `[pulse] ${ctx.actionName}`;\n console.group(label);\n console.log('prev state', ctx.prevState);\n console.log('payload', ctx.payload);\n next();\n console.log('next state', ctx.nextState);\n console.groupEnd();\n };\n}\n\n/**\n * Action history middleware — pushes entries to a caller-owned array.\n */\nexport function actionHistory(\n history: ActionEntry[],\n opts?: { maxEntries?: number },\n): Middleware {\n const max = opts?.maxEntries ?? Infinity;\n return (ctx, next) => {\n next();\n history.push({\n actionName: ctx.actionName,\n payload: ctx.payload,\n prevState: ctx.prevState,\n nextState: ctx.nextState ?? ctx.prevState,\n timestamp: Date.now(),\n });\n if (history.length > max) {\n history.splice(0, history.length - max);\n }\n };\n}\n","import { createStore } from '../store';\nimport { actionHistory } from '../middleware';\nimport type { Store } from '../store';\nimport type { ActionEntry, Middleware } from '../middleware';\n\nexport type DevtoolsEventType =\n | 'store-registered'\n | 'action-dispatched'\n | 'state-replaced'\n | 'component-mounted'\n | 'component-unmounted'\n | 'time-travel';\n\nexport interface DevtoolsEvent {\n type: DevtoolsEventType;\n storeName?: string;\n data?: any;\n}\n\nexport interface TrackedStore {\n store: Store<any>;\n history: ActionEntry[];\n name: string;\n}\n\nexport interface TrackedComponent {\n id: number;\n displayName: string;\n storeNames: string[];\n}\n\ntype DevtoolsListener = (event: DevtoolsEvent) => void;\n\nlet nextComponentId = 1;\n\nexport class PulseDevtools {\n private stores = new Map<string, TrackedStore>();\n private components = new Map<number, TrackedComponent>();\n private listeners = new Set<DevtoolsListener>();\n\n registerStore(store: Store<any>, history: ActionEntry[], name?: string): void {\n const storeName = name || store.name || `store_${this.stores.size}`;\n this.stores.set(storeName, { store, history, name: storeName });\n\n // Subscribe to track dispatches in real-time\n store.subscribe(() => {\n this.emit({ type: 'action-dispatched', storeName });\n });\n\n this.emit({ type: 'store-registered', storeName });\n }\n\n getStoreNames(): string[] {\n return Array.from(this.stores.keys());\n }\n\n getStoreState(name: string): any {\n return this.stores.get(name)?.store.getState();\n }\n\n getTrackedStore(name: string): TrackedStore | undefined {\n return this.stores.get(name);\n }\n\n getHistory(name?: string): ActionEntry[] {\n if (name) {\n return this.stores.get(name)?.history ?? [];\n }\n // All histories merged, sorted by timestamp\n const all: ActionEntry[] = [];\n for (const tracked of this.stores.values()) {\n all.push(...tracked.history);\n }\n return all.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n trackComponent(displayName: string, storeNames: string[]): number {\n const id = nextComponentId++;\n this.components.set(id, { id, displayName, storeNames });\n this.emit({ type: 'component-mounted', data: { id, displayName, storeNames } });\n return id;\n }\n\n untrackComponent(id: number): void {\n const comp = this.components.get(id);\n if (comp) {\n this.components.delete(id);\n this.emit({ type: 'component-unmounted', data: { id, displayName: comp.displayName } });\n }\n }\n\n getComponents(): TrackedComponent[] {\n return Array.from(this.components.values());\n }\n\n on(listener: DevtoolsListener): () => void {\n this.listeners.add(listener);\n return () => { this.listeners.delete(listener); };\n }\n\n emit(event: DevtoolsEvent): void {\n for (const listener of this.listeners) {\n listener(event);\n }\n }\n}\n\n/**\n * Convenience: wraps createStore with actionHistory middleware and registers with devtools.\n */\nexport function instrumentStore<S>(\n devtools: PulseDevtools,\n config: {\n state: S;\n actions: Record<string, (state: S, payload?: any) => S>;\n name?: string;\n middleware?: Middleware<S>[];\n },\n): { store: Store<S>; history: ActionEntry[] } {\n const history: ActionEntry[] = [];\n const historyMw = actionHistory(history) as Middleware<S>;\n\n const store = createStore<S>({\n ...config,\n middleware: [historyMw, ...(config.middleware || [])],\n });\n\n devtools.registerStore(store, history, config.name);\n\n return { store, history };\n}\n","import type { ComponentInstance } from './connect';\nimport type { SelectorBinding } from './store';\n\nexport const TEXT_NODE: unique symbol = Symbol('TEXT_NODE');\nexport const FRAGMENT: unique symbol = Symbol('FRAGMENT');\n\nexport type VNodeType = string | typeof TEXT_NODE | typeof FRAGMENT | ComponentFunction;\n\nexport interface VNode {\n type: VNodeType;\n props: Record<string, any>;\n children: VNode[];\n key: string | number | null;\n _dom?: Node | null;\n _instance?: ComponentInstance | null;\n}\n\nexport type ComponentFunction = (props: Record<string, any>) => VNode | null;\n\nexport interface Bindings {\n [propName: string]: SelectorBinding<any, any>;\n}\n\nexport interface Lifecycle {\n onMount?: (ctx: { dom: Node | null | undefined; props: Record<string, any> }) => void | (() => void);\n onUpdate?: (ctx: { dom: Node | null | undefined; props: Record<string, any> }) => void;\n onError?: (ctx: { error: unknown; props: Record<string, any> }) => VNode | null;\n onDestroy?: (ctx: { props: Record<string, any> }) => void;\n}\n\nexport function createTextVNode(text: string | number): VNode {\n return {\n type: TEXT_NODE,\n props: { nodeValue: String(text) },\n children: [],\n key: null,\n };\n}\n\nexport function normalizeChild(child: any): VNode | null {\n if (child == null || typeof child === 'boolean') return null;\n if (typeof child === 'string' || typeof child === 'number') {\n return createTextVNode(child);\n }\n return child as VNode;\n}\n\nexport function flattenChildren(rawChildren: any[]): VNode[] {\n const result: VNode[] = [];\n for (const child of rawChildren) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child));\n } else {\n const normalized = normalizeChild(child);\n if (normalized !== null) result.push(normalized);\n }\n }\n return result;\n}\n","import { FRAGMENT, flattenChildren } from './vnode';\nimport type { VNode, VNodeType } from './vnode';\n\nexport function h(type: VNodeType, props: Record<string, any> | null, ...rawChildren: any[]): VNode {\n props = props || {};\n const key = props.key ?? null;\n\n if (props.key !== undefined) {\n props = { ...props };\n delete props.key;\n }\n\n const children = flattenChildren(rawChildren);\n\n return { type, props, children, key };\n}\n\nexport { FRAGMENT as Fragment };\n","import { TEXT_NODE } from './vnode';\nimport type { VNode } from './vnode';\n\nexport const PATCH = {\n CREATE: 'CREATE',\n REMOVE: 'REMOVE',\n REPLACE: 'REPLACE',\n UPDATE: 'UPDATE',\n TEXT: 'TEXT',\n MOVE: 'MOVE',\n CHILDREN: 'CHILDREN',\n} as const;\n\nexport type PatchType = typeof PATCH[keyof typeof PATCH];\n\nexport interface PropPatches {\n set: Record<string, any>;\n remove: string[];\n}\n\nexport type Patch =\n | { type: typeof PATCH.CREATE; newVNode: VNode; anchor?: VNode | null }\n | { type: typeof PATCH.REMOVE; target: VNode }\n | { type: typeof PATCH.REPLACE; oldVNode: VNode; newVNode: VNode }\n | { type: typeof PATCH.UPDATE; target: VNode; propPatches: PropPatches }\n | { type: typeof PATCH.TEXT; oldVNode: VNode; newVNode: VNode }\n | { type: typeof PATCH.MOVE; vnode: VNode; anchor: VNode | null; childPatches: Patch[] }\n | { type: typeof PATCH.CHILDREN; parent: VNode; childPatches: Patch[] };\n\nexport function diff(oldVNode: VNode | null, newVNode: VNode | null): Patch[] {\n if (newVNode == null && oldVNode == null) return [];\n if (newVNode == null) return [{ type: PATCH.REMOVE, target: oldVNode! }];\n if (oldVNode == null) return [{ type: PATCH.CREATE, newVNode }];\n\n if (oldVNode.type !== newVNode.type) {\n return [{ type: PATCH.REPLACE, oldVNode, newVNode }];\n }\n\n // Transfer _dom reference: the new vnode represents the same DOM node\n newVNode._dom = oldVNode._dom;\n\n if (oldVNode.type === TEXT_NODE) {\n if (oldVNode.props.nodeValue !== newVNode.props.nodeValue) {\n return [{ type: PATCH.TEXT, oldVNode, newVNode }];\n }\n return [];\n }\n\n const patches: Patch[] = [];\n\n const propPatches = diffProps(oldVNode.props, newVNode.props);\n if (propPatches) {\n patches.push({ type: PATCH.UPDATE, target: oldVNode, propPatches });\n }\n\n const childPatches = diffChildren(oldVNode.children, newVNode.children);\n if (childPatches.length) {\n patches.push({ type: PATCH.CHILDREN, parent: oldVNode, childPatches });\n }\n\n return patches;\n}\n\nfunction diffProps(\n oldProps: Record<string, any>,\n newProps: Record<string, any>,\n): PropPatches | null {\n const set: Record<string, any> = {};\n const remove: string[] = [];\n let hasChanges = false;\n\n for (const key in newProps) {\n if (key === 'children') continue;\n if (oldProps[key] !== newProps[key]) {\n set[key] = newProps[key];\n hasChanges = true;\n }\n }\n\n for (const key in oldProps) {\n if (key === 'children') continue;\n if (!(key in newProps)) {\n remove.push(key);\n hasChanges = true;\n }\n }\n\n return hasChanges ? { set, remove } : null;\n}\n\nfunction sameVNode(a: VNode | null, b: VNode | null): boolean {\n if (a == null || b == null) return false;\n return a.type === b.type && a.key === b.key;\n}\n\nfunction warnChildKeys(children: (VNode | null)[], label: string): void {\n const seen = new Set<string | number>();\n let keyedCount = 0;\n let unkeyedCount = 0;\n\n for (const child of children) {\n if (child == null) continue;\n if (child.key != null) {\n keyedCount++;\n if (seen.has(child.key)) {\n console.warn(\n `[pulse] Duplicate key \"${String(child.key)}\" in ${label} children. ` +\n `Keys must be unique among siblings.`,\n );\n }\n seen.add(child.key);\n } else {\n unkeyedCount++;\n }\n }\n\n if (keyedCount > 0 && unkeyedCount > 0) {\n console.warn(\n `[pulse] Mixed keyed and unkeyed children in ${label} list ` +\n `(${keyedCount} keyed, ${unkeyedCount} unkeyed). ` +\n `Either all children should have keys or none should.`,\n );\n }\n}\n\nfunction diffChildren(oldChildren: (VNode | null)[], newChildren: VNode[]): Patch[] {\n if (process.env.NODE_ENV !== 'production') {\n warnChildKeys(oldChildren, 'old');\n warnChildKeys(newChildren, 'new');\n }\n\n const patches: Patch[] = [];\n\n let oldStartIdx = 0;\n let oldEndIdx = oldChildren.length - 1;\n let newStartIdx = 0;\n let newEndIdx = newChildren.length - 1;\n\n let oldStartVNode = oldChildren[oldStartIdx];\n let oldEndVNode = oldChildren[oldEndIdx];\n let newStartVNode = newChildren[newStartIdx];\n let newEndVNode = newChildren[newEndIdx];\n\n // Phase 1: two-pointer scan\n while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {\n if (oldStartVNode == null) {\n oldStartVNode = oldChildren[++oldStartIdx];\n continue;\n }\n if (oldEndVNode == null) {\n oldEndVNode = oldChildren[--oldEndIdx];\n continue;\n }\n\n if (sameVNode(oldStartVNode, newStartVNode)) {\n patches.push(...diff(oldStartVNode, newStartVNode));\n oldStartVNode = oldChildren[++oldStartIdx];\n newStartVNode = newChildren[++newStartIdx];\n } else if (sameVNode(oldEndVNode, newEndVNode)) {\n patches.push(...diff(oldEndVNode, newEndVNode));\n oldEndVNode = oldChildren[--oldEndIdx];\n newEndVNode = newChildren[--newEndIdx];\n } else if (sameVNode(oldStartVNode, newEndVNode)) {\n patches.push({\n type: PATCH.MOVE,\n vnode: oldStartVNode!,\n anchor: oldChildren[oldEndIdx + 1] || null,\n childPatches: diff(oldStartVNode, newEndVNode),\n });\n oldStartVNode = oldChildren[++oldStartIdx];\n newEndVNode = newChildren[--newEndIdx];\n } else if (sameVNode(oldEndVNode, newStartVNode)) {\n patches.push({\n type: PATCH.MOVE,\n vnode: oldEndVNode!,\n anchor: oldStartVNode,\n childPatches: diff(oldEndVNode, newStartVNode),\n });\n oldEndVNode = oldChildren[--oldEndIdx];\n newStartVNode = newChildren[++newStartIdx];\n } else {\n // Fall through to key-map phase\n break;\n }\n }\n\n // Phase 2: key-map fallback for remaining nodes\n if (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {\n const keyMap = new Map<string | number, number>();\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\n const key = oldChildren[i]?.key;\n if (key != null) keyMap.set(key, i);\n }\n\n while (newStartIdx <= newEndIdx) {\n newStartVNode = newChildren[newStartIdx];\n const oldIdx = newStartVNode.key != null\n ? keyMap.get(newStartVNode.key)\n : undefined;\n\n if (oldIdx !== undefined) {\n const matchedOld = oldChildren[oldIdx]!;\n patches.push({\n type: PATCH.MOVE,\n vnode: matchedOld,\n anchor: oldChildren[oldStartIdx] || null,\n childPatches: diff(matchedOld, newStartVNode),\n });\n oldChildren[oldIdx] = null;\n keyMap.delete(newStartVNode.key!);\n } else {\n patches.push({\n type: PATCH.CREATE,\n newVNode: newStartVNode,\n anchor: oldChildren[oldStartIdx] || null,\n });\n }\n newStartIdx++;\n }\n\n // Remove unconsumed old children\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\n if (oldChildren[i] != null) {\n patches.push({ type: PATCH.REMOVE, target: oldChildren[i]! });\n }\n }\n }\n\n // Phase 3: remaining creates or removes\n if (oldStartIdx > oldEndIdx) {\n const anchor = newChildren[newEndIdx + 1] || null;\n for (let i = newStartIdx; i <= newEndIdx; i++) {\n patches.push({ type: PATCH.CREATE, newVNode: newChildren[i], anchor });\n }\n } else if (newStartIdx > newEndIdx) {\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\n if (oldChildren[i] != null) {\n patches.push({ type: PATCH.REMOVE, target: oldChildren[i]! });\n }\n }\n }\n\n return patches;\n}\n","import { TEXT_NODE, FRAGMENT } from './vnode';\nimport { PATCH } from './diff';\nimport type { VNode } from './vnode';\nimport type { Patch } from './diff';\n\nexport function createDOMNode(vnode: VNode): Node {\n if (vnode.type === TEXT_NODE) {\n const textNode = document.createTextNode(vnode.props.nodeValue);\n vnode._dom = textNode;\n return textNode;\n }\n\n if (vnode.type === FRAGMENT) {\n const frag = document.createDocumentFragment();\n for (const child of vnode.children) {\n frag.appendChild(createDOMNode(child));\n }\n // For fragments, store ref to first child for positioning\n vnode._dom = frag;\n return frag;\n }\n\n const el = document.createElement(vnode.type as string);\n applyProps(el, {}, vnode.props);\n\n for (const child of vnode.children) {\n el.appendChild(createDOMNode(child));\n }\n\n vnode._dom = el;\n return el;\n}\n\nexport function applyProps(\n el: HTMLElement,\n oldProps: Record<string, any>,\n newProps: Record<string, any>,\n): void {\n for (const key in oldProps) {\n if (key === 'children' || key === 'key') continue;\n if (!(key in newProps)) {\n removeProp(el, key, oldProps[key]);\n }\n }\n for (const key in newProps) {\n if (key === 'children' || key === 'key') continue;\n if (oldProps[key] !== newProps[key]) {\n setProp(el, key, newProps[key], oldProps[key]);\n }\n }\n}\n\nfunction setProp(el: HTMLElement, key: string, value: any, oldValue: any): void {\n if (key.startsWith('on')) {\n const eventName = key.slice(2).toLowerCase();\n if (oldValue) el.removeEventListener(eventName, oldValue);\n if (value) el.addEventListener(eventName, value);\n } else if (key === 'className') {\n el.className = value || '';\n } else if (key === 'style' && typeof value === 'object') {\n if (typeof oldValue === 'object' && oldValue) {\n for (const prop in oldValue) {\n if (!(prop in value)) (el.style as any)[prop] = '';\n }\n }\n Object.assign(el.style, value);\n } else if (key === 'ref') {\n if (typeof value === 'function') value(el);\n } else if (value === true) {\n el.setAttribute(key, '');\n } else if (value === false || value == null) {\n el.removeAttribute(key);\n } else {\n el.setAttribute(key, value);\n }\n}\n\nfunction removeProp(el: HTMLElement, key: string, oldValue: any): void {\n if (key.startsWith('on')) {\n el.removeEventListener(key.slice(2).toLowerCase(), oldValue);\n } else if (key === 'className') {\n el.className = '';\n } else {\n el.removeAttribute(key);\n }\n}\n\nexport function applyPatches(parentDom: Node, patches: Patch[]): void {\n for (const patch of patches) {\n switch (patch.type) {\n case PATCH.CREATE: {\n const dom = createDOMNode(patch.newVNode);\n if (patch.anchor?._dom) {\n parentDom.insertBefore(dom, patch.anchor._dom);\n } else {\n parentDom.appendChild(dom);\n }\n break;\n }\n\n case PATCH.REMOVE: {\n const dom = patch.target._dom;\n if (dom?.parentNode) {\n dom.parentNode.removeChild(dom);\n }\n break;\n }\n\n case PATCH.REPLACE: {\n const newDom = createDOMNode(patch.newVNode);\n const oldDom = patch.oldVNode._dom;\n if (oldDom?.parentNode) {\n oldDom.parentNode.replaceChild(newDom, oldDom);\n }\n break;\n }\n\n case PATCH.UPDATE: {\n const dom = patch.target._dom as HTMLElement;\n const { set, remove } = patch.propPatches;\n for (const key of remove) {\n removeProp(dom, key, patch.target.props[key]);\n }\n for (const key in set) {\n setProp(dom, key, set[key], patch.target.props[key]);\n }\n break;\n }\n\n case PATCH.TEXT: {\n const dom = patch.oldVNode._dom;\n if (dom) dom.nodeValue = patch.newVNode.props.nodeValue;\n break;\n }\n\n case PATCH.MOVE: {\n const dom = patch.vnode._dom;\n if (dom) {\n if (patch.anchor?._dom) {\n parentDom.insertBefore(dom, patch.anchor._dom);\n } else {\n parentDom.appendChild(dom);\n }\n }\n if (patch.childPatches?.length && dom) {\n applyPatches(dom, patch.childPatches);\n }\n break;\n }\n\n case PATCH.CHILDREN: {\n const dom = patch.parent._dom;\n if (dom && patch.childPatches.length) {\n applyPatches(dom, patch.childPatches);\n }\n break;\n }\n }\n }\n}\n","import { diff, PATCH } from './diff';\nimport { createDOMNode, applyPatches } from './patch';\nimport { CONNECTED, ComponentInstance } from './connect';\nimport { TEXT_NODE, FRAGMENT, createTextVNode } from './vnode';\nimport type { VNode, Lifecycle } from './vnode';\nimport type { Patch } from './diff';\n\ninterface RootEntry {\n vTree: VNode;\n}\n\nconst roots = new WeakMap<Node, RootEntry>();\n\nexport function render(vnode: VNode, container: Node): void {\n const prev = roots.get(container);\n\n if (!prev) {\n // First mount\n const expanded = expand(vnode, container);\n if (!expanded) return;\n\n const dom = createDOMNode(expanded);\n container.appendChild(dom);\n\n const instances: ComponentInstance[] = [];\n collectInstances(expanded, instances);\n for (const inst of instances) {\n inst.mount(container, () => reRenderInstance(inst, container));\n }\n\n roots.set(container, { vTree: expanded });\n } else {\n // Update\n const expanded = expand(vnode, container);\n\n const oldInstances: ComponentInstance[] = [];\n collectInstances(prev.vTree, oldInstances);\n\n const patches = diff(prev.vTree, expanded);\n applyPatches(container, patches);\n\n const newInstances: ComponentInstance[] = [];\n if (expanded) collectInstances(expanded, newInstances);\n\n // Unmount removed instances\n const newSet = new Set(newInstances);\n for (const inst of oldInstances) {\n if (!newSet.has(inst)) {\n inst.unmount();\n }\n }\n\n // Mount new instances\n const oldSet = new Set(oldInstances);\n for (const inst of newInstances) {\n if (!oldSet.has(inst)) {\n inst.mount(container, () => reRenderInstance(inst, container));\n }\n }\n\n roots.set(container, { vTree: expanded! });\n }\n}\n\nfunction expand(vnode: VNode | null, parentDom: Node): VNode | null {\n if (vnode == null) return null;\n\n if (typeof vnode.type === 'function') {\n if ((vnode.type as any)[CONNECTED]) {\n // Connected component — with error boundary support\n const lifecycle: Lifecycle | undefined = (vnode.type as any)._lifecycle;\n\n try {\n const instance = new ComponentInstance(vnode.type, vnode.props);\n const childVNode = vnode.type(vnode.props);\n const expanded = expand(childVNode, parentDom);\n\n // Use placeholder for null returns so instance stays in tree (subscribes)\n const result = expanded ?? createTextVNode('');\n\n if (result._instance) {\n // Nested connected component: wrap outer in a boundary element\n // so each instance has its own VNode (no _instance collision).\n const boundary: VNode = {\n type: 'div',\n props: { style: { display: 'contents' } },\n children: [result],\n key: vnode.key,\n };\n boundary._instance = instance;\n instance.lastVTree = boundary;\n return boundary;\n }\n\n result._instance = instance;\n instance.lastVTree = result;\n\n return result;\n } catch (error) {\n if (lifecycle?.onError) {\n const fallbackVNode = lifecycle.onError({ error, props: vnode.props });\n return expand(fallbackVNode, parentDom);\n }\n throw error;\n }\n }\n\n // Plain function component\n const childVNode = vnode.type({ ...vnode.props, children: vnode.children });\n return expand(childVNode, parentDom);\n }\n\n // Element, text, or fragment: recursively expand children\n if (vnode.children?.length) {\n vnode.children = vnode.children\n .map(child => expand(child, parentDom))\n .filter((c): c is VNode => c != null);\n }\n\n return vnode;\n}\n\nfunction reRenderInstance(instance: ComponentInstance, parentDom: Node): void {\n // Guard: skip re-render if instance was unmounted (e.g. parent already rebuilt this subtree)\n if (!instance._renderCallback) return;\n\n const connectedFn = instance.connectedFn;\n const lifecycle: Lifecycle | undefined = (connectedFn as any)._lifecycle;\n\n try {\n const newVNode = connectedFn(instance.props);\n const rawExpanded = expand(newVNode, parentDom);\n\n // Use placeholder for null returns so instance stays in tree\n let innerContent = rawExpanded ?? createTextVNode('');\n\n // Wrap if nested connected component (same logic as expand)\n let newTree: VNode;\n if (innerContent._instance && innerContent._instance !== instance) {\n newTree = {\n type: 'div',\n props: { style: { display: 'contents' } },\n children: [innerContent],\n key: null,\n } as VNode;\n newTree._instance = instance;\n } else {\n innerContent._instance = instance;\n newTree = innerContent;\n }\n\n if (instance.lastVTree) {\n // Refresh stale inner instance references before diffing\n refreshInnerInstances(instance.lastVTree, instance);\n\n const patches = diff(instance.lastVTree, newTree);\n\n // Find the actual parent DOM node to patch against\n const domParent = instance.lastVTree._dom?.parentNode || parentDom;\n applyPatches(domParent, patches);\n\n // Transfer the _dom reference from old to new\n if (!newTree._dom) {\n newTree._dom = instance.lastVTree._dom;\n }\n }\n\n // Collect inner instances for lifecycle management\n const oldInner: ComponentInstance[] = [];\n collectInnerInstances(instance.lastVTree, oldInner, instance);\n const newInner: ComponentInstance[] = [];\n collectInnerInstances(newTree, newInner, instance);\n\n // Unmount removed inner instances\n const newInstSet = new Set(newInner);\n for (const inst of oldInner) {\n if (!newInstSet.has(inst)) inst.unmount();\n }\n\n instance.lastVTree = newTree;\n\n // Mount new inner instances\n const oldInstSet = new Set(oldInner);\n for (const inst of newInner) {\n if (!oldInstSet.has(inst)) {\n inst.mount(parentDom, () => reRenderInstance(inst, parentDom));\n }\n }\n\n // Lifecycle: onUpdate fires after every re-render (not on initial mount)\n if (lifecycle?.onUpdate) {\n lifecycle.onUpdate({\n dom: newTree?._dom,\n props: instance.props,\n });\n }\n\n instance.updateSelected();\n } catch (error) {\n if (lifecycle?.onError) {\n const fallbackVNode = lifecycle.onError({ error, props: instance.props });\n const fallbackExpanded = expand(fallbackVNode, parentDom);\n\n // Replace current DOM with fallback\n if (instance.lastVTree && fallbackExpanded) {\n refreshInnerInstances(instance.lastVTree, instance);\n\n const patches = diff(instance.lastVTree, fallbackExpanded);\n const domParent = instance.lastVTree._dom?.parentNode || parentDom;\n applyPatches(domParent, patches);\n\n if (!fallbackExpanded._dom) {\n fallbackExpanded._dom = instance.lastVTree._dom;\n }\n }\n\n // Unmount old inner instances on error fallback\n const oldInner: ComponentInstance[] = [];\n collectInnerInstances(instance.lastVTree, oldInner, instance);\n for (const inst of oldInner) inst.unmount();\n\n instance.lastVTree = fallbackExpanded;\n instance.updateSelected();\n } else {\n throw error;\n }\n }\n}\n\n/**\n * Before diffing a parent's lastVTree, refresh any inner connected components'\n * subtrees to reflect their current state (they may have re-rendered independently).\n */\nfunction refreshInnerInstances(vnode: VNode | null, skip: ComponentInstance): void {\n if (!vnode || !vnode.children) return;\n for (let i = 0; i < vnode.children.length; i++) {\n const child = vnode.children[i];\n if (child._instance && child._instance !== skip && child._instance.lastVTree) {\n // Replace stale reference with instance's current lastVTree\n if (child._instance.lastVTree !== child) {\n vnode.children[i] = child._instance.lastVTree;\n }\n }\n refreshInnerInstances(vnode.children[i], skip);\n }\n}\n\nfunction unmountSubtree(vnode: VNode | null, skip?: ComponentInstance): void {\n if (!vnode) return;\n if (vnode._instance && vnode._instance !== skip) vnode._instance.unmount();\n if (vnode.children) {\n for (const child of vnode.children) {\n unmountSubtree(child, skip);\n }\n }\n}\n\nfunction collectInstances(vnode: VNode | null, result: ComponentInstance[]): void {\n if (!vnode) return;\n if (vnode._instance) result.push(vnode._instance);\n if (vnode.children) {\n for (const child of vnode.children) {\n collectInstances(child, result);\n }\n }\n}\n\nfunction collectInnerInstances(\n vnode: VNode | null,\n result: ComponentInstance[],\n skip: ComponentInstance,\n): void {\n if (!vnode) return;\n if (vnode._instance && vnode._instance !== skip) result.push(vnode._instance);\n if (vnode.children) {\n for (const child of vnode.children) {\n collectInnerInstances(child, result, skip);\n }\n }\n}\n","import type { PulseDevtools } from './core';\n\n/**\n * Jump to a specific point in a store's action history.\n * Uses __devtools_replace__ to force-set the store's state.\n */\nexport function travelTo(\n devtools: PulseDevtools,\n storeName: string,\n entryIndex: number,\n): void {\n const tracked = devtools.getTrackedStore(storeName);\n if (!tracked) {\n throw new Error(`[pulse-devtools] Unknown store: \"${storeName}\"`);\n }\n\n const { store, history } = tracked;\n\n if (entryIndex < 0 || entryIndex >= history.length) {\n throw new Error(\n `[pulse-devtools] Index ${entryIndex} out of range (0..${history.length - 1})`,\n );\n }\n\n const targetState = history[entryIndex].nextState;\n store.dispatch('__devtools_replace__', targetState);\n devtools.emit({ type: 'time-travel', storeName, data: { entryIndex } });\n}\n\n/**\n * Replay actions from a given index forward, starting from that entry's prevState.\n * Useful for re-executing the action chain after modifying an earlier action.\n */\nexport function replayFrom(\n devtools: PulseDevtools,\n storeName: string,\n fromIndex: number,\n): void {\n const tracked = devtools.getTrackedStore(storeName);\n if (!tracked) {\n throw new Error(`[pulse-devtools] Unknown store: \"${storeName}\"`);\n }\n\n const { store, history } = tracked;\n\n if (fromIndex < 0 || fromIndex >= history.length) {\n throw new Error(\n `[pulse-devtools] Index ${fromIndex} out of range (0..${history.length - 1})`,\n );\n }\n\n // Snapshot the entries to replay before we start (dispatching adds new entries)\n const entriesToReplay = history.slice(fromIndex);\n\n // Reset to the state before the fromIndex action\n const baseState = history[fromIndex].prevState;\n store.dispatch('__devtools_replace__', baseState);\n\n // Replay each action\n for (const entry of entriesToReplay) {\n store.dispatch(entry.actionName, entry.payload);\n }\n\n devtools.emit({ type: 'time-travel', storeName, data: { replayFrom: fromIndex } });\n}\n","// Dark theme (Catppuccin-inspired) — all inline style objects\n\nexport const colors = {\n base: '#1e1e2e',\n surface0: '#313244',\n surface1: '#45475a',\n surface2: '#585b70',\n overlay0: '#6c7086',\n text: '#cdd6f4',\n subtext0: '#a6adc8',\n subtext1: '#bac2de',\n blue: '#89b4fa',\n green: '#a6e3a1',\n red: '#f38ba8',\n yellow: '#f9e2af',\n mauve: '#cba6f7',\n teal: '#94e2d5',\n peach: '#fab387',\n};\n\nexport const panelRoot: Record<string, string> = {\n position: 'fixed',\n bottom: '0',\n left: '0',\n right: '0',\n height: '320px',\n backgroundColor: colors.base,\n color: colors.text,\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: '12px',\n lineHeight: '1.5',\n zIndex: '2147483647',\n display: 'flex',\n flexDirection: 'column',\n borderTop: `2px solid ${colors.mauve}`,\n overflow: 'hidden',\n};\n\nexport const tabBar: Record<string, string> = {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: colors.surface0,\n borderBottom: `1px solid ${colors.surface1}`,\n padding: '0 8px',\n height: '32px',\n flexShrink: '0',\n};\n\nexport const tabButton = (active: boolean): Record<string, string> => ({\n background: 'none',\n border: 'none',\n color: active ? colors.mauve : colors.subtext0,\n fontFamily: 'inherit',\n fontSize: '12px',\n padding: '6px 12px',\n cursor: 'pointer',\n borderBottom: active ? `2px solid ${colors.mauve}` : '2px solid transparent',\n marginBottom: '-1px',\n});\n\nexport const closeButton: Record<string, string> = {\n background: 'none',\n border: 'none',\n color: colors.overlay0,\n fontSize: '16px',\n cursor: 'pointer',\n marginLeft: 'auto',\n padding: '4px 8px',\n fontFamily: 'inherit',\n};\n\nexport const tabContent: Record<string, string> = {\n flex: '1',\n overflow: 'auto',\n padding: '8px 12px',\n};\n\nexport const splitPane: Record<string, string> = {\n display: 'flex',\n height: '100%',\n gap: '1px',\n};\n\nexport const paneLeft: Record<string, string> = {\n width: '200px',\n flexShrink: '0',\n borderRight: `1px solid ${colors.surface1}`,\n overflow: 'auto',\n padding: '4px 0',\n};\n\nexport const paneRight: Record<string, string> = {\n flex: '1',\n overflow: 'auto',\n padding: '8px',\n};\n\nexport const storeItem = (selected: boolean): Record<string, string> => ({\n padding: '4px 12px',\n cursor: 'pointer',\n backgroundColor: selected ? colors.surface1 : 'transparent',\n color: selected ? colors.blue : colors.text,\n});\n\nexport const treeKey: Record<string, string> = {\n color: colors.mauve,\n};\n\nexport const treeValue: Record<string, string> = {\n color: colors.green,\n};\n\nexport const treeString: Record<string, string> = {\n color: colors.yellow,\n};\n\nexport const treeBool: Record<string, string> = {\n color: colors.peach,\n};\n\nexport const treeNull: Record<string, string> = {\n color: colors.overlay0,\n fontStyle: 'italic',\n};\n\nexport const actionEntry = (active: boolean): Record<string, string> => ({\n padding: '4px 8px',\n cursor: 'pointer',\n backgroundColor: active ? colors.surface1 : 'transparent',\n borderLeft: active ? `3px solid ${colors.blue}` : '3px solid transparent',\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n});\n\nexport const actionName: Record<string, string> = {\n color: colors.blue,\n fontWeight: 'bold',\n};\n\nexport const actionTime: Record<string, string> = {\n color: colors.overlay0,\n fontSize: '10px',\n};\n\nexport const slider: Record<string, string> = {\n width: '100%',\n accentColor: colors.mauve,\n margin: '4px 0 8px',\n};\n\nexport const filterInput: Record<string, string> = {\n width: '100%',\n backgroundColor: colors.surface0,\n border: `1px solid ${colors.surface1}`,\n color: colors.text,\n padding: '4px 8px',\n fontFamily: 'inherit',\n fontSize: '12px',\n borderRadius: '4px',\n outline: 'none',\n marginBottom: '8px',\n boxSizing: 'border-box',\n};\n\nexport const componentItem: Record<string, string> = {\n padding: '4px 8px',\n borderBottom: `1px solid ${colors.surface0}`,\n};\n\nexport const componentName: Record<string, string> = {\n color: colors.teal,\n fontWeight: 'bold',\n};\n\nexport const componentStores: Record<string, string> = {\n color: colors.overlay0,\n fontSize: '10px',\n marginLeft: '8px',\n};\n\nexport const badge: Record<string, string> = {\n display: 'inline-block',\n backgroundColor: colors.surface1,\n color: colors.subtext0,\n padding: '1px 6px',\n borderRadius: '8px',\n fontSize: '10px',\n marginLeft: '4px',\n};\n\nexport const title: Record<string, string> = {\n color: colors.mauve,\n fontWeight: 'bold',\n fontSize: '12px',\n marginRight: '8px',\n};\n","import { h } from '../../createElement';\nimport type { VNode } from '../../vnode';\nimport * as s from './styles';\n\nfunction renderValue(value: any, depth: number): VNode {\n if (value === null) {\n return h('span', { style: s.treeNull }, 'null');\n }\n if (value === undefined) {\n return h('span', { style: s.treeNull }, 'undefined');\n }\n if (typeof value === 'string') {\n return h('span', { style: s.treeString }, `\"${value}\"`);\n }\n if (typeof value === 'boolean') {\n return h('span', { style: s.treeBool }, String(value));\n }\n if (typeof value === 'number') {\n return h('span', { style: s.treeValue }, String(value));\n }\n if (Array.isArray(value)) {\n if (value.length === 0) return h('span', { style: s.treeValue }, '[]');\n if (depth > 4) return h('span', { style: s.treeNull }, '[…]');\n return h('div', { style: { paddingLeft: '12px' } },\n ...value.map((item, i) =>\n h('div', { key: i },\n h('span', { style: s.treeKey }, `${i}: `),\n renderValue(item, depth + 1),\n ),\n ),\n );\n }\n if (typeof value === 'object') {\n const keys = Object.keys(value);\n if (keys.length === 0) return h('span', { style: s.treeValue }, '{}');\n if (depth > 4) return h('span', { style: s.treeNull }, '{…}');\n return h('div', { style: { paddingLeft: '12px' } },\n ...keys.map((key) =>\n h('div', { key },\n h('span', { style: s.treeKey }, `${key}: `),\n renderValue(value[key], depth + 1),\n ),\n ),\n );\n }\n return h('span', { style: s.treeValue }, String(value));\n}\n\nexport function StoresTab({\n storeNames,\n selectedStore,\n storeStates,\n onSelectStore,\n}: {\n storeNames: string[];\n selectedStore: string | null;\n storeStates: Record<string, any>;\n onSelectStore: (name: string) => void;\n}): VNode {\n const currentState = selectedStore ? storeStates[selectedStore] : null;\n\n return h('div', { style: s.splitPane },\n h('div', { style: s.paneLeft },\n ...storeNames.map((name) =>\n h('div', {\n key: name,\n style: s.storeItem(name === selectedStore),\n onClick: () => onSelectStore(name),\n }, name),\n ),\n ),\n h('div', { style: s.paneRight },\n selectedStore\n ? h('div', null,\n h('div', { style: { marginBottom: '8px', color: s.colors.subtext0 } },\n `State of `, h('span', { style: s.actionName }, selectedStore),\n ),\n currentState != null\n ? renderValue(currentState, 0)\n : h('span', { style: s.treeNull }, 'No state'),\n )\n : h('span', { style: s.treeNull }, 'Select a store'),\n ),\n );\n}\n","import { h } from '../../createElement';\nimport type { VNode } from '../../vnode';\nimport type { ActionEntry } from '../../middleware';\nimport * as s from './styles';\n\nfunction formatTime(ts: number): string {\n const d = new Date(ts);\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n}\n\nexport function ActionsTab({\n actionLog,\n timeTravelIndex,\n filter,\n onFilterChange,\n onTravelTo,\n onSliderChange,\n}: {\n actionLog: ActionEntry[];\n timeTravelIndex: number;\n filter: string;\n onFilterChange: (value: string) => void;\n onTravelTo: (index: number) => void;\n onSliderChange: (index: number) => void;\n}): VNode {\n const filtered = filter\n ? actionLog.filter((e) => e.actionName.toLowerCase().includes(filter.toLowerCase()))\n : actionLog;\n\n return h('div', { style: { height: '100%', display: 'flex', flexDirection: 'column' } },\n // Filter\n h('input', {\n style: s.filterInput,\n placeholder: 'Filter actions…',\n value: filter,\n onInput: (e: any) => onFilterChange(e.target.value),\n }),\n // Slider\n actionLog.length > 0\n ? h('div', { style: { flexShrink: '0' } },\n h('input', {\n type: 'range',\n style: s.slider,\n min: '0',\n max: String(actionLog.length - 1),\n value: String(timeTravelIndex),\n onInput: (e: any) => onSliderChange(Number(e.target.value)),\n }),\n h('div', { style: { color: s.colors.overlay0, fontSize: '10px', marginBottom: '4px' } },\n `${timeTravelIndex + 1} / ${actionLog.length}`,\n ),\n )\n : null,\n // Action list\n h('div', { style: { flex: '1', overflow: 'auto' } },\n ...filtered.map((entry, idx) => {\n // Map filtered index back to actual index\n const actualIdx = actionLog.indexOf(entry);\n return h('div', {\n key: actualIdx,\n style: s.actionEntry(actualIdx === timeTravelIndex),\n onClick: () => onTravelTo(actualIdx),\n },\n h('span', null,\n h('span', { style: s.actionName }, entry.actionName),\n entry.payload !== undefined\n ? h('span', { style: { color: s.colors.subtext0, marginLeft: '8px' } },\n typeof entry.payload === 'object'\n ? JSON.stringify(entry.payload)\n : String(entry.payload),\n )\n : null,\n ),\n h('span', { style: s.actionTime }, formatTime(entry.timestamp)),\n );\n }),\n filtered.length === 0\n ? h('div', { style: { color: s.colors.overlay0, padding: '8px' } },\n actionLog.length === 0 ? 'No actions yet' : 'No matching actions',\n )\n : null,\n ),\n );\n}\n","import { h } from '../../createElement';\nimport type { VNode } from '../../vnode';\nimport type { TrackedComponent } from '../core';\nimport * as s from './styles';\n\nexport function ComponentsTab({\n components,\n}: {\n components: TrackedComponent[];\n}): VNode {\n if (components.length === 0) {\n return h('div', { style: { color: s.colors.overlay0, padding: '8px' } },\n 'No connected components mounted',\n );\n }\n\n return h('div', null,\n ...components.map((comp) =>\n h('div', { key: comp.id, style: s.componentItem },\n h('span', { style: s.componentName }, comp.displayName),\n comp.storeNames.length > 0\n ? h('span', { style: s.componentStores },\n comp.storeNames.map((name) =>\n h('span', { key: name, style: s.badge }, name),\n ),\n )\n : null,\n ),\n ),\n );\n}\n","import { h } from '../../createElement';\nimport { createStore } from '../../store';\nimport { connect } from '../../connect';\nimport { render } from '../../render';\nimport type { VNode } from '../../vnode';\nimport type { PulseDevtools } from '../core';\nimport type { ActionEntry } from '../../middleware';\nimport { travelTo } from '../time-travel';\nimport { StoresTab } from './stores-tab';\nimport { ActionsTab } from './actions-tab';\nimport { ComponentsTab } from './components-tab';\nimport * as s from './styles';\n\n// --- Internal panel store (no devtools middleware on itself) ---\n\ninterface PanelState {\n open: boolean;\n activeTab: 'stores' | 'actions' | 'components';\n selectedStore: string | null;\n timeTravelIndex: number;\n storeNames: string[];\n storeStates: Record<string, any>;\n actionLog: ActionEntry[];\n filter: string;\n components: { id: number; displayName: string; storeNames: string[] }[];\n}\n\nfunction createPanelStore() {\n return createStore<PanelState>({\n state: {\n open: false,\n activeTab: 'stores',\n selectedStore: null,\n timeTravelIndex: -1,\n storeNames: [],\n storeStates: {},\n actionLog: [],\n filter: '',\n components: [],\n },\n actions: {\n toggle: (state) => ({ ...state, open: !state.open }),\n open: (state) => ({ ...state, open: true }),\n close: (state) => ({ ...state, open: false }),\n setTab: (state, tab) => ({ ...state, activeTab: tab }),\n selectStore: (state, name) => ({ ...state, selectedStore: name }),\n setFilter: (state, filter) => ({ ...state, filter }),\n setTimeTravelIndex: (state, index) => ({ ...state, timeTravelIndex: index }),\n sync: (state, data) => ({ ...state, ...data }),\n },\n });\n}\n\n// --- Panel root component ---\n\nfunction PanelRootView({\n open,\n activeTab,\n selectedStore,\n timeTravelIndex,\n storeNames,\n storeStates,\n actionLog,\n filter,\n components,\n panelActions,\n}: PanelState & { panelActions: any }): VNode | null {\n if (!open) return null;\n\n const tabs: Array<{ id: PanelState['activeTab']; label: string }> = [\n { id: 'stores', label: 'Stores' },\n { id: 'actions', label: 'Actions' },\n { id: 'components', label: 'Components' },\n ];\n\n let tabContent: VNode;\n if (activeTab === 'stores') {\n tabContent = StoresTab({\n storeNames,\n selectedStore,\n storeStates,\n onSelectStore: panelActions.selectStore,\n });\n } else if (activeTab === 'actions') {\n tabContent = ActionsTab({\n actionLog,\n timeTravelIndex,\n filter,\n onFilterChange: panelActions.setFilter,\n onTravelTo: panelActions.travelTo,\n onSliderChange: panelActions.sliderChange,\n });\n } else {\n tabContent = ComponentsTab({ components });\n }\n\n return h('div', { style: s.panelRoot },\n // Tab bar (all children keyed to avoid mixed key warnings)\n h('div', { style: s.tabBar },\n h('span', { key: 'title', style: s.title }, 'Pulse'),\n ...tabs.map((tab) =>\n h('button', {\n key: tab.id,\n style: s.tabButton(tab.id === activeTab),\n onClick: () => panelActions.setTab(tab.id),\n }, tab.label),\n ),\n h('span', { key: 'badge', style: s.badge }, `${storeNames.length} stores`),\n h('button', {\n key: 'close',\n style: s.closeButton,\n onClick: panelActions.close,\n }, '\\u00d7'),\n ),\n // Content\n h('div', { style: s.tabContent }, tabContent),\n );\n}\n\n// --- Wire everything up ---\n\nexport function createPanel(\n devtools: PulseDevtools,\n markInternal?: (store: any) => void,\n) {\n const panelStore = createPanelStore();\n if (markInternal) markInternal(panelStore);\n\n // Sync devtools state into panel store (with re-entrancy guard)\n let syncing = false;\n function syncState() {\n if (syncing) return;\n syncing = true;\n try {\n const storeNames = devtools.getStoreNames();\n const storeStates: Record<string, any> = {};\n for (const name of storeNames) {\n storeStates[name] = devtools.getStoreState(name);\n }\n\n const selectedStore = panelStore.getState().selectedStore;\n const storeName = selectedStore || storeNames[0] || null;\n const history = storeName ? devtools.getHistory(storeName) : [];\n\n panelStore.dispatch('sync', {\n storeNames,\n storeStates,\n actionLog: history,\n timeTravelIndex: history.length > 0 ? history.length - 1 : -1,\n selectedStore: storeName,\n components: devtools.getComponents(),\n });\n } finally {\n syncing = false;\n }\n }\n\n // Listen to devtools events (skip component events to avoid feedback loop)\n devtools.on((event) => {\n if (event.type === 'component-mounted' || event.type === 'component-unmounted') return;\n syncState();\n });\n\n // Panel action helpers\n const panelActions = {\n selectStore: (name: string) => {\n panelStore.dispatch('selectStore', name);\n // Re-sync to load that store's history\n const history = devtools.getHistory(name);\n panelStore.dispatch('sync', {\n actionLog: history,\n timeTravelIndex: history.length > 0 ? history.length - 1 : -1,\n });\n },\n setTab: (tab: string) => panelStore.dispatch('setTab', tab),\n setFilter: (filter: string) => panelStore.dispatch('setFilter', filter),\n close: () => panelStore.dispatch('close'),\n travelTo: (index: number) => {\n const storeName = panelStore.getState().selectedStore;\n if (storeName) {\n travelTo(devtools, storeName, index);\n panelStore.dispatch('setTimeTravelIndex', index);\n }\n },\n sliderChange: (index: number) => {\n const storeName = panelStore.getState().selectedStore;\n if (storeName) {\n travelTo(devtools, storeName, index);\n panelStore.dispatch('setTimeTravelIndex', index);\n }\n },\n };\n\n // Connected panel root\n const ConnectedPanel = connect({\n open: panelStore.select((s) => s.open),\n activeTab: panelStore.select((s) => s.activeTab),\n selectedStore: panelStore.select((s) => s.selectedStore),\n timeTravelIndex: panelStore.select((s) => s.timeTravelIndex),\n storeNames: panelStore.select((s) => s.storeNames),\n storeStates: panelStore.select((s) => s.storeStates),\n actionLog: panelStore.select((s) => s.actionLog),\n filter: panelStore.select((s) => s.filter),\n components: panelStore.select((s) => s.components),\n })((props: any) => PanelRootView({ ...props, panelActions }));\n\n let container: HTMLElement | null = null;\n\n function mount() {\n if (container) return;\n container = document.createElement('div');\n container.id = 'pulse-devtools-root';\n document.body.appendChild(container);\n render(h(ConnectedPanel, null), container);\n syncState();\n }\n\n function openPanel() {\n mount();\n panelStore.dispatch('open');\n }\n\n function closePanel() {\n panelStore.dispatch('close');\n }\n\n function togglePanel() {\n mount();\n panelStore.dispatch('toggle');\n }\n\n return { openPanel, closePanel, togglePanel, panelStore };\n}\n","import { __setComponentHooks, ComponentInstance } from '../connect';\nimport { PulseDevtools, instrumentStore } from './core';\nimport { travelTo, replayFrom } from './time-travel';\nimport { createPanel } from './panel/panel';\n\n// Singleton devtools instance\nconst devtools = new PulseDevtools();\n\n// Stores that belong to the devtools panel itself (excluded from tracking)\nconst internalStores = new WeakSet<any>();\n\nexport function _markInternalStore(store: any): void {\n internalStores.add(store);\n}\n\n// Wire component tracking hooks\n__setComponentHooks(\n (instance: ComponentInstance) => {\n const bindings = (instance.connectedFn as any)._bindings || {};\n const boundStores = Object.values(bindings).map((b: any) => b.store);\n\n // Skip components only bound to internal (panel) stores\n if (boundStores.length > 0 && boundStores.every((s) => internalStores.has(s))) {\n return;\n }\n\n const storeNames = boundStores.map((s) => s.name || 'unnamed');\n const displayName =\n (instance.connectedFn as any).displayName || 'Unknown';\n const id = devtools.trackComponent(displayName, storeNames);\n (instance as any)._devtoolsId = id;\n },\n (instance: ComponentInstance) => {\n const id = (instance as any)._devtoolsId;\n if (id != null) {\n devtools.untrackComponent(id);\n }\n },\n);\n\n// Panel (lazy — only created when opened)\nlet panel: ReturnType<typeof createPanel> | null = null;\n\nfunction ensurePanel() {\n if (!panel) {\n panel = createPanel(devtools, _markInternalStore);\n }\n return panel;\n}\n\nexport function openPanel(): void {\n ensurePanel().openPanel();\n}\n\nexport function closePanel(): void {\n if (panel) panel.closePanel();\n}\n\nexport function togglePanel(): void {\n ensurePanel().togglePanel();\n}\n\n// Keyboard shortcut: Ctrl+Shift+P\nif (typeof window !== 'undefined') {\n window.addEventListener('keydown', (e) => {\n if (e.ctrlKey && e.shiftKey && e.key === 'P') {\n e.preventDefault();\n togglePanel();\n }\n });\n\n // Expose on window for console access\n (window as any).__PULSE_DEVTOOLS__ = devtools;\n}\n\n// Re-exports\nexport { PulseDevtools, instrumentStore } from './core';\nexport { travelTo, replayFrom } from './time-travel';\nexport { devtools };\n"],"names":["pending","queue","scheduleUpdate","callback","flush","batch","CONNECTED","G","hooks","__setComponentHooks","onMount","onUnmount","connect","bindings","lifecycle","Component","b","ConnectedComponent","props","selectedProps","propName","store","selector","ComponentInstance","connectedFn","__publicField","parentDom","renderCallback","_a","unsub","cleanup","changed","newValue","shallowEqual","a","keysA","keysB","key","createStore","config","state","actions","listeners","mw","getState","notify","listener","dispatchSimple","actionName","payload","action","nextState","dispatchWithMiddleware","ctx","storeObj","idx","next","fn","dispatch","subscribe","select","selectorFn","actionHistory","history","opts","nextComponentId","PulseDevtools","name","storeName","all","tracked","displayName","storeNames","id","comp","event","instrumentStore","devtools","historyMw","TEXT_NODE","FRAGMENT","createTextVNode","text","normalizeChild","child","flattenChildren","rawChildren","result","normalized","h","type","children","PATCH","diff","oldVNode","newVNode","patches","propPatches","diffProps","childPatches","diffChildren","oldProps","newProps","set","remove","hasChanges","sameVNode","warnChildKeys","label","seen","keyedCount","unkeyedCount","oldChildren","newChildren","oldStartIdx","oldEndIdx","newStartIdx","newEndIdx","oldStartVNode","oldEndVNode","newStartVNode","newEndVNode","keyMap","i","oldIdx","matchedOld","anchor","createDOMNode","vnode","textNode","frag","el","applyProps","removeProp","setProp","value","oldValue","eventName","prop","applyPatches","_b","_c","patch","dom","newDom","oldDom","roots","render","container","prev","expanded","expand","oldInstances","collectInstances","newInstances","newSet","inst","oldSet","reRenderInstance","instances","instance","childVNode","boundary","error","fallbackVNode","c","innerContent","newTree","refreshInnerInstances","domParent","oldInner","collectInnerInstances","newInner","newInstSet","oldInstSet","fallbackExpanded","skip","travelTo","entryIndex","targetState","replayFrom","fromIndex","entriesToReplay","baseState","entry","colors","panelRoot","tabBar","tabButton","active","closeButton","tabContent","splitPane","paneLeft","paneRight","storeItem","selected","treeKey","treeValue","treeString","treeBool","treeNull","actionEntry","actionTime","slider","filterInput","componentItem","componentName","componentStores","badge","title","renderValue","depth","s.treeNull","s.treeString","s.treeBool","s.treeValue","item","s.treeKey","keys","StoresTab","selectedStore","storeStates","onSelectStore","currentState","s.splitPane","s.paneLeft","s.storeItem","s.paneRight","s.colors","s.actionName","formatTime","ts","d","pad","n","ActionsTab","actionLog","timeTravelIndex","filter","onFilterChange","onTravelTo","onSliderChange","filtered","e","s.filterInput","s.slider","actualIdx","s.actionEntry","s.actionTime","ComponentsTab","components","s.componentItem","s.componentName","s.componentStores","s.badge","createPanelStore","tab","index","data","PanelRootView","open","activeTab","panelActions","tabs","s.panelRoot","s.tabBar","s.title","s.tabButton","s.closeButton","s.tabContent","createPanel","markInternal","panelStore","syncing","syncState","ConnectedPanel","s","mount","openPanel","closePanel","togglePanel","internalStores","_markInternalStore","boundStores","panel","ensurePanel"],"mappings":";;;AAAA,IAAIA,IAAU;AACd,MAAMC,wBAAY,IAAA;AAEX,SAASC,GAAeC,GAA4B;AACzD,EAAAF,EAAM,IAAIE,CAAQ,GACbH,MACHA,IAAU,IACV,eAAeI,EAAK;AAExB;AAEA,SAASA,KAAc;AACrB,QAAMC,IAAQ,CAAC,GAAGJ,CAAK;AACvB,EAAAA,EAAM,MAAA,GACND,IAAU;AACV,aAAWG,KAAYE;AACrB,IAAAF,EAAA;AAEJ;ACfO,MAAMG,IAA2B,OAAO,iBAAiB,GAS1DC,IAAI;AACLA,EAAE,oBACLA,EAAE,kBAAkB,EAAE,SA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D4H,IAAc,OAAO,OAAO/Q,CAAQ,EAAE,IAAI,CAACG,MAAWA,EAAE,KAAK;AAGnE,QAAI4Q,EAAY,SAAS,KAAKA,EAAY,MAAM,CAACP,MAAMK,GAAe,IAAIL,CAAC,CAAC;AAC1E;AAGF,UAAM7M,IAAaoN,EAAY,IAAI,CAACP,MAAMA,EAAE,QAAQ,SAAS,GACvD9M,IACHyF,EAAS,YAAoB,eAAe,WACzCvF,IAAKI,EAAS,eAAeN,GAAaC,CAAU;AACzD,IAAAwF,EAAiB,cAAcvF;AAAA,EAClC;AAAA,EACA,CAACuF,MAAgC;AAC/B,UAAMvF,IAAMuF,EAAiB;AAC7B,IAAIvF,KAAM,QACRI,EAAS,iBAAiBJ,CAAE;AAAA,EAEhC;AACF;AAGA,IAAIoN,IAA+C;AAEnD,SAASC,KAAc;AACrB,SAAKD,MACHA,IAAQd,GAAYlM,GAAU8M,EAAkB,IAE3CE;AACT;AAEO,SAASN,KAAkB;AAChC,EAAAO,GAAA,EAAc,UAAA;AAChB;AAEO,SAASN,KAAmB;AACjC,EAAIK,OAAa,WAAA;AACnB;AAEO,SAASJ,KAAoB;AAClC,EAAAK,GAAA,EAAc,YAAA;AAChB;AAGI,OAAO,SAAW,QACpB,OAAO,iBAAiB,WAAW,CAAC,MAAM;AACxC,EAAI,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,QACvC,EAAE,eAAA,GACFL,GAAA;AAEJ,CAAC,GAGA,OAAe,qBAAqB5M;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { connect } from './connect';
|
|
|
4
4
|
export { render } from './render';
|
|
5
5
|
export { flushSync } from './scheduler';
|
|
6
6
|
export { createRouter } from './router';
|
|
7
|
+
export { logger, actionHistory } from './middleware';
|
|
7
8
|
export type { VNode, ComponentFunction, Bindings, Lifecycle } from './vnode';
|
|
8
9
|
export type { Store, StoreConfig, StoreActions, SelectorBinding } from './store';
|
|
9
10
|
export type { RouteState, RouteConfig, RouterOptions, Router } from './router';
|
|
11
|
+
export type { Middleware, DispatchContext, ActionEntry } from './middleware';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Store } from './store';
|
|
2
|
+
export interface DispatchContext<S = any> {
|
|
3
|
+
store: Store<S>;
|
|
4
|
+
actionName: string;
|
|
5
|
+
payload: any;
|
|
6
|
+
prevState: S;
|
|
7
|
+
nextState: S | undefined;
|
|
8
|
+
}
|
|
9
|
+
export type Middleware<S = any> = (ctx: DispatchContext<S>, next: () => void) => void;
|
|
10
|
+
export interface ActionEntry {
|
|
11
|
+
actionName: string;
|
|
12
|
+
payload: any;
|
|
13
|
+
prevState: any;
|
|
14
|
+
nextState: any;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Logger middleware — logs action dispatches with prev/next state.
|
|
19
|
+
*/
|
|
20
|
+
export declare function logger(): Middleware;
|
|
21
|
+
/**
|
|
22
|
+
* Action history middleware — pushes entries to a caller-owned array.
|
|
23
|
+
*/
|
|
24
|
+
export declare function actionHistory(history: ActionEntry[], opts?: {
|
|
25
|
+
maxEntries?: number;
|
|
26
|
+
}): Middleware;
|
package/dist/pulse.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var nt=Object.defineProperty;var st=(t,e,s)=>e in t?nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var g=(t,e,s)=>st(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=Symbol("TEXT_NODE"),z=Symbol("FRAGMENT");function U(t){return{type:D,props:{nodeValue:String(t)},children:[],key:null}}function rt(t){return t==null||typeof t=="boolean"?null:typeof t=="string"||typeof t=="number"?U(t):t}function H(t){const e=[];for(const s of t)if(Array.isArray(s))e.push(...H(s));else{const n=rt(s);n!==null&&e.push(n)}return e}function I(t,e,...s){e=e||{};const n=e.key??null;e.key!==void 0&&(e={...e},delete e.key);const o=H(s);return{type:t,props:e,children:o,key:n}}function K(t){let e=t.state;const s=t.actions,n=new Set;function o(){return e}function r(i,u){const h=s[i];if(!h)throw new Error(`[pulse] Unknown action: "${i}"`);const p=h(e,u);if(p!==e){e=p;for(const f of n)f(e)}}function c(i){return n.add(i),()=>{n.delete(i)}}function a(i){return{store:l,selector:i}}const l={getState:o,dispatch:r,subscribe:c,select:a};return l}let P=!1;const V=new Set;function ot(t){V.add(t),P||(P=!0,queueMicrotask(ct))}function ct(){const t=[...V];V.clear(),P=!1;for(const e of t)e()}function it(){const t=[...V];V.clear(),P=!1;for(const e of t)e()}const B=Symbol("PULSE_CONNECTED");function G(t,e){return function(n){const o=t||{};function r(c){const a={};for(const l in o){const{store:i,selector:u}=o[l];a[l]=u(i.getState())}return n({...a,...c})}return r[B]=!0,r._bindings=o,r._innerComponent=n,e&&(r._lifecycle=e),r.displayName=`Connected(${n.displayName||n.name||"Anonymous"})`,r}}class lt{constructor(e,s){g(this,"connectedFn");g(this,"props");g(this,"prevSelected");g(this,"unsubscribers");g(this,"lastVTree");g(this,"parentDom");g(this,"_renderCallback");g(this,"_mountCleanup");this.connectedFn=e,this.props=s,this.prevSelected={},this.unsubscribers=[],this.lastVTree=null,this.parentDom=null,this._renderCallback=null,this._mountCleanup=null}mount(e,s){var r;this.parentDom=e,this._renderCallback=s;const n=this.connectedFn._bindings;for(const c in n){const{store:a,selector:l}=n[c];this.prevSelected[c]=l(a.getState())}for(const c in n){const{store:a}=n[c],l=a.subscribe(()=>{this._onStoreChange()});this.unsubscribers.push(l)}const o=this.connectedFn._lifecycle;if(o!=null&&o.onMount){const c=o.onMount({dom:(r=this.lastVTree)==null?void 0:r._dom,props:this.props});typeof c=="function"&&(this._mountCleanup=c)}}_onStoreChange(){const e=this.connectedFn._bindings;let s=!1;for(const n in e){const{store:o,selector:r}=e[n],c=r(o.getState());if(!at(c,this.prevSelected[n])){s=!0;break}}s&&ot(this._renderCallback)}updateSelected(){const e=this.connectedFn._bindings;for(const s in e){const{store:n,selector:o}=e[s];this.prevSelected[s]=o(n.getState())}}unmount(){this._mountCleanup&&(this._mountCleanup(),this._mountCleanup=null);const e=this.connectedFn._lifecycle;e!=null&&e.onDestroy&&e.onDestroy({props:this.props});for(const s of this.unsubscribers)s();this.unsubscribers=[],this._renderCallback=null}}function at(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return!1;const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;for(const o of s)if(!Object.prototype.hasOwnProperty.call(e,o)||!Object.is(t[o],e[o]))return!1;return!0}const y={CREATE:"CREATE",REMOVE:"REMOVE",REPLACE:"REPLACE",UPDATE:"UPDATE",TEXT:"TEXT",MOVE:"MOVE",CHILDREN:"CHILDREN"};function T(t,e){if(e==null&&t==null)return[];if(e==null)return[{type:y.REMOVE,target:t}];if(t==null)return[{type:y.CREATE,newVNode:e}];if(t.type!==e.type)return[{type:y.REPLACE,oldVNode:t,newVNode:e}];if(e._dom=t._dom,t.type===D)return t.props.nodeValue!==e.props.nodeValue?[{type:y.TEXT,oldVNode:t,newVNode:e}]:[];const s=[],n=ut(t.props,e.props);n&&s.push({type:y.UPDATE,target:t,propPatches:n});const o=ft(t.children,e.children);return o.length&&s.push({type:y.CHILDREN,parent:t,childPatches:o}),s}function ut(t,e){const s={},n=[];let o=!1;for(const r in e)r!=="children"&&t[r]!==e[r]&&(s[r]=e[r],o=!0);for(const r in t)r!=="children"&&(r in e||(n.push(r),o=!0));return o?{set:s,remove:n}:null}function O(t,e){return t==null||e==null?!1:t.type===e.type&&t.key===e.key}function q(t,e){const s=new Set;let n=0,o=0;for(const r of t)r!=null&&(r.key!=null?(n++,s.has(r.key)&&console.warn(`[pulse] Duplicate key "${String(r.key)}" in ${e} children. Keys must be unique among siblings.`),s.add(r.key)):o++);n>0&&o>0&&console.warn(`[pulse] Mixed keyed and unkeyed children in ${e} list (${n} keyed, ${o} unkeyed). Either all children should have keys or none should.`)}function ft(t,e){var h;process.env.NODE_ENV!=="production"&&(q(t,"old"),q(e,"new"));const s=[];let n=0,o=t.length-1,r=0,c=e.length-1,a=t[n],l=t[o],i=e[r],u=e[c];for(;n<=o&&r<=c;){if(a==null){a=t[++n];continue}if(l==null){l=t[--o];continue}if(O(a,i))s.push(...T(a,i)),a=t[++n],i=e[++r];else if(O(l,u))s.push(...T(l,u)),l=t[--o],u=e[--c];else if(O(a,u))s.push({type:y.MOVE,vnode:a,anchor:t[o+1]||null,childPatches:T(a,u)}),a=t[++n],u=e[--c];else if(O(l,i))s.push({type:y.MOVE,vnode:l,anchor:a,childPatches:T(l,i)}),l=t[--o],i=e[++r];else break}if(n<=o&&r<=c){const p=new Map;for(let f=n;f<=o;f++){const m=(h=t[f])==null?void 0:h.key;m!=null&&p.set(m,f)}for(;r<=c;){i=e[r];const f=i.key!=null?p.get(i.key):void 0;if(f!==void 0){const m=t[f];s.push({type:y.MOVE,vnode:m,anchor:t[n]||null,childPatches:T(m,i)}),t[f]=null,p.delete(i.key)}else s.push({type:y.CREATE,newVNode:i,anchor:t[n]||null});r++}for(let f=n;f<=o;f++)t[f]!=null&&s.push({type:y.REMOVE,target:t[f]})}if(n>o){const p=e[c+1]||null;for(let f=r;f<=c;f++)s.push({type:y.CREATE,newVNode:e[f],anchor:p})}else if(r>c)for(let p=n;p<=o;p++)t[p]!=null&&s.push({type:y.REMOVE,target:t[p]});return s}function R(t){if(t.type===D){const s=document.createTextNode(t.props.nodeValue);return t._dom=s,s}if(t.type===z){const s=document.createDocumentFragment();for(const n of t.children)s.appendChild(R(n));return t._dom=s,s}const e=document.createElement(t.type);pt(e,{},t.props);for(const s of t.children)e.appendChild(R(s));return t._dom=e,e}function pt(t,e,s){for(const n in e)n==="children"||n==="key"||n in s||J(t,n,e[n]);for(const n in s)n==="children"||n==="key"||e[n]!==s[n]&&Q(t,n,s[n],e[n])}function Q(t,e,s,n){if(e.startsWith("on")){const o=e.slice(2).toLowerCase();n&&t.removeEventListener(o,n),s&&t.addEventListener(o,s)}else if(e==="className")t.className=s||"";else if(e==="style"&&typeof s=="object"){if(typeof n=="object"&&n)for(const o in n)o in s||(t.style[o]="");Object.assign(t.style,s)}else e==="ref"?typeof s=="function"&&s(t):s===!0?t.setAttribute(e,""):s===!1||s==null?t.removeAttribute(e):t.setAttribute(e,s)}function J(t,e,s){e.startsWith("on")?t.removeEventListener(e.slice(2).toLowerCase(),s):e==="className"?t.className="":t.removeAttribute(e)}function N(t,e){var s,n,o;for(const r of e)switch(r.type){case y.CREATE:{const c=R(r.newVNode);(s=r.anchor)!=null&&s._dom?t.insertBefore(c,r.anchor._dom):t.appendChild(c);break}case y.REMOVE:{const c=r.target._dom;c!=null&&c.parentNode&&c.parentNode.removeChild(c);break}case y.REPLACE:{const c=R(r.newVNode),a=r.oldVNode._dom;a!=null&&a.parentNode&&a.parentNode.replaceChild(c,a);break}case y.UPDATE:{const c=r.target._dom,{set:a,remove:l}=r.propPatches;for(const i of l)J(c,i,r.target.props[i]);for(const i in a)Q(c,i,a[i],r.target.props[i]);break}case y.TEXT:{const c=r.oldVNode._dom;c&&(c.nodeValue=r.newVNode.props.nodeValue);break}case y.MOVE:{const c=r.vnode._dom;c&&((n=r.anchor)!=null&&n._dom?t.insertBefore(c,r.anchor._dom):t.appendChild(c)),(o=r.childPatches)!=null&&o.length&&c&&N(c,r.childPatches);break}case y.CHILDREN:{const c=r.parent._dom;c&&r.childPatches.length&&N(c,r.childPatches);break}}}const L=new WeakMap;function ht(t,e){const s=L.get(e);if(s){const n=k(t,e),o=[];C(s.vTree,o);const r=T(s.vTree,n);N(e,r);const c=[];n&&C(n,c);const a=new Set(c);for(const i of o)a.has(i)||i.unmount();const l=new Set(o);for(const i of c)l.has(i)||i.mount(e,()=>j(i,e));L.set(e,{vTree:n})}else{const n=k(t,e);if(!n)return;const o=R(n);e.appendChild(o);const r=[];C(n,r);for(const c of r)c.mount(e,()=>j(c,e));L.set(e,{vTree:n})}}function k(t,e){var s;if(t==null)return null;if(typeof t.type=="function"){if(t.type[B]){const o=t.type._lifecycle;try{const r=new lt(t.type,t.props),c=t.type(t.props),l=k(c,e)??U("");if(l._instance){const i={type:"div",props:{style:{display:"contents"}},children:[l],key:t.key};return i._instance=r,r.lastVTree=i,i}return l._instance=r,r.lastVTree=l,l}catch(r){if(o!=null&&o.onError){const c=o.onError({error:r,props:t.props});return k(c,e)}throw r}}const n=t.type({...t.props,children:t.children});return k(n,e)}return(s=t.children)!=null&&s.length&&(t.children=t.children.map(n=>k(n,e)).filter(n=>n!=null)),t}function j(t,e){var o,r;if(!t._renderCallback)return;const s=t.connectedFn,n=s._lifecycle;try{const c=s(t.props);let l=k(c,e)??U(""),i;if(l._instance&&l._instance!==t?(i={type:"div",props:{style:{display:"contents"}},children:[l],key:null},i._instance=t):(l._instance=t,i=l),t.lastVTree){F(t.lastVTree,t);const m=T(t.lastVTree,i),M=((o=t.lastVTree._dom)==null?void 0:o.parentNode)||e;N(M,m),i._dom||(i._dom=t.lastVTree._dom)}const u=[];A(t.lastVTree,u,t);const h=[];A(i,h,t);const p=new Set(h);for(const m of u)p.has(m)||m.unmount();t.lastVTree=i;const f=new Set(u);for(const m of h)f.has(m)||m.mount(e,()=>j(m,e));n!=null&&n.onUpdate&&n.onUpdate({dom:i==null?void 0:i._dom,props:t.props}),t.updateSelected()}catch(c){if(n!=null&&n.onError){const a=n.onError({error:c,props:t.props}),l=k(a,e);if(t.lastVTree&&l){F(t.lastVTree,t);const u=T(t.lastVTree,l),h=((r=t.lastVTree._dom)==null?void 0:r.parentNode)||e;N(h,u),l._dom||(l._dom=t.lastVTree._dom)}const i=[];A(t.lastVTree,i,t);for(const u of i)u.unmount();t.lastVTree=l,t.updateSelected()}else throw c}}function F(t,e){if(!(!t||!t.children))for(let s=0;s<t.children.length;s++){const n=t.children[s];n._instance&&n._instance!==e&&n._instance.lastVTree&&n._instance.lastVTree!==n&&(t.children[s]=n._instance.lastVTree),F(t.children[s],e)}}function C(t,e){if(t&&(t._instance&&e.push(t._instance),t.children))for(const s of t.children)C(s,e)}function A(t,e,s){if(t&&(t._instance&&t._instance!==s&&e.push(t._instance),t.children))for(const n of t.children)A(n,e,s)}function x(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t||"/"}function $(t){const e={};if(!t)return e;const s=t.startsWith("?")?t.slice(1):t;return s&&new URLSearchParams(s).forEach((o,r)=>{e[r]=o}),e}function Y(t,e){const s=x(t),n=x(e);if(n==="*")return{params:{"*":s}};const o=s==="/"?[""]:s.split("/").slice(1),r=n==="/"?[""]:n.split("/").slice(1);if(r.length>0&&r[r.length-1]==="*"){const l=r.slice(0,-1);if(o.length<l.length)return null;const i={};for(let h=0;h<l.length;h++){const p=l[h];if(p.startsWith(":"))i[p.slice(1)]=o[h];else if(p!==o[h])return null}const u=o.slice(l.length).join("/");return i["*"]=u,{params:i}}if(o.length!==r.length)return null;const a={};for(let l=0;l<r.length;l++){const i=r[l];if(i.startsWith(":"))a[i.slice(1)]=o[l];else if(i!==o[l])return null}return{params:a}}function X(t,e){for(const s of e){const n=Y(t,s.path);if(n)return{pattern:s.path,params:n.params}}return null}function dt(t){const{routes:e,initialPath:s}=t,n=s??window.location.pathname,o=s?"":window.location.search,r=x(n),c=$(o),a=X(r,e),l=K({state:{path:r,params:(a==null?void 0:a.params)??{},query:c,matched:(a==null?void 0:a.pattern)??null},actions:{_sync:(d,E)=>E}});function i(d){const E=d.indexOf("?"),S=x(E>=0?d.slice(0,E):d),w=E>=0?d.slice(E+1):"",_=$(w),b=X(S,e);return{path:S,params:(b==null?void 0:b.params)??{},query:_,matched:(b==null?void 0:b.pattern)??null}}function u(d){const E=i(d);window.history.pushState(null,"",d),l.dispatch("_sync",E)}function h(d){const E=i(d);window.history.replaceState(null,"",d),l.dispatch("_sync",E)}function p(){window.history.back()}function f(){window.history.forward()}function m(){const d=i(window.location.pathname+window.location.search);l.dispatch("_sync",d)}window.addEventListener("popstate",m);function M(){window.removeEventListener("popstate",m)}const Z=G({_path:l.select(d=>d.path)})(function(E){const{_path:S,path:w,component:_,children:b,...et}=E,W=Y(S,w);return W?_?I(_,{...et,params:W.params}):(b==null?void 0:b[0])??null:null});function v(d){const{to:E,children:S,...w}=d;return I("a",{...w,href:E,onClick:_=>{_.metaKey||_.ctrlKey||_.shiftKey||_.button!==0||(_.preventDefault(),u(E))}},...S||[])}function tt(d){return h(d.to),null}return{store:l,navigate:u,redirect:h,back:p,forward:f,destroy:M,Route:Z,Link:v,Redirect:tt}}exports.Fragment=z;exports.connect=G;exports.createElement=I;exports.createRouter=dt;exports.createStore=K;exports.flushSync=it;exports.h=I;exports.render=ht;
|
|
1
|
+
"use strict";var ot=Object.defineProperty;var rt=(t,e,s)=>e in t?ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var k=(t,e,s)=>rt(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=Symbol("TEXT_NODE"),Q=Symbol("FRAGMENT");function K(t){return{type:q,props:{nodeValue:String(t)},children:[],key:null}}function ct(t){return t==null||typeof t=="boolean"?null:typeof t=="string"||typeof t=="number"?K(t):t}function J(t){const e=[];for(const s of t)if(Array.isArray(s))e.push(...J(s));else{const n=ct(s);n!==null&&e.push(n)}return e}function U(t,e,...s){e=e||{};const n=e.key??null;e.key!==void 0&&(e={...e},delete e.key);const r=J(s);return{type:t,props:e,children:r,key:n}}function Y(t){let e=t.state;const s=t.actions,n=new Set,r=t.middleware;function o(){return e}function c(){for(const u of n)u(e)}function a(u,d){const S=s[u];if(!S)throw new Error(`[pulse] Unknown action: "${u}"`);const b=S(e,d);b!==e&&(e=b,c())}function l(u,d){if(u==="__devtools_replace__"){e=d,c();return}const S=s[u];if(!S)throw new Error(`[pulse] Unknown action: "${u}"`);const b={store:h,actionName:u,payload:d,prevState:e,nextState:void 0};let x=0;function C(){if(x<r.length){const f=r[x++];f(b,C)}else{const f=S(b.prevState,b.payload);b.nextState=f,f!==e&&(e=f,c())}}C()}const i=r&&r.length>0?l:a;function p(u){return n.add(u),()=>{n.delete(u)}}function y(u){return{store:h,selector:u}}const h={getState:o,dispatch:i,subscribe:p,select:y};return t.name&&(h.name=t.name),h}let j=!1;const R=new Set;function it(t){R.add(t),j||(j=!0,queueMicrotask(lt))}function lt(){const t=[...R];R.clear(),j=!1;for(const e of t)e()}function at(){const t=[...R];R.clear(),j=!1;for(const e of t)e()}const Z=Symbol("PULSE_CONNECTED"),H=globalThis;H.__PULSE_HOOKS__||(H.__PULSE_HOOKS__={onMount:null,onUnmount:null});const I=H.__PULSE_HOOKS__;function v(t,e){return function(n){const r=t||{};function o(c){const a={};for(const l in r){const{store:i,selector:p}=r[l];a[l]=p(i.getState())}return n({...a,...c})}return o[Z]=!0,o._bindings=r,o._innerComponent=n,e&&(o._lifecycle=e),o.displayName=`Connected(${n.displayName||n.name||"Anonymous"})`,o}}class ut{constructor(e,s){k(this,"connectedFn");k(this,"props");k(this,"prevSelected");k(this,"unsubscribers");k(this,"lastVTree");k(this,"parentDom");k(this,"_renderCallback");k(this,"_mountCleanup");this.connectedFn=e,this.props=s,this.prevSelected={},this.unsubscribers=[],this.lastVTree=null,this.parentDom=null,this._renderCallback=null,this._mountCleanup=null}mount(e,s){var o;this.parentDom=e,this._renderCallback=s;const n=this.connectedFn._bindings;for(const c in n){const{store:a,selector:l}=n[c];this.prevSelected[c]=l(a.getState())}for(const c in n){const{store:a}=n[c],l=a.subscribe(()=>{this._onStoreChange()});this.unsubscribers.push(l)}const r=this.connectedFn._lifecycle;if(r!=null&&r.onMount){const c=r.onMount({dom:(o=this.lastVTree)==null?void 0:o._dom,props:this.props});typeof c=="function"&&(this._mountCleanup=c)}I.onMount&&I.onMount(this)}_onStoreChange(){const e=this.connectedFn._bindings;let s=!1;for(const n in e){const{store:r,selector:o}=e[n],c=o(r.getState());if(!ft(c,this.prevSelected[n])){s=!0;break}}s&&it(this._renderCallback)}updateSelected(){const e=this.connectedFn._bindings;for(const s in e){const{store:n,selector:r}=e[s];this.prevSelected[s]=r(n.getState())}}unmount(){I.onUnmount&&I.onUnmount(this),this._mountCleanup&&(this._mountCleanup(),this._mountCleanup=null);const e=this.connectedFn._lifecycle;e!=null&&e.onDestroy&&e.onDestroy({props:this.props});for(const s of this.unsubscribers)s();this.unsubscribers=[],this._renderCallback=null}}function ft(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return!1;const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;for(const r of s)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}const m={CREATE:"CREATE",REMOVE:"REMOVE",REPLACE:"REPLACE",UPDATE:"UPDATE",TEXT:"TEXT",MOVE:"MOVE",CHILDREN:"CHILDREN"};function T(t,e){if(e==null&&t==null)return[];if(e==null)return[{type:m.REMOVE,target:t}];if(t==null)return[{type:m.CREATE,newVNode:e}];if(t.type!==e.type)return[{type:m.REPLACE,oldVNode:t,newVNode:e}];if(e._dom=t._dom,t.type===q)return t.props.nodeValue!==e.props.nodeValue?[{type:m.TEXT,oldVNode:t,newVNode:e}]:[];const s=[],n=pt(t.props,e.props);n&&s.push({type:m.UPDATE,target:t,propPatches:n});const r=ht(t.children,e.children);return r.length&&s.push({type:m.CHILDREN,parent:t,childPatches:r}),s}function pt(t,e){const s={},n=[];let r=!1;for(const o in e)o!=="children"&&t[o]!==e[o]&&(s[o]=e[o],r=!0);for(const o in t)o!=="children"&&(o in e||(n.push(o),r=!0));return r?{set:s,remove:n}:null}function A(t,e){return t==null||e==null?!1:t.type===e.type&&t.key===e.key}function z(t,e){const s=new Set;let n=0,r=0;for(const o of t)o!=null&&(o.key!=null?(n++,s.has(o.key)&&console.warn(`[pulse] Duplicate key "${String(o.key)}" in ${e} children. Keys must be unique among siblings.`),s.add(o.key)):r++);n>0&&r>0&&console.warn(`[pulse] Mixed keyed and unkeyed children in ${e} list (${n} keyed, ${r} unkeyed). Either all children should have keys or none should.`)}function ht(t,e){var y;process.env.NODE_ENV!=="production"&&(z(t,"old"),z(e,"new"));const s=[];let n=0,r=t.length-1,o=0,c=e.length-1,a=t[n],l=t[r],i=e[o],p=e[c];for(;n<=r&&o<=c;){if(a==null){a=t[++n];continue}if(l==null){l=t[--r];continue}if(A(a,i))s.push(...T(a,i)),a=t[++n],i=e[++o];else if(A(l,p))s.push(...T(l,p)),l=t[--r],p=e[--c];else if(A(a,p))s.push({type:m.MOVE,vnode:a,anchor:t[r+1]||null,childPatches:T(a,p)}),a=t[++n],p=e[--c];else if(A(l,i))s.push({type:m.MOVE,vnode:l,anchor:a,childPatches:T(l,i)}),l=t[--r],i=e[++o];else break}if(n<=r&&o<=c){const h=new Map;for(let u=n;u<=r;u++){const d=(y=t[u])==null?void 0:y.key;d!=null&&h.set(d,u)}for(;o<=c;){i=e[o];const u=i.key!=null?h.get(i.key):void 0;if(u!==void 0){const d=t[u];s.push({type:m.MOVE,vnode:d,anchor:t[n]||null,childPatches:T(d,i)}),t[u]=null,h.delete(i.key)}else s.push({type:m.CREATE,newVNode:i,anchor:t[n]||null});o++}for(let u=n;u<=r;u++)t[u]!=null&&s.push({type:m.REMOVE,target:t[u]})}if(n>r){const h=e[c+1]||null;for(let u=o;u<=c;u++)s.push({type:m.CREATE,newVNode:e[u],anchor:h})}else if(o>c)for(let h=n;h<=r;h++)t[h]!=null&&s.push({type:m.REMOVE,target:t[h]});return s}function N(t){if(t.type===q){const s=document.createTextNode(t.props.nodeValue);return t._dom=s,s}if(t.type===Q){const s=document.createDocumentFragment();for(const n of t.children)s.appendChild(N(n));return t._dom=s,s}const e=document.createElement(t.type);dt(e,{},t.props);for(const s of t.children)e.appendChild(N(s));return t._dom=e,e}function dt(t,e,s){for(const n in e)n==="children"||n==="key"||n in s||et(t,n,e[n]);for(const n in s)n==="children"||n==="key"||e[n]!==s[n]&&tt(t,n,s[n],e[n])}function tt(t,e,s,n){if(e.startsWith("on")){const r=e.slice(2).toLowerCase();n&&t.removeEventListener(r,n),s&&t.addEventListener(r,s)}else if(e==="className")t.className=s||"";else if(e==="style"&&typeof s=="object"){if(typeof n=="object"&&n)for(const r in n)r in s||(t.style[r]="");Object.assign(t.style,s)}else e==="ref"?typeof s=="function"&&s(t):s===!0?t.setAttribute(e,""):s===!1||s==null?t.removeAttribute(e):t.setAttribute(e,s)}function et(t,e,s){e.startsWith("on")?t.removeEventListener(e.slice(2).toLowerCase(),s):e==="className"?t.className="":t.removeAttribute(e)}function P(t,e){var s,n,r;for(const o of e)switch(o.type){case m.CREATE:{const c=N(o.newVNode);(s=o.anchor)!=null&&s._dom?t.insertBefore(c,o.anchor._dom):t.appendChild(c);break}case m.REMOVE:{const c=o.target._dom;c!=null&&c.parentNode&&c.parentNode.removeChild(c);break}case m.REPLACE:{const c=N(o.newVNode),a=o.oldVNode._dom;a!=null&&a.parentNode&&a.parentNode.replaceChild(c,a);break}case m.UPDATE:{const c=o.target._dom,{set:a,remove:l}=o.propPatches;for(const i of l)et(c,i,o.target.props[i]);for(const i in a)tt(c,i,a[i],o.target.props[i]);break}case m.TEXT:{const c=o.oldVNode._dom;c&&(c.nodeValue=o.newVNode.props.nodeValue);break}case m.MOVE:{const c=o.vnode._dom;c&&((n=o.anchor)!=null&&n._dom?t.insertBefore(c,o.anchor._dom):t.appendChild(c)),(r=o.childPatches)!=null&&r.length&&c&&P(c,o.childPatches);break}case m.CHILDREN:{const c=o.parent._dom;c&&o.childPatches.length&&P(c,o.childPatches);break}}}const D=new WeakMap;function mt(t,e){const s=D.get(e);if(s){const n=w(t,e),r=[];M(s.vTree,r);const o=T(s.vTree,n);P(e,o);const c=[];n&&M(n,c);const a=new Set(c);for(const i of r)a.has(i)||i.unmount();const l=new Set(r);for(const i of c)l.has(i)||i.mount(e,()=>W(i,e));D.set(e,{vTree:n})}else{const n=w(t,e);if(!n)return;const r=N(n);e.appendChild(r);const o=[];M(n,o);for(const c of o)c.mount(e,()=>W(c,e));D.set(e,{vTree:n})}}function w(t,e){var s;if(t==null)return null;if(typeof t.type=="function"){if(t.type[Z]){const r=t.type._lifecycle;try{const o=new ut(t.type,t.props),c=t.type(t.props),l=w(c,e)??K("");if(l._instance){const i={type:"div",props:{style:{display:"contents"}},children:[l],key:t.key};return i._instance=o,o.lastVTree=i,i}return l._instance=o,o.lastVTree=l,l}catch(o){if(r!=null&&r.onError){const c=r.onError({error:o,props:t.props});return w(c,e)}throw o}}const n=t.type({...t.props,children:t.children});return w(n,e)}return(s=t.children)!=null&&s.length&&(t.children=t.children.map(n=>w(n,e)).filter(n=>n!=null)),t}function W(t,e){var r,o;if(!t._renderCallback)return;const s=t.connectedFn,n=s._lifecycle;try{const c=s(t.props);let l=w(c,e)??K(""),i;if(l._instance&&l._instance!==t?(i={type:"div",props:{style:{display:"contents"}},children:[l],key:null},i._instance=t):(l._instance=t,i=l),t.lastVTree){$(t.lastVTree,t);const d=T(t.lastVTree,i),S=((r=t.lastVTree._dom)==null?void 0:r.parentNode)||e;P(S,d),i._dom||(i._dom=t.lastVTree._dom)}const p=[];L(t.lastVTree,p,t);const y=[];L(i,y,t);const h=new Set(y);for(const d of p)h.has(d)||d.unmount();t.lastVTree=i;const u=new Set(p);for(const d of y)u.has(d)||d.mount(e,()=>W(d,e));n!=null&&n.onUpdate&&n.onUpdate({dom:i==null?void 0:i._dom,props:t.props}),t.updateSelected()}catch(c){if(n!=null&&n.onError){const a=n.onError({error:c,props:t.props}),l=w(a,e);if(t.lastVTree&&l){$(t.lastVTree,t);const p=T(t.lastVTree,l),y=((o=t.lastVTree._dom)==null?void 0:o.parentNode)||e;P(y,p),l._dom||(l._dom=t.lastVTree._dom)}const i=[];L(t.lastVTree,i,t);for(const p of i)p.unmount();t.lastVTree=l,t.updateSelected()}else throw c}}function $(t,e){if(!(!t||!t.children))for(let s=0;s<t.children.length;s++){const n=t.children[s];n._instance&&n._instance!==e&&n._instance.lastVTree&&n._instance.lastVTree!==n&&(t.children[s]=n._instance.lastVTree),$(t.children[s],e)}}function M(t,e){if(t&&(t._instance&&e.push(t._instance),t.children))for(const s of t.children)M(s,e)}function L(t,e,s){if(t&&(t._instance&&t._instance!==s&&e.push(t._instance),t.children))for(const n of t.children)L(n,e,s)}function F(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t||"/"}function B(t){const e={};if(!t)return e;const s=t.startsWith("?")?t.slice(1):t;return s&&new URLSearchParams(s).forEach((r,o)=>{e[o]=r}),e}function nt(t,e){const s=F(t),n=F(e);if(n==="*")return{params:{"*":s}};const r=s==="/"?[""]:s.split("/").slice(1),o=n==="/"?[""]:n.split("/").slice(1);if(o.length>0&&o[o.length-1]==="*"){const l=o.slice(0,-1);if(r.length<l.length)return null;const i={};for(let y=0;y<l.length;y++){const h=l[y];if(h.startsWith(":"))i[h.slice(1)]=r[y];else if(h!==r[y])return null}const p=r.slice(l.length).join("/");return i["*"]=p,{params:i}}if(r.length!==o.length)return null;const a={};for(let l=0;l<o.length;l++){const i=o[l];if(i.startsWith(":"))a[i.slice(1)]=r[l];else if(i!==r[l])return null}return{params:a}}function G(t,e){for(const s of e){const n=nt(t,s.path);if(n)return{pattern:s.path,params:n.params}}return null}function yt(t){const{routes:e,initialPath:s}=t,n=s??window.location.pathname,r=s?"":window.location.search,o=F(n),c=B(r),a=G(o,e),l=Y({state:{path:o,params:(a==null?void 0:a.params)??{},query:c,matched:(a==null?void 0:a.pattern)??null},actions:{_sync:(f,_)=>_}});function i(f){const _=f.indexOf("?"),O=F(_>=0?f.slice(0,_):f),V=_>=0?f.slice(_+1):"",E=B(V),g=G(O,e);return{path:O,params:(g==null?void 0:g.params)??{},query:E,matched:(g==null?void 0:g.pattern)??null}}function p(f){const _=i(f);window.history.pushState(null,"",f),l.dispatch("_sync",_)}function y(f){const _=i(f);window.history.replaceState(null,"",f),l.dispatch("_sync",_)}function h(){window.history.back()}function u(){window.history.forward()}function d(){const f=i(window.location.pathname+window.location.search);l.dispatch("_sync",f)}window.addEventListener("popstate",d);function S(){window.removeEventListener("popstate",d)}const b=v({_path:l.select(f=>f.path)})(function(_){const{_path:O,path:V,component:E,children:g,...st}=_,X=nt(O,V);return X?E?U(E,{...st,params:X.params}):(g==null?void 0:g[0])??null:null});function x(f){const{to:_,children:O,...V}=f;return U("a",{...V,href:_,onClick:E=>{E.metaKey||E.ctrlKey||E.shiftKey||E.button!==0||(E.preventDefault(),p(_))}},...O||[])}function C(f){return y(f.to),null}return{store:l,navigate:p,redirect:y,back:h,forward:u,destroy:S,Route:b,Link:x,Redirect:C}}function _t(){return(t,e)=>{const s=`[pulse] ${t.actionName}`;console.group(s),console.log("prev state",t.prevState),console.log("payload",t.payload),e(),console.log("next state",t.nextState),console.groupEnd()}}function Et(t,e){const s=(e==null?void 0:e.maxEntries)??1/0;return(n,r)=>{r(),t.push({actionName:n.actionName,payload:n.payload,prevState:n.prevState,nextState:n.nextState??n.prevState,timestamp:Date.now()}),t.length>s&&t.splice(0,t.length-s)}}exports.Fragment=Q;exports.actionHistory=Et;exports.connect=v;exports.createElement=U;exports.createRouter=yt;exports.createStore=Y;exports.flushSync=at;exports.h=U;exports.logger=_t;exports.render=mt;
|
|
2
2
|
//# sourceMappingURL=pulse.cjs.map
|