extension-develop 4.1.39 → 4.1.40-canary.458.001a6a0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/{771~0.mjs → 5h~0.mjs} +13 -3
- package/dist/{273~0.mjs → 6l~0.mjs} +1 -1
- package/dist/{524~0.mjs → 9~0.mjs} +18 -2
- package/dist/{640~0.mjs → bh~0.mjs} +6 -1
- package/dist/bridge.mjs +14 -8
- package/dist/b~0.mjs +8568 -0
- package/dist/command-dev.d.ts +2 -0
- package/dist/command-preview.d.ts +2 -0
- package/dist/contracts.mjs +2 -1
- package/dist/{469~0.mjs → cp~0.mjs} +30 -18
- package/dist/css-parse-guard-loader.mjs +2 -2
- package/dist/c~0.mjs +56 -0
- package/dist/dead-css-url-loader.mjs +20 -119
- package/dist/dev-server/control-bridge/actions-file.d.ts +7 -0
- package/dist/dev-server/control-bridge/broker.d.ts +42 -2
- package/dist/dev-server/control-bridge/consumer-client.d.ts +7 -0
- package/dist/dev-server/control-bridge/contracts.d.ts +29 -1
- package/dist/dev-server/control-bridge/logs-file.d.ts +6 -0
- package/dist/dev-server/control-bridge/loopback.d.ts +1 -0
- package/dist/dev-server/control-bridge/producer-runtime.d.ts +5 -2
- package/dist/dev-server/control-bridge/production-control.d.ts +1 -0
- package/dist/dev-server/control-bridge/session-token.d.ts +5 -2
- package/dist/dev-server/cors.d.ts +4 -2
- package/dist/dev-server/messages.d.ts +6 -0
- package/dist/dev-server/session-restart.d.ts +3 -1
- package/dist/dev-server~0.mjs +71 -129
- package/dist/df~0.mjs +197 -0
- package/dist/{846~0.mjs → d~0.mjs} +4 -3
- package/dist/ensure-hmr-for-scripts.js +3 -3
- package/dist/ensure-hmr-for-scripts.mjs +3 -3
- package/dist/extension-js-devtools/build-stamp.json +2 -2
- package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
- package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
- package/dist/extension-js-theme/build-stamp.json +2 -2
- package/dist/{143~0.mjs → ey~0.mjs} +2 -2
- package/dist/e~0.mjs +33 -0
- package/dist/feature-scripts-classic-traced-globals-loader.mjs +7 -2
- package/dist/feature-scripts-content-script-wrapper.js +55 -17
- package/dist/feature-scripts-content-script-wrapper.mjs +55 -17
- package/dist/feature-scripts-native-geturl-import-loader.mjs +1 -1
- package/dist/{105~0.mjs → g0~0.mjs} +1 -1
- package/dist/{88~0.mjs → j6~0.mjs} +9 -1
- package/dist/{731~0.mjs → j~0.mjs} +2 -2
- package/dist/{712~0.mjs → ka~0.mjs} +18 -2
- package/dist/{852~0.mjs → k~0.mjs} +4 -2
- package/dist/late-css-import-loader.mjs +1 -1
- package/dist/lib/addon-lint.d.ts +6 -0
- package/dist/lib/build-summary.d.ts +6 -0
- package/dist/lib/dev-additions.d.ts +12 -0
- package/dist/lib/extension-base-from-stack.d.ts +16 -0
- package/dist/lib/localized-manifest-name.d.ts +9 -0
- package/dist/lib/messages.d.ts +5 -2
- package/dist/lib/process-started-at.d.ts +1 -0
- package/dist/lib/real-path.d.ts +8 -0
- package/dist/lib/resource-path.d.ts +1 -0
- package/dist/lib/session-paths.d.ts +2 -0
- package/dist/lib/split-chunks.d.ts +2 -1
- package/dist/lib/stats-handler.d.ts +1 -0
- package/dist/lib/tsconfig-includes-file.d.ts +1 -0
- package/dist/l~0.mjs +2290 -0
- package/dist/main-world-bridge.js +92 -23
- package/dist/main-world-bridge.mjs +92 -23
- package/dist/manifest-entry.d.ts +2 -0
- package/dist/manifest.mjs +3 -1
- package/dist/module.mjs +3 -3
- package/dist/{832~0.mjs → m~0.mjs} +2242 -286
- package/dist/o~0.mjs +47 -0
- package/dist/plugin-browsers/index.d.ts +7 -0
- package/dist/plugin-browsers/safari-dev-plugin.d.ts +2 -0
- package/dist/plugin-compatibility/compatibility-lib/messages.d.ts +1 -1
- package/dist/plugin-compatibility/compatibility-lib/native-browser-namespace.d.ts +5 -0
- package/dist/plugin-compatibility/feature-browser-global.d.ts +4 -0
- package/dist/plugin-compilation/compilation-lib/messages.d.ts +4 -1
- package/dist/plugin-compilation/env.d.ts +1 -0
- package/dist/plugin-compilation/index.d.ts +2 -0
- package/dist/plugin-compilation/node-builtins.d.ts +5 -0
- package/dist/plugin-compilation/one-diagnostic-per-location.d.ts +13 -0
- package/dist/plugin-compilation/resolve-file-requests.d.ts +16 -0
- package/dist/plugin-compilation/warm-ancestor-watchers.d.ts +19 -0
- package/dist/plugin-compilation/watch-real-project-path.d.ts +27 -0
- package/dist/plugin-compilation/zip.d.ts +2 -0
- package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
- package/dist/plugin-css/css-lib/build-css-rules.d.ts +3 -0
- package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +3 -1
- package/dist/plugin-css/css-lib/messages.d.ts +4 -0
- package/dist/plugin-css/css-lib/sfc-style-block.d.ts +26 -0
- package/dist/plugin-css/css-lib/unplaced-style-imports.d.ts +7 -0
- package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
- package/dist/plugin-css/dead-css-url-loader.d.ts +9 -1
- package/dist/plugin-css/index.d.ts +1 -0
- package/dist/plugin-css/sfc-style-block-loader.d.ts +18 -0
- package/dist/plugin-css/unplaced-style-import-loader.d.ts +16 -0
- package/dist/plugin-playwright/index.d.ts +22 -0
- package/dist/plugin-reload/classify-reload.d.ts +20 -0
- package/dist/plugin-reload/index.d.ts +4 -2
- package/dist/plugin-reload/messages.d.ts +1 -0
- package/dist/plugin-reload/reload-dispatch.d.ts +21 -2
- package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +6 -0
- package/dist/plugin-reload/reload-lib/scripts-replay-shim.d.ts +1 -1
- package/dist/plugin-reload/steps/inject-bridge-producer.d.ts +6 -0
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/ChunkLoader.d.ts +3 -0
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/AutoPublicPath.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/BaseUri.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/LoadScript.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/PublicPath.d.ts +1 -1
- package/dist/plugin-special-folders/get-data.d.ts +2 -0
- package/dist/plugin-special-folders/hint-import-only-scripts.d.ts +4 -0
- package/dist/plugin-special-folders/include-files.d.ts +2 -0
- package/dist/plugin-special-folders/messages.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/html-lib/inject.d.ts +1 -1
- package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-gecko.d.ts +21 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/webkit-unsupported-keys.d.ts +15 -0
- package/dist/plugin-web-extension/feature-manifest/messages.d.ts +7 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-additions.d.ts +8 -0
- package/dist/plugin-web-extension/feature-manifest/steps/warn-description-length.d.ts +25 -0
- package/dist/plugin-web-extension/feature-manifest/steps/warn-gecko-unsupported-apis.d.ts +2 -2
- package/dist/plugin-web-extension/feature-scripts/contracts.d.ts +3 -0
- package/dist/plugin-web-extension/feature-scripts/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/messages.d.ts +9 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/completion-value.d.ts +13 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/injected-sheet-urls.d.ts +5 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-bridge-pairing.d.ts +5 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-copy-routing.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/registration-worlds.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-main-world-scripts.d.ts +25 -2
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-script-sheet.d.ts +14 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/taken-extension-base.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-base-uri-runtime-module.d.ts +7 -1
- package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-public-path-runtime-module.d.ts +6 -0
- package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/compile-main-world-scripts.d.ts +4 -0
- package/dist/plugin-web-extension/feature-scripts/steps/keep-completion-value.d.ts +6 -0
- package/dist/plugin-web-extension/feature-scripts/steps/pair-runtime-main-world-bridges.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/place-runtime-script-sheets.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/prune-main-world-bridges.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/root-injected-sheet-urls.d.ts +9 -0
- package/dist/plugin-web-extension/feature-scripts/steps/route-main-world-copies.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/source-literals.d.ts +24 -0
- package/dist/plugin-web-extension/feature-scripts/steps/take-extension-base.d.ts +11 -0
- package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +18 -3
- package/dist/plugin-web-extension/feature-scripts/steps/warn-main-world-registration-changed.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-moved-page-relative-urls.d.ts +30 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-page-relative-script-path.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-unknown-registration-world.d.ts +10 -0
- package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/page-requests.d.ts +5 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/unreachable-resources.d.ts +1 -0
- package/dist/plugin-web-extension/shared/script-graph.d.ts +12 -0
- package/dist/preprocessor-passthrough-loader.mjs +1 -1
- package/dist/preview.mjs +1 -1
- package/dist/public-css-url-loader.mjs +1 -1
- package/dist/{331~0.mjs → q~0.mjs} +2 -2
- package/dist/rj~0.mjs +125 -0
- package/dist/{519~0.mjs → rl~0.mjs} +53 -3
- package/dist/rspack-config~0.mjs +2768 -3256
- package/dist/{177~0.mjs → r~0.mjs} +2 -2
- package/dist/sfc-style-block-loader.mjs +49 -0
- package/dist/stats-handler~0.mjs +15 -7
- package/dist/tm~0.mjs +71 -0
- package/dist/types.d.ts +43 -3
- package/dist/{285~0.mjs → t~0.mjs} +41 -26
- package/dist/unplaced-style-import-loader.mjs +131 -0
- package/dist/x~0.mjs +3 -0
- package/dist/y~0.mjs +234 -0
- package/dist/zip~0.mjs +5 -4
- package/dist/{363~0.mjs → z~0.mjs} +360 -267
- package/package.json +5 -5
- package/dist/527~0.mjs +0 -3
- package/dist/840~0.mjs +0 -5635
- /package/dist/{895~0.mjs → 3~0.mjs} +0 -0
- /package/dist/{374~0.mjs → 5~0.mjs} +0 -0
- /package/dist/{206~0.mjs → 6~0.mjs} +0 -0
- /package/dist/{471~0.mjs → g~0.mjs} +0 -0
- /package/dist/{117~0.mjs → w~0.mjs} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { controlTokenPath, legacyControlTokenPath } from '../../lib/session-paths.js';
|
|
2
2
|
export { controlTokenPath, legacyControlTokenPath };
|
|
3
|
-
export
|
|
3
|
+
export interface ControlTokenIo {
|
|
4
|
+
rename?: (from: string, to: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function writeControlToken(projectPath: string, browser: string, io?: ControlTokenIo): string;
|
|
4
7
|
export declare function readControlToken(projectPath: string, browser: string): string | null;
|
|
5
|
-
export declare function clearControlToken(projectPath: string, browser: string): void;
|
|
8
|
+
export declare function clearControlToken(projectPath: string, browser: string, ownToken: string): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
export declare function isExtensionOrigin(value: unknown): boolean;
|
|
3
|
-
export
|
|
4
|
-
export declare function
|
|
3
|
+
export type SessionExtensionOriginCheck = (origin: string) => boolean;
|
|
4
|
+
export declare function resolveAllowedCorsOrigin(requestOrigin: unknown, allowedWebOrigins?: readonly (string | null | undefined)[], isSessionExtensionOrigin?: SessionExtensionOriginCheck): string | null;
|
|
5
|
+
export declare function devServerCorsHeaders(requestOrigin: unknown, allowedWebOrigins?: readonly (string | null | undefined)[], isSessionExtensionOrigin?: SessionExtensionOriginCheck): Array<{
|
|
5
6
|
key: string;
|
|
6
7
|
value: string;
|
|
7
8
|
}>;
|
|
@@ -15,6 +16,7 @@ export declare function devServerAccessConfig(options: {
|
|
|
15
16
|
connectableHost: string;
|
|
16
17
|
emulatorOrigin?: string | null;
|
|
17
18
|
allowedHosts?: unknown;
|
|
19
|
+
isSessionExtensionOrigin: SessionExtensionOriginCheck;
|
|
18
20
|
}): {
|
|
19
21
|
allowedHosts: string[];
|
|
20
22
|
headers: (req: IncomingMessage) => Array<{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DevAddition } from '../lib/dev-additions.js';
|
|
1
2
|
export declare function ready(mode: 'development' | 'production', browser: string): string;
|
|
2
3
|
export declare function browserRunnerDisabled(args: {
|
|
3
4
|
browser: string;
|
|
@@ -5,10 +6,13 @@ export declare function browserRunnerDisabled(args: {
|
|
|
5
6
|
readyPath: string;
|
|
6
7
|
distPath?: string;
|
|
7
8
|
}): string;
|
|
9
|
+
export declare function devAdditionsNote(additions: readonly DevAddition[]): string;
|
|
8
10
|
export declare function shouldWarnPortConflict(requested: unknown, actual: number): boolean;
|
|
9
11
|
export declare function emulatorViewerUrl(url: string): string;
|
|
10
12
|
export declare function portInUse(requestedPort: number, newPort: number): string;
|
|
11
13
|
export declare function devServerHostRefused(host: string): string;
|
|
14
|
+
export declare function debugSessionPorts(port: number, controlPort: number | null): string;
|
|
15
|
+
export declare function lateBootRegistration(afterMs?: number): string;
|
|
12
16
|
export declare function controlBridgeUnavailable(reason: string): string;
|
|
13
17
|
export declare function extensionJsRunnerError(error: unknown): string;
|
|
14
18
|
export declare function autoExitModeEnabled(ms: number): string;
|
|
@@ -22,6 +26,8 @@ export declare function devServerRestarting(request: {
|
|
|
22
26
|
pathAfter?: string;
|
|
23
27
|
pathBefore?: string;
|
|
24
28
|
pathChanged?: string;
|
|
29
|
+
registeredBy?: string;
|
|
30
|
+
alsoChanged?: number;
|
|
25
31
|
}): string;
|
|
26
32
|
export declare function bundlerRecompiling(): string;
|
|
27
33
|
export declare function noEntrypointsDetected(port: number): string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export type DevSessionRestartReason = 'scripts' | 'html' | 'icons' | 'json' | 'env' | 'public';
|
|
1
|
+
export type DevSessionRestartReason = 'scripts' | 'html' | 'icons' | 'json' | 'env' | 'public' | 'main-world';
|
|
2
2
|
export interface DevSessionRestartRequest {
|
|
3
3
|
reason: DevSessionRestartReason;
|
|
4
4
|
pathAfter?: string;
|
|
5
5
|
pathBefore?: string;
|
|
6
6
|
pathChanged?: string;
|
|
7
7
|
manifestField?: string;
|
|
8
|
+
registeredBy?: string;
|
|
9
|
+
alsoChanged?: number;
|
|
8
10
|
}
|
|
9
11
|
export declare const DEV_SESSION_RESTART_DEBOUNCE_MS = 300;
|
|
10
12
|
type RestartHandler = (request: DevSessionRestartRequest) => void | Promise<void>;
|
package/dist/dev-server~0.mjs
CHANGED
|
@@ -5,19 +5,20 @@ import { Writable } from "node:stream";
|
|
|
5
5
|
import { rspack } from "@rspack/core";
|
|
6
6
|
import { RspackDevServer } from "@rspack/dev-server";
|
|
7
7
|
import { merge } from "webpack-merge";
|
|
8
|
-
import {
|
|
9
|
-
import { runnerCleanupError, autoExitForceKill,
|
|
10
|
-
import {
|
|
11
|
-
import { rememberSpecialFoldersConfig, rememberExcludedFiles } from "./
|
|
12
|
-
import { publicFolderOrDefault } from "./
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
8
|
+
import { debugLine, isDebug, CODES, humanLine } from "./k~0.mjs";
|
|
9
|
+
import { runnerCleanupError, autoExitForceKill, debugSessionPorts, attachEmulatorFileIndex, extensionJsRunnerError, devServerStartTimeout, resolveEmulatorOrigin, autoExitTriggered, buildEmulatorViewerUrl, runnerUncaughtException, shouldWarnPortConflict, isLoopbackAddress, ActionsFileWriter, sanitize, DEV_COMMAND_DEFAULTS, runnerUnhandledRejection, createPlaywrightMetadataWriter, createEmulatorFileIndexHolder, LogRingBuffer, getSpecialFoldersDataForProjectRoot, startControlServer, createEmulatorFilesMiddlewareEntry, devServerHostRefused, portInUse, mergeOptionLayers, devServerAccessConfig, controlBridgeUnavailable, devServerRestarting, BridgeBroker, withHostCheckMiddleware, autoExitModeEnabled, emulatorViewerUrl, detectLiveDevSessionOwner, getSessionRunId, LogsFileWriter, resolveCompanionExtensionsConfig, lateBootRegistration } from "./m~0.mjs";
|
|
10
|
+
import { codedError, real_path_isInsidePath } from "./tm~0.mjs";
|
|
11
|
+
import { rememberSpecialFoldersConfig, rememberExcludedFiles } from "./g~0.mjs";
|
|
12
|
+
import { publicFolderOrDefault } from "./g0~0.mjs";
|
|
13
|
+
import { fullReloadsDeliveredTo, createLoadedContentScripts, attachLifecycleStream, readContentScriptCount, ConfigResolvedPlugin, classifyReloadFromSources, createChangedSourcesTracker, readDevBuild, buildSourceFeatureIndex, applySplitChunksGuard, isAwaitingMainWorldRestart, createLifecycleStream, dispatchRestartReload, dispatchReload } from "./b~0.mjs";
|
|
14
|
+
import { loadCommandConfig, loadBrowserConfig, loadConfigResolvedHook, loadProjectConfigDefaults, loadCustomConfig } from "./d~0.mjs";
|
|
15
|
+
import { logsPath, legacyControlPortFilePath, controlPortFilePath, ensureSessionStateIgnoreFile, ensureSessionStateInProjectGitignore, actionsPath, readyContractPath, ensureSessionArtifactsIgnoreFile } from "./5h~0.mjs";
|
|
16
|
+
import { anotherDevSessionRefused, getDistPath, asAbsolute } from "./cp~0.mjs";
|
|
15
17
|
import { setupNoBrowserBannerOnFirstDone, resolveConnectableHost, default as webpackConfig, setupCompilerLifecycleHooks } from "./rspack-config~0.mjs";
|
|
16
|
-
import { isGeckoBasedBrowser, isEmulatorBrowser, isWebkitBasedBrowser } from "./
|
|
17
|
-
import { CONTROL_WS_PATH, clearControlToken, writeControlToken } from "./
|
|
18
|
-
import { writePersistedControlPort, readPersistedControlPort } from "./
|
|
19
|
-
import { bindDevSessionRestart, DevSessionRestartScheduler, unbindDevSessionRestart } from "./
|
|
20
|
-
import { classifyReloadFromSources, attachLifecycleStream, readContentScriptCount, ConfigResolvedPlugin, createChangedSourcesTracker, buildSourceFeatureIndex, applySplitChunksGuard, createLifecycleStream, dispatchReload } from "./840~0.mjs";
|
|
18
|
+
import { isGeckoBasedBrowser, isEmulatorBrowser, isWebkitBasedBrowser } from "./q~0.mjs";
|
|
19
|
+
import { CONTROL_WS_PATH, clearControlToken, writeControlToken } from "./t~0.mjs";
|
|
20
|
+
import { writePersistedControlPort, readPersistedControlPort } from "./w~0.mjs";
|
|
21
|
+
import { bindDevSessionRestart, DevSessionRestartScheduler, unbindDevSessionRestart } from "./z~0.mjs";
|
|
21
22
|
import * as __rspack_external_node_os_4f3c9d58 from "node:os";
|
|
22
23
|
import * as __rspack_external_node_path_806ed179 from "node:path";
|
|
23
24
|
import * as __rspack_external_node_crypto_2e7c4b46 from "node:crypto";
|
|
@@ -117,105 +118,6 @@ function setupCleanupHandlers(devServer, portManager, onSignal) {
|
|
|
117
118
|
process.on('SIGHUP', cancelAndCleanup);
|
|
118
119
|
return cancelAutoExit;
|
|
119
120
|
}
|
|
120
|
-
const EXTENSION_ORIGIN = /^[a-z][a-z0-9+.-]*-extension:\/\/[^/]/i;
|
|
121
|
-
function isExtensionOrigin(value) {
|
|
122
|
-
return EXTENSION_ORIGIN.test(String(value ?? '').trim());
|
|
123
|
-
}
|
|
124
|
-
function resolveAllowedCorsOrigin(requestOrigin, allowedWebOrigins = []) {
|
|
125
|
-
const origin = String(requestOrigin ?? '').trim();
|
|
126
|
-
if (!origin) return null;
|
|
127
|
-
if (isExtensionOrigin(origin)) return origin;
|
|
128
|
-
for (const allowed of allowedWebOrigins)if (isSameWebOrigin(origin, allowed)) return normalizeWebOrigin(origin);
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
function devServerCorsHeaders(requestOrigin, allowedWebOrigins = []) {
|
|
132
|
-
const headers = [
|
|
133
|
-
{
|
|
134
|
-
key: 'Vary',
|
|
135
|
-
value: 'Origin'
|
|
136
|
-
}
|
|
137
|
-
];
|
|
138
|
-
const allowed = resolveAllowedCorsOrigin(requestOrigin, allowedWebOrigins);
|
|
139
|
-
if (!allowed) return headers;
|
|
140
|
-
headers.push({
|
|
141
|
-
key: 'Access-Control-Allow-Origin',
|
|
142
|
-
value: allowed
|
|
143
|
-
});
|
|
144
|
-
if (!isExtensionOrigin(allowed)) headers.push({
|
|
145
|
-
key: 'Access-Control-Allow-Private-Network',
|
|
146
|
-
value: 'true'
|
|
147
|
-
});
|
|
148
|
-
return headers;
|
|
149
|
-
}
|
|
150
|
-
function parseAllowedHosts(value) {
|
|
151
|
-
const items = Array.isArray(value) ? value : String(value ?? '').split(',');
|
|
152
|
-
const hosts = items.map((item)=>String(item ?? '').trim()).filter((item)=>item.length > 0);
|
|
153
|
-
return [
|
|
154
|
-
...new Set(hosts)
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
function refusedHostName(header) {
|
|
158
|
-
const raw = String(header ?? '').trim();
|
|
159
|
-
if (!raw) return '';
|
|
160
|
-
let name = raw;
|
|
161
|
-
try {
|
|
162
|
-
name = new URL(`http://${raw}`).hostname;
|
|
163
|
-
} catch {}
|
|
164
|
-
return name.replace(/[^A-Za-z0-9.:_[\]-]/g, '?').slice(0, 255);
|
|
165
|
-
}
|
|
166
|
-
function refusedHostResponse(host) {
|
|
167
|
-
const name = host || 'an empty Host header';
|
|
168
|
-
return `Extension.js dev server refused the host "${name}".\nAllow it with: extension dev --allowed-hosts ${host || '<host>'}\nOr set commands.dev.allowedHosts in extension.config.js. Both take more than one host, comma-separated on the flag.\n`;
|
|
169
|
-
}
|
|
170
|
-
function createHostCheckMiddleware(devServer, onRefused) {
|
|
171
|
-
const announced = new Set();
|
|
172
|
-
const maxAnnounced = 20;
|
|
173
|
-
return (req, res, next)=>{
|
|
174
|
-
const server = devServer;
|
|
175
|
-
const headerName = req.headers[':authority'] ? ':authority' : 'host';
|
|
176
|
-
if (server?.isValidHost?.(req.headers, headerName)) return void next();
|
|
177
|
-
const host = refusedHostName(req.headers[headerName]);
|
|
178
|
-
if (!announced.has(host) && announced.size < maxAnnounced) {
|
|
179
|
-
announced.add(host);
|
|
180
|
-
onRefused(host);
|
|
181
|
-
}
|
|
182
|
-
res.statusCode = 403;
|
|
183
|
-
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
184
|
-
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
185
|
-
res.end(refusedHostResponse(host));
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
const HOST_CHECK_MIDDLEWARE_NAME = 'host-header-check';
|
|
189
|
-
function withHostCheckMiddleware(middlewares, devServer, onRefused) {
|
|
190
|
-
const entry = {
|
|
191
|
-
name: HOST_CHECK_MIDDLEWARE_NAME,
|
|
192
|
-
middleware: createHostCheckMiddleware(devServer, onRefused)
|
|
193
|
-
};
|
|
194
|
-
const index = middlewares.findIndex((item)=>item?.name === HOST_CHECK_MIDDLEWARE_NAME);
|
|
195
|
-
if (-1 === index) return [
|
|
196
|
-
entry,
|
|
197
|
-
...middlewares
|
|
198
|
-
];
|
|
199
|
-
return middlewares.map((item, position)=>position === index ? entry : item);
|
|
200
|
-
}
|
|
201
|
-
function devServerAccessConfig(options) {
|
|
202
|
-
const viewerOrigin = normalizeWebOrigin(options.emulatorOrigin);
|
|
203
|
-
const viewerHost = viewerOrigin ? new URL(viewerOrigin).hostname : null;
|
|
204
|
-
const allowedWebOrigins = viewerOrigin ? [
|
|
205
|
-
viewerOrigin
|
|
206
|
-
] : [];
|
|
207
|
-
const hosts = [
|
|
208
|
-
options.connectableHost,
|
|
209
|
-
viewerHost,
|
|
210
|
-
...parseAllowedHosts(options.allowedHosts)
|
|
211
|
-
].filter((host)=>Boolean(host));
|
|
212
|
-
return {
|
|
213
|
-
allowedHosts: [
|
|
214
|
-
...new Set(hosts)
|
|
215
|
-
],
|
|
216
|
-
headers: (req)=>devServerCorsHeaders(req.headers.origin, allowedWebOrigins)
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
121
|
function createResponseDataRepair(ref) {
|
|
220
122
|
return (req, res, data, byteLength)=>{
|
|
221
123
|
const untouched = {
|
|
@@ -246,8 +148,7 @@ function createResponseDataRepair(ref) {
|
|
|
246
148
|
};
|
|
247
149
|
}
|
|
248
150
|
function isUnder(file, dir) {
|
|
249
|
-
|
|
250
|
-
return '' !== rel && !rel.startsWith('..') && !__rspack_external_node_path_806ed179.isAbsolute(rel);
|
|
151
|
+
return real_path_isInsidePath(dir, file);
|
|
251
152
|
}
|
|
252
153
|
function htmlSourcesToRefresh(modifiedFiles, fileDependencies, outputPath) {
|
|
253
154
|
if (!modifiedFiles) return [];
|
|
@@ -746,9 +647,13 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
746
647
|
const allowControl = Boolean(extendedOptions.allowControl) || allowEval;
|
|
747
648
|
const authorMode = Boolean(extendedOptions.authorMode) || isDebug();
|
|
748
649
|
const bridgeActionsFile = allowControl ? new ActionsFileWriter({
|
|
749
|
-
filePath: actionsPath(packageJsonDir, browserName)
|
|
650
|
+
filePath: actionsPath(packageJsonDir, browserName),
|
|
651
|
+
owner: {
|
|
652
|
+
runId: sessionRunId,
|
|
653
|
+
logsFilePath: bridgeLogsAbsPath
|
|
654
|
+
}
|
|
750
655
|
}) : void 0;
|
|
751
|
-
const bridgeControlToken = allowControl && allowEval ? writeControlToken(packageJsonDir, browserName) : void 0;
|
|
656
|
+
const bridgeControlToken = allowControl && allowEval || !isLoopbackAddress(devServerHost) ? writeControlToken(packageJsonDir, browserName) : void 0;
|
|
752
657
|
let stampExecutorAttached;
|
|
753
658
|
let stampExecutorDetached;
|
|
754
659
|
let stampReload;
|
|
@@ -769,11 +674,21 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
769
674
|
...isGeckoBasedBrowser(browserName) && 'function' == typeof extendedOptions.browsersPlugin?.wakeBackground ? {
|
|
770
675
|
wakeExecutor: async ()=>await extendedOptions.browsersPlugin?.wakeBackground?.() === true
|
|
771
676
|
} : {},
|
|
772
|
-
onReloadApplied: (kind, label)=>stampReload?.(kind, label)
|
|
677
|
+
onReloadApplied: (kind, label)=>stampReload?.(kind, label),
|
|
678
|
+
onLateBootRegistration: (afterMs)=>humanLine(lateBootRegistration(afterMs))
|
|
773
679
|
});
|
|
774
680
|
const launchedPlugin = extendedOptions.browsersPlugin;
|
|
775
681
|
if (launchedPlugin && 'function' == typeof launchedPlugin.setReloadBroker) launchedPlugin.setReloadBroker(bridgeBroker);
|
|
776
682
|
if (launchedPlugin && 'function' == typeof launchedPlugin.setInstanceId) launchedPlugin.setInstanceId(currentInstance.instanceId);
|
|
683
|
+
let readyAnnounced = false;
|
|
684
|
+
const announceReady = ()=>{
|
|
685
|
+
if (readyAnnounced) return;
|
|
686
|
+
readyAnnounced = true;
|
|
687
|
+
try {
|
|
688
|
+
extendedOptions.onReady?.();
|
|
689
|
+
} catch {}
|
|
690
|
+
};
|
|
691
|
+
if (launchedPlugin && 'function' == typeof launchedPlugin.setReadyListener) launchedPlugin.setReadyListener(announceReady);
|
|
777
692
|
if (launchedPlugin && 'function' == typeof launchedPlugin.setLogSink) launchedPlugin.setLogSink((event)=>{
|
|
778
693
|
try {
|
|
779
694
|
bridgeBroker.ingestLog({
|
|
@@ -823,6 +738,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
823
738
|
});
|
|
824
739
|
}
|
|
825
740
|
bridgeControlPort = controlServer.port;
|
|
741
|
+
ensureSessionStateIgnoreFile(packageJsonDir);
|
|
826
742
|
writePersistedControlPort(controlPortFile, controlServer.port);
|
|
827
743
|
} catch (error) {
|
|
828
744
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -833,6 +749,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
833
749
|
bridgeLogFile.close();
|
|
834
750
|
} catch {}
|
|
835
751
|
}
|
|
752
|
+
if (isDebug()) debugLine(debugSessionPorts(port, bridgeControlPort));
|
|
836
753
|
process.env.EXTENSION_INSTANCE_ID = currentInstance.instanceId;
|
|
837
754
|
process.env.EXTENSION_CONTROL_PORT = null != bridgeControlPort ? String(bridgeControlPort) : '';
|
|
838
755
|
const emulatorFiles = emulatorLane ? createEmulatorFileIndexHolder(currentInstance.instanceId) : null;
|
|
@@ -852,7 +769,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
852
769
|
try {
|
|
853
770
|
bridgeActionsFile?.close();
|
|
854
771
|
} catch {}
|
|
855
|
-
if (bridgeControlToken) clearControlToken(packageJsonDir, browserName);
|
|
772
|
+
if (bridgeControlToken) clearControlToken(packageJsonDir, browserName, bridgeControlToken);
|
|
856
773
|
unbindDevSessionRestart();
|
|
857
774
|
});
|
|
858
775
|
const safeProjectConfig = sanitize(projectConfig);
|
|
@@ -870,6 +787,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
870
787
|
browser: devOptions.browser,
|
|
871
788
|
config: mergedExtensionsConfig
|
|
872
789
|
});
|
|
790
|
+
const readyAwaitsExecutor = allowControl && Boolean(extendedOptions.browsersPlugin);
|
|
873
791
|
const webpackConfigOptions = {
|
|
874
792
|
metadataCommand: 'dev',
|
|
875
793
|
...mergedDevOptions,
|
|
@@ -882,6 +800,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
882
800
|
controlPortUnavailableReason,
|
|
883
801
|
controlPath: CONTROL_WS_PATH,
|
|
884
802
|
logsPath: bridgeLogsRelPath,
|
|
803
|
+
readyAwaitsExecutor,
|
|
885
804
|
port: portAllocation.port,
|
|
886
805
|
output: {
|
|
887
806
|
clean: false,
|
|
@@ -902,7 +821,9 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
902
821
|
controlPort: bridgeControlPort,
|
|
903
822
|
controlPortUnavailableReason,
|
|
904
823
|
controlPath: CONTROL_WS_PATH,
|
|
905
|
-
logsPath: bridgeLogsRelPath
|
|
824
|
+
logsPath: bridgeLogsRelPath,
|
|
825
|
+
readyAwaitsRdpPort: Boolean(extendedOptions.browsersPlugin),
|
|
826
|
+
readyAwaitsExecutor
|
|
906
827
|
});
|
|
907
828
|
stampExecutorAttached = (attached)=>metadata.stampExecutorAttached(attached);
|
|
908
829
|
stampExecutorDetached = ()=>metadata.stampExecutorDetached();
|
|
@@ -922,7 +843,8 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
922
843
|
const access = devServerAccessConfig({
|
|
923
844
|
connectableHost,
|
|
924
845
|
emulatorOrigin,
|
|
925
|
-
allowedHosts: extendedOptions.allowedHosts
|
|
846
|
+
allowedHosts: extendedOptions.allowedHosts,
|
|
847
|
+
isSessionExtensionOrigin: (origin)=>bridgeBroker.isSessionExtensionOrigin(origin)
|
|
926
848
|
});
|
|
927
849
|
const serverConfig = {
|
|
928
850
|
host: devServerHost,
|
|
@@ -986,7 +908,8 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
986
908
|
const hookContext = {
|
|
987
909
|
browser: webpackConfigOptions.browser,
|
|
988
910
|
mode: webpackConfigOptions.mode,
|
|
989
|
-
command: webpackConfigOptions.metadataCommand
|
|
911
|
+
command: webpackConfigOptions.metadataCommand,
|
|
912
|
+
rspack: rspack
|
|
990
913
|
};
|
|
991
914
|
const customWebpackConfig = await loadCustomConfig(packageJsonDir, hookContext);
|
|
992
915
|
const compilerConfig = applySplitChunksGuard(merge(customWebpackConfig(baseConfig), {}));
|
|
@@ -1001,33 +924,51 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1001
924
|
readyPath: metadata.readyPath
|
|
1002
925
|
}));
|
|
1003
926
|
activeCompiler = compiler;
|
|
927
|
+
if (compiler?.hooks?.done?.tap) compiler.hooks.done.tap({
|
|
928
|
+
name: 'extjs-session-builds',
|
|
929
|
+
stage: -1000
|
|
930
|
+
}, (stats)=>{
|
|
931
|
+
bridgeBroker.noteSessionBuild(readDevBuild(stats?.compilation));
|
|
932
|
+
});
|
|
1004
933
|
const uninstallManifestGuard = installManifestDiskWriteGuard(manifestOutputPath);
|
|
1005
934
|
const releaseOutputFsGuard = suppressManifestOutputWrites(compiler, manifestOutputPath);
|
|
1006
935
|
if (!extendedOptions.browsersPlugin && compiler?.hooks?.watchRun) {
|
|
1007
936
|
const changedSources = createChangedSourcesTracker(compiler);
|
|
1008
937
|
let isFirstBridgeCompile = true;
|
|
938
|
+
const loadedContentScripts = isEmulatorBrowser(browserName) ? void 0 : createLoadedContentScripts({
|
|
939
|
+
refreshInPlace: isGeckoBasedBrowser(browserName)
|
|
940
|
+
});
|
|
1009
941
|
compiler.hooks.done.tapPromise('extjs-no-browser-reload', async (stats)=>{
|
|
1010
942
|
const compilation = stats.compilation;
|
|
1011
943
|
if (compilation.errors && compilation.errors.length > 0) return;
|
|
1012
944
|
if (isFirstBridgeCompile) {
|
|
1013
945
|
isFirstBridgeCompile = false;
|
|
946
|
+
loadedContentScripts?.noteLoaded(compilation);
|
|
1014
947
|
return;
|
|
1015
948
|
}
|
|
949
|
+
if (isAwaitingMainWorldRestart(compiler, compilation)) return;
|
|
1016
950
|
const outputPath = String(compilation.options?.output?.path || '');
|
|
1017
951
|
const contextDir = String(compilation.options?.context || '');
|
|
1018
952
|
const { forcedFull, changedSources: sources } = changedSources.snapshot();
|
|
1019
|
-
const
|
|
953
|
+
const classified = classifyReloadFromSources({
|
|
1020
954
|
changedSources: sources,
|
|
1021
955
|
forcedFull,
|
|
1022
956
|
getContentScriptCount: ()=>readContentScriptCount(compilation, outputPath),
|
|
1023
957
|
getSourceFeatureIndex: ()=>buildSourceFeatureIndex(compilation, contextDir),
|
|
1024
|
-
outputPath
|
|
958
|
+
outputPath,
|
|
959
|
+
contextDir
|
|
1025
960
|
});
|
|
1026
|
-
|
|
1027
|
-
|
|
961
|
+
const instruction = loadedContentScripts ? loadedContentScripts.resolve(compilation, classified) : classified;
|
|
962
|
+
const delivered = await dispatchReload(instruction, {
|
|
963
|
+
broker: bridgeBroker,
|
|
964
|
+
build: readDevBuild(compilation)
|
|
1028
965
|
});
|
|
966
|
+
loadedContentScripts?.settle(delivered);
|
|
1029
967
|
});
|
|
1030
968
|
}
|
|
969
|
+
if (!extendedOptions.browsersPlugin && compiler?.hooks?.done?.tap) compiler.hooks.done.tap('extjs-session-ready', (stats)=>{
|
|
970
|
+
if (!stats?.hasErrors?.()) announceReady();
|
|
971
|
+
});
|
|
1031
972
|
if (emulatorFiles) attachEmulatorFileIndex(compiler, emulatorFiles);
|
|
1032
973
|
if (emulatorViewer && !opts.isRestart && devOptions.noBrowser) {
|
|
1033
974
|
let printedViewer = false;
|
|
@@ -1097,6 +1038,9 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1097
1038
|
metadata.writeError('dev_server_start_failed', error instanceof Error ? error.message : String(error));
|
|
1098
1039
|
lifecycle.failed(error instanceof Error ? error.message : String(error));
|
|
1099
1040
|
humanLine(extensionJsRunnerError(error));
|
|
1041
|
+
try {
|
|
1042
|
+
extendedOptions.onExitError?.(error, CODES.E_DEV_SERVER_START);
|
|
1043
|
+
} catch {}
|
|
1100
1044
|
process.exit(1);
|
|
1101
1045
|
}
|
|
1102
1046
|
const firstBundle = await createCompilerAndServer({
|
|
@@ -1121,6 +1065,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1121
1065
|
currentServer = null;
|
|
1122
1066
|
portManager.holdPortAcrossRestart();
|
|
1123
1067
|
if (previous && 'function' == typeof previous.stop) await previous.stop();
|
|
1068
|
+
const fullReloadsBefore = fullReloadsDeliveredTo(bridgeBroker);
|
|
1124
1069
|
currentServer = nextBundle.server;
|
|
1125
1070
|
try {
|
|
1126
1071
|
await startBundler(nextBundle.server);
|
|
@@ -1129,12 +1074,9 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1129
1074
|
}
|
|
1130
1075
|
const stats = await nextBundle.firstCompile;
|
|
1131
1076
|
if (stats && 'function' == typeof stats.hasErrors && stats.hasErrors()) return;
|
|
1132
|
-
await
|
|
1133
|
-
type: 'full',
|
|
1134
|
-
label: 'extension'
|
|
1135
|
-
}, {
|
|
1077
|
+
await dispatchRestartReload({
|
|
1136
1078
|
broker: bridgeBroker
|
|
1137
|
-
});
|
|
1079
|
+
}, fullReloadsBefore);
|
|
1138
1080
|
});
|
|
1139
1081
|
bindDevSessionRestart(sessionRestart);
|
|
1140
1082
|
process.once('exit', ()=>{
|
package/dist/df~0.mjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import * as __rspack_external_node_path_806ed179 from "node:path";
|
|
4
|
+
const requireModule = createRequire(import.meta.url);
|
|
5
|
+
const COMPLETION_VALUE_SETTER = '__extjsCompletion';
|
|
6
|
+
const INJECTED_CLASSIC_QUERY = '__extensionjs_injected__';
|
|
7
|
+
const COMPLETION_VALUE_HOLDER = '__extjsCompletionValue';
|
|
8
|
+
const KEEP = '__extjsKeep';
|
|
9
|
+
const BLOCK_OPEN = `{let ${COMPLETION_VALUE_HOLDER};const ${COMPLETION_VALUE_SETTER}=function(value){${COMPLETION_VALUE_HOLDER}=value};\n`;
|
|
10
|
+
const CLONABLE = 'function(value){var kept=function(value){try{if(typeof structuredClone==="function")structuredClone(value)}catch(error){return}return value};try{if(value&&typeof value.then==="function")return Promise.resolve(value).then(kept)}catch(error){}return kept(value)}';
|
|
11
|
+
const BLOCK_CLOSE = `\n;(${CLONABLE})(${COMPLETION_VALUE_HOLDER})}`;
|
|
12
|
+
const KEEP_DECLARATION = `var ${KEEP} = typeof ${COMPLETION_VALUE_SETTER} === "function" ? ${COMPLETION_VALUE_SETTER} : function () {};`;
|
|
13
|
+
const KEEP_IN_PLACE = `void (typeof ${COMPLETION_VALUE_SETTER} === "function" ? ${COMPLETION_VALUE_SETTER} : function () {})`;
|
|
14
|
+
const REPEATING = new Set([
|
|
15
|
+
'ForStatement',
|
|
16
|
+
'ForInStatement',
|
|
17
|
+
'ForOfStatement',
|
|
18
|
+
'WhileStatement',
|
|
19
|
+
'DoWhileStatement',
|
|
20
|
+
'SwitchStatement',
|
|
21
|
+
'LabeledStatement',
|
|
22
|
+
'WithStatement'
|
|
23
|
+
]);
|
|
24
|
+
function parseStatements(source, resourcePath) {
|
|
25
|
+
const extension = __rspack_external_node_path_806ed179.extname(resourcePath).toLowerCase();
|
|
26
|
+
const typed = /^\.m?tsx?$/.test(extension);
|
|
27
|
+
if (!typed && !/^\.m?jsx$/.test(extension)) {
|
|
28
|
+
const base = {
|
|
29
|
+
ecmaVersion: 'latest',
|
|
30
|
+
allowHashBang: true
|
|
31
|
+
};
|
|
32
|
+
for (const options of [
|
|
33
|
+
{
|
|
34
|
+
...base,
|
|
35
|
+
sourceType: 'module'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
...base,
|
|
39
|
+
sourceType: "script",
|
|
40
|
+
allowAwaitOutsideFunction: true
|
|
41
|
+
}
|
|
42
|
+
])try {
|
|
43
|
+
return requireModule('acorn').parse(source, options).body;
|
|
44
|
+
} catch {}
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const plugins = [
|
|
48
|
+
...typed ? [
|
|
49
|
+
"typescript"
|
|
50
|
+
] : [],
|
|
51
|
+
.../^\.m?ts$/.test(extension) ? [] : [
|
|
52
|
+
'jsx'
|
|
53
|
+
]
|
|
54
|
+
];
|
|
55
|
+
return requireModule('@babel/core').parseSync(source, {
|
|
56
|
+
babelrc: false,
|
|
57
|
+
configFile: false,
|
|
58
|
+
sourceType: 'unambiguous',
|
|
59
|
+
parserOpts: {
|
|
60
|
+
plugins
|
|
61
|
+
}
|
|
62
|
+
}).program.body;
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function listOf(statements) {
|
|
68
|
+
return Array.isArray(statements) ? statements : [];
|
|
69
|
+
}
|
|
70
|
+
function collectEdits(source, program, setter) {
|
|
71
|
+
const edits = [];
|
|
72
|
+
const keep = (statement)=>{
|
|
73
|
+
const text = source.slice(statement.start, statement.end).replace(/;$/, '');
|
|
74
|
+
edits.push({
|
|
75
|
+
start: statement.start,
|
|
76
|
+
end: statement.end,
|
|
77
|
+
text: `${setter}((${text}));`
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const forget = (statement, listed)=>{
|
|
81
|
+
edits.push({
|
|
82
|
+
start: statement.start,
|
|
83
|
+
end: statement.start,
|
|
84
|
+
text: listed ? `${setter}();` : `{${setter}();`
|
|
85
|
+
});
|
|
86
|
+
if (!listed) edits.push({
|
|
87
|
+
start: statement.end,
|
|
88
|
+
end: statement.end,
|
|
89
|
+
text: '}'
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const caught = (handler)=>{
|
|
93
|
+
const at = handler.body.start + 1;
|
|
94
|
+
edits.push({
|
|
95
|
+
start: at,
|
|
96
|
+
end: at,
|
|
97
|
+
text: `${setter}();`
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const isValue = (statement)=>'ExpressionStatement' === statement.type && !statement.directive;
|
|
101
|
+
const every = (statement, listed, outermost = false)=>{
|
|
102
|
+
if (isValue(statement)) return keep(statement);
|
|
103
|
+
if ('BlockStatement' === statement.type) {
|
|
104
|
+
for (const child of listOf(statement.body))every(child, true);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if ('LabeledStatement' === statement.type) {
|
|
108
|
+
const labeled = statement.body;
|
|
109
|
+
const compound = REPEATING.has(labeled.type) || 'IfStatement' === labeled.type || 'TryStatement' === labeled.type;
|
|
110
|
+
if (!outermost && compound) forget(statement, listed);
|
|
111
|
+
return every(labeled, false, true);
|
|
112
|
+
}
|
|
113
|
+
const compound = REPEATING.has(statement.type) || 'IfStatement' === statement.type || 'TryStatement' === statement.type;
|
|
114
|
+
if (!compound) return;
|
|
115
|
+
if (!outermost) forget(statement, listed);
|
|
116
|
+
if ('IfStatement' === statement.type) {
|
|
117
|
+
every(statement.consequent, false);
|
|
118
|
+
if (statement.alternate) every(statement.alternate, false);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if ('TryStatement' === statement.type) {
|
|
122
|
+
for (const child of listOf(statement.block?.body))every(child, true);
|
|
123
|
+
if (statement.handler) {
|
|
124
|
+
caught(statement.handler);
|
|
125
|
+
for (const child of statement.handler.body.body)every(child, true);
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if ('SwitchStatement' === statement.type) {
|
|
130
|
+
for (const group of statement.cases || [])for (const child of group.consequent)every(child, true);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
every(statement.body, false);
|
|
134
|
+
};
|
|
135
|
+
const last = (statements)=>{
|
|
136
|
+
for(let index = statements.length - 1; index >= 0; index--)if (lastOf(statements[index])) return true;
|
|
137
|
+
return false;
|
|
138
|
+
};
|
|
139
|
+
const lastOf = (statement)=>{
|
|
140
|
+
if (isValue(statement)) {
|
|
141
|
+
keep(statement);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if ('BlockStatement' === statement.type) return last(listOf(statement.body));
|
|
145
|
+
if ('IfStatement' === statement.type) {
|
|
146
|
+
lastOf(statement.consequent);
|
|
147
|
+
if (statement.alternate) lastOf(statement.alternate);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if ('TryStatement' === statement.type) {
|
|
151
|
+
last(listOf(statement.block?.body));
|
|
152
|
+
if (statement.handler) {
|
|
153
|
+
caught(statement.handler);
|
|
154
|
+
last(statement.handler.body.body);
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (REPEATING.has(statement.type)) {
|
|
159
|
+
every(statement, true, true);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
};
|
|
164
|
+
last(program);
|
|
165
|
+
return edits;
|
|
166
|
+
}
|
|
167
|
+
function keepCompletionValue(source, resourcePath, options = {}) {
|
|
168
|
+
const program = parseStatements(source, resourcePath);
|
|
169
|
+
if (!program) return source;
|
|
170
|
+
const keep = options.declaresNothing ? KEEP_IN_PLACE : KEEP;
|
|
171
|
+
const declaration = options.declaresNothing ? '' : KEEP_DECLARATION;
|
|
172
|
+
const edits = collectEdits(source, program, keep);
|
|
173
|
+
if (0 === edits.length) {
|
|
174
|
+
if (!options.importsAnotherScript) return source;
|
|
175
|
+
return `${declaration}${source}\n;${keep}();`;
|
|
176
|
+
}
|
|
177
|
+
let rewritten = source;
|
|
178
|
+
for (const edit of edits.sort((a, b)=>b.start - a.start || b.end - a.end))rewritten = rewritten.slice(0, edit.start) + edit.text + rewritten.slice(edit.end);
|
|
179
|
+
return `${declaration}${rewritten}`;
|
|
180
|
+
}
|
|
181
|
+
function carriesCompletionValue(text) {
|
|
182
|
+
return text.includes(COMPLETION_VALUE_SETTER) && !endsOnCompletionValue(text);
|
|
183
|
+
}
|
|
184
|
+
function endsOnCompletionValue(text) {
|
|
185
|
+
return text.includes(BLOCK_OPEN);
|
|
186
|
+
}
|
|
187
|
+
function closeCompletionValueBlock(text) {
|
|
188
|
+
const trailer = /\n\/\/# sourceMappingURL=[^\n]*\s*$/.exec(text);
|
|
189
|
+
const whole = trailer ? text.slice(0, trailer.index) : text;
|
|
190
|
+
const directive = /^(?:"use strict"|'use strict');?/.exec(whole)?.[0] || '';
|
|
191
|
+
const body = whole.slice(directive.length);
|
|
192
|
+
return {
|
|
193
|
+
open: `${directive}${BLOCK_OPEN}`,
|
|
194
|
+
closed: `${body}${BLOCK_CLOSE}${trailer ? trailer[0] : ''}`
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export { INJECTED_CLASSIC_QUERY, carriesCompletionValue, closeCompletionValueBlock, endsOnCompletionValue, keepCompletionValue };
|
|
@@ -2,9 +2,10 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
|
|
|
2
2
|
import { createRequire, register } from "node:module";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
|
-
import { isUsingExperimentalConfig as messages_isUsingExperimentalConfig, configUnknownKeys, resolveProjectStructureSync,
|
|
6
|
-
import { debugLine, isDebug, CODES } from "./
|
|
7
|
-
import {
|
|
5
|
+
import { isUsingExperimentalConfig as messages_isUsingExperimentalConfig, configUnknownKeys, resolveProjectStructureSync, configWrongShape, configLoadingError } from "./cp~0.mjs";
|
|
6
|
+
import { debugLine, isDebug, CODES } from "./k~0.mjs";
|
|
7
|
+
import { codedError } from "./tm~0.mjs";
|
|
8
|
+
import { isWebkitBasedBrowser } from "./q~0.mjs";
|
|
8
9
|
import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
|
|
9
10
|
import * as __rspack_external_node_path_806ed179 from "node:path";
|
|
10
11
|
import * as __rspack_external_node_vm_ef240610 from "node:vm";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
2
|
import { init, parse } from "es-module-lexer";
|
|
3
3
|
import { validate } from "schema-utils";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { debugLine } from "./
|
|
4
|
+
import { EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./bh~0.mjs";
|
|
5
|
+
import { returnWithMap, adjustLoaderSourceMap, inputOrIdentityMap } from "./3~0.mjs";
|
|
6
|
+
import { debugLine } from "./k~0.mjs";
|
|
7
7
|
const schema = {
|
|
8
8
|
type: 'object',
|
|
9
9
|
properties: {
|