@dosgato/templating 0.0.8 → 0.0.12

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
@@ -100,7 +99,7 @@ export interface PageWithAncestors<DataType extends PageData = PageData> extends
100
99
  }
101
100
  export interface ComponentData {
102
101
  templateKey: string;
103
- areas: Record<string, ComponentData[]>;
102
+ areas?: Record<string, ComponentData[]>;
104
103
  }
105
104
  export interface PageData extends ComponentData {
106
105
  savedAtVersion: Date;
@@ -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
  }
@@ -103,13 +102,24 @@ class Component extends provider_1.ResourceProvider {
103
102
  * need any async data to make this determination, be sure to fetch it during the fetch phase.
104
103
  */
105
104
  cssBlocks() {
106
- return this.constructor.cssBlocks().keys();
105
+ return this.constructor.cssBlocks.keys();
107
106
  }
108
107
  /**
109
108
  * Same as cssBlocks() but for javascript.
110
109
  */
111
110
  jsBlocks() {
112
- return this.constructor.jsBlocks().keys();
111
+ return this.constructor.jsBlocks.keys();
113
112
  }
114
113
  }
115
114
  exports.Component = Component;
115
+ class Page extends Component {
116
+ constructor(page) {
117
+ super(page.data, '/', undefined);
118
+ this.pagePath = page.path;
119
+ this.ancestors = page.ancestors;
120
+ }
121
+ passError(e, path) {
122
+ console.warn(`Recoverable issue occured during render of ${this.pagePath}. Component at ${path} threw the following error:`, e);
123
+ }
124
+ }
125
+ 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.8",
3
+ "version": "0.0.12",
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;