@dosgato/templating 0.0.5 → 0.0.6

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.
@@ -1,3 +1,20 @@
1
+ export interface CSSBlock {
2
+ css?: string;
3
+ path?: string;
4
+ version?: string;
5
+ defer?: boolean;
6
+ }
7
+ export interface JSBlock {
8
+ js?: string;
9
+ path?: string;
10
+ version?: string;
11
+ defer?: boolean;
12
+ }
13
+ export interface FileDeclaration {
14
+ path: string;
15
+ version?: string;
16
+ mime: string;
17
+ }
1
18
  /**
2
19
  * This class is a parent class for Component, but it can also be used as a standalone
3
20
  * if you are creating a set of templates with shared resources. This will be fairly
@@ -20,22 +37,23 @@ export declare abstract class ResourceProvider {
20
37
  * version number of any given name will be used. Other versions of that name will be ignored.
21
38
  *
22
39
  * For convenience you can either provide the `css` property with the CSS as a string, or the
23
- * `path` property with the full server path to a CSS file (node's __dirname function will
40
+ * `path` property with the full server path (NOT URL) to a CSS file (node's __dirname function will
24
41
  * help you determine it). You MUST provide one or the other.
42
+ *
43
+ * You may also set `defer` to true if a css block is not needed for the initial render of
44
+ * the page. For instance, if your component has a modal that the user can trigger, you can
45
+ * defer the CSS for that modal since it will not be needed until the page has gone interactive
46
+ * and the user has clicked something.
25
47
  */
26
- static cssBlocks: Map<string, {
27
- css?: string;
28
- path?: string;
29
- version?: string;
30
- }>;
48
+ static cssBlocks: Map<string, CSSBlock>;
31
49
  /**
32
50
  * Same as cssBlocks() but for javascript.
51
+ *
52
+ * In this case `defer` is much more useful, as most javascript is interactive and could run
53
+ * after the page renders. Any code that adds event observers or the like should be marked with
54
+ * defer to improve the initial render time.
33
55
  */
34
- static jsBlocks: Map<string, {
35
- js?: string;
36
- path?: string;
37
- version?: string;
38
- }>;
56
+ static jsBlocks: Map<string, JSBlock>;
39
57
  /**
40
58
  * If your template needs to serve any files, like fonts or images, you can provide
41
59
  * a filesystem path in this static property and the files will be served by the rendering
@@ -58,11 +76,7 @@ export declare abstract class ResourceProvider {
58
76
  * DO NOT change the mime type without changing the name. Other templates could end up with
59
77
  * the wrong file extension.
60
78
  */
61
- static files: Map<string, {
62
- path: string;
63
- version?: string;
64
- mime: string;
65
- }>;
79
+ static files: Map<string, FileDeclaration>;
66
80
  /**
67
81
  * Template code will need to generate HTML and CSS that points at the static files
68
82
  * provided above. In order to do so, we need information from the template registry (since
package/dist/provider.js CHANGED
@@ -27,12 +27,21 @@ exports.ResourceProvider = ResourceProvider;
27
27
  * version number of any given name will be used. Other versions of that name will be ignored.
28
28
  *
29
29
  * For convenience you can either provide the `css` property with the CSS as a string, or the
30
- * `path` property with the full server path to a CSS file (node's __dirname function will
30
+ * `path` property with the full server path (NOT URL) to a CSS file (node's __dirname function will
31
31
  * help you determine it). You MUST provide one or the other.
32
+ *
33
+ * You may also set `defer` to true if a css block is not needed for the initial render of
34
+ * the page. For instance, if your component has a modal that the user can trigger, you can
35
+ * defer the CSS for that modal since it will not be needed until the page has gone interactive
36
+ * and the user has clicked something.
32
37
  */
33
38
  ResourceProvider.cssBlocks = new Map();
34
39
  /**
35
40
  * Same as cssBlocks() but for javascript.
41
+ *
42
+ * In this case `defer` is much more useful, as most javascript is interactive and could run
43
+ * after the page renders. Any code that adds event observers or the like should be marked with
44
+ * defer to improve the initial render time.
36
45
  */
37
46
  ResourceProvider.jsBlocks = new Map();
38
47
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "exports": {
6
6
  "require": "./dist/index.js",