@dosgato/templating 0.0.55 → 0.0.58
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 +3 -1
- package/dist/provider.d.ts +97 -2
- package/dist/provider.js +15 -1
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { IncomingHttpHeaders } from 'http';
|
|
4
|
+
import type { ParsedUrlQuery } from 'querystring';
|
|
3
5
|
import { ResourceProvider } from './provider.js';
|
|
4
6
|
import { APIClient } from './render.js';
|
|
5
7
|
/**
|
|
@@ -182,7 +184,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
182
184
|
hadError: boolean;
|
|
183
185
|
autoLabel: string;
|
|
184
186
|
reqHeaders: IncomingHttpHeaders;
|
|
185
|
-
|
|
187
|
+
reqQuery: ParsedUrlQuery;
|
|
186
188
|
/**
|
|
187
189
|
* For logging errors during rendering without crashing the render. If your fetch, setContext,
|
|
188
190
|
* render, or renderVariation functions throw, the error will be logged but the page render will
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,19 +1,100 @@
|
|
|
1
1
|
export interface CSSBlock {
|
|
2
|
+
/**
|
|
3
|
+
* The CSS as a string. Provide either this or `path`.
|
|
4
|
+
*/
|
|
2
5
|
css?: string;
|
|
6
|
+
/**
|
|
7
|
+
* A file path to the CSS. The rendering server will read the file on startup.
|
|
8
|
+
*/
|
|
3
9
|
path?: string;
|
|
10
|
+
/**
|
|
11
|
+
* This CSS is actually SASS and requires a compile. The rendering server will
|
|
12
|
+
* perform the compilation on startup.
|
|
13
|
+
*/
|
|
14
|
+
sass?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* A version string following SEMVER. If multiple blocks are provided with the same name,
|
|
17
|
+
* the one with the highest version number will be chosen. If blocks of different major
|
|
18
|
+
* versions are provided, an alert will appear in the log.
|
|
19
|
+
*/
|
|
4
20
|
version?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The CSS provided by this block applies to elements that are not on screen at
|
|
23
|
+
* page load, i.e. modals and dialogs.
|
|
24
|
+
*
|
|
25
|
+
* Setting it true will improve our time-to-first-paint, but any CSS that does
|
|
26
|
+
* apply to elements on screen at page load will cause a visible re-render that
|
|
27
|
+
* may disturb the user.
|
|
28
|
+
*/
|
|
5
29
|
async?: boolean;
|
|
6
30
|
}
|
|
7
31
|
export interface JSBlock {
|
|
32
|
+
/**
|
|
33
|
+
* The javascript as a string. Provide either this or `path`.
|
|
34
|
+
*/
|
|
8
35
|
js?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A file path to the javascript. The rendering server will read the file on startup.
|
|
38
|
+
*/
|
|
9
39
|
path?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A version string following SEMVER. If multiple blocks are provided with the same name,
|
|
42
|
+
* the one with the highest version number will be chosen. If blocks of different major
|
|
43
|
+
* versions are provided, an alert will appear in the log.
|
|
44
|
+
*/
|
|
10
45
|
version?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The javascript provided by this block does not need to run before the DOM finishes
|
|
48
|
+
* loading. For instance, if the javascript only places event listeners and does not
|
|
49
|
+
* modify the DOM or create globals on first run, it is eligible for this flag.
|
|
50
|
+
*
|
|
51
|
+
* Setting it true will improve our time-to-first paint, but any DOM manipulations on
|
|
52
|
+
* first run will cause visible repaints that may disturb the user.
|
|
53
|
+
*
|
|
54
|
+
* Additionally, you cannot depend on load order of any async JS, so libraries like
|
|
55
|
+
* jquery that create globals intended for later use must be loaded synchronously
|
|
56
|
+
* (unless their dependents are smart enough to wait for the global to be defined).
|
|
57
|
+
*/
|
|
11
58
|
async?: boolean;
|
|
12
59
|
}
|
|
13
60
|
export interface FileDeclaration {
|
|
61
|
+
/**
|
|
62
|
+
* The path to the file.
|
|
63
|
+
*/
|
|
14
64
|
path: string;
|
|
65
|
+
/**
|
|
66
|
+
* A version string following SEMVER. If multiple files are provided with the same name,
|
|
67
|
+
* the one with the highest version number will be chosen.
|
|
68
|
+
*/
|
|
69
|
+
version?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The mime type of the file. If omitted, it will be automatically detected from the
|
|
72
|
+
* file data.
|
|
73
|
+
*
|
|
74
|
+
* If needed, you may also specify a non-default charset with e.g. `text/html; charset=ascii`
|
|
75
|
+
*/
|
|
76
|
+
mime?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface SCSSInclude {
|
|
79
|
+
/**
|
|
80
|
+
* The SASS code as a string. This SCSS should generally only include functions
|
|
81
|
+
* and mixins. Regular CSS should be included as its own block so it can be de-duplicated.
|
|
82
|
+
*
|
|
83
|
+
* Variables don't make much sense because we only have one version of a block every
|
|
84
|
+
* time it's used, whereas variables usually change from page template to page template.
|
|
85
|
+
* Use CSS variables instead.
|
|
86
|
+
*/
|
|
87
|
+
scss?: string;
|
|
88
|
+
/**
|
|
89
|
+
* A file path to the SASS code.
|
|
90
|
+
*/
|
|
91
|
+
path?: string;
|
|
92
|
+
/**
|
|
93
|
+
* A version string following SEMVER. If multiple blocks are provided with the same name,
|
|
94
|
+
* the one with the highest version number will be chosen. If blocks of different major
|
|
95
|
+
* versions are provided, an alert will appear in the log.
|
|
96
|
+
*/
|
|
15
97
|
version?: string;
|
|
16
|
-
mime: string;
|
|
17
98
|
}
|
|
18
99
|
/**
|
|
19
100
|
* This class is a parent class for Component, but it can also be used as a standalone
|
|
@@ -46,6 +127,19 @@ export declare abstract class ResourceProvider {
|
|
|
46
127
|
* and the user has clicked something.
|
|
47
128
|
*/
|
|
48
129
|
static cssBlocks: Map<string, CSSBlock>;
|
|
130
|
+
/**
|
|
131
|
+
* A template can provide SASS mixins and functions for use by other SASS-based CSS
|
|
132
|
+
* blocks.
|
|
133
|
+
*
|
|
134
|
+
* These includes can be utilized by other SASS with the SASS `@use` and `@include`
|
|
135
|
+
* commands, e.g.
|
|
136
|
+
* ```
|
|
137
|
+
* @use 'my-mixin-name' as mx;
|
|
138
|
+
* .someclass { @include mx.somemixin(); }
|
|
139
|
+
* ```
|
|
140
|
+
* In this case `my-mixin-name` is the key used for this Map.
|
|
141
|
+
*/
|
|
142
|
+
static scssIncludes: Map<string, SCSSInclude>;
|
|
49
143
|
/**
|
|
50
144
|
* Same as cssBlocks() but for javascript.
|
|
51
145
|
*
|
|
@@ -80,7 +174,8 @@ export declare abstract class ResourceProvider {
|
|
|
80
174
|
/**
|
|
81
175
|
* Template code will need to generate HTML and CSS that points at the static files
|
|
82
176
|
* provided above. In order to do so, we need information from the template registry (since
|
|
83
|
-
* we have to deduplicate with other registered templates at startup time
|
|
177
|
+
* we have to deduplicate with other registered templates at startup time, and the structure
|
|
178
|
+
* of the webpath in general is the render server's concern).
|
|
84
179
|
*
|
|
85
180
|
* In order to avoid an ES6 dependency on the registry, we will have the registry write
|
|
86
181
|
* back to this map as templates are registered.
|
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
|
*
|
|
@@ -66,7 +79,8 @@ ResourceProvider.files = new Map();
|
|
|
66
79
|
/**
|
|
67
80
|
* Template code will need to generate HTML and CSS that points at the static files
|
|
68
81
|
* provided above. In order to do so, we need information from the template registry (since
|
|
69
|
-
* we have to deduplicate with other registered templates at startup time
|
|
82
|
+
* we have to deduplicate with other registered templates at startup time, and the structure
|
|
83
|
+
* of the webpath in general is the render server's concern).
|
|
70
84
|
*
|
|
71
85
|
* In order to avoid an ES6 dependency on the registry, we will have the registry write
|
|
72
86
|
* back to this map as templates are registered.
|