adnbn 0.2.5 → 0.2.7
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/dist/cli/builders/app/index.d.ts +2 -1
- package/dist/cli/builders/locale/index.d.ts +2 -1
- package/dist/cli/builders/manifest/index.d.ts +2 -1
- package/dist/cli/entrypoint/file/resolvers/ImportResolver.js +2 -4
- package/dist/cli/entrypoint/file/resolvers/ImportResolver.js.map +1 -1
- package/dist/cli/entrypoint/finder/AbstractAssetFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractAssetFinder.js +2 -2
- package/dist/cli/entrypoint/finder/AbstractAssetFinder.js.map +1 -1
- package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractFinder.js +6 -3
- package/dist/cli/entrypoint/finder/AbstractFinder.js.map +1 -1
- package/dist/cli/entrypoint/finder/AbstractOptionsFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractPluginFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractTransportFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AbstractViewFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/AssetPluginFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/BackgroundFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/CommandFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/ContentFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/IconFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/IconFinder.js +1 -1
- package/dist/cli/entrypoint/finder/IconFinder.js.map +1 -1
- package/dist/cli/entrypoint/finder/LocaleFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/OffscreenFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/OffscreenViewFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/PageFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/PluginFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/PopupFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/RelayFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/ServiceFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/SidebarFinder.d.ts +2 -1
- package/dist/cli/entrypoint/finder/index.d.ts +2 -1
- package/dist/cli/entrypoint/index.d.ts +2 -1
- package/dist/cli/entrypoint/parser/AbstractParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/AbstractParser.js +1 -1
- package/dist/cli/entrypoint/parser/AbstractParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/BackgroundParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/CommandParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/ContentParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/OffscreenParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/PageParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/PopupParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/RelayParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/ServiceParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/SidebarParser.d.ts +2 -1
- package/dist/cli/entrypoint/parser/ViewParser.d.ts +84 -84
- package/dist/cli/entrypoint/parser/index.d.ts +2 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/plugins/asset.d.ts +2 -1
- package/dist/cli/plugins/background/Background.d.ts +2 -1
- package/dist/cli/plugins/background/BackgroundEntry.d.ts +2 -1
- package/dist/cli/plugins/background/BackgroundManifest.d.ts +2 -1
- package/dist/cli/plugins/background/Command.d.ts +2 -1
- package/dist/cli/plugins/background/Service.d.ts +2 -1
- package/dist/cli/plugins/background/ServiceDeclaration.d.ts +2 -1
- package/dist/cli/plugins/background/index.d.ts +2 -1
- package/dist/cli/plugins/bundler.d.ts +2 -1
- package/dist/cli/plugins/bundler.js +1 -15
- package/dist/cli/plugins/bundler.js.map +1 -1
- package/dist/cli/plugins/content/Content.d.ts +2 -1
- package/dist/cli/plugins/content/ContentDriver.d.ts +2 -1
- package/dist/cli/plugins/content/ContentManager.d.ts +2 -1
- package/dist/cli/plugins/content/ContentName.d.ts +2 -1
- package/dist/cli/plugins/content/Relay.d.ts +2 -1
- package/dist/cli/plugins/content/RelayDeclaration.d.ts +2 -1
- package/dist/cli/plugins/content/index.d.ts +2 -1
- package/dist/cli/plugins/dotenv/crypt.d.ts +4 -0
- package/dist/cli/plugins/dotenv/crypt.js +26 -0
- package/dist/cli/plugins/dotenv/crypt.js.map +1 -0
- package/dist/cli/plugins/dotenv/index.d.ts +2 -1
- package/dist/cli/plugins/dotenv/index.js +9 -12
- package/dist/cli/plugins/dotenv/index.js.map +1 -1
- package/dist/cli/plugins/dotenv/utils.d.ts +9 -4
- package/dist/cli/plugins/dotenv/utils.js +31 -26
- package/dist/cli/plugins/dotenv/utils.js.map +1 -1
- package/dist/cli/plugins/html.d.ts +2 -1
- package/dist/cli/plugins/icon/Icon.d.ts +2 -1
- package/dist/cli/plugins/icon/Icon.js +1 -1
- package/dist/cli/plugins/icon/Icon.js.map +1 -1
- package/dist/cli/plugins/icon/declaration/IconDeclaration.d.ts +2 -1
- package/dist/cli/plugins/icon/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/icon/index.d.ts +2 -1
- package/dist/cli/plugins/icon/index.js +1 -2
- package/dist/cli/plugins/icon/index.js.map +1 -1
- package/dist/cli/plugins/index.d.ts +2 -1
- package/dist/cli/plugins/locale/Locale.d.ts +2 -1
- package/dist/cli/plugins/locale/declaration/LocaleDeclaration.d.ts +2 -1
- package/dist/cli/plugins/locale/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/locale/index.d.ts +2 -1
- package/dist/cli/plugins/locale/index.js +1 -1
- package/dist/cli/plugins/locale/index.js.map +1 -1
- package/dist/cli/plugins/meta/AbstractMeta.d.ts +2 -1
- package/dist/cli/plugins/meta/Author.d.ts +2 -1
- package/dist/cli/plugins/meta/Email.d.ts +2 -1
- package/dist/cli/plugins/meta/Homepage.d.ts +2 -1
- package/dist/cli/plugins/meta/Incognito.d.ts +2 -1
- package/dist/cli/plugins/meta/index.d.ts +2 -1
- package/dist/cli/plugins/offscreen/Offscreen.d.ts +2 -1
- package/dist/cli/plugins/offscreen/OffscreenDeclaration.d.ts +2 -1
- package/dist/cli/plugins/offscreen/index.d.ts +2 -1
- package/dist/cli/plugins/optimization.d.ts +2 -1
- package/dist/cli/plugins/optimization.js +2 -2
- package/dist/cli/plugins/optimization.js.map +1 -1
- package/dist/cli/plugins/output.d.ts +2 -1
- package/dist/cli/plugins/output.js +2 -2
- package/dist/cli/plugins/output.js.map +1 -1
- package/dist/cli/plugins/page/Page.d.ts +2 -1
- package/dist/cli/plugins/page/declaration/PageDeclaration.d.ts +2 -1
- package/dist/cli/plugins/page/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/page/index.d.ts +2 -1
- package/dist/cli/plugins/popup/Popup.d.ts +2 -1
- package/dist/cli/plugins/popup/declaration/PopupDeclaration.d.ts +2 -1
- package/dist/cli/plugins/popup/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/popup/index.d.ts +2 -1
- package/dist/cli/plugins/public.d.ts +2 -1
- package/dist/cli/plugins/react.d.ts +2 -1
- package/dist/cli/plugins/react.js +4 -4
- package/dist/cli/plugins/react.js.map +1 -1
- package/dist/cli/plugins/sidebar/Sidebar.d.ts +2 -1
- package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.d.ts +2 -1
- package/dist/cli/plugins/sidebar/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/sidebar/index.d.ts +2 -1
- package/dist/cli/plugins/style.d.ts +2 -1
- package/dist/cli/plugins/style.js +4 -4
- package/dist/cli/plugins/style.js.map +1 -1
- package/dist/cli/plugins/typescript/FileBuilder.d.ts +2 -1
- package/dist/cli/plugins/typescript/FileBuilder.js +2 -2
- package/dist/cli/plugins/typescript/FileBuilder.js.map +1 -1
- package/dist/cli/plugins/typescript/TypescriptConfig.d.ts +2 -1
- package/dist/cli/plugins/typescript/TypescriptConfig.js +4 -4
- package/dist/cli/plugins/typescript/TypescriptConfig.js.map +1 -1
- package/dist/cli/plugins/typescript/declaration/VendorDeclaration.d.ts +2 -1
- package/dist/cli/plugins/typescript/declaration/index.d.ts +2 -1
- package/dist/cli/plugins/typescript/declaration/transport/TransportDeclaration.d.ts +2 -1
- package/dist/cli/plugins/typescript/declaration/transport/index.d.ts +2 -1
- package/dist/cli/plugins/typescript/index.d.ts +2 -1
- package/dist/cli/plugins/version/AbstractVersion.d.ts +2 -1
- package/dist/cli/plugins/version/AddonVersion.d.ts +2 -1
- package/dist/cli/plugins/version/AddonVersion.js +2 -2
- package/dist/cli/plugins/version/AddonVersion.js.map +1 -1
- package/dist/cli/plugins/version/BrowserMinimumVersion.d.ts +2 -1
- package/dist/cli/plugins/version/index.d.ts +2 -1
- package/dist/cli/plugins/view/View.d.ts +2 -1
- package/dist/cli/plugins/view/index.d.ts +2 -1
- package/dist/cli/resolvers/bundler.d.ts +2 -1
- package/dist/cli/resolvers/config.d.ts +2 -1
- package/dist/cli/resolvers/config.js +32 -24
- package/dist/cli/resolvers/config.js.map +1 -1
- package/dist/cli/resolvers/path.d.ts +6 -4
- package/dist/cli/resolvers/path.js +24 -14
- package/dist/cli/resolvers/path.js.map +1 -1
- package/dist/cli/resolvers/plugin.d.ts +2 -1
- package/dist/cli/virtual/index.js +3 -3
- package/dist/{config-DzmiK3GH.d.ts → config-Ce0Le6r4.d.ts} +90 -59
- package/dist/entry/transport/index.d.ts +5 -5
- package/dist/entry/transport/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/locale/adapters/react/context.d.ts +2 -3
- package/dist/locale/adapters/react/index.d.ts +2 -2
- package/dist/main/config.d.ts +3 -2
- package/dist/main/env.js +1 -1
- package/dist/main/env.js.map +1 -1
- package/dist/main/index.d.ts +2 -1
- package/dist/main/plugin.d.ts +3 -2
- package/dist/message/MessageManager.js +4 -1
- package/dist/message/MessageManager.js.map +1 -1
- package/dist/message/adapters/react/useMessageHandler.d.ts +2 -2
- package/dist/message/adapters/react/useMessageHandler.js +15 -8
- package/dist/message/adapters/react/useMessageHandler.js.map +1 -1
- package/dist/transport/index.d.ts +6 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/content.d.ts +1 -1
- package/dist/types/content.js.map +1 -1
- package/dist/types/env.d.ts +9 -0
- package/dist/types/env.js +5 -0
- package/dist/types/env.js.map +1 -0
- package/dist/types/plugin.d.ts +2 -1
- package/package.json +45 -46
|
@@ -25,10 +25,11 @@ import {
|
|
|
25
25
|
versionPlugin,
|
|
26
26
|
viewPlugin
|
|
27
27
|
} from "../plugins/index.js";
|
|
28
|
-
import { getAppPath, getAppSourcePath, getConfigFile
|
|
28
|
+
import { fromRootPath, getAppPath, getAppSourcePath, getConfigFile } from "../resolvers/path.js";
|
|
29
29
|
import { Command, Mode } from "./../../types/app.js";
|
|
30
30
|
import { Browser } from "./../../types/browser.js";
|
|
31
31
|
import { Language } from "./../../types/locale.js";
|
|
32
|
+
import { DefaultIconGroupName } from "./../../types/icon.js";
|
|
32
33
|
const getUserConfig = async (config) => {
|
|
33
34
|
const configFilePath = getConfigFile(config);
|
|
34
35
|
if (existsSync(configFilePath)) {
|
|
@@ -47,46 +48,47 @@ const getUserConfig = async (config) => {
|
|
|
47
48
|
};
|
|
48
49
|
const validateConfig = (config) => {
|
|
49
50
|
const {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
outDir,
|
|
52
|
+
srcDir,
|
|
52
53
|
sharedDir,
|
|
53
54
|
appsDir,
|
|
54
|
-
|
|
55
|
+
appSrcDir,
|
|
55
56
|
jsDir,
|
|
56
57
|
cssDir,
|
|
57
58
|
assetsDir,
|
|
58
59
|
htmlDir,
|
|
59
60
|
publicDir,
|
|
60
61
|
localeDir,
|
|
61
|
-
|
|
62
|
+
iconSrcDir,
|
|
63
|
+
iconOutDir
|
|
62
64
|
} = config;
|
|
63
65
|
if ([
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
outDir,
|
|
67
|
+
srcDir,
|
|
66
68
|
sharedDir,
|
|
67
69
|
appsDir,
|
|
68
|
-
|
|
70
|
+
appSrcDir,
|
|
69
71
|
jsDir,
|
|
70
72
|
cssDir,
|
|
71
73
|
assetsDir,
|
|
72
74
|
htmlDir,
|
|
73
75
|
publicDir,
|
|
74
76
|
localeDir,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
iconSrcDir,
|
|
78
|
+
iconOutDir
|
|
77
79
|
].filter((dir) => _.isString(dir)).some((dir) => dir.includes(".."))) {
|
|
78
80
|
throw new Error('Directory paths cannot contain relative paths ("..") for security reasons.');
|
|
79
81
|
}
|
|
80
82
|
if (appsDir === sharedDir) {
|
|
81
83
|
throw new Error("Apps directory (appsDir) and shared directory (sharedDir) cannot be the same.");
|
|
82
84
|
}
|
|
83
|
-
if (
|
|
85
|
+
if (srcDir === outDir) {
|
|
84
86
|
throw new Error("Source directory (srcDir) and destination directory (outputDir) cannot be the same.");
|
|
85
87
|
}
|
|
86
|
-
if (
|
|
88
|
+
if (srcDir === ".") {
|
|
87
89
|
throw new Error('Source directory cannot be the root directory (".") for security reasons.');
|
|
88
90
|
}
|
|
89
|
-
if (publicDir === "." || [
|
|
91
|
+
if (publicDir === "." || [srcDir, outDir, appSrcDir].includes(publicDir)) {
|
|
90
92
|
throw new Error(
|
|
91
93
|
'Public directory cannot be the root directory (".") or intersect with other root directories for security reasons.'
|
|
92
94
|
);
|
|
@@ -118,7 +120,7 @@ const loadDotenv = (config) => {
|
|
|
118
120
|
];
|
|
119
121
|
const appSourcePaths = preset.map((file) => getAppSourcePath(config, file));
|
|
120
122
|
const appPaths = preset.map((file) => getAppPath(config, file));
|
|
121
|
-
const rootPaths = preset.map((file) =>
|
|
123
|
+
const rootPaths = preset.map((file) => fromRootPath(config, file));
|
|
122
124
|
const paths = [...appSourcePaths, ...appPaths, ...rootPaths];
|
|
123
125
|
const { parsed: fileVars = {} } = dotenv.config({ path: paths });
|
|
124
126
|
return { ...fileVars, ...updateLocalDotenv(config) };
|
|
@@ -138,15 +140,18 @@ var config_default = async (config) => {
|
|
|
138
140
|
author = void 0,
|
|
139
141
|
email = "EMAIL",
|
|
140
142
|
homepage = "HOMEPAGE",
|
|
143
|
+
icon = DefaultIconGroupName,
|
|
141
144
|
lang = Language.English,
|
|
142
145
|
incognito,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
rootDir = ".",
|
|
147
|
+
outDir = "dist",
|
|
148
|
+
srcDir = "src",
|
|
146
149
|
sharedDir = "shared",
|
|
147
150
|
appsDir = "apps",
|
|
148
|
-
|
|
151
|
+
appSrcDir = ".",
|
|
149
152
|
localeDir = "locales",
|
|
153
|
+
iconSrcDir = "icons",
|
|
154
|
+
iconOutDir = "icons",
|
|
150
155
|
jsDir = "js",
|
|
151
156
|
cssDir = "css",
|
|
152
157
|
assetsDir = "assets",
|
|
@@ -155,7 +160,6 @@ var config_default = async (config) => {
|
|
|
155
160
|
html = [],
|
|
156
161
|
bundler = {},
|
|
157
162
|
env = {},
|
|
158
|
-
icon = {},
|
|
159
163
|
manifestVersion = (/* @__PURE__ */ new Set([Browser.Safari])).has(browser) ? 2 : 3,
|
|
160
164
|
mode = Mode.Development,
|
|
161
165
|
analyze = false,
|
|
@@ -177,6 +181,7 @@ var config_default = async (config) => {
|
|
|
177
181
|
mergeService = false,
|
|
178
182
|
mergeOffscreen = false,
|
|
179
183
|
commonChunks = true,
|
|
184
|
+
artifactName = "[name]-[browser]-[mv]",
|
|
180
185
|
assetsFilename = mode === Mode.Production && command === Command.Build && !debug ? "[contenthash:4][ext]" : "[name]-[contenthash:4][ext]",
|
|
181
186
|
jsFilename = mode === Mode.Production && command === Command.Build && !debug ? "[contenthash:5].js" : "[name].js",
|
|
182
187
|
cssFilename = mode === Mode.Production && command === Command.Build && !debug ? "[contenthash:5].css" : "[name].css",
|
|
@@ -197,24 +202,26 @@ var config_default = async (config) => {
|
|
|
197
202
|
author,
|
|
198
203
|
homepage,
|
|
199
204
|
lang,
|
|
205
|
+
icon,
|
|
200
206
|
incognito,
|
|
201
207
|
manifestVersion,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
rootDir,
|
|
209
|
+
outDir,
|
|
210
|
+
srcDir,
|
|
205
211
|
sharedDir,
|
|
206
212
|
appsDir,
|
|
207
|
-
|
|
213
|
+
appSrcDir,
|
|
208
214
|
jsDir,
|
|
209
215
|
cssDir,
|
|
210
216
|
assetsDir,
|
|
211
217
|
publicDir,
|
|
212
218
|
htmlDir,
|
|
213
219
|
localeDir,
|
|
220
|
+
iconSrcDir,
|
|
221
|
+
iconOutDir,
|
|
214
222
|
html,
|
|
215
223
|
bundler,
|
|
216
224
|
env,
|
|
217
|
-
icon,
|
|
218
225
|
plugins,
|
|
219
226
|
analyze,
|
|
220
227
|
configFile,
|
|
@@ -235,6 +242,7 @@ var config_default = async (config) => {
|
|
|
235
242
|
mergeService,
|
|
236
243
|
mergeOffscreen,
|
|
237
244
|
commonChunks,
|
|
245
|
+
artifactName,
|
|
238
246
|
assetsFilename,
|
|
239
247
|
jsFilename,
|
|
240
248
|
cssFilename,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/resolvers/config.ts"],"sourcesContent":["import {existsSync} from \"fs\";\nimport dotenv, {type DotenvParseOutput} from \"dotenv\";\nimport {loadConfig} from \"c12\";\nimport _ from \"lodash\";\n\nimport {\n assetPlugin,\n backgroundPlugin,\n bundlerPlugin,\n contentPlugin,\n dotenvPlugin,\n htmlPlugin,\n iconPlugin,\n localePlugin,\n metaPlugin,\n offscreenPlugin,\n optimizationPlugin,\n outputPlugin,\n pagePlugin,\n popupPlugin,\n publicPlugin,\n reactPlugin,\n sidebarPlugin,\n stylePlugin,\n typescriptPlugin,\n versionPlugin,\n viewPlugin,\n} from \"../plugins\";\n\nimport {getAppPath, getAppSourcePath, getConfigFile, getInputPath} from \"../resolvers/path\";\n\nimport {Config, OptionalConfig, ReadonlyConfig, UserConfig} from \"@typing/config\";\nimport {Command, Mode} from \"@typing/app\";\nimport {Browser} from \"@typing/browser\";\nimport {Plugin} from \"@typing/plugin\";\nimport {ManifestVersion} from \"@typing/manifest\";\nimport {Language} from \"@typing/locale\";\n\nconst getUserConfig = async (config: ReadonlyConfig): Promise<UserConfig> => {\n const configFilePath = getConfigFile(config);\n\n if (existsSync(configFilePath)) {\n const {config: userConfig} = await loadConfig<UserConfig>({\n configFile: configFilePath,\n dotenv: true,\n });\n\n if (config.debug) {\n console.log(\"Loaded user config:\", configFilePath);\n }\n\n return userConfig || {};\n } else if (config.debug) {\n console.warn(\"Config file not found:\", configFilePath);\n }\n\n return {};\n};\n\nconst validateConfig = (config: ReadonlyConfig): ReadonlyConfig => {\n const {\n outputDir,\n sourceDir,\n sharedDir,\n appsDir,\n appSourceDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n publicDir,\n localeDir,\n icon,\n } = config;\n\n if (\n [\n outputDir,\n sourceDir,\n sharedDir,\n appsDir,\n appSourceDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n publicDir,\n localeDir,\n icon.outputDir,\n icon.sourceDir,\n ]\n .filter(dir => _.isString(dir))\n .some(dir => dir.includes(\"..\"))\n ) {\n throw new Error('Directory paths cannot contain relative paths (\"..\") for security reasons.');\n }\n\n if (appsDir === sharedDir) {\n throw new Error(\"Apps directory (appsDir) and shared directory (sharedDir) cannot be the same.\");\n }\n\n if (sourceDir === outputDir) {\n throw new Error(\"Source directory (srcDir) and destination directory (outputDir) cannot be the same.\");\n }\n\n if (sourceDir === \".\") {\n throw new Error('Source directory cannot be the root directory (\".\") for security reasons.');\n }\n\n if (publicDir === \".\" || [sourceDir, outputDir, appSourceDir].includes(publicDir)) {\n throw new Error(\n 'Public directory cannot be the root directory (\".\") or intersect with other root directories for security reasons.'\n );\n }\n\n return config;\n};\n\nconst updateLocalDotenv = (config: ReadonlyConfig): DotenvParseOutput => {\n const {mode, app, browser, manifestVersion} = config;\n\n const localVars: DotenvParseOutput = {\n APP: app,\n BROWSER: browser,\n MODE: mode,\n MANIFEST_VERSION: String(manifestVersion),\n };\n\n Object.assign(process.env, localVars);\n\n return localVars;\n};\n\nconst loadDotenv = (config: ReadonlyConfig): DotenvParseOutput => {\n const {mode, browser} = config;\n\n const preset = [\n `.env.${mode}.${browser}.local`,\n `.env.${mode}.${browser}`,\n `.env.${browser}.local`,\n `.env.${browser}`,\n `.env.${mode}.local`,\n `.env.${mode}`,\n `.env.local`,\n `.env`,\n ];\n\n const appSourcePaths = preset.map(file => getAppSourcePath(config, file));\n const appPaths = preset.map(file => getAppPath(config, file));\n const rootPaths = preset.map(file => getInputPath(config, file));\n\n const paths = [...appSourcePaths, ...appPaths, ...rootPaths];\n\n const {parsed: fileVars = {}} = dotenv.config({path: paths});\n\n return {...fileVars, ...updateLocalDotenv(config)};\n};\n\nexport default async (config: OptionalConfig): Promise<Config> => {\n let {\n command = Command.Build,\n debug = false,\n configFile = \"adnbn.config.ts\",\n browser = Browser.Chrome,\n app = \"myapp\",\n name = app,\n description,\n shortName,\n version = \"VERSION\",\n minimumVersion = \"MINIMUM_VERSION\",\n author = undefined,\n email = \"EMAIL\",\n homepage = \"HOMEPAGE\",\n lang = Language.English,\n incognito,\n inputDir = \".\",\n outputDir = \"dist\",\n sourceDir = \"src\",\n sharedDir = \"shared\",\n appsDir = \"apps\",\n appSourceDir = \".\",\n localeDir = \"locales\",\n jsDir = \"js\",\n cssDir = \"css\",\n assetsDir = \"assets\",\n publicDir = \"public\",\n htmlDir = \".\",\n html = [],\n bundler = {},\n env = {},\n icon = {},\n manifestVersion = (new Set<Browser>([Browser.Safari]).has(browser) ? 2 : 3) as ManifestVersion,\n mode = Mode.Development,\n analyze = false,\n plugins = [],\n mergeBackground = false,\n mergeCommands = false,\n mergeContentScripts = false,\n concatContentScripts = true,\n mergeStyles = true,\n mergeIcons = false,\n mergeLocales = true,\n mergePages = false,\n mergePopup = false,\n mergePublic = false,\n multiplePopup = false,\n mergeSidebar = false,\n multipleSidebar = false,\n mergeRelay = false,\n mergeService = false,\n mergeOffscreen = false,\n commonChunks = true,\n assetsFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:4][ext]\"\n : \"[name]-[contenthash:4][ext]\",\n jsFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:5].js\"\n : \"[name].js\",\n cssFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:5].css\"\n : \"[name].css\",\n cssIdentName = mode === Mode.Production && command === Command.Build && !debug\n ? \"[app]-[hash:base64:5]\"\n : \"[local]-[hash:base64:5]\",\n } = config;\n\n let resolvedConfig: Config = {\n command,\n debug,\n mode,\n browser,\n app,\n name,\n description,\n shortName,\n version,\n minimumVersion,\n email,\n author,\n homepage,\n lang,\n incognito,\n manifestVersion,\n inputDir,\n outputDir,\n sourceDir,\n sharedDir,\n appsDir,\n appSourceDir,\n jsDir,\n cssDir,\n assetsDir,\n publicDir,\n htmlDir,\n localeDir,\n html,\n bundler,\n env,\n icon,\n plugins,\n analyze,\n configFile,\n mergeBackground,\n mergeCommands,\n mergeContentScripts,\n concatContentScripts,\n mergeStyles,\n mergeIcons,\n mergeLocales,\n mergePages,\n mergePopup,\n mergePublic,\n multiplePopup,\n mergeSidebar,\n multipleSidebar,\n mergeRelay,\n mergeService,\n mergeOffscreen,\n commonChunks,\n assetsFilename,\n jsFilename,\n cssFilename,\n cssIdentName,\n };\n\n let vars = loadDotenv(resolvedConfig);\n\n const {plugins: userPlugins = [], ...userConfig} = await getUserConfig(resolvedConfig);\n\n resolvedConfig = validateConfig({...resolvedConfig, ...userConfig});\n\n vars = {...vars, ...loadDotenv(resolvedConfig)};\n\n /**\n * IMPORTANT: the order of plugins matters. Early plugins prepare the environment and artifacts for the following ones\n * (e.g., environment variables/output/transpilation/assets → page/version generation → bundling).\n * Reordering may result in missing artifacts, incorrect configuration, or build failures.\n */\n const corePlugins: Plugin[] = [\n dotenvPlugin(vars),\n outputPlugin(),\n optimizationPlugin(),\n typescriptPlugin(),\n reactPlugin(),\n iconPlugin(),\n assetPlugin(),\n stylePlugin(),\n localePlugin(),\n metaPlugin(),\n contentPlugin(),\n backgroundPlugin(),\n popupPlugin(),\n publicPlugin(),\n sidebarPlugin(),\n offscreenPlugin(),\n pagePlugin(),\n viewPlugin(),\n htmlPlugin(),\n versionPlugin(),\n bundlerPlugin(),\n ];\n\n return {\n ...resolvedConfig,\n plugins: [...plugins, ...userPlugins, ...corePlugins],\n };\n};\n"],"mappings":"AAAA,SAAQ,kBAAiB;AACzB,OAAO,YAAsC;AAC7C,SAAQ,kBAAiB;AACzB,OAAO,OAAO;AAEd;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAQ,YAAY,kBAAkB,eAAe,oBAAmB;AAGxE,SAAQ,SAAS,YAAW;AAC5B,SAAQ,eAAc;AAGtB,SAAQ,gBAAe;AAEvB,MAAM,gBAAgB,OAAO,WAAgD;AACzE,QAAM,iBAAiB,cAAc,MAAM;AAE3C,MAAI,WAAW,cAAc,GAAG;AAC5B,UAAM,EAAC,QAAQ,WAAU,IAAI,MAAM,WAAuB;AAAA,MACtD,YAAY;AAAA,MACZ,QAAQ;AAAA,IACZ,CAAC;AAED,QAAI,OAAO,OAAO;AACd,cAAQ,IAAI,uBAAuB,cAAc;AAAA,IACrD;AAEA,WAAO,cAAc,CAAC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,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAEA,MAAI,OAAO,WAAW,cAAc;AAEpC,QAAM,EAAC,SAAS,cAAc,CAAC,GAAG,GAAG,WAAU,IAAI,MAAM,cAAc,cAAc;AAErF,mBAAiB,eAAe,EAAC,GAAG,gBAAgB,GAAG,WAAU,CAAC;AAElE,SAAO,EAAC,GAAG,MAAM,GAAG,WAAW,cAAc,EAAC;AAO9C,QAAM,cAAwB;AAAA,IAC1B,aAAa,IAAI;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW;AAAA,IACX,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,cAAc;AAAA,IACd,cAAc;AAAA,EAClB;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,SAAS,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW;AAAA,EACxD;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/resolvers/config.ts"],"sourcesContent":["import {existsSync} from \"fs\";\nimport dotenv, {type DotenvParseOutput} from \"dotenv\";\nimport {loadConfig} from \"c12\";\nimport _ from \"lodash\";\n\nimport {\n assetPlugin,\n backgroundPlugin,\n bundlerPlugin,\n contentPlugin,\n dotenvPlugin,\n htmlPlugin,\n iconPlugin,\n localePlugin,\n metaPlugin,\n offscreenPlugin,\n optimizationPlugin,\n outputPlugin,\n pagePlugin,\n popupPlugin,\n publicPlugin,\n reactPlugin,\n sidebarPlugin,\n stylePlugin,\n typescriptPlugin,\n versionPlugin,\n viewPlugin,\n} from \"../plugins\";\n\nimport {fromRootPath, getAppPath, getAppSourcePath, getConfigFile} from \"../resolvers/path\";\n\nimport {Config, OptionalConfig, ReadonlyConfig, UserConfig} from \"@typing/config\";\nimport {Command, Mode} from \"@typing/app\";\nimport {Browser} from \"@typing/browser\";\nimport {Plugin} from \"@typing/plugin\";\nimport {ManifestVersion} from \"@typing/manifest\";\nimport {Language} from \"@typing/locale\";\nimport {DefaultIconGroupName} from \"@typing/icon\";\n\nconst getUserConfig = async (config: ReadonlyConfig): Promise<UserConfig> => {\n const configFilePath = getConfigFile(config);\n\n if (existsSync(configFilePath)) {\n const {config: userConfig} = await loadConfig<UserConfig>({\n configFile: configFilePath,\n dotenv: true,\n });\n\n if (config.debug) {\n console.log(\"Loaded user config:\", configFilePath);\n }\n\n return userConfig || {};\n } else if (config.debug) {\n console.warn(\"Config file not found:\", configFilePath);\n }\n\n return {};\n};\n\nconst validateConfig = (config: ReadonlyConfig): ReadonlyConfig => {\n const {\n outDir,\n srcDir,\n sharedDir,\n appsDir,\n appSrcDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n publicDir,\n localeDir,\n iconSrcDir,\n iconOutDir,\n } = config;\n\n if (\n [\n outDir,\n srcDir,\n sharedDir,\n appsDir,\n appSrcDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n publicDir,\n localeDir,\n iconSrcDir,\n iconOutDir,\n ]\n .filter(dir => _.isString(dir))\n .some(dir => dir.includes(\"..\"))\n ) {\n throw new Error('Directory paths cannot contain relative paths (\"..\") for security reasons.');\n }\n\n if (appsDir === sharedDir) {\n throw new Error(\"Apps directory (appsDir) and shared directory (sharedDir) cannot be the same.\");\n }\n\n if (srcDir === outDir) {\n throw new Error(\"Source directory (srcDir) and destination directory (outputDir) cannot be the same.\");\n }\n\n if (srcDir === \".\") {\n throw new Error('Source directory cannot be the root directory (\".\") for security reasons.');\n }\n\n if (publicDir === \".\" || [srcDir, outDir, appSrcDir].includes(publicDir)) {\n throw new Error(\n 'Public directory cannot be the root directory (\".\") or intersect with other root directories for security reasons.'\n );\n }\n\n return config;\n};\n\nconst updateLocalDotenv = (config: ReadonlyConfig): DotenvParseOutput => {\n const {mode, app, browser, manifestVersion} = config;\n\n const localVars: DotenvParseOutput = {\n APP: app,\n BROWSER: browser,\n MODE: mode,\n MANIFEST_VERSION: String(manifestVersion),\n };\n\n Object.assign(process.env, localVars);\n\n return localVars;\n};\n\nconst loadDotenv = (config: ReadonlyConfig): DotenvParseOutput => {\n const {mode, browser} = config;\n\n const preset = [\n `.env.${mode}.${browser}.local`,\n `.env.${mode}.${browser}`,\n `.env.${browser}.local`,\n `.env.${browser}`,\n `.env.${mode}.local`,\n `.env.${mode}`,\n `.env.local`,\n `.env`,\n ];\n\n const appSourcePaths = preset.map(file => getAppSourcePath(config, file));\n const appPaths = preset.map(file => getAppPath(config, file));\n const rootPaths = preset.map(file => fromRootPath(config, file));\n\n const paths = [...appSourcePaths, ...appPaths, ...rootPaths];\n\n const {parsed: fileVars = {}} = dotenv.config({path: paths});\n\n return {...fileVars, ...updateLocalDotenv(config)};\n};\n\nexport default async (config: OptionalConfig): Promise<Config> => {\n let {\n command = Command.Build,\n debug = false,\n configFile = \"adnbn.config.ts\",\n browser = Browser.Chrome,\n app = \"myapp\",\n name = app,\n description,\n shortName,\n version = \"VERSION\",\n minimumVersion = \"MINIMUM_VERSION\",\n author = undefined,\n email = \"EMAIL\",\n homepage = \"HOMEPAGE\",\n icon = DefaultIconGroupName,\n lang = Language.English,\n incognito,\n rootDir = \".\",\n outDir = \"dist\",\n srcDir = \"src\",\n sharedDir = \"shared\",\n appsDir = \"apps\",\n appSrcDir = \".\",\n localeDir = \"locales\",\n iconSrcDir = \"icons\",\n iconOutDir = \"icons\",\n jsDir = \"js\",\n cssDir = \"css\",\n assetsDir = \"assets\",\n publicDir = \"public\",\n htmlDir = \".\",\n html = [],\n bundler = {},\n env = {},\n manifestVersion = (new Set<Browser>([Browser.Safari]).has(browser) ? 2 : 3) as ManifestVersion,\n mode = Mode.Development,\n analyze = false,\n plugins = [],\n mergeBackground = false,\n mergeCommands = false,\n mergeContentScripts = false,\n concatContentScripts = true,\n mergeStyles = true,\n mergeIcons = false,\n mergeLocales = true,\n mergePages = false,\n mergePopup = false,\n mergePublic = false,\n multiplePopup = false,\n mergeSidebar = false,\n multipleSidebar = false,\n mergeRelay = false,\n mergeService = false,\n mergeOffscreen = false,\n commonChunks = true,\n artifactName = \"[name]-[browser]-[mv]\",\n assetsFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:4][ext]\"\n : \"[name]-[contenthash:4][ext]\",\n jsFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:5].js\"\n : \"[name].js\",\n cssFilename = mode === Mode.Production && command === Command.Build && !debug\n ? \"[contenthash:5].css\"\n : \"[name].css\",\n cssIdentName = mode === Mode.Production && command === Command.Build && !debug\n ? \"[app]-[hash:base64:5]\"\n : \"[local]-[hash:base64:5]\",\n } = config;\n\n let resolvedConfig: Config = {\n command,\n debug,\n mode,\n browser,\n app,\n name,\n description,\n shortName,\n version,\n minimumVersion,\n email,\n author,\n homepage,\n lang,\n icon,\n incognito,\n manifestVersion,\n rootDir,\n outDir,\n srcDir,\n sharedDir,\n appsDir,\n appSrcDir,\n jsDir,\n cssDir,\n assetsDir,\n publicDir,\n htmlDir,\n localeDir,\n iconSrcDir,\n iconOutDir,\n html,\n bundler,\n env,\n plugins,\n analyze,\n configFile,\n mergeBackground,\n mergeCommands,\n mergeContentScripts,\n concatContentScripts,\n mergeStyles,\n mergeIcons,\n mergeLocales,\n mergePages,\n mergePopup,\n mergePublic,\n multiplePopup,\n mergeSidebar,\n multipleSidebar,\n mergeRelay,\n mergeService,\n mergeOffscreen,\n commonChunks,\n artifactName,\n assetsFilename,\n jsFilename,\n cssFilename,\n cssIdentName,\n };\n\n let vars = loadDotenv(resolvedConfig);\n\n const {plugins: userPlugins = [], ...userConfig} = await getUserConfig(resolvedConfig);\n\n resolvedConfig = validateConfig({...resolvedConfig, ...userConfig});\n\n vars = {...vars, ...loadDotenv(resolvedConfig)};\n\n /**\n * IMPORTANT: the order of plugins matters. Early plugins prepare the environment and artifacts for the following ones\n * (e.g., environment variables/output/transpilation/assets → page/version generation → bundling).\n * Reordering may result in missing artifacts, incorrect configuration, or build failures.\n */\n const corePlugins: Plugin[] = [\n dotenvPlugin(vars),\n outputPlugin(),\n optimizationPlugin(),\n typescriptPlugin(),\n reactPlugin(),\n iconPlugin(),\n assetPlugin(),\n stylePlugin(),\n localePlugin(),\n metaPlugin(),\n contentPlugin(),\n backgroundPlugin(),\n popupPlugin(),\n publicPlugin(),\n sidebarPlugin(),\n offscreenPlugin(),\n pagePlugin(),\n viewPlugin(),\n htmlPlugin(),\n versionPlugin(),\n bundlerPlugin(),\n ];\n\n return {\n ...resolvedConfig,\n plugins: [...plugins, ...userPlugins, ...corePlugins],\n };\n};\n"],"mappings":"AAAA,SAAQ,kBAAiB;AACzB,OAAO,YAAsC;AAC7C,SAAQ,kBAAiB;AACzB,OAAO,OAAO;AAEd;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAQ,cAAc,YAAY,kBAAkB,qBAAoB;AAGxE,SAAQ,SAAS,YAAW;AAC5B,SAAQ,eAAc;AAGtB,SAAQ,gBAAe;AACvB,SAAQ,4BAA2B;AAEnC,MAAM,gBAAgB,OAAO,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EA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,SAAS,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW;AAAA,EACxD;AACJ;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReadonlyConfig } from '../../config-
|
|
1
|
+
import { R as ReadonlyConfig } from '../../config-Ce0Le6r4.js';
|
|
2
2
|
import '@rspack/core';
|
|
3
3
|
import 'html-rspack-tags-plugin';
|
|
4
4
|
import '../../types/app.js';
|
|
@@ -12,14 +12,16 @@ import '../../types/helpers.js';
|
|
|
12
12
|
import '../../types/background.js';
|
|
13
13
|
import '../../types/command.js';
|
|
14
14
|
import '../../types/locale.js';
|
|
15
|
+
import '../../types/env.js';
|
|
15
16
|
|
|
16
|
-
declare const
|
|
17
|
-
declare const
|
|
17
|
+
declare const getResolvePath: (to: string) => string;
|
|
18
|
+
declare const fromRootPath: (config: ReadonlyConfig, to?: string) => string;
|
|
18
19
|
declare const getSourcePath: (config: ReadonlyConfig, to?: string) => string;
|
|
19
20
|
declare const getSharedPath: (config: ReadonlyConfig, to?: string) => string;
|
|
20
21
|
declare const getAppPath: (config: ReadonlyConfig, to?: string) => string;
|
|
21
22
|
declare const getAppSourcePath: (config: ReadonlyConfig, to?: string) => string;
|
|
22
23
|
declare const getOutputPath: (config: ReadonlyConfig) => string;
|
|
23
24
|
declare const getConfigFile: (config: ReadonlyConfig) => string;
|
|
25
|
+
declare const getArtifactName: (config: ReadonlyConfig) => string;
|
|
24
26
|
|
|
25
|
-
export { getAppPath, getAppSourcePath,
|
|
27
|
+
export { fromRootPath, getAppPath, getAppSourcePath, getArtifactName, getConfigFile, getOutputPath, getResolvePath, getSharedPath, getSourcePath };
|
|
@@ -1,39 +1,49 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import _ from "lodash";
|
|
3
|
-
const
|
|
3
|
+
const getResolvePath = (to) => {
|
|
4
4
|
return path.resolve(process.cwd(), to);
|
|
5
5
|
};
|
|
6
|
-
const
|
|
7
|
-
return path.join(config.
|
|
6
|
+
const fromRootPath = (config, to) => {
|
|
7
|
+
return path.join(config.rootDir, to ?? "");
|
|
8
8
|
};
|
|
9
9
|
const getSourcePath = (config, to) => {
|
|
10
|
-
return
|
|
10
|
+
return fromRootPath(config, path.join(config.srcDir, to ?? ""));
|
|
11
11
|
};
|
|
12
12
|
const getSharedPath = (config, to) => {
|
|
13
|
-
return
|
|
13
|
+
return fromRootPath(config, path.join(config.srcDir, config.sharedDir, to ?? ""));
|
|
14
14
|
};
|
|
15
15
|
const getAppPath = (config, to) => {
|
|
16
|
-
return
|
|
16
|
+
return fromRootPath(config, path.join(config.srcDir, config.appsDir, config.app, to ?? ""));
|
|
17
17
|
};
|
|
18
18
|
const getAppSourcePath = (config, to) => {
|
|
19
|
-
return getAppPath(config, path.join(config.
|
|
19
|
+
return getAppPath(config, path.join(config.appSrcDir, to ?? ""));
|
|
20
20
|
};
|
|
21
21
|
const getOutputPath = (config) => {
|
|
22
|
-
return
|
|
23
|
-
config,
|
|
24
|
-
path.join(config.outputDir, `${_.kebabCase(config.app)}-${config.browser}-mv${config.manifestVersion}`)
|
|
25
|
-
);
|
|
22
|
+
return fromRootPath(config, path.join(config.outDir, getArtifactName(config)));
|
|
26
23
|
};
|
|
27
24
|
const getConfigFile = (config) => {
|
|
28
|
-
return
|
|
25
|
+
return fromRootPath(config, config.configFile);
|
|
26
|
+
};
|
|
27
|
+
const getArtifactName = (config) => {
|
|
28
|
+
const app = _.kebabCase(config.app);
|
|
29
|
+
const replacements = {
|
|
30
|
+
"[app]": app,
|
|
31
|
+
"[name]": app,
|
|
32
|
+
"[mode]": config.mode,
|
|
33
|
+
"[browser]": config.browser,
|
|
34
|
+
"[mv]": "mv" + config.manifestVersion.toString()
|
|
35
|
+
};
|
|
36
|
+
const name = _.reduce(replacements, (result, value, key) => result.replaceAll(key, value), config.artifactName);
|
|
37
|
+
return _.kebabCase(name).replace(/\bmv-(\d+)/gi, "mv$1");
|
|
29
38
|
};
|
|
30
39
|
export {
|
|
40
|
+
fromRootPath,
|
|
31
41
|
getAppPath,
|
|
32
42
|
getAppSourcePath,
|
|
43
|
+
getArtifactName,
|
|
33
44
|
getConfigFile,
|
|
34
|
-
getInputPath,
|
|
35
45
|
getOutputPath,
|
|
36
|
-
|
|
46
|
+
getResolvePath,
|
|
37
47
|
getSharedPath,
|
|
38
48
|
getSourcePath
|
|
39
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/resolvers/path.ts"],"sourcesContent":["import path from \"path\";\nimport _ from \"lodash\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\n\nexport const
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/resolvers/path.ts"],"sourcesContent":["import path from \"path\";\nimport _ from \"lodash\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\n\nexport const getResolvePath = (to: string): string => {\n return path.resolve(process.cwd(), to);\n};\n\nexport const fromRootPath = (config: ReadonlyConfig, to?: string): string => {\n return path.join(config.rootDir, to ?? \"\");\n};\n\nexport const getSourcePath = (config: ReadonlyConfig, to?: string): string => {\n return fromRootPath(config, path.join(config.srcDir, to ?? \"\"));\n};\n\nexport const getSharedPath = (config: ReadonlyConfig, to?: string): string => {\n return fromRootPath(config, path.join(config.srcDir, config.sharedDir, to ?? \"\"));\n};\n\nexport const getAppPath = (config: ReadonlyConfig, to?: string): string => {\n return fromRootPath(config, path.join(config.srcDir, config.appsDir, config.app, to ?? \"\"));\n};\n\nexport const getAppSourcePath = (config: ReadonlyConfig, to?: string): string => {\n return getAppPath(config, path.join(config.appSrcDir, to ?? \"\"));\n};\n\nexport const getOutputPath = (config: ReadonlyConfig): string => {\n return fromRootPath(config, path.join(config.outDir, getArtifactName(config)));\n};\n\nexport const getConfigFile = (config: ReadonlyConfig): string => {\n return fromRootPath(config, config.configFile);\n};\n\nexport const getArtifactName = (config: ReadonlyConfig): string => {\n const app = _.kebabCase(config.app);\n\n const replacements: Record<string, string> = {\n \"[app]\": app,\n \"[name]\": app,\n \"[mode]\": config.mode,\n \"[browser]\": config.browser,\n \"[mv]\": \"mv\" + config.manifestVersion.toString(),\n };\n\n const name = _.reduce(replacements, (result, value, key) => result.replaceAll(key, value), config.artifactName);\n\n return _.kebabCase(name).replace(/\\bmv-(\\d+)/gi, \"mv$1\");\n};\n"],"mappings":"AAAA,OAAO,UAAU;AACjB,OAAO,OAAO;AAIP,MAAM,iBAAiB,CAAC,OAAuB;AAClD,SAAO,KAAK,QAAQ,QAAQ,IAAI,GAAG,EAAE;AACzC;AAEO,MAAM,eAAe,CAAC,QAAwB,OAAwB;AACzE,SAAO,KAAK,KAAK,OAAO,SAAS,MAAM,EAAE;AAC7C;AAEO,MAAM,gBAAgB,CAAC,QAAwB,OAAwB;AAC1E,SAAO,aAAa,QAAQ,KAAK,KAAK,OAAO,QAAQ,MAAM,EAAE,CAAC;AAClE;AAEO,MAAM,gBAAgB,CAAC,QAAwB,OAAwB;AAC1E,SAAO,aAAa,QAAQ,KAAK,KAAK,OAAO,QAAQ,OAAO,WAAW,MAAM,EAAE,CAAC;AACpF;AAEO,MAAM,aAAa,CAAC,QAAwB,OAAwB;AACvE,SAAO,aAAa,QAAQ,KAAK,KAAK,OAAO,QAAQ,OAAO,SAAS,OAAO,KAAK,MAAM,EAAE,CAAC;AAC9F;AAEO,MAAM,mBAAmB,CAAC,QAAwB,OAAwB;AAC7E,SAAO,WAAW,QAAQ,KAAK,KAAK,OAAO,WAAW,MAAM,EAAE,CAAC;AACnE;AAEO,MAAM,gBAAgB,CAAC,WAAmC;AAC7D,SAAO,aAAa,QAAQ,KAAK,KAAK,OAAO,QAAQ,gBAAgB,MAAM,CAAC,CAAC;AACjF;AAEO,MAAM,gBAAgB,CAAC,WAAmC;AAC7D,SAAO,aAAa,QAAQ,OAAO,UAAU;AACjD;AAEO,MAAM,kBAAkB,CAAC,WAAmC;AAC/D,QAAM,MAAM,EAAE,UAAU,OAAO,GAAG;AAElC,QAAM,eAAuC;AAAA,IACzC,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU,OAAO;AAAA,IACjB,aAAa,OAAO;AAAA,IACpB,QAAQ,OAAO,OAAO,gBAAgB,SAAS;AAAA,EACnD;AAEA,QAAM,OAAO,EAAE,OAAO,cAAc,CAAC,QAAQ,OAAO,QAAQ,OAAO,WAAW,KAAK,KAAK,GAAG,OAAO,YAAY;AAE9G,SAAO,EAAE,UAAU,IAAI,EAAE,QAAQ,gBAAgB,MAAM;AAC3D;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as PluginHandler, c as PluginHandlerKeys, P as Plugin, f as PluginHandlerOptions, g as PluginNameHandlerResult } from '../../config-
|
|
1
|
+
import { e as PluginHandler, c as PluginHandlerKeys, P as Plugin, f as PluginHandlerOptions, g as PluginNameHandlerResult } from '../../config-Ce0Le6r4.js';
|
|
2
2
|
import '@rspack/core';
|
|
3
3
|
import 'html-rspack-tags-plugin';
|
|
4
4
|
import '../../types/app.js';
|
|
@@ -12,6 +12,7 @@ import '../../types/helpers.js';
|
|
|
12
12
|
import '../../types/background.js';
|
|
13
13
|
import '../../types/command.js';
|
|
14
14
|
import '../../types/locale.js';
|
|
15
|
+
import '../../types/env.js';
|
|
15
16
|
|
|
16
17
|
declare const resolvePluginHandler: <O extends object, T>(handler: PluginHandler<O, T> | undefined, options: O) => Promise<T | undefined>;
|
|
17
18
|
declare const processPluginHandler: <K extends PluginHandlerKeys>(plugins: Plugin[], key: K, options: PluginHandlerOptions<K> | {
|
|
@@ -8,16 +8,16 @@ var command_default = 'import type {CommandUnresolvedDefinition} from "adnbn";\n
|
|
|
8
8
|
var content_default = 'import type {ContentScriptDefinition} from "adnbn";\nimport {isContentScriptDefinition, isValidContentScriptDefinitionRenderValue} from "adnbn/entry/content";\n\nimport contentScript from "virtual:content-framework";\n\nimport * as module from "virtual:content-entrypoint";\n\ntry {\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: ContentScriptDefinition = otherDefinition;\n\n if (isContentScriptDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidContentScriptDefinitionRenderValue(defaultDefinition)) {\n definition = {...definition, render: defaultDefinition};\n }\n\n contentScript(definition);\n} catch (e) {\n console.error("The content script crashed on startup:", e);\n}\n';
|
|
9
9
|
|
|
10
10
|
// raw-loader:./transport.ts?raw
|
|
11
|
-
var transport_default = 'import
|
|
11
|
+
var transport_default = 'import type {TransportOptions, TransportType, TransportUnresolvedDefinition} from "adnbn/transport";\nimport {isValidTransportDefinition, isValidTransportInitFunction} from "adnbn/entry/transport";\n\n//@ts-ignore\nimport transport from "adnbn/entry/:entry";\n\nimport * as module from "virtual:transport-entrypoint";\n\ntry {\n const transportName = "virtual:transport-name";\n\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: TransportUnresolvedDefinition<TransportOptions, TransportType> = otherDefinition;\n\n if (isValidTransportDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, name, ...options} = definition;\n\n transport({name: transportName, init, ...options});\n} catch (e) {\n console.error("The :entry crashed on startup:", e);\n}\n';
|
|
12
12
|
|
|
13
13
|
// raw-loader:./offscreen.ts?raw
|
|
14
|
-
var offscreen_default = 'import type {OffscreenUnresolvedDefinition} from "adnbn";\nimport {isValidTransportDefinition, isValidTransportInitFunction
|
|
14
|
+
var offscreen_default = 'import type {OffscreenUnresolvedDefinition} from "adnbn";\nimport type {TransportType} from "adnbn/transport";\nimport {isValidTransportDefinition, isValidTransportInitFunction} from "adnbn/entry/transport";\nimport {Builder as OffscreenBuilder} from "adnbn/entry/offscreen";\n\nimport {Builder as ViewBuilder} from "virtual:view-framework";\n\nimport * as module from "virtual:offscreen-entrypoint";\n\ntry {\n const offscreenName = "virtual:offscreen-name";\n\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: OffscreenUnresolvedDefinition<TransportType> = otherDefinition;\n\n if (isValidTransportDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, main, name, ...options} = definition;\n\n new OffscreenBuilder({\n name: offscreenName,\n init,\n main,\n ...options,\n })\n .view(new ViewBuilder(options))\n .build()\n .catch(e => {\n console.error("Failed to build offscreen: ", e);\n });\n} catch (e) {\n console.error("The offscreen crashed on startup:", e);\n}\n';
|
|
15
15
|
|
|
16
16
|
// raw-loader:./offscreen.background.ts?raw
|
|
17
17
|
var offscreen_background_default = 'import {OffscreenBackground} from "adnbn/offscreen";\n\ntry {\n new OffscreenBackground().build();\n} catch (e) {\n console.error("Failed to build offscreen layer on background:", e);\n}\n';
|
|
18
18
|
|
|
19
19
|
// raw-loader:./relay.ts?raw
|
|
20
|
-
var relay_default = 'import type {RelayUnresolvedDefinition} from "adnbn";\nimport {isValidTransportDefinition, isValidTransportInitFunction
|
|
20
|
+
var relay_default = 'import type {RelayUnresolvedDefinition} from "adnbn";\nimport type {TransportType} from "adnbn/transport";\nimport {isValidTransportDefinition, isValidTransportInitFunction} from "adnbn/entry/transport";\nimport {Builder as RelayBuilder} from "adnbn/entry/relay";\n\nimport {Builder as ContentScriptBuilder} from "virtual:content-framework";\n\nimport * as module from "virtual:relay-entrypoint";\n\ntry {\n const relayName = "virtual:relay-name";\n\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: RelayUnresolvedDefinition<TransportType> = otherDefinition;\n\n if (isValidTransportDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, main, name, ...options} = definition;\n\n new RelayBuilder({\n name: relayName,\n init,\n main,\n ...options,\n })\n .content(new ContentScriptBuilder(options))\n .build()\n .catch(e => {\n console.error("Failed to build relay: ", e);\n });\n} catch (e) {\n console.error("The relay crashed on startup:", e);\n}\n';
|
|
21
21
|
|
|
22
22
|
// raw-loader:./view.ts?raw
|
|
23
23
|
var view_default = 'import type {ViewDefinition, ViewOptions} from "adnbn";\nimport {__t} from "adnbn/locale";\nimport {isViewDefinition, isValidViewDefinitionRenderValue} from "adnbn/entry/view";\n\nimport view from "virtual:view-framework";\n\nimport * as module from "virtual:view-entrypoint";\n\ntry {\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: ViewDefinition<ViewOptions> = otherDefinition;\n\n if (isViewDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidViewDefinitionRenderValue(defaultDefinition)) {\n definition = {...definition, render: defaultDefinition};\n }\n\n const {title, ...options} = definition;\n\n view({title: title ? __t(title) : undefined, ...options});\n} catch (e) {\n console.error("The view crashed on startup:", e);\n}\n';
|
|
@@ -5,6 +5,7 @@ import { Browser } from './types/browser.js';
|
|
|
5
5
|
import { ManifestBuilder, ManifestIncognitoValue, ManifestVersion } from './types/manifest.js';
|
|
6
6
|
import { Language } from './types/locale.js';
|
|
7
7
|
import { Awaiter } from './types/helpers.js';
|
|
8
|
+
import { EnvFilterVariant, EnvFilterOptions } from './types/env.js';
|
|
8
9
|
import { EntrypointFile } from './types/entrypoint.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -104,8 +105,8 @@ interface PluginNameHandlerResult<K extends PluginHandlerKeys> extends PluginNam
|
|
|
104
105
|
type PluginDefinition<T extends any[] = []> = (...args: T) => Plugin;
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
|
-
* Configuration
|
|
108
|
-
*
|
|
108
|
+
* Configuration object for defining various settings and build parameters
|
|
109
|
+
* for an extension application.
|
|
109
110
|
*/
|
|
110
111
|
interface Config {
|
|
111
112
|
/**
|
|
@@ -217,6 +218,20 @@ interface Config {
|
|
|
217
218
|
* @default HOMEPAGE
|
|
218
219
|
*/
|
|
219
220
|
homepage: string | (() => string | undefined);
|
|
221
|
+
/**
|
|
222
|
+
* Name of the icon group to use in the manifest as the primary extension icon (manifest.icons).
|
|
223
|
+
*
|
|
224
|
+
* An icon group is a named set of icons by sizes (e.g., 16, 32, 48, 128, ...).
|
|
225
|
+
* The value must match one of the available icon groups.
|
|
226
|
+
*
|
|
227
|
+
* @default: "default"
|
|
228
|
+
*
|
|
229
|
+
* Examples:
|
|
230
|
+
* - "default"
|
|
231
|
+
* - "active"
|
|
232
|
+
* - "disable"
|
|
233
|
+
*/
|
|
234
|
+
icon: string;
|
|
220
235
|
/**
|
|
221
236
|
* Used for Firefox under `browser_specific_settings.gecko.id`,
|
|
222
237
|
* but only if the "storage" permission is declared.
|
|
@@ -248,7 +263,7 @@ interface Config {
|
|
|
248
263
|
* This is the base directory relative to which other paths are defined.
|
|
249
264
|
* @example "addon"
|
|
250
265
|
*/
|
|
251
|
-
|
|
266
|
+
rootDir: string;
|
|
252
267
|
/**
|
|
253
268
|
* Directory where the built extensions will be placed.
|
|
254
269
|
* Final extension files will be located here.
|
|
@@ -257,7 +272,7 @@ interface Config {
|
|
|
257
272
|
*
|
|
258
273
|
* @default "dist"
|
|
259
274
|
*/
|
|
260
|
-
|
|
275
|
+
outDir: string;
|
|
261
276
|
/**
|
|
262
277
|
* Directory where the application and shared directory are located.
|
|
263
278
|
* Main directory with source code.
|
|
@@ -266,7 +281,7 @@ interface Config {
|
|
|
266
281
|
*
|
|
267
282
|
* @default "src"
|
|
268
283
|
*/
|
|
269
|
-
|
|
284
|
+
srcDir: string;
|
|
270
285
|
/**
|
|
271
286
|
* Directory with common modules, content scripts, and background scripts.
|
|
272
287
|
* Contains code used by multiple extensions.
|
|
@@ -293,7 +308,27 @@ interface Config {
|
|
|
293
308
|
*
|
|
294
309
|
* @default "."
|
|
295
310
|
*/
|
|
296
|
-
|
|
311
|
+
appSrcDir: string;
|
|
312
|
+
/**
|
|
313
|
+
* Directory for icons and logos. Can be located in the Shared directory,
|
|
314
|
+
* in the project root, or in a folder for a specific App.
|
|
315
|
+
*
|
|
316
|
+
* @example "icons"
|
|
317
|
+
*
|
|
318
|
+
* @path Full paths can be:
|
|
319
|
+
*
|
|
320
|
+
* - `{{inputDir}}/{{srcDir}}/{{icon.sourceDir}}`
|
|
321
|
+
* - `{{inputDir}}/{{sharedDir}}/{{icon.sourceDir}}`
|
|
322
|
+
* - `{{inputDir}}/{{appsDir}}/{{appDir}}/{{icon.sourceDir}}`
|
|
323
|
+
*/
|
|
324
|
+
iconSrcDir: string;
|
|
325
|
+
/**
|
|
326
|
+
* Directory for image files in outputDir.
|
|
327
|
+
*
|
|
328
|
+
* @example "icons"
|
|
329
|
+
* @path Full path: `{{inputDir}}/{{outputDir}}/{{appDir}}/{{icon.outputDir}}`
|
|
330
|
+
*/
|
|
331
|
+
iconOutDir: string;
|
|
297
332
|
/**
|
|
298
333
|
* Directory for output JavaScript files in outputDir.
|
|
299
334
|
* All compiled JS files will be placed here.
|
|
@@ -350,9 +385,7 @@ interface Config {
|
|
|
350
385
|
* - { (): HtmlOptions | HtmlOptions[] }: A function that dynamically generates and
|
|
351
386
|
* returns either an HtmlOptions object or an array of HtmlOptions objects.
|
|
352
387
|
*/
|
|
353
|
-
html: Options | Options[] |
|
|
354
|
-
(): Options | Options[];
|
|
355
|
-
};
|
|
388
|
+
html: Options | Options[] | (() => Options | Options[]);
|
|
356
389
|
/**
|
|
357
390
|
* Rspack bundler configuration.
|
|
358
391
|
*
|
|
@@ -369,56 +402,30 @@ interface Config {
|
|
|
369
402
|
* - The function parameter is mainly for inspecting the current config to decide whether
|
|
370
403
|
* additional adjustments are necessary.
|
|
371
404
|
*/
|
|
372
|
-
bundler: Configuration |
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
*
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
icon: {
|
|
397
|
-
/**
|
|
398
|
-
* Directory for icons and logos. Can be located in the Shared directory,
|
|
399
|
-
* in the project root, or in a folder for a specific App.
|
|
400
|
-
*
|
|
401
|
-
* @example "icons"
|
|
402
|
-
*
|
|
403
|
-
* @path Full paths can be:
|
|
404
|
-
*
|
|
405
|
-
* - `{{inputDir}}/{{srcDir}}/{{icon.sourceDir}}`
|
|
406
|
-
* - `{{inputDir}}/{{sharedDir}}/{{icon.sourceDir}}`
|
|
407
|
-
* - `{{inputDir}}/{{appsDir}}/{{appDir}}/{{icon.sourceDir}}`
|
|
408
|
-
*/
|
|
409
|
-
sourceDir?: string;
|
|
410
|
-
/**
|
|
411
|
-
* Directory for image files in outputDir.
|
|
412
|
-
* @example "icons"
|
|
413
|
-
* @path Full path: `{{inputDir}}/{{outputDir}}/{{appDir}}/{{icon.outputDir}}`
|
|
414
|
-
*/
|
|
415
|
-
outputDir?: string;
|
|
416
|
-
/**
|
|
417
|
-
* Default icon group name. If not specified, the default icons set will be used.
|
|
418
|
-
* @example "default"
|
|
419
|
-
*/
|
|
420
|
-
name?: string;
|
|
421
|
-
};
|
|
405
|
+
bundler: Configuration | ((rspack: Configuration) => Awaiter<Configuration>);
|
|
406
|
+
/**
|
|
407
|
+
* Environment variables inclusion settings.
|
|
408
|
+
*
|
|
409
|
+
* Supports three forms:
|
|
410
|
+
* - string: treated as a prefix filter. Only variables whose names start with this prefix are included.
|
|
411
|
+
* Equivalent to: { filter: "<PREFIX>" }.
|
|
412
|
+
* - function: a predicate that receives a variable name and returns true to include it.
|
|
413
|
+
* Equivalent to: { filter: (name) => boolean }.
|
|
414
|
+
* - object: advanced settings.
|
|
415
|
+
* - filter?: string | ((name: string) => boolean) — a prefix or predicate to select variables.
|
|
416
|
+
* - crypt?: boolean — if true, values will be obfuscated with a simple reversible scheme
|
|
417
|
+
* (for convenience only; not secure).
|
|
418
|
+
*
|
|
419
|
+
* Notes:
|
|
420
|
+
* - If no filter is provided (e.g., empty string or a function that always returns false), no variables are included.
|
|
421
|
+
* - Obfuscation is intended to reduce casual inspection only and should not be considered encryption.
|
|
422
|
+
*
|
|
423
|
+
* Examples:
|
|
424
|
+
* - `"APP_"` - include all variables starting with `APP_`
|
|
425
|
+
* - `(name) => name === "FEATURE_FLAG"` - include a single variable via predicate
|
|
426
|
+
* - `{ filter: "PUBLIC_", crypt: true }` - include by prefix and obfuscate values
|
|
427
|
+
*/
|
|
428
|
+
env: EnvFilterVariant | Partial<EnvFilterOptions>;
|
|
422
429
|
/**
|
|
423
430
|
* Array of plugins used when building the extension.
|
|
424
431
|
* Allows extending the builder's functionality.
|
|
@@ -569,6 +576,30 @@ interface Config {
|
|
|
569
576
|
* @default true
|
|
570
577
|
*/
|
|
571
578
|
commonChunks: boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Build artifact name.
|
|
581
|
+
*
|
|
582
|
+
* Used as:
|
|
583
|
+
* - the directory name where the built extension will be placed;
|
|
584
|
+
* - the base name of the packaged archive.
|
|
585
|
+
*
|
|
586
|
+
* Supports placeholders that are substituted and then normalized:
|
|
587
|
+
* - `[app]` / `[name]` — application name in kebab-case;
|
|
588
|
+
* - `[mode]` — current build mode (e.g., development, production);
|
|
589
|
+
* - `[browser]` — target browser;
|
|
590
|
+
* - `[mv]` — manifest version in mvN format (e.g., mv3).
|
|
591
|
+
*
|
|
592
|
+
* Notes:
|
|
593
|
+
* - the final name is automatically converted to kebab-case;
|
|
594
|
+
* - sequences like "mv-<number>" are normalized to "mv<number>" (e.g., "mv-3" → "mv3");
|
|
595
|
+
* - it is recommended to specify only a name (no paths or extensions).
|
|
596
|
+
*
|
|
597
|
+
* Examples:
|
|
598
|
+
* - `[app]` → `my-app`
|
|
599
|
+
* - `[app]-[browser]-[mv]` → `my-app-chrome-mv3`
|
|
600
|
+
* - `bundle-[name]-[mode]` → `bundle-my-app-production`
|
|
601
|
+
*/
|
|
602
|
+
artifactName: string;
|
|
572
603
|
/**
|
|
573
604
|
* Template for generating asset output file names.
|
|
574
605
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { isValidTransportDefinition, isValidTransportInitFunction, isValidTransportMainFunction, isValidTransportName } from './resolvers/definition.js';
|
|
2
|
-
|
|
3
|
-
import '
|
|
2
|
+
import '../../types/transport.js';
|
|
3
|
+
import 'utility-types';
|
|
4
4
|
import '../../types/entrypoint.js';
|
|
5
5
|
import '../../types/browser.js';
|
|
6
|
-
import '../../types/content.js';
|
|
7
|
-
import 'react';
|
|
8
|
-
import 'utility-types';
|
|
9
6
|
import '../../types/helpers.js';
|
|
10
7
|
import '../../types/message.js';
|
|
8
|
+
import '../../types/relay.js';
|
|
9
|
+
import '../../types/content.js';
|
|
10
|
+
import 'react';
|
|
11
11
|
import '../../types/offscreen.js';
|
|
12
12
|
import '../../types/view.js';
|
|
13
13
|
import 'html-rspack-tags-plugin';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/entry/transport/index.ts"],"sourcesContent":["export * from \"./resolvers\";\
|
|
1
|
+
{"version":3,"sources":["../../../src/entry/transport/index.ts"],"sourcesContent":["export * from \"./resolvers\";\n"],"mappings":"AAAA,cAAc;","names":[]}
|