@dosgato/templating 0.0.54 → 0.0.57

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,7 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import type { IncomingHttpHeaders } from 'http';
4
+ import type { ParsedUrlQuery } from 'querystring';
1
5
  import { ResourceProvider } from './provider.js';
2
6
  import { APIClient } from './render.js';
3
7
  /**
@@ -179,8 +183,8 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
179
183
  renderedAreas: Map<string, RenderedComponent[]>;
180
184
  hadError: boolean;
181
185
  autoLabel: string;
182
- reqHeaders: Headers;
183
- reqUrl: URL;
186
+ reqHeaders: IncomingHttpHeaders;
187
+ reqQuery: ParsedUrlQuery;
184
188
  /**
185
189
  * For logging errors during rendering without crashing the render. If your fetch, setContext,
186
190
  * render, or renderVariation functions throw, the error will be logged but the page render will
@@ -249,7 +253,7 @@ export declare abstract class Page<DataType extends PageData = any, FetchedType
249
253
  * This method will be provided to page templates by the render server. You may call it
250
254
  * at any time during fetch, context, or render, to set an HTTP header on the response
251
255
  */
252
- addHeader: (key: string, value: string) => void;
256
+ addHeader: (key: string, value: string | undefined) => void;
253
257
  protected passError(e: Error, path: string): void;
254
258
  constructor(page: PageRecord<DataType>, editMode: boolean);
255
259
  }
@@ -1,19 +1,79 @@
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
+ */
15
69
  version?: string;
16
- mime: 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;
17
77
  }
18
78
  /**
19
79
  * This class is a parent class for Component, but it can also be used as a standalone
@@ -80,7 +140,8 @@ export declare abstract class ResourceProvider {
80
140
  /**
81
141
  * Template code will need to generate HTML and CSS that points at the static files
82
142
  * 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).
143
+ * we have to deduplicate with other registered templates at startup time, and the structure
144
+ * of the webpath in general is the render server's concern).
84
145
  *
85
146
  * In order to avoid an ES6 dependency on the registry, we will have the registry write
86
147
  * back to this map as templates are registered.
package/dist/provider.js CHANGED
@@ -66,7 +66,8 @@ ResourceProvider.files = new Map();
66
66
  /**
67
67
  * Template code will need to generate HTML and CSS that points at the static files
68
68
  * 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).
69
+ * we have to deduplicate with other registered templates at startup time, and the structure
70
+ * of the webpath in general is the render server's concern).
70
71
  *
71
72
  * In order to avoid an ES6 dependency on the registry, we will have the registry write
72
73
  * back to this map as templates are registered.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.54",
3
+ "version": "0.0.57",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,6 +18,7 @@
18
18
  "txstate-utils": "^1.7.4"
19
19
  },
20
20
  "devDependencies": {
21
+ "@types/node": "^18.7.11",
21
22
  "eslint-config-standard-with-typescript": "^22.0.0",
22
23
  "typescript": "^4.4.2"
23
24
  },