@dosgato/templating 0.0.58 → 0.0.60
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 +19 -1
- package/dist/component.js +3 -2
- package/dist/provider.d.ts +13 -3
- package/dist/provider.js +0 -3
- package/dist/render.d.ts +11 -0
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -193,11 +193,21 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
193
193
|
logError(e: Error): void;
|
|
194
194
|
protected passError(e: Error, path: string): void;
|
|
195
195
|
}
|
|
196
|
+
export interface SiteInfo {
|
|
197
|
+
id: string;
|
|
198
|
+
name: string;
|
|
199
|
+
launched: boolean;
|
|
200
|
+
url?: {
|
|
201
|
+
prefix: string;
|
|
202
|
+
path: string;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
196
205
|
export interface PageRecord<DataType extends PageData = PageData> {
|
|
197
206
|
id: string;
|
|
198
207
|
linkId: string;
|
|
199
208
|
path: string;
|
|
200
209
|
data: DataType;
|
|
210
|
+
site: SiteInfo;
|
|
201
211
|
}
|
|
202
212
|
export interface ComponentData {
|
|
203
213
|
templateKey: string;
|
|
@@ -233,7 +243,15 @@ export interface RenderedComponent<C extends Component = Component> {
|
|
|
233
243
|
output: string;
|
|
234
244
|
}
|
|
235
245
|
export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
|
|
236
|
-
|
|
246
|
+
/**
|
|
247
|
+
* The page id in case you need to pass it to the API, e.g. this.api.getRootPage(this.id)
|
|
248
|
+
* in a page template or this.api.getRootPage(this.page.id) in a component template.
|
|
249
|
+
*/
|
|
250
|
+
id: string;
|
|
251
|
+
/**
|
|
252
|
+
* Other data we've already collected about the page being rendered, in case it's needed.
|
|
253
|
+
*/
|
|
254
|
+
pageInfo: PageRecord<DataType>;
|
|
237
255
|
/**
|
|
238
256
|
* This will be filled by the rendering server. The template properties are described
|
|
239
257
|
* over in apitemplate.ts in the comment for APIPageTemplate.templateProperties.
|
package/dist/component.js
CHANGED
|
@@ -175,9 +175,10 @@ export class Component extends ResourceProvider {
|
|
|
175
175
|
export class Page extends Component {
|
|
176
176
|
constructor(page, editMode) {
|
|
177
177
|
super(page.data, '', undefined, editMode);
|
|
178
|
-
this.
|
|
178
|
+
this.id = page.id;
|
|
179
|
+
this.pageInfo = page;
|
|
179
180
|
}
|
|
180
181
|
passError(e, path) {
|
|
181
|
-
console.warn(`Recoverable issue occured during render of ${this.
|
|
182
|
+
console.warn(`Recoverable issue occured during render of ${this.pageInfo.path}. Component at ${path} threw the following error:`, e);
|
|
182
183
|
}
|
|
183
184
|
}
|
package/dist/provider.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export interface CSSBlock {
|
|
|
5
5
|
css?: string;
|
|
6
6
|
/**
|
|
7
7
|
* A file path to the CSS. The rendering server will read the file on startup.
|
|
8
|
+
*
|
|
9
|
+
* Typically you will set this with import.meta.url so that the path will be relative
|
|
10
|
+
* to the javascript code where you are writing your template class:
|
|
11
|
+
* path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../static/mystyles.css')
|
|
8
12
|
*/
|
|
9
13
|
path?: string;
|
|
10
14
|
/**
|
|
@@ -35,6 +39,11 @@ export interface JSBlock {
|
|
|
35
39
|
js?: string;
|
|
36
40
|
/**
|
|
37
41
|
* A file path to the javascript. The rendering server will read the file on startup.
|
|
42
|
+
*
|
|
43
|
+
* Typically you will set this with import.meta.url so that the path will be relative
|
|
44
|
+
* to the javascript code where you are writing your template class:
|
|
45
|
+
* path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../static/myscript.js')
|
|
46
|
+
|
|
38
47
|
*/
|
|
39
48
|
path?: string;
|
|
40
49
|
/**
|
|
@@ -60,6 +69,10 @@ export interface JSBlock {
|
|
|
60
69
|
export interface FileDeclaration {
|
|
61
70
|
/**
|
|
62
71
|
* The path to the file.
|
|
72
|
+
*
|
|
73
|
+
* Typically you will set this with import.meta.url so that the path will be relative
|
|
74
|
+
* to the javascript code where you are writing your template class:
|
|
75
|
+
* path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../static/myfont.ttf')
|
|
63
76
|
*/
|
|
64
77
|
path: string;
|
|
65
78
|
/**
|
|
@@ -154,9 +167,6 @@ export declare abstract class ResourceProvider {
|
|
|
154
167
|
* server. Use the provided `webpaths` map to obtain the proper resource URLs. They will be
|
|
155
168
|
* available as soon as your template has been registered to the rendering server's templateRegistry.
|
|
156
169
|
*
|
|
157
|
-
* Typically you will set this to something like `${__dirname}/static` so that the path will be relative
|
|
158
|
-
* to where you are writing your template class.
|
|
159
|
-
*
|
|
160
170
|
* The map name you pick should be globally unique and only collide with other templates as
|
|
161
171
|
* intended. For instance, the fontawesome font only needs to be provided once, even though
|
|
162
172
|
* several templates might depend on it. Setting the name as 'fontawesome5' on all three
|
package/dist/provider.js
CHANGED
|
@@ -59,9 +59,6 @@ ResourceProvider.jsBlocks = new Map();
|
|
|
59
59
|
* server. Use the provided `webpaths` map to obtain the proper resource URLs. They will be
|
|
60
60
|
* available as soon as your template has been registered to the rendering server's templateRegistry.
|
|
61
61
|
*
|
|
62
|
-
* Typically you will set this to something like `${__dirname}/static` so that the path will be relative
|
|
63
|
-
* to where you are writing your template class.
|
|
64
|
-
*
|
|
65
62
|
* The map name you pick should be globally unique and only collide with other templates as
|
|
66
63
|
* intended. For instance, the fontawesome font only needs to be provided once, even though
|
|
67
64
|
* several templates might depend on it. Setting the name as 'fontawesome5' on all three
|
package/dist/render.d.ts
CHANGED
|
@@ -50,6 +50,17 @@ export interface APIClient {
|
|
|
50
50
|
absolute?: boolean;
|
|
51
51
|
extension?: string;
|
|
52
52
|
}) => Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a link href for a page
|
|
55
|
+
*
|
|
56
|
+
* By default this will generate relative links based on the page currently being rendered. Set
|
|
57
|
+
* absolute: true to generate a full URL suitable for a backend http request or non-HTML document
|
|
58
|
+
* like an RSS feed.
|
|
59
|
+
*/
|
|
60
|
+
getHref: (page: PageRecord, opts?: {
|
|
61
|
+
absolute?: boolean;
|
|
62
|
+
extension?: string;
|
|
63
|
+
}) => string;
|
|
53
64
|
/**
|
|
54
65
|
* This function will be provided by the rendering server and should be used inside your fetch
|
|
55
66
|
* method to prepare editor-provided HTML for rendering. It will do things like find and resolve
|