jaxs 0.6.0 → 0.7.0
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/jaxs.d.ts +67 -15
- package/dist/jaxs.js +270 -232
- package/dist/jaxs.umd.cjs +1 -1
- package/package.json +3 -3
package/dist/jaxs.d.ts
CHANGED
|
@@ -39,15 +39,14 @@ declare module "state/store-updater" {
|
|
|
39
39
|
get value(): T;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
declare module "state/updaters/
|
|
42
|
+
declare module "state/updaters/object" {
|
|
43
43
|
import { Store } from "types";
|
|
44
44
|
import { StoreUpdaterBase } from "state/store-updater";
|
|
45
|
-
export class
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setFalse(): void;
|
|
45
|
+
export class StoreUpdaterObject<T> extends StoreUpdaterBase<T> {
|
|
46
|
+
updateAttribute(name: keyof T, value: T[keyof T]): void;
|
|
47
|
+
resetAttribute(name: keyof T): void;
|
|
49
48
|
}
|
|
50
|
-
export const
|
|
49
|
+
export const objectUpdater: <T>(store: Store<T>) => StoreUpdaterObject<T>;
|
|
51
50
|
}
|
|
52
51
|
declare module "state/updaters/list" {
|
|
53
52
|
import { StoreListSorterFunction, Store } from "types";
|
|
@@ -65,14 +64,15 @@ declare module "state/updaters/list" {
|
|
|
65
64
|
}
|
|
66
65
|
export const listUpdater: <T>(store: Store<T[]>) => StoreUpdaterList<T>;
|
|
67
66
|
}
|
|
68
|
-
declare module "state/updaters/
|
|
67
|
+
declare module "state/updaters/boolean" {
|
|
69
68
|
import { Store } from "types";
|
|
70
69
|
import { StoreUpdaterBase } from "state/store-updater";
|
|
71
|
-
export class
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
|
|
71
|
+
toggle(): void;
|
|
72
|
+
setTrue(): void;
|
|
73
|
+
setFalse(): void;
|
|
74
74
|
}
|
|
75
|
-
export const
|
|
75
|
+
export const booleanUpdater: (store: Store<boolean>) => StoreUpdaterBoolean;
|
|
76
76
|
}
|
|
77
77
|
declare module "state/updaters" {
|
|
78
78
|
export const updaters: {
|
|
@@ -94,9 +94,6 @@ declare module "state/index" {
|
|
|
94
94
|
inTransaction: boolean;
|
|
95
95
|
constructor(publisher: StatePublisher);
|
|
96
96
|
create<T>(name: string, initialState: T): Store<T>;
|
|
97
|
-
createBoolean(name: string, initialState: boolean): Store<boolean>;
|
|
98
|
-
createRecord<T>(name: string, initialState: T): Store<T>;
|
|
99
|
-
createList<T>(name: string, initialState: T[]): Store<T[]>;
|
|
100
97
|
store<T>(name: string): Store<T>;
|
|
101
98
|
get<T>(name: string): T;
|
|
102
99
|
getAll(names: string[]): {};
|
|
@@ -131,10 +128,36 @@ declare module "bus/fuzzy-subscriptions" {
|
|
|
131
128
|
matches(event: string): FuzzySubscriptionData<any>[];
|
|
132
129
|
}
|
|
133
130
|
}
|
|
131
|
+
declare module "bus/custom-periodic-publisher" {
|
|
132
|
+
import { PeriodicPublisher, PublishFunction, PeriodicTimerFunction, CustomPeriodicPublisherOptions } from "types";
|
|
133
|
+
export class CustomPeriodicPublisher implements PeriodicPublisher {
|
|
134
|
+
publish: PublishFunction;
|
|
135
|
+
event: string;
|
|
136
|
+
payload: any;
|
|
137
|
+
stopped: boolean;
|
|
138
|
+
timer: PeriodicTimerFunction;
|
|
139
|
+
timeoutId: any;
|
|
140
|
+
stop: () => void;
|
|
141
|
+
callCount: number;
|
|
142
|
+
startedAt: number;
|
|
143
|
+
constructor({ publish, event, payload, timer, }: CustomPeriodicPublisherOptions);
|
|
144
|
+
start(): void;
|
|
145
|
+
setNewTimeout: () => void;
|
|
146
|
+
calculateNextTime: () => number;
|
|
147
|
+
diff(): number;
|
|
148
|
+
stopTimeout(): void;
|
|
149
|
+
publishEvent(): void;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
declare module "bus/publish-periodically" {
|
|
153
|
+
import type { PublishPeriodicallyOptions } from "types";
|
|
154
|
+
export const publishPeriodically: (options: PublishPeriodicallyOptions) => () => void;
|
|
155
|
+
}
|
|
134
156
|
declare module "bus/index" {
|
|
135
157
|
import { BusEventMatcher, BusListener, Unsubscribe, AppAdditionListenerOptions, ListenerKit } from "types";
|
|
136
158
|
import { ExactSubscriptions } from "bus/exact-subscriptions";
|
|
137
159
|
import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
|
|
160
|
+
import { publishPeriodically } from "bus/publish-periodically";
|
|
138
161
|
class JaxsBus {
|
|
139
162
|
options?: AppAdditionListenerOptions;
|
|
140
163
|
exactSubscriptions: ExactSubscriptions;
|
|
@@ -151,7 +174,7 @@ declare module "bus/index" {
|
|
|
151
174
|
publish: (event: string, payload: any) => void;
|
|
152
175
|
subscribe: (matcher: BusEventMatcher, listener: BusListener<any>) => Unsubscribe;
|
|
153
176
|
};
|
|
154
|
-
export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions };
|
|
177
|
+
export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions, publishPeriodically, };
|
|
155
178
|
}
|
|
156
179
|
declare module "rendering/templates/root" {
|
|
157
180
|
import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
|
|
@@ -171,6 +194,7 @@ declare module "rendering/templates/root" {
|
|
|
171
194
|
}
|
|
172
195
|
declare module "navigation/events" {
|
|
173
196
|
export const linkNavigationEvent = "go-to-href";
|
|
197
|
+
export const navigationEvent = "go-to";
|
|
174
198
|
export const locationChangeEvent = "navigation:location-change";
|
|
175
199
|
export const routeChangeEvent = "navigation:route-change";
|
|
176
200
|
}
|
|
@@ -413,6 +437,34 @@ declare module "types" {
|
|
|
413
437
|
Partial: StaticTemplate;
|
|
414
438
|
match: RouteMatcher;
|
|
415
439
|
};
|
|
440
|
+
export interface PeriodicPublisher {
|
|
441
|
+
event: string;
|
|
442
|
+
publish: PublishFunction;
|
|
443
|
+
payload?: any;
|
|
444
|
+
start: () => void;
|
|
445
|
+
stop: () => void;
|
|
446
|
+
}
|
|
447
|
+
export type RequiredPeriodicPublisherOptions = {
|
|
448
|
+
event: string;
|
|
449
|
+
publish: PublishFunction;
|
|
450
|
+
payload?: any;
|
|
451
|
+
};
|
|
452
|
+
export type GeneralPeriodicOptions = {
|
|
453
|
+
period: number;
|
|
454
|
+
offset?: number;
|
|
455
|
+
};
|
|
456
|
+
export type CustomPeriodicOptions = {
|
|
457
|
+
timer: PeriodicTimerFunction;
|
|
458
|
+
};
|
|
459
|
+
export type GeneralPeriodicPublisherOptions = RequiredPeriodicPublisherOptions & GeneralPeriodicOptions;
|
|
460
|
+
export type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions & CustomPeriodicOptions;
|
|
461
|
+
export type PublishPeriodicallyOptions = GeneralPeriodicPublisherOptions | CustomPeriodicPublisherOptions;
|
|
462
|
+
export type PeriodicTimerFunctionOptions = {
|
|
463
|
+
timeDiff: number;
|
|
464
|
+
callCount: number;
|
|
465
|
+
stop: () => void;
|
|
466
|
+
};
|
|
467
|
+
export type PeriodicTimerFunction = (options: PeriodicTimerFunctionOptions) => number;
|
|
416
468
|
}
|
|
417
469
|
declare module "rendering/dom/tag" {
|
|
418
470
|
import type { JaxsElement, TagAttributes, TagEventAttributes, DomPublish, RenderKit } from "types";
|
package/dist/jaxs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Z = (e, t) => t.createElement(e), tt = (e, t) => {
|
|
2
2
|
for (const s in t) {
|
|
3
3
|
if (s === "__self") continue;
|
|
4
4
|
const r = t[s].toString();
|
|
@@ -8,7 +8,7 @@ const et = (e, t) => t.createElement(e), st = (e, t) => {
|
|
|
8
8
|
} else
|
|
9
9
|
e.setAttribute(s, r);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, et = (e, t, s) => {
|
|
12
12
|
const r = {};
|
|
13
13
|
for (const n in t) {
|
|
14
14
|
const o = t[n], a = (l) => s(o, l);
|
|
@@ -19,10 +19,10 @@ const et = (e, t) => t.createElement(e), st = (e, t) => {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
e.eventMaps = r;
|
|
22
|
-
},
|
|
23
|
-
const n =
|
|
24
|
-
return
|
|
25
|
-
}, y = "http://www.w3.org/2000/svg",
|
|
22
|
+
}, st = (e, t, s, r) => {
|
|
23
|
+
const n = Z(e, r.document);
|
|
24
|
+
return tt(n, t), et(n, s, r.publish), n;
|
|
25
|
+
}, y = "http://www.w3.org/2000/svg", rt = {
|
|
26
26
|
animate: !0,
|
|
27
27
|
animateMotion: !0,
|
|
28
28
|
animateTransform: !0,
|
|
@@ -85,22 +85,22 @@ const et = (e, t) => t.createElement(e), st = (e, t) => {
|
|
|
85
85
|
tspan: !0,
|
|
86
86
|
use: !0,
|
|
87
87
|
view: !0
|
|
88
|
-
},
|
|
88
|
+
}, nt = (e, t) => !!(rt[e] || e === "a" && t === y), ot = (e, t, s) => {
|
|
89
89
|
const r = s.createElementNS(y, e);
|
|
90
90
|
for (const n in t)
|
|
91
91
|
n === "__self" || n === "xmlns" || r.setAttributeNS(null, n, t[n].toString());
|
|
92
92
|
return r;
|
|
93
|
-
},
|
|
94
|
-
class
|
|
93
|
+
}, it = (e) => e.namespaceURI === y, ut = (e, t) => t.createTextNode(e);
|
|
94
|
+
class at {
|
|
95
95
|
constructor(t) {
|
|
96
96
|
this.value = t.toString();
|
|
97
97
|
}
|
|
98
98
|
render(t) {
|
|
99
|
-
const s =
|
|
99
|
+
const s = ut(this.value, t.document);
|
|
100
100
|
return s.__jsx = "TextNode", [s];
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
const
|
|
103
|
+
const ct = (e) => typeof e == "string" || typeof e == "number", lt = (e) => new at(e), ht = (e) => ct(e) ? lt(e) : e, dt = (e) => pt(e).map(ht).flat(), pt = (e) => Array.isArray(e) ? e.flat() : e ? [e] : [], T = (e, t = {}) => e || t.children || [], mt = (e, t = "") => {
|
|
104
104
|
const s = {}, r = {};
|
|
105
105
|
for (const n in e) {
|
|
106
106
|
const o = e[n];
|
|
@@ -109,17 +109,17 @@ const ht = (e) => typeof e == "string" || typeof e == "number", dt = (e) => new
|
|
|
109
109
|
r[a] = o ? o.toString() : "";
|
|
110
110
|
} else {
|
|
111
111
|
if (o === !1) continue;
|
|
112
|
-
n === "__source" ? s.__source = e.__source : s[n] =
|
|
112
|
+
n === "__source" ? s.__source = e.__source : s[n] = ft(n, o, t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
return {
|
|
116
116
|
attributes: s,
|
|
117
117
|
events: r
|
|
118
118
|
};
|
|
119
|
-
},
|
|
120
|
-
const s = e || {}, r =
|
|
119
|
+
}, ft = (e, t, s = "") => t == null ? s : t.toString(), bt = (e, t) => {
|
|
120
|
+
const s = e || {}, r = T(t, s);
|
|
121
121
|
return s.children = s.children || r, s;
|
|
122
|
-
}, j = (e, t, s, r = []) => e.reduce(
|
|
122
|
+
}, j = (e, t, s, r = []) => e.reduce(vt(t, s), r).flat(), vt = (e, t) => (s, r) => r ? Array.isArray(r) ? j(
|
|
123
123
|
r,
|
|
124
124
|
e,
|
|
125
125
|
t,
|
|
@@ -127,7 +127,7 @@ const ht = (e) => typeof e == "string" || typeof e == "number", dt = (e) => new
|
|
|
127
127
|
) : (r.render(e, t).forEach((n) => s.push(n)), s) : s;
|
|
128
128
|
class O {
|
|
129
129
|
constructor(t) {
|
|
130
|
-
this.collection =
|
|
130
|
+
this.collection = dt(t);
|
|
131
131
|
}
|
|
132
132
|
render(t, s) {
|
|
133
133
|
this.parentElement = s;
|
|
@@ -143,7 +143,7 @@ class O {
|
|
|
143
143
|
t.forEach((r) => s.appendChild(r));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
class
|
|
146
|
+
class gt {
|
|
147
147
|
constructor(t, s) {
|
|
148
148
|
this.type = t, this.attributes = s;
|
|
149
149
|
}
|
|
@@ -161,11 +161,11 @@ class Et {
|
|
|
161
161
|
return `${this.type}${t}${s}${r}`;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
164
|
+
class yt {
|
|
165
165
|
constructor(t, s, r = []) {
|
|
166
166
|
this.type = t;
|
|
167
|
-
const { events: n, attributes: o } =
|
|
168
|
-
this.events = n, this.attributes = o, this.isSvg =
|
|
167
|
+
const { events: n, attributes: o } = mt(s);
|
|
168
|
+
this.events = n, this.attributes = o, this.isSvg = nt(this.type, this.attributes.xmlns), this.children = new O(r);
|
|
169
169
|
}
|
|
170
170
|
render(t) {
|
|
171
171
|
const s = this.generateDom(t);
|
|
@@ -175,7 +175,7 @@ class xt {
|
|
|
175
175
|
return this.isSvg ? this.generateSvgDom(t) : this.generateHtmlDom(t);
|
|
176
176
|
}
|
|
177
177
|
generateHtmlDom(t) {
|
|
178
|
-
const s =
|
|
178
|
+
const s = st(
|
|
179
179
|
this.type,
|
|
180
180
|
this.attributes,
|
|
181
181
|
this.events,
|
|
@@ -184,19 +184,19 @@ class xt {
|
|
|
184
184
|
return s.__jsx = this.jsxKey(), s;
|
|
185
185
|
}
|
|
186
186
|
generateSvgDom(t) {
|
|
187
|
-
const s =
|
|
187
|
+
const s = ot(this.type, this.attributes, t.document);
|
|
188
188
|
return s.__jsx = this.jsxKey(), s;
|
|
189
189
|
}
|
|
190
190
|
jsxKey() {
|
|
191
|
-
return new
|
|
191
|
+
return new gt(this.type, this.attributes).generate();
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
const s =
|
|
194
|
+
const Et = (e, t, ...s) => typeof e == "string" ? new yt(e, t, s) : e(bt(t, s));
|
|
195
|
+
Et.fragment = (e, t) => {
|
|
196
|
+
const s = T(t, e);
|
|
197
197
|
return new O(s);
|
|
198
198
|
};
|
|
199
|
-
class
|
|
199
|
+
class xt {
|
|
200
200
|
constructor(t, s, r) {
|
|
201
201
|
this.template = t, this.selector = s, this.renderKit = r, this.dom = [];
|
|
202
202
|
}
|
|
@@ -215,75 +215,78 @@ class _t {
|
|
|
215
215
|
return this.renderKit.document.querySelector(this.selector);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
const
|
|
219
|
-
const r = new
|
|
218
|
+
const At = (e, t, s) => {
|
|
219
|
+
const r = new xt(e, t, s);
|
|
220
220
|
return r.renderAndAttach(s), r;
|
|
221
|
-
}, M = "go-to-href", m = "navigation:location-change",
|
|
221
|
+
}, M = "go-to-href", k = "go-to", m = "navigation:location-change", $ = "navigation:route-change", wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
222
222
|
__proto__: null,
|
|
223
223
|
linkNavigationEvent: M,
|
|
224
224
|
locationChangeEvent: m,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
navigationEvent: k,
|
|
226
|
+
routeChangeEvent: $
|
|
227
|
+
}, Symbol.toStringTag, { value: "Module" })), D = (e) => {
|
|
228
|
+
e.create("route", {
|
|
228
229
|
host: "",
|
|
229
230
|
path: "",
|
|
230
231
|
query: {}
|
|
231
232
|
});
|
|
232
|
-
},
|
|
233
|
+
}, P = (e) => {
|
|
233
234
|
const t = e.closest("[href]");
|
|
234
235
|
return t && t.getAttribute("href") || "";
|
|
235
|
-
},
|
|
236
|
+
}, E = (e, { publish: t, window: s }) => {
|
|
236
237
|
s.history.pushState(null, "", e), t(m, null);
|
|
237
|
-
},
|
|
238
|
+
}, F = (e, t) => {
|
|
238
239
|
if (!e || !e.target) return;
|
|
239
240
|
e.preventDefault();
|
|
240
|
-
const s =
|
|
241
|
-
|
|
241
|
+
const s = P(e.target);
|
|
242
|
+
E(s, t);
|
|
242
243
|
}, L = (e) => e.replace(/^\?/, "").split("&").reduce((t, s) => {
|
|
243
244
|
if (!s) return t;
|
|
244
245
|
const r = s.split("=");
|
|
245
246
|
return t[r[0]] = r[1], t;
|
|
246
|
-
}, {}),
|
|
247
|
+
}, {}), z = (e, t) => {
|
|
247
248
|
const { state: s, publish: r, window: n } = t, { host: o, pathname: a, search: l } = n.location, u = a, d = L(l), c = {
|
|
248
249
|
host: o,
|
|
249
250
|
path: u,
|
|
250
251
|
query: d
|
|
251
252
|
};
|
|
252
|
-
s.store("route").update(c), r(
|
|
253
|
+
s.store("route").update(c), r($, c);
|
|
253
254
|
}, B = (e) => {
|
|
254
255
|
const { subscribe: t } = e;
|
|
255
|
-
t(M,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
T(r), n.addEventListener("popstate", () => t(m, null)), s(m, F);
|
|
256
|
+
t(M, F), t(k, (s, r) => {
|
|
257
|
+
E(s, r);
|
|
258
|
+
});
|
|
259
259
|
}, V = (e) => {
|
|
260
|
-
|
|
260
|
+
const { publish: t, subscribe: s, state: r, window: n } = e;
|
|
261
|
+
D(r), n.addEventListener("popstate", () => t(m, null)), s(m, z);
|
|
261
262
|
}, K = (e) => {
|
|
262
|
-
|
|
263
|
-
},
|
|
263
|
+
setTimeout(() => e.publish(m, null), 0);
|
|
264
|
+
}, R = (e) => {
|
|
265
|
+
V(e), B(e), K(e);
|
|
266
|
+
}, Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
264
267
|
__proto__: null,
|
|
265
|
-
publishLocation:
|
|
266
|
-
startNavigation:
|
|
267
|
-
subscribeToHistoryChange:
|
|
268
|
+
publishLocation: K,
|
|
269
|
+
startNavigation: R,
|
|
270
|
+
subscribeToHistoryChange: V,
|
|
268
271
|
subscribeToNavigation: B
|
|
269
272
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
270
|
-
class
|
|
273
|
+
class U {
|
|
271
274
|
constructor({ window: t, document: s, publish: r, subscribe: n, bus: o, state: a, renderKit: l }) {
|
|
272
275
|
this.window = t, this.document = s, this.publish = r, this.subscribe = n, this.bus = o, this.state = a, this.renderKit = l, this.roots = [];
|
|
273
276
|
}
|
|
274
277
|
render(t, s) {
|
|
275
|
-
const r =
|
|
278
|
+
const r = At(t, s, this.renderKit);
|
|
276
279
|
return this.roots.push(r), r;
|
|
277
280
|
}
|
|
278
281
|
startNavigation() {
|
|
279
|
-
|
|
282
|
+
R(this);
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
const
|
|
285
|
+
const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
283
286
|
__proto__: null,
|
|
284
|
-
App:
|
|
287
|
+
App: U
|
|
285
288
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
286
|
-
class
|
|
289
|
+
class C {
|
|
287
290
|
constructor() {
|
|
288
291
|
this.lookup = {};
|
|
289
292
|
}
|
|
@@ -306,7 +309,7 @@ class U {
|
|
|
306
309
|
this.lookup[t] || (this.lookup[t] = []);
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
|
-
class
|
|
312
|
+
class I {
|
|
310
313
|
constructor() {
|
|
311
314
|
this.lookup = [];
|
|
312
315
|
}
|
|
@@ -327,9 +330,55 @@ class q {
|
|
|
327
330
|
);
|
|
328
331
|
}
|
|
329
332
|
}
|
|
330
|
-
class
|
|
333
|
+
class _t {
|
|
334
|
+
constructor({
|
|
335
|
+
publish: t,
|
|
336
|
+
event: s,
|
|
337
|
+
payload: r,
|
|
338
|
+
timer: n
|
|
339
|
+
}) {
|
|
340
|
+
this.setNewTimeout = () => {
|
|
341
|
+
this.stopped || setTimeout(() => {
|
|
342
|
+
this.publishEvent(), this.setNewTimeout();
|
|
343
|
+
}, this.calculateNextTime());
|
|
344
|
+
}, this.calculateNextTime = () => this.timer({
|
|
345
|
+
timeDiff: this.diff(),
|
|
346
|
+
callCount: this.callCount,
|
|
347
|
+
stop: this.stop
|
|
348
|
+
}), this.publish = t, this.event = s, this.payload = r || null, this.stop = this.stopTimeout.bind(this), this.stopped = !1, this.timer = n, this.startedAt = (/* @__PURE__ */ new Date()).getTime(), this.callCount = 0;
|
|
349
|
+
}
|
|
350
|
+
start() {
|
|
351
|
+
this.setNewTimeout();
|
|
352
|
+
}
|
|
353
|
+
diff() {
|
|
354
|
+
return (/* @__PURE__ */ new Date()).getTime() - this.startedAt;
|
|
355
|
+
}
|
|
356
|
+
stopTimeout() {
|
|
357
|
+
this.stopped = !0, this.timeoutId && clearTimeout(this.timeoutId);
|
|
358
|
+
}
|
|
359
|
+
publishEvent() {
|
|
360
|
+
this.stopped || (this.callCount += 1, this.publish(this.event, this.payload));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const St = (e) => {
|
|
364
|
+
const { offset: t, period: s } = e, r = ({ callCount: n }) => t && n == 0 ? t : s;
|
|
365
|
+
return {
|
|
366
|
+
event: e.event,
|
|
367
|
+
publish: e.publish,
|
|
368
|
+
payload: e.payload,
|
|
369
|
+
timer: r
|
|
370
|
+
};
|
|
371
|
+
}, Tt = (e) => {
|
|
372
|
+
let t;
|
|
373
|
+
"timer" in e ? t = e : t = St(
|
|
374
|
+
e
|
|
375
|
+
);
|
|
376
|
+
const s = new _t(t);
|
|
377
|
+
return s.start(), s.stop;
|
|
378
|
+
};
|
|
379
|
+
class q {
|
|
331
380
|
constructor() {
|
|
332
|
-
this.exactSubscriptions = new
|
|
381
|
+
this.exactSubscriptions = new C(), this.fuzzySubscriptions = new I(), this.currentIndex = 0;
|
|
333
382
|
}
|
|
334
383
|
subscribe(t, s) {
|
|
335
384
|
let r;
|
|
@@ -363,25 +412,26 @@ class I {
|
|
|
363
412
|
}
|
|
364
413
|
}
|
|
365
414
|
const J = () => {
|
|
366
|
-
const e = new
|
|
415
|
+
const e = new q();
|
|
367
416
|
return {
|
|
368
417
|
bus: e,
|
|
369
418
|
publish: (r, n) => e.publish(r, n),
|
|
370
419
|
subscribe: (r, n) => e.subscribe(r, n)
|
|
371
420
|
};
|
|
372
|
-
},
|
|
421
|
+
}, De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
373
422
|
__proto__: null,
|
|
374
|
-
ExactSubscriptions:
|
|
375
|
-
FuzzySubscriptions:
|
|
376
|
-
JaxsBus:
|
|
377
|
-
createBus: J
|
|
423
|
+
ExactSubscriptions: C,
|
|
424
|
+
FuzzySubscriptions: I,
|
|
425
|
+
JaxsBus: q,
|
|
426
|
+
createBus: J,
|
|
427
|
+
publishPeriodically: Tt
|
|
378
428
|
}, Symbol.toStringTag, { value: "Module" })), f = (e) => Array.isArray(e), v = (e) => e !== null && !f(e) && typeof e == "object", jt = (e, t) => e === t, Ot = (e, t) => Object.keys(e).length === Object.keys(t).length, Mt = (e, t) => !(v(e) && v(t)) || !Ot(e, t) ? !1 : Object.keys(e).every((s) => {
|
|
379
429
|
const r = e[s], n = t[s];
|
|
380
|
-
return
|
|
430
|
+
return x(r, n);
|
|
381
431
|
}), kt = (e, t) => !(f(e) && f(t)) || e.length !== t.length ? !1 : e.every((s, r) => {
|
|
382
432
|
const n = t[r];
|
|
383
|
-
return
|
|
384
|
-
}),
|
|
433
|
+
return x(s, n);
|
|
434
|
+
}), x = (e, t) => v(e) ? Mt(e, t) : f(e) ? kt(e, t) : jt(e, t);
|
|
385
435
|
class g {
|
|
386
436
|
constructor(t) {
|
|
387
437
|
this.name = t.name, this.parent = t.parent, this._value = t.value, this.initialValue = structuredClone(t.value);
|
|
@@ -403,13 +453,13 @@ class g {
|
|
|
403
453
|
this.updateValue(t);
|
|
404
454
|
}
|
|
405
455
|
updateValue(t) {
|
|
406
|
-
|
|
456
|
+
x(this._value, t) || (this._value = t, this.parent.notify(this.name));
|
|
407
457
|
}
|
|
408
458
|
getUpdatedValue(t) {
|
|
409
459
|
return t(this.value);
|
|
410
460
|
}
|
|
411
461
|
}
|
|
412
|
-
class
|
|
462
|
+
class A {
|
|
413
463
|
constructor(t) {
|
|
414
464
|
this.store = t;
|
|
415
465
|
}
|
|
@@ -423,20 +473,18 @@ class x {
|
|
|
423
473
|
return this.store.value;
|
|
424
474
|
}
|
|
425
475
|
}
|
|
426
|
-
class
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
this.update(
|
|
430
|
-
}
|
|
431
|
-
setTrue() {
|
|
432
|
-
this.update(!0);
|
|
476
|
+
class $t extends A {
|
|
477
|
+
updateAttribute(t, s) {
|
|
478
|
+
const r = { ...this.value };
|
|
479
|
+
r[t] = s, this.update(r);
|
|
433
480
|
}
|
|
434
|
-
|
|
435
|
-
this.
|
|
481
|
+
resetAttribute(t) {
|
|
482
|
+
const s = { ...this.value }, r = this.store.initialValue[t];
|
|
483
|
+
s[t] = r, this.update(s);
|
|
436
484
|
}
|
|
437
485
|
}
|
|
438
|
-
const
|
|
439
|
-
class
|
|
486
|
+
const Dt = (e) => new $t(e);
|
|
487
|
+
class Pt extends A {
|
|
440
488
|
push(t) {
|
|
441
489
|
const s = [...this.value, t];
|
|
442
490
|
this.update(s);
|
|
@@ -475,25 +523,27 @@ class G extends x {
|
|
|
475
523
|
this.update(s);
|
|
476
524
|
}
|
|
477
525
|
}
|
|
478
|
-
const
|
|
479
|
-
class
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
526
|
+
const Ft = (e) => new Pt(e);
|
|
527
|
+
class Lt extends A {
|
|
528
|
+
toggle() {
|
|
529
|
+
const t = !this.value;
|
|
530
|
+
this.update(t);
|
|
483
531
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
532
|
+
setTrue() {
|
|
533
|
+
this.update(!0);
|
|
534
|
+
}
|
|
535
|
+
setFalse() {
|
|
536
|
+
this.update(!1);
|
|
487
537
|
}
|
|
488
538
|
}
|
|
489
|
-
const
|
|
539
|
+
const zt = (e) => new Lt(e), Bt = {
|
|
490
540
|
object: Dt,
|
|
491
|
-
list:
|
|
492
|
-
boolean:
|
|
493
|
-
},
|
|
494
|
-
class
|
|
541
|
+
list: Ft,
|
|
542
|
+
boolean: zt
|
|
543
|
+
}, w = "state";
|
|
544
|
+
class G {
|
|
495
545
|
constructor(t) {
|
|
496
|
-
this.publisher = t, this.stores = {}, this.eventNamePrefix =
|
|
546
|
+
this.publisher = t, this.stores = {}, this.eventNamePrefix = w, this.notifications = /* @__PURE__ */ new Set(), this.inTransaction = !1;
|
|
497
547
|
}
|
|
498
548
|
create(t, s) {
|
|
499
549
|
const r = new g({
|
|
@@ -503,18 +553,6 @@ class Q {
|
|
|
503
553
|
});
|
|
504
554
|
return this.stores[t] = r, r;
|
|
505
555
|
}
|
|
506
|
-
createBoolean(t, s) {
|
|
507
|
-
const r = this.create(t, s);
|
|
508
|
-
return r.updater = new H(r), r;
|
|
509
|
-
}
|
|
510
|
-
createRecord(t, s) {
|
|
511
|
-
const r = this.create(t, s);
|
|
512
|
-
return r.updater = new C(r), r;
|
|
513
|
-
}
|
|
514
|
-
createList(t, s) {
|
|
515
|
-
const r = this.create(t, s);
|
|
516
|
-
return r.updater = new G(r), r;
|
|
517
|
-
}
|
|
518
556
|
store(t) {
|
|
519
557
|
return this.stores[t] || new g({
|
|
520
558
|
name: t,
|
|
@@ -552,20 +590,20 @@ class Q {
|
|
|
552
590
|
return `${this.eventNamePrefix}:${t}`;
|
|
553
591
|
}
|
|
554
592
|
}
|
|
555
|
-
const
|
|
593
|
+
const H = (e) => new G(e), Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
556
594
|
__proto__: null,
|
|
557
|
-
State:
|
|
595
|
+
State: G,
|
|
558
596
|
Store: g,
|
|
559
|
-
createState:
|
|
560
|
-
eventName:
|
|
561
|
-
updaters:
|
|
597
|
+
createState: H,
|
|
598
|
+
eventName: w,
|
|
599
|
+
updaters: Bt
|
|
562
600
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
563
|
-
class
|
|
601
|
+
class Vt {
|
|
564
602
|
constructor(t) {
|
|
565
603
|
this.setupDomEnvironment(t);
|
|
566
604
|
}
|
|
567
605
|
setup() {
|
|
568
|
-
return this.setupBus(), this.setupState(), this.addBusOptions(), this.setRenderKit(), new
|
|
606
|
+
return this.setupBus(), this.setupState(), this.addBusOptions(), this.setRenderKit(), new U({
|
|
569
607
|
window: this.window,
|
|
570
608
|
document: this.document,
|
|
571
609
|
publish: this.publish,
|
|
@@ -583,7 +621,7 @@ class Lt {
|
|
|
583
621
|
this.publish = t, this.subscribe = s, this.bus = r;
|
|
584
622
|
}
|
|
585
623
|
setupState() {
|
|
586
|
-
this.state =
|
|
624
|
+
this.state = H(this.publish);
|
|
587
625
|
}
|
|
588
626
|
addBusOptions() {
|
|
589
627
|
this.bus.addListenerOptions({
|
|
@@ -602,55 +640,55 @@ class Lt {
|
|
|
602
640
|
};
|
|
603
641
|
}
|
|
604
642
|
}
|
|
605
|
-
const
|
|
606
|
-
const s = new
|
|
643
|
+
const Fe = (e = {}) => {
|
|
644
|
+
const s = new Vt(e).setup();
|
|
607
645
|
return s.startNavigation(), s;
|
|
608
646
|
};
|
|
609
647
|
var i = /* @__PURE__ */ ((e) => (e[e.removeNode = 0] = "removeNode", e[e.insertNode = 1] = "insertNode", e[e.replaceNode = 2] = "replaceNode", e[e.removeAttribute = 3] = "removeAttribute", e[e.addAttribute = 4] = "addAttribute", e[e.updateAttribute = 5] = "updateAttribute", e[e.removeEvent = 6] = "removeEvent", e[e.addEvent = 7] = "addEvent", e[e.updateEvent = 8] = "updateEvent", e[e.changeValue = 9] = "changeValue", e[e.changeText = 10] = "changeText", e))(i || {});
|
|
610
|
-
const
|
|
648
|
+
const Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
611
649
|
__proto__: null,
|
|
612
650
|
ChangeInstructionTypes: i
|
|
613
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
651
|
+
}, Symbol.toStringTag, { value: "Module" })), Kt = (e, t) => ({
|
|
614
652
|
source: e,
|
|
615
653
|
target: t,
|
|
616
654
|
type: i.changeText,
|
|
617
655
|
data: {}
|
|
618
|
-
}),
|
|
656
|
+
}), Rt = (e, t) => ({
|
|
619
657
|
source: e,
|
|
620
658
|
target: t,
|
|
621
659
|
type: i.replaceNode,
|
|
622
660
|
data: {}
|
|
623
|
-
}),
|
|
661
|
+
}), Ut = (e, t, s) => ({
|
|
624
662
|
source: e,
|
|
625
663
|
target: t,
|
|
626
664
|
data: s,
|
|
627
665
|
type: i.removeAttribute
|
|
628
|
-
}),
|
|
666
|
+
}), Ct = (e, t, s) => ({
|
|
629
667
|
source: e,
|
|
630
668
|
target: t,
|
|
631
669
|
data: s,
|
|
632
670
|
type: i.addAttribute
|
|
633
|
-
}),
|
|
671
|
+
}), It = (e, t, s) => ({
|
|
634
672
|
source: e,
|
|
635
673
|
target: t,
|
|
636
674
|
data: s,
|
|
637
675
|
type: i.updateAttribute
|
|
638
|
-
}),
|
|
676
|
+
}), qt = (e, t, s) => ({
|
|
639
677
|
source: e,
|
|
640
678
|
target: t,
|
|
641
679
|
data: s,
|
|
642
680
|
type: i.removeEvent
|
|
643
|
-
}),
|
|
681
|
+
}), Jt = (e, t, s) => ({
|
|
644
682
|
source: e,
|
|
645
683
|
target: t,
|
|
646
684
|
data: s,
|
|
647
685
|
type: i.addEvent
|
|
648
|
-
}),
|
|
686
|
+
}), Gt = (e, t, s) => ({
|
|
649
687
|
source: e,
|
|
650
688
|
target: t,
|
|
651
689
|
data: s,
|
|
652
690
|
type: i.updateEvent
|
|
653
|
-
}),
|
|
691
|
+
}), N = (e) => ({
|
|
654
692
|
source: e,
|
|
655
693
|
target: e,
|
|
656
694
|
// for type crap only
|
|
@@ -662,13 +700,13 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
662
700
|
// for type crap only
|
|
663
701
|
type: i.insertNode,
|
|
664
702
|
data: t
|
|
665
|
-
}),
|
|
703
|
+
}), Ht = (e, t, s) => ({
|
|
666
704
|
source: e,
|
|
667
705
|
target: t,
|
|
668
706
|
type: i.changeValue,
|
|
669
707
|
data: s
|
|
670
|
-
}),
|
|
671
|
-
class
|
|
708
|
+
}), Qt = (e, t) => e.type > t.type ? 1 : e.type < t.type ? -1 : 0, _ = { index: -1 };
|
|
709
|
+
class Wt {
|
|
672
710
|
constructor() {
|
|
673
711
|
this.map = {};
|
|
674
712
|
}
|
|
@@ -683,7 +721,7 @@ class Ht {
|
|
|
683
721
|
}
|
|
684
722
|
pullMatch(t) {
|
|
685
723
|
const s = t && t.__jsx;
|
|
686
|
-
return !s || !(this.map[s] && this.map[s].length) ?
|
|
724
|
+
return !s || !(this.map[s] && this.map[s].length) ? _ : this.map[s].shift();
|
|
687
725
|
}
|
|
688
726
|
clear(t) {
|
|
689
727
|
const s = t && t.__jsx;
|
|
@@ -699,10 +737,10 @@ class Ht {
|
|
|
699
737
|
return Object.values(this.map).flat();
|
|
700
738
|
}
|
|
701
739
|
}
|
|
702
|
-
const
|
|
703
|
-
const t = new
|
|
740
|
+
const S = (e) => {
|
|
741
|
+
const t = new Wt();
|
|
704
742
|
return t.populate(e), t;
|
|
705
|
-
},
|
|
743
|
+
}, Q = (e, t, s = !1) => {
|
|
706
744
|
const r = [], n = e.attributes, o = n.length, a = t.attributes, l = a.length;
|
|
707
745
|
let u, d, c;
|
|
708
746
|
for (u = 0; u < o; u++) {
|
|
@@ -717,13 +755,13 @@ const N = (e) => {
|
|
|
717
755
|
}
|
|
718
756
|
}
|
|
719
757
|
c ? h.value !== c.value && r.push(
|
|
720
|
-
|
|
758
|
+
It(e, t, {
|
|
721
759
|
name: h.name,
|
|
722
760
|
value: c.value,
|
|
723
761
|
isSvg: s
|
|
724
762
|
})
|
|
725
763
|
) : r.push(
|
|
726
|
-
|
|
764
|
+
Ut(e, t, { name: h.name, isSvg: s })
|
|
727
765
|
);
|
|
728
766
|
}
|
|
729
767
|
}
|
|
@@ -739,7 +777,7 @@ const N = (e) => {
|
|
|
739
777
|
}
|
|
740
778
|
}
|
|
741
779
|
c || r.push(
|
|
742
|
-
|
|
780
|
+
Ct(e, t, {
|
|
743
781
|
name: h.name,
|
|
744
782
|
value: h.value,
|
|
745
783
|
isSvg: s
|
|
@@ -748,18 +786,18 @@ const N = (e) => {
|
|
|
748
786
|
}
|
|
749
787
|
}
|
|
750
788
|
return r;
|
|
751
|
-
},
|
|
789
|
+
}, Xt = (e, t) => {
|
|
752
790
|
const s = [], r = e.eventMaps, n = t.eventMaps, o = Object.keys(r), a = Object.keys(n);
|
|
753
791
|
return o.forEach((l) => {
|
|
754
792
|
const u = r[l], d = n[l];
|
|
755
793
|
d ? d.busEvent !== u.busEvent && s.push(
|
|
756
|
-
|
|
794
|
+
Gt(e, t, {
|
|
757
795
|
name: l,
|
|
758
796
|
targetValue: d.listener,
|
|
759
797
|
sourceValue: u.listener
|
|
760
798
|
})
|
|
761
799
|
) : s.push(
|
|
762
|
-
|
|
800
|
+
qt(e, t, {
|
|
763
801
|
name: u.domEvent,
|
|
764
802
|
value: u.listener
|
|
765
803
|
})
|
|
@@ -767,40 +805,40 @@ const N = (e) => {
|
|
|
767
805
|
}), a.forEach((l) => {
|
|
768
806
|
const u = r[l], d = n[l];
|
|
769
807
|
u || s.push(
|
|
770
|
-
|
|
808
|
+
Jt(e, t, {
|
|
771
809
|
name: d.domEvent,
|
|
772
810
|
value: d.listener
|
|
773
811
|
})
|
|
774
812
|
);
|
|
775
813
|
}), s;
|
|
776
|
-
},
|
|
777
|
-
if (
|
|
814
|
+
}, Yt = (e) => e.tagName !== "INPUT", Zt = (e, t) => e.value === t.value, te = (e, t) => {
|
|
815
|
+
if (Yt(e) || Zt(e, t))
|
|
778
816
|
return [];
|
|
779
817
|
const s = e, r = t;
|
|
780
|
-
return [
|
|
781
|
-
},
|
|
782
|
-
const s =
|
|
818
|
+
return [Ht(s, r, { name: "value", value: r.value })];
|
|
819
|
+
}, ee = (e, t) => {
|
|
820
|
+
const s = Q(e, t), r = Xt(e, t), n = te(e, t);
|
|
783
821
|
return s.concat(r).concat(n);
|
|
784
|
-
},
|
|
822
|
+
}, se = (e, t) => Q(e, t, !0), re = (e, t) => e.textContent !== t.textContent ? [Kt(e, t)] : [], ne = (e, t, s) => {
|
|
785
823
|
let r = [];
|
|
786
|
-
if (e.nodeType === 1 &&
|
|
787
|
-
const n = e, o = t, a =
|
|
824
|
+
if (e.nodeType === 1 && it(e)) {
|
|
825
|
+
const n = e, o = t, a = se(n, o), l = s(
|
|
788
826
|
n.childNodes,
|
|
789
827
|
o.childNodes,
|
|
790
828
|
n
|
|
791
829
|
);
|
|
792
830
|
r = a.concat(l);
|
|
793
831
|
} else if (e.nodeType === 1) {
|
|
794
|
-
const n = e, o = t, a =
|
|
832
|
+
const n = e, o = t, a = ee(n, o), l = s(
|
|
795
833
|
n.childNodes,
|
|
796
834
|
o.childNodes,
|
|
797
835
|
n
|
|
798
836
|
);
|
|
799
837
|
r = a.concat(l);
|
|
800
|
-
} else e.nodeType === 3 && (r =
|
|
838
|
+
} else e.nodeType === 3 && (r = re(e, t));
|
|
801
839
|
return r;
|
|
802
|
-
},
|
|
803
|
-
const r = [], n =
|
|
840
|
+
}, W = (e, t, s) => {
|
|
841
|
+
const r = [], n = oe(e, t), o = S(e), a = S(t), l = [];
|
|
804
842
|
let u = 0;
|
|
805
843
|
for (; u < n; u++) {
|
|
806
844
|
const c = e[u], h = t[u];
|
|
@@ -817,100 +855,100 @@ const N = (e) => {
|
|
|
817
855
|
})) : c ? a.check(c) ? r.push(
|
|
818
856
|
b(h, { parent: s, index: u })
|
|
819
857
|
) : (o.clear(c), r.push(
|
|
820
|
-
|
|
858
|
+
Rt(c, h)
|
|
821
859
|
)) : r.push(
|
|
822
860
|
b(h, { parent: s, index: u })
|
|
823
861
|
);
|
|
824
|
-
} else c && o.pullMatch(c).element && r.push(
|
|
862
|
+
} else c && o.pullMatch(c).element && r.push(N(c));
|
|
825
863
|
}
|
|
826
864
|
o.remaining().forEach(({ element: c }) => {
|
|
827
|
-
r.push(
|
|
865
|
+
r.push(N(c));
|
|
828
866
|
});
|
|
829
867
|
const d = l.reduce(
|
|
830
868
|
(c, { source: h, target: p }) => c.concat(
|
|
831
|
-
|
|
869
|
+
ne(h, p, W)
|
|
832
870
|
),
|
|
833
871
|
[]
|
|
834
872
|
);
|
|
835
|
-
return r.concat(d).sort(
|
|
836
|
-
},
|
|
873
|
+
return r.concat(d).sort(Qt);
|
|
874
|
+
}, oe = (e, t) => {
|
|
837
875
|
const s = e.length, r = t.length;
|
|
838
876
|
return s > r ? s : r;
|
|
839
|
-
},
|
|
840
|
-
const r =
|
|
877
|
+
}, ie = (e, t, s) => {
|
|
878
|
+
const r = W(e, t, s);
|
|
841
879
|
return r.forEach((n) => {
|
|
842
|
-
|
|
880
|
+
ue(n);
|
|
843
881
|
}), r;
|
|
844
|
-
},
|
|
845
|
-
(
|
|
846
|
-
},
|
|
847
|
-
},
|
|
882
|
+
}, ue = (e) => {
|
|
883
|
+
(ye[e.type] || ae)(e);
|
|
884
|
+
}, ae = (e) => {
|
|
885
|
+
}, ce = (e) => {
|
|
848
886
|
const { source: t, target: s } = e;
|
|
849
887
|
t.nodeValue = s.textContent;
|
|
850
|
-
},
|
|
888
|
+
}, le = (e) => {
|
|
851
889
|
const { source: t } = e;
|
|
852
890
|
t.remove();
|
|
853
|
-
},
|
|
891
|
+
}, he = (e) => {
|
|
854
892
|
const { target: t, data: s } = e, { parent: r, index: n } = s, o = r.childNodes[n];
|
|
855
893
|
o ? o && o !== t && r.insertBefore(t, o) : r.appendChild(t);
|
|
856
|
-
},
|
|
894
|
+
}, de = (e) => {
|
|
857
895
|
const { source: t, target: s } = e;
|
|
858
896
|
t.replaceWith(s);
|
|
859
|
-
},
|
|
897
|
+
}, pe = (e) => {
|
|
860
898
|
const { source: t, data: s } = e, { name: r, isSvg: n } = s;
|
|
861
899
|
n ? t.removeAttributeNS(null, r) : t.removeAttribute(r);
|
|
862
|
-
},
|
|
900
|
+
}, X = (e) => {
|
|
863
901
|
const { source: t, data: s } = e, { name: r, value: n, isSvg: o } = s;
|
|
864
902
|
o ? t.setAttributeNS(null, r, n) : t.setAttribute(r, n);
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
},
|
|
903
|
+
}, me = (e) => {
|
|
904
|
+
X(e);
|
|
905
|
+
}, fe = (e) => {
|
|
868
906
|
const t = e.data, s = e.source, { name: r, value: n } = t;
|
|
869
907
|
s.removeEventListener(r, n);
|
|
870
|
-
},
|
|
908
|
+
}, be = (e) => {
|
|
871
909
|
const t = e.data, s = e.source, { name: r, value: n } = t;
|
|
872
910
|
s.addEventListener(r, n);
|
|
873
|
-
},
|
|
911
|
+
}, ve = (e) => {
|
|
874
912
|
const t = e.data, s = e.source, { name: r, sourceValue: n, targetValue: o } = t;
|
|
875
913
|
s.removeEventListener(r, n), s.addEventListener(r, o);
|
|
876
|
-
},
|
|
914
|
+
}, ge = (e) => {
|
|
877
915
|
const t = e.data, s = e.source, { value: r } = t;
|
|
878
916
|
s.value = r;
|
|
879
|
-
},
|
|
880
|
-
[i.changeText]:
|
|
881
|
-
[i.removeNode]:
|
|
882
|
-
[i.insertNode]:
|
|
883
|
-
[i.replaceNode]:
|
|
884
|
-
[i.removeAttribute]:
|
|
885
|
-
[i.addAttribute]:
|
|
886
|
-
[i.updateAttribute]:
|
|
887
|
-
[i.removeEvent]:
|
|
888
|
-
[i.addEvent]:
|
|
889
|
-
[i.updateEvent]:
|
|
890
|
-
[i.changeValue]:
|
|
891
|
-
},
|
|
917
|
+
}, ye = {
|
|
918
|
+
[i.changeText]: ce,
|
|
919
|
+
[i.removeNode]: le,
|
|
920
|
+
[i.insertNode]: he,
|
|
921
|
+
[i.replaceNode]: de,
|
|
922
|
+
[i.removeAttribute]: pe,
|
|
923
|
+
[i.addAttribute]: X,
|
|
924
|
+
[i.updateAttribute]: me,
|
|
925
|
+
[i.removeEvent]: fe,
|
|
926
|
+
[i.addEvent]: be,
|
|
927
|
+
[i.updateEvent]: ve,
|
|
928
|
+
[i.changeValue]: ge
|
|
929
|
+
}, Ee = (e, t, s) => {
|
|
892
930
|
const r = [...t];
|
|
893
931
|
return e.forEach((n) => {
|
|
894
|
-
|
|
932
|
+
xe(n, r, s);
|
|
895
933
|
}), r;
|
|
896
|
-
},
|
|
897
|
-
const r =
|
|
934
|
+
}, xe = (e, t, s) => {
|
|
935
|
+
const r = _e[e.type];
|
|
898
936
|
r && r(e, t, s);
|
|
899
|
-
},
|
|
937
|
+
}, Ae = (e, t) => {
|
|
900
938
|
const { source: s } = e, r = t.indexOf(s);
|
|
901
939
|
r >= 0 && t.splice(r, 1);
|
|
902
|
-
},
|
|
940
|
+
}, we = (e, t, s) => {
|
|
903
941
|
const { target: r } = e, n = e.data, { index: o, parent: a } = n;
|
|
904
942
|
s === a && t.splice(o, 0, r);
|
|
905
|
-
},
|
|
943
|
+
}, Ne = (e, t) => {
|
|
906
944
|
const { target: s, source: r } = e, n = t.indexOf(r);
|
|
907
945
|
n >= 0 && (t[n] = s);
|
|
908
|
-
},
|
|
909
|
-
[i.removeNode]:
|
|
910
|
-
[i.insertNode]:
|
|
911
|
-
[i.replaceNode]:
|
|
946
|
+
}, _e = {
|
|
947
|
+
[i.removeNode]: Ae,
|
|
948
|
+
[i.insertNode]: we,
|
|
949
|
+
[i.replaceNode]: Ne
|
|
912
950
|
};
|
|
913
|
-
class
|
|
951
|
+
class Se {
|
|
914
952
|
constructor({ Template: t, subscriptions: s, attributes: r, viewModel: n }) {
|
|
915
953
|
this.Template = t, this.viewModel = n, this.attributes = r, this.subscriptions = s, this.dom = [], this.parentElement = null;
|
|
916
954
|
}
|
|
@@ -931,12 +969,12 @@ class Ae {
|
|
|
931
969
|
const r = this.dom[0].parentElement;
|
|
932
970
|
this.parentElement = r;
|
|
933
971
|
}
|
|
934
|
-
const t = this.generateDom(this.renderKit), s =
|
|
972
|
+
const t = this.generateDom(this.renderKit), s = ie(
|
|
935
973
|
this.dom,
|
|
936
974
|
t,
|
|
937
975
|
this.parentElement
|
|
938
976
|
);
|
|
939
|
-
this.dom =
|
|
977
|
+
this.dom = Ee(
|
|
940
978
|
s,
|
|
941
979
|
this.dom,
|
|
942
980
|
this.parentElement
|
|
@@ -949,46 +987,46 @@ class Ae {
|
|
|
949
987
|
});
|
|
950
988
|
}
|
|
951
989
|
eventName(t) {
|
|
952
|
-
return `${
|
|
990
|
+
return `${w}:${t}`;
|
|
953
991
|
}
|
|
954
992
|
}
|
|
955
|
-
const
|
|
993
|
+
const Te = (e) => e, je = ({
|
|
956
994
|
Template: e,
|
|
957
995
|
viewModel: t,
|
|
958
996
|
subscriptions: s
|
|
959
|
-
}) => (s = s || [], t = t ||
|
|
997
|
+
}) => (s = s || [], t = t || Te, (r) => new Se({ Template: e, viewModel: t, subscriptions: s, attributes: r })), ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
960
998
|
__proto__: null,
|
|
961
|
-
createRouteState:
|
|
962
|
-
events:
|
|
999
|
+
createRouteState: D,
|
|
1000
|
+
events: wt,
|
|
963
1001
|
extractQueryParams: L,
|
|
964
|
-
findHref:
|
|
965
|
-
navigate:
|
|
966
|
-
onLinkClick:
|
|
967
|
-
onLocationChange:
|
|
968
|
-
start:
|
|
969
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1002
|
+
findHref: P,
|
|
1003
|
+
navigate: E,
|
|
1004
|
+
onLinkClick: F,
|
|
1005
|
+
onLocationChange: z,
|
|
1006
|
+
start: Nt
|
|
1007
|
+
}, Symbol.toStringTag, { value: "Module" })), Oe = (e) => ({ path: t }) => t === e, Me = () => !0, Y = (e) => ({ route: t }) => {
|
|
970
1008
|
const s = e.find((r) => r.match(t));
|
|
971
1009
|
return s && s.Partial;
|
|
972
|
-
},
|
|
1010
|
+
}, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
973
1011
|
__proto__: null,
|
|
974
|
-
buildRouter:
|
|
975
|
-
catchAll:
|
|
976
|
-
exactPathMatch:
|
|
977
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1012
|
+
buildRouter: Y,
|
|
1013
|
+
catchAll: Me,
|
|
1014
|
+
exactPathMatch: Oe
|
|
1015
|
+
}, Symbol.toStringTag, { value: "Module" })), ke = () => ({
|
|
978
1016
|
render: (e, t) => []
|
|
979
|
-
}),
|
|
980
|
-
const t =
|
|
981
|
-
return
|
|
1017
|
+
}), Ve = (e) => {
|
|
1018
|
+
const t = Y(e);
|
|
1019
|
+
return je({ Template: ({ route: r }) => (t({ route: r }) || ke)(), subscriptions: ["route"] });
|
|
982
1020
|
};
|
|
983
1021
|
export {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1022
|
+
Le as JaxsTypes,
|
|
1023
|
+
$e as appBuilding,
|
|
1024
|
+
je as bind,
|
|
1025
|
+
Fe as createApp,
|
|
1026
|
+
Et as jsx,
|
|
1027
|
+
De as messageBus,
|
|
1028
|
+
ze as navigation,
|
|
1029
|
+
Ve as routedView,
|
|
1030
|
+
Be as routing,
|
|
1031
|
+
Pe as state
|
|
994
1032
|
};
|
package/dist/jaxs.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),ot=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},it=(e,t,s)=>{const n={};for(const r in t){const o=t[r],a=l=>s(o,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:o,listener:a}}e.eventMaps=n},ut=(e,t,s,n)=>{const r=f(e,n.document);return ot(r,t),it(r,s,n.publish),r},g="http://www.w3.org/2000/svg",at={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ct=(e,t)=>!!(at[e]||e==="a"&&t===g),lt=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ht=e=>e.namespaceURI===g,dt=(e,t)=>t.createTextNode(e);class pt{constructor(t){this.value=t.toString()}render(t){const s=dt(this.value,t.document);return s.__jsx="TextNode",[s]}}const mt=e=>typeof e=="string"||typeof e=="number",ft=e=>new pt(e),bt=e=>mt(e)?ft(e):e,vt=e=>gt(e).map(bt).flat(),gt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],yt=(e,t="")=>{const s={},n={};for(const r in e){const o=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=o?o.toString():""}else{if(o===!1)continue;r==="__source"?s.__source=e.__source:s[r]=Et(r,o,t)}}return{attributes:s,events:n}},Et=(e,t,s="")=>t==null?s:t.toString(),xt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},N=(e,t,s,n=[])=>e.reduce(At(t,s),n).flat(),At=(e,t)=>(s,n)=>n?Array.isArray(n)?N(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=vt(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return N(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class _t{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class wt{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:o}=yt(s);this.events=r,this.attributes=o,this.isSvg=ct(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=ut(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=lt(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new _t(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new wt(e,t,s):e(xt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class St{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new St(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",b="navigation:location-change",T="navigation:route-change",jt=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,routeChangeEvent:T},Symbol.toStringTag,{value:"Module"})),k=e=>{e.createRecord("route",{host:"",path:"",query:{}})},$=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},P=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},D=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=$(e.target);P(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),F=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:o,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:o,path:u,query:d};s.store("route").update(c),n(T,c)},B=e=>{const{subscribe:t}=e;t(M,D)},z=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;k(n),r.addEventListener("popstate",()=>t(b,null)),s(b,F)},V=e=>{setTimeout(()=>e.publish(b,null),0)},K=e=>{z(e),B(e),V(e)},Ot=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:V,startNavigation:K,subscribeToHistoryChange:z,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class R{constructor({window:t,document:s,publish:n,subscribe:r,bus:o,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=o,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){K(this)}}const Mt=Object.freeze(Object.defineProperty({__proto__:null,App:R},Symbol.toStringTag,{value:"Module"}));class U{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class q{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class I{constructor(){this.exactSubscriptions=new U,this.fuzzySubscriptions=new q,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,o)=>r.index-o.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new I;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},Tt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:U,FuzzySubscriptions:q,JaxsBus:I,createBus:J},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),y=e=>e!==null&&!v(e)&&typeof e=="object",kt=(e,t)=>e===t,$t=(e,t)=>Object.keys(e).length===Object.keys(t).length,Pt=(e,t)=>!(y(e)&&y(t))||!$t(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return E(n,r)}),Dt=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return E(s,r)}),E=(e,t)=>y(e)?Pt(e,t):v(e)?Dt(e,t):kt(e,t);class x{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){E(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class A{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class H extends A{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Lt=e=>new H(e);class G extends A{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Ft=e=>new G(e);class C extends A{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const Bt={object:e=>new C(e),list:Ft,boolean:Lt},_="state";class Q{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=_,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new x({name:t,parent:this,value:s});return this.stores[t]=n,n}createBoolean(t,s){const n=this.create(t,s);return n.updater=new H(n),n}createRecord(t,s){const n=this.create(t,s);return n.updater=new C(n),n}createList(t,s){const n=this.create(t,s);return n.updater=new G(n),n}store(t){return this.stores[t]||new x({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const W=e=>new Q(e),zt=Object.freeze(Object.defineProperty({__proto__:null,State:Q,Store:x,createState:W,eventName:_,updaters:Bt},Symbol.toStringTag,{value:"Module"}));class Vt{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new R({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=W(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const Kt=(e={})=>{const s=new Vt(e).setup();return s.startNavigation(),s};var i=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(i||{});const Rt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:i},Symbol.toStringTag,{value:"Module"})),Ut=(e,t)=>({source:e,target:t,type:i.changeText,data:{}}),qt=(e,t)=>({source:e,target:t,type:i.replaceNode,data:{}}),It=(e,t,s)=>({source:e,target:t,data:s,type:i.removeAttribute}),Jt=(e,t,s)=>({source:e,target:t,data:s,type:i.addAttribute}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:i.updateAttribute}),Gt=(e,t,s)=>({source:e,target:t,data:s,type:i.removeEvent}),Ct=(e,t,s)=>({source:e,target:t,data:s,type:i.addEvent}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:i.updateEvent}),X=e=>({source:e,target:e,type:i.removeNode,data:{}}),w=(e,t)=>({target:e,source:e,type:i.insertNode,data:t}),Wt=(e,t,s)=>({source:e,target:t,type:i.changeValue,data:s}),Xt=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,Y={index:-1};class Yt{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?Y:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,o)=>(o.element!==t&&r.push(o),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const Z=e=>{const t=new Yt;return t.populate(e),t},tt=(e,t,s=!1)=>{const n=[],r=e.attributes,o=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<o;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Ht(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(It(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<o;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Jt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},Zt=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,o=Object.keys(n),a=Object.keys(r);return o.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Qt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Gt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Ct(e,t,{name:d.domEvent,value:d.listener}))}),s},te=e=>e.tagName!=="INPUT",ee=(e,t)=>e.value===t.value,se=(e,t)=>{if(te(e)||ee(e,t))return[];const s=e,n=t;return[Wt(s,n,{name:"value",value:n.value})]},ne=(e,t)=>{const s=tt(e,t),n=Zt(e,t),r=se(e,t);return s.concat(n).concat(r)},re=(e,t)=>tt(e,t,!0),oe=(e,t)=>e.textContent!==t.textContent?[Ut(e,t)]:[],ie=(e,t,s)=>{let n=[];if(e.nodeType===1&&ht(e)){const r=e,o=t,a=re(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,o=t,a=ne(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=oe(e,t));return n},et=(e,t,s)=>{const n=[],r=ue(e,t),o=Z(e),a=Z(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=o.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(w(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(w(h,{parent:s,index:u})):(o.clear(c),n.push(qt(c,h))):n.push(w(h,{parent:s,index:u}))}else c&&o.pullMatch(c).element&&n.push(X(c))}o.remaining().forEach(({element:c})=>{n.push(X(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(ie(h,m,et)),[]);return n.concat(d).sort(Xt)},ue=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},ae=(e,t,s)=>{const n=et(e,t,s);return n.forEach(r=>{ce(r)}),n},ce=e=>{(xe[e.type]||le)(e)},le=e=>{},he=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},de=e=>{const{source:t}=e;t.remove()},pe=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,o=n.childNodes[r];o?o&&o!==t&&n.insertBefore(t,o):n.appendChild(t)},me=e=>{const{source:t,target:s}=e;t.replaceWith(s)},fe=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},st=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:o}=s;o?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},be=e=>{st(e)},ve=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},ge=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},ye=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:o}=t;s.removeEventListener(n,r),s.addEventListener(n,o)},Ee=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},xe={[i.changeText]:he,[i.removeNode]:de,[i.insertNode]:pe,[i.replaceNode]:me,[i.removeAttribute]:fe,[i.addAttribute]:st,[i.updateAttribute]:be,[i.removeEvent]:ve,[i.addEvent]:ge,[i.updateEvent]:ye,[i.changeValue]:Ee},Ae=(e,t,s)=>{const n=[...t];return e.forEach(r=>{_e(r,n,s)}),n},_e=(e,t,s)=>{const n=je[e.type];n&&n(e,t,s)},we=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Se=(e,t,s)=>{const{target:n}=e,r=e.data,{index:o,parent:a}=r;s===a&&t.splice(o,0,n)},Ne=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},je={[i.removeNode]:we,[i.insertNode]:Se,[i.replaceNode]:Ne};class Oe{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=ae(this.dom,t,this.parentElement);this.dom=Ae(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${_}:${t}`}}const Me=e=>e,nt=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Me,n=>new Oe({Template:e,viewModel:t,subscriptions:s,attributes:n})),Te=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:k,events:jt,extractQueryParams:L,findHref:$,navigate:P,onLinkClick:D,onLocationChange:F,start:Ot},Symbol.toStringTag,{value:"Module"})),ke=e=>({path:t})=>t===e,$e=()=>!0,rt=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},Pe=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:rt,catchAll:$e,exactPathMatch:ke},Symbol.toStringTag,{value:"Module"})),De=()=>({render:(e,t)=>[]}),Le=e=>{const t=rt(e);return nt({Template:({route:n})=>(t({route:n})||De)(),subscriptions:["route"]})};p.JaxsTypes=Rt,p.appBuilding=Mt,p.bind=nt,p.createApp=Kt,p.jsx=O,p.messageBus=Tt,p.navigation=Te,p.routedView=Le,p.routing=Pe,p.state=zt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),nt=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},rt=(e,t,s)=>{const n={};for(const r in t){const i=t[r],a=l=>s(i,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:i,listener:a}}e.eventMaps=n},it=(e,t,s,n)=>{const r=f(e,n.document);return nt(r,t),rt(r,s,n.publish),r},g="http://www.w3.org/2000/svg",ot={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ut=(e,t)=>!!(ot[e]||e==="a"&&t===g),at=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ct=e=>e.namespaceURI===g,lt=(e,t)=>t.createTextNode(e);class ht{constructor(t){this.value=t.toString()}render(t){const s=lt(this.value,t.document);return s.__jsx="TextNode",[s]}}const dt=e=>typeof e=="string"||typeof e=="number",pt=e=>new ht(e),mt=e=>dt(e)?pt(e):e,ft=e=>bt(e).map(mt).flat(),bt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],vt=(e,t="")=>{const s={},n={};for(const r in e){const i=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=i?i.toString():""}else{if(i===!1)continue;r==="__source"?s.__source=e.__source:s[r]=gt(r,i,t)}}return{attributes:s,events:n}},gt=(e,t,s="")=>t==null?s:t.toString(),yt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},T=(e,t,s,n=[])=>e.reduce(Et(t,s),n).flat(),Et=(e,t)=>(s,n)=>n?Array.isArray(n)?T(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=ft(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return T(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class xt{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class At{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:i}=vt(s);this.events=r,this.attributes=i,this.isSvg=ut(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=it(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=at(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new xt(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new At(e,t,s):e(yt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class wt{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new wt(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",k="go-to",b="navigation:location-change",$="navigation:route-change",_t=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,navigationEvent:k,routeChangeEvent:$},Symbol.toStringTag,{value:"Module"})),P=e=>{e.create("route",{host:"",path:"",query:{}})},D=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},y=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},F=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=D(e.target);y(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),z=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:i,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:i,path:u,query:d};s.store("route").update(c),n($,c)},B=e=>{const{subscribe:t}=e;t(M,F),t(k,(s,n)=>{y(s,n)})},V=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;P(n),r.addEventListener("popstate",()=>t(b,null)),s(b,z)},K=e=>{setTimeout(()=>e.publish(b,null),0)},R=e=>{V(e),B(e),K(e)},St=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:K,startNavigation:R,subscribeToHistoryChange:V,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class U{constructor({window:t,document:s,publish:n,subscribe:r,bus:i,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=i,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){R(this)}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,App:U},Symbol.toStringTag,{value:"Module"}));class C{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class I{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class jt{constructor({publish:t,event:s,payload:n,timer:r}){this.setNewTimeout=()=>{this.stopped||setTimeout(()=>{this.publishEvent(),this.setNewTimeout()},this.calculateNextTime())},this.calculateNextTime=()=>this.timer({timeDiff:this.diff(),callCount:this.callCount,stop:this.stop}),this.publish=t,this.event=s,this.payload=n||null,this.stop=this.stopTimeout.bind(this),this.stopped=!1,this.timer=r,this.startedAt=new Date().getTime(),this.callCount=0}start(){this.setNewTimeout()}diff(){return new Date().getTime()-this.startedAt}stopTimeout(){this.stopped=!0,this.timeoutId&&clearTimeout(this.timeoutId)}publishEvent(){this.stopped||(this.callCount+=1,this.publish(this.event,this.payload))}}const Ot=e=>{const{offset:t,period:s}=e,n=({callCount:r})=>t&&r==0?t:s;return{event:e.event,publish:e.publish,payload:e.payload,timer:n}},Mt=e=>{let t;"timer"in e?t=e:t=Ot(e);const s=new jt(t);return s.start(),s.stop};class q{constructor(){this.exactSubscriptions=new C,this.fuzzySubscriptions=new I,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,i)=>r.index-i.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new q;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},kt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:C,FuzzySubscriptions:I,JaxsBus:q,createBus:J,publishPeriodically:Mt},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),E=e=>e!==null&&!v(e)&&typeof e=="object",$t=(e,t)=>e===t,Pt=(e,t)=>Object.keys(e).length===Object.keys(t).length,Dt=(e,t)=>!(E(e)&&E(t))||!Pt(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return x(n,r)}),Ft=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return x(s,r)}),x=(e,t)=>E(e)?Dt(e,t):v(e)?Ft(e,t):$t(e,t);class A{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){x(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class w{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class Lt extends w{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const zt=e=>new Lt(e);class Bt extends w{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Vt=e=>new Bt(e);class Kt extends w{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Rt={object:zt,list:Vt,boolean:e=>new Kt(e)},N="state";class G{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=N,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new A({name:t,parent:this,value:s});return this.stores[t]=n,n}store(t){return this.stores[t]||new A({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const H=e=>new G(e),Ut=Object.freeze(Object.defineProperty({__proto__:null,State:G,Store:A,createState:H,eventName:N,updaters:Rt},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new U({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=H(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const It=(e={})=>{const s=new Ct(e).setup();return s.startNavigation(),s};var o=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(o||{});const qt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:o},Symbol.toStringTag,{value:"Module"})),Jt=(e,t)=>({source:e,target:t,type:o.changeText,data:{}}),Gt=(e,t)=>({source:e,target:t,type:o.replaceNode,data:{}}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:o.removeAttribute}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:o.addAttribute}),Wt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateAttribute}),Xt=(e,t,s)=>({source:e,target:t,data:s,type:o.removeEvent}),Yt=(e,t,s)=>({source:e,target:t,data:s,type:o.addEvent}),Zt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateEvent}),Q=e=>({source:e,target:e,type:o.removeNode,data:{}}),_=(e,t)=>({target:e,source:e,type:o.insertNode,data:t}),te=(e,t,s)=>({source:e,target:t,type:o.changeValue,data:s}),ee=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,W={index:-1};class se{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?W:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,i)=>(i.element!==t&&r.push(i),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const X=e=>{const t=new se;return t.populate(e),t},Y=(e,t,s=!1)=>{const n=[],r=e.attributes,i=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<i;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Wt(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(Ht(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<i;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Qt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},ne=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,i=Object.keys(n),a=Object.keys(r);return i.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Zt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Xt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Yt(e,t,{name:d.domEvent,value:d.listener}))}),s},re=e=>e.tagName!=="INPUT",ie=(e,t)=>e.value===t.value,oe=(e,t)=>{if(re(e)||ie(e,t))return[];const s=e,n=t;return[te(s,n,{name:"value",value:n.value})]},ue=(e,t)=>{const s=Y(e,t),n=ne(e,t),r=oe(e,t);return s.concat(n).concat(r)},ae=(e,t)=>Y(e,t,!0),ce=(e,t)=>e.textContent!==t.textContent?[Jt(e,t)]:[],le=(e,t,s)=>{let n=[];if(e.nodeType===1&&ct(e)){const r=e,i=t,a=ae(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,i=t,a=ue(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=ce(e,t));return n},Z=(e,t,s)=>{const n=[],r=he(e,t),i=X(e),a=X(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=i.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(_(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(_(h,{parent:s,index:u})):(i.clear(c),n.push(Gt(c,h))):n.push(_(h,{parent:s,index:u}))}else c&&i.pullMatch(c).element&&n.push(Q(c))}i.remaining().forEach(({element:c})=>{n.push(Q(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(le(h,m,Z)),[]);return n.concat(d).sort(ee)},he=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},de=(e,t,s)=>{const n=Z(e,t,s);return n.forEach(r=>{pe(r)}),n},pe=e=>{(_e[e.type]||me)(e)},me=e=>{},fe=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},be=e=>{const{source:t}=e;t.remove()},ve=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,i=n.childNodes[r];i?i&&i!==t&&n.insertBefore(t,i):n.appendChild(t)},ge=e=>{const{source:t,target:s}=e;t.replaceWith(s)},ye=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},tt=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:i}=s;i?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},Ee=e=>{tt(e)},xe=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},Ae=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},we=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:i}=t;s.removeEventListener(n,r),s.addEventListener(n,i)},Ne=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},_e={[o.changeText]:fe,[o.removeNode]:be,[o.insertNode]:ve,[o.replaceNode]:ge,[o.removeAttribute]:ye,[o.addAttribute]:tt,[o.updateAttribute]:Ee,[o.removeEvent]:xe,[o.addEvent]:Ae,[o.updateEvent]:we,[o.changeValue]:Ne},Se=(e,t,s)=>{const n=[...t];return e.forEach(r=>{Te(r,n,s)}),n},Te=(e,t,s)=>{const n=ke[e.type];n&&n(e,t,s)},je=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Oe=(e,t,s)=>{const{target:n}=e,r=e.data,{index:i,parent:a}=r;s===a&&t.splice(i,0,n)},Me=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},ke={[o.removeNode]:je,[o.insertNode]:Oe,[o.replaceNode]:Me};class $e{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=de(this.dom,t,this.parentElement);this.dom=Se(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${N}:${t}`}}const Pe=e=>e,et=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Pe,n=>new $e({Template:e,viewModel:t,subscriptions:s,attributes:n})),De=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:P,events:_t,extractQueryParams:L,findHref:D,navigate:y,onLinkClick:F,onLocationChange:z,start:St},Symbol.toStringTag,{value:"Module"})),Fe=e=>({path:t})=>t===e,Le=()=>!0,st=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},ze=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:st,catchAll:Le,exactPathMatch:Fe},Symbol.toStringTag,{value:"Module"})),Be=()=>({render:(e,t)=>[]}),Ve=e=>{const t=st(e);return et({Template:({route:n})=>(t({route:n})||Be)(),subscriptions:["route"]})};p.JaxsTypes=qt,p.appBuilding=Tt,p.bind=et,p.createApp=It,p.jsx=O,p.messageBus=kt,p.navigation=De,p.routedView=Ve,p.routing=ze,p.state=Ut,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "jaxs",
|
|
3
3
|
"description": "Modular J/TSX application framework",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "vite build && npm run build:types",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"jsdom": "^24.1.1",
|
|
46
46
|
"prettier": "^3.3.3",
|
|
47
47
|
"typescript": "^5.5.4",
|
|
48
|
-
"vite": "^
|
|
49
|
-
"vitest": "^
|
|
48
|
+
"vite": "^6.3.5",
|
|
49
|
+
"vitest": "^3.1.4"
|
|
50
50
|
}
|
|
51
51
|
}
|