@jsenv/core 23.9.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,11 +38,11 @@ export const executePlan = async (
38
38
  coverageV8ConflictWarning,
39
39
  coverageTempDirectoryRelativeUrl,
40
40
 
41
- compileServerProtocol,
42
- compileServerPrivateKey,
43
- compileServerCertificate,
44
- compileServerIp,
45
- compileServerPort,
41
+ protocol,
42
+ privateKey,
43
+ certificate,
44
+ ip,
45
+ port,
46
46
  compileServerCanReadFromFilesystem,
47
47
  compileServerCanWriteOnFilesystem,
48
48
  babelPluginMap,
@@ -99,7 +99,7 @@ export const executePlan = async (
99
99
  try {
100
100
  const compileServer = await startCompileServer({
101
101
  signal: multipleExecutionsOperation.signal,
102
- compileServerLogLevel,
102
+ logLevel: compileServerLogLevel,
103
103
 
104
104
  projectDirectoryUrl,
105
105
  jsenvDirectoryRelativeUrl,
@@ -109,11 +109,11 @@ export const executePlan = async (
109
109
  importResolutionMethod,
110
110
  importDefaultExtension,
111
111
 
112
- compileServerProtocol,
113
- compileServerPrivateKey,
114
- compileServerCertificate,
115
- compileServerIp,
116
- compileServerPort,
112
+ protocol,
113
+ privateKey,
114
+ certificate,
115
+ ip,
116
+ port,
117
117
  compileServerCanReadFromFilesystem,
118
118
  compileServerCanWriteOnFilesystem,
119
119
  keepProcessAlive: true, // to be sure it stays alive
@@ -1,22 +1,28 @@
1
1
  import { scanBrowserRuntimeFeatures } from "../runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js"
2
- import { fetchExploringJson } from "./fetchExploringJson.js"
3
2
 
4
3
  const redirect = async () => {
5
- const [browserRuntimeFeaturesReport, { exploringHtmlFileRelativeUrl }] =
6
- await Promise.all([
7
- scanBrowserRuntimeFeatures({
8
- failFastOnFeatureDetection: true,
9
- }),
10
- fetchExploringJson(),
11
- ])
4
+ const redirectTarget = new URLSearchParams(window.location.search).get(
5
+ "redirect",
6
+ )
7
+ const browserRuntimeFeaturesReport = await scanBrowserRuntimeFeatures({
8
+ failFastOnFeatureDetection: true,
9
+ })
12
10
 
13
- if (browserRuntimeFeaturesReport.canAvoidCompilation) {
14
- window.location.href = `/${exploringHtmlFileRelativeUrl}`
15
- return
16
- }
11
+ const href = `${getDirectoryUrl(
12
+ browserRuntimeFeaturesReport,
13
+ )}${redirectTarget}`
14
+ window.location.href = href
15
+ }
17
16
 
18
- const { outDirectoryRelativeUrl, compileId } = browserRuntimeFeaturesReport
19
- window.location.href = `/${outDirectoryRelativeUrl}${compileId}/${exploringHtmlFileRelativeUrl}`
17
+ const getDirectoryUrl = ({
18
+ canAvoidCompilation,
19
+ outDirectoryRelativeUrl,
20
+ compileId,
21
+ }) => {
22
+ if (canAvoidCompilation) {
23
+ return `/`
24
+ }
25
+ return `/${outDirectoryRelativeUrl}${compileId}/`
20
26
  }
21
27
 
22
28
  redirect()
@@ -59,7 +59,7 @@ chromiumRuntime.launch = async ({
59
59
  })
60
60
  : chromiumSharing.getUniqueSharingToken()
61
61
  if (!sharingToken.isUsed()) {
62
- const { chromium } = await import("playwright")
62
+ const { chromium } = await importPlaywright({ browserName: "chromium" })
63
63
  const launchOperation = launchBrowser("chromium", {
64
64
  browserClass: chromium,
65
65
  launchBrowserOperation,
@@ -165,7 +165,7 @@ firefoxRuntime.launch = async ({
165
165
  ? firefoxSharing.getSharingToken({ firefoxExecutablePath, headless })
166
166
  : firefoxSharing.getUniqueSharingToken()
167
167
  if (!sharingToken.isUsed()) {
168
- const { firefox } = await import("playwright")
168
+ const { firefox } = await importPlaywright({ browserName: "firefox" })
169
169
  const launchOperation = launchBrowser("firefox", {
170
170
  browserClass: firefox,
171
171
 
@@ -244,7 +244,7 @@ webkitRuntime.launch = async ({
244
244
  : webkitSharing.getUniqueSharingToken()
245
245
 
246
246
  if (!sharingToken.isUsed()) {
247
- const { webkit } = await import("playwright")
247
+ const { webkit } = await await importPlaywright({ browserName: "webkit" })
248
248
  const launchOperation = launchBrowser("webkit", {
249
249
  browserClass: webkit,
250
250
  launchBrowserOperation,
@@ -349,6 +349,26 @@ const launchBrowser = async (
349
349
  }
350
350
  }
351
351
 
352
+ const importPlaywright = async ({ browserName }) => {
353
+ try {
354
+ const namespace = await import("playwright")
355
+ return namespace
356
+ } catch (e) {
357
+ if (e.code === "ERR_MODULE_NOT_FOUND") {
358
+ throw new Error(
359
+ createDetailedMessage(
360
+ `"playwright" not found. You need playwright in your dependencies when using "${browserName}Runtime"`,
361
+ {
362
+ suggestion: `npm install --save-dev playwright`,
363
+ },
364
+ ),
365
+ { cause: e },
366
+ )
367
+ }
368
+ throw e
369
+ }
370
+ }
371
+
352
372
  const stopBrowser = async (browser) => {
353
373
  const disconnected = browser.isConnected()
354
374
  ? new Promise((resolve) => {