wxt 0.21.0 → 0.21.1
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 +0 -1
- package/bin/wxt-publish-extension.mjs +4 -3
- package/dist/browser.d.mts +7 -6
- package/dist/browser.mjs +6 -5
- package/dist/builtin-modules/favicon-permission.mjs +28 -0
- package/dist/builtin-modules/index.mjs +3 -4
- package/dist/builtin-modules/unimport.mjs +1 -3
- package/dist/cli/cli-utils.mjs +8 -9
- package/dist/cli/commands.mjs +1 -3
- package/dist/cli/index.mjs +1 -3
- package/dist/core/build.d.mts +9 -8
- package/dist/core/build.mjs +10 -11
- package/dist/core/builders/vite/index.mjs +123 -75
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +1 -3
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +6 -6
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +3 -4
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +34 -26
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +3 -3
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +2 -6
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +13 -8
- package/dist/core/builders/vite/plugins/globals.mjs +1 -3
- package/dist/core/builders/vite/plugins/iifeAnonymous.mjs +1 -2
- package/dist/core/builders/vite/plugins/iifeFooter.mjs +14 -7
- package/dist/core/builders/vite/plugins/index.mjs +17 -19
- package/dist/core/builders/vite/plugins/noopBackground.mjs +14 -9
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +10 -12
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +14 -10
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +15 -13
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +1 -2
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +22 -17
- package/dist/core/clean.d.mts +3 -14
- package/dist/core/clean.mjs +19 -13
- package/dist/core/create-server.d.mts +6 -5
- package/dist/core/create-server.mjs +21 -117
- package/dist/core/define-config.mjs +1 -2
- package/dist/core/define-web-ext-config.d.mts +3 -6
- package/dist/core/define-web-ext-config.mjs +3 -12
- package/dist/core/generate-wxt-dir.mjs +53 -35
- package/dist/core/index.d.mts +3 -2
- package/dist/core/index.mjs +11 -11
- package/dist/core/initialize.mjs +28 -29
- package/dist/core/keyboard-shortcuts.mjs +4 -8
- package/dist/core/package-managers/bun.mjs +1 -3
- package/dist/core/package-managers/deno.mjs +1 -2
- package/dist/core/package-managers/index.mjs +1 -3
- package/dist/core/package-managers/npm.mjs +3 -5
- package/dist/core/package-managers/pnpm.mjs +1 -3
- package/dist/core/package-managers/yarn.mjs +1 -3
- package/dist/core/prepare.mjs +1 -3
- package/dist/core/resolve-config.mjs +63 -43
- package/dist/core/runners/manual.mjs +2 -6
- package/dist/core/runners/safari.mjs +3 -4
- package/dist/core/runners/web-ext.mjs +8 -11
- package/dist/core/runners/wsl.mjs +3 -4
- package/dist/core/utils/arrays.mjs +4 -11
- package/dist/core/utils/building/build-entrypoints.mjs +10 -11
- package/dist/core/utils/building/detect-dev-changes.mjs +37 -19
- package/dist/core/utils/building/find-entrypoints.mjs +40 -21
- package/dist/core/utils/building/group-entrypoints.mjs +3 -4
- package/dist/core/utils/building/index.mjs +7 -8
- package/dist/core/utils/building/internal-build.mjs +21 -21
- package/dist/core/utils/building/rebuild.mjs +10 -10
- package/dist/core/utils/cache.mjs +6 -8
- package/dist/core/utils/constants.mjs +3 -4
- package/dist/core/utils/content-scripts.mjs +3 -4
- package/dist/core/utils/content-security-policy.mjs +2 -5
- package/dist/core/utils/create-file-reloader.mjs +158 -0
- package/dist/core/utils/entrypoints.d.mts +10 -0
- package/dist/core/utils/entrypoints.mjs +6 -10
- package/dist/core/utils/env.mjs +24 -19
- package/dist/core/utils/environments/browser-environment.mjs +1 -3
- package/dist/core/utils/environments/environment.mjs +1 -2
- package/dist/core/utils/environments/extension-environment.mjs +1 -3
- package/dist/core/utils/environments/index.mjs +3 -4
- package/dist/core/utils/eslint.mjs +1 -2
- package/dist/core/utils/fs.mjs +23 -14
- package/dist/core/utils/globals.mjs +1 -2
- package/dist/core/utils/i18n.mjs +2 -3
- package/dist/core/utils/index.d.mts +2 -0
- package/dist/core/utils/index.mjs +3 -3
- package/dist/core/utils/log/index.mjs +5 -6
- package/dist/core/utils/log/printBuildSummary.mjs +1 -3
- package/dist/core/utils/log/printFileList.mjs +25 -21
- package/dist/core/utils/log/printHeader.mjs +3 -5
- package/dist/core/utils/log/printTable.mjs +1 -2
- package/dist/core/utils/manifest.mjs +39 -46
- package/dist/core/utils/number.mjs +1 -2
- package/dist/core/utils/package.mjs +3 -5
- package/dist/core/utils/paths.d.mts +2 -2
- package/dist/core/utils/paths.mjs +7 -9
- package/dist/core/utils/strings.mjs +4 -7
- package/dist/core/utils/syntax-errors.mjs +3 -5
- package/dist/core/utils/theme-icons.mjs +71 -0
- package/dist/core/utils/time.mjs +1 -13
- package/dist/core/utils/transform.mjs +9 -7
- package/dist/core/utils/validation.mjs +1 -2
- package/dist/core/utils/virtual-modules.mjs +9 -15
- package/dist/core/wxt.mjs +11 -12
- package/dist/core/zip.d.mts +1 -0
- package/dist/core/zip.mjs +25 -20
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/modules.d.mts +64 -61
- package/dist/modules.mjs +70 -66
- package/dist/testing/fake-browser.mjs +1 -2
- package/dist/testing/wxt-vitest-plugin.d.mts +4 -2
- package/dist/testing/wxt-vitest-plugin.mjs +5 -7
- package/dist/types.d.mts +636 -450
- package/dist/utils/app-config.d.mts +1 -0
- package/dist/utils/app-config.mjs +3 -3
- package/dist/utils/content-script-context.d.mts +49 -39
- package/dist/utils/content-script-context.mjs +37 -32
- package/dist/utils/content-script-ui/iframe.d.mts +14 -15
- package/dist/utils/content-script-ui/iframe.mjs +1 -3
- package/dist/utils/content-script-ui/integrated.d.mts +8 -7
- package/dist/utils/content-script-ui/integrated.mjs +1 -3
- package/dist/utils/content-script-ui/shadow-root.d.mts +37 -25
- package/dist/utils/content-script-ui/shadow-root.mjs +5 -8
- package/dist/utils/content-script-ui/shared.mjs +1 -3
- package/dist/utils/content-script-ui/types.d.mts +29 -34
- package/dist/utils/content-script-ui/types.mjs +1 -1
- package/dist/utils/define-app-config.d.mts +4 -3
- package/dist/utils/define-app-config.mjs +5 -5
- package/dist/utils/define-background.mjs +1 -2
- package/dist/utils/define-content-script.mjs +1 -2
- package/dist/utils/define-unlisted-script.mjs +1 -2
- package/dist/utils/define-wxt-plugin.mjs +1 -2
- package/dist/utils/inject-script.d.mts +2 -2
- package/dist/utils/inject-script.mjs +4 -5
- package/dist/utils/internal/custom-events.mjs +3 -4
- package/dist/utils/internal/location-watcher.mjs +4 -6
- package/dist/utils/internal/logger.mjs +2 -5
- package/dist/utils/match-patterns.mjs +2 -3
- package/dist/utils/split-shadow-root-css.d.mts +6 -2
- package/dist/utils/split-shadow-root-css.mjs +7 -4
- package/dist/utils/storage.mjs +2 -3
- package/dist/version.mjs +2 -3
- package/dist/virtual/background-entrypoint.mjs +4 -16
- package/dist/virtual/content-script-isolated-world-entrypoint.mjs +2 -7
- package/dist/virtual/content-script-main-world-entrypoint.mjs +2 -7
- package/dist/virtual/mock-browser.d.mts +1 -1
- package/dist/virtual/mock-browser.mjs +2 -4
- package/dist/virtual/reload-html.mjs +3 -10
- package/dist/virtual/unlisted-script-entrypoint.mjs +2 -7
- package/package.json +56 -49
- package/LICENSE +0 -21
- package/dist/core/builders/vite/plugins/download.mjs +0 -25
- package/dist/core/runners/index.mjs +0 -17
- package/dist/core/utils/minimatch-multiple.mjs +0 -28
- package/dist/core/utils/network.mjs +0 -38
- package/dist/core/utils/wsl.mjs +0 -12
- package/dist/testing/index.d.mts +0 -3
- package/dist/testing/index.mjs +0 -4
package/package.json
CHANGED
|
@@ -1,80 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.1",
|
|
5
5
|
"description": "⚡ Next-gen Web Extension Framework",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"wxt": "bun run src/cli/index.ts",
|
|
9
|
+
"build": "buildc -- bun run tsdown --config-loader unrun",
|
|
10
|
+
"check": "bun run build && bun run --sequential 'check:*'",
|
|
11
|
+
"check:default": "check",
|
|
12
|
+
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
|
13
|
+
"test": "buildc --deps-only -- vitest",
|
|
14
|
+
"test:coverage": "bun run test run --coverage",
|
|
15
|
+
"prepack": "bun run build"
|
|
16
|
+
},
|
|
7
17
|
"dependencies": {
|
|
8
18
|
"@1natsu/wait-element": "^4.1.2",
|
|
9
19
|
"@aklinker1/rollup-plugin-visualizer": "5.12.0",
|
|
10
|
-
"@webext-core/fake-browser": "^
|
|
11
|
-
"@webext-core/isolated-element": "^1.1.3",
|
|
12
|
-
"@webext-core/match-patterns": "^
|
|
20
|
+
"@webext-core/fake-browser": "^2.0.1",
|
|
21
|
+
"@webext-core/isolated-element": "^1.1.3 || ^2 || ^3",
|
|
22
|
+
"@webext-core/match-patterns": "^2.0.0",
|
|
23
|
+
"@wxt-dev/browser": "^0.2.2",
|
|
13
24
|
"@wxt-dev/storage": "^1.0.0",
|
|
14
25
|
"async-mutex": "^0.5.0",
|
|
15
|
-
"c12": "^3.3.
|
|
16
|
-
"cac": "^6.7.14",
|
|
26
|
+
"c12": "^3.3.4",
|
|
27
|
+
"cac": "^6.7.14 || ^7.0.0",
|
|
17
28
|
"chokidar": "^5.0.0",
|
|
18
29
|
"ci-info": "^4.4.0",
|
|
19
30
|
"consola": "^3.4.2",
|
|
20
31
|
"defu": "^6.1.4",
|
|
21
|
-
"dotenv": "^
|
|
22
|
-
"
|
|
23
|
-
"esbuild": "^0.27.1",
|
|
24
|
-
"fast-glob": "^3.3.3",
|
|
25
|
-
"filesize": "^11.0.13",
|
|
26
|
-
"fs-extra": "^11.3.3",
|
|
32
|
+
"dotenv-expand": "^13.0.0",
|
|
33
|
+
"filesize": "^11.0.17",
|
|
27
34
|
"get-port-please": "^3.2.0",
|
|
28
35
|
"giget": "^1.2.3 || ^2.0.0 || ^3.0.0",
|
|
29
|
-
"hookable": "^6.0
|
|
36
|
+
"hookable": "^6.1.0",
|
|
30
37
|
"import-meta-resolve": "^4.2.0",
|
|
31
|
-
"is-wsl": "^3.1.
|
|
38
|
+
"is-wsl": "^3.1.1",
|
|
32
39
|
"json5": "^2.2.3",
|
|
33
40
|
"jszip": "^3.10.1",
|
|
34
41
|
"linkedom": "^0.18.12",
|
|
35
42
|
"magicast": "^0.5.2",
|
|
36
|
-
"minimatch": "^10.1.2",
|
|
37
43
|
"nano-spawn": "^2.0.0",
|
|
44
|
+
"nanospinner": "^1.2.2",
|
|
38
45
|
"normalize-path": "^3.0.0",
|
|
39
46
|
"nypm": "^0.6.5",
|
|
40
47
|
"ohash": "^2.0.11",
|
|
41
48
|
"open": "^11.0.0",
|
|
42
|
-
"
|
|
43
|
-
"perfect-debounce": "^2.1.0",
|
|
44
|
-
"picocolors": "^1.1.1",
|
|
49
|
+
"picomatch": "^4.0.3",
|
|
45
50
|
"prompts": "^2.4.2",
|
|
46
|
-
"publish-browser-extension": "^
|
|
51
|
+
"publish-browser-extension": "^5.1.0",
|
|
47
52
|
"scule": "^1.3.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"web-ext-run": "^0.2.4",
|
|
52
|
-
"@wxt-dev/browser": "^0.1.37"
|
|
53
|
+
"tinyglobby": "^0.2.16",
|
|
54
|
+
"unimport": "^3.13.1 || ^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
55
|
+
"web-ext-run": "^0.2.4"
|
|
53
56
|
},
|
|
54
57
|
"peerDependencies": {
|
|
55
|
-
"eslint": "^8.57.0 || ^9.0.0"
|
|
58
|
+
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
59
|
+
"vite": "^6.3.4 || ^7.0.0 || ^8.0.0-0",
|
|
60
|
+
"web-ext": ">=9.2.0",
|
|
61
|
+
"typescript": ">=5.4"
|
|
56
62
|
},
|
|
57
63
|
"peerDependenciesMeta": {
|
|
58
64
|
"eslint": {
|
|
59
65
|
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"web-ext": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"typescript": {
|
|
71
|
+
"optional": true
|
|
60
72
|
}
|
|
61
73
|
},
|
|
62
74
|
"devDependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
75
|
+
"@aklinker1/buildc": "^1.1.7",
|
|
76
|
+
"@faker-js/faker": "^10.3.0",
|
|
77
|
+
"@types/bun": "^1.3.5",
|
|
65
78
|
"@types/lodash.merge": "^4.6.9",
|
|
66
|
-
"@types/node": "^
|
|
79
|
+
"@types/node": "^22",
|
|
67
80
|
"@types/normalize-path": "^3.0.2",
|
|
81
|
+
"@types/picomatch": "^4.0.2",
|
|
68
82
|
"@types/prompts": "^2.4.9",
|
|
69
|
-
"eslint": "^
|
|
83
|
+
"eslint": "^10.1.0",
|
|
70
84
|
"extract-zip": "^2.0.1",
|
|
71
|
-
"happy-dom": "^20.
|
|
85
|
+
"happy-dom": "^20.8.3",
|
|
72
86
|
"lodash.merge": "^4.6.2",
|
|
73
|
-
"oxlint": "^1.
|
|
74
|
-
"publint": "^0.3.
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
87
|
+
"oxlint": "^1.63.0",
|
|
88
|
+
"publint": "^0.3.18",
|
|
89
|
+
"tsdown": "^0.21.0",
|
|
90
|
+
"typescript": "^6.0.3",
|
|
91
|
+
"vite": "^7.3.1",
|
|
92
|
+
"vitest": "^4.1.5",
|
|
93
|
+
"vitest-plugin-random-seed": "^1.1.2",
|
|
94
|
+
"web-ext": "^10.5.0"
|
|
78
95
|
},
|
|
79
96
|
"repository": {
|
|
80
97
|
"type": "git",
|
|
@@ -182,10 +199,6 @@
|
|
|
182
199
|
"types": "./dist/testing/wxt-vitest-plugin.d.mts",
|
|
183
200
|
"default": "./dist/testing/wxt-vitest-plugin.mjs"
|
|
184
201
|
},
|
|
185
|
-
"./testing": {
|
|
186
|
-
"types": "./dist/testing/index.d.mts",
|
|
187
|
-
"default": "./dist/testing/index.mjs"
|
|
188
|
-
},
|
|
189
202
|
"./vite-builder-env": {
|
|
190
203
|
"types": "./dist/vite-builder-env.d.ts"
|
|
191
204
|
},
|
|
@@ -194,14 +207,8 @@
|
|
|
194
207
|
"default": "./dist/modules.mjs"
|
|
195
208
|
}
|
|
196
209
|
},
|
|
197
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"check": "pnpm build && pnpm run --reporter-hide-prefix /^check:.*/",
|
|
201
|
-
"check:default": "check",
|
|
202
|
-
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
|
203
|
-
"test": "buildc --deps-only -- vitest",
|
|
204
|
-
"test:coverage": "pnpm test run --coverage",
|
|
205
|
-
"sync-releases": "pnpx changelogen@latest gh release"
|
|
210
|
+
"engines": {
|
|
211
|
+
"node": ">=22",
|
|
212
|
+
"bun": ">=1.2.0"
|
|
206
213
|
}
|
|
207
|
-
}
|
|
214
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Aaron
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { fetchCached } from "../../../utils/network.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/core/builders/vite/plugins/download.ts
|
|
4
|
-
/**
|
|
5
|
-
* Downloads any URL imports, like Google Analytics, into virtual modules so they are bundled with
|
|
6
|
-
* the extension instead of depending on remote code at runtime.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import "url:https://google-tagmanager.com/gtag?id=XYZ";
|
|
10
|
-
*/
|
|
11
|
-
function download(config) {
|
|
12
|
-
return {
|
|
13
|
-
name: "wxt:download",
|
|
14
|
-
resolveId(id) {
|
|
15
|
-
if (id.startsWith("url:")) return "\0" + id;
|
|
16
|
-
},
|
|
17
|
-
load(id) {
|
|
18
|
-
if (!id.startsWith("\0url:")) return;
|
|
19
|
-
return fetchCached(id.replace("\0url:", ""), config);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { download };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { wxt } from "../wxt.mjs";
|
|
2
|
-
import { isWsl } from "../utils/wsl.mjs";
|
|
3
|
-
import { createManualRunner } from "./manual.mjs";
|
|
4
|
-
import { createSafariRunner } from "./safari.mjs";
|
|
5
|
-
import { createWebExtRunner } from "./web-ext.mjs";
|
|
6
|
-
import { createWslRunner } from "./wsl.mjs";
|
|
7
|
-
|
|
8
|
-
//#region src/core/runners/index.ts
|
|
9
|
-
async function createExtensionRunner() {
|
|
10
|
-
if (wxt.config.browser === "safari") return createSafariRunner();
|
|
11
|
-
if (isWsl()) return createWslRunner();
|
|
12
|
-
if (wxt.config.runnerConfig.config?.disabled) return createManualRunner();
|
|
13
|
-
return createWebExtRunner();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { createExtensionRunner };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { minimatch } from "minimatch";
|
|
2
|
-
|
|
3
|
-
//#region src/core/utils/minimatch-multiple.ts
|
|
4
|
-
/**
|
|
5
|
-
* Run [`minimatch`](https://npmjs.com/package/minimatch) against multiple
|
|
6
|
-
* patterns.
|
|
7
|
-
*
|
|
8
|
-
* Supports negated patterns, the order does not matter. If your `search` string
|
|
9
|
-
* matches any of the negative patterns, it will return `false`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* minimatchMultiple('a.json', ['*.json', '!b.json']); // => true
|
|
14
|
-
* minimatchMultiple('b.json', ['*.json', '!b.json']); // => false
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function minimatchMultiple(search, patterns, options) {
|
|
18
|
-
if (patterns == null) return false;
|
|
19
|
-
const negatePatterns = [];
|
|
20
|
-
const positivePatterns = [];
|
|
21
|
-
for (const pattern of patterns) if (pattern[0] === "!") negatePatterns.push(pattern.slice(1));
|
|
22
|
-
else positivePatterns.push(pattern);
|
|
23
|
-
if (negatePatterns.some((negatePattern) => minimatch(search, negatePattern, options))) return false;
|
|
24
|
-
return positivePatterns.some((positivePattern) => minimatch(search, positivePattern, options));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { minimatchMultiple };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { withTimeout } from "./time.mjs";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import dns from "node:dns";
|
|
4
|
-
|
|
5
|
-
//#region src/core/utils/network.ts
|
|
6
|
-
async function isOffline() {
|
|
7
|
-
try {
|
|
8
|
-
return await withTimeout(new Promise((res) => {
|
|
9
|
-
dns.resolve("google.com", (err) => res(err != null));
|
|
10
|
-
}), 1e3);
|
|
11
|
-
} catch (error) {
|
|
12
|
-
consola.error("Error checking offline status:", error);
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async function isOnline() {
|
|
17
|
-
return !await isOffline();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Fetches a URL with a simple GET request. Grabs it from cache if it doesn't exist, or throws an
|
|
21
|
-
* error if it can't be resolved via the network or cache.
|
|
22
|
-
*/
|
|
23
|
-
async function fetchCached(url, config) {
|
|
24
|
-
let content = "";
|
|
25
|
-
if (await isOnline()) {
|
|
26
|
-
const res = await fetch(url);
|
|
27
|
-
if (res.status < 300) {
|
|
28
|
-
content = await res.text();
|
|
29
|
-
await config.fsCache.set(url, content);
|
|
30
|
-
} else config.logger.debug(`Failed to download "${url}", falling back to cache...`);
|
|
31
|
-
}
|
|
32
|
-
if (!content) content = await config.fsCache.get(url) ?? "";
|
|
33
|
-
if (!content) throw Error(`Offline and "${url}" has not been cached. Try again when online.`);
|
|
34
|
-
return content;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
export { fetchCached };
|
package/dist/core/utils/wsl.mjs
DELETED
package/dist/testing/index.d.mts
DELETED
package/dist/testing/index.mjs
DELETED