what-core 0.8.4 → 0.11.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.
Files changed (78) hide show
  1. package/dist/chunk-2IZMPODD.min.js +2 -0
  2. package/dist/chunk-2IZMPODD.min.js.map +7 -0
  3. package/dist/chunk-2P7OVL2L.js +1386 -0
  4. package/dist/chunk-2P7OVL2L.js.map +7 -0
  5. package/dist/chunk-5EQUBJWQ.js +1365 -0
  6. package/dist/chunk-5EQUBJWQ.js.map +7 -0
  7. package/dist/chunk-6DAIK77K.min.js +2 -0
  8. package/dist/chunk-6DAIK77K.min.js.map +7 -0
  9. package/dist/chunk-AW3BAPIK.js +1685 -0
  10. package/dist/chunk-AW3BAPIK.js.map +7 -0
  11. package/dist/chunk-AZP2EOGX.js +188 -0
  12. package/dist/chunk-AZP2EOGX.js.map +7 -0
  13. package/dist/chunk-CCINITLW.js +1692 -0
  14. package/dist/chunk-CCINITLW.js.map +7 -0
  15. package/dist/chunk-F2HUXI22.js +1675 -0
  16. package/dist/chunk-F2HUXI22.js.map +7 -0
  17. package/dist/chunk-GZRA4IAJ.js +1699 -0
  18. package/dist/chunk-GZRA4IAJ.js.map +7 -0
  19. package/dist/chunk-H3GA34JK.js +1384 -0
  20. package/dist/chunk-H3GA34JK.js.map +7 -0
  21. package/dist/chunk-KBM6CWG4.min.js +2 -0
  22. package/dist/chunk-KBM6CWG4.min.js.map +7 -0
  23. package/dist/chunk-KL7TNUIU.min.js +2 -0
  24. package/dist/chunk-KL7TNUIU.min.js.map +7 -0
  25. package/dist/chunk-L6XOF7P4.min.js +2 -0
  26. package/dist/chunk-L6XOF7P4.min.js.map +7 -0
  27. package/dist/chunk-M7UEET5O.js +1323 -0
  28. package/dist/chunk-M7UEET5O.js.map +7 -0
  29. package/dist/chunk-MH7L756Y.min.js +2 -0
  30. package/dist/chunk-MH7L756Y.min.js.map +7 -0
  31. package/dist/chunk-O3SKPRTY.min.js +2 -0
  32. package/dist/chunk-O3SKPRTY.min.js.map +7 -0
  33. package/dist/chunk-RI7T5VFD.min.js +2 -0
  34. package/dist/chunk-RI7T5VFD.min.js.map +7 -0
  35. package/dist/chunk-RN6QIBWL.min.js +2 -0
  36. package/dist/chunk-RN6QIBWL.min.js.map +7 -0
  37. package/dist/chunk-VKCFJ4OT.min.js +2 -0
  38. package/dist/chunk-VKCFJ4OT.min.js.map +7 -0
  39. package/dist/chunk-VMTTYB4L.min.js +2 -0
  40. package/dist/chunk-VMTTYB4L.min.js.map +7 -0
  41. package/dist/chunk-VP4WLF5A.js +1323 -0
  42. package/dist/chunk-VP4WLF5A.js.map +7 -0
  43. package/dist/chunk-YA3W4XKH.js +1323 -0
  44. package/dist/chunk-YA3W4XKH.js.map +7 -0
  45. package/dist/index.js +213 -2788
  46. package/dist/index.js.map +4 -4
  47. package/dist/index.min.js +6 -6
  48. package/dist/index.min.js.map +4 -4
  49. package/dist/jsx-dev-runtime.js +4 -53
  50. package/dist/jsx-dev-runtime.js.map +3 -3
  51. package/dist/jsx-dev-runtime.min.js +1 -1
  52. package/dist/jsx-dev-runtime.min.js.map +4 -4
  53. package/dist/jsx-runtime.js +4 -53
  54. package/dist/jsx-runtime.js.map +3 -3
  55. package/dist/jsx-runtime.min.js +1 -1
  56. package/dist/jsx-runtime.min.js.map +4 -4
  57. package/dist/render.js +34 -2044
  58. package/dist/render.js.map +4 -4
  59. package/dist/render.min.js +1 -1
  60. package/dist/render.min.js.map +4 -4
  61. package/dist/testing.js +13 -1079
  62. package/dist/testing.js.map +4 -4
  63. package/dist/testing.min.js +1 -1
  64. package/dist/testing.min.js.map +4 -4
  65. package/package.json +2 -2
  66. package/render.d.ts +18 -0
  67. package/src/agent-context.js +3 -2
  68. package/src/dom.js +70 -6
  69. package/src/guardrails.js +17 -46
  70. package/src/h.js +15 -3
  71. package/src/head.js +72 -2
  72. package/src/hooks.js +65 -4
  73. package/src/hydration-data.js +34 -0
  74. package/src/index.js +9 -2
  75. package/src/reactive.js +100 -1
  76. package/src/render.js +604 -155
  77. package/src/server-context.js +48 -0
  78. 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