@dosgato/templating 0.0.9 → 0.0.13

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,4 +1,3 @@
1
- import { Page } from './page';
2
1
  import { ResourceProvider } from './provider';
3
2
  /**
4
3
  * This is the primary templating class to build your templates. Subclass it and provide
@@ -117,3 +116,15 @@ export interface ContextBase {
117
116
  */
118
117
  headerLevel: number;
119
118
  }
119
+ export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
120
+ pagePath: string;
121
+ ancestors: PageRecord[];
122
+ /**
123
+ * we will fill this before rendering, stuff that dosgato knows needs to be added to
124
+ * the <head> element
125
+ * the page's render function must include it
126
+ */
127
+ headContent: string;
128
+ protected passError(e: Error, path: string): void;
129
+ constructor(page: PageWithAncestors<DataType>);
130
+ }
package/dist/component.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Component = void 0;
4
- const page_1 = require("./page");
3
+ exports.Page = exports.Component = void 0;
5
4
  const provider_1 = require("./provider");
6
5
  /**
7
6
  * This is the primary templating class to build your templates. Subclass it and provide
@@ -25,9 +24,9 @@ class Component extends provider_1.ResourceProvider {
25
24
  this.path = path;
26
25
  this.hadError = false;
27
26
  let tmpParent = (_a = this.parent) !== null && _a !== void 0 ? _a : this;
28
- while (!(tmpParent instanceof page_1.Page) && tmpParent.parent)
27
+ while (!(tmpParent instanceof Page) && tmpParent.parent)
29
28
  tmpParent = tmpParent.parent;
30
- if (!(tmpParent instanceof page_1.Page))
29
+ if (!(tmpParent instanceof Page))
31
30
  throw new Error('Hydration failed, could not map component back to its page.');
32
31
  this.page = tmpParent;
33
32
  }
@@ -84,9 +83,8 @@ class Component extends provider_1.ResourceProvider {
84
83
  * continue. You generally do not need to use this function, just throw when appropriate.
85
84
  */
86
85
  logError(e) {
87
- var _a;
88
86
  this.hadError = true;
89
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.passError(e, this.path);
87
+ this.passError(e, this.path);
90
88
  }
91
89
  // helper function for recursively passing the error up until it reaches the page
92
90
  passError(e, path) {
@@ -103,13 +101,24 @@ class Component extends provider_1.ResourceProvider {
103
101
  * need any async data to make this determination, be sure to fetch it during the fetch phase.
104
102
  */
105
103
  cssBlocks() {
106
- return this.constructor.cssBlocks().keys();
104
+ return this.constructor.cssBlocks.keys();
107
105
  }
108
106
  /**
109
107
  * Same as cssBlocks() but for javascript.
110
108
  */
111
109
  jsBlocks() {
112
- return this.constructor.jsBlocks().keys();
110
+ return this.constructor.jsBlocks.keys();
113
111
  }
114
112
  }
115
113
  exports.Component = Component;
114
+ class Page extends Component {
115
+ constructor(page) {
116
+ super(page.data, '/', undefined);
117
+ this.pagePath = page.path;
118
+ this.ancestors = page.ancestors;
119
+ }
120
+ passError(e, path) {
121
+ console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
122
+ }
123
+ }
124
+ exports.Page = Page;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './apitemplate';
2
2
  export * from './component';
3
3
  export * from './links';
4
- export * from './page';
5
4
  export * from './provider';
5
+ export * from './uitemplate';
package/dist/index.js CHANGED
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./apitemplate"), exports);
18
18
  __exportStar(require("./component"), exports);
19
19
  __exportStar(require("./links"), exports);
20
- __exportStar(require("./page"), exports);
21
20
  __exportStar(require("./provider"), exports);
21
+ __exportStar(require("./uitemplate"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.9",
3
+ "version": "0.0.13",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "exports": {
6
6
  "require": "./dist/index.js",
package/dist/page.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { PageData, ContextBase, Component, PageRecord, PageWithAncestors } from './component';
2
- export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
3
- pagePath: string;
4
- ancestors: PageRecord[];
5
- /**
6
- * we will fill this before rendering, stuff that dosgato knows needs to be added to
7
- * the <head> element
8
- * the page's render function must include it
9
- */
10
- headContent: string;
11
- protected passError(e: Error, path: string): void;
12
- constructor(page: PageWithAncestors<DataType>);
13
- }
package/dist/page.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Page = void 0;
4
- const component_1 = require("./component");
5
- class Page extends component_1.Component {
6
- constructor(page) {
7
- super(page.data, '/', undefined);
8
- this.pagePath = page.path;
9
- this.ancestors = page.ancestors;
10
- }
11
- passError(e, path) {
12
- console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
13
- }
14
- }
15
- exports.Page = Page;