-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.html.update.js
More file actions
68 lines (62 loc) · 2.47 KB
/
Copy pathtypes.html.update.js
File metadata and controls
68 lines (62 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Run this script to update types.html.json. cmd>>>
* node ./types.html.update.js
* */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable global-require */
const fs = require("fs");
const htmlTypes = require("./types.html.json");
const htmlWsTypes = require("./types.html.webstorm.json");
try {
const vscodeTags = htmlTypes.tags.sort((a, b) => a.name.localeCompare(b.name));
vscodeTags.forEach((tag) => {
console.warn(`Proccessed <${tag.name}>`);
const exclude = new Set(["disabled", "readonly", "menu", "tooltip"]);
tag.attributes.forEach((a) => {
a.name = a.name.toLowerCase().trim();
if (!exclude.has(a.name) && !a.name.startsWith("w-")) {
a.name = `w-${a.name}`;
}
a.description = a.description.trim();
console.warn(` [${a.name}]`);
});
});
fs.writeFileSync("./types.html.json", JSON.stringify(htmlTypes, null, "\t"));
// update WebStorm: https://plugins.jetbrains.com/docs/intellij/websymbols-web-types.html#including-web-types
htmlWsTypes.version = require("./package.json").version;
const arrRead = htmlWsTypes.contributions.html.elements;
let arrWrite = arrRead;
arrWrite = [];
vscodeTags.forEach((tag) => {
console.warn(`Proccessed <${tag.name}>`);
const htmlDescr = {
name: tag.name,
description: tag.description,
};
const urlDoc = tag.references?.length && tag.references[0].url;
if (urlDoc) {
htmlDescr["doc-url"] = urlDoc;
}
htmlDescr.attributes = tag.attributes.map((a) => {
const wsAttr = {
name: a.name,
description: a.description,
};
if (a.values?.length) {
wsAttr.value = { kind: "plain", type: a.values.map((av) => `'${av.name}'`).join(" | ") };
}
// NiceToHave: add css-vars here
return wsAttr;
});
arrWrite.push(htmlDescr);
});
htmlWsTypes.contributions.html.elements = arrWrite;
fs.writeFileSync("./types.html.webstorm.json", JSON.stringify(htmlWsTypes, null, "\t"));
} catch (err) {
console.error(err);
}
// watchfix: VSCode built-in support: https://github.com/WICG/webcomponents/issues/776
// watchfix: VSCode css support: https://github.com/microsoft/vscode-custom-data/issues/82
// NiceToHave add types.css.json: prop [wupdark] + css-variables: but it's not supported now
// https://github.com/microsoft/vscode-extension-samples/blob/main/custom-data-sample/css.css-data.json
// https://github.com/microsoft/vscode-css-languageservice/blob/main/docs/customData.md