@stencil/core 5.0.0-alpha.4 → 5.0.0-alpha.6

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 (44) hide show
  1. package/dist/{client-Dti6fFpE.mjs → client-fWOou5EW.mjs} +2360 -2090
  2. package/dist/compiler/index.d.mts +5 -5
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-BYRrEeD-.mjs → compiler-CdUbDTbV.mjs} +13426 -12276
  7. package/dist/declarations/stencil-public-compiler.d.ts +527 -238
  8. package/dist/declarations/stencil-public-compiler.js +2 -3
  9. package/dist/declarations/stencil-public-docs.d.ts +10 -0
  10. package/dist/declarations/stencil-public-runtime.d.ts +51 -12
  11. package/dist/{index-BwTaN1Nq.d.mts → index-D8vvsppY.d.mts} +566 -350
  12. package/dist/{index-CyrGY82h.d.ts → index-Dap2E02-.d.ts} +83 -32
  13. package/dist/{index-9LTuoSiw.d.mts → index-UUlemGuu.d.mts} +13 -2
  14. package/dist/index.d.mts +0 -1
  15. package/dist/index.mjs +1 -1
  16. package/dist/jsx-runtime.d.mts +18 -0
  17. package/dist/jsx-runtime.mjs +2 -0
  18. package/dist/{node-BF2jSfWg.mjs → node-klLZLdDe.mjs} +20 -19
  19. package/dist/{regular-expression-D5pGVpCu.mjs → regular-expression-DUdhF3Ei.mjs} +113 -29
  20. package/dist/runtime/app-data/index.d.ts +1 -1
  21. package/dist/runtime/app-data/index.js +15 -9
  22. package/dist/{runtime-COEYYPyw.js → runtime/client/lazy.js} +2596 -2182
  23. package/dist/runtime/client/{index.d.ts → runtime.d.ts} +89 -47
  24. package/dist/runtime/client/{index.js → runtime.js} +2473 -2183
  25. package/dist/runtime/index.d.ts +46 -5
  26. package/dist/runtime/index.js +4956 -2
  27. package/dist/runtime/server/index.d.mts +85 -63
  28. package/dist/runtime/server/index.mjs +2462 -2193
  29. package/dist/runtime/server/runner.d.mts +44 -32
  30. package/dist/runtime/server/runner.mjs +335 -383
  31. package/dist/signals/index.d.ts +47 -0
  32. package/dist/signals/index.js +199 -0
  33. package/dist/sys/node/index.d.mts +1 -1
  34. package/dist/sys/node/index.mjs +1 -1
  35. package/dist/sys/node/worker.mjs +2 -2
  36. package/dist/testing/index.d.mts +97 -3
  37. package/dist/testing/index.mjs +197 -45
  38. package/dist/{validation-Byxie0Uk.mjs → validation-2QipI30K.mjs} +90 -77
  39. package/package.json +41 -28
  40. package/dist/index-hS-KBdAP.d.ts +0 -30
  41. package/dist/jsx-runtime-DlDkTqps.d.ts +0 -28
  42. package/dist/jsx-runtime.d.ts +0 -2
  43. package/dist/jsx-runtime.js +0 -2
  44. /package/dist/{chunk-CjcI7cDX.mjs → chunk-z9aeyW2b.mjs} +0 -0
@@ -1,9 +1,11 @@
1
- import { B as BUILD, E as reWireGetterSetter, V as Env, _ as getElement, a as Mixin, b as setAssetPath, c as forceUpdate, d as createEvent, f as getMode, g as h, h as Host, l as getRenderingRef, o as Fragment, s as bootstrapLazy, t as insertVdomAnnotations, u as renderVdom, y as getAssetPath } from "../client-Dti6fFpE.mjs";
2
- import { C as CMP_FLAGS, V as EVENT_FLAGS, h as noop } from "../regular-expression-D5pGVpCu.mjs";
3
- import { _ as getBuildFeatures, c as createWorkerContext, h as BuildContext, i as createSystem, m as Cache, p as createInMemoryFs } from "../compiler-BYRrEeD-.mjs";
4
- import { St as formatLazyBundleRuntimeMeta } from "../validation-Byxie0Uk.mjs";
5
- import { o as buildEvents } from "../node-BF2jSfWg.mjs";
1
+ import { C as setAssetPath, S as getAssetPath, U as BUILD, W as Env, _ as getRenderingRef, b as getElement, c as Mixin, d as getMode, g as forceUpdate, h, k as reWireGetterSetter, l as Fragment, m as Host, t as insertVdomAnnotations, u as bootstrapLazy, v as renderVdom, y as createEvent } from "../client-fWOou5EW.mjs";
2
+ import { I as EVENT_FLAGS, h as noop, w as CMP_FLAGS } from "../regular-expression-DUdhF3Ei.mjs";
3
+ import { _ as getBuildFeatures, c as createWorkerContext, g as BuildContext, h as Cache, i as createSystem, o as loadConfig, p as createInMemoryFs, s as createCompiler } from "../compiler-CdUbDTbV.mjs";
4
+ import { wt as formatLazyBundleRuntimeMeta } from "../validation-2QipI30K.mjs";
5
+ import { o as buildEvents } from "../node-klLZLdDe.mjs";
6
+ import fs from "node:fs";
6
7
  import path from "node:path";
8
+ import { fileURLToPath } from "node:url";
7
9
  import path$1 from "path";
8
10
  import { MockWindow, setupGlobal } from "@stencil/mock-doc";
9
11
  import { createHash } from "crypto";
@@ -223,6 +225,7 @@ const mockComponentMeta = (overrides = {}) => ({
223
225
  hasVdomStyle: false,
224
226
  hasVdomText: false,
225
227
  hasVdomXlink: false,
228
+ hasSignalsImport: false,
226
229
  hasWatchCallback: false,
227
230
  htmlAttrNames: [],
228
231
  htmlParts: [],
@@ -246,6 +249,7 @@ const mockComponentMeta = (overrides = {}) => ({
246
249
  states: [],
247
250
  styleDocs: [],
248
251
  styles: [],
252
+ globalStyles: [],
249
253
  tagName: "stub-cmp",
250
254
  virtualProperties: [],
251
255
  watchers: [],
@@ -268,8 +272,6 @@ function mockValidatedConfig(overrides = {}) {
268
272
  devServer: {},
269
273
  extras: {},
270
274
  fsNamespace: "testing",
271
- hashFileNames: false,
272
- hashedFileNameLength: 8,
273
275
  hydratedFlag: null,
274
276
  logLevel: "info",
275
277
  logger: mockLogger(),
@@ -285,11 +287,7 @@ function mockValidatedConfig(overrides = {}) {
285
287
  suppressReservedPublicNameWarnings: false,
286
288
  sys: createTestingSystem(),
287
289
  transformAliasedImportPaths: true,
288
- rolldownConfig: {
289
- inputOptions: {},
290
- outputOptions: {}
291
- },
292
- validatePrimaryPackageOutputTarget: false,
290
+ rolldownConfig: {},
293
291
  ...overrides
294
292
  };
295
293
  }
@@ -308,13 +306,11 @@ function mockConfig(overrides = {}) {
308
306
  return {
309
307
  _isTesting: true,
310
308
  buildAppCore: false,
311
- buildDist: true,
312
309
  bundles: null,
313
310
  devMode: true,
314
311
  enableCache: false,
315
312
  extras: {},
316
313
  globalScript: null,
317
- hashFileNames: false,
318
314
  logger: new TestingLogger(),
319
315
  maxConcurrentWorkers: 0,
320
316
  minifyCss: false,
@@ -366,7 +362,7 @@ function mockCompilerCtx(config) {
366
362
  activeFilesUpdated: [],
367
363
  addWatchDir: noop,
368
364
  addWatchFile: noop,
369
- cachedGlobalStyle: null,
365
+ globalStyleCache: /* @__PURE__ */ new Map(),
370
366
  changedFiles: /* @__PURE__ */ new Set(),
371
367
  changedModules: /* @__PURE__ */ new Set(),
372
368
  collections: [],
@@ -383,9 +379,11 @@ function mockCompilerCtx(config) {
383
379
  reset: noop,
384
380
  resolvedCollections: /* @__PURE__ */ new Set(),
385
381
  rolldownCache: /* @__PURE__ */ new Map(),
386
- rolldownCacheHydrate: null,
382
+ rolldownCacheSsr: null,
387
383
  rolldownCacheLazy: null,
388
384
  rolldownCacheNative: null,
385
+ transpileCache: /* @__PURE__ */ new Map(),
386
+ prevStylesMap: /* @__PURE__ */ new Map(),
389
387
  styleModeNames: /* @__PURE__ */ new Set(),
390
388
  worker: createWorkerContext(innerConfig.sys),
391
389
  cssTransformCache: /* @__PURE__ */ new Map()
@@ -478,9 +476,173 @@ const mockModule = (mod = {}) => ({
478
476
  hasVdomStyle: false,
479
477
  hasVdomText: false,
480
478
  hasVdomXlink: false,
479
+ hasSignalsImport: false,
481
480
  ...mod
482
481
  });
483
482
  //#endregion
483
+ //#region src/testing/create-test-compiler.ts
484
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
485
+ const TESTING_TSCONFIG = path.resolve(__dirname, "fixtures/tsconfig.testing.json");
486
+ /**
487
+ * Builds a patched sys that falls through to real disk for TypeScript lib files.
488
+ *
489
+ * @returns A compiler system instance with patched readFileSync, readFile, accessSync, and statSync methods
490
+ */
491
+ const createPatchedSys = () => {
492
+ const sys = mockCompilerSystem();
493
+ const originalReadFileSync = sys.readFileSync.bind(sys);
494
+ sys.readFileSync = (p) => {
495
+ const mem = originalReadFileSync(p);
496
+ if (mem !== void 0) return mem;
497
+ try {
498
+ return fs.readFileSync(p, "utf-8");
499
+ } catch {
500
+ return;
501
+ }
502
+ };
503
+ const originalReadFile = sys.readFile.bind(sys);
504
+ sys.readFile = async (p) => {
505
+ const mem = await originalReadFile(p);
506
+ if (mem !== void 0) return mem;
507
+ try {
508
+ return fs.readFileSync(p, "utf-8");
509
+ } catch {
510
+ return;
511
+ }
512
+ };
513
+ const originalAccessSync = sys.accessSync.bind(sys);
514
+ sys.accessSync = (p) => {
515
+ if (originalAccessSync(p)) return true;
516
+ try {
517
+ fs.accessSync(p);
518
+ return true;
519
+ } catch {
520
+ return false;
521
+ }
522
+ };
523
+ const originalStatSync = sys.statSync.bind(sys);
524
+ sys.statSync = (p) => {
525
+ const mem = originalStatSync(p);
526
+ if (!mem.error) return mem;
527
+ try {
528
+ const s = fs.statSync(p);
529
+ return {
530
+ isDirectory: s.isDirectory(),
531
+ isFile: s.isFile(),
532
+ isSymbolicLink: s.isSymbolicLink(),
533
+ size: s.size,
534
+ error: null
535
+ };
536
+ } catch {
537
+ return mem;
538
+ }
539
+ };
540
+ sys.getCompilerExecutingPath = () => path.resolve(__dirname, "../../dist/compiler/index.mjs");
541
+ return sys;
542
+ };
543
+ /**
544
+ * Runs the expensive one-time setup for a test compiler suite: patching the
545
+ * sys, reading and validating the tsconfig. Use this in a `beforeAll` block
546
+ * when a describe block contains multiple tests that each need a fresh
547
+ * compiler, to avoid repeating `loadConfig` on every test.
548
+ *
549
+ * @param options - Configuration options for preparing the test compiler
550
+ * @returns A {@link PreparedTestCompiler} that can be passed to {@link createTestCompiler}
551
+ *
552
+ * @example
553
+ * ```ts
554
+ * let setup: PreparedTestCompiler;
555
+ * beforeAll(async () => { setup = await prepareTestCompiler(); });
556
+ * beforeEach(async () => {
557
+ * const { compiler } = await createTestCompiler({ setup });
558
+ * });
559
+ * ```
560
+ */
561
+ const prepareTestCompiler = async (options = {}) => {
562
+ const sys = createPatchedSys();
563
+ const tsconfigPath = options.tsconfig ?? TESTING_TSCONFIG;
564
+ const { config: validatedConfig } = await loadConfig({
565
+ sys,
566
+ config: {
567
+ devMode: true,
568
+ sourceMap: false,
569
+ enableCache: false,
570
+ minifyJs: false,
571
+ minifyCss: false,
572
+ namespace: "Testing",
573
+ tsconfig: tsconfigPath,
574
+ ...options.config
575
+ },
576
+ initTsConfig: false
577
+ });
578
+ return {
579
+ _validatedConfig: validatedConfig,
580
+ _tsconfigPath: tsconfigPath
581
+ };
582
+ };
583
+ /**
584
+ * Creates a test compiler instance with a hybrid filesystem (reads from disk, writes to memory).
585
+ * This utility handles the common setup pattern for compiler tests.
586
+ *
587
+ * When multiple tests in the same suite need independent compiler instances,
588
+ * pass a {@link PreparedTestCompiler} from {@link prepareTestCompiler} as
589
+ * `options.setup` to skip the expensive `loadConfig` step on each test.
590
+ *
591
+ * @param options - Configuration options for the test compiler
592
+ * @returns An object with the compiler, validated config, and system instance
593
+ *
594
+ * @example
595
+ * ```ts
596
+ * const { compiler, config } = await createTestCompiler({
597
+ * config: { minifyCss: true }
598
+ * });
599
+ * await compiler.fs.writeFile('/src/index.html', '<cmp-a></cmp-a>');
600
+ * const result = await compiler.build();
601
+ * ```
602
+ */
603
+ const createTestCompiler = async (options = {}) => {
604
+ let validatedConfig;
605
+ let tsconfigPath;
606
+ if (options.setup) {
607
+ const freshSys = createPatchedSys();
608
+ validatedConfig = {
609
+ ...options.setup._validatedConfig,
610
+ sys: freshSys
611
+ };
612
+ tsconfigPath = options.setup._tsconfigPath;
613
+ } else {
614
+ const sys = createPatchedSys();
615
+ tsconfigPath = options.tsconfig ?? TESTING_TSCONFIG;
616
+ const { config } = await loadConfig({
617
+ sys,
618
+ config: {
619
+ devMode: true,
620
+ sourceMap: false,
621
+ enableCache: false,
622
+ minifyJs: false,
623
+ minifyCss: false,
624
+ namespace: "Testing",
625
+ tsconfig: tsconfigPath,
626
+ ...options.config
627
+ },
628
+ initTsConfig: false
629
+ });
630
+ validatedConfig = config;
631
+ }
632
+ const compiler = await createCompiler(validatedConfig);
633
+ const tsconfigObj = JSON.parse(fs.readFileSync(tsconfigPath, "utf-8"));
634
+ await compiler.fs.writeFile(tsconfigPath, JSON.stringify({
635
+ ...tsconfigObj,
636
+ include: [validatedConfig.srcDir]
637
+ }));
638
+ await compiler.fs.writeFile(path.join(validatedConfig.srcDir, "components.d.ts"), "");
639
+ return {
640
+ compiler,
641
+ config: validatedConfig,
642
+ sys: validatedConfig.sys
643
+ };
644
+ };
645
+ //#endregion
484
646
  //#region src/testing/platform/testing-constants.ts
485
647
  const styles = /* @__PURE__ */ new Map();
486
648
  const modeResolutionChain = [];
@@ -516,7 +678,7 @@ const Build = {
516
678
  * @returns the corresponding Stencil reference data structure, or undefined if one cannot be found
517
679
  */
518
680
  const getHostRef = (elm) => {
519
- if (elm.__stencil__getHostRef) return elm.__stencil__getHostRef();
681
+ if (elm.__s_ghr) return elm.__s_ghr();
520
682
  };
521
683
  /**
522
684
  * Add the provided `hostRef` instance to the global {@link hostRefs} map, using the provided `lazyInstance` as a key.
@@ -537,7 +699,7 @@ const registerInstance = (lazyInstance, hostRef) => {
537
699
  });
538
700
  hostRef = getHostRef(elm);
539
701
  }
540
- lazyInstance.__stencil__getHostRef = () => hostRef;
702
+ lazyInstance.__s_ghr = () => hostRef;
541
703
  hostRef.$lazyInstance$ = lazyInstance;
542
704
  if (hostRef.$cmpMeta$?.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) reWireGetterSetter(lazyInstance, hostRef);
543
705
  const Cstr = lazyInstance.constructor;
@@ -588,7 +750,7 @@ const registerHost = (elm, cmpMeta) => {
588
750
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
589
751
  elm["s-p"] = [];
590
752
  elm["s-rc"] = [];
591
- elm.__stencil__getHostRef = () => hostRef;
753
+ elm.__s_ghr = () => hostRef;
592
754
  };
593
755
  const setErrorHandler = (handler) => handler;
594
756
  //#endregion
@@ -728,6 +890,8 @@ function flushLoadModule(bundleId) {
728
890
  const isVitestEnvironment = typeof process !== "undefined" && process.env?.VITEST;
729
891
  const existingWindow = typeof globalThis !== "undefined" && globalThis.window;
730
892
  const win = isVitestEnvironment && existingWindow ? existingWindow : setupGlobal(global);
893
+ //#endregion
894
+ //#region src/testing/platform/testing-platform.ts
731
895
  const plt = {
732
896
  $flags$: 0,
733
897
  $resourcesUrl$: "",
@@ -738,14 +902,6 @@ const plt = {
738
902
  ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
739
903
  };
740
904
  /**
741
- * Helper function to programmatically set shadow DOM support in testing scenarios.
742
- *
743
- * This function modifies the global {@link supportsShadow} variable.
744
- *
745
- * @param supports `true` if shadow DOM is supported, `false` otherwise
746
- */
747
- const setSupportsShadowDom = (supports) => {};
748
- /**
749
905
  * Resets global testing variables and collections, so that a new set of tests can be started with a "clean slate".
750
906
  *
751
907
  * It is expected that this function be called between spec tests, and should be automatically configured by Stencil to
@@ -861,13 +1017,13 @@ function resetBuildConditionals(b) {
861
1017
  b.hydratedAttribute = false;
862
1018
  b.hydratedClass = true;
863
1019
  b.invisiblePrehydration = true;
864
- b.appendChildSlotFix = false;
865
- b.cloneNodeFix = false;
1020
+ b.staticHydrationStyles = false;
1021
+ b.lightDomPatches = false;
1022
+ b.slotChildNodes = false;
1023
+ b.slotCloneNode = false;
1024
+ b.slotDomMutations = false;
1025
+ b.slotTextContent = false;
866
1026
  b.hotModuleReplacement = false;
867
- b.scopedSlotTextContentFix = false;
868
- b.slotChildNodesFix = false;
869
- b.experimentalSlotFixes = false;
870
- b.experimentalScopedSlotChanges = false;
871
1027
  }
872
1028
  //#endregion
873
1029
  //#region src/testing/spec-page.ts
@@ -887,14 +1043,8 @@ async function newSpecPage(opts) {
887
1043
  resetBuildConditionals(BUILD);
888
1044
  if (Array.isArray(opts.components)) registerComponents(opts.components);
889
1045
  if (opts.hydrateClientSide) opts.includeAnnotations = true;
890
- if (opts.hydrateServerSide) {
891
- opts.includeAnnotations = true;
892
- setSupportsShadowDom(false);
893
- } else {
894
- opts.includeAnnotations = !!opts.includeAnnotations;
895
- if (opts.supportsShadowDom === false) setSupportsShadowDom(false);
896
- else setSupportsShadowDom(true);
897
- }
1046
+ if (opts.hydrateServerSide) opts.includeAnnotations = true;
1047
+ else opts.includeAnnotations = !!opts.includeAnnotations;
898
1048
  BUILD.cssAnnotations = opts.includeAnnotations;
899
1049
  const cmpTags = /* @__PURE__ */ new Set();
900
1050
  win["__stencil_spec_options"] = opts;
@@ -948,9 +1098,8 @@ async function newSpecPage(opts) {
948
1098
  BUILD.hydrateServerSide = true;
949
1099
  BUILD.hydrateClientSide = false;
950
1100
  }
951
- BUILD.cloneNodeFix = false;
952
- BUILD.shadowDomShim = false;
953
- BUILD.attachStyles = !!opts.attachStyles;
1101
+ BUILD.slotCloneNode = false;
1102
+ if (opts.buildFlags) Object.assign(BUILD, opts.buildFlags);
954
1103
  if (typeof opts.url === "string") page.win.location.href = opts.url;
955
1104
  if (typeof opts.direction === "string") page.doc.documentElement.setAttribute("dir", opts.direction);
956
1105
  if (typeof opts.language === "string") page.doc.documentElement.setAttribute("lang", opts.language);
@@ -963,6 +1112,9 @@ async function newSpecPage(opts) {
963
1112
  if (typeof opts.userAgent === "string") try {
964
1113
  page.win.navigator.userAgent = opts.userAgent;
965
1114
  } catch {}
1115
+ if (opts.hydrateServerSide && opts.serializeShadowRoot === "scoped") {
1116
+ for (const [, cmps] of lazyBundles) for (const cmp of cmps) if (cmp[0] & CMP_FLAGS.shadowDomEncapsulation) cmp[0] |= CMP_FLAGS.shadowNeedsScopedCss;
1117
+ }
966
1118
  bootstrapLazy(lazyBundles);
967
1119
  if (typeof opts.template === "function") renderVdom({
968
1120
  $ancestorComponent$: void 0,
@@ -1168,4 +1320,4 @@ function setupConsoleMocker() {
1168
1320
  };
1169
1321
  }
1170
1322
  //#endregion
1171
- export { Build, Env, Fragment, Host, Mixin, createEvent, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };
1323
+ export { Build, Env, Fragment, Host, Mixin, createEvent, createTestCompiler, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, prepareTestCompiler, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };
@@ -1,7 +1,7 @@
1
- import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- import { A as DIST_CUSTOM_ELEMENTS, B as DOCS_VSCODE, C as CMP_FLAGS, E as CUSTOM, F as DIST_TYPES, G as LISTENER_FLAGS, H as GENERATED_DTS, I as DOCS_CUSTOM, J as STATS, K as MEMBER_FLAGS, L as DOCS_CUSTOM_ELEMENTS_MANIFEST, M as DIST_HYDRATE_SCRIPT, N as DIST_LAZY, O as DIST, P as DIST_LAZY_LOADER, R as DOCS_JSON, T as COPY, X as VALID_CONFIG_OUTPUT_TARGETS, Z as WATCH_FLAGS, _ as sortBy, b as toTitleCase, i as flatOne, j as DIST_GLOBAL_STYLES, k as DIST_COLLECTION, n as dashToPascalCase, p as isString, r as escapeWithPattern, u as isIterable, y as toDashCase, z as DOCS_README } from "./regular-expression-D5pGVpCu.mjs";
1
+ import { t as __exportAll } from "./chunk-z9aeyW2b.mjs";
2
+ import { $ as WATCH_FLAGS, A as DIST_LAZY, C as ASSETS, D as COPY, F as DOCS_VSCODE, H as LOADER_BUNDLE, J as STATS, K as SSR_WASM, L as GENERATED_DTS, M as DOCS_CUSTOM_ELEMENTS_MANIFEST, N as DOCS_JSON, O as CUSTOM, P as DOCS_README, Q as VALID_CONFIG_OUTPUT_TARGETS, R as GLOBAL_STYLE, U as MEMBER_FLAGS, V as LISTENER_FLAGS, Y as STENCIL_REBUNDLE, Z as TYPES, _ as sortBy, b as toTitleCase, i as flatOne, j as DOCS_CUSTOM, n as dashToPascalCase, p as isString, q as STANDALONE, r as escapeWithPattern, u as isIterable, w as CMP_FLAGS, y as toDashCase } from "./regular-expression-DUdhF3Ei.mjs";
3
3
  import path, { basename, dirname, relative } from "node:path";
4
- import { minimatch } from "minimatch";
4
+ import picomatch from "picomatch";
5
5
  //#region src/utils/byte-size.ts
6
6
  /**
7
7
  * Used to learn the size of a string in bytes.
@@ -267,7 +267,8 @@ const buildWarn = (diagnostics) => {
267
267
  * @param jsonFilePath the path to the JSON file where the error occurred
268
268
  * @param msg the error message
269
269
  * @param jsonField the key for the field which caused the error, used for finding
270
- * the error line in the original JSON file
270
+ * the error line in the original JSON file. Only root-level keys (with minimal
271
+ * indentation, typically 2 spaces) are highlighted to avoid matching nested keys.
271
272
  * @returns a reference to the newly-created diagnostic
272
273
  */
273
274
  const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
@@ -276,41 +277,60 @@ const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonFie
276
277
  err.absFilePath = jsonFilePath;
277
278
  if (typeof jsonField === "string") try {
278
279
  const lines = compilerCtx.fs.readFileSync(jsonFilePath).replace(/\r/g, "\n").split("\n");
280
+ let bestMatch = null;
281
+ const ROOT_LEVEL_INDENTATION = 2;
279
282
  for (let i = 0; i < lines.length; i++) {
280
283
  const txtLine = lines[i];
281
284
  const txtIndex = txtLine.indexOf(jsonField);
282
285
  if (txtIndex > -1) {
283
- const warnLine = {
286
+ const indentation = txtLine.search(/\S/);
287
+ if (indentation === ROOT_LEVEL_INDENTATION) {
288
+ bestMatch = {
289
+ lineIndex: i,
290
+ charIndex: txtIndex,
291
+ indentation
292
+ };
293
+ break;
294
+ } else if (bestMatch === null || indentation < bestMatch.indentation) bestMatch = {
284
295
  lineIndex: i,
285
- lineNumber: i + 1,
286
- text: txtLine,
287
- errorCharStart: txtIndex,
288
- errorLength: jsonField.length
296
+ charIndex: txtIndex,
297
+ indentation
289
298
  };
290
- err.lineNumber = warnLine.lineNumber;
291
- err.columnNumber = txtIndex + 1;
292
- err.lines.push(warnLine);
293
- if (i >= 0) {
294
- const beforeWarnLine = {
295
- lineIndex: warnLine.lineIndex - 1,
296
- lineNumber: warnLine.lineNumber - 1,
297
- text: lines[i - 1],
298
- errorCharStart: -1,
299
- errorLength: -1
300
- };
301
- err.lines.unshift(beforeWarnLine);
302
- }
303
- if (i < lines.length) {
304
- const afterWarnLine = {
305
- lineIndex: warnLine.lineIndex + 1,
306
- lineNumber: warnLine.lineNumber + 1,
307
- text: lines[i + 1],
308
- errorCharStart: -1,
309
- errorLength: -1
310
- };
311
- err.lines.push(afterWarnLine);
312
- }
313
- break;
299
+ }
300
+ }
301
+ if (bestMatch !== null && bestMatch.indentation === ROOT_LEVEL_INDENTATION) {
302
+ const i = bestMatch.lineIndex;
303
+ const txtIndex = bestMatch.charIndex;
304
+ const txtLine = lines[i];
305
+ const warnLine = {
306
+ lineIndex: i,
307
+ lineNumber: i + 1,
308
+ text: txtLine,
309
+ errorCharStart: txtIndex,
310
+ errorLength: jsonField.length
311
+ };
312
+ err.lineNumber = warnLine.lineNumber;
313
+ err.columnNumber = txtIndex + 1;
314
+ err.lines.push(warnLine);
315
+ if (i > 0) {
316
+ const beforeWarnLine = {
317
+ lineIndex: warnLine.lineIndex - 1,
318
+ lineNumber: warnLine.lineNumber - 1,
319
+ text: lines[i - 1],
320
+ errorCharStart: -1,
321
+ errorLength: -1
322
+ };
323
+ err.lines.unshift(beforeWarnLine);
324
+ }
325
+ if (i < lines.length - 1) {
326
+ const afterWarnLine = {
327
+ lineIndex: warnLine.lineIndex + 1,
328
+ lineNumber: warnLine.lineNumber + 1,
329
+ text: lines[i + 1],
330
+ errorCharStart: -1,
331
+ errorLength: -1
332
+ };
333
+ err.lines.push(afterWarnLine);
314
334
  }
315
335
  }
316
336
  } catch {}
@@ -466,6 +486,7 @@ const escapeHtml = (unsafe) => {
466
486
  };
467
487
  //#endregion
468
488
  //#region src/utils/logger/logger-rolldown.ts
489
+ const isRolldownError = (e) => typeof e === "object" && e !== null && "message" in e;
469
490
  const loadRolldownDiagnostics = (config, compilerCtx, buildCtx, rolldownError) => {
470
491
  const formattedCode = formatErrorCode(rolldownError.code);
471
492
  const diagnostic = {
@@ -641,15 +662,15 @@ const getRootLength = (path) => {
641
662
  const getEncodedRootLength = (path) => {
642
663
  if (!path) return 0;
643
664
  const ch0 = path.charCodeAt(0);
644
- if (ch0 === CharacterCodes.slash || ch0 === CharacterCodes.backslash) {
665
+ if (ch0 === 47 || ch0 === 92) {
645
666
  if (path.charCodeAt(1) !== ch0) return 1;
646
- const p1 = path.indexOf(ch0 === CharacterCodes.slash ? "/" : altDirectorySeparator, 2);
667
+ const p1 = path.indexOf(ch0 === 47 ? "/" : altDirectorySeparator, 2);
647
668
  if (p1 < 0) return path.length;
648
669
  return p1 + 1;
649
670
  }
650
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === CharacterCodes.colon) {
671
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
651
672
  const ch2 = path.charCodeAt(2);
652
- if (ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash) return 3;
673
+ if (ch2 === 47 || ch2 === 92) return 3;
653
674
  if (path.length === 2) return 2;
654
675
  }
655
676
  const schemeEnd = path.indexOf(urlSchemeSeparator);
@@ -662,7 +683,7 @@ const getEncodedRootLength = (path) => {
662
683
  if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
663
684
  const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
664
685
  if (volumeSeparatorEnd !== -1) {
665
- if (path.charCodeAt(volumeSeparatorEnd) === CharacterCodes.slash) return ~(volumeSeparatorEnd + 1);
686
+ if (path.charCodeAt(volumeSeparatorEnd) === 47) return ~(volumeSeparatorEnd + 1);
666
687
  if (volumeSeparatorEnd === path.length) return ~volumeSeparatorEnd;
667
688
  }
668
689
  }
@@ -672,13 +693,13 @@ const getEncodedRootLength = (path) => {
672
693
  }
673
694
  return 0;
674
695
  };
675
- const isVolumeCharacter = (charCode) => charCode >= CharacterCodes.a && charCode <= CharacterCodes.z || charCode >= CharacterCodes.A && charCode <= CharacterCodes.Z;
696
+ const isVolumeCharacter = (charCode) => charCode >= 97 && charCode <= 122 || charCode >= 65 && charCode <= 90;
676
697
  const getFileUrlVolumeSeparatorEnd = (url, start) => {
677
698
  const ch0 = url.charCodeAt(start);
678
- if (ch0 === CharacterCodes.colon) return start + 1;
679
- if (ch0 === CharacterCodes.percent && url.charCodeAt(start + 1) === CharacterCodes._3) {
699
+ if (ch0 === 58) return start + 1;
700
+ if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
680
701
  const ch2 = url.charCodeAt(start + 2);
681
- if (ch2 === CharacterCodes.a || ch2 === CharacterCodes.A) return start + 3;
702
+ if (ch2 === 97 || ch2 === 65) return start + 3;
682
703
  }
683
704
  return -1;
684
705
  };
@@ -708,19 +729,6 @@ const normalizeFsPathQuery = (importPath) => {
708
729
  format: params ? params.get("format") : null
709
730
  };
710
731
  };
711
- var CharacterCodes = /* @__PURE__ */ function(CharacterCodes) {
712
- CharacterCodes[CharacterCodes["a"] = 97] = "a";
713
- CharacterCodes[CharacterCodes["A"] = 65] = "A";
714
- CharacterCodes[CharacterCodes["z"] = 122] = "z";
715
- CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
716
- CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
717
- CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
718
- CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
719
- CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
720
- CharacterCodes[CharacterCodes["percent"] = 37] = "percent";
721
- CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
722
- return CharacterCodes;
723
- }(CharacterCodes || {});
724
732
  /**
725
733
  * A wrapped version of node.js' {@link path.relative} which adds our custom
726
734
  * normalization logic. This solves the relative path between `from` and `to`!
@@ -776,7 +784,7 @@ function join$1(...paths) {
776
784
  * @param paths a path or path fragments to resolve
777
785
  * @returns a resolved path!
778
786
  */
779
- function resolve(...paths) {
787
+ function resolve$1(...paths) {
780
788
  /**
781
789
  * When normalizing, we should _not_ attempt to relativize the path returned by the native Node `resolve` method. When
782
790
  * calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
@@ -973,7 +981,7 @@ const flattenDiagnosticMessageText = (tsDiagnostic, diag) => {
973
981
  const shouldExcludeComponent = (tagName, excludePatterns) => {
974
982
  if (!excludePatterns || excludePatterns.length === 0) return false;
975
983
  return excludePatterns.some((pattern) => {
976
- if (isGlob(pattern)) return minimatch(tagName, pattern);
984
+ if (isGlob(pattern)) return picomatch.isMatch(tagName, pattern);
977
985
  return pattern === tagName;
978
986
  });
979
987
  };
@@ -1025,21 +1033,22 @@ const relativeImport = (pathFrom, pathTo, ext, addPrefix = true) => {
1025
1033
  };
1026
1034
  const getComponentsDtsSrcFilePath = (config) => join$1(config.srcDir, GENERATED_DTS);
1027
1035
  /**
1028
- * Helper to get an appropriate file path for `components.d.ts` for a `"dist"`
1029
- * or `"dist-types"` output target.
1036
+ * Helper to get an appropriate file path for `components.d.ts` for an output target.
1030
1037
  *
1031
- * @param outputTarget the output target of interest
1038
+ * @param typesDir the directory where types are generated
1032
1039
  * @returns a properly-formatted path
1033
1040
  */
1034
- const getComponentsDtsTypesFilePath = (outputTarget) => join$1(outputTarget.typesDir, GENERATED_DTS);
1035
- const isOutputTargetDist = (o) => o.type === DIST;
1036
- const isOutputTargetDistCollection = (o) => o.type === DIST_COLLECTION;
1037
- const isOutputTargetDistCustomElements = (o) => o.type === DIST_CUSTOM_ELEMENTS;
1041
+ const getComponentsDtsTypesFilePath = (typesDir) => join$1(typesDir, GENERATED_DTS);
1042
+ const isOutputTargetLoaderBundle = (o) => o.type === LOADER_BUNDLE;
1043
+ const isOutputTargetStandalone = (o) => o.type === STANDALONE;
1044
+ const isOutputTargetSsr = (o) => o.type === "ssr";
1045
+ const isOutputTargetSsrWasm = (o) => o.type === SSR_WASM;
1046
+ const isOutputTargetCollection = (o) => o.type === STENCIL_REBUNDLE;
1047
+ const isOutputTargetTypes = (o) => o.type === TYPES;
1048
+ const isOutputTargetGlobalStyle = (o) => o.type === GLOBAL_STYLE;
1049
+ const isOutputTargetAssets = (o) => o.type === ASSETS;
1038
1050
  const isOutputTargetCopy = (o) => o.type === COPY;
1039
1051
  const isOutputTargetDistLazy = (o) => o.type === DIST_LAZY;
1040
- const isOutputTargetDistLazyLoader = (o) => o.type === DIST_LAZY_LOADER;
1041
- const isOutputTargetDistGlobalStyles = (o) => o.type === DIST_GLOBAL_STYLES;
1042
- const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
1043
1052
  const isOutputTargetCustom = (o) => o.type === CUSTOM;
1044
1053
  const isOutputTargetDocs = (o) => o.type === "docs-readme" || o.type === "docs-json" || o.type === "docs-custom" || o.type === "docs-vscode" || o.type === "docs-custom-elements-manifest";
1045
1054
  const isOutputTargetDocsReadme = (o) => o.type === DOCS_README;
@@ -1049,15 +1058,6 @@ const isOutputTargetDocsVscode = (o) => o.type === DOCS_VSCODE;
1049
1058
  const isOutputTargetDocsCustomElementsManifest = (o) => o.type === DOCS_CUSTOM_ELEMENTS_MANIFEST;
1050
1059
  const isOutputTargetWww = (o) => o.type === "www";
1051
1060
  const isOutputTargetStats = (o) => o.type === STATS;
1052
- const isOutputTargetDistTypes = (o) => o.type === DIST_TYPES;
1053
- /**
1054
- * Checks whether or not the supplied output target's type matches one of the eligible primary
1055
- * package output target types (i.e. it can have `isPrimaryPackageOutputTarget: true` in its config).
1056
- *
1057
- * @param o The output target to check.
1058
- * @returns Whether the output target type is one of the "primary" output targets.
1059
- */
1060
- const isEligiblePrimaryPackageOutputTarget = (o) => isOutputTargetDist(o) || isOutputTargetDistCollection(o) || isOutputTargetDistCustomElements(o) || isOutputTargetDistTypes(o);
1061
1061
  /**
1062
1062
  * Retrieve the Stencil component compiler metadata from a collection of Stencil {@link d.Module}s
1063
1063
  * @param moduleFiles the collection of `Module`s to retrieve the metadata from
@@ -1073,6 +1073,19 @@ const getComponentsFromModules = (moduleFiles) => sortBy(flatOne(moduleFiles.map
1073
1073
  function isValidConfigOutputTarget(targetType) {
1074
1074
  return VALID_CONFIG_OUTPUT_TARGETS.includes(targetType);
1075
1075
  }
1076
+ /**
1077
+ * Filter output targets based on devMode and their skipInDev setting.
1078
+ * In dev mode, targets with `skipInDev: true` are filtered out.
1079
+ * In prod mode, all targets are included.
1080
+ *
1081
+ * @param targets Array of output targets to filter
1082
+ * @param devMode Whether we're in dev mode
1083
+ * @returns Filtered array of active targets
1084
+ */
1085
+ const filterActiveTargets = (targets, devMode) => {
1086
+ if (!devMode) return targets;
1087
+ return targets.filter((t) => !t.skipInDev);
1088
+ };
1076
1089
  //#endregion
1077
1090
  //#region src/utils/result.ts
1078
1091
  var result_exports = /* @__PURE__ */ __exportAll({
@@ -1442,4 +1455,4 @@ const validateComponentTag = (tag) => {
1442
1455
  if (tag.lastIndexOf("-") === tag.length - 1) return `"${tag}" tag cannot end with a dash (-)`;
1443
1456
  };
1444
1457
  //#endregion
1445
- export { join$1 as $, isOutputTargetCustom as A, isOutputTargetDocsCustomElementsManifest as B, result_exports as C, stringifyRuntimeData as Ct, getComponentsFromModules as D, getComponentsDtsTypesFilePath as E, isOutputTargetDistLazy as F, isOutputTargetStats as G, isOutputTargetDocsReadme as H, isOutputTargetDistLazyLoader as I, relativeImport as J, isOutputTargetWww as K, isOutputTargetDistTypes as L, isOutputTargetDistCollection as M, isOutputTargetDistCustomElements as N, isEligiblePrimaryPackageOutputTarget as O, isOutputTargetDistGlobalStyles as P, loadTypeScriptDiagnostics as Q, isOutputTargetDocs as R, ok as S, formatLazyBundleRuntimeMeta as St, getComponentsDtsSrcFilePath as T, isOutputTargetDocsVscode as U, isOutputTargetDocsJson as V, isOutputTargetHydrate as W, augmentDiagnosticWithNode as X, shouldExcludeComponent as Y, loadTypeScriptDiagnostic as Z, getSourceMappingUrlForEndOfFile as _, hasWarning as _t, getTextDocs as a, resolve as at, err as b, isGlob as bt, isJsFile as c, escapeHtml as ct, isTsxFile as d, TASK_CANCELED_MSG as dt, normalize as et, parsePackageJson as f, buildError as ft, getInlineSourceMappingUrlLinker as g, hasError as gt, isRemoteUrl as h, catchError as ht, generatePreamble as i, relative$1 as it, isOutputTargetDist as j, isOutputTargetCopy as k, isJsxFile as l, normalizeDiagnostics as lt, readPackageJson as m, buildWarn as mt, addDocBlock as n, normalizeFsPathQuery as nt, hasDependency as o, createOnWarnFn as ot, readOnlyArrayHasStringMember as p, buildJsonFileError as pt, isValidConfigOutputTarget as q, createJsVarName as r, normalizePath as rt, isDtsFile as s, loadRolldownDiagnostics as st, validateComponentTag as t, normalizeFsPath as tt, isTsFile as u, splitLineBreaks as ut, getSourceMappingUrlLinker as v, shouldIgnoreError as vt, filterExcludedComponents as w, byteSize as wt, map as x, formatComponentRuntimeMeta as xt, rolldownToStencilSourceMap as y, isRootPath as yt, isOutputTargetDocsCustom as z };
1458
+ export { loadTypeScriptDiagnostics as $, isOutputTargetCollection as A, isOutputTargetGlobalStyle as B, result_exports as C, formatComponentRuntimeMeta as Ct, getComponentsDtsTypesFilePath as D, getComponentsDtsSrcFilePath as E, byteSize as Et, isOutputTargetDocsCustom as F, isOutputTargetStats as G, isOutputTargetSsr as H, isOutputTargetDocsCustomElementsManifest as I, isValidConfigOutputTarget as J, isOutputTargetTypes as K, isOutputTargetDocsJson as L, isOutputTargetCustom as M, isOutputTargetDistLazy as N, getComponentsFromModules as O, isOutputTargetDocs as P, loadTypeScriptDiagnostic as Q, isOutputTargetDocsReadme as R, ok as S, isGlob as St, filterExcludedComponents as T, stringifyRuntimeData as Tt, isOutputTargetSsrWasm as U, isOutputTargetLoaderBundle as V, isOutputTargetStandalone as W, shouldExcludeComponent as X, relativeImport as Y, augmentDiagnosticWithNode as Z, getSourceMappingUrlForEndOfFile as _, catchError as _t, getTextDocs as a, relative$1 as at, err as b, shouldIgnoreError as bt, isJsFile as c, isRolldownError as ct, isTsxFile as d, normalizeDiagnostics as dt, join$1 as et, parsePackageJson as f, splitLineBreaks as ft, getInlineSourceMappingUrlLinker as g, buildWarn as gt, isRemoteUrl as h, buildJsonFileError as ht, generatePreamble as i, normalizePath as it, isOutputTargetCopy as j, isOutputTargetAssets as k, isJsxFile as l, loadRolldownDiagnostics as lt, readPackageJson as m, buildError as mt, addDocBlock as n, normalizeFsPath as nt, hasDependency as o, resolve$1 as ot, readOnlyArrayHasStringMember as p, TASK_CANCELED_MSG as pt, isOutputTargetWww as q, createJsVarName as r, normalizeFsPathQuery as rt, isDtsFile as s, createOnWarnFn as st, validateComponentTag as t, normalize as tt, isTsFile as u, escapeHtml as ut, getSourceMappingUrlLinker as v, hasError as vt, filterActiveTargets as w, formatLazyBundleRuntimeMeta as wt, map as x, isRootPath as xt, rolldownToStencilSourceMap as y, hasWarning as yt, isOutputTargetDocsVscode as z };