@pyreon/core 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Vit Bokisch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @pyreon/core
2
+
3
+ Core component model, VNode types, lifecycle hooks, and control-flow components for Pyreon.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @pyreon/core
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { h, Fragment, onMount, onUnmount, createContext, useContext } from "@pyreon/core"
15
+
16
+ function Counter() {
17
+ onMount(() => {
18
+ console.log("mounted")
19
+ return undefined
20
+ })
21
+
22
+ return h("div", null, "Hello Pyreon")
23
+ }
24
+ ```
25
+
26
+ ## API
27
+
28
+ ### VNode Creation
29
+
30
+ - **`h<P>(type, props, ...children): VNode`** -- Creates a virtual node. Accepts element tags, component functions, or Fragment.
31
+ - **`Fragment`** -- Groups children without adding a wrapper DOM element.
32
+ - **`EMPTY_PROPS`** -- Shared empty props object.
33
+
34
+ ### Components
35
+
36
+ - **`defineComponent(fn)`** -- Wraps a function as a named component.
37
+ - **`runWithHooks(instance, fn)`** -- Executes a function within a component's hook context.
38
+ - **`propagateError(error, instance)`** -- Propagates an error up the component tree.
39
+ - **`dispatchToErrorBoundary(error, instance)`** -- Sends an error to the nearest ErrorBoundary.
40
+
41
+ ### Lifecycle Hooks
42
+
43
+ - **`onMount(fn: () => CleanupFn | undefined)`** -- Runs after the component mounts. Return a cleanup function or `undefined`.
44
+ - **`onUnmount(fn)`** -- Runs when the component is removed.
45
+ - **`onUpdate(fn)`** -- Runs after each reactive update.
46
+ - **`onErrorCaptured(fn)`** -- Captures errors thrown by descendant components.
47
+
48
+ ### Context
49
+
50
+ - **`createContext<T>(defaultValue?): Context<T>`** -- Creates a context with an optional default.
51
+ - **`useContext(ctx): T`** -- Reads the nearest provided context value.
52
+ - **`withContext(ctx, value, fn)`** -- Runs `fn` with the given context value.
53
+ - **`pushContext(map)` / `popContext()`** -- Low-level context stack manipulation.
54
+
55
+ ### Refs
56
+
57
+ - **`createRef<T>(): Ref<T>`** -- Creates a mutable ref object.
58
+
59
+ ### Control-Flow Components
60
+
61
+ - **`Show`** -- Conditionally renders children based on a `when` prop.
62
+ - **`Switch` / `Match`** -- Multi-branch conditional rendering.
63
+ - **`For`** -- Keyed list rendering with efficient reconciliation.
64
+ - **`Portal`** -- Renders children into a different DOM container.
65
+ - **`Suspense`** -- Shows fallback content while async children resolve.
66
+ - **`ErrorBoundary`** -- Catches errors in descendant components and renders a fallback.
67
+
68
+ ### Utilities
69
+
70
+ - **`mapArray(source, mapFn)`** -- Reactively maps over an array source.
71
+ - **`registerErrorHandler(handler)` / `reportError(error, context)`** -- Global error telemetry.
72
+
73
+ ### Types
74
+
75
+ `VNode`, `VNodeChild`, `VNodeChildAtom`, `Props`, `ComponentFn`, `ComponentInstance`, `LifecycleHooks`, `CleanupFn`, `NativeItem`, `Ref`, `Context`, `LazyComponent`, `ShowProps`, `SwitchProps`, `MatchProps`, `ForProps`, `PortalProps`, `ErrorContext`, `ErrorHandler`
76
+
77
+ ## License
78
+
79
+ MIT