@knapsack/renderer-html 4.69.9--canary.4745.99a87d9.0 → 4.69.9--canary.4739.3a8c6f1.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,15 +1,3 @@
1
- # v4.69.8 (Thu Sep 12 2024)
2
-
3
- #### 🐛 Bug Fix
4
-
5
- - refactor Renderers for cleaner types [#4746](https://github.com/knapsack-labs/app-monorepo/pull/4746) ([@EvanLovely](https://github.com/EvanLovely))
6
-
7
- #### Authors: 1
8
-
9
- - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
10
-
11
- ---
12
-
13
1
  # v4.69.7 (Wed Sep 11 2024)
14
2
 
15
3
  #### 🐛 Bug Fix
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { Renderable, Renderer, RendererBase } from '@knapsack/app/renderers';
2
- export declare class KnapsackHtmlRenderer extends RendererBase implements Renderable {
1
+ import { KnapsackRendererBase } from '@knapsack/app';
2
+ import type { KnapsackRenderParams, KnapsackTemplateRenderer, KnapsackTemplateRendererResults, KnapsackTemplateRendererBase } from '@knapsack/app/types';
3
+ export declare class KnapsackHtmlRenderer extends KnapsackRendererBase implements KnapsackTemplateRenderer {
3
4
  constructor();
4
- render: Renderer['render'];
5
- getUsage: Renderer['getUsage'];
6
- getTemplateSuggestions: Renderer['getTemplateSuggestions'];
7
- getMeta: Renderer['getMeta'];
5
+ render(opt: KnapsackRenderParams): Promise<KnapsackTemplateRendererResults>;
6
+ getUsage({ pattern, template, demo, patternManifest, }: KnapsackRenderParams): Promise<string>;
7
+ getTemplateSuggestions(): ReturnType<KnapsackTemplateRendererBase['getTemplateSuggestions']>;
8
+ getMeta: KnapsackTemplateRenderer['getMeta'];
8
9
  }
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAkB7E,qBAAa,oBAAqB,SAAQ,YAAa,YAAW,UAAU;;IAS1E,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAkBxB;IAEF,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAS5B;IAEF,sBAAsB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CASxD;IAEF,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAWzB;CACJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAO,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,qBAAqB,CAAC;AAiB7B,qBAAa,oBACX,SAAQ,oBACR,YAAW,wBAAwB;;IAU7B,MAAM,CACV,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,+BAA+B,CAAC;IAoBrC,QAAQ,CAAC,EACb,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,eAAe,GAChB,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBnC,sBAAsB,IAAI,UAAU,CACxC,4BAA4B,CAAC,wBAAwB,CAAC,CACvD;IAWD,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAWzC;CACJ"}
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KnapsackHtmlRenderer = void 0;
4
4
  const app_1 = require("@knapsack/app");
5
- const renderers_1 = require("@knapsack/app/renderers");
6
5
  const types_1 = require("@knapsack/types");
7
6
  const file_utils_1 = require("@knapsack/file-utils");
8
7
  const path_1 = require("path");
@@ -12,52 +11,13 @@ app_1.log.setupUpdateNotifier({
12
11
  version: pkg.version,
13
12
  });
14
13
  const gitRoot = (0, file_utils_1.findGitRoot)();
15
- class KnapsackHtmlRenderer extends renderers_1.RendererBase {
14
+ class KnapsackHtmlRenderer extends app_1.KnapsackRendererBase {
16
15
  constructor() {
17
16
  super({
18
17
  id: types_1.rendererIds.html,
19
18
  extension: '.html',
20
19
  language: 'html',
21
20
  });
22
- this.render = async (opt) => {
23
- try {
24
- const usage = await this.getUsage(opt);
25
- return {
26
- ok: true,
27
- html: await (0, file_utils_1.formatCode)({
28
- contents: usage,
29
- path: 'x.html',
30
- }),
31
- };
32
- }
33
- catch (e) {
34
- return {
35
- ok: false,
36
- html: `<p>${e.message}</p>`,
37
- message: e.message,
38
- };
39
- }
40
- };
41
- this.getUsage = async ({ template, demo }) => {
42
- const { absolutePath, exists } = await (0, file_utils_1.resolvePath)({
43
- path: demo.type === 'template' ? demo.templateInfo.path : template.path,
44
- resolveFromDir: this.dataDir,
45
- });
46
- if (!exists) {
47
- throw new Error(`File does not exist: ${absolutePath}`);
48
- }
49
- return (0, file_utils_1.readFile)(absolutePath);
50
- };
51
- this.getTemplateSuggestions = async () => {
52
- const { unusedPaths } = await this.getUnusedTemplatePaths({
53
- globPaths: [(0, path_1.join)(gitRoot, '**/*.html')],
54
- });
55
- return {
56
- suggestions: unusedPaths.map((path) => ({
57
- path,
58
- })),
59
- };
60
- };
61
21
  this.getMeta = () => ({
62
22
  id: this.id,
63
23
  title: 'HTML',
@@ -71,6 +31,58 @@ class KnapsackHtmlRenderer extends renderers_1.RendererBase {
71
31
  hasTemplateSuggestionsSupport: true,
72
32
  });
73
33
  }
34
+ async render(opt) {
35
+ try {
36
+ const usage = await this.getUsage(opt);
37
+ return {
38
+ ok: true,
39
+ html: await (0, file_utils_1.formatCode)({
40
+ contents: usage,
41
+ path: 'x.html',
42
+ }),
43
+ };
44
+ }
45
+ catch (e) {
46
+ return {
47
+ ok: false,
48
+ html: `<p>${e.message}</p>`,
49
+ message: e.message,
50
+ };
51
+ }
52
+ }
53
+ async getUsage({ pattern, template, demo, patternManifest, }) {
54
+ if (app_1.KnapsackRendererBase.isTemplateDemo(demo)) {
55
+ const templateDemoPath = patternManifest.getTemplateDemoAbsolutePath({
56
+ patternId: pattern.id,
57
+ templateId: template.id,
58
+ demoId: demo.id,
59
+ });
60
+ return (0, file_utils_1.readFile)(templateDemoPath);
61
+ }
62
+ try {
63
+ const templatePath = patternManifest.getTemplateAbsolutePath({
64
+ patternId: pattern.id,
65
+ templateId: template.id,
66
+ });
67
+ return (0, file_utils_1.readFile)(templatePath);
68
+ }
69
+ catch (e) {
70
+ console.log(e);
71
+ const msg = `Error getting pattern "${pattern.id}" template "${template.id}": ${e.message}`;
72
+ app_1.log.error(msg);
73
+ throw new Error(msg);
74
+ }
75
+ }
76
+ async getTemplateSuggestions() {
77
+ const { unusedPaths } = await this.getUnusedTemplatePaths({
78
+ globPaths: [(0, path_1.join)(gitRoot, '**/*.html')],
79
+ });
80
+ return {
81
+ suggestions: unusedPaths.map((path) => ({
82
+ path,
83
+ })),
84
+ };
85
+ }
74
86
  }
75
87
  exports.KnapsackHtmlRenderer = KnapsackHtmlRenderer;
76
88
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,uDAA6E;AAC7E,2CAA8C;AAC9C,qDAM8B;AAC9B,+BAA4B;AAE5B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,0BAAa,EAAC,SAAS,CAAC,CAAC;AACzC,SAAG,CAAC,mBAAmB,CAAC;IACtB,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,OAAO,EAAE,GAAG,CAAC,OAAO;CACrB,CAAC,CAAC;AACH,MAAM,OAAO,GAAG,IAAA,wBAAW,GAAE,CAAC;AAE9B,MAAa,oBAAqB,SAAQ,wBAAY;IACpD;QACE,KAAK,CAAC;YACJ,EAAE,EAAE,mBAAW,CAAC,IAAI;YACpB,SAAS,EAAE,OAAO;YAClB,QAAQ,EAAE,MAAM;SACjB,C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AQ,EAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,MAAM,GAAG,GAAG,0BAA0B,OAAO,CAAC,EAAE,eAAe,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;YAC5F,SAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB;QAG1B,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC;YACxD,SAAS,EAAE,CAAC,IAAA,WAAI,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACxC,CAAC,CAAC;QACH,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtC,IAAI;aACL,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CAcF;AAvFD,oDAuFC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knapsack/renderer-html",
3
3
  "description": "Render HTML",
4
- "version": "4.69.9--canary.4745.99a87d9.0",
4
+ "version": "4.69.9--canary.4739.3a8c6f1.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "exports": {
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "author": "Knapsack (https://www.knapsack.cloud)",
24
24
  "dependencies": {
25
- "@knapsack/app": "4.69.9--canary.4745.99a87d9.0",
26
- "@knapsack/file-utils": "4.69.9--canary.4745.99a87d9.0",
27
- "@knapsack/types": "4.69.9--canary.4745.99a87d9.0"
25
+ "@knapsack/app": "4.69.9--canary.4739.3a8c6f1.0",
26
+ "@knapsack/file-utils": "4.69.9--canary.4739.3a8c6f1.0",
27
+ "@knapsack/types": "4.69.9--canary.4739.3a8c6f1.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@knapsack/eslint-config-starter": "4.69.9--canary.4745.99a87d9.0",
31
- "@knapsack/typescript-config-starter": "4.69.9--canary.4745.99a87d9.0",
30
+ "@knapsack/eslint-config-starter": "4.69.9--canary.4739.3a8c6f1.0",
31
+ "@knapsack/typescript-config-starter": "4.69.9--canary.4739.3a8c6f1.0",
32
32
  "eslint": "^8.57.0",
33
33
  "typescript": "^5.5.4"
34
34
  },
@@ -40,5 +40,5 @@
40
40
  "directory": "apps/client/renderers/renderer-html",
41
41
  "type": "git"
42
42
  },
43
- "gitHead": "99a87d9b9f321739fe99bf3642c0b42e4f152676"
43
+ "gitHead": "3a8c6f18de1986c14fe426336bcefb1ca8c8ca21"
44
44
  }