@gi-tcg/gts-transpiler 0.3.10 → 0.4.0

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.
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ function loosePlugin() {
68
68
  return function loosePluginTransformer(parser) {
69
69
  return class LooseParser extends parser {
70
70
  _patchedParseIdent = (liberal) => {
71
- if (this.type === tokTypes.name || this.type.keyword) return super.parseIdent(liberal);
71
+ if (this.type.label === "name" || this.type.keyword) return super.parseIdent(liberal);
72
72
  else return this.createDummyIdentifier();
73
73
  };
74
74
  #proxiedThis = new Proxy(this, { get: (target, prop) => {
@@ -1755,6 +1755,11 @@ function getPrintOptions(source, state) {
1755
1755
  context.write("\"");
1756
1756
  context.writeMapped(text.slice(1, -1), node.range[0], node.range[1], LITERAL_FROM_ID_MAPPING_DATA);
1757
1757
  context.write("\"");
1758
+ const generatedEnd = context.generatedOffset;
1759
+ context.createExtraMapping({
1760
+ start: node.range[0],
1761
+ end: node.range[1]
1762
+ }, generatedStart, generatedEnd, VERIFICATION_ONLY_MAPPING_DATA);
1758
1763
  } else if (state.attributeNameNodes.has(node) && node.range) context.writeMapped(node.raw ?? JSON.stringify(node.value), node.range[0], node.range[1], ATTRIBUTE_NAME_MAPPING_DATA);
1759
1764
  else if (directActionStubRange = state.directActionStubRange.get(node)) context.writeMapped(node.raw ?? JSON.stringify(node.value), directActionStubRange.start, directActionStubRange.start + 1, DIRECT_ACTION_STUB_MAPPING_DATA);
1760
1765
  else defaultPrinters.Literal(node, context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gi-tcg/gts-transpiler",
3
- "version": "0.3.10",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/piovium/gts.git"
@@ -9,7 +9,7 @@ export function loosePlugin() {
9
9
  private readonly _patchedParseIdent = (
10
10
  liberal?: boolean,
11
11
  ): AST.Identifier => {
12
- if (this.type === tokTypes.name || this.type.keyword) {
12
+ if (this.type.label === "name" || this.type.keyword) {
13
13
  return super.parseIdent(liberal);
14
14
  } else {
15
15
  return this.createDummyIdentifier();
@@ -92,6 +92,17 @@ export function getPrintOptions(
92
92
  LITERAL_FROM_ID_MAPPING_DATA,
93
93
  );
94
94
  context.write('"');
95
+ const generatedEnd = context.generatedOffset;
96
+ // Map error squiggle at quotation mark to the inner content
97
+ context.createExtraMapping(
98
+ {
99
+ start: node.range[0],
100
+ end: node.range[1],
101
+ },
102
+ generatedStart,
103
+ generatedEnd,
104
+ VERIFICATION_ONLY_MAPPING_DATA,
105
+ )
95
106
  } else if (state.attributeNameNodes.has(node) && node.range) {
96
107
  context.writeMapped(
97
108
  node.raw ?? JSON.stringify((node as EspolarAST.Literal).value),