hadars 0.1.35 → 0.1.37
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/README.md +77 -0
- package/cli-lib.ts +90 -5
- package/dist/chunk-F7IIMM3J.js +1060 -0
- package/dist/chunk-UNQSQIOO.js +60 -0
- package/dist/cli.js +285 -261
- package/dist/hadars-B3b_6sj2.d.cts +188 -0
- package/dist/hadars-B3b_6sj2.d.ts +188 -0
- package/dist/index.cjs +11 -19
- package/dist/index.d.cts +105 -0
- package/dist/index.d.ts +4 -175
- package/dist/index.js +14 -42
- package/dist/{jsx-runtime-97ca74a5.d.ts → jsx-runtime-BOYrELJb.d.cts} +1 -1
- package/dist/jsx-runtime-BOYrELJb.d.ts +18 -0
- package/dist/lambda.cjs +1405 -0
- package/dist/lambda.d.cts +93 -0
- package/dist/lambda.d.ts +93 -0
- package/dist/lambda.js +499 -0
- package/dist/loader.cjs +22 -44
- package/dist/slim-react/index.cjs +29 -58
- package/dist/slim-react/index.d.cts +190 -0
- package/dist/slim-react/index.d.ts +3 -3
- package/dist/slim-react/index.js +34 -1043
- package/dist/slim-react/jsx-runtime.d.cts +1 -0
- package/dist/slim-react/jsx-runtime.d.ts +1 -1
- package/dist/ssr-render-worker.js +44 -78
- package/dist/ssr-watch.js +24 -7
- package/dist/utils/Head.tsx +2 -2
- package/package.json +11 -6
- package/src/build.ts +8 -166
- package/src/lambda.ts +287 -0
- package/src/types/hadars.ts +10 -0
- package/src/utils/Head.tsx +2 -2
- package/src/utils/rspack.ts +27 -0
- package/src/utils/ssrHandler.ts +185 -0
package/dist/loader.cjs
CHANGED
|
@@ -49,16 +49,13 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
49
49
|
const fileOffset = ast.span.start - countLeadingNonCodeBytes(source);
|
|
50
50
|
const replacements = [];
|
|
51
51
|
walkAst(ast, (node) => {
|
|
52
|
-
if (node.type !== "CallExpression")
|
|
53
|
-
return;
|
|
52
|
+
if (node.type !== "CallExpression") return;
|
|
54
53
|
const callee = node.callee;
|
|
55
|
-
if (!callee || callee.type !== "Identifier")
|
|
56
|
-
return;
|
|
54
|
+
if (!callee || callee.type !== "Identifier") return;
|
|
57
55
|
const name = callee.value;
|
|
58
56
|
if (!isServer && name === "useServerData") {
|
|
59
57
|
const args2 = node.arguments;
|
|
60
|
-
if (!args2 || args2.length < 2)
|
|
61
|
-
return;
|
|
58
|
+
if (!args2 || args2.length < 2) return;
|
|
62
59
|
const fnArg = args2[1].expression ?? args2[1];
|
|
63
60
|
replacements.push({
|
|
64
61
|
start: fnArg.span.start - fileOffset,
|
|
@@ -67,11 +64,9 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
67
64
|
});
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
|
-
if (name !== "loadModule")
|
|
71
|
-
return;
|
|
67
|
+
if (name !== "loadModule") return;
|
|
72
68
|
const args = node.arguments;
|
|
73
|
-
if (!args || args.length === 0)
|
|
74
|
-
return;
|
|
69
|
+
if (!args || args.length === 0) return;
|
|
75
70
|
const firstArg = args[0].expression ?? args[0];
|
|
76
71
|
let modulePath;
|
|
77
72
|
let quoteChar;
|
|
@@ -96,8 +91,7 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
96
91
|
const replacement = isServer ? `Promise.resolve(require(${quoteChar}${modulePath}${quoteChar}))` : `import(${quoteChar}${modulePath}${quoteChar})`;
|
|
97
92
|
replacements.push({ start: node.span.start - fileOffset, end: node.span.end - fileOffset, replacement });
|
|
98
93
|
});
|
|
99
|
-
if (replacements.length === 0)
|
|
100
|
-
return source;
|
|
94
|
+
if (replacements.length === 0) return source;
|
|
101
95
|
replacements.sort((a, b) => b.start - a.start);
|
|
102
96
|
let result = srcBytes;
|
|
103
97
|
for (const { start, end, replacement } of replacements) {
|
|
@@ -106,16 +100,13 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
106
100
|
return result.toString("utf8");
|
|
107
101
|
}
|
|
108
102
|
function walkAst(node, visit) {
|
|
109
|
-
if (!node || typeof node !== "object")
|
|
110
|
-
return;
|
|
103
|
+
if (!node || typeof node !== "object") return;
|
|
111
104
|
visit(node);
|
|
112
105
|
for (const key of Object.keys(node)) {
|
|
113
|
-
if (key === "span" || key === "type" || key === "ctxt")
|
|
114
|
-
continue;
|
|
106
|
+
if (key === "span" || key === "type" || key === "ctxt") continue;
|
|
115
107
|
const val = node[key];
|
|
116
108
|
if (Array.isArray(val)) {
|
|
117
|
-
for (const child of val)
|
|
118
|
-
walkAst(child, visit);
|
|
109
|
+
for (const child of val) walkAst(child, visit);
|
|
119
110
|
} else if (val && typeof val === "object") {
|
|
120
111
|
walkAst(val, visit);
|
|
121
112
|
}
|
|
@@ -129,21 +120,17 @@ function countLeadingNonCodeBytes(source) {
|
|
|
129
120
|
continue;
|
|
130
121
|
}
|
|
131
122
|
if (source[i] === "/" && source[i + 1] === "/") {
|
|
132
|
-
while (i < source.length && source[i] !== "\n")
|
|
133
|
-
i++;
|
|
123
|
+
while (i < source.length && source[i] !== "\n") i++;
|
|
134
124
|
continue;
|
|
135
125
|
}
|
|
136
126
|
if (source[i] === "/" && source[i + 1] === "*") {
|
|
137
127
|
i += 2;
|
|
138
|
-
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
139
|
-
|
|
140
|
-
if (i + 1 < source.length)
|
|
141
|
-
i += 2;
|
|
128
|
+
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/")) i++;
|
|
129
|
+
if (i + 1 < source.length) i += 2;
|
|
142
130
|
continue;
|
|
143
131
|
}
|
|
144
132
|
if (i === 0 && source[i] === "#" && source[i + 1] === "!") {
|
|
145
|
-
while (i < source.length && source[i] !== "\n")
|
|
146
|
-
i++;
|
|
133
|
+
while (i < source.length && source[i] !== "\n") i++;
|
|
147
134
|
continue;
|
|
148
135
|
}
|
|
149
136
|
break;
|
|
@@ -163,34 +150,29 @@ function scanExpressionEnd(source, pos) {
|
|
|
163
150
|
continue;
|
|
164
151
|
}
|
|
165
152
|
if (ch === ")" || ch === "]" || ch === "}") {
|
|
166
|
-
if (depth === 0)
|
|
167
|
-
break;
|
|
153
|
+
if (depth === 0) break;
|
|
168
154
|
depth--;
|
|
169
155
|
i++;
|
|
170
156
|
continue;
|
|
171
157
|
}
|
|
172
|
-
if (ch === "," && depth === 0)
|
|
173
|
-
break;
|
|
158
|
+
if (ch === "," && depth === 0) break;
|
|
174
159
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
175
160
|
const q = ch;
|
|
176
161
|
i++;
|
|
177
162
|
while (i < source.length && source[i] !== q) {
|
|
178
|
-
if (source[i] === "\\")
|
|
179
|
-
i++;
|
|
163
|
+
if (source[i] === "\\") i++;
|
|
180
164
|
i++;
|
|
181
165
|
}
|
|
182
166
|
i++;
|
|
183
167
|
continue;
|
|
184
168
|
}
|
|
185
169
|
if (ch === "/" && source[i + 1] === "/") {
|
|
186
|
-
while (i < source.length && source[i] !== "\n")
|
|
187
|
-
i++;
|
|
170
|
+
while (i < source.length && source[i] !== "\n") i++;
|
|
188
171
|
continue;
|
|
189
172
|
}
|
|
190
173
|
if (ch === "/" && source[i + 1] === "*") {
|
|
191
174
|
i += 2;
|
|
192
|
-
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
193
|
-
i++;
|
|
175
|
+
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/")) i++;
|
|
194
176
|
i += 2;
|
|
195
177
|
continue;
|
|
196
178
|
}
|
|
@@ -207,18 +189,14 @@ function stripUseServerDataFns(source) {
|
|
|
207
189
|
while ((match = CALL_RE.exec(source)) !== null) {
|
|
208
190
|
const callStart = match.index;
|
|
209
191
|
let i = match.index + match[0].length;
|
|
210
|
-
while (i < source.length && /\s/.test(source[i]))
|
|
211
|
-
i++;
|
|
192
|
+
while (i < source.length && /\s/.test(source[i])) i++;
|
|
212
193
|
i = scanExpressionEnd(source, i);
|
|
213
|
-
if (i >= source.length || source[i] !== ",")
|
|
214
|
-
continue;
|
|
194
|
+
if (i >= source.length || source[i] !== ",") continue;
|
|
215
195
|
i++;
|
|
216
|
-
while (i < source.length && /\s/.test(source[i]))
|
|
217
|
-
i++;
|
|
196
|
+
while (i < source.length && /\s/.test(source[i])) i++;
|
|
218
197
|
const fnStart = i;
|
|
219
198
|
const fnEnd = scanExpressionEnd(source, i);
|
|
220
|
-
if (fnEnd <= fnStart)
|
|
221
|
-
continue;
|
|
199
|
+
if (fnEnd <= fnStart) continue;
|
|
222
200
|
result += source.slice(lastIndex, fnStart) + "()=>undefined";
|
|
223
201
|
lastIndex = fnEnd;
|
|
224
202
|
CALL_RE.lastIndex = fnEnd;
|
|
@@ -112,8 +112,7 @@ function createElement(type, props, ...children) {
|
|
|
112
112
|
// src/slim-react/renderContext.ts
|
|
113
113
|
var MAP_KEY = "__slimReactContextMap";
|
|
114
114
|
var _g = globalThis;
|
|
115
|
-
if (!("__slimReactContextMap" in _g))
|
|
116
|
-
_g[MAP_KEY] = null;
|
|
115
|
+
if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
|
|
117
116
|
function swapContextMap(map) {
|
|
118
117
|
const prev = _g[MAP_KEY];
|
|
119
118
|
_g[MAP_KEY] = map;
|
|
@@ -124,8 +123,7 @@ function captureMap() {
|
|
|
124
123
|
}
|
|
125
124
|
function getContextValue(context) {
|
|
126
125
|
const map = _g[MAP_KEY];
|
|
127
|
-
if (map && map.has(context))
|
|
128
|
-
return map.get(context);
|
|
126
|
+
if (map && map.has(context)) return map.get(context);
|
|
129
127
|
const c = context;
|
|
130
128
|
return "_defaultValue" in c ? c._defaultValue : c._currentValue;
|
|
131
129
|
}
|
|
@@ -207,8 +205,7 @@ function restoreContext(snap) {
|
|
|
207
205
|
}
|
|
208
206
|
function getTreeId() {
|
|
209
207
|
const { id, overflow } = s().currentTreeContext;
|
|
210
|
-
if (id === 1)
|
|
211
|
-
return overflow;
|
|
208
|
+
if (id === 1) return overflow;
|
|
212
209
|
const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
|
|
213
210
|
return stripped + overflow;
|
|
214
211
|
}
|
|
@@ -217,8 +214,7 @@ function makeId() {
|
|
|
217
214
|
const treeId = getTreeId();
|
|
218
215
|
const n = st.localIdCounter++;
|
|
219
216
|
let id = "_R_" + st.idPrefix + treeId;
|
|
220
|
-
if (n > 0)
|
|
221
|
-
id += "H" + n.toString(32);
|
|
217
|
+
if (n > 0) id += "H" + n.toString(32);
|
|
222
218
|
return id + "_";
|
|
223
219
|
}
|
|
224
220
|
|
|
@@ -279,10 +275,8 @@ function use(usable) {
|
|
|
279
275
|
return getContextValue(usable);
|
|
280
276
|
}
|
|
281
277
|
const promise = usable;
|
|
282
|
-
if (promise.status === "fulfilled")
|
|
283
|
-
|
|
284
|
-
if (promise.status === "rejected")
|
|
285
|
-
throw promise.reason;
|
|
278
|
+
if (promise.status === "fulfilled") return promise.value;
|
|
279
|
+
if (promise.status === "rejected") throw promise.reason;
|
|
286
280
|
throw promise;
|
|
287
281
|
}
|
|
288
282
|
function startTransition(callback) {
|
|
@@ -342,15 +336,13 @@ var slimDispatcher = {
|
|
|
342
336
|
useHostTransitionStatus: () => false
|
|
343
337
|
};
|
|
344
338
|
function installDispatcher() {
|
|
345
|
-
if (!_internals)
|
|
346
|
-
return null;
|
|
339
|
+
if (!_internals) return null;
|
|
347
340
|
const prev = _internals.H;
|
|
348
341
|
_internals.H = slimDispatcher;
|
|
349
342
|
return prev;
|
|
350
343
|
}
|
|
351
344
|
function restoreDispatcher(prev) {
|
|
352
|
-
if (_internals)
|
|
353
|
-
_internals.H = prev;
|
|
345
|
+
if (_internals) _internals.H = prev;
|
|
354
346
|
}
|
|
355
347
|
|
|
356
348
|
// src/slim-react/render.ts
|
|
@@ -381,8 +373,7 @@ function escapeAttr(str) {
|
|
|
381
373
|
function styleObjectToString(style) {
|
|
382
374
|
let result = "";
|
|
383
375
|
for (const key in style) {
|
|
384
|
-
if (result)
|
|
385
|
-
result += ";";
|
|
376
|
+
if (result) result += ";";
|
|
386
377
|
const cssKey = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
387
378
|
result += cssKey + ":" + style[key];
|
|
388
379
|
}
|
|
@@ -549,8 +540,7 @@ function renderAttributes(props, isSvg) {
|
|
|
549
540
|
}
|
|
550
541
|
if (key === "style" && typeof value === "object") {
|
|
551
542
|
const styleStr = styleObjectToString(value);
|
|
552
|
-
if (styleStr)
|
|
553
|
-
attrs += ` style="${escapeAttr(styleStr)}"`;
|
|
543
|
+
if (styleStr) attrs += ` style="${escapeAttr(styleStr)}"`;
|
|
554
544
|
continue;
|
|
555
545
|
}
|
|
556
546
|
attrs += ` ${attrName}="${escapeAttr(String(value))}"`;
|
|
@@ -569,14 +559,12 @@ var BufferWriter = class {
|
|
|
569
559
|
this.lastWasText = true;
|
|
570
560
|
}
|
|
571
561
|
flush(target) {
|
|
572
|
-
for (const c of this.chunks)
|
|
573
|
-
target.write(c);
|
|
562
|
+
for (const c of this.chunks) target.write(c);
|
|
574
563
|
target.lastWasText = this.lastWasText;
|
|
575
564
|
}
|
|
576
565
|
};
|
|
577
566
|
function renderNode(node, writer, isSvg = false) {
|
|
578
|
-
if (node == null || typeof node === "boolean")
|
|
579
|
-
return;
|
|
567
|
+
if (node == null || typeof node === "boolean") return;
|
|
580
568
|
if (typeof node === "string") {
|
|
581
569
|
writer.text(escapeHtml(node));
|
|
582
570
|
return;
|
|
@@ -597,8 +585,7 @@ function renderNode(node, writer, isSvg = false) {
|
|
|
597
585
|
}
|
|
598
586
|
if (typeof node === "object" && node !== null && "$$typeof" in node) {
|
|
599
587
|
const elType = node["$$typeof"];
|
|
600
|
-
if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT)
|
|
601
|
-
return;
|
|
588
|
+
if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT) return;
|
|
602
589
|
const element = node;
|
|
603
590
|
const { type, props } = element;
|
|
604
591
|
if (type === FRAGMENT_TYPE) {
|
|
@@ -619,17 +606,14 @@ function renderNode(node, writer, isSvg = false) {
|
|
|
619
606
|
}
|
|
620
607
|
}
|
|
621
608
|
function markSelectedOptionsMulti(children, selectedValues) {
|
|
622
|
-
if (children == null || typeof children === "boolean")
|
|
623
|
-
|
|
624
|
-
if (typeof children === "string" || typeof children === "number")
|
|
625
|
-
return children;
|
|
609
|
+
if (children == null || typeof children === "boolean") return children;
|
|
610
|
+
if (typeof children === "string" || typeof children === "number") return children;
|
|
626
611
|
if (Array.isArray(children)) {
|
|
627
612
|
return children.map((c) => markSelectedOptionsMulti(c, selectedValues));
|
|
628
613
|
}
|
|
629
614
|
if (typeof children === "object" && "$$typeof" in children) {
|
|
630
615
|
const elType = children["$$typeof"];
|
|
631
|
-
if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT)
|
|
632
|
-
return children;
|
|
616
|
+
if (elType !== SLIM_ELEMENT && elType !== REACT19_ELEMENT) return children;
|
|
633
617
|
const el = children;
|
|
634
618
|
if (el.type === "option") {
|
|
635
619
|
const optValue = el.props.value !== void 0 ? el.props.value : el.props.children;
|
|
@@ -650,8 +634,7 @@ function renderHostElement(tag, props, writer, isSvg) {
|
|
|
650
634
|
const textContent = props.value ?? props.defaultValue ?? props.children ?? "";
|
|
651
635
|
const filteredProps = {};
|
|
652
636
|
for (const k of Object.keys(props)) {
|
|
653
|
-
if (k !== "value" && k !== "defaultValue" && k !== "children")
|
|
654
|
-
filteredProps[k] = props[k];
|
|
637
|
+
if (k !== "value" && k !== "defaultValue" && k !== "children") filteredProps[k] = props[k];
|
|
655
638
|
}
|
|
656
639
|
writer.write(`<textarea${renderAttributes(filteredProps, false)}>`);
|
|
657
640
|
writer.text(escapeHtml(String(textContent)));
|
|
@@ -662,8 +645,7 @@ function renderHostElement(tag, props, writer, isSvg) {
|
|
|
662
645
|
const selectedValue = props.value ?? props.defaultValue;
|
|
663
646
|
const filteredProps = {};
|
|
664
647
|
for (const k of Object.keys(props)) {
|
|
665
|
-
if (k !== "value" && k !== "defaultValue")
|
|
666
|
-
filteredProps[k] = props[k];
|
|
648
|
+
if (k !== "value" && k !== "defaultValue") filteredProps[k] = props[k];
|
|
667
649
|
}
|
|
668
650
|
writer.write(`<select${renderAttributes(filteredProps, false)}>`);
|
|
669
651
|
const selectedSet = selectedValue == null ? null : Array.isArray(selectedValue) ? new Set(selectedValue.map(String)) : /* @__PURE__ */ new Set([String(selectedValue)]);
|
|
@@ -771,8 +753,7 @@ function renderComponent(type, props, writer, isSvg) {
|
|
|
771
753
|
const instance = new type(props);
|
|
772
754
|
if (typeof type.getDerivedStateFromProps === "function") {
|
|
773
755
|
const derived = type.getDerivedStateFromProps(props, instance.state ?? {});
|
|
774
|
-
if (derived != null)
|
|
775
|
-
instance.state = { ...instance.state ?? {}, ...derived };
|
|
756
|
+
if (derived != null) instance.state = { ...instance.state ?? {}, ...derived };
|
|
776
757
|
}
|
|
777
758
|
result = instance.render();
|
|
778
759
|
} else {
|
|
@@ -781,8 +762,7 @@ function renderComponent(type, props, writer, isSvg) {
|
|
|
781
762
|
} catch (e) {
|
|
782
763
|
restoreDispatcher(prevDispatcher);
|
|
783
764
|
popComponentScope(savedScope);
|
|
784
|
-
if (isProvider)
|
|
785
|
-
popContextValue(ctx, prevCtxValue);
|
|
765
|
+
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
786
766
|
throw e;
|
|
787
767
|
}
|
|
788
768
|
restoreDispatcher(prevDispatcher);
|
|
@@ -791,11 +771,9 @@ function renderComponent(type, props, writer, isSvg) {
|
|
|
791
771
|
savedIdTree = pushTreeContext(1, 0);
|
|
792
772
|
}
|
|
793
773
|
const finish = () => {
|
|
794
|
-
if (savedIdTree !== void 0)
|
|
795
|
-
popTreeContext(savedIdTree);
|
|
774
|
+
if (savedIdTree !== void 0) popTreeContext(savedIdTree);
|
|
796
775
|
popComponentScope(savedScope);
|
|
797
|
-
if (isProvider)
|
|
798
|
-
popContextValue(ctx, prevCtxValue);
|
|
776
|
+
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
799
777
|
};
|
|
800
778
|
if (result instanceof Promise) {
|
|
801
779
|
const m = captureMap();
|
|
@@ -806,11 +784,9 @@ function renderComponent(type, props, writer, isSvg) {
|
|
|
806
784
|
asyncSavedIdTree = pushTreeContext(1, 0);
|
|
807
785
|
}
|
|
808
786
|
const asyncFinish = () => {
|
|
809
|
-
if (asyncSavedIdTree !== void 0)
|
|
810
|
-
popTreeContext(asyncSavedIdTree);
|
|
787
|
+
if (asyncSavedIdTree !== void 0) popTreeContext(asyncSavedIdTree);
|
|
811
788
|
popComponentScope(savedScope);
|
|
812
|
-
if (isProvider)
|
|
813
|
-
popContextValue(ctx, prevCtxValue);
|
|
789
|
+
if (isProvider) popContextValue(ctx, prevCtxValue);
|
|
814
790
|
};
|
|
815
791
|
const r2 = renderNode(resolved, writer, isSvg);
|
|
816
792
|
if (r2 && typeof r2.then === "function") {
|
|
@@ -893,8 +869,7 @@ function renderChildArrayFrom(children, startIndex, writer, isSvg) {
|
|
|
893
869
|
}
|
|
894
870
|
}
|
|
895
871
|
function renderChildren(children, writer, isSvg = false) {
|
|
896
|
-
if (children == null)
|
|
897
|
-
return;
|
|
872
|
+
if (children == null) return;
|
|
898
873
|
if (Array.isArray(children)) {
|
|
899
874
|
return renderChildArray(children, writer, isSvg);
|
|
900
875
|
}
|
|
@@ -1053,8 +1028,7 @@ function lazy(factory) {
|
|
|
1053
1028
|
let resolved = null;
|
|
1054
1029
|
let promise = null;
|
|
1055
1030
|
return function LazyComponent(props) {
|
|
1056
|
-
if (resolved)
|
|
1057
|
-
return resolved(props);
|
|
1031
|
+
if (resolved) return resolved(props);
|
|
1058
1032
|
if (!promise) {
|
|
1059
1033
|
promise = factory().then((mod) => {
|
|
1060
1034
|
resolved = mod.default;
|
|
@@ -1064,10 +1038,8 @@ function lazy(factory) {
|
|
|
1064
1038
|
};
|
|
1065
1039
|
}
|
|
1066
1040
|
function toFlatArray(children) {
|
|
1067
|
-
if (children == null || typeof children === "boolean")
|
|
1068
|
-
|
|
1069
|
-
if (Array.isArray(children))
|
|
1070
|
-
return children.flatMap(toFlatArray);
|
|
1041
|
+
if (children == null || typeof children === "boolean") return [];
|
|
1042
|
+
if (Array.isArray(children)) return children.flatMap(toFlatArray);
|
|
1071
1043
|
return [children];
|
|
1072
1044
|
}
|
|
1073
1045
|
var Children = {
|
|
@@ -1082,8 +1054,7 @@ var Children = {
|
|
|
1082
1054
|
},
|
|
1083
1055
|
only(children) {
|
|
1084
1056
|
const arr = toFlatArray(children);
|
|
1085
|
-
if (arr.length !== 1)
|
|
1086
|
-
throw new Error("Children.only expected one child");
|
|
1057
|
+
if (arr.length !== 1) throw new Error("Children.only expected one child");
|
|
1087
1058
|
return arr[0];
|
|
1088
1059
|
},
|
|
1089
1060
|
toArray: toFlatArray
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-BOYrELJb.cjs';
|
|
2
|
+
export { C as ComponentFunction, F as FRAGMENT_TYPE, b as Fragment, d as SLIM_ELEMENT, e as SUSPENSE_TYPE, j as jsx, j as jsxDEV, j as jsxs } from '../jsx-runtime-BOYrELJb.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SSR hook implementations.
|
|
6
|
+
*
|
|
7
|
+
* On the server every hook is either a no-op or returns the initial /
|
|
8
|
+
* snapshot value. This is enough for the vast majority of React-
|
|
9
|
+
* compatible libraries to work during server-side rendering.
|
|
10
|
+
*/
|
|
11
|
+
declare function useState<T>(initialState: T | (() => T)): [T, (value: T | ((prev: T) => T)) => void];
|
|
12
|
+
declare function useReducer<S, A>(_reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void];
|
|
13
|
+
declare function useEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
14
|
+
declare function useLayoutEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
15
|
+
declare function useInsertionEffect(_effect: () => void | (() => void), _deps?: any[]): void;
|
|
16
|
+
declare function useRef<T>(initialValue: T): {
|
|
17
|
+
current: T;
|
|
18
|
+
};
|
|
19
|
+
declare function useMemo<T>(factory: () => T, _deps?: any[]): T;
|
|
20
|
+
declare function useCallback<T extends Function>(callback: T, _deps?: any[]): T;
|
|
21
|
+
declare function useId(): string;
|
|
22
|
+
declare function useDebugValue(_value: any, _format?: (v: any) => any): void;
|
|
23
|
+
declare function useImperativeHandle(_ref: any, _createHandle: () => any, _deps?: any[]): void;
|
|
24
|
+
declare function useSyncExternalStore<T>(_subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
|
|
25
|
+
declare function useTransition(): [boolean, (callback: () => void) => void];
|
|
26
|
+
declare function useDeferredValue<T>(value: T): T;
|
|
27
|
+
declare function useOptimistic<T>(passthrough: T): [T, () => void];
|
|
28
|
+
declare function useFormStatus(): {
|
|
29
|
+
pending: boolean;
|
|
30
|
+
data: null;
|
|
31
|
+
method: null;
|
|
32
|
+
action: null;
|
|
33
|
+
};
|
|
34
|
+
declare function useActionState<S>(_action: (state: S, payload: any) => S | Promise<S>, initialState: S, _permalink?: string): [S, (payload: any) => void, boolean];
|
|
35
|
+
declare function use<T>(usable: (Promise<T> & {
|
|
36
|
+
status?: string;
|
|
37
|
+
value?: T;
|
|
38
|
+
reason?: any;
|
|
39
|
+
}) | {
|
|
40
|
+
_currentValue: T;
|
|
41
|
+
}): T;
|
|
42
|
+
declare function startTransition(callback: () => void): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Minimal Context implementation for SSR.
|
|
46
|
+
*
|
|
47
|
+
* Because SSR is single-pass and synchronous within each component,
|
|
48
|
+
* we just track the "current" value on the context object and
|
|
49
|
+
* save / restore around Provider renders (handled by the renderer).
|
|
50
|
+
*/
|
|
51
|
+
interface Context<T> {
|
|
52
|
+
_defaultValue: T;
|
|
53
|
+
_currentValue: T;
|
|
54
|
+
Provider: ContextProvider<T>;
|
|
55
|
+
Consumer: (props: {
|
|
56
|
+
children: (value: T) => SlimNode;
|
|
57
|
+
}) => SlimNode;
|
|
58
|
+
}
|
|
59
|
+
type ContextProvider<T> = ((props: {
|
|
60
|
+
value: T;
|
|
61
|
+
children?: SlimNode;
|
|
62
|
+
}) => SlimNode) & {
|
|
63
|
+
_context: Context<T>;
|
|
64
|
+
};
|
|
65
|
+
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Streaming SSR renderer with Suspense support.
|
|
69
|
+
*
|
|
70
|
+
* `renderToStream` walks the virtual-node tree produced by jsx() /
|
|
71
|
+
* createElement() and writes HTML chunks into a ReadableStream.
|
|
72
|
+
*
|
|
73
|
+
* When it meets a <Suspense> boundary it:
|
|
74
|
+
* 1. Tries to render the children into a temporary buffer.
|
|
75
|
+
* 2. If a child throws a Promise (React Suspense protocol) it
|
|
76
|
+
* awaits the promise, then retries from step 1.
|
|
77
|
+
* 3. Once successful, the buffer is flushed to the real stream.
|
|
78
|
+
*
|
|
79
|
+
* The net effect is that the stream **pauses** at Suspense boundaries
|
|
80
|
+
* until the async data is ready, then continues – exactly as requested.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
interface RenderOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Must match the `identifierPrefix` option passed to `hydrateRoot` on the
|
|
86
|
+
* client so that `useId()` generates identical IDs on server and client.
|
|
87
|
+
* Defaults to `""` (React's default).
|
|
88
|
+
*/
|
|
89
|
+
identifierPrefix?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Render a component tree to a `ReadableStream<Uint8Array>`.
|
|
93
|
+
*
|
|
94
|
+
* The stream pauses at `<Suspense>` boundaries until the suspended
|
|
95
|
+
* promise resolves, then continues writing HTML.
|
|
96
|
+
*/
|
|
97
|
+
declare function renderToStream(element: SlimNode, options?: RenderOptions): ReadableStream<Uint8Array>;
|
|
98
|
+
/**
|
|
99
|
+
* Convenience: render to a complete HTML string.
|
|
100
|
+
* Retries the full tree when a component throws a Promise (Suspense protocol),
|
|
101
|
+
* so useServerData and similar hooks work without requiring explicit <Suspense>.
|
|
102
|
+
*/
|
|
103
|
+
declare function renderToString(element: SlimNode, options?: RenderOptions): Promise<string>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* slim-react – a lightweight, SSR-only React-compatible runtime.
|
|
107
|
+
*
|
|
108
|
+
* Provides just enough of the React API surface to server-render
|
|
109
|
+
* components that use hooks, Context and Suspense.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
declare function useContext<T>(context: Context<T>): T;
|
|
113
|
+
|
|
114
|
+
declare const Suspense: symbol;
|
|
115
|
+
|
|
116
|
+
declare function isValidElement(obj: unknown): obj is SlimElement;
|
|
117
|
+
declare function cloneElement(element: SlimElement, overrideProps?: Record<string, any>, ...children: SlimNode[]): SlimElement;
|
|
118
|
+
declare function forwardRef<P = any>(render: (props: P, ref: any) => SlimNode): (props: P & {
|
|
119
|
+
ref?: any;
|
|
120
|
+
}) => SlimNode;
|
|
121
|
+
declare function memo<P = any>(component: (props: P) => SlimNode): (props: P) => SlimNode;
|
|
122
|
+
declare function lazy<P = any>(factory: () => Promise<{
|
|
123
|
+
default: (props: P) => SlimNode;
|
|
124
|
+
}>): (props: P) => SlimNode;
|
|
125
|
+
declare function toFlatArray(children: SlimNode): SlimNode[];
|
|
126
|
+
declare const Children: {
|
|
127
|
+
map(children: SlimNode, fn: (child: SlimNode, index: number) => SlimNode): SlimNode[];
|
|
128
|
+
forEach(children: SlimNode, fn: (child: SlimNode, index: number) => void): void;
|
|
129
|
+
count(children: SlimNode): number;
|
|
130
|
+
only(children: SlimNode): SlimElement;
|
|
131
|
+
toArray: typeof toFlatArray;
|
|
132
|
+
};
|
|
133
|
+
declare class Component<P = {}, S = {}> {
|
|
134
|
+
props: P;
|
|
135
|
+
state: S;
|
|
136
|
+
context: any;
|
|
137
|
+
constructor(props: P);
|
|
138
|
+
setState(_partial: Partial<S> | ((prev: S) => Partial<S>)): void;
|
|
139
|
+
forceUpdate(): void;
|
|
140
|
+
render(): SlimNode;
|
|
141
|
+
}
|
|
142
|
+
declare class PureComponent<P = {}, S = {}> extends Component<P, S> {
|
|
143
|
+
}
|
|
144
|
+
declare const version = "19.1.1";
|
|
145
|
+
declare const React: {
|
|
146
|
+
useState: typeof useState;
|
|
147
|
+
useReducer: typeof useReducer;
|
|
148
|
+
useEffect: typeof useEffect;
|
|
149
|
+
useLayoutEffect: typeof useLayoutEffect;
|
|
150
|
+
useInsertionEffect: typeof useInsertionEffect;
|
|
151
|
+
useRef: typeof useRef;
|
|
152
|
+
useMemo: typeof useMemo;
|
|
153
|
+
useCallback: typeof useCallback;
|
|
154
|
+
useId: typeof useId;
|
|
155
|
+
useDebugValue: typeof useDebugValue;
|
|
156
|
+
useImperativeHandle: typeof useImperativeHandle;
|
|
157
|
+
useSyncExternalStore: typeof useSyncExternalStore;
|
|
158
|
+
useTransition: typeof useTransition;
|
|
159
|
+
useDeferredValue: typeof useDeferredValue;
|
|
160
|
+
useOptimistic: typeof useOptimistic;
|
|
161
|
+
useFormStatus: typeof useFormStatus;
|
|
162
|
+
useActionState: typeof useActionState;
|
|
163
|
+
use: typeof use;
|
|
164
|
+
startTransition: typeof startTransition;
|
|
165
|
+
createContext: typeof createContext;
|
|
166
|
+
useContext: typeof useContext;
|
|
167
|
+
createElement: typeof createElement;
|
|
168
|
+
cloneElement: typeof cloneElement;
|
|
169
|
+
isValidElement: typeof isValidElement;
|
|
170
|
+
forwardRef: typeof forwardRef;
|
|
171
|
+
memo: typeof memo;
|
|
172
|
+
lazy: typeof lazy;
|
|
173
|
+
Fragment: symbol;
|
|
174
|
+
Suspense: symbol;
|
|
175
|
+
Children: {
|
|
176
|
+
map(children: SlimNode, fn: (child: SlimNode, index: number) => SlimNode): SlimNode[];
|
|
177
|
+
forEach(children: SlimNode, fn: (child: SlimNode, index: number) => void): void;
|
|
178
|
+
count(children: SlimNode): number;
|
|
179
|
+
only(children: SlimNode): SlimElement;
|
|
180
|
+
toArray: typeof toFlatArray;
|
|
181
|
+
};
|
|
182
|
+
Component: typeof Component;
|
|
183
|
+
PureComponent: typeof PureComponent;
|
|
184
|
+
renderToStream: typeof renderToStream;
|
|
185
|
+
renderToString: typeof renderToString;
|
|
186
|
+
renderToReadableStream: typeof renderToStream;
|
|
187
|
+
version: string;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-
|
|
2
|
-
export { C as ComponentFunction,
|
|
1
|
+
import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-BOYrELJb.js';
|
|
2
|
+
export { C as ComponentFunction, F as FRAGMENT_TYPE, b as Fragment, d as SLIM_ELEMENT, e as SUSPENSE_TYPE, j as jsx, j as jsxDEV, j as jsxs } from '../jsx-runtime-BOYrELJb.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* SSR hook implementations.
|
|
@@ -187,4 +187,4 @@ declare const React: {
|
|
|
187
187
|
version: string;
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
export { Children, Component, Context, PureComponent, RenderOptions, SlimElement, SlimNode, Suspense, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
|
|
190
|
+
export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
|