@dosgato/templating 0.0.9 → 0.0.10
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/component.d.ts +12 -1
- package/dist/component.js +14 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/page.d.ts +0 -13
- package/dist/page.js +0 -15
package/dist/component.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Page } from './page';
|
|
2
1
|
import { ResourceProvider } from './provider';
|
|
3
2
|
/**
|
|
4
3
|
* This is the primary templating class to build your templates. Subclass it and provide
|
|
@@ -117,3 +116,15 @@ export interface ContextBase {
|
|
|
117
116
|
*/
|
|
118
117
|
headerLevel: number;
|
|
119
118
|
}
|
|
119
|
+
export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
|
|
120
|
+
pagePath: string;
|
|
121
|
+
ancestors: PageRecord[];
|
|
122
|
+
/**
|
|
123
|
+
* we will fill this before rendering, stuff that dosgato knows needs to be added to
|
|
124
|
+
* the <head> element
|
|
125
|
+
* the page's render function must include it
|
|
126
|
+
*/
|
|
127
|
+
headContent: string;
|
|
128
|
+
protected passError(e: Error, path: string): void;
|
|
129
|
+
constructor(page: PageWithAncestors<DataType>);
|
|
130
|
+
}
|
package/dist/component.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Component = void 0;
|
|
4
|
-
const page_1 = require("./page");
|
|
3
|
+
exports.Page = exports.Component = void 0;
|
|
5
4
|
const provider_1 = require("./provider");
|
|
6
5
|
/**
|
|
7
6
|
* This is the primary templating class to build your templates. Subclass it and provide
|
|
@@ -25,9 +24,9 @@ class Component extends provider_1.ResourceProvider {
|
|
|
25
24
|
this.path = path;
|
|
26
25
|
this.hadError = false;
|
|
27
26
|
let tmpParent = (_a = this.parent) !== null && _a !== void 0 ? _a : this;
|
|
28
|
-
while (!(tmpParent instanceof
|
|
27
|
+
while (!(tmpParent instanceof Page) && tmpParent.parent)
|
|
29
28
|
tmpParent = tmpParent.parent;
|
|
30
|
-
if (!(tmpParent instanceof
|
|
29
|
+
if (!(tmpParent instanceof Page))
|
|
31
30
|
throw new Error('Hydration failed, could not map component back to its page.');
|
|
32
31
|
this.page = tmpParent;
|
|
33
32
|
}
|
|
@@ -113,3 +112,14 @@ class Component extends provider_1.ResourceProvider {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
exports.Component = Component;
|
|
115
|
+
class Page extends Component {
|
|
116
|
+
constructor(page) {
|
|
117
|
+
super(page.data, '/', undefined);
|
|
118
|
+
this.pagePath = page.path;
|
|
119
|
+
this.ancestors = page.ancestors;
|
|
120
|
+
}
|
|
121
|
+
passError(e, path) {
|
|
122
|
+
console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.Page = Page;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./apitemplate"), exports);
|
|
18
18
|
__exportStar(require("./component"), exports);
|
|
19
19
|
__exportStar(require("./links"), exports);
|
|
20
|
-
__exportStar(require("./page"), exports);
|
|
21
20
|
__exportStar(require("./provider"), exports);
|
package/package.json
CHANGED
package/dist/page.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PageData, ContextBase, Component, PageRecord, PageWithAncestors } from './component';
|
|
2
|
-
export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
|
|
3
|
-
pagePath: string;
|
|
4
|
-
ancestors: PageRecord[];
|
|
5
|
-
/**
|
|
6
|
-
* we will fill this before rendering, stuff that dosgato knows needs to be added to
|
|
7
|
-
* the <head> element
|
|
8
|
-
* the page's render function must include it
|
|
9
|
-
*/
|
|
10
|
-
headContent: string;
|
|
11
|
-
protected passError(e: Error, path: string): void;
|
|
12
|
-
constructor(page: PageWithAncestors<DataType>);
|
|
13
|
-
}
|
package/dist/page.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Page = void 0;
|
|
4
|
-
const component_1 = require("./component");
|
|
5
|
-
class Page extends component_1.Component {
|
|
6
|
-
constructor(page) {
|
|
7
|
-
super(page.data, '/', undefined);
|
|
8
|
-
this.pagePath = page.path;
|
|
9
|
-
this.ancestors = page.ancestors;
|
|
10
|
-
}
|
|
11
|
-
passError(e, path) {
|
|
12
|
-
console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.Page = Page;
|