aptechka 0.84.4 → 0.85.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/lib/{DerivedArray-BePrxcLC.js → DerivedArray-C1gHUvCT.js} +2 -2
- package/lib/{DerivedArray-xYBpcTp8.cjs → DerivedArray-CiMrwSDt.cjs} +1 -1
- package/lib/{DragControls-BgTBgiue.js → DragControls-BNaevZBQ.js} +23 -13
- package/lib/DragControls-XC4E7seK.cjs +1 -0
- package/lib/{LocalLinks-BdqYzt1b.js → LocalLinks-CI-vxMaR.js} +1 -1
- package/lib/{Tweened-DabaFaHX.js → Tweened-C1FsHjhN.js} +1 -1
- package/lib/animation/index.js +1 -1
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +1 -1
- package/lib/{easings-BSGJFMAo.js → easings-DE1AUrbN.js} +14 -14
- package/lib/jsx/h.d.ts +0 -3
- package/lib/jsx/hooks/component/useShadow.d.ts +1 -1
- package/lib/jsx/index.cjs +1 -1
- package/lib/jsx/index.js +12 -9
- package/lib/jsx/render.d.ts +1 -1
- package/lib/{layout-C26zkY7D.js → layout-BL6AX9-r.js} +3 -3
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.d.ts +2 -2
- package/lib/layout-box/index.js +11 -5
- package/lib/local-links/index.js +1 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +5 -2
- package/lib/{morph-BtgB1YQP.js → morph-BByLJAAh.js} +8 -8
- package/lib/need_redo_tweaker/TweakerFolderElement.d.ts +1 -1
- package/lib/need_redo_tweaker/index.cjs +2 -2
- package/lib/need_redo_tweaker/index.js +4 -8
- package/lib/promises-BsIKOEDq.js +13 -0
- package/lib/promises-nDm8_iG6.cjs +1 -0
- package/lib/{render-LpimRXgl.js → render-DHKcgkoZ.js} +22 -11
- package/lib/render-R8P4qkHo.cjs +1 -0
- package/lib/router/index.cjs +1 -1
- package/lib/router/index.js +2 -2
- package/lib/scroll/ScrollElement.d.ts +1 -1
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +9 -9
- package/lib/scroll-BtUpTUwr.cjs +1 -0
- package/lib/{scroll-DoNeuIgT.js → scroll-CHhF7Put.js} +10 -14
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +23 -5
- package/lib/spa/index.js +2 -2
- package/lib/store/index.cjs +1 -1
- package/lib/store/index.js +1 -1
- package/lib/utils/color.d.ts +1 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +142 -33
- package/lib/utils/lang.d.ts +6 -0
- package/lib/utils/loading.d.ts +1 -0
- package/lib/utils/progress.d.ts +2 -0
- package/lib/utils/scroll.d.ts +4 -2
- package/package.json +3 -3
- package/lib/DragControls-FmiuZDKq.cjs +0 -1
- package/lib/render-H9BjFLZ3.cjs +0 -1
- package/lib/scroll-D2tOpCnP.cjs +0 -1
|
@@ -15,10 +15,10 @@ import { connector } from "../connector/index.js";
|
|
|
15
15
|
import { c as camelToKebab, u as uncapitalize } from "../string-B3lm2b7v.js";
|
|
16
16
|
import { i as isESClass } from "../object-CiIdEmJx.js";
|
|
17
17
|
import { a as ViewportMediaRules } from "../Viewport-0n1C_IoN.js";
|
|
18
|
+
import { elementResizer } from "../element-resizer/index.js";
|
|
18
19
|
import { c as clamp } from "../math-r8V23YFe.js";
|
|
19
20
|
import { t as toStep } from "../number-DiVt2xnh.js";
|
|
20
21
|
import { n as nullishCoalescing } from "../polyfills-CG1XJNia.js";
|
|
21
|
-
import { elementResizer } from "../element-resizer/index.js";
|
|
22
22
|
import { g as getElementTransitionDurationMS } from "../style-DBoQWK0d.js";
|
|
23
23
|
const knownSvgTags = /* @__PURE__ */ new Set([
|
|
24
24
|
// 'a', 'style', 'title', 'script',
|
|
@@ -887,7 +887,7 @@ _inputElements = new WeakMap(), _knobElements = new WeakMap(), _step = new WeakM
|
|
|
887
887
|
}, "#updateKnobPositions"), getDistance_fn = /* @__PURE__ */ __name(function() {
|
|
888
888
|
return __privateGet(this, _isFinite) ? __privateGet(this, _max) - __privateGet(this, _min) : 0;
|
|
889
889
|
}, "#getDistance"), getKnobPosition_fn = /* @__PURE__ */ __name(function(knobElement, inputValue) {
|
|
890
|
-
const parentElement = knobElement.parentElement, distance = __privateMethod(this, _TweakerNumberManagerElement_instances, getDistance_fn).call(this), progress = distance ?
|
|
890
|
+
const parentElement = knobElement.parentElement, distance = __privateMethod(this, _TweakerNumberManagerElement_instances, getDistance_fn).call(this), normalizedValue = inputValue - __privateGet(this, _min), progress = distance ? normalizedValue / distance : 0.5;
|
|
891
891
|
return (parentElement.offsetWidth - knobElement.offsetWidth) * progress;
|
|
892
892
|
}, "#getKnobPosition"), _resizeListener = new WeakMap(), __name(_TweakerNumberManagerElement, "TweakerNumberManagerElement");
|
|
893
893
|
let TweakerNumberManagerElement = _TweakerNumberManagerElement;
|
|
@@ -1437,9 +1437,6 @@ const stylesheet$1 = createStylesheet({
|
|
|
1437
1437
|
height: "0"
|
|
1438
1438
|
}
|
|
1439
1439
|
},
|
|
1440
|
-
":host(.transition-allowed) .body": {
|
|
1441
|
-
transition: "height var(--duration-short), display var(--duration-short) allow-discrete"
|
|
1442
|
-
},
|
|
1443
1440
|
":host(.opened) .body": {
|
|
1444
1441
|
height: "calc-size(auto)",
|
|
1445
1442
|
display: "block",
|
|
@@ -1456,10 +1453,9 @@ const stylesheet$1 = createStylesheet({
|
|
|
1456
1453
|
".arrow": {
|
|
1457
1454
|
width: "20px",
|
|
1458
1455
|
height: "20px",
|
|
1459
|
-
fill: aptechkaTheme.colorFont.var
|
|
1460
|
-
transition: "transform var(--duration-short)"
|
|
1456
|
+
fill: aptechkaTheme.colorFont.var
|
|
1461
1457
|
},
|
|
1462
|
-
".opened .arrow": {
|
|
1458
|
+
":host(.opened) .arrow": {
|
|
1463
1459
|
transform: "scaleY(-1)"
|
|
1464
1460
|
}
|
|
1465
1461
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
3
|
+
function wait(dur) {
|
|
4
|
+
return new Promise((res) => {
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
res();
|
|
7
|
+
}, dur);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
__name(wait, "wait");
|
|
11
|
+
export {
|
|
12
|
+
wait as w
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});function wait(dur){return new Promise(res=>{setTimeout(()=>{res()},dur)})}__name(wait,"wait");exports.wait=wait;
|
|
@@ -16,17 +16,20 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
16
16
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
17
17
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
18
18
|
import { S as Store } from "./Store-BRTHeZmO.js";
|
|
19
|
+
import { g as getElementAttributesAdvanced } from "./attributes-FObgMNCf.js";
|
|
19
20
|
import { u as uncapitalize, c as camelToKebab } from "./string-B3lm2b7v.js";
|
|
20
|
-
import {
|
|
21
|
+
import { d as diff, p as patch } from "./morph-BByLJAAh.js";
|
|
21
22
|
import { i as isESClass } from "./object-CiIdEmJx.js";
|
|
22
23
|
import "construct-style-sheets-polyfill";
|
|
23
24
|
import { a as intersector } from "./index-ClTMVKJp.js";
|
|
24
25
|
import { connector } from "./connector/index.js";
|
|
25
|
-
import { a as DerivedKeyedArray } from "./DerivedArray-
|
|
26
|
+
import { a as DerivedKeyedArray } from "./DerivedArray-C1gHUvCT.js";
|
|
26
27
|
import "./css-value-parser/index.js";
|
|
27
28
|
import "./window-resizer/index.js";
|
|
28
29
|
import "./element-resizer/index.js";
|
|
29
|
-
const activeComponent = { current: null }
|
|
30
|
+
const activeComponent = { current: null };
|
|
31
|
+
let previousComponent = null;
|
|
32
|
+
const componentElementLoadingTypes = [
|
|
30
33
|
"idle",
|
|
31
34
|
"load",
|
|
32
35
|
"visible",
|
|
@@ -41,7 +44,7 @@ const _ComponentElement = class _ComponentElement extends HTMLElement {
|
|
|
41
44
|
__privateAdd(this, _loadCallback);
|
|
42
45
|
__privateAdd(this, _connectCallbacks, []);
|
|
43
46
|
__privateAdd(this, _disconnectCallbacks, []);
|
|
44
|
-
__privateAdd(this, _loadingType, "
|
|
47
|
+
__privateAdd(this, _loadingType, "idle");
|
|
45
48
|
__privateAdd(this, _idleId);
|
|
46
49
|
__privateAdd(this, _windowLoadListener, /* @__PURE__ */ __name(() => {
|
|
47
50
|
window.removeEventListener("load", __privateGet(this, _windowLoadListener)), __privateGet(this, _loadingType) === "load" && __privateMethod(this, _ComponentElement_instances, connect_fn).call(this);
|
|
@@ -52,7 +55,7 @@ const _ComponentElement = class _ComponentElement extends HTMLElement {
|
|
|
52
55
|
__privateAdd(this, _intersectionListener, /* @__PURE__ */ __name((entry) => {
|
|
53
56
|
entry.isIntersecting && (intersector.unsubscribe(__privateGet(this, _intersectionListener)), __privateGet(this, _loadingType) === "visible" && __privateMethod(this, _ComponentElement_instances, connect_fn).call(this));
|
|
54
57
|
}, "#intersectionListener"));
|
|
55
|
-
activeComponent.current = this;
|
|
58
|
+
previousComponent = activeComponent.current, activeComponent.current = this;
|
|
56
59
|
}
|
|
57
60
|
addLoadCallback(callback) {
|
|
58
61
|
this.hasAttribute("loading") && componentElementLoadingTypes.includes(
|
|
@@ -71,12 +74,12 @@ const _ComponentElement = class _ComponentElement extends HTMLElement {
|
|
|
71
74
|
const windowLoadSetup = /* @__PURE__ */ __name(() => {
|
|
72
75
|
document.readyState === "complete" ? __privateGet(this, _windowLoadListener).call(this) : window.addEventListener("load", __privateGet(this, _windowLoadListener));
|
|
73
76
|
}, "windowLoadSetup");
|
|
74
|
-
__privateGet(this, _loadingType) === "connect" || __privateGet(this, _loadingType) === "constructor" ? __privateMethod(this, _ComponentElement_instances, connect_fn).call(this) : __privateGet(this, _loadingType) === "load" ? windowLoadSetup() : __privateGet(this, _loadingType) === "idle" ? window.requestIdleCallback ? __privateSet(this, _idleId, window.requestIdleCallback(__privateGet(this, _idleListener))) : windowLoadSetup() : __privateGet(this, _loadingType) === "visible" && intersector.subscribe(this, __privateGet(this, _intersectionListener)), activeComponent.current === this && (activeComponent.current =
|
|
77
|
+
__privateGet(this, _loadingType) === "connect" || __privateGet(this, _loadingType) === "constructor" ? __privateMethod(this, _ComponentElement_instances, connect_fn).call(this) : __privateGet(this, _loadingType) === "load" ? windowLoadSetup() : __privateGet(this, _loadingType) === "idle" ? window.requestIdleCallback ? __privateSet(this, _idleId, window.requestIdleCallback(__privateGet(this, _idleListener))) : windowLoadSetup() : __privateGet(this, _loadingType) === "visible" && intersector.subscribe(this, __privateGet(this, _intersectionListener)), activeComponent.current === this && (activeComponent.current = previousComponent);
|
|
75
78
|
}
|
|
76
79
|
disconnectedCallback() {
|
|
77
80
|
__privateGet(this, _disconnectCallbacks).forEach((callback) => {
|
|
78
81
|
callback(this);
|
|
79
|
-
}), __privateSet(this, _connectCallbacks, []), __privateSet(this, _disconnectCallbacks, []), activeComponent.current === this && (activeComponent.current =
|
|
82
|
+
}), __privateSet(this, _connectCallbacks, []), __privateSet(this, _disconnectCallbacks, []), activeComponent.current === this && (activeComponent.current = previousComponent), window.removeEventListener("load", __privateGet(this, _windowLoadListener)), window.cancelIdleCallback && __privateGet(this, _idleId) && window.cancelIdleCallback(__privateGet(this, _idleId)), intersector.unsubscribe(__privateGet(this, _intersectionListener));
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
_loadCallback = new WeakMap(), _connectCallbacks = new WeakMap(), _disconnectCallbacks = new WeakMap(), _loadingType = new WeakMap(), _idleId = new WeakMap(), _windowLoadListener = new WeakMap(), _idleListener = new WeakMap(), _intersectionListener = new WeakMap(), _ComponentElement_instances = new WeakSet(), connect_fn = /* @__PURE__ */ __name(function() {
|
|
@@ -86,7 +89,7 @@ _loadCallback = new WeakMap(), _connectCallbacks = new WeakMap(), _disconnectCal
|
|
|
86
89
|
}), __privateGet(this, _loadingType) !== "constructor" && ((_a = __privateGet(this, _loadCallback)) == null || _a.call(this)), __privateGet(this, _connectCallbacks).forEach((callback) => {
|
|
87
90
|
const unsub = callback(this);
|
|
88
91
|
unsub && __privateGet(this, _disconnectCallbacks).push(unsub);
|
|
89
|
-
}), activeComponent.current === this && (activeComponent.current =
|
|
92
|
+
}), activeComponent.current === this && (activeComponent.current = previousComponent);
|
|
90
93
|
}, "#connect"), __name(_ComponentElement, "ComponentElement");
|
|
91
94
|
let ComponentElement = _ComponentElement;
|
|
92
95
|
function subscribeToStore(element, store, callback) {
|
|
@@ -282,16 +285,24 @@ function createClassElement(jsxTag, attributes, children) {
|
|
|
282
285
|
}
|
|
283
286
|
__name(createClassElement, "createClassElement");
|
|
284
287
|
function createCustomElement(jsxTag, attributes, children) {
|
|
285
|
-
const name = jsxTag.define || `e-${camelToKebab(jsxTag.name)}`, Constructor = getOrDefineCustomElement(name, jsxTag
|
|
288
|
+
const name = jsxTag.define || `e-${camelToKebab(jsxTag.name)}`, Constructor = getOrDefineCustomElement(name, jsxTag, attributes);
|
|
289
|
+
if (attributes != null && attributes.__onlyDefine)
|
|
290
|
+
return;
|
|
291
|
+
const id = generateElementId(jsxTag.name, attributes), element = getOrCreateElement(name, id, Constructor);
|
|
286
292
|
return fillComponentElement(element, jsxTag, attributes, children), element;
|
|
287
293
|
}
|
|
288
294
|
__name(createCustomElement, "createCustomElement");
|
|
289
|
-
function getOrDefineCustomElement(name, jsxTag) {
|
|
295
|
+
function getOrDefineCustomElement(name, jsxTag, attributes) {
|
|
290
296
|
var _a;
|
|
291
297
|
let Constructor = customElements.get(name);
|
|
292
298
|
return Constructor || (Constructor = (_a = class extends ComponentElement {
|
|
293
299
|
constructor() {
|
|
294
|
-
super()
|
|
300
|
+
super(), attributes != null && attributes.__onlyDefine && this.addLoadCallback(() => fillComponentElement(
|
|
301
|
+
this,
|
|
302
|
+
jsxTag,
|
|
303
|
+
getElementAttributesAdvanced(this),
|
|
304
|
+
[]
|
|
305
|
+
));
|
|
295
306
|
}
|
|
296
307
|
}, __name(_a, "Constructor"), _a.formAssociated = jsxTag.formAssociated, _a), customElements.define(name, Constructor)), Constructor;
|
|
297
308
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);const Store=require("./Store-DZnOrofs.cjs"),attributes=require("./attributes-BADnRZpK.cjs"),string=require("./string-CbRNzmd9.cjs"),morph=require("./morph-Buhxq-X0.cjs"),object=require("./object-DTY_W6xG.cjs");require("construct-style-sheets-polyfill");const intersector_index=require("./index-DZ44osDT.cjs"),connector_index=require("./connector/index.cjs"),DerivedArray=require("./DerivedArray-CiMrwSDt.cjs");require("./css-value-parser/index.cjs");require("./window-resizer/index.cjs");require("./element-resizer/index.cjs");const activeComponent={current:null};let previousComponent=null;const componentElementLoadingTypes=["idle","load","visible","constructor","connect"];var _loadCallback,_connectCallbacks,_disconnectCallbacks,_loadingType,_idleId,_windowLoadListener,_idleListener,_intersectionListener,_ComponentElement_instances,connect_fn;const _ComponentElement=class _ComponentElement extends HTMLElement{constructor(){super();__privateAdd(this,_ComponentElement_instances);__privateAdd(this,_loadCallback);__privateAdd(this,_connectCallbacks,[]);__privateAdd(this,_disconnectCallbacks,[]);__privateAdd(this,_loadingType,"idle");__privateAdd(this,_idleId);__privateAdd(this,_windowLoadListener,__name(()=>{window.removeEventListener("load",__privateGet(this,_windowLoadListener)),__privateGet(this,_loadingType)==="load"&&__privateMethod(this,_ComponentElement_instances,connect_fn).call(this)},"#windowLoadListener"));__privateAdd(this,_idleListener,__name(()=>{__privateSet(this,_idleId,void 0),__privateGet(this,_loadingType)==="idle"&&__privateMethod(this,_ComponentElement_instances,connect_fn).call(this)},"#idleListener"));__privateAdd(this,_intersectionListener,__name(entry=>{entry.isIntersecting&&(intersector_index.intersector.unsubscribe(__privateGet(this,_intersectionListener)),__privateGet(this,_loadingType)==="visible"&&__privateMethod(this,_ComponentElement_instances,connect_fn).call(this))},"#intersectionListener"));previousComponent=activeComponent.current,activeComponent.current=this}addLoadCallback(callback){this.hasAttribute("loading")&&componentElementLoadingTypes.includes(this.getAttribute("loading"))?__privateSet(this,_loadingType,this.getAttribute("loading")):__privateSet(this,_loadingType,"constructor"),__privateSet(this,_loadCallback,callback),__privateGet(this,_loadingType)==="constructor"&&__privateGet(this,_loadCallback).call(this)}addConnectCallback(callback){__privateGet(this,_connectCallbacks).push(callback)}addDisconnectCallback(callback){__privateGet(this,_disconnectCallbacks).push(callback)}connectedCallback(){const windowLoadSetup=__name(()=>{document.readyState==="complete"?__privateGet(this,_windowLoadListener).call(this):window.addEventListener("load",__privateGet(this,_windowLoadListener))},"windowLoadSetup");__privateGet(this,_loadingType)==="connect"||__privateGet(this,_loadingType)==="constructor"?__privateMethod(this,_ComponentElement_instances,connect_fn).call(this):__privateGet(this,_loadingType)==="load"?windowLoadSetup():__privateGet(this,_loadingType)==="idle"?window.requestIdleCallback?__privateSet(this,_idleId,window.requestIdleCallback(__privateGet(this,_idleListener))):windowLoadSetup():__privateGet(this,_loadingType)==="visible"&&intersector_index.intersector.subscribe(this,__privateGet(this,_intersectionListener)),activeComponent.current===this&&(activeComponent.current=previousComponent)}disconnectedCallback(){__privateGet(this,_disconnectCallbacks).forEach(callback=>{callback(this)}),__privateSet(this,_connectCallbacks,[]),__privateSet(this,_disconnectCallbacks,[]),activeComponent.current===this&&(activeComponent.current=previousComponent),window.removeEventListener("load",__privateGet(this,_windowLoadListener)),window.cancelIdleCallback&&__privateGet(this,_idleId)&&window.cancelIdleCallback(__privateGet(this,_idleId)),intersector_index.intersector.unsubscribe(__privateGet(this,_intersectionListener))}};_loadCallback=new WeakMap,_connectCallbacks=new WeakMap,_disconnectCallbacks=new WeakMap,_loadingType=new WeakMap,_idleId=new WeakMap,_windowLoadListener=new WeakMap,_idleListener=new WeakMap,_intersectionListener=new WeakMap,_ComponentElement_instances=new WeakSet,connect_fn=__name(function(){var _a;activeComponent.current=this,this.querySelectorAll("[data-fallback]").forEach(el=>{el.remove()}),__privateGet(this,_loadingType)!=="constructor"&&((_a=__privateGet(this,_loadCallback))==null||_a.call(this)),__privateGet(this,_connectCallbacks).forEach(callback=>{const unsub=callback(this);unsub&&__privateGet(this,_disconnectCallbacks).push(unsub)}),activeComponent.current===this&&(activeComponent.current=previousComponent)},"#connect"),__name(_ComponentElement,"ComponentElement");let ComponentElement=_ComponentElement;function subscribeToStore(element,store,callback){const unsubscribe=store.subscribe(e=>{callback(e)});connector_index.connector.subscribe(element,{disconnectCallback:__name(()=>{unsubscribe()},"disconnectCallback"),maxWaitSec:20,unsubscribeAfterDisconnect:!0})}__name(subscribeToStore,"subscribeToStore");function setClassAttribute(element,classes){classes&&(classes instanceof Store.Store?subscribeToStore(element,classes,e=>{e.previous&&element.classList.remove(e.previous.toString()),e.current&&element.classList.add(e.current.toString())}):typeof classes=="object"&&!Array.isArray(classes)?Object.entries(classes).forEach(([key,value])=>{value instanceof Store.Store?subscribeToStore(element,value,e=>{element.classList.toggle(key,!!e.current)}):value&&element.classList.add(key)}):Array.isArray(classes)?classes.forEach(item=>{typeof item=="string"?element.classList.add(item):setClassAttribute(element,item)}):classes.toString().split(" ").map(v=>element.classList.add(v.trim())))}__name(setClassAttribute,"setClassAttribute");function setStyleAttribute(element,value){value&&(typeof value=="object"?Object.entries(value).forEach(([key,value2])=>{value2 instanceof Store.Store?subscribeToStore(element,value2,e=>{var _a;element.style[key]=(_a=e.current)==null?void 0:_a.toString()}):(typeof value2=="number"||typeof value2=="string"||typeof value2=="boolean")&&(element.style[key]=value2.toString())}):typeof value=="string"&&(element.style=value))}__name(setStyleAttribute,"setStyleAttribute");function setAttribute(element,key,value){key==="ref"&&value?Array.isArray(value)?value.forEach(v=>{typeof v=="object"&&"value"in v&&(v.value=element)}):typeof value=="object"&&"value"in value&&(value.value=element):key==="className"||key==="class"?setClassAttribute(element,value):key==="style"?setStyleAttribute(element,value):key==="setHtml"&&value!=null?element.innerHTML=value:typeof value=="number"?key==="tabIndex"?element.setAttribute("tabindex",value.toString()):setAttribute(element,key,value.toString()):typeof value=="string"?key==="htmlFor"?element.setAttribute("for",value):element.setAttribute(key,value):typeof value=="boolean"?value?element.setAttribute(key,""):element.removeAttribute(key):value instanceof Store.Store&&subscribeToStore(element,value,e=>{key in element?element[key]=e.current:setAttribute(element,key,e.current)})}__name(setAttribute,"setAttribute");function setAttributes(ele,attributes2){for(const[key,value]of Object.entries(attributes2!=null?attributes2:{}))typeof value=="function"&&key.startsWith("on")?ele.addEventListener(string.uncapitalize(key.replace("on","")),value):setAttribute(ele,key,value)}__name(setAttributes,"setAttributes");function createElement(tag,isSVG){return tag==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):isSVG?document.createElementNS("http://www.w3.org/2000/svg",tag):document.createElement(tag)}__name(createElement,"createElement");function filterChildren(children){const filtered=[];return(Array.isArray(children)?children:[children]).forEach(child=>{child!=null&&(typeof child=="number"?filtered.push(child.toString()):Array.isArray(child)?child.forEach(c=>{filtered.push(...filterChildren(c))}):filtered.push(child))}),filtered}__name(filterChildren,"filterChildren");function hydrateTextNode(element,newChild,index){const existingChild=element.childNodes[index];existingChild&&existingChild.nodeType===Node.TEXT_NODE?existingChild.textContent!==String(newChild)&&(console.warn(`Hydration text mismatch: expected "${newChild}", got "${existingChild.textContent}"`),existingChild.textContent=String(newChild)):newChild!=null&&newChild!==""&&element.insertBefore(document.createTextNode(String(newChild)),element.childNodes[index]||null)}__name(hydrateTextNode,"hydrateTextNode");function storeChildren(element,store){const currentChildNodes=[...element.childNodes].filter(node=>node.__storeId===store.id),newChildren=store.current,newChildrenArray=Array.isArray(newChildren)?newChildren:[newChildren],newNodes=[];if(newChildrenArray.forEach(newChild=>{let newNode=null;typeof newChild=="boolean"||typeof newChild=="number"||typeof newChild=="string"?newNode=document.createTextNode(newChild.toString()):newChild instanceof Node&&(newNode=newChild),newNode&&(newNode.__storeId=store.id,newNodes.push(newNode))}),store instanceof DerivedArray.DerivedKeyedArray){const nodesToStay=[];newNodes.forEach((newNode,i)=>{const oldNode=currentChildNodes.find(oldNode2=>oldNode2.__key===newNode.__key);oldNode?oldNode.isEqualNode(newNode)?nodesToStay.push(oldNode):(oldNode.replaceWith(newNode),nodesToStay.push(newNode)):(nodesToStay.push(newNode),element.appendChild(newNode))}),currentChildNodes.forEach(currentNode=>{nodesToStay.includes(currentNode)||currentNode.remove()})}else newNodes.forEach((node,i)=>{var _a;const founded=currentChildNodes[i];if(founded)founded.isEqualNode(node)||(founded.replaceWith(node),currentChildNodes[i]=node);else{const lastChildNode=currentChildNodes[currentChildNodes.length-1];lastChildNode?(_a=lastChildNode.parentNode)==null||_a.insertBefore(node,lastChildNode.nextSibling):element.appendChild(node)}}),currentChildNodes.slice(newNodes.length).forEach(node=>{node.remove()})}__name(storeChildren,"storeChildren");const _Props=class _Props{constructor(tag,attributes2,children){this.tag=tag,this.attributes=attributes2,this.children=children}};__name(_Props,"Props");let Props=_Props;const _ComponentProps=class _ComponentProps extends Props{};__name(_ComponentProps,"ComponentProps");let ComponentProps=_ComponentProps;const _ElementProps=class _ElementProps extends Props{};__name(_ElementProps,"ElementProps");let ElementProps=_ElementProps;const _HeadProps=class _HeadProps extends Props{};__name(_HeadProps,"HeadProps");let HeadProps=_HeadProps;function appendChildren(element,attributes2,children,isSVG=!1){const filteredChildren=filterChildren(children);setAttributes(element,attributes2),filteredChildren.forEach((child,index)=>{handleChild(element,child,index,isSVG)})}__name(appendChildren,"appendChildren");function handleChild(element,child,index,isSVG){child instanceof Store.Store?handleStoreChild(element,child):child instanceof ComponentProps?handleComponentProps(element,child):child instanceof ElementProps?handleElementProps(element,child,index,isSVG):child instanceof HeadProps?handleHeadProps(child):handleTextNode(element,child,index)}__name(handleChild,"handleChild");function handleStoreChild(element,child){subscribeToStore(element,child,()=>{storeChildren(element,child)})}__name(handleStoreChild,"handleStoreChild");function handleComponentProps(element,child){child.tag==="shadow"&&element.shadowRoot?appendChildren(element.shadowRoot,child.attributes,child.children):appendChildren(element,child.attributes,child.children)}__name(handleComponentProps,"handleComponentProps");function handleElementProps(element,child,index,isSVG){let childElement=null;if(isHydrating.value){const existingChild=element.children[index];(existingChild==null?void 0:existingChild.nodeName.toLowerCase())===child.tag?(childElement=existingChild,appendChildren(childElement,child.attributes,child.children,isSVG)):(childElement=createElement(child.tag,isSVG),appendChildren(childElement,child.attributes,child.children,isSVG),element.append(childElement))}else childElement=createElement(child.tag,isSVG),appendChildren(childElement,child.attributes,child.children,isSVG),element.append(childElement)}__name(handleElementProps,"handleElementProps");function handleHeadProps(child){const headElement=document.createElement(child.tag);appendChildren(headElement,child.attributes,child.children);const patches=morph.diff(document.head,headElement);morph.patch(document.head,patches)}__name(handleHeadProps,"handleHeadProps");function handleTextNode(element,child,index){isHydrating.value?hydrateTextNode(element,child,index):element.append(child)}__name(handleTextNode,"handleTextNode");function processChildren(attributes2,children){let result=children.filter(Boolean).length?children:attributes2==null?void 0:attributes2.children;return result?result.flat(2):[]}__name(processChildren,"processChildren");function handleStringTag(tag,attributes2,children){switch(tag){case"component":case"shadow":return new ComponentProps(tag,attributes2,children);case"head":return new HeadProps(tag,attributes2,children);default:return new ElementProps(tag,attributes2,children)}}__name(handleStringTag,"handleStringTag");function handleFunctionTag(jsxTag,attributes2,children){return object.isESClass(jsxTag)?createClassElement(jsxTag,attributes2,children):jsxTag===Fragment?Fragment(children):jsxTag.template?jsxTag(__spreadValues({},attributes2)):createCustomElement(jsxTag,attributes2,children)}__name(handleFunctionTag,"handleFunctionTag");function createClassElement(jsxTag,attributes2,children){const element=new jsxTag;return appendChildren(element,attributes2,children),element}__name(createClassElement,"createClassElement");function createCustomElement(jsxTag,attributes2,children){const name=jsxTag.define||`e-${string.camelToKebab(jsxTag.name)}`,Constructor=getOrDefineCustomElement(name,jsxTag,attributes2);if(attributes2!=null&&attributes2.__onlyDefine)return;const id=generateElementId(jsxTag.name,attributes2),element=getOrCreateElement(name,id,Constructor);return fillComponentElement(element,jsxTag,attributes2,children),element}__name(createCustomElement,"createCustomElement");function getOrDefineCustomElement(name,jsxTag,attributes$1){var _a;let Constructor=customElements.get(name);return Constructor||(Constructor=(_a=class extends ComponentElement{constructor(){super(),attributes$1!=null&&attributes$1.__onlyDefine&&this.addLoadCallback(()=>fillComponentElement(this,jsxTag,attributes.getElementAttributesAdvanced(this),[]))}},__name(_a,"Constructor"),_a.formAssociated=jsxTag.formAssociated,_a),customElements.define(name,Constructor)),Constructor}__name(getOrDefineCustomElement,"getOrDefineCustomElement");function generateElementId(tagName,attributes2){if(attributes2!=null&&attributes2.__hydrationId)return attributes2.__hydrationId;const index=(indexMap.get(tagName)||0)+1;return indexMap.set(tagName,index),`${tagName}-${index}`}__name(generateElementId,"generateElementId");function getOrCreateElement(name,id,Constructor){if(isHydrating.value){const selector=`${name}[data-id="${id}"]`,existingElement=document.querySelector(selector);if(existingElement&&existingElement instanceof Constructor)return existingElement}const element=new Constructor;return element.setAttribute("data-id",id),element}__name(getOrCreateElement,"getOrCreateElement");function fillComponentElement(element,jsxTag,attributes2,children){const props=__spreadProps(__spreadValues({},attributes2),{children}),setHtml=props.setHtml;delete props.setHtml;const result=jsxTag(props);result instanceof ElementProps?appendChildren(element,{setHtml},result):result instanceof ComponentProps&&appendChildren(element,__spreadProps(__spreadValues({},result.attributes),{setHtml}),result.children)}__name(fillComponentElement,"fillComponentElement");const isHydrating={value:!1},indexMap=new Map;function h(jsxTag,attributes2,...children){const processedChildren=processChildren(attributes2,children),processedAttributes=__spreadValues({},attributes2);return delete processedAttributes.children,typeof jsxTag=="string"?handleStringTag(jsxTag,processedAttributes,processedChildren):handleFunctionTag(jsxTag,processedAttributes,processedChildren)}__name(h,"h");function Fragment(children){const fragment=document.createDocumentFragment();return appendChildren(fragment,void 0,children),fragment}__name(Fragment,"Fragment");function render(container,Component,params,children){const element=h(Component,__spreadValues({},params),children);return container.append(element),element}__name(render,"render");function hydrate(Component,params,children){isHydrating.value=!0;const element=h(Component,__spreadValues({},params),children);return isHydrating.value=!1,element}__name(hydrate,"hydrate");exports.Fragment=Fragment;exports.activeComponent=activeComponent;exports.h=h;exports.hydrate=hydrate;exports.indexMap=indexMap;exports.render=render;
|
package/lib/router/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const history_index=require("../history/index.cjs"),LocalLinks=require("../LocalLinks-D1mYcA-B.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-CJ-MfwJ8.cjs"),PageScroll=require("../PageScroll-IlOCUUte.cjs");require("construct-style-sheets-polyfill");require("../index-DZ44osDT.cjs");const url=require("../url-CPCO10Sy.cjs"),urlpatternPolyfill=require("urlpattern-polyfill"),render=require("../render-H9BjFLZ3.cjs"),object=require("../object-DTY_W6xG.cjs");var _pattern,_module,_urlPattern,_elementConstructor,_elementInstance,_isActive,_nestTarget,_mutationObserver,_permanentHeadNodes,_temporalHeadNodes,_Route_instances,initializeRouteModule_fn,appendPermanentHeadNodes_fn,renderRouteComponent_fn,findNestTarget_fn,cleanup_fn,removeTemporalHeadNodes_fn,handleHeadMutations_fn,waitForHeadNodesLoad_fn,isLoadableNode_fn,_instanceReplaceListener;const _Route=class _Route{constructor(pattern,module2){__privateAdd(this,_Route_instances);__privateAdd(this,_pattern);__privateAdd(this,_module);__privateAdd(this,_urlPattern);__privateAdd(this,_elementConstructor,null);__privateAdd(this,_elementInstance,null);__privateAdd(this,_isActive,!1);__privateAdd(this,_nestTarget,null);__privateAdd(this,_mutationObserver);__privateAdd(this,_permanentHeadNodes,[]);__privateAdd(this,_temporalHeadNodes,[]);__privateAdd(this,_instanceReplaceListener,__name(e=>{__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateSet(this,_elementInstance,e.detail.element),__privateGet(this,_elementInstance).addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener))},"#instanceReplaceListener"));__privateSet(this,_pattern,pattern),__privateSet(this,_module,module2),__privateSet(this,_urlPattern,new URLPattern({pathname:__privateGet(this,_pattern)})),__privateSet(this,_mutationObserver,new MutationObserver(__privateMethod(this,_Route_instances,handleHeadMutations_fn).bind(this)))}get pattern(){return __privateGet(this,_pattern)}get isActive(){return __privateGet(this,_isActive)}get element(){return __privateGet(this,_elementInstance)}get nest(){return __privateGet(this,_nestTarget)}testPathname(pathname){return __privateGet(this,_urlPattern).test({pathname})}render(container,url2){return __async(this,null,function*(){__privateGet(this,_mutationObserver).observe(document.head,{childList:!0,subtree:!0}),__privateGet(this,_elementConstructor)?__privateMethod(this,_Route_instances,appendPermanentHeadNodes_fn).call(this):yield __privateMethod(this,_Route_instances,initializeRouteModule_fn).call(this),yield __privateMethod(this,_Route_instances,waitForHeadNodesLoad_fn).call(this),__privateGet(this,_elementConstructor)&&(yield __privateMethod(this,_Route_instances,renderRouteComponent_fn).call(this,container,url2)),__privateGet(this,_mutationObserver).disconnect()})}close(){__privateMethod(this,_Route_instances,cleanup_fn).call(this)}};_pattern=new WeakMap,_module=new WeakMap,_urlPattern=new WeakMap,_elementConstructor=new WeakMap,_elementInstance=new WeakMap,_isActive=new WeakMap,_nestTarget=new WeakMap,_mutationObserver=new WeakMap,_permanentHeadNodes=new WeakMap,_temporalHeadNodes=new WeakMap,_Route_instances=new WeakSet,initializeRouteModule_fn=__name(function(){return __async(this,null,function*(){const content=yield __privateGet(this,_module).call(this);__privateSet(this,_temporalHeadNodes,[...__privateGet(this,_permanentHeadNodes)]),typeof content.default=="function"&&__privateSet(this,_elementConstructor,content.default)})},"#initializeRouteModule"),appendPermanentHeadNodes_fn=__name(function(){__privateGet(this,_permanentHeadNodes).forEach(node=>{document.head.appendChild(node.cloneNode(!0))})},"#appendPermanentHeadNodes"),renderRouteComponent_fn=__name(function(container,url2){return __async(this,null,function*(){var _a;const routeParams={urlPatternResult:__privateGet(this,_urlPattern).exec({pathname:url2.pathname})};object.isESClass(__privateGet(this,_elementConstructor))?(__privateSet(this,_elementInstance,new(__privateGet(this,_elementConstructor))(routeParams)),container.appendChild(__privateGet(this,_elementInstance))):__privateSet(this,_elementInstance,render.render(container,__privateGet(this,_elementConstructor),routeParams)),(_a=__privateGet(this,_elementInstance))==null||_a.addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateMethod(this,_Route_instances,findNestTarget_fn).call(this),__privateSet(this,_isActive,!0)})},"#renderRouteComponent"),findNestTarget_fn=__name(function(){var _a;__privateGet(this,_elementInstance)&&__privateSet(this,_nestTarget,__privateGet(this,_elementInstance).querySelector("[data-nest]")||((_a=__privateGet(this,_elementInstance).shadowRoot)==null?void 0:_a.querySelector("[data-nest]"))||__privateGet(this,_elementInstance).shadowRoot||__privateGet(this,_elementInstance))},"#findNestTarget"),cleanup_fn=__name(function(){__privateGet(this,_mutationObserver).disconnect(),__privateGet(this,_elementInstance)&&(__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateGet(this,_elementInstance).remove()),__privateSet(this,_isActive,!1),__privateMethod(this,_Route_instances,removeTemporalHeadNodes_fn).call(this)},"#cleanup"),removeTemporalHeadNodes_fn=__name(function(){__privateGet(this,_temporalHeadNodes).forEach(node=>{node.parentNode===document.head&&document.head.removeChild(node)}),__privateSet(this,_temporalHeadNodes,[])},"#removeTemporalHeadNodes"),handleHeadMutations_fn=__name(function(mutations){mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{__privateGet(this,_elementConstructor)?__privateGet(this,_temporalHeadNodes).push(node):__privateGet(this,_permanentHeadNodes).push(node)})})},"#handleHeadMutations"),waitForHeadNodesLoad_fn=__name(function(){return __async(this,null,function*(){const loadableNodes=__privateGet(this,_permanentHeadNodes).filter(__privateMethod(this,_Route_instances,isLoadableNode_fn));yield Promise.all(loadableNodes.map(node=>new Promise(resolve=>{__privateMethod(this,_Route_instances,isLoadableNode_fn).call(this,node)?node.onload=()=>resolve():resolve()})))})},"#waitForHeadNodesLoad"),isLoadableNode_fn=__name(function(node){return node instanceof HTMLElement&&(node.tagName==="STYLE"||node.tagName==="SCRIPT"||node.tagName==="LINK")},"#isLoadableNode"),_instanceReplaceListener=new WeakMap,__name(_Route,"Route");let Route=_Route;globalThis.URLPattern=urlpatternPolyfill.URLPattern;var _options,_scroll,_links,_history,_announcerElement,_updateId,_routes,_lastRoute,_Router_instances,runPreprocessor_fn,categorizeRoutes_fn,closeOldRoutes_fn,renderNewRoutes_fn,sortRoutesByPathDepth_fn;const _Router=class _Router{constructor(options){__privateAdd(this,_Router_instances);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_history,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_routes,[]);__privateAdd(this,_lastRoute,null);__privateSet(this,_options,__spreadProps(__spreadValues({},options),{rootElement:(options==null?void 0:options.rootElement)||document.body,base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),__privateSet(this,_history,new history_index.History({onPop:__name(url2=>{this.navigate(url2)},"onPop")}))}history(){return __privateGet(this,_history)}get scroll(){return scroll}get routes(){return __privateGet(this,_routes)}run(){__privateMethod(this,_Router_instances,sortRoutesByPathDepth_fn).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(pattern,module2){const route=new Route(pattern,module2);__privateGet(this,_routes).push(route)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f;const isBack=__privateGet(this,_history).isBack,updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});if(__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),!(yield __privateMethod(this,_Router_instances,runPreprocessor_fn).call(this,fullUrl))||__privateGet(this,_updateId)!==updateId||(yield(_b=(_a=__privateGet(this,_options)).beforeNavigation)==null?void 0:_b.call(_a),__privateGet(this,_updateId)!==updateId))return;const{activeRoutes,newRoutes,oldRoutes,keepRoutes}=__privateMethod(this,_Router_instances,categorizeRoutes_fn).call(this,fullUrl);__privateSet(this,_lastRoute,(_c=keepRoutes[keepRoutes.length-1])!=null?_c:null),isBack||(__privateGet(this,_history).push(fullUrl),((_d=options==null?void 0:options.keepScrollPosition)==null||_d)&&__privateGet(this,_scroll).element.scrollTo({top:0,behavior:"instant"})),__privateGet(this,_announcerElement).create(document,fullUrl.pathname),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>__privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl)).finished:yield __privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),yield(_f=(_e=__privateGet(this,_options)).afterNavigation)==null?void 0:_f.call(_e)})}};_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_history=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_routes=new WeakMap,_lastRoute=new WeakMap,_Router_instances=new WeakSet,runPreprocessor_fn=__name(function(url2){return __async(this,null,function*(){if(!__privateGet(this,_options).preprocessor)return!0;try{return yield new Promise((resolve,reject)=>{var _a,_b;(_b=(_a=__privateGet(this,_options)).preprocessor)==null||_b.call(_a,{url:url2,resolve,reject})}),!0}catch(error){return console.error(error!=null?error:"Route change canceled"),!1}})},"#runPreprocessor"),categorizeRoutes_fn=__name(function(url2){let leaf=url2.pathname.replace(__privateGet(this,_options).base,"");leaf.startsWith("/")||(leaf=`/${leaf}`);const activeRoutes=__privateGet(this,_routes).filter(route=>route.isActive);return{activeRoutes,newRoutes:__privateGet(this,_routes).filter(route=>!activeRoutes.includes(route)&&route.testPathname(leaf)),oldRoutes:activeRoutes.filter(route=>!route.testPathname(leaf)),keepRoutes:activeRoutes.filter(route=>route.testPathname(leaf))}},"#categorizeRoutes"),closeOldRoutes_fn=__name(function(routes){routes.forEach(route=>route.close())},"#closeOldRoutes"),renderNewRoutes_fn=__name(function(oldRoutes,routes,url2){return __async(this,null,function*(){var _a,_b;__privateMethod(this,_Router_instances,closeOldRoutes_fn).call(this,oldRoutes);for(const route of routes){const target=(_b=(_a=__privateGet(this,_lastRoute))==null?void 0:_a.nest)!=null?_b:__privateGet(this,_options).rootElement;yield route.render(target,url2),__privateSet(this,_lastRoute,route)}})},"#renderNewRoutes"),sortRoutesByPathDepth_fn=__name(function(){__privateGet(this,_routes).sort((a,b)=>{const depthA=a.pattern.split("/").length,depthB=b.pattern.split("/").length;return depthA-depthB})},"#sortRoutesByPathDepth"),__name(_Router,"Router");let Router=_Router;exports.Router=Router;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const history_index=require("../history/index.cjs"),LocalLinks=require("../LocalLinks-D1mYcA-B.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-CJ-MfwJ8.cjs"),PageScroll=require("../PageScroll-IlOCUUte.cjs");require("construct-style-sheets-polyfill");require("../index-DZ44osDT.cjs");const url=require("../url-CPCO10Sy.cjs"),urlpatternPolyfill=require("urlpattern-polyfill"),render=require("../render-R8P4qkHo.cjs"),object=require("../object-DTY_W6xG.cjs");var _pattern,_module,_urlPattern,_elementConstructor,_elementInstance,_isActive,_nestTarget,_mutationObserver,_permanentHeadNodes,_temporalHeadNodes,_Route_instances,initializeRouteModule_fn,appendPermanentHeadNodes_fn,renderRouteComponent_fn,findNestTarget_fn,cleanup_fn,removeTemporalHeadNodes_fn,handleHeadMutations_fn,waitForHeadNodesLoad_fn,isLoadableNode_fn,_instanceReplaceListener;const _Route=class _Route{constructor(pattern,module2){__privateAdd(this,_Route_instances);__privateAdd(this,_pattern);__privateAdd(this,_module);__privateAdd(this,_urlPattern);__privateAdd(this,_elementConstructor,null);__privateAdd(this,_elementInstance,null);__privateAdd(this,_isActive,!1);__privateAdd(this,_nestTarget,null);__privateAdd(this,_mutationObserver);__privateAdd(this,_permanentHeadNodes,[]);__privateAdd(this,_temporalHeadNodes,[]);__privateAdd(this,_instanceReplaceListener,__name(e=>{__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateSet(this,_elementInstance,e.detail.element),__privateGet(this,_elementInstance).addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener))},"#instanceReplaceListener"));__privateSet(this,_pattern,pattern),__privateSet(this,_module,module2),__privateSet(this,_urlPattern,new URLPattern({pathname:__privateGet(this,_pattern)})),__privateSet(this,_mutationObserver,new MutationObserver(__privateMethod(this,_Route_instances,handleHeadMutations_fn).bind(this)))}get pattern(){return __privateGet(this,_pattern)}get isActive(){return __privateGet(this,_isActive)}get element(){return __privateGet(this,_elementInstance)}get nest(){return __privateGet(this,_nestTarget)}testPathname(pathname){return __privateGet(this,_urlPattern).test({pathname})}render(container,url2){return __async(this,null,function*(){__privateGet(this,_mutationObserver).observe(document.head,{childList:!0,subtree:!0}),__privateGet(this,_elementConstructor)?__privateMethod(this,_Route_instances,appendPermanentHeadNodes_fn).call(this):yield __privateMethod(this,_Route_instances,initializeRouteModule_fn).call(this),yield __privateMethod(this,_Route_instances,waitForHeadNodesLoad_fn).call(this),__privateGet(this,_elementConstructor)&&(yield __privateMethod(this,_Route_instances,renderRouteComponent_fn).call(this,container,url2)),__privateGet(this,_mutationObserver).disconnect()})}close(){__privateMethod(this,_Route_instances,cleanup_fn).call(this)}};_pattern=new WeakMap,_module=new WeakMap,_urlPattern=new WeakMap,_elementConstructor=new WeakMap,_elementInstance=new WeakMap,_isActive=new WeakMap,_nestTarget=new WeakMap,_mutationObserver=new WeakMap,_permanentHeadNodes=new WeakMap,_temporalHeadNodes=new WeakMap,_Route_instances=new WeakSet,initializeRouteModule_fn=__name(function(){return __async(this,null,function*(){const content=yield __privateGet(this,_module).call(this);__privateSet(this,_temporalHeadNodes,[...__privateGet(this,_permanentHeadNodes)]),typeof content.default=="function"&&__privateSet(this,_elementConstructor,content.default)})},"#initializeRouteModule"),appendPermanentHeadNodes_fn=__name(function(){__privateGet(this,_permanentHeadNodes).forEach(node=>{document.head.appendChild(node.cloneNode(!0))})},"#appendPermanentHeadNodes"),renderRouteComponent_fn=__name(function(container,url2){return __async(this,null,function*(){var _a;const routeParams={urlPatternResult:__privateGet(this,_urlPattern).exec({pathname:url2.pathname})};object.isESClass(__privateGet(this,_elementConstructor))?(__privateSet(this,_elementInstance,new(__privateGet(this,_elementConstructor))(routeParams)),container.appendChild(__privateGet(this,_elementInstance))):__privateSet(this,_elementInstance,render.render(container,__privateGet(this,_elementConstructor),routeParams)),(_a=__privateGet(this,_elementInstance))==null||_a.addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateMethod(this,_Route_instances,findNestTarget_fn).call(this),__privateSet(this,_isActive,!0)})},"#renderRouteComponent"),findNestTarget_fn=__name(function(){var _a;__privateGet(this,_elementInstance)&&__privateSet(this,_nestTarget,__privateGet(this,_elementInstance).querySelector("[data-nest]")||((_a=__privateGet(this,_elementInstance).shadowRoot)==null?void 0:_a.querySelector("[data-nest]"))||__privateGet(this,_elementInstance).shadowRoot||__privateGet(this,_elementInstance))},"#findNestTarget"),cleanup_fn=__name(function(){__privateGet(this,_mutationObserver).disconnect(),__privateGet(this,_elementInstance)&&(__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateGet(this,_elementInstance).remove()),__privateSet(this,_isActive,!1),__privateMethod(this,_Route_instances,removeTemporalHeadNodes_fn).call(this)},"#cleanup"),removeTemporalHeadNodes_fn=__name(function(){__privateGet(this,_temporalHeadNodes).forEach(node=>{node.parentNode===document.head&&document.head.removeChild(node)}),__privateSet(this,_temporalHeadNodes,[])},"#removeTemporalHeadNodes"),handleHeadMutations_fn=__name(function(mutations){mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{__privateGet(this,_elementConstructor)?__privateGet(this,_temporalHeadNodes).push(node):__privateGet(this,_permanentHeadNodes).push(node)})})},"#handleHeadMutations"),waitForHeadNodesLoad_fn=__name(function(){return __async(this,null,function*(){const loadableNodes=__privateGet(this,_permanentHeadNodes).filter(__privateMethod(this,_Route_instances,isLoadableNode_fn));yield Promise.all(loadableNodes.map(node=>new Promise(resolve=>{__privateMethod(this,_Route_instances,isLoadableNode_fn).call(this,node)?node.onload=()=>resolve():resolve()})))})},"#waitForHeadNodesLoad"),isLoadableNode_fn=__name(function(node){return node instanceof HTMLElement&&(node.tagName==="STYLE"||node.tagName==="SCRIPT"||node.tagName==="LINK")},"#isLoadableNode"),_instanceReplaceListener=new WeakMap,__name(_Route,"Route");let Route=_Route;globalThis.URLPattern=urlpatternPolyfill.URLPattern;var _options,_scroll,_links,_history,_announcerElement,_updateId,_routes,_lastRoute,_Router_instances,runPreprocessor_fn,categorizeRoutes_fn,closeOldRoutes_fn,renderNewRoutes_fn,sortRoutesByPathDepth_fn;const _Router=class _Router{constructor(options){__privateAdd(this,_Router_instances);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_history,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_routes,[]);__privateAdd(this,_lastRoute,null);__privateSet(this,_options,__spreadProps(__spreadValues({},options),{rootElement:(options==null?void 0:options.rootElement)||document.body,base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),__privateSet(this,_history,new history_index.History({onPop:__name(url2=>{this.navigate(url2)},"onPop")}))}history(){return __privateGet(this,_history)}get scroll(){return scroll}get routes(){return __privateGet(this,_routes)}run(){__privateMethod(this,_Router_instances,sortRoutesByPathDepth_fn).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(pattern,module2){const route=new Route(pattern,module2);__privateGet(this,_routes).push(route)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f;const isBack=__privateGet(this,_history).isBack,updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});if(__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),!(yield __privateMethod(this,_Router_instances,runPreprocessor_fn).call(this,fullUrl))||__privateGet(this,_updateId)!==updateId||(yield(_b=(_a=__privateGet(this,_options)).beforeNavigation)==null?void 0:_b.call(_a),__privateGet(this,_updateId)!==updateId))return;const{activeRoutes,newRoutes,oldRoutes,keepRoutes}=__privateMethod(this,_Router_instances,categorizeRoutes_fn).call(this,fullUrl);__privateSet(this,_lastRoute,(_c=keepRoutes[keepRoutes.length-1])!=null?_c:null),isBack||(__privateGet(this,_history).push(fullUrl),((_d=options==null?void 0:options.keepScrollPosition)==null||_d)&&__privateGet(this,_scroll).element.scrollTo({top:0,behavior:"instant"})),__privateGet(this,_announcerElement).create(document,fullUrl.pathname),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>__privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl)).finished:yield __privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),yield(_f=(_e=__privateGet(this,_options)).afterNavigation)==null?void 0:_f.call(_e)})}};_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_history=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_routes=new WeakMap,_lastRoute=new WeakMap,_Router_instances=new WeakSet,runPreprocessor_fn=__name(function(url2){return __async(this,null,function*(){if(!__privateGet(this,_options).preprocessor)return!0;try{return yield new Promise((resolve,reject)=>{var _a,_b;(_b=(_a=__privateGet(this,_options)).preprocessor)==null||_b.call(_a,{url:url2,resolve,reject})}),!0}catch(error){return console.error(error!=null?error:"Route change canceled"),!1}})},"#runPreprocessor"),categorizeRoutes_fn=__name(function(url2){let leaf=url2.pathname.replace(__privateGet(this,_options).base,"");leaf.startsWith("/")||(leaf=`/${leaf}`);const activeRoutes=__privateGet(this,_routes).filter(route=>route.isActive);return{activeRoutes,newRoutes:__privateGet(this,_routes).filter(route=>!activeRoutes.includes(route)&&route.testPathname(leaf)),oldRoutes:activeRoutes.filter(route=>!route.testPathname(leaf)),keepRoutes:activeRoutes.filter(route=>route.testPathname(leaf))}},"#categorizeRoutes"),closeOldRoutes_fn=__name(function(routes){routes.forEach(route=>route.close())},"#closeOldRoutes"),renderNewRoutes_fn=__name(function(oldRoutes,routes,url2){return __async(this,null,function*(){var _a,_b;__privateMethod(this,_Router_instances,closeOldRoutes_fn).call(this,oldRoutes);for(const route of routes){const target=(_b=(_a=__privateGet(this,_lastRoute))==null?void 0:_a.nest)!=null?_b:__privateGet(this,_options).rootElement;yield route.render(target,url2),__privateSet(this,_lastRoute,route)}})},"#renderNewRoutes"),sortRoutesByPathDepth_fn=__name(function(){__privateGet(this,_routes).sort((a,b)=>{const depthA=a.pattern.split("/").length,depthB=b.pattern.split("/").length;return depthA-depthB})},"#sortRoutesByPathDepth"),__name(_Router,"Router");let Router=_Router;exports.Router=Router;
|
package/lib/router/index.js
CHANGED
|
@@ -40,14 +40,14 @@ var __async = (__this, __arguments, generator) => new Promise((resolve, reject)
|
|
|
40
40
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
41
|
});
|
|
42
42
|
import { History } from "../history/index.js";
|
|
43
|
-
import { L as LocalLinks } from "../LocalLinks-
|
|
43
|
+
import { L as LocalLinks } from "../LocalLinks-CI-vxMaR.js";
|
|
44
44
|
import { P as PageAnnouncerElement } from "../PageAnnouncerElement-HcphPbXZ.js";
|
|
45
45
|
import { P as PageScroll } from "../PageScroll-CrfCwDA4.js";
|
|
46
46
|
import "construct-style-sheets-polyfill";
|
|
47
47
|
import "../index-ClTMVKJp.js";
|
|
48
48
|
import { a as normalizeBase, n as normalizeURL } from "../url-CWCY_qe_.js";
|
|
49
49
|
import { URLPattern as URLPattern$1 } from "urlpattern-polyfill";
|
|
50
|
-
import { r as render } from "../render-
|
|
50
|
+
import { r as render } from "../render-DHKcgkoZ.js";
|
|
51
51
|
import { i as isESClass } from "../object-CiIdEmJx.js";
|
|
52
52
|
var _pattern, _module, _urlPattern, _elementConstructor, _elementInstance, _isActive, _nestTarget, _mutationObserver, _permanentHeadNodes, _temporalHeadNodes, _Route_instances, initializeRouteModule_fn, appendPermanentHeadNodes_fn, renderRouteComponent_fn, findNestTarget_fn, cleanup_fn, removeTemporalHeadNodes_fn, handleHeadMutations_fn, waitForHeadNodesLoad_fn, isLoadableNode_fn, _instanceReplaceListener;
|
|
53
53
|
const _Route = class _Route {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Damped, TweenedOptions } from '../animation';
|
|
2
|
+
import { CSSProperty } from '../css-property';
|
|
2
3
|
import { Store } from '../store';
|
|
3
4
|
import { Axes2D } from '../utils';
|
|
4
|
-
import { CSSProperty } from '../css-property';
|
|
5
5
|
import { ScrollSection } from './ScrollSection';
|
|
6
6
|
export type ScrollLine = 'start' | 'end' | null;
|
|
7
7
|
export interface ScrollEvents {
|