@noego/trust 0.5.0-dev.0 → 0.5.0-dev.2

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.
Files changed (142) hide show
  1. package/README.md +49 -9
  2. package/dist/{baseline-B0AplCuF.d.ts → baseline-Bkav9mS0.d.ts} +22 -4
  3. package/dist/{chunk-V72KWVWP.js → chunk-7PY2Q6OX.js} +212 -16
  4. package/dist/chunk-7PY2Q6OX.js.map +1 -0
  5. package/dist/{chunk-NG4KYWVW.js → chunk-UG6D3V4M.js} +877 -41
  6. package/dist/chunk-UG6D3V4M.js.map +1 -0
  7. package/dist/{chunk-OSSITT3R.js → chunk-XXLWC5DB.js} +17 -61
  8. package/dist/chunk-XXLWC5DB.js.map +1 -0
  9. package/dist/cli/index.js +341 -92
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/cli/wasm-worker.js +257 -0
  12. package/dist/cli/wasm-worker.js.map +1 -0
  13. package/dist/core/index.d.ts +5 -3
  14. package/dist/core/index.js +7 -7
  15. package/dist/eslint/index.d.ts +6 -2
  16. package/dist/eslint/index.js +2 -2
  17. package/dist/licenses/@jridgewell__resolve-uri/LICENSE +19 -0
  18. package/dist/licenses/@jridgewell__sourcemap-codec/LICENSE +19 -0
  19. package/dist/licenses/@jridgewell__trace-mapping/LICENSE +19 -0
  20. package/dist/licenses/JS-DEPENDENCIES.json +83 -0
  21. package/dist/licenses/balanced-match/LICENSE.md +23 -0
  22. package/dist/licenses/brace-expansion/LICENSE +23 -0
  23. package/dist/licenses/dedent-js/LICENSE +19 -0
  24. package/dist/licenses/minimatch/LICENSE.md +55 -0
  25. package/dist/licenses/scule/LICENSE +21 -0
  26. package/dist/licenses/svelte2tsx/LICENSE +21 -0
  27. package/dist/native/licenses/CARGO-DEPENDENCIES.json +479 -0
  28. package/dist/native/licenses/LICENSE-trust.txt +15 -0
  29. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-0BSD +12 -0
  30. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-APACHE +201 -0
  31. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-MIT +23 -0
  32. package/dist/native/licenses/cargo/aho-corasick-1.1.5/COPYING +3 -0
  33. package/dist/native/licenses/cargo/aho-corasick-1.1.5/LICENSE-MIT +21 -0
  34. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-APACHE +201 -0
  35. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-MIT +25 -0
  36. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-APACHE +201 -0
  37. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-MIT +25 -0
  38. package/dist/native/licenses/cargo/bstr-1.13.1/COPYING +8 -0
  39. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-APACHE +201 -0
  40. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-MIT +21 -0
  41. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  42. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-MIT +25 -0
  43. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  44. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-MIT +25 -0
  45. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-APACHE +202 -0
  46. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-MIT +21 -0
  47. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-APACHE +201 -0
  48. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-MIT +25 -0
  49. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
  50. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-MIT +25 -0
  51. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-APACHE +201 -0
  52. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-MIT +25 -0
  53. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-APACHE +201 -0
  54. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-MIT +25 -0
  55. package/dist/native/licenses/cargo/globset-0.4.20/COPYING +3 -0
  56. package/dist/native/licenses/cargo/globset-0.4.20/LICENSE-MIT +21 -0
  57. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  58. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-MIT +25 -0
  59. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-APACHE +201 -0
  60. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-MIT +25 -0
  61. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-APACHE +176 -0
  62. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-MIT +23 -0
  63. package/dist/native/licenses/cargo/jiff-0.2.37/COPYING +3 -0
  64. package/dist/native/licenses/cargo/jiff-0.2.37/LICENSE-MIT +21 -0
  65. package/dist/native/licenses/cargo/jiff-core-0.1.1/COPYING +3 -0
  66. package/dist/native/licenses/cargo/jiff-core-0.1.1/LICENSE-MIT +21 -0
  67. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/COPYING +3 -0
  68. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/LICENSE-MIT +21 -0
  69. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/COPYING +3 -0
  70. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
  71. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-APACHE +201 -0
  72. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-MIT +25 -0
  73. package/dist/native/licenses/cargo/lzma-rust2-0.21.0/LICENSE +201 -0
  74. package/dist/native/licenses/cargo/memchr-2.8.2/COPYING +3 -0
  75. package/dist/native/licenses/cargo/memchr-2.8.2/LICENSE-MIT +21 -0
  76. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE +25 -0
  77. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-APACHE.md +177 -0
  78. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-MIT.md +24 -0
  79. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-ZLIB.md +14 -0
  80. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-APACHE +201 -0
  81. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-MIT +25 -0
  82. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-APACHE +201 -0
  83. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-MIT +25 -0
  84. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-APACHE +201 -0
  85. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-MIT +25 -0
  86. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  87. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  88. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-APACHE +176 -0
  89. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-MIT +23 -0
  90. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-APACHE +201 -0
  91. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-MIT +25 -0
  92. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
  93. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-MIT +25 -0
  94. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-APACHE +176 -0
  95. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-MIT +23 -0
  96. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-APACHE +176 -0
  97. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-BOOST +23 -0
  98. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-APACHE +176 -0
  99. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-MIT +23 -0
  100. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-APACHE +176 -0
  101. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-MIT +23 -0
  102. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  103. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-MIT +23 -0
  104. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-APACHE +176 -0
  105. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-MIT +23 -0
  106. package/dist/native/licenses/cargo/simd-adler32-0.3.10/LICENSE.md +21 -0
  107. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-APACHE +201 -0
  108. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-MIT +25 -0
  109. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-APACHE +176 -0
  110. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-MIT +23 -0
  111. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-APACHE +176 -0
  112. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-MIT +23 -0
  113. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-APACHE +176 -0
  114. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-MIT +23 -0
  115. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
  116. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
  117. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
  118. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-MIT +23 -0
  119. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
  120. package/dist/native/licenses/cargo/xxhash-rust-0.8.15/LICENSE +23 -0
  121. package/dist/native/licenses/cargo/zlib-rs-0.6.8/LICENSE +19 -0
  122. package/dist/native/licenses/cargo/zmij-1.0.23/LICENSE-MIT +23 -0
  123. package/dist/native/licenses/ts-rust/LICENSE +21 -0
  124. package/dist/native/licenses/ts-rust/NOTICE.md +53 -0
  125. package/dist/native/licenses/ts-rust/licenses/Go-LICENSE.txt +27 -0
  126. package/dist/native/licenses/ts-rust/licenses/TypeScript-LICENSE.txt +55 -0
  127. package/dist/native/licenses/ts-rust/licenses/TypeScript-NOTICE.txt +405 -0
  128. package/dist/native/licenses/ts-rust/licenses/Unicode-LICENSE.txt +39 -0
  129. package/dist/native/licenses/ts-rust/licenses/vscode-languageserver-node-LICENSE.txt +18 -0
  130. package/dist/native/licenses/typescript/LICENSE.txt +55 -0
  131. package/dist/native/licenses/typescript/ThirdPartyNoticeText.txt +193 -0
  132. package/dist/native/licenses/typescript/manifest.json +105 -0
  133. package/dist/native/trust_native_wasm.wasm +0 -0
  134. package/dist/svelte2tsx/index.cjs +7064 -0
  135. package/dist/svelte2tsx/svelte-jsx-v4.d.ts +230 -0
  136. package/dist/svelte2tsx/svelte-jsx.d.ts +1492 -0
  137. package/dist/svelte2tsx/svelte-shims-v4.d.ts +290 -0
  138. package/dist/svelte2tsx/svelte-shims.d.ts +305 -0
  139. package/package.json +25 -5
  140. package/dist/chunk-NG4KYWVW.js.map +0 -1
  141. package/dist/chunk-OSSITT3R.js.map +0 -1
  142. package/dist/chunk-V72KWVWP.js.map +0 -1
@@ -3349,7 +3349,7 @@ var DEFAULT_PRESET = {
3349
3349
  extend: "node"
3350
3350
  };
3351
3351
  var SVELTE_PRESET = {
3352
- $comment: 'Svelte 5 runes, svelte.tick, svelte/store and the Map/Set/Date classes of svelte/reactivity. An add-on: combine it with a runtime preset, e.g. "extend": ["web", "svelte"]. Deliberately NOT trusted: svelte/reactivity.SvelteURL and SvelteURLSearchParams (their constructors throw like js:URL and js:URLSearchParams), svelte.mount/hydrate, and the rest of the svelte module. Type trust covers only the runes that hand back the value they are given; $props is declared `any` and is left to type-claim.',
3352
+ $comment: 'Svelte 5 runes, svelte.tick, svelte/store and the Map/Set/Date classes of svelte/reactivity. An add-on: combine it with a runtime preset, e.g. "extend": ["web", "svelte"]. Deliberately NOT trusted: svelte/reactivity.SvelteURL and SvelteURLSearchParams (their constructors throw like js:URL and js:URLSearchParams), svelte.createContext (including its setter), fork, hydratable, mount/hydrate/unmount, motion and transition.draw. Type trust covers only the runes that hand back the value they are given; $props is declared `any` and is left to type-claim.',
3353
3353
  trust: [
3354
3354
  // Runes are compiler instructions: the compiler replaces each call with its own runtime code, which
3355
3355
  // cannot fail on typed input. Calling one where Svelte does not allow it is a compile error, or for
@@ -3368,6 +3368,58 @@ var SVELTE_PRESET = {
3368
3368
  // marks a prop bindable, returns its fallback
3369
3369
  "svelte.$inspect",
3370
3370
  // $inspect, $inspect.trace: development-only logging, removed from production builds
3371
+ "svelte.untrack",
3372
+ // runs its callback with tracking disabled, restored in finally
3373
+ "svelte.onMount",
3374
+ // registers a callback; throws only outside component initialization
3375
+ "svelte.onDestroy",
3376
+ // registers teardown; throws only outside component initialization
3377
+ "svelte.beforeUpdate",
3378
+ // registers a legacy hook; misuse-only errors
3379
+ "svelte.afterUpdate",
3380
+ // registers a legacy hook; misuse-only errors
3381
+ "svelte.createEventDispatcher",
3382
+ // creates a dispatcher; initialization misuse only
3383
+ "svelte.getAbortSignal",
3384
+ // returns the current effect signal; effect-context misuse only
3385
+ "svelte.setContext",
3386
+ // stores context; initialization misuse only
3387
+ "svelte.getContext",
3388
+ // reads context; initialization misuse only
3389
+ "svelte.hasContext",
3390
+ // tests context membership; initialization misuse only
3391
+ "svelte.getAllContexts",
3392
+ // reads the context map; initialization misuse only
3393
+ "svelte.flushSync",
3394
+ // flushes callbacks, whose bodies are checked where written
3395
+ "svelte.settled",
3396
+ // waits for updates; its deferred is only resolved
3397
+ "svelte.createRawSnippet",
3398
+ // wraps snippet callbacks, checked where written
3399
+ "svelte.__renderSnippet",
3400
+ // CLI-only generated render wrapper; arguments and snippet bodies remain checked
3401
+ "svelte/transition.fade",
3402
+ // computed styles and arithmetic only
3403
+ "svelte/transition.fly",
3404
+ // computed styles and arithmetic only
3405
+ "svelte/transition.slide",
3406
+ // computed styles and arithmetic only
3407
+ "svelte/transition.blur",
3408
+ // computed styles and arithmetic only
3409
+ "svelte/transition.scale",
3410
+ // computed styles and arithmetic only
3411
+ "svelte/transition.crossfade",
3412
+ // styles, bounding rectangles and arithmetic only
3413
+ "svelte/animate.flip",
3414
+ // bounding rectangles, styles and arithmetic only
3415
+ "svelte/easing",
3416
+ // pure arithmetic
3417
+ "svelte/attachments.createAttachmentKey",
3418
+ // creates a symbol
3419
+ "svelte/attachments.fromAction",
3420
+ // wraps an action callback, checked where written
3421
+ "svelte/events.on",
3422
+ // wraps addEventListener and returns teardown
3371
3423
  "svelte.tick",
3372
3424
  // resolves once pending state changes are applied; effect bodies it flushes are checked where written
3373
3425
  "svelte/store",
@@ -5369,14 +5421,16 @@ function patternMatchesAnyFile(baseDir, pattern) {
5369
5421
  return false;
5370
5422
  }
5371
5423
  var Zones = class {
5372
- constructor(rootDir, passthrough, ignore) {
5424
+ constructor(rootDir, passthrough, ignore, virtualPaths = /* @__PURE__ */ new Map()) {
5373
5425
  this.rootDir = rootDir;
5374
5426
  this.passthrough = passthrough;
5375
5427
  this.ignore = ignore;
5428
+ this.virtualPaths = virtualPaths;
5376
5429
  }
5377
5430
  rootDir;
5378
5431
  passthrough;
5379
5432
  ignore;
5433
+ virtualPaths;
5380
5434
  cache = /* @__PURE__ */ new Map();
5381
5435
  /** Zone of a file. Ignore wins over passthrough; files outside the root or in node_modules are external. */
5382
5436
  zoneOf(fileName) {
@@ -5388,11 +5442,11 @@ var Zones = class {
5388
5442
  }
5389
5443
  /** Project-relative posix path (for `local:` origins and baselines), or the absolute path when outside. */
5390
5444
  relativePath(fileName) {
5391
- const real = realpathOrSelf(fileName);
5445
+ const real = realpathOrSelf(this.virtualPaths.get(fileName) ?? fileName);
5392
5446
  return relativeInside(this.rootDir, real) ?? toPosix(real);
5393
5447
  }
5394
5448
  compute(fileName) {
5395
- const real = realpathOrSelf(fileName);
5449
+ const real = realpathOrSelf(this.virtualPaths.get(fileName) ?? fileName);
5396
5450
  const rel = relativeInside(this.rootDir, real);
5397
5451
  if (rel === null || rel.split("/").includes("node_modules")) return "external";
5398
5452
  if (this.ignore.some((group) => groupMatches(group, real))) return "ignore";
@@ -5614,15 +5668,19 @@ function readChain(configFile, rootDir) {
5614
5668
  visit(resolve(configFile), []);
5615
5669
  return chain;
5616
5670
  }
5617
- function zoneGroups(chain, key, validate, failWith = fail) {
5671
+ function unmatchedGlob(validate, source, message, failWith, unmatched) {
5672
+ if (validate === true) failWith(source, message);
5673
+ unmatched.push(`trust config ${source}: ${message}`);
5674
+ }
5675
+ function zoneGroups(chain, key, validate, failWith = fail, unmatched = []) {
5618
5676
  const groups = [];
5619
5677
  for (const level of chain) {
5620
5678
  const patterns = level[key];
5621
5679
  if (patterns.length === 0 || level.baseDir === null) continue;
5622
- if (validate) {
5680
+ if (validate !== false) {
5623
5681
  for (const pattern of patterns) {
5624
5682
  if (!patternMatchesAnyFile(level.baseDir, pattern)) {
5625
- failWith(level.source, `${key} glob "${pattern}" matches no files under ${level.baseDir}`);
5683
+ unmatchedGlob(validate, level.source, `${key} glob "${pattern}" matches no files under ${level.baseDir}`, failWith, unmatched);
5626
5684
  }
5627
5685
  }
5628
5686
  }
@@ -5630,16 +5688,16 @@ function zoneGroups(chain, key, validate, failWith = fail) {
5630
5688
  }
5631
5689
  return groups;
5632
5690
  }
5633
- function tsconfigMappings(chain, validate, failWith = fail) {
5691
+ function tsconfigMappings(chain, validate, failWith = fail, unmatched = []) {
5634
5692
  const mappings = [];
5635
5693
  for (const level of chain) {
5636
5694
  const baseDir = level.baseDir;
5637
5695
  if (baseDir === null) continue;
5638
5696
  level.tsconfig.forEach((entry, index) => {
5639
- if (validate) {
5697
+ if (validate !== false) {
5640
5698
  for (const pattern of entry.patterns) {
5641
5699
  if (!patternMatchesAnyFile(baseDir, pattern)) {
5642
- failWith(level.source, `tsconfig[${index}] glob "${pattern}" matches no files under ${baseDir}`);
5700
+ unmatchedGlob(validate, level.source, `tsconfig[${index}] glob "${pattern}" matches no files under ${baseDir}`, failWith, unmatched);
5643
5701
  }
5644
5702
  }
5645
5703
  }
@@ -5660,16 +5718,18 @@ function loadTrustConfig(configFile, options = {}) {
5660
5718
  const file = resolve(configFile);
5661
5719
  const rootDir = options.rootDir === void 0 ? void 0 : realpathOrSelf(resolve(options.rootDir));
5662
5720
  const chain = readChain(file, rootDir);
5663
- const validate = options.validateGlobs ?? true;
5721
+ const validate = options.validateGlobs ?? "report";
5722
+ const unmatched = [];
5664
5723
  return {
5665
5724
  file,
5666
5725
  rootDir: rootDir ?? realpathOrSelf(dirname(file)),
5667
5726
  levels: chain.map(({ source, trust, distrust, typeTrust, typeDistrust }) => ({ source, trust, distrust, typeTrust, typeDistrust })),
5668
- passthrough: zoneGroups(chain, "passthrough", validate),
5669
- ignore: zoneGroups(chain, "ignore", validate),
5670
- strict: zoneGroups(chain, "strict", validate),
5671
- tsconfig: tsconfigMappings(chain, validate),
5672
- rules: ruleSettings(chain)
5727
+ passthrough: zoneGroups(chain, "passthrough", validate, fail, unmatched),
5728
+ ignore: zoneGroups(chain, "ignore", validate, fail, unmatched),
5729
+ strict: zoneGroups(chain, "strict", validate, fail, unmatched),
5730
+ tsconfig: tsconfigMappings(chain, validate, fail, unmatched),
5731
+ rules: ruleSettings(chain),
5732
+ unmatchedGlobs: unmatched
5673
5733
  };
5674
5734
  }
5675
5735
  var cache = /* @__PURE__ */ new Map();
@@ -5700,11 +5760,777 @@ function effectiveTypeTrustList(config) {
5700
5760
  return [...new Set(config.levels.flatMap((level) => level.typeTrust))];
5701
5761
  }
5702
5762
 
5703
- // src/eslint/origin.ts
5763
+ // src/core/svelte.ts
5764
+ import { createRequire } from "module";
5704
5765
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
5705
- import { dirname as dirname2, join as join2 } from "path";
5766
+ import { basename, dirname as dirname2, join as join2, resolve as resolve3 } from "path";
5767
+ import { fileURLToPath } from "url";
5768
+
5769
+ // node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
5770
+ var comma = ",".charCodeAt(0);
5771
+ var semicolon = ";".charCodeAt(0);
5772
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5773
+ var intToChar = new Uint8Array(64);
5774
+ var charToInt = new Uint8Array(128);
5775
+ for (let i = 0; i < chars.length; i++) {
5776
+ const c = chars.charCodeAt(i);
5777
+ intToChar[i] = c;
5778
+ charToInt[c] = i;
5779
+ }
5780
+ function decodeInteger(reader) {
5781
+ let value = 0;
5782
+ let shift = 0;
5783
+ let integer = 0;
5784
+ do {
5785
+ const c = reader.next();
5786
+ integer = charToInt[c];
5787
+ value |= (integer & 31) << shift;
5788
+ shift += 5;
5789
+ } while (integer & 32);
5790
+ return value;
5791
+ }
5792
+ function decodeSign(num) {
5793
+ return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
5794
+ }
5795
+ function hasMoreVlq(reader, max) {
5796
+ if (reader.pos >= max) return false;
5797
+ return reader.peek() !== comma;
5798
+ }
5799
+ var bufLength = 1024 * 16;
5800
+ var StringReader = class {
5801
+ constructor(buffer) {
5802
+ this.pos = 0;
5803
+ this.buffer = buffer;
5804
+ }
5805
+ next() {
5806
+ return this.buffer.charCodeAt(this.pos++);
5807
+ }
5808
+ peek() {
5809
+ return this.buffer.charCodeAt(this.pos);
5810
+ }
5811
+ indexOf(char) {
5812
+ const { buffer, pos } = this;
5813
+ const idx = buffer.indexOf(char, pos);
5814
+ return idx === -1 ? buffer.length : idx;
5815
+ }
5816
+ };
5817
+ function decode(mappings) {
5818
+ const { length } = mappings;
5819
+ const reader = new StringReader(mappings);
5820
+ const decoded = [];
5821
+ let genColumn = 0;
5822
+ let sourcesIndex = 0;
5823
+ let sourceLine = 0;
5824
+ let sourceColumn = 0;
5825
+ let namesIndex = 0;
5826
+ do {
5827
+ const semi = reader.indexOf(";");
5828
+ const line = [];
5829
+ let sorted = true;
5830
+ let lastCol = 0;
5831
+ genColumn = 0;
5832
+ while (reader.pos < semi) {
5833
+ let seg;
5834
+ genColumn += decodeSign(decodeInteger(reader));
5835
+ if (genColumn < lastCol) sorted = false;
5836
+ lastCol = genColumn;
5837
+ if (hasMoreVlq(reader, semi)) {
5838
+ sourcesIndex += decodeSign(decodeInteger(reader));
5839
+ sourceLine += decodeSign(decodeInteger(reader));
5840
+ sourceColumn += decodeSign(decodeInteger(reader));
5841
+ if (hasMoreVlq(reader, semi)) {
5842
+ namesIndex += decodeSign(decodeInteger(reader));
5843
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
5844
+ } else {
5845
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
5846
+ }
5847
+ } else {
5848
+ seg = [genColumn];
5849
+ }
5850
+ line.push(seg);
5851
+ reader.pos++;
5852
+ }
5853
+ if (!sorted) sort(line);
5854
+ decoded.push(line);
5855
+ reader.pos = semi + 1;
5856
+ } while (reader.pos <= length);
5857
+ return decoded;
5858
+ }
5859
+ function sort(line) {
5860
+ line.sort(sortComparator);
5861
+ }
5862
+ function sortComparator(a, b) {
5863
+ return a[0] - b[0];
5864
+ }
5865
+
5866
+ // node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
5867
+ var schemeRegex = /^[\w+.-]+:\/\//;
5868
+ var urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
5869
+ var fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
5870
+ function isAbsoluteUrl(input) {
5871
+ return schemeRegex.test(input);
5872
+ }
5873
+ function isSchemeRelativeUrl(input) {
5874
+ return input.startsWith("//");
5875
+ }
5876
+ function isAbsolutePath(input) {
5877
+ return input.startsWith("/");
5878
+ }
5879
+ function isFileUrl(input) {
5880
+ return input.startsWith("file:");
5881
+ }
5882
+ function isRelative(input) {
5883
+ return /^[.?#]/.test(input);
5884
+ }
5885
+ function parseAbsoluteUrl(input) {
5886
+ const match2 = urlRegex.exec(input);
5887
+ return makeUrl(match2[1], match2[2] || "", match2[3], match2[4] || "", match2[5] || "/", match2[6] || "", match2[7] || "");
5888
+ }
5889
+ function parseFileUrl(input) {
5890
+ const match2 = fileRegex.exec(input);
5891
+ const path2 = match2[2];
5892
+ return makeUrl("file:", "", match2[1] || "", "", isAbsolutePath(path2) ? path2 : "/" + path2, match2[3] || "", match2[4] || "");
5893
+ }
5894
+ function makeUrl(scheme, user, host, port, path2, query, hash) {
5895
+ return {
5896
+ scheme,
5897
+ user,
5898
+ host,
5899
+ port,
5900
+ path: path2,
5901
+ query,
5902
+ hash,
5903
+ type: 7
5904
+ };
5905
+ }
5906
+ function parseUrl(input) {
5907
+ if (isSchemeRelativeUrl(input)) {
5908
+ const url2 = parseAbsoluteUrl("http:" + input);
5909
+ url2.scheme = "";
5910
+ url2.type = 6;
5911
+ return url2;
5912
+ }
5913
+ if (isAbsolutePath(input)) {
5914
+ const url2 = parseAbsoluteUrl("http://foo.com" + input);
5915
+ url2.scheme = "";
5916
+ url2.host = "";
5917
+ url2.type = 5;
5918
+ return url2;
5919
+ }
5920
+ if (isFileUrl(input))
5921
+ return parseFileUrl(input);
5922
+ if (isAbsoluteUrl(input))
5923
+ return parseAbsoluteUrl(input);
5924
+ const url = parseAbsoluteUrl("http://foo.com/" + input);
5925
+ url.scheme = "";
5926
+ url.host = "";
5927
+ url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
5928
+ return url;
5929
+ }
5930
+ function stripPathFilename(path2) {
5931
+ if (path2.endsWith("/.."))
5932
+ return path2;
5933
+ const index = path2.lastIndexOf("/");
5934
+ return path2.slice(0, index + 1);
5935
+ }
5936
+ function mergePaths(url, base) {
5937
+ normalizePath(base, base.type);
5938
+ if (url.path === "/") {
5939
+ url.path = base.path;
5940
+ } else {
5941
+ url.path = stripPathFilename(base.path) + url.path;
5942
+ }
5943
+ }
5944
+ function normalizePath(url, type) {
5945
+ const rel = type <= 4;
5946
+ const pieces = url.path.split("/");
5947
+ let pointer = 1;
5948
+ let positive = 0;
5949
+ let addTrailingSlash = false;
5950
+ for (let i = 1; i < pieces.length; i++) {
5951
+ const piece = pieces[i];
5952
+ if (!piece) {
5953
+ addTrailingSlash = true;
5954
+ continue;
5955
+ }
5956
+ addTrailingSlash = false;
5957
+ if (piece === ".")
5958
+ continue;
5959
+ if (piece === "..") {
5960
+ if (positive) {
5961
+ addTrailingSlash = true;
5962
+ positive--;
5963
+ pointer--;
5964
+ } else if (rel) {
5965
+ pieces[pointer++] = piece;
5966
+ }
5967
+ continue;
5968
+ }
5969
+ pieces[pointer++] = piece;
5970
+ positive++;
5971
+ }
5972
+ let path2 = "";
5973
+ for (let i = 1; i < pointer; i++) {
5974
+ path2 += "/" + pieces[i];
5975
+ }
5976
+ if (!path2 || addTrailingSlash && !path2.endsWith("/..")) {
5977
+ path2 += "/";
5978
+ }
5979
+ url.path = path2;
5980
+ }
5981
+ function resolve2(input, base) {
5982
+ if (!input && !base)
5983
+ return "";
5984
+ const url = parseUrl(input);
5985
+ let inputType = url.type;
5986
+ if (base && inputType !== 7) {
5987
+ const baseUrl = parseUrl(base);
5988
+ const baseType = baseUrl.type;
5989
+ switch (inputType) {
5990
+ case 1:
5991
+ url.hash = baseUrl.hash;
5992
+ // fall through
5993
+ case 2:
5994
+ url.query = baseUrl.query;
5995
+ // fall through
5996
+ case 3:
5997
+ case 4:
5998
+ mergePaths(url, baseUrl);
5999
+ // fall through
6000
+ case 5:
6001
+ url.user = baseUrl.user;
6002
+ url.host = baseUrl.host;
6003
+ url.port = baseUrl.port;
6004
+ // fall through
6005
+ case 6:
6006
+ url.scheme = baseUrl.scheme;
6007
+ }
6008
+ if (baseType > inputType)
6009
+ inputType = baseType;
6010
+ }
6011
+ normalizePath(url, inputType);
6012
+ const queryHash = url.query + url.hash;
6013
+ switch (inputType) {
6014
+ // This is impossible, because of the empty checks at the start of the function.
6015
+ // case UrlType.Empty:
6016
+ case 2:
6017
+ case 3:
6018
+ return queryHash;
6019
+ case 4: {
6020
+ const path2 = url.path.slice(1);
6021
+ if (!path2)
6022
+ return queryHash || ".";
6023
+ if (isRelative(base || input) && !isRelative(path2)) {
6024
+ return "./" + path2 + queryHash;
6025
+ }
6026
+ return path2 + queryHash;
6027
+ }
6028
+ case 5:
6029
+ return url.path + queryHash;
6030
+ default:
6031
+ return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
6032
+ }
6033
+ }
6034
+
6035
+ // node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
6036
+ function stripFilename(path2) {
6037
+ if (!path2) return "";
6038
+ const index = path2.lastIndexOf("/");
6039
+ return path2.slice(0, index + 1);
6040
+ }
6041
+ function resolver(mapUrl, sourceRoot) {
6042
+ const from = stripFilename(mapUrl);
6043
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
6044
+ return (source) => resolve2(prefix + (source || ""), from);
6045
+ }
6046
+ var COLUMN = 0;
6047
+ var SOURCES_INDEX = 1;
6048
+ var SOURCE_LINE = 2;
6049
+ var SOURCE_COLUMN = 3;
6050
+ var NAMES_INDEX = 4;
6051
+ function maybeSort(mappings, owned) {
6052
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
6053
+ if (unsortedIndex === mappings.length) return mappings;
6054
+ if (!owned) mappings = mappings.slice();
6055
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
6056
+ mappings[i] = sortSegments(mappings[i], owned);
6057
+ }
6058
+ return mappings;
6059
+ }
6060
+ function nextUnsortedSegmentLine(mappings, start) {
6061
+ for (let i = start; i < mappings.length; i++) {
6062
+ if (!isSorted(mappings[i])) return i;
6063
+ }
6064
+ return mappings.length;
6065
+ }
6066
+ function isSorted(line) {
6067
+ for (let j = 1; j < line.length; j++) {
6068
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
6069
+ return false;
6070
+ }
6071
+ }
6072
+ return true;
6073
+ }
6074
+ function sortSegments(line, owned) {
6075
+ if (!owned) line = line.slice();
6076
+ return line.sort(sortComparator2);
6077
+ }
6078
+ function sortComparator2(a, b) {
6079
+ return a[COLUMN] - b[COLUMN];
6080
+ }
6081
+ var found = false;
6082
+ function binarySearch(haystack, needle, low, high) {
6083
+ while (low <= high) {
6084
+ const mid = low + (high - low >> 1);
6085
+ const cmp = haystack[mid][COLUMN] - needle;
6086
+ if (cmp === 0) {
6087
+ found = true;
6088
+ return mid;
6089
+ }
6090
+ if (cmp < 0) {
6091
+ low = mid + 1;
6092
+ } else {
6093
+ high = mid - 1;
6094
+ }
6095
+ }
6096
+ found = false;
6097
+ return low - 1;
6098
+ }
6099
+ function upperBound(haystack, needle, index) {
6100
+ for (let i = index + 1; i < haystack.length; index = i++) {
6101
+ if (haystack[i][COLUMN] !== needle) break;
6102
+ }
6103
+ return index;
6104
+ }
6105
+ function lowerBound(haystack, needle, index) {
6106
+ for (let i = index - 1; i >= 0; index = i--) {
6107
+ if (haystack[i][COLUMN] !== needle) break;
6108
+ }
6109
+ return index;
6110
+ }
6111
+ function memoizedState() {
6112
+ return {
6113
+ lastKey: -1,
6114
+ lastNeedle: -1,
6115
+ lastIndex: -1
6116
+ };
6117
+ }
6118
+ function memoizedBinarySearch(haystack, needle, state, key) {
6119
+ const { lastKey, lastNeedle, lastIndex } = state;
6120
+ let low = 0;
6121
+ let high = haystack.length - 1;
6122
+ if (key === lastKey) {
6123
+ if (needle === lastNeedle) {
6124
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
6125
+ return lastIndex;
6126
+ }
6127
+ if (needle >= lastNeedle) {
6128
+ low = lastIndex === -1 ? 0 : lastIndex;
6129
+ } else {
6130
+ high = lastIndex;
6131
+ }
6132
+ }
6133
+ state.lastKey = key;
6134
+ state.lastNeedle = needle;
6135
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
6136
+ }
6137
+ function parse(map) {
6138
+ return typeof map === "string" ? JSON.parse(map) : map;
6139
+ }
6140
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
6141
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
6142
+ var LEAST_UPPER_BOUND = -1;
6143
+ var GREATEST_LOWER_BOUND = 1;
6144
+ var TraceMap = class {
6145
+ constructor(map, mapUrl) {
6146
+ const isString = typeof map === "string";
6147
+ if (!isString && map._decodedMemo) return map;
6148
+ const parsed = parse(map);
6149
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
6150
+ this.version = version;
6151
+ this.file = file;
6152
+ this.names = names || [];
6153
+ this.sourceRoot = sourceRoot;
6154
+ this.sources = sources;
6155
+ this.sourcesContent = sourcesContent;
6156
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
6157
+ const resolve5 = resolver(mapUrl, sourceRoot);
6158
+ this.resolvedSources = sources.map(resolve5);
6159
+ const { mappings } = parsed;
6160
+ if (typeof mappings === "string") {
6161
+ this._encoded = mappings;
6162
+ this._decoded = void 0;
6163
+ } else if (Array.isArray(mappings)) {
6164
+ this._encoded = void 0;
6165
+ this._decoded = maybeSort(mappings, isString);
6166
+ } else if (parsed.sections) {
6167
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
6168
+ } else {
6169
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
6170
+ }
6171
+ this._decodedMemo = memoizedState();
6172
+ this._bySources = void 0;
6173
+ this._bySourceMemos = void 0;
6174
+ }
6175
+ };
6176
+ function cast(map) {
6177
+ return map;
6178
+ }
6179
+ function decodedMappings(map) {
6180
+ var _a2;
6181
+ return (_a2 = cast(map))._decoded || (_a2._decoded = decode(cast(map)._encoded));
6182
+ }
6183
+ function originalPositionFor(map, needle) {
6184
+ let { line, column, bias } = needle;
6185
+ line--;
6186
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
6187
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
6188
+ const decoded = decodedMappings(map);
6189
+ if (line >= decoded.length) return OMapping(null, null, null, null);
6190
+ const segments = decoded[line];
6191
+ const index = traceSegmentInternal(
6192
+ segments,
6193
+ cast(map)._decodedMemo,
6194
+ line,
6195
+ column,
6196
+ bias || GREATEST_LOWER_BOUND
6197
+ );
6198
+ if (index === -1) return OMapping(null, null, null, null);
6199
+ const segment = segments[index];
6200
+ if (segment.length === 1) return OMapping(null, null, null, null);
6201
+ const { names, resolvedSources } = map;
6202
+ return OMapping(
6203
+ resolvedSources[segment[SOURCES_INDEX]],
6204
+ segment[SOURCE_LINE] + 1,
6205
+ segment[SOURCE_COLUMN],
6206
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
6207
+ );
6208
+ }
6209
+ function OMapping(source, line, column, name) {
6210
+ return { source, line, column, name };
6211
+ }
6212
+ function traceSegmentInternal(segments, memo, line, column, bias) {
6213
+ let index = memoizedBinarySearch(segments, column, memo, line);
6214
+ if (found) {
6215
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
6216
+ } else if (bias === LEAST_UPPER_BOUND) index++;
6217
+ if (index === -1 || index === segments.length) return -1;
6218
+ return index;
6219
+ }
6220
+
6221
+ // src/core/svelte.ts
6222
+ var SvelteFileError = class extends Error {
6223
+ };
6224
+ var sourceInputs = /* @__PURE__ */ new WeakMap();
6225
+ function svelteForSource(source) {
6226
+ return sourceInputs.get(source);
6227
+ }
6228
+ var checkerInputs = /* @__PURE__ */ new WeakMap();
6229
+ function svelteFor(checker) {
6230
+ return checkerInputs.get(checker);
6231
+ }
6232
+ function registerSvelte(program, inputs) {
6233
+ checkerInputs.set(program.getTypeChecker(), inputs);
6234
+ for (const source of program.getSourceFiles()) if (inputs.paths.has(source.fileName)) sourceInputs.set(source, inputs);
6235
+ }
6236
+ var SvelteInputs = class {
6237
+ virtual = /* @__PURE__ */ new Map();
6238
+ paths = /* @__PURE__ */ new Map();
6239
+ components = /* @__PURE__ */ new Map();
6240
+ shims = /* @__PURE__ */ new Set();
6241
+ imports = /* @__PURE__ */ new Map();
6242
+ componentShims = /* @__PURE__ */ new Map();
6243
+ extraRoots(files) {
6244
+ const roots = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set(), queue = [...files];
6245
+ while (queue.length) {
6246
+ const file = queue.pop();
6247
+ if (seen.has(file)) continue;
6248
+ seen.add(file);
6249
+ for (const shim of this.componentShims.get(file) ?? []) roots.add(shim);
6250
+ queue.push(...this.imports.get(file) ?? []);
6251
+ }
6252
+ return [...roots];
6253
+ }
6254
+ generated(file) {
6255
+ return this.paths.has(file + ".ts") ? file + ".ts" : file;
6256
+ }
6257
+ snippetCall(file, offset) {
6258
+ return this.components.get(file)?.snippetCalls.has(offset) ?? false;
6259
+ }
6260
+ original(file) {
6261
+ return this.paths.get(file) ?? file;
6262
+ }
6263
+ position(file, position) {
6264
+ const component = this.components.get(file);
6265
+ if (!component) return position;
6266
+ const offset = (component.lines[position.line - 1] ?? component.code.length) + position.column - 1;
6267
+ if (component.generatedCalls.has(offset)) return null;
6268
+ if (component.ignored.some(([start, end]) => offset >= start && offset < end)) return null;
6269
+ const mapped = originalPositionFor(component.map, { line: position.line, column: position.column - 1 });
6270
+ return mapped.line === null || mapped.column === null ? null : { line: mapped.line, column: mapped.column + 1 };
6271
+ }
6272
+ generatedLines(file, line) {
6273
+ const component = this.components.get(file);
6274
+ if (!component) return /* @__PURE__ */ new Set([line]);
6275
+ const lines = /* @__PURE__ */ new Set();
6276
+ decodedMappings(component.map).forEach((segments, generated) => {
6277
+ if (segments.some((segment) => segment.length >= 4 && segment[2] === line - 1)) lines.add(generated + 1);
6278
+ });
6279
+ return lines;
6280
+ }
6281
+ generatedPositions(file, position) {
6282
+ const component = this.components.get(file);
6283
+ if (!component) return [position];
6284
+ const positions = [];
6285
+ decodedMappings(component.map).forEach((segments, line) => {
6286
+ for (const segment of segments) {
6287
+ if (segment.length >= 4 && segment[2] === position.line - 1 && segment[3] === position.column - 1)
6288
+ positions.push({ line: line + 1, column: segment[0] + 1 });
6289
+ }
6290
+ });
6291
+ return positions;
6292
+ }
6293
+ finding(file, finding, snippetTrusted = false) {
6294
+ const component = this.components.get(file);
6295
+ if (snippetTrusted && component && finding.rule === "untrusted-call-must-return-result" && finding.origin === "svelte.Snippet") {
6296
+ const offset = (component.lines[finding.line - 1] ?? 0) + finding.column - 1;
6297
+ if (component.snippetCalls.has(offset)) return null;
6298
+ }
6299
+ const position = this.position(file, finding);
6300
+ return position ? { ...finding, ...position } : null;
6301
+ }
6302
+ error(message) {
6303
+ for (const [file, source] of this.paths) {
6304
+ if (!message.startsWith(file + ":")) continue;
6305
+ const match2 = /^(\d+):(\d+)([\s\S]*)$/.exec(message.slice(file.length + 1));
6306
+ if (!match2) return source + message.slice(file.length);
6307
+ const position = this.position(file, { line: Number(match2[1]), column: Number(match2[2]) });
6308
+ return position ? `${source}:${position.line}:${position.column}${match2[3]}` : `${source}: generated Svelte syntax error${match2[3]}`;
6309
+ }
6310
+ return message;
6311
+ }
6312
+ };
6313
+ function packageRoot() {
6314
+ let directory = dirname2(fileURLToPath(import.meta.url));
6315
+ for (; ; ) {
6316
+ const manifest = join2(directory, "package.json");
6317
+ if (existsSync2(manifest) && JSON.parse(readFileSync2(manifest, "utf8")).name === "@noego/trust") return directory;
6318
+ const parent = dirname2(directory);
6319
+ if (parent === directory) throw new Error("Cannot locate the @noego/trust package directory");
6320
+ directory = parent;
6321
+ }
6322
+ }
6323
+ function locateConverter(file) {
6324
+ const shipped = join2(packageRoot(), "dist", "svelte2tsx", "index.cjs");
6325
+ if (existsSync2(shipped)) return shipped;
6326
+ try {
6327
+ return createRequire(import.meta.url).resolve("svelte2tsx");
6328
+ } catch {
6329
+ throw new Error(`Cannot check ${file}: the svelte2tsx converter is missing from @noego/trust (dist/svelte2tsx); reinstall @noego/trust or run its build`);
6330
+ }
6331
+ }
6332
+ function prepareSvelte(ts, cwd, files, override, mappings = []) {
6333
+ const inputs = new SvelteInputs();
6334
+ const bundled = createRequire(import.meta.url);
6335
+ const runtimes = /* @__PURE__ */ new Map();
6336
+ function runtime(file) {
6337
+ const project = createRequire(join2(dirname2(file), "__trust_svelte__.cjs"));
6338
+ let manifest;
6339
+ try {
6340
+ manifest = project.resolve("svelte/package.json");
6341
+ } catch {
6342
+ throw new Error(`Cannot check ${file}: install svelte in the project; .svelte files are never silently skipped`);
6343
+ }
6344
+ const cached = runtimes.get(manifest);
6345
+ if (cached) return cached;
6346
+ const converter = locateConverter(file);
6347
+ const version = JSON.parse(readFileSync2(manifest, "utf8")).version;
6348
+ const suffix = Number(version.split(".")[0]) >= 4 ? "-v4" : "";
6349
+ const result = {
6350
+ convert: bundled(converter).svelte2tsx,
6351
+ shimDir: dirname2(manifest),
6352
+ parse: project("svelte/compiler").parse,
6353
+ version,
6354
+ shims: ["svelte-shims", "svelte-jsx"].map((name) => join2(dirname2(converter), name + suffix + ".d.ts"))
6355
+ };
6356
+ runtimes.set(manifest, result);
6357
+ return result;
6358
+ }
6359
+ function convert(file) {
6360
+ const virtual = file + ".ts";
6361
+ if (inputs.virtual.has(virtual)) return inputs.virtual.get(virtual);
6362
+ if (existsSync2(virtual)) throw new Error(`Cannot check ${file}: virtual file collides with real file ${virtual}`);
6363
+ const env = runtime(file);
6364
+ const source = readFileSync2(file, "utf8");
6365
+ const scripts = [...source.matchAll(/<script\b([^>]*)>/gi)];
6366
+ const isTsFile = scripts.length === 0 || scripts.some((match2) => /\blang\s*=\s*["'](?:ts|typescript)["']/i.test(match2[1]));
6367
+ let result;
6368
+ try {
6369
+ result = env.convert(source, { filename: file, mode: "ts", isTsFile, version: env.version, parse: env.parse, emitOnTemplateError: false });
6370
+ } catch (error) {
6371
+ const detail = error;
6372
+ throw new SvelteFileError(`${file}:${detail.start?.line ?? 1}:${(detail.start?.column ?? 0) + 1} ${detail.message ?? String(error)} (Svelte preprocessors are not run)`);
6373
+ }
6374
+ const code = result.code;
6375
+ const lines = [0];
6376
+ for (let i = 0; i < code.length; i++) if (code[i] === "\n") lines.push(i + 1);
6377
+ const ignored = [];
6378
+ for (const match2 of code.matchAll(/\/\*Ωignore_startΩ\*\/[\s\S]*?\/\*Ωignore_endΩ\*\//g)) ignored.push([match2.index, match2.index + match2[0].length]);
6379
+ const map = new TraceMap({ ...result.map, version: 3 });
6380
+ const sourceLines = [0, ...[...source.matchAll(/\n/g)].map((match2) => match2.index + 1)];
6381
+ const snippetCalls = /* @__PURE__ */ new Set();
6382
+ const generatedCalls = /* @__PURE__ */ new Set();
6383
+ const ast = ts.createSourceFile(virtual, code, ts.ScriptTarget.Latest, true);
6384
+ const visit = (node) => {
6385
+ if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
6386
+ const callee = node.expression.getText(ast);
6387
+ if (/^(?:__sveltets_|\$\$|svelteHTML\.)/.test(callee)) {
6388
+ const position = ast.getLineAndCharacterOfPosition(node.getStart(ast));
6389
+ const original = originalPositionFor(map, { line: position.line + 1, column: position.character });
6390
+ const written = original.line === null || original.column === null ? "" : source.slice(sourceLines[original.line - 1] + original.column);
6391
+ if (!written?.startsWith(callee)) generatedCalls.add(node.getStart(ast));
6392
+ }
6393
+ }
6394
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "__sveltets_2_ensureSnippet") {
6395
+ const call = node.arguments[0];
6396
+ if (call && ts.isCallExpression(call)) snippetCalls.add(call.getStart(ast));
6397
+ }
6398
+ ts.forEachChild(node, visit);
6399
+ };
6400
+ visit(ast);
6401
+ inputs.paths.set(virtual, file);
6402
+ inputs.virtual.set(virtual, code);
6403
+ inputs.components.set(virtual, { source, code, lines, ignored, snippetCalls, generatedCalls, map });
6404
+ const diagnostics = ast.parseDiagnostics ?? [];
6405
+ if (diagnostics.length) {
6406
+ const diagnostic = diagnostics[0];
6407
+ const position = ast.getLineAndCharacterOfPosition(diagnostic.start);
6408
+ throw new SvelteFileError(inputs.error(`${virtual}:${position.line + 1}:${position.character + 1} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`));
6409
+ }
6410
+ const componentShims = [];
6411
+ for (const shim of env.shims) {
6412
+ if (!existsSync2(shim)) throw new Error(`Cannot check ${file}: missing svelte2tsx shim ${shim}`);
6413
+ const virtualShim = join2(env.shimDir, "__trust_" + basename(shim));
6414
+ if (existsSync2(virtualShim)) throw new Error(`Svelte shim overlay collides with ${virtualShim}`);
6415
+ inputs.virtual.set(virtualShim, readFileSync2(shim, "utf8"));
6416
+ inputs.shims.add(virtualShim);
6417
+ componentShims.push(virtualShim);
6418
+ }
6419
+ inputs.componentShims.set(file, componentShims);
6420
+ return code;
6421
+ }
6422
+ const settings = /* @__PURE__ */ new Map();
6423
+ const seen = /* @__PURE__ */ new Set();
6424
+ const queue = [...files];
6425
+ while (queue.length) {
6426
+ const file = resolve3(queue.shift());
6427
+ if (seen.has(file)) continue;
6428
+ seen.add(file);
6429
+ const code = file.endsWith(".svelte") ? convert(file) : ts.sys.readFile(file);
6430
+ if (code === void 0 || !code.includes(".svelte")) continue;
6431
+ const grouping = groupByTsconfig(ts, cwd, [file], override, mappings);
6432
+ if (grouping.kind !== "grouped") throw new Error(grouping.message);
6433
+ const owner = [...grouping.groups.keys()][0];
6434
+ let options = settings.get(owner);
6435
+ if (!options) {
6436
+ options = readTsconfig(ts, owner).options;
6437
+ settings.set(owner, options);
6438
+ }
6439
+ const host = {
6440
+ ...ts.sys,
6441
+ fileExists: (path2) => ts.sys.fileExists(path2) || path2.endsWith(".svelte.ts") && ts.sys.fileExists(path2.slice(0, -3))
6442
+ };
6443
+ const ast = ts.createSourceFile(file, code, ts.ScriptTarget.Latest, true);
6444
+ const visit = (node) => {
6445
+ const specifier = ts.isImportDeclaration(node) || ts.isExportDeclaration(node) ? node.moduleSpecifier : ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword ? node.arguments[0] : void 0;
6446
+ if (specifier && ts.isStringLiteralLike(specifier) && specifier.text.endsWith(".svelte")) {
6447
+ const resolved = ts.resolveModuleName(specifier.text, inputs.generated(file), options, host).resolvedModule?.resolvedFileName;
6448
+ if (resolved?.endsWith(".svelte.ts") && ts.sys.fileExists(resolved.slice(0, -3))) {
6449
+ const target = resolved.slice(0, -3);
6450
+ const imports = inputs.imports.get(file) ?? /* @__PURE__ */ new Set();
6451
+ imports.add(target);
6452
+ inputs.imports.set(file, imports);
6453
+ queue.push(target);
6454
+ }
6455
+ }
6456
+ ts.forEachChild(node, visit);
6457
+ };
6458
+ visit(ast);
6459
+ }
6460
+ return inputs;
6461
+ }
6462
+
6463
+ // src/core/program.ts
6464
+ import { dirname as dirname3, resolve as resolve4 } from "path";
6465
+ function readTsconfig(ts, tsconfig) {
6466
+ if (!tsconfig) return { options: { allowJs: true, strict: true, noEmit: true }, declarationFiles: [] };
6467
+ const parsed = ts.getParsedCommandLineOfConfigFile(tsconfig, {}, {
6468
+ ...ts.sys,
6469
+ onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
6470
+ throw new Error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
6471
+ }
6472
+ });
6473
+ return {
6474
+ options: { ...parsed?.options, noEmit: true },
6475
+ declarationFiles: (parsed?.fileNames ?? []).filter((name) => /\.d\.[cm]?ts$/.test(name))
6476
+ };
6477
+ }
6478
+ function missingMappedTsconfig(mapping, file) {
6479
+ const files = mapping.patterns.length === 1 ? JSON.stringify(mapping.patterns[0]) : JSON.stringify(mapping.patterns);
6480
+ return {
6481
+ kind: "missing-mapped-tsconfig",
6482
+ message: `trust config ${mapping.source}: "tsconfig[${mapping.index}]" (files ${files}) maps ${file} to ${mapping.tsconfig}, which does not exist`
6483
+ };
6484
+ }
6485
+ function groupByTsconfig(ts, cwd, files, tsconfig, mappings = []) {
6486
+ const override = tsconfig ? resolve4(cwd, tsconfig) : void 0;
6487
+ const groups = /* @__PURE__ */ new Map();
6488
+ for (const file of files) {
6489
+ const mapping = override === void 0 ? mappings.find((entry) => groupMatches(entry, realpathOrSelf(file))) : void 0;
6490
+ if (mapping && !ts.sys.fileExists(mapping.tsconfig)) return missingMappedTsconfig(mapping, file);
6491
+ const owner = override ?? mapping?.tsconfig ?? ts.findConfigFile(dirname3(file), ts.sys.fileExists);
6492
+ const list = groups.get(owner) ?? [];
6493
+ list.push(file);
6494
+ groups.set(owner, list);
6495
+ }
6496
+ return { kind: "grouped", groups };
6497
+ }
6498
+ function createPrograms(ts, cwd, files, tsconfig, mappings = []) {
6499
+ const grouping = groupByTsconfig(ts, cwd, files, tsconfig, mappings);
6500
+ if (grouping.kind !== "grouped") return grouping;
6501
+ const svelte = prepareSvelte(ts, cwd, files, tsconfig, mappings);
6502
+ const groups = [...grouping.groups].map(([owner, groupFiles]) => {
6503
+ const settings = readTsconfig(ts, owner);
6504
+ const rootNames = [.../* @__PURE__ */ new Set([...groupFiles.map((file) => svelte.generated(file)), ...settings.declarationFiles, ...svelte.extraRoots(groupFiles)])];
6505
+ const host = ts.createCompilerHost(settings.options);
6506
+ const read = host.readFile.bind(host), exists = host.fileExists.bind(host);
6507
+ host.readFile = (file) => svelte.virtual.get(file) ?? read(file);
6508
+ host.fileExists = (file) => svelte.virtual.has(file) || exists(file);
6509
+ const realpath = host.realpath?.bind(host);
6510
+ host.realpath = (file) => svelte.virtual.has(file) ? file : realpath?.(file) ?? file;
6511
+ host.getSourceFile = (file, languageVersion) => {
6512
+ const text = host.readFile(file);
6513
+ return text === void 0 ? void 0 : ts.createSourceFile(file, text, languageVersion, true);
6514
+ };
6515
+ const program = ts.createProgram({ rootNames, options: settings.options, host });
6516
+ registerSvelte(program, svelte);
6517
+ return { tsconfig: owner, files: groupFiles, program };
6518
+ });
6519
+ return { kind: "created", groups };
6520
+ }
6521
+ function sourceFileOf(program, file) {
6522
+ file = svelteFor(program.getTypeChecker())?.generated(file) ?? file;
6523
+ return program.getSourceFile(file) ?? program.getSourceFile(realpathOrSelf(file));
6524
+ }
6525
+
6526
+ // src/eslint/origin.ts
6527
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
6528
+ import { dirname as dirname4, join as join3 } from "path";
5706
6529
  var NODE_MODULES = "/node_modules/";
5707
- var TS_LIB_FILE = /\/typescript\/lib\/lib\.[^/]*\.d\.ts$/;
6530
+ var TS_LIB_FILE = /\/(?:typescript|@tsc-rs\/[^/]+|@typescript\/native-preview-[^/]+)\/lib\/lib\.[^/]*\.d\.ts$/;
6531
+ function isGlobalAugmentation(ts, node) {
6532
+ return (node.flags & ts.NodeFlags.GlobalAugmentation) !== 0 || ts.isIdentifier(node.name) && node.name.text === "global";
6533
+ }
5708
6534
  var TRUST_PACKAGE = "@noego/trust";
5709
6535
  var JS_BASE = "js:";
5710
6536
  var NODE_PREFIX = "node:";
@@ -5724,10 +6550,10 @@ function nodeGlobalPath(members) {
5724
6550
  }
5725
6551
  var manifestNameCache = /* @__PURE__ */ new Map();
5726
6552
  function readManifestName(directory) {
5727
- const file = join2(directory, "package.json");
5728
- if (!existsSync2(file)) return null;
6553
+ const file = join3(directory, "package.json");
6554
+ if (!existsSync3(file)) return null;
5729
6555
  try {
5730
- const manifest = JSON.parse(readFileSync2(file, "utf8"));
6556
+ const manifest = JSON.parse(readFileSync3(file, "utf8"));
5731
6557
  if (manifest && typeof manifest === "object" && "name" in manifest && typeof manifest.name === "string") {
5732
6558
  return manifest.name;
5733
6559
  }
@@ -5738,7 +6564,7 @@ function readManifestName(directory) {
5738
6564
  }
5739
6565
  function nearestPackageName(fileName) {
5740
6566
  const visited = [];
5741
- let directory = dirname2(fileName);
6567
+ let directory = dirname4(fileName);
5742
6568
  let result = null;
5743
6569
  for (; ; ) {
5744
6570
  const cached = manifestNameCache.get(directory);
@@ -5752,7 +6578,7 @@ function nearestPackageName(fileName) {
5752
6578
  result = name;
5753
6579
  break;
5754
6580
  }
5755
- const parent = dirname2(directory);
6581
+ const parent = dirname4(directory);
5756
6582
  if (parent === directory) break;
5757
6583
  directory = parent;
5758
6584
  }
@@ -5781,7 +6607,8 @@ var OriginResolver = class {
5781
6607
  ts;
5782
6608
  zones;
5783
6609
  originOf(declaration) {
5784
- const fileName = toPosix(declaration.getSourceFile().fileName);
6610
+ const generated = declaration.getSourceFile().fileName;
6611
+ const fileName = toPosix(this.zones.virtualPaths.get(generated) ?? generated);
5785
6612
  const members = this.memberPath(declaration);
5786
6613
  const external = (base, path3 = members) => ({
5787
6614
  kind: "external",
@@ -5813,10 +6640,10 @@ var OriginResolver = class {
5813
6640
  for (let node = declaration; node && !ts.isSourceFile(node); node = node.parent) {
5814
6641
  if (ts.isModuleDeclaration(node)) {
5815
6642
  if (ts.isStringLiteral(node.name)) break;
5816
- if (node.flags & ts.NodeFlags.GlobalAugmentation) continue;
6643
+ if (isGlobalAugmentation(ts, node)) continue;
5817
6644
  }
5818
6645
  const name = this.containerName(node);
5819
- if (name) names.push(name);
6646
+ if (name && !(this.zones.virtualPaths.has(declaration.getSourceFile().fileName) && (name.startsWith("$$") || name.startsWith("__sveltets_")))) names.push(name);
5820
6647
  }
5821
6648
  return names.reverse();
5822
6649
  }
@@ -5834,7 +6661,7 @@ var OriginResolver = class {
5834
6661
  ambientModuleName(declaration) {
5835
6662
  const ts = this.ts;
5836
6663
  for (let node = declaration; node; node = node.parent) {
5837
- if (ts.isModuleDeclaration(node) && node.flags & ts.NodeFlags.GlobalAugmentation) return null;
6664
+ if (ts.isModuleDeclaration(node) && isGlobalAugmentation(ts, node)) return null;
5838
6665
  if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name)) return node.name.text.replace(/^node:/, "");
5839
6666
  }
5840
6667
  return null;
@@ -5871,13 +6698,13 @@ function trustDirectivesIn(ts, sourceFile) {
5871
6698
  function lineDirectivesIn(ts, sourceFile, prefix) {
5872
6699
  const text = sourceFile.text;
5873
6700
  const seen = /* @__PURE__ */ new Set();
5874
- const found = [];
6701
+ const found2 = [];
5875
6702
  const take = (ranges) => {
5876
6703
  for (const range2 of ranges ?? []) {
5877
6704
  if (seen.has(range2.pos)) continue;
5878
6705
  seen.add(range2.pos);
5879
6706
  const directive = asDirective(ts, text, range2, prefix);
5880
- if (directive) found.push(directive);
6707
+ if (directive) found2.push(directive);
5881
6708
  }
5882
6709
  };
5883
6710
  const visit = (node) => {
@@ -5887,7 +6714,7 @@ function lineDirectivesIn(ts, sourceFile, prefix) {
5887
6714
  take(ts.getTrailingCommentRanges(text, node.end));
5888
6715
  };
5889
6716
  visit(sourceFile);
5890
- return found.sort((a, b) => a.pos - b.pos);
6717
+ return found2.sort((a, b) => a.pos - b.pos);
5891
6718
  }
5892
6719
  function constFunction(ts, statement) {
5893
6720
  const list = statement.declarationList;
@@ -5965,24 +6792,24 @@ function directiveProblem(ts, sourceFile, directive) {
5965
6792
  }
5966
6793
 
5967
6794
  // src/eslint/typescript.ts
5968
- import { createRequire } from "module";
5969
- import { join as join3 } from "path";
6795
+ import { createRequire as createRequire2 } from "module";
6796
+ import { join as join4 } from "path";
5970
6797
  var cache2 = /* @__PURE__ */ new Map();
5971
6798
  function loadTypeScript(cwd) {
5972
6799
  const cached = cache2.get(cwd);
5973
6800
  if (cached) return cached;
5974
6801
  let ts;
5975
6802
  try {
5976
- ts = createRequire(join3(cwd, "__noego_trust__.cjs"))("typescript");
6803
+ ts = createRequire2(join4(cwd, "__noego_trust__.cjs"))("typescript");
5977
6804
  } catch {
5978
- ts = createRequire(import.meta.url)("typescript");
6805
+ ts = createRequire2(import.meta.url)("typescript");
5979
6806
  }
5980
6807
  cache2.set(cwd, ts);
5981
6808
  return ts;
5982
6809
  }
5983
6810
 
5984
6811
  // src/core/baseline.ts
5985
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
6812
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
5986
6813
  function countFindings(findings) {
5987
6814
  const counts = {};
5988
6815
  for (const finding of findings) {
@@ -6021,8 +6848,8 @@ function compareToBaseline(findings, baseline, scope = WHOLE_BASELINE) {
6021
6848
  if (!inScope(scope, file)) continue;
6022
6849
  for (const [rule, byOrigin] of Object.entries(byRule)) {
6023
6850
  for (const [origin, allowed] of Object.entries(byOrigin)) {
6024
- const found = groups.get(JSON.stringify([file, rule, origin]))?.length ?? 0;
6025
- if (found < allowed) stale.push({ file, rule, origin, allowed, found, findings: [] });
6851
+ const found2 = groups.get(JSON.stringify([file, rule, origin]))?.length ?? 0;
6852
+ if (found2 < allowed) stale.push({ file, rule, origin, allowed, found: found2, findings: [] });
6026
6853
  }
6027
6854
  }
6028
6855
  }
@@ -6068,9 +6895,9 @@ function parseBaseline(text, source) {
6068
6895
  return counts;
6069
6896
  }
6070
6897
  function readBaseline(baselineFile) {
6071
- if (!existsSync3(baselineFile)) return { counts: {} };
6898
+ if (!existsSync4(baselineFile)) return { counts: {} };
6072
6899
  try {
6073
- return { counts: parseBaseline(readFileSync3(baselineFile, "utf8"), baselineFile) };
6900
+ return { counts: parseBaseline(readFileSync4(baselineFile, "utf8"), baselineFile) };
6074
6901
  } catch (error) {
6075
6902
  return { error: error instanceof Error ? error.message : String(error) };
6076
6903
  }
@@ -6126,6 +6953,15 @@ export {
6126
6953
  effectiveTrustList,
6127
6954
  readZoneSettings,
6128
6955
  effectiveTypeTrustList,
6956
+ readTsconfig,
6957
+ groupByTsconfig,
6958
+ createPrograms,
6959
+ sourceFileOf,
6960
+ SvelteFileError,
6961
+ svelteForSource,
6962
+ svelteFor,
6963
+ SvelteInputs,
6964
+ prepareSvelte,
6129
6965
  nearestPackageName,
6130
6966
  isTrustPackageFile,
6131
6967
  OriginResolver,
@@ -6151,4 +6987,4 @@ export {
6151
6987
  readBaseline,
6152
6988
  describeBaselineDelta
6153
6989
  };
6154
- //# sourceMappingURL=chunk-NG4KYWVW.js.map
6990
+ //# sourceMappingURL=chunk-UG6D3V4M.js.map