@pyreon/core 0.14.0 → 0.16.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/lib/analysis/index.js.html +1 -1
- package/lib/analysis/jsx-dev-runtime.js.html +1 -1
- package/lib/analysis/jsx-runtime.js.html +1 -1
- package/lib/index.js +144 -17
- package/lib/jsx-dev-runtime.js +23 -2
- package/lib/jsx-runtime.js +23 -2
- package/lib/types/index.d.ts +169 -15
- package/lib/types/jsx-dev-runtime.d.ts +19 -4
- package/lib/types/jsx-runtime.d.ts +19 -4
- package/package.json +3 -2
- package/src/compat-marker.ts +79 -0
- package/src/context.ts +38 -7
- package/src/dynamic.ts +16 -5
- package/src/error-boundary.ts +15 -2
- package/src/for.ts +13 -1
- package/src/h.ts +16 -2
- package/src/index.ts +1 -0
- package/src/jsx-runtime.ts +20 -2
- package/src/lifecycle.ts +1 -2
- package/src/manifest.ts +55 -7
- package/src/show.ts +19 -6
- package/src/suspense.ts +1 -2
- package/src/telemetry.ts +30 -2
- package/src/tests/compat-marker.test.ts +96 -0
- package/src/tests/core.test.ts +1 -1
- package/src/tests/dynamic.test.ts +33 -1
- package/src/tests/extract-props-overloads.types.test.ts +135 -0
- package/src/tests/for.test.ts +23 -0
- package/src/tests/h.test.ts +21 -0
- package/src/tests/manifest-snapshot.test.ts +6 -1
- package/src/tests/native-marker-error-boundary.test.ts +12 -0
- package/src/tests/show.test.ts +76 -0
- package/src/tests/telemetry.test.ts +61 -0
- package/src/types.ts +45 -2
- package/lib/index.js.map +0 -1
- package/lib/jsx-dev-runtime.js.map +0 -1
- package/lib/jsx-runtime.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/jsx-dev-runtime.d.ts.map +0 -1
- package/lib/types/jsx-runtime.d.ts.map +0 -1
|
@@ -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":"46e89893-1","name":"lifecycle.ts"},{"uid":"46e89893-3","name":"component.ts"},{"uid":"46e89893-5","name":"compat-marker.ts"},{"uid":"46e89893-7","name":"context.ts"},{"uid":"46e89893-9","name":"h.ts"},{"uid":"46e89893-11","name":"dynamic.ts"},{"uid":"46e89893-13","name":"telemetry.ts"},{"uid":"46e89893-15","name":"error-boundary.ts"},{"uid":"46e89893-17","name":"for.ts"},{"uid":"46e89893-19","name":"lazy.ts"},{"uid":"46e89893-21","name":"map-array.ts"},{"uid":"46e89893-23","name":"portal.ts"},{"uid":"46e89893-25","name":"props.ts"},{"uid":"46e89893-27","name":"ref.ts"},{"uid":"46e89893-29","name":"show.ts"},{"uid":"46e89893-31","name":"style.ts"},{"uid":"46e89893-33","name":"suspense.ts"},{"uid":"46e89893-35","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"46e89893-1":{"renderedLength":3078,"gzipLength":1313,"brotliLength":0,"metaUid":"46e89893-0"},"46e89893-3":{"renderedLength":1471,"gzipLength":693,"brotliLength":0,"metaUid":"46e89893-2"},"46e89893-5":{"renderedLength":3173,"gzipLength":1409,"brotliLength":0,"metaUid":"46e89893-4"},"46e89893-7":{"renderedLength":3600,"gzipLength":1542,"brotliLength":0,"metaUid":"46e89893-6"},"46e89893-9":{"renderedLength":1813,"gzipLength":957,"brotliLength":0,"metaUid":"46e89893-8"},"46e89893-11":{"renderedLength":490,"gzipLength":291,"brotliLength":0,"metaUid":"46e89893-10"},"46e89893-13":{"renderedLength":1208,"gzipLength":633,"brotliLength":0,"metaUid":"46e89893-12"},"46e89893-15":{"renderedLength":1659,"gzipLength":842,"brotliLength":0,"metaUid":"46e89893-14"},"46e89893-17":{"renderedLength":700,"gzipLength":478,"brotliLength":0,"metaUid":"46e89893-16"},"46e89893-19":{"renderedLength":461,"gzipLength":273,"brotliLength":0,"metaUid":"46e89893-18"},"46e89893-21":{"renderedLength":1018,"gzipLength":571,"brotliLength":0,"metaUid":"46e89893-20"},"46e89893-23":{"renderedLength":818,"gzipLength":491,"brotliLength":0,"metaUid":"46e89893-22"},"46e89893-25":{"renderedLength":4339,"gzipLength":1641,"brotliLength":0,"metaUid":"46e89893-24"},"46e89893-27":{"renderedLength":86,"gzipLength":98,"brotliLength":0,"metaUid":"46e89893-26"},"46e89893-29":{"renderedLength":2022,"gzipLength":854,"brotliLength":0,"metaUid":"46e89893-28"},"46e89893-31":{"renderedLength":1858,"gzipLength":825,"brotliLength":0,"metaUid":"46e89893-30"},"46e89893-33":{"renderedLength":1104,"gzipLength":614,"brotliLength":0,"metaUid":"46e89893-32"},"46e89893-35":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"46e89893-34"}},"nodeMetas":{"46e89893-0":{"id":"/src/lifecycle.ts","moduleParts":{"index.js":"46e89893-1"},"imported":[],"importedBy":[{"uid":"46e89893-34"},{"uid":"46e89893-2"},{"uid":"46e89893-6"},{"uid":"46e89893-14"}]},"46e89893-2":{"id":"/src/component.ts","moduleParts":{"index.js":"46e89893-3"},"imported":[{"uid":"46e89893-0"}],"importedBy":[{"uid":"46e89893-34"},{"uid":"46e89893-14"}]},"46e89893-4":{"id":"/src/compat-marker.ts","moduleParts":{"index.js":"46e89893-5"},"imported":[],"importedBy":[{"uid":"46e89893-34"},{"uid":"46e89893-14"}]},"46e89893-6":{"id":"/src/context.ts","moduleParts":{"index.js":"46e89893-7"},"imported":[{"uid":"46e89893-36"},{"uid":"46e89893-0"}],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-8":{"id":"/src/h.ts","moduleParts":{"index.js":"46e89893-9"},"imported":[],"importedBy":[{"uid":"46e89893-34"},{"uid":"46e89893-10"},{"uid":"46e89893-18"},{"uid":"46e89893-32"}]},"46e89893-10":{"id":"/src/dynamic.ts","moduleParts":{"index.js":"46e89893-11"},"imported":[{"uid":"46e89893-8"}],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-12":{"id":"/src/telemetry.ts","moduleParts":{"index.js":"46e89893-13"},"imported":[],"importedBy":[{"uid":"46e89893-34"},{"uid":"46e89893-14"}]},"46e89893-14":{"id":"/src/error-boundary.ts","moduleParts":{"index.js":"46e89893-15"},"imported":[{"uid":"46e89893-36"},{"uid":"46e89893-4"},{"uid":"46e89893-2"},{"uid":"46e89893-0"},{"uid":"46e89893-12"}],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-16":{"id":"/src/for.ts","moduleParts":{"index.js":"46e89893-17"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-18":{"id":"/src/lazy.ts","moduleParts":{"index.js":"46e89893-19"},"imported":[{"uid":"46e89893-36"},{"uid":"46e89893-8"}],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-20":{"id":"/src/map-array.ts","moduleParts":{"index.js":"46e89893-21"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-22":{"id":"/src/portal.ts","moduleParts":{"index.js":"46e89893-23"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-24":{"id":"/src/props.ts","moduleParts":{"index.js":"46e89893-25"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-26":{"id":"/src/ref.ts","moduleParts":{"index.js":"46e89893-27"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-28":{"id":"/src/show.ts","moduleParts":{"index.js":"46e89893-29"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-30":{"id":"/src/style.ts","moduleParts":{"index.js":"46e89893-31"},"imported":[],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-32":{"id":"/src/suspense.ts","moduleParts":{"index.js":"46e89893-33"},"imported":[{"uid":"46e89893-8"}],"importedBy":[{"uid":"46e89893-34"}]},"46e89893-34":{"id":"/src/index.ts","moduleParts":{"index.js":"46e89893-35"},"imported":[{"uid":"46e89893-2"},{"uid":"46e89893-4"},{"uid":"46e89893-6"},{"uid":"46e89893-10"},{"uid":"46e89893-14"},{"uid":"46e89893-16"},{"uid":"46e89893-8"},{"uid":"46e89893-18"},{"uid":"46e89893-0"},{"uid":"46e89893-20"},{"uid":"46e89893-22"},{"uid":"46e89893-24"},{"uid":"46e89893-26"},{"uid":"46e89893-28"},{"uid":"46e89893-30"},{"uid":"46e89893-32"},{"uid":"46e89893-12"}],"importedBy":[],"isEntry":true},"46e89893-36":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"46e89893-6"},{"uid":"46e89893-14"},{"uid":"46e89893-18"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
|
@@ -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":"jsx-dev-runtime.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"jsx-dev-runtime.js","children":[{"name":"src","children":[{"uid":"235a8e25-1","name":"h.ts"},{"uid":"235a8e25-3","name":"jsx-runtime.ts"},{"uid":"235a8e25-5","name":"jsx-dev-runtime.ts"}]}]}],"isRoot":true},"nodeParts":{"235a8e25-1":{"renderedLength":1813,"gzipLength":957,"brotliLength":0,"metaUid":"235a8e25-0"},"235a8e25-3":{"renderedLength":1103,"gzipLength":640,"brotliLength":0,"metaUid":"235a8e25-2"},"235a8e25-5":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"235a8e25-4"}},"nodeMetas":{"235a8e25-0":{"id":"/src/h.ts","moduleParts":{"jsx-dev-runtime.js":"235a8e25-1"},"imported":[],"importedBy":[{"uid":"235a8e25-2"}]},"235a8e25-2":{"id":"/src/jsx-runtime.ts","moduleParts":{"jsx-dev-runtime.js":"235a8e25-3"},"imported":[{"uid":"235a8e25-0"}],"importedBy":[{"uid":"235a8e25-4"}]},"235a8e25-4":{"id":"/src/jsx-dev-runtime.ts","moduleParts":{"jsx-dev-runtime.js":"235a8e25-5"},"imported":[{"uid":"235a8e25-2"}],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
|
@@ -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":"jsx-runtime.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"jsx-runtime.js","children":[{"name":"src","children":[{"uid":"8c2807f7-1","name":"h.ts"},{"uid":"8c2807f7-3","name":"jsx-runtime.ts"}]}]}],"isRoot":true},"nodeParts":{"8c2807f7-1":{"renderedLength":1813,"gzipLength":957,"brotliLength":0,"metaUid":"8c2807f7-0"},"8c2807f7-3":{"renderedLength":1103,"gzipLength":640,"brotliLength":0,"metaUid":"8c2807f7-2"}},"nodeMetas":{"8c2807f7-0":{"id":"/src/h.ts","moduleParts":{"jsx-runtime.js":"8c2807f7-1"},"imported":[],"importedBy":[{"uid":"8c2807f7-2"}]},"8c2807f7-2":{"id":"/src/jsx-runtime.ts","moduleParts":{"jsx-runtime.js":"8c2807f7-3"},"imported":[{"uid":"8c2807f7-0"}],"importedBy":[],"isEntry":true}},"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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { signal } from "@pyreon/reactivity";
|
|
1
|
+
import { setSnapshotCapture, signal } from "@pyreon/reactivity";
|
|
2
2
|
|
|
3
3
|
//#region src/lifecycle.ts
|
|
4
|
-
const __DEV__$3 =
|
|
4
|
+
const __DEV__$3 = process.env.NODE_ENV !== "production";
|
|
5
5
|
let _current = null;
|
|
6
6
|
function setCurrentHooks(hooks) {
|
|
7
7
|
_current = hooks;
|
|
@@ -157,6 +157,80 @@ function dispatchToErrorBoundary(err) {
|
|
|
157
157
|
return handler ? handler(err) : false;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/compat-marker.ts
|
|
162
|
+
/**
|
|
163
|
+
* Compat-mode native-component marker.
|
|
164
|
+
*
|
|
165
|
+
* Pyreon ships compat layers (`@pyreon/{react,preact,vue,solid}-compat`) that
|
|
166
|
+
* wrap every JSX-called component function to emulate that source framework's
|
|
167
|
+
* render-on-state-change semantics. That wrapping is correct for user code
|
|
168
|
+
* (the whole point of compat mode) but corrupts Pyreon framework components
|
|
169
|
+
* — those manage their own reactivity via `provide()` / signals / lifecycle
|
|
170
|
+
* hooks, and wrapping them runs their setup body inside the compat layer's
|
|
171
|
+
* render context instead of Pyreon's, breaking `provide()` and
|
|
172
|
+
* `onMount()` / `onUnmount()` calls.
|
|
173
|
+
*
|
|
174
|
+
* Framework components opt out of compat wrapping by setting a well-known
|
|
175
|
+
* registry symbol (`Symbol.for('pyreon:native-compat')`) on the function.
|
|
176
|
+
* The compat layer reads that symbol and routes marked components straight
|
|
177
|
+
* through Pyreon's `h()` mount path. The symbol is registry-shared, so no
|
|
178
|
+
* import direction between framework and compat is implied — both sides
|
|
179
|
+
* reference the same global symbol via the helpers exported here.
|
|
180
|
+
*
|
|
181
|
+
* Audience: framework-package authors writing JSX components in `@pyreon/*`
|
|
182
|
+
* packages whose setup body uses `provide()` / lifecycle hooks / signal
|
|
183
|
+
* subscriptions. Wrap exported components with `nativeCompat()`. One line
|
|
184
|
+
* per export site; zero runtime cost beyond a single property write at
|
|
185
|
+
* module load.
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* The well-known registry symbol that marks a component as a Pyreon native
|
|
189
|
+
* framework component. Compat layers check this symbol to decide whether to
|
|
190
|
+
* skip their `wrapCompatComponent` call.
|
|
191
|
+
*
|
|
192
|
+
* Exported for advanced cases where a caller needs to test the marker
|
|
193
|
+
* directly (most callers should use `isNativeCompat()`).
|
|
194
|
+
*/
|
|
195
|
+
const NATIVE_COMPAT_MARKER = Symbol.for("pyreon:native-compat");
|
|
196
|
+
/**
|
|
197
|
+
* Mark a Pyreon framework component as "self-managing" — compat layers will
|
|
198
|
+
* skip their React/Vue/Solid/Preact-style wrapping and route the component
|
|
199
|
+
* directly through Pyreon's mount path. Use on every `@pyreon/*` JSX
|
|
200
|
+
* component whose setup body uses `provide()`, lifecycle hooks
|
|
201
|
+
* (`onMount` / `onUnmount`), signal-driven reactivity, or any other Pyreon
|
|
202
|
+
* native pattern that depends on the active component-setup frame.
|
|
203
|
+
*
|
|
204
|
+
* Idempotent: re-applying the marker is a no-op. Non-function inputs pass
|
|
205
|
+
* through unchanged so callers don't have to typecheck before wrapping.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* import { nativeCompat, provide } from '@pyreon/core'
|
|
209
|
+
*
|
|
210
|
+
* export const RouterView = nativeCompat(function RouterView(props) {
|
|
211
|
+
* provide(RouterContext, ...)
|
|
212
|
+
* return <div data-pyreon-router-view>{children}</div>
|
|
213
|
+
* })
|
|
214
|
+
*/
|
|
215
|
+
function nativeCompat(fn) {
|
|
216
|
+
if (typeof fn === "function") fn[NATIVE_COMPAT_MARKER] = true;
|
|
217
|
+
return fn;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Read whether a component has been marked as a Pyreon native framework
|
|
221
|
+
* component. Compat-layer code calls this from its `jsx()` to decide whether
|
|
222
|
+
* to wrap or pass through.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* import { isNativeCompat } from '@pyreon/core'
|
|
226
|
+
*
|
|
227
|
+
* if (isNativeCompat(type)) return h(type, props)
|
|
228
|
+
* return wrapCompatComponent(type)(props)
|
|
229
|
+
*/
|
|
230
|
+
function isNativeCompat(fn) {
|
|
231
|
+
return typeof fn === "function" && fn[NATIVE_COMPAT_MARKER] === true;
|
|
232
|
+
}
|
|
233
|
+
|
|
160
234
|
//#endregion
|
|
161
235
|
//#region src/context.ts
|
|
162
236
|
/**
|
|
@@ -191,7 +265,7 @@ function setContextStackProvider(fn) {
|
|
|
191
265
|
function getStack() {
|
|
192
266
|
return _stackProvider();
|
|
193
267
|
}
|
|
194
|
-
|
|
268
|
+
process.env.NODE_ENV;
|
|
195
269
|
function pushContext(values) {
|
|
196
270
|
getStack().push(values);
|
|
197
271
|
}
|
|
@@ -248,23 +322,50 @@ function captureContextStack() {
|
|
|
248
322
|
}
|
|
249
323
|
/**
|
|
250
324
|
* Execute `fn()` with a previously captured context stack active.
|
|
251
|
-
*
|
|
325
|
+
*
|
|
326
|
+
* After `fn()` returns, removes ONLY the snapshot frames this call pushed
|
|
327
|
+
* — anything `fn()` itself pushed (typically provider frames from
|
|
328
|
+
* `provide()` calls during component mount) stays on the stack so
|
|
329
|
+
* subsequent reactive re-runs (e.g. `_bind` text bindings,
|
|
330
|
+
* `renderEffect` callbacks) can still find ancestor providers via
|
|
331
|
+
* `useContext`. Pre-fix this method was `stack.length = savedLength`,
|
|
332
|
+
* which destructively truncated provider frames pushed during mount —
|
|
333
|
+
* silently breaking `useMode()` / `useTheme()` / `useRouter()` etc. on
|
|
334
|
+
* every signal-driven update under a `mountReactive` boundary.
|
|
252
335
|
*/
|
|
253
336
|
function restoreContextStack(snapshot, fn) {
|
|
254
337
|
const stack = getStack();
|
|
255
|
-
const
|
|
338
|
+
const insertIndex = stack.length;
|
|
256
339
|
for (const frame of snapshot) stack.push(frame);
|
|
257
340
|
try {
|
|
258
341
|
return fn();
|
|
259
342
|
} finally {
|
|
260
|
-
stack.length
|
|
343
|
+
stack.splice(insertIndex, snapshot.length);
|
|
261
344
|
}
|
|
262
345
|
}
|
|
346
|
+
setSnapshotCapture({
|
|
347
|
+
capture: () => captureContextStack(),
|
|
348
|
+
restore: (snap, fn) => restoreContextStack(snap, fn)
|
|
349
|
+
});
|
|
263
350
|
|
|
264
351
|
//#endregion
|
|
265
352
|
//#region src/h.ts
|
|
266
|
-
/**
|
|
267
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Marker for fragment nodes — renders children without a wrapper element.
|
|
355
|
+
*
|
|
356
|
+
* MUST use `Symbol.for(...)` (global registry, keyed by string), NOT
|
|
357
|
+
* `Symbol(...)` (fresh per evaluation). `h.ts` is inlined into BOTH the
|
|
358
|
+
* main `lib/index.js` and the `lib/jsx-runtime.js` published bundles —
|
|
359
|
+
* each bundle's evaluation of a bare `Symbol(...)` would produce a
|
|
360
|
+
* DISTINCT Symbol identity. JSX `<>` compiles to `jsx(Fragment, ...)` and
|
|
361
|
+
* resolves to jsx-runtime's identity; `runtime-server` checks
|
|
362
|
+
* `vnode.type === Fragment` against the main-entry identity. Mismatch
|
|
363
|
+
* fell through to `renderElement` and crashed SSG with
|
|
364
|
+
* `TypeError: Cannot convert a Symbol value to a string`.
|
|
365
|
+
* `Symbol.for()` keys by string in a global registry shared across all
|
|
366
|
+
* bundle evaluations — same identity everywhere.
|
|
367
|
+
*/
|
|
368
|
+
const Fragment = Symbol.for("Pyreon.Fragment");
|
|
268
369
|
/**
|
|
269
370
|
* Hyperscript function — the compiled output of JSX.
|
|
270
371
|
* `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
|
|
@@ -295,12 +396,14 @@ function flattenChildren(children) {
|
|
|
295
396
|
|
|
296
397
|
//#endregion
|
|
297
398
|
//#region src/dynamic.ts
|
|
298
|
-
const __DEV__$2 =
|
|
399
|
+
const __DEV__$2 = process.env.NODE_ENV !== "production";
|
|
299
400
|
function Dynamic(props) {
|
|
300
|
-
const { component, ...rest } = props;
|
|
401
|
+
const { component, children, ...rest } = props;
|
|
301
402
|
if (__DEV__$2 && !component) console.warn("[Pyreon] <Dynamic> received a falsy `component` prop. Nothing will be rendered.");
|
|
302
403
|
if (!component) return null;
|
|
303
|
-
return h(component, rest);
|
|
404
|
+
if (children === void 0) return h(component, rest);
|
|
405
|
+
if (Array.isArray(children)) return h(component, rest, ...children);
|
|
406
|
+
return h(component, rest, children);
|
|
304
407
|
}
|
|
305
408
|
|
|
306
409
|
//#endregion
|
|
@@ -308,10 +411,17 @@ function Dynamic(props) {
|
|
|
308
411
|
let _handlers = [];
|
|
309
412
|
/**
|
|
310
413
|
* Register a global error handler. Called whenever a component throws in any
|
|
311
|
-
* lifecycle phase
|
|
414
|
+
* lifecycle phase, OR an effect throws in `@pyreon/reactivity`. Returns an
|
|
415
|
+
* unregister function.
|
|
416
|
+
*
|
|
417
|
+
* Also installs a `globalThis.__pyreon_report_error__` bridge so the
|
|
418
|
+
* reactivity package (which can't depend on core) can forward effect errors
|
|
419
|
+
* into the same telemetry pipeline. Pre-fix the two surfaces were
|
|
420
|
+
* disconnected — Sentry/Datadog wiring missed effect-thrown errors.
|
|
312
421
|
*/
|
|
313
422
|
function registerErrorHandler(handler) {
|
|
314
423
|
_handlers.push(handler);
|
|
424
|
+
_installReactivityBridge();
|
|
315
425
|
return () => {
|
|
316
426
|
_handlers = _handlers.filter((h) => h !== handler);
|
|
317
427
|
};
|
|
@@ -325,10 +435,22 @@ function reportError(ctx) {
|
|
|
325
435
|
h(ctx);
|
|
326
436
|
} catch {}
|
|
327
437
|
}
|
|
438
|
+
const _bridgeHost = globalThis;
|
|
439
|
+
function _installReactivityBridge() {
|
|
440
|
+
if (_bridgeHost.__pyreon_report_error__) return;
|
|
441
|
+
_bridgeHost.__pyreon_report_error__ = (err, phase) => {
|
|
442
|
+
reportError({
|
|
443
|
+
component: "Effect",
|
|
444
|
+
phase,
|
|
445
|
+
error: err,
|
|
446
|
+
timestamp: Date.now()
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
}
|
|
328
450
|
|
|
329
451
|
//#endregion
|
|
330
452
|
//#region src/error-boundary.ts
|
|
331
|
-
const __DEV__$1 =
|
|
453
|
+
const __DEV__$1 = process.env.NODE_ENV !== "production";
|
|
332
454
|
/**
|
|
333
455
|
* ErrorBoundary — catches errors thrown by child components and renders a
|
|
334
456
|
* fallback UI instead of crashing the whole tree.
|
|
@@ -376,6 +498,7 @@ function ErrorBoundary(props) {
|
|
|
376
498
|
return typeof ch === "function" ? ch() : ch;
|
|
377
499
|
};
|
|
378
500
|
}
|
|
501
|
+
nativeCompat(ErrorBoundary);
|
|
379
502
|
|
|
380
503
|
//#endregion
|
|
381
504
|
//#region src/for.ts
|
|
@@ -637,6 +760,9 @@ function createRef() {
|
|
|
637
760
|
|
|
638
761
|
//#endregion
|
|
639
762
|
//#region src/show.ts
|
|
763
|
+
function callWhen(when) {
|
|
764
|
+
return typeof when === "function" ? when() : when;
|
|
765
|
+
}
|
|
640
766
|
/**
|
|
641
767
|
* Conditionally render children based on a reactive condition.
|
|
642
768
|
*
|
|
@@ -651,7 +777,7 @@ function createRef() {
|
|
|
651
777
|
* )
|
|
652
778
|
*/
|
|
653
779
|
function Show(props) {
|
|
654
|
-
return (() => props.when
|
|
780
|
+
return (() => callWhen(props.when) ? props.children ?? null : props.fallback ?? null);
|
|
655
781
|
}
|
|
656
782
|
/**
|
|
657
783
|
* A branch inside `<Switch>`. Renders when `when()` is truthy.
|
|
@@ -691,7 +817,8 @@ function Switch(props) {
|
|
|
691
817
|
const branches = normalizeBranches(props.children);
|
|
692
818
|
for (const branch of branches) {
|
|
693
819
|
if (!isMatchVNode(branch)) continue;
|
|
694
|
-
|
|
820
|
+
const matchProps = branch.props;
|
|
821
|
+
if (callWhen(matchProps.when)) return resolveMatchChildren(branch);
|
|
695
822
|
}
|
|
696
823
|
return props.fallback ?? null;
|
|
697
824
|
});
|
|
@@ -781,7 +908,7 @@ function normalizeStyleValue(key, value) {
|
|
|
781
908
|
|
|
782
909
|
//#endregion
|
|
783
910
|
//#region src/suspense.ts
|
|
784
|
-
const __DEV__ =
|
|
911
|
+
const __DEV__ = process.env.NODE_ENV !== "production";
|
|
785
912
|
/**
|
|
786
913
|
* Suspense — shows `fallback` while a lazy child component is still loading.
|
|
787
914
|
*
|
|
@@ -809,5 +936,5 @@ function Suspense(props) {
|
|
|
809
936
|
}
|
|
810
937
|
|
|
811
938
|
//#endregion
|
|
812
|
-
export { CSS_UNITLESS, Dynamic, EMPTY_PROPS, ErrorBoundary, For, ForSymbol, Fragment, Match, MatchSymbol, Portal, PortalSymbol, REACTIVE_PROP, Show, Suspense, Switch, _rp, captureContextStack, createContext, createReactiveContext, createRef, createUniqueId, cx, defineComponent, dispatchToErrorBoundary, h, lazy, makeReactiveProps, mapArray, mergeProps, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, provide, pushContext, registerErrorHandler, reportError, restoreContextStack, runWithHooks, setContextStackProvider, splitProps, toKebabCase, useContext, withContext };
|
|
939
|
+
export { CSS_UNITLESS, Dynamic, EMPTY_PROPS, ErrorBoundary, For, ForSymbol, Fragment, Match, MatchSymbol, NATIVE_COMPAT_MARKER, Portal, PortalSymbol, REACTIVE_PROP, Show, Suspense, Switch, _rp, captureContextStack, createContext, createReactiveContext, createRef, createUniqueId, cx, defineComponent, dispatchToErrorBoundary, h, isNativeCompat, lazy, makeReactiveProps, mapArray, mergeProps, nativeCompat, normalizeStyleValue, onErrorCaptured, onMount, onUnmount, onUpdate, popContext, propagateError, provide, pushContext, registerErrorHandler, reportError, restoreContextStack, runWithHooks, setContextStackProvider, splitProps, toKebabCase, useContext, withContext };
|
|
813
940
|
//# sourceMappingURL=index.js.map
|
package/lib/jsx-dev-runtime.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
//#region src/h.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Marker for fragment nodes — renders children without a wrapper element.
|
|
4
|
+
*
|
|
5
|
+
* MUST use `Symbol.for(...)` (global registry, keyed by string), NOT
|
|
6
|
+
* `Symbol(...)` (fresh per evaluation). `h.ts` is inlined into BOTH the
|
|
7
|
+
* main `lib/index.js` and the `lib/jsx-runtime.js` published bundles —
|
|
8
|
+
* each bundle's evaluation of a bare `Symbol(...)` would produce a
|
|
9
|
+
* DISTINCT Symbol identity. JSX `<>` compiles to `jsx(Fragment, ...)` and
|
|
10
|
+
* resolves to jsx-runtime's identity; `runtime-server` checks
|
|
11
|
+
* `vnode.type === Fragment` against the main-entry identity. Mismatch
|
|
12
|
+
* fell through to `renderElement` and crashed SSG with
|
|
13
|
+
* `TypeError: Cannot convert a Symbol value to a string`.
|
|
14
|
+
* `Symbol.for()` keys by string in a global registry shared across all
|
|
15
|
+
* bundle evaluations — same identity everywhere.
|
|
16
|
+
*/
|
|
17
|
+
const Fragment = Symbol.for("Pyreon.Fragment");
|
|
4
18
|
/**
|
|
5
19
|
* Hyperscript function — the compiled output of JSX.
|
|
6
20
|
* `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
|
|
@@ -37,6 +51,13 @@ function flattenChildren(children) {
|
|
|
37
51
|
* When tsconfig has `"jsxImportSource": "@pyreon/core"`, the TS/bundler compiler
|
|
38
52
|
* rewrites JSX to imports from this file automatically:
|
|
39
53
|
* <div class="x" /> → jsx("div", { class: "x" })
|
|
54
|
+
*
|
|
55
|
+
* The triple-slash reference above makes this file self-declare its DOM-lib
|
|
56
|
+
* dependency. Without it, any consumer whose tsconfig has `lib: ["ESNext"]`
|
|
57
|
+
* (no DOM) — e.g. backend-only packages like @pyreon/cli — fails to typecheck
|
|
58
|
+
* once `@pyreon/core` becomes resolvable from their dependency graph (e.g. via
|
|
59
|
+
* a transitive devDep), because tsc auto-resolves jsxImportSource and pulls
|
|
60
|
+
* jsx-runtime.ts into the consumer's compilation unit.
|
|
40
61
|
*/
|
|
41
62
|
function jsx(type, props, key) {
|
|
42
63
|
const { children, ...rest } = props;
|
package/lib/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
//#region src/h.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Marker for fragment nodes — renders children without a wrapper element.
|
|
4
|
+
*
|
|
5
|
+
* MUST use `Symbol.for(...)` (global registry, keyed by string), NOT
|
|
6
|
+
* `Symbol(...)` (fresh per evaluation). `h.ts` is inlined into BOTH the
|
|
7
|
+
* main `lib/index.js` and the `lib/jsx-runtime.js` published bundles —
|
|
8
|
+
* each bundle's evaluation of a bare `Symbol(...)` would produce a
|
|
9
|
+
* DISTINCT Symbol identity. JSX `<>` compiles to `jsx(Fragment, ...)` and
|
|
10
|
+
* resolves to jsx-runtime's identity; `runtime-server` checks
|
|
11
|
+
* `vnode.type === Fragment` against the main-entry identity. Mismatch
|
|
12
|
+
* fell through to `renderElement` and crashed SSG with
|
|
13
|
+
* `TypeError: Cannot convert a Symbol value to a string`.
|
|
14
|
+
* `Symbol.for()` keys by string in a global registry shared across all
|
|
15
|
+
* bundle evaluations — same identity everywhere.
|
|
16
|
+
*/
|
|
17
|
+
const Fragment = Symbol.for("Pyreon.Fragment");
|
|
4
18
|
/**
|
|
5
19
|
* Hyperscript function — the compiled output of JSX.
|
|
6
20
|
* `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
|
|
@@ -37,6 +51,13 @@ function flattenChildren(children) {
|
|
|
37
51
|
* When tsconfig has `"jsxImportSource": "@pyreon/core"`, the TS/bundler compiler
|
|
38
52
|
* rewrites JSX to imports from this file automatically:
|
|
39
53
|
* <div class="x" /> → jsx("div", { class: "x" })
|
|
54
|
+
*
|
|
55
|
+
* The triple-slash reference above makes this file self-declare its DOM-lib
|
|
56
|
+
* dependency. Without it, any consumer whose tsconfig has `lib: ["ESNext"]`
|
|
57
|
+
* (no DOM) — e.g. backend-only packages like @pyreon/cli — fails to typecheck
|
|
58
|
+
* once `@pyreon/core` becomes resolvable from their dependency graph (e.g. via
|
|
59
|
+
* a transitive devDep), because tsc auto-resolves jsxImportSource and pulls
|
|
60
|
+
* jsx-runtime.ts into the consumer's compilation unit.
|
|
40
61
|
*/
|
|
41
62
|
function jsx(type, props, key) {
|
|
42
63
|
const { children, ...rest } = props;
|