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.
- package/dist/jaxs.d.ts +634 -0
- package/dist/jaxs.js +793 -1071
- package/dist/jaxs.umd.cjs +1 -0
- package/package.json +41 -34
- package/.env +0 -1
- package/README.md +0 -15
- package/bun.lockb +0 -0
- package/bundle.ts +0 -5
- package/bunfig.toml +0 -0
- package/cypress/e2e/add-remove-nested-children.cy.js +0 -39
- package/cypress/e2e/add-remove-root-children.cy.js +0 -37
- package/cypress/e2e/svg-renders.cy.js +0 -10
- package/cypress/jaxs-apps/add-remove-nested-children.html +0 -12
- package/cypress/jaxs-apps/add-remove-nested-children.jsx +0 -85
- package/cypress/jaxs-apps/add-remove-root-children.html +0 -15
- package/cypress/jaxs-apps/add-remove-root-children.jsx +0 -54
- package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js +0 -1022
- package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-nested-children.html +0 -12
- package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js +0 -1665
- package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js +0 -1011
- package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-root-children.html +0 -15
- package/cypress/jaxs-apps/dist/svg.04290504.js +0 -644
- package/cypress/jaxs-apps/dist/svg.04290504.js.map +0 -1
- package/cypress/jaxs-apps/dist/svg.html +0 -11
- package/cypress/jaxs-apps/svg.html +0 -11
- package/cypress/jaxs-apps/svg.jsx +0 -15
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.js +0 -10
- package/src/app.ts +0 -84
- package/src/debugging.js +0 -5
- package/src/jaxs.ts +0 -7
- package/src/jsx.js +0 -27
- package/src/messageBus.ts +0 -70
- package/src/navigation/findHref.js +0 -10
- package/src/navigation/routeState.js +0 -15
- package/src/navigation/setupHistory.js +0 -38
- package/src/navigation/setupNavigation.js +0 -25
- package/src/navigation.ts +0 -2
- package/src/rendering/change/compile.ts +0 -1
- package/src/rendering/change/instructions/attributes.ts +0 -81
- package/src/rendering/change/instructions/children.ts +0 -127
- package/src/rendering/change/instructions/element.ts +0 -49
- package/src/rendering/change/instructions/events.ts +0 -51
- package/src/rendering/change/instructions/generate.ts +0 -122
- package/src/rendering/change/instructions/idMap.js +0 -55
- package/src/rendering/change/instructions/node.ts +0 -55
- package/src/rendering/change/instructions/text.ts +0 -10
- package/src/rendering/change.ts +0 -139
- package/src/rendering/dom/attributesAndEvents.ts +0 -33
- package/src/rendering/dom/create.ts +0 -66
- package/src/rendering/dom/svg.ts +0 -18
- package/src/rendering/templates/bound.js +0 -56
- package/src/rendering/templates/children.ts +0 -99
- package/src/rendering/templates/root.ts +0 -55
- package/src/rendering/templates/tag.ts +0 -92
- package/src/rendering/templates/text.ts +0 -17
- package/src/state/equality.js +0 -36
- package/src/state/stores.js +0 -63
- package/src/state/testingTypes.js +0 -6
- package/src/state.js +0 -89
- package/src/types.ts +0 -160
- package/src/views/conditionals.jsx +0 -18
- package/src/views/link.jsx +0 -5
- package/src/views.js +0 -7
- package/tsconfig.json +0 -26
|
@@ -1,1665 +0,0 @@
|
|
|
1
|
-
// modules are defined as an array
|
|
2
|
-
// [ module function, map of requires ]
|
|
3
|
-
//
|
|
4
|
-
// map of requires is short require name -> numeric require
|
|
5
|
-
//
|
|
6
|
-
// anything defined in a previous bundle is accessed via the
|
|
7
|
-
// orig method which is the require for previous bundles
|
|
8
|
-
|
|
9
|
-
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
|
|
10
|
-
/* eslint-disable no-undef */
|
|
11
|
-
var globalObject =
|
|
12
|
-
typeof globalThis !== 'undefined'
|
|
13
|
-
? globalThis
|
|
14
|
-
: typeof self !== 'undefined'
|
|
15
|
-
? self
|
|
16
|
-
: typeof window !== 'undefined'
|
|
17
|
-
? window
|
|
18
|
-
: typeof global !== 'undefined'
|
|
19
|
-
? global
|
|
20
|
-
: {};
|
|
21
|
-
/* eslint-enable no-undef */
|
|
22
|
-
|
|
23
|
-
// Save the require from previous bundle to this closure if any
|
|
24
|
-
var previousRequire =
|
|
25
|
-
typeof globalObject[parcelRequireName] === 'function' &&
|
|
26
|
-
globalObject[parcelRequireName];
|
|
27
|
-
|
|
28
|
-
var cache = previousRequire.cache || {};
|
|
29
|
-
// Do not use `require` to prevent Webpack from trying to bundle this call
|
|
30
|
-
var nodeRequire =
|
|
31
|
-
typeof module !== 'undefined' &&
|
|
32
|
-
typeof module.require === 'function' &&
|
|
33
|
-
module.require.bind(module);
|
|
34
|
-
|
|
35
|
-
function newRequire(name, jumped) {
|
|
36
|
-
if (!cache[name]) {
|
|
37
|
-
if (!modules[name]) {
|
|
38
|
-
// if we cannot find the module within our internal map or
|
|
39
|
-
// cache jump to the current global require ie. the last bundle
|
|
40
|
-
// that was added to the page.
|
|
41
|
-
var currentRequire =
|
|
42
|
-
typeof globalObject[parcelRequireName] === 'function' &&
|
|
43
|
-
globalObject[parcelRequireName];
|
|
44
|
-
if (!jumped && currentRequire) {
|
|
45
|
-
return currentRequire(name, true);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// If there are other bundles on this page the require from the
|
|
49
|
-
// previous one is saved to 'previousRequire'. Repeat this as
|
|
50
|
-
// many times as there are bundles until the module is found or
|
|
51
|
-
// we exhaust the require chain.
|
|
52
|
-
if (previousRequire) {
|
|
53
|
-
return previousRequire(name, true);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Try the node require function if it exists.
|
|
57
|
-
if (nodeRequire && typeof name === 'string') {
|
|
58
|
-
return nodeRequire(name);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var err = new Error("Cannot find module '" + name + "'");
|
|
62
|
-
err.code = 'MODULE_NOT_FOUND';
|
|
63
|
-
throw err;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
localRequire.resolve = resolve;
|
|
67
|
-
localRequire.cache = {};
|
|
68
|
-
|
|
69
|
-
var module = (cache[name] = new newRequire.Module(name));
|
|
70
|
-
|
|
71
|
-
modules[name][0].call(
|
|
72
|
-
module.exports,
|
|
73
|
-
localRequire,
|
|
74
|
-
module,
|
|
75
|
-
module.exports,
|
|
76
|
-
this
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return cache[name].exports;
|
|
81
|
-
|
|
82
|
-
function localRequire(x) {
|
|
83
|
-
var res = localRequire.resolve(x);
|
|
84
|
-
return res === false ? {} : newRequire(res);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function resolve(x) {
|
|
88
|
-
var id = modules[name][1][x];
|
|
89
|
-
return id != null ? id : x;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function Module(moduleName) {
|
|
94
|
-
this.id = moduleName;
|
|
95
|
-
this.bundle = newRequire;
|
|
96
|
-
this.exports = {};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
newRequire.isParcelRequire = true;
|
|
100
|
-
newRequire.Module = Module;
|
|
101
|
-
newRequire.modules = modules;
|
|
102
|
-
newRequire.cache = cache;
|
|
103
|
-
newRequire.parent = previousRequire;
|
|
104
|
-
newRequire.register = function (id, exports) {
|
|
105
|
-
modules[id] = [
|
|
106
|
-
function (require, module) {
|
|
107
|
-
module.exports = exports;
|
|
108
|
-
},
|
|
109
|
-
{},
|
|
110
|
-
];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
Object.defineProperty(newRequire, 'root', {
|
|
114
|
-
get: function () {
|
|
115
|
-
return globalObject[parcelRequireName];
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
globalObject[parcelRequireName] = newRequire;
|
|
120
|
-
|
|
121
|
-
for (var i = 0; i < entry.length; i++) {
|
|
122
|
-
newRequire(entry[i]);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (mainEntry) {
|
|
126
|
-
// Expose entry point to Node, AMD or browser globals
|
|
127
|
-
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
|
128
|
-
var mainExports = newRequire(mainEntry);
|
|
129
|
-
|
|
130
|
-
// CommonJS
|
|
131
|
-
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
132
|
-
module.exports = mainExports;
|
|
133
|
-
|
|
134
|
-
// RequireJS
|
|
135
|
-
} else if (typeof define === 'function' && define.amd) {
|
|
136
|
-
define(function () {
|
|
137
|
-
return mainExports;
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// <script>
|
|
141
|
-
} else if (globalName) {
|
|
142
|
-
this[globalName] = mainExports;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
})({"gAaC1":[function(require,module,exports) {
|
|
146
|
-
var global = arguments[3];
|
|
147
|
-
var HMR_HOST = null;
|
|
148
|
-
var HMR_PORT = null;
|
|
149
|
-
var HMR_SECURE = false;
|
|
150
|
-
var HMR_ENV_HASH = "d6ea1d42532a7575";
|
|
151
|
-
module.bundle.HMR_BUNDLE_ID = "64a677193bb9b3f5";
|
|
152
|
-
"use strict";
|
|
153
|
-
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */ /*::
|
|
154
|
-
import type {
|
|
155
|
-
HMRAsset,
|
|
156
|
-
HMRMessage,
|
|
157
|
-
} from '@parcel/reporter-dev-server/src/HMRServer.js';
|
|
158
|
-
interface ParcelRequire {
|
|
159
|
-
(string): mixed;
|
|
160
|
-
cache: {|[string]: ParcelModule|};
|
|
161
|
-
hotData: {|[string]: mixed|};
|
|
162
|
-
Module: any;
|
|
163
|
-
parent: ?ParcelRequire;
|
|
164
|
-
isParcelRequire: true;
|
|
165
|
-
modules: {|[string]: [Function, {|[string]: string|}]|};
|
|
166
|
-
HMR_BUNDLE_ID: string;
|
|
167
|
-
root: ParcelRequire;
|
|
168
|
-
}
|
|
169
|
-
interface ParcelModule {
|
|
170
|
-
hot: {|
|
|
171
|
-
data: mixed,
|
|
172
|
-
accept(cb: (Function) => void): void,
|
|
173
|
-
dispose(cb: (mixed) => void): void,
|
|
174
|
-
// accept(deps: Array<string> | string, cb: (Function) => void): void,
|
|
175
|
-
// decline(): void,
|
|
176
|
-
_acceptCallbacks: Array<(Function) => void>,
|
|
177
|
-
_disposeCallbacks: Array<(mixed) => void>,
|
|
178
|
-
|};
|
|
179
|
-
}
|
|
180
|
-
interface ExtensionContext {
|
|
181
|
-
runtime: {|
|
|
182
|
-
reload(): void,
|
|
183
|
-
getURL(url: string): string;
|
|
184
|
-
getManifest(): {manifest_version: number, ...};
|
|
185
|
-
|};
|
|
186
|
-
}
|
|
187
|
-
declare var module: {bundle: ParcelRequire, ...};
|
|
188
|
-
declare var HMR_HOST: string;
|
|
189
|
-
declare var HMR_PORT: string;
|
|
190
|
-
declare var HMR_ENV_HASH: string;
|
|
191
|
-
declare var HMR_SECURE: boolean;
|
|
192
|
-
declare var chrome: ExtensionContext;
|
|
193
|
-
declare var browser: ExtensionContext;
|
|
194
|
-
declare var __parcel__import__: (string) => Promise<void>;
|
|
195
|
-
declare var __parcel__importScripts__: (string) => Promise<void>;
|
|
196
|
-
declare var globalThis: typeof self;
|
|
197
|
-
declare var ServiceWorkerGlobalScope: Object;
|
|
198
|
-
*/ var OVERLAY_ID = "__parcel__error__overlay__";
|
|
199
|
-
var OldModule = module.bundle.Module;
|
|
200
|
-
function Module(moduleName) {
|
|
201
|
-
OldModule.call(this, moduleName);
|
|
202
|
-
this.hot = {
|
|
203
|
-
data: module.bundle.hotData[moduleName],
|
|
204
|
-
_acceptCallbacks: [],
|
|
205
|
-
_disposeCallbacks: [],
|
|
206
|
-
accept: function(fn) {
|
|
207
|
-
this._acceptCallbacks.push(fn || function() {});
|
|
208
|
-
},
|
|
209
|
-
dispose: function(fn) {
|
|
210
|
-
this._disposeCallbacks.push(fn);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
module.bundle.hotData[moduleName] = undefined;
|
|
214
|
-
}
|
|
215
|
-
module.bundle.Module = Module;
|
|
216
|
-
module.bundle.hotData = {};
|
|
217
|
-
var checkedAssets /*: {|[string]: boolean|} */ , assetsToDispose /*: Array<[ParcelRequire, string]> */ , assetsToAccept /*: Array<[ParcelRequire, string]> */ ;
|
|
218
|
-
function getHostname() {
|
|
219
|
-
return HMR_HOST || (location.protocol.indexOf("http") === 0 ? location.hostname : "localhost");
|
|
220
|
-
}
|
|
221
|
-
function getPort() {
|
|
222
|
-
return HMR_PORT || location.port;
|
|
223
|
-
}
|
|
224
|
-
// eslint-disable-next-line no-redeclare
|
|
225
|
-
var parent = module.bundle.parent;
|
|
226
|
-
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== "undefined") {
|
|
227
|
-
var hostname = getHostname();
|
|
228
|
-
var port = getPort();
|
|
229
|
-
var protocol = HMR_SECURE || location.protocol == "https:" && ![
|
|
230
|
-
"localhost",
|
|
231
|
-
"127.0.0.1",
|
|
232
|
-
"0.0.0.0"
|
|
233
|
-
].includes(hostname) ? "wss" : "ws";
|
|
234
|
-
var ws;
|
|
235
|
-
try {
|
|
236
|
-
ws = new WebSocket(protocol + "://" + hostname + (port ? ":" + port : "") + "/");
|
|
237
|
-
} catch (err) {
|
|
238
|
-
if (err.message) console.error(err.message);
|
|
239
|
-
ws = {};
|
|
240
|
-
}
|
|
241
|
-
// Web extension context
|
|
242
|
-
var extCtx = typeof browser === "undefined" ? typeof chrome === "undefined" ? null : chrome : browser;
|
|
243
|
-
// Safari doesn't support sourceURL in error stacks.
|
|
244
|
-
// eval may also be disabled via CSP, so do a quick check.
|
|
245
|
-
var supportsSourceURL = false;
|
|
246
|
-
try {
|
|
247
|
-
(0, eval)('throw new Error("test"); //# sourceURL=test.js');
|
|
248
|
-
} catch (err) {
|
|
249
|
-
supportsSourceURL = err.stack.includes("test.js");
|
|
250
|
-
}
|
|
251
|
-
// $FlowFixMe
|
|
252
|
-
ws.onmessage = async function(event /*: {data: string, ...} */ ) {
|
|
253
|
-
checkedAssets = {} /*: {|[string]: boolean|} */ ;
|
|
254
|
-
assetsToAccept = [];
|
|
255
|
-
assetsToDispose = [];
|
|
256
|
-
var data /*: HMRMessage */ = JSON.parse(event.data);
|
|
257
|
-
if (data.type === "update") {
|
|
258
|
-
// Remove error overlay if there is one
|
|
259
|
-
if (typeof document !== "undefined") removeErrorOverlay();
|
|
260
|
-
let assets = data.assets.filter((asset)=>asset.envHash === HMR_ENV_HASH);
|
|
261
|
-
// Handle HMR Update
|
|
262
|
-
let handled = assets.every((asset)=>{
|
|
263
|
-
return asset.type === "css" || asset.type === "js" && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle);
|
|
264
|
-
});
|
|
265
|
-
if (handled) {
|
|
266
|
-
console.clear();
|
|
267
|
-
// Dispatch custom event so other runtimes (e.g React Refresh) are aware.
|
|
268
|
-
if (typeof window !== "undefined" && typeof CustomEvent !== "undefined") window.dispatchEvent(new CustomEvent("parcelhmraccept"));
|
|
269
|
-
await hmrApplyUpdates(assets);
|
|
270
|
-
// Dispose all old assets.
|
|
271
|
-
let processedAssets = {} /*: {|[string]: boolean|} */ ;
|
|
272
|
-
for(let i = 0; i < assetsToDispose.length; i++){
|
|
273
|
-
let id = assetsToDispose[i][1];
|
|
274
|
-
if (!processedAssets[id]) {
|
|
275
|
-
hmrDispose(assetsToDispose[i][0], id);
|
|
276
|
-
processedAssets[id] = true;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Run accept callbacks. This will also re-execute other disposed assets in topological order.
|
|
280
|
-
processedAssets = {};
|
|
281
|
-
for(let i = 0; i < assetsToAccept.length; i++){
|
|
282
|
-
let id = assetsToAccept[i][1];
|
|
283
|
-
if (!processedAssets[id]) {
|
|
284
|
-
hmrAccept(assetsToAccept[i][0], id);
|
|
285
|
-
processedAssets[id] = true;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
} else fullReload();
|
|
289
|
-
}
|
|
290
|
-
if (data.type === "error") {
|
|
291
|
-
// Log parcel errors to console
|
|
292
|
-
for (let ansiDiagnostic of data.diagnostics.ansi){
|
|
293
|
-
let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
|
|
294
|
-
console.error("\uD83D\uDEA8 [parcel]: " + ansiDiagnostic.message + "\n" + stack + "\n\n" + ansiDiagnostic.hints.join("\n"));
|
|
295
|
-
}
|
|
296
|
-
if (typeof document !== "undefined") {
|
|
297
|
-
// Render the fancy html overlay
|
|
298
|
-
removeErrorOverlay();
|
|
299
|
-
var overlay = createErrorOverlay(data.diagnostics.html);
|
|
300
|
-
// $FlowFixMe
|
|
301
|
-
document.body.appendChild(overlay);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
ws.onerror = function(e) {
|
|
306
|
-
if (e.message) console.error(e.message);
|
|
307
|
-
};
|
|
308
|
-
ws.onclose = function() {
|
|
309
|
-
console.warn("[parcel] \uD83D\uDEA8 Connection to the HMR server was lost");
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function removeErrorOverlay() {
|
|
313
|
-
var overlay = document.getElementById(OVERLAY_ID);
|
|
314
|
-
if (overlay) {
|
|
315
|
-
overlay.remove();
|
|
316
|
-
console.log("[parcel] \u2728 Error resolved");
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function createErrorOverlay(diagnostics) {
|
|
320
|
-
var overlay = document.createElement("div");
|
|
321
|
-
overlay.id = OVERLAY_ID;
|
|
322
|
-
let errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">';
|
|
323
|
-
for (let diagnostic of diagnostics){
|
|
324
|
-
let stack = diagnostic.frames.length ? diagnostic.frames.reduce((p, frame)=>{
|
|
325
|
-
return `${p}
|
|
326
|
-
<a href="/__parcel_launch_editor?file=${encodeURIComponent(frame.location)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${frame.location}</a>
|
|
327
|
-
${frame.code}`;
|
|
328
|
-
}, "") : diagnostic.stack;
|
|
329
|
-
errorHTML += `
|
|
330
|
-
<div>
|
|
331
|
-
<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">
|
|
332
|
-
\u{1F6A8} ${diagnostic.message}
|
|
333
|
-
</div>
|
|
334
|
-
<pre>${stack}</pre>
|
|
335
|
-
<div>
|
|
336
|
-
${diagnostic.hints.map((hint)=>"<div>\uD83D\uDCA1 " + hint + "</div>").join("")}
|
|
337
|
-
</div>
|
|
338
|
-
${diagnostic.documentation ? `<div>\u{1F4DD} <a style="color: violet" href="${diagnostic.documentation}" target="_blank">Learn more</a></div>` : ""}
|
|
339
|
-
</div>
|
|
340
|
-
`;
|
|
341
|
-
}
|
|
342
|
-
errorHTML += "</div>";
|
|
343
|
-
overlay.innerHTML = errorHTML;
|
|
344
|
-
return overlay;
|
|
345
|
-
}
|
|
346
|
-
function fullReload() {
|
|
347
|
-
if ("reload" in location) location.reload();
|
|
348
|
-
else if (extCtx && extCtx.runtime && extCtx.runtime.reload) extCtx.runtime.reload();
|
|
349
|
-
}
|
|
350
|
-
function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
|
|
351
|
-
var modules = bundle.modules;
|
|
352
|
-
if (!modules) return [];
|
|
353
|
-
var parents = [];
|
|
354
|
-
var k, d, dep;
|
|
355
|
-
for(k in modules)for(d in modules[k][1]){
|
|
356
|
-
dep = modules[k][1][d];
|
|
357
|
-
if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) parents.push([
|
|
358
|
-
bundle,
|
|
359
|
-
k
|
|
360
|
-
]);
|
|
361
|
-
}
|
|
362
|
-
if (bundle.parent) parents = parents.concat(getParents(bundle.parent, id));
|
|
363
|
-
return parents;
|
|
364
|
-
}
|
|
365
|
-
function updateLink(link) {
|
|
366
|
-
var href = link.getAttribute("href");
|
|
367
|
-
if (!href) return;
|
|
368
|
-
var newLink = link.cloneNode();
|
|
369
|
-
newLink.onload = function() {
|
|
370
|
-
if (link.parentNode !== null) // $FlowFixMe
|
|
371
|
-
link.parentNode.removeChild(link);
|
|
372
|
-
};
|
|
373
|
-
newLink.setAttribute("href", // $FlowFixMe
|
|
374
|
-
href.split("?")[0] + "?" + Date.now());
|
|
375
|
-
// $FlowFixMe
|
|
376
|
-
link.parentNode.insertBefore(newLink, link.nextSibling);
|
|
377
|
-
}
|
|
378
|
-
var cssTimeout = null;
|
|
379
|
-
function reloadCSS() {
|
|
380
|
-
if (cssTimeout) return;
|
|
381
|
-
cssTimeout = setTimeout(function() {
|
|
382
|
-
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
|
383
|
-
for(var i = 0; i < links.length; i++){
|
|
384
|
-
// $FlowFixMe[incompatible-type]
|
|
385
|
-
var href /*: string */ = links[i].getAttribute("href");
|
|
386
|
-
var hostname = getHostname();
|
|
387
|
-
var servedFromHMRServer = hostname === "localhost" ? new RegExp("^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):" + getPort()).test(href) : href.indexOf(hostname + ":" + getPort());
|
|
388
|
-
var absolute = /^https?:\/\//i.test(href) && href.indexOf(location.origin) !== 0 && !servedFromHMRServer;
|
|
389
|
-
if (!absolute) updateLink(links[i]);
|
|
390
|
-
}
|
|
391
|
-
cssTimeout = null;
|
|
392
|
-
}, 50);
|
|
393
|
-
}
|
|
394
|
-
function hmrDownload(asset) {
|
|
395
|
-
if (asset.type === "js") {
|
|
396
|
-
if (typeof document !== "undefined") {
|
|
397
|
-
let script = document.createElement("script");
|
|
398
|
-
script.src = asset.url + "?t=" + Date.now();
|
|
399
|
-
if (asset.outputFormat === "esmodule") script.type = "module";
|
|
400
|
-
return new Promise((resolve, reject)=>{
|
|
401
|
-
var _document$head;
|
|
402
|
-
script.onload = ()=>resolve(script);
|
|
403
|
-
script.onerror = reject;
|
|
404
|
-
(_document$head = document.head) === null || _document$head === void 0 || _document$head.appendChild(script);
|
|
405
|
-
});
|
|
406
|
-
} else if (typeof importScripts === "function") {
|
|
407
|
-
// Worker scripts
|
|
408
|
-
if (asset.outputFormat === "esmodule") return import(asset.url + "?t=" + Date.now());
|
|
409
|
-
else return new Promise((resolve, reject)=>{
|
|
410
|
-
try {
|
|
411
|
-
importScripts(asset.url + "?t=" + Date.now());
|
|
412
|
-
resolve();
|
|
413
|
-
} catch (err) {
|
|
414
|
-
reject(err);
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
async function hmrApplyUpdates(assets) {
|
|
421
|
-
global.parcelHotUpdate = Object.create(null);
|
|
422
|
-
let scriptsToRemove;
|
|
423
|
-
try {
|
|
424
|
-
// If sourceURL comments aren't supported in eval, we need to load
|
|
425
|
-
// the update from the dev server over HTTP so that stack traces
|
|
426
|
-
// are correct in errors/logs. This is much slower than eval, so
|
|
427
|
-
// we only do it if needed (currently just Safari).
|
|
428
|
-
// https://bugs.webkit.org/show_bug.cgi?id=137297
|
|
429
|
-
// This path is also taken if a CSP disallows eval.
|
|
430
|
-
if (!supportsSourceURL) {
|
|
431
|
-
let promises = assets.map((asset)=>{
|
|
432
|
-
var _hmrDownload;
|
|
433
|
-
return (_hmrDownload = hmrDownload(asset)) === null || _hmrDownload === void 0 ? void 0 : _hmrDownload.catch((err)=>{
|
|
434
|
-
// Web extension fix
|
|
435
|
-
if (extCtx && extCtx.runtime && extCtx.runtime.getManifest().manifest_version == 3 && typeof ServiceWorkerGlobalScope != "undefined" && global instanceof ServiceWorkerGlobalScope) {
|
|
436
|
-
extCtx.runtime.reload();
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
throw err;
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
scriptsToRemove = await Promise.all(promises);
|
|
443
|
-
}
|
|
444
|
-
assets.forEach(function(asset) {
|
|
445
|
-
hmrApply(module.bundle.root, asset);
|
|
446
|
-
});
|
|
447
|
-
} finally{
|
|
448
|
-
delete global.parcelHotUpdate;
|
|
449
|
-
if (scriptsToRemove) scriptsToRemove.forEach((script)=>{
|
|
450
|
-
if (script) {
|
|
451
|
-
var _document$head2;
|
|
452
|
-
(_document$head2 = document.head) === null || _document$head2 === void 0 || _document$head2.removeChild(script);
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function hmrApply(bundle /*: ParcelRequire */ , asset /*: HMRAsset */ ) {
|
|
458
|
-
var modules = bundle.modules;
|
|
459
|
-
if (!modules) return;
|
|
460
|
-
if (asset.type === "css") reloadCSS();
|
|
461
|
-
else if (asset.type === "js") {
|
|
462
|
-
let deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID];
|
|
463
|
-
if (deps) {
|
|
464
|
-
if (modules[asset.id]) {
|
|
465
|
-
// Remove dependencies that are removed and will become orphaned.
|
|
466
|
-
// This is necessary so that if the asset is added back again, the cache is gone, and we prevent a full page reload.
|
|
467
|
-
let oldDeps = modules[asset.id][1];
|
|
468
|
-
for(let dep in oldDeps)if (!deps[dep] || deps[dep] !== oldDeps[dep]) {
|
|
469
|
-
let id = oldDeps[dep];
|
|
470
|
-
let parents = getParents(module.bundle.root, id);
|
|
471
|
-
if (parents.length === 1) hmrDelete(module.bundle.root, id);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (supportsSourceURL) // Global eval. We would use `new Function` here but browser
|
|
475
|
-
// support for source maps is better with eval.
|
|
476
|
-
(0, eval)(asset.output);
|
|
477
|
-
// $FlowFixMe
|
|
478
|
-
let fn = global.parcelHotUpdate[asset.id];
|
|
479
|
-
modules[asset.id] = [
|
|
480
|
-
fn,
|
|
481
|
-
deps
|
|
482
|
-
];
|
|
483
|
-
} else if (bundle.parent) hmrApply(bundle.parent, asset);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
function hmrDelete(bundle, id) {
|
|
487
|
-
let modules = bundle.modules;
|
|
488
|
-
if (!modules) return;
|
|
489
|
-
if (modules[id]) {
|
|
490
|
-
// Collect dependencies that will become orphaned when this module is deleted.
|
|
491
|
-
let deps = modules[id][1];
|
|
492
|
-
let orphans = [];
|
|
493
|
-
for(let dep in deps){
|
|
494
|
-
let parents = getParents(module.bundle.root, deps[dep]);
|
|
495
|
-
if (parents.length === 1) orphans.push(deps[dep]);
|
|
496
|
-
}
|
|
497
|
-
// Delete the module. This must be done before deleting dependencies in case of circular dependencies.
|
|
498
|
-
delete modules[id];
|
|
499
|
-
delete bundle.cache[id];
|
|
500
|
-
// Now delete the orphans.
|
|
501
|
-
orphans.forEach((id)=>{
|
|
502
|
-
hmrDelete(module.bundle.root, id);
|
|
503
|
-
});
|
|
504
|
-
} else if (bundle.parent) hmrDelete(bundle.parent, id);
|
|
505
|
-
}
|
|
506
|
-
function hmrAcceptCheck(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) {
|
|
507
|
-
if (hmrAcceptCheckOne(bundle, id, depsByBundle)) return true;
|
|
508
|
-
// Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload.
|
|
509
|
-
let parents = getParents(module.bundle.root, id);
|
|
510
|
-
let accepted = false;
|
|
511
|
-
while(parents.length > 0){
|
|
512
|
-
let v = parents.shift();
|
|
513
|
-
let a = hmrAcceptCheckOne(v[0], v[1], null);
|
|
514
|
-
if (a) // If this parent accepts, stop traversing upward, but still consider siblings.
|
|
515
|
-
accepted = true;
|
|
516
|
-
else {
|
|
517
|
-
// Otherwise, queue the parents in the next level upward.
|
|
518
|
-
let p = getParents(module.bundle.root, v[1]);
|
|
519
|
-
if (p.length === 0) {
|
|
520
|
-
// If there are no parents, then we've reached an entry without accepting. Reload.
|
|
521
|
-
accepted = false;
|
|
522
|
-
break;
|
|
523
|
-
}
|
|
524
|
-
parents.push(...p);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return accepted;
|
|
528
|
-
}
|
|
529
|
-
function hmrAcceptCheckOne(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) {
|
|
530
|
-
var modules = bundle.modules;
|
|
531
|
-
if (!modules) return;
|
|
532
|
-
if (depsByBundle && !depsByBundle[bundle.HMR_BUNDLE_ID]) {
|
|
533
|
-
// If we reached the root bundle without finding where the asset should go,
|
|
534
|
-
// there's nothing to do. Mark as "accepted" so we don't reload the page.
|
|
535
|
-
if (!bundle.parent) return true;
|
|
536
|
-
return hmrAcceptCheck(bundle.parent, id, depsByBundle);
|
|
537
|
-
}
|
|
538
|
-
if (checkedAssets[id]) return true;
|
|
539
|
-
checkedAssets[id] = true;
|
|
540
|
-
var cached = bundle.cache[id];
|
|
541
|
-
assetsToDispose.push([
|
|
542
|
-
bundle,
|
|
543
|
-
id
|
|
544
|
-
]);
|
|
545
|
-
if (!cached || cached.hot && cached.hot._acceptCallbacks.length) {
|
|
546
|
-
assetsToAccept.push([
|
|
547
|
-
bundle,
|
|
548
|
-
id
|
|
549
|
-
]);
|
|
550
|
-
return true;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
function hmrDispose(bundle /*: ParcelRequire */ , id /*: string */ ) {
|
|
554
|
-
var cached = bundle.cache[id];
|
|
555
|
-
bundle.hotData[id] = {};
|
|
556
|
-
if (cached && cached.hot) cached.hot.data = bundle.hotData[id];
|
|
557
|
-
if (cached && cached.hot && cached.hot._disposeCallbacks.length) cached.hot._disposeCallbacks.forEach(function(cb) {
|
|
558
|
-
cb(bundle.hotData[id]);
|
|
559
|
-
});
|
|
560
|
-
delete bundle.cache[id];
|
|
561
|
-
}
|
|
562
|
-
function hmrAccept(bundle /*: ParcelRequire */ , id /*: string */ ) {
|
|
563
|
-
// Execute the module.
|
|
564
|
-
bundle(id);
|
|
565
|
-
// Run the accept callbacks in the new version of the module.
|
|
566
|
-
var cached = bundle.cache[id];
|
|
567
|
-
if (cached && cached.hot && cached.hot._acceptCallbacks.length) cached.hot._acceptCallbacks.forEach(function(cb) {
|
|
568
|
-
var assetsToAlsoAccept = cb(function() {
|
|
569
|
-
return getParents(module.bundle.root, id);
|
|
570
|
-
});
|
|
571
|
-
if (assetsToAlsoAccept && assetsToAccept.length) {
|
|
572
|
-
assetsToAlsoAccept.forEach(function(a) {
|
|
573
|
-
hmrDispose(a[0], a[1]);
|
|
574
|
-
});
|
|
575
|
-
// $FlowFixMe[method-unbinding]
|
|
576
|
-
assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
},{}],"bAfYR":[function(require,module,exports) {
|
|
582
|
-
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
|
583
|
-
parcelHelpers.defineInteropFlag(exports);
|
|
584
|
-
parcelHelpers.export(exports, "render", ()=>render);
|
|
585
|
-
parcelHelpers.export(exports, "navigation", ()=>exports_navigation);
|
|
586
|
-
parcelHelpers.export(exports, "jsx", ()=>jsx_default);
|
|
587
|
-
parcelHelpers.export(exports, "createBus", ()=>createBus);
|
|
588
|
-
parcelHelpers.export(exports, "createApp", ()=>createApp);
|
|
589
|
-
parcelHelpers.export(exports, "bind", ()=>bind);
|
|
590
|
-
parcelHelpers.export(exports, "State", ()=>State);
|
|
591
|
-
var __defProp = Object.defineProperty;
|
|
592
|
-
var __export = (target, all)=>{
|
|
593
|
-
for(var name in all)__defProp(target, name, {
|
|
594
|
-
get: all[name],
|
|
595
|
-
enumerable: true,
|
|
596
|
-
configurable: true,
|
|
597
|
-
set: (newValue)=>all[name] = ()=>newValue
|
|
598
|
-
});
|
|
599
|
-
};
|
|
600
|
-
// src/rendering/dom/create.ts
|
|
601
|
-
var setAttributesOnElement = (element, attributes)=>{
|
|
602
|
-
for(const key in attributes){
|
|
603
|
-
if (key === "__self") continue;
|
|
604
|
-
if (key === "value") element.value = attributes[key];
|
|
605
|
-
else element.setAttribute(key, attributes[key]);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
var setEventsOnElement = (element, events, publish)=>{
|
|
609
|
-
const eventMaps = {};
|
|
610
|
-
for(const domEvent in events){
|
|
611
|
-
const eventName = events[domEvent];
|
|
612
|
-
const listener = (event)=>publish(eventName, event);
|
|
613
|
-
element.addEventListener(domEvent, listener);
|
|
614
|
-
eventMaps[domEvent] = {
|
|
615
|
-
domEvent,
|
|
616
|
-
busEvent: eventName,
|
|
617
|
-
listener
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
element.eventMaps = eventMaps;
|
|
621
|
-
};
|
|
622
|
-
var createNode = (type, document)=>{
|
|
623
|
-
document = document || window.document;
|
|
624
|
-
return document.createElement(type);
|
|
625
|
-
};
|
|
626
|
-
var createTextNode = (value, document)=>{
|
|
627
|
-
document = document || window.document;
|
|
628
|
-
return document.createTextNode(value);
|
|
629
|
-
};
|
|
630
|
-
var createDecoratedNode = (type, attributes, events, renderKit)=>{
|
|
631
|
-
const dom = createNode(type, renderKit.document);
|
|
632
|
-
setAttributesOnElement(dom, attributes);
|
|
633
|
-
setEventsOnElement(dom, events, renderKit.publish);
|
|
634
|
-
return dom;
|
|
635
|
-
};
|
|
636
|
-
// src/rendering/dom/attributesAndEvents.ts
|
|
637
|
-
var separateAttrsAndEvents = (combined, defaultValue = "")=>{
|
|
638
|
-
const attributes = {};
|
|
639
|
-
const events = {};
|
|
640
|
-
for(const key in combined){
|
|
641
|
-
const value = combined[key];
|
|
642
|
-
if (key.match(/^on.+/i)) {
|
|
643
|
-
const eventKey = key.slice(2).toLowerCase();
|
|
644
|
-
events[eventKey] = value;
|
|
645
|
-
} else attributes[key] = normalizeValueForKey(combined, key, defaultValue);
|
|
646
|
-
}
|
|
647
|
-
return {
|
|
648
|
-
attributes,
|
|
649
|
-
events
|
|
650
|
-
};
|
|
651
|
-
};
|
|
652
|
-
var normalizeValueForKey = (object, key, defaultValue = "")=>{
|
|
653
|
-
if (object[key] === undefined) return defaultValue;
|
|
654
|
-
return object[key];
|
|
655
|
-
};
|
|
656
|
-
// src/rendering/dom/svg.ts
|
|
657
|
-
var namespace = "http://www.w3.org/2000/svg";
|
|
658
|
-
var isSvgTag = (tagType)=>tagType === "svg";
|
|
659
|
-
var isSvg = (element)=>element.namespaceURI === namespace;
|
|
660
|
-
var createSvgNode = (type, attributes, renderKit)=>{
|
|
661
|
-
const document = renderKit && renderKit.document || window.document;
|
|
662
|
-
const node = document.createElementNS(namespace, type);
|
|
663
|
-
for(const key in attributes){
|
|
664
|
-
if (key === "__self" || key === "xmlns") continue;
|
|
665
|
-
node.setAttributeNS(null, key, attributes[key]);
|
|
666
|
-
}
|
|
667
|
-
return node;
|
|
668
|
-
};
|
|
669
|
-
// src/rendering/templates/text.ts
|
|
670
|
-
class TextTemplate {
|
|
671
|
-
value;
|
|
672
|
-
constructor(content){
|
|
673
|
-
this.value = content.toString();
|
|
674
|
-
}
|
|
675
|
-
render(renderKit) {
|
|
676
|
-
const textNode = createTextNode(this.value, renderKit.document);
|
|
677
|
-
if (!textNode) return [];
|
|
678
|
-
textNode.__jsx = "TextNode";
|
|
679
|
-
return [
|
|
680
|
-
textNode
|
|
681
|
-
];
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
// src/rendering/templates/children.ts
|
|
685
|
-
var ensureArray = (children)=>{
|
|
686
|
-
if (Array.isArray(children)) return children.flat();
|
|
687
|
-
if (!children) return [];
|
|
688
|
-
return [
|
|
689
|
-
children
|
|
690
|
-
];
|
|
691
|
-
};
|
|
692
|
-
var recursiveRender = (children, renderKit, rendered = [])=>children.reduce(renderReducer(renderKit), rendered).flat();
|
|
693
|
-
var renderReducer = (renderKit)=>(aggregate, view)=>{
|
|
694
|
-
if (!view) return aggregate;
|
|
695
|
-
if (Array.isArray(view)) {
|
|
696
|
-
const dom = recursiveRender(view, renderKit, aggregate);
|
|
697
|
-
return dom;
|
|
698
|
-
}
|
|
699
|
-
view.render(renderKit).forEach((template)=>aggregate.push(template));
|
|
700
|
-
return aggregate;
|
|
701
|
-
};
|
|
702
|
-
var replaceTextNodes = (child)=>{
|
|
703
|
-
if (isTextNode(child)) return textNode(child);
|
|
704
|
-
return child;
|
|
705
|
-
};
|
|
706
|
-
var isTextNode = (child)=>{
|
|
707
|
-
return typeof child === "string" || typeof child === "number";
|
|
708
|
-
};
|
|
709
|
-
var textNode = (content)=>{
|
|
710
|
-
return new TextTemplate(content);
|
|
711
|
-
};
|
|
712
|
-
var withSvgFlag = (isSvg2)=>(template)=>{
|
|
713
|
-
template && (template.isSvg = template.isSvg || isSvg2);
|
|
714
|
-
return template;
|
|
715
|
-
};
|
|
716
|
-
class Children {
|
|
717
|
-
collection;
|
|
718
|
-
parentElement;
|
|
719
|
-
isSvg;
|
|
720
|
-
constructor(jsxChildren, isSvg2 = false){
|
|
721
|
-
this.collection = ensureArray(jsxChildren);
|
|
722
|
-
this.collection = this.collection.map(replaceTextNodes);
|
|
723
|
-
this.collection = this.collection.flat();
|
|
724
|
-
this.collection = this.collection.map(withSvgFlag(isSvg2));
|
|
725
|
-
this.isSvg = isSvg2;
|
|
726
|
-
}
|
|
727
|
-
render(renderKit, parentElement) {
|
|
728
|
-
this.parentElement = parentElement;
|
|
729
|
-
const dom = this.generateDom(renderKit);
|
|
730
|
-
this.attachToParent(dom);
|
|
731
|
-
return dom;
|
|
732
|
-
}
|
|
733
|
-
generateDom(renderKit) {
|
|
734
|
-
return recursiveRender(this.collection, renderKit);
|
|
735
|
-
}
|
|
736
|
-
attachToParent(dom) {
|
|
737
|
-
if (this.parentElement === undefined) return;
|
|
738
|
-
const parent = this.parentElement;
|
|
739
|
-
dom.forEach((node)=>parent.appendChild(node));
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
// src/rendering/templates/tag.ts
|
|
743
|
-
class Tag {
|
|
744
|
-
type;
|
|
745
|
-
events;
|
|
746
|
-
attributes;
|
|
747
|
-
children;
|
|
748
|
-
isSvg;
|
|
749
|
-
constructor(tagType, combinedAttributes, children2, isSvg2 = false){
|
|
750
|
-
this.type = tagType;
|
|
751
|
-
const { events, attributes } = separateAttrsAndEvents(combinedAttributes);
|
|
752
|
-
this.events = events;
|
|
753
|
-
this.attributes = attributes;
|
|
754
|
-
this.isSvg = isSvg2 || isSvgTag(this.type);
|
|
755
|
-
this.children = new Children(children2, this.isSvg);
|
|
756
|
-
}
|
|
757
|
-
render(renderKit) {
|
|
758
|
-
const dom = this.generateDom(renderKit);
|
|
759
|
-
if (!dom) return [];
|
|
760
|
-
this.children.render(renderKit, dom);
|
|
761
|
-
return [
|
|
762
|
-
dom
|
|
763
|
-
];
|
|
764
|
-
}
|
|
765
|
-
generateDom(renderKit) {
|
|
766
|
-
if (this.isSvg) return this.generateSvnDom(renderKit);
|
|
767
|
-
else return this.generateHtmlDom(renderKit);
|
|
768
|
-
}
|
|
769
|
-
generateHtmlDom(renderKit) {
|
|
770
|
-
const node = createDecoratedNode(this.type, this.attributes, this.events, renderKit);
|
|
771
|
-
node.__jsx = this.key();
|
|
772
|
-
return node;
|
|
773
|
-
}
|
|
774
|
-
generateSvnDom(renderKit) {
|
|
775
|
-
const node = createSvgNode(this.type, this.attributes, renderKit);
|
|
776
|
-
node.__jsx = this.key();
|
|
777
|
-
return node;
|
|
778
|
-
}
|
|
779
|
-
key() {
|
|
780
|
-
return this.attributes.key || this.source() || this.createKey();
|
|
781
|
-
}
|
|
782
|
-
source() {
|
|
783
|
-
if (this.attributes.__source) {
|
|
784
|
-
const { fileName, lineNumber, columnNumber } = this.attributes.__source;
|
|
785
|
-
return `${fileName}:${lineNumber}:${columnNumber}`;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
createKey() {
|
|
789
|
-
const id = this.attributes.id ? `#${this.attributes.id}` : "";
|
|
790
|
-
const type = this.attributes.type ? `[type=${this.attributes.type}]` : "";
|
|
791
|
-
const name = this.attributes.name ? `[name=${this.attributes.name}]` : "";
|
|
792
|
-
return `${this.type}${id}${type}${name}`;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
// src/jsx.js
|
|
796
|
-
var ensureChildrenArray = (maybeChildren, attributes)=>maybeChildren || attributes.children || [];
|
|
797
|
-
var packageAttributes = (maybeAttributes, maybeChildren)=>{
|
|
798
|
-
const attributes = maybeAttributes || {};
|
|
799
|
-
const children3 = ensureChildrenArray(maybeChildren, attributes);
|
|
800
|
-
attributes.children = attributes.children || children3;
|
|
801
|
-
return attributes;
|
|
802
|
-
};
|
|
803
|
-
var jsx = (type, attributes, ...children3)=>{
|
|
804
|
-
if (typeof type === "string") return new Tag(type, attributes, children3);
|
|
805
|
-
return type(packageAttributes(attributes, children3));
|
|
806
|
-
};
|
|
807
|
-
jsx.fragment = (attributes, maybeChildren)=>{
|
|
808
|
-
const children3 = ensureChildrenArray(maybeChildren, attributes);
|
|
809
|
-
return new Children(children3);
|
|
810
|
-
};
|
|
811
|
-
var jsx_default = jsx;
|
|
812
|
-
// src/rendering/templates/root.ts
|
|
813
|
-
class Root {
|
|
814
|
-
template;
|
|
815
|
-
selector;
|
|
816
|
-
renderKit;
|
|
817
|
-
dom;
|
|
818
|
-
parentElement;
|
|
819
|
-
constructor(template, selector, renderKit){
|
|
820
|
-
this.template = template;
|
|
821
|
-
this.selector = selector;
|
|
822
|
-
this.renderKit = renderKit;
|
|
823
|
-
this.dom = [];
|
|
824
|
-
this.parentElement = null;
|
|
825
|
-
}
|
|
826
|
-
renderAndAttach(renderKit) {
|
|
827
|
-
this.parentElement = this.getParentElement();
|
|
828
|
-
this.dom = this.render({
|
|
829
|
-
...renderKit,
|
|
830
|
-
parent: this.parentElement
|
|
831
|
-
});
|
|
832
|
-
if (this.parentElement) this.attach();
|
|
833
|
-
}
|
|
834
|
-
render(renderKit) {
|
|
835
|
-
return this.template.render(renderKit);
|
|
836
|
-
}
|
|
837
|
-
attach() {
|
|
838
|
-
this.parentElement && (this.parentElement.innerHTML = "");
|
|
839
|
-
this.dom.forEach((element)=>{
|
|
840
|
-
this.parentElement && this.parentElement.appendChild(element);
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
getParentElement() {
|
|
844
|
-
return this.renderKit.document.querySelector(this.selector);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
var render = (template, selector, renderKit)=>{
|
|
848
|
-
const root = new Root(template, selector, renderKit);
|
|
849
|
-
root.renderAndAttach(renderKit);
|
|
850
|
-
return root;
|
|
851
|
-
};
|
|
852
|
-
// src/state/testingTypes.js
|
|
853
|
-
var isBoolean = (value)=>typeof value === "boolean";
|
|
854
|
-
var isNumber = (value)=>typeof value === "number";
|
|
855
|
-
var isString = (value)=>typeof value === "string";
|
|
856
|
-
var isArray = (value)=>Array.isArray(value);
|
|
857
|
-
var isObject = (value)=>value !== null && !isArray(value) && typeof value === "object";
|
|
858
|
-
// src/state/equality.js
|
|
859
|
-
var areElementEqual = (oldValue, newValue)=>oldValue === newValue;
|
|
860
|
-
var keyLengthSame = (oldValue, newValue)=>Object.keys(oldValue).length === Object.keys(newValue).length;
|
|
861
|
-
var areObjectsEqual = (oldValue, newValue)=>{
|
|
862
|
-
if (!(isObject(oldValue) && isObject(newValue))) return false;
|
|
863
|
-
if (!keyLengthSame(oldValue, newValue)) return false;
|
|
864
|
-
Object.keys(oldValue).every((key)=>{
|
|
865
|
-
const oldInnerValue = oldValue[key];
|
|
866
|
-
const newInnerValue = newValue[key];
|
|
867
|
-
return areEqual(oldInnerValue, newInnerValue);
|
|
868
|
-
});
|
|
869
|
-
};
|
|
870
|
-
var areArraysEqual = (oldValue, newValue)=>{
|
|
871
|
-
if (!(isArray(oldValue) && isArray(newValue))) return false;
|
|
872
|
-
if (oldValue.length !== newValue.length) return false;
|
|
873
|
-
oldValue.every((oldInnerValue, index)=>{
|
|
874
|
-
const newInnerValue = newValue[index];
|
|
875
|
-
return areEqual(oldInnerValue, newInnerValue);
|
|
876
|
-
});
|
|
877
|
-
};
|
|
878
|
-
var areEqual = (oldValue, newValue)=>{
|
|
879
|
-
if (isObject(oldValue)) return areObjectsEqual(oldValue, newValue);
|
|
880
|
-
if (isArray(oldValue)) return areArraysEqual(oldValue, newValue);
|
|
881
|
-
return areElementEqual(oldValue, newValue);
|
|
882
|
-
};
|
|
883
|
-
// src/state/stores.js
|
|
884
|
-
class GeneralStore {
|
|
885
|
-
nullEvent = {};
|
|
886
|
-
constructor({ name, value, parent }){
|
|
887
|
-
this.name = name;
|
|
888
|
-
this.value = value;
|
|
889
|
-
this.parent = parent;
|
|
890
|
-
this.initialState = value;
|
|
891
|
-
}
|
|
892
|
-
update(newValue) {
|
|
893
|
-
if (this.isEqual(newValue)) return;
|
|
894
|
-
this.value = newValue;
|
|
895
|
-
return this.parent.publish(this.event());
|
|
896
|
-
}
|
|
897
|
-
reset() {
|
|
898
|
-
this.update(this.initialState);
|
|
899
|
-
}
|
|
900
|
-
isEqual(newValue) {
|
|
901
|
-
return areElementEqual(this.value, newValue);
|
|
902
|
-
}
|
|
903
|
-
event() {
|
|
904
|
-
return {
|
|
905
|
-
name: this.name,
|
|
906
|
-
value: this.value
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
class BooleanStore extends GeneralStore {
|
|
911
|
-
toggle() {
|
|
912
|
-
this.update(!this.value);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
class NumericStore extends GeneralStore {
|
|
916
|
-
}
|
|
917
|
-
class StringStore extends GeneralStore {
|
|
918
|
-
}
|
|
919
|
-
class ListStore extends GeneralStore {
|
|
920
|
-
isEqual(newValue) {
|
|
921
|
-
return areArraysEqual(this.value, newValue);
|
|
922
|
-
}
|
|
923
|
-
push(newValue) {
|
|
924
|
-
const value = [
|
|
925
|
-
...this.value,
|
|
926
|
-
newValue
|
|
927
|
-
];
|
|
928
|
-
this.update(value);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
class RecordStore extends GeneralStore {
|
|
932
|
-
isEqual(newValue) {
|
|
933
|
-
return areObjectsEqual(this.value, newValue);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
// src/state.js
|
|
937
|
-
var eventPrefix = "state-change";
|
|
938
|
-
var eventName = (name)=>`${eventPrefix}:${name}`;
|
|
939
|
-
class State {
|
|
940
|
-
constructor(publish){
|
|
941
|
-
this.publisher = publish;
|
|
942
|
-
this.stores = {};
|
|
943
|
-
this.events = [];
|
|
944
|
-
this.transacting = false;
|
|
945
|
-
}
|
|
946
|
-
create(name, value) {
|
|
947
|
-
const StoreClass = this.storeTypeFor(value);
|
|
948
|
-
const store = new StoreClass({
|
|
949
|
-
name,
|
|
950
|
-
value,
|
|
951
|
-
parent: this
|
|
952
|
-
});
|
|
953
|
-
this.addStore(name, store);
|
|
954
|
-
}
|
|
955
|
-
add(store) {
|
|
956
|
-
const name = store.name;
|
|
957
|
-
this.addStore(name, store);
|
|
958
|
-
}
|
|
959
|
-
getStore(name) {
|
|
960
|
-
return this.stores[name];
|
|
961
|
-
}
|
|
962
|
-
addStore(name, store) {
|
|
963
|
-
this.stores[name] = store;
|
|
964
|
-
this[name] = store;
|
|
965
|
-
}
|
|
966
|
-
storeTypeFor(value) {
|
|
967
|
-
if (isArray(value)) return ListStore;
|
|
968
|
-
if (isObject(value)) return RecordStore;
|
|
969
|
-
if (isNumber(value)) return NumericStore;
|
|
970
|
-
if (isBoolean(value)) return BooleanStore;
|
|
971
|
-
if (isString(value)) return StringStore;
|
|
972
|
-
return GeneralStore;
|
|
973
|
-
}
|
|
974
|
-
publish(event) {
|
|
975
|
-
this.events.push(event);
|
|
976
|
-
if (!this.transacting) this.publishAll();
|
|
977
|
-
}
|
|
978
|
-
publishAll() {
|
|
979
|
-
const publishedStores = [];
|
|
980
|
-
this.events.reverse().forEach((event)=>{
|
|
981
|
-
const { name, value } = event;
|
|
982
|
-
if (!publishedStores.includes(name)) {
|
|
983
|
-
publishedStores.push(name);
|
|
984
|
-
this.publisher(`${eventPrefix}:${name}`, value);
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
this.events = [];
|
|
988
|
-
}
|
|
989
|
-
transaction(setter) {
|
|
990
|
-
this.transacting = true;
|
|
991
|
-
setter(this);
|
|
992
|
-
this.transacting = false;
|
|
993
|
-
this.publishAll();
|
|
994
|
-
}
|
|
995
|
-
value() {
|
|
996
|
-
return Object.keys(this.stores).reduce((valueObject, key)=>{
|
|
997
|
-
valueObject[key] = this.stores[key].value;
|
|
998
|
-
return valueObject;
|
|
999
|
-
}, {});
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
// src/types.ts
|
|
1003
|
-
var ChangeInstructions;
|
|
1004
|
-
(function(ChangeInstructions2) {
|
|
1005
|
-
ChangeInstructions2[ChangeInstructions2["removeNode"] = 0] = "removeNode";
|
|
1006
|
-
ChangeInstructions2[ChangeInstructions2["insertNode"] = 1] = "insertNode";
|
|
1007
|
-
ChangeInstructions2[ChangeInstructions2["replaceNode"] = 2] = "replaceNode";
|
|
1008
|
-
ChangeInstructions2[ChangeInstructions2["removeAttribute"] = 3] = "removeAttribute";
|
|
1009
|
-
ChangeInstructions2[ChangeInstructions2["addAttribute"] = 4] = "addAttribute";
|
|
1010
|
-
ChangeInstructions2[ChangeInstructions2["updateAttribute"] = 5] = "updateAttribute";
|
|
1011
|
-
ChangeInstructions2[ChangeInstructions2["removeEvent"] = 6] = "removeEvent";
|
|
1012
|
-
ChangeInstructions2[ChangeInstructions2["addEvent"] = 7] = "addEvent";
|
|
1013
|
-
ChangeInstructions2[ChangeInstructions2["updateEvent"] = 8] = "updateEvent";
|
|
1014
|
-
ChangeInstructions2[ChangeInstructions2["changeValue"] = 9] = "changeValue";
|
|
1015
|
-
ChangeInstructions2[ChangeInstructions2["changeText"] = 10] = "changeText";
|
|
1016
|
-
})(ChangeInstructions || (ChangeInstructions = {}));
|
|
1017
|
-
// src/rendering/change/instructions/generate.ts
|
|
1018
|
-
var changeText = (source, target)=>({
|
|
1019
|
-
source,
|
|
1020
|
-
target,
|
|
1021
|
-
type: ChangeInstructions.changeText,
|
|
1022
|
-
data: {}
|
|
1023
|
-
});
|
|
1024
|
-
var replaceNode = (source, target)=>({
|
|
1025
|
-
source,
|
|
1026
|
-
target,
|
|
1027
|
-
type: ChangeInstructions.replaceNode,
|
|
1028
|
-
data: {}
|
|
1029
|
-
});
|
|
1030
|
-
var removeAttribute = (source, target, data)=>({
|
|
1031
|
-
source,
|
|
1032
|
-
target,
|
|
1033
|
-
data,
|
|
1034
|
-
type: ChangeInstructions.removeAttribute
|
|
1035
|
-
});
|
|
1036
|
-
var addAttribute = (source, target, data)=>({
|
|
1037
|
-
source,
|
|
1038
|
-
target,
|
|
1039
|
-
data,
|
|
1040
|
-
type: ChangeInstructions.addAttribute
|
|
1041
|
-
});
|
|
1042
|
-
var updateAttribute = (source, target, data)=>({
|
|
1043
|
-
source,
|
|
1044
|
-
target,
|
|
1045
|
-
data,
|
|
1046
|
-
type: ChangeInstructions.updateAttribute
|
|
1047
|
-
});
|
|
1048
|
-
var removeEvent = (source, target, data)=>({
|
|
1049
|
-
source,
|
|
1050
|
-
target,
|
|
1051
|
-
data,
|
|
1052
|
-
type: ChangeInstructions.removeEvent
|
|
1053
|
-
});
|
|
1054
|
-
var addEvent = (source, target, data)=>({
|
|
1055
|
-
source,
|
|
1056
|
-
target,
|
|
1057
|
-
data,
|
|
1058
|
-
type: ChangeInstructions.addEvent
|
|
1059
|
-
});
|
|
1060
|
-
var updateEvent = (source, target, data)=>({
|
|
1061
|
-
source,
|
|
1062
|
-
target,
|
|
1063
|
-
data,
|
|
1064
|
-
type: ChangeInstructions.updateEvent
|
|
1065
|
-
});
|
|
1066
|
-
var removeNode = (source)=>({
|
|
1067
|
-
source,
|
|
1068
|
-
target: source,
|
|
1069
|
-
type: ChangeInstructions.removeNode,
|
|
1070
|
-
data: {}
|
|
1071
|
-
});
|
|
1072
|
-
var insertNode = (target, data)=>({
|
|
1073
|
-
target,
|
|
1074
|
-
source: target,
|
|
1075
|
-
type: ChangeInstructions.insertNode,
|
|
1076
|
-
data
|
|
1077
|
-
});
|
|
1078
|
-
var changeValue = (source, target, data)=>({
|
|
1079
|
-
source,
|
|
1080
|
-
target,
|
|
1081
|
-
type: ChangeInstructions.changeValue,
|
|
1082
|
-
data
|
|
1083
|
-
});
|
|
1084
|
-
// src/rendering/change/instructions/idMap.js
|
|
1085
|
-
var nullMatch = {
|
|
1086
|
-
index: -1
|
|
1087
|
-
};
|
|
1088
|
-
class IdMap {
|
|
1089
|
-
constructor(){
|
|
1090
|
-
this.map = {};
|
|
1091
|
-
}
|
|
1092
|
-
populate(list) {
|
|
1093
|
-
list.forEach((element, i)=>{
|
|
1094
|
-
const id = element.__jsx;
|
|
1095
|
-
if (id) {
|
|
1096
|
-
this.map[id] = this.map[id] || [];
|
|
1097
|
-
this.map[id].push({
|
|
1098
|
-
element,
|
|
1099
|
-
index: i
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
pullMatch(element) {
|
|
1105
|
-
const id = element && element.__jsx;
|
|
1106
|
-
if (!id) return nullMatch;
|
|
1107
|
-
if (!(this.map[id] && this.map[id].length)) return nullMatch;
|
|
1108
|
-
return this.map[id].shift();
|
|
1109
|
-
}
|
|
1110
|
-
clear(element) {
|
|
1111
|
-
const id = element && element.__jsx;
|
|
1112
|
-
if (!(id && this.map[id] && this.map[id].length)) return;
|
|
1113
|
-
const matches = this.map[id];
|
|
1114
|
-
this.map[id] = matches.reduce((collection, possibleMatch)=>{
|
|
1115
|
-
if (possibleMatch.element !== element) collection.push(possibleMatch);
|
|
1116
|
-
return collection;
|
|
1117
|
-
}, []);
|
|
1118
|
-
}
|
|
1119
|
-
check(element) {
|
|
1120
|
-
const id = element && element.__jsx;
|
|
1121
|
-
if (!(id && this.map[id])) return false;
|
|
1122
|
-
return this.map[id].length > 0;
|
|
1123
|
-
}
|
|
1124
|
-
remaining() {
|
|
1125
|
-
return Object.values(this.map).flat();
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
var createIdMap = (list)=>{
|
|
1129
|
-
const map = new IdMap;
|
|
1130
|
-
map.populate(list);
|
|
1131
|
-
return map;
|
|
1132
|
-
};
|
|
1133
|
-
// src/rendering/change/instructions/attributes.ts
|
|
1134
|
-
var compileForAttributes = (source, target, isSvg2 = false)=>{
|
|
1135
|
-
const instructions = [];
|
|
1136
|
-
const sourceAttributes = source.attributes;
|
|
1137
|
-
const sourceLength = sourceAttributes.length;
|
|
1138
|
-
const targetAttributes = target.attributes;
|
|
1139
|
-
const targetLength = targetAttributes.length;
|
|
1140
|
-
let index;
|
|
1141
|
-
let innerIndex;
|
|
1142
|
-
let matchingAttribute;
|
|
1143
|
-
for(index = 0; index < sourceLength; index++){
|
|
1144
|
-
matchingAttribute = null;
|
|
1145
|
-
const sourceAttribute = sourceAttributes.item(index);
|
|
1146
|
-
if (!sourceAttribute) continue;
|
|
1147
|
-
for(innerIndex = 0; innerIndex < targetLength; innerIndex++){
|
|
1148
|
-
const targetAttribute = targetAttributes.item(innerIndex);
|
|
1149
|
-
if (!targetAttribute) continue;
|
|
1150
|
-
if (sourceAttribute.name == targetAttribute.name) {
|
|
1151
|
-
matchingAttribute = targetAttribute;
|
|
1152
|
-
break;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
if (!matchingAttribute) instructions.push(removeAttribute(source, target, {
|
|
1156
|
-
name: sourceAttribute.name,
|
|
1157
|
-
isSvg: isSvg2
|
|
1158
|
-
}));
|
|
1159
|
-
else if (sourceAttribute.value !== matchingAttribute.value) instructions.push(updateAttribute(source, target, {
|
|
1160
|
-
name: sourceAttribute.name,
|
|
1161
|
-
value: matchingAttribute.value,
|
|
1162
|
-
isSvg: isSvg2
|
|
1163
|
-
}));
|
|
1164
|
-
}
|
|
1165
|
-
for(index = 0; index < targetLength; index++){
|
|
1166
|
-
matchingAttribute = null;
|
|
1167
|
-
const targetAttribute = targetAttributes.item(index);
|
|
1168
|
-
if (!targetAttribute) continue;
|
|
1169
|
-
for(innerIndex = 0; innerIndex < sourceLength; innerIndex++){
|
|
1170
|
-
const sourceAttribute = sourceAttributes.item(innerIndex);
|
|
1171
|
-
if (!sourceAttribute) continue;
|
|
1172
|
-
if (sourceAttribute.name == targetAttribute.name) {
|
|
1173
|
-
matchingAttribute = sourceAttribute;
|
|
1174
|
-
break;
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
if (!matchingAttribute) instructions.push(addAttribute(source, target, {
|
|
1178
|
-
name: targetAttribute.name,
|
|
1179
|
-
value: targetAttribute.value,
|
|
1180
|
-
isSvg: isSvg2
|
|
1181
|
-
}));
|
|
1182
|
-
}
|
|
1183
|
-
return instructions;
|
|
1184
|
-
};
|
|
1185
|
-
// src/rendering/change/instructions/events.ts
|
|
1186
|
-
var compileForEvents = (source, target)=>{
|
|
1187
|
-
const instructions = [];
|
|
1188
|
-
const sourceEventMaps = source.eventMaps;
|
|
1189
|
-
const targetEventMaps = target.eventMaps;
|
|
1190
|
-
const sourceDomEvents = Object.keys(sourceEventMaps);
|
|
1191
|
-
const targetDomEvents = Object.keys(targetEventMaps);
|
|
1192
|
-
sourceDomEvents.forEach((domEvent)=>{
|
|
1193
|
-
const sourceEventMap = sourceEventMaps[domEvent];
|
|
1194
|
-
const targetEventMap = targetEventMaps[domEvent];
|
|
1195
|
-
if (!targetEventMap) instructions.push(removeEvent(source, target, {
|
|
1196
|
-
name: sourceEventMap.domEvent,
|
|
1197
|
-
value: sourceEventMap.listener
|
|
1198
|
-
}));
|
|
1199
|
-
else if (targetEventMap.busEvent !== sourceEventMap.busEvent) instructions.push(updateEvent(source, target, {
|
|
1200
|
-
name: domEvent,
|
|
1201
|
-
targetValue: targetEventMap.listener,
|
|
1202
|
-
sourceValue: sourceEventMap.listener
|
|
1203
|
-
}));
|
|
1204
|
-
});
|
|
1205
|
-
targetDomEvents.forEach((domEvent)=>{
|
|
1206
|
-
const sourceEventMap = sourceEventMaps[domEvent];
|
|
1207
|
-
const targetEventMap = targetEventMaps[domEvent];
|
|
1208
|
-
if (!sourceEventMap) instructions.push(addEvent(source, target, {
|
|
1209
|
-
name: targetEventMap.domEvent,
|
|
1210
|
-
value: targetEventMap.listener
|
|
1211
|
-
}));
|
|
1212
|
-
});
|
|
1213
|
-
return instructions;
|
|
1214
|
-
};
|
|
1215
|
-
// src/rendering/change/instructions/element.ts
|
|
1216
|
-
var compileForElement = (source, target)=>{
|
|
1217
|
-
const attributeInstructions = compileForAttributes(source, target);
|
|
1218
|
-
const eventInstructions = compileForEvents(source, target);
|
|
1219
|
-
const valueInstructions = compileForInputValue(source, target);
|
|
1220
|
-
return attributeInstructions.concat(eventInstructions).concat(valueInstructions);
|
|
1221
|
-
};
|
|
1222
|
-
var compileForSvg = (source, target)=>{
|
|
1223
|
-
return compileForAttributes(source, target, true);
|
|
1224
|
-
};
|
|
1225
|
-
var compileForInputValue = (sourceElement, targetElement)=>{
|
|
1226
|
-
const instructions = [];
|
|
1227
|
-
if (sourceElement.tagName !== "INPUT") return instructions;
|
|
1228
|
-
const source = sourceElement;
|
|
1229
|
-
const target = targetElement;
|
|
1230
|
-
if (source.value !== target.value) instructions.push(changeValue(source, target, {
|
|
1231
|
-
name: "value",
|
|
1232
|
-
value: target.value
|
|
1233
|
-
}));
|
|
1234
|
-
return instructions;
|
|
1235
|
-
};
|
|
1236
|
-
// src/rendering/change/instructions/text.ts
|
|
1237
|
-
var compileForText = (source, target)=>{
|
|
1238
|
-
if (source.textContent !== target.textContent) return [
|
|
1239
|
-
changeText(source, target)
|
|
1240
|
-
];
|
|
1241
|
-
return [];
|
|
1242
|
-
};
|
|
1243
|
-
// src/rendering/change/instructions/node.ts
|
|
1244
|
-
var NodeTypes;
|
|
1245
|
-
(function(NodeTypes2) {
|
|
1246
|
-
NodeTypes2[NodeTypes2["ElementNode"] = 1] = "ElementNode";
|
|
1247
|
-
NodeTypes2[NodeTypes2["TextNode"] = 3] = "TextNode";
|
|
1248
|
-
})(NodeTypes || (NodeTypes = {}));
|
|
1249
|
-
var compileForNodeGenerator = (compileForCollection)=>(source, target)=>{
|
|
1250
|
-
let instructions = [];
|
|
1251
|
-
if (source.nodeType === NodeTypes.ElementNode && isSvg(source)) {
|
|
1252
|
-
const sourceElement = source;
|
|
1253
|
-
const targetElement = target;
|
|
1254
|
-
const baseInstructions = compileForSvg(sourceElement, targetElement);
|
|
1255
|
-
const childrenInstructions = compileForCollection(sourceElement.childNodes, targetElement.childNodes, sourceElement);
|
|
1256
|
-
instructions = baseInstructions.concat(childrenInstructions);
|
|
1257
|
-
} else if (source.nodeType === NodeTypes.ElementNode) {
|
|
1258
|
-
const sourceElement = source;
|
|
1259
|
-
const targetElement = target;
|
|
1260
|
-
const baseInstructions = compileForElement(sourceElement, targetElement);
|
|
1261
|
-
const childrenInstructions = compileForCollection(sourceElement.childNodes, targetElement.childNodes, sourceElement);
|
|
1262
|
-
instructions = baseInstructions.concat(childrenInstructions);
|
|
1263
|
-
} else if (source.nodeType === NodeTypes.TextNode) instructions = compileForText(source, target);
|
|
1264
|
-
return instructions;
|
|
1265
|
-
};
|
|
1266
|
-
// src/rendering/change/instructions/children.ts
|
|
1267
|
-
var compileChildren = (sourceList, targetList, parent)=>{
|
|
1268
|
-
const baseInstructions = [];
|
|
1269
|
-
const length = largerLength(sourceList, targetList);
|
|
1270
|
-
const sourceMap = createIdMap(sourceList);
|
|
1271
|
-
const targetMap = createIdMap(targetList);
|
|
1272
|
-
const nodesPairsToDiff = [];
|
|
1273
|
-
let index = 0;
|
|
1274
|
-
for(; index < length; index++){
|
|
1275
|
-
const source = sourceList[index];
|
|
1276
|
-
const target = targetList[index];
|
|
1277
|
-
if (target && targetMap.check(target)) {
|
|
1278
|
-
const matchingSource = sourceMap.pullMatch(target);
|
|
1279
|
-
targetMap.clear(target);
|
|
1280
|
-
if (matchingSource.element) {
|
|
1281
|
-
if (matchingSource.index !== index) baseInstructions.push(insertNode(matchingSource.element, {
|
|
1282
|
-
parent,
|
|
1283
|
-
index
|
|
1284
|
-
}));
|
|
1285
|
-
nodesPairsToDiff.push({
|
|
1286
|
-
source: matchingSource.element,
|
|
1287
|
-
target
|
|
1288
|
-
});
|
|
1289
|
-
} else if (source) {
|
|
1290
|
-
if (targetMap.check(source)) baseInstructions.push(insertNode(target, {
|
|
1291
|
-
parent,
|
|
1292
|
-
index
|
|
1293
|
-
}));
|
|
1294
|
-
else {
|
|
1295
|
-
sourceMap.clear(source);
|
|
1296
|
-
baseInstructions.push(replaceNode(source, target));
|
|
1297
|
-
}
|
|
1298
|
-
} else baseInstructions.push(insertNode(target, {
|
|
1299
|
-
parent,
|
|
1300
|
-
index
|
|
1301
|
-
}));
|
|
1302
|
-
} else if (source) {
|
|
1303
|
-
const matchingSource = sourceMap.pullMatch(source);
|
|
1304
|
-
if (matchingSource.element) baseInstructions.push(removeNode(source));
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
sourceMap.remaining().forEach(({ element: element2 })=>{
|
|
1308
|
-
baseInstructions.push(removeNode(element2));
|
|
1309
|
-
});
|
|
1310
|
-
const nodeInstructions = nodesPairsToDiff.reduce((collection, { source, target })=>{
|
|
1311
|
-
return collection.concat(compileForNode(source, target));
|
|
1312
|
-
}, []);
|
|
1313
|
-
return baseInstructions.concat(nodeInstructions).sort(instructionsSorter);
|
|
1314
|
-
};
|
|
1315
|
-
var instructionsSorter = (left, right)=>{
|
|
1316
|
-
if (left.type > right.type) return 1;
|
|
1317
|
-
if (left.type < right.type) return -1;
|
|
1318
|
-
return 0;
|
|
1319
|
-
};
|
|
1320
|
-
var largerLength = (sourceList, targetList)=>{
|
|
1321
|
-
const sourceLength = Array.from(sourceList).length;
|
|
1322
|
-
const targetLength = Array.from(targetList).length;
|
|
1323
|
-
return sourceLength > targetLength ? sourceLength : targetLength;
|
|
1324
|
-
};
|
|
1325
|
-
var compileForNode = compileForNodeGenerator(compileChildren);
|
|
1326
|
-
// src/rendering/change.ts
|
|
1327
|
-
var change = (source, target, parent)=>{
|
|
1328
|
-
const instructions = compileChildren(source, target, parent);
|
|
1329
|
-
instructions.forEach((instruction)=>{
|
|
1330
|
-
performInstruction(instruction);
|
|
1331
|
-
});
|
|
1332
|
-
};
|
|
1333
|
-
var performInstruction = (instruction)=>{
|
|
1334
|
-
const performer = performers[instruction.type] || noop;
|
|
1335
|
-
performer(instruction);
|
|
1336
|
-
};
|
|
1337
|
-
var noop = (_instruction)=>{};
|
|
1338
|
-
var changeText2 = (instruction)=>{
|
|
1339
|
-
const { source, target } = instruction;
|
|
1340
|
-
source.nodeValue = target.textContent;
|
|
1341
|
-
};
|
|
1342
|
-
var removeNode2 = (instruction)=>{
|
|
1343
|
-
const { source } = instruction;
|
|
1344
|
-
source.remove();
|
|
1345
|
-
};
|
|
1346
|
-
var insertNode2 = (instruction)=>{
|
|
1347
|
-
const { target, data } = instruction;
|
|
1348
|
-
const { parent, index } = data;
|
|
1349
|
-
const sibling = parent.childNodes[index];
|
|
1350
|
-
if (!sibling) parent.appendChild(target);
|
|
1351
|
-
else if (sibling && sibling !== target) parent.insertBefore(target, sibling);
|
|
1352
|
-
};
|
|
1353
|
-
var replaceNode2 = (instruction)=>{
|
|
1354
|
-
const { source, target } = instruction;
|
|
1355
|
-
source.replaceWith(target);
|
|
1356
|
-
};
|
|
1357
|
-
var removeAttribute2 = (instruction)=>{
|
|
1358
|
-
const { source, data } = instruction;
|
|
1359
|
-
const { name, isSvg: isSvg2 } = data;
|
|
1360
|
-
if (isSvg2) source.removeAttributeNS(null, name);
|
|
1361
|
-
else source.removeAttribute(name);
|
|
1362
|
-
};
|
|
1363
|
-
var addAttribute2 = (instruction)=>{
|
|
1364
|
-
const { source, data } = instruction;
|
|
1365
|
-
const { name, value, isSvg: isSvg2 } = data;
|
|
1366
|
-
if (isSvg2) source.setAttributeNS(null, name, value);
|
|
1367
|
-
else source.setAttribute(name, value);
|
|
1368
|
-
};
|
|
1369
|
-
var updateAttribute2 = (instruction)=>{
|
|
1370
|
-
addAttribute2(instruction);
|
|
1371
|
-
};
|
|
1372
|
-
var removeEvent2 = (instruction)=>{
|
|
1373
|
-
const data = instruction.data;
|
|
1374
|
-
const source = instruction.source;
|
|
1375
|
-
const { name, value } = data;
|
|
1376
|
-
source.removeEventListener(name, value);
|
|
1377
|
-
};
|
|
1378
|
-
var addEvent2 = (instruction)=>{
|
|
1379
|
-
const data = instruction.data;
|
|
1380
|
-
const source = instruction.source;
|
|
1381
|
-
const { name, value } = data;
|
|
1382
|
-
source.addEventListener(name, value);
|
|
1383
|
-
};
|
|
1384
|
-
var updateEvent2 = (instruction)=>{
|
|
1385
|
-
const data = instruction.data;
|
|
1386
|
-
const source = instruction.source;
|
|
1387
|
-
const { name, sourceValue, targetValue } = data;
|
|
1388
|
-
source.removeEventListener(name, sourceValue);
|
|
1389
|
-
source.addEventListener(name, targetValue);
|
|
1390
|
-
};
|
|
1391
|
-
var changeValue2 = (instruction)=>{
|
|
1392
|
-
const data = instruction.data;
|
|
1393
|
-
const source = instruction.source;
|
|
1394
|
-
const { value } = data;
|
|
1395
|
-
source.value = value;
|
|
1396
|
-
};
|
|
1397
|
-
var performers = {
|
|
1398
|
-
[ChangeInstructions.changeText]: changeText2,
|
|
1399
|
-
[ChangeInstructions.removeNode]: removeNode2,
|
|
1400
|
-
[ChangeInstructions.insertNode]: insertNode2,
|
|
1401
|
-
[ChangeInstructions.replaceNode]: replaceNode2,
|
|
1402
|
-
[ChangeInstructions.removeAttribute]: removeAttribute2,
|
|
1403
|
-
[ChangeInstructions.addAttribute]: addAttribute2,
|
|
1404
|
-
[ChangeInstructions.updateAttribute]: updateAttribute2,
|
|
1405
|
-
[ChangeInstructions.removeEvent]: removeEvent2,
|
|
1406
|
-
[ChangeInstructions.addEvent]: addEvent2,
|
|
1407
|
-
[ChangeInstructions.updateEvent]: updateEvent2,
|
|
1408
|
-
[ChangeInstructions.changeValue]: changeValue2
|
|
1409
|
-
};
|
|
1410
|
-
// src/rendering/templates/bound.js
|
|
1411
|
-
var passThroughViewModel = (state2)=>state2;
|
|
1412
|
-
class Bound {
|
|
1413
|
-
constructor(TemplateClass, viewModel, subscriptions, attributes2){
|
|
1414
|
-
this.TemplateClass = TemplateClass;
|
|
1415
|
-
this.viewModel = viewModel || passThroughViewModel;
|
|
1416
|
-
this.attributes = attributes2 || {};
|
|
1417
|
-
this.subscriptions = subscriptions;
|
|
1418
|
-
this.dom = [];
|
|
1419
|
-
}
|
|
1420
|
-
render(renderKit) {
|
|
1421
|
-
this.parentElement = renderKit.parent;
|
|
1422
|
-
this.renderKit = renderKit;
|
|
1423
|
-
this.subscribeForRerender();
|
|
1424
|
-
this.dom = this._render(renderKit);
|
|
1425
|
-
return this.dom;
|
|
1426
|
-
}
|
|
1427
|
-
_render(renderKit) {
|
|
1428
|
-
const props = {
|
|
1429
|
-
...this.attributes,
|
|
1430
|
-
...this.viewModel(renderKit.state.value())
|
|
1431
|
-
};
|
|
1432
|
-
const template = this.TemplateClass(props);
|
|
1433
|
-
const dom = !template ? [] : template.render(renderKit);
|
|
1434
|
-
return dom;
|
|
1435
|
-
}
|
|
1436
|
-
rerender() {
|
|
1437
|
-
if (!this.parentElement) this.parentElement = this.dom[0] && this.dom[0].parentElement;
|
|
1438
|
-
const newDom = this._render(this.renderKit);
|
|
1439
|
-
change(this.dom, newDom, this.parentElement);
|
|
1440
|
-
if (this.parentElement) this.dom = Array.from(this.parentElement.childNodes);
|
|
1441
|
-
}
|
|
1442
|
-
subscribeForRerender() {
|
|
1443
|
-
this.subscriptions.forEach((storeName)=>{
|
|
1444
|
-
this.renderKit.subscribe(eventName(storeName), ()=>this.rerender());
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
var bind = ({ Template, viewModel, subscriptions })=>{
|
|
1449
|
-
subscriptions = subscriptions || [];
|
|
1450
|
-
return (attributes2)=>new Bound(Template, viewModel, subscriptions, attributes2);
|
|
1451
|
-
};
|
|
1452
|
-
// src/messageBus.ts
|
|
1453
|
-
class MessageBus {
|
|
1454
|
-
listeners;
|
|
1455
|
-
options;
|
|
1456
|
-
constructor(){
|
|
1457
|
-
this.options = {};
|
|
1458
|
-
this.listeners = {};
|
|
1459
|
-
}
|
|
1460
|
-
subscribe(eventName2, listener) {
|
|
1461
|
-
this.ensureListenerCollection(eventName2);
|
|
1462
|
-
this.listeners[eventName2].push(listener);
|
|
1463
|
-
}
|
|
1464
|
-
publish(eventName2, payload) {
|
|
1465
|
-
const listeners = this.listeners[eventName2];
|
|
1466
|
-
if (!listeners) return false;
|
|
1467
|
-
listeners.forEach((listener)=>{
|
|
1468
|
-
listener(payload, this.buildListenerKit(eventName2));
|
|
1469
|
-
});
|
|
1470
|
-
return true;
|
|
1471
|
-
}
|
|
1472
|
-
ensureListenerCollection(eventName2) {
|
|
1473
|
-
if (this.listeners[eventName2]) return;
|
|
1474
|
-
this.listeners[eventName2] = [];
|
|
1475
|
-
}
|
|
1476
|
-
buildListenerKit(eventName2) {
|
|
1477
|
-
return {
|
|
1478
|
-
eventName: eventName2,
|
|
1479
|
-
publish: this.publish.bind(this),
|
|
1480
|
-
...this.options
|
|
1481
|
-
};
|
|
1482
|
-
}
|
|
1483
|
-
addListenerOptions(options) {
|
|
1484
|
-
this.options = {
|
|
1485
|
-
...this.options,
|
|
1486
|
-
...options
|
|
1487
|
-
};
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
var createBus = ()=>{
|
|
1491
|
-
const bus = new MessageBus;
|
|
1492
|
-
const publish = bus.publish.bind(bus);
|
|
1493
|
-
const subscribe = bus.subscribe.bind(bus);
|
|
1494
|
-
return {
|
|
1495
|
-
bus,
|
|
1496
|
-
publish,
|
|
1497
|
-
subscribe
|
|
1498
|
-
};
|
|
1499
|
-
};
|
|
1500
|
-
// src/navigation/routeState.js
|
|
1501
|
-
var createRouteState = (state2)=>{
|
|
1502
|
-
const store = new RecordStore({
|
|
1503
|
-
name: "route",
|
|
1504
|
-
value: {
|
|
1505
|
-
host: "",
|
|
1506
|
-
path: "",
|
|
1507
|
-
query: ""
|
|
1508
|
-
},
|
|
1509
|
-
parent: state2
|
|
1510
|
-
});
|
|
1511
|
-
state2.add(store);
|
|
1512
|
-
};
|
|
1513
|
-
// src/navigation/setupHistory.js
|
|
1514
|
-
var locationChangeEvent = "locationChange";
|
|
1515
|
-
var routeChangeEvent = "routeChange";
|
|
1516
|
-
var extractQueryParams = (queryString)=>{
|
|
1517
|
-
return queryString.replace(/^\?/, "").split("&").reduce((aggregate, pairString)=>{
|
|
1518
|
-
if (!pairString) return aggregate;
|
|
1519
|
-
const pair = pairString.split("=");
|
|
1520
|
-
aggregate[pair[0]] = pair[1];
|
|
1521
|
-
return aggregate;
|
|
1522
|
-
}, {});
|
|
1523
|
-
};
|
|
1524
|
-
var onLocationChange = (_payload, { publish, state: state2 })=>{
|
|
1525
|
-
const { host, pathname, search } = window.location;
|
|
1526
|
-
const path = pathname;
|
|
1527
|
-
const query = extractQueryParams(search);
|
|
1528
|
-
state2.route.update({
|
|
1529
|
-
host,
|
|
1530
|
-
path,
|
|
1531
|
-
query
|
|
1532
|
-
});
|
|
1533
|
-
publish(routeChangeEvent, {
|
|
1534
|
-
host,
|
|
1535
|
-
path,
|
|
1536
|
-
query
|
|
1537
|
-
});
|
|
1538
|
-
};
|
|
1539
|
-
var setupHistory = (app)=>{
|
|
1540
|
-
const { publish, subscribe, state: state2 } = app;
|
|
1541
|
-
createRouteState(state2);
|
|
1542
|
-
window.addEventListener("popstate", ()=>publish(locationChangeEvent));
|
|
1543
|
-
subscribe(locationChangeEvent, onLocationChange);
|
|
1544
|
-
};
|
|
1545
|
-
// src/navigation/findHref.js
|
|
1546
|
-
var findHref = (node2)=>{
|
|
1547
|
-
if (!node2 || !node2.getAttribute) return "";
|
|
1548
|
-
while(!node2.getAttribute("href")){
|
|
1549
|
-
node2 = node2.parentNode;
|
|
1550
|
-
if (!node2 || !node2.getAttribute) return "";
|
|
1551
|
-
}
|
|
1552
|
-
return node2.getAttribute("href");
|
|
1553
|
-
};
|
|
1554
|
-
// src/navigation/setupNavigation.js
|
|
1555
|
-
var linkNavigationEvent = "goToHref";
|
|
1556
|
-
var programmaticNavigationEvent = "navigate";
|
|
1557
|
-
var navigate = (path, { publish })=>{
|
|
1558
|
-
window.history.pushState(null, "", path);
|
|
1559
|
-
publish(locationChangeEvent);
|
|
1560
|
-
};
|
|
1561
|
-
var onLinkClick = (domEvent, { publish })=>{
|
|
1562
|
-
if (!domEvent || !domEvent.target) return;
|
|
1563
|
-
domEvent.preventDefault();
|
|
1564
|
-
const href = findHref(domEvent.target);
|
|
1565
|
-
navigate(href, {
|
|
1566
|
-
publish
|
|
1567
|
-
});
|
|
1568
|
-
};
|
|
1569
|
-
var setupNavigation = (app)=>{
|
|
1570
|
-
const { subscribe } = app;
|
|
1571
|
-
subscribe(linkNavigationEvent, onLinkClick);
|
|
1572
|
-
subscribe(programmaticNavigationEvent, navigate);
|
|
1573
|
-
};
|
|
1574
|
-
// src/app.ts
|
|
1575
|
-
var setupBus = (app)=>{
|
|
1576
|
-
const { publish, subscribe, bus } = createBus();
|
|
1577
|
-
app.publish = publish;
|
|
1578
|
-
app.subscribe = subscribe;
|
|
1579
|
-
app.bus = bus;
|
|
1580
|
-
};
|
|
1581
|
-
var setupState = (app)=>{
|
|
1582
|
-
const state3 = new State(app.publish);
|
|
1583
|
-
app.state = state3;
|
|
1584
|
-
};
|
|
1585
|
-
var connectBusToState = (app)=>{
|
|
1586
|
-
const { bus } = app;
|
|
1587
|
-
bus.addListenerOptions({
|
|
1588
|
-
state: app.state
|
|
1589
|
-
});
|
|
1590
|
-
};
|
|
1591
|
-
var setupRenderKit = (app, document)=>{
|
|
1592
|
-
app.renderKit = {
|
|
1593
|
-
publish: app.publish,
|
|
1594
|
-
subscribe: app.subscribe,
|
|
1595
|
-
state: app.state,
|
|
1596
|
-
document
|
|
1597
|
-
};
|
|
1598
|
-
};
|
|
1599
|
-
var triggerRoute = (app)=>{
|
|
1600
|
-
const publish = app.publish;
|
|
1601
|
-
setTimeout(()=>{
|
|
1602
|
-
publish(locationChangeEvent, null);
|
|
1603
|
-
}, 0);
|
|
1604
|
-
};
|
|
1605
|
-
var addRender = (app)=>{
|
|
1606
|
-
app.render = (template, selector)=>{
|
|
1607
|
-
return render(template, selector, app.renderKit);
|
|
1608
|
-
};
|
|
1609
|
-
};
|
|
1610
|
-
var createApp = (document = window.document)=>{
|
|
1611
|
-
const app = {};
|
|
1612
|
-
setupBus(app);
|
|
1613
|
-
setupState(app);
|
|
1614
|
-
connectBusToState(app);
|
|
1615
|
-
setupRenderKit(app, document);
|
|
1616
|
-
setupHistory(app);
|
|
1617
|
-
setupNavigation(app);
|
|
1618
|
-
triggerRoute(app);
|
|
1619
|
-
addRender(app);
|
|
1620
|
-
return app;
|
|
1621
|
-
};
|
|
1622
|
-
// src/navigation.ts
|
|
1623
|
-
var exports_navigation = {};
|
|
1624
|
-
__export(exports_navigation, {
|
|
1625
|
-
setupNavigation: ()=>{
|
|
1626
|
-
return setupNavigation;
|
|
1627
|
-
},
|
|
1628
|
-
setupHistory: ()=>{
|
|
1629
|
-
return setupHistory;
|
|
1630
|
-
}
|
|
1631
|
-
});
|
|
1632
|
-
|
|
1633
|
-
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"gkKU3":[function(require,module,exports) {
|
|
1634
|
-
exports.interopDefault = function(a) {
|
|
1635
|
-
return a && a.__esModule ? a : {
|
|
1636
|
-
default: a
|
|
1637
|
-
};
|
|
1638
|
-
};
|
|
1639
|
-
exports.defineInteropFlag = function(a) {
|
|
1640
|
-
Object.defineProperty(a, "__esModule", {
|
|
1641
|
-
value: true
|
|
1642
|
-
});
|
|
1643
|
-
};
|
|
1644
|
-
exports.exportAll = function(source, dest) {
|
|
1645
|
-
Object.keys(source).forEach(function(key) {
|
|
1646
|
-
if (key === "default" || key === "__esModule" || Object.prototype.hasOwnProperty.call(dest, key)) return;
|
|
1647
|
-
Object.defineProperty(dest, key, {
|
|
1648
|
-
enumerable: true,
|
|
1649
|
-
get: function() {
|
|
1650
|
-
return source[key];
|
|
1651
|
-
}
|
|
1652
|
-
});
|
|
1653
|
-
});
|
|
1654
|
-
return dest;
|
|
1655
|
-
};
|
|
1656
|
-
exports.export = function(dest, destName, get) {
|
|
1657
|
-
Object.defineProperty(dest, destName, {
|
|
1658
|
-
enumerable: true,
|
|
1659
|
-
get: get
|
|
1660
|
-
});
|
|
1661
|
-
};
|
|
1662
|
-
|
|
1663
|
-
},{}]},["gAaC1"], null, "parcelRequireee15")
|
|
1664
|
-
|
|
1665
|
-
//# sourceMappingURL=add-remove-root-children.3bb9b3f5.js.map
|