silentium-components 0.0.5 → 0.0.7
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/CHANGELOG.md +22 -0
- package/dist/silentium-components.cjs +134 -483
- package/dist/silentium-components.cjs.map +1 -1
- package/dist/silentium-components.d.ts +8 -190
- package/dist/silentium-components.js +130 -467
- package/dist/silentium-components.js.map +1 -1
- package/dist/silentium-components.min.js +1 -1
- package/dist/silentium-components.min.mjs +1 -1
- package/dist/silentium-components.min.mjs.map +1 -1
- package/dist/silentium-components.mjs +130 -467
- package/dist/silentium-components.mjs.map +1 -1
- package/docs/build.sh +3 -4
- package/docs/index.html +3 -3
- package/docs/pages/behaviors/deadline.html +60 -0
- package/docs/pages/behaviors.html +5 -0
- package/docs/routes.json +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +7 -5
- package/src/behaviors/Deadline._value.test.ts +27 -0
- package/src/behaviors/Deadline.test.ts +28 -0
- package/src/behaviors/Deadline.ts +49 -0
- package/src/behaviors/Dirty.test.ts +5 -5
- package/src/behaviors/Dirty.ts +48 -54
- package/src/behaviors/Loading.test.ts +8 -8
- package/src/behaviors/Loading.ts +21 -31
- package/src/behaviors/Path.index.test.ts +5 -5
- package/src/behaviors/Path.nested.test.ts +5 -5
- package/src/behaviors/Path.test.ts +5 -5
- package/src/behaviors/Path.ts +26 -30
- package/src/behaviors/index.ts +1 -1
- package/src/controls/GroupActiveClass.test.ts +16 -13
- package/src/controls/GroupActiveClass.ts +19 -22
- package/src/controls/index.ts +0 -5
- package/src/index.ts +0 -2
- package/src/navigation/Router.test.ts +47 -0
- package/src/navigation/Router.ts +43 -111
- package/src/navigation/index.ts +0 -6
- package/src/strings/Concatenated.test.ts +11 -0
- package/src/strings/Concatenated.ts +18 -0
- package/src/structures/HashTable.test.ts +5 -5
- package/src/structures/HashTable.ts +14 -25
- package/src/system/RegexpMatched.test.ts +14 -0
- package/src/system/RegexpMatched.ts +17 -0
- package/src/system/index.ts +1 -0
- package/src/behaviors/Touched.ts +0 -1
- package/src/controls/ComputedElement.ts +0 -51
- package/src/controls/Input.ts +0 -45
- package/src/controls/Link.ts +0 -53
- package/src/controls/Text.ts +0 -16
- package/src/controls/Visible.ts +0 -16
- package/src/jsdom/JSDomDocument.ts +0 -15
- package/src/jsdom/JSDomElement.ts +0 -28
- package/src/jsdom/JSDomQuerySelector.ts +0 -28
- package/src/navigation/CurrentPage.ts +0 -27
- package/src/navigation/Navigation.default.test.ts +0 -54
- package/src/navigation/Navigation.main.test.ts +0 -47
- package/src/navigation/Navigation.ts +0 -92
- package/src/navigation/Navigation.wildcard.test.ts +0 -52
- package/src/navigation/PageFetchTransport.ts +0 -26
- package/src/navigation/RouteDisplay.ts +0 -18
- package/src/navigation/RoutePageType.ts +0 -3
- package/src/page/EntryPointPage.ts +0 -20
- package/src/page/Page.ts +0 -12
- package/src/page/PageFake.ts +0 -8
- package/src/page/index.ts +0 -2
package/src/controls/Link.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { GuestObjectType, SourceType, value } from "silentium";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated move to web api
|
|
5
|
-
*/
|
|
6
|
-
export class Link {
|
|
7
|
-
public constructor(
|
|
8
|
-
private linkSource: GuestObjectType<string>,
|
|
9
|
-
private basePath: SourceType<string>,
|
|
10
|
-
) {}
|
|
11
|
-
|
|
12
|
-
public watchClick(selector: string, subselector?: string) {
|
|
13
|
-
const wrapperEl = document.querySelectorAll(selector);
|
|
14
|
-
if (wrapperEl.length) {
|
|
15
|
-
wrapperEl.forEach((theElement) => {
|
|
16
|
-
theElement.addEventListener("click", (e) => {
|
|
17
|
-
if (subselector) {
|
|
18
|
-
theElement
|
|
19
|
-
.querySelectorAll(subselector)
|
|
20
|
-
.forEach((theSubElement) => {
|
|
21
|
-
if (
|
|
22
|
-
e?.target === theSubElement ||
|
|
23
|
-
e?.currentTarget === theSubElement
|
|
24
|
-
) {
|
|
25
|
-
this.handleClick({
|
|
26
|
-
preventDefault: e.preventDefault.bind(e),
|
|
27
|
-
target: theSubElement,
|
|
28
|
-
} as unknown as Event);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
this.handleClick(e);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
throw new Error(`Link wrapper not found for selector ${selector}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private handleClick(e: Event) {
|
|
42
|
-
let href = (e?.target as HTMLElement)?.getAttribute("href");
|
|
43
|
-
if (!href) {
|
|
44
|
-
href = (e?.currentTarget as HTMLElement)?.getAttribute("href");
|
|
45
|
-
}
|
|
46
|
-
if (href && href.indexOf("http") !== 0) {
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
value(this.basePath, (basePath) => {
|
|
49
|
-
this.linkSource.give(basePath + href);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/controls/Text.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { GuestObjectType } from "silentium";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Move to web api
|
|
5
|
-
*/
|
|
6
|
-
export class Text implements GuestObjectType {
|
|
7
|
-
public constructor(private selector: string) {}
|
|
8
|
-
|
|
9
|
-
public give(value: unknown) {
|
|
10
|
-
const element = document.querySelector(this.selector) as HTMLElement;
|
|
11
|
-
if (element) {
|
|
12
|
-
element.innerText = String(value);
|
|
13
|
-
}
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
}
|
package/src/controls/Visible.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { GuestObjectType } from "silentium";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated move to web api
|
|
5
|
-
*/
|
|
6
|
-
export class Visible implements GuestObjectType<boolean> {
|
|
7
|
-
public constructor(private selector: string) {}
|
|
8
|
-
|
|
9
|
-
public give(isVisible: boolean): this {
|
|
10
|
-
const el = document.querySelector(this.selector) as HTMLElement;
|
|
11
|
-
if (el) {
|
|
12
|
-
el.style.display = isVisible ? "block" : "none";
|
|
13
|
-
}
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { JSDOM } from "jsdom";
|
|
2
|
-
import { give, GuestType, SourceObjectType } from "silentium";
|
|
3
|
-
|
|
4
|
-
export class JSDomDocument implements SourceObjectType<Document> {
|
|
5
|
-
private dom: JSDOM;
|
|
6
|
-
|
|
7
|
-
public constructor(body: string = "") {
|
|
8
|
-
this.dom = new JSDOM(`<!DOCTYPE html><body>${body}</body></html>`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public value(guest: GuestType<Document>) {
|
|
12
|
-
give(this.dom.window.document, guest);
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GuestType,
|
|
3
|
-
Patron,
|
|
4
|
-
SourceObjectType,
|
|
5
|
-
SourceType,
|
|
6
|
-
SourceChangeable,
|
|
7
|
-
value,
|
|
8
|
-
} from "silentium";
|
|
9
|
-
|
|
10
|
-
export class JSDomElement implements SourceObjectType<HTMLElement> {
|
|
11
|
-
private source = new SourceChangeable<HTMLElement>();
|
|
12
|
-
|
|
13
|
-
public constructor(documentSource: SourceType<Document>, html: string) {
|
|
14
|
-
value(
|
|
15
|
-
documentSource,
|
|
16
|
-
new Patron((document) => {
|
|
17
|
-
const div = document.createElement("div");
|
|
18
|
-
div.innerHTML = html;
|
|
19
|
-
this.source.give(div.children[0] as HTMLElement);
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public value(guest: GuestType<HTMLElement>) {
|
|
25
|
-
value(this.source, guest);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
give,
|
|
3
|
-
GuestCast,
|
|
4
|
-
GuestType,
|
|
5
|
-
SourceObjectType,
|
|
6
|
-
SourceType,
|
|
7
|
-
value,
|
|
8
|
-
} from "silentium";
|
|
9
|
-
|
|
10
|
-
export class JSDomQuerySelector implements SourceObjectType<HTMLElement> {
|
|
11
|
-
public constructor(
|
|
12
|
-
private documentSource: SourceType<Document>,
|
|
13
|
-
private selector: string,
|
|
14
|
-
) {}
|
|
15
|
-
|
|
16
|
-
public value(guest: GuestType<HTMLElement>) {
|
|
17
|
-
value(
|
|
18
|
-
this.documentSource,
|
|
19
|
-
new GuestCast(guest, (document) => {
|
|
20
|
-
const el = document.querySelector(this.selector) as HTMLElement;
|
|
21
|
-
if (el) {
|
|
22
|
-
give(el, guest);
|
|
23
|
-
}
|
|
24
|
-
}),
|
|
25
|
-
);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { GuestType, SourceChangeable, SourceChangeableType } from "silentium";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated move to web api
|
|
5
|
-
*/
|
|
6
|
-
export class CurrentPage implements SourceChangeableType<string> {
|
|
7
|
-
private source: SourceChangeable<string>;
|
|
8
|
-
|
|
9
|
-
public constructor() {
|
|
10
|
-
const correctUrl = location.href.replace(location.origin, "");
|
|
11
|
-
this.source = new SourceChangeable(correctUrl);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public give(value: string): this {
|
|
15
|
-
this.source.give(value);
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public value(guest: GuestType<string>) {
|
|
20
|
-
this.source.value(guest);
|
|
21
|
-
return guest;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public pool() {
|
|
25
|
-
return this.source.pool();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { give, GuestType, PrivateClass, SourceChangeable } from "silentium";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
3
|
-
import { PageFake } from "../page/PageFake";
|
|
4
|
-
import { Navigation } from "./Navigation";
|
|
5
|
-
import { RoutePageTransportType } from "./PageFetchTransport";
|
|
6
|
-
|
|
7
|
-
class FakeTransport implements RoutePageTransportType {
|
|
8
|
-
public constructor(
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
basePath = null,
|
|
11
|
-
private template = "null",
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
public content(guest: GuestType<string>): void {
|
|
15
|
-
give(this.template, guest);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
test("navigation", () => {
|
|
20
|
-
const pageLoading = new SourceChangeable(false);
|
|
21
|
-
const basePath = new SourceChangeable("/some/path/#");
|
|
22
|
-
const currentPage = new SourceChangeable("/some/path/unknown-page");
|
|
23
|
-
const display = {
|
|
24
|
-
display(content: string) {
|
|
25
|
-
expect(content).toBe("default.html");
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const navigation = new Navigation(
|
|
30
|
-
pageLoading,
|
|
31
|
-
basePath,
|
|
32
|
-
currentPage,
|
|
33
|
-
display,
|
|
34
|
-
new PrivateClass(FakeTransport),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
navigation.routes([
|
|
38
|
-
{
|
|
39
|
-
url: "/",
|
|
40
|
-
template: "main.html",
|
|
41
|
-
aliases: ["/some/path/"],
|
|
42
|
-
page: new PageFake(),
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
url: "",
|
|
46
|
-
template: "default.html",
|
|
47
|
-
aliases: ["/some/path/"],
|
|
48
|
-
page: new PageFake(),
|
|
49
|
-
default: true,
|
|
50
|
-
},
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
expect(true).toBe(true);
|
|
54
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { give, GuestType, PrivateClass, SourceChangeable } from "silentium";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
3
|
-
import { PageFake } from "../page/PageFake";
|
|
4
|
-
import { Navigation } from "./Navigation";
|
|
5
|
-
import { RoutePageTransportType } from "./PageFetchTransport";
|
|
6
|
-
|
|
7
|
-
class FakeTransport implements RoutePageTransportType {
|
|
8
|
-
public constructor(
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
basePath = null,
|
|
11
|
-
private template = "null",
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
public content(guest: GuestType<string>): void {
|
|
15
|
-
give(this.template, guest);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
test("navigation", () => {
|
|
20
|
-
const pageLoading = new SourceChangeable(false);
|
|
21
|
-
const basePath = new SourceChangeable("/some/path/#");
|
|
22
|
-
const currentPage = new SourceChangeable("/some/path/");
|
|
23
|
-
const display = {
|
|
24
|
-
display(content: string) {
|
|
25
|
-
expect(content).toBe("main.html");
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const navigation = new Navigation(
|
|
30
|
-
pageLoading,
|
|
31
|
-
basePath,
|
|
32
|
-
currentPage,
|
|
33
|
-
display,
|
|
34
|
-
new PrivateClass(FakeTransport),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
navigation.routes([
|
|
38
|
-
{
|
|
39
|
-
url: "/",
|
|
40
|
-
template: "main.html",
|
|
41
|
-
aliases: ["/some/path/"],
|
|
42
|
-
page: new PageFake(),
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
expect(true).toBe(true);
|
|
47
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SourceAll,
|
|
3
|
-
Patron,
|
|
4
|
-
PrivateType,
|
|
5
|
-
SourceType,
|
|
6
|
-
value,
|
|
7
|
-
give,
|
|
8
|
-
SourceChangeableType,
|
|
9
|
-
} from "silentium";
|
|
10
|
-
import { RoutePageTransportType } from "src/navigation/PageFetchTransport";
|
|
11
|
-
import { RouteDisplayType } from "src/navigation/RouteDisplay";
|
|
12
|
-
import { RoutePageType } from "src/navigation/RoutePageType";
|
|
13
|
-
|
|
14
|
-
export interface RouteDocument {
|
|
15
|
-
url: string;
|
|
16
|
-
template: string;
|
|
17
|
-
aliases?: string[];
|
|
18
|
-
page: RoutePageType;
|
|
19
|
-
default?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class Navigation {
|
|
23
|
-
public constructor(
|
|
24
|
-
private loading: SourceChangeableType<boolean>,
|
|
25
|
-
private basePath: SourceType<string>,
|
|
26
|
-
private currentPage: SourceChangeableType<string>,
|
|
27
|
-
private display: RouteDisplayType,
|
|
28
|
-
private pageTransport: PrivateType<RoutePageTransportType>,
|
|
29
|
-
) {}
|
|
30
|
-
|
|
31
|
-
public routes(routes: RouteDocument[]) {
|
|
32
|
-
const defaultRoute = routes.find((route) => route.default);
|
|
33
|
-
const all = new SourceAll<{
|
|
34
|
-
basePath: string;
|
|
35
|
-
currentPage: string;
|
|
36
|
-
}>();
|
|
37
|
-
value(this.basePath, new Patron(all.guestKey("basePath")));
|
|
38
|
-
value(this.currentPage, new Patron(all.guestKey("currentPage")));
|
|
39
|
-
|
|
40
|
-
all.value(
|
|
41
|
-
new Patron(({ basePath, currentPage }) => {
|
|
42
|
-
const urlWithoutBasePath = currentPage.replace(basePath, "");
|
|
43
|
-
const routeMatchedToAlias = routes.find(
|
|
44
|
-
(route) =>
|
|
45
|
-
route.aliases &&
|
|
46
|
-
(route.aliases.includes(currentPage) ||
|
|
47
|
-
route.aliases.includes(urlWithoutBasePath)),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (routeMatchedToAlias) {
|
|
51
|
-
const correctUrl = basePath + routeMatchedToAlias.url;
|
|
52
|
-
|
|
53
|
-
if (correctUrl !== currentPage) {
|
|
54
|
-
give(correctUrl, this.currentPage);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let route = routes.find((route) => {
|
|
60
|
-
if (route.url.indexOf("*") >= 0) {
|
|
61
|
-
const regexp = new RegExp(
|
|
62
|
-
route.url.replaceAll("*", ".*").replaceAll("/", "/"),
|
|
63
|
-
);
|
|
64
|
-
return regexp.test(urlWithoutBasePath);
|
|
65
|
-
}
|
|
66
|
-
return route.url.replaceAll("*", "") === urlWithoutBasePath;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (!route && defaultRoute) {
|
|
70
|
-
route = defaultRoute;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (route) {
|
|
74
|
-
const basePathWithoutHash = basePath
|
|
75
|
-
.replace("/#", "")
|
|
76
|
-
.replace("#", "")
|
|
77
|
-
.replace(/[^/]+\.html$/, "");
|
|
78
|
-
give(true, this.loading);
|
|
79
|
-
this.pageTransport
|
|
80
|
-
.get(basePathWithoutHash, route.template)
|
|
81
|
-
.content((templateContent) => {
|
|
82
|
-
this.display.display(templateContent);
|
|
83
|
-
route.page.mounted();
|
|
84
|
-
give(false, this.loading);
|
|
85
|
-
});
|
|
86
|
-
} else {
|
|
87
|
-
throw new Error("No matching route in Navigation");
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { give, GuestType, PrivateClass, SourceChangeable } from "silentium";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
3
|
-
import { PageFake } from "../page/PageFake";
|
|
4
|
-
import { Navigation } from "./Navigation";
|
|
5
|
-
import { RoutePageTransportType } from "./PageFetchTransport";
|
|
6
|
-
|
|
7
|
-
class FakeTransport implements RoutePageTransportType {
|
|
8
|
-
public constructor(
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
basePath = null,
|
|
11
|
-
private template = "null",
|
|
12
|
-
) {}
|
|
13
|
-
public content(guest: GuestType<string>): void {
|
|
14
|
-
give(this.template, guest);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
test("navigation", () => {
|
|
19
|
-
const pageLoading = new SourceChangeable(false);
|
|
20
|
-
const basePath = new SourceChangeable("/some/path/#");
|
|
21
|
-
const currentPage = new SourceChangeable("/some/path/catalog/information");
|
|
22
|
-
const display = {
|
|
23
|
-
display(content: string) {
|
|
24
|
-
expect(content).toBe("catalog.html");
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const navigation = new Navigation(
|
|
29
|
-
pageLoading,
|
|
30
|
-
basePath,
|
|
31
|
-
currentPage,
|
|
32
|
-
display,
|
|
33
|
-
new PrivateClass(FakeTransport),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
navigation.routes([
|
|
37
|
-
{
|
|
38
|
-
url: "/",
|
|
39
|
-
template: "default.html",
|
|
40
|
-
aliases: ["/some/path/"],
|
|
41
|
-
page: new PageFake(),
|
|
42
|
-
default: true,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
url: "/catalog*",
|
|
46
|
-
template: "catalog.html",
|
|
47
|
-
page: new PageFake(),
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
expect(true).toBe(true);
|
|
52
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { give, GuestType } from "silentium";
|
|
2
|
-
|
|
3
|
-
export interface RoutePageTransportType {
|
|
4
|
-
content(guest: GuestType<string>): void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Not needed anymore same thing in web api existed
|
|
9
|
-
* @deprecated
|
|
10
|
-
*/
|
|
11
|
-
export class PageFetchTransport implements RoutePageTransportType {
|
|
12
|
-
public constructor(
|
|
13
|
-
private basePath: string,
|
|
14
|
-
private template: string,
|
|
15
|
-
) {}
|
|
16
|
-
|
|
17
|
-
public content(guest: GuestType<string>): void {
|
|
18
|
-
fetch(this.basePath + "/" + this.template)
|
|
19
|
-
.then((result) => {
|
|
20
|
-
return result.text();
|
|
21
|
-
})
|
|
22
|
-
.then((result) => {
|
|
23
|
-
give(result, guest);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface RouteDisplayType {
|
|
2
|
-
display(content: string): void;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Renders content on selector
|
|
7
|
-
* @deprecated move to web api
|
|
8
|
-
*/
|
|
9
|
-
export class RouteDisplay implements RouteDisplayType {
|
|
10
|
-
public constructor(private selector: string) {}
|
|
11
|
-
|
|
12
|
-
public display(content: string): void {
|
|
13
|
-
const contentEl = document.querySelector(this.selector);
|
|
14
|
-
if (contentEl) {
|
|
15
|
-
contentEl.innerHTML = content;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RoutePageType } from "../navigation";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated not needed
|
|
5
|
-
*/
|
|
6
|
-
export class EntryPointPage implements RoutePageType {
|
|
7
|
-
public constructor(
|
|
8
|
-
private title: string,
|
|
9
|
-
private entryPointUrl: string,
|
|
10
|
-
) {}
|
|
11
|
-
|
|
12
|
-
public mounted() {
|
|
13
|
-
document.title = this.title;
|
|
14
|
-
import(this.entryPointUrl).then((module) => {
|
|
15
|
-
if (module.main) {
|
|
16
|
-
module.main();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/page/Page.ts
DELETED
package/src/page/PageFake.ts
DELETED
package/src/page/index.ts
DELETED