what-core 0.14.0 → 0.15.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -38
  3. package/a11y.d.ts +128 -0
  4. package/data.d.ts +294 -0
  5. package/dist/a11y.js +510 -0
  6. package/dist/a11y.min.js +413 -0
  7. package/dist/actions.js +158 -0
  8. package/dist/actions.min.js +112 -0
  9. package/dist/animation.js +481 -0
  10. package/dist/animation.min.js +295 -0
  11. package/dist/async.js +180 -0
  12. package/dist/async.min.js +134 -0
  13. package/dist/components.js +577 -0
  14. package/dist/components.min.js +413 -0
  15. package/dist/data.js +1212 -0
  16. package/dist/data.min.js +918 -0
  17. package/dist/diagnostics.js +187 -0
  18. package/dist/diagnostics.min.js +134 -0
  19. package/dist/dom.js +796 -0
  20. package/dist/dom.min.js +603 -0
  21. package/dist/entries/a11y.js +43 -0
  22. package/dist/entries/a11y.min.js +43 -0
  23. package/dist/entries/data.js +29 -0
  24. package/dist/entries/data.min.js +29 -0
  25. package/dist/entries/dom.js +45 -0
  26. package/dist/entries/dom.min.js +45 -0
  27. package/dist/entries/form.js +31 -0
  28. package/dist/entries/form.min.js +31 -0
  29. package/dist/entries/internal.js +123 -0
  30. package/dist/entries/internal.min.js +123 -0
  31. package/dist/entries/motion.js +23 -0
  32. package/dist/entries/motion.min.js +23 -0
  33. package/dist/entries/ui.js +25 -0
  34. package/dist/entries/ui.min.js +25 -0
  35. package/dist/env.js +5 -0
  36. package/dist/env.min.js +5 -0
  37. package/dist/errors.js +1518 -0
  38. package/dist/errors.min.js +548 -0
  39. package/dist/form.js +936 -0
  40. package/dist/form.min.js +703 -0
  41. package/dist/guardrails.js +84 -0
  42. package/dist/guardrails.min.js +55 -0
  43. package/dist/h.js +232 -0
  44. package/dist/h.min.js +171 -0
  45. package/dist/head.js +241 -0
  46. package/dist/head.min.js +207 -0
  47. package/dist/helpers.js +126 -0
  48. package/dist/helpers.min.js +98 -0
  49. package/dist/hooks.js +255 -0
  50. package/dist/hooks.min.js +153 -0
  51. package/dist/hot.js +215 -0
  52. package/dist/hot.min.js +24 -0
  53. package/dist/hydration-data.js +495 -0
  54. package/dist/hydration-data.min.js +371 -0
  55. package/dist/import-changes.js +273 -0
  56. package/dist/import-changes.min.js +272 -0
  57. package/dist/index.js +95 -0
  58. package/dist/index.min.js +95 -227
  59. package/dist/jsx-dev-runtime.js +10 -0
  60. package/dist/jsx-dev-runtime.min.js +10 -1
  61. package/dist/jsx-runtime.js +27 -0
  62. package/dist/jsx-runtime.min.js +15 -1
  63. package/dist/live.js +54 -0
  64. package/dist/live.min.js +49 -0
  65. package/dist/markup-rules.js +250 -0
  66. package/dist/markup-rules.min.js +213 -0
  67. package/dist/reactive.js +3334 -0
  68. package/dist/reactive.min.js +2033 -0
  69. package/dist/render.js +4746 -0
  70. package/dist/render.min.js +2797 -1
  71. package/dist/scheduler.js +225 -0
  72. package/dist/scheduler.min.js +162 -0
  73. package/dist/selector.js +11 -0
  74. package/dist/selector.min.js +10 -0
  75. package/dist/server-context.js +148 -0
  76. package/dist/server-context.min.js +121 -0
  77. package/dist/skeleton.js +342 -0
  78. package/dist/skeleton.min.js +310 -0
  79. package/dist/store.js +72 -0
  80. package/dist/store.min.js +50 -0
  81. package/dist/testing.js +720 -0
  82. package/dist/testing.min.js +458 -1
  83. package/dist/vnode-adoption.js +19 -0
  84. package/dist/vnode-adoption.min.js +19 -0
  85. package/dist/vnode-renderer.js +61 -0
  86. package/dist/vnode-renderer.min.js +47 -0
  87. package/dom.d.ts +44 -0
  88. package/form.d.ts +218 -0
  89. package/hot.d.ts +35 -0
  90. package/index.d.ts +421 -736
  91. package/internal.d.ts +284 -0
  92. package/jsx-runtime.d.ts +160 -137
  93. package/markup-rules.d.ts +83 -0
  94. package/motion.d.ts +156 -0
  95. package/package.json +117 -3
  96. package/render.d.ts +278 -29
  97. package/src/a11y.js +64 -59
  98. package/src/actions.js +226 -0
  99. package/src/animation.js +105 -57
  100. package/src/async.js +259 -0
  101. package/src/components.js +495 -144
  102. package/src/data.js +1410 -1159
  103. package/src/diagnostics.js +263 -0
  104. package/src/dom.js +1159 -872
  105. package/src/entries/a11y.js +24 -0
  106. package/src/entries/data.js +17 -0
  107. package/src/entries/dom.js +29 -0
  108. package/src/entries/form.js +16 -0
  109. package/src/entries/internal.js +63 -0
  110. package/src/entries/motion.js +13 -0
  111. package/src/entries/ui.js +13 -0
  112. package/src/env-development.js +12 -0
  113. package/src/env.js +33 -0
  114. package/src/errors.js +1144 -168
  115. package/src/form.js +723 -225
  116. package/src/guardrails.js +38 -126
  117. package/src/h.js +227 -152
  118. package/src/head.js +189 -19
  119. package/src/helpers.js +47 -75
  120. package/src/hooks.js +233 -248
  121. package/src/hot.js +316 -0
  122. package/src/hydration-data.js +859 -16
  123. package/src/import-changes.js +156 -0
  124. package/src/index.js +38 -188
  125. package/src/jsx-dev-runtime.js +7 -14
  126. package/src/jsx-runtime.js +25 -9
  127. package/src/live.js +80 -0
  128. package/src/markup-rules.js +387 -0
  129. package/src/reactive.js +4400 -862
  130. package/src/render.js +6502 -2570
  131. package/src/scheduler.js +56 -21
  132. package/src/selector.js +31 -0
  133. package/src/server-context.js +252 -22
  134. package/src/skeleton.js +22 -12
  135. package/src/store.js +17 -31
  136. package/src/testing.js +389 -63
  137. package/src/vnode-adoption.js +48 -0
  138. package/src/vnode-renderer.js +114 -0
  139. package/testing.d.ts +81 -1
  140. package/ui.d.ts +20 -0
  141. package/dist/chunk-6YOUZ6T4.min.js +0 -1
  142. package/dist/chunk-FN6HXME3.min.js +0 -11
  143. package/dist/chunk-VKZY7JPN.min.js +0 -1
  144. package/src/agent-context.js +0 -127
  145. package/src/warnings.js +0 -193
@@ -0,0 +1,187 @@
1
+ // src/diagnostics.js
2
+ import { getErrorDefinition } from "./errors.js";
3
+ var VERSION = "0.15.0";
4
+ var SKILL_PATH = "node_modules/what-framework/skills/what-diagnostics/SKILL.md";
5
+ var MAX_EVENTS = 500;
6
+ var seq = 0;
7
+ var dropped = 0;
8
+ var events = /* @__PURE__ */ new Map();
9
+ var listeners = /* @__PURE__ */ new Set();
10
+ var pending = [];
11
+ var delivering = false;
12
+ var captures = /* @__PURE__ */ new Set();
13
+ var pointed = /* @__PURE__ */ new Set();
14
+ var ownerSource = null;
15
+ function _setOwnerSource(fn) {
16
+ ownerSource = fn;
17
+ }
18
+ function interpolate(template, data) {
19
+ return template.replace(/\{\{(\w+)\}\}/g, (_, key) => data[key] === void 0 ? "(unknown)" : String(data[key]));
20
+ }
21
+ function docsUrl(code) {
22
+ return `https://github.com/CelsianJs/what-framework/blob/v${VERSION}/docs/ERRORS.md#${code.toLowerCase().replace(/_/g, "-")}`;
23
+ }
24
+ function fixLine(code) {
25
+ return ` fix: what_fix({ error: "${code}" }) \xB7 ${SKILL_PATH} \xB7 ${docsUrl(code)}`;
26
+ }
27
+ function print(ev) {
28
+ for (const c of captures) if (c.quiet) return;
29
+ const lines = [`[what] ${ev.code} ${ev.message}`];
30
+ if (ev.owner.length) lines.push(` in ${ev.owner.join(" \u203A ")}`);
31
+ if (ev.loc) lines.push(` at ${ev.loc}`);
32
+ if (!pointed.has(ev.code)) {
33
+ pointed.add(ev.code);
34
+ lines.push(fixLine(ev.code));
35
+ }
36
+ if (typeof console === "undefined") return;
37
+ (ev.severity === "error" ? console.error : console.warn)(lines.join("\n"));
38
+ }
39
+ function _thrownMessage(code, message) {
40
+ return `[what] ${code} ${message.replace(/^\[what\] /, "")}
41
+ ${fixLine(code)}`;
42
+ }
43
+ function report(code, detail = {}) {
44
+ const known = getErrorDefinition(code);
45
+ const def = known || getErrorDefinition("ERR_UNKNOWN");
46
+ const data = known ? detail.data || {} : { ...detail.data, errorCode: code };
47
+ const subject = detail.subject || null;
48
+ const message = interpolate(def.template, data);
49
+ const key = subject ? `${def.code}|${subject.kind}|${subject.id ?? subject.name}` : `${def.code}|${message}`;
50
+ const where = ownerSource !== null && (detail.owner == null || detail.loc == null) ? ownerSource() : null;
51
+ const owner = detail.owner || (where !== null ? [...where] : []);
52
+ const loc = detail.loc || (where !== null ? where.loc : null);
53
+ let ev = events.get(key);
54
+ if (ev) {
55
+ events.delete(key);
56
+ ev.count++;
57
+ ev.seq = ++seq;
58
+ ev.message = message;
59
+ ev.data = data;
60
+ ev.owner = owner;
61
+ ev.loc = loc;
62
+ events.set(key, ev);
63
+ } else {
64
+ const at = ++seq;
65
+ ev = {
66
+ seq: at,
67
+ firstSeq: at,
68
+ code: def.code,
69
+ severity: def.severity,
70
+ message,
71
+ fix: def.suggestion,
72
+ owner,
73
+ loc,
74
+ subject,
75
+ data,
76
+ count: 1
77
+ };
78
+ events.set(key, ev);
79
+ if (events.size > MAX_EVENTS) {
80
+ events.delete(events.keys().next().value);
81
+ dropped++;
82
+ }
83
+ print(ev);
84
+ }
85
+ for (const c of captures) c.record(key, ev);
86
+ deliver(ev);
87
+ return ev;
88
+ }
89
+ function copy(ev) {
90
+ return { ...ev, owner: [...ev.owner], subject: ev.subject && { ...ev.subject }, data: { ...ev.data } };
91
+ }
92
+ function deliver(ev) {
93
+ if (listeners.size === 0) return;
94
+ pending.push(Object.freeze(copy(ev)));
95
+ if (delivering) return;
96
+ delivering = true;
97
+ try {
98
+ for (let i = 0; i < pending.length; i++) {
99
+ for (const fn of listeners) {
100
+ try {
101
+ fn(pending[i]);
102
+ } catch {
103
+ }
104
+ }
105
+ }
106
+ } finally {
107
+ pending.length = 0;
108
+ delivering = false;
109
+ }
110
+ }
111
+ function subscribe(fn) {
112
+ listeners.add(fn);
113
+ return () => {
114
+ listeners.delete(fn);
115
+ };
116
+ }
117
+ function capture({ quiet = false } = {}) {
118
+ const byKey = /* @__PURE__ */ new Map();
119
+ const collected = [];
120
+ const sink = {
121
+ quiet,
122
+ record(key, ev) {
123
+ const mine = byKey.get(key);
124
+ if (mine) {
125
+ Object.assign(mine, copy(ev), { firstSeq: mine.firstSeq, count: mine.count + 1 });
126
+ return;
127
+ }
128
+ const own = { ...copy(ev), firstSeq: ev.seq, count: 1 };
129
+ byKey.set(key, own);
130
+ collected.push(own);
131
+ }
132
+ };
133
+ captures.add(sink);
134
+ return {
135
+ events: collected,
136
+ clear() {
137
+ byKey.clear();
138
+ collected.length = 0;
139
+ },
140
+ stop() {
141
+ captures.delete(sink);
142
+ return collected;
143
+ }
144
+ };
145
+ }
146
+ function getDiagnostics({ since = 0 } = {}) {
147
+ const out = [];
148
+ for (const ev of events.values()) if (ev.seq > since) out.push(copy(ev));
149
+ return { events: out, seq, dropped };
150
+ }
151
+ function clearDiagnostics() {
152
+ events.clear();
153
+ pointed.clear();
154
+ dropped = 0;
155
+ }
156
+ var nextBinding = null;
157
+ function setNextBinding(binding, name) {
158
+ nextBinding = { binding, name };
159
+ }
160
+ function clearNextBinding() {
161
+ nextBinding = null;
162
+ }
163
+ function recordObservation(hooks, type, subject, state) {
164
+ if (!hooks?.onRecord) return;
165
+ try {
166
+ hooks.onRecord(type, subject, state);
167
+ } catch (error) {
168
+ try {
169
+ console.error("[what] devtools hook onRecord threw:", error);
170
+ } catch {
171
+ }
172
+ }
173
+ }
174
+ export {
175
+ VERSION,
176
+ _setOwnerSource,
177
+ _thrownMessage,
178
+ capture,
179
+ clearDiagnostics,
180
+ clearNextBinding,
181
+ getDiagnostics,
182
+ nextBinding,
183
+ recordObservation,
184
+ report,
185
+ setNextBinding,
186
+ subscribe
187
+ };
@@ -0,0 +1,134 @@
1
+ // src/diagnostics.js
2
+ import { getErrorDefinition as q } from "./errors.min.js";
3
+ var _ = "0.15.0", k = "node_modules/what-framework/skills/what-diagnostics/SKILL.md", N = 500, x = 0, b = 0, s = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), d = [], h = !1, w = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set(), S = null;
4
+ function z(e) {
5
+ S = e;
6
+ }
7
+ function O(e, t) {
8
+ return e.replace(/\{\{(\w+)\}\}/g, (n, o) => t[o] === void 0 ? "(unknown)" : String(t[o]));
9
+ }
10
+ function E(e) {
11
+ return `https://github.com/CelsianJs/what-framework/blob/v${_}/docs/ERRORS.md#${e.toLowerCase().replace(/_/g, "-")}`;
12
+ }
13
+ function j(e) {
14
+ return ` fix: what_fix({ error: "${e}" }) \xB7 ${k} \xB7 ${E(e)}`;
15
+ }
16
+ function L(e) {
17
+ for (let n of w) if (n.quiet) return;
18
+ let t = [`[what] ${e.code} ${e.message}`];
19
+ e.owner.length && t.push(` in ${e.owner.join(" \u203A ")}`), e.loc && t.push(` at ${e.loc}`), $.has(e.code) || ($.add(e.code), t.push(j(e.code))), !(typeof console > "u") && (e.severity === "error" ? console.error : console.warn)(t.join(`
20
+ `));
21
+ }
22
+ function B(e, t) {
23
+ return `[what] ${e} ${t.replace(/^\[what\] /, "")}
24
+ ${j(e)}`;
25
+ }
26
+ function C(e, t = {}) {
27
+ let n = q(e), o = n || q("ERR_UNKNOWN"), i = n ? t.data || {} : { ...t.data, errorCode: e }, c = t.subject || null, u = O(o.template, i), l = c ? `${o.code}|${c.kind}|${c.id ?? c.name}` : `${o.code}|${u}`, f = S !== null && (t.owner == null || t.loc == null) ? S() : null, m = t.owner || (f !== null ? [...f] : []), y = t.loc || (f !== null ? f.loc : null), r = s.get(l);
28
+ if (r)
29
+ s.delete(l), r.count++, r.seq = ++x, r.message = u, r.data = i, r.owner = m, r.loc = y, s.set(l, r);
30
+ else {
31
+ let a = ++x;
32
+ r = {
33
+ seq: a,
34
+ firstSeq: a,
35
+ code: o.code,
36
+ severity: o.severity,
37
+ message: u,
38
+ fix: o.suggestion,
39
+ owner: m,
40
+ loc: y,
41
+ subject: c,
42
+ data: i,
43
+ count: 1
44
+ }, s.set(l, r), s.size > N && (s.delete(s.keys().next().value), b++), L(r);
45
+ }
46
+ for (let a of w) a.record(l, r);
47
+ return K(r), r;
48
+ }
49
+ function g(e) {
50
+ return { ...e, owner: [...e.owner], subject: e.subject && { ...e.subject }, data: { ...e.data } };
51
+ }
52
+ function K(e) {
53
+ if (p.size !== 0 && (d.push(Object.freeze(g(e))), !h)) {
54
+ h = !0;
55
+ try {
56
+ for (let t = 0; t < d.length; t++)
57
+ for (let n of p)
58
+ try {
59
+ n(d[t]);
60
+ } catch {
61
+ }
62
+ } finally {
63
+ d.length = 0, h = !1;
64
+ }
65
+ }
66
+ }
67
+ function D(e) {
68
+ return p.add(e), () => {
69
+ p.delete(e);
70
+ };
71
+ }
72
+ function I({ quiet: e = !1 } = {}) {
73
+ let t = /* @__PURE__ */ new Map(), n = [], o = {
74
+ quiet: e,
75
+ record(i, c) {
76
+ let u = t.get(i);
77
+ if (u) {
78
+ Object.assign(u, g(c), { firstSeq: u.firstSeq, count: u.count + 1 });
79
+ return;
80
+ }
81
+ let l = { ...g(c), firstSeq: c.seq, count: 1 };
82
+ t.set(i, l), n.push(l);
83
+ }
84
+ };
85
+ return w.add(o), {
86
+ events: n,
87
+ clear() {
88
+ t.clear(), n.length = 0;
89
+ },
90
+ stop() {
91
+ return w.delete(o), n;
92
+ }
93
+ };
94
+ }
95
+ function A({ since: e = 0 } = {}) {
96
+ let t = [];
97
+ for (let n of s.values()) n.seq > e && t.push(g(n));
98
+ return { events: t, seq: x, dropped: b };
99
+ }
100
+ function T() {
101
+ s.clear(), $.clear(), b = 0;
102
+ }
103
+ var R = null;
104
+ function U(e, t) {
105
+ R = { binding: e, name: t };
106
+ }
107
+ function V() {
108
+ R = null;
109
+ }
110
+ function H(e, t, n, o) {
111
+ if (e?.onRecord)
112
+ try {
113
+ e.onRecord(t, n, o);
114
+ } catch (i) {
115
+ try {
116
+ console.error("[what] devtools hook onRecord threw:", i);
117
+ } catch {
118
+ }
119
+ }
120
+ }
121
+ export {
122
+ _ as VERSION,
123
+ z as _setOwnerSource,
124
+ B as _thrownMessage,
125
+ I as capture,
126
+ T as clearDiagnostics,
127
+ V as clearNextBinding,
128
+ A as getDiagnostics,
129
+ R as nextBinding,
130
+ H as recordObservation,
131
+ C as report,
132
+ U as setNextBinding,
133
+ D as subscribe
134
+ };