baraqex 1.0.43 → 1.0.44
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/bin/baraqex.js +1 -1
- package/dist/browser.js +137 -782
- package/dist/browser.js.map +4 -4
- package/dist/index.js +214 -883
- package/dist/index.js.map +4 -4
- package/dist/server/index.js +79 -214
- package/dist/server/index.js.map +4 -4
- package/package.json +2 -2
- package/templates/ssr-template/index.html +35 -0
- package/templates/ssr-template/package-lock.json +2664 -445
- package/templates/ssr-template/package.json +20 -14
- package/templates/ssr-template/src/App.tsx +65 -42
- package/templates/ssr-template/src/client.tsx +2 -10
- package/templates/ssr-template/src/server.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -15,84 +15,7 @@ var __export = (target, all) => {
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
// node_modules/frontend-hamroun/dist/index.
|
|
19
|
-
function jsx(type, props) {
|
|
20
|
-
console.log("JSX Transform:", { type, props });
|
|
21
|
-
const processedProps = { ...props };
|
|
22
|
-
if (arguments.length > 2) {
|
|
23
|
-
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
|
24
|
-
}
|
|
25
|
-
return { type, props: processedProps };
|
|
26
|
-
}
|
|
27
|
-
async function createElement(vnode) {
|
|
28
|
-
console.log("Creating element from:", vnode);
|
|
29
|
-
if (vnode == null) {
|
|
30
|
-
return document.createTextNode("");
|
|
31
|
-
}
|
|
32
|
-
if (typeof vnode === "boolean") {
|
|
33
|
-
return document.createTextNode("");
|
|
34
|
-
}
|
|
35
|
-
if (typeof vnode === "number" || typeof vnode === "string") {
|
|
36
|
-
return document.createTextNode(String(vnode));
|
|
37
|
-
}
|
|
38
|
-
if (Array.isArray(vnode)) {
|
|
39
|
-
const fragment = document.createDocumentFragment();
|
|
40
|
-
for (const child of vnode) {
|
|
41
|
-
const node = await createElement(child);
|
|
42
|
-
fragment.appendChild(node);
|
|
43
|
-
}
|
|
44
|
-
return fragment;
|
|
45
|
-
}
|
|
46
|
-
if ("type" in vnode && vnode.props !== void 0) {
|
|
47
|
-
const { type, props } = vnode;
|
|
48
|
-
if (typeof type === "function") {
|
|
49
|
-
try {
|
|
50
|
-
const result = await type(props || {});
|
|
51
|
-
const node = await createElement(result);
|
|
52
|
-
if (node instanceof Element) {
|
|
53
|
-
node.setAttribute("data-component-id", type.name || type.toString());
|
|
54
|
-
}
|
|
55
|
-
return node;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error("Error rendering component:", error);
|
|
58
|
-
return document.createTextNode("");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const element = document.createElement(type);
|
|
62
|
-
for (const [key, value] of Object.entries(props || {})) {
|
|
63
|
-
if (key === "children")
|
|
64
|
-
continue;
|
|
65
|
-
if (key.startsWith("on") && typeof value === "function") {
|
|
66
|
-
const eventName = key.toLowerCase().slice(2);
|
|
67
|
-
const existingHandler = element.__events?.[eventName];
|
|
68
|
-
if (existingHandler) {
|
|
69
|
-
element.removeEventListener(eventName, existingHandler);
|
|
70
|
-
}
|
|
71
|
-
element.addEventListener(eventName, value);
|
|
72
|
-
if (!element.__events) {
|
|
73
|
-
element.__events = {};
|
|
74
|
-
}
|
|
75
|
-
element.__events[eventName] = value;
|
|
76
|
-
} else if (key === "style" && typeof value === "object") {
|
|
77
|
-
Object.assign(element.style, value);
|
|
78
|
-
} else if (key === "className") {
|
|
79
|
-
element.setAttribute("class", String(value));
|
|
80
|
-
} else if (key !== "key" && key !== "ref") {
|
|
81
|
-
element.setAttribute(key, String(value));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const children = props?.children;
|
|
85
|
-
if (children != null) {
|
|
86
|
-
const childArray = Array.isArray(children) ? children.flat() : [children];
|
|
87
|
-
for (const child of childArray) {
|
|
88
|
-
const childNode = await createElement(child);
|
|
89
|
-
element.appendChild(childNode);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return element;
|
|
93
|
-
}
|
|
94
|
-
return document.createTextNode(String(vnode));
|
|
95
|
-
}
|
|
18
|
+
// node_modules/frontend-hamroun/dist/index.mjs
|
|
96
19
|
function batchUpdates(fn) {
|
|
97
20
|
if (isBatching) {
|
|
98
21
|
queue.push(fn);
|
|
@@ -103,65 +26,57 @@ function batchUpdates(fn) {
|
|
|
103
26
|
fn();
|
|
104
27
|
while (queue.length > 0) {
|
|
105
28
|
const nextFn = queue.shift();
|
|
106
|
-
nextFn
|
|
29
|
+
nextFn == null ? void 0 : nextFn();
|
|
107
30
|
}
|
|
108
31
|
} finally {
|
|
109
32
|
isBatching = false;
|
|
110
33
|
}
|
|
111
34
|
}
|
|
112
|
-
function createContext(defaultValue) {
|
|
113
|
-
const contextId = Symbol("context");
|
|
114
|
-
const Provider = ({ value, children }) => {
|
|
115
|
-
contexts.set(contextId, value);
|
|
116
|
-
return children;
|
|
117
|
-
};
|
|
118
|
-
const Consumer = ({ children }) => {
|
|
119
|
-
const value = contexts.get(contextId) ?? defaultValue;
|
|
120
|
-
return children(value);
|
|
121
|
-
};
|
|
122
|
-
const context = {
|
|
123
|
-
Provider,
|
|
124
|
-
Consumer,
|
|
125
|
-
displayName: "Context"
|
|
126
|
-
};
|
|
127
|
-
return context;
|
|
128
|
-
}
|
|
129
|
-
function useContext(context) {
|
|
130
|
-
return {};
|
|
131
|
-
}
|
|
132
35
|
function setRenderCallback(callback, element, container) {
|
|
133
36
|
globalRenderCallback = callback;
|
|
134
37
|
globalContainer = container;
|
|
135
38
|
currentElement = element;
|
|
136
39
|
}
|
|
137
|
-
function prepareRender(
|
|
40
|
+
function prepareRender() {
|
|
138
41
|
currentRender++;
|
|
139
|
-
isSSR = isServerSideRender;
|
|
140
42
|
stateIndices.set(currentRender, 0);
|
|
141
|
-
if (!states.has(currentRender)) {
|
|
142
|
-
states.set(currentRender, []);
|
|
143
|
-
}
|
|
144
43
|
return currentRender;
|
|
145
44
|
}
|
|
146
45
|
function finishRender() {
|
|
46
|
+
if (isServer) {
|
|
47
|
+
serverStates.delete(currentRender);
|
|
48
|
+
}
|
|
49
|
+
currentRender = 0;
|
|
147
50
|
}
|
|
148
51
|
function useState(initial) {
|
|
149
52
|
if (!currentRender) {
|
|
150
53
|
throw new Error("useState must be called within a render");
|
|
151
54
|
}
|
|
55
|
+
if (isServer) {
|
|
56
|
+
if (!serverStates.has(currentRender)) {
|
|
57
|
+
serverStates.set(currentRender, /* @__PURE__ */ new Map());
|
|
58
|
+
}
|
|
59
|
+
const componentState = serverStates.get(currentRender);
|
|
60
|
+
const index2 = stateIndices.get(currentRender) || 0;
|
|
61
|
+
if (!componentState.has(index2)) {
|
|
62
|
+
componentState.set(index2, initial);
|
|
63
|
+
}
|
|
64
|
+
const state2 = componentState.get(index2);
|
|
65
|
+
const setState2 = (newValue) => {
|
|
66
|
+
};
|
|
67
|
+
stateIndices.set(currentRender, index2 + 1);
|
|
68
|
+
return [state2, setState2];
|
|
69
|
+
}
|
|
152
70
|
if (!states.has(currentRender)) {
|
|
153
71
|
states.set(currentRender, []);
|
|
154
72
|
}
|
|
155
73
|
const componentStates = states.get(currentRender);
|
|
156
|
-
const index = stateIndices.get(currentRender)
|
|
74
|
+
const index = stateIndices.get(currentRender);
|
|
157
75
|
if (index >= componentStates.length) {
|
|
158
76
|
componentStates.push(initial);
|
|
159
77
|
}
|
|
160
78
|
const state = componentStates[index];
|
|
161
79
|
const setState = (newValue) => {
|
|
162
|
-
if (isSSR) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
80
|
const nextValue = typeof newValue === "function" ? newValue(componentStates[index]) : newValue;
|
|
166
81
|
if (componentStates[index] === nextValue)
|
|
167
82
|
return;
|
|
@@ -178,24 +93,19 @@ function useState(initial) {
|
|
|
178
93
|
function useEffect(callback, deps) {
|
|
179
94
|
if (!currentRender)
|
|
180
95
|
throw new Error("useEffect must be called within a render");
|
|
181
|
-
|
|
182
|
-
const effectIndex2 = stateIndices.get(currentRender) || 0;
|
|
183
|
-
stateIndices.set(currentRender, effectIndex2 + 1);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const effectIndex = stateIndices.get(currentRender) || 0;
|
|
96
|
+
const effectIndex = stateIndices.get(currentRender);
|
|
187
97
|
if (!effects.has(currentRender)) {
|
|
188
98
|
effects.set(currentRender, []);
|
|
189
99
|
}
|
|
190
100
|
const componentEffects = effects.get(currentRender);
|
|
191
101
|
const prevEffect = componentEffects[effectIndex];
|
|
192
102
|
if (!prevEffect || !deps || !prevEffect.deps || deps.some((dep, i) => dep !== prevEffect.deps[i])) {
|
|
193
|
-
if (prevEffect
|
|
103
|
+
if (prevEffect == null ? void 0 : prevEffect.cleanup) {
|
|
194
104
|
prevEffect.cleanup();
|
|
195
105
|
}
|
|
196
106
|
queueMicrotask(() => {
|
|
197
107
|
const cleanup = callback() || void 0;
|
|
198
|
-
componentEffects[effectIndex] = { cleanup, deps
|
|
108
|
+
componentEffects[effectIndex] = { cleanup, deps };
|
|
199
109
|
});
|
|
200
110
|
}
|
|
201
111
|
stateIndices.set(currentRender, effectIndex + 1);
|
|
@@ -203,7 +113,7 @@ function useEffect(callback, deps) {
|
|
|
203
113
|
function useMemo(factory, deps) {
|
|
204
114
|
if (!currentRender)
|
|
205
115
|
throw new Error("useMemo must be called within a render");
|
|
206
|
-
const memoIndex = stateIndices.get(currentRender)
|
|
116
|
+
const memoIndex = stateIndices.get(currentRender);
|
|
207
117
|
if (!memos.has(currentRender)) {
|
|
208
118
|
memos.set(currentRender, []);
|
|
209
119
|
}
|
|
@@ -211,7 +121,7 @@ function useMemo(factory, deps) {
|
|
|
211
121
|
const prevMemo = componentMemos[memoIndex];
|
|
212
122
|
if (!prevMemo || deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i]))) {
|
|
213
123
|
const value = factory();
|
|
214
|
-
componentMemos[memoIndex] = { value, deps
|
|
124
|
+
componentMemos[memoIndex] = { value, deps };
|
|
215
125
|
stateIndices.set(currentRender, memoIndex + 1);
|
|
216
126
|
return value;
|
|
217
127
|
}
|
|
@@ -221,7 +131,7 @@ function useMemo(factory, deps) {
|
|
|
221
131
|
function useRef(initial) {
|
|
222
132
|
if (!currentRender)
|
|
223
133
|
throw new Error("useRef must be called within a render");
|
|
224
|
-
const refIndex = stateIndices.get(currentRender)
|
|
134
|
+
const refIndex = stateIndices.get(currentRender);
|
|
225
135
|
if (!refs.has(currentRender)) {
|
|
226
136
|
refs.set(currentRender, []);
|
|
227
137
|
}
|
|
@@ -238,9 +148,6 @@ function useRef(initial) {
|
|
|
238
148
|
}
|
|
239
149
|
async function rerender(rendererId) {
|
|
240
150
|
try {
|
|
241
|
-
if (isSSR) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
151
|
const componentEffects = effects.get(rendererId);
|
|
245
152
|
if (componentEffects) {
|
|
246
153
|
componentEffects.forEach((effect) => {
|
|
@@ -260,619 +167,211 @@ function useErrorBoundary() {
|
|
|
260
167
|
const [error, setError] = useState(null);
|
|
261
168
|
return [error, () => setError(null)];
|
|
262
169
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
170
|
+
function createContext(defaultValue) {
|
|
171
|
+
const context = {
|
|
172
|
+
Provider: ({ value, children }) => {
|
|
173
|
+
return children;
|
|
174
|
+
},
|
|
175
|
+
Consumer: ({ children }) => {
|
|
176
|
+
return children(defaultValue);
|
|
177
|
+
},
|
|
178
|
+
_id: Symbol(),
|
|
179
|
+
useSelector: (selector) => {
|
|
180
|
+
return selector(defaultValue);
|
|
274
181
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.log("Render completed successfully");
|
|
278
|
-
} catch (error) {
|
|
279
|
-
console.error("Error during render:", error);
|
|
280
|
-
throw error;
|
|
281
|
-
}
|
|
182
|
+
};
|
|
183
|
+
return context;
|
|
282
184
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
console.log("Starting hydration...");
|
|
286
|
-
await render(element, container);
|
|
287
|
-
console.log("Hydration completed successfully");
|
|
288
|
-
} catch (error) {
|
|
289
|
-
console.error("Error during hydration:", error);
|
|
290
|
-
throw error;
|
|
291
|
-
}
|
|
185
|
+
function useContext(context) {
|
|
186
|
+
return context;
|
|
292
187
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
} finally {
|
|
188
|
+
function jsx(type, props) {
|
|
189
|
+
console.log("JSX Transform:", { type, props });
|
|
190
|
+
const processedProps = { ...props };
|
|
191
|
+
if (arguments.length > 2) {
|
|
192
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
|
299
193
|
}
|
|
194
|
+
return { type, props: processedProps };
|
|
300
195
|
}
|
|
301
|
-
async function
|
|
302
|
-
|
|
303
|
-
|
|
196
|
+
async function createElement(vnode) {
|
|
197
|
+
var _a;
|
|
198
|
+
console.log("Creating element from:", vnode);
|
|
199
|
+
if (vnode == null) {
|
|
200
|
+
return document.createTextNode("");
|
|
304
201
|
}
|
|
305
|
-
if (typeof
|
|
306
|
-
return
|
|
202
|
+
if (typeof vnode === "boolean") {
|
|
203
|
+
return document.createTextNode("");
|
|
307
204
|
}
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
return results.join("");
|
|
205
|
+
if (typeof vnode === "number" || typeof vnode === "string") {
|
|
206
|
+
return document.createTextNode(String(vnode));
|
|
311
207
|
}
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
208
|
+
if (Array.isArray(vnode)) {
|
|
209
|
+
const fragment = document.createDocumentFragment();
|
|
210
|
+
for (const child of vnode) {
|
|
211
|
+
const node = await createElement(child);
|
|
212
|
+
fragment.appendChild(node);
|
|
213
|
+
}
|
|
214
|
+
return fragment;
|
|
215
|
+
}
|
|
216
|
+
if ("type" in vnode && vnode.props !== void 0) {
|
|
217
|
+
const { type, props } = vnode;
|
|
314
218
|
if (typeof type === "function") {
|
|
315
219
|
try {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} finally {
|
|
321
|
-
finishRender();
|
|
220
|
+
const result = await type(props || {});
|
|
221
|
+
const node = await createElement(result);
|
|
222
|
+
if (node instanceof Element) {
|
|
223
|
+
node.setAttribute("data-component-id", type.name || type.toString());
|
|
322
224
|
}
|
|
225
|
+
return node;
|
|
323
226
|
} catch (error) {
|
|
324
227
|
console.error("Error rendering component:", error);
|
|
325
|
-
return
|
|
228
|
+
return document.createTextNode("");
|
|
326
229
|
}
|
|
327
230
|
}
|
|
328
|
-
|
|
329
|
-
|
|
231
|
+
const element = document.createElement(type);
|
|
232
|
+
for (const [key, value] of Object.entries(props || {})) {
|
|
233
|
+
if (key === "children")
|
|
234
|
+
continue;
|
|
235
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
236
|
+
const eventName = key.toLowerCase().slice(2);
|
|
237
|
+
const existingHandler = (_a = element.__events) == null ? void 0 : _a[eventName];
|
|
238
|
+
if (existingHandler) {
|
|
239
|
+
element.removeEventListener(eventName, existingHandler);
|
|
240
|
+
}
|
|
241
|
+
element.addEventListener(eventName, value);
|
|
242
|
+
if (!element.__events) {
|
|
243
|
+
element.__events = {};
|
|
244
|
+
}
|
|
245
|
+
element.__events[eventName] = value;
|
|
246
|
+
} else if (key === "style" && typeof value === "object") {
|
|
247
|
+
Object.assign(element.style, value);
|
|
248
|
+
} else if (key === "className") {
|
|
249
|
+
element.setAttribute("class", String(value));
|
|
250
|
+
} else if (key !== "key" && key !== "ref") {
|
|
251
|
+
element.setAttribute(key, String(value));
|
|
252
|
+
}
|
|
330
253
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const { children, ...attrs } = props;
|
|
339
|
-
const voidElements = /* @__PURE__ */ new Set([
|
|
340
|
-
"area",
|
|
341
|
-
"base",
|
|
342
|
-
"br",
|
|
343
|
-
"col",
|
|
344
|
-
"embed",
|
|
345
|
-
"hr",
|
|
346
|
-
"img",
|
|
347
|
-
"input",
|
|
348
|
-
"link",
|
|
349
|
-
"meta",
|
|
350
|
-
"param",
|
|
351
|
-
"source",
|
|
352
|
-
"track",
|
|
353
|
-
"wbr"
|
|
354
|
-
]);
|
|
355
|
-
const attributeString = Object.entries(attrs).filter(([key, value]) => {
|
|
356
|
-
if (key.startsWith("on") || key === "key" || key === "ref")
|
|
357
|
-
return false;
|
|
358
|
-
if (value == null || value === false)
|
|
359
|
-
return false;
|
|
360
|
-
return true;
|
|
361
|
-
}).map(([key, value]) => {
|
|
362
|
-
if (key === "className")
|
|
363
|
-
key = "class";
|
|
364
|
-
if (value === true)
|
|
365
|
-
return key;
|
|
366
|
-
if (key === "style" && typeof value === "object" && value !== null) {
|
|
367
|
-
const styleString = Object.entries(value).map(([prop, val]) => `${kebabCase(prop)}:${val}`).join(";");
|
|
368
|
-
return `style="${escapeHtml(styleString)}"`;
|
|
254
|
+
const children = props == null ? void 0 : props.children;
|
|
255
|
+
if (children != null) {
|
|
256
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
|
257
|
+
for (const child of childArray) {
|
|
258
|
+
const childNode = await createElement(child);
|
|
259
|
+
element.appendChild(childNode);
|
|
260
|
+
}
|
|
369
261
|
}
|
|
370
|
-
return
|
|
371
|
-
}).join(" ");
|
|
372
|
-
const openTag = `<${tagName}${attributeString ? " " + attributeString : ""}>`;
|
|
373
|
-
if (voidElements.has(tagName)) {
|
|
374
|
-
return openTag.slice(0, -1) + "/>";
|
|
375
|
-
}
|
|
376
|
-
const closeTag = `</${tagName}>`;
|
|
377
|
-
if (children != null) {
|
|
378
|
-
const childrenString = await renderNodeToString(children);
|
|
379
|
-
return openTag + childrenString + closeTag;
|
|
262
|
+
return element;
|
|
380
263
|
}
|
|
381
|
-
return
|
|
382
|
-
}
|
|
383
|
-
function escapeHtml(text) {
|
|
384
|
-
const htmlEscapes = {
|
|
385
|
-
"&": "&",
|
|
386
|
-
"<": "<",
|
|
387
|
-
">": ">",
|
|
388
|
-
'"': """,
|
|
389
|
-
"'": "'",
|
|
390
|
-
"/": "/"
|
|
391
|
-
};
|
|
392
|
-
return text.replace(/[&<>"'/]/g, (match) => htmlEscapes[match]);
|
|
393
|
-
}
|
|
394
|
-
function kebabCase(str) {
|
|
395
|
-
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
396
|
-
}
|
|
397
|
-
function arePropsEqual(oldProps, newProps) {
|
|
398
|
-
const oldKeys = Object.keys(oldProps).filter((k) => k !== "children");
|
|
399
|
-
const newKeys = Object.keys(newProps).filter((k) => k !== "children");
|
|
400
|
-
if (oldKeys.length !== newKeys.length)
|
|
401
|
-
return false;
|
|
402
|
-
return oldKeys.every((key) => oldProps[key] === newProps[key]);
|
|
403
|
-
}
|
|
404
|
-
function diff(oldNode, newNode) {
|
|
405
|
-
if (oldNode == null || newNode == null)
|
|
406
|
-
return oldNode !== newNode;
|
|
407
|
-
if (typeof oldNode !== typeof newNode)
|
|
408
|
-
return true;
|
|
409
|
-
if (typeof newNode === "string" || typeof newNode === "number")
|
|
410
|
-
return oldNode !== newNode;
|
|
411
|
-
if (newNode.type !== oldNode.type)
|
|
412
|
-
return true;
|
|
413
|
-
return !arePropsEqual(oldNode.props, newNode.props);
|
|
414
|
-
}
|
|
415
|
-
function shouldComponentUpdate(oldProps, newProps) {
|
|
416
|
-
return !arePropsEqual(oldProps, newProps);
|
|
417
|
-
}
|
|
418
|
-
function parsePath(path5) {
|
|
419
|
-
const pattern = path5.replace(/\/+$/, "").replace(/^\/+/, "/").replace(/\/:([^/]+)/g, "/([^/]+)");
|
|
420
|
-
const paramNames = [];
|
|
421
|
-
path5.replace(/\/:([^/]+)/g, (_, paramName) => {
|
|
422
|
-
paramNames.push(paramName);
|
|
423
|
-
return "";
|
|
424
|
-
});
|
|
425
|
-
return { pattern, paramNames };
|
|
264
|
+
return document.createTextNode(String(vnode));
|
|
426
265
|
}
|
|
427
|
-
function
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const params = {};
|
|
435
|
-
paramNames.forEach((name, index) => {
|
|
436
|
-
params[name] = match[index + 1];
|
|
437
|
-
});
|
|
438
|
-
return params;
|
|
266
|
+
async function hydrate(element, container) {
|
|
267
|
+
isHydrating = true;
|
|
268
|
+
try {
|
|
269
|
+
await render(element, container);
|
|
270
|
+
} finally {
|
|
271
|
+
isHydrating = false;
|
|
272
|
+
}
|
|
439
273
|
}
|
|
440
|
-
function
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
};
|
|
450
|
-
};
|
|
451
|
-
const [location, setLocation] = useState(getInitialLocation());
|
|
452
|
-
const [params, setParams] = useState({});
|
|
453
|
-
useEffect(() => {
|
|
454
|
-
for (const route of routes) {
|
|
455
|
-
const matchedParams = matchPath(location.pathname, route);
|
|
456
|
-
if (matchedParams) {
|
|
457
|
-
setParams(matchedParams);
|
|
458
|
-
break;
|
|
274
|
+
async function render(element, container) {
|
|
275
|
+
console.log("Rendering to:", container.id);
|
|
276
|
+
batchUpdates(async () => {
|
|
277
|
+
const rendererId = prepareRender();
|
|
278
|
+
try {
|
|
279
|
+
setRenderCallback(render, element, container);
|
|
280
|
+
const domNode = await createElement(element);
|
|
281
|
+
if (!isHydrating) {
|
|
282
|
+
container.innerHTML = "";
|
|
459
283
|
}
|
|
284
|
+
container.appendChild(domNode);
|
|
285
|
+
} finally {
|
|
286
|
+
finishRender();
|
|
460
287
|
}
|
|
461
|
-
}, [location, routes]);
|
|
462
|
-
useEffect(() => {
|
|
463
|
-
if (typeof window === "undefined")
|
|
464
|
-
return;
|
|
465
|
-
const handlePopState = () => {
|
|
466
|
-
setLocation({
|
|
467
|
-
pathname: window.location.pathname,
|
|
468
|
-
search: window.location.search,
|
|
469
|
-
hash: window.location.hash
|
|
470
|
-
});
|
|
471
|
-
};
|
|
472
|
-
window.addEventListener("popstate", handlePopState);
|
|
473
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
474
|
-
}, []);
|
|
475
|
-
const navigate = (to, options = {}) => {
|
|
476
|
-
if (typeof window === "undefined")
|
|
477
|
-
return;
|
|
478
|
-
const { replace = false, state = null } = options;
|
|
479
|
-
if (replace) {
|
|
480
|
-
window.history.replaceState(state, "", to);
|
|
481
|
-
} else {
|
|
482
|
-
window.history.pushState(state, "", to);
|
|
483
|
-
}
|
|
484
|
-
setLocation({
|
|
485
|
-
pathname: window.location.pathname,
|
|
486
|
-
search: window.location.search,
|
|
487
|
-
hash: window.location.hash
|
|
488
|
-
});
|
|
489
|
-
};
|
|
490
|
-
const match = (path5) => {
|
|
491
|
-
const { pattern } = parsePath(path5);
|
|
492
|
-
const regex = new RegExp(`^${pattern}`);
|
|
493
|
-
return regex.test(location.pathname);
|
|
494
|
-
};
|
|
495
|
-
const routerValue = {
|
|
496
|
-
location: {
|
|
497
|
-
pathname: location.pathname,
|
|
498
|
-
search: location.search,
|
|
499
|
-
hash: location.hash
|
|
500
|
-
},
|
|
501
|
-
params,
|
|
502
|
-
navigate,
|
|
503
|
-
match
|
|
504
|
-
};
|
|
505
|
-
return jsx(RouterContext.Provider, { value: routerValue, children });
|
|
506
|
-
}
|
|
507
|
-
function Route({ path: path5, component: Component2, props = {} }) {
|
|
508
|
-
const context = useContext();
|
|
509
|
-
const params = context.params;
|
|
510
|
-
const locationPathname = context.location.pathname;
|
|
511
|
-
const routeToMatch = { path: path5, component: Component2 };
|
|
512
|
-
const match = matchPath(locationPathname, routeToMatch);
|
|
513
|
-
if (!match)
|
|
514
|
-
return null;
|
|
515
|
-
return jsx(Component2, { ...props, params });
|
|
516
|
-
}
|
|
517
|
-
function Switch({ children }) {
|
|
518
|
-
const context = useContext();
|
|
519
|
-
const locationPathname = context.location.pathname;
|
|
520
|
-
const child = Array.isArray(children) ? children.find((child2) => {
|
|
521
|
-
if (!child2 || typeof child2.type !== "function" || !child2.props.path)
|
|
522
|
-
return false;
|
|
523
|
-
const routeObj = {
|
|
524
|
-
path: child2.props.path,
|
|
525
|
-
component: child2.type,
|
|
526
|
-
exact: child2.props.exact || false
|
|
527
|
-
};
|
|
528
|
-
return matchPath(locationPathname, routeObj);
|
|
529
|
-
}) : children;
|
|
530
|
-
return child || null;
|
|
531
|
-
}
|
|
532
|
-
function Link({ to, replace = false, state = null, className = "", activeClassName = "", children, ...rest }) {
|
|
533
|
-
const context = useContext();
|
|
534
|
-
const navigate = context.navigate;
|
|
535
|
-
const match = context.match;
|
|
536
|
-
const handleClick = (e) => {
|
|
537
|
-
e.preventDefault();
|
|
538
|
-
navigate(to, { replace, state });
|
|
539
|
-
};
|
|
540
|
-
const isActive = match(to);
|
|
541
|
-
const classes = [
|
|
542
|
-
className,
|
|
543
|
-
isActive ? activeClassName : ""
|
|
544
|
-
].filter(Boolean).join(" ");
|
|
545
|
-
return jsx("a", {
|
|
546
|
-
href: to,
|
|
547
|
-
className: classes || void 0,
|
|
548
|
-
onClick: handleClick,
|
|
549
|
-
...rest,
|
|
550
|
-
children
|
|
551
288
|
});
|
|
552
289
|
}
|
|
553
|
-
function
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}, [to]);
|
|
559
|
-
return null;
|
|
560
|
-
}
|
|
561
|
-
function useLocation() {
|
|
562
|
-
const context = useContext();
|
|
563
|
-
return context.location;
|
|
290
|
+
function renderToString(vnode) {
|
|
291
|
+
prepareRender();
|
|
292
|
+
const html = renderNodeToString(vnode);
|
|
293
|
+
finishRender();
|
|
294
|
+
return html;
|
|
564
295
|
}
|
|
565
|
-
function
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
...prev,
|
|
598
|
-
[name]: true
|
|
599
|
-
}));
|
|
600
|
-
};
|
|
601
|
-
const handleBlur = (e) => {
|
|
602
|
-
const { name } = e.target;
|
|
603
|
-
setTouched((prev) => ({
|
|
604
|
-
...prev,
|
|
605
|
-
[name]: true
|
|
606
|
-
}));
|
|
607
|
-
};
|
|
608
|
-
const setFieldValue = (field, value) => {
|
|
609
|
-
setValues((prev) => ({
|
|
610
|
-
...prev,
|
|
611
|
-
[field]: value
|
|
612
|
-
}));
|
|
613
|
-
setDirty((prev) => ({
|
|
614
|
-
...prev,
|
|
615
|
-
[field]: true
|
|
616
|
-
}));
|
|
617
|
-
};
|
|
618
|
-
const setFieldError = (field, error) => {
|
|
619
|
-
setErrors((prev) => ({
|
|
620
|
-
...prev,
|
|
621
|
-
[field]: error
|
|
622
|
-
}));
|
|
623
|
-
};
|
|
624
|
-
const updateValues = (newValues) => {
|
|
625
|
-
setValues((prev) => ({
|
|
626
|
-
...prev,
|
|
627
|
-
...newValues
|
|
628
|
-
}));
|
|
629
|
-
const dirtyFields = {};
|
|
630
|
-
Object.keys(newValues).forEach((key) => {
|
|
631
|
-
dirtyFields[key] = true;
|
|
632
|
-
});
|
|
633
|
-
setDirty((prev) => ({
|
|
634
|
-
...prev,
|
|
635
|
-
...dirtyFields
|
|
636
|
-
}));
|
|
637
|
-
};
|
|
638
|
-
const resetForm = () => {
|
|
639
|
-
setValues(initialValues);
|
|
640
|
-
setErrors({});
|
|
641
|
-
setTouched({});
|
|
642
|
-
setDirty({});
|
|
643
|
-
setIsSubmitting(false);
|
|
644
|
-
};
|
|
645
|
-
const handleSubmit = async (e) => {
|
|
646
|
-
e.preventDefault();
|
|
647
|
-
const allTouched = {};
|
|
648
|
-
Object.keys(values).forEach((key) => {
|
|
649
|
-
allTouched[key] = true;
|
|
650
|
-
});
|
|
651
|
-
setTouched(allTouched);
|
|
652
|
-
let validationErrors = {};
|
|
653
|
-
if (validate) {
|
|
654
|
-
validationErrors = validate(values);
|
|
655
|
-
setErrors(validationErrors || {});
|
|
656
|
-
}
|
|
657
|
-
if (Object.keys(validationErrors).length === 0 && onSubmit) {
|
|
658
|
-
setIsSubmitting(true);
|
|
659
|
-
setSubmitCount((count) => count + 1);
|
|
660
|
-
try {
|
|
661
|
-
await onSubmit(values, {
|
|
662
|
-
fields: Object.keys(values).reduce((acc, key) => {
|
|
663
|
-
acc[key] = {
|
|
664
|
-
value: values[key],
|
|
665
|
-
error: errors[key],
|
|
666
|
-
touched: touched[key] || false,
|
|
667
|
-
dirty: dirty[key] || false
|
|
668
|
-
};
|
|
669
|
-
return acc;
|
|
670
|
-
}, {}),
|
|
671
|
-
isValid,
|
|
672
|
-
isDirty,
|
|
673
|
-
isSubmitting: true,
|
|
674
|
-
submitCount: submitCount + 1
|
|
675
|
-
});
|
|
676
|
-
} finally {
|
|
677
|
-
setIsSubmitting(false);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
return {
|
|
682
|
-
values,
|
|
683
|
-
errors,
|
|
684
|
-
touched,
|
|
685
|
-
dirty,
|
|
686
|
-
isValid,
|
|
687
|
-
isDirty,
|
|
688
|
-
isSubmitting,
|
|
689
|
-
submitCount,
|
|
690
|
-
handleChange,
|
|
691
|
-
handleBlur,
|
|
692
|
-
handleSubmit,
|
|
693
|
-
setFieldValue,
|
|
694
|
-
setFieldError,
|
|
695
|
-
setValues: updateValues,
|
|
696
|
-
resetForm
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
function createEventBus() {
|
|
700
|
-
const events = /* @__PURE__ */ new Map();
|
|
701
|
-
const onceHandlers = /* @__PURE__ */ new WeakMap();
|
|
702
|
-
const on = (event, handler) => {
|
|
703
|
-
if (!events.has(event)) {
|
|
704
|
-
events.set(event, /* @__PURE__ */ new Set());
|
|
705
|
-
}
|
|
706
|
-
events.get(event).add(handler);
|
|
707
|
-
return () => off(event, handler);
|
|
708
|
-
};
|
|
709
|
-
const once = (event, handler) => {
|
|
710
|
-
const onceWrapper = (...args) => {
|
|
711
|
-
off(event, onceWrapper);
|
|
712
|
-
handler(...args);
|
|
713
|
-
};
|
|
714
|
-
onceHandlers.set(handler, onceWrapper);
|
|
715
|
-
return on(event, onceWrapper);
|
|
716
|
-
};
|
|
717
|
-
const off = (event, handler) => {
|
|
718
|
-
if (!handler) {
|
|
719
|
-
events.delete(event);
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
const wrappedHandler = onceHandlers.get(handler);
|
|
723
|
-
const handlerToRemove = wrappedHandler || handler;
|
|
724
|
-
if (events.has(event)) {
|
|
725
|
-
events.get(event).delete(handlerToRemove);
|
|
726
|
-
if (events.get(event).size === 0) {
|
|
727
|
-
events.delete(event);
|
|
296
|
+
function renderNodeToString(vnode) {
|
|
297
|
+
var _a, _b, _c;
|
|
298
|
+
if (vnode === null || vnode === void 0)
|
|
299
|
+
return "";
|
|
300
|
+
if (typeof vnode === "boolean")
|
|
301
|
+
return "";
|
|
302
|
+
if (typeof vnode === "number" || typeof vnode === "string")
|
|
303
|
+
return escapeHtml(String(vnode));
|
|
304
|
+
if (typeof vnode.type === "function") {
|
|
305
|
+
const Component2 = vnode.type;
|
|
306
|
+
const renderedNode = Component2(vnode.props || {});
|
|
307
|
+
return renderNodeToString(renderedNode);
|
|
308
|
+
}
|
|
309
|
+
if (typeof vnode.type === "string") {
|
|
310
|
+
const tag = vnode.type;
|
|
311
|
+
let attrs = "";
|
|
312
|
+
let children = "";
|
|
313
|
+
if (vnode.props) {
|
|
314
|
+
for (const [key, value] of Object.entries(vnode.props)) {
|
|
315
|
+
if (key === "children")
|
|
316
|
+
continue;
|
|
317
|
+
if (key.startsWith("on"))
|
|
318
|
+
continue;
|
|
319
|
+
if (key === "className") {
|
|
320
|
+
attrs += ` class="${escapeHtml(value)}"`;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
324
|
+
attrs += ` ${key}="${escapeHtml(String(value))}"`;
|
|
325
|
+
} else if (value === true) {
|
|
326
|
+
attrs += ` ${key}`;
|
|
327
|
+
}
|
|
728
328
|
}
|
|
729
329
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
};
|
|
766
|
-
const chain = middlewares.map((middleware) => middleware(middlewareAPI));
|
|
767
|
-
dispatch = chain.reduce((a, b) => (next) => a(b(next)))(dispatch);
|
|
768
|
-
}
|
|
769
|
-
function subscribe(listener) {
|
|
770
|
-
listeners.push(listener);
|
|
771
|
-
return function unsubscribe() {
|
|
772
|
-
listeners = listeners.filter((l) => l !== listener);
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
dispatch({ type: "@@INIT" });
|
|
776
|
-
return {
|
|
777
|
-
getState: () => state,
|
|
778
|
-
dispatch,
|
|
779
|
-
subscribe
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
function StoreProvider({ store, children }) {
|
|
783
|
-
const [state, setState] = useState(store.getState());
|
|
784
|
-
useEffect(() => {
|
|
785
|
-
const unsubscribe = store.subscribe(() => {
|
|
786
|
-
setState(store.getState());
|
|
787
|
-
});
|
|
788
|
-
return unsubscribe;
|
|
789
|
-
}, [store]);
|
|
790
|
-
return jsx(StoreContext.Provider, {
|
|
791
|
-
value: { store, state },
|
|
792
|
-
children
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
function useSelector(selector) {
|
|
796
|
-
const context = useContext();
|
|
797
|
-
return selector(context.state);
|
|
798
|
-
}
|
|
799
|
-
function useDispatch() {
|
|
800
|
-
const context = useContext();
|
|
801
|
-
return context.store.dispatch;
|
|
802
|
-
}
|
|
803
|
-
function useStore() {
|
|
804
|
-
const context = useContext();
|
|
805
|
-
return context.store;
|
|
806
|
-
}
|
|
807
|
-
function emitAppInit(data) {
|
|
808
|
-
globalEventBus.emit(LifecycleEvents.APP_INIT, data);
|
|
809
|
-
}
|
|
810
|
-
function emitAppMounted(rootElement) {
|
|
811
|
-
globalEventBus.emit(LifecycleEvents.APP_MOUNTED, rootElement);
|
|
812
|
-
}
|
|
813
|
-
function emitAppUpdated() {
|
|
814
|
-
globalEventBus.emit(LifecycleEvents.APP_UPDATED);
|
|
815
|
-
}
|
|
816
|
-
function emitAppError(error) {
|
|
817
|
-
globalEventBus.emit(LifecycleEvents.APP_ERROR, error);
|
|
330
|
+
const childrenArray = ((_a = vnode.props) == null ? void 0 : _a.children) ? Array.isArray(vnode.props.children) ? vnode.props.children : [vnode.props.children] : [];
|
|
331
|
+
for (const child of childrenArray) {
|
|
332
|
+
children += renderNodeToString(child);
|
|
333
|
+
}
|
|
334
|
+
const selfClosing = [
|
|
335
|
+
"area",
|
|
336
|
+
"base",
|
|
337
|
+
"br",
|
|
338
|
+
"col",
|
|
339
|
+
"embed",
|
|
340
|
+
"hr",
|
|
341
|
+
"img",
|
|
342
|
+
"input",
|
|
343
|
+
"link",
|
|
344
|
+
"meta",
|
|
345
|
+
"param",
|
|
346
|
+
"source",
|
|
347
|
+
"track",
|
|
348
|
+
"wbr"
|
|
349
|
+
];
|
|
350
|
+
if (selfClosing.includes(tag)) {
|
|
351
|
+
return `<${tag}${attrs}/>`;
|
|
352
|
+
}
|
|
353
|
+
return `<${tag}${attrs}>${children}</${tag}>`;
|
|
354
|
+
}
|
|
355
|
+
if (vnode.type === Symbol.for("react.fragment")) {
|
|
356
|
+
let fragmentOutput = "";
|
|
357
|
+
const children = Array.isArray((_b = vnode.props) == null ? void 0 : _b.children) ? vnode.props.children : ((_c = vnode.props) == null ? void 0 : _c.children) ? [vnode.props.children] : [];
|
|
358
|
+
for (const child of children) {
|
|
359
|
+
fragmentOutput += renderNodeToString(child);
|
|
360
|
+
}
|
|
361
|
+
return fragmentOutput;
|
|
362
|
+
}
|
|
363
|
+
console.warn("Unknown vnode type:", vnode.type);
|
|
364
|
+
return "";
|
|
818
365
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
821
|
-
}
|
|
822
|
-
function emitComponentCreated(info) {
|
|
823
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_CREATED, info);
|
|
824
|
-
}
|
|
825
|
-
function emitComponentMounted(info, element) {
|
|
826
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_MOUNTED, info, element);
|
|
827
|
-
}
|
|
828
|
-
function emitComponentUpdated(info, prevProps, newProps) {
|
|
829
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_UPDATED, info, prevProps, newProps);
|
|
830
|
-
}
|
|
831
|
-
function emitComponentError(info, error) {
|
|
832
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_ERROR, info, error);
|
|
833
|
-
}
|
|
834
|
-
function emitComponentUnmounted(info) {
|
|
835
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_UNMOUNTED, info);
|
|
836
|
-
}
|
|
837
|
-
function onAppInit(handler) {
|
|
838
|
-
return globalEventBus.on(LifecycleEvents.APP_INIT, handler);
|
|
839
|
-
}
|
|
840
|
-
function onAppMounted(handler) {
|
|
841
|
-
return globalEventBus.on(LifecycleEvents.APP_MOUNTED, handler);
|
|
842
|
-
}
|
|
843
|
-
function onAppUpdated(handler) {
|
|
844
|
-
return globalEventBus.on(LifecycleEvents.APP_UPDATED, handler);
|
|
845
|
-
}
|
|
846
|
-
function onAppError(handler) {
|
|
847
|
-
return globalEventBus.on(LifecycleEvents.APP_ERROR, handler);
|
|
848
|
-
}
|
|
849
|
-
function onAppDestroyed(handler) {
|
|
850
|
-
return globalEventBus.on(LifecycleEvents.APP_DESTROYED, handler);
|
|
851
|
-
}
|
|
852
|
-
function onComponentCreated(handler) {
|
|
853
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_CREATED, handler);
|
|
854
|
-
}
|
|
855
|
-
function onComponentMounted(handler) {
|
|
856
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_MOUNTED, handler);
|
|
857
|
-
}
|
|
858
|
-
function onComponentUpdated(handler) {
|
|
859
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_UPDATED, handler);
|
|
860
|
-
}
|
|
861
|
-
function onComponentError(handler) {
|
|
862
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_ERROR, handler);
|
|
863
|
-
}
|
|
864
|
-
function onComponentUnmounted(handler) {
|
|
865
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_UNMOUNTED, handler);
|
|
366
|
+
function escapeHtml(text) {
|
|
367
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
866
368
|
}
|
|
867
|
-
var
|
|
369
|
+
var isBatching, queue, currentRender, states, stateIndices, effects, memos, refs, globalRenderCallback, globalContainer, currentElement, isServer, serverStates, Fragment, isHydrating, server;
|
|
868
370
|
var init_dist = __esm({
|
|
869
|
-
"node_modules/frontend-hamroun/dist/index.
|
|
870
|
-
Fragment = ({ children }) => children;
|
|
371
|
+
"node_modules/frontend-hamroun/dist/index.mjs"() {
|
|
871
372
|
isBatching = false;
|
|
872
373
|
queue = [];
|
|
873
|
-
contexts = /* @__PURE__ */ new Map();
|
|
874
374
|
currentRender = 0;
|
|
875
|
-
isSSR = false;
|
|
876
375
|
states = /* @__PURE__ */ new Map();
|
|
877
376
|
stateIndices = /* @__PURE__ */ new Map();
|
|
878
377
|
effects = /* @__PURE__ */ new Map();
|
|
@@ -881,139 +380,15 @@ var init_dist = __esm({
|
|
|
881
380
|
globalRenderCallback = null;
|
|
882
381
|
globalContainer = null;
|
|
883
382
|
currentElement = null;
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
componentDidMount() {
|
|
892
|
-
}
|
|
893
|
-
async setState(newState) {
|
|
894
|
-
const prevState = { ...this.state };
|
|
895
|
-
this.state = { ...prevState, ...newState };
|
|
896
|
-
console.log(`${this.constructor.name} state updated:`, {
|
|
897
|
-
prev: prevState,
|
|
898
|
-
next: this.state
|
|
899
|
-
});
|
|
900
|
-
await Promise.resolve();
|
|
901
|
-
if (this._mounted) {
|
|
902
|
-
await this.update();
|
|
903
|
-
} else {
|
|
904
|
-
await this.update();
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
_replayEvents(oldElement, newElement) {
|
|
908
|
-
const oldEvents = oldElement.__events || {};
|
|
909
|
-
Object.entries(oldEvents).forEach(([event, handler]) => {
|
|
910
|
-
newElement.addEventListener(event, handler);
|
|
911
|
-
});
|
|
912
|
-
newElement.__events = oldEvents;
|
|
913
|
-
}
|
|
914
|
-
_deepCloneWithEvents(node) {
|
|
915
|
-
const clone = node.cloneNode(false);
|
|
916
|
-
const events = node.__events || {};
|
|
917
|
-
clone.__events = events;
|
|
918
|
-
Object.entries(events).forEach(([event, handler]) => {
|
|
919
|
-
clone.addEventListener(event, handler);
|
|
920
|
-
});
|
|
921
|
-
Array.from(node.childNodes).forEach((child) => {
|
|
922
|
-
if (child instanceof HTMLElement) {
|
|
923
|
-
clone.appendChild(this._deepCloneWithEvents(child));
|
|
924
|
-
} else {
|
|
925
|
-
clone.appendChild(child.cloneNode(true));
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
return clone;
|
|
929
|
-
}
|
|
930
|
-
async update() {
|
|
931
|
-
const vdom = this.render();
|
|
932
|
-
if (!vdom)
|
|
933
|
-
return document.createTextNode("");
|
|
934
|
-
const rendered = await createElement(vdom);
|
|
935
|
-
if (rendered instanceof HTMLElement) {
|
|
936
|
-
return this._updateElement(rendered);
|
|
937
|
-
}
|
|
938
|
-
const wrapper = document.createElement("div");
|
|
939
|
-
wrapper.appendChild(rendered);
|
|
940
|
-
return this._updateElement(wrapper);
|
|
941
|
-
}
|
|
942
|
-
async _updateElement(rendered) {
|
|
943
|
-
const newElement = this._deepCloneWithEvents(rendered);
|
|
944
|
-
newElement.__instance = this;
|
|
945
|
-
if (!this.element) {
|
|
946
|
-
this.element = newElement;
|
|
947
|
-
if (!this._mounted) {
|
|
948
|
-
this._mounted = true;
|
|
949
|
-
queueMicrotask(() => this.componentDidMount());
|
|
950
|
-
}
|
|
951
|
-
} else if (this.element.parentNode) {
|
|
952
|
-
this.element.parentNode.replaceChild(newElement, this.element);
|
|
953
|
-
this.element = newElement;
|
|
954
|
-
}
|
|
955
|
-
return this.element;
|
|
956
|
-
}
|
|
957
|
-
render() {
|
|
958
|
-
throw new Error("Component must implement render() method");
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
RouterContext = createContext({
|
|
962
|
-
location: {
|
|
963
|
-
pathname: "/",
|
|
964
|
-
search: "",
|
|
965
|
-
hash: ""
|
|
966
|
-
},
|
|
967
|
-
params: {},
|
|
968
|
-
navigate: () => {
|
|
969
|
-
},
|
|
970
|
-
match: () => false
|
|
971
|
-
});
|
|
972
|
-
globalEventBus = createEventBus();
|
|
973
|
-
StoreContext = createContext({
|
|
974
|
-
store: {
|
|
975
|
-
getState: () => ({}),
|
|
976
|
-
dispatch: () => {
|
|
977
|
-
},
|
|
978
|
-
subscribe: () => () => {
|
|
979
|
-
}
|
|
980
|
-
},
|
|
981
|
-
state: {}
|
|
982
|
-
});
|
|
983
|
-
logger = (store) => (next) => (action) => {
|
|
984
|
-
console.group(action.type);
|
|
985
|
-
console.log("Previous state:", store.getState());
|
|
986
|
-
console.log("Action:", action);
|
|
987
|
-
const result = next(action);
|
|
988
|
-
console.log("Next state:", store.getState());
|
|
989
|
-
console.groupEnd();
|
|
990
|
-
return result;
|
|
991
|
-
};
|
|
992
|
-
thunk = (store) => (next) => (action) => {
|
|
993
|
-
if (typeof action === "function") {
|
|
994
|
-
return action(store.dispatch, store.getState);
|
|
383
|
+
isServer = typeof window === "undefined";
|
|
384
|
+
serverStates = /* @__PURE__ */ new Map();
|
|
385
|
+
Fragment = ({ children }) => children;
|
|
386
|
+
isHydrating = false;
|
|
387
|
+
server = {
|
|
388
|
+
async getServer() {
|
|
389
|
+
throw new Error("Server module can only be used in Node.js environment");
|
|
995
390
|
}
|
|
996
|
-
return next(action);
|
|
997
391
|
};
|
|
998
|
-
(function(LifecycleEvents2) {
|
|
999
|
-
LifecycleEvents2["APP_INIT"] = "app:init";
|
|
1000
|
-
LifecycleEvents2["APP_MOUNTED"] = "app:mounted";
|
|
1001
|
-
LifecycleEvents2["APP_UPDATED"] = "app:updated";
|
|
1002
|
-
LifecycleEvents2["APP_ERROR"] = "app:error";
|
|
1003
|
-
LifecycleEvents2["APP_DESTROYED"] = "app:destroyed";
|
|
1004
|
-
LifecycleEvents2["COMPONENT_CREATED"] = "component:created";
|
|
1005
|
-
LifecycleEvents2["COMPONENT_MOUNTED"] = "component:mounted";
|
|
1006
|
-
LifecycleEvents2["COMPONENT_UPDATED"] = "component:updated";
|
|
1007
|
-
LifecycleEvents2["COMPONENT_ERROR"] = "component:error";
|
|
1008
|
-
LifecycleEvents2["COMPONENT_UNMOUNTED"] = "component:unmounted";
|
|
1009
|
-
LifecycleEvents2["ROUTER_BEFORE_CHANGE"] = "router:before-change";
|
|
1010
|
-
LifecycleEvents2["ROUTER_AFTER_CHANGE"] = "router:after-change";
|
|
1011
|
-
LifecycleEvents2["ROUTER_ERROR"] = "router:error";
|
|
1012
|
-
LifecycleEvents2["STORE_INITIALIZED"] = "store:initialized";
|
|
1013
|
-
LifecycleEvents2["STORE_BEFORE_ACTION"] = "store:before-action";
|
|
1014
|
-
LifecycleEvents2["STORE_AFTER_ACTION"] = "store:after-action";
|
|
1015
|
-
LifecycleEvents2["STORE_ERROR"] = "store:error";
|
|
1016
|
-
})(LifecycleEvents || (LifecycleEvents = {}));
|
|
1017
392
|
}
|
|
1018
393
|
});
|
|
1019
394
|
|
|
@@ -1967,13 +1342,13 @@ function createDevServer(options = {}) {
|
|
|
1967
1342
|
});
|
|
1968
1343
|
}
|
|
1969
1344
|
function createProductionServer(config) {
|
|
1970
|
-
const
|
|
1345
|
+
const server2 = new Server({
|
|
1971
1346
|
...config,
|
|
1972
1347
|
// Fix the PORT parsing
|
|
1973
1348
|
port: config.port || (process.env.PORT ? parseInt(process.env.PORT) : 8080)
|
|
1974
1349
|
});
|
|
1975
|
-
|
|
1976
|
-
return
|
|
1350
|
+
server2.addShutdownHandler();
|
|
1351
|
+
return server2;
|
|
1977
1352
|
}
|
|
1978
1353
|
function getRequestIp(req) {
|
|
1979
1354
|
return req.ip || req.headers["x-forwarded-for"]?.split(",")[0].trim() || req.socket.remoteAddress || "";
|
|
@@ -2320,9 +1695,9 @@ var init_server = __esm({
|
|
|
2320
1695
|
process.on("SIGINT", gracefulShutdown);
|
|
2321
1696
|
}
|
|
2322
1697
|
};
|
|
2323
|
-
renderComponent = (
|
|
1698
|
+
renderComponent = (Component, props = {}) => {
|
|
2324
1699
|
try {
|
|
2325
|
-
const html = renderToString(
|
|
1700
|
+
const html = renderToString(Component(props));
|
|
2326
1701
|
return {
|
|
2327
1702
|
html: typeof html === "string" ? html : String(html),
|
|
2328
1703
|
success: true
|
|
@@ -2584,40 +1959,17 @@ export {
|
|
|
2584
1959
|
ApiRouter2 as ApiRouter,
|
|
2585
1960
|
AuthService2 as AuthService,
|
|
2586
1961
|
BaraqexServer,
|
|
2587
|
-
Component,
|
|
2588
1962
|
Database2 as Database,
|
|
2589
1963
|
Fragment,
|
|
2590
|
-
LifecycleEvents,
|
|
2591
|
-
Link,
|
|
2592
|
-
Redirect,
|
|
2593
|
-
Route,
|
|
2594
|
-
RouterProvider,
|
|
2595
|
-
StoreProvider,
|
|
2596
|
-
Switch,
|
|
2597
1964
|
baraqexRenderToString,
|
|
2598
1965
|
batchUpdates,
|
|
2599
1966
|
callWasmFunction,
|
|
2600
1967
|
createContext,
|
|
2601
1968
|
createDevServer2 as createDevServer,
|
|
2602
|
-
createElement,
|
|
2603
|
-
createEventBus,
|
|
2604
1969
|
createProductionServer2 as createProductionServer,
|
|
2605
1970
|
createServer2 as createServer,
|
|
2606
|
-
createStore,
|
|
2607
|
-
diff,
|
|
2608
|
-
emitAppDestroyed,
|
|
2609
|
-
emitAppError,
|
|
2610
|
-
emitAppInit,
|
|
2611
|
-
emitAppMounted,
|
|
2612
|
-
emitAppUpdated,
|
|
2613
|
-
emitComponentCreated,
|
|
2614
|
-
emitComponentError,
|
|
2615
|
-
emitComponentMounted,
|
|
2616
|
-
emitComponentUnmounted,
|
|
2617
|
-
emitComponentUpdated,
|
|
2618
1971
|
ensureDirectory2 as ensureDirectory,
|
|
2619
1972
|
errorHandler2 as errorHandler,
|
|
2620
|
-
globalEventBus as eventBus,
|
|
2621
1973
|
generateDocument,
|
|
2622
1974
|
generateErrorPage,
|
|
2623
1975
|
generateLoadingPage,
|
|
@@ -2631,22 +1983,10 @@ export {
|
|
|
2631
1983
|
isDirectoryEmpty2 as isDirectoryEmpty,
|
|
2632
1984
|
isWasmReady,
|
|
2633
1985
|
jsx,
|
|
2634
|
-
jsx as jsxDEV,
|
|
2635
1986
|
jsx as jsxs,
|
|
2636
1987
|
loadGoWasm,
|
|
2637
1988
|
loadGoWasmFromFile2 as loadGoWasmFromFile,
|
|
2638
|
-
logger,
|
|
2639
1989
|
notFoundHandler2 as notFoundHandler,
|
|
2640
|
-
onAppDestroyed,
|
|
2641
|
-
onAppError,
|
|
2642
|
-
onAppInit,
|
|
2643
|
-
onAppMounted,
|
|
2644
|
-
onAppUpdated,
|
|
2645
|
-
onComponentCreated,
|
|
2646
|
-
onComponentError,
|
|
2647
|
-
onComponentMounted,
|
|
2648
|
-
onComponentUnmounted,
|
|
2649
|
-
onComponentUpdated,
|
|
2650
1990
|
rateLimit2 as rateLimit,
|
|
2651
1991
|
readJsonFile2 as readJsonFile,
|
|
2652
1992
|
render,
|
|
@@ -2656,23 +1996,14 @@ export {
|
|
|
2656
1996
|
safeJsonParse2 as safeJsonParse,
|
|
2657
1997
|
sendError2 as sendError,
|
|
2658
1998
|
sendSuccess2 as sendSuccess,
|
|
2659
|
-
|
|
2660
|
-
thunk,
|
|
1999
|
+
server,
|
|
2661
2000
|
useContext,
|
|
2662
|
-
useDispatch,
|
|
2663
2001
|
useEffect,
|
|
2664
2002
|
useErrorBoundary,
|
|
2665
|
-
useEvent,
|
|
2666
|
-
useForm,
|
|
2667
2003
|
useGoWasm,
|
|
2668
|
-
useLocation,
|
|
2669
2004
|
useMemo,
|
|
2670
|
-
useNavigate,
|
|
2671
|
-
useParams,
|
|
2672
2005
|
useRef,
|
|
2673
|
-
useSelector,
|
|
2674
2006
|
useState,
|
|
2675
|
-
useStore,
|
|
2676
2007
|
validateFields2 as validateFields,
|
|
2677
2008
|
validateFileUpload2 as validateFileUpload,
|
|
2678
2009
|
writeJsonFile2 as writeJsonFile
|