@pyreon/solid-compat 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.
@@ -1,257 +1,59 @@
1
- import { ErrorBoundary, For, Match, Show, Suspense, Switch, createContext as pyreonCreateContext, onMount as onMount$1, onUnmount, useContext as pyreonUseContext } from "@pyreon/core";
2
- import { batch as pyreonBatch, computed, createSelector as createSelector$1, effect, effectScope, getCurrentScope, runUntracked, setCurrentScope, signal } from "@pyreon/reactivity";
1
+ import { ComponentFn, ErrorBoundary, For, LazyComponent, Match, Props, Show, Suspense, Switch, VNodeChild, createContext as pyreonCreateContext, useContext as pyreonUseContext } from "@pyreon/core";
2
+ import { EffectScope, batch as pyreonBatch, runUntracked } from "@pyreon/reactivity";
3
3
 
4
- //#region src/jsx-runtime.ts
5
-
6
- function getCurrentCtx() {
7
- return _currentCtx;
8
- }
9
- function getHookIndex() {
10
- return _hookIndex++;
11
- }
12
- //#endregion
13
- //#region src/index.ts
14
- function createSignal(initialValue) {
15
- const ctx = getCurrentCtx();
16
- if (ctx) {
17
- const idx = getHookIndex();
18
- if (idx >= ctx.hooks.length) ctx.hooks[idx] = signal(initialValue);
19
- const s = ctx.hooks[idx];
20
- const {
21
- scheduleRerender
22
- } = ctx;
23
- const getter = () => s();
24
- const setter = v => {
25
- if (typeof v === "function") s.update(v);else s.set(v);
26
- scheduleRerender();
27
- };
28
- return [getter, setter];
29
- }
30
- const s = signal(initialValue);
31
- const getter = () => s();
32
- const setter = v => {
33
- if (typeof v === "function") s.update(v);else s.set(v);
34
- };
35
- return [getter, setter];
36
- }
4
+ //#region src/index.d.ts
5
+ type SignalGetter<T> = () => T;
6
+ type SignalSetter<T> = (v: T | ((prev: T) => T)) => void;
7
+ declare function createSignal<T>(initialValue: T): [SignalGetter<T>, SignalSetter<T>];
37
8
  /**
38
- * Solid-compatible `createEffect` — creates a reactive side effect.
39
- *
40
- * In component context: hook-indexed, only created on first render. The effect
41
- * uses Pyreon's native tracking so signal reads are automatically tracked.
42
- * A re-entrance guard prevents infinite loops from signal writes inside
43
- * the effect.
44
- */
45
- function createEffect(fn) {
46
- const ctx = getCurrentCtx();
47
- if (ctx) {
48
- const idx = getHookIndex();
49
- if (idx < ctx.hooks.length) return;
50
- let running = false;
51
- const e = effect(() => {
52
- if (running) return;
53
- running = true;
54
- try {
55
- fn();
56
- } finally {
57
- running = false;
58
- }
59
- });
60
- const stop = () => e.dispose();
61
- ctx.hooks[idx] = stop;
62
- ctx.unmountCallbacks.push(stop);
63
- return;
64
- }
65
- effect(fn);
66
- }
9
+ * Solid-compatible `createEffect` — creates a reactive side effect.
10
+ *
11
+ * In component context: hook-indexed, only created on first render. The effect
12
+ * uses Pyreon's native tracking so signal reads are automatically tracked.
13
+ * A re-entrance guard prevents infinite loops from signal writes inside
14
+ * the effect.
15
+ */
16
+ declare function createEffect(fn: () => void): void;
67
17
  /**
68
- * Solid-compatible `createRenderEffect` — same as createEffect.
69
- * In Solid, this runs during the render phase; here it runs as a Pyreon effect.
70
- */
71
- function createRenderEffect(fn) {
72
- createEffect(fn);
73
- }
18
+ * Solid-compatible `createRenderEffect` — same as createEffect.
19
+ * In Solid, this runs during the render phase; here it runs as a Pyreon effect.
20
+ */
21
+ declare function createRenderEffect(fn: () => void): void;
74
22
  /**
75
- * Solid-compatible `createMemo` — derives a value from reactive sources.
76
- *
77
- * In component context: hook-indexed, only created on first render.
78
- * Uses Pyreon's native computed for auto-tracking.
79
- */
80
- function createMemo(fn) {
81
- const ctx = getCurrentCtx();
82
- if (ctx) {
83
- const idx = getHookIndex();
84
- if (idx >= ctx.hooks.length) ctx.hooks[idx] = computed(fn);
85
- const c = ctx.hooks[idx];
86
- return () => c();
87
- }
88
- const c = computed(fn);
89
- return () => c();
90
- }
91
- function createRoot(fn) {
92
- const scope = effectScope();
93
- const prev = getCurrentScope();
94
- setCurrentScope(scope);
95
- try {
96
- return fn(() => scope.stop());
97
- } finally {
98
- setCurrentScope(prev);
99
- }
100
- }
101
- function on(deps, fn) {
102
- let prevInput;
103
- let prevValue;
104
- let initialized = false;
105
- return () => {
106
- const input = Array.isArray(deps) ? deps.map(d => d()) : deps();
107
- if (!initialized) {
108
- initialized = true;
109
- prevValue = fn(input, void 0, void 0);
110
- prevInput = input;
111
- return prevValue;
112
- }
113
- const result = runUntracked(() => fn(input, prevInput, prevValue));
114
- prevInput = input;
115
- prevValue = result;
116
- return result;
117
- };
118
- }
119
- function onMount(fn) {
120
- const ctx = getCurrentCtx();
121
- if (ctx) {
122
- const idx = getHookIndex();
123
- if (idx >= ctx.hooks.length) {
124
- ctx.hooks[idx] = true;
125
- ctx.pendingEffects.push({
126
- fn: () => {
127
- fn();
128
- },
129
- deps: void 0,
130
- cleanup: void 0
131
- });
132
- }
133
- return;
134
- }
135
- onMount$1(fn);
136
- }
23
+ * Solid-compatible `createMemo` — derives a value from reactive sources.
24
+ *
25
+ * In component context: hook-indexed, only created on first render.
26
+ * Uses Pyreon's native computed for auto-tracking.
27
+ */
28
+ declare function createMemo<T>(fn: () => T): () => T;
29
+ declare function createRoot<T>(fn: (dispose: () => void) => T): T;
30
+ type AccessorArray = readonly (() => unknown)[];
31
+ type OnEffectFunction<D, V> = (input: D, prevInput: D | undefined, prev: V | undefined) => V;
32
+ declare function on<S extends (() => unknown) | AccessorArray, V>(deps: S, fn: OnEffectFunction<S extends (() => infer R) ? R : S extends readonly (() => infer R)[] ? R[] : never, V>): () => V | undefined;
137
33
  /**
138
- * Solid-compatible `onCleanup` — registers a callback to run when the component unmounts.
139
- */
140
- function onCleanup(fn) {
141
- const ctx = getCurrentCtx();
142
- if (ctx) {
143
- const idx = getHookIndex();
144
- if (idx >= ctx.hooks.length) {
145
- ctx.hooks[idx] = true;
146
- ctx.unmountCallbacks.push(fn);
147
- }
148
- return;
149
- }
150
- onUnmount(fn);
151
- }
152
- function createSelector(source) {
153
- const ctx = getCurrentCtx();
154
- if (ctx) {
155
- const idx = getHookIndex();
156
- if (idx >= ctx.hooks.length) ctx.hooks[idx] = createSelector$1(source);
157
- return ctx.hooks[idx];
158
- }
159
- return createSelector$1(source);
160
- }
161
- function mergeProps(...sources) {
162
- const target = {};
163
- for (const source of sources) {
164
- const descriptors = Object.getOwnPropertyDescriptors(source);
165
- for (const key of Reflect.ownKeys(descriptors)) {
166
- const desc = descriptors[key];
167
- if (!desc) continue;
168
- if (desc.get) Object.defineProperty(target, key, {
169
- get: desc.get,
170
- enumerable: true,
171
- configurable: true
172
- });else Object.defineProperty(target, key, {
173
- value: desc.value,
174
- writable: true,
175
- enumerable: true,
176
- configurable: true
177
- });
178
- }
179
- }
180
- return target;
181
- }
182
- function splitProps(props, ...keys) {
183
- const picked = {};
184
- const rest = {};
185
- const keySet = new Set(keys.flat());
186
- const descriptors = Object.getOwnPropertyDescriptors(props);
187
- for (const key of Reflect.ownKeys(descriptors)) {
188
- const desc = descriptors[key];
189
- if (!desc) continue;
190
- const target = typeof key === "string" && keySet.has(key) ? picked : rest;
191
- if (desc.get) Object.defineProperty(target, key, {
192
- get: desc.get,
193
- enumerable: true,
194
- configurable: true
195
- });else Object.defineProperty(target, key, {
196
- value: desc.value,
197
- writable: true,
198
- enumerable: true,
199
- configurable: true
200
- });
201
- }
202
- return [picked, rest];
203
- }
204
- function children(fn) {
205
- return createMemo(() => {
206
- const result = fn();
207
- if (typeof result === "function") return result();
208
- return result;
209
- });
210
- }
211
- function lazy(loader) {
212
- const loaded = signal(null);
213
- const error = signal(null);
214
- let promise = null;
215
- const load = () => {
216
- if (!promise) promise = loader().then(mod => {
217
- loaded.set(mod.default);
218
- return mod;
219
- }).catch(err => {
220
- const e = err instanceof Error ? err : new Error(String(err));
221
- error.set(e);
222
- promise = null;
223
- throw e;
224
- });
225
- return promise;
226
- };
227
- const LazyComponent = props => {
228
- const err = error();
229
- if (err) throw err;
230
- const comp = loaded();
231
- if (!comp) return null;
232
- return comp(props);
233
- };
234
- LazyComponent.__loading = () => {
235
- const isLoading = loaded() === null && error() === null;
236
- if (isLoading) load();
237
- return isLoading;
238
- };
239
- LazyComponent.preload = load;
240
- return LazyComponent;
241
- }
242
- function getOwner() {
243
- return getCurrentScope();
244
- }
245
- function runWithOwner(owner, fn) {
246
- const prev = getCurrentScope();
247
- setCurrentScope(owner);
248
- try {
249
- return fn();
250
- } finally {
251
- setCurrentScope(prev);
252
- }
253
- }
254
-
34
+ * Solid-compatible `onMount` — runs once after the component's first render.
35
+ */
36
+ type CleanupFn = () => void;
37
+ declare function onMount(fn: () => CleanupFn | void | undefined): void;
38
+ /**
39
+ * Solid-compatible `onCleanup` — registers a callback to run when the component unmounts.
40
+ */
41
+ declare function onCleanup(fn: () => void): void;
42
+ declare function createSelector<T>(source: () => T): (key: T) => boolean;
43
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
44
+ type MergeProps<T extends object[]> = UnionToIntersection<T[number]>;
45
+ declare function mergeProps<T extends object[]>(...sources: [...T]): MergeProps<T>;
46
+ declare function splitProps<T extends Record<string, unknown>, K extends (keyof T)[]>(props: T, ...keys: K): [Pick<T, K[number]>, Omit<T, K[number]>];
47
+ declare function children(fn: () => VNodeChild): () => VNodeChild;
48
+ declare function lazy<P extends Props>(loader: () => Promise<{
49
+ default: ComponentFn<P>;
50
+ }>): LazyComponent<P> & {
51
+ preload: () => Promise<{
52
+ default: ComponentFn<P>;
53
+ }>;
54
+ };
55
+ declare function getOwner(): EffectScope | null;
56
+ declare function runWithOwner<T>(owner: EffectScope | null, fn: () => T): T;
255
57
  //#endregion
256
- export { ErrorBoundary, For, Match, Show, Suspense, Switch, pyreonBatch as batch, children, createEffect as createComputed, createEffect, pyreonCreateContext as createContext, createMemo, createRenderEffect, createRoot, createSelector, createSignal, getOwner, lazy, mergeProps, on, onCleanup, onMount, runWithOwner, splitProps, runUntracked as untrack, pyreonUseContext as useContext };
257
- //# sourceMappingURL=index.d.ts.map
58
+ export { ErrorBoundary, For, Match, Show, SignalGetter, SignalSetter, Suspense, Switch, pyreonBatch as batch, children, createEffect as createComputed, createEffect, pyreonCreateContext as createContext, createMemo, createRenderEffect, createRoot, createSelector, createSignal, getOwner, lazy, mergeProps, on, onCleanup, onMount, runWithOwner, splitProps, runUntracked as untrack, pyreonUseContext as useContext };
59
+ //# sourceMappingURL=index2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["pyreonSignal","pyreonEffect","pyreonComputed","pyreonCreateSelector"],"sources":["../../../src/jsx-runtime.ts","../../../src/index.ts"],"mappings":";;;;;AAqEA,SAAgB,aAAA,CAAA,EAAsC;EACpD,OAAO,WAAA;;AAGT,SAAgB,YAAA,CAAA,EAAuB;EACrC,OAAO,UAAA,EAAA;;;;AC3BT,SAAgB,YAAA,CAAgB,YAAA,EAAqD;EACnF,MAAM,GAAA,GAAM,aAAA,CAAA,CAAe;EAC3B,IAAI,GAAA,EAAK;IACP,MAAM,GAAA,GAAM,YAAA,CAAA,CAAc;IAC1B,IAAI,GAAA,IAAO,GAAA,CAAI,KAAA,CAAM,MAAA,EACnB,GAAA,CAAI,KAAA,CAAM,GAAA,CAAA,GAAOA,MAAAA,CAAgB,YAAA,CAAa;IAEhD,MAAM,CAAA,GAAI,GAAA,CAAI,KAAA,CAAM,GAAA,CAAA;IACpB,MAAM;MAAE;IAAA,CAAA,GAAqB,GAAA;IAE7B,MAAM,MAAA,GAAA,CAAA,KAAgC,CAAA,CAAA,CAAG;IACzC,MAAM,MAAA,GAA2B,CAAA,IAAM;MACrC,IAAI,OAAO,CAAA,KAAM,UAAA,EACf,CAAA,CAAE,MAAA,CAAO,CAAA,CAAoB,CAAA,KAE7B,CAAA,CAAE,GAAA,CAAI,CAAA,CAAE;MAEV,gBAAA,CAAA,CAAkB;;IAEpB,OAAO,CAAC,MAAA,EAAQ,MAAA,CAAO;;EAIzB,MAAM,CAAA,GAAIA,MAAAA,CAAgB,YAAA,CAAa;EACvC,MAAM,MAAA,GAAA,CAAA,KAAgC,CAAA,CAAA,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AA,IAAA,CAC7C,IAAA,EAAM,CAAA,EACN,EAAA,EAAI,gBAAA,CACF,CAAA,2BAA0B,CAAA,GAAI,CAAA,sCAAuC,CAAA,YACrE,CAAA,UAEK,CAAA;;AAxDT;;KAgGK,SAAA;AAAA,iBAEW,OAAA,CAAQ,EAAA,QAAU,SAAA;;AAlFlC;;iBA2GgB,SAAA,CAAU,EAAA;AAAA,iBAiBV,cAAA,GAAA,CAAkB,MAAA,QAAc,CAAA,IAAK,GAAA,EAAK,CAAA;AAAA,KAerD,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAA,6BACrD,CAAA,sBAEE,CAAA;AAAA,KAGC,UAAA,uBAAiC,mBAAA,CAAoB,CAAA;AAAA,iBAE1C,UAAA,oBAAA,CAAA,GAAkC,OAAA,MAAa,CAAA,IAAK,UAAA,CAAW,CAAA;AAAA,iBA6B/D,UAAA,WAAqB,MAAA,oCAA0C,CAAA,IAAA,CAC7E,KAAA,EAAO,CAAA,KACJ,IAAA,EAAM,CAAA,IACP,IAAA,CAAK,CAAA,EAAG,CAAA,WAAY,IAAA,CAAK,CAAA,EAAG,CAAA;AAAA,iBA+BhB,QAAA,CAAS,EAAA,QAAU,UAAA,SAAmB,UAAA;AAAA,iBAYtC,IAAA,WAAe,KAAA,CAAA,CAC7B,MAAA,QAAc,OAAA;EAAU,OAAA,EAAS,WAAA,CAAY,CAAA;AAAA,KAC5C,aAAA,CAAc,CAAA;EAAO,OAAA,QAAe,OAAA;IAAU,OAAA,EAAS,WAAA,CAAY,CAAA;EAAA;AAAA;AAAA,iBAiDtD,QAAA,CAAA,GAAY,WAAA;AAAA,iBAIZ,YAAA,GAAA,CAAgB,KAAA,EAAO,WAAA,SAAoB,EAAA,QAAU,CAAA,GAAI,CAAA"}
@@ -1,142 +1,10 @@
1
- import { ErrorBoundary, For, Fragment, Match, Show, Suspense, Switch, h, onUnmount } from "@pyreon/core";
2
- import { runUntracked, signal } from "@pyreon/reactivity";
1
+ import { ComponentFn, Fragment, Props, VNode, VNodeChild } from "@pyreon/core";
3
2
 
4
- //#region src/jsx-runtime.ts
5
-
6
- function beginRender(ctx) {
7
- _currentCtx = ctx;
8
- _hookIndex = 0;
9
- ctx.pendingEffects = [];
10
- ctx.pendingLayoutEffects = [];
11
- }
12
- function endRender() {
13
- _currentCtx = null;
14
- _hookIndex = 0;
15
- }
16
- function runLayoutEffects(entries) {
17
- for (const entry of entries) {
18
- if (entry.cleanup) entry.cleanup();
19
- const cleanup = entry.fn();
20
- entry.cleanup = typeof cleanup === "function" ? cleanup : void 0;
21
- }
22
- }
23
- function scheduleEffects(ctx, entries) {
24
- if (entries.length === 0) return;
25
- queueMicrotask(() => {
26
- for (const entry of entries) {
27
- if (ctx.unmounted) return;
28
- if (entry.cleanup) entry.cleanup();
29
- const cleanup = entry.fn();
30
- entry.cleanup = typeof cleanup === "function" ? cleanup : void 0;
31
- }
32
- });
33
- }
34
- function wrapCompatComponent(solidComponent) {
35
- if (_nativeComponents.has(solidComponent)) return solidComponent;
36
- let wrapped = _wrapperCache.get(solidComponent);
37
- if (wrapped) return wrapped;
38
- wrapped = props => {
39
- const existing = props[_CHILD_INSTANCE];
40
- const ctx = existing?.ctx ?? {
41
- hooks: [],
42
- scheduleRerender: () => {},
43
- pendingEffects: [],
44
- pendingLayoutEffects: [],
45
- unmounted: false,
46
- unmountCallbacks: []
47
- };
48
- if (existing) {
49
- ctx.unmounted = false;
50
- ctx.unmountCallbacks = [];
51
- }
52
- const version = existing?.version ?? signal(0);
53
- let updateScheduled = existing?.updateScheduled ?? false;
54
- ctx.scheduleRerender = () => {
55
- if (ctx.unmounted || updateScheduled) return;
56
- updateScheduled = true;
57
- queueMicrotask(() => {
58
- updateScheduled = false;
59
- if (!ctx.unmounted) version.set(version.peek() + 1);
60
- });
61
- };
62
- onUnmount(() => {
63
- ctx.unmounted = true;
64
- for (const cb of ctx.unmountCallbacks) cb();
65
- });
66
- const {
67
- [_CHILD_INSTANCE]: _stripped,
68
- ...cleanProps
69
- } = props;
70
- return () => {
71
- version();
72
- beginRender(ctx);
73
- const result = runUntracked(() => solidComponent(cleanProps));
74
- const layoutEffects = ctx.pendingLayoutEffects;
75
- const effects = ctx.pendingEffects;
76
- endRender();
77
- runLayoutEffects(layoutEffects);
78
- scheduleEffects(ctx, effects);
79
- return result;
80
- };
81
- };
82
- if ("__loading" in solidComponent) wrapped.__loading = solidComponent.__loading;
83
- _wrapperCache.set(solidComponent, wrapped);
84
- return wrapped;
85
- }
86
- function createChildInstance() {
87
- return {
88
- ctx: {
89
- hooks: [],
90
- scheduleRerender: noop,
91
- pendingEffects: [],
92
- pendingLayoutEffects: [],
93
- unmounted: false,
94
- unmountCallbacks: []
95
- },
96
- version: signal(0),
97
- updateScheduled: false
98
- };
99
- }
100
- /**
101
- * During a parent component render, get or create the child instance at the
102
- * current hook index. Returns undefined when called outside a component render.
103
- */
104
- function resolveChildInstance() {
105
- const parentCtx = _currentCtx;
106
- if (!parentCtx) return void 0;
107
- const idx = _hookIndex++;
108
- if (idx < parentCtx.hooks.length) return parentCtx.hooks[idx];
109
- const instance = createChildInstance();
110
- parentCtx.hooks[idx] = instance;
111
- return instance;
112
- }
113
- function jsx(type, props, key) {
114
- const {
115
- children,
116
- ...rest
117
- } = props;
118
- const propsWithKey = key != null ? {
119
- ...rest,
120
- key
121
- } : rest;
122
- if (typeof type === "function") {
123
- if (_nativeComponents.has(type)) return h(type, children !== void 0 ? {
124
- ...propsWithKey,
125
- children
126
- } : propsWithKey);
127
- const wrapped = wrapCompatComponent(type);
128
- const componentProps = children !== void 0 ? {
129
- ...propsWithKey,
130
- children
131
- } : {
132
- ...propsWithKey
133
- };
134
- const childInstance = resolveChildInstance();
135
- if (childInstance) componentProps[_CHILD_INSTANCE] = childInstance;
136
- return h(wrapped, componentProps);
137
- }
138
- return h(type, propsWithKey, ...(children === void 0 ? [] : Array.isArray(children) ? children : [children]));
139
- }
3
+ //#region src/jsx-runtime.d.ts
4
+ declare function jsx(type: string | ComponentFn | symbol, props: Props & {
5
+ children?: VNodeChild | VNodeChild[];
6
+ }, key?: string | number | null): VNode;
7
+ declare const jsxs: typeof jsx;
140
8
  //#endregion
141
9
  export { Fragment, jsx, jsxs };
142
- //# sourceMappingURL=jsx-runtime.d.ts.map
10
+ //# sourceMappingURL=jsx-runtime2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.d.ts","names":[],"sources":["../../../src/jsx-runtime.ts"],"mappings":";;;;;AA6EA,SAAgB,WAAA,CAAY,GAAA,EAA0B;EACpD,WAAA,GAAc,GAAA;EACd,UAAA,GAAa,CAAA;EACb,GAAA,CAAI,cAAA,GAAiB,EAAE;EACvB,GAAA,CAAI,oBAAA,GAAuB,EAAE;;AAG/B,SAAgB,SAAA,CAAA,EAAkB;EAChC,WAAA,GAAc,IAAA;EACd,UAAA,GAAa,CAAA;;AAKf,SAAS,gBAAA,CAAiB,OAAA,EAA8B;EACtD,KAAK,MAAM,KAAA,IAAS,OAAA,EAAS;IAC3B,IAAI,KAAA,CAAM,OAAA,EAAS,KAAA,CAAM,OAAA,CAAA,CAAS;IAClC,MAAM,OAAA,GAAU,KAAA,CAAM,EAAA,CAAA,CAAI;IAC1B,KAAA,CAAM,OAAA,GAAU,OAAO,OAAA,KAAY,UAAA,GAAa,OAAA,GAAU,KAAA,CAAA;;;AAI9D,SAAS,eAAA,CAAgB,GAAA,EAAoB,OAAA,EAA8B;EACzE,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;EAC1B,cAAA,CAAA,MAAqB;IACnB,KAAK,MAAM,KAAA,IAAS,OAAA,EAAS;MAC3B,IAAI,GAAA,CAAI,SAAA,EAAW;MACnB,IAAI,KAAA,CAAM,OAAA,EAAS,KAAA,CAAM,OAAA,CAAA,CAAS;MAClC,MAAM,OAAA,GAAU,KAAA,CAAM,EAAA,CAAA,CAAI;MAC1B,KAAA,CAAM,OAAA,GAAU,OAAO,OAAA,KAAY,UAAA,GAAa,OAAA,GAAU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A,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACO;EACP,MAAM;IAAE,QAAA;IAAU,GAAG;EAAA,CAAA,GAAS,KAAA;EAC9B,MAAM,YAAA,GAAgB,GAAA,IAAO,IAAA,GAAO;IAAE,GAAG,IAAA;IAAM;GAAK,GAAG,IAAA;EAEvD,IAAI,OAAO,IAAA,KAAS,UAAA,EAAY;IAC9B,IAAI,iBAAA,CAAkB,GAAA,CAAI,IAAA,CAAK,EAE7B,OAAO,CAAA,CAAE,IAAA,EADc,QAAA,KAAa,KAAA,CAAA,GAAY;MAAE,GAAG,YAAA;MAAc;KAAU,GAAG,YAAA,CACnC;IAG/C,MAAM,OAAA,GAAU,mBAAA,CAAoB,IAAA,CAAK;IACzC,MAAM,cAAA,GACJ,QAAA,KAAa,KAAA,CAAA,GAAY;MAAE,GAAG,YAAA;MAAc;KAAU,GAAG;MAAE,GAAG;IAAA,CAAc;IAE9E,MAAM,aAAA,GAAgB,oBAAA,CAAA,CAAsB;IAC5C,IAAI,aAAA,EACA,cAAA,CAA2C,eAAA,CAAA,GAAmB,aAAA;IAGlE,OAAO,CAAA,CAAE,OAAA,EAAS,cAAA,CAAe;;EAMnC,OAAO,CAAA,CAAE,IAAA,EAAM,YAAA,EAAc,IAFV,QAAA,KAAa,KAAA,CAAA,GAAY,EAAE,GAAG,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,GAAG,QAAA,GAAW,CAAC,QAAA,CAAS,EAEnC"}
1
+ {"version":3,"file":"jsx-runtime2.d.ts","names":[],"sources":["../../../src/jsx-runtime.ts"],"mappings":";;;iBA0QgB,GAAA,CACd,IAAA,WAAe,WAAA,WACf,KAAA,EAAO,KAAA;EAAU,QAAA,GAAW,UAAA,GAAa,UAAA;AAAA,GACzC,GAAA,4BACC,KAAA;AAAA,cA4BU,IAAA,SAAI,GAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/solid-compat",
3
- "version": "0.5.6",
3
+ "version": "0.6.0",
4
4
  "description": "SolidJS-compatible API shim for Pyreon — write Solid-style code that runs on Pyreon's reactive engine",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,9 +49,9 @@
49
49
  "prepublishOnly": "bun run build"
50
50
  },
51
51
  "dependencies": {
52
- "@pyreon/core": "^0.5.6",
53
- "@pyreon/reactivity": "^0.5.6",
54
- "@pyreon/runtime-dom": "^0.5.6"
52
+ "@pyreon/core": "^0.6.0",
53
+ "@pyreon/reactivity": "^0.6.0",
54
+ "@pyreon/runtime-dom": "^0.6.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@happy-dom/global-registrator": "^20.8.3",