what-core 0.8.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-AW3BAPIK.js +1685 -0
- package/dist/chunk-AW3BAPIK.js.map +7 -0
- package/dist/chunk-AZP2EOGX.js +188 -0
- package/dist/chunk-AZP2EOGX.js.map +7 -0
- package/dist/chunk-F2HUXI22.js +1675 -0
- package/dist/chunk-F2HUXI22.js.map +7 -0
- package/dist/chunk-KBM6CWG4.min.js +2 -0
- package/dist/chunk-KBM6CWG4.min.js.map +7 -0
- package/dist/chunk-KL7TNUIU.min.js +2 -0
- package/dist/chunk-KL7TNUIU.min.js.map +7 -0
- package/dist/chunk-L6XOF7P4.min.js +2 -0
- package/dist/chunk-L6XOF7P4.min.js.map +7 -0
- package/dist/chunk-M7UEET5O.js +1323 -0
- package/dist/chunk-M7UEET5O.js.map +7 -0
- package/dist/chunk-O3SKPRTY.min.js +2 -0
- package/dist/chunk-O3SKPRTY.min.js.map +7 -0
- package/dist/chunk-RN6QIBWL.min.js +2 -0
- package/dist/chunk-RN6QIBWL.min.js.map +7 -0
- package/dist/chunk-VMTTYB4L.min.js +2 -0
- package/dist/chunk-VMTTYB4L.min.js.map +7 -0
- package/dist/chunk-VP4WLF5A.js +1323 -0
- package/dist/chunk-VP4WLF5A.js.map +7 -0
- package/dist/chunk-YA3W4XKH.js +1323 -0
- package/dist/chunk-YA3W4XKH.js.map +7 -0
- package/dist/index.js +212 -2785
- package/dist/index.js.map +4 -4
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +4 -4
- package/dist/jsx-dev-runtime.js +4 -53
- package/dist/jsx-dev-runtime.js.map +3 -3
- package/dist/jsx-dev-runtime.min.js +1 -1
- package/dist/jsx-dev-runtime.min.js.map +4 -4
- package/dist/jsx-runtime.js +4 -53
- package/dist/jsx-runtime.js.map +3 -3
- package/dist/jsx-runtime.min.js +1 -1
- package/dist/jsx-runtime.min.js.map +4 -4
- package/dist/render.js +22 -2044
- package/dist/render.js.map +4 -4
- package/dist/render.min.js +1 -1
- package/dist/render.min.js.map +4 -4
- package/dist/testing.js +13 -1079
- package/dist/testing.js.map +4 -4
- package/dist/testing.min.js +1 -1
- package/dist/testing.min.js.map +4 -4
- package/package.json +2 -2
- package/src/dom.js +54 -6
- package/src/h.js +15 -3
- package/src/head.js +72 -2
- package/src/hooks.js +65 -4
- package/src/hydration-data.js +34 -0
- package/src/index.js +9 -2
- package/src/reactive.js +78 -1
- package/src/render.js +450 -105
- package/src/server-context.js +48 -0
- package/src/store.js +6 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// What Framework - Render-scoped server context (SSR keystone).
|
|
2
|
+
//
|
|
3
|
+
// Holds per-render SSR state that must NOT leak across concurrent requests:
|
|
4
|
+
// the head sink, the current page's loader data, and the resource cache.
|
|
5
|
+
//
|
|
6
|
+
// Concurrency model:
|
|
7
|
+
// - renderToString() is SYNCHRONOUS. A module-global set at the start of the
|
|
8
|
+
// render and cleared in a `finally` lives within one uninterrupted tick, so
|
|
9
|
+
// no other request's render can observe it (same reasoning React's
|
|
10
|
+
// server dispatcher uses). Use runWithServerContext() for that path.
|
|
11
|
+
// - ASYNC paths (renderToStream, async loaders, async createResource) must
|
|
12
|
+
// thread the ctx object explicitly through the call stack and NEVER read
|
|
13
|
+
// this module global across an `await` — two requests can interleave there.
|
|
14
|
+
//
|
|
15
|
+
// getServerContext() returns null on the client and outside of any render, so
|
|
16
|
+
// `typeof document === 'undefined'` guards keep behaving correctly.
|
|
17
|
+
|
|
18
|
+
let _current = null;
|
|
19
|
+
|
|
20
|
+
/** @returns the active render context, or null on the client / outside a render. */
|
|
21
|
+
export function getServerContext() {
|
|
22
|
+
return _current;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Set the active context. Returns the PREVIOUS context so callers can restore it
|
|
27
|
+
* manually (runWithServerContext does this for you).
|
|
28
|
+
*/
|
|
29
|
+
export function setServerContext(ctx) {
|
|
30
|
+
const prev = _current;
|
|
31
|
+
_current = ctx;
|
|
32
|
+
return prev;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Run `fn` with `ctx` as the active context, restoring the previous context
|
|
37
|
+
* afterwards (even if `fn` throws). Returns whatever `fn` returns. Safe for the
|
|
38
|
+
* synchronous render path; do not rely on it across `await` boundaries.
|
|
39
|
+
*/
|
|
40
|
+
export function runWithServerContext(ctx, fn) {
|
|
41
|
+
const prev = _current;
|
|
42
|
+
_current = ctx;
|
|
43
|
+
try {
|
|
44
|
+
return fn();
|
|
45
|
+
} finally {
|
|
46
|
+
_current = prev;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/store.js
CHANGED
|
@@ -85,9 +85,12 @@ export function createStore(definition) {
|
|
|
85
85
|
computeds[key] = computed(() => fn(proxy));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
// Build action functions bound to signals
|
|
88
|
+
// Build action functions bound to signals.
|
|
89
|
+
// Actions may return a value (e.g. `addItem(): newId`) — propagate it
|
|
90
|
+
// through the batch() wrapper so callers can use the return value.
|
|
89
91
|
for (const [key, fn] of Object.entries(actions)) {
|
|
90
92
|
actions[key] = (...args) => {
|
|
93
|
+
let result;
|
|
91
94
|
batch(() => {
|
|
92
95
|
const proxy = new Proxy({}, {
|
|
93
96
|
get(_, prop) {
|
|
@@ -101,8 +104,9 @@ export function createStore(definition) {
|
|
|
101
104
|
return true;
|
|
102
105
|
},
|
|
103
106
|
});
|
|
104
|
-
fn.apply(proxy, args);
|
|
107
|
+
result = fn.apply(proxy, args);
|
|
105
108
|
});
|
|
109
|
+
return result;
|
|
106
110
|
};
|
|
107
111
|
}
|
|
108
112
|
|