@arcgis/lumina-compiler 4.33.0-next.14 → 4.33.0-next.141

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 (143) hide show
  1. package/dist/context/index.d.ts +25 -25
  2. package/dist/context/logger.d.ts +8 -0
  3. package/dist/context/typeScript.d.ts +2 -2
  4. package/dist/context/utils.d.ts +1 -1
  5. package/dist/dependencies/arcgisCore.d.ts +1 -1
  6. package/dist/dependencies/discover.d.ts +5 -4
  7. package/dist/dependencies/index.d.ts +2 -2
  8. package/dist/dependencies/loaders.d.ts +3 -7
  9. package/dist/dependencies/lumina.d.ts +3 -0
  10. package/dist/dependencies/stencil.d.ts +3 -2
  11. package/dist/dependencies/testSetupFiles.d.ts +1 -9
  12. package/dist/dependencies/updateLumina.d.ts +4 -4
  13. package/dist/dependencies/utils.d.ts +2 -2
  14. package/dist/docs/config.d.ts +1 -1
  15. package/dist/docs/index.d.ts +2 -2
  16. package/dist/docs/stencilDocsJson.d.ts +7 -3
  17. package/dist/docs/vsCodeCustomData/index.d.ts +2 -2
  18. package/dist/docs/vsCodeCustomData/utils.d.ts +2 -2
  19. package/dist/docs/webTypes/description.d.ts +1 -1
  20. package/dist/docs/webTypes/index.d.ts +2 -2
  21. package/dist/docs/webTypes/utils.d.ts +2 -2
  22. package/dist/entrypoints/addNonLazyImports.d.ts +2 -2
  23. package/dist/entrypoints/config.d.ts +1 -0
  24. package/dist/entrypoints/dtsUtils.d.ts +3 -3
  25. package/dist/entrypoints/findUtils.d.ts +1 -1
  26. package/dist/entrypoints/handleComponentImports.d.ts +2 -2
  27. package/dist/entrypoints/pathMapping.d.ts +1 -1
  28. package/dist/entrypoints/resolveTagName.d.ts +3 -3
  29. package/dist/extractor/apiJsonUtils.d.ts +2 -2
  30. package/dist/extractor/declaration.d.ts +1 -38
  31. package/dist/extractor/extractor.d.ts +6 -5
  32. package/dist/extractor/helpers/cssDoc.d.ts +1 -1
  33. package/dist/extractor/helpers/event.d.ts +3 -3
  34. package/dist/extractor/helpers/method.d.ts +3 -3
  35. package/dist/extractor/helpers/property.d.ts +3 -3
  36. package/dist/extractor/helpers/resolveType.d.ts +3 -3
  37. package/dist/extractor/helpers/typeValue.d.ts +2 -2
  38. package/dist/extractor/index.d.ts +3 -3
  39. package/dist/extractor/parseStoryFiles.d.ts +2 -0
  40. package/dist/frameworkTypes/index.d.ts +2 -2
  41. package/dist/frameworkTypes/lumina.d.ts +1 -1
  42. package/dist/frameworkTypes/preact.d.ts +1 -1
  43. package/dist/frameworkTypes/react.d.ts +1 -1
  44. package/dist/frameworkTypes/stencil.d.ts +1 -1
  45. package/dist/frameworkTypes/utils.d.ts +2 -2
  46. package/dist/frameworkTypes/vanilla.d.ts +1 -1
  47. package/dist/index.d.ts +11 -11
  48. package/dist/index.js +6886 -110
  49. package/dist/jsxToLitHtml/autoAddNothing.d.ts +2 -2
  50. package/dist/jsxToLitHtml/comments.d.ts +4 -4
  51. package/dist/jsxToLitHtml/config.d.ts +1 -1
  52. package/dist/jsxToLitHtml/convertProps.d.ts +5 -6
  53. package/dist/jsxToLitHtml/imports.d.ts +2 -3
  54. package/dist/jsxToLitHtml/index.d.ts +1 -1
  55. package/dist/jsxToLitHtml/inferPropType.d.ts +3 -3
  56. package/dist/jsxToLitHtml/insertRepeatCall.d.ts +2 -2
  57. package/dist/jsxToLitHtml/jsxVisitor.d.ts +3 -4
  58. package/dist/jsxToLitHtml/templateParts.d.ts +2 -2
  59. package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +1 -1
  60. package/dist/jsxToLitHtml/types.d.ts +5 -4
  61. package/dist/jsxToLitHtml/utils.d.ts +1 -0
  62. package/dist/loader/hideUntilHydrated.d.ts +1 -1
  63. package/dist/loader/index.d.ts +2 -2
  64. package/dist/loader/lazy.d.ts +3 -3
  65. package/dist/loader/storybookApiJson.d.ts +1 -1
  66. package/dist/logger-KpGU2b3R.js +28 -0
  67. package/dist/plugins/buildCdn.d.ts +56 -6
  68. package/dist/plugins/buildStencilHydrate.d.ts +2 -2
  69. package/dist/plugins/buildWebApp.d.ts +3 -0
  70. package/dist/plugins/buildWrappers.d.ts +2 -2
  71. package/dist/plugins/configureVite.d.ts +5 -5
  72. package/dist/plugins/externalizeDependencies.d.ts +2 -6
  73. package/dist/plugins/handleDynamicAssets.d.ts +2 -2
  74. package/dist/plugins/handleStaticAssets.d.ts +2 -2
  75. package/dist/plugins/loadLitCss.d.ts +2 -6
  76. package/dist/plugins/printTotalBuildSize.d.ts +2 -2
  77. package/dist/plugins/provideAssets.d.ts +3 -20
  78. package/dist/plugins/setAssetsPath.d.ts +2 -2
  79. package/dist/plugins/updatePackageJson.d.ts +4 -4
  80. package/dist/publicTypes.d.ts +89 -30
  81. package/dist/puppeteerTesting/globalSetup.d.ts +2 -2
  82. package/dist/puppeteerTesting/globalSetup.js +105 -2
  83. package/dist/puppeteerTesting/index.d.ts +7 -8
  84. package/dist/puppeteerTesting/index.js +1134 -5
  85. package/dist/puppeteerTesting/injected.d.ts +1 -1
  86. package/dist/puppeteerTesting/puppeteer/browser.d.ts +1 -1
  87. package/dist/puppeteerTesting/puppeteer/element.d.ts +3 -3
  88. package/dist/puppeteerTesting/puppeteer/events.d.ts +2 -2
  89. package/dist/puppeteerTesting/puppeteer/page.d.ts +1 -1
  90. package/dist/puppeteerTesting/puppeteer/types.d.ts +3 -3
  91. package/dist/puppeteerTesting/vitest/matchers/attributes.d.ts +1 -1
  92. package/dist/puppeteerTesting/vitest/matchers/classList.d.ts +1 -1
  93. package/dist/puppeteerTesting/vitest/matchers/events.d.ts +1 -1
  94. package/dist/puppeteerTesting/vitest/matchers/index.d.ts +13 -13
  95. package/dist/puppeteerTesting/vitest/matchers/text.d.ts +1 -1
  96. package/dist/puppeteerTesting/vitest/runner.d.ts +3 -3
  97. package/dist/puppeteerTesting/vitest/runner.js +50 -1
  98. package/dist/puppeteerTesting/vitest/types.d.ts +1 -1
  99. package/dist/testing/index.d.ts +4 -4
  100. package/dist/testing/index.js +152 -24
  101. package/dist/testing/mount.d.ts +9 -2
  102. package/dist/testing/wrapController.d.ts +2 -3
  103. package/dist/tests/utils.d.ts +3 -3
  104. package/dist/transformers/index.d.ts +3 -3
  105. package/dist/transformers/injectRuntimeOptions.d.ts +2 -2
  106. package/dist/transformers/internalTypeScriptApis.d.ts +2 -2
  107. package/dist/transformers/liftDecorators.d.ts +1 -1
  108. package/dist/transformers/members.d.ts +2 -2
  109. package/dist/transformers/property.d.ts +4 -4
  110. package/dist/transformers/propertyOptions.d.ts +5 -5
  111. package/dist/transformers/utils.d.ts +3 -3
  112. package/dist/types/astTransformers.d.ts +2 -2
  113. package/dist/types/hideInternalLitElement.d.ts +1 -1
  114. package/dist/types/index.d.ts +2 -2
  115. package/dist/types/liftSetterTypes.d.ts +2 -3
  116. package/dist/types/textTransformers.d.ts +2 -2
  117. package/dist/types/transformComponentMembers.d.ts +1 -1
  118. package/dist/types-C3YmWTVv.js +13 -0
  119. package/dist/useLumina.d.ts +1 -1
  120. package/package.json +14 -13
  121. package/dist/chunk-6XNX5V4L.js +0 -1
  122. package/dist/chunk-JFKSI6I7.js +0 -1
  123. package/dist/context/typeScript.spec.d.ts +0 -1
  124. package/dist/context/utils.spec.d.ts +0 -1
  125. package/dist/defaultAssetsUrl.spec.d.ts +0 -1
  126. package/dist/dependencies/lit.d.ts +0 -2
  127. package/dist/dependencies/updateLumina.spec.d.ts +0 -1
  128. package/dist/docs/steniclDocsJson.test.d.ts +0 -1
  129. package/dist/entrypoints/dtsUtils.spec.d.ts +0 -1
  130. package/dist/entrypoints/findUtils.spec.d.ts +0 -1
  131. package/dist/entrypoints/resolveTagName.spec.d.ts +0 -1
  132. package/dist/extractor/declaration.spec.d.ts +0 -1
  133. package/dist/extractor/helpers/cssDoc.spec.d.ts +0 -1
  134. package/dist/extractor/helpers/jsDoc.d.ts +0 -11
  135. package/dist/extractor/helpers/resolveType.spec.d.ts +0 -1
  136. package/dist/extractor/helpers/typeValue.spec.d.ts +0 -1
  137. package/dist/jsxToLitHtml/utils.spec.d.ts +0 -1
  138. package/dist/loader/lazy.spec.d.ts +0 -1
  139. package/dist/plugins/buildCdn.spec.d.ts +0 -1
  140. package/dist/plugins/externalizeDependencies.spec.d.ts +0 -1
  141. package/dist/plugins/provideAssets.spec.d.ts +0 -1
  142. package/dist/plugins/updatePackageJson.spec.d.ts +0 -1
  143. package/dist/types/failOnJsonImport.d.ts +0 -2
@@ -1,14 +1,13 @@
1
- import type ts from "typescript";
2
- import type { Plugin } from "vite";
3
- import type { build as esbuildBuild } from "esbuild";
4
- import type { CompilerContext } from "./context";
5
- import type { PluginOptions as VitePluginDtsOptions } from "vite-plugin-dts";
6
- import type { ExternalsOptions as RollupPluginNodeExternalsOptions } from "rollup-plugin-node-externals";
7
- import type { PuppeteerLaunchOptions } from "puppeteer";
8
- import type { WebTypesOptions } from "./docs/webTypes/types";
9
- import type { VsCodeDocOptions } from "./docs/vsCodeCustomData/types";
10
- import type { ApiJson, ApiModule } from "@arcgis/api-extractor";
11
- import type { LuminaApiExtractor } from "./extractor/extractor";
1
+ import { default as ts } from 'typescript';
2
+ import { Plugin } from 'vite';
3
+ import { build as esbuildBuild } from 'esbuild';
4
+ import { CompilerContext } from './context';
5
+ import { PluginOptions as VitePluginDtsOptions } from 'vite-plugin-dts';
6
+ import { ExternalsOptions as RollupPluginNodeExternalsOptions } from 'rollup-plugin-node-externals';
7
+ import { WebTypesOptions } from './docs/webTypes/types';
8
+ import { VsCodeDocOptions } from './docs/vsCodeCustomData/types';
9
+ import { ApiJson, ApiModule, CopyDocDefinitions } from '@arcgis/api-extractor';
10
+ import { LuminaApiExtractor } from './extractor/extractor';
12
11
  /**
13
12
  * `useLumina()` returns an array of Vite plugins. The array additionally
14
13
  * has a `context` property for accessing the compiler context.
@@ -71,6 +70,19 @@ export type BuildOptions = {
71
70
  * Configuration for CDN build.
72
71
  */
73
72
  readonly cdn?: BuildCdnOptions;
73
+ /** @deprecated Use Storybook build or separate test app package. */
74
+ readonly webApp?: {
75
+ /**
76
+ * If set, will produce a web app build, based on index.html files and
77
+ * cdn build.
78
+ *
79
+ * @default undefined
80
+ * @example "www"
81
+ * @see [Based on Stencil's www build](https://stenciljs.com/docs/www)
82
+ * @deprecated Use Storybook build or separate test app package.
83
+ */
84
+ readonly destination?: string;
85
+ };
74
86
  /**
75
87
  * Options for externalizing or bundling in dependencies.
76
88
  */
@@ -115,19 +127,39 @@ export type BuildCdnOptions = {
115
127
  */
116
128
  readonly skip?: boolean;
117
129
  /**
130
+ * @deprecated To improve CDN experience and simplify redirect handling,
131
+ * deprecated namespace to use consistent CDN folder and file names.
132
+ *
133
+ * Reference: https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/5051#issuecomment-5482327
134
+ *
118
135
  * Determines the CDN folder name and the name of the entrypoint file inside.
119
136
  *
120
137
  * @default "cdn"
121
138
  */
122
139
  readonly namespace?: string;
123
140
  /**
124
- * To produce the CDN build, Lumina takes the lazy-loading build of your
125
- * package, and post-processes it with ESBuild. You can customize the options
126
- * passed to ESBuild.
141
+ * To produce the CDN build, Lumina takes the dist/loader.js file and
142
+ * and post-processes it with ESBuild to make it ready for consumption in the
143
+ * browser.
144
+ *
145
+ * You can customize the options passed to ESBuild. Note, some options may
146
+ * conflict with the Lumina build process.
127
147
  *
128
148
  * @see https://esbuild.github.io/api/#overview
129
149
  */
130
150
  readonly esbuildOptions?: Parameters<typeof esbuildBuild>[0];
151
+ /**
152
+ * A callback for mutating CDN chunks before they are written to disk.
153
+ * This callback is for advanced use cases only. The build output may change
154
+ * between Lumina versions without prior notice. Using this callback may
155
+ * corrupt the CDN source map if it is enabled.
156
+ */
157
+ readonly transformer?: (chunks: Map<string, CdnChunk>, context: CompilerContext) => void;
158
+ };
159
+ export type CdnChunk = {
160
+ code: string;
161
+ isAsync: boolean | undefined;
162
+ oldSingleExportName: string | undefined;
131
163
  };
132
164
  /**
133
165
  * Generic type for the different kinds of wrappers.
@@ -237,7 +269,13 @@ export type ServeEnvironmentOptions = {
237
269
  * `index.html`.
238
270
  * In such case, you can set `extraDependencies: ["@arcgis/map-components"]`
239
271
  */
240
- readonly extraDependencies?: string[];
272
+ readonly extraDependencies?: (DetailedExtraDependency | string)[];
273
+ };
274
+ export type DetailedExtraDependency = {
275
+ /** @example "@arcgis/map-config-components" */
276
+ name: string;
277
+ /** @example ():string => `https://example.com/arcgis-components/builds/main/cdn/map-config-components/` */
278
+ getCdnUrl: (context: CompilerContext) => string;
241
279
  };
242
280
  export type PuppeteerTestingOptions = {
243
281
  /**
@@ -252,9 +290,20 @@ export type PuppeteerTestingOptions = {
252
290
  * @default 0
253
291
  */
254
292
  readonly waitForChangesDelay?: number;
255
- readonly launchOptions?: PuppeteerLaunchOptions;
293
+ /**
294
+ * @example
295
+ * ```ts
296
+ * import type { LaunchOptions } from "puppeteer";
297
+ * // ...
298
+ * launchOptions: {
299
+ * args: ["--no-sandbox", "--disable-setuid-sandbox"],
300
+ * } satisfies LaunchOptions;
301
+ * ```
302
+ */
303
+ readonly launchOptions?: Record<string, unknown>;
256
304
  };
257
305
  export type GenerateDocumentationOptions = {
306
+ readonly copyDefinitions?: CopyDocDefinitions;
258
307
  /**
259
308
  * The name of the file to write the api.json to. api.json is a file format
260
309
  * based on custom-elements-manifest that describes all the components in the
@@ -267,22 +316,39 @@ export type GenerateDocumentationOptions = {
267
316
  * The name of the file to write the Stencil-like docs JSON to.
268
317
  * For backwards compatibility.
269
318
  *
319
+ * @deprecated Use api.json instead.
270
320
  * @default "docs/docs.json"
271
321
  * @see https://stenciljs.com/docs/docs-json
272
322
  */
273
323
  readonly stencilLikeDocsJsonFileName?: string | false;
324
+ /**
325
+ * Get a prefix for a public-facing URL for each component story.
326
+ *
327
+ * @example
328
+ * Set this to "https://developers.arcgis.com/javascript/latest/storybook/map-components/".
329
+ * This will produce URLs like
330
+ * "https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/arcgis-area-measurement-2d--demo&singleStory=true"
331
+ * @see https://qawebgis.esri.com/components/lumina/storybook
332
+ */
333
+ readonly publicStoryUrlPrefix?: string;
274
334
  /**
275
335
  * Provide a URL to a page that documents the component.
276
336
  * This URL will be visible in VS Code and IntelliJ when hovering over a
277
337
  * component tag in an .html file
338
+ *
339
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/references/map-components/${tagName}/`
278
340
  */
279
- readonly getComponentDocsUrl?: (tag: string, name: string) => string | undefined;
341
+ readonly getComponentDocsUrl?: (tagName: string, className: string) => string | undefined;
280
342
  /**
281
343
  * Provide a URL to a page that documents the component.
282
344
  * This URL will be visible in VS Code and IntelliJ when hovering over a
283
345
  * component tag in an .html file
346
+ *
347
+ * If you wish to provide multiple URLs, use "getPublicStoryUrl" instead.
348
+ *
349
+ * @example (tagName) => `https://developers.arcgis.com/javascript/latest/storybook/map-components/?path=/story/${tagName}--demo&singleStory=true`
284
350
  */
285
- readonly getComponentDemoUrl?: (tag: string, name: string) => string | undefined;
351
+ readonly getComponentDemoUrl?: (tagName: string, className: string) => string | undefined;
286
352
  /**
287
353
  * Additional options for web component documentation for VS Code. This
288
354
  * documentation provides intellisense when editing .html and .css files.
@@ -328,7 +394,7 @@ export type GenerateTypesOptions = Omit<VitePluginDtsOptions, "beforeWriteFile"
328
394
  * This transformer is used only on .d.ts files of your components. Any
329
395
  * .d.ts files for utility files or other non-entrypoint files are not
330
396
  * affected by this transformer. For those, you can use the
331
- * `declarationAstTransformers` option.
397
+ * `declarationTextTransformers` option.
332
398
  */
333
399
  readonly declarationAstTransformers?: FileTransformer[];
334
400
  /**
@@ -407,7 +473,7 @@ export type ApiJsonOptions = {
407
473
  *
408
474
  * @default LuminaApiExtractor
409
475
  */
410
- readonly Extractor: typeof LuminaApiExtractor;
476
+ readonly Extractor?: typeof LuminaApiExtractor;
411
477
  /**
412
478
  * This function will be called after the api.json is created but before it is
413
479
  * used to generate any output files.
@@ -645,14 +711,14 @@ export type AssetTransformer = {
645
711
  };
646
712
  export type LintingOptions = {
647
713
  /**
648
- * Lumina emits build-time errors for common issues and possible bugs.
714
+ * Lumina includes build-time checks for common issues and possible bugs.
649
715
  * Most of those should be immediately addressable. However, some (like
650
716
  * updating default value for boolean properties) may require a breaking
651
717
  * change.
652
718
  *
653
- * This option exists to temporary turn these errors into warnings.
719
+ * This option exists to temporarily turn these errors into warnings.
654
720
  * @example
655
- * To silence an error in a file, add an entry like thw following with the
721
+ * To silence an error in a file, add an entry like the following with the
656
722
  * relative path to the file:
657
723
  *
658
724
  * ```ts
@@ -660,13 +726,6 @@ export type LintingOptions = {
660
726
  * ```
661
727
  */
662
728
  silence: {
663
- /**
664
- * Default values for boolean properties must default to false (or
665
- * undefined), never to true.
666
- *
667
- * [Documentation](https://qawebgis.esri.com/components/lumina/properties#boolean-properties)
668
- */
669
- booleanMustDefaultFalse?: string[];
670
729
  /**
671
730
  * Lumina components may declare required properties using `@required` JSDoc
672
731
  * tag.
@@ -1,5 +1,5 @@
1
- import type { GlobalSetupContext } from "vitest/dist/node.js";
2
- import { type ConnectOptions } from "puppeteer";
1
+ import { GlobalSetupContext } from 'vitest/dist/node.js';
2
+ import { ConnectOptions } from 'puppeteer';
3
3
  declare module "vitest" {
4
4
  interface ProvidedContext {
5
5
  isDevToolsEnabled?: boolean;
@@ -1,4 +1,95 @@
1
- import"../chunk-JFKSI6I7.js";import{launch as l}from"puppeteer";import{createServer as a}from"vite";async function m(t){process.cwd()!==t.config.root&&process.chdir(t.config.root);let[r,e]=await Promise.all([p(t),d(t)]);return async()=>{await Promise.all([e.close(),r.close()]),setInterval(()=>{e.watcher.close()},100).unref()}}async function p(t){let r=t.config,e=r.puppeteerLaunchOptions??{},o=1e3*60*60,s={acceptInsecureCerts:!0,protocolTimeout:e.devtools?o:void 0,args:["--force-prefers-no-reduced-motion",...e.args??[]],...e,headless:e.headless??(e.devtools?void 0:"shell")},n=await l(s),i={...s,browserWSEndpoint:n.wsEndpoint()};return t.provide("puppeteerConnectOptions",i),t.provide("isDevToolsEnabled",s.devtools??!1),t.provide("isHeadlessBrowser",e.headless===void 0?e.devtools!==!0:e.headless!==!1),t.provide("puppeteerWaitForChangesDelay",r.puppeteerWaitForChangesDelay),n}async function d(t){let r={__IS_IN_PUPPETEER__:!0},e=await a({logLevel:"error",server:{open:!1,hmr:!1},root:t.config.root,mode:t.config.mode,clearScreen:!1,define:r});return await e.listen(),await v(t,e),c(t,e),e}async function v(t,r){let e=await r.transformIndexHtml("/",`<!doctype html>
1
+ import { launch as i } from "puppeteer";
2
+ import { createServer as l } from "vite";
3
+ async function h(r) {
4
+ process.cwd() !== r.config.root && process.chdir(r.config.root);
5
+ const [o, e] = await Promise.all([c(r), d(r)]);
6
+ return async () => {
7
+ await Promise.all([e.close(), o.close()]), setInterval(() => {
8
+ e.watcher.close();
9
+ }, 100).unref();
10
+ };
11
+ }
12
+ async function c(r) {
13
+ const o = r.config, e = o.puppeteerLaunchOptions ?? {}, t = 1e3 * 60 * 60, s = {
14
+ acceptInsecureCerts: !0,
15
+ /**
16
+ * Allow stopping on a "debugger;" breakpoint for 30 min. Default was 3min.
17
+ */
18
+ protocolTimeout: e.devtools ? t : void 0,
19
+ /**
20
+ * Force animations to be enabled to run tests consistently regardless of OS
21
+ * settings.
22
+ */
23
+ args: ["--force-prefers-no-reduced-motion", ...e.args ?? []],
24
+ ...e,
25
+ /**
26
+ * The "new" headless mode is running very slow when you have multiple
27
+ * browser tabs open (running tests concurrently). The slowdown seems to be
28
+ * most prominent around `requestAnimationFrame()`, which sometimes takes
29
+ * up to 15s! It indeed appears that `requestAnimationFrame()` is one tab
30
+ * is blocked until several other tabs complete and close.
31
+ *
32
+ * All these issues are fixed by using the old headless mode. It is marked
33
+ * to be removed from Puppeteer in 2024. However, we are looking to migrate
34
+ * away from Puppeteer toward Vitest Browser Mode (Playwright) anyway.
35
+ *
36
+ * See:
37
+ * - https://github.com/puppeteer/puppeteer/issues/11944#issuecomment-1967860373
38
+ * - https://github.com/puppeteer/puppeteer/issues/10109
39
+ * - https://github.com/puppeteer/puppeteer/issues/12982
40
+ */
41
+ headless: e.headless ?? (e.devtools ? void 0 : "shell")
42
+ }, n = await i(s), a = { ...s, browserWSEndpoint: n.wsEndpoint() };
43
+ return r.provide("puppeteerConnectOptions", a), r.provide("isDevToolsEnabled", s.devtools ?? !1), r.provide(
44
+ "isHeadlessBrowser",
45
+ /**
46
+ * Default value for headless depends on devtools argument:
47
+ * https://github.com/puppeteer/puppeteer/blob/b5f08d55401dcfbcfd5d885920ec5098f96ab249/packages/puppeteer-core/src/node/ChromeLauncher.ts#L241-L242
48
+ */
49
+ e.headless === void 0 ? e.devtools !== !0 : e.headless !== !1
50
+ ), r.provide("puppeteerWaitForChangesDelay", o.puppeteerWaitForChangesDelay), n;
51
+ }
52
+ async function d(r) {
53
+ const o = {
54
+ // eslint-disable-next-line @typescript-eslint/naming-convention
55
+ __IS_IN_PUPPETEER__: !0
56
+ }, e = await l({
57
+ /**
58
+ * Do not clutter tests console with Vite logs.
59
+ * Also, this matches the setting that Vitest uses when it starts up Vite.
60
+ */
61
+ logLevel: "error",
62
+ server: {
63
+ /**
64
+ * Vitest should not auto-open the page (as it would do so in the default
65
+ * browser). Instead, if you want to see the page, you should start
66
+ * puppeteer in headed mode, which will open the browser for you.
67
+ */
68
+ open: !1,
69
+ /**
70
+ * On code changes, browser page reloading will cause a Puppeteer page
71
+ * navigation, which will fail the test. Instead of HMR, use Vitest
72
+ * watch mode.
73
+ */
74
+ hmr: !1
75
+ },
76
+ /**
77
+ * This should be process.cwd() in most cases, but setting in here just in
78
+ * case
79
+ */
80
+ root: r.config.root,
81
+ // Set mode to "test"
82
+ mode: r.config.mode,
83
+ // This interferes with the Vitest output
84
+ clearScreen: !1,
85
+ define: o
86
+ });
87
+ return await e.listen(), await v(r, e), p(r, e), e;
88
+ }
89
+ async function v(r, o) {
90
+ const e = await o.transformIndexHtml(
91
+ "/",
92
+ `<!doctype html>
2
93
  <html lang="en">
3
94
  <head>
4
95
  <meta charset="utf-8" />
@@ -8,4 +99,16 @@ import"../chunk-JFKSI6I7.js";import{launch as l}from"puppeteer";import{createSer
8
99
  </head>
9
100
  <body>
10
101
  </body>
11
- </html>`);t.provide("devServerHtml",e)}function c(t,r){let e=r.resolvedUrls,o=e?.local.at(0)??e?.network.at(0);if(o===void 0)throw new Error("Failed to resolve the dev server URL");t.provide("devServerUrl",o)}export{m as setup};
102
+ </html>`
103
+ );
104
+ r.provide("devServerHtml", e);
105
+ }
106
+ function p(r, o) {
107
+ const e = o.resolvedUrls, t = e?.local.at(0) ?? e?.network.at(0);
108
+ if (t === void 0)
109
+ throw new Error("Failed to resolve the dev server URL");
110
+ r.provide("devServerUrl", t);
111
+ }
112
+ export {
113
+ h as setup
114
+ };
@@ -1,11 +1,10 @@
1
- import "vitest";
2
- import type { PuppeteerMatchers } from "./vitest/matchers";
3
- export type * from "./puppeteer/types";
4
- export type { NewE2EPageOptions } from "./puppeteer/page";
5
- export { newE2EPage } from "./puppeteer/page";
6
- export type { E2EElement } from "./puppeteer/element";
7
- export type { EventSpy } from "./puppeteer/events";
8
- export { setupPuppeteerTest } from "./vitest/setupFile";
1
+ import { PuppeteerMatchers } from './vitest/matchers';
2
+ export type * from './puppeteer/types';
3
+ export type { NewE2EPageOptions } from './puppeteer/page';
4
+ export { newE2EPage } from './puppeteer/page';
5
+ export type { E2EElement } from './puppeteer/element';
6
+ export type { EventSpy } from './puppeteer/events';
7
+ export { setupPuppeteerTest } from './vitest/setupFile';
9
8
  declare module "vitest" {
10
9
  interface Assertion<T = any> extends PuppeteerMatchers<T> {
11
10
  }