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.
Files changed (94) hide show
  1. package/dist/dom-11AL5tu8.cjs +2121 -0
  2. package/dist/dom-77kNwui3.mjs +2028 -0
  3. package/dist/dom-8PVikEgj.cjs +2102 -0
  4. package/dist/dom-B0seF_6L.mjs +2095 -0
  5. package/dist/dom-B1I0Ntr-.cjs +2128 -0
  6. package/dist/dom-B2s8h2Oe.cjs +2102 -0
  7. package/dist/dom-B3MC1bVG.mjs +2034 -0
  8. package/dist/dom-B3OUXCES.mjs +2070 -0
  9. package/dist/dom-BBBIovzv.mjs +2034 -0
  10. package/dist/dom-BEu4Sfd-.cjs +2117 -0
  11. package/dist/dom-BEzo1MUJ.cjs +2117 -0
  12. package/dist/dom-BJERuZjE.mjs +2090 -0
  13. package/dist/dom-BMlw6puj.mjs +2034 -0
  14. package/dist/dom-BUDmDmgY.cjs +2102 -0
  15. package/dist/dom-BawwQ--f.mjs +2049 -0
  16. package/dist/dom-Bei2KSCq.cjs +2142 -0
  17. package/dist/dom-BfPMu0dJ.mjs +2057 -0
  18. package/dist/dom-BxWLR_CU.mjs +2034 -0
  19. package/dist/dom-C-4x7pHa.cjs +2124 -0
  20. package/dist/dom-C1NIQBAt.cjs +2117 -0
  21. package/dist/dom-CCyoKmdi.mjs +2049 -0
  22. package/dist/dom-CDGc8hoY.mjs +2058 -0
  23. package/dist/dom-CFT2GRw6.mjs +2034 -0
  24. package/dist/dom-CNKp2T-z.cjs +2126 -0
  25. package/dist/dom-CSWaOL3c.mjs +2099 -0
  26. package/dist/dom-CfWHCMus.cjs +2164 -0
  27. package/dist/dom-Clzpm3xS.mjs +1977 -0
  28. package/dist/dom-Co1NqlV6.mjs +2059 -0
  29. package/dist/dom-Crz9TlxR.cjs +2034 -0
  30. package/dist/dom-CxRqR3pd.cjs +2102 -0
  31. package/dist/dom-D3TRLsDS.cjs +2102 -0
  32. package/dist/dom-DD7QcWLf.cjs +2033 -0
  33. package/dist/dom-DHKdnUMm.cjs +2118 -0
  34. package/dist/dom-DKQ6CnRq.mjs +2050 -0
  35. package/dist/dom-DLIPg3QY.mjs +1977 -0
  36. package/dist/dom-DLKmVfPz.mjs +2057 -0
  37. package/dist/dom-DNGWHS7t.cjs +2159 -0
  38. package/dist/dom-DPbGY8oU.mjs +2073 -0
  39. package/dist/dom-DTo7fRwx.mjs +2055 -0
  40. package/dist/dom-Daho4GPR.mjs +2053 -0
  41. package/dist/dom-Db15rsM1.mjs +2049 -0
  42. package/dist/dom-DgoG3lqb.cjs +2117 -0
  43. package/dist/dom-DmGkOplK.cjs +2127 -0
  44. package/dist/dom-DtgVTMnb.mjs +1977 -0
  45. package/dist/dom-DvHgqwJh.mjs +2046 -0
  46. package/dist/dom-EqEVp0-C.cjs +2033 -0
  47. package/dist/dom-NjCYLgPw.cjs +2126 -0
  48. package/dist/dom-UHntoboN.cjs +2139 -0
  49. package/dist/dom-Z-gE5GK8.cjs +2168 -0
  50. package/dist/dom-mlV6havt.mjs +2048 -0
  51. package/dist/dom-x3xpYktC.cjs +2114 -0
  52. package/dist/dom-yD0xCNhJ.cjs +2096 -0
  53. package/dist/index-B2aNqkPk.d.ts +1440 -0
  54. package/dist/index-B_CgmZnk.d.ts +1433 -0
  55. package/dist/index-CEtCW1xG.d.ts +1433 -0
  56. package/dist/index-CfTsJbfE.d.ts +1432 -0
  57. package/dist/{index-S3MRf--S.d.ts → index-Co0eiBV7.d.ts} +270 -198
  58. package/dist/index-CtUAjHuo.d.ts +1433 -0
  59. package/dist/index-CuzRXgFf.d.ts +1439 -0
  60. package/dist/index-DFuY8uu9.d.ts +1431 -0
  61. package/dist/index-Dhj90n6u.d.ts +1433 -0
  62. package/dist/index-DjCdylRj.d.ts +1438 -0
  63. package/dist/index-DyKry_9r.d.ts +1439 -0
  64. package/dist/index-FWrGRiCX.d.ts +1431 -0
  65. package/dist/index-wIzDVlFz.d.ts +1439 -0
  66. package/dist/index.cjs +408 -3
  67. package/dist/index.d.cts +29 -153
  68. package/dist/index.d.ts +29 -153
  69. package/dist/index.mjs +339 -3
  70. package/dist/render/client.cjs +97 -2
  71. package/dist/render/client.d.cts +2 -2
  72. package/dist/render/client.d.ts +2 -2
  73. package/dist/render/client.mjs +79 -2
  74. package/dist/render/index.cjs +21 -2
  75. package/dist/render/index.d.cts +1 -1
  76. package/dist/render/index.d.ts +1 -1
  77. package/dist/render/index.mjs +2 -2
  78. package/dist/render/server.cjs +94 -2
  79. package/dist/render/server.d.cts +2 -2
  80. package/dist/render/server.d.ts +2 -2
  81. package/dist/render/server.mjs +55 -2
  82. package/package.json +10 -17
  83. package/dist/dom-Cm_LuWlw.mjs +0 -2
  84. package/dist/dom-Cm_LuWlw.mjs.map +0 -1
  85. package/dist/dom-DLKNKVTt.cjs +0 -2
  86. package/dist/dom-DLKNKVTt.cjs.map +0 -1
  87. package/dist/index.cjs.map +0 -1
  88. package/dist/index.mjs.map +0 -1
  89. package/dist/render/client.cjs.map +0 -1
  90. package/dist/render/client.mjs.map +0 -1
  91. package/dist/render/index.cjs.map +0 -1
  92. package/dist/render/index.mjs.map +0 -1
  93. package/dist/render/server.cjs.map +0 -1
  94. package/dist/render/server.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,15 +1,13 @@
1
- import { f as VNode, e as VNodeAttributes, R as RenderInput, G as Globals, o as Props, l as VNodeChild, d as Ref } from './index-S3MRf--S.js';
2
- export { $, A as AllHTMLElements, C as CSSProperties, n as Children, Y as D, Z as Dequery, W as DequeryChain, Q as DequeryOptions, D as DomAbstractionImpl, U as ElementCreationOptions, F as FontFaceProperties, M as FormFieldValue, O as FormKeyValues, E as Fragment, K as KeyFrameProperties, a6 as Listener, N as NodeType, P as ParentElementInput, b as ParentElementInputAsync, c as RefUpdateFn, p as RenderNodeInput, a as RenderResult, q as RenderResultNode, a7 as Store, S as SyncRenderInput, w as SyncRenderResult, V as VAttributes, m as VNodeChildren, h as VNodeKey, k as VNodeRef, j as VNodeRefCallback, i as VNodeRefObject, g as VNodeType, T as adefaultConfig, r as createInPlaceErrorMessageVNode, L as createRef, a8 as createStore, X as dequery, v as getRenderer, z as globalScopeDomApis, u as handleLifecycleEventsForOnMount, _ as isDequery, B as isJSX, J as isRef, s as jsx, I as jsxDEV, H as jsxs, t as observeUnmount, a3 as renderHTML, y as renderIsomorphicAsync, x as renderIsomorphicSync, a5 as runWithTimeGuard, a4 as sleep, a2 as waitForRefWithPolling, a1 as waitForSelectorWithPolling, a0 as waitForWithPolling } from './index-S3MRf--S.js';
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 MemoryProviderOptions = {};
42
- interface MemoryStorage<T> extends PersistenceProviderImpl<T> {
43
- backendApi: Omit<Omit<Storage, 'key'>, 'length'>;
44
- }
45
- interface WebStorage<T> extends PersistenceProviderImpl<T> {
46
- backendApi: Storage;
47
- }
48
-
49
- type MiddlewareFn<T> = (key: string, value: T) => T;
50
- /** a simple key/value persistence interface */
51
- interface PersistenceProviderImpl<T> {
52
- get: (key: string, defaultValue: T, middlewareFn?: MiddlewareFn<T>) => T;
53
- set: (key: string, value: T, middlewareFn?: MiddlewareFn<T>) => void;
54
- remove: (key: string) => void;
55
- removeAll: () => void;
56
- backendApi: any;
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 = 'page-refresh' | 'slot-refresh';
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 = 'loading' | 'loaded' | 'error';
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, type FetchResponse, type FetchWithControllersInit, Globals, Headers, type I18nStore, type MemoryStorage, type MiddlewareFn, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, type PersistenceProvider, type PersistenceProviderImpl, type PersistenceProviderOptions, ProgressController, ProgressSignal, 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, type WebStorage, areDomNodesEqual, createI18n, ensureKey, fetch, getAllKeysFromPath, getByPath, i18n, inDevMode, matchRouteRegistrations, parseHeaders, replaceDomWithVdom, serializeBody, setByPath, setupRouter, tokenizePath, updateDom, updateDomWithVdom, webstorage };
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
- var O=Object.defineProperty;var n=(r,e)=>O(r,"name",{value:e,configurable:!0});import{l as A,k as R,$ as p,f as v}from"./dom-Cm_LuWlw.mjs";import{y as se,D as re,F as oe,w as ne,q as ae,c as ie,x as ce,n as ue,m as le,p as de,b as pe,g as fe,h as ge,z as he,i as me,j as ye,e as we,d as Se,o as xe,E as Re,a as Pe,r as Ee,v as be,H as Ae,s as ve,G as Ce,u as Te,t as De,C as Me,B as qe,A as Le}from"./dom-Cm_LuWlw.mjs";const C=!0,F=n(()=>{const r=new Map;return{clear:n(()=>{r.clear()},"clear"),getItem:n(e=>r.get(String(e))??null,"getItem"),removeItem:n(e=>{r.delete(String(e))},"removeItem"),setItem:n((e,o)=>{r.set(String(e),o)},"setItem")}},"newInMemoryGenericStorageBackend"),W=F();class y{static{n(this,"WebStorageProvider")}storage;constructor(e){this.storage=e||W}get(e,o,t){const s=this.storage.getItem(e);if(s===null)return o;let a=JSON.parse(s);return t&&(a=t(e,a)),a}set(e,o,t){t&&(o=t(e,o)),this.storage.setItem(e,JSON.stringify(o))}remove(e){this.storage.removeItem(e)}removeAll(){this.storage.clear()}get backendApi(){return this.storage}}const $=n((r,e)=>{switch(r){case"session":return new y(window.sessionStorage);case"local":return new y(window.localStorage)}return new y},"getPersistenceProvider$1"),H=n((r,e)=>new y,"getPersistenceProvider"),V=n(()=>typeof window>"u"||typeof window.document>"u","isServer"),k=n((r="local",e)=>V()?H():$(r),"webstorage"),z=/{([^}]*)}/g,G=n((r,e)=>r.replace(z,(o,t)=>e[t]||`{${t}}`),"interpolate"),T=n(()=>{const r=A({});let e="en";const o=[];return{language:e,changeLanguage(t){e=t,o.forEach(s=>s(t))},t(t,s={}){const a=r.get(`${e}.${t}`)||t;return typeof a!="string"?a:G(a,s)},load(t,s){r.set(t,{...r.get(t),...s})},subscribe(t){return o.push(t),()=>{const s=o.indexOf(t);s>=0&&o.splice(s,1)}}}},"createI18n"),w=T(),J=n(({path:r,replacements:e,tag:o,...t})=>{const s={};return w.subscribe(()=>{const a=w.t(r,e);console.log("new val",a)}),{tag:o||"span",attributes:{ref:s,...t},children:w.t(r,e)}},"Trans");class m{static{n(this,"Headers")}map;constructor(e={}){this.map=new Map,e instanceof m?e.forEach((o,t)=>this.map.set(t,o)):Object.entries(e).forEach(([o,t])=>this.map.set(o.toLowerCase(),t))}append(e,o){this.map.set(e.toLowerCase(),o)}get(e){return this.map.get(e.toLowerCase())||null}has(e){return this.map.has(e.toLowerCase())}forEach(e){this.map.forEach((o,t)=>e(o,t))}}class D extends EventTarget{static{n(this,"ProgressSignal")}_progress;constructor(){super(),this._progress={loaded:0,total:0}}get progress(){return this._progress}dispatchProgress(e){this._progress={loaded:e.loaded,total:e.total},this.dispatchEvent(new ProgressEvent("progress",{loaded:e.loaded,total:e.total}))}}class U{static{n(this,"ProgressController")}signal;constructor(){this.signal=new D}}function M(r){return r?r instanceof FormData||r instanceof Blob||r instanceof URLSearchParams||r instanceof ArrayBuffer||ArrayBuffer.isView(r)||typeof r=="string"?r:typeof r=="object"?JSON.stringify(r):String(r):null}n(M,"serializeBody");function q(r){const e=new m;return r.split(`\r
2
- `).forEach(o=>{const[t,...s]=o.split(": ");t&&e.append(t,s.join(": "))}),e}n(q,"parseHeaders");async function L(r,e={}){return!e.progressSignal&&typeof globalThis.fetch=="function"?L(r,e):new Promise((o,t)=>{const s=new XMLHttpRequest,a=(e.method||"GET").toUpperCase(),l=M(e.body||null),f=e.progressSignal,g=e.signal;if(g){const u=n(()=>{s.abort(),t(new DOMException("The operation was aborted.","AbortError"))},"abortHandler");g.addEventListener("abort",u,{once:!0})}s.open(a,r.toString(),!0),e.credentials==="include"?s.withCredentials=!0:e.credentials==="omit"&&(s.withCredentials=!1),e.headers instanceof m?e.headers.forEach((u,h)=>s.setRequestHeader(h,u)):e.headers&&Object.entries(e.headers).forEach(([u,h])=>{s.setRequestHeader(u,h)}),f&&(s.upload&&(s.upload.onprogress=u=>f.dispatchProgress(u)),s.onprogress=u=>f.dispatchProgress(u)),s.onload=()=>{const u={ok:s.status>=200&&s.status<300,status:s.status,statusText:s.statusText,headers:q(s.getAllResponseHeaders()),url:s.responseURL,text:n(()=>Promise.resolve(s.responseText),"text"),json:n(()=>Promise.resolve(JSON.parse(s.responseText)),"json"),blob:n(()=>Promise.resolve(new Blob([s.response])),"blob")};o(u)},s.onerror=()=>t(new TypeError("Network request failed")),s.ontimeout=()=>t(new TypeError("Network request timed out")),s.onabort=()=>t(new DOMException("The operation was aborted.","AbortError")),s.send(l)})}n(L,"fetch");const P=n(r=>{const e=/:([^\/\.\\]+)/g,o={};let t=1;const s=r.replace(e,(a,l)=>(o[l]=t++,"([^/.\\]+)"));return{groups:o,regexp:new RegExp(`^${s}$`)}},"tokenizePath"),I=n((r,e,o)=>{for(const t of r){if(o&&t.path!==o||t.exact&&t.path!==e)continue;const s=t.tokenizedPath.regexp.exec(e);if(!s)continue;const a={};for(const[f,g]of Object.entries(t.tokenizedPath.groups))a[f]=s[g];const l={url:e,params:a};return typeof t.handler=="function"&&t.handler(l),l}return!1},"matchRouteRegistrations"),_=n((r={strategy:"page-refresh"},e)=>{const o=[];typeof window<"u"&&!e&&(e=globalThis.__defuss_window||window),e||console.warn("Router requires a Window API implementation!");const t={...r,listeners:[],onRouteChange:n(s=>{t.listeners.push(s)},"onRouteChange"),tokenizePath:P,add(s){return o.some(l=>l.path===s.path)||o.push({...s,tokenizedPath:P(s.path)}),t},match(s){return I(o,e.document.location.pathname,s)},navigate(s){const a=t.strategy||"page-refresh",l=e?e.document.location.pathname:"";if(a==="page-refresh")document.location.href=s;else if(a==="slot-refresh"){typeof e<"u"&&e.history.pushState({},"",s);for(const f of t.listeners)f(s,l)}},getRoutes(){return o}};return t},"setupRouter"),S=_(),j=n(({path:r,exact:e,children:o,router:t=S})=>(t.add({path:r,exact:e||!1}),t.match(r)?o[0]:null),"Route"),N=n(({path:r,to:e,router:o=S,exact:t})=>(requestAnimationFrame(()=>{j({path:r,router:o,exact:t,children:[!0]})&&o.navigate(e)}),null),"Redirect"),x="router-slot",X=n(({router:r=S,children:e,RouterOutlet:o,...t})=>{const{tag:s,...a}=t,l=R();return r.strategy="slot-refresh",r.onRouteChange(()=>{p(l).update(o())}),document.getElementById(x)&&console.warn(`It seems there's more than one <RouterSlot /> components defined as an element with id #${x} already exists in the DOM.`),{children:o()||[],type:t.tag||"div",attributes:{...a,id:x,ref:l}}},"RouterSlot"),B=n(({fallback:r,ref:e,children:o,class:t,className:s,id:a,loadingClassName:l,loadedClassName:f,errorClassName:g,onError:u})=>{let h=o;const i=R(n(function(d){try{if(!i.current){C&&console.warn("Suspense container is not mounted yet, but a state update demands a render. State is:",d);return}p(i.current).removeClass(l||"suspense-loading"),p(i.current).removeClass(f||"suspense-loaded"),p(i.current).removeClass(g||"suspense-error"),!o||d==="error"?(p(i.current).addClass(g||"suspense-error"),p(i).jsx({type:"div",children:["Loading error!"]})):d==="loading"?(p(i.current).addClass(l||"suspense-loading"),p(i).jsx(r)):d==="loaded"&&(p(i.current).addClass(f||"suspense-loaded"),console.log("[Async render] start"),p(i).jsx(h),console.log("[Async render] finished"))}catch(b){i.update("error"),i.error=b,typeof u=="function"&&u(b)}},"onSuspenseUpdate"),"loading");if(v(e)){let c=!0;e.update=d=>{c||i.update(d)},e.update("loading"),c=!1}const E=(o||[]).map(c=>{try{if(!c||c&&!c.type)return Promise.resolve("");if(c.type.constructor.name==="AsyncFunction"){const d={...c.attributes,children:c.children};return c.type(d)}return Promise.resolve(c)}catch(d){i.update("error"),i.error=d,typeof u=="function"&&u(d)}});return{type:"div",attributes:{id:a,class:t,className:s,ref:i,onMount:n(()=>{E.length&&(i.update("loading"),Promise.all(E).then(c=>{h=c.flatMap(d=>d?.type==="Fragment"?d.children:d),i.update("loaded")}).catch(c=>{i.update("error"),i.error=c,console.error("SuspenseLoadingError",c),p(i).jsx(`SuspenseLoadingError: ${c}`),typeof u=="function"&&u(c)}))},"onMount")},children:r?[r]:[]}},"Async"),K=B;export{p as $,B as Async,se as D,re as DequeryChain,oe as Fragment,m as Headers,U as ProgressController,D as ProgressSignal,N as Redirect,j as Route,S as Router,X as RouterSlot,x as RouterSlotId,K as Suspense,J as Trans,ne as adefaultConfig,ae as areDomNodesEqual,T as createI18n,ie as createInPlaceErrorMessageVNode,R as createRef,A as createStore,ce as dequery,ue as ensureKey,L as fetch,le as getAllKeysFromPath,de as getByPath,pe as getRenderer,fe as globalScopeDomApis,ge as handleLifecycleEventsForOnMount,w as i18n,C as inDevMode,he as isDequery,me as isJSX,v as isRef,ye as jsx,we as jsxDEV,Se as jsxs,I as matchRouteRegistrations,xe as observeUnmount,q as parseHeaders,Re as renderHTML,Pe as renderIsomorphicAsync,Ee as renderIsomorphicSync,be as replaceDomWithVdom,Ae as runWithTimeGuard,M as serializeBody,ve as setByPath,_ as setupRouter,Ce as sleep,P as tokenizePath,Te as updateDom,De as updateDomWithVdom,Me as waitForRefWithPolling,qe as waitForSelectorWithPolling,Le as waitForWithPolling,k as webstorage};
3
- //# sourceMappingURL=index.mjs.map
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 };