@node-projects/web-component-designer-htmlparserservice-base-custom-webcomponent 0.1.2 → 0.1.4

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 ts from 'typescript';
2
1
  function* findAllNodesOfKind(node, kind) {
3
2
  if (node.kind == kind)
4
3
  yield node;
@@ -14,6 +13,7 @@ export class BaseCustomWebcomponentParserService {
14
13
  const sourceFile = this.parseTypescriptFile(code);
15
14
  let htmlCode = "";
16
15
  let cssStyle = "";
16
+ //@ts-ignore
17
17
  const nodes = findAllNodesOfKind(sourceFile, ts.SyntaxKind.TaggedTemplateExpression);
18
18
  for (let nd of nodes) {
19
19
  if (nd.tag.escapedText == 'html' && nd.parent.name.escapedText == "template")
@@ -29,25 +29,36 @@ export class BaseCustomWebcomponentParserService {
29
29
  const sourceFile = this.parseTypescriptFile(code);
30
30
  const transformTemplateLiterals = (context) => (rootNode) => {
31
31
  function visit(node) {
32
+ //@ts-ignore
32
33
  if (ts.isTemplateLiteral(node) &&
34
+ //@ts-ignore
33
35
  ts.isTaggedTemplateExpression(node.parent) &&
34
36
  node.parent.tag.escapedText == 'html' &&
35
37
  node.parent.parent.name.escapedText == "template") {
38
+ //@ts-ignore
36
39
  return ts.factory.createNoSubstitutionTemplateLiteral(html.replaceAll('\n', '\r\n'), html.replaceAll('\n', '\r\n'));
37
40
  }
38
41
  else if (css &&
42
+ //@ts-ignore
39
43
  ts.isTemplateLiteral(node) &&
44
+ //@ts-ignore
40
45
  ts.isTaggedTemplateExpression(node.parent) &&
41
46
  node.parent.tag.escapedText == 'css' &&
42
47
  node.parent.parent.name.escapedText == "style") {
48
+ //@ts-ignore
43
49
  return ts.factory.createNoSubstitutionTemplateLiteral(css.replaceAll('\n', '\r\n'), css.replaceAll('\n', '\r\n'));
44
50
  }
51
+ //@ts-ignore
45
52
  return ts.visitEachChild(node, visit, context);
46
53
  }
54
+ //@ts-ignore
47
55
  return ts.visitNode(rootNode, visit);
48
56
  };
57
+ //@ts-ignore
49
58
  let transformed = ts.transform(sourceFile, [transformTemplateLiterals]).transformed[0];
59
+ //@ts-ignore
50
60
  const printer = ts.createPrinter({ newLine: newLineCrLf ? ts.NewLineKind.CarriageReturnLineFeed : ts.NewLineKind.LineFeed });
61
+ //@ts-ignore
51
62
  const result = printer.printNode(ts.EmitHint.Unspecified, transformed, transformed);
52
63
  return result;
53
64
  }
@@ -59,6 +70,7 @@ export class BaseCustomWebcomponentParserService {
59
70
  getDefaultLibFileName: () => 'lib.d.ts',
60
71
  getNewLine: () => '\n',
61
72
  getSourceFile: filename => {
73
+ //@ts-ignore
62
74
  return ts.createSourceFile(filename, code, ts.ScriptTarget.Latest, true);
63
75
  },
64
76
  readFile: () => null,
@@ -66,8 +78,10 @@ export class BaseCustomWebcomponentParserService {
66
78
  writeFile: () => null,
67
79
  };
68
80
  const filename = 'aa.ts';
81
+ //@ts-ignore
69
82
  const program = ts.createProgram([filename], {
70
83
  noResolve: true,
84
+ //@ts-ignore
71
85
  target: ts.ScriptTarget.Latest,
72
86
  }, compilerHost);
73
87
  const sourceFile = program.getSourceFile(filename);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Parser Service for Templates inside of BaseCustomWebcomponent",
3
3
  "name": "@node-projects/web-component-designer-htmlparserservice-base-custom-webcomponent",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "type": "module",
6
6
  "main": "./dist/service/htmlParserService/BaseCustomWebcomponentParserService.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -12,8 +12,8 @@
12
12
  "prepublishOnly": "npm run build"
13
13
  },
14
14
  "dependencies": {
15
- "@node-projects/web-component-designer": "=>0.1.1",
16
- "typescript": "=>5.2.2"
15
+ "@node-projects/web-component-designer": ">=0.1.1",
16
+ "typescript": ">=5.2.2"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",