defuss 2.0.2 → 2.0.4
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/dom-11AL5tu8.cjs +2121 -0
- package/dist/dom-77kNwui3.mjs +2028 -0
- package/dist/dom-8PVikEgj.cjs +2102 -0
- package/dist/dom-B0seF_6L.mjs +2095 -0
- package/dist/dom-B1I0Ntr-.cjs +2128 -0
- package/dist/dom-B2s8h2Oe.cjs +2102 -0
- package/dist/dom-B3MC1bVG.mjs +2034 -0
- package/dist/dom-B3OUXCES.mjs +2070 -0
- package/dist/dom-BBBIovzv.mjs +2034 -0
- package/dist/dom-BEu4Sfd-.cjs +2117 -0
- package/dist/dom-BEzo1MUJ.cjs +2117 -0
- package/dist/dom-BJERuZjE.mjs +2090 -0
- package/dist/dom-BMlw6puj.mjs +2034 -0
- package/dist/dom-BUDmDmgY.cjs +2102 -0
- package/dist/dom-BawwQ--f.mjs +2049 -0
- package/dist/dom-Bei2KSCq.cjs +2142 -0
- package/dist/dom-BfPMu0dJ.mjs +2057 -0
- package/dist/dom-BxWLR_CU.mjs +2034 -0
- package/dist/dom-C-4x7pHa.cjs +2124 -0
- package/dist/dom-C1NIQBAt.cjs +2117 -0
- package/dist/dom-CCyoKmdi.mjs +2049 -0
- package/dist/dom-CDGc8hoY.mjs +2058 -0
- package/dist/dom-CFT2GRw6.mjs +2034 -0
- package/dist/dom-CNKp2T-z.cjs +2126 -0
- package/dist/dom-CSWaOL3c.mjs +2099 -0
- package/dist/dom-CfWHCMus.cjs +2164 -0
- package/dist/dom-Clzpm3xS.mjs +1977 -0
- package/dist/dom-Co1NqlV6.mjs +2059 -0
- package/dist/dom-Crz9TlxR.cjs +2034 -0
- package/dist/dom-CxRqR3pd.cjs +2102 -0
- package/dist/dom-D3TRLsDS.cjs +2102 -0
- package/dist/dom-DD7QcWLf.cjs +2033 -0
- package/dist/dom-DHKdnUMm.cjs +2118 -0
- package/dist/dom-DKQ6CnRq.mjs +2050 -0
- package/dist/dom-DLIPg3QY.mjs +1977 -0
- package/dist/dom-DLKmVfPz.mjs +2057 -0
- package/dist/dom-DNGWHS7t.cjs +2159 -0
- package/dist/dom-DPbGY8oU.mjs +2073 -0
- package/dist/dom-DTo7fRwx.mjs +2055 -0
- package/dist/dom-Daho4GPR.mjs +2053 -0
- package/dist/dom-Db15rsM1.mjs +2049 -0
- package/dist/dom-DgoG3lqb.cjs +2117 -0
- package/dist/dom-DmGkOplK.cjs +2127 -0
- package/dist/dom-DtgVTMnb.mjs +1977 -0
- package/dist/dom-DvHgqwJh.mjs +2046 -0
- package/dist/dom-EqEVp0-C.cjs +2033 -0
- package/dist/dom-NjCYLgPw.cjs +2126 -0
- package/dist/dom-UHntoboN.cjs +2139 -0
- package/dist/dom-Z-gE5GK8.cjs +2168 -0
- package/dist/dom-mlV6havt.mjs +2048 -0
- package/dist/dom-x3xpYktC.cjs +2114 -0
- package/dist/dom-yD0xCNhJ.cjs +2096 -0
- package/dist/index-B2aNqkPk.d.ts +1440 -0
- package/dist/index-B_CgmZnk.d.ts +1433 -0
- package/dist/index-CEtCW1xG.d.ts +1433 -0
- package/dist/index-CfTsJbfE.d.ts +1432 -0
- package/dist/{index-S3MRf--S.d.ts → index-Co0eiBV7.d.ts} +270 -198
- package/dist/index-CtUAjHuo.d.ts +1433 -0
- package/dist/index-CuzRXgFf.d.ts +1439 -0
- package/dist/index-DFuY8uu9.d.ts +1431 -0
- package/dist/index-Dhj90n6u.d.ts +1433 -0
- package/dist/index-DjCdylRj.d.ts +1438 -0
- package/dist/index-DyKry_9r.d.ts +1439 -0
- package/dist/index-FWrGRiCX.d.ts +1431 -0
- package/dist/index-wIzDVlFz.d.ts +1439 -0
- package/dist/index.cjs +408 -3
- package/dist/index.d.cts +29 -153
- package/dist/index.d.ts +29 -153
- package/dist/index.mjs +339 -3
- package/dist/render/client.cjs +97 -2
- package/dist/render/client.d.cts +2 -2
- package/dist/render/client.d.ts +2 -2
- package/dist/render/client.mjs +79 -2
- package/dist/render/index.cjs +21 -2
- package/dist/render/index.d.cts +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.mjs +2 -2
- package/dist/render/server.cjs +94 -2
- package/dist/render/server.d.cts +2 -2
- package/dist/render/server.d.ts +2 -2
- package/dist/render/server.mjs +55 -2
- package/package.json +10 -17
- package/dist/dom-Cm_LuWlw.mjs +0 -2
- package/dist/dom-Cm_LuWlw.mjs.map +0 -1
- package/dist/dom-DLKNKVTt.cjs +0 -2
- package/dist/dom-DLKNKVTt.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/render/client.cjs.map +0 -1
- package/dist/render/client.mjs.map +0 -1
- package/dist/render/index.cjs.map +0 -1
- package/dist/render/index.mjs.map +0 -1
- package/dist/render/server.cjs.map +0 -1
- package/dist/render/server.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { $, A as AllHTMLElements, C as CSSProperties,
|
|
1
|
+
import { Q as PersistenceProviderType, T as PersistenceProviderOptions, U as PersistenceProviderImpl, h as VNode, g as VNodeAttributes, R as RenderInput, G as Globals, N as NodeType, q as Props, n as VNodeChild, f as Ref } from './index-B2aNqkPk.js';
|
|
2
|
+
export { a4 as $, A as AllHTMLElements, C as CSSProperties, W as Call, Z as CallChainImpl, _ as CallChainImplThenable, p as Children, a2 as Dequery, D as DomAbstractionImpl, F as FontFaceProperties, I as Fragment, K as KeyFrameProperties, ak as Listener, ai as MemoryStorage, ah as MiddlewareFn, X as NonChainedReturnCallNames, P as ParentElementInput, b as ParentElementInputAsync, d as RefUpdateFn, e as RefUpdateRenderFn, c as RefUpdateRenderFnInput, r as RenderNodeInput, a as RenderResult, s as RenderResultNode, al as Store, S as SyncRenderInput, y as SyncRenderResult, V as VAttributes, o as VNodeChildren, j as VNodeKey, m as VNodeRef, l as VNodeRefCallback, k as VNodeRefObject, i as VNodeType, aj as WebStorage, a9 as createCall, aa as createGetterSetterCall, t as createInPlaceErrorMessageVNode, O as createRef, am as createStore, ab as createSubChain, a1 as delayedAutoStart, a3 as dequery, Y as emptyImpl, a0 as getAllFormValues, a7 as getDefaultDequeryOptions, x as getRenderer, E as globalScopeDomApis, w as handleLifecycleEventsForOnMount, a5 as isDequery, a6 as isDequeryOptionsObject, H as isJSX, M as isRef, u as jsx, L as jsxDEV, J as jsxs, a8 as mapArrayIndexAccess, v as observeUnmount, B as renderIsomorphicAsync, z as renderIsomorphicSync, ae as renderNode, af as resolveNodes, ad as runWithTimeGuard, $ as scrollHelper, ac as subChainForNextAwait, ag as traverse } from './index-B2aNqkPk.js';
|
|
3
3
|
import * as CSS from 'csstype';
|
|
4
4
|
export { CSS };
|
|
5
5
|
|
|
6
|
-
declare const getAllKeysFromPath: (path: string) => Array<string | number>;
|
|
7
|
-
declare const ensureKey: (obj: Record<string, any>, key: string | number, nextKey?: string | number) => void;
|
|
8
|
-
declare const getByPath: (obj: any, path: string) => any;
|
|
9
|
-
declare const setByPath: (obj: any, path: string, value: any) => any;
|
|
10
|
-
|
|
11
6
|
declare const inDevMode = true;
|
|
12
7
|
|
|
8
|
+
/** returns the persistence provider (isomorphic) */
|
|
9
|
+
declare const webstorage: <T>(provider?: PersistenceProviderType, options?: PersistenceProviderOptions) => PersistenceProviderImpl<T>;
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* Compares two DOM nodes for equality with performance optimizations.
|
|
15
13
|
* 1. Checks for reference equality.
|
|
@@ -22,7 +20,7 @@ declare const areDomNodesEqual: (oldNode: Node, newNode: Node) => boolean;
|
|
|
22
20
|
* Partially updates a DOM subtree by comparing `targetElement` to
|
|
23
21
|
* newly parsed HTML. No `.innerHTML` is used here; we parse via DOMParser.
|
|
24
22
|
*/
|
|
25
|
-
declare const updateDom: (targetElement: Element, newHTML: string) => void;
|
|
23
|
+
declare const updateDom: (targetElement: Element, newHTML: string, Parser: typeof DOMParser) => void;
|
|
26
24
|
/********************************************************
|
|
27
25
|
* 1) Define a "valid" child type & utility
|
|
28
26
|
********************************************************/
|
|
@@ -37,29 +35,23 @@ declare function updateDomWithVdom(parentElement: Element, newVDOM: RenderInput,
|
|
|
37
35
|
* at the cost of losing partial update performance.
|
|
38
36
|
*/
|
|
39
37
|
declare function replaceDomWithVdom(parentElement: Element, newVDOM: RenderInput, globals: Globals): void;
|
|
40
|
-
|
|
41
|
-
type
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
type PersistenceProvider = 'session' | 'local' | 'memory';
|
|
59
|
-
type PersistenceProviderOptions = MemoryProviderOptions;
|
|
60
|
-
|
|
61
|
-
/** returns the persistence provider (isomorphic) */
|
|
62
|
-
declare const webstorage: <T>(provider?: PersistenceProvider, options?: PersistenceProviderOptions) => PersistenceProviderImpl<T>;
|
|
38
|
+
declare function waitForDOM(check: () => Array<NodeType>, timeout: number, document?: Document): Promise<Array<NodeType>>;
|
|
39
|
+
declare function parseDOM(input: string, type: DOMParserSupportedType, Parser: typeof DOMParser): Document;
|
|
40
|
+
declare function isSVG(input: string, Parser: typeof DOMParser): boolean;
|
|
41
|
+
declare function isHTML(input: string, Parser: typeof DOMParser): boolean;
|
|
42
|
+
declare const isMarkup: (input: string, Parser: typeof DOMParser) => boolean;
|
|
43
|
+
declare function renderMarkup(markup: string, Parser: typeof DOMParser, doc?: Document): ChildNode[];
|
|
44
|
+
declare function getMimeType(input: string, Parser: typeof DOMParser): DOMParserSupportedType;
|
|
45
|
+
/**
|
|
46
|
+
* Enhanced version of processFormElements that handles all form control types
|
|
47
|
+
* including multiple select elements and radio button groups
|
|
48
|
+
*/
|
|
49
|
+
declare function processAllFormElements(node: NodeType, callback: (input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, key: string) => void): void;
|
|
50
|
+
declare function checkElementVisibility(element: HTMLElement, window: Window, document: Document): boolean;
|
|
51
|
+
declare function getEventMap(element: HTMLElement): Map<string, Set<EventListener>>;
|
|
52
|
+
declare function addElementEvent(element: HTMLElement, eventType: string, handler: EventListener): void;
|
|
53
|
+
declare function removeElementEvent(element: HTMLElement, eventType: string, handler?: EventListener): void;
|
|
54
|
+
declare function clearElementEvents(element: HTMLElement): void;
|
|
63
55
|
|
|
64
56
|
type TranslationObject = {
|
|
65
57
|
[key: string]: string | VNode | TranslationObject;
|
|
@@ -89,125 +81,9 @@ interface TransProps extends Props {
|
|
|
89
81
|
}
|
|
90
82
|
declare const Trans: ({ path, replacements, tag, ...attrs }: TransProps) => VNodeChild;
|
|
91
83
|
|
|
92
|
-
/**
|
|
93
|
-
* custom headers class to manage HTTP headers with case-insensitive keys.
|
|
94
|
-
* simplifies header manipulation by providing utility methods.
|
|
95
|
-
*/
|
|
96
|
-
declare class Headers {
|
|
97
|
-
private map;
|
|
98
|
-
/**
|
|
99
|
-
* initializes the Headers instance with provided headers or another Headers object.
|
|
100
|
-
* ensures all header keys are stored in lowercase for consistent access.
|
|
101
|
-
* @param init initial headers as a record or another Headers instance
|
|
102
|
-
*/
|
|
103
|
-
constructor(init?: Record<string, string> | Headers);
|
|
104
|
-
/**
|
|
105
|
-
* appends or sets the value for a specific header key.
|
|
106
|
-
* stores the key in lowercase to maintain case-insensitivity.
|
|
107
|
-
* @param key header name
|
|
108
|
-
* @param value header value
|
|
109
|
-
*/
|
|
110
|
-
append(key: string, value: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* retrieves the value of a specific header key.
|
|
113
|
-
* @param key header name
|
|
114
|
-
* @returns the header value or null if not found
|
|
115
|
-
*/
|
|
116
|
-
get(key: string): string | null;
|
|
117
|
-
/**
|
|
118
|
-
* checks if a specific header key exists.
|
|
119
|
-
* @param key header name
|
|
120
|
-
* @returns boolean indicating existence of the header
|
|
121
|
-
*/
|
|
122
|
-
has(key: string): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* iterates over all headers and executes the provided callback for each.
|
|
125
|
-
* @param callback function to execute for each header
|
|
126
|
-
*/
|
|
127
|
-
forEach(callback: (value: string, key: string) => void): void;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* ProgressSignal extends EventTarget to dispatch and track progress events.
|
|
131
|
-
* useful for monitoring the progress of network requests.
|
|
132
|
-
*/
|
|
133
|
-
declare class ProgressSignal extends EventTarget {
|
|
134
|
-
private _progress;
|
|
135
|
-
/**
|
|
136
|
-
* initializes the ProgressSignal with zero progress.
|
|
137
|
-
*/
|
|
138
|
-
constructor();
|
|
139
|
-
/**
|
|
140
|
-
* retrieves the current progress.
|
|
141
|
-
* @returns an object containing loaded and total bytes
|
|
142
|
-
*/
|
|
143
|
-
get progress(): {
|
|
144
|
-
loaded: number;
|
|
145
|
-
total: number;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* dispatches a progress event with updated loaded and total bytes.
|
|
149
|
-
* updates the internal progress state.
|
|
150
|
-
* @param event the ProgressEvent containing progress information
|
|
151
|
-
*/
|
|
152
|
-
dispatchProgress(event: ProgressEvent): void;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* ProgressController manages a ProgressSignal for tracking request progress.
|
|
156
|
-
* provides a centralized way to handle progress events.
|
|
157
|
-
*/
|
|
158
|
-
declare class ProgressController {
|
|
159
|
-
signal: ProgressSignal;
|
|
160
|
-
/**
|
|
161
|
-
* initializes the ProgressController with a new ProgressSignal.
|
|
162
|
-
*/
|
|
163
|
-
constructor();
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* serializes the request body into a format suitable for XMLHttpRequest.
|
|
167
|
-
* handles various body types including JSON objects and FormData.
|
|
168
|
-
* @param body the body to serialize
|
|
169
|
-
* @returns the serialized body or null if no body is provided
|
|
170
|
-
*/
|
|
171
|
-
declare function serializeBody(body: BodyInit | Record<string, unknown> | null | undefined): XMLHttpRequestBodyInit | Document | null;
|
|
172
|
-
/**
|
|
173
|
-
* parses a raw header string from an XMLHttpRequest into a Headers instance.
|
|
174
|
-
* @param headerStr the raw header string
|
|
175
|
-
* @returns a Headers instance containing parsed headers
|
|
176
|
-
*/
|
|
177
|
-
declare function parseHeaders(headerStr: string): Headers;
|
|
178
|
-
/**
|
|
179
|
-
* extends the standard RequestInit to include an optional ProgressSignal.
|
|
180
|
-
* allows tracking the progress of the network request.
|
|
181
|
-
*/
|
|
182
|
-
interface FetchWithControllersInit extends RequestInit {
|
|
183
|
-
progressSignal?: ProgressSignal;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* represents the response from a fetch operation, mirroring the native Response interface.
|
|
187
|
-
* includes methods to access the response body in various formats.
|
|
188
|
-
*/
|
|
189
|
-
interface FetchResponse {
|
|
190
|
-
ok: boolean;
|
|
191
|
-
status: number;
|
|
192
|
-
statusText: string;
|
|
193
|
-
headers: Headers;
|
|
194
|
-
url: string;
|
|
195
|
-
text: () => Promise<string>;
|
|
196
|
-
json: () => Promise<unknown>;
|
|
197
|
-
blob: () => Promise<Blob>;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* performs a network fetch request with support for progress tracking using XMLHttpRequest.
|
|
201
|
-
* falls back to the native fetch implementation if no ProgressSignal is provided.
|
|
202
|
-
* @param input the resource to fetch, typically a URL string
|
|
203
|
-
* @param init optional configuration for the request, including method, headers, body, credentials, and progressSignal
|
|
204
|
-
* @returns a promise resolving to a FetchResponse containing the response details
|
|
205
|
-
*/
|
|
206
|
-
declare function fetch(input: string | URL, init?: FetchWithControllersInit): Promise<FetchResponse>;
|
|
207
|
-
|
|
208
84
|
type OnHandleRouteChangeFn = (newRoute: string, oldRoute: string) => void;
|
|
209
85
|
type OnRouteChangeFn = (cb: OnHandleRouteChangeFn) => void;
|
|
210
|
-
type RouterStrategy =
|
|
86
|
+
type RouterStrategy = "page-refresh" | "slot-refresh";
|
|
211
87
|
interface RouterConfig {
|
|
212
88
|
strategy?: RouterStrategy;
|
|
213
89
|
}
|
|
@@ -257,7 +133,7 @@ declare const Route: ({ path, exact, children, router }: RouteProps) => VNodeChi
|
|
|
257
133
|
interface RedirectProps extends RouteProps {
|
|
258
134
|
to: string;
|
|
259
135
|
}
|
|
260
|
-
declare const Redirect: ({ path, to, router, exact }: RedirectProps) => VNodeChild;
|
|
136
|
+
declare const Redirect: ({ path, to, router, exact, }: RedirectProps) => VNodeChild;
|
|
261
137
|
|
|
262
138
|
declare const RouterSlotId = "router-slot";
|
|
263
139
|
interface RouterSlotProps extends Props {
|
|
@@ -279,7 +155,7 @@ interface RouterSlotProps extends Props {
|
|
|
279
155
|
*/
|
|
280
156
|
declare const RouterSlot: ({ router, children, RouterOutlet, ...attributes }: RouterSlotProps) => VNodeChild;
|
|
281
157
|
|
|
282
|
-
type AsyncState =
|
|
158
|
+
type AsyncState = "loading" | "loaded" | "error";
|
|
283
159
|
interface AsyncStateRef extends Ref<HTMLElement> {
|
|
284
160
|
/** The state of the async content */
|
|
285
161
|
state?: AsyncState;
|
|
@@ -306,7 +182,7 @@ interface AsyncProps extends Props {
|
|
|
306
182
|
/** to override the name of the .suspense-error transition CSS class name */
|
|
307
183
|
errorClassName?: string;
|
|
308
184
|
}
|
|
309
|
-
declare const Async: ({ fallback, ref, children, class: _class, className, id, loadingClassName, loadedClassName, errorClassName, onError }: AsyncProps) => {
|
|
185
|
+
declare const Async: ({ fallback, ref, children, class: _class, className, id, loadingClassName, loadedClassName, errorClassName, onError, }: AsyncProps) => {
|
|
310
186
|
type: string;
|
|
311
187
|
attributes: {
|
|
312
188
|
id: string | undefined;
|
|
@@ -317,7 +193,7 @@ declare const Async: ({ fallback, ref, children, class: _class, className, id, l
|
|
|
317
193
|
};
|
|
318
194
|
children: VNode<VNodeAttributes>[];
|
|
319
195
|
};
|
|
320
|
-
declare const Suspense: ({ fallback, ref, children, class: _class, className, id, loadingClassName, loadedClassName, errorClassName, onError }: AsyncProps) => {
|
|
196
|
+
declare const Suspense: ({ fallback, ref, children, class: _class, className, id, loadingClassName, loadedClassName, errorClassName, onError, }: AsyncProps) => {
|
|
321
197
|
type: string;
|
|
322
198
|
attributes: {
|
|
323
199
|
id: string | undefined;
|
|
@@ -329,4 +205,4 @@ declare const Suspense: ({ fallback, ref, children, class: _class, className, id
|
|
|
329
205
|
children: VNode<VNodeAttributes>[];
|
|
330
206
|
};
|
|
331
207
|
|
|
332
|
-
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef,
|
|
208
|
+
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef, Globals, type I18nStore, NodeType, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, type RedirectProps, Ref, RenderInput, type Replacements, Route, type RouteHandler, type RouteParams, type RouteProps, type RouteRegistration, type RouteRequest, Router, type RouterConfig, RouterSlot, RouterSlotId, type RouterSlotProps, type RouterStrategy, Suspense, type TokenizedPath, Trans, type TransProps, type TranslationObject, type Translations, VNode, VNodeAttributes, VNodeChild, type ValidChild, addElementEvent, areDomNodesEqual, checkElementVisibility, clearElementEvents, createI18n, getEventMap, getMimeType, i18n, inDevMode, isHTML, isMarkup, isSVG, matchRouteRegistrations, parseDOM, processAllFormElements, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, tokenizePath, updateDom, updateDomWithVdom, waitForDOM, webstorage };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,339 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { l as createStore, m as isServer, k as createRef, $, f as isRef } from './dom-DtgVTMnb.mjs';
|
|
2
|
+
export { H as Call, J as CallChainImpl, K as CallChainImplThenable, F as Fragment, N as NonChainedReturnCallNames, D as addElementEvent, n as areDomNodesEqual, B as checkElementVisibility, G as clearElementEvents, U as createCall, V as createGetterSetterCall, c as createInPlaceErrorMessageVNode, W as createSubChain, O as delayedAutoStart, P as dequery, I as emptyImpl, M as getAllFormValues, S as getDefaultDequeryOptions, C as getEventMap, z as getMimeType, g as getRenderer, b as globalScopeDomApis, h as handleLifecycleEventsForOnMount, Q as isDequery, R as isDequeryOptionsObject, v as isHTML, i as isJSX, x as isMarkup, t as isSVG, j as jsx, e as jsxDEV, d as jsxs, T as mapArrayIndexAccess, o as observeUnmount, s as parseDOM, A as processAllFormElements, E as removeElementEvent, a as renderIsomorphicAsync, r as renderIsomorphicSync, y as renderMarkup, Z as renderNode, q as replaceDomWithVdom, _ as resolveNodes, Y as runWithTimeGuard, L as scrollHelper, X as subChainForNextAwait, a0 as traverse, u as updateDom, p as updateDomWithVdom, w as waitForDOM, a1 as webstorage } from './dom-DtgVTMnb.mjs';
|
|
3
|
+
import 'defuss-runtime';
|
|
4
|
+
|
|
5
|
+
const inDevMode = true;
|
|
6
|
+
|
|
7
|
+
const VARIABLE_REGEX = /{([^}]*)}/g;
|
|
8
|
+
const interpolate = (template, replacements) => template.replace(VARIABLE_REGEX, (_, key) => replacements[key] || `{${key}}`);
|
|
9
|
+
const createI18n = () => {
|
|
10
|
+
const translationsStore = createStore({});
|
|
11
|
+
let language = "en";
|
|
12
|
+
const onLanguageChangeCallbacks = [];
|
|
13
|
+
return {
|
|
14
|
+
language,
|
|
15
|
+
changeLanguage(newLanguage) {
|
|
16
|
+
language = newLanguage;
|
|
17
|
+
onLanguageChangeCallbacks.forEach((callback) => callback(newLanguage));
|
|
18
|
+
},
|
|
19
|
+
// example usage of the t function with placeholders:
|
|
20
|
+
// const translatedString = t('greeting', { name: 'John', age: '30' }, 'common');
|
|
21
|
+
// this would replace placeholders {name} and {age} in the translation string with 'John' and '30' respectively.
|
|
22
|
+
t(path, replacements = {}) {
|
|
23
|
+
const template = translationsStore.get(`${language}.${path}`) || path;
|
|
24
|
+
if (typeof template !== "string") {
|
|
25
|
+
return template;
|
|
26
|
+
}
|
|
27
|
+
return interpolate(template, replacements);
|
|
28
|
+
},
|
|
29
|
+
load(newLanguage, namespaceTranslations) {
|
|
30
|
+
translationsStore.set(newLanguage, {
|
|
31
|
+
...translationsStore.get(newLanguage),
|
|
32
|
+
...namespaceTranslations
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
subscribe(onLanguageChange) {
|
|
36
|
+
onLanguageChangeCallbacks.push(onLanguageChange);
|
|
37
|
+
return () => {
|
|
38
|
+
const index = onLanguageChangeCallbacks.indexOf(onLanguageChange);
|
|
39
|
+
if (index >= 0) onLanguageChangeCallbacks.splice(index, 1);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const i18n = createI18n();
|
|
45
|
+
|
|
46
|
+
const Trans = ({ path, replacements, tag, ...attrs }) => {
|
|
47
|
+
const ref = {};
|
|
48
|
+
i18n.subscribe(() => {
|
|
49
|
+
const value = i18n.t(path, replacements);
|
|
50
|
+
console.log("new val", value);
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
tag: tag || "span",
|
|
54
|
+
attributes: {
|
|
55
|
+
ref,
|
|
56
|
+
...attrs
|
|
57
|
+
},
|
|
58
|
+
// initially render
|
|
59
|
+
children: i18n.t(path, replacements)
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const tokenizePath = (path) => {
|
|
64
|
+
const paramNameRegexp = /:([^\/\.\\]+)/g;
|
|
65
|
+
const groups = {};
|
|
66
|
+
let groupIndex = 1;
|
|
67
|
+
const pattern = path.replace(paramNameRegexp, (_, paramName) => {
|
|
68
|
+
groups[paramName] = groupIndex++;
|
|
69
|
+
return "([^/.\\]+)";
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
groups,
|
|
73
|
+
regexp: new RegExp(`^${pattern}$`)
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const matchRouteRegistrations = (routeRegistrations, actualPathName, haystackPathName) => {
|
|
77
|
+
for (const route of routeRegistrations) {
|
|
78
|
+
if (haystackPathName && route.path !== haystackPathName) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (route.exact && route.path !== actualPathName) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const match = route.tokenizedPath.regexp.exec(actualPathName);
|
|
85
|
+
if (!match) continue;
|
|
86
|
+
const params = {};
|
|
87
|
+
for (const [paramName, groupIndex] of Object.entries(
|
|
88
|
+
route.tokenizedPath.groups
|
|
89
|
+
)) {
|
|
90
|
+
params[paramName] = match[groupIndex];
|
|
91
|
+
}
|
|
92
|
+
const request = { url: actualPathName, params };
|
|
93
|
+
if (typeof route.handler === "function") {
|
|
94
|
+
route.handler(request);
|
|
95
|
+
}
|
|
96
|
+
return request;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
};
|
|
100
|
+
const setupRouter = (config = {
|
|
101
|
+
strategy: "page-refresh"
|
|
102
|
+
// default
|
|
103
|
+
}, windowImpl) => {
|
|
104
|
+
const routeRegistrations = [];
|
|
105
|
+
if (typeof window !== "undefined" && !windowImpl) {
|
|
106
|
+
windowImpl = globalThis.__defuss_window || window;
|
|
107
|
+
}
|
|
108
|
+
if (!windowImpl && !isServer()) {
|
|
109
|
+
console.warn("Router requires a Window API implementation!");
|
|
110
|
+
}
|
|
111
|
+
const api = {
|
|
112
|
+
...config,
|
|
113
|
+
listeners: [],
|
|
114
|
+
onRouteChange: (cb) => {
|
|
115
|
+
api.listeners.push(cb);
|
|
116
|
+
},
|
|
117
|
+
tokenizePath,
|
|
118
|
+
add(registration) {
|
|
119
|
+
const isAlreadyRegistered = routeRegistrations.some(
|
|
120
|
+
(registeredRoute) => registeredRoute.path === registration.path
|
|
121
|
+
);
|
|
122
|
+
if (!isAlreadyRegistered) {
|
|
123
|
+
routeRegistrations.push({
|
|
124
|
+
...registration,
|
|
125
|
+
tokenizedPath: tokenizePath(registration.path)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return api;
|
|
129
|
+
},
|
|
130
|
+
match(path) {
|
|
131
|
+
return matchRouteRegistrations(
|
|
132
|
+
routeRegistrations,
|
|
133
|
+
windowImpl.document.location.pathname,
|
|
134
|
+
path
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
navigate(newPath) {
|
|
138
|
+
const strategy = api.strategy || "page-refresh";
|
|
139
|
+
const oldPath = windowImpl ? windowImpl.document.location.pathname : "";
|
|
140
|
+
if (strategy === "page-refresh") {
|
|
141
|
+
document.location.href = newPath;
|
|
142
|
+
} else if (strategy === "slot-refresh") {
|
|
143
|
+
if (typeof windowImpl !== "undefined") {
|
|
144
|
+
windowImpl.history.pushState({}, "", newPath);
|
|
145
|
+
}
|
|
146
|
+
for (const listener of api.listeners) {
|
|
147
|
+
listener(newPath, oldPath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
getRoutes() {
|
|
152
|
+
return routeRegistrations;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return api;
|
|
156
|
+
};
|
|
157
|
+
const Router = setupRouter();
|
|
158
|
+
|
|
159
|
+
const Route = ({ path, exact, children, router = Router }) => {
|
|
160
|
+
router.add({
|
|
161
|
+
path,
|
|
162
|
+
exact: exact || false
|
|
163
|
+
});
|
|
164
|
+
return router.match(path) ? children[0] : null;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const Redirect = ({
|
|
168
|
+
path,
|
|
169
|
+
to,
|
|
170
|
+
router = Router,
|
|
171
|
+
exact
|
|
172
|
+
}) => {
|
|
173
|
+
queueMicrotask(() => {
|
|
174
|
+
if (Route({ path, router, exact, children: [true] })) {
|
|
175
|
+
router.navigate(to);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return null;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const RouterSlotId = "router-slot";
|
|
182
|
+
const RouterSlot = ({
|
|
183
|
+
router = Router,
|
|
184
|
+
children,
|
|
185
|
+
RouterOutlet,
|
|
186
|
+
...attributes
|
|
187
|
+
}) => {
|
|
188
|
+
const { tag, ...attributesWithoutTag } = attributes;
|
|
189
|
+
const ref = createRef();
|
|
190
|
+
router.strategy = "slot-refresh";
|
|
191
|
+
router.onRouteChange(async () => {
|
|
192
|
+
await $(ref).update(RouterOutlet());
|
|
193
|
+
});
|
|
194
|
+
if (document.getElementById(RouterSlotId)) {
|
|
195
|
+
console.warn(
|
|
196
|
+
`It seems there's more than one <RouterSlot /> components defined as an element with id #${RouterSlotId} already exists in the DOM.`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
children: RouterOutlet() || [],
|
|
201
|
+
type: attributes.tag || "div",
|
|
202
|
+
attributes: {
|
|
203
|
+
...attributesWithoutTag,
|
|
204
|
+
id: RouterSlotId,
|
|
205
|
+
ref
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const Async = ({
|
|
211
|
+
fallback,
|
|
212
|
+
ref,
|
|
213
|
+
children,
|
|
214
|
+
class: _class,
|
|
215
|
+
className,
|
|
216
|
+
id,
|
|
217
|
+
loadingClassName,
|
|
218
|
+
loadedClassName,
|
|
219
|
+
errorClassName,
|
|
220
|
+
onError
|
|
221
|
+
}) => {
|
|
222
|
+
let childrenToRender = children;
|
|
223
|
+
const containerRef = createRef(
|
|
224
|
+
function onSuspenseUpdate(state) {
|
|
225
|
+
try {
|
|
226
|
+
if (!containerRef.current) {
|
|
227
|
+
if (inDevMode) {
|
|
228
|
+
console.warn(
|
|
229
|
+
"Suspense container is not mounted yet, but a state update demands a render. State is:",
|
|
230
|
+
state
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
(async () => {
|
|
236
|
+
await $(containerRef.current).removeClass(
|
|
237
|
+
loadingClassName || "suspense-loading"
|
|
238
|
+
);
|
|
239
|
+
await $(containerRef.current).removeClass(
|
|
240
|
+
loadedClassName || "suspense-loaded"
|
|
241
|
+
);
|
|
242
|
+
await $(containerRef.current).removeClass(
|
|
243
|
+
errorClassName || "suspense-error"
|
|
244
|
+
);
|
|
245
|
+
if (!children || state === "error") {
|
|
246
|
+
await $(containerRef.current).addClass(
|
|
247
|
+
errorClassName || "suspense-error"
|
|
248
|
+
);
|
|
249
|
+
await $(containerRef).jsx({
|
|
250
|
+
type: "div",
|
|
251
|
+
children: ["Loading error!"]
|
|
252
|
+
});
|
|
253
|
+
} else if (state === "loading") {
|
|
254
|
+
await $(containerRef.current).addClass(
|
|
255
|
+
loadingClassName || "suspense-loading"
|
|
256
|
+
);
|
|
257
|
+
await $(containerRef).jsx(fallback);
|
|
258
|
+
} else if (state === "loaded") {
|
|
259
|
+
await $(containerRef.current).addClass(
|
|
260
|
+
loadedClassName || "suspense-loaded"
|
|
261
|
+
);
|
|
262
|
+
console.log("[Async render] start");
|
|
263
|
+
await $(containerRef).jsx(childrenToRender);
|
|
264
|
+
console.log("[Async render] finished");
|
|
265
|
+
}
|
|
266
|
+
})();
|
|
267
|
+
} catch (error) {
|
|
268
|
+
containerRef.update("error");
|
|
269
|
+
containerRef.error = error;
|
|
270
|
+
if (typeof onError === "function") {
|
|
271
|
+
onError(error);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"loading"
|
|
276
|
+
);
|
|
277
|
+
if (isRef(ref)) {
|
|
278
|
+
let isInitial = true;
|
|
279
|
+
ref.updateState = (state) => {
|
|
280
|
+
if (!isInitial) {
|
|
281
|
+
containerRef.updateState(state);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
ref.updateState("loading");
|
|
285
|
+
isInitial = false;
|
|
286
|
+
}
|
|
287
|
+
const promisedChildren = (children || []).map((vnode) => {
|
|
288
|
+
try {
|
|
289
|
+
if (!vnode || vnode && !vnode.type) {
|
|
290
|
+
return Promise.resolve("");
|
|
291
|
+
}
|
|
292
|
+
if (vnode.type.constructor.name === "AsyncFunction") {
|
|
293
|
+
const props = {
|
|
294
|
+
...vnode.attributes,
|
|
295
|
+
children: vnode.children
|
|
296
|
+
};
|
|
297
|
+
return vnode.type(props);
|
|
298
|
+
}
|
|
299
|
+
return Promise.resolve(vnode);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
containerRef.updateState("error");
|
|
302
|
+
containerRef.error = error;
|
|
303
|
+
if (typeof onError === "function") {
|
|
304
|
+
onError(error);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
const onMount = () => {
|
|
309
|
+
if (promisedChildren.length) {
|
|
310
|
+
containerRef.updateState("loading");
|
|
311
|
+
Promise.all(promisedChildren).then((awaitedVnodes) => {
|
|
312
|
+
childrenToRender = awaitedVnodes.flatMap(
|
|
313
|
+
(vnode) => vnode?.type === "Fragment" ? vnode.children : vnode
|
|
314
|
+
);
|
|
315
|
+
containerRef.updateState("loaded");
|
|
316
|
+
}).catch((error) => {
|
|
317
|
+
containerRef.updateState("error");
|
|
318
|
+
containerRef.error = error;
|
|
319
|
+
{
|
|
320
|
+
console.error("SuspenseLoadingError", error);
|
|
321
|
+
}
|
|
322
|
+
(async () => {
|
|
323
|
+
await $(containerRef).jsx(`SuspenseLoadingError: ${error}`);
|
|
324
|
+
})();
|
|
325
|
+
if (typeof onError === "function") {
|
|
326
|
+
onError(error);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
type: "div",
|
|
333
|
+
attributes: { id, class: _class, className, ref: containerRef, onMount },
|
|
334
|
+
children: fallback ? [fallback] : []
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
const Suspense = Async;
|
|
338
|
+
|
|
339
|
+
export { $, Async, Redirect, Route, Router, RouterSlot, RouterSlotId, Suspense, Trans, createI18n, createRef, createStore, i18n, inDevMode, isRef, matchRouteRegistrations, setupRouter, tokenizePath };
|