jaxs 0.3.2 → 0.4.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.
Files changed (69) hide show
  1. package/dist/jaxs.d.ts +634 -0
  2. package/dist/jaxs.js +793 -1071
  3. package/dist/jaxs.umd.cjs +1 -0
  4. package/package.json +41 -34
  5. package/.env +0 -1
  6. package/README.md +0 -15
  7. package/bun.lockb +0 -0
  8. package/bundle.ts +0 -5
  9. package/bunfig.toml +0 -0
  10. package/cypress/e2e/add-remove-nested-children.cy.js +0 -39
  11. package/cypress/e2e/add-remove-root-children.cy.js +0 -37
  12. package/cypress/e2e/svg-renders.cy.js +0 -10
  13. package/cypress/jaxs-apps/add-remove-nested-children.html +0 -12
  14. package/cypress/jaxs-apps/add-remove-nested-children.jsx +0 -85
  15. package/cypress/jaxs-apps/add-remove-root-children.html +0 -15
  16. package/cypress/jaxs-apps/add-remove-root-children.jsx +0 -54
  17. package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js +0 -1022
  18. package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js.map +0 -1
  19. package/cypress/jaxs-apps/dist/add-remove-nested-children.html +0 -12
  20. package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js +0 -1665
  21. package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js.map +0 -1
  22. package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js +0 -1011
  23. package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js.map +0 -1
  24. package/cypress/jaxs-apps/dist/add-remove-root-children.html +0 -15
  25. package/cypress/jaxs-apps/dist/svg.04290504.js +0 -644
  26. package/cypress/jaxs-apps/dist/svg.04290504.js.map +0 -1
  27. package/cypress/jaxs-apps/dist/svg.html +0 -11
  28. package/cypress/jaxs-apps/svg.html +0 -11
  29. package/cypress/jaxs-apps/svg.jsx +0 -15
  30. package/cypress/support/commands.js +0 -25
  31. package/cypress/support/e2e.js +0 -20
  32. package/cypress.config.js +0 -10
  33. package/src/app.ts +0 -84
  34. package/src/debugging.js +0 -5
  35. package/src/jaxs.ts +0 -7
  36. package/src/jsx.js +0 -27
  37. package/src/messageBus.ts +0 -70
  38. package/src/navigation/findHref.js +0 -10
  39. package/src/navigation/routeState.js +0 -15
  40. package/src/navigation/setupHistory.js +0 -38
  41. package/src/navigation/setupNavigation.js +0 -25
  42. package/src/navigation.ts +0 -2
  43. package/src/rendering/change/compile.ts +0 -1
  44. package/src/rendering/change/instructions/attributes.ts +0 -81
  45. package/src/rendering/change/instructions/children.ts +0 -127
  46. package/src/rendering/change/instructions/element.ts +0 -49
  47. package/src/rendering/change/instructions/events.ts +0 -51
  48. package/src/rendering/change/instructions/generate.ts +0 -122
  49. package/src/rendering/change/instructions/idMap.js +0 -55
  50. package/src/rendering/change/instructions/node.ts +0 -55
  51. package/src/rendering/change/instructions/text.ts +0 -10
  52. package/src/rendering/change.ts +0 -139
  53. package/src/rendering/dom/attributesAndEvents.ts +0 -33
  54. package/src/rendering/dom/create.ts +0 -66
  55. package/src/rendering/dom/svg.ts +0 -18
  56. package/src/rendering/templates/bound.js +0 -56
  57. package/src/rendering/templates/children.ts +0 -99
  58. package/src/rendering/templates/root.ts +0 -55
  59. package/src/rendering/templates/tag.ts +0 -92
  60. package/src/rendering/templates/text.ts +0 -17
  61. package/src/state/equality.js +0 -36
  62. package/src/state/stores.js +0 -63
  63. package/src/state/testingTypes.js +0 -6
  64. package/src/state.js +0 -89
  65. package/src/types.ts +0 -160
  66. package/src/views/conditionals.jsx +0 -18
  67. package/src/views/link.jsx +0 -5
  68. package/src/views.js +0 -7
  69. package/tsconfig.json +0 -26
package/dist/jaxs.js CHANGED
@@ -1,1156 +1,878 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
-
12
- // src/rendering/dom/create.ts
13
- var setAttributesOnElement = (element, attributes) => {
14
- for (const key in attributes) {
15
- if (key === "__self")
16
- continue;
17
- if (key === "value") {
18
- element.value = attributes[key];
19
- } else {
20
- element.setAttribute(key, attributes[key]);
21
- }
22
- }
23
- };
24
- var setEventsOnElement = (element, events, publish) => {
25
- const eventMaps = {};
26
- for (const domEvent in events) {
27
- const eventName = events[domEvent];
28
- const listener = (event) => publish(eventName, event);
29
- element.addEventListener(domEvent, listener);
30
- eventMaps[domEvent] = {
31
- domEvent,
32
- busEvent: eventName,
33
- listener
1
+ const tt = (e, t) => t.createElement(e), et = (e, t) => {
2
+ for (const s in t) {
3
+ if (s === "__self") continue;
4
+ const n = t[s].toString();
5
+ s === "value" ? e.value = n : e.setAttribute(s, n);
6
+ }
7
+ }, st = (e, t, s) => {
8
+ const n = {};
9
+ for (const r in t) {
10
+ const o = t[r], a = (h) => s(o, h);
11
+ e.addEventListener(r, a), n[r] = {
12
+ domEvent: r,
13
+ busEvent: o,
14
+ listener: a
34
15
  };
35
16
  }
36
- element.eventMaps = eventMaps;
37
- };
38
- var createNode = (type, document) => {
39
- return document.createElement(type);
40
- };
41
- var createTextNode = (value, document) => {
42
- return document.createTextNode(value);
43
- };
44
- var createDecoratedNode = (type, attributes, events, renderKit) => {
45
- const dom = createNode(type, renderKit.document);
46
- setAttributesOnElement(dom, attributes);
47
- setEventsOnElement(dom, events, renderKit.publish);
48
- return dom;
49
- };
50
-
51
- // src/rendering/dom/attributesAndEvents.ts
52
- var separateAttrsAndEvents = (combined, defaultValue = "") => {
53
- const attributes = {};
54
- const events = {};
55
- for (const key in combined) {
56
- const value = combined[key];
57
- if (key.match(/^on.+/i)) {
58
- const eventKey = key.slice(2).toLowerCase();
59
- events[eventKey] = value;
17
+ e.eventMaps = n;
18
+ }, nt = (e, t, s, n) => {
19
+ const r = tt(e, n.document);
20
+ return et(r, t), st(r, s, n.publish), r;
21
+ }, N = "http://www.w3.org/2000/svg", rt = (e) => e === "svg", ot = (e, t, s) => {
22
+ const n = s.createElementNS(N, e);
23
+ for (const r in t)
24
+ r === "__self" || r === "xmlns" || n.setAttributeNS(null, r, t[r].toString());
25
+ return n;
26
+ }, it = (e) => e.namespaceURI === N, at = (e, t) => t.createTextNode(e);
27
+ class ct {
28
+ constructor(t) {
29
+ this.value = t.toString(), this.isSvg = !1;
30
+ }
31
+ render(t) {
32
+ const s = at(this.value, t.document);
33
+ return s.__jsx = "TextNode", [s];
34
+ }
35
+ }
36
+ const ut = (e) => typeof e == "string" || typeof e == "number", ht = (e) => new ct(e), lt = (e) => ut(e) ? ht(e) : e, dt = (e) => (t) => (t && (t.isSvg = t.isSvg || e), t), pt = (e, t) => mt(e).map(lt).flat().map(dt(t)), mt = (e) => Array.isArray(e) ? e.flat() : e ? [e] : [], j = (e, t = {}) => e || t.children || [], bt = (e, t = "") => {
37
+ const s = {}, n = {};
38
+ for (const r in e) {
39
+ const o = e[r];
40
+ if (r.match(/^on.+/i)) {
41
+ const a = r.slice(2).toLowerCase();
42
+ n[a] = o ? o.toString() : "";
60
43
  } else {
61
- attributes[key] = normalizeValueForKey(combined, key, defaultValue);
44
+ if (o === !1) continue;
45
+ r === "__source" ? s.__source = e.__source : s[r] = ft(r, o, t);
62
46
  }
63
47
  }
64
48
  return {
65
- attributes,
66
- events
49
+ attributes: s,
50
+ events: n
67
51
  };
68
- };
69
- var normalizeValueForKey = (object, key, defaultValue = "") => {
70
- if (object[key] === undefined)
71
- return defaultValue;
72
- return object[key];
73
- };
74
-
75
- // src/rendering/dom/svg.ts
76
- var namespace = "http://www.w3.org/2000/svg";
77
- var isSvgTag = (tagType) => tagType === "svg";
78
- var isSvg = (element) => element.namespaceURI === namespace;
79
- var createSvgNode = (type, attributes, renderKit) => {
80
- const { document } = renderKit;
81
- const node = document.createElementNS(namespace, type);
82
- for (const key in attributes) {
83
- if (key === "__self" || key === "xmlns")
84
- continue;
85
- node.setAttributeNS(null, key, attributes[key]);
86
- }
87
- return node;
88
- };
89
-
90
- // src/rendering/templates/text.ts
91
- class TextTemplate {
92
- value;
93
- constructor(content) {
94
- this.value = content.toString();
95
- }
96
- render(renderKit) {
97
- const textNode = createTextNode(this.value, renderKit.document);
98
- if (!textNode)
99
- return [];
100
- textNode.__jsx = "TextNode";
101
- return [textNode];
52
+ }, ft = (e, t, s = "") => t == null ? s : t.toString(), vt = (e, t) => {
53
+ const s = e || {}, n = j(t, s);
54
+ return s.children = s.children || n, s;
55
+ }, k = (e, t, s = []) => e.reduce(gt(t), s).flat(), gt = (e) => (t, s) => s ? Array.isArray(s) ? k(s, e, t) : (s.render(e).forEach((n) => t.push(n)), t) : t;
56
+ class O {
57
+ constructor(t, s = !1) {
58
+ this.collection = pt(t, s), this.isSvg = s;
59
+ }
60
+ render(t, s) {
61
+ this.parentElement = s;
62
+ const n = this.generateDom(t);
63
+ return this.attachToParent(n), n;
64
+ }
65
+ generateDom(t) {
66
+ return k(this.collection, t);
67
+ }
68
+ attachToParent(t) {
69
+ if (this.parentElement === void 0) return;
70
+ const s = this.parentElement;
71
+ t.forEach((n) => s.appendChild(n));
102
72
  }
103
73
  }
104
-
105
- // src/rendering/templates/children.ts
106
- var ensureArray = (children) => {
107
- if (Array.isArray(children)) {
108
- return children.flat();
74
+ class yt {
75
+ constructor(t, s) {
76
+ this.type = t, this.attributes = s;
109
77
  }
110
- if (!children) {
111
- return [];
78
+ generate() {
79
+ return this.attributes.key || this.sourceKey() || this.createKeyFromAttributes();
112
80
  }
113
- return [children];
114
- };
115
- var recursiveRender = (children, renderKit, rendered = []) => children.reduce(renderReducer(renderKit), rendered).flat();
116
- var renderReducer = (renderKit) => (aggregate, view) => {
117
- if (!view)
118
- return aggregate;
119
- if (Array.isArray(view)) {
120
- const dom = recursiveRender(view, renderKit, aggregate);
121
- return dom;
122
- }
123
- view.render(renderKit).forEach((template) => aggregate.push(template));
124
- return aggregate;
125
- };
126
- var replaceTextNodes = (child) => {
127
- if (isTextNode(child)) {
128
- return textNode(child);
129
- }
130
- return child;
131
- };
132
- var isTextNode = (child) => {
133
- return typeof child === "string" || typeof child === "number";
134
- };
135
- var textNode = (content) => {
136
- return new TextTemplate(content);
137
- };
138
- var withSvgFlag = (isSvg2) => (template) => {
139
- template && (template.isSvg = template.isSvg || isSvg2);
140
- return template;
141
- };
142
-
143
- class Children {
144
- collection;
145
- parentElement;
146
- isSvg;
147
- constructor(jsxChildren, isSvg2 = false) {
148
- this.collection = ensureArray(jsxChildren);
149
- this.collection = this.collection.map(replaceTextNodes);
150
- this.collection = this.collection.flat();
151
- this.collection = this.collection.map(withSvgFlag(isSvg2));
152
- this.isSvg = isSvg2;
153
- }
154
- render(renderKit, parentElement) {
155
- this.parentElement = parentElement;
156
- const dom = this.generateDom(renderKit);
157
- this.attachToParent(dom);
158
- return dom;
159
- }
160
- generateDom(renderKit) {
161
- return recursiveRender(this.collection, renderKit);
162
- }
163
- attachToParent(dom) {
164
- if (this.parentElement === undefined)
165
- return;
166
- const parent = this.parentElement;
167
- dom.forEach((node) => parent.appendChild(node));
168
- }
169
- }
170
-
171
- // src/rendering/templates/tag.ts
172
- class Tag {
173
- type;
174
- events;
175
- attributes;
176
- children;
177
- isSvg;
178
- constructor(tagType, combinedAttributes, children2, isSvg2 = false) {
179
- this.type = tagType;
180
- const { events, attributes } = separateAttrsAndEvents(combinedAttributes);
181
- this.events = events;
182
- this.attributes = attributes;
183
- this.isSvg = isSvg2 || isSvgTag(this.type);
184
- this.children = new Children(children2, this.isSvg);
185
- }
186
- render(renderKit) {
187
- const dom = this.generateDom(renderKit);
188
- if (!dom)
189
- return [];
190
- this.children.render(renderKit, dom);
191
- return [dom];
192
- }
193
- generateDom(renderKit) {
194
- if (this.isSvg) {
195
- return this.generateSvnDom(renderKit);
196
- } else {
197
- return this.generateHtmlDom(renderKit);
198
- }
199
- }
200
- generateHtmlDom(renderKit) {
201
- const node = createDecoratedNode(this.type, this.attributes, this.events, renderKit);
202
- node.__jsx = this.key();
203
- return node;
204
- }
205
- generateSvnDom(renderKit) {
206
- const node = createSvgNode(this.type, this.attributes, renderKit);
207
- node.__jsx = this.key();
208
- return node;
209
- }
210
- key() {
211
- return this.attributes.key || this.source() || this.createKey();
212
- }
213
- source() {
81
+ sourceKey() {
214
82
  if (this.attributes.__source) {
215
- const { fileName, lineNumber, columnNumber } = this.attributes.__source;
216
- return `${fileName}:${lineNumber}:${columnNumber}`;
83
+ const { fileName: t, lineNumber: s, columnNumber: n } = this.attributes.__source;
84
+ return `${t}:${s}:${n}`;
217
85
  }
218
86
  }
219
- createKey() {
220
- const id = this.attributes.id ? `#${this.attributes.id}` : "";
221
- const type = this.attributes.type ? `[type=${this.attributes.type}]` : "";
222
- const name = this.attributes.name ? `[name=${this.attributes.name}]` : "";
223
- return `${this.type}${id}${type}${name}`;
87
+ createKeyFromAttributes() {
88
+ const t = this.attributes.id ? `#${this.attributes.id}` : "", s = this.attributes.type ? `[type=${this.attributes.type}]` : "", n = this.attributes.name ? `[name=${this.attributes.name}]` : "";
89
+ return `${this.type}${t}${s}${n}`;
224
90
  }
225
91
  }
226
-
227
- // src/jsx.js
228
- var ensureChildrenArray = (maybeChildren, attributes) => maybeChildren || attributes.children || [];
229
- var packageAttributes = (maybeAttributes, maybeChildren) => {
230
- const attributes = maybeAttributes || {};
231
- const children3 = ensureChildrenArray(maybeChildren, attributes);
232
- attributes.children = attributes.children || children3;
233
- return attributes;
234
- };
235
- var jsx = (type, attributes, ...children3) => {
236
- if (typeof type === "string") {
237
- return new Tag(type, attributes, children3);
92
+ class Et {
93
+ constructor(t, s, n = [], r = !1) {
94
+ this.type = t;
95
+ const { events: o, attributes: a } = bt(s);
96
+ this.events = o, this.attributes = a, this.isSvg = r || rt(this.type), this.children = new O(n, this.isSvg);
97
+ }
98
+ render(t) {
99
+ const s = this.generateDom(t);
100
+ return s ? (this.children.render(t, s), [s]) : [];
101
+ }
102
+ generateDom(t) {
103
+ return this.isSvg ? this.generateSvgDom(t) : this.generateHtmlDom(t);
104
+ }
105
+ generateHtmlDom(t) {
106
+ const s = nt(
107
+ this.type,
108
+ this.attributes,
109
+ this.events,
110
+ t
111
+ );
112
+ return s.__jsx = this.jsxKey(), s;
113
+ }
114
+ generateSvgDom(t) {
115
+ const s = ot(this.type, this.attributes, t.document);
116
+ return s.__jsx = this.jsxKey(), s;
117
+ }
118
+ jsxKey() {
119
+ return new yt(this.type, this.attributes).generate();
238
120
  }
239
- return type(packageAttributes(attributes, children3));
240
- };
241
- jsx.fragment = (attributes, maybeChildren) => {
242
- const children3 = ensureChildrenArray(maybeChildren, attributes);
243
- return new Children(children3);
121
+ }
122
+ const xt = (e, t, ...s) => typeof e == "string" ? new Et(e, t, s) : e(vt(t, s));
123
+ xt.fragment = (e, t) => {
124
+ const s = j(t, e);
125
+ return new O(s);
244
126
  };
245
- var jsx_default = jsx;
246
- // src/rendering/templates/root.ts
247
- class Root {
248
- template;
249
- selector;
250
- renderKit;
251
- dom;
252
- parentElement;
253
- constructor(template, selector, renderKit) {
254
- this.template = template;
255
- this.selector = selector;
256
- this.renderKit = renderKit;
257
- this.dom = [];
258
- this.parentElement = null;
259
- }
260
- renderAndAttach(renderKit) {
261
- this.parentElement = this.getParentElement();
262
- this.dom = this.render({ ...renderKit, parent: this.parentElement });
263
- if (this.parentElement) {
264
- this.attach();
265
- }
127
+ class At {
128
+ constructor(t, s, n) {
129
+ this.template = t, this.selector = s, this.renderKit = n, this.dom = [];
130
+ }
131
+ renderAndAttach(t) {
132
+ this.parentElement = this.getParentElement(), this.dom = this.render({ ...t, parent: this.parentElement }), this.parentElement && this.attach();
266
133
  }
267
- render(renderKit) {
268
- return this.template.render(renderKit);
134
+ render(t) {
135
+ return this.template.render(t);
269
136
  }
270
137
  attach() {
271
- this.parentElement && (this.parentElement.innerHTML = "");
272
- this.dom.forEach((element) => {
273
- this.parentElement && this.parentElement.appendChild(element);
138
+ this.parentElement && (this.parentElement.innerHTML = ""), this.dom.forEach((t) => {
139
+ this.parentElement && this.parentElement.appendChild(t);
274
140
  });
275
141
  }
276
142
  getParentElement() {
277
143
  return this.renderKit.document.querySelector(this.selector);
278
144
  }
279
145
  }
280
- var render = (template, selector, renderKit) => {
281
- const root = new Root(template, selector, renderKit);
282
- root.renderAndAttach(renderKit);
283
- return root;
284
- };
285
- // src/state/testingTypes.js
286
- var isBoolean = (value) => typeof value === "boolean";
287
- var isNumber = (value) => typeof value === "number";
288
- var isString = (value) => typeof value === "string";
289
- var isArray = (value) => Array.isArray(value);
290
- var isObject = (value) => value !== null && !isArray(value) && typeof value === "object";
291
-
292
- // src/state/equality.js
293
- var areElementEqual = (oldValue, newValue) => oldValue === newValue;
294
- var keyLengthSame = (oldValue, newValue) => Object.keys(oldValue).length === Object.keys(newValue).length;
295
- var areObjectsEqual = (oldValue, newValue) => {
296
- if (!(isObject(oldValue) && isObject(newValue)))
297
- return false;
298
- if (!keyLengthSame(oldValue, newValue))
299
- return false;
300
- Object.keys(oldValue).every((key) => {
301
- const oldInnerValue = oldValue[key];
302
- const newInnerValue = newValue[key];
303
- return areEqual(oldInnerValue, newInnerValue);
304
- });
305
- };
306
- var areArraysEqual = (oldValue, newValue) => {
307
- if (!(isArray(oldValue) && isArray(newValue)))
308
- return false;
309
- if (oldValue.length !== newValue.length)
310
- return false;
311
- oldValue.every((oldInnerValue, index) => {
312
- const newInnerValue = newValue[index];
313
- return areEqual(oldInnerValue, newInnerValue);
146
+ const St = (e, t, s) => {
147
+ const n = new At(e, t, s);
148
+ return n.renderAndAttach(s), n;
149
+ }, $ = "go-to-href", m = "navigation:location-change", M = "navigation:route-change", _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
150
+ __proto__: null,
151
+ linkNavigationEvent: $,
152
+ locationChangeEvent: m,
153
+ routeChangeEvent: M
154
+ }, Symbol.toStringTag, { value: "Module" })), F = (e) => {
155
+ e.createRecord("route", {
156
+ host: "",
157
+ path: "",
158
+ query: {}
314
159
  });
315
- };
316
- var areEqual = (oldValue, newValue) => {
317
- if (isObject(oldValue))
318
- return areObjectsEqual(oldValue, newValue);
319
- if (isArray(oldValue))
320
- return areArraysEqual(oldValue, newValue);
321
- return areElementEqual(oldValue, newValue);
322
- };
323
-
324
- // src/state/stores.js
325
- class GeneralStore {
326
- nullEvent = {};
327
- constructor({ name, value, parent }) {
328
- this.name = name;
329
- this.value = value;
330
- this.parent = parent;
331
- this.initialState = value;
332
- }
333
- update(newValue) {
334
- if (this.isEqual(newValue))
335
- return;
336
- this.value = newValue;
337
- return this.parent.publish(this.event());
160
+ }, T = (e) => {
161
+ const t = e.closest("[href]");
162
+ return t && t.getAttribute("href") || "";
163
+ }, D = (e, { publish: t, window: s }) => {
164
+ s.history.pushState(null, "", e), t(m, null);
165
+ }, z = (e, t) => {
166
+ if (!e || !e.target) return;
167
+ e.preventDefault();
168
+ const s = T(e.target);
169
+ D(s, t);
170
+ }, L = (e) => e.replace(/^\?/, "").split("&").reduce((t, s) => {
171
+ if (!s) return t;
172
+ const n = s.split("=");
173
+ return t[n[0]] = n[1], t;
174
+ }, {}), P = (e, t) => {
175
+ const { state: s, publish: n, window: r } = t, { host: o, pathname: a, search: h } = r.location, i = a, d = L(h), u = {
176
+ host: o,
177
+ path: i,
178
+ query: d
179
+ };
180
+ s.store("route").update(u), n(M, u);
181
+ }, U = (e) => {
182
+ const { subscribe: t } = e;
183
+ t($, z);
184
+ }, B = (e) => {
185
+ const { publish: t, subscribe: s, state: n, window: r } = e;
186
+ F(n), r.addEventListener("popstate", () => t(m, null)), s(m, P);
187
+ }, K = (e) => {
188
+ setTimeout(() => e.publish(m, null), 0);
189
+ }, V = (e) => {
190
+ B(e), U(e), K(e);
191
+ }, wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
192
+ __proto__: null,
193
+ publishLocation: K,
194
+ startNavigation: V,
195
+ subscribeToHistoryChange: B,
196
+ subscribeToNavigation: U
197
+ }, Symbol.toStringTag, { value: "Module" }));
198
+ class R {
199
+ constructor({ window: t, document: s, publish: n, subscribe: r, bus: o, state: a, renderKit: h }) {
200
+ this.window = t, this.document = s, this.publish = n, this.subscribe = r, this.bus = o, this.state = a, this.renderKit = h, this.roots = [];
201
+ }
202
+ render(t, s) {
203
+ const n = St(t, s, this.renderKit);
204
+ return this.roots.push(n), n;
205
+ }
206
+ startNavigation() {
207
+ V(this);
338
208
  }
339
- reset() {
340
- this.update(this.initialState);
209
+ }
210
+ const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
211
+ __proto__: null,
212
+ App: R
213
+ }, Symbol.toStringTag, { value: "Module" }));
214
+ class J {
215
+ constructor() {
216
+ this.lookup = {};
217
+ }
218
+ add(t, s, n) {
219
+ this.ensureArrayFor(t);
220
+ const r = {
221
+ listener: s,
222
+ index: n,
223
+ matcher: t
224
+ };
225
+ return this.lookup[t].push(r), () => this.remove(r);
226
+ }
227
+ remove(t) {
228
+ this.lookup[t.matcher] && (this.lookup[t.matcher] = this.lookup[t.matcher].reduce((s, n) => (n !== t && s.push(n), s), []));
229
+ }
230
+ matches(t) {
231
+ return this.lookup[t] || [];
232
+ }
233
+ ensureArrayFor(t) {
234
+ this.lookup[t] || (this.lookup[t] = []);
235
+ }
236
+ }
237
+ class q {
238
+ constructor() {
239
+ this.lookup = [];
240
+ }
241
+ add(t, s, n) {
242
+ const r = {
243
+ listener: s,
244
+ index: n,
245
+ matcher: t
246
+ };
247
+ return this.lookup.push(r), () => this.remove(r);
248
+ }
249
+ remove(t) {
250
+ this.lookup = this.lookup.reduce((s, n) => (n !== t && s.push(n), s), []);
341
251
  }
342
- isEqual(newValue) {
343
- return areElementEqual(this.value, newValue);
252
+ matches(t) {
253
+ return this.lookup.filter(
254
+ (s) => s.matcher.test(t)
255
+ );
344
256
  }
345
- event() {
257
+ }
258
+ class H {
259
+ constructor() {
260
+ this.exactSubscriptions = new J(), this.fuzzySubscriptions = new q(), this.currentIndex = 0;
261
+ }
262
+ subscribe(t, s) {
263
+ let n;
264
+ return typeof t == "string" ? n = this.exactSubscriptions.add(
265
+ t,
266
+ s,
267
+ this.currentIndex
268
+ ) : n = this.fuzzySubscriptions.add(
269
+ t,
270
+ s,
271
+ this.currentIndex
272
+ ), this.currentIndex += 1, n;
273
+ }
274
+ publish(t, s) {
275
+ [
276
+ ...this.exactSubscriptions.matches(t),
277
+ ...this.fuzzySubscriptions.matches(t)
278
+ ].sort((r, o) => r.index - o.index).forEach((r) => {
279
+ r.listener(s, this.listenerOptions(t));
280
+ });
281
+ }
282
+ addListenerOptions(t) {
283
+ this.options = t;
284
+ }
285
+ listenerOptions(t) {
346
286
  return {
347
- name: this.name,
348
- value: this.value
287
+ eventName: t,
288
+ ...this.options,
289
+ publish: this.publish.bind(this)
349
290
  };
350
291
  }
351
292
  }
352
-
353
- class BooleanStore extends GeneralStore {
354
- toggle() {
355
- this.update(!this.value);
293
+ const I = () => {
294
+ const e = new H();
295
+ return {
296
+ bus: e,
297
+ publish: (n, r) => e.publish(n, r),
298
+ subscribe: (n, r) => e.subscribe(n, r)
299
+ };
300
+ }, me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
301
+ __proto__: null,
302
+ ExactSubscriptions: J,
303
+ FuzzySubscriptions: q,
304
+ JaxsBus: H,
305
+ createBus: I
306
+ }, Symbol.toStringTag, { value: "Module" })), f = (e) => Array.isArray(e), g = (e) => e !== null && !f(e) && typeof e == "object", Nt = (e, t) => e === t, jt = (e, t) => Object.keys(e).length === Object.keys(t).length, kt = (e, t) => !(g(e) && g(t)) || !jt(e, t) ? !1 : Object.keys(e).every((s) => {
307
+ const n = e[s], r = t[s];
308
+ return E(n, r);
309
+ }), Ot = (e, t) => !(f(e) && f(t)) || e.length !== t.length ? !1 : e.every((s, n) => {
310
+ const r = t[n];
311
+ return E(s, r);
312
+ }), E = (e, t) => g(e) ? kt(e, t) : f(e) ? Ot(e, t) : Nt(e, t);
313
+ class b {
314
+ constructor(t) {
315
+ this.store = t;
316
+ }
317
+ update(t) {
318
+ this.store.update(t);
319
+ }
320
+ reset() {
321
+ this.store.update(this.store.initialState);
322
+ }
323
+ get value() {
324
+ return this.store.value;
325
+ }
326
+ addUpdaterFunction(t, s) {
327
+ this.constructor.prototype[t] = (...n) => {
328
+ const r = s(this.value, ...n);
329
+ this.update(r);
330
+ };
331
+ }
332
+ addUpdaterFunctions(t) {
333
+ for (const s in t)
334
+ this.addUpdaterFunction(s, t[s]);
356
335
  }
357
336
  }
358
-
359
- class NumericStore extends GeneralStore {
337
+ class x extends b {
338
+ push(t) {
339
+ const s = [...this.value, t];
340
+ this.update(s);
341
+ }
342
+ pop() {
343
+ const t = [...this.value], s = t.pop();
344
+ return this.update(t), s;
345
+ }
346
+ unshift(t) {
347
+ const s = [t, ...this.value];
348
+ this.update(s);
349
+ }
350
+ shift() {
351
+ const t = [...this.value], s = t.shift();
352
+ return this.update(t), s;
353
+ }
354
+ addSorter(t, s) {
355
+ this[t] = () => {
356
+ this.sortBy(s);
357
+ };
358
+ }
359
+ sortBy(t) {
360
+ const s = [...this.value];
361
+ s.sort(t), this.update(s);
362
+ }
363
+ insertAt(t, s) {
364
+ const n = [...this.value];
365
+ n.splice(t, 0, s), this.update(n);
366
+ }
360
367
  }
361
-
362
- class StringStore extends GeneralStore {
368
+ class y {
369
+ constructor(t) {
370
+ this.name = t.name, this.parent = t.parent, this._value = t.value, this.initialState = structuredClone(t.value), this.updater = new b(this);
371
+ }
372
+ get value() {
373
+ return this._value;
374
+ }
375
+ set value(t) {
376
+ throw new Error("Cannot set value directly. Use an updater!");
377
+ }
378
+ update(t) {
379
+ if (typeof t == "function") {
380
+ const s = this.getUpdatedValue(t);
381
+ this.updateValue(s);
382
+ } else
383
+ this.updateValue(t);
384
+ }
385
+ updateValue(t) {
386
+ E(this._value, t) || (this._value = t, this.parent.notify(this.name));
387
+ }
388
+ getUpdatedValue(t) {
389
+ return t(this.value);
390
+ }
391
+ addUpdaters(t) {
392
+ this.updater.addUpdaterFunctions(t);
393
+ }
394
+ addUpdater(t, s) {
395
+ this.updater.addUpdaterFunction(t, s);
396
+ }
397
+ addSorter(t, s) {
398
+ this.updater instanceof x && this.updater.addSorter(t, s);
399
+ }
363
400
  }
364
-
365
- class ListStore extends GeneralStore {
366
- isEqual(newValue) {
367
- return areArraysEqual(this.value, newValue);
401
+ class Q extends b {
402
+ toggle() {
403
+ const t = !this.value;
404
+ this.update(t);
368
405
  }
369
- push(newValue) {
370
- const value = [...this.value, newValue];
371
- this.update(value);
406
+ setTrue() {
407
+ this.update(!0);
408
+ }
409
+ setFalse() {
410
+ this.update(!1);
372
411
  }
373
412
  }
374
-
375
- class RecordStore extends GeneralStore {
376
- isEqual(newValue) {
377
- return areObjectsEqual(this.value, newValue);
413
+ class W extends b {
414
+ updateAttribute(t, s) {
415
+ const n = { ...this.value };
416
+ n[t] = s, this.update(n);
378
417
  }
379
418
  }
380
-
381
- // src/state.js
382
- var eventPrefix = "state-change";
383
- var eventName = (name) => `${eventPrefix}:${name}`;
384
-
385
- class State {
386
- constructor(publish) {
387
- this.publisher = publish;
388
- this.stores = {};
389
- this.events = [];
390
- this.transacting = false;
391
- }
392
- create(name, value) {
393
- const StoreClass = this.storeTypeFor(value);
394
- const store = new StoreClass({ name, value, parent: this });
395
- this.addStore(name, store);
396
- }
397
- add(store) {
398
- const name = store.name;
399
- this.addStore(name, store);
400
- }
401
- getStore(name) {
402
- return this.stores[name];
403
- }
404
- addStore(name, store) {
405
- this.stores[name] = store;
406
- this[name] = store;
407
- }
408
- storeTypeFor(value) {
409
- if (isArray(value))
410
- return ListStore;
411
- if (isObject(value))
412
- return RecordStore;
413
- if (isNumber(value))
414
- return NumericStore;
415
- if (isBoolean(value))
416
- return BooleanStore;
417
- if (isString(value))
418
- return StringStore;
419
- return GeneralStore;
420
- }
421
- publish(event) {
422
- this.events.push(event);
423
- if (!this.transacting)
424
- this.publishAll();
419
+ const A = "state";
420
+ class G {
421
+ constructor(t) {
422
+ this.publisher = t, this.stores = {}, this.eventNamePrefix = A, this.notifications = /* @__PURE__ */ new Set(), this.inTransaction = !1;
423
+ }
424
+ create(t, s) {
425
+ const n = new y({
426
+ name: t,
427
+ parent: this,
428
+ value: s
429
+ });
430
+ return this.stores[t] = n, n;
431
+ }
432
+ createBoolean(t, s) {
433
+ const n = this.create(t, s);
434
+ return n.updater = new Q(n), n;
435
+ }
436
+ createRecord(t, s) {
437
+ const n = this.create(t, s);
438
+ return n.updater = new W(n), n;
439
+ }
440
+ createList(t, s) {
441
+ const n = this.create(t, s);
442
+ return n.updater = new x(n), n;
443
+ }
444
+ store(t) {
445
+ return this.stores[t] || new y({
446
+ name: t,
447
+ parent: this,
448
+ value: void 0
449
+ });
450
+ }
451
+ get(t) {
452
+ return this.store(t).value;
453
+ }
454
+ getAll(t) {
455
+ return t.reduce((s, n) => (s[n] = this.get(n), s), {});
456
+ }
457
+ notify(t) {
458
+ this.inTransaction ? this.notifications.add(t) : this.publish(t);
459
+ }
460
+ update(t, s) {
461
+ this.store(t).update(s);
462
+ }
463
+ transaction(t) {
464
+ this.inTransaction = !0, t(this.stores), this.inTransaction = !1, this.publishAll();
425
465
  }
426
466
  publishAll() {
427
- const publishedStores = [];
428
- this.events.reverse().forEach((event) => {
429
- const { name, value } = event;
430
- if (!publishedStores.includes(name)) {
431
- publishedStores.push(name);
432
- this.publisher(`${eventPrefix}:${name}`, value);
433
- }
467
+ this.notifications.forEach((t) => {
468
+ this.publish(t);
469
+ }), this.notifications.clear();
470
+ }
471
+ publish(t) {
472
+ this.publisher(this.event(t), {
473
+ state: this,
474
+ store: this.store(t)
475
+ });
476
+ }
477
+ event(t) {
478
+ return `${this.eventNamePrefix}:${t}`;
479
+ }
480
+ }
481
+ const X = (e) => new G(e), be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
482
+ __proto__: null,
483
+ BooleanUpdater: Q,
484
+ JaxsState: G,
485
+ JaxsStore: y,
486
+ JaxsStoreUpdater: b,
487
+ ListUpdater: x,
488
+ ObjectUpdater: W,
489
+ createState: X,
490
+ eventName: A
491
+ }, Symbol.toStringTag, { value: "Module" }));
492
+ class $t {
493
+ constructor(t) {
494
+ this.setupDomEnvironment(t);
495
+ }
496
+ setup() {
497
+ return this.setupBus(), this.setupState(), this.addBusOptions(), this.setRenderKit(), new R({
498
+ window: this.window,
499
+ document: this.document,
500
+ publish: this.publish,
501
+ subscribe: this.subscribe,
502
+ bus: this.bus,
503
+ state: this.state,
504
+ renderKit: this.renderKit
434
505
  });
435
- this.events = [];
436
506
  }
437
- transaction(setter) {
438
- this.transacting = true;
439
- setter(this);
440
- this.transacting = false;
441
- this.publishAll();
507
+ setupDomEnvironment(t) {
508
+ 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);
509
+ }
510
+ setupBus() {
511
+ const { publish: t, subscribe: s, bus: n } = I();
512
+ this.publish = t, this.subscribe = s, this.bus = n;
442
513
  }
443
- value() {
444
- return Object.keys(this.stores).reduce((valueObject, key) => {
445
- valueObject[key] = this.stores[key].value;
446
- return valueObject;
447
- }, {});
514
+ setupState() {
515
+ this.state = X(this.publish);
516
+ }
517
+ addBusOptions() {
518
+ this.bus.addListenerOptions({
519
+ state: this.state,
520
+ document: this.document,
521
+ window: this.window
522
+ });
523
+ }
524
+ setRenderKit() {
525
+ this.renderKit = {
526
+ publish: this.publish,
527
+ subscribe: this.subscribe,
528
+ state: this.state,
529
+ document: this.document,
530
+ window: this.window
531
+ };
448
532
  }
449
533
  }
450
-
451
- // src/types.ts
452
- var ChangeInstructions;
453
- (function(ChangeInstructions2) {
454
- ChangeInstructions2[ChangeInstructions2["removeNode"] = 0] = "removeNode";
455
- ChangeInstructions2[ChangeInstructions2["insertNode"] = 1] = "insertNode";
456
- ChangeInstructions2[ChangeInstructions2["replaceNode"] = 2] = "replaceNode";
457
- ChangeInstructions2[ChangeInstructions2["removeAttribute"] = 3] = "removeAttribute";
458
- ChangeInstructions2[ChangeInstructions2["addAttribute"] = 4] = "addAttribute";
459
- ChangeInstructions2[ChangeInstructions2["updateAttribute"] = 5] = "updateAttribute";
460
- ChangeInstructions2[ChangeInstructions2["removeEvent"] = 6] = "removeEvent";
461
- ChangeInstructions2[ChangeInstructions2["addEvent"] = 7] = "addEvent";
462
- ChangeInstructions2[ChangeInstructions2["updateEvent"] = 8] = "updateEvent";
463
- ChangeInstructions2[ChangeInstructions2["changeValue"] = 9] = "changeValue";
464
- ChangeInstructions2[ChangeInstructions2["changeText"] = 10] = "changeText";
465
- })(ChangeInstructions || (ChangeInstructions = {}));
466
-
467
- // src/rendering/change/instructions/generate.ts
468
- var changeText = (source, target) => ({
469
- source,
470
- target,
471
- type: ChangeInstructions.changeText,
534
+ const fe = (e = {}) => {
535
+ const s = new $t(e).setup();
536
+ return s.startNavigation(), s;
537
+ };
538
+ var c = /* @__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))(c || {});
539
+ const ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
540
+ __proto__: null,
541
+ ChangeInstructionTypes: c
542
+ }, Symbol.toStringTag, { value: "Module" })), Mt = (e, t) => ({
543
+ source: e,
544
+ target: t,
545
+ type: c.changeText,
472
546
  data: {}
473
- });
474
- var replaceNode = (source, target) => ({
475
- source,
476
- target,
477
- type: ChangeInstructions.replaceNode,
547
+ }), Ft = (e, t) => ({
548
+ source: e,
549
+ target: t,
550
+ type: c.replaceNode,
478
551
  data: {}
479
- });
480
- var removeAttribute = (source, target, data) => ({
481
- source,
482
- target,
483
- data,
484
- type: ChangeInstructions.removeAttribute
485
- });
486
- var addAttribute = (source, target, data) => ({
487
- source,
488
- target,
489
- data,
490
- type: ChangeInstructions.addAttribute
491
- });
492
- var updateAttribute = (source, target, data) => ({
493
- source,
494
- target,
495
- data,
496
- type: ChangeInstructions.updateAttribute
497
- });
498
- var removeEvent = (source, target, data) => ({
499
- source,
500
- target,
501
- data,
502
- type: ChangeInstructions.removeEvent
503
- });
504
- var addEvent = (source, target, data) => ({
505
- source,
506
- target,
507
- data,
508
- type: ChangeInstructions.addEvent
509
- });
510
- var updateEvent = (source, target, data) => ({
511
- source,
512
- target,
513
- data,
514
- type: ChangeInstructions.updateEvent
515
- });
516
- var removeNode = (source) => ({
517
- source,
518
- target: source,
519
- type: ChangeInstructions.removeNode,
552
+ }), Tt = (e, t, s) => ({
553
+ source: e,
554
+ target: t,
555
+ data: s,
556
+ type: c.removeAttribute
557
+ }), Dt = (e, t, s) => ({
558
+ source: e,
559
+ target: t,
560
+ data: s,
561
+ type: c.addAttribute
562
+ }), zt = (e, t, s) => ({
563
+ source: e,
564
+ target: t,
565
+ data: s,
566
+ type: c.updateAttribute
567
+ }), Lt = (e, t, s) => ({
568
+ source: e,
569
+ target: t,
570
+ data: s,
571
+ type: c.removeEvent
572
+ }), Pt = (e, t, s) => ({
573
+ source: e,
574
+ target: t,
575
+ data: s,
576
+ type: c.addEvent
577
+ }), Ut = (e, t, s) => ({
578
+ source: e,
579
+ target: t,
580
+ data: s,
581
+ type: c.updateEvent
582
+ }), S = (e) => ({
583
+ source: e,
584
+ target: e,
585
+ // for type crap only
586
+ type: c.removeNode,
520
587
  data: {}
521
- });
522
- var insertNode = (target, data) => ({
523
- target,
524
- source: target,
525
- type: ChangeInstructions.insertNode,
526
- data
527
- });
528
- var changeValue = (source, target, data) => ({
529
- source,
530
- target,
531
- type: ChangeInstructions.changeValue,
532
- data
533
- });
534
-
535
- // src/rendering/change/instructions/idMap.js
536
- var nullMatch = { index: -1 };
537
-
538
- class IdMap {
588
+ }), v = (e, t) => ({
589
+ target: e,
590
+ source: e,
591
+ // for type crap only
592
+ type: c.insertNode,
593
+ data: t
594
+ }), Bt = (e, t, s) => ({
595
+ source: e,
596
+ target: t,
597
+ type: c.changeValue,
598
+ data: s
599
+ }), Kt = (e, t) => e.type > t.type ? 1 : e.type < t.type ? -1 : 0, _ = { index: -1 };
600
+ class Vt {
539
601
  constructor() {
540
602
  this.map = {};
541
603
  }
542
- populate(list) {
543
- list.forEach((element, i) => {
544
- const id = element.__jsx;
545
- if (id) {
546
- this.map[id] = this.map[id] || [];
547
- this.map[id].push({
548
- element,
549
- index: i
550
- });
551
- }
604
+ populate(t) {
605
+ t.forEach((s, n) => {
606
+ const r = s.__jsx;
607
+ r && (this.map[r] = this.map[r] || [], this.map[r].push({
608
+ element: s,
609
+ index: n
610
+ }));
552
611
  });
553
612
  }
554
- pullMatch(element) {
555
- const id = element && element.__jsx;
556
- if (!id)
557
- return nullMatch;
558
- if (!(this.map[id] && this.map[id].length))
559
- return nullMatch;
560
- return this.map[id].shift();
561
- }
562
- clear(element) {
563
- const id = element && element.__jsx;
564
- if (!(id && this.map[id] && this.map[id].length))
565
- return;
566
- const matches = this.map[id];
567
- this.map[id] = matches.reduce((collection, possibleMatch) => {
568
- if (possibleMatch.element !== element)
569
- collection.push(possibleMatch);
570
- return collection;
571
- }, []);
572
- }
573
- check(element) {
574
- const id = element && element.__jsx;
575
- if (!(id && this.map[id]))
576
- return false;
577
- return this.map[id].length > 0;
613
+ pullMatch(t) {
614
+ const s = t && t.__jsx;
615
+ return !s || !(this.map[s] && this.map[s].length) ? _ : this.map[s].shift();
616
+ }
617
+ clear(t) {
618
+ const s = t && t.__jsx;
619
+ if (!(s && this.map[s] && this.map[s].length)) return;
620
+ const n = this.map[s];
621
+ this.map[s] = n.reduce((r, o) => (o.element !== t && r.push(o), r), []);
622
+ }
623
+ check(t) {
624
+ const s = t && t.__jsx;
625
+ return s && this.map[s] ? this.map[s].length > 0 : !1;
578
626
  }
579
627
  remaining() {
580
628
  return Object.values(this.map).flat();
581
629
  }
582
630
  }
583
- var createIdMap = (list) => {
584
- const map = new IdMap;
585
- map.populate(list);
586
- return map;
587
- };
588
-
589
- // src/rendering/change/instructions/attributes.ts
590
- var compileForAttributes = (source, target, isSvg2 = false) => {
591
- const instructions = [];
592
- const sourceAttributes = source.attributes;
593
- const sourceLength = sourceAttributes.length;
594
- const targetAttributes = target.attributes;
595
- const targetLength = targetAttributes.length;
596
- let index;
597
- let innerIndex;
598
- let matchingAttribute;
599
- for (index = 0;index < sourceLength; index++) {
600
- matchingAttribute = null;
601
- const sourceAttribute = sourceAttributes.item(index);
602
- if (!sourceAttribute)
603
- continue;
604
- for (innerIndex = 0;innerIndex < targetLength; innerIndex++) {
605
- const targetAttribute = targetAttributes.item(innerIndex);
606
- if (!targetAttribute)
607
- continue;
608
- if (sourceAttribute.name == targetAttribute.name) {
609
- matchingAttribute = targetAttribute;
610
- break;
611
- }
612
- }
613
- if (!matchingAttribute) {
614
- instructions.push(removeAttribute(source, target, { name: sourceAttribute.name, isSvg: isSvg2 }));
615
- } else if (sourceAttribute.value !== matchingAttribute.value) {
616
- instructions.push(updateAttribute(source, target, {
617
- name: sourceAttribute.name,
618
- value: matchingAttribute.value,
619
- isSvg: isSvg2
620
- }));
621
- }
622
- }
623
- for (index = 0;index < targetLength; index++) {
624
- matchingAttribute = null;
625
- const targetAttribute = targetAttributes.item(index);
626
- if (!targetAttribute)
627
- continue;
628
- for (innerIndex = 0;innerIndex < sourceLength; innerIndex++) {
629
- const sourceAttribute = sourceAttributes.item(innerIndex);
630
- if (!sourceAttribute)
631
- continue;
632
- if (sourceAttribute.name == targetAttribute.name) {
633
- matchingAttribute = sourceAttribute;
634
- break;
631
+ const w = (e) => {
632
+ const t = new Vt();
633
+ return t.populate(e), t;
634
+ }, Y = (e, t, s = !1) => {
635
+ const n = [], r = e.attributes, o = r.length, a = t.attributes, h = a.length;
636
+ let i, d, u;
637
+ for (i = 0; i < o; i++) {
638
+ u = null;
639
+ const l = r.item(i);
640
+ if (l) {
641
+ for (d = 0; d < h; d++) {
642
+ const p = a.item(d);
643
+ if (p && l.name == p.name) {
644
+ u = p;
645
+ break;
646
+ }
635
647
  }
636
- }
637
- if (!matchingAttribute) {
638
- instructions.push(addAttribute(source, target, {
639
- name: targetAttribute.name,
640
- value: targetAttribute.value,
641
- isSvg: isSvg2
642
- }));
648
+ u ? l.value !== u.value && n.push(
649
+ zt(e, t, {
650
+ name: l.name,
651
+ value: u.value,
652
+ isSvg: s
653
+ })
654
+ ) : n.push(
655
+ Tt(e, t, { name: l.name, isSvg: s })
656
+ );
643
657
  }
644
658
  }
645
- return instructions;
646
- };
647
-
648
- // src/rendering/change/instructions/events.ts
649
- var compileForEvents = (source, target) => {
650
- const instructions = [];
651
- const sourceEventMaps = source.eventMaps;
652
- const targetEventMaps = target.eventMaps;
653
- const sourceDomEvents = Object.keys(sourceEventMaps);
654
- const targetDomEvents = Object.keys(targetEventMaps);
655
- sourceDomEvents.forEach((domEvent) => {
656
- const sourceEventMap = sourceEventMaps[domEvent];
657
- const targetEventMap = targetEventMaps[domEvent];
658
- if (!targetEventMap) {
659
- instructions.push(removeEvent(source, target, {
660
- name: sourceEventMap.domEvent,
661
- value: sourceEventMap.listener
662
- }));
663
- } else if (targetEventMap.busEvent !== sourceEventMap.busEvent) {
664
- instructions.push(updateEvent(source, target, {
665
- name: domEvent,
666
- targetValue: targetEventMap.listener,
667
- sourceValue: sourceEventMap.listener
668
- }));
669
- }
670
- });
671
- targetDomEvents.forEach((domEvent) => {
672
- const sourceEventMap = sourceEventMaps[domEvent];
673
- const targetEventMap = targetEventMaps[domEvent];
674
- if (!sourceEventMap) {
675
- instructions.push(addEvent(source, target, {
676
- name: targetEventMap.domEvent,
677
- value: targetEventMap.listener
678
- }));
679
- }
680
- });
681
- return instructions;
682
- };
683
-
684
- // src/rendering/change/instructions/element.ts
685
- var compileForElement = (source, target) => {
686
- const attributeInstructions = compileForAttributes(source, target);
687
- const eventInstructions = compileForEvents(source, target);
688
- const valueInstructions = compileForInputValue(source, target);
689
- return attributeInstructions.concat(eventInstructions).concat(valueInstructions);
690
- };
691
- var compileForSvg = (source, target) => {
692
- return compileForAttributes(source, target, true);
693
- };
694
- var compileForInputValue = (sourceElement, targetElement) => {
695
- const instructions = [];
696
- if (sourceElement.tagName !== "INPUT") {
697
- return instructions;
698
- }
699
- const source = sourceElement;
700
- const target = targetElement;
701
- if (source.value !== target.value) {
702
- instructions.push(changeValue(source, target, { name: "value", value: target.value }));
703
- }
704
- return instructions;
705
- };
706
-
707
- // src/rendering/change/instructions/text.ts
708
- var compileForText = (source, target) => {
709
- if (source.textContent !== target.textContent) {
710
- return [changeText(source, target)];
711
- }
712
- return [];
713
- };
714
-
715
- // src/rendering/change/instructions/node.ts
716
- var NodeTypes;
717
- (function(NodeTypes2) {
718
- NodeTypes2[NodeTypes2["ElementNode"] = 1] = "ElementNode";
719
- NodeTypes2[NodeTypes2["TextNode"] = 3] = "TextNode";
720
- })(NodeTypes || (NodeTypes = {}));
721
- var compileForNodeGenerator = (compileForCollection) => (source, target) => {
722
- let instructions = [];
723
- if (source.nodeType === NodeTypes.ElementNode && isSvg(source)) {
724
- const sourceElement = source;
725
- const targetElement = target;
726
- const baseInstructions = compileForSvg(sourceElement, targetElement);
727
- const childrenInstructions = compileForCollection(sourceElement.childNodes, targetElement.childNodes, sourceElement);
728
- instructions = baseInstructions.concat(childrenInstructions);
729
- } else if (source.nodeType === NodeTypes.ElementNode) {
730
- const sourceElement = source;
731
- const targetElement = target;
732
- const baseInstructions = compileForElement(sourceElement, targetElement);
733
- const childrenInstructions = compileForCollection(sourceElement.childNodes, targetElement.childNodes, sourceElement);
734
- instructions = baseInstructions.concat(childrenInstructions);
735
- } else if (source.nodeType === NodeTypes.TextNode) {
736
- instructions = compileForText(source, target);
737
- }
738
- return instructions;
739
- };
740
-
741
- // src/rendering/change/instructions/children.ts
742
- var compileChildren = (sourceList, targetList, parent) => {
743
- const baseInstructions = [];
744
- const length = largerLength(sourceList, targetList);
745
- const sourceMap = createIdMap(sourceList);
746
- const targetMap = createIdMap(targetList);
747
- const nodesPairsToDiff = [];
748
- let index = 0;
749
- for (;index < length; index++) {
750
- const source = sourceList[index];
751
- const target = targetList[index];
752
- if (target && targetMap.check(target)) {
753
- const matchingSource = sourceMap.pullMatch(target);
754
- targetMap.clear(target);
755
- if (matchingSource.element) {
756
- if (matchingSource.index !== index) {
757
- baseInstructions.push(insertNode(matchingSource.element, { parent, index }));
758
- }
759
- nodesPairsToDiff.push({
760
- source: matchingSource.element,
761
- target
762
- });
763
- } else if (source) {
764
- if (targetMap.check(source)) {
765
- baseInstructions.push(insertNode(target, { parent, index }));
766
- } else {
767
- sourceMap.clear(source);
768
- baseInstructions.push(replaceNode(source, target));
659
+ for (i = 0; i < h; i++) {
660
+ u = null;
661
+ const l = a.item(i);
662
+ if (l) {
663
+ for (d = 0; d < o; d++) {
664
+ const p = r.item(d);
665
+ if (p && p.name == l.name) {
666
+ u = p;
667
+ break;
769
668
  }
770
- } else {
771
- baseInstructions.push(insertNode(target, { parent, index }));
772
- }
773
- } else if (source) {
774
- const matchingSource = sourceMap.pullMatch(source);
775
- if (matchingSource.element) {
776
- baseInstructions.push(removeNode(source));
777
669
  }
670
+ u || n.push(
671
+ Dt(e, t, {
672
+ name: l.name,
673
+ value: l.value,
674
+ isSvg: s
675
+ })
676
+ );
778
677
  }
779
678
  }
780
- sourceMap.remaining().forEach(({ element: element2 }) => {
781
- baseInstructions.push(removeNode(element2));
679
+ return n;
680
+ }, Rt = (e, t) => {
681
+ const s = [], n = e.eventMaps, r = t.eventMaps, o = Object.keys(n), a = Object.keys(r);
682
+ return o.forEach((h) => {
683
+ const i = n[h], d = r[h];
684
+ d ? d.busEvent !== i.busEvent && s.push(
685
+ Ut(e, t, {
686
+ name: h,
687
+ targetValue: d.listener,
688
+ sourceValue: i.listener
689
+ })
690
+ ) : s.push(
691
+ Lt(e, t, {
692
+ name: i.domEvent,
693
+ value: i.listener
694
+ })
695
+ );
696
+ }), a.forEach((h) => {
697
+ const i = n[h], d = r[h];
698
+ i || s.push(
699
+ Pt(e, t, {
700
+ name: d.domEvent,
701
+ value: d.listener
702
+ })
703
+ );
704
+ }), s;
705
+ }, Jt = (e) => e.tagName !== "INPUT", qt = (e, t) => e.value === t.value, Ht = (e, t) => {
706
+ if (Jt(e) || qt(e, t))
707
+ return [];
708
+ const s = e, n = t;
709
+ return [Bt(s, n, { name: "value", value: n.value })];
710
+ }, It = (e, t) => {
711
+ const s = Y(e, t), n = Rt(e, t), r = Ht(e, t);
712
+ return s.concat(n).concat(r);
713
+ }, Qt = (e, t) => Y(e, t, !0), Wt = (e, t) => e.textContent !== t.textContent ? [Mt(e, t)] : [], Gt = (e, t, s) => {
714
+ let n = [];
715
+ if (e.nodeType === 1 && it(e)) {
716
+ const r = e, o = t, a = Qt(r, o), h = s(
717
+ r.childNodes,
718
+ o.childNodes,
719
+ r
720
+ );
721
+ n = a.concat(h);
722
+ } else if (e.nodeType === 1) {
723
+ const r = e, o = t, a = It(r, o), h = s(
724
+ r.childNodes,
725
+ o.childNodes,
726
+ r
727
+ );
728
+ n = a.concat(h);
729
+ } else e.nodeType === 3 && (n = Wt(e, t));
730
+ return n;
731
+ }, Z = (e, t, s) => {
732
+ const n = [], r = Xt(e, t), o = w(e), a = w(t), h = [];
733
+ let i = 0;
734
+ for (; i < r; i++) {
735
+ const u = e[i], l = t[i];
736
+ if (l && a.check(l)) {
737
+ const p = o.pullMatch(l);
738
+ a.clear(l), p.element ? (p.index !== i && n.push(
739
+ v(p.element, {
740
+ parent: s,
741
+ index: i
742
+ })
743
+ ), h.push({
744
+ source: p.element,
745
+ target: l
746
+ })) : u ? a.check(u) ? n.push(
747
+ v(l, { parent: s, index: i })
748
+ ) : (o.clear(u), n.push(
749
+ Ft(u, l)
750
+ )) : n.push(
751
+ v(l, { parent: s, index: i })
752
+ );
753
+ } else u && o.pullMatch(u).element && n.push(S(u));
754
+ }
755
+ o.remaining().forEach(({ element: u }) => {
756
+ n.push(S(u));
782
757
  });
783
- const nodeInstructions = nodesPairsToDiff.reduce((collection, { source, target }) => {
784
- return collection.concat(compileForNode(source, target));
785
- }, []);
786
- return baseInstructions.concat(nodeInstructions).sort(instructionsSorter);
787
- };
788
- var instructionsSorter = (left, right) => {
789
- if (left.type > right.type)
790
- return 1;
791
- if (left.type < right.type)
792
- return -1;
793
- return 0;
794
- };
795
- var largerLength = (sourceList, targetList) => {
796
- const sourceLength = Array.from(sourceList).length;
797
- const targetLength = Array.from(targetList).length;
798
- return sourceLength > targetLength ? sourceLength : targetLength;
799
- };
800
- var compileForNode = compileForNodeGenerator(compileChildren);
801
- // src/rendering/change.ts
802
- var change = (source, target, parent) => {
803
- const instructions = compileChildren(source, target, parent);
804
- instructions.forEach((instruction) => {
805
- performInstruction(instruction);
758
+ const d = h.reduce(
759
+ (u, { source: l, target: p }) => u.concat(
760
+ Gt(l, p, Z)
761
+ ),
762
+ []
763
+ );
764
+ return n.concat(d).sort(Kt);
765
+ }, Xt = (e, t) => {
766
+ const s = e.length, n = t.length;
767
+ return s > n ? s : n;
768
+ }, Yt = (e, t, s) => {
769
+ Z(e, t, s).forEach((r) => {
770
+ Zt(r);
806
771
  });
807
- };
808
- var performInstruction = (instruction) => {
809
- const performer = performers[instruction.type] || noop;
810
- performer(instruction);
811
- };
812
- var noop = (_instruction) => {
813
- };
814
- var changeText2 = (instruction) => {
815
- const { source, target } = instruction;
816
- source.nodeValue = target.textContent;
817
- };
818
- var removeNode2 = (instruction) => {
819
- const { source } = instruction;
820
- source.remove();
821
- };
822
- var insertNode2 = (instruction) => {
823
- const { target, data } = instruction;
824
- const { parent, index } = data;
825
- const sibling = parent.childNodes[index];
826
- if (!sibling) {
827
- parent.appendChild(target);
828
- } else if (sibling && sibling !== target) {
829
- parent.insertBefore(target, sibling);
830
- }
831
- };
832
- var replaceNode2 = (instruction) => {
833
- const { source, target } = instruction;
834
- source.replaceWith(target);
835
- };
836
- var removeAttribute2 = (instruction) => {
837
- const { source, data } = instruction;
838
- const { name, isSvg: isSvg2 } = data;
839
- if (isSvg2) {
840
- source.removeAttributeNS(null, name);
841
- } else {
842
- source.removeAttribute(name);
843
- }
844
- };
845
- var addAttribute2 = (instruction) => {
846
- const { source, data } = instruction;
847
- const { name, value, isSvg: isSvg2 } = data;
848
- if (isSvg2) {
849
- source.setAttributeNS(null, name, value);
850
- } else {
851
- source.setAttribute(name, value);
852
- }
853
- };
854
- var updateAttribute2 = (instruction) => {
855
- addAttribute2(instruction);
856
- };
857
- var removeEvent2 = (instruction) => {
858
- const data = instruction.data;
859
- const source = instruction.source;
860
- const { name, value } = data;
861
- source.removeEventListener(name, value);
862
- };
863
- var addEvent2 = (instruction) => {
864
- const data = instruction.data;
865
- const source = instruction.source;
866
- const { name, value } = data;
867
- source.addEventListener(name, value);
868
- };
869
- var updateEvent2 = (instruction) => {
870
- const data = instruction.data;
871
- const source = instruction.source;
872
- const { name, sourceValue, targetValue } = data;
873
- source.removeEventListener(name, sourceValue);
874
- source.addEventListener(name, targetValue);
875
- };
876
- var changeValue2 = (instruction) => {
877
- const data = instruction.data;
878
- const source = instruction.source;
879
- const { value } = data;
880
- source.value = value;
881
- };
882
- var performers = {
883
- [ChangeInstructions.changeText]: changeText2,
884
- [ChangeInstructions.removeNode]: removeNode2,
885
- [ChangeInstructions.insertNode]: insertNode2,
886
- [ChangeInstructions.replaceNode]: replaceNode2,
887
- [ChangeInstructions.removeAttribute]: removeAttribute2,
888
- [ChangeInstructions.addAttribute]: addAttribute2,
889
- [ChangeInstructions.updateAttribute]: updateAttribute2,
890
- [ChangeInstructions.removeEvent]: removeEvent2,
891
- [ChangeInstructions.addEvent]: addEvent2,
892
- [ChangeInstructions.updateEvent]: updateEvent2,
893
- [ChangeInstructions.changeValue]: changeValue2
894
- };
895
-
896
- // src/rendering/templates/bound.js
897
- var passThroughViewModel = (state2) => state2;
898
-
899
- class Bound {
900
- constructor(TemplateClass, viewModel, subscriptions, attributes2) {
901
- this.TemplateClass = TemplateClass;
902
- this.viewModel = viewModel || passThroughViewModel;
903
- this.attributes = attributes2 || {};
904
- this.subscriptions = subscriptions;
905
- this.dom = [];
906
- }
907
- render(renderKit) {
908
- this.parentElement = renderKit.parent;
909
- this.renderKit = renderKit;
910
- this.subscribeForRerender();
911
- this.dom = this._render(renderKit);
912
- return this.dom;
913
- }
914
- _render(renderKit) {
915
- const props = {
772
+ }, Zt = (e) => {
773
+ (he[e.type] || Ct)(e);
774
+ }, Ct = (e) => {
775
+ }, te = (e) => {
776
+ const { source: t, target: s } = e;
777
+ t.nodeValue = s.textContent;
778
+ }, ee = (e) => {
779
+ const { source: t } = e;
780
+ t.remove();
781
+ }, se = (e) => {
782
+ const { target: t, data: s } = e, { parent: n, index: r } = s, o = n.childNodes[r];
783
+ o ? o && o !== t && n.insertBefore(t, o) : n.appendChild(t);
784
+ }, ne = (e) => {
785
+ const { source: t, target: s } = e;
786
+ t.replaceWith(s);
787
+ }, re = (e) => {
788
+ const { source: t, data: s } = e, { name: n, isSvg: r } = s;
789
+ r ? t.removeAttributeNS(null, n) : t.removeAttribute(n);
790
+ }, C = (e) => {
791
+ const { source: t, data: s } = e, { name: n, value: r, isSvg: o } = s;
792
+ o ? t.setAttributeNS(null, n, r) : t.setAttribute(n, r);
793
+ }, oe = (e) => {
794
+ C(e);
795
+ }, ie = (e) => {
796
+ const t = e.data, s = e.source, { name: n, value: r } = t;
797
+ s.removeEventListener(n, r);
798
+ }, ae = (e) => {
799
+ const t = e.data, s = e.source, { name: n, value: r } = t;
800
+ s.addEventListener(n, r);
801
+ }, ce = (e) => {
802
+ const t = e.data, s = e.source, { name: n, sourceValue: r, targetValue: o } = t;
803
+ s.removeEventListener(n, r), s.addEventListener(n, o);
804
+ }, ue = (e) => {
805
+ const t = e.data, s = e.source, { value: n } = t;
806
+ s.value = n;
807
+ }, he = {
808
+ [c.changeText]: te,
809
+ [c.removeNode]: ee,
810
+ [c.insertNode]: se,
811
+ [c.replaceNode]: ne,
812
+ [c.removeAttribute]: re,
813
+ [c.addAttribute]: C,
814
+ [c.updateAttribute]: oe,
815
+ [c.removeEvent]: ie,
816
+ [c.addEvent]: ae,
817
+ [c.updateEvent]: ce,
818
+ [c.changeValue]: ue
819
+ };
820
+ class le {
821
+ constructor({ Template: t, subscriptions: s, attributes: n, viewModel: r }) {
822
+ this.Template = t, this.viewModel = r, this.attributes = n, this.subscriptions = s, this.dom = [], this.parentElement = null;
823
+ }
824
+ render(t) {
825
+ return this.parentElement = t.parent, this.renderKit = t, this.subscribeForRerender(), this.dom = this.generateDom(t), this.dom;
826
+ }
827
+ generateDom(t) {
828
+ const s = {
916
829
  ...this.attributes,
917
- ...this.viewModel(renderKit.state.value())
918
- };
919
- const template = this.TemplateClass(props);
920
- const dom = !template ? [] : template.render(renderKit);
921
- return dom;
830
+ ...this.viewModel(
831
+ t.state.getAll(this.subscriptions)
832
+ )
833
+ }, n = this.Template(s);
834
+ return n ? n.render(t) : [];
922
835
  }
923
836
  rerender() {
924
- if (!this.parentElement) {
925
- this.parentElement = this.dom[0] && this.dom[0].parentElement;
926
- }
927
- const newDom = this._render(this.renderKit);
928
- change(this.dom, newDom, this.parentElement);
929
- if (this.parentElement) {
930
- this.dom = Array.from(this.parentElement.childNodes);
837
+ if (!this.parentElement && this.dom[0]) {
838
+ const s = this.dom[0].parentElement;
839
+ this.parentElement = s;
931
840
  }
841
+ const t = this.generateDom(this.renderKit);
842
+ Yt(this.dom, t, this.parentElement), this.parentElement && (this.dom = Array.from(this.parentElement.childNodes));
932
843
  }
933
844
  subscribeForRerender() {
934
- this.subscriptions.forEach((storeName) => {
935
- this.renderKit.subscribe(eventName(storeName), () => this.rerender());
845
+ const { subscribe: t } = this.renderKit;
846
+ this.subscriptions.forEach((s) => {
847
+ t(this.eventName(s), () => this.rerender());
936
848
  });
937
849
  }
938
- }
939
- var bind = ({ Template, viewModel, subscriptions }) => {
940
- subscriptions = subscriptions || [];
941
- return (attributes2) => new Bound(Template, viewModel, subscriptions, attributes2);
942
- };
943
- // src/messageBus.ts
944
- class MessageBus {
945
- listeners;
946
- options;
947
- constructor() {
948
- this.options = {};
949
- this.listeners = {};
950
- }
951
- subscribe(eventName2, listener) {
952
- this.ensureListenerCollection(eventName2);
953
- this.listeners[eventName2].push(listener);
954
- }
955
- publish(eventName2, payload) {
956
- const listeners = this.listeners[eventName2];
957
- if (!listeners)
958
- return false;
959
- listeners.forEach((listener) => {
960
- listener(payload, this.buildListenerKit(eventName2));
961
- });
962
- return true;
963
- }
964
- ensureListenerCollection(eventName2) {
965
- if (this.listeners[eventName2])
966
- return;
967
- this.listeners[eventName2] = [];
968
- }
969
- buildListenerKit(eventName2) {
970
- return {
971
- eventName: eventName2,
972
- publish: this.publish.bind(this),
973
- ...this.options
974
- };
975
- }
976
- addListenerOptions(options) {
977
- this.options = {
978
- ...this.options,
979
- ...options
980
- };
850
+ eventName(t) {
851
+ return `${A}:${t}`;
981
852
  }
982
853
  }
983
- var createBus = () => {
984
- const bus = new MessageBus;
985
- const publish = bus.publish.bind(bus);
986
- const subscribe = bus.subscribe.bind(bus);
987
- return {
988
- bus,
989
- publish,
990
- subscribe
991
- };
992
- };
993
- // src/navigation/routeState.js
994
- var createRouteState = (state2) => {
995
- const store = new RecordStore({
996
- name: "route",
997
- value: {
998
- host: "",
999
- path: "",
1000
- query: ""
1001
- },
1002
- parent: state2
1003
- });
1004
- state2.add(store);
1005
- };
1006
-
1007
- // src/navigation/setupHistory.js
1008
- var locationChangeEvent = "locationChange";
1009
- var routeChangeEvent = "routeChange";
1010
- var extractQueryParams = (queryString) => {
1011
- return queryString.replace(/^\?/, "").split("&").reduce((aggregate, pairString) => {
1012
- if (!pairString)
1013
- return aggregate;
1014
- const pair = pairString.split("=");
1015
- aggregate[pair[0]] = pair[1];
1016
- return aggregate;
1017
- }, {});
1018
- };
1019
- var onLocationChange = (_payload, { publish, state: state2, window }) => {
1020
- const { host, pathname, search } = window.location;
1021
- const path = pathname;
1022
- const query = extractQueryParams(search);
1023
- state2.route.update({
1024
- host,
1025
- path,
1026
- query
1027
- });
1028
- publish(routeChangeEvent, { host, path, query });
1029
- };
1030
- var setupHistory = (app) => {
1031
- const { publish, subscribe, state: state2, window } = app;
1032
- createRouteState(state2);
1033
- window.addEventListener("popstate", () => publish(locationChangeEvent));
1034
- subscribe(locationChangeEvent, onLocationChange);
1035
- };
1036
-
1037
- // src/navigation/findHref.js
1038
- var findHref = (node2) => {
1039
- if (!node2 || !node2.getAttribute)
1040
- return "";
1041
- while (!node2.getAttribute("href")) {
1042
- node2 = node2.parentNode;
1043
- if (!node2 || !node2.getAttribute)
1044
- return "";
1045
- }
1046
- return node2.getAttribute("href");
1047
- };
1048
-
1049
- // src/navigation/setupNavigation.js
1050
- var linkNavigationEvent = "goToHref";
1051
- var programmaticNavigationEvent = "navigate";
1052
- var navigate = (path, { publish, window }) => {
1053
- window.history.pushState(null, "", path);
1054
- publish(locationChangeEvent);
1055
- };
1056
- var onLinkClick = (domEvent, { publish, window }) => {
1057
- if (!domEvent || !domEvent.target)
1058
- return;
1059
- domEvent.preventDefault();
1060
- const href = findHref(domEvent.target);
1061
- navigate(href, { publish, window });
1062
- };
1063
- var setupNavigation = (app) => {
1064
- const { subscribe } = app;
1065
- subscribe(linkNavigationEvent, onLinkClick);
1066
- subscribe(programmaticNavigationEvent, navigate);
1067
- };
1068
-
1069
- // src/app.ts
1070
- var setupBus = (app) => {
1071
- const { publish, subscribe, bus } = createBus();
1072
- app.publish = publish;
1073
- app.subscribe = subscribe;
1074
- app.bus = bus;
1075
- };
1076
- var setupState = (app) => {
1077
- const state3 = new State(app.publish);
1078
- app.state = state3;
1079
- };
1080
- var connectBusToState = (app) => {
1081
- const { bus } = app;
1082
- bus.addListenerOptions({
1083
- state: app.state,
1084
- document: app.document,
1085
- window: app.window
1086
- });
1087
- };
1088
- var setupRenderKit = (app) => {
1089
- app.renderKit = {
1090
- publish: app.publish,
1091
- subscribe: app.subscribe,
1092
- state: app.state,
1093
- document: app.document,
1094
- window: app.window
1095
- };
1096
- };
1097
- var triggerRoute = (app) => {
1098
- const publish = app.publish;
1099
- setTimeout(() => {
1100
- publish(locationChangeEvent, null);
1101
- }, 0);
1102
- };
1103
- var addRender = (app) => {
1104
- app.render = (template, selector) => {
1105
- return render(template, selector, app.renderKit);
1106
- };
1107
- };
1108
- var setupDomEnvironment = (app, domEnvironment) => {
1109
- const { window, document } = domEnvironment;
1110
- if (window) {
1111
- app.window = window;
1112
- app.document = window.document;
1113
- } else if (document) {
1114
- app.window = document.defaultView;
1115
- app.document = document;
1116
- } else {
1117
- app.window = window;
1118
- app.document = window?.document;
1119
- }
1120
- };
1121
- var createApp = (domEnvironment) => {
1122
- const app = {};
1123
- setupDomEnvironment(app, domEnvironment || {});
1124
- setupBus(app);
1125
- setupState(app);
1126
- connectBusToState(app);
1127
- setupRenderKit(app);
1128
- setupHistory(app);
1129
- setupNavigation(app);
1130
- triggerRoute(app);
1131
- addRender(app);
1132
- return app;
1133
- };
1134
- // src/navigation.ts
1135
- var exports_navigation = {};
1136
- __export(exports_navigation, {
1137
- setupNavigation: () => {
1138
- {
1139
- return setupNavigation;
1140
- }
1141
- },
1142
- setupHistory: () => {
1143
- {
1144
- return setupHistory;
1145
- }
1146
- }
1147
- });
854
+ const de = (e) => e, ge = ({
855
+ Template: e,
856
+ viewModel: t,
857
+ subscriptions: s
858
+ }) => (s = s || [], t = t || de, (n) => new le({ Template: e, viewModel: t, subscriptions: s, attributes: n })), ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
859
+ __proto__: null,
860
+ createRouteState: F,
861
+ events: _t,
862
+ extractQueryParams: L,
863
+ findHref: T,
864
+ navigate: D,
865
+ onLinkClick: z,
866
+ onLocationChange: P,
867
+ start: wt
868
+ }, Symbol.toStringTag, { value: "Module" }));
1148
869
  export {
1149
- render,
1150
- exports_navigation as navigation,
1151
- jsx_default as jsx,
1152
- createBus,
1153
- createApp,
1154
- bind,
1155
- State
870
+ ve as JaxsTypes,
871
+ pe as appBuilding,
872
+ ge as bind,
873
+ fe as createApp,
874
+ xt as jsx,
875
+ me as messageBus,
876
+ ye as navigation,
877
+ be as state
1156
878
  };