@atscript/core 0.1.88 → 0.1.90

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.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";
2
- //#region rolldown:runtime
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,12 +7,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
16
20
  }
17
21
  return to;
18
22
  };
@@ -22,17 +26,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
26
  }) : target, mod));
23
27
 
24
28
  //#endregion
25
- const node_fs = __toESM(require("node:fs"));
26
- const node_fs_promises = __toESM(require("node:fs/promises"));
27
- const node_path = __toESM(require("node:path"));
28
- const node_url = __toESM(require("node:url"));
29
- const rolldown = __toESM(require("rolldown"));
30
- const path = __toESM(require("path"));
31
- const url = __toESM(require("url"));
32
- const __prostojs_parser = __toESM(require("@prostojs/parser"));
33
- const defu = __toESM(require("defu"));
34
- const fs_promises = __toESM(require("fs/promises"));
35
- const glob = __toESM(require("glob"));
29
+ let node_fs = require("node:fs");
30
+ node_fs = __toESM(node_fs);
31
+ let node_fs_promises = require("node:fs/promises");
32
+ let node_path = require("node:path");
33
+ node_path = __toESM(node_path);
34
+ let node_url = require("node:url");
35
+ let rolldown = require("rolldown");
36
+ let path = require("path");
37
+ path = __toESM(path);
38
+ let url = require("url");
39
+ let _prostojs_parser = require("@prostojs/parser");
40
+ let defu = require("defu");
41
+ let fs_promises = require("fs/promises");
42
+ let glob = require("glob");
36
43
 
37
44
  //#region packages/core/src/parser/nodes/semantic-node.ts
38
45
  function _define_property$16(obj, key, value) {
@@ -42,7 +49,7 @@ function _define_property$16(obj, key, value) {
42
49
  configurable: true,
43
50
  writable: true
44
51
  });
45
- else obj[key] = value;
52
+ else obj[key] = value;
46
53
  return obj;
47
54
  }
48
55
  var SemanticNode = class {
@@ -77,9 +84,9 @@ var SemanticNode = class {
77
84
  }
78
85
  annotate(name, token) {
79
86
  if (!this.annotations) this.annotations = [];
80
- if (!this.annotationsCounter) this.annotationsCounter = new Map();
87
+ if (!this.annotationsCounter) this.annotationsCounter = /* @__PURE__ */ new Map();
81
88
  if (this.annotationsCounter.has(name)) this.annotationsCounter.set(name, this.annotationsCounter.get(name) + 1);
82
- else this.annotationsCounter.set(name, 1);
89
+ else this.annotationsCounter.set(name, 1);
83
90
  token.parentNode = this;
84
91
  const a = {
85
92
  name,
@@ -109,7 +116,7 @@ else this.annotationsCounter.set(name, 1);
109
116
  return this.token("identifier")?.text;
110
117
  }
111
118
  saveToken(token, semantic) {
112
- if (!this.tokens) this.tokens = new Map();
119
+ if (!this.tokens) this.tokens = /* @__PURE__ */ new Map();
113
120
  token.parentNode = this;
114
121
  this.tokens.set(semantic, token);
115
122
  return this;
@@ -192,12 +199,12 @@ var SemanticAnnotateNode = class extends SemanticNode {
192
199
  doc.registerExport(this);
193
200
  }
194
201
  } else if (this.token("export")) doc.registerMessage(this.token("export"), "Cannot export mutating ad-hoc annotations block");
195
- const block$2 = this.token("inner");
196
- if (block$2) {
197
- block$2.blockType = "annotate";
198
- doc.blocksIndex.add(block$2);
202
+ const block = this.token("inner");
203
+ if (block) {
204
+ block.blockType = "annotate";
205
+ doc.blocksIndex.add(block);
199
206
  }
200
- const seenEntries = new Set();
207
+ const seenEntries = /* @__PURE__ */ new Set();
201
208
  for (const entry of this.entries) {
202
209
  const entryPath = entry.hasChain ? `${entry.id}.${entry.chain.map((c) => c.text).join(".")}` : entry.id;
203
210
  if (seenEntries.has(entryPath)) {
@@ -229,8 +236,8 @@ var SemanticAnnotateNode = class extends SemanticNode {
229
236
  //#region packages/core/src/parser/nodes/array-node.ts
230
237
  var SemanticArrayNode = class extends SemanticNode {
231
238
  get props() {
232
- if (this.definition) return isStructure(this.definition) ? this.definition.props : new Map();
233
- return new Map();
239
+ if (this.definition) return isStructure(this.definition) ? this.definition.props : /* @__PURE__ */ new Map();
240
+ return /* @__PURE__ */ new Map();
234
241
  }
235
242
  constructor() {
236
243
  super("array");
@@ -258,7 +265,7 @@ function _define_property$15(obj, key, value) {
258
265
  configurable: true,
259
266
  writable: true
260
267
  });
261
- else obj[key] = value;
268
+ else obj[key] = value;
262
269
  return obj;
263
270
  }
264
271
  var SemanticGroup = class extends SemanticNode {
@@ -325,7 +332,7 @@ function _define_property$14(obj, key, value) {
325
332
  configurable: true,
326
333
  writable: true
327
334
  });
328
- else obj[key] = value;
335
+ else obj[key] = value;
329
336
  return obj;
330
337
  }
331
338
  var SemanticInterfaceNode = class extends SemanticNode {
@@ -354,8 +361,8 @@ var SemanticInterfaceNode = class extends SemanticNode {
354
361
  }
355
362
  }
356
363
  get props() {
357
- if (this.definition) return isStructure(this.definition) ? this.definition.props : new Map();
358
- return new Map();
364
+ if (this.definition) return isStructure(this.definition) ? this.definition.props : /* @__PURE__ */ new Map();
365
+ return /* @__PURE__ */ new Map();
359
366
  }
360
367
  toString(level = 0, prefix = "●") {
361
368
  let s = super.toString(level, prefix);
@@ -379,7 +386,7 @@ function _define_property$13(obj, key, value) {
379
386
  configurable: true,
380
387
  writable: true
381
388
  });
382
- else obj[key] = value;
389
+ else obj[key] = value;
383
390
  return obj;
384
391
  }
385
392
  var Token = class Token {
@@ -388,11 +395,10 @@ var Token = class Token {
388
395
  return `[${this.type}] "${this.text}"${children}`;
389
396
  }
390
397
  clone(replace) {
391
- const t = {
398
+ return new Token({
392
399
  ...this._data,
393
400
  ...replace
394
- };
395
- return new Token(t);
401
+ });
396
402
  }
397
403
  get text() {
398
404
  return this._data.text || "";
@@ -464,18 +470,18 @@ function _define_property$12(obj, key, value) {
464
470
  configurable: true,
465
471
  writable: true
466
472
  });
467
- else obj[key] = value;
473
+ else obj[key] = value;
468
474
  return obj;
469
475
  }
470
476
  var SemanticPrimitiveNode = class SemanticPrimitiveNode extends SemanticNode {
471
477
  applyAnnotations() {
472
478
  this.annotations = [];
473
479
  for (const [name, value] of Object.entries(this.config.annotations || {})) {
474
- const spec = this.annotationTree ? resolveAnnotation(name, this.annotationTree) : undefined;
480
+ const spec = this.annotationTree ? resolveAnnotation(name, this.annotationTree) : void 0;
475
481
  const isMultiple = spec?.config.multiple ?? false;
476
482
  if (Array.isArray(value)) {
477
483
  if (isMultiple) for (const item of value) this.annotations.push(toAnnotationTokens(name, item, spec));
478
- else if (value.length > 0) this.annotations.push(toAnnotationTokens(name, value[0], spec));
484
+ else if (value.length > 0) this.annotations.push(toAnnotationTokens(name, value[0], spec));
479
485
  } else this.annotations.push(toAnnotationTokens(name, value, spec));
480
486
  }
481
487
  }
@@ -484,7 +490,7 @@ else if (value.length > 0) this.annotations.push(toAnnotationTokens(name, value[
484
490
  }
485
491
  getAllTags(_processed) {
486
492
  const allTags = [this._id];
487
- const processed = _processed || new Set();
493
+ const processed = _processed || /* @__PURE__ */ new Set();
488
494
  processed.add(this);
489
495
  for (const [, node] of this.props) {
490
496
  if (processed.has(node)) continue;
@@ -507,7 +513,7 @@ else if (value.length > 0) this.annotations.push(toAnnotationTokens(name, value[
507
513
  }
508
514
  constructor(_id, config, parentKey = "", annotationTree) {
509
515
  super("primitive"), _define_property$12(this, "_id", void 0), _define_property$12(this, "config", void 0), _define_property$12(this, "parentKey", void 0), _define_property$12(this, "annotationTree", void 0), _define_property$12(this, "type", void 0), _define_property$12(this, "props", void 0), _define_property$12(this, "tags", void 0), this._id = _id, this.config = config, this.parentKey = parentKey, this.annotationTree = annotationTree;
510
- this.props = new Map();
516
+ this.props = /* @__PURE__ */ new Map();
511
517
  this.tags = new Set([_id, ...config?.tags || []]);
512
518
  for (const [ext, def] of Object.entries(config.extensions || {})) {
513
519
  const node = new SemanticPrimitiveNode(ext, {
@@ -523,7 +529,7 @@ else if (value.length > 0) this.annotations.push(toAnnotationTokens(name, value[
523
529
  this.props.set(ext, node);
524
530
  }
525
531
  if (typeof config.type === "object") this.type = config.type.kind === "final" ? config.type.value : config.type.kind;
526
- else this.type = config.type;
532
+ else this.type = config.type;
527
533
  this.applyAnnotations();
528
534
  }
529
535
  };
@@ -543,18 +549,16 @@ function toAnnotationTokens(name, value, spec) {
543
549
  token: dummyToken,
544
550
  args: [num(value)]
545
551
  };
546
- const argNames = spec?.arguments.map((a) => a.name) ?? Object.keys(value);
547
- const raw = argNames.map((argName) => {
552
+ const raw = (spec?.arguments.map((a) => a.name) ?? Object.keys(value)).map((argName) => {
548
553
  const v = value[argName];
549
- if (v === undefined) return undefined;
554
+ if (v === void 0) return;
550
555
  return typeof v === "number" ? num(v) : text$1(String(v));
551
556
  });
552
- while (raw.length > 0 && raw[raw.length - 1] === undefined) raw.pop();
553
- const args = raw.map((t) => t ?? text$1(""));
557
+ while (raw.length > 0 && raw[raw.length - 1] === void 0) raw.pop();
554
558
  return {
555
559
  name,
556
560
  token: dummyToken,
557
- args
561
+ args: raw.map((t) => t ?? text$1(""))
558
562
  };
559
563
  }
560
564
  const dummyToken = new Token({
@@ -634,7 +638,7 @@ function _define_property$11(obj, key, value) {
634
638
  configurable: true,
635
639
  writable: true
636
640
  });
637
- else obj[key] = value;
641
+ else obj[key] = value;
638
642
  return obj;
639
643
  }
640
644
  var SemanticRefNode = class extends SemanticNode {
@@ -692,27 +696,27 @@ function _define_property$10(obj, key, value) {
692
696
  configurable: true,
693
697
  writable: true
694
698
  });
695
- else obj[key] = value;
699
+ else obj[key] = value;
696
700
  return obj;
697
701
  }
698
702
  var SemanticStructureNode = class extends SemanticGroup {
699
703
  /**
700
704
  * Shortcut to set props, used as utility
701
- */ setProps(props$1) {
702
- this.nodes = props$1;
703
- for (const prop of props$1) {
705
+ */ setProps(props) {
706
+ this.nodes = props;
707
+ for (const prop of props) {
704
708
  prop.ownerNode = this;
705
709
  this.props.set(prop.id, prop);
706
710
  }
707
711
  }
708
712
  registerAtDocument(doc) {
709
- const block$2 = this.token("identifier");
710
- block$2.blockType = "structure";
711
- doc.blocksIndex.add(block$2);
713
+ const block = this.token("identifier");
714
+ block.blockType = "structure";
715
+ doc.blocksIndex.add(block);
712
716
  for (const node of this.nodes) {
713
717
  const token = node.token("identifier");
714
718
  if (!token) {
715
- doc.registerMessage(block$2, "Has empty prop node");
719
+ doc.registerMessage(block, "Has empty prop node");
716
720
  continue;
717
721
  }
718
722
  const name = token.text;
@@ -743,28 +747,28 @@ var SemanticStructureNode = class extends SemanticGroup {
743
747
  if (opts.documentation) prop.setDocumentation(opts.documentation);
744
748
  prop.saveToken(propToken, "identifier");
745
749
  if (typeof opts.type === "string") {
746
- const ref$1 = new SemanticRefNode();
750
+ const ref = new SemanticRefNode();
747
751
  const [first, ...rest] = opts.type.split(".");
748
752
  const refToken = token.clone({
749
753
  type: "identifier",
750
754
  text: first
751
755
  });
752
- ref$1.saveToken(refToken, "identifier");
756
+ ref.saveToken(refToken, "identifier");
753
757
  for (const chain of rest) {
754
758
  const chainToken = token.clone({
755
759
  type: "identifier",
756
760
  text: chain
757
761
  });
758
- ref$1.addChain(chainToken);
762
+ ref.addChain(chainToken);
759
763
  }
760
- prop.define(ref$1);
764
+ prop.define(ref);
761
765
  } else prop.define(opts.type);
762
766
  prop.ownerNode = this;
763
767
  this.nodes.push(prop);
764
768
  this.props.set(opts.name, prop);
765
769
  }
766
770
  constructor() {
767
- super(), _define_property$10(this, "props", new Map());
771
+ super(), _define_property$10(this, "props", /* @__PURE__ */ new Map());
768
772
  this.entity = "structure";
769
773
  }
770
774
  };
@@ -806,7 +810,7 @@ function _define_property$9(obj, key, value) {
806
810
  configurable: true,
807
811
  writable: true
808
812
  });
809
- else obj[key] = value;
813
+ else obj[key] = value;
810
814
  return obj;
811
815
  }
812
816
  var SemanticQueryNode = class extends SemanticNode {
@@ -928,13 +932,13 @@ function isAnnotate(node) {
928
932
  return node?.entity === "annotate";
929
933
  }
930
934
  function isQueryLogical(node) {
931
- return node?.operands !== undefined;
935
+ return node?.operands !== void 0;
932
936
  }
933
937
  function isQueryComparison(node) {
934
- return node?.left !== undefined;
938
+ return node?.left !== void 0;
935
939
  }
936
940
  function isQueryFieldRef(node) {
937
- return node?.fieldRef !== undefined;
941
+ return node?.fieldRef !== void 0;
938
942
  }
939
943
 
940
944
  //#endregion
@@ -946,7 +950,7 @@ function _define_property$8(obj, key, value) {
946
950
  configurable: true,
947
951
  writable: true
948
952
  });
949
- else obj[key] = value;
953
+ else obj[key] = value;
950
954
  return obj;
951
955
  }
952
956
  var AnnotationSpec = class {
@@ -963,14 +967,14 @@ var AnnotationSpec = class {
963
967
  return `${quote}\${${placeholderIndex}:${defaultValue}}${quote}`;
964
968
  }).join(", ");
965
969
  }
966
- validateType(tokenType, type$1) {
967
- switch (type$1) {
968
- case "string": return tokenType === "text" ? undefined : "string expected.";
969
- case "number": return tokenType === "number" ? undefined : "number expected.";
970
- case "boolean": return tokenType === "identifier" ? undefined : "boolean expected.";
971
- case "ref": return tokenType === "identifier" ? undefined : "type reference expected.";
972
- case "query": return tokenType === "query" ? undefined : "query expression expected (use backticks).";
973
- default: return `unknown type "${type$1}".`;
970
+ validateType(tokenType, type) {
971
+ switch (type) {
972
+ case "string": return tokenType === "text" ? void 0 : "string expected.";
973
+ case "number": return tokenType === "number" ? void 0 : "number expected.";
974
+ case "boolean": return tokenType === "identifier" ? void 0 : "boolean expected.";
975
+ case "ref": return tokenType === "identifier" ? void 0 : "type reference expected.";
976
+ case "query": return tokenType === "query" ? void 0 : "query expression expected (use backticks).";
977
+ default: return `unknown type "${type}".`;
974
978
  }
975
979
  }
976
980
  modify(mainToken, args, doc) {
@@ -1030,7 +1034,7 @@ var AnnotationSpec = class {
1030
1034
  range: token.range
1031
1035
  });
1032
1036
  }
1033
- return messages.length > 0 ? messages : undefined;
1037
+ return messages.length > 0 ? messages : void 0;
1034
1038
  }
1035
1039
  /**
1036
1040
  * Cross-file-dependent validation, deferred to diagnostic time
@@ -1043,20 +1047,19 @@ var AnnotationSpec = class {
1043
1047
  * diagnostics. Annotate-block entries' `defType` guard is handled separately
1044
1048
  * by `getDiagMessages` (the `referred` loop) and is skipped here.
1045
1049
  */ validateDeferred(mainToken, args, doc) {
1046
- if (!mainToken.parentNode) return undefined;
1050
+ if (!mainToken.parentNode) return;
1047
1051
  const messages = [];
1048
1052
  if (this.config.defType?.length) {
1049
1053
  const parentNode = mainToken.parentNode;
1050
- const idToken = isRef(parentNode) ? parentNode.token("identifier") : undefined;
1051
- const isAnnotateEntry = !!idToken && !!doc.annotateBlockAt(idToken.range.start.line, idToken.range.start.character);
1052
- if (!isAnnotateEntry) {
1054
+ const idToken = isRef(parentNode) ? parentNode.token("identifier") : void 0;
1055
+ if (!(!!idToken && !!doc.annotateBlockAt(idToken.range.start.line, idToken.range.start.character))) {
1053
1056
  let def = parentNode.getDefinition();
1054
1057
  if (isRef(def)) def = doc.unwindType(def.id, def.chain)?.def || def;
1055
1058
  messages.push(...this.validateTargetType(def, mainToken.range) || []);
1056
1059
  }
1057
1060
  }
1058
1061
  if (this.config.validate) messages.push(...this.config.validate(mainToken, args, doc) || []);
1059
- return messages.length > 0 ? messages : undefined;
1062
+ return messages.length > 0 ? messages : void 0;
1060
1063
  }
1061
1064
  /**
1062
1065
  * Checks an already-resolved target node against this annotation's `defType`
@@ -1066,16 +1069,15 @@ var AnnotationSpec = class {
1066
1069
  * the deferred annotate-entry check in `AtscriptDoc.getDiagMessages`, where
1067
1070
  * imported target types finally resolve.
1068
1071
  */ validateTargetType(def, range) {
1069
- if (!this.config.defType?.length) return undefined;
1072
+ if (!this.config.defType?.length) return;
1070
1073
  let defEntity = def?.entity || "unknown";
1071
1074
  if (isInterface(def) || isStructure(def)) defEntity = "object";
1072
- else if (isGroup(def) && def.entity !== "tuple") defEntity = def.op === "&" ? "intersection" : "union";
1075
+ else if (isGroup(def) && def.entity !== "tuple") defEntity = def.op === "&" ? "intersection" : "union";
1073
1076
  if (!isPrimitive(def) && !this.config.defType.includes(defEntity) || isPrimitive(def) && !this.config.defType.includes(def.type)) return [{
1074
1077
  message: `Expected type is (${this.config.defType.join(" | ")}), got "${isPrimitive(def) ? def.type : def?.entity || "unknown"}"`,
1075
1078
  severity: 1,
1076
1079
  range
1077
1080
  }];
1078
- return undefined;
1079
1081
  }
1080
1082
  renderDocs(index) {
1081
1083
  if (typeof index === "number") {
@@ -1084,13 +1086,10 @@ else if (isGroup(def) && def.entity !== "tuple") defEntity = def.op === "&" ? "i
1084
1086
  const values = a.values ? `\n\nValues:\n${a.values.join(", ")}` : "";
1085
1087
  return `### \`${a.name}${a.optional ? "?" : ""}: ${a.type}\`\n\n${a.description}${values}`;
1086
1088
  }
1087
- } else {
1088
- const args = this.arguments;
1089
- return `### ${index} ${args.map((a) => `\`${a.name}${a.optional ? "?" : ""}: ${a.type}\``).join(", ")}\n\n${this.config.description}`;
1090
- }
1089
+ } else return `### ${index} ${this.arguments.map((a) => `\`${a.name}${a.optional ? "?" : ""}: ${a.type}\``).join(", ")}\n\n${this.config.description}`;
1091
1090
  }
1092
- getDefaultValueForType(name, type$1) {
1093
- switch (type$1) {
1091
+ getDefaultValueForType(name, type) {
1092
+ switch (type) {
1094
1093
  case "string": return name;
1095
1094
  case "number": return "0";
1096
1095
  case "boolean": return "true";
@@ -1113,37 +1112,50 @@ function resolveAnnotation(name, annotationsTree) {
1113
1112
  const parts = name.split(".");
1114
1113
  let current = annotationsTree;
1115
1114
  for (const part of parts) {
1116
- if (part === "$self") return undefined;
1117
- if (!current || isAnnotationSpec(current)) return undefined;
1115
+ if (part === "$self") return;
1116
+ if (!current || isAnnotationSpec(current)) return;
1118
1117
  current = current[part];
1119
1118
  }
1120
1119
  if (isAnnotationSpec(current)) return current;
1121
1120
  if (current && !isAnnotationSpec(current) && current.$self) return current.$self;
1122
- return undefined;
1123
1121
  }
1124
1122
 
1125
1123
  //#endregion
1126
1124
  //#region packages/core/src/config/define-config.ts
1127
- function defineConfig(config) {
1125
+ /**
1126
+ * Defines the configuration for the Intertation parser
1127
+ */ function defineConfig(config) {
1128
1128
  return config;
1129
1129
  }
1130
1130
 
1131
1131
  //#endregion
1132
1132
  //#region packages/core/src/resolve-bare.ts
1133
- function isBareSpecifier(specifier) {
1133
+ /**
1134
+ * Returns true if the specifier is a bare specifier (not relative or absolute).
1135
+ * Bare specifiers: 'my-lib/user', '@org/pkg/models'
1136
+ * NOT bare: './user', '../shared', '/absolute/path'
1137
+ */ function isBareSpecifier(specifier) {
1134
1138
  return specifier[0] !== "." && specifier[0] !== "/";
1135
1139
  }
1136
- function isBareId(id) {
1140
+ /**
1141
+ * Returns true if the document ID is a bare specifier placeholder.
1142
+ */ function isBareId(id) {
1137
1143
  return id.startsWith("bare:");
1138
1144
  }
1139
- function parseBareSpecifier(specifier) {
1145
+ /**
1146
+ * Parse a bare specifier into package name and subpath.
1147
+ *
1148
+ * '@scope/pkg/sub/path' → { packageName: '@scope/pkg', subpath: './sub/path' }
1149
+ * 'pkg/sub' → { packageName: 'pkg', subpath: './sub' }
1150
+ * 'pkg' → { packageName: 'pkg', subpath: '.' }
1151
+ */ function parseBareSpecifier(specifier) {
1140
1152
  if (specifier.startsWith("@")) {
1141
- const firstSlash$1 = specifier.indexOf("/");
1142
- if (firstSlash$1 === -1) return {
1153
+ const firstSlash = specifier.indexOf("/");
1154
+ if (firstSlash === -1) return {
1143
1155
  packageName: specifier,
1144
1156
  subpath: "."
1145
1157
  };
1146
- const secondSlash = specifier.indexOf("/", firstSlash$1 + 1);
1158
+ const secondSlash = specifier.indexOf("/", firstSlash + 1);
1147
1159
  if (secondSlash === -1) return {
1148
1160
  packageName: specifier,
1149
1161
  subpath: "."
@@ -1163,21 +1175,23 @@ function parseBareSpecifier(specifier) {
1163
1175
  subpath: `./${specifier.slice(firstSlash + 1)}`
1164
1176
  };
1165
1177
  }
1166
- function resolvePackageExports(exports$1, subpath) {
1167
- if (!exports$1 || typeof exports$1 !== "object") return undefined;
1168
- const exportsMap = exports$1;
1178
+ /**
1179
+ * Resolve a subpath against a package.json `exports` field using the `atscript` condition.
1180
+ * Returns the resolved file path relative to the package directory, or undefined.
1181
+ */ function resolvePackageExports(exports, subpath) {
1182
+ if (!exports || typeof exports !== "object") return;
1183
+ const exportsMap = exports;
1169
1184
  const subpathWithExt = subpath === "." ? "." : `${subpath}.as`;
1170
1185
  const entry = exportsMap[subpathWithExt];
1171
1186
  if (entry) return resolveExportEntry(entry);
1172
1187
  for (const [pattern, value] of Object.entries(exportsMap)) {
1173
1188
  if (!pattern.includes("*")) continue;
1174
1189
  const match = matchSubpathPattern(pattern, subpathWithExt);
1175
- if (match !== undefined) {
1190
+ if (match !== void 0) {
1176
1191
  const resolved = resolveExportEntry(value);
1177
1192
  if (resolved) return resolved.replaceAll("*", match);
1178
1193
  }
1179
1194
  }
1180
- return undefined;
1181
1195
  }
1182
1196
  /**
1183
1197
  * Resolve a single export entry, checking for `atscript` condition.
@@ -1188,18 +1202,16 @@ function resolvePackageExports(exports$1, subpath) {
1188
1202
  if (typeof obj["atscript"] === "string") return obj["atscript"];
1189
1203
  if (typeof obj["default"] === "string") return obj["default"];
1190
1204
  }
1191
- return undefined;
1192
1205
  }
1193
1206
  /**
1194
1207
  * Match a subpath against a pattern with a single `*` wildcard.
1195
1208
  * Returns the matched wildcard portion, or undefined if no match.
1196
1209
  */ function matchSubpathPattern(pattern, subpath) {
1197
1210
  const starIdx = pattern.indexOf("*");
1198
- if (starIdx === -1) return undefined;
1211
+ if (starIdx === -1) return;
1199
1212
  const prefix = pattern.slice(0, starIdx);
1200
1213
  const suffix = pattern.slice(starIdx + 1);
1201
1214
  if (subpath.startsWith(prefix) && subpath.endsWith(suffix) && subpath.length >= prefix.length + suffix.length) return subpath.slice(prefix.length, subpath.length - suffix.length);
1202
- return undefined;
1203
1215
  }
1204
1216
  /**
1205
1217
  * Check if a file exists.
@@ -1211,11 +1223,27 @@ function resolvePackageExports(exports$1, subpath) {
1211
1223
  return false;
1212
1224
  }
1213
1225
  }
1214
- const resolveCache = new Map();
1215
- function clearResolveBareCache() {
1226
+ const resolveCache = /* @__PURE__ */ new Map();
1227
+ /**
1228
+ * Clear the bare specifier resolution cache.
1229
+ * Call this when node_modules may have changed (e.g., after install).
1230
+ */ function clearResolveBareCache() {
1216
1231
  resolveCache.clear();
1217
1232
  }
1218
- async function resolveBareSpecifier(specifier, fromDir) {
1233
+ /**
1234
+ * Resolve a bare specifier to an absolute file path.
1235
+ *
1236
+ * Algorithm:
1237
+ * 1. Parse specifier into packageName + subpath
1238
+ * 2. Walk up from `fromDir` looking for `node_modules/<packageName>/package.json`
1239
+ * 3. Check `exports` field for subpath with `atscript` condition
1240
+ * 4. Fallback: check if file exists at `node_modules/<pkg>/<subpath>.as`
1241
+ * 5. Resolve symlinks via `fs.realpath`
1242
+ *
1243
+ * @param specifier Bare specifier, e.g. 'my-lib/user' or '@org/pkg/models'
1244
+ * @param fromDir Absolute directory of the importing file
1245
+ * @returns Resolved absolute file path, or undefined if not found
1246
+ */ async function resolveBareSpecifier(specifier, fromDir) {
1219
1247
  const cacheKey = `${fromDir}\0${specifier}`;
1220
1248
  if (resolveCache.has(cacheKey)) return resolveCache.get(cacheKey);
1221
1249
  const result = await _resolveBareSpecifier(specifier, fromDir);
@@ -1225,7 +1253,7 @@ async function resolveBareSpecifier(specifier, fromDir) {
1225
1253
  async function _resolveBareSpecifier(specifier, fromDir) {
1226
1254
  const { packageName, subpath } = parseBareSpecifier(specifier);
1227
1255
  let dir = fromDir;
1228
- const root$1 = node_path.default.parse(dir).root;
1256
+ const root = node_path.default.parse(dir).root;
1229
1257
  while (true) {
1230
1258
  const pkgDir = node_path.default.join(dir, "node_modules", packageName);
1231
1259
  const pkgJsonPath = node_path.default.join(pkgDir, "package.json");
@@ -1244,10 +1272,9 @@ async function _resolveBareSpecifier(specifier, fromDir) {
1244
1272
  if (await fileExists(directPath)) return resolveRealPath(directPath);
1245
1273
  }
1246
1274
  const parentDir = node_path.default.dirname(dir);
1247
- if (parentDir === dir || dir === root$1) break;
1275
+ if (parentDir === dir || dir === root) break;
1248
1276
  dir = parentDir;
1249
1277
  }
1250
- return undefined;
1251
1278
  }
1252
1279
  /**
1253
1280
  * Resolve symlinks to get the canonical path (important for pnpm).
@@ -1279,8 +1306,7 @@ function getRelPath(fromUri, toUri) {
1279
1306
  const toPath = new url.URL(toUri).pathname;
1280
1307
  const relPath = path.default.relative(path.default.dirname(fromPath), toPath);
1281
1308
  const { dir, name } = path.default.parse(relPath);
1282
- const prefix = dir.startsWith("..") ? "" : "./";
1283
- return `${prefix}${dir ? `${dir}/` : ""}${name}`;
1309
+ return `${dir.startsWith("..") ? "" : "./"}${dir ? `${dir}/` : ""}${name}`;
1284
1310
  }
1285
1311
 
1286
1312
  //#endregion
@@ -1308,9 +1334,8 @@ async function bundleTsConfig(configFile, forceFormat) {
1308
1334
  transform: {
1309
1335
  filter: { id: /\.[cm]?[jt]s$/u },
1310
1336
  handler(code, id) {
1311
- const injectValues = `const ${dirnameVarName} = ${JSON.stringify(node_path.default.dirname(id))};` + `const ${filenameVarName} = ${JSON.stringify(id)};` + `const ${importMetaUrlVarName} = ${JSON.stringify((0, node_url.pathToFileURL)(id).href)};`;
1312
1337
  return {
1313
- code: injectValues + code,
1338
+ code: `const ${dirnameVarName} = ${JSON.stringify(node_path.default.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify((0, node_url.pathToFileURL)(id).href)};` + code,
1314
1339
  map: null
1315
1340
  };
1316
1341
  }
@@ -1318,13 +1343,12 @@ async function bundleTsConfig(configFile, forceFormat) {
1318
1343
  }]
1319
1344
  });
1320
1345
  const outputDir = node_path.default.dirname(configFile);
1321
- const result = await bundle.write({
1346
+ const fileName = (await bundle.write({
1322
1347
  dir: outputDir,
1323
1348
  format: forceFormat || "esm",
1324
1349
  sourcemap: "inline",
1325
1350
  entryFileNames: forceFormat === "cjs" ? "atscript.config.[hash].cjs" : "atscript.config.[hash].mjs"
1326
- });
1327
- const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
1351
+ })).output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
1328
1352
  return node_path.default.join(outputDir, fileName);
1329
1353
  }
1330
1354
  const SUPPORTED_JS_CONFIG_FORMATS = [
@@ -1339,11 +1363,13 @@ const SUPPORTED_TS_CONFIG_FORMATS = [
1339
1363
  ];
1340
1364
  const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
1341
1365
  const DEFAULT_CONFIG_BASE = "atscript.config";
1342
- async function resolveConfigFile(docUri, _root) {
1366
+ /**
1367
+ * Resolves nearest config file
1368
+ */ async function resolveConfigFile(docUri, _root) {
1343
1369
  const startDir = docUri.endsWith(".as") ? node_path.default.dirname(docUri) : docUri;
1344
- const root$1 = _root || startDir;
1370
+ const root = _root || startDir;
1345
1371
  let currentDir = startDir;
1346
- const rootId = `file://${root$1}`;
1372
+ const rootId = `file://${root}`;
1347
1373
  while (true) {
1348
1374
  const candidate = await findConfigFileName(currentDir);
1349
1375
  if (candidate) return node_path.default.join(currentDir, candidate).replace(/^file:/, "");
@@ -1351,7 +1377,6 @@ async function resolveConfigFile(docUri, _root) {
1351
1377
  if (currentDir === rootId || parentDir === currentDir) break;
1352
1378
  currentDir = parentDir;
1353
1379
  }
1354
- return undefined;
1355
1380
  }
1356
1381
  async function findConfigFileName(d) {
1357
1382
  const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)(fileUriToPath(d)));
@@ -1383,10 +1408,8 @@ async function loadConfig(configPath, forceFormat) {
1383
1408
  /* @vite-ignore */
1384
1409
  (0, node_url.pathToFileURL)(configPath).href
1385
1410
  )).default;
1386
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
1387
- const rawConfigPath = node_path.default.resolve(configPath);
1388
- return await loadTsConfig(rawConfigPath, forceFormat);
1389
- } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
1411
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(node_path.default.resolve(configPath), forceFormat);
1412
+ else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
1390
1413
  } catch (error) {
1391
1414
  console.error(error);
1392
1415
  throw new Error("Error happened while loading config.");
@@ -1395,21 +1418,22 @@ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
1395
1418
 
1396
1419
  //#endregion
1397
1420
  //#region packages/core/src/defaults/db-query-lsp.ts
1398
- function getQueryScope(queryArgToken, doc) {
1421
+ /**
1422
+ * Determine the allowed type scope for a query arg token
1423
+ * by reading sibling annotations on the owner node.
1424
+ */ function getQueryScope(queryArgToken, doc) {
1399
1425
  const annotationRef = queryArgToken.annotationRef;
1400
- if (!annotationRef) return undefined;
1426
+ if (!annotationRef) return;
1401
1427
  const owner = queryArgToken.parentNode;
1402
- if (!owner) return undefined;
1428
+ if (!owner) return;
1403
1429
  const annotationName = annotationRef.text.slice(1);
1404
1430
  if (annotationName === "db.view.filter") return getViewFilterScope(owner);
1405
1431
  if (annotationName === "db.view.joins") return getViewJoinsScope(owner, queryArgToken);
1406
1432
  if (annotationName === "db.rel.filter") return getRelFilterScope(owner);
1407
- return undefined;
1408
1433
  }
1409
1434
  function getViewFilterScope(owner) {
1410
- const forAnnotations = owner.annotations?.filter((a) => a.name === "db.view.for");
1411
- const entryTypeName = forAnnotations?.[0]?.args[0]?.text;
1412
- if (!entryTypeName) return undefined;
1435
+ const entryTypeName = (owner.annotations?.filter((a) => a.name === "db.view.for"))?.[0]?.args[0]?.text;
1436
+ if (!entryTypeName) return;
1413
1437
  const allowedTypes = [entryTypeName];
1414
1438
  const joinsAnnotations = owner.annotations?.filter((a) => a.name === "db.view.joins");
1415
1439
  if (joinsAnnotations) {
@@ -1421,12 +1445,10 @@ function getViewFilterScope(owner) {
1421
1445
  };
1422
1446
  }
1423
1447
  function getViewJoinsScope(owner, queryArgToken) {
1424
- const forAnnotations = owner.annotations?.filter((a) => a.name === "db.view.for");
1425
- const entryTypeName = forAnnotations?.[0]?.args[0]?.text;
1426
- if (!entryTypeName) return undefined;
1427
- const joinsAnnotation = owner.annotations?.find((a) => a.name === "db.view.joins" && a.args.includes(queryArgToken));
1428
- const joinTargetName = joinsAnnotation?.args[0]?.text;
1429
- if (!joinTargetName) return undefined;
1448
+ const entryTypeName = (owner.annotations?.filter((a) => a.name === "db.view.for"))?.[0]?.args[0]?.text;
1449
+ if (!entryTypeName) return;
1450
+ const joinTargetName = (owner.annotations?.find((a) => a.name === "db.view.joins" && a.args.includes(queryArgToken)))?.args[0]?.text;
1451
+ if (!joinTargetName) return;
1430
1452
  return {
1431
1453
  allowedTypes: [joinTargetName, entryTypeName],
1432
1454
  unqualifiedTarget: entryTypeName
@@ -1435,7 +1457,7 @@ function getViewJoinsScope(owner, queryArgToken) {
1435
1457
  function getRelFilterScope(owner) {
1436
1458
  let def = owner.getDefinition();
1437
1459
  if (isArray(def)) def = def?.getDefinition();
1438
- if (!isRef(def)) return undefined;
1460
+ if (!isRef(def)) return;
1439
1461
  const targetTypeName = def.id;
1440
1462
  const allowedTypes = [targetTypeName];
1441
1463
  const viaAnnotation = owner.annotations?.find((a) => a.name === "db.rel.via");
@@ -1445,16 +1467,17 @@ function getRelFilterScope(owner) {
1445
1467
  unqualifiedTarget: targetTypeName
1446
1468
  };
1447
1469
  }
1448
- function resolveQueryFieldRef(fieldRefNode, doc, scope) {
1470
+ /**
1471
+ * Resolve a query field ref node to a property definition.
1472
+ */ function resolveQueryFieldRef(fieldRefNode, doc, scope) {
1449
1473
  const typeName = fieldRefNode.typeRef?.text ?? scope.unqualifiedTarget;
1450
- if (!typeName) return undefined;
1451
- const fieldPath = fieldRefNode.fieldRef.text;
1452
- const chain = fieldPath.split(".");
1474
+ if (!typeName) return;
1475
+ const chain = fieldRefNode.fieldRef.text.split(".");
1453
1476
  const parentChain = chain.slice(0, -1);
1454
1477
  const parentUnwound = doc.unwindType(typeName, parentChain);
1455
- if (!parentUnwound?.def) return undefined;
1478
+ if (!parentUnwound?.def) return;
1456
1479
  const unwound = doc.unwindType(typeName, chain);
1457
- if (!unwound?.node) return undefined;
1480
+ if (!unwound?.node) return;
1458
1481
  const prop = unwound.node;
1459
1482
  return {
1460
1483
  targetUri: parentUnwound.doc.id,
@@ -1462,21 +1485,21 @@ function resolveQueryFieldRef(fieldRefNode, doc, scope) {
1462
1485
  prop
1463
1486
  };
1464
1487
  }
1465
- function getFieldsForType(doc, typeName) {
1488
+ /**
1489
+ * Get fields available for a type (resolving extends/intersections).
1490
+ */ function getFieldsForType(doc, typeName) {
1466
1491
  const unwound = doc.unwindType(typeName);
1467
1492
  if (!unwound?.def) return [];
1468
1493
  let def = doc.mergeIntersection(unwound.def);
1469
- if (isInterface(def)) {
1470
- const resolved = doc.resolveInterfaceExtends(def);
1471
- if (resolved) def = resolved;
1472
- else def = def.getDefinition() || def;
1473
- }
1494
+ if (isInterface(def)) def = doc.resolveInterfaceExtends(def) || def.getDefinition() || def;
1474
1495
  if (isStructure(def) || isInterface(def)) return Array.from(def.props.values());
1475
1496
  return [];
1476
1497
  }
1477
- function getQueryCompletionScope(queryArgToken, doc) {
1498
+ /**
1499
+ * Get completion scope data for a query context.
1500
+ */ function getQueryCompletionScope(queryArgToken, doc) {
1478
1501
  const scope = getQueryScope(queryArgToken, doc);
1479
- if (!scope) return undefined;
1502
+ if (!scope) return;
1480
1503
  return {
1481
1504
  typeNames: scope.allowedTypes,
1482
1505
  unqualifiedTarget: scope.unqualifiedTarget,
@@ -1507,7 +1530,12 @@ const VALUE_KEYWORDS$1 = new Set([
1507
1530
  "null",
1508
1531
  "undefined"
1509
1532
  ]);
1510
- function analyzeQueryCursorContext(textBeforeCursor) {
1533
+ /**
1534
+ * Analyze text inside backticks up to cursor position
1535
+ * to determine what kind of completions to offer.
1536
+ * Uses lightweight text scanning, not full AST parsing,
1537
+ * so it works on incomplete/mid-typing input.
1538
+ */ function analyzeQueryCursorContext(textBeforeCursor) {
1511
1539
  const trimmed = textBeforeCursor.trimEnd();
1512
1540
  const hasTrailingSpace = textBeforeCursor.length > trimmed.length;
1513
1541
  if (trimmed.length === 0) return { type: "field-start" };
@@ -1520,17 +1548,17 @@ function analyzeQueryCursorContext(textBeforeCursor) {
1520
1548
  };
1521
1549
  return { type: "field-start" };
1522
1550
  }
1523
- const tokens$1 = tokenizeQueryText(trimmed);
1524
- if (tokens$1.length === 0) return { type: "field-start" };
1525
- const last = tokens$1[tokens$1.length - 1];
1551
+ const tokens = tokenizeQueryText(trimmed);
1552
+ if (tokens.length === 0) return { type: "field-start" };
1553
+ const last = tokens[tokens.length - 1];
1526
1554
  if (LOGICAL_KEYWORDS.has(last) || last === "(") return { type: "field-start" };
1527
1555
  if (SYMBOLIC_OPS$1.has(last)) return { type: "after-operator" };
1528
1556
  if (last === "in" || last === "matches") return { type: "after-operator" };
1529
1557
  if (last === "exists") return { type: "after-comparison" };
1530
1558
  if (VALUE_KEYWORDS$1.has(last)) return { type: "after-comparison" };
1531
1559
  if (/^['"]/.test(last) || /^\d/.test(last)) return { type: "after-comparison" };
1532
- if (tokens$1.length >= 2) {
1533
- const prev = tokens$1[tokens$1.length - 2];
1560
+ if (tokens.length >= 2) {
1561
+ const prev = tokens[tokens.length - 2];
1534
1562
  if (SYMBOLIC_OPS$1.has(prev) || KEYWORD_OPS.has(prev)) return { type: "after-comparison" };
1535
1563
  }
1536
1564
  if (/^\w+$/u.test(last)) {
@@ -1542,53 +1570,53 @@ function analyzeQueryCursorContext(textBeforeCursor) {
1542
1570
  /**
1543
1571
  * Simple tokenizer for query text — splits into identifiers, operators, and punctuation.
1544
1572
  * Does NOT need to handle all edge cases; just enough for cursor context analysis.
1545
- */ function tokenizeQueryText(text$2) {
1546
- const tokens$1 = [];
1573
+ */ function tokenizeQueryText(text) {
1574
+ const tokens = [];
1547
1575
  let i = 0;
1548
- while (i < text$2.length) {
1549
- if (/\s/.test(text$2[i])) {
1576
+ while (i < text.length) {
1577
+ if (/\s/.test(text[i])) {
1550
1578
  i++;
1551
1579
  continue;
1552
1580
  }
1553
- if (text$2[i] === "'" || text$2[i] === "\"") {
1554
- const quote = text$2[i];
1581
+ if (text[i] === "'" || text[i] === "\"") {
1582
+ const quote = text[i];
1555
1583
  let j = i + 1;
1556
- while (j < text$2.length && text$2[j] !== quote) {
1557
- if (text$2[j] === "\\") j++;
1584
+ while (j < text.length && text[j] !== quote) {
1585
+ if (text[j] === "\\") j++;
1558
1586
  j++;
1559
1587
  }
1560
- tokens$1.push(text$2.slice(i, j + 1));
1588
+ tokens.push(text.slice(i, j + 1));
1561
1589
  i = j + 1;
1562
1590
  continue;
1563
1591
  }
1564
- if (i + 1 < text$2.length) {
1565
- const two = text$2.slice(i, i + 2);
1592
+ if (i + 1 < text.length) {
1593
+ const two = text.slice(i, i + 2);
1566
1594
  if (two === "!=" || two === ">=" || two === "<=") {
1567
- tokens$1.push(two);
1595
+ tokens.push(two);
1568
1596
  i += 2;
1569
1597
  continue;
1570
1598
  }
1571
1599
  }
1572
- if ("=><(),".includes(text$2[i])) {
1573
- tokens$1.push(text$2[i]);
1600
+ if ("=><(),".includes(text[i])) {
1601
+ tokens.push(text[i]);
1574
1602
  i++;
1575
1603
  continue;
1576
1604
  }
1577
- if (text$2[i] === ".") {
1578
- tokens$1.push(".");
1605
+ if (text[i] === ".") {
1606
+ tokens.push(".");
1579
1607
  i++;
1580
1608
  continue;
1581
1609
  }
1582
- if (/[\w]/u.test(text$2[i])) {
1610
+ if (/[\w]/u.test(text[i])) {
1583
1611
  let j = i;
1584
- while (j < text$2.length && /[\w]/u.test(text$2[j])) j++;
1585
- tokens$1.push(text$2.slice(i, j));
1612
+ while (j < text.length && /[\w]/u.test(text[j])) j++;
1613
+ tokens.push(text.slice(i, j));
1586
1614
  i = j;
1587
1615
  continue;
1588
1616
  }
1589
1617
  i++;
1590
1618
  }
1591
- return tokens$1;
1619
+ return tokens;
1592
1620
  }
1593
1621
 
1594
1622
  //#endregion
@@ -1600,7 +1628,7 @@ function _define_property$7(obj, key, value) {
1600
1628
  configurable: true,
1601
1629
  writable: true
1602
1630
  });
1603
- else obj[key] = value;
1631
+ else obj[key] = value;
1604
1632
  return obj;
1605
1633
  }
1606
1634
  var IdRegistry = class {
@@ -1612,12 +1640,12 @@ var IdRegistry = class {
1612
1640
  registerDefinition(token) {
1613
1641
  if (!token) return;
1614
1642
  if (this.reserved.has(token.text)) this.forbidden.add(token);
1615
- else if (this.definitions.has(token.text)) this.duplicates.add(token);
1616
- else this.definitions.set(token.text, token);
1643
+ else if (this.definitions.has(token.text)) this.duplicates.add(token);
1644
+ else this.definitions.set(token.text, token);
1617
1645
  }
1618
1646
  isDefined(t) {
1619
- const text$2 = typeof t === "string" ? t : t.text;
1620
- return this.definitions.has(text$2) || this.globalTypes.has(text$2);
1647
+ const text = typeof t === "string" ? t : t.text;
1648
+ return this.definitions.has(text) || this.globalTypes.has(text);
1621
1649
  }
1622
1650
  getErrors() {
1623
1651
  return [...Array.from(this.duplicates, (t) => ({
@@ -1633,9 +1661,9 @@ else this.definitions.set(token.text, token);
1633
1661
  constructor(globalTypes = []) {
1634
1662
  _define_property$7(this, "reserved", void 0);
1635
1663
  _define_property$7(this, "globalTypes", void 0);
1636
- _define_property$7(this, "definitions", new Map());
1637
- _define_property$7(this, "duplicates", new Set());
1638
- _define_property$7(this, "forbidden", new Set());
1664
+ _define_property$7(this, "definitions", /* @__PURE__ */ new Map());
1665
+ _define_property$7(this, "duplicates", /* @__PURE__ */ new Set());
1666
+ _define_property$7(this, "forbidden", /* @__PURE__ */ new Set());
1639
1667
  this.reserved = new Set([
1640
1668
  "interface",
1641
1669
  "type",
@@ -1658,7 +1686,7 @@ function _define_property$6(obj, key, value) {
1658
1686
  configurable: true,
1659
1687
  writable: true
1660
1688
  });
1661
- else obj[key] = value;
1689
+ else obj[key] = value;
1662
1690
  return obj;
1663
1691
  }
1664
1692
  var NodeIterator = class NodeIterator {
@@ -1699,14 +1727,14 @@ var NodeIterator = class NodeIterator {
1699
1727
  fork(nodes) {
1700
1728
  return new NodeIterator(nodes || this.nodes, this.messages, this.badNodes, this.issues, nodes ? this.$ : this.parent, nodes ? 0 : this.i).update();
1701
1729
  }
1702
- skip(pun$1) {
1703
- while (this.$?.type === "comment" || this.$?.type === "punctuation" && pun$1?.length && pun$1.includes(this.$.text)) this.move();
1730
+ skip(pun) {
1731
+ while (this.$?.type === "comment" || this.$?.type === "punctuation" && pun?.length && pun.includes(this.$.text)) this.move();
1704
1732
  return this;
1705
1733
  }
1706
- skipUntil(pun$1) {
1734
+ skipUntil(pun) {
1707
1735
  while (this.$ && !this.satisfies({
1708
1736
  node: "punctuation",
1709
- text: pun$1
1737
+ text: pun
1710
1738
  })) this.move();
1711
1739
  }
1712
1740
  unexpected(force = false, msg = "Unexpected token") {
@@ -1722,15 +1750,14 @@ var NodeIterator = class NodeIterator {
1722
1750
  satisfies(...rules) {
1723
1751
  for (const rule of rules) {
1724
1752
  const passed = Array.isArray(rule.node) ? rule.node.includes(this.$?.type) : this.$?.type === rule.node;
1725
- if (passed && rule.text === undefined) return true;
1753
+ if (passed && rule.text === void 0) return true;
1726
1754
  if (passed && Array.isArray(rule.text) ? rule.text.includes(this.$?.text) : this.$?.text === rule.text) return true;
1727
1755
  }
1728
1756
  return false;
1729
1757
  }
1730
1758
  confirmIssues() {
1731
1759
  if (this.issues.unexpectedEOB) {
1732
- const node = this.lastNode || this.parent;
1733
- const pos = node?.getRange().end || {
1760
+ const pos = (this.lastNode || this.parent)?.getRange().end || {
1734
1761
  character: 1,
1735
1762
  line: 1
1736
1763
  };
@@ -1764,7 +1791,7 @@ var NodeIterator = class NodeIterator {
1764
1791
  }
1765
1792
  })).concat(this.messages);
1766
1793
  }
1767
- constructor(nodes, messages = [], badNodes = new Map(), issues = {}, parent, i = -1) {
1794
+ constructor(nodes, messages = [], badNodes = /* @__PURE__ */ new Map(), issues = {}, parent, i = -1) {
1768
1795
  _define_property$6(this, "nodes", void 0);
1769
1796
  _define_property$6(this, "messages", void 0);
1770
1797
  _define_property$6(this, "badNodes", void 0);
@@ -1783,7 +1810,9 @@ var NodeIterator = class NodeIterator {
1783
1810
 
1784
1811
  //#endregion
1785
1812
  //#region packages/core/src/tokenizer/tokens/a-identifier.token.ts
1786
- const AIdentifierToken = new __prostojs_parser.Node({
1813
+ /**
1814
+ * Annotation (@) Identifier node
1815
+ */ const AIdentifierToken = new _prostojs_parser.Node({
1787
1816
  name: "annotation",
1788
1817
  start: { token: RegExp("@[\\p{ID_Continue}$.]*", "u") },
1789
1818
  end: {
@@ -1805,7 +1834,9 @@ const pairs = {
1805
1834
  "(": ")",
1806
1835
  "[": "]"
1807
1836
  };
1808
- const BlockToken = new __prostojs_parser.Node({
1837
+ /**
1838
+ * Block node
1839
+ */ const BlockToken = new _prostojs_parser.Node({
1809
1840
  name: "block",
1810
1841
  start: {
1811
1842
  token: RegExp("(?<text>[([{])", "u"),
@@ -1825,7 +1856,7 @@ const BlockToken = new __prostojs_parser.Node({
1825
1856
 
1826
1857
  //#endregion
1827
1858
  //#region packages/core/src/tokenizer/tokens/comment.token.ts
1828
- const inline = new __prostojs_parser.Node({
1859
+ const inline = new _prostojs_parser.Node({
1829
1860
  name: "inline-comment",
1830
1861
  start: {
1831
1862
  token: "//",
@@ -1842,7 +1873,7 @@ const inline = new __prostojs_parser.Node({
1842
1873
  },
1843
1874
  mapContent: "text"
1844
1875
  });
1845
- const block$1 = new __prostojs_parser.Node({
1876
+ const block$1 = new _prostojs_parser.Node({
1846
1877
  name: "block-comment",
1847
1878
  start: {
1848
1879
  token: "/*",
@@ -1859,7 +1890,9 @@ const block$1 = new __prostojs_parser.Node({
1859
1890
  },
1860
1891
  mapContent: "text"
1861
1892
  });
1862
- const commentNodes = {
1893
+ /**
1894
+ * Block and inline comments
1895
+ */ const commentNodes = {
1863
1896
  inline,
1864
1897
  block: block$1,
1865
1898
  all: [inline, block$1]
@@ -1867,7 +1900,9 @@ const commentNodes = {
1867
1900
 
1868
1901
  //#endregion
1869
1902
  //#region packages/core/src/tokenizer/tokens/identifier.token.ts
1870
- const IdentifierToken = new __prostojs_parser.Node({
1903
+ /**
1904
+ * Identifier node
1905
+ */ const IdentifierToken = new _prostojs_parser.Node({
1871
1906
  name: "identifier",
1872
1907
  start: { token: RegExp("[\\p{ID_Start}$_][\\p{ID_Continue}$]*", "u") },
1873
1908
  end: {
@@ -1884,7 +1919,9 @@ const IdentifierToken = new __prostojs_parser.Node({
1884
1919
 
1885
1920
  //#endregion
1886
1921
  //#region packages/core/src/tokenizer/tokens/number.token.ts
1887
- const NumberToken = new __prostojs_parser.Node({
1922
+ /**
1923
+ * Number node
1924
+ */ const NumberToken = new _prostojs_parser.Node({
1888
1925
  name: "number",
1889
1926
  start: { token: /[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/u },
1890
1927
  end: {
@@ -1901,7 +1938,9 @@ const NumberToken = new __prostojs_parser.Node({
1901
1938
 
1902
1939
  //#endregion
1903
1940
  //#region packages/core/src/tokenizer/tokens/punctuation.token.ts
1904
- const PunctuationToken = new __prostojs_parser.Node({
1941
+ /**
1942
+ * Punctuation node
1943
+ */ const PunctuationToken = new _prostojs_parser.Node({
1905
1944
  name: "punctuation",
1906
1945
  start: {
1907
1946
  token: RegExp("(?<text>[\\n!&+,./:;=?|])", "u"),
@@ -1918,9 +1957,47 @@ const PunctuationToken = new __prostojs_parser.Node({
1918
1957
  }
1919
1958
  });
1920
1959
 
1960
+ //#endregion
1961
+ //#region packages/core/src/tokenizer/tokens/query-block.token.ts
1962
+ /**
1963
+ * Query block node — parenthesized sub-expressions inside backtick queries.
1964
+ *
1965
+ * Produces exactly the same token shape as `BlockToken` (`type: 'block'`,
1966
+ * `text: '('`) so every consumer keeps working, but it recognizes
1967
+ * `QueryOperatorToken` inside, which makes `!=`, `>=`, `<=`, `>`, `<`
1968
+ * work within parentheses (the generic block only knows `PunctuationToken`,
1969
+ * whose charset has no `<` / `>`).
1970
+ *
1971
+ * Only registered inside `QueryToken` (and itself, for nested parens) —
1972
+ * the generic `BlockToken` is left untouched so tokenization of `(`/`[`/`{`
1973
+ * outside queries does not change.
1974
+ */ const QueryBlockToken = new _prostojs_parser.Node({
1975
+ name: "block",
1976
+ start: {
1977
+ token: RegExp("(?<text>\\()", "u"),
1978
+ omit: true
1979
+ },
1980
+ end: {
1981
+ token: ")",
1982
+ omit: true
1983
+ },
1984
+ skip: /\s/u,
1985
+ eofClose: true,
1986
+ data: {
1987
+ type: "block",
1988
+ text: ""
1989
+ }
1990
+ });
1991
+
1921
1992
  //#endregion
1922
1993
  //#region packages/core/src/tokenizer/tokens/query-operator.token.ts
1923
- const QueryOperatorToken = new __prostojs_parser.Node({
1994
+ /**
1995
+ * Query operator token — matches symbolic comparison operators
1996
+ * inside backtick-delimited query expressions.
1997
+ *
1998
+ * Multi-character operators (!=, >=, <=) are matched as single tokens.
1999
+ * Only recognized inside QueryToken — not in root or BlockToken.
2000
+ */ const QueryOperatorToken = new _prostojs_parser.Node({
1924
2001
  name: "punctuation",
1925
2002
  start: {
1926
2003
  token: RegExp("(?<text>!=|>=|<=|[=><])", "u"),
@@ -1939,7 +2016,10 @@ const QueryOperatorToken = new __prostojs_parser.Node({
1939
2016
 
1940
2017
  //#endregion
1941
2018
  //#region packages/core/src/tokenizer/tokens/query.token.ts
1942
- const QueryToken = new __prostojs_parser.Node({
2019
+ /**
2020
+ * Query node — backtick-delimited filter expressions
2021
+ * Content inside backticks is tokenized into children.
2022
+ */ const QueryToken = new _prostojs_parser.Node({
1943
2023
  name: "query",
1944
2024
  start: {
1945
2025
  token: /`/u,
@@ -1960,7 +2040,11 @@ const QueryToken = new __prostojs_parser.Node({
1960
2040
  //#endregion
1961
2041
  //#region packages/core/src/tokenizer/tokens/regexp.token.ts
1962
2042
  const REGEXP_LITERAL_RE = /\/(?![/*])(?:\\.|\[.*?]|[^/\\\n\r[])*\/[dgimsuy]*/;
1963
- const RegExpToken = new __prostojs_parser.Node({
2043
+ /**
2044
+ * RegExp literal – `/pattern/flags`
2045
+ * • Starts with `/` but *not* `//` or `/*`
2046
+ * • Ends with `/` followed by zero-or-more valid flags
2047
+ */ const RegExpToken = new _prostojs_parser.Node({
1964
2048
  name: "regexp",
1965
2049
  start: {
1966
2050
  token: REGEXP_LITERAL_RE,
@@ -1981,7 +2065,9 @@ const RegExpToken = new __prostojs_parser.Node({
1981
2065
 
1982
2066
  //#endregion
1983
2067
  //#region packages/core/src/tokenizer/tokens/text.node.ts
1984
- const TextToken = new __prostojs_parser.Node({
2068
+ /**
2069
+ * Text node single or doublequoted
2070
+ */ const TextToken = new _prostojs_parser.Node({
1985
2071
  name: "text",
1986
2072
  start: {
1987
2073
  token: RegExp("(?<quote>[\"'])", "u"),
@@ -2018,9 +2104,10 @@ const tokens = {
2018
2104
  text: TextToken,
2019
2105
  regexp: RegExpToken,
2020
2106
  query: QueryToken,
2021
- root: undefined
2107
+ queryBlock: QueryBlockToken,
2108
+ root: void 0
2022
2109
  };
2023
- const root = new __prostojs_parser.Node({
2110
+ const root = new _prostojs_parser.Node({
2024
2111
  name: "root",
2025
2112
  skip: /\s/u,
2026
2113
  eofClose: true,
@@ -2037,13 +2124,38 @@ const root = new __prostojs_parser.Node({
2037
2124
  });
2038
2125
  tokens.root = root;
2039
2126
  BlockToken.recognize(RegExpToken, ...commentNodes.all, BlockToken, QueryToken, AIdentifierToken, IdentifierToken, TextToken, NumberToken, PunctuationToken);
2040
- QueryToken.recognize(RegExpToken, QueryOperatorToken, BlockToken, IdentifierToken, TextToken, NumberToken, PunctuationToken);
2041
- function extractTokens(node) {
2042
- return node.content.map((item) => {
2043
- if (typeof item === "string") return {
2044
- type: "unknown",
2045
- text: item
2046
- };
2127
+ QueryToken.recognize(RegExpToken, QueryOperatorToken, QueryBlockToken, BlockToken, IdentifierToken, TextToken, NumberToken, PunctuationToken);
2128
+ QueryBlockToken.recognize(RegExpToken, QueryOperatorToken, QueryBlockToken, IdentifierToken, TextToken, NumberToken, PunctuationToken);
2129
+ /**
2130
+ * Recursively extract TLexicalToken[] from a ParsedNode tree.
2131
+ * Replaces the v0.5 mapContent('children', callback) + global loop.
2132
+ *
2133
+ * v0.6 Position has { offset, line, column }.
2134
+ * line is 1-based, column is 1-based.
2135
+ * VSCode expects 0-based line, 0-based character.
2136
+ */ function extractTokens(node) {
2137
+ const content = node.content;
2138
+ return content.map((item, index) => {
2139
+ if (typeof item === "string") {
2140
+ const prev = content[index - 1];
2141
+ const next = content[index + 1];
2142
+ const start = typeof prev === "object" ? prev.end : node.start;
2143
+ const end = typeof next === "object" ? next.start : node.end;
2144
+ return {
2145
+ type: "unknown",
2146
+ text: item,
2147
+ getRange: () => ({
2148
+ start: {
2149
+ line: start.line - 1,
2150
+ character: start.column - 1
2151
+ },
2152
+ end: {
2153
+ line: end.line - 1,
2154
+ character: end.column - 1
2155
+ }
2156
+ })
2157
+ };
2158
+ }
2047
2159
  const data = item.data;
2048
2160
  data.getRange = () => ({
2049
2161
  start: {
@@ -2064,29 +2176,29 @@ function extractTokens(node) {
2064
2176
  //#region packages/core/src/tokenizer/index.ts
2065
2177
  function tokenize(source, debug = false) {
2066
2178
  const result = root.parse(source);
2067
- if (debug) console.log((0, __prostojs_parser.printTree)(result));
2179
+ if (debug) console.log((0, _prostojs_parser.printTree)(result));
2068
2180
  return extractTokens(result);
2069
2181
  }
2070
2182
 
2071
2183
  //#endregion
2072
2184
  //#region packages/core/src/parser/pipes/tokens.pipe.ts
2073
- const identifier = (...text$2) => $token("identifier", text$2.length > 0 ? text$2 : undefined);
2074
- const text = (...text$2) => $token("text", text$2.length > 0 ? text$2 : undefined);
2075
- const block = (...text$2) => $token("block", text$2.length > 0 ? text$2.map((v) => v[0]) : undefined);
2076
- const pun = (...text$2) => $token("punctuation", text$2.length > 0 ? text$2 : undefined);
2077
- function $token(name, text$2) {
2185
+ const identifier = (...text) => $token("identifier", text.length > 0 ? text : void 0);
2186
+ const text = (...text) => $token("text", text.length > 0 ? text : void 0);
2187
+ const block = (...text) => $token("block", text.length > 0 ? text.map((v) => v[0]) : void 0);
2188
+ const pun = (...text) => $token("punctuation", text.length > 0 ? text : void 0);
2189
+ function $token(name, text) {
2078
2190
  const opts = {
2079
2191
  optional: false,
2080
- saveAs: undefined,
2081
- skip: undefined,
2192
+ saveAs: void 0,
2193
+ skip: void 0,
2082
2194
  expect: [{
2083
2195
  node: name,
2084
- text: text$2
2196
+ text
2085
2197
  }],
2086
- contains: undefined,
2198
+ contains: void 0,
2087
2199
  isGlobal: false,
2088
2200
  empty: false,
2089
- wrapper: undefined,
2201
+ wrapper: void 0,
2090
2202
  wrapMultiple: false,
2091
2203
  debug: false,
2092
2204
  eob: false,
@@ -2096,7 +2208,7 @@ function $token(name, text$2) {
2096
2208
  return {
2097
2209
  expect: [{
2098
2210
  node: name,
2099
- text: text$2
2211
+ text
2100
2212
  }],
2101
2213
  handler(ni, target) {
2102
2214
  if (opts.debug) debugger;
@@ -2137,7 +2249,7 @@ function $token(name, text$2) {
2137
2249
  ni.move();
2138
2250
  if (opts.skip) ni.skip(opts.skip);
2139
2251
  if (opts.wrapMultiple) continue;
2140
- else return true;
2252
+ else return true;
2141
2253
  } else {
2142
2254
  if (!opts.optional) ni.unexpected();
2143
2255
  return opts.optional;
@@ -2222,7 +2334,7 @@ function $pipe(entity, pipe = []) {
2222
2334
  pipe,
2223
2335
  toString: () => entity,
2224
2336
  skipTokens: [],
2225
- stopCondition: undefined,
2337
+ stopCondition: void 0,
2226
2338
  skip(...s) {
2227
2339
  this.skipTokens.push(...s);
2228
2340
  return this;
@@ -2237,12 +2349,12 @@ function $pipe(entity, pipe = []) {
2237
2349
  }
2238
2350
  };
2239
2351
  }
2240
- function runPipes(pipes$1, ni, singlePass = false) {
2352
+ function runPipes(pipes, ni, singlePass = false) {
2241
2353
  const nodes = [];
2242
2354
  while (ni.$) {
2243
2355
  let matched = true;
2244
2356
  let depth = ni.index;
2245
- for (const { targetFactory, pipe, skipTokens: skip, stopCondition } of pipes$1) {
2357
+ for (const { targetFactory, pipe, skipTokens: skip, stopCondition } of pipes) {
2246
2358
  const target = { node: targetFactory() };
2247
2359
  const fork = ni.fork();
2248
2360
  fork.skip(skip);
@@ -2277,15 +2389,15 @@ function runPipes(pipes$1, ni, singlePass = false) {
2277
2389
  }
2278
2390
  return nodes;
2279
2391
  }
2280
- function runPipesOnce(pipes$1, ni) {
2281
- return runPipes(pipes$1, ni, true)[0];
2392
+ function runPipesOnce(pipes, ni) {
2393
+ return runPipes(pipes, ni, true)[0];
2282
2394
  }
2283
2395
 
2284
2396
  //#endregion
2285
2397
  //#region packages/core/src/parser/grouping.ts
2286
2398
  function groupByPriority(nodes, priority) {
2287
2399
  if (nodes.length === 1) return nodes[0];
2288
- if (nodes.length === 0) return undefined;
2400
+ if (nodes.length === 0) return;
2289
2401
  if (nodes.length % 2 === 0) throw new Error(`Invalid number of nodes ${nodes.length}. Odd number expected`);
2290
2402
  let currentPass = nodes;
2291
2403
  let temporaryResult = [];
@@ -2294,7 +2406,7 @@ function groupByPriority(nodes, priority) {
2294
2406
  for (const [i, node] of currentPass.entries()) {
2295
2407
  const isOperator = i % 2 === 1;
2296
2408
  if (!isOperator && node instanceof Token) throw new Error(`Unexpected token ${node.toString()} at ${i}`);
2297
- else if (isOperator && !(node instanceof Token)) throw new Error(`Unexpected token ${isGroup(node) ? node.op : node.token.toString()} at ${i}`);
2409
+ else if (isOperator && !(node instanceof Token)) throw new Error(`Unexpected token ${isGroup(node) ? node.op : node.token.toString()} at ${i}`);
2298
2410
  if (isOperator) {
2299
2411
  if (node.text !== p) temporaryResult.push(node);
2300
2412
  continue;
@@ -2336,40 +2448,34 @@ const VALUE_KEYWORDS = new Set([
2336
2448
  "null",
2337
2449
  "undefined"
2338
2450
  ]);
2339
- function parseQueryExpression(children, messages, sourceToken) {
2340
- if (children.length === 0) return undefined;
2451
+ /**
2452
+ * Parse a backtick-delimited query expression from its child tokens.
2453
+ * Returns a SemanticQueryNode or undefined if the content is empty.
2454
+ */ function parseQueryExpression(children, messages, sourceToken) {
2455
+ if (children.length === 0) return;
2456
+ const ctx = {
2457
+ messages,
2458
+ fallback: sourceToken.range
2459
+ };
2341
2460
  const ni = new NodeIterator(children, messages);
2342
2461
  ni.move();
2343
- const expr = parseOrExpr(ni, messages);
2344
- if (!expr) return undefined;
2345
- if (ni.$) messages.push({
2346
- severity: 1,
2347
- message: `Unexpected token in query expression: "${ni.$.text}"`,
2348
- range: ni.$.getRange?.() ?? {
2349
- start: {
2350
- line: 0,
2351
- character: 0
2352
- },
2353
- end: {
2354
- line: 0,
2355
- character: 0
2356
- }
2357
- }
2358
- });
2462
+ const expr = parseOrExpr(ni, ctx);
2463
+ if (!expr) return;
2464
+ if (ni.$) pushError(ni, ctx, `Unexpected token in query expression: "${ni.$.text}"`);
2359
2465
  const node = new SemanticQueryNode();
2360
2466
  node.expression = expr;
2361
2467
  node.sourceToken = sourceToken;
2362
2468
  return node;
2363
2469
  }
2364
- function parseOrExpr(ni, messages) {
2365
- const left = parseAndExpr(ni, messages);
2366
- if (!left) return undefined;
2470
+ function parseOrExpr(ni, ctx) {
2471
+ const left = parseAndExpr(ni, ctx);
2472
+ if (!left) return;
2367
2473
  const operands = [left];
2368
2474
  while (ni.$?.type === "identifier" && ni.$.text === "or") {
2369
2475
  ni.move();
2370
- const right = parseAndExpr(ni, messages);
2476
+ const right = parseAndExpr(ni, ctx);
2371
2477
  if (!right) {
2372
- pushError(ni, messages, "Expected expression after \"or\"");
2478
+ pushError(ni, ctx, "Expected expression after \"or\"");
2373
2479
  break;
2374
2480
  }
2375
2481
  operands.push(right);
@@ -2380,15 +2486,15 @@ function parseOrExpr(ni, messages) {
2380
2486
  node.operands = operands;
2381
2487
  return node;
2382
2488
  }
2383
- function parseAndExpr(ni, messages) {
2384
- const left = parseUnaryExpr(ni, messages);
2385
- if (!left) return undefined;
2489
+ function parseAndExpr(ni, ctx) {
2490
+ const left = parseUnaryExpr(ni, ctx);
2491
+ if (!left) return;
2386
2492
  const operands = [left];
2387
2493
  while (ni.$?.type === "identifier" && ni.$.text === "and") {
2388
2494
  ni.move();
2389
- const right = parseUnaryExpr(ni, messages);
2495
+ const right = parseUnaryExpr(ni, ctx);
2390
2496
  if (!right) {
2391
- pushError(ni, messages, "Expected expression after \"and\"");
2497
+ pushError(ni, ctx, "Expected expression after \"and\"");
2392
2498
  break;
2393
2499
  }
2394
2500
  operands.push(right);
@@ -2399,13 +2505,13 @@ function parseAndExpr(ni, messages) {
2399
2505
  node.operands = operands;
2400
2506
  return node;
2401
2507
  }
2402
- function parseUnaryExpr(ni, messages) {
2508
+ function parseUnaryExpr(ni, ctx) {
2403
2509
  if (ni.$?.type === "identifier" && ni.$.text === "not") {
2404
2510
  ni.move();
2405
- const operand = parseUnaryExpr(ni, messages);
2511
+ const operand = parseUnaryExpr(ni, ctx);
2406
2512
  if (!operand) {
2407
- pushError(ni, messages, "Expected expression after \"not\"");
2408
- return undefined;
2513
+ pushError(ni, ctx, "Expected expression after \"not\"");
2514
+ return;
2409
2515
  }
2410
2516
  const node = new SemanticQueryLogicalNode();
2411
2517
  node.operator = "not";
@@ -2413,30 +2519,35 @@ function parseUnaryExpr(ni, messages) {
2413
2519
  return node;
2414
2520
  }
2415
2521
  if (ni.$?.type === "block" && ni.$.text === "(") {
2416
- const blockChildren = ni.$.children || [];
2522
+ const blockToken = ni.$;
2523
+ const blockChildren = blockToken.children || [];
2417
2524
  ni.move();
2525
+ const subCtx = {
2526
+ messages: ctx.messages,
2527
+ fallback: rangeOf(blockToken, ctx)
2528
+ };
2418
2529
  if (blockChildren.length === 0) {
2419
- pushError(ni, messages, "Empty parenthesized expression");
2420
- return undefined;
2530
+ pushErrorAt(subCtx.fallback, ctx, "Empty parenthesized expression");
2531
+ return;
2421
2532
  }
2422
- const subNi = new NodeIterator(blockChildren, messages);
2533
+ const subNi = new NodeIterator(blockChildren, ctx.messages);
2423
2534
  subNi.move();
2424
- const expr = parseOrExpr(subNi, messages);
2425
- if (subNi.$) pushError(subNi, messages, `Unexpected token in parenthesized expression: "${subNi.$.text}"`);
2535
+ const expr = parseOrExpr(subNi, subCtx);
2536
+ if (subNi.$) pushError(subNi, subCtx, `Unexpected token in parenthesized expression: "${subNi.$.text}"`);
2426
2537
  return expr;
2427
2538
  }
2428
- return parseComparison(ni, messages);
2539
+ return parseComparison(ni, ctx);
2429
2540
  }
2430
- function parseComparison(ni, messages) {
2431
- const left = parseFieldRef(ni, messages);
2432
- if (!left) return undefined;
2541
+ function parseComparison(ni, ctx) {
2542
+ const left = parseFieldRef(ni, ctx);
2543
+ if (!left) return;
2433
2544
  if (ni.$?.type === "punctuation" && SYMBOLIC_OPS.has(ni.$.text)) {
2434
2545
  const opText = ni.$.text;
2435
2546
  ni.move();
2436
- const right = parseValueOrFieldRef(ni, messages);
2547
+ const right = parseValueOrFieldRef(ni, ctx);
2437
2548
  if (!right) {
2438
- pushError(ni, messages, `Expected value or field reference after "${opText}"`);
2439
- return undefined;
2549
+ pushError(ni, ctx, `Expected value or field reference after "${opText}"`);
2550
+ return;
2440
2551
  }
2441
2552
  const node = new SemanticQueryComparisonNode();
2442
2553
  node.left = left;
@@ -2448,8 +2559,8 @@ function parseComparison(ni, messages) {
2448
2559
  const opText = ni.$.text;
2449
2560
  if (opText === "in") {
2450
2561
  ni.move();
2451
- const right = parseValueList(ni, messages);
2452
- if (!right) return undefined;
2562
+ const right = parseValueList(ni, ctx);
2563
+ if (!right) return;
2453
2564
  const node = new SemanticQueryComparisonNode();
2454
2565
  node.left = left;
2455
2566
  node.operator = "in";
@@ -2458,10 +2569,10 @@ function parseComparison(ni, messages) {
2458
2569
  }
2459
2570
  if (opText === "matches") {
2460
2571
  ni.move();
2461
- const right = parseValueOrFieldRef(ni, messages);
2572
+ const right = parseValueOrFieldRef(ni, ctx);
2462
2573
  if (!right) {
2463
- pushError(ni, messages, "Expected value after \"matches\"");
2464
- return undefined;
2574
+ pushError(ni, ctx, "Expected value after \"matches\"");
2575
+ return;
2465
2576
  }
2466
2577
  const node = new SemanticQueryComparisonNode();
2467
2578
  node.left = left;
@@ -2476,19 +2587,18 @@ function parseComparison(ni, messages) {
2476
2587
  node.operator = "exists";
2477
2588
  return node;
2478
2589
  }
2479
- if (opText === "not") return parseNotComparison(ni, messages, left);
2480
- pushError(ni, messages, `Unknown operator "${opText}"`);
2481
- return undefined;
2590
+ if (opText === "not") return parseNotComparison(ni, ctx, left);
2591
+ pushError(ni, ctx, `Unknown operator "${opText}"`);
2592
+ return;
2482
2593
  }
2483
- pushError(ni, messages, "Expected operator after field reference");
2484
- return undefined;
2594
+ pushError(ni, ctx, "Expected operator after field reference");
2485
2595
  }
2486
- function parseNotComparison(ni, messages, left) {
2596
+ function parseNotComparison(ni, ctx, left) {
2487
2597
  ni.move();
2488
2598
  if (ni.$?.type === "identifier" && ni.$.text === "in") {
2489
2599
  ni.move();
2490
- const right = parseValueList(ni, messages);
2491
- if (!right) return undefined;
2600
+ const right = parseValueList(ni, ctx);
2601
+ if (!right) return;
2492
2602
  const node = new SemanticQueryComparisonNode();
2493
2603
  node.left = left;
2494
2604
  node.operator = "not in";
@@ -2502,13 +2612,12 @@ function parseNotComparison(ni, messages, left) {
2502
2612
  node.operator = "not exists";
2503
2613
  return node;
2504
2614
  }
2505
- pushError(ni, messages, "Expected \"in\" or \"exists\" after \"not\"");
2506
- return undefined;
2615
+ pushError(ni, ctx, "Expected \"in\" or \"exists\" after \"not\"");
2507
2616
  }
2508
- function parseFieldRef(ni, messages) {
2617
+ function parseFieldRef(ni, ctx) {
2509
2618
  if (ni.$?.type !== "identifier") {
2510
- pushError(ni, messages, "Expected field reference");
2511
- return undefined;
2619
+ pushError(ni, ctx, "Expected field reference");
2620
+ return;
2512
2621
  }
2513
2622
  const firstToken = new Token(ni.$);
2514
2623
  ni.move();
@@ -2524,39 +2633,37 @@ function parseFieldRef(ni, messages) {
2524
2633
  fieldText += `.${ni.$.text}`;
2525
2634
  ni.move();
2526
2635
  } else {
2527
- pushError(ni, messages, "Expected identifier after \".\"");
2636
+ pushError(ni, ctx, "Expected identifier after \".\"");
2528
2637
  break;
2529
2638
  }
2530
2639
  }
2531
- const node$2 = new SemanticQueryFieldRefNode();
2532
- node$2.typeRef = firstToken;
2533
- if (fieldText !== secondToken.text) node$2.fieldRef = secondToken.clone({ text: fieldText });
2534
- else node$2.fieldRef = secondToken;
2535
- return node$2;
2640
+ const node = new SemanticQueryFieldRefNode();
2641
+ node.typeRef = firstToken;
2642
+ node.fieldRef = fieldText === secondToken.text ? secondToken : secondToken.clone({ text: fieldText });
2643
+ return node;
2536
2644
  }
2537
- pushError(ni, messages, "Expected identifier after \".\"");
2538
- const node$1 = new SemanticQueryFieldRefNode();
2539
- node$1.fieldRef = firstToken;
2540
- return node$1;
2645
+ pushError(ni, ctx, "Expected identifier after \".\"");
2646
+ const node = new SemanticQueryFieldRefNode();
2647
+ node.fieldRef = firstToken;
2648
+ return node;
2541
2649
  }
2542
2650
  const node = new SemanticQueryFieldRefNode();
2543
2651
  node.fieldRef = firstToken;
2544
2652
  return node;
2545
2653
  }
2546
- function parseValueOrFieldRef(ni, messages) {
2547
- if (!ni.$) return undefined;
2548
- if (ni.$.type === "text" || ni.$.type === "number" || ni.$.type === "regexp") return parseValue(ni, messages);
2654
+ function parseValueOrFieldRef(ni, ctx) {
2655
+ if (!ni.$) return;
2656
+ if (ni.$.type === "text" || ni.$.type === "number" || ni.$.type === "regexp") return parseValue(ni, ctx);
2549
2657
  if (ni.$.type === "identifier") {
2550
- if (VALUE_KEYWORDS.has(ni.$.text)) return parseValue(ni, messages);
2551
- return parseFieldRef(ni, messages);
2658
+ if (VALUE_KEYWORDS.has(ni.$.text)) return parseValue(ni, ctx);
2659
+ return parseFieldRef(ni, ctx);
2552
2660
  }
2553
- pushError(ni, messages, "Expected value or field reference");
2554
- return undefined;
2661
+ pushError(ni, ctx, "Expected value or field reference");
2555
2662
  }
2556
- function parseValue(ni, messages) {
2663
+ function parseValue(ni, ctx) {
2557
2664
  if (!ni.$) {
2558
- pushError(ni, messages, "Expected value");
2559
- return undefined;
2665
+ pushError(ni, ctx, "Expected value");
2666
+ return;
2560
2667
  }
2561
2668
  const token = ni.$;
2562
2669
  if (token.type === "text" || token.type === "number" || token.type === "regexp" || token.type === "identifier" && VALUE_KEYWORDS.has(token.text)) {
@@ -2565,47 +2672,49 @@ function parseValue(ni, messages) {
2565
2672
  ni.move();
2566
2673
  return node;
2567
2674
  }
2568
- pushError(ni, messages, `Unexpected token "${token.text}" where value expected`);
2569
- return undefined;
2675
+ pushError(ni, ctx, `Unexpected token "${token.text}" where value expected`);
2570
2676
  }
2571
- function parseValueList(ni, messages) {
2677
+ function parseValueList(ni, ctx) {
2572
2678
  if (ni.$?.type === "block" && ni.$.text === "(") {
2573
- const blockChildren = ni.$.children || [];
2679
+ const blockToken = ni.$;
2680
+ const blockChildren = blockToken.children || [];
2574
2681
  ni.move();
2682
+ const subCtx = {
2683
+ messages: ctx.messages,
2684
+ fallback: rangeOf(blockToken, ctx)
2685
+ };
2575
2686
  const values = [];
2576
2687
  if (blockChildren.length === 0) {
2577
- pushError(ni, messages, "Empty value list in \"in\" expression");
2578
- return undefined;
2688
+ pushErrorAt(subCtx.fallback, ctx, "Empty value list in \"in\" expression");
2689
+ return;
2579
2690
  }
2580
- const subNi = new NodeIterator(blockChildren, messages);
2691
+ const subNi = new NodeIterator(blockChildren, ctx.messages);
2581
2692
  subNi.move();
2582
- const first = parseValue(subNi, messages);
2693
+ const first = parseValue(subNi, subCtx);
2583
2694
  if (first) values.push(first);
2584
2695
  while (subNi.$?.type === "punctuation" && subNi.$.text === ",") {
2585
2696
  subNi.move();
2586
- const v = parseValue(subNi, messages);
2697
+ const v = parseValue(subNi, subCtx);
2587
2698
  if (v) values.push(v);
2588
2699
  }
2589
- if (subNi.$) pushError(subNi, messages, `Unexpected token in value list: "${subNi.$.text}"`);
2700
+ if (subNi.$) pushError(subNi, subCtx, `Unexpected token in value list: "${subNi.$.text}"`);
2590
2701
  const node = new SemanticQueryValueListNode();
2591
2702
  node.values = values;
2592
2703
  return node;
2593
2704
  }
2594
- pushError(ni, messages, "Expected parenthesized value list after \"in\"");
2595
- return undefined;
2705
+ pushError(ni, ctx, "Expected parenthesized value list after \"in\"");
2596
2706
  }
2597
- function pushError(ni, messages, message) {
2598
- const range = ni.$?.getRange?.() ?? {
2599
- start: {
2600
- line: 0,
2601
- character: 0
2602
- },
2603
- end: {
2604
- line: 0,
2605
- character: 0
2606
- }
2607
- };
2608
- messages.push({
2707
+ /**
2708
+ * Range of a token, falling back to the enclosing query/paren range when the
2709
+ * token carries no position of its own.
2710
+ */ function rangeOf(token, ctx) {
2711
+ return token?.getRange?.() ?? ctx.fallback;
2712
+ }
2713
+ function pushError(ni, ctx, message) {
2714
+ pushErrorAt(rangeOf(ni.$, ctx), ctx, message);
2715
+ }
2716
+ function pushErrorAt(range, ctx, message) {
2717
+ ctx.messages.push({
2609
2718
  severity: 1,
2610
2719
  message,
2611
2720
  range
@@ -2658,7 +2767,7 @@ function refWithChain() {
2658
2767
  } else if (fork.$.children?.length === 1 && fork.$.children[0].type === "text") {
2659
2768
  if (isRef(target.node)) target.node.addChain(new Token(fork.$.children[0]));
2660
2769
  } else return true;
2661
- else {
2770
+ else {
2662
2771
  fork.skip(["\n"]);
2663
2772
  if (fork.next().satisfies(s.id)) {
2664
2773
  if (isRef(target.node)) target.node.addDot(new Token(fork.$));
@@ -2765,7 +2874,7 @@ function annotations() {
2765
2874
  } else break;
2766
2875
  }
2767
2876
  if (ni.satisfies(opts.end)) ni.skip([";", "\n"]);
2768
- else if (ni.$) {
2877
+ else if (ni.$) {
2769
2878
  ni.unexpected(false, `Unexpected token in annotation ${ni.toString()}`);
2770
2879
  ni.skipUntil([";", "\n"]);
2771
2880
  ni.skip([";", "\n"]);
@@ -2774,12 +2883,12 @@ else if (ni.$) {
2774
2883
  return true;
2775
2884
  } };
2776
2885
  }
2777
- function definition(pipes$1) {
2886
+ function definition(pipes) {
2778
2887
  const opts = {
2779
2888
  sep: [],
2780
2889
  priority: false,
2781
2890
  multiple: false,
2782
- from: undefined,
2891
+ from: void 0,
2783
2892
  debug: false,
2784
2893
  skip: []
2785
2894
  };
@@ -2797,7 +2906,7 @@ function definition(pipes$1) {
2797
2906
  targetNode.define(new $n.SemanticGroup());
2798
2907
  return true;
2799
2908
  }
2800
- const resolvedPipes = pipes$1.map((p) => typeof p === "function" ? p() : p);
2909
+ const resolvedPipes = pipes.map((p) => typeof p === "function" ? p() : p);
2801
2910
  const node = runPipesOnce(resolvedPipes, fork);
2802
2911
  if (node) {
2803
2912
  fork.accepted();
@@ -2818,7 +2927,7 @@ function definition(pipes$1) {
2818
2927
  text: opts.sep
2819
2928
  })) {
2820
2929
  if (opts.priority) if (fork.next(opts.skip).$) nodes.push(new Token(fork.$));
2821
- else {
2930
+ else {
2822
2931
  fork.unexpected(false, "Unexpected end of group");
2823
2932
  break;
2824
2933
  }
@@ -2841,7 +2950,7 @@ else {
2841
2950
  }
2842
2951
  }
2843
2952
  if (nodes.length === 1) targetNode.define(nodes[0]);
2844
- else if (opts.priority && opts.sep.length > 0) {
2953
+ else if (opts.priority && opts.sep.length > 0) {
2845
2954
  if (nodes.length % 2 === 0) {
2846
2955
  fork.next().unexpected(false, "Error in group definition");
2847
2956
  return false;
@@ -2888,8 +2997,8 @@ function unwrap(attr) {
2888
2997
  target.node.define(new $n.SemanticGroup(nodes));
2889
2998
  return true;
2890
2999
  },
2891
- with(pipes$1) {
2892
- opts.pipes = pipes$1;
3000
+ with(pipes) {
3001
+ opts.pipes = pipes;
2893
3002
  return this;
2894
3003
  }
2895
3004
  };
@@ -2898,13 +3007,12 @@ function propName() {
2898
3007
  return { handler(ni, target) {
2899
3008
  switch (ni.$?.type) {
2900
3009
  case "identifier":
2901
- case "text": {
3010
+ case "text":
2902
3011
  target.node.saveToken(new Token(ni.$), "identifier");
2903
3012
  ni.accepted();
2904
3013
  ni.move();
2905
3014
  ni.skip(["\n"]);
2906
3015
  return true;
2907
- }
2908
3016
  case "block": {
2909
3017
  const childrenLength = ni.$.children?.length || 0;
2910
3018
  const firstText = ni.$.children?.[0]?.text;
@@ -2927,13 +3035,12 @@ function propName() {
2927
3035
  }
2928
3036
  if (ni.$.text === "[" && !childrenLength) ni.unexpected(false, "Wildcard \"*\" or a Regular Expression expected");
2929
3037
  if (ni.$.text === "[" && childrenLength > 1) ni.unexpected(false, firstText?.startsWith("/") ? "Invalid Regular Expression" : "To many arguments in prop pattern []");
2930
- else ni.unexpected(false, "Unexpected identifier at property name");
3038
+ else ni.unexpected(false, "Unexpected identifier at property name");
2931
3039
  return false;
2932
3040
  }
2933
- default: {
3041
+ default:
2934
3042
  ni.unexpected(false, "Unexpected identifier at property name");
2935
3043
  return false;
2936
- }
2937
3044
  }
2938
3045
  } };
2939
3046
  }
@@ -2980,9 +3087,8 @@ function extendsClause() {
2980
3087
  //#region packages/core/src/parser/pipes/pipes.ts
2981
3088
  const ref = $pipe("ref", [refWithChain()]);
2982
3089
  const constText = defineValuePipe("const", "text", false);
2983
- const constNumber = defineValuePipe("const", "number", false);
2984
3090
  const allowedValuesPipeArray = [
2985
- constNumber,
3091
+ defineValuePipe("const", "number", false),
2986
3092
  ref,
2987
3093
  constText
2988
3094
  ];
@@ -3045,14 +3151,13 @@ const importPipe = $pipe("import", [
3045
3151
  text().saveAs("path").skip(";", "\n"),
3046
3152
  definition([$pipe("ref", [identifier().saveAs("identifier").skip("\n")])]).from("inner").separatedBy(",").skip("\n").respectPriority()
3047
3153
  ]).skip("\n", ";");
3048
- const skipComments = { handler(ni) {
3049
- ni.skip();
3050
- return true;
3051
- } };
3052
3154
  const annotateEntry = $pipe("ref", [
3053
3155
  annotations(),
3054
3156
  refWithChain(),
3055
- skipComments,
3157
+ { handler(ni) {
3158
+ ni.skip();
3159
+ return true;
3160
+ } },
3056
3161
  pun(";", ",", "\n").orEob().lookBehind()
3057
3162
  ]).skip("\n", ";", ",");
3058
3163
  const annotatePipe = $pipe("annotate", [
@@ -3076,12 +3181,12 @@ const pipes = {
3076
3181
 
3077
3182
  //#endregion
3078
3183
  //#region packages/core/src/parser/types.ts
3079
- var TSeverity = /*#__PURE__*/ function(TSeverity$1) {
3080
- TSeverity$1[TSeverity$1["Error"] = 1] = "Error";
3081
- TSeverity$1[TSeverity$1["Warning"] = 2] = "Warning";
3082
- TSeverity$1[TSeverity$1["Info"] = 3] = "Info";
3083
- TSeverity$1[TSeverity$1["Hint"] = 4] = "Hint";
3084
- return TSeverity$1;
3184
+ var TSeverity = /* @__PURE__ */ function(TSeverity) {
3185
+ TSeverity[TSeverity["Error"] = 1] = "Error";
3186
+ TSeverity[TSeverity["Warning"] = 2] = "Warning";
3187
+ TSeverity[TSeverity["Info"] = 3] = "Info";
3188
+ TSeverity[TSeverity["Hint"] = 4] = "Hint";
3189
+ return TSeverity;
3085
3190
  }({});
3086
3191
 
3087
3192
  //#endregion
@@ -3093,7 +3198,7 @@ function _define_property$5(obj, key, value) {
3093
3198
  configurable: true,
3094
3199
  writable: true
3095
3200
  });
3096
- else obj[key] = value;
3201
+ else obj[key] = value;
3097
3202
  return obj;
3098
3203
  }
3099
3204
  /**
@@ -3135,19 +3240,22 @@ else obj[key] = value;
3135
3240
  const endCmp = comparePos(a.range.end, b.range.end);
3136
3241
  return startCmp >= 0 && endCmp <= 0;
3137
3242
  }
3138
- var BlocksIndex = class {
3243
+ /**
3244
+ * Implementation of `IBlocksIndex` that manages a collection of tokens and provides efficient methods to add tokens
3245
+ * and query the most nested token at a specific position.
3246
+ */ var BlocksIndex = class {
3139
3247
  /**
3140
3248
  * Adds a new token to the index. The token collection is maintained in sorted order by start position.
3141
3249
  * @param block - The token to add.
3142
- */ add(block$2) {
3250
+ */ add(block) {
3143
3251
  let left = 0;
3144
3252
  let right = this.blocks.length;
3145
3253
  while (left < right) {
3146
3254
  const mid = left + right >> 1;
3147
- if (comparePos(this.blocks[mid].range.start, block$2.range.start) < 0) left = mid + 1;
3148
- else right = mid;
3255
+ if (comparePos(this.blocks[mid].range.start, block.range.start) < 0) left = mid + 1;
3256
+ else right = mid;
3149
3257
  }
3150
- this.blocks.splice(left, 0, block$2);
3258
+ this.blocks.splice(left, 0, block);
3151
3259
  }
3152
3260
  /**
3153
3261
  * Finds the most nested token at a specific position.
@@ -3156,14 +3264,14 @@ else right = mid;
3156
3264
  * @returns The most nested token at the given position, or `undefined` if no token is found.
3157
3265
  */ at(line, character) {
3158
3266
  const candidates = [];
3159
- for (const block$2 of this.blocks) {
3160
- if (comparePos(block$2.range.start, {
3267
+ for (const block of this.blocks) {
3268
+ if (comparePos(block.range.start, {
3161
3269
  line,
3162
3270
  character
3163
3271
  }) > 0) break;
3164
- if (contains(block$2, line, character)) candidates.push(block$2);
3272
+ if (contains(block, line, character)) candidates.push(block);
3165
3273
  }
3166
- if (candidates.length === 0) return undefined;
3274
+ if (candidates.length === 0) return;
3167
3275
  let result = candidates[0];
3168
3276
  for (let i = 1; i < candidates.length; i++) if (moreNested(candidates[i], result)) result = candidates[i];
3169
3277
  return result;
@@ -3185,17 +3293,20 @@ function _define_property$4(obj, key, value) {
3185
3293
  configurable: true,
3186
3294
  writable: true
3187
3295
  });
3188
- else obj[key] = value;
3296
+ else obj[key] = value;
3189
3297
  return obj;
3190
3298
  }
3191
- var TokensIndex = class {
3299
+ /**
3300
+ * A class that implements a flat index for tokens, allowing quick access to tokens
3301
+ * at a specific line and character. Tokens in this index are not nested.
3302
+ */ var TokensIndex = class {
3192
3303
  /**
3193
3304
  * Adds a token to the index. The token is stored based on its starting line.
3194
3305
  * @param token - The token to add to the index.
3195
3306
  */ add(token) {
3196
3307
  if (!token?.range) return;
3197
3308
  const line = token.range.start.line;
3198
- this.tokensMap[line] = this.tokensMap[line] ?? new Set();
3309
+ this.tokensMap[line] = this.tokensMap[line] ?? /* @__PURE__ */ new Set();
3199
3310
  this.tokensMap[line].add(token);
3200
3311
  }
3201
3312
  /**
@@ -3204,10 +3315,10 @@ var TokensIndex = class {
3204
3315
  * @param character - The character position within the line to search for.
3205
3316
  * @returns The token at the specified line and character, or `undefined` if none exists.
3206
3317
  */ at(line, character) {
3207
- const tokens$1 = this.tokensMap[line];
3208
- if (!tokens$1) return undefined;
3318
+ const tokens = this.tokensMap[line];
3319
+ if (!tokens) return;
3209
3320
  let best;
3210
- for (const t of tokens$1) if (t.range.start.character <= character && t.range.end.character >= character) {
3321
+ for (const t of tokens) if (t.range.start.character <= character && t.range.end.character >= character) {
3211
3322
  if (!best || t.range.start.character > best.range.start.character || t.range.start.character === best.range.start.character && t.range.end.character < best.range.end.character) best = t;
3212
3323
  }
3213
3324
  return best;
@@ -3231,14 +3342,13 @@ var TokensIndex = class {
3231
3342
  if (candidate) return candidate;
3232
3343
  }
3233
3344
  for (let l = line - 1; l >= 0; l--) {
3234
- const tokens$1 = this.tokensMap[l];
3235
- if (tokens$1 && tokens$1.size > 0) {
3345
+ const tokens = this.tokensMap[l];
3346
+ if (tokens && tokens.size > 0) {
3236
3347
  let candidate;
3237
- for (const t of tokens$1) if (!candidate || t.range.end.character > candidate.range.end.character) candidate = t;
3348
+ for (const t of tokens) if (!candidate || t.range.end.character > candidate.range.end.character) candidate = t;
3238
3349
  if (candidate) return candidate;
3239
3350
  }
3240
3351
  }
3241
- return undefined;
3242
3352
  }
3243
3353
  constructor() {
3244
3354
  /**
@@ -3257,7 +3367,7 @@ function _define_property$3(obj, key, value) {
3257
3367
  configurable: true,
3258
3368
  writable: true
3259
3369
  });
3260
- else obj[key] = value;
3370
+ else obj[key] = value;
3261
3371
  return obj;
3262
3372
  }
3263
3373
  var AtscriptDoc = class {
@@ -3272,7 +3382,7 @@ var AtscriptDoc = class {
3272
3382
  }
3273
3383
  resolveAnnotation(name) {
3274
3384
  let spec = this._annotationSpecCache.get(name);
3275
- if (spec === undefined && !this._annotationSpecCache.has(name)) {
3385
+ if (spec === void 0 && !this._annotationSpecCache.has(name)) {
3276
3386
  spec = resolveAnnotation(name, this.config.annotations);
3277
3387
  this._annotationSpecCache.set(name, spec);
3278
3388
  }
@@ -3311,11 +3421,10 @@ var AtscriptDoc = class {
3311
3421
  get text() {
3312
3422
  return this._text;
3313
3423
  }
3314
- update(text$2, debug = false) {
3315
- this._text = text$2;
3424
+ update(text, debug = false) {
3425
+ this._text = text;
3316
3426
  this.cleanup();
3317
- const rawTokens = tokenize(text$2, debug);
3318
- const ni = new NodeIterator(rawTokens, []).move();
3427
+ const ni = new NodeIterator(tokenize(text, debug), []).move();
3319
3428
  this.nodes = runPipes([
3320
3429
  pipes.importPipe,
3321
3430
  pipes.type,
@@ -3335,8 +3444,8 @@ var AtscriptDoc = class {
3335
3444
  this.queryFieldRefs = [];
3336
3445
  this.imports.clear();
3337
3446
  this.resolvedImports.clear();
3338
- this._allMessages = undefined;
3339
- this._annotateNodesByTarget = undefined;
3447
+ this._allMessages = void 0;
3448
+ this._annotateNodesByTarget = void 0;
3340
3449
  this.tokensIndex = new TokensIndex();
3341
3450
  this.blocksIndex = new BlocksIndex();
3342
3451
  this.resolvedAnnotations = [];
@@ -3383,14 +3492,12 @@ var AtscriptDoc = class {
3383
3492
  } else {
3384
3493
  let severity = 1;
3385
3494
  switch (this.config.unknownAnnotation) {
3386
- case "warn": {
3495
+ case "warn":
3387
3496
  severity = 2;
3388
3497
  break;
3389
- }
3390
- case "allow": {
3498
+ case "allow":
3391
3499
  severity = 0;
3392
3500
  break;
3393
- }
3394
3501
  default:
3395
3502
  }
3396
3503
  if (severity > 0) this.registerMessage(mainToken, `Unknown annotation "${mainToken.text}"`, severity, "dim");
@@ -3417,9 +3524,9 @@ var AtscriptDoc = class {
3417
3524
  *
3418
3525
  * If the type cannot be resolved or does not exist, returns `undefined`.
3419
3526
  */ unwindType(name, chain = [], watchCb, _tracked) {
3420
- const tracked = _tracked || new Set();
3527
+ const tracked = _tracked || /* @__PURE__ */ new Set();
3421
3528
  const decl = this.getDeclarationOwnerNode(name);
3422
- if (!decl) return undefined;
3529
+ if (!decl) return;
3423
3530
  const callCb = watchCb ? () => {
3424
3531
  if (def && !tracked.has(def) && [
3425
3532
  "type",
@@ -3450,19 +3557,19 @@ var AtscriptDoc = class {
3450
3557
  }
3451
3558
  };
3452
3559
  resolveType();
3453
- if (!def) return undefined;
3560
+ if (!def) return;
3454
3561
  if (isAnnotate(def)) return doc.unwindType(def.targetName, chain, watchCb, tracked);
3455
3562
  for (const item of chain) {
3456
3563
  const itemText = typeof item === "string" ? item : item.text;
3457
- if (!def) return undefined;
3564
+ if (!def) return;
3458
3565
  if (isProp(def)) if (def.nestedProps?.get(itemText)) def = def.nestedProps.get(itemText);
3459
- else {
3566
+ else {
3460
3567
  def = def.nestedType;
3461
3568
  resolveRef();
3462
3569
  resolveType();
3463
3570
  if (isStructure(def) || isInterface(def)) def = def.props.get(itemText);
3464
3571
  }
3465
- else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.props.get(itemText);
3572
+ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.props.get(itemText);
3466
3573
  }
3467
3574
  if (_tracked) callCb();
3468
3575
  while (isProp(def)) {
@@ -3475,7 +3582,7 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3475
3582
  def,
3476
3583
  doc,
3477
3584
  node
3478
- } : undefined;
3585
+ } : void 0;
3479
3586
  }
3480
3587
  getUsageListAt(line, character) {
3481
3588
  const token = this.tokensIndex.at(line, character);
@@ -3485,7 +3592,7 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3485
3592
  let right = givenNode.annotations;
3486
3593
  let def = givenNode.getDefinition();
3487
3594
  if (def) {
3488
- const refDef = isRef(def) ? def : undefined;
3595
+ const refDef = isRef(def) ? def : void 0;
3489
3596
  if (refDef) {
3490
3597
  const chainNodes = [];
3491
3598
  const unwound = this.unwindType(refDef.token("identifier").text, refDef.chain, (intermediate) => {
@@ -3507,20 +3614,20 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3507
3614
  * when folding annotations across a ref boundary. Annotations without a
3508
3615
  * resolvable spec pass through (default is to inherit). Returns the input
3509
3616
  * array unchanged when nothing is dropped.
3510
- */ filterPassedWhenReferred(annotations$1) {
3511
- if (!annotations$1?.length) return annotations$1;
3617
+ */ filterPassedWhenReferred(annotations) {
3618
+ if (!annotations?.length) return annotations;
3512
3619
  let filtered;
3513
- for (let i = 0; i < annotations$1.length; i++) if (this.resolveAnnotation(annotations$1[i].name)?.config.passedWhenReferred === false) filtered ?? (filtered = annotations$1.slice(0, i));
3514
- else filtered?.push(annotations$1[i]);
3515
- return filtered ?? annotations$1;
3620
+ for (let i = 0; i < annotations.length; i++) if (this.resolveAnnotation(annotations[i].name)?.config.passedWhenReferred === false) filtered ?? (filtered = annotations.slice(0, i));
3621
+ else filtered?.push(annotations[i]);
3622
+ return filtered ?? annotations;
3516
3623
  }
3517
3624
  /**
3518
3625
  * If the position falls inside an `annotate` block, returns that block's node
3519
3626
  * (whose `targetName` is the annotated interface). Entry refs within the block
3520
3627
  * resolve through the target interface rather than as top-level definitions.
3521
3628
  */ annotateBlockAt(line, character) {
3522
- const block$2 = this.blocksIndex.at(line, character);
3523
- return block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode) ? block$2.parentNode : undefined;
3629
+ const block = this.blocksIndex.at(line, character);
3630
+ return block?.blockType === "annotate" && isAnnotate(block.parentNode) ? block.parentNode : void 0;
3524
3631
  }
3525
3632
  /**
3526
3633
  * Collects ad-hoc annotations from all `annotate` blocks targeting a given type/interface.
@@ -3528,11 +3635,11 @@ else filtered?.push(annotations$1[i]);
3528
3635
  * For entries without a chain (root-level), the key is the entry identifier.
3529
3636
  */ getAnnotateNodesFor(targetName) {
3530
3637
  if (!this._annotateNodesByTarget) {
3531
- const index = new Map();
3638
+ const index = /* @__PURE__ */ new Map();
3532
3639
  for (const node of this.nodes) if (isAnnotate(node)) {
3533
3640
  const existing = index.get(node.targetName);
3534
3641
  if (existing) existing.push(node);
3535
- else index.set(node.targetName, [node]);
3642
+ else index.set(node.targetName, [node]);
3536
3643
  }
3537
3644
  this._annotateNodesByTarget = index;
3538
3645
  }
@@ -3551,9 +3658,9 @@ else index.set(node.targetName, [node]);
3551
3658
  * the child's file apply to grandparent-inherited fields, even when the chain crosses
3552
3659
  * package boundaries (child → mid → grandparent, all in different .as files).
3553
3660
  */ resolveInterfaceExtends(node, _visited, _originDoc) {
3554
- if (!node.hasExtends) return undefined;
3555
- const visited = _visited || new Set();
3556
- if (node.id && visited.has(node.id)) return undefined;
3661
+ if (!node.hasExtends) return;
3662
+ const visited = _visited || /* @__PURE__ */ new Set();
3663
+ if (node.id && visited.has(node.id)) return;
3557
3664
  if (node.id) visited.add(node.id);
3558
3665
  const originDoc = _originDoc ?? this;
3559
3666
  let mergedStruct;
@@ -3562,10 +3669,8 @@ else index.set(node.targetName, [node]);
3562
3669
  if (!unwound?.def) continue;
3563
3670
  let parentDef = unwound.def;
3564
3671
  const parentDeclName = unwound.node?.id ?? parentDef.id;
3565
- if (isInterface(parentDef) && parentDef.hasExtends) {
3566
- const resolved = unwound.doc.resolveInterfaceExtends(parentDef, visited, originDoc);
3567
- parentDef = resolved || parentDef.getDefinition() || parentDef;
3568
- } else if (isInterface(parentDef)) parentDef = parentDef.getDefinition() || parentDef;
3672
+ if (isInterface(parentDef) && parentDef.hasExtends) parentDef = unwound.doc.resolveInterfaceExtends(parentDef, visited, originDoc) || parentDef.getDefinition() || parentDef;
3673
+ else if (isInterface(parentDef)) parentDef = parentDef.getDefinition() || parentDef;
3569
3674
  parentDef = this.mergeIntersection(parentDef);
3570
3675
  const annotateNodes = [];
3571
3676
  const collect = (doc, name) => {
@@ -3577,16 +3682,10 @@ else index.set(node.targetName, [node]);
3577
3682
  if (originDoc !== this && originDoc !== unwound.doc) collect(originDoc, parentDeclName);
3578
3683
  if (annotateNodes.length > 0) parentDef = this.applyAnnotateBlocksToStructure(parentDef, annotateNodes);
3579
3684
  if (!mergedStruct) mergedStruct = parentDef;
3580
- else {
3581
- const merged = this.mergeDefs(mergedStruct, parentDef);
3582
- mergedStruct = merged[0];
3583
- }
3685
+ else mergedStruct = this.mergeDefs(mergedStruct, parentDef)[0];
3584
3686
  }
3585
3687
  const ownDef = node.getDefinition();
3586
- if (ownDef && mergedStruct) {
3587
- const merged = this.mergeDefs(mergedStruct, ownDef);
3588
- return merged[0];
3589
- }
3688
+ if (ownDef && mergedStruct) return this.mergeDefs(mergedStruct, ownDef)[0];
3590
3689
  return mergedStruct || ownDef;
3591
3690
  }
3592
3691
  /**
@@ -3617,19 +3716,19 @@ else {
3617
3716
  * prop. Returns a new structure with cloned props/structures along touched paths, or
3618
3717
  * `undefined` when nothing matched (so callers can reuse the original by reference).
3619
3718
  */ foldAnnotationsIntoStructure(struct, entries) {
3620
- const byHead = new Map();
3719
+ const byHead = /* @__PURE__ */ new Map();
3621
3720
  for (const entry of entries) {
3622
3721
  const head = entry.parts[0];
3623
- let group$1 = byHead.get(head);
3624
- if (!group$1) {
3625
- group$1 = {
3722
+ let group = byHead.get(head);
3723
+ if (!group) {
3724
+ group = {
3626
3725
  own: [],
3627
3726
  nested: []
3628
3727
  };
3629
- byHead.set(head, group$1);
3728
+ byHead.set(head, group);
3630
3729
  }
3631
- if (entry.parts.length === 1) group$1.own.push(...entry.anns);
3632
- else group$1.nested.push({
3730
+ if (entry.parts.length === 1) group.own.push(...entry.anns);
3731
+ else group.nested.push({
3633
3732
  parts: entry.parts.slice(1),
3634
3733
  anns: entry.anns
3635
3734
  });
@@ -3637,18 +3736,18 @@ else group$1.nested.push({
3637
3736
  const newProps = [];
3638
3737
  let changed = false;
3639
3738
  for (const [name, prop] of struct.props) {
3640
- const group$1 = byHead.get(name);
3641
- if (!group$1) {
3739
+ const group = byHead.get(name);
3740
+ if (!group) {
3642
3741
  newProps.push(prop);
3643
3742
  continue;
3644
3743
  }
3645
3744
  const propDef = prop.getDefinition();
3646
3745
  let newDef = propDef;
3647
- if (group$1.nested.length > 0 && propDef && isStructure(propDef)) {
3648
- const foldedNested = this.foldAnnotationsIntoStructure(propDef, group$1.nested);
3746
+ if (group.nested.length > 0 && propDef && isStructure(propDef)) {
3747
+ const foldedNested = this.foldAnnotationsIntoStructure(propDef, group.nested);
3649
3748
  if (foldedNested) newDef = foldedNested;
3650
3749
  }
3651
- if (group$1.own.length === 0 && newDef === propDef) {
3750
+ if (group.own.length === 0 && newDef === propDef) {
3652
3751
  newProps.push(prop);
3653
3752
  continue;
3654
3753
  }
@@ -3656,13 +3755,13 @@ else group$1.nested.push({
3656
3755
  const idToken = prop.token("identifier");
3657
3756
  if (idToken) cloned.saveToken(idToken, "identifier");
3658
3757
  if (newDef) cloned.define(newDef);
3659
- cloned.annotations = group$1.own.length > 0 ? this.mergeNodesAnnotations(prop.annotations, group$1.own) : prop.annotations;
3758
+ cloned.annotations = group.own.length > 0 ? this.mergeNodesAnnotations(prop.annotations, group.own) : prop.annotations;
3660
3759
  const optionalToken = prop.token("optional");
3661
3760
  if (optionalToken) cloned.saveToken(optionalToken, "optional");
3662
3761
  newProps.push(cloned);
3663
3762
  changed = true;
3664
3763
  }
3665
- if (!changed) return undefined;
3764
+ if (!changed) return;
3666
3765
  const newStruct = new SemanticStructureNode();
3667
3766
  newStruct.setProps(newProps);
3668
3767
  newStruct.annotations = struct.annotations;
@@ -3675,9 +3774,8 @@ else group$1.nested.push({
3675
3774
  range: r.range,
3676
3775
  token: r
3677
3776
  }));
3678
- if (token.exported) for (const d of this.dependants) {
3679
- const imp = d.imports.get(this.id);
3680
- if (imp?.imports.find((t) => t.text === token.text)) refs.push(...d.referred.filter((t) => t.text === token.text).map((r) => ({
3777
+ if (token.exported) {
3778
+ for (const d of this.dependants) if (d.imports.get(this.id)?.imports.find((t) => t.text === token.text)) refs.push(...d.referred.filter((t) => t.text === token.text).map((r) => ({
3681
3779
  uri: d.id,
3682
3780
  range: r.range,
3683
3781
  token: r
@@ -3686,20 +3784,20 @@ else group$1.nested.push({
3686
3784
  return refs;
3687
3785
  }
3688
3786
  if (isProp(token.parentNode)) {
3689
- const propName$1 = token.parentNode.id;
3690
- if (!propName$1) return undefined;
3787
+ const propName = token.parentNode.id;
3788
+ if (!propName) return;
3691
3789
  let parentName;
3692
- for (const node of this.nodes) if ((isInterface(node) || isStructure(node)) && node.props.get(propName$1) === token.parentNode) {
3790
+ for (const node of this.nodes) if ((isInterface(node) || isStructure(node)) && node.props.get(propName) === token.parentNode) {
3693
3791
  parentName = node.id;
3694
3792
  break;
3695
3793
  }
3696
- if (!parentName) return undefined;
3794
+ if (!parentName) return;
3697
3795
  const refs = [];
3698
3796
  const searchDoc = (doc, uri) => {
3699
3797
  for (const t of doc.referred) {
3700
3798
  if (t.text !== parentName || !isRef(t.parentNode) || !t.parentNode.hasChain) continue;
3701
3799
  const chainToken = t.parentNode.chain[0];
3702
- if (chainToken?.text === propName$1) refs.push({
3800
+ if (chainToken?.text === propName) refs.push({
3703
3801
  uri,
3704
3802
  range: chainToken.range,
3705
3803
  token: chainToken
@@ -3707,7 +3805,7 @@ else group$1.nested.push({
3707
3805
  }
3708
3806
  for (const node of doc.nodes) {
3709
3807
  if (!isAnnotate(node) || node.targetName !== parentName) continue;
3710
- for (const entry of node.entries) if (entry.id === propName$1) {
3808
+ for (const entry of node.entries) if (entry.id === propName) {
3711
3809
  const entryToken = entry.token("identifier");
3712
3810
  if (entryToken) refs.push({
3713
3811
  uri,
@@ -3717,11 +3815,10 @@ else group$1.nested.push({
3717
3815
  }
3718
3816
  }
3719
3817
  for (const qfr of doc.queryFieldRefs) {
3720
- if (!qfr.queryArgToken || qfr.fieldRef.text !== propName$1) continue;
3818
+ if (!qfr.queryArgToken || qfr.fieldRef.text !== propName) continue;
3721
3819
  const scope = getQueryScope(qfr.queryArgToken, doc);
3722
3820
  if (!scope) continue;
3723
- const resolvedTypeName = qfr.typeRef?.text ?? scope.unqualifiedTarget;
3724
- if (resolvedTypeName === parentName) refs.push({
3821
+ if ((qfr.typeRef?.text ?? scope.unqualifiedTarget) === parentName) refs.push({
3725
3822
  uri,
3726
3823
  range: qfr.fieldRef.range,
3727
3824
  token: qfr.fieldRef
@@ -3729,13 +3826,9 @@ else group$1.nested.push({
3729
3826
  }
3730
3827
  };
3731
3828
  searchDoc(this, this.id);
3732
- const parentDefToken = this.registry.definitions.get(parentName);
3733
- if (parentDefToken?.exported) {
3829
+ if (this.registry.definitions.get(parentName)?.exported) {
3734
3830
  const targetName = parentName;
3735
- for (const d of this.dependants) {
3736
- const imp = d.imports.get(this.id);
3737
- if (imp?.imports.find((t) => t.text === targetName)) searchDoc(d, d.id);
3738
- }
3831
+ for (const d of this.dependants) if (d.imports.get(this.id)?.imports.find((t) => t.text === targetName)) searchDoc(d, d.id);
3739
3832
  }
3740
3833
  return refs;
3741
3834
  }
@@ -3752,13 +3845,12 @@ else group$1.nested.push({
3752
3845
  }
3753
3846
  }
3754
3847
  }
3755
- return undefined;
3848
+ return;
3756
3849
  }
3757
3850
  {
3758
3851
  const defForToken = this.getDefinitionFor(token);
3759
3852
  if (defForToken?.token?.isDefinition && defForToken.doc) return defForToken.doc.usageListFor(defForToken.token);
3760
3853
  }
3761
- return undefined;
3762
3854
  }
3763
3855
  /**
3764
3856
  * Retrieves the definition (i.e., the “go to definition” target) for a given token.
@@ -3799,7 +3891,7 @@ else group$1.nested.push({
3799
3891
  uri: targetDoc.id,
3800
3892
  doc: targetDoc,
3801
3893
  token: target
3802
- } : undefined;
3894
+ } : void 0;
3803
3895
  }
3804
3896
  }
3805
3897
  if (token.isReference) {
@@ -3808,7 +3900,7 @@ else group$1.nested.push({
3808
3900
  uri: this.id,
3809
3901
  doc: this,
3810
3902
  token: def
3811
- } : undefined;
3903
+ } : void 0;
3812
3904
  }
3813
3905
  }
3814
3906
  getToDefinitionAt(line, character) {
@@ -3826,7 +3918,7 @@ else group$1.nested.push({
3826
3918
  targetSelectionRange: unwound.node.token("identifier")?.range ?? zeroRange,
3827
3919
  originSelectionRange: token.range
3828
3920
  }];
3829
- return undefined;
3921
+ return;
3830
3922
  }
3831
3923
  if (isQueryFieldRef(token.parentNode)) {
3832
3924
  const fieldRefNode = token.parentNode;
@@ -3841,7 +3933,7 @@ else group$1.nested.push({
3841
3933
  targetRange: result.token?.range ?? zeroRange,
3842
3934
  targetSelectionRange: result.token?.range ?? zeroRange,
3843
3935
  originSelectionRange: token.range
3844
- }] : undefined;
3936
+ }] : void 0;
3845
3937
  }
3846
3938
  if (token === fieldRefNode.fieldRef) {
3847
3939
  const resolved = resolveQueryFieldRef(fieldRefNode, this, scope);
@@ -3857,7 +3949,7 @@ else group$1.nested.push({
3857
3949
  }
3858
3950
  }
3859
3951
  }
3860
- return undefined;
3952
+ return;
3861
3953
  }
3862
3954
  if (isProp(token.parentNode)) return [{
3863
3955
  targetUri: this.id,
@@ -3881,19 +3973,19 @@ else group$1.nested.push({
3881
3973
  targetRange: result.token?.range ?? zeroRange,
3882
3974
  targetSelectionRange: result.token?.range ?? zeroRange,
3883
3975
  originSelectionRange: token.range
3884
- }] : undefined;
3976
+ }] : void 0;
3885
3977
  }
3886
3978
  }
3887
3979
  }
3888
- registerImport({ from, imports, block: block$2 }) {
3980
+ registerImport({ from, imports, block }) {
3889
3981
  const importId = resolveAtscriptFromPath(from.text, this.id);
3890
3982
  this.imports.set(importId, {
3891
3983
  from,
3892
3984
  imports
3893
3985
  });
3894
- this.blocksIndex.add(block$2);
3895
- block$2.blockType = "import";
3896
- block$2.fromPath = from.text;
3986
+ this.blocksIndex.add(block);
3987
+ block.blockType = "import";
3988
+ block.fromPath = from.text;
3897
3989
  this.tokensIndex.add(from);
3898
3990
  from.fromPath = from.text;
3899
3991
  imports.forEach((t) => {
@@ -3933,27 +4025,26 @@ else group$1.nested.push({
3933
4025
  * - `token`: The specific token for the declaration (if applicable).
3934
4026
  *
3935
4027
  * If no declaration is found, returns `undefined`.
3936
- */ getDeclarationOwnerNode(identifier$1) {
3937
- if (this.config.primitives?.has(identifier$1)) return {
4028
+ */ getDeclarationOwnerNode(identifier) {
4029
+ if (this.config.primitives?.has(identifier)) return {
3938
4030
  doc: this,
3939
- node: this.config.primitives.get(identifier$1)
4031
+ node: this.config.primitives.get(identifier)
3940
4032
  };
3941
- const def = this.registry.definitions.get(identifier$1);
4033
+ const def = this.registry.definitions.get(identifier);
3942
4034
  if (def?.imported && def.fromPath) {
3943
4035
  const absolutePath = this.resolveImportId(resolveAtscriptFromPath(def.fromPath, this.id));
3944
- const doc = this.dependenciesMap.get(absolutePath);
3945
- return doc?.getDeclarationOwnerNode(identifier$1);
4036
+ return this.dependenciesMap.get(absolutePath)?.getDeclarationOwnerNode(identifier);
3946
4037
  } else if (!def?.imported) return def ? {
3947
4038
  doc: this,
3948
4039
  node: def.parentNode,
3949
4040
  token: def
3950
- } : undefined;
4041
+ } : void 0;
3951
4042
  }
3952
4043
  registerExport(node) {
3953
4044
  if (node.id) this.exports.set(node.id, node);
3954
4045
  }
3955
4046
  registerMessage(token, message, severity = 1, tag) {
3956
- if (this._allMessages) this._allMessages = undefined;
4047
+ if (this._allMessages) this._allMessages = void 0;
3957
4048
  this.messages.push({
3958
4049
  severity,
3959
4050
  message,
@@ -3965,13 +4056,13 @@ else group$1.nested.push({
3965
4056
  if (messages) this.messages.push(...messages);
3966
4057
  }
3967
4058
  clearMessages() {
3968
- this._allMessages = undefined;
4059
+ this._allMessages = void 0;
3969
4060
  }
3970
4061
  getUnusedTokens() {
3971
4062
  const refSet = new Set(this.referred.filter((r) => !r.imported).map((r) => r.text));
3972
- const tokens$1 = [];
3973
- for (const [key, token] of this.registry.definitions) if (!refSet.has(key) && !this.exports.has(key)) tokens$1.push(token);
3974
- return tokens$1;
4063
+ const tokens = [];
4064
+ for (const [key, token] of this.registry.definitions) if (!refSet.has(key) && !this.exports.has(key)) tokens.push(token);
4065
+ return tokens;
3975
4066
  }
3976
4067
  renderDiagMessage(m, addSourceLinses = false, colors = false) {
3977
4068
  const c = {
@@ -3985,30 +4076,26 @@ else group$1.nested.push({
3985
4076
  let sc = "";
3986
4077
  let banner = "[atscript]";
3987
4078
  switch (m.severity) {
3988
- case TSeverity.Error: {
4079
+ case TSeverity.Error:
3989
4080
  sc = c.red;
3990
4081
  banner += "[Error]";
3991
4082
  break;
3992
- }
3993
- case TSeverity.Warning: {
4083
+ case TSeverity.Warning:
3994
4084
  sc = c.yellow;
3995
4085
  banner += "[Warning]";
3996
4086
  break;
3997
- }
3998
- case TSeverity.Info: {
4087
+ case TSeverity.Info:
3999
4088
  sc = "";
4000
4089
  banner += "[Info]";
4001
4090
  break;
4002
- }
4003
- case TSeverity.Hint: {
4091
+ case TSeverity.Hint:
4004
4092
  sc = c.dim;
4005
4093
  banner += "[Hint]";
4006
4094
  break;
4007
- }
4008
4095
  default: sc = "";
4009
4096
  }
4010
4097
  const n = m.range.start.line + 1;
4011
- let out = `\n${sc}${banner} ${m.message}${c.reset}` + `\nin ${c.blue}${this.id}:${n}:${m.range.start.character + 1}${c.reset}`;
4098
+ let out = `\n${sc}${banner} ${m.message}${c.reset}\nin ${c.blue}${this.id}:${n}:${m.range.start.character + 1}${c.reset}`;
4012
4099
  if (addSourceLinses) {
4013
4100
  const lines = this.text.split("\n");
4014
4101
  const renderLines = [
@@ -4024,7 +4111,7 @@ else group$1.nested.push({
4024
4111
  l: lines[n - 1],
4025
4112
  i: n - 1
4026
4113
  }
4027
- ].filter((r) => r.l !== undefined);
4114
+ ].filter((r) => r.l !== void 0);
4028
4115
  const nl = String(n).length + 1;
4029
4116
  for (const { l, i } of renderLines) {
4030
4117
  const prefix = `${c.dim + c.cyan}${`0${i}`.slice(-nl)} | ${c.reset}`;
@@ -4050,7 +4137,7 @@ else group$1.nested.push({
4050
4137
  });
4051
4138
  const ownDef = iface.getDefinition();
4052
4139
  if (ownDef && isStructure(ownDef)) {
4053
- const parentProps = new Map();
4140
+ const parentProps = /* @__PURE__ */ new Map();
4054
4141
  for (const t of iface.extendsTokens) {
4055
4142
  if (t.text === iface.id) continue;
4056
4143
  const unwound = this.unwindType(t.text);
@@ -4088,8 +4175,7 @@ else group$1.nested.push({
4088
4175
  if (!this.registry.isDefined(targetName)) continue;
4089
4176
  const chain = isRef(t.parentNode) && t.parentNode.hasChain ? [t.text, ...t.parentNode.chain.map((c) => c.text)] : [t.text];
4090
4177
  const unwound = this.unwindType(targetName, chain);
4091
- const chainResolved = unwound?.def && !isGroup(unwound.def);
4092
- const resolvedType = chainResolved ? unwound.def : this.resolveChainWithMerge(targetName, chain);
4178
+ const resolvedType = unwound?.def && !isGroup(unwound.def) ? unwound.def : this.resolveChainWithMerge(targetName, chain);
4093
4179
  if (!resolvedType) {
4094
4180
  const lastToken = chain.length > 1 && isRef(t.parentNode) ? t.parentNode.chain[t.parentNode.chain.length - 1] || t : t;
4095
4181
  this._allMessages.push({
@@ -4103,8 +4189,7 @@ else group$1.nested.push({
4103
4189
  const token = t.parentNode.chain[i];
4104
4190
  const memberChain = [t.text, ...t.parentNode.chain.slice(0, i + 1).map((c) => c.text)];
4105
4191
  const decl = this.unwindType(targetName, memberChain);
4106
- const memberResolved = decl?.def && !isGroup(decl.def);
4107
- if (!memberResolved && !this.resolveChainWithMerge(targetName, memberChain)) this._allMessages.push({
4192
+ if (!(decl?.def && !isGroup(decl.def)) && !this.resolveChainWithMerge(targetName, memberChain)) this._allMessages.push({
4108
4193
  severity: 1,
4109
4194
  message: `Unknown property "${memberChain.join(".")}" in "${targetName}"`,
4110
4195
  range: token.range
@@ -4112,8 +4197,7 @@ else group$1.nested.push({
4112
4197
  }
4113
4198
  }
4114
4199
  if (resolvedType && isRef(t.parentNode) && t.parentNode.annotations) for (const a of t.parentNode.annotations) {
4115
- const spec = this.resolveAnnotation(a.token.text.slice(1));
4116
- const msgs = spec?.validateTargetType(resolvedType, a.token.range);
4200
+ const msgs = this.resolveAnnotation(a.token.text.slice(1))?.validateTargetType(resolvedType, a.token.range);
4117
4201
  if (msgs) this._allMessages.push(...msgs);
4118
4202
  }
4119
4203
  continue;
@@ -4145,8 +4229,7 @@ else group$1.nested.push({
4145
4229
  const length = t.parentNode.chain.length - 1;
4146
4230
  for (let i = length; i >= 0; i--) {
4147
4231
  const token = t.parentNode.chain[i];
4148
- const decl = this.unwindType(t.parentNode.id, t.parentNode.chain.slice(0, i + 1));
4149
- if (!decl?.def) this._allMessages.push({
4232
+ if (!this.unwindType(t.parentNode.id, t.parentNode.chain.slice(0, i + 1))?.def) this._allMessages.push({
4150
4233
  severity: 1,
4151
4234
  message: `Unknown member "${token.text}"`,
4152
4235
  range: token.range
@@ -4172,7 +4255,7 @@ else group$1.nested.push({
4172
4255
  * only need a yes/no resolution check use the truthiness of the result.
4173
4256
  */ resolveChainWithMerge(targetName, chain) {
4174
4257
  let def = this.unwindType(targetName)?.def;
4175
- if (!def) return undefined;
4258
+ if (!def) return;
4176
4259
  for (const prop of chain) {
4177
4260
  def = this.mergeIntersection(def);
4178
4261
  if (isProp(def)) {
@@ -4181,30 +4264,29 @@ else group$1.nested.push({
4181
4264
  }
4182
4265
  if (isStructure(def) || isInterface(def)) {
4183
4266
  const next = def.props.get(prop);
4184
- if (!next) return undefined;
4267
+ if (!next) return;
4185
4268
  def = next.getDefinition() || next;
4186
4269
  } else if (isGroup(def)) {
4187
4270
  const found = this.findPropInGroup(def, prop);
4188
- if (!found) return undefined;
4271
+ if (!found) return;
4189
4272
  def = found;
4190
- } else return undefined;
4273
+ } else return;
4191
4274
  }
4192
4275
  if (isRef(def)) def = this.unwindType(def.id, def.chain)?.def || def;
4193
4276
  return def;
4194
4277
  }
4195
- findPropInGroup(group$1, propName$1) {
4196
- for (const item of group$1.unwrap()) {
4278
+ findPropInGroup(group, propName) {
4279
+ for (const item of group.unwrap()) {
4197
4280
  const merged = this.mergeIntersection(item);
4198
4281
  if (isStructure(merged) || isInterface(merged)) {
4199
- const prop = merged.props.get(propName$1);
4282
+ const prop = merged.props.get(propName);
4200
4283
  if (prop) return prop.getDefinition() || prop;
4201
4284
  }
4202
4285
  if (isGroup(merged)) {
4203
- const found = this.findPropInGroup(merged, propName$1);
4286
+ const found = this.findPropInGroup(merged, propName);
4204
4287
  if (found) return found;
4205
4288
  }
4206
4289
  }
4207
- return undefined;
4208
4290
  }
4209
4291
  mergeIntersection(node) {
4210
4292
  if (!isGroup(node)) return node;
@@ -4223,10 +4305,8 @@ else group$1.nested.push({
4223
4305
  } else left = merged[0];
4224
4306
  }
4225
4307
  newGroup.push(left);
4226
- if (newGroup.length > 1) {
4227
- const newNode = new SemanticGroup(newGroup, "&");
4228
- return newNode;
4229
- } else return newGroup[0];
4308
+ if (newGroup.length > 1) return new SemanticGroup(newGroup, "&");
4309
+ else return newGroup[0];
4230
4310
  }
4231
4311
  mergeDefs(_left, _right) {
4232
4312
  let left = _left;
@@ -4260,7 +4340,7 @@ else group$1.nested.push({
4260
4340
  const oldProps = [leftProp, rightProp].filter(Boolean);
4261
4341
  let optionalToken = oldProps[0]?.token("optional");
4262
4342
  for (const oldProp of oldProps) if (!oldProp.token("optional")) {
4263
- optionalToken = undefined;
4343
+ optionalToken = void 0;
4264
4344
  break;
4265
4345
  }
4266
4346
  if (optionalToken) prop.saveToken(optionalToken, "optional");
@@ -4285,18 +4365,17 @@ else group$1.nested.push({
4285
4365
  * @param right - An optional array of annotation tokens to merge (higher priority).
4286
4366
  * @returns A merged array of annotation tokens, preserving order while preventing duplicates.
4287
4367
  */ mergeNodesAnnotations(left, right) {
4288
- const annotations$1 = [];
4289
- const savedAnnotations = new Set();
4368
+ const annotations = [];
4369
+ const savedAnnotations = /* @__PURE__ */ new Set();
4290
4370
  for (const a of right || []) {
4291
- annotations$1.push(a);
4371
+ annotations.push(a);
4292
4372
  savedAnnotations.add(a.name);
4293
4373
  }
4294
4374
  for (const a of left || []) {
4295
4375
  const spec = this.resolveAnnotation(a.name);
4296
- const append = spec && spec.config.multiple && spec.config.mergeStrategy === "append";
4297
- if (append || !savedAnnotations.has(a.name)) annotations$1.push(a);
4376
+ if (spec && spec.config.multiple && spec.config.mergeStrategy === "append" || !savedAnnotations.has(a.name)) annotations.push(a);
4298
4377
  }
4299
- return annotations$1;
4378
+ return annotations;
4300
4379
  }
4301
4380
  constructor(id, config, manager) {
4302
4381
  _define_property$3(this, "id", void 0);
@@ -4354,22 +4433,22 @@ else group$1.nested.push({
4354
4433
  this.messages = [];
4355
4434
  this.tokensIndex = new TokensIndex();
4356
4435
  this.blocksIndex = new BlocksIndex();
4357
- this.imports = new Map();
4358
- this.resolvedImports = new Map();
4359
- this.importedDefs = new Map();
4360
- this.exports = new Map();
4361
- this.dependencies = new Set();
4362
- this.dependants = new Set();
4436
+ this.imports = /* @__PURE__ */ new Map();
4437
+ this.resolvedImports = /* @__PURE__ */ new Map();
4438
+ this.importedDefs = /* @__PURE__ */ new Map();
4439
+ this.exports = /* @__PURE__ */ new Map();
4440
+ this.dependencies = /* @__PURE__ */ new Set();
4441
+ this.dependants = /* @__PURE__ */ new Set();
4363
4442
  this.referred = [];
4364
4443
  this.queryFieldRefs = [];
4365
- this.dependenciesMap = new Map();
4366
- this._annotationSpecCache = new Map();
4444
+ this.dependenciesMap = /* @__PURE__ */ new Map();
4445
+ this._annotationSpecCache = /* @__PURE__ */ new Map();
4367
4446
  this.nodes = [];
4368
4447
  this._text = "";
4369
4448
  this.resolvedAnnotations = [];
4370
4449
  this.annotations = [];
4371
4450
  this._nextTypeId = 0;
4372
- this._allMessages = undefined;
4451
+ this._allMessages = void 0;
4373
4452
  this.registry = new IdRegistry(Array.from(config.primitives?.keys() || []));
4374
4453
  }
4375
4454
  };
@@ -4384,13 +4463,13 @@ const zeroRange = {
4384
4463
  }
4385
4464
  };
4386
4465
  function createSyntheticRef(name) {
4387
- const ref$1 = new SemanticRefNode();
4388
- ref$1.saveToken(new Token({
4466
+ const ref = new SemanticRefNode();
4467
+ ref.saveToken(new Token({
4389
4468
  text: name,
4390
4469
  type: "identifier",
4391
4470
  getRange: () => zeroRange
4392
4471
  }), "identifier");
4393
- return ref$1;
4472
+ return ref;
4394
4473
  }
4395
4474
 
4396
4475
  //#endregion
@@ -4584,13 +4663,13 @@ const expectAnnotations = {
4584
4663
  validate(token, args, doc) {
4585
4664
  const field = token.parentNode;
4586
4665
  const errors = [];
4587
- const definition$1 = field.getDefinition();
4588
- if (!definition$1) return errors;
4666
+ const definition = field.getDefinition();
4667
+ if (!definition) return errors;
4589
4668
  let wrongType = false;
4590
- if (isRef(definition$1)) {
4591
- const def = doc.unwindType(definition$1.id, definition$1.chain)?.def;
4669
+ if (isRef(definition)) {
4670
+ const def = doc.unwindType(definition.id, definition.chain)?.def;
4592
4671
  if (!isArray(def)) wrongType = true;
4593
- } else if (!isArray(definition$1)) wrongType = true;
4672
+ } else if (!isArray(definition)) wrongType = true;
4594
4673
  if (wrongType) errors.push({
4595
4674
  message: `@expect.array.uniqueItems requires an array field`,
4596
4675
  severity: 1,
@@ -4612,17 +4691,16 @@ const expectAnnotations = {
4612
4691
  validate(token, args, doc) {
4613
4692
  const field = token.parentNode;
4614
4693
  const errors = [];
4615
- const isOptional = !!field.token("optional");
4616
- if (isOptional) errors.push({
4694
+ if (!!field.token("optional")) errors.push({
4617
4695
  message: `@expect.array.key can't be optional`,
4618
4696
  severity: 1,
4619
4697
  range: field.token("identifier").range
4620
4698
  });
4621
- const definition$1 = field.getDefinition();
4622
- if (!definition$1) return errors;
4699
+ const definition = field.getDefinition();
4700
+ if (!definition) return errors;
4623
4701
  let wrongType = false;
4624
- if (isRef(definition$1)) {
4625
- const def = doc.unwindType(definition$1.id, definition$1.chain)?.def;
4702
+ if (isRef(definition)) {
4703
+ const def = doc.unwindType(definition.id, definition.chain)?.def;
4626
4704
  if (isPrimitive(def) && !["string", "number"].includes(def.config.type)) wrongType = true;
4627
4705
  } else wrongType = true;
4628
4706
  if (wrongType) errors.push({
@@ -4716,17 +4794,15 @@ const metaAnnotations = {
4716
4794
  //#region packages/core/src/defaults/primitives.ts
4717
4795
  const IPV4_PATTERN = "^((25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)$";
4718
4796
  const IPV6_PATTERN = "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$";
4719
- const positive = {
4720
- documentation: "Number that greater than or equal to zero.",
4721
- annotations: { "expect.min": 0 }
4722
- };
4723
- const negative = {
4724
- documentation: "Number that less than or equal to zero.",
4725
- annotations: { "expect.max": 0 }
4726
- };
4727
4797
  const positiveOrNegative = {
4728
- positive,
4729
- negative
4798
+ positive: {
4799
+ documentation: "Number that greater than or equal to zero.",
4800
+ annotations: { "expect.min": 0 }
4801
+ },
4802
+ negative: {
4803
+ documentation: "Number that less than or equal to zero.",
4804
+ annotations: { "expect.max": 0 }
4805
+ }
4730
4806
  };
4731
4807
  const primitives = {
4732
4808
  never: { documentation: "Represents impossible type." },
@@ -4959,7 +5035,7 @@ const primitives = {
4959
5035
  //#endregion
4960
5036
  //#region packages/core/src/default-atscript-config.ts
4961
5037
  function getDefaultAtscriptConfig() {
4962
- const defaulTAtscriptConfig = {
5038
+ return {
4963
5039
  primitives,
4964
5040
  annotations: {
4965
5041
  meta: { ...metaAnnotations },
@@ -4967,7 +5043,6 @@ function getDefaultAtscriptConfig() {
4967
5043
  emit: { ...emitAnnotations }
4968
5044
  }
4969
5045
  };
4970
- return defaulTAtscriptConfig;
4971
5046
  }
4972
5047
 
4973
5048
  //#endregion
@@ -4979,7 +5054,7 @@ function _define_property$2(obj, key, value) {
4979
5054
  configurable: true,
4980
5055
  writable: true
4981
5056
  });
4982
- else obj[key] = value;
5057
+ else obj[key] = value;
4983
5058
  return obj;
4984
5059
  }
4985
5060
  var PluginManager = class {
@@ -4991,7 +5066,7 @@ var PluginManager = class {
4991
5066
  const raw = await this.config();
4992
5067
  this._docConfig = {};
4993
5068
  if (raw?.primitives) {
4994
- this._docConfig.primitives = new Map();
5069
+ this._docConfig.primitives = /* @__PURE__ */ new Map();
4995
5070
  for (const [key, value] of Object.entries(raw.primitives)) this._docConfig.primitives.set(key, new SemanticPrimitiveNode(key, value, "", raw.annotations));
4996
5071
  }
4997
5072
  if (raw?.annotations) this._docConfig.annotations = { ...raw.annotations };
@@ -5002,7 +5077,7 @@ var PluginManager = class {
5002
5077
  async config(config = this.cfg) {
5003
5078
  if (!this._config) {
5004
5079
  config = (0, defu.defu)(config, getDefaultAtscriptConfig());
5005
- const seen = new Set();
5080
+ const seen = /* @__PURE__ */ new Set();
5006
5081
  for (const plugin of this.plugins) {
5007
5082
  if (seen.has(plugin.name)) continue;
5008
5083
  seen.add(plugin.name);
@@ -5044,16 +5119,15 @@ var PluginManager = class {
5044
5119
  for (const plugin of this.plugins) if (plugin.buildEnd) await plugin.buildEnd(output, format, repo);
5045
5120
  }
5046
5121
  async loopInAnnotationsSpec(cb) {
5047
- const config = await this.config();
5048
- const annotations$1 = config.annotations || {};
5049
- return this._loopInAnnotationsSpec(annotations$1, cb);
5122
+ const annotations = (await this.config()).annotations || {};
5123
+ return this._loopInAnnotationsSpec(annotations, cb);
5050
5124
  }
5051
- _loopInAnnotationsSpec(annotations$1, cb, prefix) {
5052
- if (annotations$1.$self && prefix) cb(prefix, annotations$1.$self);
5053
- for (const [key, value] of Object.entries(annotations$1)) {
5125
+ _loopInAnnotationsSpec(annotations, cb, prefix) {
5126
+ if (annotations.$self && prefix) cb(prefix, annotations.$self);
5127
+ for (const [key, value] of Object.entries(annotations)) {
5054
5128
  if (key === "$self") continue;
5055
5129
  if (isAnnotationSpec(value)) cb(prefix ? `${prefix}.${key}` : key, value);
5056
- else this._loopInAnnotationsSpec(value, cb, prefix ? `${prefix}.${key}` : key);
5130
+ else this._loopInAnnotationsSpec(value, cb, prefix ? `${prefix}.${key}` : key);
5057
5131
  }
5058
5132
  }
5059
5133
  constructor(cfg) {
@@ -5075,7 +5149,7 @@ function _define_property$1(obj, key, value) {
5075
5149
  configurable: true,
5076
5150
  writable: true
5077
5151
  });
5078
- else obj[key] = value;
5152
+ else obj[key] = value;
5079
5153
  return obj;
5080
5154
  }
5081
5155
  var AtscriptRepo = class {
@@ -5084,12 +5158,12 @@ var AtscriptRepo = class {
5084
5158
  }
5085
5159
  async getPrimitivesTags() {
5086
5160
  const manager = await this.getSharedPluginManager();
5087
- if (!manager) return undefined;
5161
+ if (!manager) return;
5088
5162
  const docConfig = await manager.getDocConfig();
5089
- const primitives$1 = Array.from(docConfig.primitives?.entries() || []);
5163
+ const primitives = Array.from(docConfig.primitives?.entries() || []);
5090
5164
  const tags = [];
5091
- const processed = new Set();
5092
- for (const [, primitive] of primitives$1) tags.push(...primitive.getAllTags(processed));
5165
+ const processed = /* @__PURE__ */ new Set();
5166
+ for (const [, primitive] of primitives) tags.push(...primitive.getAllTags(processed));
5093
5167
  return new Set(tags);
5094
5168
  }
5095
5169
  async getUsedAnnotations() {
@@ -5099,7 +5173,7 @@ var AtscriptRepo = class {
5099
5173
  };
5100
5174
  const mapArgType = (t) => ANNOTATION_TYPE_MAP[t] || t;
5101
5175
  const manager = await this.getSharedPluginManager();
5102
- const annotations$1 = {};
5176
+ const annotations = {};
5103
5177
  if (manager) await manager.loopInAnnotationsSpec((name, spec) => {
5104
5178
  const types = [];
5105
5179
  const multiple = !!spec.config.multiple;
@@ -5117,62 +5191,57 @@ var AtscriptRepo = class {
5117
5191
  type: mapArgType(spec.config.argument.type),
5118
5192
  optional: spec.config.argument.optional
5119
5193
  });
5120
- else types.push({ type: "boolean" });
5121
- annotations$1[name] = {
5194
+ else types.push({ type: "boolean" });
5195
+ annotations[name] = {
5122
5196
  multiple,
5123
5197
  fromSpec: true,
5124
- typeSet: new Set(),
5198
+ typeSet: /* @__PURE__ */ new Set(),
5125
5199
  types
5126
5200
  };
5127
5201
  });
5128
5202
  for (const doc of Array.from(this.atscripts.values())) {
5129
5203
  const awaited = await doc;
5130
5204
  for (const { name, token, args } of awaited.annotations) {
5131
- if (annotations$1[name]?.fromSpec) continue;
5132
- if (!annotations$1[name]) {
5133
- const types = [];
5134
- const multiple = false;
5135
- annotations$1[name] = {
5136
- multiple,
5137
- fromSpec: false,
5138
- typeSet: new Set(),
5139
- types
5140
- };
5141
- }
5142
- const isArray$1 = token.parentNode.countAnnotations(name) > 1;
5143
- if (isArray$1) annotations$1[name].multiple = true;
5205
+ if (annotations[name]?.fromSpec) continue;
5206
+ if (!annotations[name]) annotations[name] = {
5207
+ multiple: false,
5208
+ fromSpec: false,
5209
+ typeSet: /* @__PURE__ */ new Set(),
5210
+ types: []
5211
+ };
5212
+ if (token.parentNode.countAnnotations(name) > 1) annotations[name].multiple = true;
5144
5213
  for (const arg of args) if (arg.type === "text") {
5145
- if (!annotations$1[name].typeSet.has("string")) {
5146
- annotations$1[name].typeSet.add("string");
5147
- annotations$1[name].types.push({ type: "string" });
5214
+ if (!annotations[name].typeSet.has("string")) {
5215
+ annotations[name].typeSet.add("string");
5216
+ annotations[name].types.push({ type: "string" });
5148
5217
  }
5149
5218
  } else if (arg.type === "number") {
5150
- if (!annotations$1[name].typeSet.has("number")) {
5151
- annotations$1[name].typeSet.add("number");
5152
- annotations$1[name].types.push({ type: "number" });
5219
+ if (!annotations[name].typeSet.has("number")) {
5220
+ annotations[name].typeSet.add("number");
5221
+ annotations[name].types.push({ type: "number" });
5153
5222
  }
5154
5223
  } else if (arg.type === "identifier" && ["true", "false"].includes(arg.text)) {
5155
- if (!annotations$1[name].typeSet.has("boolean")) {
5156
- annotations$1[name].typeSet.add("boolean");
5157
- annotations$1[name].types.push({ type: "boolean" });
5224
+ if (!annotations[name].typeSet.has("boolean")) {
5225
+ annotations[name].typeSet.add("boolean");
5226
+ annotations[name].types.push({ type: "boolean" });
5158
5227
  }
5159
- } else if (!annotations$1[name].typeSet.has("unknown")) {
5160
- annotations$1[name].typeSet.add("unknown");
5161
- annotations$1[name].types.push({ type: "unknown" });
5228
+ } else if (!annotations[name].typeSet.has("unknown")) {
5229
+ annotations[name].typeSet.add("unknown");
5230
+ annotations[name].types.push({ type: "unknown" });
5162
5231
  }
5163
- if (args.length === 0 && !annotations$1[name].typeSet.has("boolean")) {
5164
- annotations$1[name].typeSet.add("boolean");
5165
- annotations$1[name].types.push({ type: "boolean" });
5232
+ if (args.length === 0 && !annotations[name].typeSet.has("boolean")) {
5233
+ annotations[name].typeSet.add("boolean");
5234
+ annotations[name].types.push({ type: "boolean" });
5166
5235
  }
5167
5236
  }
5168
5237
  }
5169
- return annotations$1;
5238
+ return annotations;
5170
5239
  }
5171
5240
  async loadPluginManagerFor(id) {
5172
5241
  if (this.sharedConfig) {
5173
5242
  if (!this.sharedPluginManager) this.sharedPluginManager = {
5174
5243
  manager: new PluginManager(this.sharedConfig),
5175
- dependants: new Set()
5244
+ dependants: /* @__PURE__ */ new Set()
5176
5245
  };
5177
5246
  return this.sharedPluginManager;
5178
5247
  }
@@ -5189,14 +5258,14 @@ else types.push({ type: "boolean" });
5189
5258
  return {
5190
5259
  file: configFile,
5191
5260
  manager,
5192
- dependants: new Set()
5261
+ dependants: /* @__PURE__ */ new Set()
5193
5262
  };
5194
5263
  } else {
5195
5264
  const manager = new PluginManager({ rootDir: process.cwd() });
5196
5265
  await manager.getDocConfig();
5197
5266
  return {
5198
5267
  manager,
5199
- dependants: new Set()
5268
+ dependants: /* @__PURE__ */ new Set()
5200
5269
  };
5201
5270
  }
5202
5271
  }
@@ -5211,18 +5280,18 @@ else types.push({ type: "boolean" });
5211
5280
  }
5212
5281
  return config;
5213
5282
  }
5214
- async openDocument(id, text$2) {
5283
+ async openDocument(id, text) {
5215
5284
  let atscript = this.atscripts.get(id);
5216
5285
  if (atscript) {
5217
- if (text$2) {
5286
+ if (text) {
5218
5287
  atscript = atscript.then((d) => {
5219
- d.update(text$2);
5288
+ d.update(text);
5220
5289
  return d;
5221
5290
  });
5222
5291
  this.atscripts.set(id, atscript);
5223
5292
  }
5224
5293
  } else {
5225
- atscript = this._openDocument(id, text$2);
5294
+ atscript = this._openDocument(id, text);
5226
5295
  atscript.catch(() => {
5227
5296
  this.atscripts.delete(id);
5228
5297
  });
@@ -5230,11 +5299,11 @@ else types.push({ type: "boolean" });
5230
5299
  }
5231
5300
  return atscript;
5232
5301
  }
5233
- async _openDocument(id, text$2) {
5302
+ async _openDocument(id, text) {
5234
5303
  const { manager } = await this.resolveConfig(id);
5235
5304
  const newId = await manager.resolve(id);
5236
5305
  if (!newId) throw new Error(`Document not resolved: ${id}`);
5237
- const content = text$2 || await manager.load(newId);
5306
+ const content = text || await manager.load(newId);
5238
5307
  if (typeof content !== "string") throw new TypeError(`Document not found: ${newId}`);
5239
5308
  const atscript = new AtscriptDoc(id, await manager.getDocConfig(), manager);
5240
5309
  atscript.update(content);
@@ -5245,11 +5314,10 @@ else types.push({ type: "boolean" });
5245
5314
  await this.checkImports(atscript);
5246
5315
  }
5247
5316
  async checkImports(atscript, checked) {
5248
- const _checked = checked || new Set();
5317
+ const _checked = checked || /* @__PURE__ */ new Set();
5249
5318
  if (_checked.has(atscript.id)) return;
5250
5319
  _checked.add(atscript.id);
5251
- const promise = Promise.all(Array.from(atscript.imports.values(), async ({ from, imports }) => this.checkImport(atscript, from, imports, _checked)));
5252
- const results = await promise;
5320
+ const results = await Promise.all(Array.from(atscript.imports.values(), async ({ from, imports }) => this.checkImport(atscript, from, imports, _checked)));
5253
5321
  atscript.updateDependencies(results.filter(Boolean));
5254
5322
  }
5255
5323
  async checkImport(atscript, from, imports, checked) {
@@ -5297,7 +5365,7 @@ else types.push({ type: "boolean" });
5297
5365
  }
5298
5366
  return external;
5299
5367
  }
5300
- constructor(root$1 = process.cwd(), sharedConfig) {
5368
+ constructor(root = process.cwd(), sharedConfig) {
5301
5369
  _define_property$1(this, "root", void 0);
5302
5370
  _define_property$1(this, "sharedConfig", void 0);
5303
5371
  _define_property$1(this, "configFormat", void 0);
@@ -5314,18 +5382,35 @@ else types.push({ type: "boolean" });
5314
5382
  /**
5315
5383
  * cache for raw content of config files
5316
5384
  */ _define_property$1(this, "configFiles", void 0);
5317
- this.root = root$1;
5385
+ this.root = root;
5318
5386
  this.sharedConfig = sharedConfig;
5319
- this.configs = new Map();
5320
- this.atscripts = new Map();
5321
- this.resolvedToBare = new Map();
5322
- this.configFiles = new Map();
5387
+ this.configs = /* @__PURE__ */ new Map();
5388
+ this.atscripts = /* @__PURE__ */ new Map();
5389
+ this.resolvedToBare = /* @__PURE__ */ new Map();
5390
+ this.configFiles = /* @__PURE__ */ new Map();
5323
5391
  }
5324
5392
  };
5325
5393
 
5326
5394
  //#endregion
5327
5395
  //#region packages/core/src/plugin/types.ts
5328
- const DEFAULT_FORMAT = "__default__";
5396
+ /**
5397
+ * Well-known render format for a plugin's primary output.
5398
+ *
5399
+ * When a `.as` file is saved in an editor (VSCode, etc.), the editor
5400
+ * passes this format to `render()` and `buildEnd()`. Plugins should
5401
+ * check for this value alongside their own format strings to produce
5402
+ * output that is essential for the development experience — typically
5403
+ * type declarations for the host language.
5404
+ *
5405
+ * @example
5406
+ * ```ts
5407
+ * render(doc, format) {
5408
+ * if (format === 'dts' || format === DEFAULT_FORMAT) {
5409
+ * return [{ fileName: `${doc.name}.d.ts`, content: renderTypes(doc) }]
5410
+ * }
5411
+ * }
5412
+ * ```
5413
+ */ const DEFAULT_FORMAT = "__default__";
5329
5414
  const createAtscriptPlugin = (plugin) => plugin;
5330
5415
 
5331
5416
  //#endregion
@@ -5337,7 +5422,7 @@ function _define_property(obj, key, value) {
5337
5422
  configurable: true,
5338
5423
  writable: true
5339
5424
  });
5340
- else obj[key] = value;
5425
+ else obj[key] = value;
5341
5426
  return obj;
5342
5427
  }
5343
5428
  async function build(config) {
@@ -5346,13 +5431,11 @@ async function build(config) {
5346
5431
  const repo = new AtscriptRepo(rootDir, config);
5347
5432
  const entries = [];
5348
5433
  if (config.entries && config.entries.length > 0) for (const entry of config.entries) entries.push(path.default.join(rootDir, entry));
5349
- else {
5350
- const includes = config.include && config.include.length > 0 ? config.include : ["**/*.as"];
5351
- const excludes = config.exclude && config.exclude.length > 0 ? config.exclude : ["node_modules"];
5352
- const found = await (0, glob.glob)(includes, {
5434
+ else {
5435
+ const found = await (0, glob.glob)(config.include && config.include.length > 0 ? config.include : ["**/*.as"], {
5353
5436
  cwd: rootDir,
5354
5437
  absolute: true,
5355
- ignore: excludes
5438
+ ignore: config.exclude && config.exclude.length > 0 ? config.exclude : ["node_modules"]
5356
5439
  });
5357
5440
  entries.push(...found);
5358
5441
  }
@@ -5367,7 +5450,7 @@ var BuildRepo = class {
5367
5450
  return this.docs.find((d) => d.id === id);
5368
5451
  }
5369
5452
  async diagnostics() {
5370
- const docMessages = new Map();
5453
+ const docMessages = /* @__PURE__ */ new Map();
5371
5454
  for (const document of this.docs) docMessages.set(document.id, document.getDiagMessages());
5372
5455
  return docMessages;
5373
5456
  }
@@ -5391,11 +5474,18 @@ var BuildRepo = class {
5391
5474
  }
5392
5475
  return outFiles;
5393
5476
  }
5394
- async write(config, docs = this.docs) {
5477
+ /**
5478
+ * Renders every document and writes the outputs to disk.
5479
+ *
5480
+ * Each write is awaited and atomic (temp file + rename), because a consumer
5481
+ * watching the output — a dev server, a type checker, another build — must
5482
+ * never observe a half-written file, and an un-awaited write can be
5483
+ * truncated when the process exits.
5484
+ */ async write(config, docs = this.docs) {
5395
5485
  const outFiles = await this.generate(config, docs);
5396
5486
  for (const o of outFiles) if (o.target) {
5397
5487
  await (0, fs_promises.mkdir)(path.default.dirname(o.target), { recursive: true });
5398
- (0, fs_promises.writeFile)(o.target, o.content);
5488
+ await writeFileAtomic(o.target, o.content);
5399
5489
  }
5400
5490
  return outFiles;
5401
5491
  }
@@ -5408,12 +5498,49 @@ var BuildRepo = class {
5408
5498
  this.docs = docs;
5409
5499
  }
5410
5500
  };
5501
+ let tmpSeq = 0;
5502
+ /**
5503
+ * Writes `content` to a sibling temp file and renames it over `target`, so the
5504
+ * target is either the old file or the new one — never a partial write.
5505
+ * The temp file is removed if anything goes wrong.
5506
+ */ async function writeFileAtomic(target, content) {
5507
+ const tmp = `${target}.${process.pid}.${tmpSeq++}.tmp`;
5508
+ try {
5509
+ await (0, fs_promises.writeFile)(tmp, content);
5510
+ await (0, fs_promises.rename)(tmp, target);
5511
+ } catch (error) {
5512
+ try {
5513
+ await (0, fs_promises.rm)(tmp, { force: true });
5514
+ } catch {}
5515
+ throw error;
5516
+ }
5517
+ }
5411
5518
 
5412
5519
  //#endregion
5413
5520
  //#region packages/core/src/flatten.ts
5414
- function flattenInterfaceNode(doc, node, options) {
5415
- const flatMap = new Map();
5416
- const stack = new Set();
5521
+ /**
5522
+ * Flattens an interface node into a map of dot-notation paths to their type descriptors.
5523
+ *
5524
+ * This utility exists to improve type-safety for filter expressions and `$select`/`$sort`
5525
+ * operations in the DB layer. The generated `__flat` static property on `@db.table`
5526
+ * interfaces uses this map to provide autocomplete and compile-time checks for
5527
+ * dot-notation query paths.
5528
+ *
5529
+ * Walks the interface structure (including inherited props from `extends`) and collects
5530
+ * all reachable field paths. Nested objects are recursed into, arrays are recursed through
5531
+ * their element types, and unions/intersections are recursed through each branch (with
5532
+ * colliding paths merged into union groups).
5533
+ *
5534
+ * Fields annotated with `@db.json` are treated as leaves — their sub-paths are NOT included,
5535
+ * because `@db.json` fields are stored as a single JSON column in the database and their
5536
+ * sub-paths are not individually queryable.
5537
+ *
5538
+ * @param doc - The document owning the interface node.
5539
+ * @param node - The interface node to flatten.
5540
+ * @returns A map of dot-separated paths to their field descriptors.
5541
+ */ function flattenInterfaceNode(doc, node, options) {
5542
+ const flatMap = /* @__PURE__ */ new Map();
5543
+ const stack = /* @__PURE__ */ new Set();
5417
5544
  let struct;
5418
5545
  if (node.hasExtends) struct = doc.resolveInterfaceExtends(node);
5419
5546
  if (!struct) struct = node.getDefinition();
@@ -5448,10 +5575,10 @@ function isPhantomNode(doc, def) {
5448
5575
  }
5449
5576
  function resolveNode(doc, def) {
5450
5577
  if (isRef(def)) {
5451
- const ref$1 = def;
5452
- const unwound = doc.unwindType(ref$1.id, ref$1.chain);
5578
+ const ref = def;
5579
+ const unwound = doc.unwindType(ref.id, ref.chain);
5453
5580
  if (unwound?.def) return resolveNode(unwound.doc, unwound.def);
5454
- return undefined;
5581
+ return;
5455
5582
  }
5456
5583
  if (isInterface(def)) {
5457
5584
  const iface = def;
@@ -5462,7 +5589,7 @@ function resolveNode(doc, def) {
5462
5589
  def: struct,
5463
5590
  doc
5464
5591
  };
5465
- return undefined;
5592
+ return;
5466
5593
  }
5467
5594
  return {
5468
5595
  def,
@@ -5472,18 +5599,18 @@ function resolveNode(doc, def) {
5472
5599
  function isComplexNode(def) {
5473
5600
  return isStructure(def) || isArray(def) || isGroup(def) && def.entity !== "tuple";
5474
5601
  }
5475
- function addToFlatMap(flatMap, path$6, descriptor) {
5476
- const existing = flatMap.get(path$6);
5602
+ function addToFlatMap(flatMap, path, descriptor) {
5603
+ const existing = flatMap.get(path);
5477
5604
  if (existing) {
5478
- const group$1 = new SemanticGroup([existing.def, descriptor.def], "|");
5479
- flatMap.set(path$6, {
5480
- def: group$1,
5605
+ const group = new SemanticGroup([existing.def, descriptor.def], "|");
5606
+ flatMap.set(path, {
5607
+ def: group,
5481
5608
  doc: existing.doc,
5482
5609
  optional: existing.optional || descriptor.optional,
5483
5610
  propNode: existing.propNode,
5484
- intermediate: existing.intermediate && descriptor.intermediate ? true : undefined
5611
+ intermediate: existing.intermediate && descriptor.intermediate ? true : void 0
5485
5612
  });
5486
- } else flatMap.set(path$6, descriptor);
5613
+ } else flatMap.set(path, descriptor);
5487
5614
  }
5488
5615
  function walkStructure(doc, struct, prefix, parentOptional, flatMap, stack, options) {
5489
5616
  for (const [name, prop] of struct.props) {
@@ -5491,11 +5618,11 @@ function walkStructure(doc, struct, prefix, parentOptional, flatMap, stack, opti
5491
5618
  const propDef = prop.getDefinition();
5492
5619
  if (isPhantomNode(doc, propDef)) continue;
5493
5620
  if (options?.skipNavProps && hasNavPropAnnotation(prop)) continue;
5494
- const path$6 = prefix ? `${prefix}.${name}` : name;
5621
+ const path = prefix ? `${prefix}.${name}` : name;
5495
5622
  const optional = parentOptional || !!prop.token("optional");
5496
5623
  const dbJson = hasDbJsonAnnotation(prop);
5497
5624
  if (!propDef) {
5498
- addToFlatMap(flatMap, path$6, {
5625
+ addToFlatMap(flatMap, path, {
5499
5626
  def: prop,
5500
5627
  doc,
5501
5628
  optional,
@@ -5505,7 +5632,7 @@ function walkStructure(doc, struct, prefix, parentOptional, flatMap, stack, opti
5505
5632
  }
5506
5633
  const resolved = resolveNode(doc, propDef);
5507
5634
  if (!resolved) {
5508
- addToFlatMap(flatMap, path$6, {
5635
+ addToFlatMap(flatMap, path, {
5509
5636
  def: propDef,
5510
5637
  doc,
5511
5638
  optional,
@@ -5514,7 +5641,7 @@ function walkStructure(doc, struct, prefix, parentOptional, flatMap, stack, opti
5514
5641
  continue;
5515
5642
  }
5516
5643
  if (dbJson) {
5517
- addToFlatMap(flatMap, path$6, {
5644
+ addToFlatMap(flatMap, path, {
5518
5645
  def: resolved.def,
5519
5646
  doc: resolved.doc,
5520
5647
  optional,
@@ -5523,12 +5650,12 @@ function walkStructure(doc, struct, prefix, parentOptional, flatMap, stack, opti
5523
5650
  });
5524
5651
  continue;
5525
5652
  }
5526
- walkNode(resolved.doc, resolved.def, path$6, optional, prop, flatMap, stack, options);
5653
+ walkNode(resolved.doc, resolved.def, path, optional, prop, flatMap, stack, options);
5527
5654
  }
5528
5655
  }
5529
- function walkNode(doc, def, path$6, optional, propNode, flatMap, stack, options) {
5656
+ function walkNode(doc, def, path, optional, propNode, flatMap, stack, options) {
5530
5657
  if (stack.has(def)) {
5531
- addToFlatMap(flatMap, path$6, {
5658
+ addToFlatMap(flatMap, path, {
5532
5659
  def,
5533
5660
  doc,
5534
5661
  optional,
@@ -5539,69 +5666,68 @@ function walkNode(doc, def, path$6, optional, propNode, flatMap, stack, options)
5539
5666
  stack.add(def);
5540
5667
  try {
5541
5668
  if (isStructure(def)) {
5542
- addToFlatMap(flatMap, path$6, {
5669
+ addToFlatMap(flatMap, path, {
5543
5670
  def,
5544
5671
  doc,
5545
5672
  optional,
5546
5673
  propNode,
5547
5674
  intermediate: true
5548
5675
  });
5549
- walkStructure(doc, def, path$6, optional, flatMap, stack, options);
5676
+ walkStructure(doc, def, path, optional, flatMap, stack, options);
5550
5677
  } else if (isArray(def)) {
5551
5678
  const elementDef = def.getDefinition();
5552
- const resolvedElement = elementDef ? resolveNode(doc, elementDef) : undefined;
5553
- const isComplexElement = resolvedElement && (isStructure(resolvedElement.def) || isGroup(resolvedElement.def) && resolvedElement.def.entity !== "tuple" || isArray(resolvedElement.def));
5554
- if (isComplexElement) {
5555
- addToFlatMap(flatMap, path$6, {
5679
+ const resolvedElement = elementDef ? resolveNode(doc, elementDef) : void 0;
5680
+ if (resolvedElement && (isStructure(resolvedElement.def) || isGroup(resolvedElement.def) && resolvedElement.def.entity !== "tuple" || isArray(resolvedElement.def))) {
5681
+ addToFlatMap(flatMap, path, {
5556
5682
  def,
5557
5683
  doc,
5558
5684
  optional,
5559
5685
  propNode,
5560
5686
  intermediate: true
5561
5687
  });
5562
- walkArrayElement(doc, def, path$6, optional, flatMap, stack, options);
5563
- } else addToFlatMap(flatMap, path$6, {
5688
+ walkArrayElement(doc, def, path, optional, flatMap, stack, options);
5689
+ } else addToFlatMap(flatMap, path, {
5564
5690
  def,
5565
5691
  doc,
5566
5692
  optional,
5567
5693
  propNode
5568
5694
  });
5569
5695
  } else if (isGroup(def) && def.entity !== "structure") {
5570
- const group$1 = def;
5571
- if (group$1.op === "&") {
5696
+ const group = def;
5697
+ if (group.op === "&") {
5572
5698
  const merged = doc.mergeIntersection(def);
5573
5699
  if (merged !== def && isStructure(merged)) {
5574
- addToFlatMap(flatMap, path$6, {
5700
+ addToFlatMap(flatMap, path, {
5575
5701
  def: merged,
5576
5702
  doc,
5577
5703
  optional,
5578
5704
  propNode,
5579
5705
  intermediate: true
5580
5706
  });
5581
- walkStructure(doc, merged, path$6, optional, flatMap, stack, options);
5582
- } else addToFlatMap(flatMap, path$6, {
5707
+ walkStructure(doc, merged, path, optional, flatMap, stack, options);
5708
+ } else addToFlatMap(flatMap, path, {
5583
5709
  def,
5584
5710
  doc,
5585
5711
  optional,
5586
5712
  propNode
5587
5713
  });
5588
- } else if (group$1.op === "|") {
5589
- const branches = group$1.unwrap();
5714
+ } else if (group.op === "|") {
5715
+ const branches = group.unwrap();
5590
5716
  let hasComplexBranch = false;
5591
5717
  let hasLeafBranch = false;
5592
5718
  for (const branch of branches) {
5593
5719
  const resolved = resolveNode(doc, branch);
5594
5720
  if (resolved && isComplexNode(resolved.def)) hasComplexBranch = true;
5595
- else hasLeafBranch = true;
5721
+ else hasLeafBranch = true;
5596
5722
  }
5597
5723
  if (hasComplexBranch) {
5598
- if (hasLeafBranch) addToFlatMap(flatMap, path$6, {
5724
+ if (hasLeafBranch) addToFlatMap(flatMap, path, {
5599
5725
  def,
5600
5726
  doc,
5601
5727
  optional,
5602
5728
  propNode
5603
5729
  });
5604
- else addToFlatMap(flatMap, path$6, {
5730
+ else addToFlatMap(flatMap, path, {
5605
5731
  def,
5606
5732
  doc,
5607
5733
  optional,
@@ -5610,21 +5736,21 @@ else addToFlatMap(flatMap, path$6, {
5610
5736
  });
5611
5737
  for (const branch of branches) {
5612
5738
  const resolved = resolveNode(doc, branch);
5613
- if (resolved) walkBranch(resolved.doc, resolved.def, path$6, optional, flatMap, stack, options);
5739
+ if (resolved) walkBranch(resolved.doc, resolved.def, path, optional, flatMap, stack, options);
5614
5740
  }
5615
- } else addToFlatMap(flatMap, path$6, {
5741
+ } else addToFlatMap(flatMap, path, {
5616
5742
  def,
5617
5743
  doc,
5618
5744
  optional,
5619
5745
  propNode
5620
5746
  });
5621
- } else addToFlatMap(flatMap, path$6, {
5747
+ } else addToFlatMap(flatMap, path, {
5622
5748
  def,
5623
5749
  doc,
5624
5750
  optional,
5625
5751
  propNode
5626
5752
  });
5627
- } else addToFlatMap(flatMap, path$6, {
5753
+ } else addToFlatMap(flatMap, path, {
5628
5754
  def,
5629
5755
  doc,
5630
5756
  optional,
@@ -5646,13 +5772,13 @@ function walkArrayElement(doc, arrayNode, prefix, parentOptional, flatMap, stack
5646
5772
  * Does NOT add an entry for the branch itself — the parent already did that.
5647
5773
  */ function walkBranch(doc, def, prefix, parentOptional, flatMap, stack, options) {
5648
5774
  if (isStructure(def)) walkStructure(doc, def, prefix, parentOptional, flatMap, stack, options);
5649
- else if (isArray(def)) walkArrayElement(doc, def, prefix, parentOptional, flatMap, stack, options);
5650
- else if (isGroup(def) && def.entity !== "structure") {
5651
- const group$1 = def;
5652
- if (group$1.op === "&") {
5775
+ else if (isArray(def)) walkArrayElement(doc, def, prefix, parentOptional, flatMap, stack, options);
5776
+ else if (isGroup(def) && def.entity !== "structure") {
5777
+ const group = def;
5778
+ if (group.op === "&") {
5653
5779
  const merged = doc.mergeIntersection(def);
5654
5780
  if (isStructure(merged)) walkStructure(doc, merged, prefix, parentOptional, flatMap, stack, options);
5655
- } else if (group$1.op === "|") for (const branch of group$1.unwrap()) {
5781
+ } else if (group.op === "|") for (const branch of group.unwrap()) {
5656
5782
  const resolved = resolveNode(doc, branch);
5657
5783
  if (resolved) walkBranch(resolved.doc, resolved.def, prefix, parentOptional, flatMap, stack, options);
5658
5784
  }
@@ -5660,69 +5786,69 @@ else if (isGroup(def) && def.entity !== "structure") {
5660
5786
  }
5661
5787
 
5662
5788
  //#endregion
5663
- exports.$n = $n
5664
- exports.AnnotationSpec = AnnotationSpec
5665
- exports.AtscriptDoc = AtscriptDoc
5666
- exports.AtscriptRepo = AtscriptRepo
5667
- exports.BuildRepo = BuildRepo
5668
- exports.DEFAULT_FORMAT = DEFAULT_FORMAT
5669
- exports.PluginManager = PluginManager
5670
- exports.SemanticAnnotateNode = SemanticAnnotateNode
5671
- exports.SemanticArrayNode = SemanticArrayNode
5672
- exports.SemanticConstNode = SemanticConstNode
5673
- exports.SemanticGroup = SemanticGroup
5674
- exports.SemanticImportNode = SemanticImportNode
5675
- exports.SemanticInterfaceNode = SemanticInterfaceNode
5676
- exports.SemanticNode = SemanticNode
5677
- exports.SemanticPrimitiveNode = SemanticPrimitiveNode
5678
- exports.SemanticPropNode = SemanticPropNode
5679
- exports.SemanticQueryComparisonNode = SemanticQueryComparisonNode
5680
- exports.SemanticQueryFieldRefNode = SemanticQueryFieldRefNode
5681
- exports.SemanticQueryLogicalNode = SemanticQueryLogicalNode
5682
- exports.SemanticQueryNode = SemanticQueryNode
5683
- exports.SemanticQueryValueListNode = SemanticQueryValueListNode
5684
- exports.SemanticQueryValueNode = SemanticQueryValueNode
5685
- exports.SemanticRefNode = SemanticRefNode
5686
- exports.SemanticStructureNode = SemanticStructureNode
5687
- exports.SemanticTupleNode = SemanticTupleNode
5688
- exports.SemanticTypeNode = SemanticTypeNode
5689
- exports.Token = Token
5690
- exports.analyzeQueryCursorContext = analyzeQueryCursorContext
5691
- exports.build = build
5692
- exports.clearResolveBareCache = clearResolveBareCache
5693
- exports.createAtscriptPlugin = createAtscriptPlugin
5694
- exports.defineConfig = defineConfig
5695
- exports.fileUriToPath = fileUriToPath
5696
- exports.flattenInterfaceNode = flattenInterfaceNode
5697
- exports.getFieldsForType = getFieldsForType
5698
- exports.getQueryCompletionScope = getQueryCompletionScope
5699
- exports.getQueryScope = getQueryScope
5700
- exports.getRelPath = getRelPath
5701
- exports.hasNavPropAnnotation = hasNavPropAnnotation
5702
- exports.isAnnotate = isAnnotate
5703
- exports.isAnnotationSpec = isAnnotationSpec
5704
- exports.isArray = isArray
5705
- exports.isBareId = isBareId
5706
- exports.isBareSpecifier = isBareSpecifier
5707
- exports.isConst = isConst
5708
- exports.isGroup = isGroup
5709
- exports.isImport = isImport
5710
- exports.isInterface = isInterface
5711
- exports.isPhantomNode = isPhantomNode
5712
- exports.isPrimitive = isPrimitive
5713
- exports.isProp = isProp
5714
- exports.isQueryComparison = isQueryComparison
5715
- exports.isQueryFieldRef = isQueryFieldRef
5716
- exports.isQueryLogical = isQueryLogical
5717
- exports.isRef = isRef
5718
- exports.isStructure = isStructure
5719
- exports.isTuple = isTuple
5720
- exports.isType = isType
5721
- exports.loadConfig = loadConfig
5722
- exports.loadTsConfig = loadTsConfig
5723
- exports.parseBareSpecifier = parseBareSpecifier
5724
- exports.resolveAnnotation = resolveAnnotation
5725
- exports.resolveAtscriptFromPath = resolveAtscriptFromPath
5726
- exports.resolveBareSpecifier = resolveBareSpecifier
5727
- exports.resolveConfigFile = resolveConfigFile
5728
- exports.resolveQueryFieldRef = resolveQueryFieldRef
5789
+ exports.$n = $n;
5790
+ exports.AnnotationSpec = AnnotationSpec;
5791
+ exports.AtscriptDoc = AtscriptDoc;
5792
+ exports.AtscriptRepo = AtscriptRepo;
5793
+ exports.BuildRepo = BuildRepo;
5794
+ exports.DEFAULT_FORMAT = DEFAULT_FORMAT;
5795
+ exports.PluginManager = PluginManager;
5796
+ exports.SemanticAnnotateNode = SemanticAnnotateNode;
5797
+ exports.SemanticArrayNode = SemanticArrayNode;
5798
+ exports.SemanticConstNode = SemanticConstNode;
5799
+ exports.SemanticGroup = SemanticGroup;
5800
+ exports.SemanticImportNode = SemanticImportNode;
5801
+ exports.SemanticInterfaceNode = SemanticInterfaceNode;
5802
+ exports.SemanticNode = SemanticNode;
5803
+ exports.SemanticPrimitiveNode = SemanticPrimitiveNode;
5804
+ exports.SemanticPropNode = SemanticPropNode;
5805
+ exports.SemanticQueryComparisonNode = SemanticQueryComparisonNode;
5806
+ exports.SemanticQueryFieldRefNode = SemanticQueryFieldRefNode;
5807
+ exports.SemanticQueryLogicalNode = SemanticQueryLogicalNode;
5808
+ exports.SemanticQueryNode = SemanticQueryNode;
5809
+ exports.SemanticQueryValueListNode = SemanticQueryValueListNode;
5810
+ exports.SemanticQueryValueNode = SemanticQueryValueNode;
5811
+ exports.SemanticRefNode = SemanticRefNode;
5812
+ exports.SemanticStructureNode = SemanticStructureNode;
5813
+ exports.SemanticTupleNode = SemanticTupleNode;
5814
+ exports.SemanticTypeNode = SemanticTypeNode;
5815
+ exports.Token = Token;
5816
+ exports.analyzeQueryCursorContext = analyzeQueryCursorContext;
5817
+ exports.build = build;
5818
+ exports.clearResolveBareCache = clearResolveBareCache;
5819
+ exports.createAtscriptPlugin = createAtscriptPlugin;
5820
+ exports.defineConfig = defineConfig;
5821
+ exports.fileUriToPath = fileUriToPath;
5822
+ exports.flattenInterfaceNode = flattenInterfaceNode;
5823
+ exports.getFieldsForType = getFieldsForType;
5824
+ exports.getQueryCompletionScope = getQueryCompletionScope;
5825
+ exports.getQueryScope = getQueryScope;
5826
+ exports.getRelPath = getRelPath;
5827
+ exports.hasNavPropAnnotation = hasNavPropAnnotation;
5828
+ exports.isAnnotate = isAnnotate;
5829
+ exports.isAnnotationSpec = isAnnotationSpec;
5830
+ exports.isArray = isArray;
5831
+ exports.isBareId = isBareId;
5832
+ exports.isBareSpecifier = isBareSpecifier;
5833
+ exports.isConst = isConst;
5834
+ exports.isGroup = isGroup;
5835
+ exports.isImport = isImport;
5836
+ exports.isInterface = isInterface;
5837
+ exports.isPhantomNode = isPhantomNode;
5838
+ exports.isPrimitive = isPrimitive;
5839
+ exports.isProp = isProp;
5840
+ exports.isQueryComparison = isQueryComparison;
5841
+ exports.isQueryFieldRef = isQueryFieldRef;
5842
+ exports.isQueryLogical = isQueryLogical;
5843
+ exports.isRef = isRef;
5844
+ exports.isStructure = isStructure;
5845
+ exports.isTuple = isTuple;
5846
+ exports.isType = isType;
5847
+ exports.loadConfig = loadConfig;
5848
+ exports.loadTsConfig = loadTsConfig;
5849
+ exports.parseBareSpecifier = parseBareSpecifier;
5850
+ exports.resolveAnnotation = resolveAnnotation;
5851
+ exports.resolveAtscriptFromPath = resolveAtscriptFromPath;
5852
+ exports.resolveBareSpecifier = resolveBareSpecifier;
5853
+ exports.resolveConfigFile = resolveConfigFile;
5854
+ exports.resolveQueryFieldRef = resolveQueryFieldRef;