@a11d/lit-application 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Application.d.ts +22 -22
- package/dist/Application.js +113 -112
- package/dist/Dialog/Dialog.d.ts +21 -21
- package/dist/Dialog/Dialog.js +1 -1
- package/dist/Dialog/DialogCancelledError.d.ts +4 -4
- package/dist/Dialog/DialogCancelledError.js +5 -5
- package/dist/Dialog/DialogComponent.d.ts +44 -44
- package/dist/Dialog/DialogComponent.js +164 -163
- package/dist/Dialog/DialogHost.d.ts +10 -10
- package/dist/Dialog/DialogHost.js +13 -13
- package/dist/Dialog/PageDialog.d.ts +12 -12
- package/dist/Dialog/PageDialog.js +23 -23
- package/dist/Dialog/index.d.ts +5 -5
- package/dist/Dialog/index.js +5 -5
- package/dist/Notification/NotificationComponent.d.ts +5 -5
- package/dist/Notification/NotificationComponent.js +1 -1
- package/dist/Notification/NotificationHost.d.ts +43 -43
- package/dist/Notification/NotificationHost.js +93 -93
- package/dist/Notification/index.d.ts +2 -2
- package/dist/Notification/index.js +2 -2
- package/dist/Page/Page.d.ts +5 -5
- package/dist/Page/Page.js +1 -1
- package/dist/Page/PageComponent.d.ts +21 -21
- package/dist/Page/PageComponent.js +40 -39
- package/dist/Page/PageError.d.ts +17 -17
- package/dist/Page/PageError.js +69 -69
- package/dist/Page/PageHost.d.ts +10 -10
- package/dist/Page/PageHost.js +19 -19
- package/dist/Page/index.d.ts +4 -4
- package/dist/Page/index.js +4 -4
- package/dist/PwaHelper/Manifest.d.ts +17 -17
- package/dist/PwaHelper/Manifest.js +1 -1
- package/dist/PwaHelper/ManifestProvider.d.ts +4 -4
- package/dist/PwaHelper/ManifestProvider.js +17 -17
- package/dist/PwaHelper/PwaHelper.d.ts +15 -15
- package/dist/PwaHelper/PwaHelper.js +40 -40
- package/dist/PwaHelper/index.d.ts +3 -3
- package/dist/PwaHelper/index.js +3 -3
- package/dist/Router/Router.d.ts +16 -16
- package/dist/Router/Router.js +39 -38
- package/dist/Router/RouterController.d.ts +9 -9
- package/dist/Router/RouterController.js +27 -27
- package/dist/Router/RoutesContainer.d.ts +18 -18
- package/dist/Router/RoutesContainer.js +9 -9
- package/dist/Router/index.d.ts +5 -5
- package/dist/Router/index.js +5 -5
- package/dist/Router/route.d.ts +5 -5
- package/dist/Router/route.js +20 -20
- package/dist/Router/routerLink.d.ts +26 -26
- package/dist/Router/routerLink.js +109 -109
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/HookSet.d.ts +4 -4
- package/dist/utilities/HookSet.js +5 -5
- package/dist/utilities/HttpError.d.ts +6 -6
- package/dist/utilities/HttpError.js +47 -46
- package/dist/utilities/HttpErrorCode.d.ts +40 -40
- package/dist/utilities/HttpErrorCode.js +1 -1
- package/dist/utilities/RootCssInjectorController.d.ts +11 -11
- package/dist/utilities/RootCssInjectorController.js +20 -20
- package/dist/utilities/WindowHelper.d.ts +9 -9
- package/dist/utilities/WindowHelper.js +22 -21
- package/dist/utilities/index.d.ts +9 -9
- package/dist/utilities/index.js +9 -9
- package/dist/utilities/nonInertable.d.ts +2 -2
- package/dist/utilities/nonInertable.js +11 -11
- package/dist/utilities/queryInstanceElement.d.ts +2 -2
- package/dist/utilities/queryInstanceElement.js +9 -9
- package/dist/utilities/querySymbolizedElement.d.ts +2 -2
- package/dist/utilities/querySymbolizedElement.js +14 -14
- package/package.json +40 -40
- package/dist/utilities/LocalStorageEntry.d.ts +0 -13
- package/dist/utilities/LocalStorageEntry.d.ts.map +0 -1
- package/dist/utilities/LocalStorageEntry.js +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Manifest } from '../index.js';
|
|
2
|
-
declare global {
|
|
3
|
-
const manifest: Manifest | undefined;
|
|
4
|
-
}
|
|
1
|
+
import { type Manifest } from '../index.js';
|
|
2
|
+
declare global {
|
|
3
|
+
const manifest: Manifest | undefined;
|
|
4
|
+
}
|
|
5
5
|
//# sourceMappingURL=ManifestProvider.d.ts.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Application } from '../index.js';
|
|
2
|
-
Application.connectingHooks.add(async () => {
|
|
3
|
-
// @ts-expect-error - This is declared as a constant property
|
|
4
|
-
globalThis.manifest = undefined;
|
|
5
|
-
const manifestLink = globalThis.document.head.querySelector('link[rel=manifest]');
|
|
6
|
-
try {
|
|
7
|
-
if (manifestLink) {
|
|
8
|
-
const content = await fetch(manifestLink.href);
|
|
9
|
-
const jsonText = await content.text();
|
|
10
|
-
// @ts-expect-error - This is declared as a constant property
|
|
11
|
-
globalThis.manifest = JSON.parse(jsonText);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
// Ignore
|
|
16
|
-
}
|
|
17
|
-
});
|
|
1
|
+
import { Application } from '../index.js';
|
|
2
|
+
Application.connectingHooks.add(async () => {
|
|
3
|
+
// @ts-expect-error - This is declared as a constant property
|
|
4
|
+
globalThis.manifest = undefined;
|
|
5
|
+
const manifestLink = globalThis.document.head.querySelector('link[rel=manifest]');
|
|
6
|
+
try {
|
|
7
|
+
if (manifestLink) {
|
|
8
|
+
const content = await fetch(manifestLink.href);
|
|
9
|
+
const jsonText = await content.text();
|
|
10
|
+
// @ts-expect-error - This is declared as a constant property
|
|
11
|
+
globalThis.manifest = JSON.parse(jsonText);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Ignore
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface BeforeInstallPromptEvent extends Event {
|
|
2
|
-
readonly platforms: Array<string>;
|
|
3
|
-
readonly userChoice: Promise<{
|
|
4
|
-
readonly outcome: 'accepted' | 'dismissed';
|
|
5
|
-
readonly platform: string;
|
|
6
|
-
}>;
|
|
7
|
-
prompt(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export declare class PwaHelper {
|
|
10
|
-
private static pwaPrompt?;
|
|
11
|
-
static get serviceWorkerContainer(): ServiceWorkerContainer | undefined;
|
|
12
|
-
static registerServiceWorker(absolutePath: string): Promise<void>;
|
|
13
|
-
static unregisterServiceWorkers(): Promise<void>;
|
|
14
|
-
private static requestInstallation;
|
|
15
|
-
}
|
|
1
|
+
export interface BeforeInstallPromptEvent extends Event {
|
|
2
|
+
readonly platforms: Array<string>;
|
|
3
|
+
readonly userChoice: Promise<{
|
|
4
|
+
readonly outcome: 'accepted' | 'dismissed';
|
|
5
|
+
readonly platform: string;
|
|
6
|
+
}>;
|
|
7
|
+
prompt(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare class PwaHelper {
|
|
10
|
+
private static pwaPrompt?;
|
|
11
|
+
static get serviceWorkerContainer(): ServiceWorkerContainer | undefined;
|
|
12
|
+
static registerServiceWorker(absolutePath: string): Promise<void>;
|
|
13
|
+
static unregisterServiceWorkers(): Promise<void>;
|
|
14
|
+
private static requestInstallation;
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=PwaHelper.d.ts.map
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
export class PwaHelper {
|
|
3
|
-
static get serviceWorkerContainer() {
|
|
4
|
-
return navigator.serviceWorker;
|
|
5
|
-
}
|
|
6
|
-
static async registerServiceWorker(absolutePath) {
|
|
7
|
-
try {
|
|
8
|
-
await this.serviceWorkerContainer?.register(absolutePath, { scope: '/' });
|
|
9
|
-
await this.requestInstallation();
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
// eslint-disable-next-line no-console
|
|
13
|
-
console.error(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
static async unregisterServiceWorkers() {
|
|
17
|
-
const serviceWorkers = await this.serviceWorkerContainer?.getRegistrations() || [];
|
|
18
|
-
for (const serviceWorker of serviceWorkers) {
|
|
19
|
-
serviceWorker.unregister();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static async requestInstallation() {
|
|
23
|
-
const isRequestPossible = this.pwaPrompt !== undefined;
|
|
24
|
-
if (isRequestPossible === false) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
await this.pwaPrompt?.prompt();
|
|
28
|
-
const userChoice = await this.pwaPrompt?.userChoice;
|
|
29
|
-
if (userChoice?.outcome !== 'accepted') {
|
|
30
|
-
throw new Error('PWA installation was not accepted');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
_a = PwaHelper;
|
|
35
|
-
(() => {
|
|
36
|
-
window.addEventListener('beforeinstallprompt', e => {
|
|
37
|
-
_a.pwaPrompt = e;
|
|
38
|
-
e.preventDefault();
|
|
39
|
-
});
|
|
40
|
-
})();
|
|
1
|
+
var _a;
|
|
2
|
+
export class PwaHelper {
|
|
3
|
+
static get serviceWorkerContainer() {
|
|
4
|
+
return navigator.serviceWorker;
|
|
5
|
+
}
|
|
6
|
+
static async registerServiceWorker(absolutePath) {
|
|
7
|
+
try {
|
|
8
|
+
await this.serviceWorkerContainer?.register(absolutePath, { scope: '/' });
|
|
9
|
+
await this.requestInstallation();
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.error(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
static async unregisterServiceWorkers() {
|
|
17
|
+
const serviceWorkers = await this.serviceWorkerContainer?.getRegistrations() || [];
|
|
18
|
+
for (const serviceWorker of serviceWorkers) {
|
|
19
|
+
serviceWorker.unregister();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
static async requestInstallation() {
|
|
23
|
+
const isRequestPossible = this.pwaPrompt !== undefined;
|
|
24
|
+
if (isRequestPossible === false) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
await this.pwaPrompt?.prompt();
|
|
28
|
+
const userChoice = await this.pwaPrompt?.userChoice;
|
|
29
|
+
if (userChoice?.outcome !== 'accepted') {
|
|
30
|
+
throw new Error('PWA installation was not accepted');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_a = PwaHelper;
|
|
35
|
+
(() => {
|
|
36
|
+
window.addEventListener('beforeinstallprompt', e => {
|
|
37
|
+
_a.pwaPrompt = e;
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
});
|
|
40
|
+
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Manifest.js';
|
|
2
|
-
export * from './ManifestProvider.js';
|
|
3
|
-
export * from './PwaHelper.js';
|
|
1
|
+
export * from './Manifest.js';
|
|
2
|
+
export * from './ManifestProvider.js';
|
|
3
|
+
export * from './PwaHelper.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/PwaHelper/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Manifest.js';
|
|
2
|
-
export * from './ManifestProvider.js';
|
|
3
|
-
export * from './PwaHelper.js';
|
|
1
|
+
export * from './Manifest.js';
|
|
2
|
+
export * from './ManifestProvider.js';
|
|
3
|
+
export * from './PwaHelper.js';
|
package/dist/Router/Router.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { RoutesContainer, type Page } from './RoutesContainer.js';
|
|
2
|
-
export declare const enum RouteMatchMode {
|
|
3
|
-
All = "all",
|
|
4
|
-
IgnoreParameters = "ignore-parameters"
|
|
5
|
-
}
|
|
6
|
-
export declare class Router {
|
|
7
|
-
static readonly container: RoutesContainer;
|
|
8
|
-
get basePath(): string;
|
|
9
|
-
set basePath(value: string);
|
|
10
|
-
static getPathOf(page: Page): string | undefined;
|
|
11
|
-
static setPathByPage(page: Page): void;
|
|
12
|
-
static match(page: Page, mode?: RouteMatchMode): boolean;
|
|
13
|
-
private static getRouteOf;
|
|
14
|
-
static get path(): string;
|
|
15
|
-
static set path(value: string);
|
|
16
|
-
}
|
|
1
|
+
import { RoutesContainer, type Page } from './RoutesContainer.js';
|
|
2
|
+
export declare const enum RouteMatchMode {
|
|
3
|
+
All = "all",
|
|
4
|
+
IgnoreParameters = "ignore-parameters"
|
|
5
|
+
}
|
|
6
|
+
export declare class Router {
|
|
7
|
+
static readonly container: RoutesContainer;
|
|
8
|
+
get basePath(): string;
|
|
9
|
+
set basePath(value: string);
|
|
10
|
+
static getPathOf(page: Page): string | undefined;
|
|
11
|
+
static setPathByPage(page: Page): void;
|
|
12
|
+
static match(page: Page, mode?: RouteMatchMode): boolean;
|
|
13
|
+
private static getRouteOf;
|
|
14
|
+
static get path(): string;
|
|
15
|
+
static set path(value: string);
|
|
16
|
+
}
|
|
17
17
|
//# sourceMappingURL=Router.d.ts.map
|
package/dist/Router/Router.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { compile, match } from 'path-to-regexp';
|
|
2
|
-
import { RoutesContainer } from './RoutesContainer.js';
|
|
3
|
-
|
|
4
|
-
get basePath() { return Router.container.basePath; }
|
|
5
|
-
set basePath(value) { Router.container.basePath = value; }
|
|
6
|
-
static getPathOf(page) {
|
|
7
|
-
const route = this.getRouteOf(page);
|
|
8
|
-
return route === undefined ? undefined : compile(route)(page.parameters);
|
|
9
|
-
}
|
|
10
|
-
static setPathByPage(page) {
|
|
11
|
-
const path = Router.getPathOf(page);
|
|
12
|
-
if (path) {
|
|
13
|
-
Router.path = path;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
static match(page, mode = "all" /* RouteMatchMode.All */) {
|
|
17
|
-
const route = Router.getRouteOf(page);
|
|
18
|
-
const m = route === undefined ? false : match(route)(Router.path);
|
|
19
|
-
if (m === false) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (mode === "ignore-parameters" /* RouteMatchMode.IgnoreParameters */) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
const parameters = m.params;
|
|
26
|
-
return Object.keys(parameters).every(key => key in (page.parameters ?? {}) && parameters[key] === page.parameters[key]);
|
|
27
|
-
}
|
|
28
|
-
static getRouteOf(page) {
|
|
29
|
-
return [...Router.container]
|
|
30
|
-
.find(([, { pageConstructor }]) => pageConstructor.name === page.constructor.name)?.[0];
|
|
31
|
-
}
|
|
32
|
-
static get path() { return window.location.pathname + window.location.search; }
|
|
33
|
-
static set path(value) {
|
|
34
|
-
window.history.pushState(null, '', value);
|
|
35
|
-
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
Router.container = new RoutesContainer;
|
|
1
|
+
import { compile, match } from 'path-to-regexp';
|
|
2
|
+
import { RoutesContainer } from './RoutesContainer.js';
|
|
3
|
+
class Router {
|
|
4
|
+
get basePath() { return Router.container.basePath; }
|
|
5
|
+
set basePath(value) { Router.container.basePath = value; }
|
|
6
|
+
static getPathOf(page) {
|
|
7
|
+
const route = this.getRouteOf(page);
|
|
8
|
+
return route === undefined ? undefined : compile(route)(page.parameters);
|
|
9
|
+
}
|
|
10
|
+
static setPathByPage(page) {
|
|
11
|
+
const path = Router.getPathOf(page);
|
|
12
|
+
if (path) {
|
|
13
|
+
Router.path = path;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
static match(page, mode = "all" /* RouteMatchMode.All */) {
|
|
17
|
+
const route = Router.getRouteOf(page);
|
|
18
|
+
const m = route === undefined ? false : match(route)(Router.path);
|
|
19
|
+
if (m === false) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (mode === "ignore-parameters" /* RouteMatchMode.IgnoreParameters */) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const parameters = m.params;
|
|
26
|
+
return Object.keys(parameters).every(key => key in (page.parameters ?? {}) && parameters[key] === page.parameters[key]);
|
|
27
|
+
}
|
|
28
|
+
static getRouteOf(page) {
|
|
29
|
+
return [...Router.container]
|
|
30
|
+
.find(([, { pageConstructor }]) => pageConstructor.name === page.constructor.name)?.[0];
|
|
31
|
+
}
|
|
32
|
+
static get path() { return window.location.pathname + window.location.search; }
|
|
33
|
+
static set path(value) {
|
|
34
|
+
window.history.pushState(null, '', value);
|
|
35
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Router.container = new RoutesContainer;
|
|
39
|
+
export { Router };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
-
import { ReactiveControllerHost } from '@a11d/lit';
|
|
3
|
-
export declare class RouterController extends RouterControllerBase {
|
|
4
|
-
protected readonly host: ReactiveControllerHost & HTMLElement;
|
|
5
|
-
hostConnected(): void;
|
|
6
|
-
constructor(...args: ConstructorParameters<typeof RouterControllerBase>);
|
|
7
|
-
private currentPage?;
|
|
8
|
-
private importDecoratorRoutesIfAvailable;
|
|
9
|
-
}
|
|
1
|
+
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
+
import { ReactiveControllerHost } from '@a11d/lit';
|
|
3
|
+
export declare class RouterController extends RouterControllerBase {
|
|
4
|
+
protected readonly host: ReactiveControllerHost & HTMLElement;
|
|
5
|
+
hostConnected(): void;
|
|
6
|
+
constructor(...args: ConstructorParameters<typeof RouterControllerBase>);
|
|
7
|
+
private currentPage?;
|
|
8
|
+
private importDecoratorRoutesIfAvailable;
|
|
9
|
+
}
|
|
10
10
|
//# sourceMappingURL=RouterController.d.ts.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
-
import { Router } from './Router.js';
|
|
3
|
-
export class RouterController extends RouterControllerBase {
|
|
4
|
-
hostConnected() {
|
|
5
|
-
this.importDecoratorRoutesIfAvailable();
|
|
6
|
-
super.hostConnected();
|
|
7
|
-
}
|
|
8
|
-
constructor(...args) {
|
|
9
|
-
super(...args);
|
|
10
|
-
this.host = args[0];
|
|
11
|
-
}
|
|
12
|
-
importDecoratorRoutesIfAvailable() {
|
|
13
|
-
const decoratorRoutes = [...Router.container]
|
|
14
|
-
.filter(([, { routerHostConstructor }]) => this.host.constructor === routerHostConstructor || this.host.constructor.prototype instanceof routerHostConstructor)
|
|
15
|
-
.map(([route, { pageConstructor }]) => ({ route, pageConstructor }));
|
|
16
|
-
for (const { pageConstructor, route } of decoratorRoutes) {
|
|
17
|
-
this.routes.push({
|
|
18
|
-
path: route,
|
|
19
|
-
render: p => {
|
|
20
|
-
return this.currentPage?.parameters === p && this.currentPage?.constructor === pageConstructor
|
|
21
|
-
? this.currentPage
|
|
22
|
-
: this.currentPage = new pageConstructor(p);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
+
import { Router } from './Router.js';
|
|
3
|
+
export class RouterController extends RouterControllerBase {
|
|
4
|
+
hostConnected() {
|
|
5
|
+
this.importDecoratorRoutesIfAvailable();
|
|
6
|
+
super.hostConnected();
|
|
7
|
+
}
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
super(...args);
|
|
10
|
+
this.host = args[0];
|
|
11
|
+
}
|
|
12
|
+
importDecoratorRoutesIfAvailable() {
|
|
13
|
+
const decoratorRoutes = [...Router.container]
|
|
14
|
+
.filter(([, { routerHostConstructor }]) => this.host.constructor === routerHostConstructor || this.host.constructor.prototype instanceof routerHostConstructor)
|
|
15
|
+
.map(([route, { pageConstructor }]) => ({ route, pageConstructor }));
|
|
16
|
+
for (const { pageConstructor, route } of decoratorRoutes) {
|
|
17
|
+
this.routes.push({
|
|
18
|
+
path: route,
|
|
19
|
+
render: p => {
|
|
20
|
+
return this.currentPage?.parameters === p && this.currentPage?.constructor === pageConstructor
|
|
21
|
+
? this.currentPage
|
|
22
|
+
: this.currentPage = new pageConstructor(p);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { Component } from '@a11d/lit';
|
|
2
|
-
import type { PageComponent } from '../Page/index.js';
|
|
3
|
-
export type Page = PageComponent<any>;
|
|
4
|
-
type PageConstructor = Constructor<Page>;
|
|
5
|
-
type RouterHost = Component;
|
|
6
|
-
type RouterHostConstructor = Constructor<RouterHost>;
|
|
7
|
-
type RouteMetadata = {
|
|
8
|
-
routerHostConstructor: RouterHostConstructor;
|
|
9
|
-
pageConstructor: PageConstructor;
|
|
10
|
-
};
|
|
11
|
-
export declare class RoutesContainer extends Map<string, {
|
|
12
|
-
routerHostConstructor: RouterHostConstructor;
|
|
13
|
-
pageConstructor: PageConstructor;
|
|
14
|
-
}> {
|
|
15
|
-
basePath: string;
|
|
16
|
-
set(key: string, value: RouteMetadata): this;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
1
|
+
import type { Component } from '@a11d/lit';
|
|
2
|
+
import type { PageComponent } from '../Page/index.js';
|
|
3
|
+
export type Page = PageComponent<any>;
|
|
4
|
+
type PageConstructor = Constructor<Page>;
|
|
5
|
+
type RouterHost = Component;
|
|
6
|
+
type RouterHostConstructor = Constructor<RouterHost>;
|
|
7
|
+
type RouteMetadata = {
|
|
8
|
+
routerHostConstructor: RouterHostConstructor;
|
|
9
|
+
pageConstructor: PageConstructor;
|
|
10
|
+
};
|
|
11
|
+
export declare class RoutesContainer extends Map<string, {
|
|
12
|
+
routerHostConstructor: RouterHostConstructor;
|
|
13
|
+
pageConstructor: PageConstructor;
|
|
14
|
+
}> {
|
|
15
|
+
basePath: string;
|
|
16
|
+
set(key: string, value: RouteMetadata): this;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
19
|
//# sourceMappingURL=RoutesContainer.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export class RoutesContainer extends Map {
|
|
2
|
-
constructor() {
|
|
3
|
-
super(...arguments);
|
|
4
|
-
this.basePath = '';
|
|
5
|
-
}
|
|
6
|
-
set(key, value) {
|
|
7
|
-
return super.set(this.basePath + key, value);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
export class RoutesContainer extends Map {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(...arguments);
|
|
4
|
+
this.basePath = '';
|
|
5
|
+
}
|
|
6
|
+
set(key, value) {
|
|
7
|
+
return super.set(this.basePath + key, value);
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/Router/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import 'urlpattern-polyfill';
|
|
2
|
-
export * from './Router.js';
|
|
3
|
-
export * from './RouterController.js';
|
|
4
|
-
export * from './routerLink.js';
|
|
5
|
-
export * from './route.js';
|
|
1
|
+
import 'urlpattern-polyfill';
|
|
2
|
+
export * from './Router.js';
|
|
3
|
+
export * from './RouterController.js';
|
|
4
|
+
export * from './routerLink.js';
|
|
5
|
+
export * from './route.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/Router/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import 'urlpattern-polyfill';
|
|
2
|
-
export * from './Router.js';
|
|
3
|
-
export * from './RouterController.js';
|
|
4
|
-
export * from './routerLink.js';
|
|
5
|
-
export * from './route.js';
|
|
1
|
+
import 'urlpattern-polyfill';
|
|
2
|
+
export * from './Router.js';
|
|
3
|
+
export * from './RouterController.js';
|
|
4
|
+
export * from './routerLink.js';
|
|
5
|
+
export * from './route.js';
|
package/dist/Router/route.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component } from '@a11d/lit';
|
|
2
|
-
import type { PageComponent } from '../Page/index.js';
|
|
3
|
-
type RouteParameters = [...routes: Array<string>] | [RouterHost: Constructor<Component>, ...routes: Array<string>];
|
|
4
|
-
export declare const route: (...parameters: RouteParameters) => (pageConstructor: Constructor<PageComponent<any>>) => void;
|
|
5
|
-
export {};
|
|
1
|
+
import { Component } from '@a11d/lit';
|
|
2
|
+
import type { PageComponent } from '../Page/index.js';
|
|
3
|
+
type RouteParameters = [...routes: Array<string>] | [RouterHost: Constructor<Component>, ...routes: Array<string>];
|
|
4
|
+
export declare const route: (...parameters: RouteParameters) => (pageConstructor: Constructor<PageComponent<any>>) => void;
|
|
5
|
+
export {};
|
|
6
6
|
//# sourceMappingURL=route.d.ts.map
|
package/dist/Router/route.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Router } from './Router.js';
|
|
2
|
-
import { Application } from '../Application.js';
|
|
3
|
-
function getParameters(...parameters) {
|
|
4
|
-
return typeof parameters[0] === 'string'
|
|
5
|
-
? {
|
|
6
|
-
routerHostConstructor: Application,
|
|
7
|
-
routes: parameters,
|
|
8
|
-
} : {
|
|
9
|
-
routerHostConstructor: parameters[0],
|
|
10
|
-
routes: parameters.slice(1),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export const route = (...parameters) => {
|
|
14
|
-
return (pageConstructor) => {
|
|
15
|
-
const { routerHostConstructor, routes } = getParameters(...parameters);
|
|
16
|
-
for (const route of routes) {
|
|
17
|
-
Router.container.set(route, { routerHostConstructor, pageConstructor });
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
1
|
+
import { Router } from './Router.js';
|
|
2
|
+
import { Application } from '../Application.js';
|
|
3
|
+
function getParameters(...parameters) {
|
|
4
|
+
return typeof parameters[0] === 'string'
|
|
5
|
+
? {
|
|
6
|
+
routerHostConstructor: Application,
|
|
7
|
+
routes: parameters,
|
|
8
|
+
} : {
|
|
9
|
+
routerHostConstructor: parameters[0],
|
|
10
|
+
routes: parameters.slice(1),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export const route = (...parameters) => {
|
|
14
|
+
return (pageConstructor) => {
|
|
15
|
+
const { routerHostConstructor, routes } = getParameters(...parameters);
|
|
16
|
+
for (const route of routes) {
|
|
17
|
+
Router.container.set(route, { routerHostConstructor, pageConstructor });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { AsyncDirective, ElementPart, PartInfo } from '@a11d/lit';
|
|
2
|
-
import { RouteMatchMode } from './index.js';
|
|
3
|
-
import { PageComponent } from '../Page/index.js';
|
|
4
|
-
import { DialogComponent } from '../Dialog/index.js';
|
|
5
|
-
type Parameters = {
|
|
6
|
-
component: PageComponent<any> | DialogComponent<any, any>;
|
|
7
|
-
matchMode?: RouteMatchMode;
|
|
8
|
-
selectionChangeHandler?: (this: Element, selected: boolean) => void;
|
|
9
|
-
invocationHandler?: () => void;
|
|
10
|
-
};
|
|
11
|
-
type ShorthandParametersOrParameters = [component: PageComponent<any> | DialogComponent<any, any>] | [parameters: Parameters];
|
|
12
|
-
declare class RouterLinkDirective extends AsyncDirective {
|
|
13
|
-
readonly element: Element;
|
|
14
|
-
readonly parameters: Parameters;
|
|
15
|
-
constructor(partInfo: PartInfo);
|
|
16
|
-
update(part: ElementPart, parameters: ShorthandParametersOrParameters): unknown;
|
|
17
|
-
render(...parameters: ShorthandParametersOrParameters): symbol;
|
|
18
|
-
protected disconnected(): void;
|
|
19
|
-
handleEvent(event: Event): void;
|
|
20
|
-
private addEventListeners;
|
|
21
|
-
private removeEventListeners;
|
|
22
|
-
private invoke;
|
|
23
|
-
private executeSelectionChange;
|
|
24
|
-
}
|
|
25
|
-
export declare const routerLink: (...values: ShorthandParametersOrParameters) => import("lit-html/directive.js").DirectiveResult<typeof RouterLinkDirective>;
|
|
26
|
-
export {};
|
|
1
|
+
import { AsyncDirective, ElementPart, PartInfo } from '@a11d/lit';
|
|
2
|
+
import { RouteMatchMode } from './index.js';
|
|
3
|
+
import { PageComponent } from '../Page/index.js';
|
|
4
|
+
import { DialogComponent } from '../Dialog/index.js';
|
|
5
|
+
type Parameters = {
|
|
6
|
+
component: PageComponent<any> | DialogComponent<any, any>;
|
|
7
|
+
matchMode?: RouteMatchMode;
|
|
8
|
+
selectionChangeHandler?: (this: Element, selected: boolean) => void;
|
|
9
|
+
invocationHandler?: () => void;
|
|
10
|
+
};
|
|
11
|
+
type ShorthandParametersOrParameters = [component: PageComponent<any> | DialogComponent<any, any>] | [parameters: Parameters];
|
|
12
|
+
declare class RouterLinkDirective extends AsyncDirective {
|
|
13
|
+
readonly element: Element;
|
|
14
|
+
readonly parameters: Parameters;
|
|
15
|
+
constructor(partInfo: PartInfo);
|
|
16
|
+
update(part: ElementPart, parameters: ShorthandParametersOrParameters): unknown;
|
|
17
|
+
render(...parameters: ShorthandParametersOrParameters): symbol;
|
|
18
|
+
protected disconnected(): void;
|
|
19
|
+
handleEvent(event: Event): void;
|
|
20
|
+
private addEventListeners;
|
|
21
|
+
private removeEventListeners;
|
|
22
|
+
private invoke;
|
|
23
|
+
private executeSelectionChange;
|
|
24
|
+
}
|
|
25
|
+
export declare const routerLink: (...values: ShorthandParametersOrParameters) => import("lit-html/directive.js").DirectiveResult<typeof RouterLinkDirective>;
|
|
26
|
+
export {};
|
|
27
27
|
//# sourceMappingURL=routerLink.d.ts.map
|