@telperion/elements 6.1.0 → 7.1.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/.build-manifest.json +22 -1
- package/README.md +40 -5
- package/_chunks/code-cdn-element-ClAO2lep.d.cts +200 -0
- package/_chunks/code-cdn-element-ClAO2lep.d.ts +200 -0
- package/code/bundled-language-loader.cjs +18 -0
- package/code/bundled-language-loader.cjs.map +1 -0
- package/code/bundled-language-loader.js +16 -0
- package/code/bundled-language-loader.js.map +1 -0
- package/code/cdn-language-loader.cjs +41 -0
- package/code/cdn-language-loader.cjs.map +1 -0
- package/code/cdn-language-loader.js +36 -0
- package/code/cdn-language-loader.js.map +1 -0
- package/code/cdn.cjs +21 -0
- package/code/cdn.cjs.map +1 -0
- package/code/cdn.d.cts +3 -0
- package/code/cdn.d.ts +3 -0
- package/code/cdn.js +16 -0
- package/code/cdn.js.map +1 -0
- package/code/code-element-base.cjs +241 -0
- package/code/code-element-base.cjs.map +1 -0
- package/code/code-element-base.js +239 -0
- package/code/code-element-base.js.map +1 -0
- package/code/code-element.cjs +16 -0
- package/code/code-element.cjs.map +1 -0
- package/code/code-element.js +14 -0
- package/code/code-element.js.map +1 -0
- package/code/copy.cjs +41 -0
- package/code/copy.cjs.map +1 -0
- package/code/copy.js +39 -0
- package/code/copy.js.map +1 -0
- package/code/css-variables-theme.cjs +24 -0
- package/code/css-variables-theme.cjs.map +1 -0
- package/code/css-variables-theme.js +21 -0
- package/code/css-variables-theme.js.map +1 -0
- package/code/highlighter.cjs +84 -0
- package/code/highlighter.cjs.map +1 -0
- package/code/highlighter.js +80 -0
- package/code/highlighter.js.map +1 -0
- package/code/index.cjs +19 -0
- package/code/index.cjs.map +1 -0
- package/code/index.d.cts +13 -0
- package/code/index.d.ts +13 -0
- package/code/index.js +6 -0
- package/code/index.js.map +1 -0
- package/code/language-loader.cjs +22 -0
- package/code/language-loader.cjs.map +1 -0
- package/code/language-loader.js +19 -0
- package/code/language-loader.js.map +1 -0
- package/code/line-ranges.cjs +28 -0
- package/code/line-ranges.cjs.map +1 -0
- package/code/line-ranges.js +25 -0
- package/code/line-ranges.js.map +1 -0
- package/code/source.cjs +52 -0
- package/code/source.cjs.map +1 -0
- package/code/source.js +48 -0
- package/code/source.js.map +1 -0
- package/code/styles.cjs +183 -0
- package/code/styles.cjs.map +1 -0
- package/code/styles.js +181 -0
- package/code/styles.js.map +1 -0
- package/code/templates.cjs +66 -0
- package/code/templates.cjs.map +1 -0
- package/code/templates.js +63 -0
- package/code/templates.js.map +1 -0
- package/custom-elements.json +3993 -2377
- package/fesm/elements.mjs +501 -216
- package/fesm/elements.mjs.map +1 -1
- package/iife/code/cdn.js +263 -0
- package/iife/code/cdn.js.map +1 -0
- package/iife/elements.js +36 -36
- package/iife/elements.js.map +1 -1
- package/iife/router/index.js +23 -23
- package/iife/router/index.js.map +1 -1
- package/index.cjs +23 -18
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +8 -6
- package/index.js.map +1 -1
- package/package.json +39 -2
- package/router/history-managed.cjs +1 -1
- package/router/history-managed.cjs.map +1 -1
- package/router/history-managed.js +1 -1
- package/router/history-managed.js.map +1 -1
- package/router/index.cjs +23 -18
- package/router/index.cjs.map +1 -1
- package/router/index.d.cts +273 -168
- package/router/index.d.ts +273 -168
- package/router/index.js +8 -6
- package/router/index.js.map +1 -1
- package/router/route-element.cjs +244 -0
- package/router/route-element.cjs.map +1 -0
- package/router/route-element.js +239 -0
- package/router/route-element.js.map +1 -0
- package/router/route-events.cjs +14 -0
- package/router/route-events.cjs.map +1 -0
- package/router/route-events.js +10 -0
- package/router/route-events.js.map +1 -0
- package/router/route-source.cjs +134 -0
- package/router/route-source.cjs.map +1 -0
- package/router/route-source.js +129 -0
- package/router/route-source.js.map +1 -0
- package/router/route-templates.cjs +18 -0
- package/router/route-templates.cjs.map +1 -0
- package/router/route-templates.js +16 -0
- package/router/route-templates.js.map +1 -0
- package/router/{tha-router-config.cjs → router-config-element.cjs} +51 -51
- package/router/router-config-element.cjs.map +1 -0
- package/router/{tha-router-config.js → router-config-element.js} +52 -52
- package/router/router-config-element.js.map +1 -0
- package/router/{tha-router.cjs → router-element.cjs} +47 -33
- package/router/router-element.cjs.map +1 -0
- package/router/{tha-router.js → router-element.js} +47 -33
- package/router/router-element.js.map +1 -0
- package/router/{tha-router-link.cjs → router-link-element.cjs} +15 -15
- package/router/router-link-element.cjs.map +1 -0
- package/router/{tha-router-link.js → router-link-element.js} +16 -16
- package/router/router-link-element.js.map +1 -0
- package/router/{tha-router-outlet.cjs → router-outlet-element.cjs} +44 -31
- package/router/router-outlet-element.cjs.map +1 -0
- package/router/{tha-router-outlet.js → router-outlet-element.js} +43 -30
- package/router/router-outlet-element.js.map +1 -0
- package/router/{tha-router-param.cjs → router-param-element.cjs} +62 -62
- package/router/router-param-element.cjs.map +1 -0
- package/router/{tha-router-param.js → router-param-element.js} +62 -62
- package/router/router-param-element.js.map +1 -0
- package/router/tha-route.cjs +0 -128
- package/router/tha-route.cjs.map +0 -1
- package/router/tha-route.js +0 -125
- package/router/tha-route.js.map +0 -1
- package/router/tha-router-config.cjs.map +0 -1
- package/router/tha-router-config.js.map +0 -1
- package/router/tha-router-link.cjs.map +0 -1
- package/router/tha-router-link.js.map +0 -1
- package/router/tha-router-outlet.cjs.map +0 -1
- package/router/tha-router-outlet.js.map +0 -1
- package/router/tha-router-param.cjs.map +0 -1
- package/router/tha-router-param.js.map +0 -1
- package/router/tha-router.cjs.map +0 -1
- package/router/tha-router.js.map +0 -1
package/router/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { RouterElement } from './router-element.js';
|
|
2
|
+
export { RouteElement } from './route-element.js';
|
|
3
|
+
export { RouterLinkElement } from './router-link-element.js';
|
|
4
|
+
export { RouterOutletElement } from './router-outlet-element.js';
|
|
5
|
+
export { RouterConfigElement } from './router-config-element.js';
|
|
6
|
+
export { RouterParamElement } from './router-param-element.js';
|
|
7
|
+
export { ROUTE_ERROR_EVENT, ROUTE_LOAD_EVENT } from './route-events.js';
|
|
8
|
+
export { defaultRouteSourceLoader } from './route-source.js';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/router/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var signals = require('@lit-labs/signals');
|
|
5
|
+
var lit = require('lit');
|
|
6
|
+
var decorators_js = require('lit/decorators.js');
|
|
7
|
+
var routeEvents = require('./route-events.cjs');
|
|
8
|
+
var routeSource = require('./route-source.cjs');
|
|
9
|
+
var routeTemplates = require('./route-templates.cjs');
|
|
10
|
+
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
/**
|
|
13
|
+
* Symbol used to access the route's content fragment signal.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
const FRAGMENT = Symbol('RouteElement:fragment');
|
|
17
|
+
/**
|
|
18
|
+
* Symbol used to access the route's URLPattern instance.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
const PATH_PATTERN = Symbol('RouteElement:path-pattern');
|
|
22
|
+
/**
|
|
23
|
+
* Symbol used to access the status signal of the route's `src` content.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
const SOURCE_STATUS = Symbol('RouteElement:source-status');
|
|
27
|
+
/**
|
|
28
|
+
* Symbol used by the router to mark the route as active or inactive.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
const SET_ACTIVE = Symbol('RouteElement:set-active');
|
|
32
|
+
/** Boolean attributes reflecting the status of the route's `src` content. */
|
|
33
|
+
const STATUS_ATTRIBUTES = ['loading', 'loaded', 'error'];
|
|
34
|
+
/**
|
|
35
|
+
* A custom element that defines a route in the router.
|
|
36
|
+
*
|
|
37
|
+
* The route's content comes from either:
|
|
38
|
+
* - an inline `<template>` child, or
|
|
39
|
+
* - a `src` URL, fetched the first time the route becomes active and cached
|
|
40
|
+
* until `src` changes. Optional `<template data-loading>` and
|
|
41
|
+
* `<template data-error>` children are rendered while loading and on failure.
|
|
42
|
+
*
|
|
43
|
+
* The `path` attribute uses URLPattern syntax and supports:
|
|
44
|
+
* - Static paths: `/about`, `/users`
|
|
45
|
+
* - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
|
|
46
|
+
* - Wildcards: `/blog/*`, `/docs/**`
|
|
47
|
+
*
|
|
48
|
+
* While a `src` is involved, the route reflects its status as one of the
|
|
49
|
+
* boolean attributes `loading`, `loaded` or `error`.
|
|
50
|
+
*
|
|
51
|
+
* @fires tp-route-load - The `src` content has loaded. `detail: { src }`
|
|
52
|
+
* @fires tp-route-error - The `src` content failed to load. `detail: { src, error }`
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```html
|
|
56
|
+
* <tp-router>
|
|
57
|
+
* <tp-route path="/">
|
|
58
|
+
* <template><h1>Home Page</h1></template>
|
|
59
|
+
* </tp-route>
|
|
60
|
+
* <tp-route path="/docs/:slug" src="/partials/docs.html">
|
|
61
|
+
* <template data-loading><p>Loading…</p></template>
|
|
62
|
+
* <template data-error><p>Could not load the docs.</p></template>
|
|
63
|
+
* </tp-route>
|
|
64
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
65
|
+
* </tp-router>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
exports.RouteElement = class RouteElement extends lit.LitElement {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
/** The route's `<template>` children, grouped by role. */
|
|
72
|
+
this.#templates = signals.signal(routeTemplates.readRouteTemplates(this));
|
|
73
|
+
/** Loader and cache for the `src` content. */
|
|
74
|
+
this.#source = new routeSource.RouteSource(state => this.#onSourceChange(state));
|
|
75
|
+
/** Whether the router currently matches this route. */
|
|
76
|
+
this.#active = false;
|
|
77
|
+
/**
|
|
78
|
+
* Signal with the fragment to render for this route:
|
|
79
|
+
* - no `src`: the inline template's content
|
|
80
|
+
* - `src` loaded: the fetched content
|
|
81
|
+
* - `src` failed: the `data-error` template's content
|
|
82
|
+
* - otherwise: the `data-loading` template's content
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
this[_a] = signals.computed(() => {
|
|
86
|
+
const templates = this.#templates.get();
|
|
87
|
+
const { status, fragment } = this.#source.state.get();
|
|
88
|
+
switch (status) {
|
|
89
|
+
case 'none': return templates.content;
|
|
90
|
+
case 'loaded': return fragment;
|
|
91
|
+
case 'error': return templates.error;
|
|
92
|
+
default: return templates.loading;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Signal with the status of the route's `src` content.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
this[_b] = signals.computed(() => this.#source.state.get().status);
|
|
100
|
+
/**
|
|
101
|
+
* URLPattern instance for matching the current URL against this route's path.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
this[_c] = null;
|
|
105
|
+
/**
|
|
106
|
+
* The URL pattern to match for this route.
|
|
107
|
+
* Uses URLPattern syntax with support for dynamic segments and wildcards.
|
|
108
|
+
*
|
|
109
|
+
* @attr path
|
|
110
|
+
* @example "/users/:id"
|
|
111
|
+
* @example "/blog/*"
|
|
112
|
+
*/
|
|
113
|
+
this.path = null;
|
|
114
|
+
/**
|
|
115
|
+
* URL of an HTML file to use as the route's content, resolved against
|
|
116
|
+
* `document.baseURI`. Fetched the first time the route becomes active and
|
|
117
|
+
* cached until it changes. Takes precedence over the inline `<template>`.
|
|
118
|
+
*
|
|
119
|
+
* The fetched HTML is trusted like `innerHTML`: it is inserted as-is,
|
|
120
|
+
* although its `<script>` elements do not run.
|
|
121
|
+
*
|
|
122
|
+
* @attr src
|
|
123
|
+
* @example "/partials/about.html"
|
|
124
|
+
*/
|
|
125
|
+
this.src = null;
|
|
126
|
+
/**
|
|
127
|
+
* Function that fetches the `src` content. Override it to add headers,
|
|
128
|
+
* credentials or caching, or to stub requests in tests. It receives the
|
|
129
|
+
* absolute URL and an `AbortSignal`, and must reject on failure.
|
|
130
|
+
*/
|
|
131
|
+
this.loader = routeSource.defaultRouteSourceLoader;
|
|
132
|
+
/** Observes changes to child elements to detect template updates */
|
|
133
|
+
this.#templateObserver = new MutationObserver(() => {
|
|
134
|
+
this.#templates.set(routeTemplates.readRouteTemplates(this));
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/** The route's `<template>` children, grouped by role. */
|
|
138
|
+
#templates;
|
|
139
|
+
/** Loader and cache for the `src` content. */
|
|
140
|
+
#source;
|
|
141
|
+
/** Whether the router currently matches this route. */
|
|
142
|
+
#active;
|
|
143
|
+
/** Observes changes to child elements to detect template updates */
|
|
144
|
+
#templateObserver;
|
|
145
|
+
/**
|
|
146
|
+
* Lifecycle callback when the element is connected to the DOM.
|
|
147
|
+
* Sets up observer to watch for template content changes.
|
|
148
|
+
*/
|
|
149
|
+
connectedCallback() {
|
|
150
|
+
super.connectedCallback();
|
|
151
|
+
this.#templateObserver.observe(this, { childList: true });
|
|
152
|
+
this.#templates.set(routeTemplates.readRouteTemplates(this));
|
|
153
|
+
// Resume a request cancelled by a previous disconnect
|
|
154
|
+
if (this.#active)
|
|
155
|
+
this.#syncSource();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Lifecycle callback when an attribute changes.
|
|
159
|
+
* Updates the URLPattern when the path attribute changes, and the content
|
|
160
|
+
* source when the src attribute changes.
|
|
161
|
+
*
|
|
162
|
+
* @param name - The attribute name that changed
|
|
163
|
+
* @param _old - The old attribute value
|
|
164
|
+
* @param value - The new attribute value
|
|
165
|
+
*/
|
|
166
|
+
attributeChangedCallback(name, _old, value) {
|
|
167
|
+
super.attributeChangedCallback(name, _old, value);
|
|
168
|
+
switch (name) {
|
|
169
|
+
case 'path':
|
|
170
|
+
this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
|
|
171
|
+
break;
|
|
172
|
+
case 'src':
|
|
173
|
+
this.#syncSource();
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Picks up `src` changes made through the property. Loads the new content
|
|
179
|
+
* right away when the route is active.
|
|
180
|
+
*/
|
|
181
|
+
willUpdate(changed) {
|
|
182
|
+
super.willUpdate(changed);
|
|
183
|
+
if (changed.has('src'))
|
|
184
|
+
this.#syncSource();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Called by the router when this route starts or stops matching.
|
|
188
|
+
* Activating a route with a `src` loads its content unless already cached.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
[(_a = FRAGMENT, _b = SOURCE_STATUS, _c = PATH_PATTERN, SET_ACTIVE)](active) {
|
|
193
|
+
this.#active = active;
|
|
194
|
+
this.#syncSource();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Points the source at the current `src` and loads it when active.
|
|
198
|
+
*/
|
|
199
|
+
#syncSource() {
|
|
200
|
+
this.#source.setUrl(this.src ? routeSource.resolveRouteSrc(this.src) : null);
|
|
201
|
+
if (this.#active)
|
|
202
|
+
void this.#source.load(this.loader);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Reflects the source status as attributes and dispatches load/error events.
|
|
206
|
+
*/
|
|
207
|
+
#onSourceChange({ status, url, error }) {
|
|
208
|
+
for (const attribute of STATUS_ATTRIBUTES) {
|
|
209
|
+
this.toggleAttribute(attribute, attribute === status);
|
|
210
|
+
}
|
|
211
|
+
if (!url)
|
|
212
|
+
return;
|
|
213
|
+
if (status === 'loaded')
|
|
214
|
+
this.dispatchEvent(routeEvents.createRouteSourceEvent(routeEvents.ROUTE_LOAD_EVENT, { src: url }));
|
|
215
|
+
if (status === 'error')
|
|
216
|
+
this.dispatchEvent(routeEvents.createRouteSourceEvent(routeEvents.ROUTE_ERROR_EVENT, { src: url, error }));
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Lifecycle callback when the element is disconnected from the DOM.
|
|
220
|
+
* Cleans up the template observer and cancels any in-flight request.
|
|
221
|
+
*/
|
|
222
|
+
disconnectedCallback() {
|
|
223
|
+
super.disconnectedCallback();
|
|
224
|
+
this.#templateObserver.disconnect();
|
|
225
|
+
this.#source.abort();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
tslib.__decorate([
|
|
229
|
+
decorators_js.property({ type: String }),
|
|
230
|
+
tslib.__metadata("design:type", Object)
|
|
231
|
+
], exports.RouteElement.prototype, "path", void 0);
|
|
232
|
+
tslib.__decorate([
|
|
233
|
+
decorators_js.property({ type: String }),
|
|
234
|
+
tslib.__metadata("design:type", Object)
|
|
235
|
+
], exports.RouteElement.prototype, "src", void 0);
|
|
236
|
+
exports.RouteElement = tslib.__decorate([
|
|
237
|
+
decorators_js.customElement('tp-route')
|
|
238
|
+
], exports.RouteElement);
|
|
239
|
+
|
|
240
|
+
exports.FRAGMENT = FRAGMENT;
|
|
241
|
+
exports.PATH_PATTERN = PATH_PATTERN;
|
|
242
|
+
exports.SET_ACTIVE = SET_ACTIVE;
|
|
243
|
+
exports.SOURCE_STATUS = SOURCE_STATUS;
|
|
244
|
+
//# sourceMappingURL=route-element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-element.cjs","sources":["../../../../libs/elements/src/router/route-element.ts"],"sourcesContent":[null],"names":["RouteElement","LitElement","signal","readRouteTemplates","RouteSource","computed","defaultRouteSourceLoader","resolveRouteSrc","createRouteSource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EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5G;AAEA;;;AAGG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE;AACnC,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;IACtB;;AAxHAC,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACA,CAAA,EAAAZ,oBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAc3BW,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACD,CAAA,EAAAZ,oBAAA,CAAA,SAAA,EAAA,KAAA,EAAA,MAAA,CAAA;AAjEfA,oBAAY,GAAAW,gBAAA,CAAA;IADxBE,2BAAa,CAAC,UAAU;AACZ,CAAA,EAAAb,oBAAY,CA4KxB;;;;;;;"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { signal, computed } from '@lit-labs/signals';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
5
|
+
import { createRouteSourceEvent, ROUTE_LOAD_EVENT, ROUTE_ERROR_EVENT } from './route-events.js';
|
|
6
|
+
import { RouteSource, defaultRouteSourceLoader, resolveRouteSrc } from './route-source.js';
|
|
7
|
+
import { readRouteTemplates } from './route-templates.js';
|
|
8
|
+
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
/**
|
|
11
|
+
* Symbol used to access the route's content fragment signal.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const FRAGMENT = Symbol('RouteElement:fragment');
|
|
15
|
+
/**
|
|
16
|
+
* Symbol used to access the route's URLPattern instance.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
const PATH_PATTERN = Symbol('RouteElement:path-pattern');
|
|
20
|
+
/**
|
|
21
|
+
* Symbol used to access the status signal of the route's `src` content.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
const SOURCE_STATUS = Symbol('RouteElement:source-status');
|
|
25
|
+
/**
|
|
26
|
+
* Symbol used by the router to mark the route as active or inactive.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
const SET_ACTIVE = Symbol('RouteElement:set-active');
|
|
30
|
+
/** Boolean attributes reflecting the status of the route's `src` content. */
|
|
31
|
+
const STATUS_ATTRIBUTES = ['loading', 'loaded', 'error'];
|
|
32
|
+
/**
|
|
33
|
+
* A custom element that defines a route in the router.
|
|
34
|
+
*
|
|
35
|
+
* The route's content comes from either:
|
|
36
|
+
* - an inline `<template>` child, or
|
|
37
|
+
* - a `src` URL, fetched the first time the route becomes active and cached
|
|
38
|
+
* until `src` changes. Optional `<template data-loading>` and
|
|
39
|
+
* `<template data-error>` children are rendered while loading and on failure.
|
|
40
|
+
*
|
|
41
|
+
* The `path` attribute uses URLPattern syntax and supports:
|
|
42
|
+
* - Static paths: `/about`, `/users`
|
|
43
|
+
* - Dynamic segments: `/users/:id`, `/posts/:category/:slug`
|
|
44
|
+
* - Wildcards: `/blog/*`, `/docs/**`
|
|
45
|
+
*
|
|
46
|
+
* While a `src` is involved, the route reflects its status as one of the
|
|
47
|
+
* boolean attributes `loading`, `loaded` or `error`.
|
|
48
|
+
*
|
|
49
|
+
* @fires tp-route-load - The `src` content has loaded. `detail: { src }`
|
|
50
|
+
* @fires tp-route-error - The `src` content failed to load. `detail: { src, error }`
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```html
|
|
54
|
+
* <tp-router>
|
|
55
|
+
* <tp-route path="/">
|
|
56
|
+
* <template><h1>Home Page</h1></template>
|
|
57
|
+
* </tp-route>
|
|
58
|
+
* <tp-route path="/docs/:slug" src="/partials/docs.html">
|
|
59
|
+
* <template data-loading><p>Loading…</p></template>
|
|
60
|
+
* <template data-error><p>Could not load the docs.</p></template>
|
|
61
|
+
* </tp-route>
|
|
62
|
+
* <tp-router-outlet></tp-router-outlet>
|
|
63
|
+
* </tp-router>
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
let RouteElement = class RouteElement extends LitElement {
|
|
67
|
+
constructor() {
|
|
68
|
+
super(...arguments);
|
|
69
|
+
/** The route's `<template>` children, grouped by role. */
|
|
70
|
+
this.#templates = signal(readRouteTemplates(this));
|
|
71
|
+
/** Loader and cache for the `src` content. */
|
|
72
|
+
this.#source = new RouteSource(state => this.#onSourceChange(state));
|
|
73
|
+
/** Whether the router currently matches this route. */
|
|
74
|
+
this.#active = false;
|
|
75
|
+
/**
|
|
76
|
+
* Signal with the fragment to render for this route:
|
|
77
|
+
* - no `src`: the inline template's content
|
|
78
|
+
* - `src` loaded: the fetched content
|
|
79
|
+
* - `src` failed: the `data-error` template's content
|
|
80
|
+
* - otherwise: the `data-loading` template's content
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
this[_a] = computed(() => {
|
|
84
|
+
const templates = this.#templates.get();
|
|
85
|
+
const { status, fragment } = this.#source.state.get();
|
|
86
|
+
switch (status) {
|
|
87
|
+
case 'none': return templates.content;
|
|
88
|
+
case 'loaded': return fragment;
|
|
89
|
+
case 'error': return templates.error;
|
|
90
|
+
default: return templates.loading;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Signal with the status of the route's `src` content.
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
this[_b] = computed(() => this.#source.state.get().status);
|
|
98
|
+
/**
|
|
99
|
+
* URLPattern instance for matching the current URL against this route's path.
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
this[_c] = null;
|
|
103
|
+
/**
|
|
104
|
+
* The URL pattern to match for this route.
|
|
105
|
+
* Uses URLPattern syntax with support for dynamic segments and wildcards.
|
|
106
|
+
*
|
|
107
|
+
* @attr path
|
|
108
|
+
* @example "/users/:id"
|
|
109
|
+
* @example "/blog/*"
|
|
110
|
+
*/
|
|
111
|
+
this.path = null;
|
|
112
|
+
/**
|
|
113
|
+
* URL of an HTML file to use as the route's content, resolved against
|
|
114
|
+
* `document.baseURI`. Fetched the first time the route becomes active and
|
|
115
|
+
* cached until it changes. Takes precedence over the inline `<template>`.
|
|
116
|
+
*
|
|
117
|
+
* The fetched HTML is trusted like `innerHTML`: it is inserted as-is,
|
|
118
|
+
* although its `<script>` elements do not run.
|
|
119
|
+
*
|
|
120
|
+
* @attr src
|
|
121
|
+
* @example "/partials/about.html"
|
|
122
|
+
*/
|
|
123
|
+
this.src = null;
|
|
124
|
+
/**
|
|
125
|
+
* Function that fetches the `src` content. Override it to add headers,
|
|
126
|
+
* credentials or caching, or to stub requests in tests. It receives the
|
|
127
|
+
* absolute URL and an `AbortSignal`, and must reject on failure.
|
|
128
|
+
*/
|
|
129
|
+
this.loader = defaultRouteSourceLoader;
|
|
130
|
+
/** Observes changes to child elements to detect template updates */
|
|
131
|
+
this.#templateObserver = new MutationObserver(() => {
|
|
132
|
+
this.#templates.set(readRouteTemplates(this));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** The route's `<template>` children, grouped by role. */
|
|
136
|
+
#templates;
|
|
137
|
+
/** Loader and cache for the `src` content. */
|
|
138
|
+
#source;
|
|
139
|
+
/** Whether the router currently matches this route. */
|
|
140
|
+
#active;
|
|
141
|
+
/** Observes changes to child elements to detect template updates */
|
|
142
|
+
#templateObserver;
|
|
143
|
+
/**
|
|
144
|
+
* Lifecycle callback when the element is connected to the DOM.
|
|
145
|
+
* Sets up observer to watch for template content changes.
|
|
146
|
+
*/
|
|
147
|
+
connectedCallback() {
|
|
148
|
+
super.connectedCallback();
|
|
149
|
+
this.#templateObserver.observe(this, { childList: true });
|
|
150
|
+
this.#templates.set(readRouteTemplates(this));
|
|
151
|
+
// Resume a request cancelled by a previous disconnect
|
|
152
|
+
if (this.#active)
|
|
153
|
+
this.#syncSource();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Lifecycle callback when an attribute changes.
|
|
157
|
+
* Updates the URLPattern when the path attribute changes, and the content
|
|
158
|
+
* source when the src attribute changes.
|
|
159
|
+
*
|
|
160
|
+
* @param name - The attribute name that changed
|
|
161
|
+
* @param _old - The old attribute value
|
|
162
|
+
* @param value - The new attribute value
|
|
163
|
+
*/
|
|
164
|
+
attributeChangedCallback(name, _old, value) {
|
|
165
|
+
super.attributeChangedCallback(name, _old, value);
|
|
166
|
+
switch (name) {
|
|
167
|
+
case 'path':
|
|
168
|
+
this[PATH_PATTERN] = value ? new URLPattern({ pathname: value }) : null;
|
|
169
|
+
break;
|
|
170
|
+
case 'src':
|
|
171
|
+
this.#syncSource();
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Picks up `src` changes made through the property. Loads the new content
|
|
177
|
+
* right away when the route is active.
|
|
178
|
+
*/
|
|
179
|
+
willUpdate(changed) {
|
|
180
|
+
super.willUpdate(changed);
|
|
181
|
+
if (changed.has('src'))
|
|
182
|
+
this.#syncSource();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Called by the router when this route starts or stops matching.
|
|
186
|
+
* Activating a route with a `src` loads its content unless already cached.
|
|
187
|
+
*
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
[(_a = FRAGMENT, _b = SOURCE_STATUS, _c = PATH_PATTERN, SET_ACTIVE)](active) {
|
|
191
|
+
this.#active = active;
|
|
192
|
+
this.#syncSource();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Points the source at the current `src` and loads it when active.
|
|
196
|
+
*/
|
|
197
|
+
#syncSource() {
|
|
198
|
+
this.#source.setUrl(this.src ? resolveRouteSrc(this.src) : null);
|
|
199
|
+
if (this.#active)
|
|
200
|
+
void this.#source.load(this.loader);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Reflects the source status as attributes and dispatches load/error events.
|
|
204
|
+
*/
|
|
205
|
+
#onSourceChange({ status, url, error }) {
|
|
206
|
+
for (const attribute of STATUS_ATTRIBUTES) {
|
|
207
|
+
this.toggleAttribute(attribute, attribute === status);
|
|
208
|
+
}
|
|
209
|
+
if (!url)
|
|
210
|
+
return;
|
|
211
|
+
if (status === 'loaded')
|
|
212
|
+
this.dispatchEvent(createRouteSourceEvent(ROUTE_LOAD_EVENT, { src: url }));
|
|
213
|
+
if (status === 'error')
|
|
214
|
+
this.dispatchEvent(createRouteSourceEvent(ROUTE_ERROR_EVENT, { src: url, error }));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Lifecycle callback when the element is disconnected from the DOM.
|
|
218
|
+
* Cleans up the template observer and cancels any in-flight request.
|
|
219
|
+
*/
|
|
220
|
+
disconnectedCallback() {
|
|
221
|
+
super.disconnectedCallback();
|
|
222
|
+
this.#templateObserver.disconnect();
|
|
223
|
+
this.#source.abort();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
__decorate([
|
|
227
|
+
property({ type: String }),
|
|
228
|
+
__metadata("design:type", Object)
|
|
229
|
+
], RouteElement.prototype, "path", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: String }),
|
|
232
|
+
__metadata("design:type", Object)
|
|
233
|
+
], RouteElement.prototype, "src", void 0);
|
|
234
|
+
RouteElement = __decorate([
|
|
235
|
+
customElement('tp-route')
|
|
236
|
+
], RouteElement);
|
|
237
|
+
|
|
238
|
+
export { FRAGMENT, PATH_PATTERN, RouteElement, SET_ACTIVE, SOURCE_STATUS };
|
|
239
|
+
//# sourceMappingURL=route-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-element.js","sources":["../../../../libs/elements/src/router/route-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AA4BA;;;AAGG;MACU,QA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B,EAAE;AAE5B,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE;AACnC,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;IACtB;;AAxHA,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACA,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAc3B,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACD,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,KAAA,EAAA,MAAA,CAAA;AAjEf,YAAY,GAAA,UAAA,CAAA;IADxB,aAAa,CAAC,UAAU;AACZ,CAAA,EAAA,YAAY,CA4KxB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** Fired on a `<tp-route>` when its `src` content has loaded. Bubbles and is composed. */
|
|
4
|
+
const ROUTE_LOAD_EVENT = "tp-route-load";
|
|
5
|
+
/** Fired on a `<tp-route>` when its `src` content failed to load. Bubbles and is composed. */
|
|
6
|
+
const ROUTE_ERROR_EVENT = "tp-route-error";
|
|
7
|
+
function createRouteSourceEvent(type, detail) {
|
|
8
|
+
return new CustomEvent(type, { detail, bubbles: true, composed: true });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.ROUTE_ERROR_EVENT = ROUTE_ERROR_EVENT;
|
|
12
|
+
exports.ROUTE_LOAD_EVENT = ROUTE_LOAD_EVENT;
|
|
13
|
+
exports.createRouteSourceEvent = createRouteSourceEvent;
|
|
14
|
+
//# sourceMappingURL=route-events.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-events.cjs","sources":["../../../../libs/elements/src/router/route-events.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,gBAAgB,GAAG;AAChC;AACO,MAAM,iBAAiB,GAAG;AAmB3B,SAAU,sBAAsB,CACpC,IAAwD,EACxD,MAA8B,EAAA;AAE9B,IAAA,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACzE;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Fired on a `<tp-route>` when its `src` content has loaded. Bubbles and is composed. */
|
|
2
|
+
const ROUTE_LOAD_EVENT = "tp-route-load";
|
|
3
|
+
/** Fired on a `<tp-route>` when its `src` content failed to load. Bubbles and is composed. */
|
|
4
|
+
const ROUTE_ERROR_EVENT = "tp-route-error";
|
|
5
|
+
function createRouteSourceEvent(type, detail) {
|
|
6
|
+
return new CustomEvent(type, { detail, bubbles: true, composed: true });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { ROUTE_ERROR_EVENT, ROUTE_LOAD_EVENT, createRouteSourceEvent };
|
|
10
|
+
//# sourceMappingURL=route-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-events.js","sources":["../../../../libs/elements/src/router/route-events.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,gBAAgB,GAAG;AAChC;AACO,MAAM,iBAAiB,GAAG;AAmB3B,SAAU,sBAAsB,CACpC,IAAwD,EACxD,MAA8B,EAAA;AAE9B,IAAA,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACzE;;;;"}
|