@knapsack/renderer-html 4.69.8--canary.4739.0cd3f38.0 → 4.69.8--canary.4746.02d415c.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -53
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
export declare class KnapsackHtmlRenderer extends KnapsackRendererBase implements KnapsackTemplateRenderer {
|
1
|
+
import { Renderable, Renderer, RendererBase } from '@knapsack/app/renderers';
|
2
|
+
export declare class KnapsackHtmlRenderer extends RendererBase implements Renderable {
|
4
3
|
constructor();
|
5
|
-
render
|
6
|
-
getUsage
|
7
|
-
getTemplateSuggestions
|
8
|
-
getMeta:
|
4
|
+
render: Renderer['render'];
|
5
|
+
getUsage: Renderer['getUsage'];
|
6
|
+
getTemplateSuggestions: Renderer['getTemplateSuggestions'];
|
7
|
+
getMeta: Renderer['getMeta'];
|
9
8
|
}
|
10
9
|
//# 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":"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"}
|
package/dist/index.js
CHANGED
@@ -2,6 +2,7 @@
|
|
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");
|
5
6
|
const types_1 = require("@knapsack/types");
|
6
7
|
const file_utils_1 = require("@knapsack/file-utils");
|
7
8
|
const path_1 = require("path");
|
@@ -11,13 +12,52 @@ app_1.log.setupUpdateNotifier({
|
|
11
12
|
version: pkg.version,
|
12
13
|
});
|
13
14
|
const gitRoot = (0, file_utils_1.findGitRoot)();
|
14
|
-
class KnapsackHtmlRenderer extends
|
15
|
+
class KnapsackHtmlRenderer extends renderers_1.RendererBase {
|
15
16
|
constructor() {
|
16
17
|
super({
|
17
18
|
id: types_1.rendererIds.html,
|
18
19
|
extension: '.html',
|
19
20
|
language: 'html',
|
20
21
|
});
|
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
|
+
};
|
21
61
|
this.getMeta = () => ({
|
22
62
|
id: this.id,
|
23
63
|
title: 'HTML',
|
@@ -31,58 +71,6 @@ class KnapsackHtmlRenderer extends app_1.KnapsackRendererBase {
|
|
31
71
|
hasTemplateSuggestionsSupport: true,
|
32
72
|
});
|
33
73
|
}
|
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
|
-
}
|
86
74
|
}
|
87
75
|
exports.KnapsackHtmlRenderer = KnapsackHtmlRenderer;
|
88
76
|
//# 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,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,CAAC,CAAC;QAGL,WAAM,GAAuB,KAAK,EAAE,GAAG,EAAE,EAAE;YACzC,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAEvC,OAAO;oBACL,EAAE,EAAE,IAAI;oBACR,IAAI,EAAE,MAAM,IAAA,uBA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AAC,EAAE;YACX,KAAK,EAAE,MAAM;YACb,0BAA0B,EAAE,MAAM;YAClC,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,KAAK;YACtB,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE,KAAK;YACtB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,mBAAmB,EAAE,KAAK;YAC1B,6BAA6B,EAAE,IAAI;SACpC,CAAC,CAAC;IAvDH,CAAC;CAwDF;AA/DD,oDA+DC"}
|
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.4746.02d415c.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.4746.02d415c.0",
|
26
|
+
"@knapsack/file-utils": "4.69.8--canary.4746.02d415c.0",
|
27
|
+
"@knapsack/types": "4.69.8--canary.4746.02d415c.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.4746.02d415c.0",
|
31
|
+
"@knapsack/typescript-config-starter": "4.69.8--canary.4746.02d415c.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": "02d415c844da6e3083eae6588a7645e0ce0fde57"
|
44
44
|
}
|