@pyreon/core 0.5.6 → 0.6.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/README.md +2 -1
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js +22 -1
- package/lib/index.js.map +1 -1
- package/lib/jsx-dev-runtime.js.map +1 -1
- package/lib/jsx-runtime.js.map +1 -1
- package/lib/types/index.d.ts +22 -6
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/jsx-dev-runtime.d.ts +2 -2
- package/lib/types/jsx-dev-runtime.d.ts.map +1 -1
- package/lib/types/jsx-runtime.d.ts +2 -2
- package/lib/types/jsx-runtime.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/component.ts +3 -3
- package/src/context.ts +18 -0
- package/src/h.ts +1 -1
- package/src/index.ts +3 -0
- package/src/suspense.ts +1 -1
- package/src/tests/core.test.ts +17 -0
- package/src/types.ts +12 -2
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ function Counter() {
|
|
|
48
48
|
|
|
49
49
|
- **`createContext<T>(defaultValue?): Context<T>`** -- Creates a context with an optional default.
|
|
50
50
|
- **`useContext(ctx): T`** -- Reads the nearest provided context value.
|
|
51
|
+
- **`provide(ctx, value)`** -- Provides a context value for the current component's subtree (auto-cleans up on unmount).
|
|
51
52
|
- **`withContext(ctx, value, fn)`** -- Runs `fn` with the given context value.
|
|
52
53
|
- **`pushContext(map)` / `popContext()`** -- Low-level context stack manipulation.
|
|
53
54
|
|
|
@@ -71,7 +72,7 @@ function Counter() {
|
|
|
71
72
|
|
|
72
73
|
### Types
|
|
73
74
|
|
|
74
|
-
`VNode`, `VNodeChild`, `VNodeChildAtom`, `Props`, `ComponentFn`, `ComponentInstance`, `LifecycleHooks`, `CleanupFn`, `NativeItem`, `Ref`, `Context`, `LazyComponent`, `ShowProps`, `SwitchProps`, `MatchProps`, `ForProps`, `PortalProps`, `ErrorContext`, `ErrorHandler`
|
|
75
|
+
`VNode`, `VNodeChild`, `VNodeChildAtom`, `Props`, `ComponentFn`, `ExtractProps`, `HigherOrderComponent`, `ComponentInstance`, `LifecycleHooks`, `CleanupFn`, `NativeItem`, `Ref`, `Context`, `LazyComponent`, `ShowProps`, `SwitchProps`, `MatchProps`, `ForProps`, `PortalProps`, `ErrorContext`, `ErrorHandler`
|
|
75
76
|
|
|
76
77
|
## License
|
|
77
78
|
|
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"f6a1d275-1","name":"lifecycle.ts"},{"uid":"f6a1d275-3","name":"component.ts"},{"uid":"f6a1d275-5","name":"context.ts"},{"uid":"f6a1d275-7","name":"h.ts"},{"uid":"f6a1d275-9","name":"dynamic.ts"},{"uid":"f6a1d275-11","name":"telemetry.ts"},{"uid":"f6a1d275-13","name":"error-boundary.ts"},{"uid":"f6a1d275-15","name":"for.ts"},{"uid":"f6a1d275-17","name":"lazy.ts"},{"uid":"f6a1d275-19","name":"map-array.ts"},{"uid":"f6a1d275-21","name":"portal.ts"},{"uid":"f6a1d275-23","name":"ref.ts"},{"uid":"f6a1d275-25","name":"show.ts"},{"uid":"f6a1d275-27","name":"style.ts"},{"uid":"f6a1d275-29","name":"suspense.ts"},{"uid":"f6a1d275-31","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"f6a1d275-1":{"renderedLength":1459,"gzipLength":658,"brotliLength":0,"metaUid":"f6a1d275-0"},"f6a1d275-3":{"renderedLength":1430,"gzipLength":679,"brotliLength":0,"metaUid":"f6a1d275-2"},"f6a1d275-5":{"renderedLength":2213,"gzipLength":1033,"brotliLength":0,"metaUid":"f6a1d275-4"},"f6a1d275-7":{"renderedLength":1082,"gzipLength":597,"brotliLength":0,"metaUid":"f6a1d275-6"},"f6a1d275-9":{"renderedLength":381,"gzipLength":268,"brotliLength":0,"metaUid":"f6a1d275-8"},"f6a1d275-11":{"renderedLength":570,"gzipLength":346,"brotliLength":0,"metaUid":"f6a1d275-10"},"f6a1d275-13":{"renderedLength":1664,"gzipLength":843,"brotliLength":0,"metaUid":"f6a1d275-12"},"f6a1d275-15":{"renderedLength":700,"gzipLength":478,"brotliLength":0,"metaUid":"f6a1d275-14"},"f6a1d275-17":{"renderedLength":461,"gzipLength":273,"brotliLength":0,"metaUid":"f6a1d275-16"},"f6a1d275-19":{"renderedLength":1018,"gzipLength":571,"brotliLength":0,"metaUid":"f6a1d275-18"},"f6a1d275-21":{"renderedLength":818,"gzipLength":491,"brotliLength":0,"metaUid":"f6a1d275-20"},"f6a1d275-23":{"renderedLength":86,"gzipLength":98,"brotliLength":0,"metaUid":"f6a1d275-22"},"f6a1d275-25":{"renderedLength":1892,"gzipLength":810,"brotliLength":0,"metaUid":"f6a1d275-24"},"f6a1d275-27":{"renderedLength":1137,"gzipLength":581,"brotliLength":0,"metaUid":"f6a1d275-26"},"f6a1d275-29":{"renderedLength":1138,"gzipLength":627,"brotliLength":0,"metaUid":"f6a1d275-28"},"f6a1d275-31":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f6a1d275-30"}},"nodeMetas":{"f6a1d275-0":{"id":"/src/lifecycle.ts","moduleParts":{"index.js":"f6a1d275-1"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"},{"uid":"f6a1d275-2"},{"uid":"f6a1d275-4"},{"uid":"f6a1d275-12"}]},"f6a1d275-2":{"id":"/src/component.ts","moduleParts":{"index.js":"f6a1d275-3"},"imported":[{"uid":"f6a1d275-0"}],"importedBy":[{"uid":"f6a1d275-30"},{"uid":"f6a1d275-12"}]},"f6a1d275-4":{"id":"/src/context.ts","moduleParts":{"index.js":"f6a1d275-5"},"imported":[{"uid":"f6a1d275-0"}],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-6":{"id":"/src/h.ts","moduleParts":{"index.js":"f6a1d275-7"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"},{"uid":"f6a1d275-8"},{"uid":"f6a1d275-16"},{"uid":"f6a1d275-28"}]},"f6a1d275-8":{"id":"/src/dynamic.ts","moduleParts":{"index.js":"f6a1d275-9"},"imported":[{"uid":"f6a1d275-6"}],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-10":{"id":"/src/telemetry.ts","moduleParts":{"index.js":"f6a1d275-11"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"},{"uid":"f6a1d275-12"}]},"f6a1d275-12":{"id":"/src/error-boundary.ts","moduleParts":{"index.js":"f6a1d275-13"},"imported":[{"uid":"f6a1d275-32"},{"uid":"f6a1d275-2"},{"uid":"f6a1d275-0"},{"uid":"f6a1d275-10"}],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-14":{"id":"/src/for.ts","moduleParts":{"index.js":"f6a1d275-15"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-16":{"id":"/src/lazy.ts","moduleParts":{"index.js":"f6a1d275-17"},"imported":[{"uid":"f6a1d275-32"},{"uid":"f6a1d275-6"}],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-18":{"id":"/src/map-array.ts","moduleParts":{"index.js":"f6a1d275-19"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-20":{"id":"/src/portal.ts","moduleParts":{"index.js":"f6a1d275-21"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-22":{"id":"/src/ref.ts","moduleParts":{"index.js":"f6a1d275-23"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-24":{"id":"/src/show.ts","moduleParts":{"index.js":"f6a1d275-25"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-26":{"id":"/src/style.ts","moduleParts":{"index.js":"f6a1d275-27"},"imported":[],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-28":{"id":"/src/suspense.ts","moduleParts":{"index.js":"f6a1d275-29"},"imported":[{"uid":"f6a1d275-6"}],"importedBy":[{"uid":"f6a1d275-30"}]},"f6a1d275-30":{"id":"/src/index.ts","moduleParts":{"index.js":"f6a1d275-31"},"imported":[{"uid":"f6a1d275-2"},{"uid":"f6a1d275-4"},{"uid":"f6a1d275-8"},{"uid":"f6a1d275-12"},{"uid":"f6a1d275-14"},{"uid":"f6a1d275-6"},{"uid":"f6a1d275-16"},{"uid":"f6a1d275-0"},{"uid":"f6a1d275-18"},{"uid":"f6a1d275-20"},{"uid":"f6a1d275-22"},{"uid":"f6a1d275-24"},{"uid":"f6a1d275-26"},{"uid":"f6a1d275-28"},{"uid":"f6a1d275-10"}],"importedBy":[],"isEntry":true},"f6a1d275-32":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"f6a1d275-12"},{"uid":"f6a1d275-16"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.js
CHANGED
|
@@ -109,6 +109,12 @@ function dispatchToErrorBoundary(err) {
|
|
|
109
109
|
|
|
110
110
|
//#endregion
|
|
111
111
|
//#region src/context.ts
|
|
112
|
+
/**
|
|
113
|
+
* Provide / inject — like React context or Vue provide/inject.
|
|
114
|
+
*
|
|
115
|
+
* Values flow down the component tree without prop-drilling.
|
|
116
|
+
* The renderer maintains the context stack as it walks the VNode tree.
|
|
117
|
+
*/
|
|
112
118
|
function createContext(defaultValue) {
|
|
113
119
|
return {
|
|
114
120
|
id: Symbol("PyreonContext"),
|
|
@@ -153,6 +159,21 @@ function useContext(context) {
|
|
|
153
159
|
return context.defaultValue;
|
|
154
160
|
}
|
|
155
161
|
/**
|
|
162
|
+
* Provide a context value for the current component's subtree.
|
|
163
|
+
* Must be called during component setup (like onMount/onUnmount).
|
|
164
|
+
* Automatically cleaned up when the component unmounts.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* const ThemeProvider = ({ children }: { children: VNodeChild }) => {
|
|
168
|
+
* provide(ThemeContext, { color: "blue" })
|
|
169
|
+
* return children
|
|
170
|
+
* }
|
|
171
|
+
*/
|
|
172
|
+
function provide(context, value) {
|
|
173
|
+
pushContext(new Map([[context.id, value]]));
|
|
174
|
+
onUnmount(() => popContext());
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
156
177
|
* Provide a value for `context` during `fn()`.
|
|
157
178
|
* Used by the renderer when it encounters a `<Provider>` component.
|
|
158
179
|
*/
|
|
@@ -545,5 +566,5 @@ function Suspense(props) {
|
|
|
545
566
|
}
|
|
546
567
|
|
|
547
568
|
//#endregion
|
|
548
|
-
export { CSS_UNITLESS, Dynamic, EMPTY_PROPS, ErrorBoundary, For, ForSymbol, Fragment, Match, MatchSymbol, Portal, PortalSymbol, Show, Suspense, Switch, createContext, createRef, defineComponent, dispatchToErrorBoundary, h, lazy, mapArray, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, pushContext, registerErrorHandler, reportError, runWithHooks, setContextStackProvider, toKebabCase, useContext, withContext };
|
|
569
|
+
export { CSS_UNITLESS, Dynamic, EMPTY_PROPS, ErrorBoundary, For, ForSymbol, Fragment, Match, MatchSymbol, Portal, PortalSymbol, Show, Suspense, Switch, createContext, createRef, defineComponent, dispatchToErrorBoundary, h, lazy, mapArray, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, provide, pushContext, registerErrorHandler, reportError, runWithHooks, setContextStackProvider, toKebabCase, useContext, withContext };
|
|
549
570
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["__DEV__","__DEV__","__DEV__","__DEV__"],"sources":["../src/lifecycle.ts","../src/component.ts","../src/context.ts","../src/h.ts","../src/dynamic.ts","../src/telemetry.ts","../src/error-boundary.ts","../src/for.ts","../src/lazy.ts","../src/map-array.ts","../src/portal.ts","../src/ref.ts","../src/show.ts","../src/style.ts","../src/suspense.ts"],"sourcesContent":["import type { CleanupFn, LifecycleHooks } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n// The currently-executing component's hook storage, set by the renderer\n// before calling the component function, cleared immediately after.\nlet _current: LifecycleHooks | null = null\n\nexport function setCurrentHooks(hooks: LifecycleHooks | null) {\n _current = hooks\n}\n\nexport function getCurrentHooks(): LifecycleHooks | null {\n return _current\n}\n\nfunction warnOutsideSetup(hookName: string): void {\n if (__DEV__ && !_current) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n `[Pyreon] ${hookName}() called outside component setup. ` +\n \"Lifecycle hooks must be called synchronously during a component's setup function.\",\n )\n }\n}\n\n/**\n * Register a callback to run after the component is mounted to the DOM.\n * Optionally return a cleanup function — it will run on unmount.\n */\n// biome-ignore lint/suspicious/noConfusingVoidType: void allows callbacks that return nothing\nexport function onMount(fn: () => CleanupFn | void | undefined) {\n warnOutsideSetup(\"onMount\")\n _current?.mount.push(fn)\n}\n\n/**\n * Register a callback to run when the component is removed from the DOM.\n */\nexport function onUnmount(fn: () => void) {\n warnOutsideSetup(\"onUnmount\")\n _current?.unmount.push(fn)\n}\n\n/**\n * Register a callback to run after each reactive update.\n */\nexport function onUpdate(fn: () => void) {\n warnOutsideSetup(\"onUpdate\")\n _current?.update.push(fn)\n}\n\n/**\n * Register an error handler for this component subtree.\n *\n * When an error is thrown during rendering or in a child component,\n * the nearest `onErrorCaptured` handler is called with the error.\n * Return `true` to mark the error as handled and stop propagation.\n *\n * @example\n * onErrorCaptured((err) => {\n * setError(String(err))\n * return true // handled — don't propagate\n * })\n */\nexport function onErrorCaptured(fn: (err: unknown) => boolean | undefined) {\n warnOutsideSetup(\"onErrorCaptured\")\n _current?.error.push(fn)\n}\n","import { setCurrentHooks } from \"./lifecycle\"\nimport type { ComponentFn, LifecycleHooks, Props, VNode } from \"./types\"\n\n/**\n * Identity wrapper — marks a function as a Pyreon component and preserves its type.\n * Useful for IDE tooling and future compiler optimisations.\n */\nexport function defineComponent<P extends Props>(fn: ComponentFn<P>): ComponentFn<P> {\n return fn\n}\n\n/**\n * Run a component function in a tracked context so that lifecycle hooks\n * registered inside it (onMount, onUnmount, onErrorCaptured, etc.) are captured.\n *\n * Called by the renderer — not intended for user code.\n */\nexport function runWithHooks<P extends Props>(\n fn: ComponentFn<P>,\n props: P,\n): { vnode: VNode | null; hooks: LifecycleHooks } {\n const hooks: LifecycleHooks = { mount: [], unmount: [], update: [], error: [] }\n setCurrentHooks(hooks)\n let vnode: VNode | null = null\n try {\n vnode = fn(props)\n } finally {\n setCurrentHooks(null)\n }\n return { vnode, hooks }\n}\n\n/**\n * Walk up error handlers collected during component rendering.\n * Returns true if any handler marked the error as handled.\n */\nexport function propagateError(err: unknown, hooks: LifecycleHooks): boolean {\n for (const handler of hooks.error) {\n if (handler(err) === true) return true\n }\n return false\n}\n\n// ─── Error boundary stack ────────────────────────────────────────────────────\n// Module-level stack of active ErrorBoundary handlers (innermost last).\n// ErrorBoundary pushes during its own setup (before children mount) so that\n// any child mountComponent error can dispatch up to the nearest boundary.\n\nconst _errorBoundaryStack: ((err: unknown) => boolean)[] = []\n\nexport function pushErrorBoundary(handler: (err: unknown) => boolean): void {\n _errorBoundaryStack.push(handler)\n}\n\nexport function popErrorBoundary(): void {\n _errorBoundaryStack.pop()\n}\n\n/**\n * Dispatch an error to the nearest active ErrorBoundary.\n * Returns true if the boundary handled it, false if none was registered.\n */\nexport function dispatchToErrorBoundary(err: unknown): boolean {\n const handler = _errorBoundaryStack[_errorBoundaryStack.length - 1]\n return handler ? handler(err) : false\n}\n","/**\n * Provide / inject — like React context or Vue provide/inject.\n *\n * Values flow down the component tree without prop-drilling.\n * The renderer maintains the context stack as it walks the VNode tree.\n */\n\nexport interface Context<T> {\n readonly id: symbol\n readonly defaultValue: T\n}\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n return { id: Symbol(\"PyreonContext\"), defaultValue }\n}\n\n// ─── Runtime context stack (managed by the renderer) ─────────────────────────\n\n// Default stack — used for CSR and single-threaded SSR.\n// On Node.js with concurrent requests, @pyreon/runtime-server replaces this with\n// an AsyncLocalStorage-backed provider via setContextStackProvider().\nconst _defaultStack: Map<symbol, unknown>[] = []\nlet _stackProvider: () => Map<symbol, unknown>[] = () => _defaultStack\n\n/**\n * Override the context stack provider. Called by @pyreon/runtime-server to\n * inject an AsyncLocalStorage-backed stack that isolates concurrent SSR requests.\n * Has no effect in the browser (CSR always uses the default module-level stack).\n */\nexport function setContextStackProvider(fn: () => Map<symbol, unknown>[]): void {\n _stackProvider = fn\n}\n\nfunction getStack(): Map<symbol, unknown>[] {\n return _stackProvider()\n}\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\nexport function pushContext(values: Map<symbol, unknown>) {\n getStack().push(values)\n}\n\nexport function popContext() {\n const stack = getStack()\n if (__DEV__ && stack.length === 0) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] popContext() called on an empty context stack. This likely indicates a missing Provider.\",\n )\n return\n }\n stack.pop()\n}\n\n/**\n * Read the nearest provided value for a context.\n * Falls back to `context.defaultValue` if none found.\n */\nexport function useContext<T>(context: Context<T>): T {\n const stack = getStack()\n for (let i = stack.length - 1; i >= 0; i--) {\n const frame = stack[i]\n if (frame?.has(context.id)) {\n return frame.get(context.id) as T\n }\n }\n return context.defaultValue\n}\n\n/**\n * Provide a value for `context` during `fn()`.\n * Used by the renderer when it encounters a `<Provider>` component.\n */\nexport function withContext<T>(context: Context<T>, value: T, fn: () => void) {\n const frame = new Map<symbol, unknown>([[context.id, value]])\n pushContext(frame)\n try {\n fn()\n } finally {\n popContext()\n }\n}\n","import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNode | null) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","import { h } from \"./h\"\nimport type { ComponentFn, Props, VNode } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\nexport interface DynamicProps extends Props {\n component: ComponentFn | string\n}\n\nexport function Dynamic(props: DynamicProps): VNode | null {\n const { component, ...rest } = props\n if (__DEV__ && !component) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\"[Pyreon] <Dynamic> received a falsy `component` prop. Nothing will be rendered.\")\n }\n if (!component) return null\n return h(component as string | ComponentFn, rest as Props)\n}\n","/**\n * Error telemetry — hook into Pyreon's error reporting for Sentry, Datadog, etc.\n *\n * @example\n * import { registerErrorHandler } from \"@pyreon/core\"\n * import * as Sentry from \"@sentry/browser\"\n *\n * registerErrorHandler(ctx => {\n * Sentry.captureException(ctx.error, {\n * extra: { component: ctx.component, phase: ctx.phase },\n * })\n * })\n */\n\nexport interface ErrorContext {\n /** Component function name, or \"Anonymous\" */\n component: string\n /** Lifecycle phase where the error occurred */\n phase: \"setup\" | \"render\" | \"mount\" | \"unmount\" | \"effect\"\n /** The thrown value */\n error: unknown\n /** Unix timestamp (ms) */\n timestamp: number\n /** Component props at the time of the error */\n props?: Record<string, unknown>\n}\n\nexport type ErrorHandler = (ctx: ErrorContext) => void\n\nlet _handlers: ErrorHandler[] = []\n\n/**\n * Register a global error handler. Called whenever a component throws in any\n * lifecycle phase. Returns an unregister function.\n */\nexport function registerErrorHandler(handler: ErrorHandler): () => void {\n _handlers.push(handler)\n return () => {\n _handlers = _handlers.filter((h) => h !== handler)\n }\n}\n\n/**\n * Internal — called by the runtime whenever a component error is caught.\n * Existing console.error calls are preserved; this is additive.\n */\nexport function reportError(ctx: ErrorContext): void {\n for (const h of _handlers) {\n try {\n h(ctx)\n } catch {\n // handler errors must never propagate back into the framework\n }\n }\n}\n","import { signal } from \"@pyreon/reactivity\"\nimport { popErrorBoundary, pushErrorBoundary } from \"./component\"\nimport { onUnmount } from \"./lifecycle\"\nimport { reportError } from \"./telemetry\"\nimport type { VNodeChild, VNodeChildAtom } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n/**\n * ErrorBoundary — catches errors thrown by child components and renders a\n * fallback UI instead of crashing the whole tree.\n *\n * Also reports caught errors to any registered telemetry handlers.\n *\n * How error propagation works:\n * ErrorBoundary pushes a handler onto the module-level boundary stack\n * synchronously during its own setup (before children are mounted).\n * When mountComponent catches a child error, it calls dispatchToErrorBoundary()\n * which invokes the innermost boundary's handler.\n *\n * Usage:\n * h(ErrorBoundary, {\n * fallback: (err) => h(\"p\", null, `Error: ${err}`),\n * children: h(MyComponent, null),\n * })\n *\n * // or with JSX:\n * <ErrorBoundary fallback={(err) => <p>Error: {String(err)}</p>}>\n * <MyComponent />\n * </ErrorBoundary>\n */\nexport function ErrorBoundary(props: {\n /**\n * Rendered when a child throws. Receives the caught error and a `reset`\n * function — calling `reset()` clears the error and re-renders children.\n */\n fallback: (err: unknown, reset: () => void) => VNodeChild\n children?: VNodeChild\n}): VNodeChild {\n if (__DEV__ && typeof props.fallback !== \"function\") {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] <ErrorBoundary> expects `fallback` to be a function: (err, reset) => VNode. \" +\n `Received ${typeof props.fallback}.`,\n )\n }\n\n const error = signal<unknown>(null)\n const reset = () => error.set(null)\n\n const handler = (err: unknown): boolean => {\n if (error.peek() !== null) return false // already in error state — let outer boundary catch it\n error.set(err)\n reportError({ component: \"ErrorBoundary\", phase: \"render\", error: err, timestamp: Date.now() })\n return true\n }\n\n // Push synchronously — before children are mounted — so child errors see this boundary\n pushErrorBoundary(handler)\n onUnmount(() => popErrorBoundary())\n\n return (): VNodeChildAtom => {\n const err = error()\n if (err != null) return props.fallback(err, reset) as VNodeChildAtom\n const ch = props.children\n return (typeof ch === \"function\" ? ch() : ch) as VNodeChildAtom\n }\n}\n","import type { NativeItem, Props, VNode } from \"./types\"\n\n/**\n * Symbol used as the VNode type for a For list — runtime-dom handles it\n * via mountFor, bypassing the generic VNode reconciler.\n */\nexport const ForSymbol: unique symbol = Symbol(\"pyreon.For\")\n\nexport interface ForProps<T> {\n each: () => T[]\n by: (item: T) => string | number\n children: (item: T) => VNode | NativeItem\n}\n\n/**\n * Efficient reactive list rendering.\n *\n * Unlike a plain `() => items().map(item => h(...))`, For never re-creates\n * VNodes for existing keys — only new keys invoke `children()`. Structural\n * mutations (swap, sort, filter) are O(n) key scan + O(k) DOM moves where k\n * is the number of actually displaced entries.\n *\n * Usage:\n * <For each={items} by={r => r.id}>{r => <li>...</li>}</For>\n */\nexport function For<T>(props: ForProps<T>): VNode {\n return {\n type: ForSymbol as unknown as string,\n props: props as unknown as Props,\n children: [],\n key: null,\n }\n}\n","import { signal } from \"@pyreon/reactivity\"\nimport { h } from \"./h\"\nimport type { LazyComponent } from \"./suspense\"\nimport type { ComponentFn, Props } from \"./types\"\n\nexport function lazy<P extends Props>(\n load: () => Promise<{ default: ComponentFn<P> }>,\n): LazyComponent<P> {\n const loaded = signal<ComponentFn<P> | null>(null)\n const error = signal<Error | null>(null)\n\n load()\n .then((m) => loaded.set(m.default))\n .catch((e) => error.set(e instanceof Error ? e : new Error(String(e))))\n\n const wrapper = ((props: P) => {\n const err = error()\n if (err) throw err\n const comp = loaded()\n return comp ? h(comp as ComponentFn, props as Props) : null\n }) as LazyComponent<P>\n\n wrapper.__loading = () => loaded() === null && error() === null\n return wrapper\n}\n","/**\n * mapArray — keyed reactive list mapping.\n *\n * Creates each mapped item exactly once per key, then reuses it across\n * updates. When the source array is reordered or partially changed, only\n * new keys invoke `map()`; existing entries return the cached result.\n *\n * This makes structural list operations (swap, sort, filter) O(k) in\n * allocations where k is the number of new/removed keys, not O(n).\n *\n * The returned accessor reads `source()` reactively, so it can be passed\n * directly to the keyed-list reconciler.\n */\nexport function mapArray<T, U>(\n source: () => T[],\n getKey: (item: T) => string | number,\n map: (item: T) => U,\n): () => U[] {\n const cache = new Map<string | number, U>()\n\n return () => {\n const items = source()\n const result: U[] = []\n const newKeys = new Set<string | number>()\n\n for (const item of items) {\n const key = getKey(item)\n newKeys.add(key)\n if (!cache.has(key)) {\n cache.set(key, map(item))\n }\n result.push(cache.get(key) as U)\n }\n\n // Evict entries whose keys are no longer present\n for (const key of cache.keys()) {\n if (!newKeys.has(key)) cache.delete(key)\n }\n\n return result\n }\n}\n","import type { Props, VNode, VNodeChild } from \"./types\"\n\n/**\n * Symbol used as the VNode type for a Portal — runtime-dom mounts the\n * children into `target` instead of the normal parent.\n */\nexport const PortalSymbol: unique symbol = Symbol(\"pyreon.Portal\")\n\nexport interface PortalProps {\n /** DOM element to render children into (e.g. document.body). */\n target: Element\n children: VNodeChild\n}\n\n/**\n * Portal — renders `children` into a different DOM node than the\n * current parent tree.\n *\n * Useful for modals, tooltips, dropdowns, and any overlay that needs to\n * escape CSS overflow/stacking context restrictions.\n *\n * @example\n * // Render a modal at document.body level regardless of where in the\n * // component tree <Modal> is used:\n * Portal({ target: document.body, children: h(Modal, { onClose }) })\n *\n * // JSX:\n * <Portal target={document.body}>\n * <Modal onClose={close} />\n * </Portal>\n */\nexport function Portal(props: PortalProps): VNode {\n return {\n type: PortalSymbol as unknown as string,\n props: props as unknown as Props,\n children: [],\n key: null,\n }\n}\n","/**\n * createRef — mutable container for a DOM element or component value.\n *\n * Usage:\n * const inputRef = createRef<HTMLInputElement>()\n * onMount(() => { inputRef.current?.focus() })\n * return <input ref={inputRef} />\n *\n * The runtime sets `ref.current` after the element is inserted into the DOM\n * and clears it to `null` when the element is removed.\n */\n\nexport interface Ref<T = unknown> {\n current: T | null\n}\n\nexport function createRef<T = unknown>(): Ref<T> {\n return { current: null }\n}\n","import type { Props, VNode, VNodeChild, VNodeChildAtom } from \"./types\"\n\n// ─── Show ─────────────────────────────────────────────────────────────────────\n\nexport interface ShowProps extends Props {\n /** Accessor — children render when truthy, fallback when falsy. */\n when: () => unknown\n fallback?: VNodeChild\n children?: VNodeChild\n}\n\n/**\n * Conditionally render children based on a reactive condition.\n *\n * @example\n * h(Show, { when: () => isLoggedIn() },\n * h(Dashboard, null)\n * )\n *\n * // With fallback:\n * h(Show, { when: () => user(), fallback: h(Login, null) },\n * h(Dashboard, null)\n * )\n */\nexport function Show(props: ShowProps): VNode | null {\n // Returns a reactive accessor; the renderer unwraps it at mount time.\n return ((): VNodeChildAtom =>\n (props.when()\n ? (props.children ?? null)\n : (props.fallback ?? null)) as VNodeChildAtom) as unknown as VNode\n}\n\n// ─── Switch / Match ───────────────────────────────────────────────────────────\n\nexport interface MatchProps extends Props {\n /** Accessor — this branch renders when truthy. */\n when: () => unknown\n children?: VNodeChild\n}\n\n/**\n * A branch inside `<Switch>`. Renders when `when()` is truthy.\n * Must be used as a direct child of `Switch`.\n *\n * `Match` acts as a pure type/identity marker — Switch identifies it by checking\n * `vnode.type === Match` rather than by the runtime return value.\n */\nexport function Match(_props: MatchProps): VNode | null {\n // Match is never mounted directly — Switch inspects Match VNodes by type identity.\n return null\n}\n\nexport interface SwitchProps extends Props {\n /** Rendered when no Match branch is truthy. */\n fallback?: VNodeChild\n children?: VNodeChild | VNodeChild[]\n}\n\n/**\n * Multi-branch conditional rendering. Evaluates each `Match` child in order,\n * renders the first whose `when()` is truthy, or `fallback` if none match.\n *\n * @example\n * h(Switch, { fallback: h(\"p\", null, \"404\") },\n * h(Match, { when: () => route() === \"/\" }, h(Home, null)),\n * h(Match, { when: () => route() === \"/about\" }, h(About, null)),\n * )\n */\nfunction isMatchVNode(branch: VNodeChild): branch is VNode {\n return (\n branch !== null &&\n typeof branch === \"object\" &&\n !Array.isArray(branch) &&\n (branch as VNode).type === Match\n )\n}\n\nfunction resolveMatchChildren(matchVNode: VNode): VNodeChildAtom {\n if (matchVNode.children.length === 0) {\n return ((matchVNode.props as unknown as MatchProps).children ?? null) as VNodeChildAtom\n }\n if (matchVNode.children.length === 1) return matchVNode.children[0] as VNodeChildAtom\n return matchVNode.children as unknown as VNodeChildAtom\n}\n\nfunction normalizeBranches(children: SwitchProps[\"children\"]): VNodeChild[] {\n if (Array.isArray(children)) return children\n if (children != null) return [children]\n return []\n}\n\nexport function Switch(props: SwitchProps): VNode | null {\n // Returns a reactive accessor; the renderer unwraps it at mount time.\n return ((): VNodeChildAtom => {\n const branches = normalizeBranches(props.children)\n\n for (const branch of branches) {\n if (!isMatchVNode(branch)) continue\n const matchProps = branch.props as unknown as MatchProps\n if (matchProps.when()) return resolveMatchChildren(branch)\n }\n\n return (props.fallback ?? null) as VNodeChildAtom\n }) as unknown as VNode\n}\n\n// Keep MatchSymbol export for any code that was using it\nexport const MatchSymbol: unique symbol = Symbol(\"pyreon.Match\")\n","// Shared style utilities used by both runtime-dom and runtime-server.\n\n// CSS properties where numeric values are unitless (e.g. `opacity: 0.5`, `zIndex: 10`).\n// All other numeric values get \"px\" appended automatically (e.g. `height: 100` → `\"100px\"`).\nexport const CSS_UNITLESS = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"flex\",\n \"flexGrow\",\n \"flexPositive\",\n \"flexShrink\",\n \"flexNegative\",\n \"flexOrder\",\n \"gridArea\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"fontWeight\",\n \"lineClamp\",\n \"lineHeight\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n \"fillOpacity\",\n \"floodOpacity\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n])\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function toKebabCase(str: string): string {\n return str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)\n}\n\n/** Normalize a style value — appends \"px\" to numbers for non-unitless properties. */\nexport function normalizeStyleValue(key: string, value: unknown): string {\n return typeof value === \"number\" && !CSS_UNITLESS.has(key) ? `${value}px` : String(value)\n}\n","import { Fragment, h } from \"./h\"\nimport type { Props, VNode, VNodeChild } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n/** Internal marker attached to lazy()-wrapped components */\nexport type LazyComponent<P extends Props = Props> = ((props: P) => VNode | null) & {\n __loading: () => boolean\n}\n\n/**\n * Suspense — shows `fallback` while a lazy child component is still loading.\n *\n * Works in tandem with `lazy()` from `@pyreon/react-compat` (or `@pyreon/core/lazy`).\n * The child VNode's `.type.__loading()` signal drives the switch.\n *\n * Usage:\n * const Page = lazy(() => import(\"./Page\"))\n *\n * h(Suspense, { fallback: h(Spinner, null) }, h(Page, null))\n * // or with JSX:\n * <Suspense fallback={<Spinner />}><Page /></Suspense>\n */\nexport function Suspense(props: { fallback: VNodeChild; children?: VNodeChild }): VNode {\n if (__DEV__ && props.fallback === undefined) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] <Suspense> is missing a `fallback` prop. Provide fallback UI to show while loading.\",\n )\n }\n\n return h(Fragment, null, () => {\n const ch = props.children\n const childNode = typeof ch === \"function\" ? ch() : ch\n\n // Check if the child is a VNode whose type is a lazy component still loading\n const isLoading =\n childNode != null &&\n typeof childNode === \"object\" &&\n !Array.isArray(childNode) &&\n typeof (childNode as VNode).type === \"function\" &&\n ((childNode as VNode).type as unknown as LazyComponent).__loading?.()\n\n if (isLoading) {\n const fb = props.fallback\n return typeof fb === \"function\" ? fb() : fb\n }\n return childNode\n })\n}\n"],"mappings":";;;AAEA,MAAMA,YAAU,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;AAI3E,IAAI,WAAkC;AAEtC,SAAgB,gBAAgB,OAA8B;AAC5D,YAAW;;AAOb,SAAS,iBAAiB,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D,CAAC;;AAGF,SAAgB,YAAY,KAAqB;AAC/C,QAAO,IAAI,QAAQ,WAAW,MAAM,IAAI,EAAE,aAAa,GAAG;;;AAI5D,SAAgB,oBAAoB,KAAa,OAAwB;AACvE,QAAO,OAAO,UAAU,YAAY,CAAC,aAAa,IAAI,IAAI,GAAG,GAAG,MAAM,MAAM,OAAO,MAAM;;;;;ACvD3F,MAAM,UAAU,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;AAoB3E,SAAgB,SAAS,OAA+D;AACtF,KAAI,WAAW,MAAM,aAAa,OAEhC,SAAQ,KACN,+FACD;AAGH,QAAO,EAAE,UAAU,YAAY;EAC7B,MAAM,KAAK,MAAM;EACjB,MAAM,YAAY,OAAO,OAAO,aAAa,IAAI,GAAG;AAUpD,MANE,aAAa,QACb,OAAO,cAAc,YACrB,CAAC,MAAM,QAAQ,UAAU,IACzB,OAAQ,UAAoB,SAAS,cACnC,UAAoB,KAAkC,aAAa,EAExD;GACb,MAAM,KAAK,MAAM;AACjB,UAAO,OAAO,OAAO,aAAa,IAAI,GAAG;;AAE3C,SAAO;GACP"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["__DEV__","__DEV__","__DEV__","__DEV__"],"sources":["../src/lifecycle.ts","../src/component.ts","../src/context.ts","../src/h.ts","../src/dynamic.ts","../src/telemetry.ts","../src/error-boundary.ts","../src/for.ts","../src/lazy.ts","../src/map-array.ts","../src/portal.ts","../src/ref.ts","../src/show.ts","../src/style.ts","../src/suspense.ts"],"sourcesContent":["import type { CleanupFn, LifecycleHooks } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n// The currently-executing component's hook storage, set by the renderer\n// before calling the component function, cleared immediately after.\nlet _current: LifecycleHooks | null = null\n\nexport function setCurrentHooks(hooks: LifecycleHooks | null) {\n _current = hooks\n}\n\nexport function getCurrentHooks(): LifecycleHooks | null {\n return _current\n}\n\nfunction warnOutsideSetup(hookName: string): void {\n if (__DEV__ && !_current) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n `[Pyreon] ${hookName}() called outside component setup. ` +\n \"Lifecycle hooks must be called synchronously during a component's setup function.\",\n )\n }\n}\n\n/**\n * Register a callback to run after the component is mounted to the DOM.\n * Optionally return a cleanup function — it will run on unmount.\n */\n// biome-ignore lint/suspicious/noConfusingVoidType: void allows callbacks that return nothing\nexport function onMount(fn: () => CleanupFn | void | undefined) {\n warnOutsideSetup(\"onMount\")\n _current?.mount.push(fn)\n}\n\n/**\n * Register a callback to run when the component is removed from the DOM.\n */\nexport function onUnmount(fn: () => void) {\n warnOutsideSetup(\"onUnmount\")\n _current?.unmount.push(fn)\n}\n\n/**\n * Register a callback to run after each reactive update.\n */\nexport function onUpdate(fn: () => void) {\n warnOutsideSetup(\"onUpdate\")\n _current?.update.push(fn)\n}\n\n/**\n * Register an error handler for this component subtree.\n *\n * When an error is thrown during rendering or in a child component,\n * the nearest `onErrorCaptured` handler is called with the error.\n * Return `true` to mark the error as handled and stop propagation.\n *\n * @example\n * onErrorCaptured((err) => {\n * setError(String(err))\n * return true // handled — don't propagate\n * })\n */\nexport function onErrorCaptured(fn: (err: unknown) => boolean | undefined) {\n warnOutsideSetup(\"onErrorCaptured\")\n _current?.error.push(fn)\n}\n","import { setCurrentHooks } from \"./lifecycle\"\nimport type { ComponentFn, LifecycleHooks, Props, VNodeChild } from \"./types\"\n\n/**\n * Identity wrapper — marks a function as a Pyreon component and preserves its type.\n * Useful for IDE tooling and future compiler optimisations.\n */\nexport function defineComponent<P extends Props>(fn: ComponentFn<P>): ComponentFn<P> {\n return fn\n}\n\n/**\n * Run a component function in a tracked context so that lifecycle hooks\n * registered inside it (onMount, onUnmount, onErrorCaptured, etc.) are captured.\n *\n * Called by the renderer — not intended for user code.\n */\nexport function runWithHooks<P extends Props>(\n fn: ComponentFn<P>,\n props: P,\n): { vnode: VNodeChild; hooks: LifecycleHooks } {\n const hooks: LifecycleHooks = { mount: [], unmount: [], update: [], error: [] }\n setCurrentHooks(hooks)\n let vnode: VNodeChild = null\n try {\n vnode = fn(props)\n } finally {\n setCurrentHooks(null)\n }\n return { vnode, hooks }\n}\n\n/**\n * Walk up error handlers collected during component rendering.\n * Returns true if any handler marked the error as handled.\n */\nexport function propagateError(err: unknown, hooks: LifecycleHooks): boolean {\n for (const handler of hooks.error) {\n if (handler(err) === true) return true\n }\n return false\n}\n\n// ─── Error boundary stack ────────────────────────────────────────────────────\n// Module-level stack of active ErrorBoundary handlers (innermost last).\n// ErrorBoundary pushes during its own setup (before children mount) so that\n// any child mountComponent error can dispatch up to the nearest boundary.\n\nconst _errorBoundaryStack: ((err: unknown) => boolean)[] = []\n\nexport function pushErrorBoundary(handler: (err: unknown) => boolean): void {\n _errorBoundaryStack.push(handler)\n}\n\nexport function popErrorBoundary(): void {\n _errorBoundaryStack.pop()\n}\n\n/**\n * Dispatch an error to the nearest active ErrorBoundary.\n * Returns true if the boundary handled it, false if none was registered.\n */\nexport function dispatchToErrorBoundary(err: unknown): boolean {\n const handler = _errorBoundaryStack[_errorBoundaryStack.length - 1]\n return handler ? handler(err) : false\n}\n","/**\n * Provide / inject — like React context or Vue provide/inject.\n *\n * Values flow down the component tree without prop-drilling.\n * The renderer maintains the context stack as it walks the VNode tree.\n */\n\nimport { onUnmount } from \"./lifecycle\"\n\nexport interface Context<T> {\n readonly id: symbol\n readonly defaultValue: T\n}\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n return { id: Symbol(\"PyreonContext\"), defaultValue }\n}\n\n// ─── Runtime context stack (managed by the renderer) ─────────────────────────\n\n// Default stack — used for CSR and single-threaded SSR.\n// On Node.js with concurrent requests, @pyreon/runtime-server replaces this with\n// an AsyncLocalStorage-backed provider via setContextStackProvider().\nconst _defaultStack: Map<symbol, unknown>[] = []\nlet _stackProvider: () => Map<symbol, unknown>[] = () => _defaultStack\n\n/**\n * Override the context stack provider. Called by @pyreon/runtime-server to\n * inject an AsyncLocalStorage-backed stack that isolates concurrent SSR requests.\n * Has no effect in the browser (CSR always uses the default module-level stack).\n */\nexport function setContextStackProvider(fn: () => Map<symbol, unknown>[]): void {\n _stackProvider = fn\n}\n\nfunction getStack(): Map<symbol, unknown>[] {\n return _stackProvider()\n}\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\nexport function pushContext(values: Map<symbol, unknown>) {\n getStack().push(values)\n}\n\nexport function popContext() {\n const stack = getStack()\n if (__DEV__ && stack.length === 0) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] popContext() called on an empty context stack. This likely indicates a missing Provider.\",\n )\n return\n }\n stack.pop()\n}\n\n/**\n * Read the nearest provided value for a context.\n * Falls back to `context.defaultValue` if none found.\n */\nexport function useContext<T>(context: Context<T>): T {\n const stack = getStack()\n for (let i = stack.length - 1; i >= 0; i--) {\n const frame = stack[i]\n if (frame?.has(context.id)) {\n return frame.get(context.id) as T\n }\n }\n return context.defaultValue\n}\n\n/**\n * Provide a context value for the current component's subtree.\n * Must be called during component setup (like onMount/onUnmount).\n * Automatically cleaned up when the component unmounts.\n *\n * @example\n * const ThemeProvider = ({ children }: { children: VNodeChild }) => {\n * provide(ThemeContext, { color: \"blue\" })\n * return children\n * }\n */\nexport function provide<T>(context: Context<T>, value: T): void {\n pushContext(new Map<symbol, unknown>([[context.id, value]]))\n onUnmount(() => popContext())\n}\n\n/**\n * Provide a value for `context` during `fn()`.\n * Used by the renderer when it encounters a `<Provider>` component.\n */\nexport function withContext<T>(context: Context<T>, value: T, fn: () => void) {\n const frame = new Map<symbol, unknown>([[context.id, value]])\n pushContext(frame)\n try {\n fn()\n } finally {\n popContext()\n }\n}\n","import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNodeChild) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","import { h } from \"./h\"\nimport type { ComponentFn, Props, VNode } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\nexport interface DynamicProps extends Props {\n component: ComponentFn | string\n}\n\nexport function Dynamic(props: DynamicProps): VNode | null {\n const { component, ...rest } = props\n if (__DEV__ && !component) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\"[Pyreon] <Dynamic> received a falsy `component` prop. Nothing will be rendered.\")\n }\n if (!component) return null\n return h(component as string | ComponentFn, rest as Props)\n}\n","/**\n * Error telemetry — hook into Pyreon's error reporting for Sentry, Datadog, etc.\n *\n * @example\n * import { registerErrorHandler } from \"@pyreon/core\"\n * import * as Sentry from \"@sentry/browser\"\n *\n * registerErrorHandler(ctx => {\n * Sentry.captureException(ctx.error, {\n * extra: { component: ctx.component, phase: ctx.phase },\n * })\n * })\n */\n\nexport interface ErrorContext {\n /** Component function name, or \"Anonymous\" */\n component: string\n /** Lifecycle phase where the error occurred */\n phase: \"setup\" | \"render\" | \"mount\" | \"unmount\" | \"effect\"\n /** The thrown value */\n error: unknown\n /** Unix timestamp (ms) */\n timestamp: number\n /** Component props at the time of the error */\n props?: Record<string, unknown>\n}\n\nexport type ErrorHandler = (ctx: ErrorContext) => void\n\nlet _handlers: ErrorHandler[] = []\n\n/**\n * Register a global error handler. Called whenever a component throws in any\n * lifecycle phase. Returns an unregister function.\n */\nexport function registerErrorHandler(handler: ErrorHandler): () => void {\n _handlers.push(handler)\n return () => {\n _handlers = _handlers.filter((h) => h !== handler)\n }\n}\n\n/**\n * Internal — called by the runtime whenever a component error is caught.\n * Existing console.error calls are preserved; this is additive.\n */\nexport function reportError(ctx: ErrorContext): void {\n for (const h of _handlers) {\n try {\n h(ctx)\n } catch {\n // handler errors must never propagate back into the framework\n }\n }\n}\n","import { signal } from \"@pyreon/reactivity\"\nimport { popErrorBoundary, pushErrorBoundary } from \"./component\"\nimport { onUnmount } from \"./lifecycle\"\nimport { reportError } from \"./telemetry\"\nimport type { VNodeChild, VNodeChildAtom } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n/**\n * ErrorBoundary — catches errors thrown by child components and renders a\n * fallback UI instead of crashing the whole tree.\n *\n * Also reports caught errors to any registered telemetry handlers.\n *\n * How error propagation works:\n * ErrorBoundary pushes a handler onto the module-level boundary stack\n * synchronously during its own setup (before children are mounted).\n * When mountComponent catches a child error, it calls dispatchToErrorBoundary()\n * which invokes the innermost boundary's handler.\n *\n * Usage:\n * h(ErrorBoundary, {\n * fallback: (err) => h(\"p\", null, `Error: ${err}`),\n * children: h(MyComponent, null),\n * })\n *\n * // or with JSX:\n * <ErrorBoundary fallback={(err) => <p>Error: {String(err)}</p>}>\n * <MyComponent />\n * </ErrorBoundary>\n */\nexport function ErrorBoundary(props: {\n /**\n * Rendered when a child throws. Receives the caught error and a `reset`\n * function — calling `reset()` clears the error and re-renders children.\n */\n fallback: (err: unknown, reset: () => void) => VNodeChild\n children?: VNodeChild\n}): VNodeChild {\n if (__DEV__ && typeof props.fallback !== \"function\") {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] <ErrorBoundary> expects `fallback` to be a function: (err, reset) => VNode. \" +\n `Received ${typeof props.fallback}.`,\n )\n }\n\n const error = signal<unknown>(null)\n const reset = () => error.set(null)\n\n const handler = (err: unknown): boolean => {\n if (error.peek() !== null) return false // already in error state — let outer boundary catch it\n error.set(err)\n reportError({ component: \"ErrorBoundary\", phase: \"render\", error: err, timestamp: Date.now() })\n return true\n }\n\n // Push synchronously — before children are mounted — so child errors see this boundary\n pushErrorBoundary(handler)\n onUnmount(() => popErrorBoundary())\n\n return (): VNodeChildAtom => {\n const err = error()\n if (err != null) return props.fallback(err, reset) as VNodeChildAtom\n const ch = props.children\n return (typeof ch === \"function\" ? ch() : ch) as VNodeChildAtom\n }\n}\n","import type { NativeItem, Props, VNode } from \"./types\"\n\n/**\n * Symbol used as the VNode type for a For list — runtime-dom handles it\n * via mountFor, bypassing the generic VNode reconciler.\n */\nexport const ForSymbol: unique symbol = Symbol(\"pyreon.For\")\n\nexport interface ForProps<T> {\n each: () => T[]\n by: (item: T) => string | number\n children: (item: T) => VNode | NativeItem\n}\n\n/**\n * Efficient reactive list rendering.\n *\n * Unlike a plain `() => items().map(item => h(...))`, For never re-creates\n * VNodes for existing keys — only new keys invoke `children()`. Structural\n * mutations (swap, sort, filter) are O(n) key scan + O(k) DOM moves where k\n * is the number of actually displaced entries.\n *\n * Usage:\n * <For each={items} by={r => r.id}>{r => <li>...</li>}</For>\n */\nexport function For<T>(props: ForProps<T>): VNode {\n return {\n type: ForSymbol as unknown as string,\n props: props as unknown as Props,\n children: [],\n key: null,\n }\n}\n","import { signal } from \"@pyreon/reactivity\"\nimport { h } from \"./h\"\nimport type { LazyComponent } from \"./suspense\"\nimport type { ComponentFn, Props } from \"./types\"\n\nexport function lazy<P extends Props>(\n load: () => Promise<{ default: ComponentFn<P> }>,\n): LazyComponent<P> {\n const loaded = signal<ComponentFn<P> | null>(null)\n const error = signal<Error | null>(null)\n\n load()\n .then((m) => loaded.set(m.default))\n .catch((e) => error.set(e instanceof Error ? e : new Error(String(e))))\n\n const wrapper = ((props: P) => {\n const err = error()\n if (err) throw err\n const comp = loaded()\n return comp ? h(comp as ComponentFn, props as Props) : null\n }) as LazyComponent<P>\n\n wrapper.__loading = () => loaded() === null && error() === null\n return wrapper\n}\n","/**\n * mapArray — keyed reactive list mapping.\n *\n * Creates each mapped item exactly once per key, then reuses it across\n * updates. When the source array is reordered or partially changed, only\n * new keys invoke `map()`; existing entries return the cached result.\n *\n * This makes structural list operations (swap, sort, filter) O(k) in\n * allocations where k is the number of new/removed keys, not O(n).\n *\n * The returned accessor reads `source()` reactively, so it can be passed\n * directly to the keyed-list reconciler.\n */\nexport function mapArray<T, U>(\n source: () => T[],\n getKey: (item: T) => string | number,\n map: (item: T) => U,\n): () => U[] {\n const cache = new Map<string | number, U>()\n\n return () => {\n const items = source()\n const result: U[] = []\n const newKeys = new Set<string | number>()\n\n for (const item of items) {\n const key = getKey(item)\n newKeys.add(key)\n if (!cache.has(key)) {\n cache.set(key, map(item))\n }\n result.push(cache.get(key) as U)\n }\n\n // Evict entries whose keys are no longer present\n for (const key of cache.keys()) {\n if (!newKeys.has(key)) cache.delete(key)\n }\n\n return result\n }\n}\n","import type { Props, VNode, VNodeChild } from \"./types\"\n\n/**\n * Symbol used as the VNode type for a Portal — runtime-dom mounts the\n * children into `target` instead of the normal parent.\n */\nexport const PortalSymbol: unique symbol = Symbol(\"pyreon.Portal\")\n\nexport interface PortalProps {\n /** DOM element to render children into (e.g. document.body). */\n target: Element\n children: VNodeChild\n}\n\n/**\n * Portal — renders `children` into a different DOM node than the\n * current parent tree.\n *\n * Useful for modals, tooltips, dropdowns, and any overlay that needs to\n * escape CSS overflow/stacking context restrictions.\n *\n * @example\n * // Render a modal at document.body level regardless of where in the\n * // component tree <Modal> is used:\n * Portal({ target: document.body, children: h(Modal, { onClose }) })\n *\n * // JSX:\n * <Portal target={document.body}>\n * <Modal onClose={close} />\n * </Portal>\n */\nexport function Portal(props: PortalProps): VNode {\n return {\n type: PortalSymbol as unknown as string,\n props: props as unknown as Props,\n children: [],\n key: null,\n }\n}\n","/**\n * createRef — mutable container for a DOM element or component value.\n *\n * Usage:\n * const inputRef = createRef<HTMLInputElement>()\n * onMount(() => { inputRef.current?.focus() })\n * return <input ref={inputRef} />\n *\n * The runtime sets `ref.current` after the element is inserted into the DOM\n * and clears it to `null` when the element is removed.\n */\n\nexport interface Ref<T = unknown> {\n current: T | null\n}\n\nexport function createRef<T = unknown>(): Ref<T> {\n return { current: null }\n}\n","import type { Props, VNode, VNodeChild, VNodeChildAtom } from \"./types\"\n\n// ─── Show ─────────────────────────────────────────────────────────────────────\n\nexport interface ShowProps extends Props {\n /** Accessor — children render when truthy, fallback when falsy. */\n when: () => unknown\n fallback?: VNodeChild\n children?: VNodeChild\n}\n\n/**\n * Conditionally render children based on a reactive condition.\n *\n * @example\n * h(Show, { when: () => isLoggedIn() },\n * h(Dashboard, null)\n * )\n *\n * // With fallback:\n * h(Show, { when: () => user(), fallback: h(Login, null) },\n * h(Dashboard, null)\n * )\n */\nexport function Show(props: ShowProps): VNode | null {\n // Returns a reactive accessor; the renderer unwraps it at mount time.\n return ((): VNodeChildAtom =>\n (props.when()\n ? (props.children ?? null)\n : (props.fallback ?? null)) as VNodeChildAtom) as unknown as VNode\n}\n\n// ─── Switch / Match ───────────────────────────────────────────────────────────\n\nexport interface MatchProps extends Props {\n /** Accessor — this branch renders when truthy. */\n when: () => unknown\n children?: VNodeChild\n}\n\n/**\n * A branch inside `<Switch>`. Renders when `when()` is truthy.\n * Must be used as a direct child of `Switch`.\n *\n * `Match` acts as a pure type/identity marker — Switch identifies it by checking\n * `vnode.type === Match` rather than by the runtime return value.\n */\nexport function Match(_props: MatchProps): VNode | null {\n // Match is never mounted directly — Switch inspects Match VNodes by type identity.\n return null\n}\n\nexport interface SwitchProps extends Props {\n /** Rendered when no Match branch is truthy. */\n fallback?: VNodeChild\n children?: VNodeChild | VNodeChild[]\n}\n\n/**\n * Multi-branch conditional rendering. Evaluates each `Match` child in order,\n * renders the first whose `when()` is truthy, or `fallback` if none match.\n *\n * @example\n * h(Switch, { fallback: h(\"p\", null, \"404\") },\n * h(Match, { when: () => route() === \"/\" }, h(Home, null)),\n * h(Match, { when: () => route() === \"/about\" }, h(About, null)),\n * )\n */\nfunction isMatchVNode(branch: VNodeChild): branch is VNode {\n return (\n branch !== null &&\n typeof branch === \"object\" &&\n !Array.isArray(branch) &&\n (branch as VNode).type === Match\n )\n}\n\nfunction resolveMatchChildren(matchVNode: VNode): VNodeChildAtom {\n if (matchVNode.children.length === 0) {\n return ((matchVNode.props as unknown as MatchProps).children ?? null) as VNodeChildAtom\n }\n if (matchVNode.children.length === 1) return matchVNode.children[0] as VNodeChildAtom\n return matchVNode.children as unknown as VNodeChildAtom\n}\n\nfunction normalizeBranches(children: SwitchProps[\"children\"]): VNodeChild[] {\n if (Array.isArray(children)) return children\n if (children != null) return [children]\n return []\n}\n\nexport function Switch(props: SwitchProps): VNode | null {\n // Returns a reactive accessor; the renderer unwraps it at mount time.\n return ((): VNodeChildAtom => {\n const branches = normalizeBranches(props.children)\n\n for (const branch of branches) {\n if (!isMatchVNode(branch)) continue\n const matchProps = branch.props as unknown as MatchProps\n if (matchProps.when()) return resolveMatchChildren(branch)\n }\n\n return (props.fallback ?? null) as VNodeChildAtom\n }) as unknown as VNode\n}\n\n// Keep MatchSymbol export for any code that was using it\nexport const MatchSymbol: unique symbol = Symbol(\"pyreon.Match\")\n","// Shared style utilities used by both runtime-dom and runtime-server.\n\n// CSS properties where numeric values are unitless (e.g. `opacity: 0.5`, `zIndex: 10`).\n// All other numeric values get \"px\" appended automatically (e.g. `height: 100` → `\"100px\"`).\nexport const CSS_UNITLESS = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"flex\",\n \"flexGrow\",\n \"flexPositive\",\n \"flexShrink\",\n \"flexNegative\",\n \"flexOrder\",\n \"gridArea\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"fontWeight\",\n \"lineClamp\",\n \"lineHeight\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n \"fillOpacity\",\n \"floodOpacity\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n])\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function toKebabCase(str: string): string {\n return str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)\n}\n\n/** Normalize a style value — appends \"px\" to numbers for non-unitless properties. */\nexport function normalizeStyleValue(key: string, value: unknown): string {\n return typeof value === \"number\" && !CSS_UNITLESS.has(key) ? `${value}px` : String(value)\n}\n","import { Fragment, h } from \"./h\"\nimport type { Props, VNode, VNodeChild } from \"./types\"\n\nconst __DEV__ = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\"\n\n/** Internal marker attached to lazy()-wrapped components */\nexport type LazyComponent<P extends Props = Props> = ((props: P) => VNodeChild) & {\n __loading: () => boolean\n}\n\n/**\n * Suspense — shows `fallback` while a lazy child component is still loading.\n *\n * Works in tandem with `lazy()` from `@pyreon/react-compat` (or `@pyreon/core/lazy`).\n * The child VNode's `.type.__loading()` signal drives the switch.\n *\n * Usage:\n * const Page = lazy(() => import(\"./Page\"))\n *\n * h(Suspense, { fallback: h(Spinner, null) }, h(Page, null))\n * // or with JSX:\n * <Suspense fallback={<Spinner />}><Page /></Suspense>\n */\nexport function Suspense(props: { fallback: VNodeChild; children?: VNodeChild }): VNode {\n if (__DEV__ && props.fallback === undefined) {\n // biome-ignore lint/suspicious/noConsole: dev-only warning\n console.warn(\n \"[Pyreon] <Suspense> is missing a `fallback` prop. Provide fallback UI to show while loading.\",\n )\n }\n\n return h(Fragment, null, () => {\n const ch = props.children\n const childNode = typeof ch === \"function\" ? ch() : ch\n\n // Check if the child is a VNode whose type is a lazy component still loading\n const isLoading =\n childNode != null &&\n typeof childNode === \"object\" &&\n !Array.isArray(childNode) &&\n typeof (childNode as VNode).type === \"function\" &&\n ((childNode as VNode).type as unknown as LazyComponent).__loading?.()\n\n if (isLoading) {\n const fb = props.fallback\n return typeof fb === \"function\" ? fb() : fb\n }\n return childNode\n })\n}\n"],"mappings":";;;AAEA,MAAMA,YAAU,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;AAI3E,IAAI,WAAkC;AAEtC,SAAgB,gBAAgB,OAA8B;AAC5D,YAAW;;AAOb,SAAS,iBAAiB,UAAwB;AAChD,KAAIA,aAAW,CAAC,SAEd,SAAQ,KACN,YAAY,SAAS,sHAEtB;;;;;;AASL,SAAgB,QAAQ,IAAwC;AAC9D,kBAAiB,UAAU;AAC3B,WAAU,MAAM,KAAK,GAAG;;;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ACD,CAAC;;AAGF,SAAgB,YAAY,KAAqB;AAC/C,QAAO,IAAI,QAAQ,WAAW,MAAM,IAAI,EAAE,aAAa,GAAG;;;AAI5D,SAAgB,oBAAoB,KAAa,OAAwB;AACvE,QAAO,OAAO,UAAU,YAAY,CAAC,aAAa,IAAI,IAAI,GAAG,GAAG,MAAM,MAAM,OAAO,MAAM;;;;;ACvD3F,MAAM,UAAU,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;AAoB3E,SAAgB,SAAS,OAA+D;AACtF,KAAI,WAAW,MAAM,aAAa,OAEhC,SAAQ,KACN,+FACD;AAGH,QAAO,EAAE,UAAU,YAAY;EAC7B,MAAM,KAAK,MAAM;EACjB,MAAM,YAAY,OAAO,OAAO,aAAa,IAAI,GAAG;AAUpD,MANE,aAAa,QACb,OAAO,cAAc,YACrB,CAAC,MAAM,QAAQ,UAAU,IACzB,OAAQ,UAAoB,SAAS,cACnC,UAAoB,KAAkC,aAAa,EAExD;GACb,MAAM,KAAK,MAAM;AACjB,UAAO,OAAO,OAAO,aAAa,IAAI,GAAG;;AAE3C,SAAO;GACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/h.ts","../src/jsx-runtime.ts"],"sourcesContent":["import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNode | null) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","/**\n * JSX automatic runtime.\n *\n * When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n * rewrites JSX to imports from this file automatically:\n * <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n */\nimport { Fragment, h } from \"./h\"\nimport type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\nexport { Fragment }\n\nexport function jsx(\n type: string | ComponentFn | symbol,\n props: Props & { children?: VNodeChild | VNodeChild[] },\n key?: string | number | null,\n): VNode {\n const { children, ...rest } = props\n const propsWithKey = (key != null ? { ...rest, key } : rest) as Props\n\n if (typeof type === \"function\") {\n // Component: keep children in props.children so the component function can access them.\n // Children must NOT be spread as h() rest args because mountComponent only passes vnode.props.\n const componentProps = children !== undefined ? { ...propsWithKey, children } : propsWithKey\n return h(type, componentProps)\n }\n\n // DOM element or symbol (Fragment, ForSymbol): children go in vnode.children\n const childArray = children === undefined ? [] : Array.isArray(children) ? children : [children]\n return h(type, propsWithKey, ...(childArray as VNodeChild[]))\n}\n\n// jsxs is called when there are multiple static children — same signature\nexport const jsxs = jsx\n\n// ─── JSX types ────────────────────────────────────────────────────────────────\n\ntype Booleanish = boolean | \"true\" | \"false\"\ntype CSSProperties = { [K in keyof CSSStyleDeclaration]?: string | number }\ntype StyleValue = string | CSSProperties\n\n/** Common HTML attributes accepted by all Pyreon elements */\ninterface PyreonHTMLAttributes {\n // Identity\n id?: string\n class?: string | (() => string)\n className?: string | (() => string)\n style?: StyleValue | (() => StyleValue)\n // pyreon-specific directives\n \"n-show\"?: boolean | (() => boolean)\n // Accessible\n role?: string\n tabIndex?: number | (() => number)\n title?: string\n lang?: string\n dir?: \"ltr\" | \"rtl\" | \"auto\"\n hidden?: boolean | (() => boolean)\n draggable?: Booleanish\n // ARIA\n \"aria-label\"?: string | (() => string)\n \"aria-hidden\"?: Booleanish | (() => Booleanish)\n \"aria-disabled\"?: Booleanish | (() => Booleanish)\n \"aria-expanded\"?: Booleanish | (() => Booleanish)\n \"aria-selected\"?: Booleanish | (() => Booleanish)\n \"aria-checked\"?: Booleanish | \"mixed\" | (() => Booleanish | \"mixed\")\n \"aria-current\"?: Booleanish | \"page\" | \"step\" | \"location\" | \"date\" | \"time\"\n \"aria-live\"?: \"off\" | \"assertive\" | \"polite\"\n \"aria-atomic\"?: Booleanish\n \"aria-busy\"?: Booleanish\n \"aria-controls\"?: string\n \"aria-describedby\"?: string\n \"aria-labelledby\"?: string\n \"aria-placeholder\"?: string\n \"aria-required\"?: Booleanish | (() => Booleanish)\n \"aria-invalid\"?: Booleanish | \"grammar\" | \"spelling\"\n \"aria-valuemin\"?: number\n \"aria-valuemax\"?: number\n \"aria-valuenow\"?: number\n \"aria-valuetext\"?: string\n \"aria-haspopup\"?: Booleanish | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\"\n \"aria-posinset\"?: number\n \"aria-setsize\"?: number\n \"aria-level\"?: number\n \"aria-multiline\"?: Booleanish\n \"aria-multiselectable\"?: Booleanish\n \"aria-orientation\"?: \"horizontal\" | \"vertical\"\n \"aria-readonly\"?: Booleanish | (() => Booleanish)\n \"aria-sort\"?: \"none\" | \"ascending\" | \"descending\" | \"other\"\n \"aria-autocomplete\"?: \"none\" | \"inline\" | \"list\" | \"both\"\n \"aria-colcount\"?: number\n \"aria-colindex\"?: number\n \"aria-colspan\"?: number\n \"aria-rowcount\"?: number\n \"aria-rowindex\"?: number\n \"aria-rowspan\"?: number\n // DOM lifecycle ref — object ref or callback ref\n ref?: { current: unknown } | ((el: Element | null) => void)\n // Key for list reconciliation\n key?: string | number\n // Children — allows null, undefined, boolean in JSX children positions\n children?: VNodeChild | VNodeChild[]\n // innerHTML\n innerHTML?: string\n dangerouslySetInnerHTML?: { __html: string }\n // Events\n onClick?: (e: MouseEvent) => void\n onDblClick?: (e: MouseEvent) => void\n onMouseDown?: (e: MouseEvent) => void\n onMouseUp?: (e: MouseEvent) => void\n onMouseEnter?: (e: MouseEvent) => void\n onMouseLeave?: (e: MouseEvent) => void\n onMouseMove?: (e: MouseEvent) => void\n onMouseOver?: (e: MouseEvent) => void\n onMouseOut?: (e: MouseEvent) => void\n onContextMenu?: (e: MouseEvent) => void\n onKeyDown?: (e: KeyboardEvent) => void\n onKeyUp?: (e: KeyboardEvent) => void\n onKeyPress?: (e: KeyboardEvent) => void\n onFocus?: (e: FocusEvent) => void\n onBlur?: (e: FocusEvent) => void\n onChange?: (e: Event) => void\n onInput?: (e: InputEvent) => void\n onSubmit?: (e: SubmitEvent) => void\n onReset?: (e: Event) => void\n onScroll?: (e: Event) => void\n onWheel?: (e: WheelEvent) => void\n onDragStart?: (e: DragEvent) => void\n onDragEnd?: (e: DragEvent) => void\n onDragOver?: (e: DragEvent) => void\n onDragEnter?: (e: DragEvent) => void\n onDragLeave?: (e: DragEvent) => void\n onDrop?: (e: DragEvent) => void\n onTouchStart?: (e: TouchEvent) => void\n onTouchEnd?: (e: TouchEvent) => void\n onTouchMove?: (e: TouchEvent) => void\n onPointerDown?: (e: PointerEvent) => void\n onPointerUp?: (e: PointerEvent) => void\n onPointerMove?: (e: PointerEvent) => void\n onPointerEnter?: (e: PointerEvent) => void\n onPointerLeave?: (e: PointerEvent) => void\n onPointerCancel?: (e: PointerEvent) => void\n onPointerOver?: (e: PointerEvent) => void\n onPointerOut?: (e: PointerEvent) => void\n onTransitionEnd?: (e: TransitionEvent) => void\n onAnimationStart?: (e: AnimationEvent) => void\n onAnimationEnd?: (e: AnimationEvent) => void\n onAnimationIteration?: (e: AnimationEvent) => void\n onLoad?: (e: Event) => void\n onError?: (e: Event | string) => void\n onAbort?: (e: Event) => void\n onSelect?: (e: Event) => void\n onCopy?: (e: ClipboardEvent) => void\n onCut?: (e: ClipboardEvent) => void\n onPaste?: (e: ClipboardEvent) => void\n // Catch-all for data-* and other arbitrary attributes\n [key: string]: unknown\n}\n\n/** Attributes specific to form inputs */\ninterface InputAttributes extends PyreonHTMLAttributes {\n type?: string | (() => string)\n value?: string | number | (() => string | number)\n defaultValue?: string | number\n checked?: boolean | (() => boolean)\n defaultChecked?: boolean\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n min?: string | number\n max?: string | number\n step?: string | number\n minLength?: number\n maxLength?: number\n pattern?: string\n multiple?: boolean\n name?: string\n accept?: string\n autoComplete?: string\n autoFocus?: boolean\n form?: string\n list?: string\n size?: number\n src?: string | (() => string)\n alt?: string\n width?: number | string\n height?: number | string\n}\n\ninterface AnchorAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\" | string\n rel?: string\n download?: string | boolean\n}\n\ninterface ButtonAttributes extends PyreonHTMLAttributes {\n type?: \"button\" | \"submit\" | \"reset\"\n disabled?: boolean | (() => boolean)\n name?: string\n value?: string\n form?: string\n formAction?: string\n formMethod?: string\n formEncType?: string\n formNoValidate?: boolean\n formTarget?: string\n}\n\ninterface TextareaAttributes extends PyreonHTMLAttributes {\n value?: string | (() => string)\n defaultValue?: string\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n rows?: number\n cols?: number\n minLength?: number\n maxLength?: number\n name?: string\n autoFocus?: boolean\n form?: string\n wrap?: \"hard\" | \"soft\"\n}\n\ninterface SelectAttributes extends PyreonHTMLAttributes {\n value?: string | string[] | (() => string | string[])\n defaultValue?: string | string[]\n disabled?: boolean | (() => boolean)\n required?: boolean | (() => boolean)\n multiple?: boolean\n name?: string\n size?: number\n form?: string\n autoFocus?: boolean\n}\n\ninterface OptionAttributes extends PyreonHTMLAttributes {\n value?: string | number | (() => string | number)\n disabled?: boolean | (() => boolean)\n selected?: boolean | (() => boolean)\n label?: string\n}\n\ninterface FormAttributes extends PyreonHTMLAttributes {\n action?: string\n method?: \"get\" | \"post\"\n encType?: string\n noValidate?: boolean\n target?: string\n name?: string\n autoComplete?: string\n}\n\ninterface ImgAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n alt?: string | (() => string)\n width?: number | string | (() => number | string)\n height?: number | string | (() => number | string)\n loading?: \"lazy\" | \"eager\"\n decoding?: \"auto\" | \"async\" | \"sync\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n referrerPolicy?: string\n srcSet?: string\n sizes?: string\n}\n\ninterface VideoAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n poster?: string\n preload?: \"none\" | \"metadata\" | \"auto\"\n playsInline?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface AudioAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n preload?: \"none\" | \"metadata\" | \"auto\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface LabelAttributes extends PyreonHTMLAttributes {\n htmlFor?: string\n for?: string\n form?: string\n}\n\ninterface ThAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\"\n abbr?: string\n headers?: string\n}\n\ninterface TdAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n headers?: string\n}\n\ninterface ColAttributes extends PyreonHTMLAttributes {\n span?: number\n}\n\ninterface IframeAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n allow?: string\n allowFullScreen?: boolean\n loading?: \"lazy\" | \"eager\"\n name?: string\n sandbox?: string\n referrerPolicy?: string\n title?: string\n}\n\ninterface LinkAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n rel?: string\n type?: string\n as?: string\n media?: string\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n referrerPolicy?: string\n}\n\ninterface MetaAttributes extends PyreonHTMLAttributes {\n name?: string\n content?: string | (() => string)\n httpEquiv?: string\n charset?: string\n property?: string\n}\n\ninterface ScriptAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n async?: boolean\n defer?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n noModule?: boolean\n referrerPolicy?: string\n}\n\ninterface SourceAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n srcSet?: string\n sizes?: string\n media?: string\n}\n\ninterface ProgressAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n max?: number\n}\n\ninterface MeterAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n min?: number\n max?: number\n low?: number\n high?: number\n optimum?: number\n}\n\ninterface DetailsAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface DialogAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface OlAttributes extends PyreonHTMLAttributes {\n start?: number\n reversed?: boolean\n type?: \"1\" | \"a\" | \"A\" | \"i\" | \"I\"\n}\n\ninterface SvgAttributes extends PyreonHTMLAttributes {\n viewBox?: string\n xmlns?: string\n fill?: string | (() => string)\n stroke?: string | (() => string)\n \"stroke-width\"?: string | number\n \"stroke-linecap\"?: \"butt\" | \"round\" | \"square\"\n \"stroke-linejoin\"?: \"miter\" | \"round\" | \"bevel\"\n \"fill-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-path\"?: string\n d?: string\n cx?: string | number\n cy?: string | number\n r?: string | number\n rx?: string | number\n ry?: string | number\n x?: string | number\n y?: string | number\n x1?: string | number\n y1?: string | number\n x2?: string | number\n y2?: string | number\n width?: string | number\n height?: string | number\n transform?: string | (() => string)\n opacity?: string | number | (() => string | number)\n points?: string\n \"font-size\"?: string | number\n \"text-anchor\"?: \"start\" | \"middle\" | \"end\"\n \"dominant-baseline\"?: string\n}\n\ndeclare global {\n namespace JSX {\n /** The type that JSX expressions evaluate to */\n type Element = import(\"./types\").VNode\n\n /**\n * Valid JSX tag types — intrinsic strings + component functions.\n * Components may return VNode, null, strings, functions (reactive getters), etc.\n * (TS 5.1+ feature)\n */\n type ElementType = keyof IntrinsicElements | ((props: any) => import(\"./types\").VNodeChild)\n\n /** Tells TS which prop name carries children in component calls */\n interface ElementChildrenAttribute {\n // biome-ignore lint/complexity/noBannedTypes: JSX spec requires {} for ElementChildrenAttribute\n children: {}\n }\n\n interface IntrinsicElements {\n // Document structure\n html: PyreonHTMLAttributes\n head: PyreonHTMLAttributes\n body: PyreonHTMLAttributes\n title: PyreonHTMLAttributes\n base: PyreonHTMLAttributes\n meta: MetaAttributes\n link: LinkAttributes\n script: ScriptAttributes\n style: PyreonHTMLAttributes\n noscript: PyreonHTMLAttributes\n // Sections\n main: PyreonHTMLAttributes\n header: PyreonHTMLAttributes\n footer: PyreonHTMLAttributes\n nav: PyreonHTMLAttributes\n aside: PyreonHTMLAttributes\n section: PyreonHTMLAttributes\n article: PyreonHTMLAttributes\n address: PyreonHTMLAttributes\n h1: PyreonHTMLAttributes\n h2: PyreonHTMLAttributes\n h3: PyreonHTMLAttributes\n h4: PyreonHTMLAttributes\n h5: PyreonHTMLAttributes\n h6: PyreonHTMLAttributes\n hgroup: PyreonHTMLAttributes\n // Block text\n p: PyreonHTMLAttributes\n pre: PyreonHTMLAttributes\n blockquote: PyreonHTMLAttributes\n figure: PyreonHTMLAttributes\n figcaption: PyreonHTMLAttributes\n div: PyreonHTMLAttributes\n hr: PyreonHTMLAttributes\n // Inline text\n span: PyreonHTMLAttributes\n a: AnchorAttributes\n em: PyreonHTMLAttributes\n strong: PyreonHTMLAttributes\n small: PyreonHTMLAttributes\n s: PyreonHTMLAttributes\n cite: PyreonHTMLAttributes\n q: PyreonHTMLAttributes\n abbr: PyreonHTMLAttributes\n time: PyreonHTMLAttributes\n code: PyreonHTMLAttributes\n var: PyreonHTMLAttributes\n samp: PyreonHTMLAttributes\n kbd: PyreonHTMLAttributes\n mark: PyreonHTMLAttributes\n sub: PyreonHTMLAttributes\n sup: PyreonHTMLAttributes\n i: PyreonHTMLAttributes\n b: PyreonHTMLAttributes\n u: PyreonHTMLAttributes\n bdi: PyreonHTMLAttributes\n bdo: PyreonHTMLAttributes\n br: PyreonHTMLAttributes\n wbr: PyreonHTMLAttributes\n ruby: PyreonHTMLAttributes\n rt: PyreonHTMLAttributes\n rp: PyreonHTMLAttributes\n // Lists\n ul: PyreonHTMLAttributes\n ol: OlAttributes\n li: PyreonHTMLAttributes\n dl: PyreonHTMLAttributes\n dt: PyreonHTMLAttributes\n dd: PyreonHTMLAttributes\n // Forms\n form: FormAttributes\n label: LabelAttributes\n input: InputAttributes\n button: ButtonAttributes\n select: SelectAttributes\n datalist: PyreonHTMLAttributes\n optgroup: PyreonHTMLAttributes\n option: OptionAttributes\n textarea: TextareaAttributes\n output: PyreonHTMLAttributes\n progress: ProgressAttributes\n meter: MeterAttributes\n fieldset: PyreonHTMLAttributes\n legend: PyreonHTMLAttributes\n // Tables\n table: PyreonHTMLAttributes\n caption: PyreonHTMLAttributes\n colgroup: PyreonHTMLAttributes\n col: ColAttributes\n thead: PyreonHTMLAttributes\n tbody: PyreonHTMLAttributes\n tfoot: PyreonHTMLAttributes\n tr: PyreonHTMLAttributes\n th: ThAttributes\n td: TdAttributes\n // Media\n img: ImgAttributes\n video: VideoAttributes\n audio: AudioAttributes\n source: SourceAttributes\n track: PyreonHTMLAttributes\n picture: PyreonHTMLAttributes\n canvas: PyreonHTMLAttributes\n svg: SvgAttributes\n path: SvgAttributes\n circle: SvgAttributes\n ellipse: SvgAttributes\n line: SvgAttributes\n polyline: SvgAttributes\n polygon: SvgAttributes\n rect: SvgAttributes\n text: SvgAttributes\n tspan: SvgAttributes\n g: SvgAttributes\n defs: SvgAttributes\n use: SvgAttributes & { href?: string }\n symbol: SvgAttributes\n clipPath: SvgAttributes\n mask: SvgAttributes\n marker: SvgAttributes\n pattern: SvgAttributes\n linearGradient: SvgAttributes\n radialGradient: SvgAttributes\n stop: SvgAttributes & {\n offset?: string | number\n \"stop-color\"?: string\n \"stop-opacity\"?: string | number\n }\n // Interactive / embedding\n details: DetailsAttributes\n summary: PyreonHTMLAttributes\n dialog: DialogAttributes\n iframe: IframeAttributes\n embed: PyreonHTMLAttributes\n object: PyreonHTMLAttributes\n param: PyreonHTMLAttributes\n // Semantic / misc\n menu: PyreonHTMLAttributes\n menuitem: PyreonHTMLAttributes\n template: PyreonHTMLAttributes\n slot: PyreonHTMLAttributes\n portal: PyreonHTMLAttributes\n // Catch-all for custom elements and data-* attrs\n [tagName: string]: PyreonHTMLAttributes\n }\n }\n}\n"],"mappings":";;AAGA,MAAa,WAA0B,OAAO,kBAAkB;;;;;;;;;AAUhE,MAAa,cAAqB,EAAE;AAmBpC,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACC;EACN,OAAQ,SAAS;EACjB,UAAU,kBAAkB,SAAS;EACrC,KAAM,OAAO,OAAkC;EAChD;;AAGH,SAAS,kBAAkB,UAAsC;AAE/D,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACnC,KAAI,MAAM,QAAQ,SAAS,GAAG,CAC5B,QAAO,gBAAgB,SAAS;AAGpC,QAAO;;AAGT,SAAS,gBAAgB,UAAsC;CAC7D,MAAM,SAAuB,EAAE;AAC/B,MAAK,MAAM,SAAS,SAClB,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,KAAK,GAAG,gBAAgB,MAAsB,CAAC;KAEtD,QAAO,KAAK,MAAM;AAGtB,QAAO;;;;;;;;;;;;ACpDT,SAAgB,IACd,MACA,OACA,KACO;CACP,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAgB,OAAO,OAAO;EAAE,GAAG;EAAM;EAAK,GAAG;AAEvD,KAAI,OAAO,SAAS,WAIlB,QAAO,EAAE,MADc,aAAa,SAAY;EAAE,GAAG;EAAc;EAAU,GAAG,aAClD;AAKhC,QAAO,EAAE,MAAM,cAAc,GADV,aAAa,SAAY,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CACnC;;AAI/D,MAAa,OAAO"}
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/h.ts","../src/jsx-runtime.ts"],"sourcesContent":["import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNodeChild) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","/**\n * JSX automatic runtime.\n *\n * When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n * rewrites JSX to imports from this file automatically:\n * <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n */\nimport { Fragment, h } from \"./h\"\nimport type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\nexport { Fragment }\n\nexport function jsx(\n type: string | ComponentFn | symbol,\n props: Props & { children?: VNodeChild | VNodeChild[] },\n key?: string | number | null,\n): VNode {\n const { children, ...rest } = props\n const propsWithKey = (key != null ? { ...rest, key } : rest) as Props\n\n if (typeof type === \"function\") {\n // Component: keep children in props.children so the component function can access them.\n // Children must NOT be spread as h() rest args because mountComponent only passes vnode.props.\n const componentProps = children !== undefined ? { ...propsWithKey, children } : propsWithKey\n return h(type, componentProps)\n }\n\n // DOM element or symbol (Fragment, ForSymbol): children go in vnode.children\n const childArray = children === undefined ? [] : Array.isArray(children) ? children : [children]\n return h(type, propsWithKey, ...(childArray as VNodeChild[]))\n}\n\n// jsxs is called when there are multiple static children — same signature\nexport const jsxs = jsx\n\n// ─── JSX types ────────────────────────────────────────────────────────────────\n\ntype Booleanish = boolean | \"true\" | \"false\"\ntype CSSProperties = { [K in keyof CSSStyleDeclaration]?: string | number }\ntype StyleValue = string | CSSProperties\n\n/** Common HTML attributes accepted by all Pyreon elements */\ninterface PyreonHTMLAttributes {\n // Identity\n id?: string\n class?: string | (() => string)\n className?: string | (() => string)\n style?: StyleValue | (() => StyleValue)\n // pyreon-specific directives\n \"n-show\"?: boolean | (() => boolean)\n // Accessible\n role?: string\n tabIndex?: number | (() => number)\n title?: string\n lang?: string\n dir?: \"ltr\" | \"rtl\" | \"auto\"\n hidden?: boolean | (() => boolean)\n draggable?: Booleanish\n // ARIA\n \"aria-label\"?: string | (() => string)\n \"aria-hidden\"?: Booleanish | (() => Booleanish)\n \"aria-disabled\"?: Booleanish | (() => Booleanish)\n \"aria-expanded\"?: Booleanish | (() => Booleanish)\n \"aria-selected\"?: Booleanish | (() => Booleanish)\n \"aria-checked\"?: Booleanish | \"mixed\" | (() => Booleanish | \"mixed\")\n \"aria-current\"?: Booleanish | \"page\" | \"step\" | \"location\" | \"date\" | \"time\"\n \"aria-live\"?: \"off\" | \"assertive\" | \"polite\"\n \"aria-atomic\"?: Booleanish\n \"aria-busy\"?: Booleanish\n \"aria-controls\"?: string\n \"aria-describedby\"?: string\n \"aria-labelledby\"?: string\n \"aria-placeholder\"?: string\n \"aria-required\"?: Booleanish | (() => Booleanish)\n \"aria-invalid\"?: Booleanish | \"grammar\" | \"spelling\"\n \"aria-valuemin\"?: number\n \"aria-valuemax\"?: number\n \"aria-valuenow\"?: number\n \"aria-valuetext\"?: string\n \"aria-haspopup\"?: Booleanish | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\"\n \"aria-posinset\"?: number\n \"aria-setsize\"?: number\n \"aria-level\"?: number\n \"aria-multiline\"?: Booleanish\n \"aria-multiselectable\"?: Booleanish\n \"aria-orientation\"?: \"horizontal\" | \"vertical\"\n \"aria-readonly\"?: Booleanish | (() => Booleanish)\n \"aria-sort\"?: \"none\" | \"ascending\" | \"descending\" | \"other\"\n \"aria-autocomplete\"?: \"none\" | \"inline\" | \"list\" | \"both\"\n \"aria-colcount\"?: number\n \"aria-colindex\"?: number\n \"aria-colspan\"?: number\n \"aria-rowcount\"?: number\n \"aria-rowindex\"?: number\n \"aria-rowspan\"?: number\n // DOM lifecycle ref — object ref or callback ref\n ref?: { current: unknown } | ((el: Element | null) => void)\n // Key for list reconciliation\n key?: string | number\n // Children — allows null, undefined, boolean in JSX children positions\n children?: VNodeChild | VNodeChild[]\n // innerHTML\n innerHTML?: string\n dangerouslySetInnerHTML?: { __html: string }\n // Events\n onClick?: (e: MouseEvent) => void\n onDblClick?: (e: MouseEvent) => void\n onMouseDown?: (e: MouseEvent) => void\n onMouseUp?: (e: MouseEvent) => void\n onMouseEnter?: (e: MouseEvent) => void\n onMouseLeave?: (e: MouseEvent) => void\n onMouseMove?: (e: MouseEvent) => void\n onMouseOver?: (e: MouseEvent) => void\n onMouseOut?: (e: MouseEvent) => void\n onContextMenu?: (e: MouseEvent) => void\n onKeyDown?: (e: KeyboardEvent) => void\n onKeyUp?: (e: KeyboardEvent) => void\n onKeyPress?: (e: KeyboardEvent) => void\n onFocus?: (e: FocusEvent) => void\n onBlur?: (e: FocusEvent) => void\n onChange?: (e: Event) => void\n onInput?: (e: InputEvent) => void\n onSubmit?: (e: SubmitEvent) => void\n onReset?: (e: Event) => void\n onScroll?: (e: Event) => void\n onWheel?: (e: WheelEvent) => void\n onDragStart?: (e: DragEvent) => void\n onDragEnd?: (e: DragEvent) => void\n onDragOver?: (e: DragEvent) => void\n onDragEnter?: (e: DragEvent) => void\n onDragLeave?: (e: DragEvent) => void\n onDrop?: (e: DragEvent) => void\n onTouchStart?: (e: TouchEvent) => void\n onTouchEnd?: (e: TouchEvent) => void\n onTouchMove?: (e: TouchEvent) => void\n onPointerDown?: (e: PointerEvent) => void\n onPointerUp?: (e: PointerEvent) => void\n onPointerMove?: (e: PointerEvent) => void\n onPointerEnter?: (e: PointerEvent) => void\n onPointerLeave?: (e: PointerEvent) => void\n onPointerCancel?: (e: PointerEvent) => void\n onPointerOver?: (e: PointerEvent) => void\n onPointerOut?: (e: PointerEvent) => void\n onTransitionEnd?: (e: TransitionEvent) => void\n onAnimationStart?: (e: AnimationEvent) => void\n onAnimationEnd?: (e: AnimationEvent) => void\n onAnimationIteration?: (e: AnimationEvent) => void\n onLoad?: (e: Event) => void\n onError?: (e: Event | string) => void\n onAbort?: (e: Event) => void\n onSelect?: (e: Event) => void\n onCopy?: (e: ClipboardEvent) => void\n onCut?: (e: ClipboardEvent) => void\n onPaste?: (e: ClipboardEvent) => void\n // Catch-all for data-* and other arbitrary attributes\n [key: string]: unknown\n}\n\n/** Attributes specific to form inputs */\ninterface InputAttributes extends PyreonHTMLAttributes {\n type?: string | (() => string)\n value?: string | number | (() => string | number)\n defaultValue?: string | number\n checked?: boolean | (() => boolean)\n defaultChecked?: boolean\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n min?: string | number\n max?: string | number\n step?: string | number\n minLength?: number\n maxLength?: number\n pattern?: string\n multiple?: boolean\n name?: string\n accept?: string\n autoComplete?: string\n autoFocus?: boolean\n form?: string\n list?: string\n size?: number\n src?: string | (() => string)\n alt?: string\n width?: number | string\n height?: number | string\n}\n\ninterface AnchorAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\" | string\n rel?: string\n download?: string | boolean\n}\n\ninterface ButtonAttributes extends PyreonHTMLAttributes {\n type?: \"button\" | \"submit\" | \"reset\"\n disabled?: boolean | (() => boolean)\n name?: string\n value?: string\n form?: string\n formAction?: string\n formMethod?: string\n formEncType?: string\n formNoValidate?: boolean\n formTarget?: string\n}\n\ninterface TextareaAttributes extends PyreonHTMLAttributes {\n value?: string | (() => string)\n defaultValue?: string\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n rows?: number\n cols?: number\n minLength?: number\n maxLength?: number\n name?: string\n autoFocus?: boolean\n form?: string\n wrap?: \"hard\" | \"soft\"\n}\n\ninterface SelectAttributes extends PyreonHTMLAttributes {\n value?: string | string[] | (() => string | string[])\n defaultValue?: string | string[]\n disabled?: boolean | (() => boolean)\n required?: boolean | (() => boolean)\n multiple?: boolean\n name?: string\n size?: number\n form?: string\n autoFocus?: boolean\n}\n\ninterface OptionAttributes extends PyreonHTMLAttributes {\n value?: string | number | (() => string | number)\n disabled?: boolean | (() => boolean)\n selected?: boolean | (() => boolean)\n label?: string\n}\n\ninterface FormAttributes extends PyreonHTMLAttributes {\n action?: string\n method?: \"get\" | \"post\"\n encType?: string\n noValidate?: boolean\n target?: string\n name?: string\n autoComplete?: string\n}\n\ninterface ImgAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n alt?: string | (() => string)\n width?: number | string | (() => number | string)\n height?: number | string | (() => number | string)\n loading?: \"lazy\" | \"eager\"\n decoding?: \"auto\" | \"async\" | \"sync\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n referrerPolicy?: string\n srcSet?: string\n sizes?: string\n}\n\ninterface VideoAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n poster?: string\n preload?: \"none\" | \"metadata\" | \"auto\"\n playsInline?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface AudioAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n preload?: \"none\" | \"metadata\" | \"auto\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface LabelAttributes extends PyreonHTMLAttributes {\n htmlFor?: string\n for?: string\n form?: string\n}\n\ninterface ThAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\"\n abbr?: string\n headers?: string\n}\n\ninterface TdAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n headers?: string\n}\n\ninterface ColAttributes extends PyreonHTMLAttributes {\n span?: number\n}\n\ninterface IframeAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n allow?: string\n allowFullScreen?: boolean\n loading?: \"lazy\" | \"eager\"\n name?: string\n sandbox?: string\n referrerPolicy?: string\n title?: string\n}\n\ninterface LinkAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n rel?: string\n type?: string\n as?: string\n media?: string\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n referrerPolicy?: string\n}\n\ninterface MetaAttributes extends PyreonHTMLAttributes {\n name?: string\n content?: string | (() => string)\n httpEquiv?: string\n charset?: string\n property?: string\n}\n\ninterface ScriptAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n async?: boolean\n defer?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n noModule?: boolean\n referrerPolicy?: string\n}\n\ninterface SourceAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n srcSet?: string\n sizes?: string\n media?: string\n}\n\ninterface ProgressAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n max?: number\n}\n\ninterface MeterAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n min?: number\n max?: number\n low?: number\n high?: number\n optimum?: number\n}\n\ninterface DetailsAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface DialogAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface OlAttributes extends PyreonHTMLAttributes {\n start?: number\n reversed?: boolean\n type?: \"1\" | \"a\" | \"A\" | \"i\" | \"I\"\n}\n\ninterface SvgAttributes extends PyreonHTMLAttributes {\n viewBox?: string\n xmlns?: string\n fill?: string | (() => string)\n stroke?: string | (() => string)\n \"stroke-width\"?: string | number\n \"stroke-linecap\"?: \"butt\" | \"round\" | \"square\"\n \"stroke-linejoin\"?: \"miter\" | \"round\" | \"bevel\"\n \"fill-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-path\"?: string\n d?: string\n cx?: string | number\n cy?: string | number\n r?: string | number\n rx?: string | number\n ry?: string | number\n x?: string | number\n y?: string | number\n x1?: string | number\n y1?: string | number\n x2?: string | number\n y2?: string | number\n width?: string | number\n height?: string | number\n transform?: string | (() => string)\n opacity?: string | number | (() => string | number)\n points?: string\n \"font-size\"?: string | number\n \"text-anchor\"?: \"start\" | \"middle\" | \"end\"\n \"dominant-baseline\"?: string\n}\n\ndeclare global {\n namespace JSX {\n /** The type that JSX expressions evaluate to */\n type Element = import(\"./types\").VNode\n\n /**\n * Valid JSX tag types — intrinsic strings + component functions.\n * Components may return VNode, null, strings, functions (reactive getters), etc.\n * (TS 5.1+ feature)\n */\n type ElementType = keyof IntrinsicElements | ((props: any) => import(\"./types\").VNodeChild)\n\n /** Tells TS which prop name carries children in component calls */\n interface ElementChildrenAttribute {\n // biome-ignore lint/complexity/noBannedTypes: JSX spec requires {} for ElementChildrenAttribute\n children: {}\n }\n\n interface IntrinsicElements {\n // Document structure\n html: PyreonHTMLAttributes\n head: PyreonHTMLAttributes\n body: PyreonHTMLAttributes\n title: PyreonHTMLAttributes\n base: PyreonHTMLAttributes\n meta: MetaAttributes\n link: LinkAttributes\n script: ScriptAttributes\n style: PyreonHTMLAttributes\n noscript: PyreonHTMLAttributes\n // Sections\n main: PyreonHTMLAttributes\n header: PyreonHTMLAttributes\n footer: PyreonHTMLAttributes\n nav: PyreonHTMLAttributes\n aside: PyreonHTMLAttributes\n section: PyreonHTMLAttributes\n article: PyreonHTMLAttributes\n address: PyreonHTMLAttributes\n h1: PyreonHTMLAttributes\n h2: PyreonHTMLAttributes\n h3: PyreonHTMLAttributes\n h4: PyreonHTMLAttributes\n h5: PyreonHTMLAttributes\n h6: PyreonHTMLAttributes\n hgroup: PyreonHTMLAttributes\n // Block text\n p: PyreonHTMLAttributes\n pre: PyreonHTMLAttributes\n blockquote: PyreonHTMLAttributes\n figure: PyreonHTMLAttributes\n figcaption: PyreonHTMLAttributes\n div: PyreonHTMLAttributes\n hr: PyreonHTMLAttributes\n // Inline text\n span: PyreonHTMLAttributes\n a: AnchorAttributes\n em: PyreonHTMLAttributes\n strong: PyreonHTMLAttributes\n small: PyreonHTMLAttributes\n s: PyreonHTMLAttributes\n cite: PyreonHTMLAttributes\n q: PyreonHTMLAttributes\n abbr: PyreonHTMLAttributes\n time: PyreonHTMLAttributes\n code: PyreonHTMLAttributes\n var: PyreonHTMLAttributes\n samp: PyreonHTMLAttributes\n kbd: PyreonHTMLAttributes\n mark: PyreonHTMLAttributes\n sub: PyreonHTMLAttributes\n sup: PyreonHTMLAttributes\n i: PyreonHTMLAttributes\n b: PyreonHTMLAttributes\n u: PyreonHTMLAttributes\n bdi: PyreonHTMLAttributes\n bdo: PyreonHTMLAttributes\n br: PyreonHTMLAttributes\n wbr: PyreonHTMLAttributes\n ruby: PyreonHTMLAttributes\n rt: PyreonHTMLAttributes\n rp: PyreonHTMLAttributes\n // Lists\n ul: PyreonHTMLAttributes\n ol: OlAttributes\n li: PyreonHTMLAttributes\n dl: PyreonHTMLAttributes\n dt: PyreonHTMLAttributes\n dd: PyreonHTMLAttributes\n // Forms\n form: FormAttributes\n label: LabelAttributes\n input: InputAttributes\n button: ButtonAttributes\n select: SelectAttributes\n datalist: PyreonHTMLAttributes\n optgroup: PyreonHTMLAttributes\n option: OptionAttributes\n textarea: TextareaAttributes\n output: PyreonHTMLAttributes\n progress: ProgressAttributes\n meter: MeterAttributes\n fieldset: PyreonHTMLAttributes\n legend: PyreonHTMLAttributes\n // Tables\n table: PyreonHTMLAttributes\n caption: PyreonHTMLAttributes\n colgroup: PyreonHTMLAttributes\n col: ColAttributes\n thead: PyreonHTMLAttributes\n tbody: PyreonHTMLAttributes\n tfoot: PyreonHTMLAttributes\n tr: PyreonHTMLAttributes\n th: ThAttributes\n td: TdAttributes\n // Media\n img: ImgAttributes\n video: VideoAttributes\n audio: AudioAttributes\n source: SourceAttributes\n track: PyreonHTMLAttributes\n picture: PyreonHTMLAttributes\n canvas: PyreonHTMLAttributes\n svg: SvgAttributes\n path: SvgAttributes\n circle: SvgAttributes\n ellipse: SvgAttributes\n line: SvgAttributes\n polyline: SvgAttributes\n polygon: SvgAttributes\n rect: SvgAttributes\n text: SvgAttributes\n tspan: SvgAttributes\n g: SvgAttributes\n defs: SvgAttributes\n use: SvgAttributes & { href?: string }\n symbol: SvgAttributes\n clipPath: SvgAttributes\n mask: SvgAttributes\n marker: SvgAttributes\n pattern: SvgAttributes\n linearGradient: SvgAttributes\n radialGradient: SvgAttributes\n stop: SvgAttributes & {\n offset?: string | number\n \"stop-color\"?: string\n \"stop-opacity\"?: string | number\n }\n // Interactive / embedding\n details: DetailsAttributes\n summary: PyreonHTMLAttributes\n dialog: DialogAttributes\n iframe: IframeAttributes\n embed: PyreonHTMLAttributes\n object: PyreonHTMLAttributes\n param: PyreonHTMLAttributes\n // Semantic / misc\n menu: PyreonHTMLAttributes\n menuitem: PyreonHTMLAttributes\n template: PyreonHTMLAttributes\n slot: PyreonHTMLAttributes\n portal: PyreonHTMLAttributes\n // Catch-all for custom elements and data-* attrs\n [tagName: string]: PyreonHTMLAttributes\n }\n }\n}\n"],"mappings":";;AAGA,MAAa,WAA0B,OAAO,kBAAkB;;;;;;;;;AAUhE,MAAa,cAAqB,EAAE;AAmBpC,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACC;EACN,OAAQ,SAAS;EACjB,UAAU,kBAAkB,SAAS;EACrC,KAAM,OAAO,OAAkC;EAChD;;AAGH,SAAS,kBAAkB,UAAsC;AAE/D,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACnC,KAAI,MAAM,QAAQ,SAAS,GAAG,CAC5B,QAAO,gBAAgB,SAAS;AAGpC,QAAO;;AAGT,SAAS,gBAAgB,UAAsC;CAC7D,MAAM,SAAuB,EAAE;AAC/B,MAAK,MAAM,SAAS,SAClB,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,KAAK,GAAG,gBAAgB,MAAsB,CAAC;KAEtD,QAAO,KAAK,MAAM;AAGtB,QAAO;;;;;;;;;;;;ACpDT,SAAgB,IACd,MACA,OACA,KACO;CACP,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAgB,OAAO,OAAO;EAAE,GAAG;EAAM;EAAK,GAAG;AAEvD,KAAI,OAAO,SAAS,WAIlB,QAAO,EAAE,MADc,aAAa,SAAY;EAAE,GAAG;EAAc;EAAU,GAAG,aAClD;AAKhC,QAAO,EAAE,MAAM,cAAc,GADV,aAAa,SAAY,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CACnC;;AAI/D,MAAa,OAAO"}
|
package/lib/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/h.ts","../src/jsx-runtime.ts"],"sourcesContent":["import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNode | null) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","/**\n * JSX automatic runtime.\n *\n * When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n * rewrites JSX to imports from this file automatically:\n * <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n */\nimport { Fragment, h } from \"./h\"\nimport type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\nexport { Fragment }\n\nexport function jsx(\n type: string | ComponentFn | symbol,\n props: Props & { children?: VNodeChild | VNodeChild[] },\n key?: string | number | null,\n): VNode {\n const { children, ...rest } = props\n const propsWithKey = (key != null ? { ...rest, key } : rest) as Props\n\n if (typeof type === \"function\") {\n // Component: keep children in props.children so the component function can access them.\n // Children must NOT be spread as h() rest args because mountComponent only passes vnode.props.\n const componentProps = children !== undefined ? { ...propsWithKey, children } : propsWithKey\n return h(type, componentProps)\n }\n\n // DOM element or symbol (Fragment, ForSymbol): children go in vnode.children\n const childArray = children === undefined ? [] : Array.isArray(children) ? children : [children]\n return h(type, propsWithKey, ...(childArray as VNodeChild[]))\n}\n\n// jsxs is called when there are multiple static children — same signature\nexport const jsxs = jsx\n\n// ─── JSX types ────────────────────────────────────────────────────────────────\n\ntype Booleanish = boolean | \"true\" | \"false\"\ntype CSSProperties = { [K in keyof CSSStyleDeclaration]?: string | number }\ntype StyleValue = string | CSSProperties\n\n/** Common HTML attributes accepted by all Pyreon elements */\ninterface PyreonHTMLAttributes {\n // Identity\n id?: string\n class?: string | (() => string)\n className?: string | (() => string)\n style?: StyleValue | (() => StyleValue)\n // pyreon-specific directives\n \"n-show\"?: boolean | (() => boolean)\n // Accessible\n role?: string\n tabIndex?: number | (() => number)\n title?: string\n lang?: string\n dir?: \"ltr\" | \"rtl\" | \"auto\"\n hidden?: boolean | (() => boolean)\n draggable?: Booleanish\n // ARIA\n \"aria-label\"?: string | (() => string)\n \"aria-hidden\"?: Booleanish | (() => Booleanish)\n \"aria-disabled\"?: Booleanish | (() => Booleanish)\n \"aria-expanded\"?: Booleanish | (() => Booleanish)\n \"aria-selected\"?: Booleanish | (() => Booleanish)\n \"aria-checked\"?: Booleanish | \"mixed\" | (() => Booleanish | \"mixed\")\n \"aria-current\"?: Booleanish | \"page\" | \"step\" | \"location\" | \"date\" | \"time\"\n \"aria-live\"?: \"off\" | \"assertive\" | \"polite\"\n \"aria-atomic\"?: Booleanish\n \"aria-busy\"?: Booleanish\n \"aria-controls\"?: string\n \"aria-describedby\"?: string\n \"aria-labelledby\"?: string\n \"aria-placeholder\"?: string\n \"aria-required\"?: Booleanish | (() => Booleanish)\n \"aria-invalid\"?: Booleanish | \"grammar\" | \"spelling\"\n \"aria-valuemin\"?: number\n \"aria-valuemax\"?: number\n \"aria-valuenow\"?: number\n \"aria-valuetext\"?: string\n \"aria-haspopup\"?: Booleanish | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\"\n \"aria-posinset\"?: number\n \"aria-setsize\"?: number\n \"aria-level\"?: number\n \"aria-multiline\"?: Booleanish\n \"aria-multiselectable\"?: Booleanish\n \"aria-orientation\"?: \"horizontal\" | \"vertical\"\n \"aria-readonly\"?: Booleanish | (() => Booleanish)\n \"aria-sort\"?: \"none\" | \"ascending\" | \"descending\" | \"other\"\n \"aria-autocomplete\"?: \"none\" | \"inline\" | \"list\" | \"both\"\n \"aria-colcount\"?: number\n \"aria-colindex\"?: number\n \"aria-colspan\"?: number\n \"aria-rowcount\"?: number\n \"aria-rowindex\"?: number\n \"aria-rowspan\"?: number\n // DOM lifecycle ref — object ref or callback ref\n ref?: { current: unknown } | ((el: Element | null) => void)\n // Key for list reconciliation\n key?: string | number\n // Children — allows null, undefined, boolean in JSX children positions\n children?: VNodeChild | VNodeChild[]\n // innerHTML\n innerHTML?: string\n dangerouslySetInnerHTML?: { __html: string }\n // Events\n onClick?: (e: MouseEvent) => void\n onDblClick?: (e: MouseEvent) => void\n onMouseDown?: (e: MouseEvent) => void\n onMouseUp?: (e: MouseEvent) => void\n onMouseEnter?: (e: MouseEvent) => void\n onMouseLeave?: (e: MouseEvent) => void\n onMouseMove?: (e: MouseEvent) => void\n onMouseOver?: (e: MouseEvent) => void\n onMouseOut?: (e: MouseEvent) => void\n onContextMenu?: (e: MouseEvent) => void\n onKeyDown?: (e: KeyboardEvent) => void\n onKeyUp?: (e: KeyboardEvent) => void\n onKeyPress?: (e: KeyboardEvent) => void\n onFocus?: (e: FocusEvent) => void\n onBlur?: (e: FocusEvent) => void\n onChange?: (e: Event) => void\n onInput?: (e: InputEvent) => void\n onSubmit?: (e: SubmitEvent) => void\n onReset?: (e: Event) => void\n onScroll?: (e: Event) => void\n onWheel?: (e: WheelEvent) => void\n onDragStart?: (e: DragEvent) => void\n onDragEnd?: (e: DragEvent) => void\n onDragOver?: (e: DragEvent) => void\n onDragEnter?: (e: DragEvent) => void\n onDragLeave?: (e: DragEvent) => void\n onDrop?: (e: DragEvent) => void\n onTouchStart?: (e: TouchEvent) => void\n onTouchEnd?: (e: TouchEvent) => void\n onTouchMove?: (e: TouchEvent) => void\n onPointerDown?: (e: PointerEvent) => void\n onPointerUp?: (e: PointerEvent) => void\n onPointerMove?: (e: PointerEvent) => void\n onPointerEnter?: (e: PointerEvent) => void\n onPointerLeave?: (e: PointerEvent) => void\n onPointerCancel?: (e: PointerEvent) => void\n onPointerOver?: (e: PointerEvent) => void\n onPointerOut?: (e: PointerEvent) => void\n onTransitionEnd?: (e: TransitionEvent) => void\n onAnimationStart?: (e: AnimationEvent) => void\n onAnimationEnd?: (e: AnimationEvent) => void\n onAnimationIteration?: (e: AnimationEvent) => void\n onLoad?: (e: Event) => void\n onError?: (e: Event | string) => void\n onAbort?: (e: Event) => void\n onSelect?: (e: Event) => void\n onCopy?: (e: ClipboardEvent) => void\n onCut?: (e: ClipboardEvent) => void\n onPaste?: (e: ClipboardEvent) => void\n // Catch-all for data-* and other arbitrary attributes\n [key: string]: unknown\n}\n\n/** Attributes specific to form inputs */\ninterface InputAttributes extends PyreonHTMLAttributes {\n type?: string | (() => string)\n value?: string | number | (() => string | number)\n defaultValue?: string | number\n checked?: boolean | (() => boolean)\n defaultChecked?: boolean\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n min?: string | number\n max?: string | number\n step?: string | number\n minLength?: number\n maxLength?: number\n pattern?: string\n multiple?: boolean\n name?: string\n accept?: string\n autoComplete?: string\n autoFocus?: boolean\n form?: string\n list?: string\n size?: number\n src?: string | (() => string)\n alt?: string\n width?: number | string\n height?: number | string\n}\n\ninterface AnchorAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\" | string\n rel?: string\n download?: string | boolean\n}\n\ninterface ButtonAttributes extends PyreonHTMLAttributes {\n type?: \"button\" | \"submit\" | \"reset\"\n disabled?: boolean | (() => boolean)\n name?: string\n value?: string\n form?: string\n formAction?: string\n formMethod?: string\n formEncType?: string\n formNoValidate?: boolean\n formTarget?: string\n}\n\ninterface TextareaAttributes extends PyreonHTMLAttributes {\n value?: string | (() => string)\n defaultValue?: string\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n rows?: number\n cols?: number\n minLength?: number\n maxLength?: number\n name?: string\n autoFocus?: boolean\n form?: string\n wrap?: \"hard\" | \"soft\"\n}\n\ninterface SelectAttributes extends PyreonHTMLAttributes {\n value?: string | string[] | (() => string | string[])\n defaultValue?: string | string[]\n disabled?: boolean | (() => boolean)\n required?: boolean | (() => boolean)\n multiple?: boolean\n name?: string\n size?: number\n form?: string\n autoFocus?: boolean\n}\n\ninterface OptionAttributes extends PyreonHTMLAttributes {\n value?: string | number | (() => string | number)\n disabled?: boolean | (() => boolean)\n selected?: boolean | (() => boolean)\n label?: string\n}\n\ninterface FormAttributes extends PyreonHTMLAttributes {\n action?: string\n method?: \"get\" | \"post\"\n encType?: string\n noValidate?: boolean\n target?: string\n name?: string\n autoComplete?: string\n}\n\ninterface ImgAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n alt?: string | (() => string)\n width?: number | string | (() => number | string)\n height?: number | string | (() => number | string)\n loading?: \"lazy\" | \"eager\"\n decoding?: \"auto\" | \"async\" | \"sync\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n referrerPolicy?: string\n srcSet?: string\n sizes?: string\n}\n\ninterface VideoAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n poster?: string\n preload?: \"none\" | \"metadata\" | \"auto\"\n playsInline?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface AudioAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n preload?: \"none\" | \"metadata\" | \"auto\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface LabelAttributes extends PyreonHTMLAttributes {\n htmlFor?: string\n for?: string\n form?: string\n}\n\ninterface ThAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\"\n abbr?: string\n headers?: string\n}\n\ninterface TdAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n headers?: string\n}\n\ninterface ColAttributes extends PyreonHTMLAttributes {\n span?: number\n}\n\ninterface IframeAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n allow?: string\n allowFullScreen?: boolean\n loading?: \"lazy\" | \"eager\"\n name?: string\n sandbox?: string\n referrerPolicy?: string\n title?: string\n}\n\ninterface LinkAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n rel?: string\n type?: string\n as?: string\n media?: string\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n referrerPolicy?: string\n}\n\ninterface MetaAttributes extends PyreonHTMLAttributes {\n name?: string\n content?: string | (() => string)\n httpEquiv?: string\n charset?: string\n property?: string\n}\n\ninterface ScriptAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n async?: boolean\n defer?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n noModule?: boolean\n referrerPolicy?: string\n}\n\ninterface SourceAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n srcSet?: string\n sizes?: string\n media?: string\n}\n\ninterface ProgressAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n max?: number\n}\n\ninterface MeterAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n min?: number\n max?: number\n low?: number\n high?: number\n optimum?: number\n}\n\ninterface DetailsAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface DialogAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface OlAttributes extends PyreonHTMLAttributes {\n start?: number\n reversed?: boolean\n type?: \"1\" | \"a\" | \"A\" | \"i\" | \"I\"\n}\n\ninterface SvgAttributes extends PyreonHTMLAttributes {\n viewBox?: string\n xmlns?: string\n fill?: string | (() => string)\n stroke?: string | (() => string)\n \"stroke-width\"?: string | number\n \"stroke-linecap\"?: \"butt\" | \"round\" | \"square\"\n \"stroke-linejoin\"?: \"miter\" | \"round\" | \"bevel\"\n \"fill-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-path\"?: string\n d?: string\n cx?: string | number\n cy?: string | number\n r?: string | number\n rx?: string | number\n ry?: string | number\n x?: string | number\n y?: string | number\n x1?: string | number\n y1?: string | number\n x2?: string | number\n y2?: string | number\n width?: string | number\n height?: string | number\n transform?: string | (() => string)\n opacity?: string | number | (() => string | number)\n points?: string\n \"font-size\"?: string | number\n \"text-anchor\"?: \"start\" | \"middle\" | \"end\"\n \"dominant-baseline\"?: string\n}\n\ndeclare global {\n namespace JSX {\n /** The type that JSX expressions evaluate to */\n type Element = import(\"./types\").VNode\n\n /**\n * Valid JSX tag types — intrinsic strings + component functions.\n * Components may return VNode, null, strings, functions (reactive getters), etc.\n * (TS 5.1+ feature)\n */\n type ElementType = keyof IntrinsicElements | ((props: any) => import(\"./types\").VNodeChild)\n\n /** Tells TS which prop name carries children in component calls */\n interface ElementChildrenAttribute {\n // biome-ignore lint/complexity/noBannedTypes: JSX spec requires {} for ElementChildrenAttribute\n children: {}\n }\n\n interface IntrinsicElements {\n // Document structure\n html: PyreonHTMLAttributes\n head: PyreonHTMLAttributes\n body: PyreonHTMLAttributes\n title: PyreonHTMLAttributes\n base: PyreonHTMLAttributes\n meta: MetaAttributes\n link: LinkAttributes\n script: ScriptAttributes\n style: PyreonHTMLAttributes\n noscript: PyreonHTMLAttributes\n // Sections\n main: PyreonHTMLAttributes\n header: PyreonHTMLAttributes\n footer: PyreonHTMLAttributes\n nav: PyreonHTMLAttributes\n aside: PyreonHTMLAttributes\n section: PyreonHTMLAttributes\n article: PyreonHTMLAttributes\n address: PyreonHTMLAttributes\n h1: PyreonHTMLAttributes\n h2: PyreonHTMLAttributes\n h3: PyreonHTMLAttributes\n h4: PyreonHTMLAttributes\n h5: PyreonHTMLAttributes\n h6: PyreonHTMLAttributes\n hgroup: PyreonHTMLAttributes\n // Block text\n p: PyreonHTMLAttributes\n pre: PyreonHTMLAttributes\n blockquote: PyreonHTMLAttributes\n figure: PyreonHTMLAttributes\n figcaption: PyreonHTMLAttributes\n div: PyreonHTMLAttributes\n hr: PyreonHTMLAttributes\n // Inline text\n span: PyreonHTMLAttributes\n a: AnchorAttributes\n em: PyreonHTMLAttributes\n strong: PyreonHTMLAttributes\n small: PyreonHTMLAttributes\n s: PyreonHTMLAttributes\n cite: PyreonHTMLAttributes\n q: PyreonHTMLAttributes\n abbr: PyreonHTMLAttributes\n time: PyreonHTMLAttributes\n code: PyreonHTMLAttributes\n var: PyreonHTMLAttributes\n samp: PyreonHTMLAttributes\n kbd: PyreonHTMLAttributes\n mark: PyreonHTMLAttributes\n sub: PyreonHTMLAttributes\n sup: PyreonHTMLAttributes\n i: PyreonHTMLAttributes\n b: PyreonHTMLAttributes\n u: PyreonHTMLAttributes\n bdi: PyreonHTMLAttributes\n bdo: PyreonHTMLAttributes\n br: PyreonHTMLAttributes\n wbr: PyreonHTMLAttributes\n ruby: PyreonHTMLAttributes\n rt: PyreonHTMLAttributes\n rp: PyreonHTMLAttributes\n // Lists\n ul: PyreonHTMLAttributes\n ol: OlAttributes\n li: PyreonHTMLAttributes\n dl: PyreonHTMLAttributes\n dt: PyreonHTMLAttributes\n dd: PyreonHTMLAttributes\n // Forms\n form: FormAttributes\n label: LabelAttributes\n input: InputAttributes\n button: ButtonAttributes\n select: SelectAttributes\n datalist: PyreonHTMLAttributes\n optgroup: PyreonHTMLAttributes\n option: OptionAttributes\n textarea: TextareaAttributes\n output: PyreonHTMLAttributes\n progress: ProgressAttributes\n meter: MeterAttributes\n fieldset: PyreonHTMLAttributes\n legend: PyreonHTMLAttributes\n // Tables\n table: PyreonHTMLAttributes\n caption: PyreonHTMLAttributes\n colgroup: PyreonHTMLAttributes\n col: ColAttributes\n thead: PyreonHTMLAttributes\n tbody: PyreonHTMLAttributes\n tfoot: PyreonHTMLAttributes\n tr: PyreonHTMLAttributes\n th: ThAttributes\n td: TdAttributes\n // Media\n img: ImgAttributes\n video: VideoAttributes\n audio: AudioAttributes\n source: SourceAttributes\n track: PyreonHTMLAttributes\n picture: PyreonHTMLAttributes\n canvas: PyreonHTMLAttributes\n svg: SvgAttributes\n path: SvgAttributes\n circle: SvgAttributes\n ellipse: SvgAttributes\n line: SvgAttributes\n polyline: SvgAttributes\n polygon: SvgAttributes\n rect: SvgAttributes\n text: SvgAttributes\n tspan: SvgAttributes\n g: SvgAttributes\n defs: SvgAttributes\n use: SvgAttributes & { href?: string }\n symbol: SvgAttributes\n clipPath: SvgAttributes\n mask: SvgAttributes\n marker: SvgAttributes\n pattern: SvgAttributes\n linearGradient: SvgAttributes\n radialGradient: SvgAttributes\n stop: SvgAttributes & {\n offset?: string | number\n \"stop-color\"?: string\n \"stop-opacity\"?: string | number\n }\n // Interactive / embedding\n details: DetailsAttributes\n summary: PyreonHTMLAttributes\n dialog: DialogAttributes\n iframe: IframeAttributes\n embed: PyreonHTMLAttributes\n object: PyreonHTMLAttributes\n param: PyreonHTMLAttributes\n // Semantic / misc\n menu: PyreonHTMLAttributes\n menuitem: PyreonHTMLAttributes\n template: PyreonHTMLAttributes\n slot: PyreonHTMLAttributes\n portal: PyreonHTMLAttributes\n // Catch-all for custom elements and data-* attrs\n [tagName: string]: PyreonHTMLAttributes\n }\n }\n}\n"],"mappings":";;AAGA,MAAa,WAA0B,OAAO,kBAAkB;;;;;;;;;AAUhE,MAAa,cAAqB,EAAE;AAmBpC,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACC;EACN,OAAQ,SAAS;EACjB,UAAU,kBAAkB,SAAS;EACrC,KAAM,OAAO,OAAkC;EAChD;;AAGH,SAAS,kBAAkB,UAAsC;AAE/D,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACnC,KAAI,MAAM,QAAQ,SAAS,GAAG,CAC5B,QAAO,gBAAgB,SAAS;AAGpC,QAAO;;AAGT,SAAS,gBAAgB,UAAsC;CAC7D,MAAM,SAAuB,EAAE;AAC/B,MAAK,MAAM,SAAS,SAClB,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,KAAK,GAAG,gBAAgB,MAAsB,CAAC;KAEtD,QAAO,KAAK,MAAM;AAGtB,QAAO;;;;;;;;;;;;ACpDT,SAAgB,IACd,MACA,OACA,KACO;CACP,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAgB,OAAO,OAAO;EAAE,GAAG;EAAM;EAAK,GAAG;AAEvD,KAAI,OAAO,SAAS,WAIlB,QAAO,EAAE,MADc,aAAa,SAAY;EAAE,GAAG;EAAc;EAAU,GAAG,aAClD;AAKhC,QAAO,EAAE,MAAM,cAAc,GADV,aAAa,SAAY,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CACnC;;AAI/D,MAAa,OAAO"}
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/h.ts","../src/jsx-runtime.ts"],"sourcesContent":["import type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\n/** Marker for fragment nodes — renders children without a wrapper element */\nexport const Fragment: unique symbol = Symbol(\"Pyreon.Fragment\")\n\n/**\n * Hyperscript function — the compiled output of JSX.\n * `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n *\n * Generic on P so TypeScript validates props match the component's signature\n * at the call site, then stores the result in the loosely-typed VNode.\n */\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nexport const EMPTY_PROPS: Props = {} as Props\n\n/** Makes `children` optional in P (if present) so it can be passed as rest args to h(). */\ntype PropsWithOptionalChildren<P extends Props> = Omit<P, \"children\"> &\n (\"children\" extends keyof P ? { children?: P[\"children\"] } : unknown)\n\n// Overload: component with typed props — children is optional in the props object\n// because it can be passed as rest args. Extra keys are allowed via `& Props`.\nexport function h<P extends Props>(\n type: ComponentFn<P>,\n props: (PropsWithOptionalChildren<P> & Props) | null,\n ...children: VNodeChild[]\n): VNode\n// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union\nexport function h(\n type: string | ((p: any) => VNodeChild) | symbol,\n props: Props | null,\n ...children: VNodeChild[]\n): VNode\nexport function h<P extends Props>(\n type: string | ComponentFn<P> | symbol,\n props: P | null,\n ...children: VNodeChild[]\n): VNode {\n return {\n type: type as string | ComponentFn | symbol,\n props: (props ?? EMPTY_PROPS) as Props,\n children: normalizeChildren(children),\n key: (props?.key as string | number | null) ?? null,\n }\n}\n\nfunction normalizeChildren(children: VNodeChild[]): VNodeChild[] {\n // Fast path: no nested arrays — return as-is without allocating\n for (let i = 0; i < children.length; i++) {\n if (Array.isArray(children[i])) {\n return flattenChildren(children)\n }\n }\n return children\n}\n\nfunction flattenChildren(children: VNodeChild[]): VNodeChild[] {\n const result: VNodeChild[] = []\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...flattenChildren(child as VNodeChild[]))\n } else {\n result.push(child)\n }\n }\n return result\n}\n","/**\n * JSX automatic runtime.\n *\n * When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n * rewrites JSX to imports from this file automatically:\n * <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n */\nimport { Fragment, h } from \"./h\"\nimport type { ComponentFn, Props, VNode, VNodeChild } from \"./types\"\n\nexport { Fragment }\n\nexport function jsx(\n type: string | ComponentFn | symbol,\n props: Props & { children?: VNodeChild | VNodeChild[] },\n key?: string | number | null,\n): VNode {\n const { children, ...rest } = props\n const propsWithKey = (key != null ? { ...rest, key } : rest) as Props\n\n if (typeof type === \"function\") {\n // Component: keep children in props.children so the component function can access them.\n // Children must NOT be spread as h() rest args because mountComponent only passes vnode.props.\n const componentProps = children !== undefined ? { ...propsWithKey, children } : propsWithKey\n return h(type, componentProps)\n }\n\n // DOM element or symbol (Fragment, ForSymbol): children go in vnode.children\n const childArray = children === undefined ? [] : Array.isArray(children) ? children : [children]\n return h(type, propsWithKey, ...(childArray as VNodeChild[]))\n}\n\n// jsxs is called when there are multiple static children — same signature\nexport const jsxs = jsx\n\n// ─── JSX types ────────────────────────────────────────────────────────────────\n\ntype Booleanish = boolean | \"true\" | \"false\"\ntype CSSProperties = { [K in keyof CSSStyleDeclaration]?: string | number }\ntype StyleValue = string | CSSProperties\n\n/** Common HTML attributes accepted by all Pyreon elements */\ninterface PyreonHTMLAttributes {\n // Identity\n id?: string\n class?: string | (() => string)\n className?: string | (() => string)\n style?: StyleValue | (() => StyleValue)\n // pyreon-specific directives\n \"n-show\"?: boolean | (() => boolean)\n // Accessible\n role?: string\n tabIndex?: number | (() => number)\n title?: string\n lang?: string\n dir?: \"ltr\" | \"rtl\" | \"auto\"\n hidden?: boolean | (() => boolean)\n draggable?: Booleanish\n // ARIA\n \"aria-label\"?: string | (() => string)\n \"aria-hidden\"?: Booleanish | (() => Booleanish)\n \"aria-disabled\"?: Booleanish | (() => Booleanish)\n \"aria-expanded\"?: Booleanish | (() => Booleanish)\n \"aria-selected\"?: Booleanish | (() => Booleanish)\n \"aria-checked\"?: Booleanish | \"mixed\" | (() => Booleanish | \"mixed\")\n \"aria-current\"?: Booleanish | \"page\" | \"step\" | \"location\" | \"date\" | \"time\"\n \"aria-live\"?: \"off\" | \"assertive\" | \"polite\"\n \"aria-atomic\"?: Booleanish\n \"aria-busy\"?: Booleanish\n \"aria-controls\"?: string\n \"aria-describedby\"?: string\n \"aria-labelledby\"?: string\n \"aria-placeholder\"?: string\n \"aria-required\"?: Booleanish | (() => Booleanish)\n \"aria-invalid\"?: Booleanish | \"grammar\" | \"spelling\"\n \"aria-valuemin\"?: number\n \"aria-valuemax\"?: number\n \"aria-valuenow\"?: number\n \"aria-valuetext\"?: string\n \"aria-haspopup\"?: Booleanish | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\"\n \"aria-posinset\"?: number\n \"aria-setsize\"?: number\n \"aria-level\"?: number\n \"aria-multiline\"?: Booleanish\n \"aria-multiselectable\"?: Booleanish\n \"aria-orientation\"?: \"horizontal\" | \"vertical\"\n \"aria-readonly\"?: Booleanish | (() => Booleanish)\n \"aria-sort\"?: \"none\" | \"ascending\" | \"descending\" | \"other\"\n \"aria-autocomplete\"?: \"none\" | \"inline\" | \"list\" | \"both\"\n \"aria-colcount\"?: number\n \"aria-colindex\"?: number\n \"aria-colspan\"?: number\n \"aria-rowcount\"?: number\n \"aria-rowindex\"?: number\n \"aria-rowspan\"?: number\n // DOM lifecycle ref — object ref or callback ref\n ref?: { current: unknown } | ((el: Element | null) => void)\n // Key for list reconciliation\n key?: string | number\n // Children — allows null, undefined, boolean in JSX children positions\n children?: VNodeChild | VNodeChild[]\n // innerHTML\n innerHTML?: string\n dangerouslySetInnerHTML?: { __html: string }\n // Events\n onClick?: (e: MouseEvent) => void\n onDblClick?: (e: MouseEvent) => void\n onMouseDown?: (e: MouseEvent) => void\n onMouseUp?: (e: MouseEvent) => void\n onMouseEnter?: (e: MouseEvent) => void\n onMouseLeave?: (e: MouseEvent) => void\n onMouseMove?: (e: MouseEvent) => void\n onMouseOver?: (e: MouseEvent) => void\n onMouseOut?: (e: MouseEvent) => void\n onContextMenu?: (e: MouseEvent) => void\n onKeyDown?: (e: KeyboardEvent) => void\n onKeyUp?: (e: KeyboardEvent) => void\n onKeyPress?: (e: KeyboardEvent) => void\n onFocus?: (e: FocusEvent) => void\n onBlur?: (e: FocusEvent) => void\n onChange?: (e: Event) => void\n onInput?: (e: InputEvent) => void\n onSubmit?: (e: SubmitEvent) => void\n onReset?: (e: Event) => void\n onScroll?: (e: Event) => void\n onWheel?: (e: WheelEvent) => void\n onDragStart?: (e: DragEvent) => void\n onDragEnd?: (e: DragEvent) => void\n onDragOver?: (e: DragEvent) => void\n onDragEnter?: (e: DragEvent) => void\n onDragLeave?: (e: DragEvent) => void\n onDrop?: (e: DragEvent) => void\n onTouchStart?: (e: TouchEvent) => void\n onTouchEnd?: (e: TouchEvent) => void\n onTouchMove?: (e: TouchEvent) => void\n onPointerDown?: (e: PointerEvent) => void\n onPointerUp?: (e: PointerEvent) => void\n onPointerMove?: (e: PointerEvent) => void\n onPointerEnter?: (e: PointerEvent) => void\n onPointerLeave?: (e: PointerEvent) => void\n onPointerCancel?: (e: PointerEvent) => void\n onPointerOver?: (e: PointerEvent) => void\n onPointerOut?: (e: PointerEvent) => void\n onTransitionEnd?: (e: TransitionEvent) => void\n onAnimationStart?: (e: AnimationEvent) => void\n onAnimationEnd?: (e: AnimationEvent) => void\n onAnimationIteration?: (e: AnimationEvent) => void\n onLoad?: (e: Event) => void\n onError?: (e: Event | string) => void\n onAbort?: (e: Event) => void\n onSelect?: (e: Event) => void\n onCopy?: (e: ClipboardEvent) => void\n onCut?: (e: ClipboardEvent) => void\n onPaste?: (e: ClipboardEvent) => void\n // Catch-all for data-* and other arbitrary attributes\n [key: string]: unknown\n}\n\n/** Attributes specific to form inputs */\ninterface InputAttributes extends PyreonHTMLAttributes {\n type?: string | (() => string)\n value?: string | number | (() => string | number)\n defaultValue?: string | number\n checked?: boolean | (() => boolean)\n defaultChecked?: boolean\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n min?: string | number\n max?: string | number\n step?: string | number\n minLength?: number\n maxLength?: number\n pattern?: string\n multiple?: boolean\n name?: string\n accept?: string\n autoComplete?: string\n autoFocus?: boolean\n form?: string\n list?: string\n size?: number\n src?: string | (() => string)\n alt?: string\n width?: number | string\n height?: number | string\n}\n\ninterface AnchorAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\" | string\n rel?: string\n download?: string | boolean\n}\n\ninterface ButtonAttributes extends PyreonHTMLAttributes {\n type?: \"button\" | \"submit\" | \"reset\"\n disabled?: boolean | (() => boolean)\n name?: string\n value?: string\n form?: string\n formAction?: string\n formMethod?: string\n formEncType?: string\n formNoValidate?: boolean\n formTarget?: string\n}\n\ninterface TextareaAttributes extends PyreonHTMLAttributes {\n value?: string | (() => string)\n defaultValue?: string\n placeholder?: string | (() => string)\n disabled?: boolean | (() => boolean)\n readOnly?: boolean\n required?: boolean | (() => boolean)\n rows?: number\n cols?: number\n minLength?: number\n maxLength?: number\n name?: string\n autoFocus?: boolean\n form?: string\n wrap?: \"hard\" | \"soft\"\n}\n\ninterface SelectAttributes extends PyreonHTMLAttributes {\n value?: string | string[] | (() => string | string[])\n defaultValue?: string | string[]\n disabled?: boolean | (() => boolean)\n required?: boolean | (() => boolean)\n multiple?: boolean\n name?: string\n size?: number\n form?: string\n autoFocus?: boolean\n}\n\ninterface OptionAttributes extends PyreonHTMLAttributes {\n value?: string | number | (() => string | number)\n disabled?: boolean | (() => boolean)\n selected?: boolean | (() => boolean)\n label?: string\n}\n\ninterface FormAttributes extends PyreonHTMLAttributes {\n action?: string\n method?: \"get\" | \"post\"\n encType?: string\n noValidate?: boolean\n target?: string\n name?: string\n autoComplete?: string\n}\n\ninterface ImgAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n alt?: string | (() => string)\n width?: number | string | (() => number | string)\n height?: number | string | (() => number | string)\n loading?: \"lazy\" | \"eager\"\n decoding?: \"auto\" | \"async\" | \"sync\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n referrerPolicy?: string\n srcSet?: string\n sizes?: string\n}\n\ninterface VideoAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n poster?: string\n preload?: \"none\" | \"metadata\" | \"auto\"\n playsInline?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface AudioAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n controls?: boolean\n autoPlay?: boolean\n muted?: boolean\n loop?: boolean\n preload?: \"none\" | \"metadata\" | \"auto\"\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n}\n\ninterface LabelAttributes extends PyreonHTMLAttributes {\n htmlFor?: string\n for?: string\n form?: string\n}\n\ninterface ThAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\"\n abbr?: string\n headers?: string\n}\n\ninterface TdAttributes extends PyreonHTMLAttributes {\n colSpan?: number\n rowSpan?: number\n headers?: string\n}\n\ninterface ColAttributes extends PyreonHTMLAttributes {\n span?: number\n}\n\ninterface IframeAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n width?: number | string\n height?: number | string\n allow?: string\n allowFullScreen?: boolean\n loading?: \"lazy\" | \"eager\"\n name?: string\n sandbox?: string\n referrerPolicy?: string\n title?: string\n}\n\ninterface LinkAttributes extends PyreonHTMLAttributes {\n href?: string | (() => string)\n rel?: string\n type?: string\n as?: string\n media?: string\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n referrerPolicy?: string\n}\n\ninterface MetaAttributes extends PyreonHTMLAttributes {\n name?: string\n content?: string | (() => string)\n httpEquiv?: string\n charset?: string\n property?: string\n}\n\ninterface ScriptAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n async?: boolean\n defer?: boolean\n crossOrigin?: \"anonymous\" | \"use-credentials\"\n integrity?: string\n noModule?: boolean\n referrerPolicy?: string\n}\n\ninterface SourceAttributes extends PyreonHTMLAttributes {\n src?: string | (() => string)\n type?: string\n srcSet?: string\n sizes?: string\n media?: string\n}\n\ninterface ProgressAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n max?: number\n}\n\ninterface MeterAttributes extends PyreonHTMLAttributes {\n value?: number | (() => number)\n min?: number\n max?: number\n low?: number\n high?: number\n optimum?: number\n}\n\ninterface DetailsAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface DialogAttributes extends PyreonHTMLAttributes {\n open?: boolean | (() => boolean)\n}\n\ninterface OlAttributes extends PyreonHTMLAttributes {\n start?: number\n reversed?: boolean\n type?: \"1\" | \"a\" | \"A\" | \"i\" | \"I\"\n}\n\ninterface SvgAttributes extends PyreonHTMLAttributes {\n viewBox?: string\n xmlns?: string\n fill?: string | (() => string)\n stroke?: string | (() => string)\n \"stroke-width\"?: string | number\n \"stroke-linecap\"?: \"butt\" | \"round\" | \"square\"\n \"stroke-linejoin\"?: \"miter\" | \"round\" | \"bevel\"\n \"fill-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-rule\"?: \"nonzero\" | \"evenodd\"\n \"clip-path\"?: string\n d?: string\n cx?: string | number\n cy?: string | number\n r?: string | number\n rx?: string | number\n ry?: string | number\n x?: string | number\n y?: string | number\n x1?: string | number\n y1?: string | number\n x2?: string | number\n y2?: string | number\n width?: string | number\n height?: string | number\n transform?: string | (() => string)\n opacity?: string | number | (() => string | number)\n points?: string\n \"font-size\"?: string | number\n \"text-anchor\"?: \"start\" | \"middle\" | \"end\"\n \"dominant-baseline\"?: string\n}\n\ndeclare global {\n namespace JSX {\n /** The type that JSX expressions evaluate to */\n type Element = import(\"./types\").VNode\n\n /**\n * Valid JSX tag types — intrinsic strings + component functions.\n * Components may return VNode, null, strings, functions (reactive getters), etc.\n * (TS 5.1+ feature)\n */\n type ElementType = keyof IntrinsicElements | ((props: any) => import(\"./types\").VNodeChild)\n\n /** Tells TS which prop name carries children in component calls */\n interface ElementChildrenAttribute {\n // biome-ignore lint/complexity/noBannedTypes: JSX spec requires {} for ElementChildrenAttribute\n children: {}\n }\n\n interface IntrinsicElements {\n // Document structure\n html: PyreonHTMLAttributes\n head: PyreonHTMLAttributes\n body: PyreonHTMLAttributes\n title: PyreonHTMLAttributes\n base: PyreonHTMLAttributes\n meta: MetaAttributes\n link: LinkAttributes\n script: ScriptAttributes\n style: PyreonHTMLAttributes\n noscript: PyreonHTMLAttributes\n // Sections\n main: PyreonHTMLAttributes\n header: PyreonHTMLAttributes\n footer: PyreonHTMLAttributes\n nav: PyreonHTMLAttributes\n aside: PyreonHTMLAttributes\n section: PyreonHTMLAttributes\n article: PyreonHTMLAttributes\n address: PyreonHTMLAttributes\n h1: PyreonHTMLAttributes\n h2: PyreonHTMLAttributes\n h3: PyreonHTMLAttributes\n h4: PyreonHTMLAttributes\n h5: PyreonHTMLAttributes\n h6: PyreonHTMLAttributes\n hgroup: PyreonHTMLAttributes\n // Block text\n p: PyreonHTMLAttributes\n pre: PyreonHTMLAttributes\n blockquote: PyreonHTMLAttributes\n figure: PyreonHTMLAttributes\n figcaption: PyreonHTMLAttributes\n div: PyreonHTMLAttributes\n hr: PyreonHTMLAttributes\n // Inline text\n span: PyreonHTMLAttributes\n a: AnchorAttributes\n em: PyreonHTMLAttributes\n strong: PyreonHTMLAttributes\n small: PyreonHTMLAttributes\n s: PyreonHTMLAttributes\n cite: PyreonHTMLAttributes\n q: PyreonHTMLAttributes\n abbr: PyreonHTMLAttributes\n time: PyreonHTMLAttributes\n code: PyreonHTMLAttributes\n var: PyreonHTMLAttributes\n samp: PyreonHTMLAttributes\n kbd: PyreonHTMLAttributes\n mark: PyreonHTMLAttributes\n sub: PyreonHTMLAttributes\n sup: PyreonHTMLAttributes\n i: PyreonHTMLAttributes\n b: PyreonHTMLAttributes\n u: PyreonHTMLAttributes\n bdi: PyreonHTMLAttributes\n bdo: PyreonHTMLAttributes\n br: PyreonHTMLAttributes\n wbr: PyreonHTMLAttributes\n ruby: PyreonHTMLAttributes\n rt: PyreonHTMLAttributes\n rp: PyreonHTMLAttributes\n // Lists\n ul: PyreonHTMLAttributes\n ol: OlAttributes\n li: PyreonHTMLAttributes\n dl: PyreonHTMLAttributes\n dt: PyreonHTMLAttributes\n dd: PyreonHTMLAttributes\n // Forms\n form: FormAttributes\n label: LabelAttributes\n input: InputAttributes\n button: ButtonAttributes\n select: SelectAttributes\n datalist: PyreonHTMLAttributes\n optgroup: PyreonHTMLAttributes\n option: OptionAttributes\n textarea: TextareaAttributes\n output: PyreonHTMLAttributes\n progress: ProgressAttributes\n meter: MeterAttributes\n fieldset: PyreonHTMLAttributes\n legend: PyreonHTMLAttributes\n // Tables\n table: PyreonHTMLAttributes\n caption: PyreonHTMLAttributes\n colgroup: PyreonHTMLAttributes\n col: ColAttributes\n thead: PyreonHTMLAttributes\n tbody: PyreonHTMLAttributes\n tfoot: PyreonHTMLAttributes\n tr: PyreonHTMLAttributes\n th: ThAttributes\n td: TdAttributes\n // Media\n img: ImgAttributes\n video: VideoAttributes\n audio: AudioAttributes\n source: SourceAttributes\n track: PyreonHTMLAttributes\n picture: PyreonHTMLAttributes\n canvas: PyreonHTMLAttributes\n svg: SvgAttributes\n path: SvgAttributes\n circle: SvgAttributes\n ellipse: SvgAttributes\n line: SvgAttributes\n polyline: SvgAttributes\n polygon: SvgAttributes\n rect: SvgAttributes\n text: SvgAttributes\n tspan: SvgAttributes\n g: SvgAttributes\n defs: SvgAttributes\n use: SvgAttributes & { href?: string }\n symbol: SvgAttributes\n clipPath: SvgAttributes\n mask: SvgAttributes\n marker: SvgAttributes\n pattern: SvgAttributes\n linearGradient: SvgAttributes\n radialGradient: SvgAttributes\n stop: SvgAttributes & {\n offset?: string | number\n \"stop-color\"?: string\n \"stop-opacity\"?: string | number\n }\n // Interactive / embedding\n details: DetailsAttributes\n summary: PyreonHTMLAttributes\n dialog: DialogAttributes\n iframe: IframeAttributes\n embed: PyreonHTMLAttributes\n object: PyreonHTMLAttributes\n param: PyreonHTMLAttributes\n // Semantic / misc\n menu: PyreonHTMLAttributes\n menuitem: PyreonHTMLAttributes\n template: PyreonHTMLAttributes\n slot: PyreonHTMLAttributes\n portal: PyreonHTMLAttributes\n // Catch-all for custom elements and data-* attrs\n [tagName: string]: PyreonHTMLAttributes\n }\n }\n}\n"],"mappings":";;AAGA,MAAa,WAA0B,OAAO,kBAAkB;;;;;;;;;AAUhE,MAAa,cAAqB,EAAE;AAmBpC,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACC;EACN,OAAQ,SAAS;EACjB,UAAU,kBAAkB,SAAS;EACrC,KAAM,OAAO,OAAkC;EAChD;;AAGH,SAAS,kBAAkB,UAAsC;AAE/D,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACnC,KAAI,MAAM,QAAQ,SAAS,GAAG,CAC5B,QAAO,gBAAgB,SAAS;AAGpC,QAAO;;AAGT,SAAS,gBAAgB,UAAsC;CAC7D,MAAM,SAAuB,EAAE;AAC/B,MAAK,MAAM,SAAS,SAClB,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,KAAK,GAAG,gBAAgB,MAAsB,CAAC;KAEtD,QAAO,KAAK,MAAM;AAGtB,QAAO;;;;;;;;;;;;ACpDT,SAAgB,IACd,MACA,OACA,KACO;CACP,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAgB,OAAO,OAAO;EAAE,GAAG;EAAM;EAAK,GAAG;AAEvD,KAAI,OAAO,SAAS,WAIlB,QAAO,EAAE,MADc,aAAa,SAAY;EAAE,GAAG;EAAc;EAAU,GAAG,aAClD;AAKhC,QAAO,EAAE,MAAM,cAAc,GADV,aAAa,SAAY,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CACnC;;AAI/D,MAAa,OAAO"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -11,9 +11,13 @@ interface VNode {
|
|
|
11
11
|
type Props = Record<string, unknown>;
|
|
12
12
|
/**
|
|
13
13
|
* A component is a plain function that runs ONCE.
|
|
14
|
-
* It returns
|
|
14
|
+
* It returns any renderable content and may call lifecycle hooks during setup.
|
|
15
15
|
*/
|
|
16
|
-
type ComponentFn<P extends Props = Props> = (props: P) =>
|
|
16
|
+
type ComponentFn<P extends Props = Props> = (props: P) => VNodeChild;
|
|
17
|
+
/** Extract the props type from a component function, or pass through if already a props type. */
|
|
18
|
+
type ExtractProps<T> = T extends ComponentFn<infer P> ? P : T;
|
|
19
|
+
/** A higher-order component that wraps a component, optionally transforming its props. */
|
|
20
|
+
type HigherOrderComponent<HOP extends Props, P extends Props | undefined = undefined> = (Component: ComponentFn<HOP>) => ComponentFn<P extends undefined ? HOP : P>;
|
|
17
21
|
/**
|
|
18
22
|
* Internal runtime handle created by the renderer for each mounted component.
|
|
19
23
|
*/
|
|
@@ -55,7 +59,7 @@ declare function defineComponent<P extends Props>(fn: ComponentFn<P>): Component
|
|
|
55
59
|
* Called by the renderer — not intended for user code.
|
|
56
60
|
*/
|
|
57
61
|
declare function runWithHooks<P extends Props>(fn: ComponentFn<P>, props: P): {
|
|
58
|
-
vnode:
|
|
62
|
+
vnode: VNodeChild;
|
|
59
63
|
hooks: LifecycleHooks;
|
|
60
64
|
};
|
|
61
65
|
/**
|
|
@@ -94,6 +98,18 @@ declare function popContext(): void;
|
|
|
94
98
|
* Falls back to `context.defaultValue` if none found.
|
|
95
99
|
*/
|
|
96
100
|
declare function useContext<T>(context: Context<T>): T;
|
|
101
|
+
/**
|
|
102
|
+
* Provide a context value for the current component's subtree.
|
|
103
|
+
* Must be called during component setup (like onMount/onUnmount).
|
|
104
|
+
* Automatically cleaned up when the component unmounts.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const ThemeProvider = ({ children }: { children: VNodeChild }) => {
|
|
108
|
+
* provide(ThemeContext, { color: "blue" })
|
|
109
|
+
* return children
|
|
110
|
+
* }
|
|
111
|
+
*/
|
|
112
|
+
declare function provide<T>(context: Context<T>, value: T): void;
|
|
97
113
|
/**
|
|
98
114
|
* Provide a value for `context` during `fn()`.
|
|
99
115
|
* Used by the renderer when it encounters a `<Provider>` component.
|
|
@@ -180,11 +196,11 @@ type PropsWithOptionalChildren<P extends Props> = Omit<P, "children"> & ("childr
|
|
|
180
196
|
children?: P["children"];
|
|
181
197
|
} : unknown);
|
|
182
198
|
declare function h<P extends Props>(type: ComponentFn<P>, props: (PropsWithOptionalChildren<P> & Props) | null, ...children: VNodeChild[]): VNode;
|
|
183
|
-
declare function h(type: string | ((p: any) =>
|
|
199
|
+
declare function h(type: string | ((p: any) => VNodeChild) | symbol, props: Props | null, ...children: VNodeChild[]): VNode;
|
|
184
200
|
//#endregion
|
|
185
201
|
//#region src/suspense.d.ts
|
|
186
202
|
/** Internal marker attached to lazy()-wrapped components */
|
|
187
|
-
type LazyComponent<P extends Props = Props> = ((props: P) =>
|
|
203
|
+
type LazyComponent<P extends Props = Props> = ((props: P) => VNodeChild) & {
|
|
188
204
|
__loading: () => boolean;
|
|
189
205
|
};
|
|
190
206
|
/**
|
|
@@ -389,5 +405,5 @@ declare function registerErrorHandler(handler: ErrorHandler): () => void;
|
|
|
389
405
|
*/
|
|
390
406
|
declare function reportError(ctx: ErrorContext): void;
|
|
391
407
|
//#endregion
|
|
392
|
-
export { CSS_UNITLESS, type CleanupFn, type ComponentFn, type ComponentInstance, type Context, Dynamic, type DynamicProps, EMPTY_PROPS, ErrorBoundary, type ErrorContext, type ErrorHandler, For, type ForProps, ForSymbol, Fragment, type LazyComponent, type LifecycleHooks, Match, type MatchProps, MatchSymbol, type NativeItem, Portal, type PortalProps, PortalSymbol, type Props, type Ref, Show, type ShowProps, Suspense, Switch, type SwitchProps, type VNode, type VNodeChild, type VNodeChildAtom, createContext, createRef, defineComponent, dispatchToErrorBoundary, h, lazy, mapArray, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, pushContext, registerErrorHandler, reportError, runWithHooks, setContextStackProvider, toKebabCase, useContext, withContext };
|
|
408
|
+
export { CSS_UNITLESS, type CleanupFn, type ComponentFn, type ComponentInstance, type Context, Dynamic, type DynamicProps, EMPTY_PROPS, ErrorBoundary, type ErrorContext, type ErrorHandler, type ExtractProps, For, type ForProps, ForSymbol, Fragment, type HigherOrderComponent, type LazyComponent, type LifecycleHooks, Match, type MatchProps, MatchSymbol, type NativeItem, Portal, type PortalProps, PortalSymbol, type Props, type Ref, Show, type ShowProps, Suspense, Switch, type SwitchProps, type VNode, type VNodeChild, type VNodeChildAtom, createContext, createRef, defineComponent, dispatchToErrorBoundary, h, lazy, mapArray, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, provide, pushContext, registerErrorHandler, reportError, runWithHooks, setContextStackProvider, toKebabCase, useContext, withContext };
|
|
393
409
|
//# sourceMappingURL=index2.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/component.ts","../../../src/context.ts","../../../src/dynamic.ts","../../../src/error-boundary.ts","../../../src/for.ts","../../../src/h.ts","../../../src/suspense.ts","../../../src/lazy.ts","../../../src/lifecycle.ts","../../../src/map-array.ts","../../../src/portal.ts","../../../src/ref.ts","../../../src/show.ts","../../../src/style.ts","../../../src/telemetry.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA,WAAe,WAAA;EACf,KAAA,EAAO,KAAA;EACP,QAAA,EAAU,UAAA;EACV,GAAA;AAAA;AAAA,KAKU,KAAA,GAAQ,MAAA;;AAVpB;;;KAkBY,WAAA,WAAsB,KAAA,GAAQ,KAAA,KAAU,KAAA,EAAO,CAAA,KAAM,KAAA;;;;
|
|
1
|
+
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/component.ts","../../../src/context.ts","../../../src/dynamic.ts","../../../src/error-boundary.ts","../../../src/for.ts","../../../src/h.ts","../../../src/suspense.ts","../../../src/lazy.ts","../../../src/lifecycle.ts","../../../src/map-array.ts","../../../src/portal.ts","../../../src/ref.ts","../../../src/show.ts","../../../src/style.ts","../../../src/telemetry.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA,WAAe,WAAA;EACf,KAAA,EAAO,KAAA;EACP,QAAA,EAAU,UAAA;EACV,GAAA;AAAA;AAAA,KAKU,KAAA,GAAQ,MAAA;;AAVpB;;;KAkBY,WAAA,WAAsB,KAAA,GAAQ,KAAA,KAAU,KAAA,EAAO,CAAA,KAAM,UAAA;;KAKrD,YAAA,MAAkB,CAAA,SAAU,WAAA,YAAuB,CAAA,GAAI,CAAA;;KAGvD,oBAAA,aAAiC,KAAA,YAAiB,KAAA,6BAC5D,SAAA,EAAW,WAAA,CAAY,GAAA,MACpB,WAAA,CAAY,CAAA,qBAAsB,GAAA,GAAM,CAAA;;;;UAK5B,iBAAA;EACf,KAAA,EAAO,KAAA;EA9BG;EAgCV,MAAA;EACA,OAAA;AAAA;AAAA,KAMU,SAAA;;;;;AAzBZ;UAkCiB,UAAA;EAAA,SACN,UAAA;EACT,EAAA,EAAI,WAAA;EACJ,OAAA;AAAA;AAAA,UAGe,cAAA;EAEf,KAAA,SAAc,SAAA;EACd,OAAA;EACA,MAAA;EA5CgC;EA8ChC,KAAA,IAAS,GAAA;AAAA;;;AAn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B,KAAA;EfZe;Eecf,SAAA;EfbO;EeeP,KAAA,GAAQ,MAAA;AAAA;AAAA,KAGE,YAAA,IAAgB,GAAA,EAAK,YAAA;;;AfXjC;;iBemBgB,oBAAA,CAAqB,OAAA,EAAS,YAAA;;;AfX9C;;iBesBgB,WAAA,CAAY,GAAA,EAAK,YAAA"}
|
|
@@ -11,9 +11,9 @@ interface VNode {
|
|
|
11
11
|
type Props = Record<string, unknown>;
|
|
12
12
|
/**
|
|
13
13
|
* A component is a plain function that runs ONCE.
|
|
14
|
-
* It returns
|
|
14
|
+
* It returns any renderable content and may call lifecycle hooks during setup.
|
|
15
15
|
*/
|
|
16
|
-
type ComponentFn<P extends Props = Props> = (props: P) =>
|
|
16
|
+
type ComponentFn<P extends Props = Props> = (props: P) => VNodeChild;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/h.d.ts
|
|
19
19
|
/** Marker for fragment nodes — renders children without a wrapper element */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/h.ts","../../../src/jsx-runtime.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA,WAAe,WAAA;EACf,KAAA,EAAO,KAAA;EACP,QAAA,EAAU,UAAA;EACV,GAAA;AAAA;AAAA,KAKU,KAAA,GAAQ,MAAA;;AAVpB;;;KAkBY,WAAA,WAAsB,KAAA,GAAQ,KAAA,KAAU,KAAA,EAAO,CAAA,KAAM,
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/h.ts","../../../src/jsx-runtime.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA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AkB,oBAAA;IAAA;EAAA;AAAA"}
|
|
@@ -11,9 +11,9 @@ interface VNode {
|
|
|
11
11
|
type Props = Record<string, unknown>;
|
|
12
12
|
/**
|
|
13
13
|
* A component is a plain function that runs ONCE.
|
|
14
|
-
* It returns
|
|
14
|
+
* It returns any renderable content and may call lifecycle hooks during setup.
|
|
15
15
|
*/
|
|
16
|
-
type ComponentFn<P extends Props = Props> = (props: P) =>
|
|
16
|
+
type ComponentFn<P extends Props = Props> = (props: P) => VNodeChild;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/h.d.ts
|
|
19
19
|
/** Marker for fragment nodes — renders children without a wrapper element */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/h.ts","../../../src/jsx-runtime.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA,WAAe,WAAA;EACf,KAAA,EAAO,KAAA;EACP,QAAA,EAAU,UAAA;EACV,GAAA;AAAA;AAAA,KAKU,KAAA,GAAQ,MAAA;;AAVpB;;;KAkBY,WAAA,WAAsB,KAAA,GAAQ,KAAA,KAAU,KAAA,EAAO,CAAA,KAAM,
|
|
1
|
+
{"version":3,"file":"jsx-runtime2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/h.ts","../../../src/jsx-runtime.ts"],"mappings":";KAGY,cAAA,GAAiB,KAAA,GAAQ,KAAA;AAAA,KACzB,UAAA,GAAa,cAAA,UAAwB,cAAA;AAAA,UAEhC,KAAA;;EAEf,IAAA,WAAe,WAAA;EACf,KAAA,EAAO,KAAA;EACP,QAAA,EAAU,UAAA;EACV,GAAA;AAAA;AAAA,KAKU,KAAA,GAAQ,MAAA;;AAVpB;;;KAkBY,WAAA,WAAsB,KAAA,GAAQ,KAAA,KAAU,KAAA,EAAO,CAAA,KAA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EAAI,YAAA;MAEJ,GAAA,EAAK,aAAA;MACL,KAAA,EAAO,eAAA;MACP,KAAA,EAAO,eAAA;MACP,MAAA,EAAQ,gBAAA;MACR,KAAA,EAAO,oBAAA;MACP,OAAA,EAAS,oBAAA;MACT,MAAA,EAAQ,oBAAA;MACR,GAAA,EAAK,aAAA;MACL,IAAA,EAAM,aAAA;MACN,MAAA,EAAQ,aAAA;MACR,OAAA,EAAS,aAAA;MACT,IAAA,EAAM,aAAA;MACN,QAAA,EAAU,aAAA;MACV,OAAA,EAAS,aAAA;MACT,IAAA,EAAM,aAAA;MACN,IAAA,EAAM,aAAA;MACN,KAAA,EAAO,aAAA;MACP,CAAA,EAAG,aAAA;MACH,IAAA,EAAM,aAAA;MACN,GAAA,EAAK,aAAA;QAAkB,IAAA;MAAA;MACvB,MAAA,EAAQ,aAAA;MACR,QAAA,EAAU,aAAA;MACV,IAAA,EAAM,aAAA;MACN,MAAA,EAAQ,aAAA;MACR,OAAA,EAAS,aAAA;MACT,cAAA,EAAgB,aAAA;MAChB,cAAA,EAAgB,aAAA;MAChB,IAAA,EAAM,aAAA;QACJ,MAAA;QACA,YAAA;QACA,cAAA;MAAA;MAGF,OAAA,EAAS,iBAAA;MACT,OAAA,EAAS,oBAAA;MACT,MAAA,EAAQ,gBAAA;MACR,MAAA,EAAQ,gBAAA;MACR,KAAA,EAAO,oBAAA;MACP,MAAA,EAAQ,oBAAA;MACR,KAAA,EAAO,oBAAA;MAEP,IAAA,EAAM,oBAAA;MACN,QAAA,EAAU,oBAAA;MACV,QAAA,EAAU,oBAAA;MACV,IAAA,EAAM,oBAAA;MACN,MAAA,EAAQ,oBAAA;MAAA,CAEP,OAAA,WAAkB,oBAAA;IAAA;EAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Core component model and lifecycle for Pyreon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"prepublishOnly": "bun run build"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@pyreon/reactivity": "^0.
|
|
52
|
+
"@pyreon/reactivity": "^0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/component.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setCurrentHooks } from "./lifecycle"
|
|
2
|
-
import type { ComponentFn, LifecycleHooks, Props,
|
|
2
|
+
import type { ComponentFn, LifecycleHooks, Props, VNodeChild } from "./types"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Identity wrapper — marks a function as a Pyreon component and preserves its type.
|
|
@@ -18,10 +18,10 @@ export function defineComponent<P extends Props>(fn: ComponentFn<P>): ComponentF
|
|
|
18
18
|
export function runWithHooks<P extends Props>(
|
|
19
19
|
fn: ComponentFn<P>,
|
|
20
20
|
props: P,
|
|
21
|
-
): { vnode:
|
|
21
|
+
): { vnode: VNodeChild; hooks: LifecycleHooks } {
|
|
22
22
|
const hooks: LifecycleHooks = { mount: [], unmount: [], update: [], error: [] }
|
|
23
23
|
setCurrentHooks(hooks)
|
|
24
|
-
let vnode:
|
|
24
|
+
let vnode: VNodeChild = null
|
|
25
25
|
try {
|
|
26
26
|
vnode = fn(props)
|
|
27
27
|
} finally {
|
package/src/context.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* The renderer maintains the context stack as it walks the VNode tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { onUnmount } from "./lifecycle"
|
|
9
|
+
|
|
8
10
|
export interface Context<T> {
|
|
9
11
|
readonly id: symbol
|
|
10
12
|
readonly defaultValue: T
|
|
@@ -68,6 +70,22 @@ export function useContext<T>(context: Context<T>): T {
|
|
|
68
70
|
return context.defaultValue
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Provide a context value for the current component's subtree.
|
|
75
|
+
* Must be called during component setup (like onMount/onUnmount).
|
|
76
|
+
* Automatically cleaned up when the component unmounts.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const ThemeProvider = ({ children }: { children: VNodeChild }) => {
|
|
80
|
+
* provide(ThemeContext, { color: "blue" })
|
|
81
|
+
* return children
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
export function provide<T>(context: Context<T>, value: T): void {
|
|
85
|
+
pushContext(new Map<symbol, unknown>([[context.id, value]]))
|
|
86
|
+
onUnmount(() => popContext())
|
|
87
|
+
}
|
|
88
|
+
|
|
71
89
|
/**
|
|
72
90
|
* Provide a value for `context` during `fn()`.
|
|
73
91
|
* Used by the renderer when it encounters a `<Provider>` component.
|
package/src/h.ts
CHANGED
|
@@ -26,7 +26,7 @@ export function h<P extends Props>(
|
|
|
26
26
|
): VNode
|
|
27
27
|
// Overload: intrinsic element, symbol, generic/dynamic component, or mixed union
|
|
28
28
|
export function h(
|
|
29
|
-
type: string | ((p: any) =>
|
|
29
|
+
type: string | ((p: any) => VNodeChild) | symbol,
|
|
30
30
|
props: Props | null,
|
|
31
31
|
...children: VNodeChild[]
|
|
32
32
|
): VNode
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { Context } from "./context"
|
|
|
5
5
|
export {
|
|
6
6
|
createContext,
|
|
7
7
|
popContext,
|
|
8
|
+
provide,
|
|
8
9
|
pushContext,
|
|
9
10
|
setContextStackProvider,
|
|
10
11
|
useContext,
|
|
@@ -34,6 +35,8 @@ export type {
|
|
|
34
35
|
CleanupFn,
|
|
35
36
|
ComponentFn,
|
|
36
37
|
ComponentInstance,
|
|
38
|
+
ExtractProps,
|
|
39
|
+
HigherOrderComponent,
|
|
37
40
|
LifecycleHooks,
|
|
38
41
|
NativeItem,
|
|
39
42
|
Props,
|
package/src/suspense.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Props, VNode, VNodeChild } from "./types"
|
|
|
4
4
|
const __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV !== "production"
|
|
5
5
|
|
|
6
6
|
/** Internal marker attached to lazy()-wrapped components */
|
|
7
|
-
export type LazyComponent<P extends Props = Props> = ((props: P) =>
|
|
7
|
+
export type LazyComponent<P extends Props = Props> = ((props: P) => VNodeChild) & {
|
|
8
8
|
__loading: () => boolean
|
|
9
9
|
}
|
|
10
10
|
|
package/src/tests/core.test.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
PortalSymbol,
|
|
22
22
|
popContext,
|
|
23
23
|
propagateError,
|
|
24
|
+
provide,
|
|
24
25
|
pushContext,
|
|
25
26
|
registerErrorHandler,
|
|
26
27
|
reportError,
|
|
@@ -336,6 +337,22 @@ describe("createContext / useContext", () => {
|
|
|
336
337
|
popContext()
|
|
337
338
|
expect(useContext(ctx)).toBe("default")
|
|
338
339
|
})
|
|
340
|
+
|
|
341
|
+
test("provide() pushes context and registers cleanup on unmount", () => {
|
|
342
|
+
const ctx = createContext("default")
|
|
343
|
+
const { hooks } = runWithHooks(
|
|
344
|
+
(() => {
|
|
345
|
+
provide(ctx, "provided")
|
|
346
|
+
return null
|
|
347
|
+
}) as ComponentFn,
|
|
348
|
+
{} as Props,
|
|
349
|
+
)
|
|
350
|
+
// Context is available after provide()
|
|
351
|
+
expect(useContext(ctx)).toBe("provided")
|
|
352
|
+
// Running unmount hooks should pop the context
|
|
353
|
+
for (const fn of hooks.unmount) fn()
|
|
354
|
+
expect(useContext(ctx)).toBe("default")
|
|
355
|
+
})
|
|
339
356
|
})
|
|
340
357
|
|
|
341
358
|
// ─── createRef ───────────────────────────────────────────────────────────────
|
package/src/types.ts
CHANGED
|
@@ -20,9 +20,19 @@ export type Props = Record<string, unknown>
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* A component is a plain function that runs ONCE.
|
|
23
|
-
* It returns
|
|
23
|
+
* It returns any renderable content and may call lifecycle hooks during setup.
|
|
24
24
|
*/
|
|
25
|
-
export type ComponentFn<P extends Props = Props> = (props: P) =>
|
|
25
|
+
export type ComponentFn<P extends Props = Props> = (props: P) => VNodeChild
|
|
26
|
+
|
|
27
|
+
// ─── Utility types ───────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
/** Extract the props type from a component function, or pass through if already a props type. */
|
|
30
|
+
export type ExtractProps<T> = T extends ComponentFn<infer P> ? P : T
|
|
31
|
+
|
|
32
|
+
/** A higher-order component that wraps a component, optionally transforming its props. */
|
|
33
|
+
export type HigherOrderComponent<HOP extends Props, P extends Props | undefined = undefined> = (
|
|
34
|
+
Component: ComponentFn<HOP>,
|
|
35
|
+
) => ComponentFn<P extends undefined ? HOP : P>
|
|
26
36
|
|
|
27
37
|
/**
|
|
28
38
|
* Internal runtime handle created by the renderer for each mounted component.
|