@knapsack/renderer-html 4.69.8--canary.4746.02d415c.0 → 4.69.8--canary.4739.a806fc4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -41
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
|
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:
|
5
|
-
getUsage:
|
6
|
-
getTemplateSuggestions:
|
7
|
-
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
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
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
|
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,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAA0D;AAO1D,2CAA8C;AAC9C,qDAK8B;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,oBACX,SAAQ,0BAAoB;IAG5B;QACE,KAAK,CAAC;YACJ,EAAE,EAAE,m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AAC,CAAC;YACH,OAAO,IAAA,qBAAQ,EAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,eAAe,CAAC,uBAAuB,CAAC;gBAC3D,SAAS,EAAE,OAAO,CAAC,EAAE;gBACrB,UAAU,EAAE,QAAQ,CAAC,EAAE;aACxB,CAAC,CAAC;YACH,OAAO,IAAA,qBAAQ,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.8--canary.
|
4
|
+
"version": "4.69.8--canary.4739.a806fc4.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.8--canary.
|
26
|
-
"@knapsack/file-utils": "4.69.8--canary.
|
27
|
-
"@knapsack/types": "4.69.8--canary.
|
25
|
+
"@knapsack/app": "4.69.8--canary.4739.a806fc4.0",
|
26
|
+
"@knapsack/file-utils": "4.69.8--canary.4739.a806fc4.0",
|
27
|
+
"@knapsack/types": "4.69.8--canary.4739.a806fc4.0"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@knapsack/eslint-config-starter": "4.69.8--canary.
|
31
|
-
"@knapsack/typescript-config-starter": "4.69.8--canary.
|
30
|
+
"@knapsack/eslint-config-starter": "4.69.8--canary.4739.a806fc4.0",
|
31
|
+
"@knapsack/typescript-config-starter": "4.69.8--canary.4739.a806fc4.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": "
|
43
|
+
"gitHead": "a806fc491b243eedff7bd10705ecdb6386c714c8"
|
44
44
|
}
|