tinkiet 0.10.1 → 0.11.2
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/accordion/accordion.d.ts +4 -0
- package/accordion/index.js +30 -38
- package/badge/badge.d.ts +2 -2
- package/badge/index.js +25 -5
- package/box/box.d.ts +1 -1
- package/box/focusable-box.d.ts +1 -1
- package/checkbox/checkbox.d.ts +5 -3
- package/checkbox/index.js +55 -42
- package/chip/index.js +1 -1
- package/index.js +297 -173
- package/loading/index.js +107 -12
- package/loading/loading.d.ts +1 -0
- package/package.json +11 -1
- package/pages/index.js +38 -22
- package/pages/pages.d.ts +2 -0
- package/router/index.d.ts +48 -0
- package/router/index.js +256 -0
- package/router/route-matcher.d.ts +4 -0
- package/umd/tinkiet.min.js +117 -121
package/loading/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_lit__ from "lit";
|
|
2
|
-
import
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_if_defined_js_76c6050d__ from "lit/directives/if-defined.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643__ from "lit/directives/class-map.js";
|
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE_lit_decorators_js_226d44c5__ from "lit/decorators.js";
|
|
4
5
|
/******/ var __webpack_modules__ = ({
|
|
5
6
|
|
|
@@ -219,7 +220,7 @@ var x = (y) => {
|
|
|
219
220
|
var x = {}; __webpack_require__.d(x, y); return x
|
|
220
221
|
}
|
|
221
222
|
var y = (x) => (() => (x))
|
|
222
|
-
module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitElement), ["css"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.css), ["html"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.html), ["unsafeCSS"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.unsafeCSS) });
|
|
223
|
+
module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitElement), ["css"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.css), ["html"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.html), ["nothing"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.nothing), ["unsafeCSS"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.unsafeCSS) });
|
|
223
224
|
|
|
224
225
|
/***/ }),
|
|
225
226
|
|
|
@@ -235,7 +236,29 @@ module.exports = x({ ["LitElement"]: () => (__WEBPACK_EXTERNAL_MODULE_lit__.LitE
|
|
|
235
236
|
|
|
236
237
|
/***/ }),
|
|
237
238
|
|
|
238
|
-
/***/
|
|
239
|
+
/***/ 3517:
|
|
240
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
241
|
+
|
|
242
|
+
var x = (y) => {
|
|
243
|
+
var x = {}; __webpack_require__.d(x, y); return x
|
|
244
|
+
}
|
|
245
|
+
var y = (x) => (() => (x))
|
|
246
|
+
module.exports = x({ ["ifDefined"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_if_defined_js_76c6050d__.ifDefined) });
|
|
247
|
+
|
|
248
|
+
/***/ }),
|
|
249
|
+
|
|
250
|
+
/***/ 4955:
|
|
251
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
252
|
+
|
|
253
|
+
var x = (y) => {
|
|
254
|
+
var x = {}; __webpack_require__.d(x, y); return x
|
|
255
|
+
}
|
|
256
|
+
var y = (x) => (() => (x))
|
|
257
|
+
module.exports = x({ ["classMap"]: () => (__WEBPACK_EXTERNAL_MODULE_lit_directives_class_map_js_2f88e643__.classMap) });
|
|
258
|
+
|
|
259
|
+
/***/ }),
|
|
260
|
+
|
|
261
|
+
/***/ 8895:
|
|
239
262
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
240
263
|
|
|
241
264
|
|
|
@@ -248,12 +271,45 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
248
271
|
var external_lit_ = __webpack_require__(2927);
|
|
249
272
|
// EXTERNAL MODULE: external "lit/decorators.js"
|
|
250
273
|
var decorators_js_ = __webpack_require__(8899);
|
|
251
|
-
|
|
274
|
+
// EXTERNAL MODULE: external "lit/directives/class-map.js"
|
|
275
|
+
var class_map_js_ = __webpack_require__(4955);
|
|
276
|
+
;// ./node_modules/lit-html/lit-html.js
|
|
277
|
+
/**
|
|
278
|
+
* @license
|
|
279
|
+
* Copyright 2017 Google LLC
|
|
280
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
281
|
+
*/
|
|
282
|
+
const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+h,n=`<${o}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=y(3),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x)}return[P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t)}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l())}}}else if(8===r.nodeType)if(r.data===o)d.push({type:2,index:c});else{let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1}c++}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n]}o!==l?.index&&(h=C.nextNode(),o++)}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else{const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r}o&&!e&&this.j(t)}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===E?void 0:t}}class I extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E)}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t)}}const Z={M:e,P:h,A:o,C:1,L:V,R:M,D:u,V:S,I:R,H:k,N:I,U:L,B:H,F:z},j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{})}return h._$AI(t),h};
|
|
283
|
+
//# sourceMappingURL=lit-html.js.map
|
|
284
|
+
|
|
285
|
+
;// ./node_modules/lit-html/directive.js
|
|
286
|
+
/**
|
|
287
|
+
* @license
|
|
288
|
+
* Copyright 2017 Google LLC
|
|
289
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
290
|
+
*/
|
|
291
|
+
const directive_t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},directive_e=t=>(...e)=>({_$litDirective$:t,values:e});class directive_i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
292
|
+
//# sourceMappingURL=directive.js.map
|
|
293
|
+
|
|
294
|
+
;// ./node_modules/lit-html/directives/style-map.js
|
|
252
295
|
|
|
296
|
+
/**
|
|
297
|
+
* @license
|
|
298
|
+
* Copyright 2018 Google LLC
|
|
299
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
300
|
+
*/const style_map_n="important",style_map_i=" !"+style_map_n,style_map_o=directive_e(class extends directive_i{constructor(t){if(super(t),t.type!==directive_t.ATTRIBUTE||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(style_map_i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?style_map_n:""):s[t]=e}}return T}});
|
|
301
|
+
//# sourceMappingURL=style-map.js.map
|
|
302
|
+
|
|
303
|
+
;// ./node_modules/lit/directives/style-map.js
|
|
304
|
+
|
|
305
|
+
//# sourceMappingURL=style-map.js.map
|
|
306
|
+
|
|
307
|
+
// EXTERNAL MODULE: external "lit/directives/if-defined.js"
|
|
308
|
+
var if_defined_js_ = __webpack_require__(3517);
|
|
253
309
|
// EXTERNAL MODULE: ./tinkiet/box/index.ts
|
|
254
310
|
var box = __webpack_require__(3433);
|
|
255
311
|
;// ./tinkiet/loading/loading.scss
|
|
256
|
-
/* harmony default export */ const loading = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{--color: hsl(var(--primary));--background-color: var(--tk-loading-background-color, hsl(var(--surface-dim)))}:host([secondary]){--color: hsl(var(--secondary))}:host([error]){--color: hsl(var(--error))}.circle{display:inline-flex;animation:rotator 3s linear infinite;transform-origin:center;width:56px;height:56px}.circle .path{stroke-dasharray:265;stroke-dashoffset:0;transform-origin:center;stroke:var(--color);animation:dash 3s ease-in-out infinite}@keyframes rotator{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dashoffset:265}50%{stroke-dashoffset:65;transform:rotate(90deg)}100%{stroke-dashoffset:265;transform:rotate(360deg)}}:host([small]) .circle{width:20px;height:20px}:host([small]) .line{height:2px}:host([large]) .circle{width:96px;height:96px}:host([large]) .line{height:14px}.line{position:relative;background-color:var(--background-color);overflow:hidden;height:6px}.line .progress{background-color:var(--color);height:100%}.line .indeterminate{background-color:
|
|
312
|
+
/* harmony default export */ const loading = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host{--color: hsl(var(--primary));--background-color: var(--tk-loading-background-color, hsl(var(--surface-dim)))}:host([secondary]){--color: hsl(var(--secondary))}:host([error]){--color: hsl(var(--error))}.circle{display:inline-flex;animation:rotator 3s linear infinite;transform-origin:center;width:56px;height:56px}.circle .track{stroke:var(--background-color);opacity:.4}.circle .path{stroke-dasharray:265;stroke-dashoffset:0;transform-origin:center;stroke:var(--color);animation:dash 3s ease-in-out infinite}@keyframes rotator{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dashoffset:265}50%{stroke-dashoffset:65;transform:rotate(90deg)}100%{stroke-dashoffset:265;transform:rotate(360deg)}}:host([small]) .circle{width:20px;height:20px}:host([small]) .line{height:2px}:host([large]) .circle{width:96px;height:96px}:host([large]) .line{height:14px}.line{position:relative;background-color:var(--background-color);overflow:hidden;height:6px}.line .progress{background-color:var(--color);height:100%;position:relative;width:100%}.line .indeterminate{background-color:rgba(0,0,0,0);position:absolute;top:0;left:0;right:0;bottom:0}.line .indeterminate:before{content:\"\";position:absolute;background-color:var(--color);top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite}.line .indeterminate:after{content:\"\";position:absolute;background-color:var(--color);top:0;left:0;bottom:0;will-change:left,right;animation:indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;animation-delay:1.15s}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}100%{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}100%{left:107%;right:-8%}}");
|
|
257
313
|
;// ./tinkiet/loading/loading.ts
|
|
258
314
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
259
315
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -266,6 +322,8 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
|
|
|
266
322
|
|
|
267
323
|
|
|
268
324
|
|
|
325
|
+
|
|
326
|
+
|
|
269
327
|
let TkLoading = class TkLoading extends box/* TkBox */.P {
|
|
270
328
|
constructor() {
|
|
271
329
|
super(...arguments);
|
|
@@ -282,28 +340,65 @@ let TkLoading = class TkLoading extends box/* TkBox */.P {
|
|
|
282
340
|
];
|
|
283
341
|
}
|
|
284
342
|
render() {
|
|
343
|
+
const percent = this.normalizePercent(this.percent);
|
|
344
|
+
const radius = 40;
|
|
345
|
+
const circumference = 2 * Math.PI * radius;
|
|
346
|
+
const dashOffset = circumference * (1 - percent / 100);
|
|
347
|
+
const isDeterminateCircle = this.circle && !this.indeterminate && this.hasAttribute("percent");
|
|
348
|
+
const ariaValueNow = this.indeterminate ? undefined : percent;
|
|
349
|
+
const circleStyle = isDeterminateCircle ? style_map_o({ animation: "none" }) : external_lit_.nothing;
|
|
350
|
+
const progressStyle = isDeterminateCircle
|
|
351
|
+
? style_map_o({
|
|
352
|
+
animation: "none",
|
|
353
|
+
strokeDasharray: `${circumference}`,
|
|
354
|
+
strokeDashoffset: `${dashOffset}`
|
|
355
|
+
})
|
|
356
|
+
: external_lit_.nothing;
|
|
285
357
|
return (0,external_lit_.html) `
|
|
286
358
|
${this.circle
|
|
287
359
|
? (0,external_lit_.html) `
|
|
288
|
-
<svg
|
|
360
|
+
<svg
|
|
361
|
+
class="circle"
|
|
362
|
+
viewBox="0 0 100 100"
|
|
363
|
+
role="progressbar"
|
|
364
|
+
aria-valuemin="0"
|
|
365
|
+
aria-valuemax="100"
|
|
366
|
+
aria-valuenow=${(0,if_defined_js_.ifDefined)(ariaValueNow)}
|
|
367
|
+
style=${circleStyle}
|
|
368
|
+
>
|
|
369
|
+
<circle class="track" fill="none" stroke-width="1em" cx="50" cy="50" r="40"></circle>
|
|
289
370
|
<circle
|
|
290
|
-
class=${
|
|
371
|
+
class=${(0,class_map_js_.classMap)({ indeterminate: this.indeterminate, path: true })}
|
|
291
372
|
fill="none"
|
|
292
373
|
stroke-width="1em"
|
|
293
374
|
stroke-linecap="butt"
|
|
294
375
|
cx="50"
|
|
295
376
|
cy="50"
|
|
296
377
|
r="40"
|
|
378
|
+
style=${progressStyle}
|
|
297
379
|
></circle>
|
|
298
380
|
</svg>
|
|
299
|
-
|
|
381
|
+
`
|
|
300
382
|
: (0,external_lit_.html) `
|
|
301
|
-
<div
|
|
302
|
-
|
|
383
|
+
<div
|
|
384
|
+
class="line"
|
|
385
|
+
role="progressbar"
|
|
386
|
+
aria-valuemin="0"
|
|
387
|
+
aria-valuemax="100"
|
|
388
|
+
aria-valuenow=${(0,if_defined_js_.ifDefined)(ariaValueNow)}
|
|
389
|
+
>
|
|
390
|
+
<div class=${(0,class_map_js_.classMap)({ progress: true, indeterminate: this.indeterminate })} style=${style_map_o(this.indeterminate ? { width: "100%" } : { width: `${percent}%` })}>
|
|
391
|
+
${this.indeterminate ? (0,external_lit_.html) `<span class="visually-hidden">Loading</span>` : external_lit_.nothing}
|
|
392
|
+
</div>
|
|
303
393
|
</div>
|
|
304
|
-
|
|
394
|
+
`}
|
|
305
395
|
`;
|
|
306
396
|
}
|
|
397
|
+
normalizePercent(value) {
|
|
398
|
+
if (!Number.isFinite(value))
|
|
399
|
+
return 0;
|
|
400
|
+
return Math.min(100, Math.max(0, value));
|
|
401
|
+
}
|
|
307
402
|
};
|
|
308
403
|
__decorate([
|
|
309
404
|
(0,decorators_js_.property)({ attribute: true, type: Boolean })
|
|
@@ -382,7 +477,7 @@ var __webpack_exports__ = {};
|
|
|
382
477
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
383
478
|
/* harmony export */ k: () => (/* reexport safe */ _loading__WEBPACK_IMPORTED_MODULE_0__.k)
|
|
384
479
|
/* harmony export */ });
|
|
385
|
-
/* harmony import */ var _loading__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
480
|
+
/* harmony import */ var _loading__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8895);
|
|
386
481
|
|
|
387
482
|
|
|
388
483
|
const __webpack_exports__TkLoading = __webpack_exports__.k;
|
package/loading/loading.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinkiet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Pragmatic UI Web Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./index.js",
|
|
12
|
+
"types": "./index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./router": {
|
|
15
|
+
"import": "./router/index.js",
|
|
16
|
+
"types": "./router/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
"keywords": [
|
|
10
20
|
"web",
|
|
11
21
|
"components",
|
package/pages/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var external_lit_ = __webpack_require__(2927);
|
|
|
27
27
|
// EXTERNAL MODULE: external "lit/decorators.js"
|
|
28
28
|
var decorators_js_ = __webpack_require__(8899);
|
|
29
29
|
;// ./tinkiet/pages/pages.scss
|
|
30
|
-
/* harmony default export */ const pages = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}");
|
|
30
|
+
/* harmony default export */ const pages = ("*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box}:host ::slotted([hidden]){display:none !important}");
|
|
31
31
|
;// ./tinkiet/pages/pages.ts
|
|
32
32
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
33
33
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -47,7 +47,9 @@ let TkPages = class TkPages extends external_lit_.LitElement {
|
|
|
47
47
|
this.scrollHistory = {};
|
|
48
48
|
}
|
|
49
49
|
set page(val) {
|
|
50
|
-
|
|
50
|
+
const oldVal = this._page;
|
|
51
|
+
if (oldVal === val)
|
|
52
|
+
return;
|
|
51
53
|
this._page = val;
|
|
52
54
|
if (oldVal && this.handleScroll) {
|
|
53
55
|
const el = this.querySelector(`[page=${oldVal}]`);
|
|
@@ -61,6 +63,17 @@ let TkPages = class TkPages extends external_lit_.LitElement {
|
|
|
61
63
|
get page() {
|
|
62
64
|
return this._page;
|
|
63
65
|
}
|
|
66
|
+
firstUpdated() {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
// If no page is set, pick the first child with a page attr or default to "default"
|
|
69
|
+
if (!this.page) {
|
|
70
|
+
const first = (_a = this.querySelector("[page]")) !== null && _a !== void 0 ? _a : this.querySelector(":scope > *");
|
|
71
|
+
if (first) {
|
|
72
|
+
this.page = (_b = first.getAttribute("page")) !== null && _b !== void 0 ? _b : "default";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this.updatePages();
|
|
76
|
+
}
|
|
64
77
|
render() {
|
|
65
78
|
return (0,external_lit_.html) `
|
|
66
79
|
<slot></slot>
|
|
@@ -68,34 +81,37 @@ let TkPages = class TkPages extends external_lit_.LitElement {
|
|
|
68
81
|
}
|
|
69
82
|
updated(props) {
|
|
70
83
|
if (props.has("page")) {
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
this.updatePages();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
updatePages() {
|
|
88
|
+
const scrollElement = document.scrollingElement || document.documentElement;
|
|
89
|
+
this.querySelectorAll(":scope > *").forEach(el => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const elPageAttribute = (_a = el.getAttribute("page")) !== null && _a !== void 0 ? _a : "default";
|
|
92
|
+
if (elPageAttribute === this.page) {
|
|
93
|
+
el.removeAttribute("hidden");
|
|
94
|
+
if (this.selected) {
|
|
95
|
+
el.setAttribute(this.selected, "");
|
|
83
96
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (this.selected != "") {
|
|
87
|
-
el.removeAttribute(this.selected);
|
|
88
|
-
}
|
|
97
|
+
if (this.handleScroll && !el.hasAttribute("no-scroll")) {
|
|
98
|
+
scrollElement.scrollTop = (_b = this.scrollHistory[elPageAttribute]) !== null && _b !== void 0 ? _b : 0;
|
|
89
99
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
el.setAttribute("hidden", "");
|
|
103
|
+
if (this.selected) {
|
|
104
|
+
el.removeAttribute(this.selected);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
92
108
|
}
|
|
93
109
|
};
|
|
94
110
|
TkPages.styles = (0,external_lit_.css) `
|
|
95
111
|
${(0,external_lit_.unsafeCSS)(pages)}
|
|
96
112
|
`;
|
|
97
113
|
__decorate([
|
|
98
|
-
(0,decorators_js_.property)({ attribute: "page", type: String })
|
|
114
|
+
(0,decorators_js_.property)({ attribute: "page", type: String, reflect: true })
|
|
99
115
|
], TkPages.prototype, "page", null);
|
|
100
116
|
__decorate([
|
|
101
117
|
(0,decorators_js_.property)({ attribute: true, type: String })
|
package/pages/pages.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ export declare class TkPages extends LitElement {
|
|
|
7
7
|
selected: string;
|
|
8
8
|
handleScroll: boolean;
|
|
9
9
|
private scrollHistory;
|
|
10
|
+
firstUpdated(): void;
|
|
10
11
|
render(): import("lit").TemplateResult<1>;
|
|
11
12
|
updated(props: any): void;
|
|
13
|
+
private updatePages;
|
|
12
14
|
}
|
|
13
15
|
declare global {
|
|
14
16
|
interface HTMLElementTagNameMap {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface RouteContext {
|
|
2
|
+
/** Pathname without query/hash, e.g. /tk/page1 */
|
|
3
|
+
path: string;
|
|
4
|
+
/** Full path with query/hash, e.g. /tk/page1?foo=bar#hash */
|
|
5
|
+
fullPath: string;
|
|
6
|
+
/** Matched params from pattern (:id, :section*, ...) */
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
/** Query parameters */
|
|
9
|
+
query: URLSearchParams;
|
|
10
|
+
/** Matched route pattern (if any) */
|
|
11
|
+
route: string | null;
|
|
12
|
+
/** Shared mutable state for middlewares */
|
|
13
|
+
state: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export type NextFunction = () => Promise<void>;
|
|
16
|
+
export type Middleware = (ctx: RouteContext, next: NextFunction) => void | Promise<void>;
|
|
17
|
+
export interface NavigateOptions {
|
|
18
|
+
replace?: boolean;
|
|
19
|
+
silent?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class Router {
|
|
22
|
+
private layers;
|
|
23
|
+
private started;
|
|
24
|
+
/**
|
|
25
|
+
* Global middleware:
|
|
26
|
+
* router.use((ctx, next) => { ... })
|
|
27
|
+
*
|
|
28
|
+
* Pattern-scoped middleware:
|
|
29
|
+
* router.use('/tk/:page', (ctx, next) => { ... })
|
|
30
|
+
*/
|
|
31
|
+
use(handler: Middleware): void;
|
|
32
|
+
use(pattern: string, handler: Middleware): void;
|
|
33
|
+
/**
|
|
34
|
+
* Programmatic navigation.
|
|
35
|
+
* Example: router.navigate('/tk/home');
|
|
36
|
+
*/
|
|
37
|
+
navigate(path: string, options?: NavigateOptions): void;
|
|
38
|
+
/**
|
|
39
|
+
* Start listening to history and link clicks, and dispatch initial URL.
|
|
40
|
+
*/
|
|
41
|
+
start(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Shortcut to go back in history.
|
|
44
|
+
*/
|
|
45
|
+
back(): void;
|
|
46
|
+
private createMatcher;
|
|
47
|
+
private dispatch;
|
|
48
|
+
}
|
package/router/index.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/******/ // The require scope
|
|
2
|
+
/******/ var __webpack_require__ = {};
|
|
3
|
+
/******/
|
|
4
|
+
/************************************************************************/
|
|
5
|
+
/******/ /* webpack/runtime/define property getters */
|
|
6
|
+
/******/ (() => {
|
|
7
|
+
/******/ // define getter functions for harmony exports
|
|
8
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
9
|
+
/******/ for(var key in definition) {
|
|
10
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
11
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ }
|
|
14
|
+
/******/ };
|
|
15
|
+
/******/ })();
|
|
16
|
+
/******/
|
|
17
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
18
|
+
/******/ (() => {
|
|
19
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
20
|
+
/******/ })();
|
|
21
|
+
/******/
|
|
22
|
+
/************************************************************************/
|
|
23
|
+
var __webpack_exports__ = {};
|
|
24
|
+
|
|
25
|
+
;// ./tinkiet/router/route-matcher.ts
|
|
26
|
+
function matchPath(pattern, pathname) {
|
|
27
|
+
if (pattern === '*') {
|
|
28
|
+
return { params: {} };
|
|
29
|
+
}
|
|
30
|
+
const patternParts = pattern.split('/').filter(Boolean);
|
|
31
|
+
const pathParts = pathname.split('/').filter(Boolean);
|
|
32
|
+
const params = {};
|
|
33
|
+
let pathIndex = 0;
|
|
34
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
35
|
+
const pat = patternParts[i];
|
|
36
|
+
const segment = pathParts[pathIndex];
|
|
37
|
+
const isRestParam = pat.startsWith(':') && pat.endsWith('*');
|
|
38
|
+
const isOptionalParam = pat.startsWith(':') && pat.endsWith('?');
|
|
39
|
+
const isParam = pat.startsWith(':') && !isRestParam && !isOptionalParam;
|
|
40
|
+
// Wildcard "rest" param: :name*
|
|
41
|
+
if (isRestParam) {
|
|
42
|
+
const name = pat.slice(1, -1); // remove ':' and '*'
|
|
43
|
+
params[name] = decodeURIComponent(pathParts.slice(pathIndex).join('/'));
|
|
44
|
+
return { params };
|
|
45
|
+
}
|
|
46
|
+
// Optional param :name?
|
|
47
|
+
if (isOptionalParam) {
|
|
48
|
+
if (segment != null) {
|
|
49
|
+
const name = pat.slice(1, -1); // remove ':' and '?'
|
|
50
|
+
params[name] = decodeURIComponent(segment);
|
|
51
|
+
pathIndex += 1;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// Simple param :name
|
|
56
|
+
if (isParam) {
|
|
57
|
+
if (segment == null)
|
|
58
|
+
return null;
|
|
59
|
+
const name = pat.slice(1);
|
|
60
|
+
params[name] = decodeURIComponent(segment);
|
|
61
|
+
pathIndex += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Plain wildcard "*"
|
|
65
|
+
if (pat === '*') {
|
|
66
|
+
return { params };
|
|
67
|
+
}
|
|
68
|
+
// Static segment
|
|
69
|
+
if (segment !== pat) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
pathIndex += 1;
|
|
73
|
+
}
|
|
74
|
+
// Extra segments in path not matched by optional/rest params => no match
|
|
75
|
+
if (pathIndex < pathParts.length) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return { params };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
;// ./tinkiet/router/index.ts
|
|
82
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
83
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
84
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
85
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
86
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
87
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
88
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
// router.ts
|
|
92
|
+
|
|
93
|
+
class Router {
|
|
94
|
+
constructor() {
|
|
95
|
+
this.layers = [];
|
|
96
|
+
this.started = false;
|
|
97
|
+
}
|
|
98
|
+
use(patternOrHandler, handler) {
|
|
99
|
+
if (typeof patternOrHandler === 'string') {
|
|
100
|
+
if (!handler) {
|
|
101
|
+
throw new Error('router.use(pattern, handler) requires a handler');
|
|
102
|
+
}
|
|
103
|
+
const pattern = patternOrHandler;
|
|
104
|
+
this.layers.push({
|
|
105
|
+
pattern,
|
|
106
|
+
matcher: this.createMatcher(pattern),
|
|
107
|
+
stack: [handler]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const globalHandler = patternOrHandler;
|
|
112
|
+
this.layers.push({
|
|
113
|
+
pattern: null,
|
|
114
|
+
matcher: null,
|
|
115
|
+
stack: [globalHandler]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Programmatic navigation.
|
|
121
|
+
* Example: router.navigate('/tk/home');
|
|
122
|
+
*/
|
|
123
|
+
navigate(path, options = {}) {
|
|
124
|
+
if (!this.started)
|
|
125
|
+
return;
|
|
126
|
+
const url = new URL(path, window.location.origin);
|
|
127
|
+
const href = url.pathname + url.search + url.hash;
|
|
128
|
+
if (options.replace) {
|
|
129
|
+
history.replaceState(null, '', href);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
history.pushState(null, '', href);
|
|
133
|
+
}
|
|
134
|
+
if (!options.silent) {
|
|
135
|
+
void this.dispatch(url);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Start listening to history and link clicks, and dispatch initial URL.
|
|
140
|
+
*/
|
|
141
|
+
start() {
|
|
142
|
+
if (this.started)
|
|
143
|
+
return;
|
|
144
|
+
this.started = true;
|
|
145
|
+
// Back/forward
|
|
146
|
+
window.addEventListener('popstate', () => {
|
|
147
|
+
const url = new URL(window.location.href);
|
|
148
|
+
void this.dispatch(url);
|
|
149
|
+
});
|
|
150
|
+
// Intercept <a> clicks for SPA navigation
|
|
151
|
+
document.addEventListener('click', (event) => {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
const path = event.composedPath();
|
|
154
|
+
// Find first element in the composed path that exposes an href
|
|
155
|
+
let linkEl = null;
|
|
156
|
+
let href = null;
|
|
157
|
+
for (const el of path) {
|
|
158
|
+
if (!(el instanceof HTMLElement))
|
|
159
|
+
continue;
|
|
160
|
+
const elHref = (_a = el.href) !== null && _a !== void 0 ? _a : el.getAttribute('href');
|
|
161
|
+
if (elHref) {
|
|
162
|
+
linkEl = el;
|
|
163
|
+
href = elHref;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!linkEl || !href)
|
|
168
|
+
return;
|
|
169
|
+
const url = new URL(href, window.location.origin);
|
|
170
|
+
const sameOrigin = url.origin === window.location.origin;
|
|
171
|
+
const targetAttr = (_b = linkEl.target) !== null && _b !== void 0 ? _b : linkEl.getAttribute('target');
|
|
172
|
+
const isModifiedClick = event.metaKey ||
|
|
173
|
+
event.ctrlKey ||
|
|
174
|
+
event.shiftKey ||
|
|
175
|
+
event.altKey ||
|
|
176
|
+
event.button !== 0;
|
|
177
|
+
if (!sameOrigin || isModifiedClick || targetAttr === '_blank')
|
|
178
|
+
return;
|
|
179
|
+
if (linkEl.hasAttribute('download'))
|
|
180
|
+
return;
|
|
181
|
+
// Let browser handle hash-only navigation on same path
|
|
182
|
+
if (url.pathname === window.location.pathname && url.hash !== '')
|
|
183
|
+
return;
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
this.navigate(url.pathname + url.search + url.hash);
|
|
186
|
+
});
|
|
187
|
+
const initialUrl = new URL(window.location.href);
|
|
188
|
+
void this.dispatch(initialUrl);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Shortcut to go back in history.
|
|
192
|
+
*/
|
|
193
|
+
back() {
|
|
194
|
+
window.history.back();
|
|
195
|
+
}
|
|
196
|
+
// ---------- Internals ----------
|
|
197
|
+
createMatcher(pattern) {
|
|
198
|
+
if (pattern === '*') {
|
|
199
|
+
return () => ({ params: {} });
|
|
200
|
+
}
|
|
201
|
+
return (pathname) => matchPath(pattern, pathname);
|
|
202
|
+
}
|
|
203
|
+
dispatch(url) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const pathname = url.pathname;
|
|
206
|
+
const fullPath = url.pathname + url.search + url.hash;
|
|
207
|
+
const ctx = {
|
|
208
|
+
path: pathname,
|
|
209
|
+
fullPath,
|
|
210
|
+
params: {},
|
|
211
|
+
query: url.searchParams,
|
|
212
|
+
route: null,
|
|
213
|
+
state: {}
|
|
214
|
+
};
|
|
215
|
+
let layerIndex = -1;
|
|
216
|
+
const runLayer = (index) => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
if (index <= layerIndex) {
|
|
218
|
+
throw new Error('next() called multiple times for the same layer');
|
|
219
|
+
}
|
|
220
|
+
layerIndex = index;
|
|
221
|
+
if (index >= this.layers.length) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const layer = this.layers[index];
|
|
225
|
+
const { matcher, pattern, stack } = layer;
|
|
226
|
+
const matchResult = matcher ? matcher(pathname) : { params: {} };
|
|
227
|
+
if (!matchResult) {
|
|
228
|
+
return runLayer(index + 1);
|
|
229
|
+
}
|
|
230
|
+
ctx.route = pattern;
|
|
231
|
+
ctx.params = Object.assign(Object.assign({}, ctx.params), matchResult.params);
|
|
232
|
+
let stackIndex = -1;
|
|
233
|
+
const runMiddleware = (mwIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
if (mwIndex <= stackIndex) {
|
|
235
|
+
throw new Error('next() called multiple times inside a layer');
|
|
236
|
+
}
|
|
237
|
+
stackIndex = mwIndex;
|
|
238
|
+
if (mwIndex >= stack.length) {
|
|
239
|
+
return runLayer(index + 1);
|
|
240
|
+
}
|
|
241
|
+
const mw = stack[mwIndex];
|
|
242
|
+
yield mw(ctx, () => runMiddleware(mwIndex + 1));
|
|
243
|
+
});
|
|
244
|
+
yield runMiddleware(0);
|
|
245
|
+
});
|
|
246
|
+
try {
|
|
247
|
+
yield runLayer(0);
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
console.error('[router] Unhandled error during dispatch', err);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export { Router };
|