@dosgato/templating 0.0.3 → 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.
- package/dist/apitemplate.d.ts +14 -0
- package/dist/index.js +5 -1
- package/dist/links.d.ts +1 -0
- package/dist/provider.d.ts +30 -16
- package/dist/provider.js +10 -1
- package/package.json +1 -1
package/dist/apitemplate.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface APITemplate {
|
|
|
11
11
|
* edu.txstate.RichTextEditor could be useful but no special format is required.
|
|
12
12
|
*/
|
|
13
13
|
templateKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* A uniquey human-readable name describing this template
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
14
18
|
/**
|
|
15
19
|
* Each template must declare its areas and the template keys of components that will be
|
|
16
20
|
* permitted inside each area. The list of allowed component templates can be updated beyond
|
|
@@ -48,6 +52,16 @@ export interface APITemplate {
|
|
|
48
52
|
* names.
|
|
49
53
|
*/
|
|
50
54
|
validate: (data: any) => Promise<Record<string, string[]>>;
|
|
55
|
+
/**
|
|
56
|
+
* Hard-coded properties that may be set on page templates to influence the rendering of
|
|
57
|
+
* components on the page. For instance, a set of color choices that are customized for
|
|
58
|
+
* each template design. Components on the page may refer to the color information stored
|
|
59
|
+
* in the template during dialogs and while rendering. Changing to a different page template
|
|
60
|
+
* could then result in different color choices for components like buttons.
|
|
61
|
+
*
|
|
62
|
+
* Must be null for non-page templates.
|
|
63
|
+
*/
|
|
64
|
+
templateProperties?: any;
|
|
51
65
|
}
|
|
52
66
|
/**
|
|
53
67
|
* In dosgato CMS, the data in the database is not altered except during user activity. This
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/links.d.ts
CHANGED
package/dist/provider.d.ts
CHANGED
|
@@ -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
|
/**
|