hadars 0.1.16 → 0.1.18
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-TGSIYGY2.js +40 -0
- package/dist/cli.js +695 -165
- package/dist/index.cjs +61 -6
- package/dist/index.d.ts +40 -1
- package/dist/index.js +58 -6
- package/dist/jsx-runtime-97ca74a5.d.ts +18 -0
- package/dist/slim-react/index.cjs +874 -0
- package/dist/slim-react/index.d.ts +180 -0
- package/dist/slim-react/index.js +784 -0
- package/dist/slim-react/jsx-runtime.cjs +51 -0
- package/dist/slim-react/jsx-runtime.d.ts +1 -0
- package/dist/slim-react/jsx-runtime.js +10 -0
- package/dist/ssr-render-worker.js +619 -108
- package/dist/ssr-watch.js +37 -13
- package/dist/utils/Head.tsx +3 -6
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/build.ts +55 -49
- package/src/components/CacheSegment.tsx +67 -0
- package/src/index.tsx +2 -0
- package/src/slim-react/context.ts +52 -0
- package/src/slim-react/hooks.ts +137 -0
- package/src/slim-react/index.ts +225 -0
- package/src/slim-react/jsx-runtime.ts +7 -0
- package/src/slim-react/jsx.ts +53 -0
- package/src/slim-react/render.ts +686 -0
- package/src/slim-react/renderContext.ts +105 -0
- package/src/slim-react/types.ts +27 -0
- package/src/ssr-render-worker.ts +83 -118
- package/src/utils/Head.tsx +3 -6
- package/src/utils/response.tsx +42 -105
- package/src/utils/rspack.ts +45 -15
- package/src/utils/segmentCache.ts +87 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/slim-react/index.ts
|
|
21
|
+
var slim_react_exports = {};
|
|
22
|
+
__export(slim_react_exports, {
|
|
23
|
+
Children: () => Children,
|
|
24
|
+
Component: () => Component,
|
|
25
|
+
FRAGMENT_TYPE: () => FRAGMENT_TYPE,
|
|
26
|
+
Fragment: () => Fragment,
|
|
27
|
+
PureComponent: () => PureComponent,
|
|
28
|
+
SLIM_ELEMENT: () => SLIM_ELEMENT,
|
|
29
|
+
SUSPENSE_TYPE: () => SUSPENSE_TYPE,
|
|
30
|
+
Suspense: () => Suspense,
|
|
31
|
+
cloneElement: () => cloneElement,
|
|
32
|
+
createContext: () => createContext,
|
|
33
|
+
createElement: () => createElement,
|
|
34
|
+
default: () => slim_react_default,
|
|
35
|
+
forwardRef: () => forwardRef,
|
|
36
|
+
isValidElement: () => isValidElement,
|
|
37
|
+
jsx: () => jsx,
|
|
38
|
+
jsxDEV: () => jsx,
|
|
39
|
+
jsxs: () => jsx,
|
|
40
|
+
lazy: () => lazy,
|
|
41
|
+
memo: () => memo,
|
|
42
|
+
renderToReadableStream: () => renderToStream,
|
|
43
|
+
renderToStream: () => renderToStream,
|
|
44
|
+
renderToString: () => renderToString,
|
|
45
|
+
startTransition: () => startTransition,
|
|
46
|
+
use: () => use,
|
|
47
|
+
useActionState: () => useActionState,
|
|
48
|
+
useCallback: () => useCallback,
|
|
49
|
+
useContext: () => useContext,
|
|
50
|
+
useDebugValue: () => useDebugValue,
|
|
51
|
+
useDeferredValue: () => useDeferredValue,
|
|
52
|
+
useEffect: () => useEffect,
|
|
53
|
+
useFormStatus: () => useFormStatus,
|
|
54
|
+
useId: () => useId,
|
|
55
|
+
useImperativeHandle: () => useImperativeHandle,
|
|
56
|
+
useInsertionEffect: () => useInsertionEffect,
|
|
57
|
+
useLayoutEffect: () => useLayoutEffect,
|
|
58
|
+
useMemo: () => useMemo,
|
|
59
|
+
useOptimistic: () => useOptimistic,
|
|
60
|
+
useReducer: () => useReducer,
|
|
61
|
+
useRef: () => useRef,
|
|
62
|
+
useState: () => useState,
|
|
63
|
+
useSyncExternalStore: () => useSyncExternalStore,
|
|
64
|
+
useTransition: () => useTransition
|
|
65
|
+
});
|
|
66
|
+
module.exports = __toCommonJS(slim_react_exports);
|
|
67
|
+
|
|
68
|
+
// src/slim-react/types.ts
|
|
69
|
+
var SLIM_ELEMENT = Symbol.for("react.element");
|
|
70
|
+
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
71
|
+
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
72
|
+
|
|
73
|
+
// src/slim-react/jsx.ts
|
|
74
|
+
var Fragment = FRAGMENT_TYPE;
|
|
75
|
+
function jsx(type, props, key) {
|
|
76
|
+
return {
|
|
77
|
+
$$typeof: SLIM_ELEMENT,
|
|
78
|
+
type,
|
|
79
|
+
props: props || {},
|
|
80
|
+
key: key ?? (props?.key ?? null)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function createElement(type, props, ...children) {
|
|
84
|
+
const normalizedProps = { ...props || {} };
|
|
85
|
+
if (children.length === 1) {
|
|
86
|
+
normalizedProps.children = children[0];
|
|
87
|
+
} else if (children.length > 1) {
|
|
88
|
+
normalizedProps.children = children;
|
|
89
|
+
}
|
|
90
|
+
const key = normalizedProps.key ?? null;
|
|
91
|
+
delete normalizedProps.key;
|
|
92
|
+
return {
|
|
93
|
+
$$typeof: SLIM_ELEMENT,
|
|
94
|
+
type,
|
|
95
|
+
props: normalizedProps,
|
|
96
|
+
key
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/slim-react/renderContext.ts
|
|
101
|
+
var GLOBAL_KEY = "__slimReactRenderState";
|
|
102
|
+
var EMPTY = { id: 0, overflow: "", bits: 0 };
|
|
103
|
+
function s() {
|
|
104
|
+
const g = globalThis;
|
|
105
|
+
if (!g[GLOBAL_KEY]) {
|
|
106
|
+
g[GLOBAL_KEY] = { currentTreeContext: { ...EMPTY }, localIdCounter: 0, idPrefix: "" };
|
|
107
|
+
}
|
|
108
|
+
return g[GLOBAL_KEY];
|
|
109
|
+
}
|
|
110
|
+
function resetRenderState() {
|
|
111
|
+
const st = s();
|
|
112
|
+
st.currentTreeContext = { ...EMPTY };
|
|
113
|
+
st.localIdCounter = 0;
|
|
114
|
+
}
|
|
115
|
+
function pushTreeContext(totalChildren, index) {
|
|
116
|
+
const st = s();
|
|
117
|
+
const saved = { ...st.currentTreeContext };
|
|
118
|
+
const pendingBits = 32 - Math.clz32(totalChildren);
|
|
119
|
+
const slot = index + 1;
|
|
120
|
+
const totalBits = st.currentTreeContext.bits + pendingBits;
|
|
121
|
+
if (totalBits <= 30) {
|
|
122
|
+
st.currentTreeContext = {
|
|
123
|
+
id: st.currentTreeContext.id << pendingBits | slot,
|
|
124
|
+
overflow: st.currentTreeContext.overflow,
|
|
125
|
+
bits: totalBits
|
|
126
|
+
};
|
|
127
|
+
} else {
|
|
128
|
+
let newOverflow = st.currentTreeContext.overflow;
|
|
129
|
+
if (st.currentTreeContext.bits > 0)
|
|
130
|
+
newOverflow += st.currentTreeContext.id.toString(32);
|
|
131
|
+
st.currentTreeContext = { id: 1 << pendingBits | slot, overflow: newOverflow, bits: pendingBits };
|
|
132
|
+
}
|
|
133
|
+
return saved;
|
|
134
|
+
}
|
|
135
|
+
function popTreeContext(saved) {
|
|
136
|
+
s().currentTreeContext = saved;
|
|
137
|
+
}
|
|
138
|
+
function pushComponentScope() {
|
|
139
|
+
const st = s();
|
|
140
|
+
const saved = st.localIdCounter;
|
|
141
|
+
st.localIdCounter = 0;
|
|
142
|
+
return saved;
|
|
143
|
+
}
|
|
144
|
+
function popComponentScope(saved) {
|
|
145
|
+
s().localIdCounter = saved;
|
|
146
|
+
}
|
|
147
|
+
function snapshotContext() {
|
|
148
|
+
const st = s();
|
|
149
|
+
return { tree: { ...st.currentTreeContext }, localId: st.localIdCounter };
|
|
150
|
+
}
|
|
151
|
+
function restoreContext(snap) {
|
|
152
|
+
const st = s();
|
|
153
|
+
st.currentTreeContext = { ...snap.tree };
|
|
154
|
+
st.localIdCounter = snap.localId;
|
|
155
|
+
}
|
|
156
|
+
function getTreeId() {
|
|
157
|
+
const { id, overflow, bits } = s().currentTreeContext;
|
|
158
|
+
return bits > 0 ? overflow + id.toString(32) : overflow;
|
|
159
|
+
}
|
|
160
|
+
function makeId() {
|
|
161
|
+
const st = s();
|
|
162
|
+
const treeId = getTreeId();
|
|
163
|
+
const n = st.localIdCounter++;
|
|
164
|
+
let id = ":" + st.idPrefix + "R";
|
|
165
|
+
if (treeId.length > 0)
|
|
166
|
+
id += treeId;
|
|
167
|
+
id += ":";
|
|
168
|
+
if (n > 0)
|
|
169
|
+
id += "H" + n.toString(32) + ":";
|
|
170
|
+
return id;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/slim-react/hooks.ts
|
|
174
|
+
function useState(initialState) {
|
|
175
|
+
const value = typeof initialState === "function" ? initialState() : initialState;
|
|
176
|
+
return [value, () => {
|
|
177
|
+
}];
|
|
178
|
+
}
|
|
179
|
+
function useReducer(_reducer, initialState) {
|
|
180
|
+
return [initialState, () => {
|
|
181
|
+
}];
|
|
182
|
+
}
|
|
183
|
+
function useEffect(_effect, _deps) {
|
|
184
|
+
}
|
|
185
|
+
function useLayoutEffect(_effect, _deps) {
|
|
186
|
+
}
|
|
187
|
+
function useInsertionEffect(_effect, _deps) {
|
|
188
|
+
}
|
|
189
|
+
function useRef(initialValue) {
|
|
190
|
+
return { current: initialValue };
|
|
191
|
+
}
|
|
192
|
+
function useMemo(factory, _deps) {
|
|
193
|
+
return factory();
|
|
194
|
+
}
|
|
195
|
+
function useCallback(callback, _deps) {
|
|
196
|
+
return callback;
|
|
197
|
+
}
|
|
198
|
+
function useId() {
|
|
199
|
+
return makeId();
|
|
200
|
+
}
|
|
201
|
+
function useDebugValue(_value, _format) {
|
|
202
|
+
}
|
|
203
|
+
function useImperativeHandle(_ref, _createHandle, _deps) {
|
|
204
|
+
}
|
|
205
|
+
function useSyncExternalStore(_subscribe, getSnapshot, getServerSnapshot) {
|
|
206
|
+
return (getServerSnapshot || getSnapshot)();
|
|
207
|
+
}
|
|
208
|
+
function useTransition() {
|
|
209
|
+
return [false, (cb) => cb()];
|
|
210
|
+
}
|
|
211
|
+
function useDeferredValue(value) {
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
function useOptimistic(passthrough) {
|
|
215
|
+
return [passthrough, () => {
|
|
216
|
+
}];
|
|
217
|
+
}
|
|
218
|
+
function useFormStatus() {
|
|
219
|
+
return { pending: false, data: null, method: null, action: null };
|
|
220
|
+
}
|
|
221
|
+
function useActionState(_action, initialState, _permalink) {
|
|
222
|
+
return [initialState, () => {
|
|
223
|
+
}, false];
|
|
224
|
+
}
|
|
225
|
+
function use(usable) {
|
|
226
|
+
if (typeof usable === "object" && usable !== null && "_currentValue" in usable) {
|
|
227
|
+
return usable._currentValue;
|
|
228
|
+
}
|
|
229
|
+
const promise = usable;
|
|
230
|
+
if (promise.status === "fulfilled")
|
|
231
|
+
return promise.value;
|
|
232
|
+
if (promise.status === "rejected")
|
|
233
|
+
throw promise.reason;
|
|
234
|
+
throw promise;
|
|
235
|
+
}
|
|
236
|
+
function startTransition(callback) {
|
|
237
|
+
callback();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/slim-react/context.ts
|
|
241
|
+
function createContext(defaultValue) {
|
|
242
|
+
const context = {
|
|
243
|
+
_currentValue: defaultValue,
|
|
244
|
+
Provider: null,
|
|
245
|
+
Consumer: null
|
|
246
|
+
};
|
|
247
|
+
const Provider = function ContextProvider({
|
|
248
|
+
children
|
|
249
|
+
}) {
|
|
250
|
+
return children ?? null;
|
|
251
|
+
};
|
|
252
|
+
Provider._context = context;
|
|
253
|
+
context.Provider = Provider;
|
|
254
|
+
context.Consumer = ({ children }) => {
|
|
255
|
+
return children(
|
|
256
|
+
context._currentValue
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
return context;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/slim-react/render.ts
|
|
263
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
264
|
+
"area",
|
|
265
|
+
"base",
|
|
266
|
+
"br",
|
|
267
|
+
"col",
|
|
268
|
+
"embed",
|
|
269
|
+
"hr",
|
|
270
|
+
"img",
|
|
271
|
+
"input",
|
|
272
|
+
"link",
|
|
273
|
+
"meta",
|
|
274
|
+
"param",
|
|
275
|
+
"source",
|
|
276
|
+
"track",
|
|
277
|
+
"wbr"
|
|
278
|
+
]);
|
|
279
|
+
function escapeHtml(str) {
|
|
280
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
281
|
+
}
|
|
282
|
+
function escapeAttr(str) {
|
|
283
|
+
return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
284
|
+
}
|
|
285
|
+
function styleObjectToString(style) {
|
|
286
|
+
return Object.entries(style).map(([key, value]) => {
|
|
287
|
+
const cssKey = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
288
|
+
return `${cssKey}:${value}`;
|
|
289
|
+
}).join(";");
|
|
290
|
+
}
|
|
291
|
+
var SVG_ATTR_MAP = {
|
|
292
|
+
// Presentation / geometry
|
|
293
|
+
accentHeight: "accent-height",
|
|
294
|
+
alignmentBaseline: "alignment-baseline",
|
|
295
|
+
arabicForm: "arabic-form",
|
|
296
|
+
baselineShift: "baseline-shift",
|
|
297
|
+
capHeight: "cap-height",
|
|
298
|
+
clipPath: "clip-path",
|
|
299
|
+
clipRule: "clip-rule",
|
|
300
|
+
colorInterpolation: "color-interpolation",
|
|
301
|
+
colorInterpolationFilters: "color-interpolation-filters",
|
|
302
|
+
colorProfile: "color-profile",
|
|
303
|
+
dominantBaseline: "dominant-baseline",
|
|
304
|
+
enableBackground: "enable-background",
|
|
305
|
+
fillOpacity: "fill-opacity",
|
|
306
|
+
fillRule: "fill-rule",
|
|
307
|
+
floodColor: "flood-color",
|
|
308
|
+
floodOpacity: "flood-opacity",
|
|
309
|
+
fontFamily: "font-family",
|
|
310
|
+
fontSize: "font-size",
|
|
311
|
+
fontSizeAdjust: "font-size-adjust",
|
|
312
|
+
fontStretch: "font-stretch",
|
|
313
|
+
fontStyle: "font-style",
|
|
314
|
+
fontVariant: "font-variant",
|
|
315
|
+
fontWeight: "font-weight",
|
|
316
|
+
glyphName: "glyph-name",
|
|
317
|
+
glyphOrientationHorizontal: "glyph-orientation-horizontal",
|
|
318
|
+
glyphOrientationVertical: "glyph-orientation-vertical",
|
|
319
|
+
horizAdvX: "horiz-adv-x",
|
|
320
|
+
horizOriginX: "horiz-origin-x",
|
|
321
|
+
imageRendering: "image-rendering",
|
|
322
|
+
letterSpacing: "letter-spacing",
|
|
323
|
+
lightingColor: "lighting-color",
|
|
324
|
+
markerEnd: "marker-end",
|
|
325
|
+
markerMid: "marker-mid",
|
|
326
|
+
markerStart: "marker-start",
|
|
327
|
+
overlinePosition: "overline-position",
|
|
328
|
+
overlineThickness: "overline-thickness",
|
|
329
|
+
paintOrder: "paint-order",
|
|
330
|
+
panose1: "panose-1",
|
|
331
|
+
pointerEvents: "pointer-events",
|
|
332
|
+
renderingIntent: "rendering-intent",
|
|
333
|
+
shapeRendering: "shape-rendering",
|
|
334
|
+
stopColor: "stop-color",
|
|
335
|
+
stopOpacity: "stop-opacity",
|
|
336
|
+
strikethroughPosition: "strikethrough-position",
|
|
337
|
+
strikethroughThickness: "strikethrough-thickness",
|
|
338
|
+
strokeDasharray: "stroke-dasharray",
|
|
339
|
+
strokeDashoffset: "stroke-dashoffset",
|
|
340
|
+
strokeLinecap: "stroke-linecap",
|
|
341
|
+
strokeLinejoin: "stroke-linejoin",
|
|
342
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
343
|
+
strokeOpacity: "stroke-opacity",
|
|
344
|
+
strokeWidth: "stroke-width",
|
|
345
|
+
textAnchor: "text-anchor",
|
|
346
|
+
textDecoration: "text-decoration",
|
|
347
|
+
textRendering: "text-rendering",
|
|
348
|
+
underlinePosition: "underline-position",
|
|
349
|
+
underlineThickness: "underline-thickness",
|
|
350
|
+
unicodeBidi: "unicode-bidi",
|
|
351
|
+
unicodeRange: "unicode-range",
|
|
352
|
+
unitsPerEm: "units-per-em",
|
|
353
|
+
vAlphabetic: "v-alphabetic",
|
|
354
|
+
vHanging: "v-hanging",
|
|
355
|
+
vIdeographic: "v-ideographic",
|
|
356
|
+
vMathematical: "v-mathematical",
|
|
357
|
+
vertAdvY: "vert-adv-y",
|
|
358
|
+
vertOriginX: "vert-origin-x",
|
|
359
|
+
vertOriginY: "vert-origin-y",
|
|
360
|
+
wordSpacing: "word-spacing",
|
|
361
|
+
writingMode: "writing-mode",
|
|
362
|
+
xHeight: "x-height",
|
|
363
|
+
// Namespace-prefixed
|
|
364
|
+
xlinkActuate: "xlink:actuate",
|
|
365
|
+
xlinkArcrole: "xlink:arcrole",
|
|
366
|
+
xlinkHref: "xlink:href",
|
|
367
|
+
xlinkRole: "xlink:role",
|
|
368
|
+
xlinkShow: "xlink:show",
|
|
369
|
+
xlinkTitle: "xlink:title",
|
|
370
|
+
xlinkType: "xlink:type",
|
|
371
|
+
xmlBase: "xml:base",
|
|
372
|
+
xmlLang: "xml:lang",
|
|
373
|
+
xmlSpace: "xml:space",
|
|
374
|
+
xmlns: "xmlns",
|
|
375
|
+
xmlnsXlink: "xmlns:xlink",
|
|
376
|
+
// Filter / lighting
|
|
377
|
+
baseFrequency: "baseFrequency",
|
|
378
|
+
colorInterpolation_filters: "color-interpolation-filters",
|
|
379
|
+
diffuseConstant: "diffuseConstant",
|
|
380
|
+
edgeMode: "edgeMode",
|
|
381
|
+
filterUnits: "filterUnits",
|
|
382
|
+
gradientTransform: "gradientTransform",
|
|
383
|
+
gradientUnits: "gradientUnits",
|
|
384
|
+
kernelMatrix: "kernelMatrix",
|
|
385
|
+
kernelUnitLength: "kernelUnitLength",
|
|
386
|
+
lengthAdjust: "lengthAdjust",
|
|
387
|
+
limitingConeAngle: "limitingConeAngle",
|
|
388
|
+
markerHeight: "markerHeight",
|
|
389
|
+
markerWidth: "markerWidth",
|
|
390
|
+
maskContentUnits: "maskContentUnits",
|
|
391
|
+
maskUnits: "maskUnits",
|
|
392
|
+
numOctaves: "numOctaves",
|
|
393
|
+
pathLength: "pathLength",
|
|
394
|
+
patternContentUnits: "patternContentUnits",
|
|
395
|
+
patternTransform: "patternTransform",
|
|
396
|
+
patternUnits: "patternUnits",
|
|
397
|
+
pointsAtX: "pointsAtX",
|
|
398
|
+
pointsAtY: "pointsAtY",
|
|
399
|
+
pointsAtZ: "pointsAtZ",
|
|
400
|
+
preserveAspectRatio: "preserveAspectRatio",
|
|
401
|
+
primitiveUnits: "primitiveUnits",
|
|
402
|
+
refX: "refX",
|
|
403
|
+
refY: "refY",
|
|
404
|
+
repeatCount: "repeatCount",
|
|
405
|
+
repeatDur: "repeatDur",
|
|
406
|
+
specularConstant: "specularConstant",
|
|
407
|
+
specularExponent: "specularExponent",
|
|
408
|
+
spreadMethod: "spreadMethod",
|
|
409
|
+
startOffset: "startOffset",
|
|
410
|
+
stdDeviation: "stdDeviation",
|
|
411
|
+
stitchTiles: "stitchTiles",
|
|
412
|
+
surfaceScale: "surfaceScale",
|
|
413
|
+
systemLanguage: "systemLanguage",
|
|
414
|
+
tableValues: "tableValues",
|
|
415
|
+
targetX: "targetX",
|
|
416
|
+
targetY: "targetY",
|
|
417
|
+
textLength: "textLength",
|
|
418
|
+
viewBox: "viewBox",
|
|
419
|
+
xChannelSelector: "xChannelSelector",
|
|
420
|
+
yChannelSelector: "yChannelSelector"
|
|
421
|
+
};
|
|
422
|
+
function renderAttributes(props, isSvg) {
|
|
423
|
+
let attrs = "";
|
|
424
|
+
for (const [key, value] of Object.entries(props)) {
|
|
425
|
+
if (key === "children" || key === "key" || key === "ref" || key === "dangerouslySetInnerHTML")
|
|
426
|
+
continue;
|
|
427
|
+
if (key.startsWith("on") && key.length > 2 && key[2] === key[2].toUpperCase())
|
|
428
|
+
continue;
|
|
429
|
+
let attrName;
|
|
430
|
+
if (isSvg && key in SVG_ATTR_MAP) {
|
|
431
|
+
attrName = SVG_ATTR_MAP[key];
|
|
432
|
+
} else {
|
|
433
|
+
attrName = key === "className" ? "class" : key === "htmlFor" ? "for" : key === "tabIndex" ? "tabindex" : key;
|
|
434
|
+
}
|
|
435
|
+
if (value === false || value == null)
|
|
436
|
+
continue;
|
|
437
|
+
if (value === true) {
|
|
438
|
+
attrs += ` ${attrName}`;
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (key === "style" && typeof value === "object") {
|
|
442
|
+
attrs += ` style="${escapeAttr(styleObjectToString(value))}"`;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
attrs += ` ${attrName}="${escapeAttr(String(value))}"`;
|
|
446
|
+
}
|
|
447
|
+
return attrs;
|
|
448
|
+
}
|
|
449
|
+
var BufferWriter = class {
|
|
450
|
+
chunks = [];
|
|
451
|
+
write(chunk) {
|
|
452
|
+
this.chunks.push(chunk);
|
|
453
|
+
}
|
|
454
|
+
flush(target) {
|
|
455
|
+
for (const c of this.chunks)
|
|
456
|
+
target.write(c);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
function renderNode(node, writer, isSvg = false) {
|
|
460
|
+
if (node == null || typeof node === "boolean")
|
|
461
|
+
return;
|
|
462
|
+
if (typeof node === "string") {
|
|
463
|
+
writer.write(escapeHtml(node));
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (typeof node === "number") {
|
|
467
|
+
writer.write(String(node));
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (Array.isArray(node)) {
|
|
471
|
+
return renderChildArray(node, writer, isSvg);
|
|
472
|
+
}
|
|
473
|
+
if (typeof node === "object" && node !== null && Symbol.iterator in node && !("$$typeof" in node)) {
|
|
474
|
+
return renderChildArray(
|
|
475
|
+
Array.from(node),
|
|
476
|
+
writer,
|
|
477
|
+
isSvg
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (typeof node === "object" && node !== null && "$$typeof" in node && node.$$typeof === SLIM_ELEMENT) {
|
|
481
|
+
const element = node;
|
|
482
|
+
const { type, props } = element;
|
|
483
|
+
if (type === FRAGMENT_TYPE) {
|
|
484
|
+
return renderChildren(props.children, writer, isSvg);
|
|
485
|
+
}
|
|
486
|
+
if (type === SUSPENSE_TYPE) {
|
|
487
|
+
return renderSuspense(props, writer, isSvg);
|
|
488
|
+
}
|
|
489
|
+
if (typeof type === "function") {
|
|
490
|
+
return renderComponent(type, props, writer, isSvg);
|
|
491
|
+
}
|
|
492
|
+
if (typeof type === "string") {
|
|
493
|
+
return renderHostElement(type, props, writer, isSvg);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function renderHostElement(tag, props, writer, isSvg) {
|
|
498
|
+
const enteringSvg = tag === "svg";
|
|
499
|
+
const childSvg = isSvg || enteringSvg;
|
|
500
|
+
const effectiveProps = enteringSvg && !props.xmlns ? { xmlns: "http://www.w3.org/2000/svg", ...props } : props;
|
|
501
|
+
writer.write(`<${tag}${renderAttributes(effectiveProps, childSvg)}>`);
|
|
502
|
+
const childContext = tag === "foreignObject" ? false : childSvg;
|
|
503
|
+
let inner = void 0;
|
|
504
|
+
if (props.dangerouslySetInnerHTML) {
|
|
505
|
+
writer.write(props.dangerouslySetInnerHTML.__html);
|
|
506
|
+
} else {
|
|
507
|
+
inner = renderChildren(props.children, writer, childContext);
|
|
508
|
+
}
|
|
509
|
+
if (inner && typeof inner.then === "function") {
|
|
510
|
+
return inner.then(() => {
|
|
511
|
+
if (!VOID_ELEMENTS.has(tag))
|
|
512
|
+
writer.write(`</${tag}>`);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
if (!VOID_ELEMENTS.has(tag))
|
|
516
|
+
writer.write(`</${tag}>`);
|
|
517
|
+
}
|
|
518
|
+
var REACT_MEMO = Symbol.for("react.memo");
|
|
519
|
+
var REACT_FORWARD_REF = Symbol.for("react.forward_ref");
|
|
520
|
+
var REACT_PROVIDER = Symbol.for("react.provider");
|
|
521
|
+
var REACT_CONTEXT = Symbol.for("react.context");
|
|
522
|
+
function renderComponent(type, props, writer, isSvg) {
|
|
523
|
+
const typeOf = type?.$$typeof;
|
|
524
|
+
if (typeOf === REACT_MEMO) {
|
|
525
|
+
return renderNode(
|
|
526
|
+
{ $$typeof: SLIM_ELEMENT, type: type.type, props, key: null },
|
|
527
|
+
writer,
|
|
528
|
+
isSvg
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
if (typeOf === REACT_FORWARD_REF) {
|
|
532
|
+
return renderComponent(type.render, props, writer, isSvg);
|
|
533
|
+
}
|
|
534
|
+
const isProvider = "_context" in type || typeOf === REACT_PROVIDER || typeOf === REACT_CONTEXT && "value" in props;
|
|
535
|
+
let prevCtxValue;
|
|
536
|
+
let ctx;
|
|
537
|
+
if (isProvider) {
|
|
538
|
+
ctx = type._context ?? type;
|
|
539
|
+
prevCtxValue = ctx._currentValue;
|
|
540
|
+
ctx._currentValue = props.value;
|
|
541
|
+
}
|
|
542
|
+
const savedScope = pushComponentScope();
|
|
543
|
+
let result;
|
|
544
|
+
try {
|
|
545
|
+
if (type.prototype && typeof type.prototype.render === "function") {
|
|
546
|
+
const instance = new type(props);
|
|
547
|
+
result = instance.render();
|
|
548
|
+
} else {
|
|
549
|
+
result = type(props);
|
|
550
|
+
}
|
|
551
|
+
} catch (e) {
|
|
552
|
+
popComponentScope(savedScope);
|
|
553
|
+
if (isProvider)
|
|
554
|
+
ctx._currentValue = prevCtxValue;
|
|
555
|
+
throw e;
|
|
556
|
+
}
|
|
557
|
+
const finish = () => {
|
|
558
|
+
popComponentScope(savedScope);
|
|
559
|
+
if (isProvider)
|
|
560
|
+
ctx._currentValue = prevCtxValue;
|
|
561
|
+
};
|
|
562
|
+
if (result instanceof Promise) {
|
|
563
|
+
return result.then((resolved) => {
|
|
564
|
+
const r2 = renderNode(resolved, writer, isSvg);
|
|
565
|
+
if (r2 && typeof r2.then === "function") {
|
|
566
|
+
return r2.then(finish);
|
|
567
|
+
}
|
|
568
|
+
finish();
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const r = renderNode(result, writer, isSvg);
|
|
572
|
+
if (r && typeof r.then === "function") {
|
|
573
|
+
return r.then(finish);
|
|
574
|
+
}
|
|
575
|
+
finish();
|
|
576
|
+
}
|
|
577
|
+
function isTextLike(node) {
|
|
578
|
+
return typeof node === "string" || typeof node === "number";
|
|
579
|
+
}
|
|
580
|
+
function renderChildArray(children, writer, isSvg) {
|
|
581
|
+
const totalChildren = children.length;
|
|
582
|
+
for (let i = 0; i < totalChildren; i++) {
|
|
583
|
+
if (i > 0 && isTextLike(children[i]) && isTextLike(children[i - 1])) {
|
|
584
|
+
writer.write("<!-- -->");
|
|
585
|
+
}
|
|
586
|
+
const savedTree = pushTreeContext(totalChildren, i);
|
|
587
|
+
const r = renderNode(children[i], writer, isSvg);
|
|
588
|
+
if (r && typeof r.then === "function") {
|
|
589
|
+
return r.then(() => {
|
|
590
|
+
popTreeContext(savedTree);
|
|
591
|
+
return renderChildArrayFrom(children, i + 1, writer, isSvg);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
popTreeContext(savedTree);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function renderChildArrayFrom(children, startIndex, writer, isSvg) {
|
|
598
|
+
const totalChildren = children.length;
|
|
599
|
+
for (let i = startIndex; i < totalChildren; i++) {
|
|
600
|
+
if (i > 0 && isTextLike(children[i]) && isTextLike(children[i - 1])) {
|
|
601
|
+
writer.write("<!-- -->");
|
|
602
|
+
}
|
|
603
|
+
const savedTree = pushTreeContext(totalChildren, i);
|
|
604
|
+
const r = renderNode(children[i], writer, isSvg);
|
|
605
|
+
if (r && typeof r.then === "function") {
|
|
606
|
+
return r.then(() => {
|
|
607
|
+
popTreeContext(savedTree);
|
|
608
|
+
return renderChildArrayFrom(children, i + 1, writer, isSvg);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
popTreeContext(savedTree);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function renderChildren(children, writer, isSvg = false) {
|
|
615
|
+
if (children == null)
|
|
616
|
+
return;
|
|
617
|
+
if (Array.isArray(children)) {
|
|
618
|
+
return renderChildArray(children, writer, isSvg);
|
|
619
|
+
}
|
|
620
|
+
return renderNode(children, writer, isSvg);
|
|
621
|
+
}
|
|
622
|
+
var MAX_SUSPENSE_RETRIES = 25;
|
|
623
|
+
async function renderSuspense(props, writer, isSvg = false) {
|
|
624
|
+
const { children, fallback } = props;
|
|
625
|
+
let attempts = 0;
|
|
626
|
+
const snap = snapshotContext();
|
|
627
|
+
while (attempts < MAX_SUSPENSE_RETRIES) {
|
|
628
|
+
restoreContext(snap);
|
|
629
|
+
try {
|
|
630
|
+
const buffer = new BufferWriter();
|
|
631
|
+
const r = renderNode(children, buffer, isSvg);
|
|
632
|
+
if (r && typeof r.then === "function") {
|
|
633
|
+
await r;
|
|
634
|
+
}
|
|
635
|
+
writer.write("<!--$-->");
|
|
636
|
+
buffer.flush(writer);
|
|
637
|
+
writer.write("<!--/$-->");
|
|
638
|
+
return;
|
|
639
|
+
} catch (error) {
|
|
640
|
+
if (error && typeof error.then === "function") {
|
|
641
|
+
await error;
|
|
642
|
+
attempts++;
|
|
643
|
+
} else {
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
restoreContext(snap);
|
|
649
|
+
writer.write("<!--$?-->");
|
|
650
|
+
if (fallback) {
|
|
651
|
+
const r = renderNode(fallback, writer, isSvg);
|
|
652
|
+
if (r && typeof r.then === "function")
|
|
653
|
+
await r;
|
|
654
|
+
}
|
|
655
|
+
writer.write("<!--/$-->");
|
|
656
|
+
}
|
|
657
|
+
function renderToStream(element) {
|
|
658
|
+
const encoder = new TextEncoder();
|
|
659
|
+
return new ReadableStream({
|
|
660
|
+
async start(controller) {
|
|
661
|
+
resetRenderState();
|
|
662
|
+
const writer = {
|
|
663
|
+
write(chunk) {
|
|
664
|
+
controller.enqueue(encoder.encode(chunk));
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
try {
|
|
668
|
+
const r = renderNode(element, writer);
|
|
669
|
+
if (r && typeof r.then === "function")
|
|
670
|
+
await r;
|
|
671
|
+
controller.close();
|
|
672
|
+
} catch (error) {
|
|
673
|
+
controller.error(error);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
async function renderToString(element) {
|
|
679
|
+
for (let attempt = 0; attempt < MAX_SUSPENSE_RETRIES; attempt++) {
|
|
680
|
+
resetRenderState();
|
|
681
|
+
const chunks = [];
|
|
682
|
+
const writer = { write(c) {
|
|
683
|
+
chunks.push(c);
|
|
684
|
+
} };
|
|
685
|
+
try {
|
|
686
|
+
const r = renderNode(element, writer);
|
|
687
|
+
if (r && typeof r.then === "function")
|
|
688
|
+
await r;
|
|
689
|
+
return chunks.join("");
|
|
690
|
+
} catch (error) {
|
|
691
|
+
if (error && typeof error.then === "function") {
|
|
692
|
+
await error;
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
throw error;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
throw new Error("[slim-react] renderToString exceeded maximum retries");
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/slim-react/index.ts
|
|
702
|
+
function useContext(context) {
|
|
703
|
+
return context._currentValue;
|
|
704
|
+
}
|
|
705
|
+
var Suspense = SUSPENSE_TYPE;
|
|
706
|
+
function isValidElement(obj) {
|
|
707
|
+
return typeof obj === "object" && obj !== null && obj.$$typeof === SLIM_ELEMENT;
|
|
708
|
+
}
|
|
709
|
+
function cloneElement(element, overrideProps, ...children) {
|
|
710
|
+
return {
|
|
711
|
+
$$typeof: SLIM_ELEMENT,
|
|
712
|
+
type: element.type,
|
|
713
|
+
props: {
|
|
714
|
+
...element.props,
|
|
715
|
+
...overrideProps,
|
|
716
|
+
...children.length === 1 ? { children: children[0] } : children.length > 1 ? { children } : {}
|
|
717
|
+
},
|
|
718
|
+
key: overrideProps?.key ?? element.key
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
function forwardRef(render) {
|
|
722
|
+
const component = (props) => render(props, props.ref ?? null);
|
|
723
|
+
component.displayName = render.displayName || render.name || "ForwardRef";
|
|
724
|
+
return component;
|
|
725
|
+
}
|
|
726
|
+
function memo(component) {
|
|
727
|
+
return component;
|
|
728
|
+
}
|
|
729
|
+
function lazy(factory) {
|
|
730
|
+
let resolved = null;
|
|
731
|
+
let promise = null;
|
|
732
|
+
return function LazyComponent(props) {
|
|
733
|
+
if (resolved)
|
|
734
|
+
return resolved(props);
|
|
735
|
+
if (!promise) {
|
|
736
|
+
promise = factory().then((mod) => {
|
|
737
|
+
resolved = mod.default;
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
throw promise;
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function toFlatArray(children) {
|
|
744
|
+
if (children == null || typeof children === "boolean")
|
|
745
|
+
return [];
|
|
746
|
+
if (Array.isArray(children))
|
|
747
|
+
return children.flatMap(toFlatArray);
|
|
748
|
+
return [children];
|
|
749
|
+
}
|
|
750
|
+
var Children = {
|
|
751
|
+
map(children, fn) {
|
|
752
|
+
return toFlatArray(children).map((child, i) => fn(child, i));
|
|
753
|
+
},
|
|
754
|
+
forEach(children, fn) {
|
|
755
|
+
toFlatArray(children).forEach((child, i) => fn(child, i));
|
|
756
|
+
},
|
|
757
|
+
count(children) {
|
|
758
|
+
return toFlatArray(children).length;
|
|
759
|
+
},
|
|
760
|
+
only(children) {
|
|
761
|
+
const arr = toFlatArray(children);
|
|
762
|
+
if (arr.length !== 1)
|
|
763
|
+
throw new Error("Children.only expected one child");
|
|
764
|
+
return arr[0];
|
|
765
|
+
},
|
|
766
|
+
toArray: toFlatArray
|
|
767
|
+
};
|
|
768
|
+
var Component = class {
|
|
769
|
+
props;
|
|
770
|
+
state;
|
|
771
|
+
context;
|
|
772
|
+
constructor(props) {
|
|
773
|
+
this.props = props;
|
|
774
|
+
this.state = {};
|
|
775
|
+
}
|
|
776
|
+
setState(_partial) {
|
|
777
|
+
}
|
|
778
|
+
forceUpdate() {
|
|
779
|
+
}
|
|
780
|
+
render() {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
var PureComponent = class extends Component {
|
|
785
|
+
};
|
|
786
|
+
var React = {
|
|
787
|
+
// Hooks
|
|
788
|
+
useState,
|
|
789
|
+
useReducer,
|
|
790
|
+
useEffect,
|
|
791
|
+
useLayoutEffect,
|
|
792
|
+
useInsertionEffect,
|
|
793
|
+
useRef,
|
|
794
|
+
useMemo,
|
|
795
|
+
useCallback,
|
|
796
|
+
useId,
|
|
797
|
+
useDebugValue,
|
|
798
|
+
useImperativeHandle,
|
|
799
|
+
useSyncExternalStore,
|
|
800
|
+
useTransition,
|
|
801
|
+
useDeferredValue,
|
|
802
|
+
useOptimistic,
|
|
803
|
+
useFormStatus,
|
|
804
|
+
useActionState,
|
|
805
|
+
use,
|
|
806
|
+
startTransition,
|
|
807
|
+
// Context
|
|
808
|
+
createContext,
|
|
809
|
+
useContext,
|
|
810
|
+
// Elements
|
|
811
|
+
createElement,
|
|
812
|
+
cloneElement,
|
|
813
|
+
isValidElement,
|
|
814
|
+
forwardRef,
|
|
815
|
+
memo,
|
|
816
|
+
lazy,
|
|
817
|
+
Fragment,
|
|
818
|
+
Suspense,
|
|
819
|
+
// Compat
|
|
820
|
+
Children,
|
|
821
|
+
Component,
|
|
822
|
+
PureComponent,
|
|
823
|
+
// Rendering
|
|
824
|
+
renderToStream,
|
|
825
|
+
renderToString,
|
|
826
|
+
renderToReadableStream: renderToStream,
|
|
827
|
+
// Version stub
|
|
828
|
+
version: "19.0.0-slim"
|
|
829
|
+
};
|
|
830
|
+
var slim_react_default = React;
|
|
831
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
832
|
+
0 && (module.exports = {
|
|
833
|
+
Children,
|
|
834
|
+
Component,
|
|
835
|
+
FRAGMENT_TYPE,
|
|
836
|
+
Fragment,
|
|
837
|
+
PureComponent,
|
|
838
|
+
SLIM_ELEMENT,
|
|
839
|
+
SUSPENSE_TYPE,
|
|
840
|
+
Suspense,
|
|
841
|
+
cloneElement,
|
|
842
|
+
createContext,
|
|
843
|
+
createElement,
|
|
844
|
+
forwardRef,
|
|
845
|
+
isValidElement,
|
|
846
|
+
jsx,
|
|
847
|
+
jsxDEV,
|
|
848
|
+
jsxs,
|
|
849
|
+
lazy,
|
|
850
|
+
memo,
|
|
851
|
+
renderToReadableStream,
|
|
852
|
+
renderToStream,
|
|
853
|
+
renderToString,
|
|
854
|
+
startTransition,
|
|
855
|
+
use,
|
|
856
|
+
useActionState,
|
|
857
|
+
useCallback,
|
|
858
|
+
useContext,
|
|
859
|
+
useDebugValue,
|
|
860
|
+
useDeferredValue,
|
|
861
|
+
useEffect,
|
|
862
|
+
useFormStatus,
|
|
863
|
+
useId,
|
|
864
|
+
useImperativeHandle,
|
|
865
|
+
useInsertionEffect,
|
|
866
|
+
useLayoutEffect,
|
|
867
|
+
useMemo,
|
|
868
|
+
useOptimistic,
|
|
869
|
+
useReducer,
|
|
870
|
+
useRef,
|
|
871
|
+
useState,
|
|
872
|
+
useSyncExternalStore,
|
|
873
|
+
useTransition
|
|
874
|
+
});
|