From 0f57e143af3d5e2a5cc8718fd44ff367efe8c9ee Mon Sep 17 00:00:00 2001 From: Jack Works <5390719+Jack-Works@users.noreply.github.com> Date: Wed, 9 Apr 2025 00:42:18 +0800 Subject: [PATCH 1/3] chore: pick useful changes from turbo pr --- .ignore | 2 - .node-version | 2 +- cspell.json | 8 +- package.json | 7 +- packages/gun-utils/builder.mjs | 10 +- packages/gun-utils/package.json | 3 + packages/mask/.webpack/config.ts | 25 +- packages/mask/.webpack/flags.ts | 15 +- .../mask/.webpack/plugins/ProfilingPlugin.ts | 4 +- packages/mask/.webpack/plugins/manifest.ts | 4 +- packages/mask/.webpack/tsconfig.json | 3 +- packages/mask/.webpack/webpack.config.js | 2 - packages/mask/.webpack/webpack.config.ts | 2 +- packages/polyfills/package.json | 2 +- packages/scripts/src/bin/args.ts | 13 +- packages/scripts/src/bin/build-rspack.mjs | 8 +- packages/scripts/src/bin/build-rspack.ts | 13 +- packages/scripts/src/bin/build.mjs | 8 +- packages/scripts/src/bin/build.ts | 13 +- packages/scripts/src/bin/dev-rspack.mjs | 8 +- packages/scripts/src/bin/dev-rspack.ts | 11 +- packages/scripts/src/bin/dev.mjs | 8 +- packages/scripts/src/bin/dev.ts | 11 +- packages/scripts/src/cloudflare/index.ts | 4 +- packages/scripts/src/codegen/icon-codegen.ts | 2 +- packages/scripts/src/codegen/index.ts | 10 +- packages/scripts/src/codegen/typescript.ts | 2 +- .../scripts/src/commands/changeset-release.ts | 10 +- packages/scripts/src/commands/clean.ts | 2 +- packages/scripts/src/commands/index.ts | 6 +- packages/scripts/src/commands/sync-develop.ts | 2 +- packages/scripts/src/extension/ci.ts | 15 +- packages/scripts/src/extension/dotenv.ts | 6 +- packages/scripts/src/extension/flags.ts | 4 +- packages/scripts/src/extension/index.ts | 4 +- packages/scripts/src/extension/normal.ts | 28 +-- packages/scripts/src/index.ts | 36 +-- packages/scripts/src/linter/index-lint.ts | 6 +- packages/scripts/src/linter/package-json.ts | 6 +- .../scripts/src/linter/plugin-projects.ts | 12 +- packages/scripts/src/linter/po-files.ts | 6 +- packages/scripts/src/locale-kit-next/index.ts | 6 +- .../scripts/src/locale-kit-next/run-lingui.ts | 8 +- .../scripts/src/projects/build-constants.ts | 6 +- .../scripts/src/projects/build-contracts.ts | 6 +- packages/scripts/src/projects/gun.ts | 2 +- .../scripts/src/projects/injected-scripts.ts | 2 +- packages/scripts/src/projects/mask-sdk.ts | 2 +- packages/scripts/src/projects/polyfill.ts | 2 +- .../scripts/src/projects/sandboxed-plugins.ts | 23 +- packages/scripts/src/projects/sentry.ts | 2 +- packages/scripts/src/spellcheck/index.ts | 2 +- packages/scripts/src/utils/index.ts | 16 +- packages/scripts/src/utils/prettier.ts | 2 +- packages/scripts/src/utils/run.ts | 4 +- packages/scripts/src/utils/task.ts | 6 +- packages/scripts/src/utils/write.ts | 2 +- packages/scripts/tsconfig.json | 3 +- patches/{gulp@5.0.0.patch => gulp.patch} | 24 +- pnpm-lock.yaml | 218 +----------------- 60 files changed, 245 insertions(+), 434 deletions(-) delete mode 100644 packages/mask/.webpack/webpack.config.js rename patches/{gulp@5.0.0.patch => gulp.patch} (55%) diff --git a/.ignore b/.ignore index 376b54a68a75..c98d244df8cb 100644 --- a/.ignore +++ b/.ignore @@ -1,5 +1,3 @@ # Ignores for rg or ag patches/ -packages/mask/dashboard/assets/images/SetupTutorial.svg - **/locale/*.{po,json} diff --git a/.node-version b/.node-version index 7bceec795e9d..c9758a53fae1 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -v22.2.0 +v23.6.0 diff --git a/cspell.json b/cspell.json index 91f589c6ff26..3cd369cbb7e3 100644 --- a/cspell.json +++ b/cspell.json @@ -241,15 +241,15 @@ "ignoreRegExpList": ["/[A-Za-z0-9]{44}/", "/[A-Za-z0-9]{46}/", "/[A-Za-z0-9]{59}/"], "overrides": [], "words": [ - "Arbitrum", - "Boba", + "arbitrum", + "boba", "cashtags", - "Celo", + "celo", "endregion", "linkedin", "luma", "muln", - "Sepolia", + "sepolia", "tanstack", "tiktok", "tweetnacl", diff --git a/package.json b/package.json index ae3d2712ceb0..2f7bf7ab57b3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "packageManager": "pnpm@9.12.1", "engines": { - "node": ">=22.2.0", + "node": ">=23.6.0", "yarn": ">=999.0.0", "npm": ">=999.0.0" }, @@ -70,7 +70,6 @@ "@masknet/eslint-plugin": "^0.3.0", "@masknet/typescript-plugin": "workspace:^", "@nice-labs/git-rev": "^3.5.1", - "@swc-node/register": "^1.10.9", "@swc/core": "1.11.7", "@tanstack/eslint-plugin-query": "^5.66.1", "@types/lodash-es": "^4.17.12", @@ -155,10 +154,10 @@ "@protobufjs/inquire@1.1.0": "patches/@protobufjs__inquire@1.1.0.patch", "eslint-plugin-i@2.29.1": "patches/eslint-plugin-i@2.29.1.patch", "react-use@17.5.0": "patches/react-use@17.5.0.patch", - "gulp@5.0.0": "patches/gulp@5.0.0.patch", "react-devtools-inline@5.3.0": "patches/react-devtools-inline@5.3.0.patch", "@splinetool/runtime@0.9.342": "patches/@splinetool__runtime@0.9.342.patch", - "@scamsniffer/detector": "patches/@scamsniffer__detector.patch" + "@scamsniffer/detector": "patches/@scamsniffer__detector.patch", + "gulp": "patches/gulp.patch" } } } diff --git a/packages/gun-utils/builder.mjs b/packages/gun-utils/builder.mjs index cca981f56d0f..612e3ff7c295 100644 --- a/packages/gun-utils/builder.mjs +++ b/packages/gun-utils/builder.mjs @@ -1,5 +1,6 @@ import { createRequire } from 'module' import { readFile, writeFile } from 'fs/promises' +import { minify } from '@swc/core' const require = createRequire(import.meta.url) const files = await Promise.all( [ @@ -69,12 +70,15 @@ const patchedSource = files // patch instanceof Object to instanceof globalThis.Object .replace(/instanceof\s+Object/g, 'instanceof globalThis.Object') -const result = `(() => { +const result = await minify( + `(() => { ${init.toString().replace('// Source Code Here', patchedSource)}; if (!globalThis.Gun) { globalThis.Gun = ${init.name}().Gun; } })(); undefined; -` -writeFile(new URL('./gun.js', import.meta.url), result) +`, + { mangle: false, compress: false }, +) +writeFile(new URL('./gun.js', import.meta.url), result.code) diff --git a/packages/gun-utils/package.json b/packages/gun-utils/package.json index 9e1ca3157e44..5f48ca55a7a6 100644 --- a/packages/gun-utils/package.json +++ b/packages/gun-utils/package.json @@ -17,5 +17,8 @@ "dependencies": { "event-iterator": "^2.0.0", "gun": "0.2020.1234" + }, + "devDependencies": { + "@swc/core": "1.9.3" } } diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index 014094cae787..e0b918af7e87 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -7,8 +7,8 @@ import { emitJSONFile } from '@nice-labs/emit-file-webpack-plugin' import DevtoolsIgnorePlugin from 'devtools-ignore-webpack-plugin' import WebExtensionPlugin from 'webpack-target-webextension' import ReactCompiler from 'react-compiler-webpack' -import { getGitInfo } from './git-info.js' -import { emitManifestFile } from './plugins/manifest.js' +import { getGitInfo } from './git-info.ts' +import { emitManifestFile } from './plugins/manifest.ts' // @ts-expect-error import LavaMoat from '@lavamoat/webpack' @@ -16,12 +16,12 @@ import { readFile, readdir } from 'node:fs/promises' import { createRequire } from 'node:module' import { join } from 'node:path' -import { computeCacheKey, computedBuildFlags, normalizeBuildFlags, type BuildFlags } from './flags.js' -import { ProfilingPlugin } from './plugins/ProfilingPlugin.js' -import { joinEntryItem, normalizeEntryDescription, type EntryDescription } from './utils.js' +import { computeCacheKey, computedBuildFlags, normalizeBuildFlags, type BuildFlags } from './flags.ts' +import { ProfilingPlugin } from './plugins/ProfilingPlugin.ts' +import { joinEntryItem, normalizeEntryDescription, type EntryDescription } from './utils.ts' -import './clean-hmr.js' -import { TrustedTypesPlugin } from './plugins/TrustedTypesPlugin.js' +import './clean-hmr.ts' +import { TrustedTypesPlugin } from './plugins/TrustedTypesPlugin.ts' const require = createRequire(import.meta.url) const patchesDir = join(import.meta.dirname, '../../../patches') @@ -492,11 +492,12 @@ export async function createConfiguration( } } -enum TemplateType { - Loading, - NoLoading, - Background, -} +const TemplateType = { + Loading: 0, + NoLoading: 1, + Background: 2, +} as const +type TemplateType = (typeof TemplateType)[keyof typeof TemplateType] const pages = { loading: readFile(join(import.meta.dirname, './with-loading.html'), 'utf8'), noLoading: readFile(join(import.meta.dirname, './with-no-loading.html'), 'utf8'), diff --git a/packages/mask/.webpack/flags.ts b/packages/mask/.webpack/flags.ts index c8238383f940..853e6ed906c9 100644 --- a/packages/mask/.webpack/flags.ts +++ b/packages/mask/.webpack/flags.ts @@ -1,14 +1,15 @@ import type { Configuration } from 'webpack' import { join, isAbsolute } from 'node:path' -export enum ManifestFile { - ChromiumMV2 = 'chromium-mv2', - ChromiumMV3 = 'chromium-mv3', - ChromiumBetaMV3 = 'chromium-beta-mv3', - FirefoxMV2 = 'firefox-mv2', - FirefoxMV3 = 'firefox-mv3', - SafariMV3 = 'safari-mv3', +export const ManifestFile = { + ChromiumMV2: 'chromium-mv2', + ChromiumMV3: 'chromium-mv3', + ChromiumBetaMV3: 'chromium-beta-mv3', + FirefoxMV2: 'firefox-mv2', + FirefoxMV3: 'firefox-mv3', + SafariMV3: 'safari-mv3', } +export type ManifestFile = (typeof ManifestFile)[keyof typeof ManifestFile] export interface BuildFlags { /** If this field is set, manifest.json will copy the content of manifest-*.json */ manifestFile?: ManifestFile diff --git a/packages/mask/.webpack/plugins/ProfilingPlugin.ts b/packages/mask/.webpack/plugins/ProfilingPlugin.ts index b5897e9e861a..ef6ca3f74423 100644 --- a/packages/mask/.webpack/plugins/ProfilingPlugin.ts +++ b/packages/mask/.webpack/plugins/ProfilingPlugin.ts @@ -11,8 +11,10 @@ export class ProfilingPlugin { apply(compiler: Compiler) { const { javascript, Template, RuntimeModule } = compiler.webpack class HintRuntimeModule extends RuntimeModule { - constructor(private modules: data) { + private modules: data + constructor(modules: data) { super('profiling-hint') + this.modules = modules } override generate() { return `globalThis.measure?.set_compile_info?.(${JSON.stringify(this.modules)});` diff --git a/packages/mask/.webpack/plugins/manifest.ts b/packages/mask/.webpack/plugins/manifest.ts index c22d08cd54b8..f1bfda91e5c5 100644 --- a/packages/mask/.webpack/plugins/manifest.ts +++ b/packages/mask/.webpack/plugins/manifest.ts @@ -1,9 +1,9 @@ /* spell-checker: disable */ import emitFile from '@nice-labs/emit-file-webpack-plugin' -import type { ComputedFlags, NormalizedFlags } from '../flags.js' +import type { ComputedFlags, NormalizedFlags } from '../flags.ts' import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs' import type { Manifest } from 'webextension-polyfill' -import { parseJSONc } from '../utils.js' +import { parseJSONc } from '../utils.ts' import { join } from 'node:path' const cloneDeep = (x: T): T => JSON.parse(JSON.stringify(x)) diff --git a/packages/mask/.webpack/tsconfig.json b/packages/mask/.webpack/tsconfig.json index 96475e1d2b61..815d00884001 100644 --- a/packages/mask/.webpack/tsconfig.json +++ b/packages/mask/.webpack/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "incremental": false, - "composite": false + "composite": false, + "allowImportingTsExtensions": true }, "include": ["./**/*.ts"] } diff --git a/packages/mask/.webpack/webpack.config.js b/packages/mask/.webpack/webpack.config.js deleted file mode 100644 index 8e8155aa1b4a..000000000000 --- a/packages/mask/.webpack/webpack.config.js +++ /dev/null @@ -1,2 +0,0 @@ -// webpack-cli does not know swc-node -export { default } from './webpack.config.ts' diff --git a/packages/mask/.webpack/webpack.config.ts b/packages/mask/.webpack/webpack.config.ts index 2fe130d51a58..352cb464ca74 100644 --- a/packages/mask/.webpack/webpack.config.ts +++ b/packages/mask/.webpack/webpack.config.ts @@ -1,4 +1,4 @@ -import { createConfiguration } from './config.js' +import { createConfiguration } from './config.ts' export default async function (cli_env: any) { const flags = JSON.parse(Buffer.from(cli_env.flags, 'hex').toString('utf-8')) return createConfiguration(false, flags) diff --git a/packages/polyfills/package.json b/packages/polyfills/package.json index 21a86be88614..13ed95a905ba 100644 --- a/packages/polyfills/package.json +++ b/packages/polyfills/package.json @@ -11,11 +11,11 @@ "build": "rollup -c" }, "dependencies": { - "@types/webextension-polyfill": "^0.10.7", "core-js": "3.41.0", "tslib": "^2.6.3" }, "devDependencies": { + "@types/webextension-polyfill": "^0.10.7", "@rollup/plugin-commonjs": "^28.0.2", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.0", diff --git a/packages/scripts/src/bin/args.ts b/packages/scripts/src/bin/args.ts index 6db08ef6fe64..6db5f7f6b21d 100644 --- a/packages/scripts/src/bin/args.ts +++ b/packages/scripts/src/bin/args.ts @@ -1,8 +1,8 @@ import yargs from 'yargs' -import type { BuildFlagsExtended } from '../extension/flags.js' +import type { BuildFlagsExtended } from '../extension/flags.ts' import { hideBin } from 'yargs/helpers' -import { applyDotEnv, parseManifest } from '../extension/dotenv.js' -import { ManifestFile } from '../../../mask/.webpack/flags.js' +import { applyDotEnv, parseManifest } from '../extension/dotenv.ts' +import { ManifestFile } from '../../../mask/.webpack/flags.ts' const manifestFiles = Object.values(ManifestFile) export function extensionArgsParser(mode: 'development' | 'production') { @@ -23,7 +23,7 @@ export function extensionArgsParser(mode: 'development' | 'production') { .options('progress', { type: 'boolean', description: 'Show build progress' }) .options('hmr', { type: 'boolean', description: 'Enable Hot Module Reload' }) .options('reactRefresh', { type: 'boolean', description: 'Enable react-refresh', implies: 'hmr' }) - .options('csp', { type: 'boolean', description: 'Enable strict contentScript.' }) + .options('csp', { type: 'boolean', description: 'Enable strict Content Security Policy.' }) .options('lavamoat', { type: 'boolean', description: 'Enable LavaMoat.' }) .option('reactCompiler', { type: 'string', @@ -36,7 +36,10 @@ export function extensionArgsParser(mode: 'development' | 'production') { description: 'Enable react compiler', }) .options('devtools', { type: 'boolean', description: 'Enable devtools' }) - .options('devtoolsEditorURI', { type: 'string', description: 'Editor URI to be used in React Devtools.' }) + .options('devtoolsEditorURI', { + type: 'string', + description: 'Default editor URI to be used in React Devtools.', + }) .options('sourceMap', { type: 'string', description: 'Enable source map', diff --git a/packages/scripts/src/bin/build-rspack.mjs b/packages/scripts/src/bin/build-rspack.mjs index 5a8a8cf20223..7cad78dee8dd 100755 --- a/packages/scripts/src/bin/build-rspack.mjs +++ b/packages/scripts/src/bin/build-rspack.mjs @@ -1,11 +1,11 @@ #!/usr/bin/env node -import { spawnSync } from 'child_process' -import { fileURLToPath } from 'url' +import { spawnSync } from 'node:child_process' +import { fileURLToPath } from 'node:url' const child = spawnSync( process.execPath, [ - '--import', - '@swc-node/register/esm-register', + '--experimental-strip-types', + '--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.resolve('./build-rspack.ts')), ...process.argv.slice(2), ], diff --git a/packages/scripts/src/bin/build-rspack.ts b/packages/scripts/src/bin/build-rspack.ts index e55ee96fd6cc..c1b4cc3c2283 100755 --- a/packages/scripts/src/bin/build-rspack.ts +++ b/packages/scripts/src/bin/build-rspack.ts @@ -1,11 +1,10 @@ -#!/usr/bin/env node --import swc-register-esm -import { spawn } from 'child_process' -import { promisify } from 'util' +import { spawn } from 'node:child_process' +import { promisify } from 'node:util' import { series } from 'gulp' -import { codegen } from '../codegen/index.js' -import { awaitChildProcess, awaitTask } from '../utils/index.js' -import { buildExtensionFlagRspack } from '../extension/index.js' -import { extensionArgsParser } from './args.js' +import { codegen } from '../codegen/index.ts' +import { awaitChildProcess, awaitTask } from '../utils/index.ts' +import { buildExtensionFlagRspack } from '../extension/index.ts' +import { extensionArgsParser } from './args.ts' await promisify(codegen)() // \\-- is used for debug diff --git a/packages/scripts/src/bin/build.mjs b/packages/scripts/src/bin/build.mjs index bbebfe68fefa..e076b3e299b8 100755 --- a/packages/scripts/src/bin/build.mjs +++ b/packages/scripts/src/bin/build.mjs @@ -1,11 +1,11 @@ #!/usr/bin/env node -import { spawnSync } from 'child_process' -import { fileURLToPath } from 'url' +import { spawnSync } from 'node:child_process' +import { fileURLToPath } from 'node:url' const child = spawnSync( process.execPath, [ - '--import', - '@swc-node/register/esm-register', + '--experimental-strip-types', + '--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.resolve('./build.ts')), ...process.argv.slice(2), ], diff --git a/packages/scripts/src/bin/build.ts b/packages/scripts/src/bin/build.ts index 0b69edf4e6aa..0d2b528e14bd 100755 --- a/packages/scripts/src/bin/build.ts +++ b/packages/scripts/src/bin/build.ts @@ -1,11 +1,10 @@ -#!/usr/bin/env node --import swc-register-esm -import { spawn } from 'child_process' -import { promisify } from 'util' +import { spawn } from 'node:child_process' +import { promisify } from 'node:util' import { series } from 'gulp' -import { codegen } from '../codegen/index.js' -import { awaitChildProcess, awaitTask } from '../utils/index.js' -import { buildExtensionFlag } from '../extension/index.js' -import { extensionArgsParser } from './args.js' +import { codegen } from '../codegen/index.ts' +import { awaitChildProcess, awaitTask } from '../utils/index.ts' +import { buildExtensionFlag } from '../extension/index.ts' +import { extensionArgsParser } from './args.ts' await promisify(codegen)() // \\-- is used for debug diff --git a/packages/scripts/src/bin/dev-rspack.mjs b/packages/scripts/src/bin/dev-rspack.mjs index 7be10f4f83f8..018f8cce82c1 100755 --- a/packages/scripts/src/bin/dev-rspack.mjs +++ b/packages/scripts/src/bin/dev-rspack.mjs @@ -1,12 +1,12 @@ #!/usr/bin/env node -import { spawnSync } from 'child_process' -import { fileURLToPath } from 'url' +import { spawnSync } from 'node:child_process' +import { fileURLToPath } from 'node:url' const child = spawnSync( process.execPath, [ - '--import', - '@swc-node/register/esm-register', + '--experimental-strip-types', + '--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.resolve('./dev-rspack.ts')), ...process.argv.slice(2), ], diff --git a/packages/scripts/src/bin/dev-rspack.ts b/packages/scripts/src/bin/dev-rspack.ts index 9afe2dad948b..c7f4147308ad 100755 --- a/packages/scripts/src/bin/dev-rspack.ts +++ b/packages/scripts/src/bin/dev-rspack.ts @@ -1,9 +1,8 @@ -#!/usr/bin/env node --import swc-register-esm -import { spawn } from 'child_process' -import { codegenWatch } from '../codegen/index.js' -import { awaitChildProcess, cleanupWhenExit } from '../utils/index.js' -import { extensionWatchRspack } from '../extension/index.js' -import { extensionArgsParser } from './args.js' +import { spawn } from 'node:child_process' +import { codegenWatch } from '../codegen/index.ts' +import { awaitChildProcess, cleanupWhenExit } from '../utils/index.ts' +import { extensionWatchRspack } from '../extension/index.ts' +import { extensionArgsParser } from './args.ts' cleanupWhenExit() codegenWatch(console.error) diff --git a/packages/scripts/src/bin/dev.mjs b/packages/scripts/src/bin/dev.mjs index cf7c5ecea585..781a36c083f4 100755 --- a/packages/scripts/src/bin/dev.mjs +++ b/packages/scripts/src/bin/dev.mjs @@ -1,12 +1,12 @@ #!/usr/bin/env node -import { spawnSync } from 'child_process' -import { fileURLToPath } from 'url' +import { spawnSync } from 'node:child_process' +import { fileURLToPath } from 'node:url' const child = spawnSync( process.execPath, [ - '--import', - '@swc-node/register/esm-register', + '--experimental-strip-types', + '--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.resolve('./dev.ts')), ...process.argv.slice(2), ], diff --git a/packages/scripts/src/bin/dev.ts b/packages/scripts/src/bin/dev.ts index 2aed583c27a8..507179997851 100755 --- a/packages/scripts/src/bin/dev.ts +++ b/packages/scripts/src/bin/dev.ts @@ -1,9 +1,8 @@ -#!/usr/bin/env node --import swc-register-esm -import { spawn } from 'child_process' -import { codegenWatch } from '../codegen/index.js' -import { awaitChildProcess, cleanupWhenExit } from '../utils/index.js' -import { extensionWatch } from '../extension/index.js' -import { extensionArgsParser } from './args.js' +import { spawn } from 'node:child_process' +import { codegenWatch } from '../codegen/index.ts' +import { awaitChildProcess, cleanupWhenExit } from '../utils/index.ts' +import { extensionWatch } from '../extension/index.ts' +import { extensionArgsParser } from './args.ts' cleanupWhenExit() codegenWatch(console.error) diff --git a/packages/scripts/src/cloudflare/index.ts b/packages/scripts/src/cloudflare/index.ts index 6c00bedb1a89..f3c482e6a68d 100644 --- a/packages/scripts/src/cloudflare/index.ts +++ b/packages/scripts/src/cloudflare/index.ts @@ -1,6 +1,6 @@ import { dest, parallel, series, src, type TaskFunction } from 'gulp' -import { PKG_PATH, ROOT_PATH, task } from '../utils/index.js' -import { codegen } from '../codegen/index.js' +import { PKG_PATH, ROOT_PATH, task } from '../utils/index.ts' +import { codegen } from '../codegen/index.ts' import { fileURLToPath } from 'url' const DIST_PATH = new URL('dist/cloudflare', ROOT_PATH) diff --git a/packages/scripts/src/codegen/icon-codegen.ts b/packages/scripts/src/codegen/icon-codegen.ts index 9f116416ef6f..bd5ef927b815 100644 --- a/packages/scripts/src/codegen/icon-codegen.ts +++ b/packages/scripts/src/codegen/icon-codegen.ts @@ -2,7 +2,7 @@ import { readFile, writeFile } from 'fs/promises' import { watch } from 'gulp' import { camelCase, snakeCase, upperFirst } from 'lodash-es' import { parse as parsePath } from 'path' -import { PKG_PATH, ROOT_PATH, prettier, watchTask } from '../utils/index.js' +import { PKG_PATH, ROOT_PATH, prettier, watchTask } from '../utils/index.ts' import type { Position } from 'source-map' import { fileURLToPath } from 'url' diff --git a/packages/scripts/src/codegen/index.ts b/packages/scripts/src/codegen/index.ts index 586bf4bcf6b5..0b40e951a23b 100644 --- a/packages/scripts/src/codegen/index.ts +++ b/packages/scripts/src/codegen/index.ts @@ -1,7 +1,7 @@ -import { getProcessLock, markTaskNeedCleanup, watchTask } from '../utils/index.js' +import { getProcessLock, markTaskNeedCleanup, watchTask } from '../utils/index.ts' import { series, parallel, type TaskFunction } from 'gulp' -import { typescriptWatch } from './typescript.js' -import { iconCodegen, iconCodegenWatch } from './icon-codegen.js' +import { typescriptWatch } from './typescript.ts' +import { iconCodegen, iconCodegenWatch } from './icon-codegen.ts' // typescript is explicitly eliminated from this task. // our build process does not rely on tsc to give output, we have an extra check for tsc. @@ -11,5 +11,5 @@ export const codegenWatch: TaskFunction = markTaskNeedCleanup( ) watchTask(codegen, codegenWatch, 'codegen', 'All codegen tasks combined into one') -export * from './icon-codegen.js' -export * from './typescript.js' +export * from './icon-codegen.ts' +export * from './typescript.ts' diff --git a/packages/scripts/src/codegen/typescript.ts b/packages/scripts/src/codegen/typescript.ts index d7806a5f2404..46125406a425 100644 --- a/packages/scripts/src/codegen/typescript.ts +++ b/packages/scripts/src/codegen/typescript.ts @@ -1,4 +1,4 @@ -import { watchTask, shell, cleanupWhenExit } from '../utils/index.js' +import { watchTask, shell, cleanupWhenExit } from '../utils/index.ts' export function typescript() { return shell`npx tsc -b` diff --git a/packages/scripts/src/commands/changeset-release.ts b/packages/scripts/src/commands/changeset-release.ts index f5a8d15a4cbc..f39ffcc8c2f4 100644 --- a/packages/scripts/src/commands/changeset-release.ts +++ b/packages/scripts/src/commands/changeset-release.ts @@ -1,8 +1,8 @@ -import { readFile } from 'fs/promises' -import { awaitChildProcess } from '../utils/awaitChildProcess.js' -import { ROOT_PATH } from '../utils/paths.js' -import { shell } from '../utils/run.js' -import { task } from '../utils/task.js' +import { readFile } from 'node:fs/promises' +import { awaitChildProcess } from '../utils/awaitChildProcess.ts' +import { ROOT_PATH } from '../utils/paths.ts' +import { shell } from '../utils/run.ts' +import { task } from '../utils/task.ts' import { fileURLToPath } from 'node:url' const packages = [ diff --git a/packages/scripts/src/commands/clean.ts b/packages/scripts/src/commands/clean.ts index 5ed3fff0e366..ad02107e76b7 100644 --- a/packages/scripts/src/commands/clean.ts +++ b/packages/scripts/src/commands/clean.ts @@ -1,4 +1,4 @@ -import { awaitChildProcess, printShell, ROOT_PATH, shell, task } from '../utils/index.js' +import { awaitChildProcess, printShell, ROOT_PATH, shell, task } from '../utils/index.ts' export async function clean() { const { rimraf: rm } = await import('rimraf') diff --git a/packages/scripts/src/commands/index.ts b/packages/scripts/src/commands/index.ts index 80a52ba84311..827c7603dfb0 100644 --- a/packages/scripts/src/commands/index.ts +++ b/packages/scripts/src/commands/index.ts @@ -1,3 +1,3 @@ -export * from './clean.js' -export * from './sync-develop.js' -export * from './changeset-release.js' +export * from './clean.ts' +export * from './sync-develop.ts' +export * from './changeset-release.ts' diff --git a/packages/scripts/src/commands/sync-develop.ts b/packages/scripts/src/commands/sync-develop.ts index 9499a3c8561b..c858dc8b07b3 100644 --- a/packages/scripts/src/commands/sync-develop.ts +++ b/packages/scripts/src/commands/sync-develop.ts @@ -1,4 +1,4 @@ -import { shell, task } from '../utils/index.js' +import { shell, task } from '../utils/index.ts' const REPO_URL = 'https://github.com/DimensionDev/Maskbook.git' diff --git a/packages/scripts/src/extension/ci.ts b/packages/scripts/src/extension/ci.ts index 8bf0d26371e8..3b2236c79f2e 100644 --- a/packages/scripts/src/extension/ci.ts +++ b/packages/scripts/src/extension/ci.ts @@ -1,12 +1,11 @@ -#!/usr/bin/env node --import swc-register-esm -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' import { series, type TaskFunction } from 'gulp' -import { buildBaseExtension } from './normal.js' -import { ROOT_PATH, task } from '../utils/index.js' -import { codegen } from '../codegen/index.js' -import { type BuildFlagsExtended } from './flags.js' -import { copyFile } from 'fs/promises' -import { ManifestFile } from '../../../mask/.webpack/flags.js' +import { buildBaseExtension } from './normal.ts' +import { ROOT_PATH, task } from '../utils/index.ts' +import { codegen } from '../codegen/index.ts' +import { type BuildFlagsExtended } from './flags.ts' +import { copyFile } from 'node:fs/promises' +import { ManifestFile } from '../../../mask/.webpack/flags.ts' const BUILD_PATH = new URL('build/', ROOT_PATH) export const ciBuild: TaskFunction = series( diff --git a/packages/scripts/src/extension/dotenv.ts b/packages/scripts/src/extension/dotenv.ts index ca48242e6cd1..faf0504482f1 100644 --- a/packages/scripts/src/extension/dotenv.ts +++ b/packages/scripts/src/extension/dotenv.ts @@ -1,7 +1,7 @@ import { config } from 'dotenv' -import { ROOT_PATH } from '../utils/paths.js' -import type { BuildFlags } from './flags.js' -import { ManifestFile } from '../../../mask/.webpack/flags.js' +import { ROOT_PATH } from '../utils/paths.ts' +import type { BuildFlags } from './flags.ts' +import { ManifestFile } from '../../../mask/.webpack/flags.ts' export function applyDotEnv(flags: BuildFlags) { if (flags.mode === 'production') return diff --git a/packages/scripts/src/extension/flags.ts b/packages/scripts/src/extension/flags.ts index 23c64380ff80..80116c9d57a8 100644 --- a/packages/scripts/src/extension/flags.ts +++ b/packages/scripts/src/extension/flags.ts @@ -1,5 +1,5 @@ -import type { BuildFlags } from '../../../mask/.webpack/flags.js' -export type { BuildFlags } from '../../../mask/.webpack/flags.js' +import type { BuildFlags } from '../../../mask/.webpack/flags.ts' +export type { BuildFlags } from '../../../mask/.webpack/flags.ts' export interface BuildFlagsExtended extends BuildFlags { progress?: boolean diff --git a/packages/scripts/src/extension/index.ts b/packages/scripts/src/extension/index.ts index d46813a1667f..f6fb74dfc48c 100644 --- a/packages/scripts/src/extension/index.ts +++ b/packages/scripts/src/extension/index.ts @@ -1,2 +1,2 @@ -export * from './normal.js' -export * from './ci.js' +export * from './normal.ts' +export * from './ci.ts' diff --git a/packages/scripts/src/extension/normal.ts b/packages/scripts/src/extension/normal.ts index baa9b4eb725e..9849f1c5feec 100644 --- a/packages/scripts/src/extension/normal.ts +++ b/packages/scripts/src/extension/normal.ts @@ -1,16 +1,16 @@ import { compact } from 'lodash-es' -import { awaitChildProcess, cleanupWhenExit, PKG_PATH, shell, task, watchTask } from '../utils/index.js' -import { buildInjectedScript, watchInjectedScript } from '../projects/injected-scripts.js' -import { buildMaskSDK, watchMaskSDK } from '../projects/mask-sdk.js' -import { buildPolyfill } from '../projects/polyfill.js' -import { buildGun } from '../projects/gun.js' +import { awaitChildProcess, cleanupWhenExit, PKG_PATH, shell, task, watchTask } from '../utils/index.ts' +import { buildInjectedScript, watchInjectedScript } from '../projects/injected-scripts.ts' +import { buildMaskSDK, watchMaskSDK } from '../projects/mask-sdk.ts' +import { buildPolyfill } from '../projects/polyfill.ts' +import { buildGun } from '../projects/gun.ts' import { parallel, series, type TaskFunction } from 'gulp' -import { buildSentry } from '../projects/sentry.js' -import type { BuildFlags, BuildFlagsExtended } from './flags.js' -import { ManifestFile } from '../../../mask/.webpack/flags.js' -import { applyDotEnv } from './dotenv.js' -import { fileURLToPath } from 'url' -import { createRequire } from 'module' +import { buildSentry } from '../projects/sentry.ts' +import type { BuildFlags, BuildFlagsExtended } from './flags.ts' +import { ManifestFile } from '../../../mask/.webpack/flags.ts' +import { applyDotEnv } from './dotenv.ts' +import { fileURLToPath } from 'node:url' +import { createRequire } from 'node:module' export function buildWebpackFlag(name: string, args: BuildFlagsExtended) { const f = () => webpack(false, args) @@ -115,15 +115,15 @@ async function webpack(rspack: boolean, flags: BuildFlagsExtended) { const rspack = await import('@rspack/cli') const cli = new rspack.RspackCLI() console.log( - '$ node --import @swc-node/register/esm-register ./packages/mask/node_modules/@rspack/cli/bin/rspack.js', + '$ node --experimental-strip-types ./packages/mask/node_modules/@rspack/cli/bin/rspack.js', ...compact(rspack_argv), ) return cli.run(['node', 'rspack', ...compact(rspack_argv)]) } else { const command = [ JSON.stringify(process.execPath), - '--import', - '@swc-node/register/esm-register', + '--experimental-strip-types', + '--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.resolve(rspack ? 'rspack/bin/rspack.js' : './init.js')), flags.mode === 'development' ? 'serve' : undefined, ...argv, diff --git a/packages/scripts/src/index.ts b/packages/scripts/src/index.ts index 49ec2ca9d6fd..4963f1b542ac 100644 --- a/packages/scripts/src/index.ts +++ b/packages/scripts/src/index.ts @@ -1,24 +1,24 @@ -export { codegen, codegenWatch, iconCodegen, iconCodegenWatch, typescript, typescriptWatch } from './codegen/index.js' -export { ciBuild, buildChrome, extensionWatch, extensionWatchRspack } from './extension/index.js' -export { buildCloudflare } from './cloudflare/index.js' +export { codegen, codegenWatch, iconCodegen, iconCodegenWatch, typescript, typescriptWatch } from './codegen/index.ts' +export { ciBuild, buildChrome, extensionWatch, extensionWatchRspack } from './extension/index.ts' +export { buildCloudflare } from './cloudflare/index.ts' // Tools -export { clean, syncDevelop, changesetRelease } from './commands/index.js' -export { syncLanguages } from './locale-kit-next/index.js' -export { runLinguiExtract, runLinguiCompile } from './locale-kit-next/run-lingui.js' -export { reorderSpellcheck } from './spellcheck/index.js' +export { clean, syncDevelop, changesetRelease } from './commands/index.ts' +export { syncLanguages } from './locale-kit-next/index.ts' +export { runLinguiExtract, runLinguiCompile } from './locale-kit-next/run-lingui.ts' +export { reorderSpellcheck } from './spellcheck/index.ts' // Sub-projects build commands -export { buildInjectedScript, watchInjectedScript } from './projects/injected-scripts.js' -export { buildMaskSDK, watchMaskSDK } from './projects/mask-sdk.js' -export { buildPolyfill } from './projects/polyfill.js' -export { buildGun } from './projects/gun.js' -export { buildSandboxedPlugin, watchSandboxedPlugin } from './projects/sandboxed-plugins.js' -export { buildConstants } from './projects/build-constants.js' -export { buildContracts } from './projects/build-contracts.js' +export { buildInjectedScript, watchInjectedScript } from './projects/injected-scripts.ts' +export { buildMaskSDK, watchMaskSDK } from './projects/mask-sdk.ts' +export { buildPolyfill } from './projects/polyfill.ts' +export { buildGun } from './projects/gun.ts' +export { buildSandboxedPlugin, watchSandboxedPlugin } from './projects/sandboxed-plugins.ts' +export { buildConstants } from './projects/build-constants.ts' +export { buildContracts } from './projects/build-contracts.ts' // Linter -export { fixPluginsTSConfig } from './linter/plugin-projects.js' -export { lintPackageJson } from './linter/package-json.js' -export { lintIndex } from './linter/index-lint.js' -export { cleanPo } from './linter/po-files.js' +export { fixPluginsTSConfig } from './linter/plugin-projects.ts' +export { lintPackageJson } from './linter/package-json.ts' +export { lintIndex } from './linter/index-lint.ts' +export { cleanPo } from './linter/po-files.ts' diff --git a/packages/scripts/src/linter/index-lint.ts b/packages/scripts/src/linter/index-lint.ts index 0a69044273e6..ec9c8bf4ab91 100644 --- a/packages/scripts/src/linter/index-lint.ts +++ b/packages/scripts/src/linter/index-lint.ts @@ -1,6 +1,6 @@ -import { task } from '../utils/task.js' -import { readFile } from 'fs/promises' -import { ROOT_PATH } from '../utils/paths.js' +import { task } from '../utils/task.ts' +import { readFile } from 'node:fs/promises' +import { ROOT_PATH } from '../utils/paths.ts' import ts from 'typescript' const pattern = 'packages/**/index.ts' diff --git a/packages/scripts/src/linter/package-json.ts b/packages/scripts/src/linter/package-json.ts index c4ddfa9dec0f..140a983ecd4e 100644 --- a/packages/scripts/src/linter/package-json.ts +++ b/packages/scripts/src/linter/package-json.ts @@ -1,6 +1,6 @@ -import { task } from '../utils/task.js' -import { readFile, writeFile } from 'fs/promises' -import { ROOT_PATH } from '../utils/paths.js' +import { task } from '../utils/task.ts' +import { readFile, writeFile } from 'node:fs/promises' +import { ROOT_PATH } from '../utils/paths.ts' const pattern = 'packages/**/package.json' export async function lintPackageJson() { diff --git a/packages/scripts/src/linter/plugin-projects.ts b/packages/scripts/src/linter/plugin-projects.ts index 8e707e27d485..e80de800efa3 100644 --- a/packages/scripts/src/linter/plugin-projects.ts +++ b/packages/scripts/src/linter/plugin-projects.ts @@ -1,10 +1,10 @@ -import { readFileSync } from 'fs' -import { fileURLToPath } from 'url' -import { task } from '../utils/task.js' -import { readdir, writeFile } from 'fs/promises' -import { join } from 'path' +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import { task } from '../utils/task.ts' +import { readdir, writeFile } from 'node:fs/promises' +import { join } from 'node:path' import { exists } from 'fs-extra' -import { prettier } from '../utils/prettier.js' +import { prettier } from '../utils/prettier.ts' export async function fixPluginsTSConfig() { const folder = new URL('../../../plugins', import.meta.url) diff --git a/packages/scripts/src/linter/po-files.ts b/packages/scripts/src/linter/po-files.ts index 4dcdd53c88aa..24472bfba100 100644 --- a/packages/scripts/src/linter/po-files.ts +++ b/packages/scripts/src/linter/po-files.ts @@ -1,6 +1,6 @@ -import { task } from '../utils/task.js' -import { readFile, writeFile } from 'fs/promises' -import { ROOT_PATH } from '../utils/paths.js' +import { task } from '../utils/task.ts' +import { readFile, writeFile } from 'node:fs/promises' +import { ROOT_PATH } from '../utils/paths.ts' const pattern = 'packages/**/locale/*.po' diff --git a/packages/scripts/src/locale-kit-next/index.ts b/packages/scripts/src/locale-kit-next/index.ts index fc2a9efdfa74..ca6e340ad8c0 100644 --- a/packages/scripts/src/locale-kit-next/index.ts +++ b/packages/scripts/src/locale-kit-next/index.ts @@ -1,6 +1,6 @@ -import { readdir, writeFile } from 'fs/promises' -import { dirname } from 'path' -import { ROOT_PATH, task, prettier } from '../utils/index.js' +import { readdir, writeFile } from 'node:fs/promises' +import { dirname } from 'node:path' +import { ROOT_PATH, task, prettier } from '../utils/index.ts' const mainFallbackMap = new Map([['zh', 'zh-TW']]) diff --git a/packages/scripts/src/locale-kit-next/run-lingui.ts b/packages/scripts/src/locale-kit-next/run-lingui.ts index 74d48ecc5183..01677fbbea01 100644 --- a/packages/scripts/src/locale-kit-next/run-lingui.ts +++ b/packages/scripts/src/locale-kit-next/run-lingui.ts @@ -1,7 +1,7 @@ -import { readdir, readFile } from 'fs/promises' -import { join, relative } from 'path' -import { ROOT_PATH, task, shell, awaitChildProcess } from '../utils/index.js' -import { fileURLToPath } from 'url' +import { readdir, readFile } from 'node:fs/promises' +import { join, relative } from 'node:path' +import { ROOT_PATH, task, shell, awaitChildProcess } from '../utils/index.ts' +import { fileURLToPath } from 'node:url' async function getLinguiEnabledPackages() { const folders: string[] = [] diff --git a/packages/scripts/src/projects/build-constants.ts b/packages/scripts/src/projects/build-constants.ts index d8662b7259e1..a80322c539ed 100644 --- a/packages/scripts/src/projects/build-constants.ts +++ b/packages/scripts/src/projects/build-constants.ts @@ -1,8 +1,8 @@ import { promises as fs } from 'node:fs' import { resolve, join } from 'node:path' -import { awaitChildProcess } from '../utils/awaitChildProcess.js' -import { shell } from '../utils/run.js' -import { task } from '../utils/task.js' +import { awaitChildProcess } from '../utils/awaitChildProcess.ts' +import { shell } from '../utils/run.ts' +import { task } from '../utils/task.ts' type Primitive = string | number | boolean diff --git a/packages/scripts/src/projects/build-contracts.ts b/packages/scripts/src/projects/build-contracts.ts index c97f58b27843..6ae203e53cf6 100644 --- a/packages/scripts/src/projects/build-contracts.ts +++ b/packages/scripts/src/projects/build-contracts.ts @@ -1,8 +1,8 @@ import { promises as fs } from 'fs' import { join } from 'path' -import { task } from '../utils/task.js' -import { awaitChildProcess } from '../utils/awaitChildProcess.js' -import { shell } from '../utils/run.js' +import { task } from '../utils/task.ts' +import { awaitChildProcess } from '../utils/awaitChildProcess.ts' +import { shell } from '../utils/run.ts' import { rimraf } from 'rimraf' const ABIS_PATH = join(import.meta.dirname, '../../../web3-contracts/abis/') diff --git a/packages/scripts/src/projects/gun.ts b/packages/scripts/src/projects/gun.ts index 4442072ddd48..026c151c7358 100644 --- a/packages/scripts/src/projects/gun.ts +++ b/packages/scripts/src/projects/gun.ts @@ -1,4 +1,4 @@ -import { fromNPMTask, PKG_PATH } from '../utils/index.js' +import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildGun] = fromNPMTask( // new URL('gun-utils/', PKG_PATH), diff --git a/packages/scripts/src/projects/injected-scripts.ts b/packages/scripts/src/projects/injected-scripts.ts index 5caab7981da6..fe1df89c547d 100644 --- a/packages/scripts/src/projects/injected-scripts.ts +++ b/packages/scripts/src/projects/injected-scripts.ts @@ -1,4 +1,4 @@ -import { fromNPMTask, PKG_PATH } from '../utils/index.js' +import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildInjectedScript, watchInjectedScript] = fromNPMTask( new URL('injected-script/', PKG_PATH), 'injected-script', diff --git a/packages/scripts/src/projects/mask-sdk.ts b/packages/scripts/src/projects/mask-sdk.ts index 08466e614599..556152e2b8a2 100644 --- a/packages/scripts/src/projects/mask-sdk.ts +++ b/packages/scripts/src/projects/mask-sdk.ts @@ -1,4 +1,4 @@ -import { fromNPMTask, PKG_PATH } from '../utils/index.js' +import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildMaskSDK, watchMaskSDK] = fromNPMTask( // new URL('mask-sdk/', PKG_PATH), diff --git a/packages/scripts/src/projects/polyfill.ts b/packages/scripts/src/projects/polyfill.ts index e4759520a791..ec7b176c253c 100644 --- a/packages/scripts/src/projects/polyfill.ts +++ b/packages/scripts/src/projects/polyfill.ts @@ -1,4 +1,4 @@ -import { fromNPMTask, PKG_PATH } from '../utils/index.js' +import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildPolyfill] = fromNPMTask( new URL('polyfills/', PKG_PATH), 'polyfill', diff --git a/packages/scripts/src/projects/sandboxed-plugins.ts b/packages/scripts/src/projects/sandboxed-plugins.ts index 8b7a34079cf4..46faaa6c0c67 100644 --- a/packages/scripts/src/projects/sandboxed-plugins.ts +++ b/packages/scripts/src/projects/sandboxed-plugins.ts @@ -4,13 +4,13 @@ import { readdir, readFile, writeFile } from 'node:fs/promises' import { isAbsolute, join, relative } from 'node:path' import { createRequire } from 'node:module' import { ensureDir } from 'fs-extra' -import { awaitTask, watchTask } from '../utils/task.js' -import { PKG_PATH, ROOT_PATH } from '../utils/paths.js' -import { parseJSONc } from '../utils/jsonc.js' +import { awaitTask, watchTask } from '../utils/task.ts' +import { PKG_PATH, ROOT_PATH } from '../utils/paths.ts' +import { parseJSONc } from '../utils/jsonc.ts' import { transform } from '@swc/core' import { dest, lastRun, parallel, src, type TaskFunction } from 'gulp' import { parseArgs } from 'node:util' -import { getLanguageFamilyName } from '../locale-kit-next/index.js' +import { getLanguageFamilyName } from '../locale-kit-next/index.ts' const require = createRequire(new URL(import.meta.url)) const sandboxedPlugins = new URL('./sandboxed-plugins/', PKG_PATH) @@ -107,7 +107,7 @@ export async function buildSandboxedPluginConfigurable(distPath: string, isProdu const writeInternalList = writeFile(join(distPath, './plugins.json'), JSON.stringify(internalList, null, 4)) await Promise.all([tasks, writeInternalList]) await writeFile( - join(distPath, './mv3-preload.js'), + join(distPath, './mv3-preload.ts'), mv3PreloadList.size ? (function* () { yield `importScripts(\n` @@ -155,7 +155,7 @@ function createBuilder({ id, manifestRoot, distPath, onJS, origin }: BuilderOpti return compile } function removeMJSSuffix(name: string) { - if (name.endsWith('.mjs')) return name.slice(0, -4) + '.js' + if (name.endsWith('.mjs')) return name.slice(0, -4) + '.ts' return name } @@ -210,11 +210,12 @@ async function getLocales(manifest: any, manifestPath: string): Promise void, - ) { + public origin: string + public onJS: (id: string, relative: string) => void + constructor(origin: string, onJS: (id: string, relative: string) => void) { super({ objectMode: true, defaultEncoding: 'utf-8' }) + this.origin = origin + this.onJS = onJS } wasm = require.resolve('@masknet/static-module-record-swc') override _transform( @@ -222,7 +223,7 @@ class TransformStream extends Transform { encoding: BufferEncoding, callback: TransformCallback, ): void { - if (!(file.path.endsWith('.js') || file.path.endsWith('.mjs'))) { + if (!(file.path.endsWith('.ts') || file.path.endsWith('.mjs'))) { return callback(null, file) } const relative = file.relative.replace(/\\/g, '/') diff --git a/packages/scripts/src/projects/sentry.ts b/packages/scripts/src/projects/sentry.ts index 5763a6adaa67..03cf0608993a 100644 --- a/packages/scripts/src/projects/sentry.ts +++ b/packages/scripts/src/projects/sentry.ts @@ -1,3 +1,3 @@ -import { fromNPMTask, PKG_PATH } from '../utils/index.js' +import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildSentry] = fromNPMTask(new URL('sentry/', PKG_PATH), 'build-sentry', 'Build sentry.') diff --git a/packages/scripts/src/spellcheck/index.ts b/packages/scripts/src/spellcheck/index.ts index f13e044721f3..e3913d799d5a 100644 --- a/packages/scripts/src/spellcheck/index.ts +++ b/packages/scripts/src/spellcheck/index.ts @@ -1,5 +1,5 @@ import { readFile, writeFile } from 'fs/promises' -import { prettier, ROOT_PATH, task } from '../utils/index.js' +import { prettier, ROOT_PATH, task } from '../utils/index.ts' const CONFIGURE_PATH = new URL('cspell.json', ROOT_PATH) diff --git a/packages/scripts/src/utils/index.ts b/packages/scripts/src/utils/index.ts index 93406d28a644..3c199b164dfe 100644 --- a/packages/scripts/src/utils/index.ts +++ b/packages/scripts/src/utils/index.ts @@ -1,8 +1,8 @@ -export * from './paths.js' -export * from './awaitChildProcess.js' -export * from './prettier.js' -export * from './task.js' -export * from './run.js' -export * from './process-lock.js' -export * from './write.js' -export * from './exit.js' +export * from './paths.ts' +export * from './awaitChildProcess.ts' +export * from './prettier.ts' +export * from './task.ts' +export * from './run.ts' +export * from './process-lock.ts' +export * from './write.ts' +export * from './exit.ts' diff --git a/packages/scripts/src/utils/prettier.ts b/packages/scripts/src/utils/prettier.ts index 969edc2729de..2cb815eb72e0 100644 --- a/packages/scripts/src/utils/prettier.ts +++ b/packages/scripts/src/utils/prettier.ts @@ -1,5 +1,5 @@ import type { Options } from 'prettier' -import { ROOT_PATH } from './paths.js' +import { ROOT_PATH } from './paths.ts' export async function prettier(code: string, parser: Options['parser'] = 'typescript', tabWidth = 4) { const { diff --git a/packages/scripts/src/utils/run.ts b/packages/scripts/src/utils/run.ts index 258f5f4ae402..caa5d08cdf83 100644 --- a/packages/scripts/src/utils/run.ts +++ b/packages/scripts/src/utils/run.ts @@ -1,9 +1,9 @@ import { spawn } from 'child_process' -import { ROOT_PATH } from './paths.js' +import { ROOT_PATH } from './paths.ts' import { relative } from 'path' import chalk from 'chalk' import { fileURLToPath } from 'url' -import { markChildProcess } from './exit.js' +import { markChildProcess } from './exit.ts' function logShell(e: string, args: string[], url: URL | string) { if (typeof url === 'object') url = fileURLToPath(url) diff --git a/packages/scripts/src/utils/task.ts b/packages/scripts/src/utils/task.ts index 0ac6cacee613..6582ee84e6e6 100644 --- a/packages/scripts/src/utils/task.ts +++ b/packages/scripts/src/utils/task.ts @@ -1,7 +1,7 @@ import { series, type TaskFunction } from 'gulp' -import { shell } from './run.js' -import { awaitChildProcess } from './awaitChildProcess.js' -import { cleanupWhenExit } from './exit.js' +import { shell } from './run.ts' +import { awaitChildProcess } from './awaitChildProcess.ts' +import { cleanupWhenExit } from './exit.ts' export function task( f: T, diff --git a/packages/scripts/src/utils/write.ts b/packages/scripts/src/utils/write.ts index 78f3bbae4fbb..79b7b4ffe603 100644 --- a/packages/scripts/src/utils/write.ts +++ b/packages/scripts/src/utils/write.ts @@ -1,5 +1,5 @@ import { readFile, writeFile } from 'fs/promises' -import { prettier } from './prettier.js' +import { prettier } from './prettier.ts' export async function changeFile(path: string | URL, f: (x: string) => string | Promise) { const content = await readFile(path, 'utf8') diff --git a/packages/scripts/tsconfig.json b/packages/scripts/tsconfig.json index 2848410355a0..29157ea692da 100644 --- a/packages/scripts/tsconfig.json +++ b/packages/scripts/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "lib": ["ESNext"], "composite": false, - "incremental": false + "incremental": false, + "allowImportingTsExtensions": true }, "include": ["./src"] } diff --git a/patches/gulp@5.0.0.patch b/patches/gulp.patch similarity index 55% rename from patches/gulp@5.0.0.patch rename to patches/gulp.patch index 6a033d6ad8e2..88e4e1954b8d 100644 --- a/patches/gulp@5.0.0.patch +++ b/patches/gulp.patch @@ -1,18 +1,16 @@ diff --git a/bin/gulp.js b/bin/gulp.js -index f4b80cc41c688105989296a0731729a171b27ac0..168717d5afce46eeefa118dd9aa6ef9a8f455ded 100755 +index f4b80cc41c688105989296a0731729a171b27ac0..d0703389c9cb8fc7bea0a1ef8e7b920fe354fa0a 100755 --- a/bin/gulp.js +++ b/bin/gulp.js -@@ -1,3 +1,3 @@ +@@ -1,3 +1,2 @@ #!/usr/bin/env node - --require('gulp-cli')(); -+const cli = require('gulp-cli'); -+cli(); -diff --git a/bin/swc-gulp.js b/bin/swc-gulp.js + require('gulp-cli')(); +diff --git a/bin/ts-gulp.js b/bin/ts-gulp.js new file mode 100644 -index 0000000000000000000000000000000000000000..a14351c2a7743af318d7efab246099c142bf3813 +index 0000000000000000000000000000000000000000..a8e66080f68b94741ebfc5fe76336f4aea9c4897 --- /dev/null -+++ b/bin/swc-gulp.js ++++ b/bin/ts-gulp.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node + @@ -21,18 +19,18 @@ index 0000000000000000000000000000000000000000..a14351c2a7743af318d7efab246099c1 +const child = spawnSync( + process.execPath, + [ -+ '--import', -+ '@swc-node/register/esm-register', ++ '--disable-warning=ExperimentalWarning', ++ '--experimental-strip-types', + join(__dirname, './gulp.js'), + ...process.argv.slice(2), + ], + { + stdio: 'inherit', -+ } ++ }, +); +if (child.status) process.exit(child.status); diff --git a/package.json b/package.json -index be5477ddf77fc32ebce569347c38ac322dbda6e7..c27a348e4c84f08865c91ece656b41145440064b 100644 +index be5477ddf77fc32ebce569347c38ac322dbda6e7..68a2a528abe62341b10f31a87687833065724700 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ @@ -40,7 +38,7 @@ index be5477ddf77fc32ebce569347c38ac322dbda6e7..c27a348e4c84f08865c91ece656b4114 ], "bin": { - "gulp": "./bin/gulp.js" -+ "gulp": "./bin/swc-gulp.js" ++ "gulp": "./bin/ts-gulp.js" }, "scripts": { "lint": "eslint .", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df24f8d705da..fecbdf4c6b06 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,9 +57,9 @@ patchedDependencies: eslint-plugin-i@2.29.1: hash: zgide6rxzjqivhxxv36ouq6c4y path: patches/eslint-plugin-i@2.29.1.patch - gulp@5.0.0: - hash: 43h33nymtjr4cs2ejuui5ulgfe - path: patches/gulp@5.0.0.patch + gulp: + hash: tdwx5kqhf6grdas2dblneqarim + path: patches/gulp.patch react-devtools-inline@5.3.0: hash: jy5l47kz5zhgguiggeursqr63y path: patches/react-devtools-inline@5.3.0.patch @@ -189,9 +189,6 @@ importers: '@nice-labs/git-rev': specifier: ^3.5.1 version: 3.5.1 - '@swc-node/register': - specifier: ^1.10.9 - version: 1.10.9(@swc/core@1.11.7(@swc/helpers@0.5.15))(@swc/types@0.1.19)(typescript@5.8.2) '@swc/core': specifier: 1.11.7 version: 1.11.7(@swc/helpers@0.5.15) @@ -239,7 +236,7 @@ importers: version: 4.1.4(@typescript-eslint/eslint-plugin@8.26.0(@typescript-eslint/parser@8.26.0(eslint@9.21.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.21.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.21.0(jiti@2.4.2)) gulp: specifier: ^5.0.0 - version: 5.0.0(patch_hash=43h33nymtjr4cs2ejuui5ulgfe) + version: 5.0.0(patch_hash=tdwx5kqhf6grdas2dblneqarim) husky: specifier: ^9.1.7 version: 9.1.7 @@ -349,6 +346,10 @@ importers: gun: specifier: 0.2020.1234 version: 0.2020.1234(bufferutil@4.0.8)(utf-8-validate@5.0.10) + devDependencies: + '@swc/core': + specifier: 1.11.7 + version: 1.11.7(@swc/helpers@0.5.15) packages/icons: {} @@ -2184,9 +2185,6 @@ importers: packages/polyfills: dependencies: - '@types/webextension-polyfill': - specifier: ^0.10.7 - version: 0.10.7 core-js: specifier: 3.41.0 version: 3.41.0 @@ -2209,6 +2207,9 @@ importers: '@types/node': specifier: 22.13.9 version: 22.13.9 + '@types/webextension-polyfill': + specifier: ^0.10.7 + version: 0.10.7 core-js-compat: specifier: 3.41.0 version: 3.41.0 @@ -4072,15 +4073,6 @@ packages: '@dual-bundle/import-meta-resolve@4.1.0': resolution: {integrity: sha512-+nxncfwHM5SgAtrVzgpzJOI1ol0PkumhVo469KCf9lUi21IGcY90G98VuHm9VRrUypmAzawAHO9bs6hqeADaVg==} - '@emnapi/core@1.2.0': - resolution: {integrity: sha512-E7Vgw78I93we4ZWdYCb4DGAwRROGkMIXk7/y87UmANR+J6qsWusmC3gLt0H+O0KOt5e6O38U8oJamgbudrES/w==} - - '@emnapi/runtime@1.2.0': - resolution: {integrity: sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==} - - '@emnapi/wasi-threads@1.0.1': - resolution: {integrity: sha512-iIBu7mwkq4UQGeMEM8bLwNK962nXdhodeScX4slfQnRhEMMzvYivHhutCIk8uojvmASXXPC2WNEjwxFWk72Oqw==} - '@emotion/babel-plugin@11.11.0': resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==} @@ -5584,9 +5576,6 @@ packages: resolution: {integrity: sha512-odBwQ/EyQh3/CVMTxVD95EWsOI6I7T02+4gpVNVDNR4+yoQuFjsq8yb3+618oXJCunpShiKO9XmX4ve1mCzyLQ==} engines: {node: '>= 10'} - '@napi-rs/wasm-runtime@0.2.4': - resolution: {integrity: sha512-9zESzOO5aDByvhIAsOy9TbpZ0Ur2AJbUI7UT73kcUTS2mxAMHOBaa1st/jAymNoCtvrit99kkzT1FZuXVcgfIQ==} - '@nice-labs/emit-file-webpack-plugin@1.1.4': resolution: {integrity: sha512-yNYzYN6N2wrcoOcxfNgBP7GLVoewfV7vsg4muVLAJdIBQWnXx+t7d/MEp0n3BYhcxH4MEjm6IZ6jDVzFa3zkJw==} engines: {node: '>= 12'} @@ -5696,65 +5685,6 @@ packages: resolution: {integrity: sha512-ssLUjjj/DXl6m4oydyA6vgVHyJcis4Ui0hS7+EyOxZVMXbiVZeGOficfJfgELTNqTbHLmTb3TBVyJspNDkqbLw==} deprecated: OvernightJS/logger has been deprecated in favor of jet-logger - '@oxc-resolver/binding-darwin-arm64@1.10.2': - resolution: {integrity: sha512-aOCZYXqmFL+2sXlaVkYbAOtICGGeTFtmdul8OimQfOXHJods6YHJ2nR6+rEeBcJzaXyXPP18ne1IsEc4AYL1IA==} - cpu: [arm64] - os: [darwin] - - '@oxc-resolver/binding-darwin-x64@1.10.2': - resolution: {integrity: sha512-6WD7lHGkoduFZfUgnC2suKOlqttQRKxWsiVXiiGPu3mfXvQAhMd/gekuH1t8vOhFlPJduaww15n5UB0bSjCK+w==} - cpu: [x64] - os: [darwin] - - '@oxc-resolver/binding-freebsd-x64@1.10.2': - resolution: {integrity: sha512-nEqHWx/Ot5p7Mafj8qH6vFlLSvHjECxAcZwhnAMqRuQu1NgXC/QM3emkdhVGy7QJgsxZbHpPaF6TERNf5/NL9Q==} - cpu: [x64] - os: [freebsd] - - '@oxc-resolver/binding-linux-arm-gnueabihf@1.10.2': - resolution: {integrity: sha512-+AlZI0fPnpfArh8aC5k2295lmQrxa2p8gBLxC3buvCkz0ZpbVLxyyAXz3J2jGwJnmc5MUPLEqPYw6ZlAGH4XHA==} - cpu: [arm] - os: [linux] - - '@oxc-resolver/binding-linux-arm64-gnu@1.10.2': - resolution: {integrity: sha512-8fZ8NszFaUZaoA8eUwkF2lHjgUs76aFiewWgG/cjcZmwKp+ErZQLW8eOvIWZ4SohHQ+ScvhVsSaU2PU38c88gw==} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@oxc-resolver/binding-linux-arm64-musl@1.10.2': - resolution: {integrity: sha512-oPrLICrw96Ym9n04FWXWGkbkpF6qJtZ57JSnqI3oQ24xHTt4iWyjHKHQO46NbJAK9sFb3Qce4BzV8faDI5Rifg==} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@oxc-resolver/binding-linux-x64-gnu@1.10.2': - resolution: {integrity: sha512-eli74jTAUiIfqi8IPFqiPxQS69Alcr6w/IFRyf3XxrkxeFGgcgxJkRIxWNTKJ6T3EXxjuma+49LdZn6l9rEj7A==} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@oxc-resolver/binding-linux-x64-musl@1.10.2': - resolution: {integrity: sha512-HH9zmjNSQo3rkbqJH5nIjGrtjC+QPrUy0KGGMR/oRCSLuD0cNFJ/Uly1XAugwSm4oEw0+rv6PmeclXmVTKsxhw==} - cpu: [x64] - os: [linux] - libc: [musl] - - '@oxc-resolver/binding-wasm32-wasi@1.10.2': - resolution: {integrity: sha512-3ItX23q33sfVBtMMdMhVDSe0NX5zBHxHfmFiXhSJuwNaVIwGpLFU7WU2nmq9oNdnmTOvjL8vlhOqiGvumBLlRA==} - engines: {node: '>=14.0.0'} - cpu: [wasm32] - - '@oxc-resolver/binding-win32-arm64-msvc@1.10.2': - resolution: {integrity: sha512-aVoj2V+jmQ1N+lVy9AhaLmzssJM0lcKt8D0UL83aNLZJ5lSN7hgBuUXTVmL+VF268f167khjo38z+fbELDVm8Q==} - cpu: [arm64] - os: [win32] - - '@oxc-resolver/binding-win32-x64-msvc@1.10.2': - resolution: {integrity: sha512-l8BDQWyP0Piw8hlmYPUqTRKLsq+ceG9h+9p6ZrjNzwW9AmJX7T7T2hgoVVHqS6f4WNA/CFkb3RyZP9QTzNkyyA==} - cpu: [x64] - os: [win32] - '@parcel/watcher-android-arm64@2.3.0': resolution: {integrity: sha512-f4o9eA3dgk0XRT3XhB0UWpWpLnKgrh1IwNJKJ7UJek7eTYccQ8LR7XUWFKqw6aEq5KUNlCcGvSzKqSX/vtWVVA==} engines: {node: '>= 10.0.0'} @@ -6644,22 +6574,6 @@ packages: '@streamparser/json@0.0.20': resolution: {integrity: sha512-VqAAkydywPpkw63WQhPVKCD3SdwXuihCUVZbbiY3SfSTGQyHmwRoq27y4dmJdZuJwd5JIlQoMPyGvMbUPY0RKQ==} - '@swc-node/core@1.13.3': - resolution: {integrity: sha512-OGsvXIid2Go21kiNqeTIn79jcaX4l0G93X2rAnas4LFoDyA9wAwVK7xZdm+QsKoMn5Mus2yFLCc4OtX2dD/PWA==} - engines: {node: '>= 10'} - peerDependencies: - '@swc/core': 1.11.7 - '@swc/types': '>= 0.1' - - '@swc-node/register@1.10.9': - resolution: {integrity: sha512-iXy2sjP0phPEpK2yivjRC3PAgoLaT4sjSk0LDWCTdcTBJmR4waEog0E6eJbvoOkLkOtWw37SB8vCkl/bbh4+8A==} - peerDependencies: - '@swc/core': 1.11.7 - typescript: '>= 4.3' - - '@swc-node/sourcemap-support@0.5.1': - resolution: {integrity: sha512-JxIvIo/Hrpv0JCHSyRpetAdQ6lB27oFYhv0PKCNf1g2gUXOjpeR1exrXccRxLMuAV5WAmGFBwRnNOJqN38+qtg==} - '@swc/core-darwin-arm64@1.11.7': resolution: {integrity: sha512-3+LhCP2H50CLI6yv/lhOtoZ5B/hi7Q/23dye1KhbSDeDprLTm/KfLJh/iQqwaHUponf5m8C2U0y6DD+HGLz8Yw==} engines: {node: '>=10'} @@ -6807,9 +6721,6 @@ packages: '@tsconfig/node16@1.0.3': resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} - '@tybys/wasm-util@0.9.0': - resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==} - '@typechain/web3-v1@6.0.7': resolution: {integrity: sha512-HWkGplyPL3eWiP0sszqKZh6Bjrdm23srtirUdKp/4BEWKp/o6zofLt8lDn468bRQlQdHaobrbfEeT+3gf/r4eg==} peerDependencies: @@ -12850,9 +12761,6 @@ packages: outvariant@1.4.2: resolution: {integrity: sha512-Ou3dJ6bA/UJ5GVHxah4LnqDwZRwAmWxrG3wtrHrbGnP4RnLCtA64A4F+ae7Y8ww660JaddSoArUR5HjipWSHAQ==} - oxc-resolver@1.10.2: - resolution: {integrity: sha512-NIbwVqoU8Bhl7PVtItHCg+VFFokIDwBgIgFUwFG2Y8ePhxftFh5xG+KLar5PLWXlCP4WunPIuXD3jr3v6/MfRw==} - p-cancelable@2.1.1: resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==} engines: {node: '>=8'} @@ -17532,22 +17440,6 @@ snapshots: '@dual-bundle/import-meta-resolve@4.1.0': {} - '@emnapi/core@1.2.0': - dependencies: - '@emnapi/wasi-threads': 1.0.1 - tslib: 2.8.1 - optional: true - - '@emnapi/runtime@1.2.0': - dependencies: - tslib: 2.8.1 - optional: true - - '@emnapi/wasi-threads@1.0.1': - dependencies: - tslib: 2.8.1 - optional: true - '@emotion/babel-plugin@11.11.0': dependencies: '@babel/helper-module-imports': 7.25.9 @@ -19832,13 +19724,6 @@ snapshots: '@napi-rs/image-win32-x64-msvc': 1.4.1 optional: true - '@napi-rs/wasm-runtime@0.2.4': - dependencies: - '@emnapi/core': 1.2.0 - '@emnapi/runtime': 1.2.0 - '@tybys/wasm-util': 0.9.0 - optional: true - '@nice-labs/emit-file-webpack-plugin@1.1.4(@magic-works/webpack@5.88.2)': dependencies: webpack: '@magic-works/webpack@5.88.2(@magic-works/webpack@5.88.2)(@swc/core@1.11.7(@swc/helpers@0.5.15))(webpack-cli@6.0.1)' @@ -19964,41 +19849,6 @@ snapshots: colors: 1.4.0 util: 0.11.1 - '@oxc-resolver/binding-darwin-arm64@1.10.2': - optional: true - - '@oxc-resolver/binding-darwin-x64@1.10.2': - optional: true - - '@oxc-resolver/binding-freebsd-x64@1.10.2': - optional: true - - '@oxc-resolver/binding-linux-arm-gnueabihf@1.10.2': - optional: true - - '@oxc-resolver/binding-linux-arm64-gnu@1.10.2': - optional: true - - '@oxc-resolver/binding-linux-arm64-musl@1.10.2': - optional: true - - '@oxc-resolver/binding-linux-x64-gnu@1.10.2': - optional: true - - '@oxc-resolver/binding-linux-x64-musl@1.10.2': - optional: true - - '@oxc-resolver/binding-wasm32-wasi@1.10.2': - dependencies: - '@napi-rs/wasm-runtime': 0.2.4 - optional: true - - '@oxc-resolver/binding-win32-arm64-msvc@1.10.2': - optional: true - - '@oxc-resolver/binding-win32-x64-msvc@1.10.2': - optional: true - '@parcel/watcher-android-arm64@2.3.0': optional: true @@ -21133,31 +20983,6 @@ snapshots: '@streamparser/json@0.0.20': {} - '@swc-node/core@1.13.3(@swc/core@1.11.7(@swc/helpers@0.5.15))(@swc/types@0.1.19)': - dependencies: - '@swc/core': 1.11.7(@swc/helpers@0.5.15) - '@swc/types': 0.1.19 - - '@swc-node/register@1.10.9(@swc/core@1.11.7(@swc/helpers@0.5.15))(@swc/types@0.1.19)(typescript@5.8.2)': - dependencies: - '@swc-node/core': 1.13.3(@swc/core@1.11.7(@swc/helpers@0.5.15))(@swc/types@0.1.19) - '@swc-node/sourcemap-support': 0.5.1 - '@swc/core': 1.11.7(@swc/helpers@0.5.15) - colorette: 2.0.20 - debug: 4.3.7 - oxc-resolver: 1.10.2 - pirates: 4.0.6 - tslib: 2.8.1 - typescript: 5.8.2 - transitivePeerDependencies: - - '@swc/types' - - supports-color - - '@swc-node/sourcemap-support@0.5.1': - dependencies: - source-map-support: 0.5.21 - tslib: 2.8.1 - '@swc/core-darwin-arm64@1.11.7': optional: true @@ -21274,11 +21099,6 @@ snapshots: '@tsconfig/node16@1.0.3': {} - '@tybys/wasm-util@0.9.0': - dependencies: - tslib: 2.8.1 - optional: true - '@typechain/web3-v1@6.0.7(typechain@8.3.2(typescript@5.8.2))(typescript@5.8.2)(web3-core@1.10.4(encoding@0.1.13))(web3-eth-contract@1.10.2(encoding@0.1.13))(web3@1.10.2(bufferutil@4.0.8)(encoding@0.1.13)(utf-8-validate@5.0.10))': dependencies: lodash: 4.17.21 @@ -26522,7 +26342,7 @@ snapshots: v8flags: 4.0.1 yargs: 16.2.0 - gulp@5.0.0(patch_hash=43h33nymtjr4cs2ejuui5ulgfe): + gulp@5.0.0(patch_hash=tdwx5kqhf6grdas2dblneqarim): dependencies: glob-watcher: 6.0.0 gulp-cli: 3.0.0 @@ -29345,20 +29165,6 @@ snapshots: outvariant@1.4.2: {} - oxc-resolver@1.10.2: - optionalDependencies: - '@oxc-resolver/binding-darwin-arm64': 1.10.2 - '@oxc-resolver/binding-darwin-x64': 1.10.2 - '@oxc-resolver/binding-freebsd-x64': 1.10.2 - '@oxc-resolver/binding-linux-arm-gnueabihf': 1.10.2 - '@oxc-resolver/binding-linux-arm64-gnu': 1.10.2 - '@oxc-resolver/binding-linux-arm64-musl': 1.10.2 - '@oxc-resolver/binding-linux-x64-gnu': 1.10.2 - '@oxc-resolver/binding-linux-x64-musl': 1.10.2 - '@oxc-resolver/binding-wasm32-wasi': 1.10.2 - '@oxc-resolver/binding-win32-arm64-msvc': 1.10.2 - '@oxc-resolver/binding-win32-x64-msvc': 1.10.2 - p-cancelable@2.1.1: {} p-cancelable@3.0.0: {} From f07f020cd3242c9c4ad711091690dea3760bdc77 Mon Sep 17 00:00:00 2001 From: Jack Works <5390719+Jack-Works@users.noreply.github.com> Date: Wed, 9 Apr 2025 01:44:30 +0800 Subject: [PATCH 2/3] fix: linter --- eslint.config.js | 3 +- packages/backup-format/tests/encryption.ts | 2 +- packages/scripts/src/cloudflare/index.ts | 4 +-- packages/scripts/src/codegen/icon-codegen.ts | 32 +++++++++---------- .../scripts/src/commands/changeset-release.ts | 2 +- packages/scripts/src/extension/ci.ts | 6 ++-- packages/scripts/src/extension/normal.ts | 6 ++-- packages/scripts/src/linter/package-json.ts | 2 +- packages/scripts/src/linter/po-files.ts | 2 +- packages/scripts/src/locale-kit-next/index.ts | 12 +++---- .../scripts/src/projects/build-contracts.ts | 4 +-- packages/scripts/src/projects/gun.ts | 2 +- .../scripts/src/projects/injected-scripts.ts | 2 +- packages/scripts/src/projects/mask-sdk.ts | 2 +- packages/scripts/src/projects/polyfill.ts | 2 +- .../scripts/src/projects/sandboxed-plugins.ts | 14 ++++---- packages/scripts/src/projects/sentry.ts | 2 +- packages/scripts/src/spellcheck/index.ts | 4 +-- .../scripts/src/utils/awaitChildProcess.ts | 2 +- packages/scripts/src/utils/exit.ts | 2 +- packages/scripts/src/utils/paths.ts | 2 +- packages/scripts/src/utils/process-lock.ts | 6 ++-- packages/scripts/src/utils/run.ts | 6 ++-- packages/scripts/src/utils/write.ts | 2 +- .../evm/src/helpers/isValidDomain.ts | 1 + 25 files changed, 63 insertions(+), 61 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 2be082cd7ad2..ab76f3c319c2 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -529,7 +529,7 @@ const moduleSystemRules = { 'import/no-duplicates': 'warn', // duplicate specifiers 'import/no-empty-named-blocks': 'warn', // bans import T, {} 'unused-imports/no-unused-imports': 'warn', - // 'unicorn/prefer-node-protocol': 'warn', + 'unicorn/prefer-node-protocol': 'warn', '@typescript-eslint/consistent-type-exports': ['warn', { fixMixedExportsWithInlineTypeSpecifier: true }], '@typescript-eslint/consistent-type-imports': [ 'warn', @@ -597,7 +597,6 @@ export default tseslint.config( '**/i18n_generated.ts', '**/languages.ts', 'packages/contracts', - 'packages/scripts', 'packages/mask/.webpack', ], }, diff --git a/packages/backup-format/tests/encryption.ts b/packages/backup-format/tests/encryption.ts index 424bc9d077ed..8805cf56c069 100644 --- a/packages/backup-format/tests/encryption.ts +++ b/packages/backup-format/tests/encryption.ts @@ -1,5 +1,5 @@ import { test, expect, beforeAll } from 'vitest' -import { webcrypto } from 'crypto' +import { webcrypto } from 'node:crypto' import { encryptBackup, decryptBackup } from '../src/index.js' beforeAll(() => { diff --git a/packages/scripts/src/cloudflare/index.ts b/packages/scripts/src/cloudflare/index.ts index f3c482e6a68d..aa580462f9ba 100644 --- a/packages/scripts/src/cloudflare/index.ts +++ b/packages/scripts/src/cloudflare/index.ts @@ -1,9 +1,9 @@ import { dest, parallel, series, src, type TaskFunction } from 'gulp' import { PKG_PATH, ROOT_PATH, task } from '../utils/index.ts' import { codegen } from '../codegen/index.ts' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' -const DIST_PATH = new URL('dist/cloudflare', ROOT_PATH) +const DIST_PATH = new URL('./dist/cloudflare', ROOT_PATH) function copyLocalesJSON() { return src('**/locale/*.json', { diff --git a/packages/scripts/src/codegen/icon-codegen.ts b/packages/scripts/src/codegen/icon-codegen.ts index bd5ef927b815..db23b3d36e97 100644 --- a/packages/scripts/src/codegen/icon-codegen.ts +++ b/packages/scripts/src/codegen/icon-codegen.ts @@ -1,16 +1,16 @@ -import { readFile, writeFile } from 'fs/promises' +import { readFile, writeFile } from 'node:fs/promises' import { watch } from 'gulp' import { camelCase, snakeCase, upperFirst } from 'lodash-es' -import { parse as parsePath } from 'path' +import { parse as parsePath } from 'node:path' import { PKG_PATH, ROOT_PATH, prettier, watchTask } from '../utils/index.ts' import type { Position } from 'source-map' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const pattern = 'packages/icons/**/*.@(svg|jpe?g|png)' -const iconRoot = new URL('icons/', PKG_PATH) -const CODE_FILE = fileURLToPath(new URL('icon-generated-as', iconRoot)) +const iconRoot = new URL('./icons/', PKG_PATH) +const CODE_FILE = fileURLToPath(new URL('./icon-generated-as', iconRoot)) -const dynamicColorRe = /(?:\w=('|")currentColor\1|var\(--icon-color)/ +const dynamicColorRe = /\w=('|")currentColor\1|var\(--icon-color/ const attr2KeyValue = (attr: string) => { const index = attr.indexOf(':') @@ -19,11 +19,11 @@ const attr2KeyValue = (attr: string) => { function svg2jsx(code: string) { return code .trim() - .replace(/(\w+-\w+)=('|").*?\2/g, (p: string, m1: string) => { + .replaceAll(/(\w+-\w+)=('|").*?\2/g, (p: string, m1: string) => { return p.replace(m1, camelCase(m1)) }) .replaceAll('xlink:href', 'xlinkHref') - .replace(/\bstyle=('|")(.+?)\1/g, (_p: string, _m1: string, style: string) => { + .replaceAll(/\bstyle=('|")(.+?)\1/g, (_p: string, _m1: string, style: string) => { const attributes = style .split(';') .map(attr2KeyValue) @@ -37,7 +37,7 @@ function getIntrinsicSize(data: string | Buffer): [number, number] | undefined { // from `viewBox="0 0 2124 660"`, we match `2124 / 660` out. const match = data.match(/viewBox="0 0 (\d+) (\d+)"/) if (match) { - return [parseFloat(match[1]), parseFloat(match[2])] + return [Number.parseFloat(match[1]), Number.parseFloat(match[2])] } } // TODO: support binary image. @@ -62,12 +62,12 @@ async function generateIcons() { const asJSX = { js: [ // - `import { __createIcon } from './utils/internal.js'`, + "import { __createIcon } from './utils/internal.js'", ], dts: [ // - `import type { GeneratedIconProps, GeneratedIconNonSquareProps } from './utils/internal.js'`, - `import type { ComponentType } from 'react'`, + "import type { GeneratedIconProps, GeneratedIconNonSquareProps } from './utils/internal.js'", + "import type { ComponentType } from 'react'", ], dtsMap: new SourceMapGenerator({ file: 'icon-generated-as-jsx.d.ts' }), } @@ -142,7 +142,7 @@ async function generateIcons() { .map((x) => x.args) .map(([variant, url, jsx, isColorful]) => { return ( - `{` + + "{" + [ variant.length === 0 ? null : `c: ${JSON.stringify(variant.sort())}`, variant.length === 0 && jsx ? null : `u: () => ${url}`, @@ -165,10 +165,10 @@ async function generateIcons() { const jsdoc = [] as string[] if (variant.some((x) => x.args[3])) jsdoc.push('🎨 This icon supports custom color.') - else jsdoc.push('🖼️ This icon brings its own colors.') + else jsdoc.push('🖼\uFE0F This icon brings its own colors.') - jsdoc.push(`| Variant | Link | Preview |`) - jsdoc.push(`| ------- | ---- | ------- |`) + jsdoc.push("| Variant | Link | Preview |") + jsdoc.push("| ------- | ---- | ------- |") for (const { args, assetPath } of variant) { jsdoc.push(`| ${args[0].join(', ') || 'default'} | ${createLink(assetPath)} | !${createLink(assetPath)} |`) } diff --git a/packages/scripts/src/commands/changeset-release.ts b/packages/scripts/src/commands/changeset-release.ts index f39ffcc8c2f4..b5ca7d35d1bb 100644 --- a/packages/scripts/src/commands/changeset-release.ts +++ b/packages/scripts/src/commands/changeset-release.ts @@ -14,7 +14,7 @@ const packages = [ ] export async function changesetRelease() { const tsc = awaitChildProcess(shell.cwd(ROOT_PATH)`npx tsc -b ./tsconfig.npm.json`) - const buildTask: Promise[] = packages.map((path) => + const buildTask: Array> = packages.map((path) => readFile(new URL('./package.json', path), 'utf-8') .then(JSON.parse) .then((json) => { diff --git a/packages/scripts/src/extension/ci.ts b/packages/scripts/src/extension/ci.ts index 3b2236c79f2e..95d470cf03ec 100644 --- a/packages/scripts/src/extension/ci.ts +++ b/packages/scripts/src/extension/ci.ts @@ -7,7 +7,7 @@ import { type BuildFlagsExtended } from './flags.ts' import { copyFile } from 'node:fs/promises' import { ManifestFile } from '../../../mask/.webpack/flags.ts' -const BUILD_PATH = new URL('build/', ROOT_PATH) +const BUILD_PATH = new URL('./build/', ROOT_PATH) export const ciBuild: TaskFunction = series( codegen, buildBaseExtension, @@ -31,9 +31,9 @@ function zipTo( reproducible?: boolean, ): TaskFunction { const f: TaskFunction = async () => { - await copyFile(new URL(`manifest-${withManifestFile}.json`, BUILD_PATH), new URL('manifest.json', BUILD_PATH)) + await copyFile(new URL(`manifest-${withManifestFile}.json`, BUILD_PATH), new URL('./manifest.json', BUILD_PATH)) if (!reproducible && withManifestFile === ManifestFile.ChromiumBetaMV3) { - await copyFile(new URL('build-info-beta.json', BUILD_PATH), new URL('build-info.json', BUILD_PATH)) + await copyFile(new URL('./build-info-beta.json', BUILD_PATH), new URL('./build-info.json', BUILD_PATH)) } const { cmd } = await import('web-ext') await cmd.build({ diff --git a/packages/scripts/src/extension/normal.ts b/packages/scripts/src/extension/normal.ts index 9849f1c5feec..fcfd9be2c738 100644 --- a/packages/scripts/src/extension/normal.ts +++ b/packages/scripts/src/extension/normal.ts @@ -61,7 +61,7 @@ function preTask() { watchMaskSDK() buildSentry() } -export async function extensionWatch(f: Function | BuildFlagsExtended) { +export async function extensionWatch(f: (() => void) | BuildFlagsExtended) { preTask() if (typeof f === 'function') { const flags: BuildFlags = { @@ -74,7 +74,7 @@ export async function extensionWatch(f: Function | BuildFlagsExtended) { } return webpack(false, f) } -export async function extensionWatchRspack(f: Function | BuildFlagsExtended) { +export async function extensionWatchRspack(f: (() => void) | BuildFlagsExtended) { preTask() if (typeof f === 'function') { const flags: BuildFlags = { @@ -128,6 +128,6 @@ async function webpack(rspack: boolean, flags: BuildFlagsExtended) { flags.mode === 'development' ? 'serve' : undefined, ...argv, ] - return awaitChildProcess(shell.cwd(new URL('mask', PKG_PATH))([compact(command).join(' ')])) + return awaitChildProcess(shell.cwd(new URL('./mask', PKG_PATH))([compact(command).join(' ')])) } } diff --git a/packages/scripts/src/linter/package-json.ts b/packages/scripts/src/linter/package-json.ts index 140a983ecd4e..a033e5ccba94 100644 --- a/packages/scripts/src/linter/package-json.ts +++ b/packages/scripts/src/linter/package-json.ts @@ -19,7 +19,7 @@ export async function lintPackageJson() { if (!('type' in json)) type.push(file) if ('lingui' in json) { - let template: any = { + const template: any = { compileNamespace: 'json', locales: ['en-US', 'ja-JP', 'ko-KR', 'zh-CN', 'zh-TW'], fallbackLocales: { diff --git a/packages/scripts/src/linter/po-files.ts b/packages/scripts/src/linter/po-files.ts index 24472bfba100..b313d67bdc7d 100644 --- a/packages/scripts/src/linter/po-files.ts +++ b/packages/scripts/src/linter/po-files.ts @@ -17,7 +17,7 @@ export async function cleanPo() { str .split('\n') .map((x) => x.replace(/^#.+/, '')) - .filter((x) => x) + .filter(Boolean) .join('\n'), ) }), diff --git a/packages/scripts/src/locale-kit-next/index.ts b/packages/scripts/src/locale-kit-next/index.ts index ca6e340ad8c0..31bf1ec7fefe 100644 --- a/packages/scripts/src/locale-kit-next/index.ts +++ b/packages/scripts/src/locale-kit-next/index.ts @@ -25,16 +25,16 @@ export async function syncLanguages() { for (const [language] of languages) { code += `import ${language.replace('-', '_')} from './${language}.json' with { type: 'json' }\n` } - code += `export const languages = {\n` + code += "export const languages = {\n" for (const [language, familyName] of languages) { code += ` '${familyName}': ${language.replace('-', '_')},\n` } - code += `}\n` + code += "}\n" // Non-plugin i18n files if (!poFile.includes('plugin')) { - const target = `@masknet/shared-base` + const target = "@masknet/shared-base" code += `import { createI18NBundle } from '${target}'\n` - code += `export const addI18N = createI18NBundle(languages as any)\n` + code += "export const addI18N = createI18NBundle(languages as any)\n" } { @@ -53,14 +53,14 @@ export async function syncLanguages() { )` } code = await prettier(code) - await writeFile(new URL('languages.ts', inputDir), code, { encoding: 'utf8' }) + await writeFile(new URL('./languages.ts', inputDir), code, { encoding: 'utf8' }) } } { const map: Record = {} const code = await prettier(`${basicHeader}\nexport default ${JSON.stringify(map)}`) - await writeFile(new URL('packages/mask/background/services/helper/i18n-cache-query-list.ts', ROOT_PATH), code, { + await writeFile(new URL('./packages/mask/background/services/helper/i18n-cache-query-list.ts', ROOT_PATH), code, { encoding: 'utf8', }) } diff --git a/packages/scripts/src/projects/build-contracts.ts b/packages/scripts/src/projects/build-contracts.ts index 6ae203e53cf6..09572f025c55 100644 --- a/packages/scripts/src/projects/build-contracts.ts +++ b/packages/scripts/src/projects/build-contracts.ts @@ -1,5 +1,5 @@ -import { promises as fs } from 'fs' -import { join } from 'path' +import { promises as fs } from 'node:fs' +import { join } from 'node:path' import { task } from '../utils/task.ts' import { awaitChildProcess } from '../utils/awaitChildProcess.ts' import { shell } from '../utils/run.ts' diff --git a/packages/scripts/src/projects/gun.ts b/packages/scripts/src/projects/gun.ts index 026c151c7358..f04d9f2f13a8 100644 --- a/packages/scripts/src/projects/gun.ts +++ b/packages/scripts/src/projects/gun.ts @@ -1,7 +1,7 @@ import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildGun] = fromNPMTask( // - new URL('gun-utils/', PKG_PATH), + new URL('./gun-utils/', PKG_PATH), 'gun', 'Build gun required for Mask Network.', ) diff --git a/packages/scripts/src/projects/injected-scripts.ts b/packages/scripts/src/projects/injected-scripts.ts index fe1df89c547d..3fece72c2dde 100644 --- a/packages/scripts/src/projects/injected-scripts.ts +++ b/packages/scripts/src/projects/injected-scripts.ts @@ -1,6 +1,6 @@ import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildInjectedScript, watchInjectedScript] = fromNPMTask( - new URL('injected-script/', PKG_PATH), + new URL('./injected-script/', PKG_PATH), 'injected-script', 'An extra script that runs in the main frame to provide some extra functionality of Mask Network.', ) diff --git a/packages/scripts/src/projects/mask-sdk.ts b/packages/scripts/src/projects/mask-sdk.ts index 556152e2b8a2..235c281ae93a 100644 --- a/packages/scripts/src/projects/mask-sdk.ts +++ b/packages/scripts/src/projects/mask-sdk.ts @@ -1,7 +1,7 @@ import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildMaskSDK, watchMaskSDK] = fromNPMTask( // - new URL('mask-sdk/', PKG_PATH), + new URL('./mask-sdk/', PKG_PATH), 'mask-sdk', 'Build Mask SDK.', ) diff --git a/packages/scripts/src/projects/polyfill.ts b/packages/scripts/src/projects/polyfill.ts index ec7b176c253c..b1ea9d9fa104 100644 --- a/packages/scripts/src/projects/polyfill.ts +++ b/packages/scripts/src/projects/polyfill.ts @@ -1,6 +1,6 @@ import { fromNPMTask, PKG_PATH } from '../utils/index.ts' export const [buildPolyfill] = fromNPMTask( - new URL('polyfills/', PKG_PATH), + new URL('./polyfills/', PKG_PATH), 'polyfill', 'Build polyfill required for Mask Network.', ) diff --git a/packages/scripts/src/projects/sandboxed-plugins.ts b/packages/scripts/src/projects/sandboxed-plugins.ts index 46faaa6c0c67..76eff8d2cb28 100644 --- a/packages/scripts/src/projects/sandboxed-plugins.ts +++ b/packages/scripts/src/projects/sandboxed-plugins.ts @@ -107,17 +107,17 @@ export async function buildSandboxedPluginConfigurable(distPath: string, isProdu const writeInternalList = writeFile(join(distPath, './plugins.json'), JSON.stringify(internalList, null, 4)) await Promise.all([tasks, writeInternalList]) await writeFile( - join(distPath, './mv3-preload.ts'), + join(distPath, './mv3-preload.js'), mv3PreloadList.size ? (function* () { - yield `importScripts(\n` + yield "importScripts(\n" for (const file of mv3PreloadList) { if (file.includes('\\') || file.includes('"')) throw new TypeError('Invalid path') yield ' "/sandboxed-modules/' yield file yield '", \n' } - yield `)\nnull` + yield ")\nnull" })() : 'null', { encoding: 'utf-8' }, @@ -155,7 +155,7 @@ function createBuilder({ id, manifestRoot, distPath, onJS, origin }: BuilderOpti return compile } function removeMJSSuffix(name: string) { - if (name.endsWith('.mjs')) return name.slice(0, -4) + '.ts' + if (name.endsWith('.mjs')) return name.slice(0, -4) + '.js' return name } @@ -199,7 +199,7 @@ async function getLocales(manifest: any, manifestPath: string): Promise x.isFile()).map((x) => x.name)) return [...languageFamily].map( @@ -223,10 +223,10 @@ class TransformStream extends Transform { encoding: BufferEncoding, callback: TransformCallback, ): void { - if (!(file.path.endsWith('.ts') || file.path.endsWith('.mjs'))) { + if (!(file.path.endsWith('.js') || file.path.endsWith('.mjs'))) { return callback(null, file) } - const relative = file.relative.replace(/\\/g, '/') + const relative = file.relative.replaceAll('\\', '/') this.onJS(this.origin, file.relative) const sandboxedPath = 'mask-modules://' + this.origin + '/' + relative const options = { diff --git a/packages/scripts/src/projects/sentry.ts b/packages/scripts/src/projects/sentry.ts index 03cf0608993a..e46f125a81f5 100644 --- a/packages/scripts/src/projects/sentry.ts +++ b/packages/scripts/src/projects/sentry.ts @@ -1,3 +1,3 @@ import { fromNPMTask, PKG_PATH } from '../utils/index.ts' -export const [buildSentry] = fromNPMTask(new URL('sentry/', PKG_PATH), 'build-sentry', 'Build sentry.') +export const [buildSentry] = fromNPMTask(new URL('./sentry/', PKG_PATH), 'build-sentry', 'Build sentry.') diff --git a/packages/scripts/src/spellcheck/index.ts b/packages/scripts/src/spellcheck/index.ts index e3913d799d5a..a99b1b409cbc 100644 --- a/packages/scripts/src/spellcheck/index.ts +++ b/packages/scripts/src/spellcheck/index.ts @@ -1,7 +1,7 @@ -import { readFile, writeFile } from 'fs/promises' +import { readFile, writeFile } from 'node:fs/promises' import { prettier, ROOT_PATH, task } from '../utils/index.ts' -const CONFIGURE_PATH = new URL('cspell.json', ROOT_PATH) +const CONFIGURE_PATH = new URL('./cspell.json', ROOT_PATH) interface RootConfigure extends Configure { overrides?: Configure[] diff --git a/packages/scripts/src/utils/awaitChildProcess.ts b/packages/scripts/src/utils/awaitChildProcess.ts index 9a982f599f76..069e96a71e5d 100644 --- a/packages/scripts/src/utils/awaitChildProcess.ts +++ b/packages/scripts/src/utils/awaitChildProcess.ts @@ -1,4 +1,4 @@ -import type { ChildProcess } from 'child_process' +import type { ChildProcess } from 'node:child_process' export function awaitChildProcess(child: ChildProcess) { return new Promise((resolve, reject) => { diff --git a/packages/scripts/src/utils/exit.ts b/packages/scripts/src/utils/exit.ts index 9ab6358dfb4b..5f9e145bf2ae 100644 --- a/packages/scripts/src/utils/exit.ts +++ b/packages/scripts/src/utils/exit.ts @@ -1,4 +1,4 @@ -import type { ChildProcess } from 'child_process' +import type { ChildProcess } from 'node:child_process' import { series, type TaskFunction } from 'gulp' const childProcess: ChildProcess[] = [] diff --git a/packages/scripts/src/utils/paths.ts b/packages/scripts/src/utils/paths.ts index 90f7370cfd8b..bcefa077e6da 100644 --- a/packages/scripts/src/utils/paths.ts +++ b/packages/scripts/src/utils/paths.ts @@ -1,2 +1,2 @@ export const ROOT_PATH = new URL('../../../../', import.meta.url) -export const PKG_PATH = new URL('packages/', ROOT_PATH) +export const PKG_PATH = new URL('./packages/', ROOT_PATH) diff --git a/packages/scripts/src/utils/process-lock.ts b/packages/scripts/src/utils/process-lock.ts index efd8cb165f31..fb632abd1933 100644 --- a/packages/scripts/src/utils/process-lock.ts +++ b/packages/scripts/src/utils/process-lock.ts @@ -1,12 +1,14 @@ // TODO: load this lazy import Lock from 'proper-lockfile' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' export async function getProcessLock(lockName: string) { const lockfilePath = getLockPosition(lockName) while (true) { if (isLocked(lockName)) { - await new Promise((resolve) => setTimeout(resolve, 500)) + await new Promise((resolve) => { + setTimeout(resolve, 500) + }) } else { try { Lock.lockSync(import.meta.filename, { lockfilePath, update: 200 }) diff --git a/packages/scripts/src/utils/run.ts b/packages/scripts/src/utils/run.ts index caa5d08cdf83..3daf81dd2fec 100644 --- a/packages/scripts/src/utils/run.ts +++ b/packages/scripts/src/utils/run.ts @@ -1,8 +1,8 @@ -import { spawn } from 'child_process' +import { spawn } from 'node:child_process' import { ROOT_PATH } from './paths.ts' -import { relative } from 'path' +import { relative } from 'node:path' import chalk from 'chalk' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' import { markChildProcess } from './exit.ts' function logShell(e: string, args: string[], url: URL | string) { diff --git a/packages/scripts/src/utils/write.ts b/packages/scripts/src/utils/write.ts index 79b7b4ffe603..5f9fd138e5dc 100644 --- a/packages/scripts/src/utils/write.ts +++ b/packages/scripts/src/utils/write.ts @@ -1,4 +1,4 @@ -import { readFile, writeFile } from 'fs/promises' +import { readFile, writeFile } from 'node:fs/promises' import { prettier } from './prettier.ts' export async function changeFile(path: string | URL, f: (x: string) => string | Promise) { diff --git a/packages/web3-shared/evm/src/helpers/isValidDomain.ts b/packages/web3-shared/evm/src/helpers/isValidDomain.ts index 2cd11f0ee19c..c9223a326e93 100644 --- a/packages/web3-shared/evm/src/helpers/isValidDomain.ts +++ b/packages/web3-shared/evm/src/helpers/isValidDomain.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line unicorn/prefer-node-protocol import punycode from 'punycode' // cspell:ignore binanceus klever kresus taiko From a60a372d96373bae07800e2b5b16acaa0319f30c Mon Sep 17 00:00:00 2001 From: Jack-Works Date: Tue, 8 Apr 2025 17:45:28 +0000 Subject: [PATCH 3/3] fix: prettier --- packages/scripts/src/codegen/icon-codegen.ts | 6 +++--- packages/scripts/src/locale-kit-next/index.ts | 18 +++++++++++------- .../scripts/src/projects/sandboxed-plugins.ts | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/scripts/src/codegen/icon-codegen.ts b/packages/scripts/src/codegen/icon-codegen.ts index db23b3d36e97..722024169231 100644 --- a/packages/scripts/src/codegen/icon-codegen.ts +++ b/packages/scripts/src/codegen/icon-codegen.ts @@ -142,7 +142,7 @@ async function generateIcons() { .map((x) => x.args) .map(([variant, url, jsx, isColorful]) => { return ( - "{" + + '{' + [ variant.length === 0 ? null : `c: ${JSON.stringify(variant.sort())}`, variant.length === 0 && jsx ? null : `u: () => ${url}`, @@ -167,8 +167,8 @@ async function generateIcons() { if (variant.some((x) => x.args[3])) jsdoc.push('🎨 This icon supports custom color.') else jsdoc.push('🖼\uFE0F This icon brings its own colors.') - jsdoc.push("| Variant | Link | Preview |") - jsdoc.push("| ------- | ---- | ------- |") + jsdoc.push('| Variant | Link | Preview |') + jsdoc.push('| ------- | ---- | ------- |') for (const { args, assetPath } of variant) { jsdoc.push(`| ${args[0].join(', ') || 'default'} | ${createLink(assetPath)} | !${createLink(assetPath)} |`) } diff --git a/packages/scripts/src/locale-kit-next/index.ts b/packages/scripts/src/locale-kit-next/index.ts index 31bf1ec7fefe..70402353ddfc 100644 --- a/packages/scripts/src/locale-kit-next/index.ts +++ b/packages/scripts/src/locale-kit-next/index.ts @@ -25,16 +25,16 @@ export async function syncLanguages() { for (const [language] of languages) { code += `import ${language.replace('-', '_')} from './${language}.json' with { type: 'json' }\n` } - code += "export const languages = {\n" + code += 'export const languages = {\n' for (const [language, familyName] of languages) { code += ` '${familyName}': ${language.replace('-', '_')},\n` } - code += "}\n" + code += '}\n' // Non-plugin i18n files if (!poFile.includes('plugin')) { - const target = "@masknet/shared-base" + const target = '@masknet/shared-base' code += `import { createI18NBundle } from '${target}'\n` - code += "export const addI18N = createI18NBundle(languages as any)\n" + code += 'export const addI18N = createI18NBundle(languages as any)\n' } { @@ -60,9 +60,13 @@ export async function syncLanguages() { { const map: Record = {} const code = await prettier(`${basicHeader}\nexport default ${JSON.stringify(map)}`) - await writeFile(new URL('./packages/mask/background/services/helper/i18n-cache-query-list.ts', ROOT_PATH), code, { - encoding: 'utf8', - }) + await writeFile( + new URL('./packages/mask/background/services/helper/i18n-cache-query-list.ts', ROOT_PATH), + code, + { + encoding: 'utf8', + }, + ) } } task( diff --git a/packages/scripts/src/projects/sandboxed-plugins.ts b/packages/scripts/src/projects/sandboxed-plugins.ts index 76eff8d2cb28..e12326f52ed9 100644 --- a/packages/scripts/src/projects/sandboxed-plugins.ts +++ b/packages/scripts/src/projects/sandboxed-plugins.ts @@ -110,14 +110,14 @@ export async function buildSandboxedPluginConfigurable(distPath: string, isProdu join(distPath, './mv3-preload.js'), mv3PreloadList.size ? (function* () { - yield "importScripts(\n" + yield 'importScripts(\n' for (const file of mv3PreloadList) { if (file.includes('\\') || file.includes('"')) throw new TypeError('Invalid path') yield ' "/sandboxed-modules/' yield file yield '", \n' } - yield ")\nnull" + yield ')\nnull' })() : 'null', { encoding: 'utf-8' }, @@ -199,7 +199,7 @@ async function getLocales(manifest: any, manifestPath: string): Promise x.isFile()).map((x) => x.name)) return [...languageFamily].map(