baraqex 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +786 -141
- package/dist/browser.js.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +893 -223
- package/dist/index.js.map +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +221 -85
- package/dist/server/index.js.map +4 -4
- package/package.json +14 -10
- package/templates/ssr-template/package-lock.json +160 -1395
- package/templates/ssr-template/package.json +1 -1
- package/templates/ssr-template/src/App.tsx +1 -1
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,82 @@
|
|
|
1
|
-
// node_modules/frontend-hamroun/dist/index.
|
|
1
|
+
// node_modules/frontend-hamroun/dist/index.js
|
|
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
|
+
}
|
|
2
80
|
var isBatching = false;
|
|
3
81
|
var queue = [];
|
|
4
82
|
function batchUpdates(fn) {
|
|
@@ -11,13 +89,35 @@ function batchUpdates(fn) {
|
|
|
11
89
|
fn();
|
|
12
90
|
while (queue.length > 0) {
|
|
13
91
|
const nextFn = queue.shift();
|
|
14
|
-
nextFn
|
|
92
|
+
nextFn?.();
|
|
15
93
|
}
|
|
16
94
|
} finally {
|
|
17
95
|
isBatching = false;
|
|
18
96
|
}
|
|
19
97
|
}
|
|
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
|
+
}
|
|
20
119
|
var currentRender = 0;
|
|
120
|
+
var isSSR = false;
|
|
21
121
|
var states = /* @__PURE__ */ new Map();
|
|
22
122
|
var stateIndices = /* @__PURE__ */ new Map();
|
|
23
123
|
var effects = /* @__PURE__ */ new Map();
|
|
@@ -26,53 +126,39 @@ var refs = /* @__PURE__ */ new Map();
|
|
|
26
126
|
var globalRenderCallback = null;
|
|
27
127
|
var globalContainer = null;
|
|
28
128
|
var currentElement = null;
|
|
29
|
-
var isServer = typeof window === "undefined";
|
|
30
|
-
var serverStates = /* @__PURE__ */ new Map();
|
|
31
129
|
function setRenderCallback(callback, element, container) {
|
|
32
130
|
globalRenderCallback = callback;
|
|
33
131
|
globalContainer = container;
|
|
34
132
|
currentElement = element;
|
|
35
133
|
}
|
|
36
|
-
function prepareRender() {
|
|
134
|
+
function prepareRender(component = null, isServerSideRender = false) {
|
|
37
135
|
currentRender++;
|
|
136
|
+
isSSR = isServerSideRender;
|
|
38
137
|
stateIndices.set(currentRender, 0);
|
|
138
|
+
if (!states.has(currentRender)) {
|
|
139
|
+
states.set(currentRender, []);
|
|
140
|
+
}
|
|
39
141
|
return currentRender;
|
|
40
142
|
}
|
|
41
143
|
function finishRender() {
|
|
42
|
-
if (isServer) {
|
|
43
|
-
serverStates.delete(currentRender);
|
|
44
|
-
}
|
|
45
|
-
currentRender = 0;
|
|
46
144
|
}
|
|
47
145
|
function useState(initial) {
|
|
48
146
|
if (!currentRender) {
|
|
49
147
|
throw new Error("useState must be called within a render");
|
|
50
148
|
}
|
|
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
|
-
}
|
|
66
149
|
if (!states.has(currentRender)) {
|
|
67
150
|
states.set(currentRender, []);
|
|
68
151
|
}
|
|
69
152
|
const componentStates = states.get(currentRender);
|
|
70
|
-
const index = stateIndices.get(currentRender);
|
|
153
|
+
const index = stateIndices.get(currentRender) || 0;
|
|
71
154
|
if (index >= componentStates.length) {
|
|
72
155
|
componentStates.push(initial);
|
|
73
156
|
}
|
|
74
157
|
const state = componentStates[index];
|
|
75
158
|
const setState = (newValue) => {
|
|
159
|
+
if (isSSR) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
76
162
|
const nextValue = typeof newValue === "function" ? newValue(componentStates[index]) : newValue;
|
|
77
163
|
if (componentStates[index] === nextValue)
|
|
78
164
|
return;
|
|
@@ -89,19 +175,24 @@ function useState(initial) {
|
|
|
89
175
|
function useEffect(callback, deps) {
|
|
90
176
|
if (!currentRender)
|
|
91
177
|
throw new Error("useEffect must be called within a render");
|
|
92
|
-
|
|
178
|
+
if (isSSR) {
|
|
179
|
+
const effectIndex2 = stateIndices.get(currentRender) || 0;
|
|
180
|
+
stateIndices.set(currentRender, effectIndex2 + 1);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const effectIndex = stateIndices.get(currentRender) || 0;
|
|
93
184
|
if (!effects.has(currentRender)) {
|
|
94
185
|
effects.set(currentRender, []);
|
|
95
186
|
}
|
|
96
187
|
const componentEffects = effects.get(currentRender);
|
|
97
188
|
const prevEffect = componentEffects[effectIndex];
|
|
98
189
|
if (!prevEffect || !deps || !prevEffect.deps || deps.some((dep, i) => dep !== prevEffect.deps[i])) {
|
|
99
|
-
if (prevEffect
|
|
190
|
+
if (prevEffect?.cleanup) {
|
|
100
191
|
prevEffect.cleanup();
|
|
101
192
|
}
|
|
102
193
|
queueMicrotask(() => {
|
|
103
194
|
const cleanup = callback() || void 0;
|
|
104
|
-
componentEffects[effectIndex] = { cleanup, deps };
|
|
195
|
+
componentEffects[effectIndex] = { cleanup, deps: deps || [] };
|
|
105
196
|
});
|
|
106
197
|
}
|
|
107
198
|
stateIndices.set(currentRender, effectIndex + 1);
|
|
@@ -109,7 +200,7 @@ function useEffect(callback, deps) {
|
|
|
109
200
|
function useMemo(factory, deps) {
|
|
110
201
|
if (!currentRender)
|
|
111
202
|
throw new Error("useMemo must be called within a render");
|
|
112
|
-
const memoIndex = stateIndices.get(currentRender);
|
|
203
|
+
const memoIndex = stateIndices.get(currentRender) || 0;
|
|
113
204
|
if (!memos.has(currentRender)) {
|
|
114
205
|
memos.set(currentRender, []);
|
|
115
206
|
}
|
|
@@ -117,7 +208,7 @@ function useMemo(factory, deps) {
|
|
|
117
208
|
const prevMemo = componentMemos[memoIndex];
|
|
118
209
|
if (!prevMemo || deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i]))) {
|
|
119
210
|
const value = factory();
|
|
120
|
-
componentMemos[memoIndex] = { value, deps };
|
|
211
|
+
componentMemos[memoIndex] = { value, deps: deps || [] };
|
|
121
212
|
stateIndices.set(currentRender, memoIndex + 1);
|
|
122
213
|
return value;
|
|
123
214
|
}
|
|
@@ -127,7 +218,7 @@ function useMemo(factory, deps) {
|
|
|
127
218
|
function useRef(initial) {
|
|
128
219
|
if (!currentRender)
|
|
129
220
|
throw new Error("useRef must be called within a render");
|
|
130
|
-
const refIndex = stateIndices.get(currentRender);
|
|
221
|
+
const refIndex = stateIndices.get(currentRender) || 0;
|
|
131
222
|
if (!refs.has(currentRender)) {
|
|
132
223
|
refs.set(currentRender, []);
|
|
133
224
|
}
|
|
@@ -144,6 +235,9 @@ function useRef(initial) {
|
|
|
144
235
|
}
|
|
145
236
|
async function rerender(rendererId) {
|
|
146
237
|
try {
|
|
238
|
+
if (isSSR) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
147
241
|
const componentEffects = effects.get(rendererId);
|
|
148
242
|
if (componentEffects) {
|
|
149
243
|
componentEffects.forEach((effect) => {
|
|
@@ -163,133 +257,640 @@ function useErrorBoundary() {
|
|
|
163
257
|
const [error, setError] = useState(null);
|
|
164
258
|
return [error, () => setError(null)];
|
|
165
259
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
260
|
+
async function render(element, container) {
|
|
261
|
+
try {
|
|
262
|
+
setRenderCallback(render, element, container);
|
|
263
|
+
const renderId = prepareRender(element);
|
|
264
|
+
const domNode = await createElement(element);
|
|
265
|
+
if (container instanceof Element) {
|
|
266
|
+
container.innerHTML = "";
|
|
267
|
+
} else {
|
|
268
|
+
while (container.firstChild) {
|
|
269
|
+
container.removeChild(container.firstChild);
|
|
270
|
+
}
|
|
177
271
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
272
|
+
container.appendChild(domNode);
|
|
273
|
+
finishRender();
|
|
274
|
+
console.log("Render completed successfully");
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error("Error during render:", error);
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
183
279
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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;
|
|
189
288
|
}
|
|
190
|
-
return { type, props: processedProps };
|
|
191
289
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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);
|
|
307
|
+
}
|
|
308
|
+
function shouldComponentUpdate(oldProps, newProps) {
|
|
309
|
+
return !arePropsEqual(oldProps, newProps);
|
|
310
|
+
}
|
|
311
|
+
var Component = class {
|
|
312
|
+
constructor(props = {}) {
|
|
313
|
+
this.state = {};
|
|
314
|
+
this.element = null;
|
|
315
|
+
this._mounted = false;
|
|
316
|
+
this.props = props;
|
|
198
317
|
}
|
|
199
|
-
|
|
200
|
-
return document.createTextNode("");
|
|
318
|
+
componentDidMount() {
|
|
201
319
|
}
|
|
202
|
-
|
|
203
|
-
|
|
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
|
+
}
|
|
204
333
|
}
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
334
|
+
_replayEvents(oldElement, newElement) {
|
|
335
|
+
const oldEvents = oldElement.__events || {};
|
|
336
|
+
Object.entries(oldEvents).forEach(([event, handler]) => {
|
|
337
|
+
newElement.addEventListener(event, handler);
|
|
338
|
+
});
|
|
339
|
+
newElement.__events = oldEvents;
|
|
340
|
+
}
|
|
341
|
+
_deepCloneWithEvents(node) {
|
|
342
|
+
const clone = node.cloneNode(false);
|
|
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;
|
|
356
|
+
}
|
|
357
|
+
async update() {
|
|
358
|
+
const vdom = this.render();
|
|
359
|
+
if (!vdom)
|
|
360
|
+
return document.createTextNode("");
|
|
361
|
+
const rendered = await createElement(vdom);
|
|
362
|
+
if (rendered instanceof HTMLElement) {
|
|
363
|
+
return this._updateElement(rendered);
|
|
210
364
|
}
|
|
211
|
-
|
|
365
|
+
const wrapper = document.createElement("div");
|
|
366
|
+
wrapper.appendChild(rendered);
|
|
367
|
+
return this._updateElement(wrapper);
|
|
212
368
|
}
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
return node;
|
|
223
|
-
} catch (error) {
|
|
224
|
-
console.error("Error rendering component:", error);
|
|
225
|
-
return document.createTextNode("");
|
|
369
|
+
async _updateElement(rendered) {
|
|
370
|
+
const newElement = this._deepCloneWithEvents(rendered);
|
|
371
|
+
newElement.__instance = this;
|
|
372
|
+
if (!this.element) {
|
|
373
|
+
this.element = newElement;
|
|
374
|
+
if (!this._mounted) {
|
|
375
|
+
this._mounted = true;
|
|
376
|
+
queueMicrotask(() => this.componentDidMount());
|
|
226
377
|
}
|
|
378
|
+
} else if (this.element.parentNode) {
|
|
379
|
+
this.element.parentNode.replaceChild(newElement, this.element);
|
|
380
|
+
this.element = newElement;
|
|
227
381
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
382
|
+
return this.element;
|
|
383
|
+
}
|
|
384
|
+
render() {
|
|
385
|
+
throw new Error("Component must implement render() method");
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
var RouterContext = createContext({
|
|
389
|
+
location: {
|
|
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;
|
|
249
440
|
}
|
|
250
441
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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);
|
|
641
|
+
try {
|
|
642
|
+
await onSubmit(values, {
|
|
643
|
+
fields: Object.keys(values).reduce((acc, key) => {
|
|
644
|
+
acc[key] = {
|
|
645
|
+
value: values[key],
|
|
646
|
+
error: errors[key],
|
|
647
|
+
touched: touched[key] || false,
|
|
648
|
+
dirty: dirty[key] || false
|
|
649
|
+
};
|
|
650
|
+
return acc;
|
|
651
|
+
}, {}),
|
|
652
|
+
isValid,
|
|
653
|
+
isDirty,
|
|
654
|
+
isSubmitting: true,
|
|
655
|
+
submitCount: submitCount + 1
|
|
656
|
+
});
|
|
657
|
+
} finally {
|
|
658
|
+
setIsSubmitting(false);
|
|
257
659
|
}
|
|
258
660
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
661
|
+
};
|
|
662
|
+
return {
|
|
663
|
+
values,
|
|
664
|
+
errors,
|
|
665
|
+
touched,
|
|
666
|
+
dirty,
|
|
667
|
+
isValid,
|
|
668
|
+
isDirty,
|
|
669
|
+
isSubmitting,
|
|
670
|
+
submitCount,
|
|
671
|
+
handleChange,
|
|
672
|
+
handleBlur,
|
|
673
|
+
handleSubmit,
|
|
674
|
+
setFieldValue,
|
|
675
|
+
setFieldError,
|
|
676
|
+
setValues: updateValues,
|
|
677
|
+
resetForm
|
|
678
|
+
};
|
|
262
679
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
680
|
+
function createEventBus() {
|
|
681
|
+
const events = /* @__PURE__ */ new Map();
|
|
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);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
const emit = (event, ...args) => {
|
|
713
|
+
if (!events.has(event)) {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const handlers = Array.from(events.get(event));
|
|
717
|
+
for (const handler of handlers) {
|
|
718
|
+
handler(...args);
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
const clear = (event) => {
|
|
722
|
+
if (event) {
|
|
723
|
+
events.delete(event);
|
|
724
|
+
} else {
|
|
725
|
+
events.clear();
|
|
726
|
+
}
|
|
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);
|
|
750
|
+
}
|
|
751
|
+
function subscribe(listener) {
|
|
752
|
+
listeners.push(listener);
|
|
753
|
+
return function unsubscribe() {
|
|
754
|
+
listeners = listeners.filter((l) => l !== listener);
|
|
755
|
+
};
|
|
270
756
|
}
|
|
757
|
+
dispatch({ type: "@@INIT" });
|
|
758
|
+
return {
|
|
759
|
+
getState: () => state,
|
|
760
|
+
dispatch,
|
|
761
|
+
subscribe
|
|
762
|
+
};
|
|
271
763
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const domNode = await createElement(element);
|
|
279
|
-
if (!isHydrating) {
|
|
280
|
-
container.innerHTML = "";
|
|
281
|
-
}
|
|
282
|
-
container.appendChild(domNode);
|
|
283
|
-
} finally {
|
|
284
|
-
finishRender();
|
|
764
|
+
var StoreContext = createContext({
|
|
765
|
+
store: {
|
|
766
|
+
getState: () => ({}),
|
|
767
|
+
dispatch: () => {
|
|
768
|
+
},
|
|
769
|
+
subscribe: () => () => {
|
|
285
770
|
}
|
|
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
|
|
286
785
|
});
|
|
287
786
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
787
|
+
function useSelector(selector) {
|
|
788
|
+
const context = useContext();
|
|
789
|
+
return selector(context.state);
|
|
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);
|
|
291
811
|
}
|
|
812
|
+
return next(action);
|
|
292
813
|
};
|
|
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
|
+
}
|
|
293
894
|
|
|
294
895
|
// src/wasm.ts
|
|
295
896
|
async function loadGoWasm(wasmUrl, options = {}) {
|
|
@@ -570,17 +1171,17 @@ function escapeHtml(text) {
|
|
|
570
1171
|
// src/browser.ts
|
|
571
1172
|
function renderToString(content) {
|
|
572
1173
|
if (typeof content === "string") {
|
|
573
|
-
return
|
|
1174
|
+
return content;
|
|
574
1175
|
}
|
|
575
1176
|
if (typeof content === "function") {
|
|
576
1177
|
try {
|
|
577
1178
|
const result = content();
|
|
578
|
-
return
|
|
1179
|
+
return String(result);
|
|
579
1180
|
} catch (error) {
|
|
580
|
-
return
|
|
1181
|
+
return `<!-- Error rendering: ${error} -->`;
|
|
581
1182
|
}
|
|
582
1183
|
}
|
|
583
|
-
return
|
|
1184
|
+
return String(content);
|
|
584
1185
|
}
|
|
585
1186
|
function generateToken(length = 32) {
|
|
586
1187
|
const array = new Uint8Array(length);
|
|
@@ -604,10 +1205,33 @@ var isBrowser = typeof window !== "undefined";
|
|
|
604
1205
|
var isNode = false;
|
|
605
1206
|
console.log("Baraqex - Browser version loaded");
|
|
606
1207
|
export {
|
|
1208
|
+
Component,
|
|
607
1209
|
Fragment,
|
|
1210
|
+
LifecycleEvents,
|
|
1211
|
+
Link,
|
|
1212
|
+
Redirect,
|
|
1213
|
+
Route,
|
|
1214
|
+
RouterProvider,
|
|
1215
|
+
StoreProvider,
|
|
1216
|
+
Switch,
|
|
608
1217
|
batchUpdates,
|
|
609
1218
|
callWasmFunction,
|
|
610
1219
|
createContext,
|
|
1220
|
+
createElement,
|
|
1221
|
+
createEventBus,
|
|
1222
|
+
createStore,
|
|
1223
|
+
diff,
|
|
1224
|
+
emitAppDestroyed,
|
|
1225
|
+
emitAppError,
|
|
1226
|
+
emitAppInit,
|
|
1227
|
+
emitAppMounted,
|
|
1228
|
+
emitAppUpdated,
|
|
1229
|
+
emitComponentCreated,
|
|
1230
|
+
emitComponentError,
|
|
1231
|
+
emitComponentMounted,
|
|
1232
|
+
emitComponentUnmounted,
|
|
1233
|
+
emitComponentUpdated,
|
|
1234
|
+
globalEventBus as eventBus,
|
|
611
1235
|
generateDocument,
|
|
612
1236
|
generateErrorPage,
|
|
613
1237
|
generateLoadingPage,
|
|
@@ -618,18 +1242,39 @@ export {
|
|
|
618
1242
|
isNode,
|
|
619
1243
|
isWasmReady,
|
|
620
1244
|
jsx,
|
|
1245
|
+
jsx as jsxDEV,
|
|
621
1246
|
jsx as jsxs,
|
|
622
1247
|
loadGoWasm,
|
|
1248
|
+
logger,
|
|
1249
|
+
onAppDestroyed,
|
|
1250
|
+
onAppError,
|
|
1251
|
+
onAppInit,
|
|
1252
|
+
onAppMounted,
|
|
1253
|
+
onAppUpdated,
|
|
1254
|
+
onComponentCreated,
|
|
1255
|
+
onComponentError,
|
|
1256
|
+
onComponentMounted,
|
|
1257
|
+
onComponentUnmounted,
|
|
1258
|
+
onComponentUpdated,
|
|
623
1259
|
render,
|
|
624
1260
|
renderToString,
|
|
625
1261
|
safeJsonParse,
|
|
626
|
-
|
|
1262
|
+
shouldComponentUpdate,
|
|
1263
|
+
thunk,
|
|
627
1264
|
useContext,
|
|
1265
|
+
useDispatch,
|
|
628
1266
|
useEffect,
|
|
629
1267
|
useErrorBoundary,
|
|
1268
|
+
useEvent,
|
|
1269
|
+
useForm,
|
|
630
1270
|
useGoWasm,
|
|
1271
|
+
useLocation,
|
|
631
1272
|
useMemo,
|
|
1273
|
+
useNavigate,
|
|
1274
|
+
useParams,
|
|
632
1275
|
useRef,
|
|
633
|
-
|
|
1276
|
+
useSelector,
|
|
1277
|
+
useState,
|
|
1278
|
+
useStore
|
|
634
1279
|
};
|
|
635
1280
|
//# sourceMappingURL=browser.js.map
|