baraqex 1.0.42 → 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.d.ts +16 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +188 -951
- 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/esbuild.config.js +19 -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 +0 -1
package/dist/browser.js
CHANGED
|
@@ -1,82 +1,4 @@
|
|
|
1
|
-
// node_modules/frontend-hamroun/dist/index.
|
|
2
|
-
function jsx(type, props) {
|
|
3
|
-
console.log("JSX Transform:", { type, props });
|
|
4
|
-
const processedProps = { ...props };
|
|
5
|
-
if (arguments.length > 2) {
|
|
6
|
-
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
|
7
|
-
}
|
|
8
|
-
return { type, props: processedProps };
|
|
9
|
-
}
|
|
10
|
-
var Fragment = ({ children }) => children;
|
|
11
|
-
async function createElement(vnode) {
|
|
12
|
-
console.log("Creating element from:", vnode);
|
|
13
|
-
if (vnode == null) {
|
|
14
|
-
return document.createTextNode("");
|
|
15
|
-
}
|
|
16
|
-
if (typeof vnode === "boolean") {
|
|
17
|
-
return document.createTextNode("");
|
|
18
|
-
}
|
|
19
|
-
if (typeof vnode === "number" || typeof vnode === "string") {
|
|
20
|
-
return document.createTextNode(String(vnode));
|
|
21
|
-
}
|
|
22
|
-
if (Array.isArray(vnode)) {
|
|
23
|
-
const fragment = document.createDocumentFragment();
|
|
24
|
-
for (const child of vnode) {
|
|
25
|
-
const node = await createElement(child);
|
|
26
|
-
fragment.appendChild(node);
|
|
27
|
-
}
|
|
28
|
-
return fragment;
|
|
29
|
-
}
|
|
30
|
-
if ("type" in vnode && vnode.props !== void 0) {
|
|
31
|
-
const { type, props } = vnode;
|
|
32
|
-
if (typeof type === "function") {
|
|
33
|
-
try {
|
|
34
|
-
const result = await type(props || {});
|
|
35
|
-
const node = await createElement(result);
|
|
36
|
-
if (node instanceof Element) {
|
|
37
|
-
node.setAttribute("data-component-id", type.name || type.toString());
|
|
38
|
-
}
|
|
39
|
-
return node;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("Error rendering component:", error);
|
|
42
|
-
return document.createTextNode("");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const element = document.createElement(type);
|
|
46
|
-
for (const [key, value] of Object.entries(props || {})) {
|
|
47
|
-
if (key === "children")
|
|
48
|
-
continue;
|
|
49
|
-
if (key.startsWith("on") && typeof value === "function") {
|
|
50
|
-
const eventName = key.toLowerCase().slice(2);
|
|
51
|
-
const existingHandler = element.__events?.[eventName];
|
|
52
|
-
if (existingHandler) {
|
|
53
|
-
element.removeEventListener(eventName, existingHandler);
|
|
54
|
-
}
|
|
55
|
-
element.addEventListener(eventName, value);
|
|
56
|
-
if (!element.__events) {
|
|
57
|
-
element.__events = {};
|
|
58
|
-
}
|
|
59
|
-
element.__events[eventName] = value;
|
|
60
|
-
} else if (key === "style" && typeof value === "object") {
|
|
61
|
-
Object.assign(element.style, value);
|
|
62
|
-
} else if (key === "className") {
|
|
63
|
-
element.setAttribute("class", String(value));
|
|
64
|
-
} else if (key !== "key" && key !== "ref") {
|
|
65
|
-
element.setAttribute(key, String(value));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const children = props?.children;
|
|
69
|
-
if (children != null) {
|
|
70
|
-
const childArray = Array.isArray(children) ? children.flat() : [children];
|
|
71
|
-
for (const child of childArray) {
|
|
72
|
-
const childNode = await createElement(child);
|
|
73
|
-
element.appendChild(childNode);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return element;
|
|
77
|
-
}
|
|
78
|
-
return document.createTextNode(String(vnode));
|
|
79
|
-
}
|
|
1
|
+
// node_modules/frontend-hamroun/dist/index.mjs
|
|
80
2
|
var isBatching = false;
|
|
81
3
|
var queue = [];
|
|
82
4
|
function batchUpdates(fn) {
|
|
@@ -89,35 +11,13 @@ function batchUpdates(fn) {
|
|
|
89
11
|
fn();
|
|
90
12
|
while (queue.length > 0) {
|
|
91
13
|
const nextFn = queue.shift();
|
|
92
|
-
nextFn
|
|
14
|
+
nextFn == null ? void 0 : nextFn();
|
|
93
15
|
}
|
|
94
16
|
} finally {
|
|
95
17
|
isBatching = false;
|
|
96
18
|
}
|
|
97
19
|
}
|
|
98
|
-
var contexts = /* @__PURE__ */ new Map();
|
|
99
|
-
function createContext(defaultValue) {
|
|
100
|
-
const contextId = Symbol("context");
|
|
101
|
-
const Provider = ({ value, children }) => {
|
|
102
|
-
contexts.set(contextId, value);
|
|
103
|
-
return children;
|
|
104
|
-
};
|
|
105
|
-
const Consumer = ({ children }) => {
|
|
106
|
-
const value = contexts.get(contextId) ?? defaultValue;
|
|
107
|
-
return children(value);
|
|
108
|
-
};
|
|
109
|
-
const context = {
|
|
110
|
-
Provider,
|
|
111
|
-
Consumer,
|
|
112
|
-
displayName: "Context"
|
|
113
|
-
};
|
|
114
|
-
return context;
|
|
115
|
-
}
|
|
116
|
-
function useContext(context) {
|
|
117
|
-
return {};
|
|
118
|
-
}
|
|
119
20
|
var currentRender = 0;
|
|
120
|
-
var isSSR = false;
|
|
121
21
|
var states = /* @__PURE__ */ new Map();
|
|
122
22
|
var stateIndices = /* @__PURE__ */ new Map();
|
|
123
23
|
var effects = /* @__PURE__ */ new Map();
|
|
@@ -126,39 +26,53 @@ var refs = /* @__PURE__ */ new Map();
|
|
|
126
26
|
var globalRenderCallback = null;
|
|
127
27
|
var globalContainer = null;
|
|
128
28
|
var currentElement = null;
|
|
29
|
+
var isServer = typeof window === "undefined";
|
|
30
|
+
var serverStates = /* @__PURE__ */ new Map();
|
|
129
31
|
function setRenderCallback(callback, element, container) {
|
|
130
32
|
globalRenderCallback = callback;
|
|
131
33
|
globalContainer = container;
|
|
132
34
|
currentElement = element;
|
|
133
35
|
}
|
|
134
|
-
function prepareRender(
|
|
36
|
+
function prepareRender() {
|
|
135
37
|
currentRender++;
|
|
136
|
-
isSSR = isServerSideRender;
|
|
137
38
|
stateIndices.set(currentRender, 0);
|
|
138
|
-
if (!states.has(currentRender)) {
|
|
139
|
-
states.set(currentRender, []);
|
|
140
|
-
}
|
|
141
39
|
return currentRender;
|
|
142
40
|
}
|
|
143
41
|
function finishRender() {
|
|
42
|
+
if (isServer) {
|
|
43
|
+
serverStates.delete(currentRender);
|
|
44
|
+
}
|
|
45
|
+
currentRender = 0;
|
|
144
46
|
}
|
|
145
47
|
function useState(initial) {
|
|
146
48
|
if (!currentRender) {
|
|
147
49
|
throw new Error("useState must be called within a render");
|
|
148
50
|
}
|
|
51
|
+
if (isServer) {
|
|
52
|
+
if (!serverStates.has(currentRender)) {
|
|
53
|
+
serverStates.set(currentRender, /* @__PURE__ */ new Map());
|
|
54
|
+
}
|
|
55
|
+
const componentState = serverStates.get(currentRender);
|
|
56
|
+
const index2 = stateIndices.get(currentRender) || 0;
|
|
57
|
+
if (!componentState.has(index2)) {
|
|
58
|
+
componentState.set(index2, initial);
|
|
59
|
+
}
|
|
60
|
+
const state2 = componentState.get(index2);
|
|
61
|
+
const setState2 = (newValue) => {
|
|
62
|
+
};
|
|
63
|
+
stateIndices.set(currentRender, index2 + 1);
|
|
64
|
+
return [state2, setState2];
|
|
65
|
+
}
|
|
149
66
|
if (!states.has(currentRender)) {
|
|
150
67
|
states.set(currentRender, []);
|
|
151
68
|
}
|
|
152
69
|
const componentStates = states.get(currentRender);
|
|
153
|
-
const index = stateIndices.get(currentRender)
|
|
70
|
+
const index = stateIndices.get(currentRender);
|
|
154
71
|
if (index >= componentStates.length) {
|
|
155
72
|
componentStates.push(initial);
|
|
156
73
|
}
|
|
157
74
|
const state = componentStates[index];
|
|
158
75
|
const setState = (newValue) => {
|
|
159
|
-
if (isSSR) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
76
|
const nextValue = typeof newValue === "function" ? newValue(componentStates[index]) : newValue;
|
|
163
77
|
if (componentStates[index] === nextValue)
|
|
164
78
|
return;
|
|
@@ -175,24 +89,19 @@ function useState(initial) {
|
|
|
175
89
|
function useEffect(callback, deps) {
|
|
176
90
|
if (!currentRender)
|
|
177
91
|
throw new Error("useEffect must be called within a render");
|
|
178
|
-
|
|
179
|
-
const effectIndex2 = stateIndices.get(currentRender) || 0;
|
|
180
|
-
stateIndices.set(currentRender, effectIndex2 + 1);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const effectIndex = stateIndices.get(currentRender) || 0;
|
|
92
|
+
const effectIndex = stateIndices.get(currentRender);
|
|
184
93
|
if (!effects.has(currentRender)) {
|
|
185
94
|
effects.set(currentRender, []);
|
|
186
95
|
}
|
|
187
96
|
const componentEffects = effects.get(currentRender);
|
|
188
97
|
const prevEffect = componentEffects[effectIndex];
|
|
189
98
|
if (!prevEffect || !deps || !prevEffect.deps || deps.some((dep, i) => dep !== prevEffect.deps[i])) {
|
|
190
|
-
if (prevEffect
|
|
99
|
+
if (prevEffect == null ? void 0 : prevEffect.cleanup) {
|
|
191
100
|
prevEffect.cleanup();
|
|
192
101
|
}
|
|
193
102
|
queueMicrotask(() => {
|
|
194
103
|
const cleanup = callback() || void 0;
|
|
195
|
-
componentEffects[effectIndex] = { cleanup, deps
|
|
104
|
+
componentEffects[effectIndex] = { cleanup, deps };
|
|
196
105
|
});
|
|
197
106
|
}
|
|
198
107
|
stateIndices.set(currentRender, effectIndex + 1);
|
|
@@ -200,7 +109,7 @@ function useEffect(callback, deps) {
|
|
|
200
109
|
function useMemo(factory, deps) {
|
|
201
110
|
if (!currentRender)
|
|
202
111
|
throw new Error("useMemo must be called within a render");
|
|
203
|
-
const memoIndex = stateIndices.get(currentRender)
|
|
112
|
+
const memoIndex = stateIndices.get(currentRender);
|
|
204
113
|
if (!memos.has(currentRender)) {
|
|
205
114
|
memos.set(currentRender, []);
|
|
206
115
|
}
|
|
@@ -208,7 +117,7 @@ function useMemo(factory, deps) {
|
|
|
208
117
|
const prevMemo = componentMemos[memoIndex];
|
|
209
118
|
if (!prevMemo || deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i]))) {
|
|
210
119
|
const value = factory();
|
|
211
|
-
componentMemos[memoIndex] = { value, deps
|
|
120
|
+
componentMemos[memoIndex] = { value, deps };
|
|
212
121
|
stateIndices.set(currentRender, memoIndex + 1);
|
|
213
122
|
return value;
|
|
214
123
|
}
|
|
@@ -218,7 +127,7 @@ function useMemo(factory, deps) {
|
|
|
218
127
|
function useRef(initial) {
|
|
219
128
|
if (!currentRender)
|
|
220
129
|
throw new Error("useRef must be called within a render");
|
|
221
|
-
const refIndex = stateIndices.get(currentRender)
|
|
130
|
+
const refIndex = stateIndices.get(currentRender);
|
|
222
131
|
if (!refs.has(currentRender)) {
|
|
223
132
|
refs.set(currentRender, []);
|
|
224
133
|
}
|
|
@@ -235,9 +144,6 @@ function useRef(initial) {
|
|
|
235
144
|
}
|
|
236
145
|
async function rerender(rendererId) {
|
|
237
146
|
try {
|
|
238
|
-
if (isSSR) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
147
|
const componentEffects = effects.get(rendererId);
|
|
242
148
|
if (componentEffects) {
|
|
243
149
|
componentEffects.forEach((effect) => {
|
|
@@ -257,640 +163,133 @@ function useErrorBoundary() {
|
|
|
257
163
|
const [error, setError] = useState(null);
|
|
258
164
|
return [error, () => setError(null)];
|
|
259
165
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
166
|
+
function createContext(defaultValue) {
|
|
167
|
+
const context = {
|
|
168
|
+
Provider: ({ value, children }) => {
|
|
169
|
+
return children;
|
|
170
|
+
},
|
|
171
|
+
Consumer: ({ children }) => {
|
|
172
|
+
return children(defaultValue);
|
|
173
|
+
},
|
|
174
|
+
_id: Symbol(),
|
|
175
|
+
useSelector: (selector) => {
|
|
176
|
+
return selector(defaultValue);
|
|
271
177
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
console.log("Render completed successfully");
|
|
275
|
-
} catch (error) {
|
|
276
|
-
console.error("Error during render:", error);
|
|
277
|
-
throw error;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
async function hydrate(element, container) {
|
|
281
|
-
try {
|
|
282
|
-
console.log("Starting hydration...");
|
|
283
|
-
await render(element, container);
|
|
284
|
-
console.log("Hydration completed successfully");
|
|
285
|
-
} catch (error) {
|
|
286
|
-
console.error("Error during hydration:", error);
|
|
287
|
-
throw error;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function arePropsEqual(oldProps, newProps) {
|
|
291
|
-
const oldKeys = Object.keys(oldProps).filter((k) => k !== "children");
|
|
292
|
-
const newKeys = Object.keys(newProps).filter((k) => k !== "children");
|
|
293
|
-
if (oldKeys.length !== newKeys.length)
|
|
294
|
-
return false;
|
|
295
|
-
return oldKeys.every((key) => oldProps[key] === newProps[key]);
|
|
296
|
-
}
|
|
297
|
-
function diff(oldNode, newNode) {
|
|
298
|
-
if (oldNode == null || newNode == null)
|
|
299
|
-
return oldNode !== newNode;
|
|
300
|
-
if (typeof oldNode !== typeof newNode)
|
|
301
|
-
return true;
|
|
302
|
-
if (typeof newNode === "string" || typeof newNode === "number")
|
|
303
|
-
return oldNode !== newNode;
|
|
304
|
-
if (newNode.type !== oldNode.type)
|
|
305
|
-
return true;
|
|
306
|
-
return !arePropsEqual(oldNode.props, newNode.props);
|
|
178
|
+
};
|
|
179
|
+
return context;
|
|
307
180
|
}
|
|
308
|
-
function
|
|
309
|
-
return
|
|
181
|
+
function useContext(context) {
|
|
182
|
+
return context;
|
|
310
183
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
this.props = props;
|
|
317
|
-
}
|
|
318
|
-
componentDidMount() {
|
|
319
|
-
}
|
|
320
|
-
async setState(newState) {
|
|
321
|
-
const prevState = { ...this.state };
|
|
322
|
-
this.state = { ...prevState, ...newState };
|
|
323
|
-
console.log(`${this.constructor.name} state updated:`, {
|
|
324
|
-
prev: prevState,
|
|
325
|
-
next: this.state
|
|
326
|
-
});
|
|
327
|
-
await Promise.resolve();
|
|
328
|
-
if (this._mounted) {
|
|
329
|
-
await this.update();
|
|
330
|
-
} else {
|
|
331
|
-
await this.update();
|
|
332
|
-
}
|
|
184
|
+
function jsx(type, props) {
|
|
185
|
+
console.log("JSX Transform:", { type, props });
|
|
186
|
+
const processedProps = { ...props };
|
|
187
|
+
if (arguments.length > 2) {
|
|
188
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
|
333
189
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
190
|
+
return { type, props: processedProps };
|
|
191
|
+
}
|
|
192
|
+
var Fragment = ({ children }) => children;
|
|
193
|
+
async function createElement(vnode) {
|
|
194
|
+
var _a;
|
|
195
|
+
console.log("Creating element from:", vnode);
|
|
196
|
+
if (vnode == null) {
|
|
197
|
+
return document.createTextNode("");
|
|
340
198
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const events = node.__events || {};
|
|
344
|
-
clone.__events = events;
|
|
345
|
-
Object.entries(events).forEach(([event, handler]) => {
|
|
346
|
-
clone.addEventListener(event, handler);
|
|
347
|
-
});
|
|
348
|
-
Array.from(node.childNodes).forEach((child) => {
|
|
349
|
-
if (child instanceof HTMLElement) {
|
|
350
|
-
clone.appendChild(this._deepCloneWithEvents(child));
|
|
351
|
-
} else {
|
|
352
|
-
clone.appendChild(child.cloneNode(true));
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
return clone;
|
|
199
|
+
if (typeof vnode === "boolean") {
|
|
200
|
+
return document.createTextNode("");
|
|
356
201
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (!vdom)
|
|
360
|
-
return document.createTextNode("");
|
|
361
|
-
const rendered = await createElement(vdom);
|
|
362
|
-
if (rendered instanceof HTMLElement) {
|
|
363
|
-
return this._updateElement(rendered);
|
|
364
|
-
}
|
|
365
|
-
const wrapper = document.createElement("div");
|
|
366
|
-
wrapper.appendChild(rendered);
|
|
367
|
-
return this._updateElement(wrapper);
|
|
202
|
+
if (typeof vnode === "number" || typeof vnode === "string") {
|
|
203
|
+
return document.createTextNode(String(vnode));
|
|
368
204
|
}
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!this._mounted) {
|
|
375
|
-
this._mounted = true;
|
|
376
|
-
queueMicrotask(() => this.componentDidMount());
|
|
377
|
-
}
|
|
378
|
-
} else if (this.element.parentNode) {
|
|
379
|
-
this.element.parentNode.replaceChild(newElement, this.element);
|
|
380
|
-
this.element = newElement;
|
|
205
|
+
if (Array.isArray(vnode)) {
|
|
206
|
+
const fragment = document.createDocumentFragment();
|
|
207
|
+
for (const child of vnode) {
|
|
208
|
+
const node = await createElement(child);
|
|
209
|
+
fragment.appendChild(node);
|
|
381
210
|
}
|
|
382
|
-
return
|
|
383
|
-
}
|
|
384
|
-
render() {
|
|
385
|
-
throw new Error("Component must implement render() method");
|
|
211
|
+
return fragment;
|
|
386
212
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
pathname: "/",
|
|
391
|
-
search: "",
|
|
392
|
-
hash: ""
|
|
393
|
-
},
|
|
394
|
-
params: {},
|
|
395
|
-
navigate: () => {
|
|
396
|
-
},
|
|
397
|
-
match: () => false
|
|
398
|
-
});
|
|
399
|
-
function parsePath(path) {
|
|
400
|
-
const pattern = path.replace(/\/+$/, "").replace(/^\/+/, "/").replace(/\/:([^/]+)/g, "/([^/]+)");
|
|
401
|
-
const paramNames = [];
|
|
402
|
-
path.replace(/\/:([^/]+)/g, (_, paramName) => {
|
|
403
|
-
paramNames.push(paramName);
|
|
404
|
-
return "";
|
|
405
|
-
});
|
|
406
|
-
return { pattern, paramNames };
|
|
407
|
-
}
|
|
408
|
-
function matchPath(pathname, route) {
|
|
409
|
-
const { path, exact = false } = route;
|
|
410
|
-
const { pattern, paramNames } = parsePath(path);
|
|
411
|
-
const regex = new RegExp(`^${pattern}${exact ? "$" : ""}`);
|
|
412
|
-
const match = pathname.match(regex);
|
|
413
|
-
if (!match)
|
|
414
|
-
return null;
|
|
415
|
-
const params = {};
|
|
416
|
-
paramNames.forEach((name, index) => {
|
|
417
|
-
params[name] = match[index + 1];
|
|
418
|
-
});
|
|
419
|
-
return params;
|
|
420
|
-
}
|
|
421
|
-
function RouterProvider({ routes, children }) {
|
|
422
|
-
const getInitialLocation = () => {
|
|
423
|
-
if (typeof window === "undefined") {
|
|
424
|
-
return { pathname: "/", search: "", hash: "" };
|
|
425
|
-
}
|
|
426
|
-
return {
|
|
427
|
-
pathname: window.location.pathname,
|
|
428
|
-
search: window.location.search,
|
|
429
|
-
hash: window.location.hash
|
|
430
|
-
};
|
|
431
|
-
};
|
|
432
|
-
const [location, setLocation] = useState(getInitialLocation());
|
|
433
|
-
const [params, setParams] = useState({});
|
|
434
|
-
useEffect(() => {
|
|
435
|
-
for (const route of routes) {
|
|
436
|
-
const matchedParams = matchPath(location.pathname, route);
|
|
437
|
-
if (matchedParams) {
|
|
438
|
-
setParams(matchedParams);
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}, [location, routes]);
|
|
443
|
-
useEffect(() => {
|
|
444
|
-
if (typeof window === "undefined")
|
|
445
|
-
return;
|
|
446
|
-
const handlePopState = () => {
|
|
447
|
-
setLocation({
|
|
448
|
-
pathname: window.location.pathname,
|
|
449
|
-
search: window.location.search,
|
|
450
|
-
hash: window.location.hash
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
window.addEventListener("popstate", handlePopState);
|
|
454
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
455
|
-
}, []);
|
|
456
|
-
const navigate = (to, options = {}) => {
|
|
457
|
-
if (typeof window === "undefined")
|
|
458
|
-
return;
|
|
459
|
-
const { replace = false, state = null } = options;
|
|
460
|
-
if (replace) {
|
|
461
|
-
window.history.replaceState(state, "", to);
|
|
462
|
-
} else {
|
|
463
|
-
window.history.pushState(state, "", to);
|
|
464
|
-
}
|
|
465
|
-
setLocation({
|
|
466
|
-
pathname: window.location.pathname,
|
|
467
|
-
search: window.location.search,
|
|
468
|
-
hash: window.location.hash
|
|
469
|
-
});
|
|
470
|
-
};
|
|
471
|
-
const match = (path) => {
|
|
472
|
-
const { pattern } = parsePath(path);
|
|
473
|
-
const regex = new RegExp(`^${pattern}`);
|
|
474
|
-
return regex.test(location.pathname);
|
|
475
|
-
};
|
|
476
|
-
const routerValue = {
|
|
477
|
-
location: {
|
|
478
|
-
pathname: location.pathname,
|
|
479
|
-
search: location.search,
|
|
480
|
-
hash: location.hash
|
|
481
|
-
},
|
|
482
|
-
params,
|
|
483
|
-
navigate,
|
|
484
|
-
match
|
|
485
|
-
};
|
|
486
|
-
return jsx(RouterContext.Provider, { value: routerValue, children });
|
|
487
|
-
}
|
|
488
|
-
function Route({ path, component: Component2, props = {} }) {
|
|
489
|
-
const context = useContext();
|
|
490
|
-
const params = context.params;
|
|
491
|
-
const locationPathname = context.location.pathname;
|
|
492
|
-
const routeToMatch = { path, component: Component2 };
|
|
493
|
-
const match = matchPath(locationPathname, routeToMatch);
|
|
494
|
-
if (!match)
|
|
495
|
-
return null;
|
|
496
|
-
return jsx(Component2, { ...props, params });
|
|
497
|
-
}
|
|
498
|
-
function Switch({ children }) {
|
|
499
|
-
const context = useContext();
|
|
500
|
-
const locationPathname = context.location.pathname;
|
|
501
|
-
const child = Array.isArray(children) ? children.find((child2) => {
|
|
502
|
-
if (!child2 || typeof child2.type !== "function" || !child2.props.path)
|
|
503
|
-
return false;
|
|
504
|
-
const routeObj = {
|
|
505
|
-
path: child2.props.path,
|
|
506
|
-
component: child2.type,
|
|
507
|
-
exact: child2.props.exact || false
|
|
508
|
-
};
|
|
509
|
-
return matchPath(locationPathname, routeObj);
|
|
510
|
-
}) : children;
|
|
511
|
-
return child || null;
|
|
512
|
-
}
|
|
513
|
-
function Link({ to, replace = false, state = null, className = "", activeClassName = "", children, ...rest }) {
|
|
514
|
-
const context = useContext();
|
|
515
|
-
const navigate = context.navigate;
|
|
516
|
-
const match = context.match;
|
|
517
|
-
const handleClick = (e) => {
|
|
518
|
-
e.preventDefault();
|
|
519
|
-
navigate(to, { replace, state });
|
|
520
|
-
};
|
|
521
|
-
const isActive = match(to);
|
|
522
|
-
const classes = [
|
|
523
|
-
className,
|
|
524
|
-
isActive ? activeClassName : ""
|
|
525
|
-
].filter(Boolean).join(" ");
|
|
526
|
-
return jsx("a", {
|
|
527
|
-
href: to,
|
|
528
|
-
className: classes || void 0,
|
|
529
|
-
onClick: handleClick,
|
|
530
|
-
...rest,
|
|
531
|
-
children
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
function Redirect({ to, replace = true }) {
|
|
535
|
-
const context = useContext();
|
|
536
|
-
const navigate = context.navigate;
|
|
537
|
-
useEffect(() => {
|
|
538
|
-
navigate(to, { replace });
|
|
539
|
-
}, [to]);
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
|
-
function useLocation() {
|
|
543
|
-
const context = useContext();
|
|
544
|
-
return context.location;
|
|
545
|
-
}
|
|
546
|
-
function useParams() {
|
|
547
|
-
const context = useContext();
|
|
548
|
-
return context.params;
|
|
549
|
-
}
|
|
550
|
-
function useNavigate() {
|
|
551
|
-
const context = useContext();
|
|
552
|
-
return context.navigate;
|
|
553
|
-
}
|
|
554
|
-
function useForm(options) {
|
|
555
|
-
const { initialValues, validate, onSubmit } = options;
|
|
556
|
-
const [values, setValues] = useState(initialValues);
|
|
557
|
-
const [errors, setErrors] = useState({});
|
|
558
|
-
const [touched, setTouched] = useState({});
|
|
559
|
-
const [dirty, setDirty] = useState({});
|
|
560
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
561
|
-
const [submitCount, setSubmitCount] = useState(0);
|
|
562
|
-
const isValid = Object.keys(errors).length === 0;
|
|
563
|
-
const isDirty = Object.values(dirty).some(Boolean);
|
|
564
|
-
useEffect(() => {
|
|
565
|
-
if (validate) {
|
|
566
|
-
const validationErrors = validate(values);
|
|
567
|
-
setErrors(validationErrors || {});
|
|
568
|
-
}
|
|
569
|
-
}, [values, validate]);
|
|
570
|
-
const handleChange = (e) => {
|
|
571
|
-
const { name, value, type, checked } = e.target;
|
|
572
|
-
const fieldValue = type === "checkbox" ? checked : value;
|
|
573
|
-
setValues((prev) => ({
|
|
574
|
-
...prev,
|
|
575
|
-
[name]: fieldValue
|
|
576
|
-
}));
|
|
577
|
-
setDirty((prev) => ({
|
|
578
|
-
...prev,
|
|
579
|
-
[name]: true
|
|
580
|
-
}));
|
|
581
|
-
};
|
|
582
|
-
const handleBlur = (e) => {
|
|
583
|
-
const { name } = e.target;
|
|
584
|
-
setTouched((prev) => ({
|
|
585
|
-
...prev,
|
|
586
|
-
[name]: true
|
|
587
|
-
}));
|
|
588
|
-
};
|
|
589
|
-
const setFieldValue = (field, value) => {
|
|
590
|
-
setValues((prev) => ({
|
|
591
|
-
...prev,
|
|
592
|
-
[field]: value
|
|
593
|
-
}));
|
|
594
|
-
setDirty((prev) => ({
|
|
595
|
-
...prev,
|
|
596
|
-
[field]: true
|
|
597
|
-
}));
|
|
598
|
-
};
|
|
599
|
-
const setFieldError = (field, error) => {
|
|
600
|
-
setErrors((prev) => ({
|
|
601
|
-
...prev,
|
|
602
|
-
[field]: error
|
|
603
|
-
}));
|
|
604
|
-
};
|
|
605
|
-
const updateValues = (newValues) => {
|
|
606
|
-
setValues((prev) => ({
|
|
607
|
-
...prev,
|
|
608
|
-
...newValues
|
|
609
|
-
}));
|
|
610
|
-
const dirtyFields = {};
|
|
611
|
-
Object.keys(newValues).forEach((key) => {
|
|
612
|
-
dirtyFields[key] = true;
|
|
613
|
-
});
|
|
614
|
-
setDirty((prev) => ({
|
|
615
|
-
...prev,
|
|
616
|
-
...dirtyFields
|
|
617
|
-
}));
|
|
618
|
-
};
|
|
619
|
-
const resetForm = () => {
|
|
620
|
-
setValues(initialValues);
|
|
621
|
-
setErrors({});
|
|
622
|
-
setTouched({});
|
|
623
|
-
setDirty({});
|
|
624
|
-
setIsSubmitting(false);
|
|
625
|
-
};
|
|
626
|
-
const handleSubmit = async (e) => {
|
|
627
|
-
e.preventDefault();
|
|
628
|
-
const allTouched = {};
|
|
629
|
-
Object.keys(values).forEach((key) => {
|
|
630
|
-
allTouched[key] = true;
|
|
631
|
-
});
|
|
632
|
-
setTouched(allTouched);
|
|
633
|
-
let validationErrors = {};
|
|
634
|
-
if (validate) {
|
|
635
|
-
validationErrors = validate(values);
|
|
636
|
-
setErrors(validationErrors || {});
|
|
637
|
-
}
|
|
638
|
-
if (Object.keys(validationErrors).length === 0 && onSubmit) {
|
|
639
|
-
setIsSubmitting(true);
|
|
640
|
-
setSubmitCount((count) => count + 1);
|
|
213
|
+
if ("type" in vnode && vnode.props !== void 0) {
|
|
214
|
+
const { type, props } = vnode;
|
|
215
|
+
if (typeof type === "function") {
|
|
641
216
|
try {
|
|
642
|
-
await
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}, {}),
|
|
652
|
-
isValid,
|
|
653
|
-
isDirty,
|
|
654
|
-
isSubmitting: true,
|
|
655
|
-
submitCount: submitCount + 1
|
|
656
|
-
});
|
|
657
|
-
} finally {
|
|
658
|
-
setIsSubmitting(false);
|
|
217
|
+
const result = await type(props || {});
|
|
218
|
+
const node = await createElement(result);
|
|
219
|
+
if (node instanceof Element) {
|
|
220
|
+
node.setAttribute("data-component-id", type.name || type.toString());
|
|
221
|
+
}
|
|
222
|
+
return node;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.error("Error rendering component:", error);
|
|
225
|
+
return document.createTextNode("");
|
|
659
226
|
}
|
|
660
227
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const onceHandlers = /* @__PURE__ */ new WeakMap();
|
|
683
|
-
const on = (event, handler) => {
|
|
684
|
-
if (!events.has(event)) {
|
|
685
|
-
events.set(event, /* @__PURE__ */ new Set());
|
|
686
|
-
}
|
|
687
|
-
events.get(event).add(handler);
|
|
688
|
-
return () => off(event, handler);
|
|
689
|
-
};
|
|
690
|
-
const once = (event, handler) => {
|
|
691
|
-
const onceWrapper = (...args) => {
|
|
692
|
-
off(event, onceWrapper);
|
|
693
|
-
handler(...args);
|
|
694
|
-
};
|
|
695
|
-
onceHandlers.set(handler, onceWrapper);
|
|
696
|
-
return on(event, onceWrapper);
|
|
697
|
-
};
|
|
698
|
-
const off = (event, handler) => {
|
|
699
|
-
if (!handler) {
|
|
700
|
-
events.delete(event);
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
const wrappedHandler = onceHandlers.get(handler);
|
|
704
|
-
const handlerToRemove = wrappedHandler || handler;
|
|
705
|
-
if (events.has(event)) {
|
|
706
|
-
events.get(event).delete(handlerToRemove);
|
|
707
|
-
if (events.get(event).size === 0) {
|
|
708
|
-
events.delete(event);
|
|
228
|
+
const element = document.createElement(type);
|
|
229
|
+
for (const [key, value] of Object.entries(props || {})) {
|
|
230
|
+
if (key === "children")
|
|
231
|
+
continue;
|
|
232
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
233
|
+
const eventName = key.toLowerCase().slice(2);
|
|
234
|
+
const existingHandler = (_a = element.__events) == null ? void 0 : _a[eventName];
|
|
235
|
+
if (existingHandler) {
|
|
236
|
+
element.removeEventListener(eventName, existingHandler);
|
|
237
|
+
}
|
|
238
|
+
element.addEventListener(eventName, value);
|
|
239
|
+
if (!element.__events) {
|
|
240
|
+
element.__events = {};
|
|
241
|
+
}
|
|
242
|
+
element.__events[eventName] = value;
|
|
243
|
+
} else if (key === "style" && typeof value === "object") {
|
|
244
|
+
Object.assign(element.style, value);
|
|
245
|
+
} else if (key === "className") {
|
|
246
|
+
element.setAttribute("class", String(value));
|
|
247
|
+
} else if (key !== "key" && key !== "ref") {
|
|
248
|
+
element.setAttribute(key, String(value));
|
|
709
249
|
}
|
|
710
250
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
handler(...args);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
const clear = (event) => {
|
|
722
|
-
if (event) {
|
|
723
|
-
events.delete(event);
|
|
724
|
-
} else {
|
|
725
|
-
events.clear();
|
|
251
|
+
const children = props == null ? void 0 : props.children;
|
|
252
|
+
if (children != null) {
|
|
253
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
|
254
|
+
for (const child of childArray) {
|
|
255
|
+
const childNode = await createElement(child);
|
|
256
|
+
element.appendChild(childNode);
|
|
257
|
+
}
|
|
726
258
|
}
|
|
727
|
-
|
|
728
|
-
return { on, once, off, emit, clear };
|
|
729
|
-
}
|
|
730
|
-
var globalEventBus = createEventBus();
|
|
731
|
-
function useEvent(event, handler, options = {}) {
|
|
732
|
-
return options.once ? globalEventBus.once(event, handler) : globalEventBus.on(event, handler);
|
|
733
|
-
}
|
|
734
|
-
function createStore(reducer, initialState, middlewares = []) {
|
|
735
|
-
let state = initialState;
|
|
736
|
-
let listeners = [];
|
|
737
|
-
let dispatch = (action) => {
|
|
738
|
-
state = reducer(state, action);
|
|
739
|
-
listeners.forEach((listener) => listener());
|
|
740
|
-
return action;
|
|
741
|
-
};
|
|
742
|
-
if (middlewares.length > 0) {
|
|
743
|
-
const middlewareAPI = {
|
|
744
|
-
getState: () => state,
|
|
745
|
-
dispatch: (action) => dispatch(action),
|
|
746
|
-
subscribe: (listener) => subscribe(listener)
|
|
747
|
-
};
|
|
748
|
-
const chain = middlewares.map((middleware) => middleware(middlewareAPI));
|
|
749
|
-
dispatch = chain.reduce((a, b) => (next) => a(b(next)))(dispatch);
|
|
259
|
+
return element;
|
|
750
260
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
261
|
+
return document.createTextNode(String(vnode));
|
|
262
|
+
}
|
|
263
|
+
var isHydrating = false;
|
|
264
|
+
async function hydrate(element, container) {
|
|
265
|
+
isHydrating = true;
|
|
266
|
+
try {
|
|
267
|
+
await render(element, container);
|
|
268
|
+
} finally {
|
|
269
|
+
isHydrating = false;
|
|
756
270
|
}
|
|
757
|
-
dispatch({ type: "@@INIT" });
|
|
758
|
-
return {
|
|
759
|
-
getState: () => state,
|
|
760
|
-
dispatch,
|
|
761
|
-
subscribe
|
|
762
|
-
};
|
|
763
271
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
272
|
+
async function render(element, container) {
|
|
273
|
+
console.log("Rendering to:", container.id);
|
|
274
|
+
batchUpdates(async () => {
|
|
275
|
+
const rendererId = prepareRender();
|
|
276
|
+
try {
|
|
277
|
+
setRenderCallback(render, element, container);
|
|
278
|
+
const domNode = await createElement(element);
|
|
279
|
+
if (!isHydrating) {
|
|
280
|
+
container.innerHTML = "";
|
|
281
|
+
}
|
|
282
|
+
container.appendChild(domNode);
|
|
283
|
+
} finally {
|
|
284
|
+
finishRender();
|
|
770
285
|
}
|
|
771
|
-
},
|
|
772
|
-
state: {}
|
|
773
|
-
});
|
|
774
|
-
function StoreProvider({ store, children }) {
|
|
775
|
-
const [state, setState] = useState(store.getState());
|
|
776
|
-
useEffect(() => {
|
|
777
|
-
const unsubscribe = store.subscribe(() => {
|
|
778
|
-
setState(store.getState());
|
|
779
|
-
});
|
|
780
|
-
return unsubscribe;
|
|
781
|
-
}, [store]);
|
|
782
|
-
return jsx(StoreContext.Provider, {
|
|
783
|
-
value: { store, state },
|
|
784
|
-
children
|
|
785
286
|
});
|
|
786
287
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
function useDispatch() {
|
|
792
|
-
const context = useContext();
|
|
793
|
-
return context.store.dispatch;
|
|
794
|
-
}
|
|
795
|
-
function useStore() {
|
|
796
|
-
const context = useContext();
|
|
797
|
-
return context.store;
|
|
798
|
-
}
|
|
799
|
-
var logger = (store) => (next) => (action) => {
|
|
800
|
-
console.group(action.type);
|
|
801
|
-
console.log("Previous state:", store.getState());
|
|
802
|
-
console.log("Action:", action);
|
|
803
|
-
const result = next(action);
|
|
804
|
-
console.log("Next state:", store.getState());
|
|
805
|
-
console.groupEnd();
|
|
806
|
-
return result;
|
|
807
|
-
};
|
|
808
|
-
var thunk = (store) => (next) => (action) => {
|
|
809
|
-
if (typeof action === "function") {
|
|
810
|
-
return action(store.dispatch, store.getState);
|
|
288
|
+
var server = {
|
|
289
|
+
async getServer() {
|
|
290
|
+
throw new Error("Server module can only be used in Node.js environment");
|
|
811
291
|
}
|
|
812
|
-
return next(action);
|
|
813
292
|
};
|
|
814
|
-
var LifecycleEvents;
|
|
815
|
-
(function(LifecycleEvents2) {
|
|
816
|
-
LifecycleEvents2["APP_INIT"] = "app:init";
|
|
817
|
-
LifecycleEvents2["APP_MOUNTED"] = "app:mounted";
|
|
818
|
-
LifecycleEvents2["APP_UPDATED"] = "app:updated";
|
|
819
|
-
LifecycleEvents2["APP_ERROR"] = "app:error";
|
|
820
|
-
LifecycleEvents2["APP_DESTROYED"] = "app:destroyed";
|
|
821
|
-
LifecycleEvents2["COMPONENT_CREATED"] = "component:created";
|
|
822
|
-
LifecycleEvents2["COMPONENT_MOUNTED"] = "component:mounted";
|
|
823
|
-
LifecycleEvents2["COMPONENT_UPDATED"] = "component:updated";
|
|
824
|
-
LifecycleEvents2["COMPONENT_ERROR"] = "component:error";
|
|
825
|
-
LifecycleEvents2["COMPONENT_UNMOUNTED"] = "component:unmounted";
|
|
826
|
-
LifecycleEvents2["ROUTER_BEFORE_CHANGE"] = "router:before-change";
|
|
827
|
-
LifecycleEvents2["ROUTER_AFTER_CHANGE"] = "router:after-change";
|
|
828
|
-
LifecycleEvents2["ROUTER_ERROR"] = "router:error";
|
|
829
|
-
LifecycleEvents2["STORE_INITIALIZED"] = "store:initialized";
|
|
830
|
-
LifecycleEvents2["STORE_BEFORE_ACTION"] = "store:before-action";
|
|
831
|
-
LifecycleEvents2["STORE_AFTER_ACTION"] = "store:after-action";
|
|
832
|
-
LifecycleEvents2["STORE_ERROR"] = "store:error";
|
|
833
|
-
})(LifecycleEvents || (LifecycleEvents = {}));
|
|
834
|
-
function emitAppInit(data) {
|
|
835
|
-
globalEventBus.emit(LifecycleEvents.APP_INIT, data);
|
|
836
|
-
}
|
|
837
|
-
function emitAppMounted(rootElement) {
|
|
838
|
-
globalEventBus.emit(LifecycleEvents.APP_MOUNTED, rootElement);
|
|
839
|
-
}
|
|
840
|
-
function emitAppUpdated() {
|
|
841
|
-
globalEventBus.emit(LifecycleEvents.APP_UPDATED);
|
|
842
|
-
}
|
|
843
|
-
function emitAppError(error) {
|
|
844
|
-
globalEventBus.emit(LifecycleEvents.APP_ERROR, error);
|
|
845
|
-
}
|
|
846
|
-
function emitAppDestroyed() {
|
|
847
|
-
globalEventBus.emit(LifecycleEvents.APP_DESTROYED);
|
|
848
|
-
}
|
|
849
|
-
function emitComponentCreated(info) {
|
|
850
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_CREATED, info);
|
|
851
|
-
}
|
|
852
|
-
function emitComponentMounted(info, element) {
|
|
853
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_MOUNTED, info, element);
|
|
854
|
-
}
|
|
855
|
-
function emitComponentUpdated(info, prevProps, newProps) {
|
|
856
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_UPDATED, info, prevProps, newProps);
|
|
857
|
-
}
|
|
858
|
-
function emitComponentError(info, error) {
|
|
859
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_ERROR, info, error);
|
|
860
|
-
}
|
|
861
|
-
function emitComponentUnmounted(info) {
|
|
862
|
-
globalEventBus.emit(LifecycleEvents.COMPONENT_UNMOUNTED, info);
|
|
863
|
-
}
|
|
864
|
-
function onAppInit(handler) {
|
|
865
|
-
return globalEventBus.on(LifecycleEvents.APP_INIT, handler);
|
|
866
|
-
}
|
|
867
|
-
function onAppMounted(handler) {
|
|
868
|
-
return globalEventBus.on(LifecycleEvents.APP_MOUNTED, handler);
|
|
869
|
-
}
|
|
870
|
-
function onAppUpdated(handler) {
|
|
871
|
-
return globalEventBus.on(LifecycleEvents.APP_UPDATED, handler);
|
|
872
|
-
}
|
|
873
|
-
function onAppError(handler) {
|
|
874
|
-
return globalEventBus.on(LifecycleEvents.APP_ERROR, handler);
|
|
875
|
-
}
|
|
876
|
-
function onAppDestroyed(handler) {
|
|
877
|
-
return globalEventBus.on(LifecycleEvents.APP_DESTROYED, handler);
|
|
878
|
-
}
|
|
879
|
-
function onComponentCreated(handler) {
|
|
880
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_CREATED, handler);
|
|
881
|
-
}
|
|
882
|
-
function onComponentMounted(handler) {
|
|
883
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_MOUNTED, handler);
|
|
884
|
-
}
|
|
885
|
-
function onComponentUpdated(handler) {
|
|
886
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_UPDATED, handler);
|
|
887
|
-
}
|
|
888
|
-
function onComponentError(handler) {
|
|
889
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_ERROR, handler);
|
|
890
|
-
}
|
|
891
|
-
function onComponentUnmounted(handler) {
|
|
892
|
-
return globalEventBus.on(LifecycleEvents.COMPONENT_UNMOUNTED, handler);
|
|
893
|
-
}
|
|
894
293
|
|
|
895
294
|
// src/wasm.ts
|
|
896
295
|
async function loadGoWasm(wasmUrl, options = {}) {
|
|
@@ -981,194 +380,50 @@ function useGoWasm(wasmUrl, options = {}) {
|
|
|
981
380
|
};
|
|
982
381
|
}
|
|
983
382
|
|
|
984
|
-
// src/
|
|
383
|
+
// src/browser.ts
|
|
985
384
|
function generateDocument(content, options = {}) {
|
|
986
|
-
const {
|
|
987
|
-
title = "Frontend Hamroun App",
|
|
988
|
-
description = "",
|
|
989
|
-
lang = "en",
|
|
990
|
-
charset = "UTF-8",
|
|
991
|
-
viewport = "width=device-width, initial-scale=1.0",
|
|
992
|
-
scripts = [],
|
|
993
|
-
styles = [],
|
|
994
|
-
meta = {},
|
|
995
|
-
bodyClasses = "",
|
|
996
|
-
htmlAttrs = {},
|
|
997
|
-
bodyAttrs = {},
|
|
998
|
-
initialData = {},
|
|
999
|
-
componentName = ""
|
|
1000
|
-
} = options;
|
|
1001
|
-
const htmlAttributes = Object.entries(htmlAttrs).map(([key, value]) => `${key}="${escapeHtml(value)}"`).join(" ");
|
|
1002
|
-
const bodyAttributes = Object.entries(bodyAttrs).map(([key, value]) => `${key}="${escapeHtml(value)}"`).join(" ");
|
|
1003
|
-
const metaTags = [
|
|
1004
|
-
`<meta charset="${charset}">`,
|
|
1005
|
-
`<meta name="viewport" content="${viewport}">`,
|
|
1006
|
-
description ? `<meta name="description" content="${escapeHtml(description)}">` : ""
|
|
1007
|
-
];
|
|
1008
|
-
Object.entries(meta).forEach(([name, content2]) => {
|
|
1009
|
-
metaTags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(content2)}">`);
|
|
1010
|
-
});
|
|
1011
|
-
const scriptTags = scripts.map((src) => {
|
|
1012
|
-
if (src.startsWith("<script")) {
|
|
1013
|
-
return src;
|
|
1014
|
-
}
|
|
1015
|
-
return `<script src="${escapeHtml(src)}" ${src.endsWith(".js") ? 'type="module"' : ""} defer><\/script>`;
|
|
1016
|
-
});
|
|
1017
|
-
const styleTags = styles.map((href) => {
|
|
1018
|
-
if (href.startsWith("<style")) {
|
|
1019
|
-
return href;
|
|
1020
|
-
}
|
|
1021
|
-
return `<link rel="stylesheet" href="${escapeHtml(href)}">`;
|
|
1022
|
-
});
|
|
1023
|
-
const initialDataScript = Object.keys(initialData).length > 0 ? `<script id="__APP_DATA__" type="application/json">${escapeHtml(JSON.stringify(initialData))}<\/script>` : "";
|
|
385
|
+
const { title = "App", description = "", styles = [], scripts = [] } = options;
|
|
1024
386
|
return `<!DOCTYPE html>
|
|
1025
|
-
<html lang="
|
|
387
|
+
<html lang="en">
|
|
1026
388
|
<head>
|
|
1027
|
-
|
|
389
|
+
<meta charset="UTF-8">
|
|
390
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1028
391
|
<title>${escapeHtml(title)}</title>
|
|
1029
|
-
${
|
|
392
|
+
${description ? `<meta name="description" content="${escapeHtml(description)}">` : ""}
|
|
393
|
+
${styles.map((href) => `<link rel="stylesheet" href="${escapeHtml(href)}">`).join("\n ")}
|
|
1030
394
|
</head>
|
|
1031
|
-
<body
|
|
1032
|
-
<div id="app-root"
|
|
1033
|
-
${
|
|
1034
|
-
${scriptTags.join("\n ")}
|
|
395
|
+
<body>
|
|
396
|
+
<div id="app-root">${content}</div>
|
|
397
|
+
${scripts.map((src) => `<script src="${escapeHtml(src)}" defer><\/script>`).join("\n ")}
|
|
1035
398
|
</body>
|
|
1036
399
|
</html>`;
|
|
1037
400
|
}
|
|
1038
|
-
function generateErrorPage(statusCode, message
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
401: "Unauthorized",
|
|
1042
|
-
403: "Forbidden",
|
|
1043
|
-
404: "Not Found",
|
|
1044
|
-
500: "Internal Server Error"
|
|
1045
|
-
};
|
|
1046
|
-
const title = `${statusCode} - ${errorMessages[statusCode] || "Error"}`;
|
|
1047
|
-
const isDev = false;
|
|
1048
|
-
const errorDetails = isDev && error ? `
|
|
1049
|
-
<div class="error-details">
|
|
1050
|
-
<pre>${escapeHtml(error.stack || error.message)}</pre>
|
|
1051
|
-
</div>
|
|
1052
|
-
` : "";
|
|
1053
|
-
const content = `
|
|
1054
|
-
<div class="error-container">
|
|
401
|
+
function generateErrorPage(statusCode, message) {
|
|
402
|
+
return generateDocument(`
|
|
403
|
+
<div style="text-align: center; padding: 2rem;">
|
|
1055
404
|
<h1>${statusCode}</h1>
|
|
1056
|
-
<h2>${escapeHtml(errorMessages[statusCode] || "Error")}</h2>
|
|
1057
405
|
<p>${escapeHtml(message)}</p>
|
|
1058
|
-
|
|
1059
|
-
<a href="/" class="home-link">Back to Home</a>
|
|
406
|
+
<a href="/">Back to Home</a>
|
|
1060
407
|
</div>
|
|
1061
|
-
|
|
1062
|
-
const styles = [`<style>
|
|
1063
|
-
body {
|
|
1064
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
1065
|
-
display: flex;
|
|
1066
|
-
justify-content: center;
|
|
1067
|
-
align-items: center;
|
|
1068
|
-
min-height: 100vh;
|
|
1069
|
-
margin: 0;
|
|
1070
|
-
background-color: #f7f7f7;
|
|
1071
|
-
color: #333;
|
|
1072
|
-
}
|
|
1073
|
-
.error-container {
|
|
1074
|
-
text-align: center;
|
|
1075
|
-
padding: 2rem;
|
|
1076
|
-
border-radius: 8px;
|
|
1077
|
-
background-color: white;
|
|
1078
|
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
1079
|
-
max-width: 600px;
|
|
1080
|
-
width: 100%;
|
|
1081
|
-
}
|
|
1082
|
-
h1 {
|
|
1083
|
-
font-size: 6rem;
|
|
1084
|
-
margin: 0;
|
|
1085
|
-
color: #e74c3c;
|
|
1086
|
-
}
|
|
1087
|
-
h2 {
|
|
1088
|
-
margin-top: 0;
|
|
1089
|
-
margin-bottom: 1rem;
|
|
1090
|
-
color: #333;
|
|
1091
|
-
}
|
|
1092
|
-
.error-details {
|
|
1093
|
-
text-align: left;
|
|
1094
|
-
margin: 2rem 0;
|
|
1095
|
-
padding: 1rem;
|
|
1096
|
-
background-color: #f8f8f8;
|
|
1097
|
-
border-radius: 4px;
|
|
1098
|
-
overflow: auto;
|
|
1099
|
-
}
|
|
1100
|
-
pre {
|
|
1101
|
-
margin: 0;
|
|
1102
|
-
font-family: monospace;
|
|
1103
|
-
font-size: 0.85rem;
|
|
1104
|
-
white-space: pre-wrap;
|
|
1105
|
-
}
|
|
1106
|
-
.home-link {
|
|
1107
|
-
display: inline-block;
|
|
1108
|
-
margin-top: 1.5rem;
|
|
1109
|
-
padding: 0.75rem 1.5rem;
|
|
1110
|
-
background-color: #3498db;
|
|
1111
|
-
color: white;
|
|
1112
|
-
text-decoration: none;
|
|
1113
|
-
border-radius: 4px;
|
|
1114
|
-
transition: background-color 0.2s;
|
|
1115
|
-
}
|
|
1116
|
-
.home-link:hover {
|
|
1117
|
-
background-color: #2980b9;
|
|
1118
|
-
}
|
|
1119
|
-
</style>`];
|
|
1120
|
-
return generateDocument(content, {
|
|
1121
|
-
title,
|
|
1122
|
-
description: `Error ${statusCode}: ${errorMessages[statusCode] || "Error"}`,
|
|
1123
|
-
bodyClasses: "error-page",
|
|
1124
|
-
styles
|
|
1125
|
-
});
|
|
408
|
+
`, { title: `Error ${statusCode}` });
|
|
1126
409
|
}
|
|
1127
410
|
function generateLoadingPage(message = "Loading...") {
|
|
1128
|
-
|
|
1129
|
-
<div
|
|
1130
|
-
<div
|
|
411
|
+
return generateDocument(`
|
|
412
|
+
<div style="text-align: center; padding: 2rem;">
|
|
413
|
+
<div style="display: inline-block; width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; animation: spin 1s linear infinite;"></div>
|
|
1131
414
|
<p>${escapeHtml(message)}</p>
|
|
415
|
+
<style>
|
|
416
|
+
@keyframes spin {
|
|
417
|
+
0% { transform: rotate(0deg); }
|
|
418
|
+
100% { transform: rotate(360deg); }
|
|
419
|
+
}
|
|
420
|
+
</style>
|
|
1132
421
|
</div>
|
|
1133
|
-
|
|
1134
|
-
const styles = [`<style>
|
|
1135
|
-
body {
|
|
1136
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
1137
|
-
display: flex;
|
|
1138
|
-
justify-content: center;
|
|
1139
|
-
align-items: center;
|
|
1140
|
-
min-height: 100vh;
|
|
1141
|
-
margin: 0;
|
|
1142
|
-
background-color: #f7f7f7;
|
|
1143
|
-
color: #333;
|
|
1144
|
-
}
|
|
1145
|
-
.loading-container {
|
|
1146
|
-
text-align: center;
|
|
1147
|
-
}
|
|
1148
|
-
.spinner {
|
|
1149
|
-
width: 50px;
|
|
1150
|
-
height: 50px;
|
|
1151
|
-
border: 5px solid rgba(0, 0, 0, 0.1);
|
|
1152
|
-
border-radius: 50%;
|
|
1153
|
-
border-top-color: #3498db;
|
|
1154
|
-
animation: spin 1s ease-in-out infinite;
|
|
1155
|
-
margin: 0 auto 20px;
|
|
1156
|
-
}
|
|
1157
|
-
@keyframes spin {
|
|
1158
|
-
to { transform: rotate(360deg); }
|
|
1159
|
-
}
|
|
1160
|
-
</style>`];
|
|
1161
|
-
return generateDocument(content, {
|
|
1162
|
-
title: "Loading",
|
|
1163
|
-
bodyClasses: "loading-page",
|
|
1164
|
-
styles
|
|
1165
|
-
});
|
|
422
|
+
`, { title: "Loading" });
|
|
1166
423
|
}
|
|
1167
424
|
function escapeHtml(text) {
|
|
1168
425
|
return String(text).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1169
426
|
}
|
|
1170
|
-
|
|
1171
|
-
// src/browser.ts
|
|
1172
427
|
function renderToString(content) {
|
|
1173
428
|
if (typeof content === "string") {
|
|
1174
429
|
return content;
|
|
@@ -1203,78 +458,60 @@ function safeJsonParse(json, fallback) {
|
|
|
1203
458
|
}
|
|
1204
459
|
var isBrowser = typeof window !== "undefined";
|
|
1205
460
|
var isNode = false;
|
|
461
|
+
var Server = null;
|
|
462
|
+
var createServer = null;
|
|
463
|
+
var createDevServer = null;
|
|
464
|
+
var createProductionServer = null;
|
|
465
|
+
var Database = null;
|
|
466
|
+
var AuthService = null;
|
|
467
|
+
var ApiRouter = null;
|
|
468
|
+
var requestLogger = null;
|
|
469
|
+
var errorHandler = null;
|
|
470
|
+
var notFoundHandler = null;
|
|
471
|
+
var rateLimit = null;
|
|
472
|
+
var initNodeWasm = null;
|
|
473
|
+
var loadGoWasmFromFile = null;
|
|
1206
474
|
console.log("Baraqex - Browser version loaded");
|
|
1207
475
|
export {
|
|
1208
|
-
|
|
476
|
+
ApiRouter,
|
|
477
|
+
AuthService,
|
|
478
|
+
Database,
|
|
1209
479
|
Fragment,
|
|
1210
|
-
|
|
1211
|
-
Link,
|
|
1212
|
-
Redirect,
|
|
1213
|
-
Route,
|
|
1214
|
-
RouterProvider,
|
|
1215
|
-
StoreProvider,
|
|
1216
|
-
Switch,
|
|
480
|
+
Server,
|
|
1217
481
|
batchUpdates,
|
|
1218
482
|
callWasmFunction,
|
|
1219
483
|
createContext,
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
emitAppDestroyed,
|
|
1225
|
-
emitAppError,
|
|
1226
|
-
emitAppInit,
|
|
1227
|
-
emitAppMounted,
|
|
1228
|
-
emitAppUpdated,
|
|
1229
|
-
emitComponentCreated,
|
|
1230
|
-
emitComponentError,
|
|
1231
|
-
emitComponentMounted,
|
|
1232
|
-
emitComponentUnmounted,
|
|
1233
|
-
emitComponentUpdated,
|
|
1234
|
-
globalEventBus as eventBus,
|
|
484
|
+
createDevServer,
|
|
485
|
+
createProductionServer,
|
|
486
|
+
createServer,
|
|
487
|
+
errorHandler,
|
|
1235
488
|
generateDocument,
|
|
1236
489
|
generateErrorPage,
|
|
1237
490
|
generateLoadingPage,
|
|
1238
491
|
generateToken,
|
|
1239
492
|
getWasmFunctions,
|
|
1240
493
|
hydrate,
|
|
494
|
+
initNodeWasm,
|
|
1241
495
|
isBrowser,
|
|
1242
496
|
isNode,
|
|
1243
497
|
isWasmReady,
|
|
1244
498
|
jsx,
|
|
1245
|
-
jsx as jsxDEV,
|
|
1246
499
|
jsx as jsxs,
|
|
1247
500
|
loadGoWasm,
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
onAppInit,
|
|
1252
|
-
onAppMounted,
|
|
1253
|
-
onAppUpdated,
|
|
1254
|
-
onComponentCreated,
|
|
1255
|
-
onComponentError,
|
|
1256
|
-
onComponentMounted,
|
|
1257
|
-
onComponentUnmounted,
|
|
1258
|
-
onComponentUpdated,
|
|
501
|
+
loadGoWasmFromFile,
|
|
502
|
+
notFoundHandler,
|
|
503
|
+
rateLimit,
|
|
1259
504
|
render,
|
|
1260
505
|
renderToString,
|
|
506
|
+
requestLogger,
|
|
1261
507
|
safeJsonParse,
|
|
1262
|
-
|
|
1263
|
-
thunk,
|
|
508
|
+
server,
|
|
1264
509
|
useContext,
|
|
1265
|
-
useDispatch,
|
|
1266
510
|
useEffect,
|
|
1267
511
|
useErrorBoundary,
|
|
1268
|
-
useEvent,
|
|
1269
|
-
useForm,
|
|
1270
512
|
useGoWasm,
|
|
1271
|
-
useLocation,
|
|
1272
513
|
useMemo,
|
|
1273
|
-
useNavigate,
|
|
1274
|
-
useParams,
|
|
1275
514
|
useRef,
|
|
1276
|
-
|
|
1277
|
-
useState,
|
|
1278
|
-
useStore
|
|
515
|
+
useState
|
|
1279
516
|
};
|
|
1280
517
|
//# sourceMappingURL=browser.js.map
|