@dosgato/templating 0.0.57 → 0.0.59
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 +9 -0
- package/dist/component.js +1 -0
- package/dist/provider.d.ts +47 -3
- package/dist/provider.js +13 -3
- package/dist/render.d.ts +8 -0
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -233,6 +233,15 @@ export interface RenderedComponent<C extends Component = Component> {
|
|
|
233
233
|
output: string;
|
|
234
234
|
}
|
|
235
235
|
export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
|
|
236
|
+
/**
|
|
237
|
+
* The page id in case you need to pass it to the API, e.g. this.api.getRootPage(this.id)
|
|
238
|
+
* in a page template or this.api.getRootPage(this.page.id) in a component template.
|
|
239
|
+
*/
|
|
240
|
+
id: string;
|
|
241
|
+
/**
|
|
242
|
+
* The page path, can also be used to figure out where the page is, but you'll likely prefer
|
|
243
|
+
* using the page id in API queries
|
|
244
|
+
*/
|
|
236
245
|
pagePath: string;
|
|
237
246
|
/**
|
|
238
247
|
* This will be filled by the rendering server. The template properties are described
|
package/dist/component.js
CHANGED
|
@@ -176,6 +176,7 @@ export class Page extends Component {
|
|
|
176
176
|
constructor(page, editMode) {
|
|
177
177
|
super(page.data, '', undefined, editMode);
|
|
178
178
|
this.pagePath = page.path;
|
|
179
|
+
this.id = page.id;
|
|
179
180
|
}
|
|
180
181
|
passError(e, path) {
|
|
181
182
|
console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
|
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
|
/**
|
|
@@ -75,6 +88,27 @@ export interface FileDeclaration {
|
|
|
75
88
|
*/
|
|
76
89
|
mime?: string;
|
|
77
90
|
}
|
|
91
|
+
export interface SCSSInclude {
|
|
92
|
+
/**
|
|
93
|
+
* The SASS code as a string. This SCSS should generally only include functions
|
|
94
|
+
* and mixins. Regular CSS should be included as its own block so it can be de-duplicated.
|
|
95
|
+
*
|
|
96
|
+
* Variables don't make much sense because we only have one version of a block every
|
|
97
|
+
* time it's used, whereas variables usually change from page template to page template.
|
|
98
|
+
* Use CSS variables instead.
|
|
99
|
+
*/
|
|
100
|
+
scss?: string;
|
|
101
|
+
/**
|
|
102
|
+
* A file path to the SASS code.
|
|
103
|
+
*/
|
|
104
|
+
path?: string;
|
|
105
|
+
/**
|
|
106
|
+
* A version string following SEMVER. If multiple blocks are provided with the same name,
|
|
107
|
+
* the one with the highest version number will be chosen. If blocks of different major
|
|
108
|
+
* versions are provided, an alert will appear in the log.
|
|
109
|
+
*/
|
|
110
|
+
version?: string;
|
|
111
|
+
}
|
|
78
112
|
/**
|
|
79
113
|
* This class is a parent class for Component, but it can also be used as a standalone
|
|
80
114
|
* if you are creating a set of templates with shared resources. This will be fairly
|
|
@@ -106,6 +140,19 @@ export declare abstract class ResourceProvider {
|
|
|
106
140
|
* and the user has clicked something.
|
|
107
141
|
*/
|
|
108
142
|
static cssBlocks: Map<string, CSSBlock>;
|
|
143
|
+
/**
|
|
144
|
+
* A template can provide SASS mixins and functions for use by other SASS-based CSS
|
|
145
|
+
* blocks.
|
|
146
|
+
*
|
|
147
|
+
* These includes can be utilized by other SASS with the SASS `@use` and `@include`
|
|
148
|
+
* commands, e.g.
|
|
149
|
+
* ```
|
|
150
|
+
* @use 'my-mixin-name' as mx;
|
|
151
|
+
* .someclass { @include mx.somemixin(); }
|
|
152
|
+
* ```
|
|
153
|
+
* In this case `my-mixin-name` is the key used for this Map.
|
|
154
|
+
*/
|
|
155
|
+
static scssIncludes: Map<string, SCSSInclude>;
|
|
109
156
|
/**
|
|
110
157
|
* Same as cssBlocks() but for javascript.
|
|
111
158
|
*
|
|
@@ -120,9 +167,6 @@ export declare abstract class ResourceProvider {
|
|
|
120
167
|
* server. Use the provided `webpaths` map to obtain the proper resource URLs. They will be
|
|
121
168
|
* available as soon as your template has been registered to the rendering server's templateRegistry.
|
|
122
169
|
*
|
|
123
|
-
* Typically you will set this to something like `${__dirname}/static` so that the path will be relative
|
|
124
|
-
* to where you are writing your template class.
|
|
125
|
-
*
|
|
126
170
|
* The map name you pick should be globally unique and only collide with other templates as
|
|
127
171
|
* intended. For instance, the fontawesome font only needs to be provided once, even though
|
|
128
172
|
* several templates might depend on it. Setting the name as 'fontawesome5' on all three
|
package/dist/provider.js
CHANGED
|
@@ -32,6 +32,19 @@ export class ResourceProvider {
|
|
|
32
32
|
* and the user has clicked something.
|
|
33
33
|
*/
|
|
34
34
|
ResourceProvider.cssBlocks = new Map();
|
|
35
|
+
/**
|
|
36
|
+
* A template can provide SASS mixins and functions for use by other SASS-based CSS
|
|
37
|
+
* blocks.
|
|
38
|
+
*
|
|
39
|
+
* These includes can be utilized by other SASS with the SASS `@use` and `@include`
|
|
40
|
+
* commands, e.g.
|
|
41
|
+
* ```
|
|
42
|
+
* @use 'my-mixin-name' as mx;
|
|
43
|
+
* .someclass { @include mx.somemixin(); }
|
|
44
|
+
* ```
|
|
45
|
+
* In this case `my-mixin-name` is the key used for this Map.
|
|
46
|
+
*/
|
|
47
|
+
ResourceProvider.scssIncludes = new Map();
|
|
35
48
|
/**
|
|
36
49
|
* Same as cssBlocks() but for javascript.
|
|
37
50
|
*
|
|
@@ -46,9 +59,6 @@ ResourceProvider.jsBlocks = new Map();
|
|
|
46
59
|
* server. Use the provided `webpaths` map to obtain the proper resource URLs. They will be
|
|
47
60
|
* available as soon as your template has been registered to the rendering server's templateRegistry.
|
|
48
61
|
*
|
|
49
|
-
* Typically you will set this to something like `${__dirname}/static` so that the path will be relative
|
|
50
|
-
* to where you are writing your template class.
|
|
51
|
-
*
|
|
52
62
|
* The map name you pick should be globally unique and only collide with other templates as
|
|
53
63
|
* intended. For instance, the fontawesome font only needs to be provided once, even though
|
|
54
64
|
* several templates might depend on it. Setting the name as 'fontawesome5' on all three
|
package/dist/render.d.ts
CHANGED
|
@@ -50,6 +50,14 @@ 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, absolute?: boolean) => string;
|
|
53
61
|
/**
|
|
54
62
|
* This function will be provided by the rendering server and should be used inside your fetch
|
|
55
63
|
* method to prepare editor-provided HTML for rendering. It will do things like find and resolve
|