@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
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var signals = require('@lit-labs/signals');
|
|
4
|
+
|
|
5
|
+
const NO_SOURCE = Object.freeze({ status: "none", url: null, fragment: null, error: null });
|
|
6
|
+
/**
|
|
7
|
+
* Default {@link RouteSourceLoader}: a plain `fetch` that rejects on non-2xx
|
|
8
|
+
* responses.
|
|
9
|
+
*/
|
|
10
|
+
const defaultRouteSourceLoader = async (url, signal) => {
|
|
11
|
+
const response = await fetch(url, { signal });
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new Error(`Failed to load route source "${url}": ${response.status} ${response.statusText}`);
|
|
14
|
+
}
|
|
15
|
+
return response.text();
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a `src` attribute value against the document base URL.
|
|
19
|
+
*/
|
|
20
|
+
function resolveRouteSrc(src, base = document.baseURI) {
|
|
21
|
+
return new URL(src, base).href;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses an HTML string into an inert `DocumentFragment`.
|
|
25
|
+
*
|
|
26
|
+
* Parsing goes through a detached `<template>`, so `<script>` elements are
|
|
27
|
+
* never executed (not even when the fragment is later cloned into the
|
|
28
|
+
* document) and `<html>` / `<head>` / `<body>` wrappers are dropped.
|
|
29
|
+
*/
|
|
30
|
+
function parseRouteHtml(html) {
|
|
31
|
+
const template = document.createElement("template");
|
|
32
|
+
template.innerHTML = html;
|
|
33
|
+
return template.content;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Loads, parses and caches the remote content of a single route.
|
|
37
|
+
*
|
|
38
|
+
* - Content is requested once per URL and cached until the URL changes.
|
|
39
|
+
* - Concurrent {@link load} calls share the in-flight request.
|
|
40
|
+
* - Changing the URL or calling {@link abort} cancels the in-flight request;
|
|
41
|
+
* late responses for a superseded request are ignored.
|
|
42
|
+
* - Failures are not cached: the next {@link load} retries.
|
|
43
|
+
*/
|
|
44
|
+
class RouteSource {
|
|
45
|
+
#controller;
|
|
46
|
+
#pending;
|
|
47
|
+
#onChange;
|
|
48
|
+
/**
|
|
49
|
+
* @param onChange - Called synchronously after every state transition.
|
|
50
|
+
*/
|
|
51
|
+
constructor(onChange = () => undefined) {
|
|
52
|
+
/** Reactive snapshot of the current state. */
|
|
53
|
+
this.state = signals.signal(NO_SOURCE);
|
|
54
|
+
this.#controller = null;
|
|
55
|
+
this.#pending = null;
|
|
56
|
+
this.#onChange = onChange;
|
|
57
|
+
}
|
|
58
|
+
/** Current absolute URL, or `null` when the route has no `src`. */
|
|
59
|
+
get url() {
|
|
60
|
+
return this.state.get().url;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Points the source at a new URL. A no-op when the URL is unchanged;
|
|
64
|
+
* otherwise any in-flight request is cancelled and the cache is dropped.
|
|
65
|
+
*/
|
|
66
|
+
setUrl(url) {
|
|
67
|
+
if (url === this.url)
|
|
68
|
+
return;
|
|
69
|
+
this.#cancel();
|
|
70
|
+
this.#set(url ? { status: "idle", url, fragment: null, error: null } : NO_SOURCE);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Ensures the content for the current URL is loaded.
|
|
74
|
+
*
|
|
75
|
+
* @returns A promise that settles once the content is loaded or failed.
|
|
76
|
+
* It never rejects; failures are reported through {@link state}.
|
|
77
|
+
*/
|
|
78
|
+
load(loader) {
|
|
79
|
+
const { status, url } = this.state.get();
|
|
80
|
+
if (!url || status === "loaded")
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
if (this.#pending)
|
|
83
|
+
return this.#pending;
|
|
84
|
+
const controller = new AbortController();
|
|
85
|
+
this.#controller = controller;
|
|
86
|
+
this.#set({ status: "loading", url, fragment: null, error: null });
|
|
87
|
+
const pending = this.#request(loader, url, controller).finally(() => {
|
|
88
|
+
if (this.#controller !== controller)
|
|
89
|
+
return;
|
|
90
|
+
this.#controller = null;
|
|
91
|
+
this.#pending = null;
|
|
92
|
+
});
|
|
93
|
+
this.#pending = pending;
|
|
94
|
+
return pending;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Cancels the in-flight request, if any. Already loaded content is kept.
|
|
98
|
+
*/
|
|
99
|
+
abort() {
|
|
100
|
+
if (!this.#controller)
|
|
101
|
+
return;
|
|
102
|
+
const { url } = this.state.get();
|
|
103
|
+
this.#cancel();
|
|
104
|
+
this.#set({ status: "idle", url, fragment: null, error: null });
|
|
105
|
+
}
|
|
106
|
+
async #request(loader, url, controller) {
|
|
107
|
+
try {
|
|
108
|
+
const html = await loader(url, controller.signal);
|
|
109
|
+
if (controller.signal.aborted)
|
|
110
|
+
return;
|
|
111
|
+
this.#set({ status: "loaded", url, fragment: parseRouteHtml(html), error: null });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (controller.signal.aborted)
|
|
115
|
+
return;
|
|
116
|
+
this.#set({ status: "error", url, fragment: null, error });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
#cancel() {
|
|
120
|
+
this.#controller?.abort();
|
|
121
|
+
this.#controller = null;
|
|
122
|
+
this.#pending = null;
|
|
123
|
+
}
|
|
124
|
+
#set(state) {
|
|
125
|
+
this.state.set(state);
|
|
126
|
+
this.#onChange(state);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
exports.RouteSource = RouteSource;
|
|
131
|
+
exports.defaultRouteSourceLoader = defaultRouteSourceLoader;
|
|
132
|
+
exports.parseRouteHtml = parseRouteHtml;
|
|
133
|
+
exports.resolveRouteSrc = resolveRouteSrc;
|
|
134
|
+
//# sourceMappingURL=route-source.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-source.cjs","sources":["../../../../libs/elements/src/router/route-source.ts"],"sourcesContent":[null],"names":["signal"],"mappings":";;;;AAgCA,MAAM,SAAS,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAE7G;;;AAGG;AACI,MAAM,wBAAwB,GAAsB,OAAO,GAAG,EAAE,MAAM,KAAI;IAC/E,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC;AAE7C,IAAA,IAAI,CAAC,QAA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EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACjE;AAEA,IAAA,MAAM,QAAQ,CAAC,MAAyB,EAAE,GAAW,EAAE,UAA2B,EAAA;AAChF,QAAA,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC;AAEjD,YAAA,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE;YAE/B,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE;AAE/B,YAAA,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC5D;IACF;IAEA,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE;AACzB,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI;AACvB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;IACtB;AAEA,IAAA,IAAI,CAAC,KAAuB,EAAA;AAC1B,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;IACvB;AACD;;;;;;;"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { signal } from '@lit-labs/signals';
|
|
2
|
+
|
|
3
|
+
const NO_SOURCE = Object.freeze({ status: "none", url: null, fragment: null, error: null });
|
|
4
|
+
/**
|
|
5
|
+
* Default {@link RouteSourceLoader}: a plain `fetch` that rejects on non-2xx
|
|
6
|
+
* responses.
|
|
7
|
+
*/
|
|
8
|
+
const defaultRouteSourceLoader = async (url, signal) => {
|
|
9
|
+
const response = await fetch(url, { signal });
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw new Error(`Failed to load route source "${url}": ${response.status} ${response.statusText}`);
|
|
12
|
+
}
|
|
13
|
+
return response.text();
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a `src` attribute value against the document base URL.
|
|
17
|
+
*/
|
|
18
|
+
function resolveRouteSrc(src, base = document.baseURI) {
|
|
19
|
+
return new URL(src, base).href;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parses an HTML string into an inert `DocumentFragment`.
|
|
23
|
+
*
|
|
24
|
+
* Parsing goes through a detached `<template>`, so `<script>` elements are
|
|
25
|
+
* never executed (not even when the fragment is later cloned into the
|
|
26
|
+
* document) and `<html>` / `<head>` / `<body>` wrappers are dropped.
|
|
27
|
+
*/
|
|
28
|
+
function parseRouteHtml(html) {
|
|
29
|
+
const template = document.createElement("template");
|
|
30
|
+
template.innerHTML = html;
|
|
31
|
+
return template.content;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Loads, parses and caches the remote content of a single route.
|
|
35
|
+
*
|
|
36
|
+
* - Content is requested once per URL and cached until the URL changes.
|
|
37
|
+
* - Concurrent {@link load} calls share the in-flight request.
|
|
38
|
+
* - Changing the URL or calling {@link abort} cancels the in-flight request;
|
|
39
|
+
* late responses for a superseded request are ignored.
|
|
40
|
+
* - Failures are not cached: the next {@link load} retries.
|
|
41
|
+
*/
|
|
42
|
+
class RouteSource {
|
|
43
|
+
#controller;
|
|
44
|
+
#pending;
|
|
45
|
+
#onChange;
|
|
46
|
+
/**
|
|
47
|
+
* @param onChange - Called synchronously after every state transition.
|
|
48
|
+
*/
|
|
49
|
+
constructor(onChange = () => undefined) {
|
|
50
|
+
/** Reactive snapshot of the current state. */
|
|
51
|
+
this.state = signal(NO_SOURCE);
|
|
52
|
+
this.#controller = null;
|
|
53
|
+
this.#pending = null;
|
|
54
|
+
this.#onChange = onChange;
|
|
55
|
+
}
|
|
56
|
+
/** Current absolute URL, or `null` when the route has no `src`. */
|
|
57
|
+
get url() {
|
|
58
|
+
return this.state.get().url;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Points the source at a new URL. A no-op when the URL is unchanged;
|
|
62
|
+
* otherwise any in-flight request is cancelled and the cache is dropped.
|
|
63
|
+
*/
|
|
64
|
+
setUrl(url) {
|
|
65
|
+
if (url === this.url)
|
|
66
|
+
return;
|
|
67
|
+
this.#cancel();
|
|
68
|
+
this.#set(url ? { status: "idle", url, fragment: null, error: null } : NO_SOURCE);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Ensures the content for the current URL is loaded.
|
|
72
|
+
*
|
|
73
|
+
* @returns A promise that settles once the content is loaded or failed.
|
|
74
|
+
* It never rejects; failures are reported through {@link state}.
|
|
75
|
+
*/
|
|
76
|
+
load(loader) {
|
|
77
|
+
const { status, url } = this.state.get();
|
|
78
|
+
if (!url || status === "loaded")
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
if (this.#pending)
|
|
81
|
+
return this.#pending;
|
|
82
|
+
const controller = new AbortController();
|
|
83
|
+
this.#controller = controller;
|
|
84
|
+
this.#set({ status: "loading", url, fragment: null, error: null });
|
|
85
|
+
const pending = this.#request(loader, url, controller).finally(() => {
|
|
86
|
+
if (this.#controller !== controller)
|
|
87
|
+
return;
|
|
88
|
+
this.#controller = null;
|
|
89
|
+
this.#pending = null;
|
|
90
|
+
});
|
|
91
|
+
this.#pending = pending;
|
|
92
|
+
return pending;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Cancels the in-flight request, if any. Already loaded content is kept.
|
|
96
|
+
*/
|
|
97
|
+
abort() {
|
|
98
|
+
if (!this.#controller)
|
|
99
|
+
return;
|
|
100
|
+
const { url } = this.state.get();
|
|
101
|
+
this.#cancel();
|
|
102
|
+
this.#set({ status: "idle", url, fragment: null, error: null });
|
|
103
|
+
}
|
|
104
|
+
async #request(loader, url, controller) {
|
|
105
|
+
try {
|
|
106
|
+
const html = await loader(url, controller.signal);
|
|
107
|
+
if (controller.signal.aborted)
|
|
108
|
+
return;
|
|
109
|
+
this.#set({ status: "loaded", url, fragment: parseRouteHtml(html), error: null });
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (controller.signal.aborted)
|
|
113
|
+
return;
|
|
114
|
+
this.#set({ status: "error", url, fragment: null, error });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
#cancel() {
|
|
118
|
+
this.#controller?.abort();
|
|
119
|
+
this.#controller = null;
|
|
120
|
+
this.#pending = null;
|
|
121
|
+
}
|
|
122
|
+
#set(state) {
|
|
123
|
+
this.state.set(state);
|
|
124
|
+
this.#onChange(state);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { RouteSource, defaultRouteSourceLoader, parseRouteHtml, resolveRouteSrc };
|
|
129
|
+
//# sourceMappingURL=route-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-source.js","sources":["../../../../libs/elements/src/router/route-source.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAgCA,MAAM,SAAS,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAE7G;;;AAGG;AACI,MAAM,wBAAwB,GAAsB,OAAO,GAAG,EAAE,MAAM,KAAI;IAC/E,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC;AAE7C,IAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AAChB,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,6BAAA,EAAgC,GAAG,CAAA,GAAA,EAAM,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAA,CAAE,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AAG,MAAM,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC;AAEjD,YAAA,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE;YAE/B,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE;AAE/B,YAAA,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC5D;IACF;IAEA,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE;AACzB,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI;AACvB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;IACtB;AAEA,IAAA,IAAI,CAAC,KAAuB,EAAA;AAC1B,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;IACvB;AACD;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collects the direct `<template>` children of a route element by role.
|
|
5
|
+
* For each role the first matching template wins.
|
|
6
|
+
*/
|
|
7
|
+
function readRouteTemplates(route) {
|
|
8
|
+
const templates = Array.from(route.children).filter((child) => child instanceof HTMLTemplateElement);
|
|
9
|
+
const find = (predicate) => templates.find(predicate)?.content ?? null;
|
|
10
|
+
return {
|
|
11
|
+
content: find(template => !template.hasAttribute("data-loading") && !template.hasAttribute("data-error")),
|
|
12
|
+
loading: find(template => template.hasAttribute("data-loading")),
|
|
13
|
+
error: find(template => template.hasAttribute("data-error")),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.readRouteTemplates = readRouteTemplates;
|
|
18
|
+
//# sourceMappingURL=route-templates.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-templates.cjs","sources":["../../../../libs/elements/src/router/route-templates.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAYA;;;AAGG;AACG,SAAU,kBAAkB,CAAC,KAAc,EAAA;IAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjD,CAAC,KAAK,KAAmC,KAAK,YAAY,mBAAmB,CAC9E;AACD,IAAA,MAAM,IAAI,GAAG,CAAC,SAAqD,KACjE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,IAAI,IAAI;IAE5C,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;AACzG,QAAA,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AAChE,QAAA,KAAK,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;KAC7D;AACH;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects the direct `<template>` children of a route element by role.
|
|
3
|
+
* For each role the first matching template wins.
|
|
4
|
+
*/
|
|
5
|
+
function readRouteTemplates(route) {
|
|
6
|
+
const templates = Array.from(route.children).filter((child) => child instanceof HTMLTemplateElement);
|
|
7
|
+
const find = (predicate) => templates.find(predicate)?.content ?? null;
|
|
8
|
+
return {
|
|
9
|
+
content: find(template => !template.hasAttribute("data-loading") && !template.hasAttribute("data-error")),
|
|
10
|
+
loading: find(template => template.hasAttribute("data-loading")),
|
|
11
|
+
error: find(template => template.hasAttribute("data-error")),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { readRouteTemplates };
|
|
16
|
+
//# sourceMappingURL=route-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-templates.js","sources":["../../../../libs/elements/src/router/route-templates.ts"],"sourcesContent":[null],"names":[],"mappings":"AAYA;;;AAGG;AACG,SAAU,kBAAkB,CAAC,KAAc,EAAA;IAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjD,CAAC,KAAK,KAAmC,KAAK,YAAY,mBAAmB,CAC9E;AACD,IAAA,MAAM,IAAI,GAAG,CAAC,SAAqD,KACjE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,IAAI,IAAI;IAE5C,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;AACzG,QAAA,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AAChE,QAAA,KAAK,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;KAC7D;AACH;;;;"}
|
|
@@ -21,13 +21,13 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
21
21
|
* ```html
|
|
22
22
|
* <head>
|
|
23
23
|
* <!-- All routers will use hash routing by default -->
|
|
24
|
-
* <
|
|
24
|
+
* <tp-router-config history="hash"></tp-router-config>
|
|
25
25
|
* </head>
|
|
26
26
|
* <body>
|
|
27
|
-
* <
|
|
27
|
+
* <tp-router>
|
|
28
28
|
* <!-- Uses hash history (global default) -->
|
|
29
|
-
* <
|
|
30
|
-
* </
|
|
29
|
+
* <tp-route path="/home">...</tp-route>
|
|
30
|
+
* </tp-router>
|
|
31
31
|
* </body>
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
@@ -40,20 +40,20 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
40
40
|
* ```html
|
|
41
41
|
* <body>
|
|
42
42
|
* <!-- Section 1: Hash routing -->
|
|
43
|
-
* <
|
|
44
|
-
* <
|
|
43
|
+
* <tp-router-config history="hash">
|
|
44
|
+
* <tp-router>
|
|
45
45
|
* <!-- Uses hash history from parent config -->
|
|
46
|
-
* <
|
|
47
|
-
* </
|
|
48
|
-
* </
|
|
46
|
+
* <tp-route path="/dashboard">...</tp-route>
|
|
47
|
+
* </tp-router>
|
|
48
|
+
* </tp-router-config>
|
|
49
49
|
*
|
|
50
50
|
* <!-- Section 2: Memory routing (isolated) -->
|
|
51
|
-
* <
|
|
52
|
-
* <
|
|
51
|
+
* <tp-router-config history="memory">
|
|
52
|
+
* <tp-router>
|
|
53
53
|
* <!-- Uses memory history from parent config -->
|
|
54
|
-
* <
|
|
55
|
-
* </
|
|
56
|
-
* </
|
|
54
|
+
* <tp-route path="/preview">...</tp-route>
|
|
55
|
+
* </tp-router>
|
|
56
|
+
* </tp-router-config>
|
|
57
57
|
* </body>
|
|
58
58
|
* ```
|
|
59
59
|
*
|
|
@@ -67,7 +67,7 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
67
67
|
* <!DOCTYPE html>
|
|
68
68
|
* <html>
|
|
69
69
|
* <head>
|
|
70
|
-
* <
|
|
70
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
71
71
|
* </head>
|
|
72
72
|
* <body>
|
|
73
73
|
* <!-- All routers use browser history -->
|
|
@@ -82,16 +82,16 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
82
82
|
* ```html
|
|
83
83
|
* <head>
|
|
84
84
|
* <!-- Global: browser history -->
|
|
85
|
-
* <
|
|
85
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
86
86
|
* </head>
|
|
87
87
|
* <body>
|
|
88
88
|
* <!-- Main app uses browser history -->
|
|
89
|
-
* <
|
|
89
|
+
* <tp-router>...</tp-router>
|
|
90
90
|
*
|
|
91
91
|
* <!-- Admin section uses hash history -->
|
|
92
|
-
* <
|
|
93
|
-
* <
|
|
94
|
-
* </
|
|
92
|
+
* <tp-router-config history="hash">
|
|
93
|
+
* <tp-router>...</tp-router>
|
|
94
|
+
* </tp-router-config>
|
|
95
95
|
* </body>
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
@@ -102,17 +102,17 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
102
102
|
* ```html
|
|
103
103
|
* <body>
|
|
104
104
|
* <!-- Each component has independent navigation -->
|
|
105
|
-
* <
|
|
105
|
+
* <tp-router-config history="memory:component1">
|
|
106
106
|
* <my-widget>
|
|
107
|
-
* <
|
|
107
|
+
* <tp-router>...</tp-router>
|
|
108
108
|
* </my-widget>
|
|
109
|
-
* </
|
|
109
|
+
* </tp-router-config>
|
|
110
110
|
*
|
|
111
|
-
* <
|
|
111
|
+
* <tp-router-config history="memory:component2">
|
|
112
112
|
* <my-widget>
|
|
113
|
-
* <
|
|
113
|
+
* <tp-router>...</tp-router>
|
|
114
114
|
* </my-widget>
|
|
115
|
-
* </
|
|
115
|
+
* </tp-router-config>
|
|
116
116
|
* </body>
|
|
117
117
|
* ```
|
|
118
118
|
*
|
|
@@ -125,11 +125,11 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
125
125
|
*
|
|
126
126
|
* it('should navigate', async () => {
|
|
127
127
|
* const el = await fixture(html`
|
|
128
|
-
* <
|
|
129
|
-
* <
|
|
130
|
-
* <
|
|
131
|
-
* </
|
|
132
|
-
* </
|
|
128
|
+
* <tp-router-config history="memory:test">
|
|
129
|
+
* <tp-router>
|
|
130
|
+
* <tp-route path="/test">Test Page</tp-route>
|
|
131
|
+
* </tp-router>
|
|
132
|
+
* </tp-router-config>
|
|
133
133
|
* `);
|
|
134
134
|
*
|
|
135
135
|
* // Test navigation without affecting browser URL
|
|
@@ -141,56 +141,56 @@ var historyManaged = require('./history-managed.cjs');
|
|
|
141
141
|
* Router components resolve their history in this order:
|
|
142
142
|
*
|
|
143
143
|
* 1. **Own `history` attribute** (highest priority)
|
|
144
|
-
* 2. **Parent `
|
|
145
|
-
* 3. **Global `
|
|
144
|
+
* 2. **Parent `tp-router-config`** (local configuration)
|
|
145
|
+
* 3. **Global `tp-router-config`** (in `<head>`)
|
|
146
146
|
* 4. **Default** (`"browser"`)
|
|
147
147
|
*
|
|
148
148
|
* ## Best Practices
|
|
149
149
|
*
|
|
150
|
-
* ✅ **DO**: Place one `
|
|
150
|
+
* ✅ **DO**: Place one `tp-router-config` in `<head>` for global settings
|
|
151
151
|
*
|
|
152
152
|
* ```html
|
|
153
153
|
* <head>
|
|
154
|
-
* <
|
|
154
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
155
155
|
* </head>
|
|
156
156
|
* ```
|
|
157
157
|
*
|
|
158
158
|
* ✅ **DO**: Use local configs for sections with different routing needs
|
|
159
159
|
*
|
|
160
160
|
* ```html
|
|
161
|
-
* <
|
|
161
|
+
* <tp-router-config history="memory">
|
|
162
162
|
* <component-preview>...</component-preview>
|
|
163
|
-
* </
|
|
163
|
+
* </tp-router-config>
|
|
164
164
|
* ```
|
|
165
165
|
*
|
|
166
166
|
* ✅ **DO**: Use named memory history for isolated components
|
|
167
167
|
*
|
|
168
168
|
* ```html
|
|
169
|
-
* <
|
|
169
|
+
* <tp-router-config history="memory:sidebar">
|
|
170
170
|
* <sidebar-nav>...</sidebar-nav>
|
|
171
|
-
* </
|
|
171
|
+
* </tp-router-config>
|
|
172
172
|
* ```
|
|
173
173
|
*
|
|
174
174
|
* ❌ **DON'T**: Place multiple configs in `<head>` (last one wins)
|
|
175
175
|
*
|
|
176
176
|
* ```html
|
|
177
177
|
* <head>
|
|
178
|
-
* <
|
|
179
|
-
* <
|
|
178
|
+
* <tp-router-config history="browser"></tp-router-config>
|
|
179
|
+
* <tp-router-config history="hash"></tp-router-config> <!-- Overrides above -->
|
|
180
180
|
* </head>
|
|
181
181
|
* ```
|
|
182
182
|
*
|
|
183
183
|
* ❌ **DON'T**: Nest configs unnecessarily (inner configs take precedence)
|
|
184
184
|
*
|
|
185
185
|
* ```html
|
|
186
|
-
* <
|
|
187
|
-
* <
|
|
186
|
+
* <tp-router-config history="browser">
|
|
187
|
+
* <tp-router-config history="hash">
|
|
188
188
|
* <!-- Uses hash, not browser -->
|
|
189
|
-
* </
|
|
190
|
-
* </
|
|
189
|
+
* </tp-router-config>
|
|
190
|
+
* </tp-router-config>
|
|
191
191
|
* ```
|
|
192
192
|
*/
|
|
193
|
-
exports.
|
|
193
|
+
exports.RouterConfigElement = class RouterConfigElement extends historyManaged.HistoryManaged(signalWatcherLitElement.SignalWatcherLitElement) {
|
|
194
194
|
/**
|
|
195
195
|
* Cleanup function for the global history effect.
|
|
196
196
|
* Only used when the element is placed in `<head>`.
|
|
@@ -207,7 +207,7 @@ exports.ThaRouterConfig = class ThaRouterConfig extends historyManaged.HistoryMa
|
|
|
207
207
|
super.connectedCallback();
|
|
208
208
|
if (!document.head.contains(this))
|
|
209
209
|
return;
|
|
210
|
-
console.log('
|
|
210
|
+
console.log('RouterConfigElement: Setting global history type to', this[historyManaged.HISTORY_TYPE].get());
|
|
211
211
|
// Set the global history type when this element is connected in <head>
|
|
212
212
|
this.#globalHistoryUnsubscribe = this.updateEffect(() => {
|
|
213
213
|
history.GLOBAL_HISTORY_TYPE.set(this[historyManaged.HISTORY_TYPE].get());
|
|
@@ -235,7 +235,7 @@ exports.ThaRouterConfig = class ThaRouterConfig extends historyManaged.HistoryMa
|
|
|
235
235
|
return this;
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
|
-
exports.
|
|
239
|
-
decorators_js.customElement('
|
|
240
|
-
], exports.
|
|
241
|
-
//# sourceMappingURL=
|
|
238
|
+
exports.RouterConfigElement = tslib.__decorate([
|
|
239
|
+
decorators_js.customElement('tp-router-config')
|
|
240
|
+
], exports.RouterConfigElement);
|
|
241
|
+
//# sourceMappingURL=router-config-element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-config-element.cjs","sources":["../../../../libs/elements/src/router/router-config-element.ts"],"sourcesContent":[null],"names":["RouterConfigElement","HistoryManaged","SignalWatcherLitElement","noop","HISTORY_TYPE","GLOBAL_HISTORY_TYPE","__decorate","customElement"],"mappings":";;;;;;;;;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsLG;AAEUA,2BAAmB,GAAzB,MAAM,mBAAoB,SAAQC,6BAAc,CAACC,+CAAuB,CAAC,CAAA;AAC9E;;;;AAIG;IACH,yBAAyB,GAAGC,SAAI;AAEhC;;;;;AAKG;IACM,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;QAEzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE;AAEnC,QAAA,OAAO,CAAC,GAAG,CAAC,qDAAqD,EAAE,IAAI,CAACC,2BAAY,CAAC,CAAC,GAAG,EAAE,CAAC;;QAG5F,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,YAAY,CAAC,MAAK;YACtDC,2BAAmB,CAAC,GAAG,CAAC,IAAI,CAACD,2BAAY,CAAC,CAAC,GAAG,EAAG,CAAC;AACpD,QAAA,CAAC,CAAC;IACJ;AAEA;;;;AAIG;IACM,oBAAoB,GAAA;QAC3B,KAAK,CAAC,oBAAoB,EAAE;AAE5B,QAAA,IAAI;YACF,IAAI,CAAC,yBAAyB,EAAE;QAClC;QAAE,MAAM,EAAC;IACX;AAEA;;;;;AAKG;IACgB,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;;AAhDWJ,2BAAmB,GAAAM,gBAAA,CAAA;IAD/BC,2BAAa,CAAC,kBAAkB;AACpB,CAAA,EAAAP,2BAAmB,CAiD/B;;"}
|