@bemedev/dev-utils 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -0
- package/lib/_virtual/_rolldown/runtime.cjs +1 -1
- package/lib/build-tests/addTarball.cjs +5 -1
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +3 -0
- package/lib/build-tests/addTarball.js +5 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs +17 -9
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +5 -0
- package/lib/build-tests/buildPackageJson.js +17 -9
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs +3 -0
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +3 -0
- package/lib/build-tests/cleanup.js +3 -0
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +6 -0
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +6 -0
- package/lib/build-tests/cli/cli.js +6 -0
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/post.cjs +3 -0
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +3 -0
- package/lib/build-tests/cli/post.js +3 -0
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +3 -0
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +3 -0
- package/lib/build-tests/cli/pre.js +3 -0
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs +3 -0
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +3 -0
- package/lib/build-tests/cli/test.js +3 -0
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs +42 -0
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +42 -0
- package/lib/build-tests/constants.js +42 -0
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +7 -0
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +7 -0
- package/lib/build-tests/getRelativePath.js +7 -0
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
- package/lib/build-tests/getTypescriptOutdir.js +5 -0
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs +9 -0
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +9 -0
- package/lib/build-tests/import.js +9 -0
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +7 -0
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +13 -0
- package/lib/build-tests/imports/create.js +7 -0
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +9 -0
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +12 -0
- package/lib/build-tests/imports/helper.js +9 -0
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/pack.cjs +7 -1
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +5 -0
- package/lib/build-tests/pack.js +7 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/plugins/hmr.cjs +72 -0
- package/lib/plugins/hmr.cjs.map +1 -0
- package/lib/plugins/hmr.d.ts +22 -0
- package/lib/plugins/hmr.js +71 -0
- package/lib/plugins/hmr.js.map +1 -0
- package/lib/plugins/index.cjs +5 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -0
- package/lib/plugins/suppressWarnings.cjs +37 -0
- package/lib/plugins/suppressWarnings.cjs.map +1 -0
- package/lib/plugins/suppressWarnings.d.ts +12 -0
- package/lib/plugins/suppressWarnings.js +36 -0
- package/lib/plugins/suppressWarnings.js.map +1 -0
- package/lib/rolldown-config/config.cjs +13 -5
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +7 -0
- package/lib/rolldown-config/config.js +13 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs +15 -0
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +15 -0
- package/lib/rolldown-config/constants.js +15 -0
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +16 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +14 -0
- package/lib/rolldown-config/helpers.js +16 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/input.cjs +8 -0
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +8 -0
- package/lib/rolldown-config/input.js +8 -0
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs +8 -0
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +8 -0
- package/lib/rolldown-config/output.js +8 -0
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +5 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +10 -6
- package/lib/rolldown-config/plugins/circulars.js +5 -5
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +10 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +10 -0
- package/lib/rolldown-config/plugins/clean.js +10 -1
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +4 -3
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -3
- package/lib/rolldown-config/plugins/externals.js +4 -3
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +6 -0
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +6 -0
- package/lib/rolldown-config/plugins/index.js +6 -0
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +7 -0
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.js +7 -0
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +18 -0
- package/lib/utils/array.cjs +7 -0
- package/lib/utils/array.cjs.map +1 -1
- package/lib/utils/array.d.ts +8 -0
- package/lib/utils/array.js +7 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bemedev/globals/types.d.ts +20 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
- package/lib/utils/clamp.cjs +18 -0
- package/lib/utils/clamp.cjs.map +1 -0
- package/lib/utils/clamp.d.ts +10 -0
- package/lib/utils/clamp.js +17 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/identity.cjs +9 -0
- package/lib/utils/identity.cjs.map +1 -1
- package/lib/utils/identity.d.ts +9 -0
- package/lib/utils/identity.js +9 -0
- package/lib/utils/identity.js.map +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs +7 -0
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +7 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +17 -1
- package/lib/vitest-exclude/constants.cjs +3 -0
- package/lib/vitest-exclude/constants.cjs.map +1 -1
- package/lib/vitest-exclude/constants.d.ts +3 -0
- package/lib/vitest-exclude/constants.js +3 -0
- package/lib/vitest-exclude/constants.js.map +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -0
- package/lib/vitest-exclude/vitest.cjs +25 -12
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +9 -8
- package/lib/vitest-exclude/vitest.js +25 -12
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +30 -0
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
- package/lib/vitest-exclude/vitest.utils.js +30 -0
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +11 -2
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +9 -1
- package/lib/vitest-extended/acceptation.js +11 -2
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +34 -27
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +20 -37
- package/lib/vitest-extended/createTests.js +34 -27
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +13 -2
- package/lib/vitest-extended/done.cjs +18 -15
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +6 -5
- package/lib/vitest-extended/done.js +18 -15
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +12 -0
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +12 -0
- package/lib/vitest-extended/each/error.js +12 -0
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +17 -0
- package/lib/vitest-extended/each/pass.cjs +9 -20
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +9 -20
- package/lib/vitest-extended/each/pass.js +9 -20
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +24 -0
- package/lib/vitest-extended/fakeWaiter.cjs +7 -0
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
- package/lib/vitest-extended/fakeWaiter.js +7 -0
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js +11 -0
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +9 -4
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js +18 -0
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
- package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.js +3 -0
- package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs +22 -0
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js +22 -0
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +18 -0
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +18 -0
- package/lib/vitest-extended/identity.js +18 -0
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/isDefined.cjs +9 -0
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +9 -0
- package/lib/vitest-extended/isDefined.js +9 -0
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs +7 -0
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +7 -0
- package/lib/vitest-extended/isFunction.js +7 -0
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/project.cjs +7 -0
- package/lib/vitest-extended/project.cjs.map +1 -1
- package/lib/vitest-extended/project.d.ts +7 -0
- package/lib/vitest-extended/project.js +7 -0
- package/lib/vitest-extended/project.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs +6 -0
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +6 -0
- package/lib/vitest-extended/toArray.js +6 -0
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs +8 -0
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +8 -0
- package/lib/vitest-extended/toStringFlat.js +8 -0
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +64 -0
- package/package.json +14 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.cjs","names":["existsSync","ts","path"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,
|
|
1
|
+
{"version":3,"file":"typescript.config.cjs","names":["readFileSync","readdirSync","join","statSync","existsSync","ts","path","dirname"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,GAAOA,GAAAA,aAAAA,CAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,WAAA,GAAUC,GAAAA,YAAAA,CAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAWC,KAAAA,KAAAA,CAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,QAAA,GAAOC,GAAAA,SAAAA,CAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYC,GAAAA;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAeC,wBAAAA,QAAG,eACtB,YACAD,GAAAA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,wBAAAA,QAAG,eAAeC,QAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACRD,wBAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqBA,wBAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GACAE,KAAAA,QAAAA,CAAQD,MAAI,CAGI;AACpB"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import ts from '@typescript/typescript6';
|
|
2
|
+
/**
|
|
3
|
+
* Loads and parses the closest `tsconfig.json` from the search path.
|
|
4
|
+
*
|
|
5
|
+
* @param searchPath - Directory path from which to locate the tsconfig.
|
|
6
|
+
* @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.
|
|
7
|
+
*
|
|
8
|
+
* @returns Parsed TypeScript configuration object.
|
|
9
|
+
*/
|
|
2
10
|
export declare function getConfig(searchPath: string, configName?: string): ts.ParsedCommandLine;
|
|
11
|
+
/**
|
|
12
|
+
* Reads and parses the specified `tsconfig.json` file path.
|
|
13
|
+
*
|
|
14
|
+
* @param path - Absolute or relative path to the tsconfig file.
|
|
15
|
+
*
|
|
16
|
+
* @returns Parsed TypeScript configuration object.
|
|
17
|
+
*/
|
|
3
18
|
export declare const readTsConfig: (path: string) => ts.ParsedCommandLine;
|
|
@@ -40,10 +40,25 @@ const _host = {
|
|
|
40
40
|
fileExists: existsSync,
|
|
41
41
|
readFile: _readFile
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Loads and parses the closest `tsconfig.json` from the search path.
|
|
45
|
+
*
|
|
46
|
+
* @param searchPath - Directory path from which to locate the tsconfig.
|
|
47
|
+
* @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.
|
|
48
|
+
*
|
|
49
|
+
* @returns Parsed TypeScript configuration object.
|
|
50
|
+
*/
|
|
43
51
|
function getConfig(searchPath, configName = "tsconfig.json") {
|
|
44
52
|
const tsconfigPath = ts.findConfigFile(searchPath, existsSync, configName);
|
|
45
53
|
return readTsConfig(tsconfigPath);
|
|
46
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads and parses the specified `tsconfig.json` file path.
|
|
57
|
+
*
|
|
58
|
+
* @param path - Absolute or relative path to the tsconfig file.
|
|
59
|
+
*
|
|
60
|
+
* @returns Parsed TypeScript configuration object.
|
|
61
|
+
*/
|
|
47
62
|
const readTsConfig = (path) => {
|
|
48
63
|
const configFile = ts.readConfigFile(path, _readFile);
|
|
49
64
|
if (configFile.error) throw new Error(ts.formatDiagnostic(configFile.error, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;AACZ
|
|
1
|
+
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAe,GAAG,eACtB,YACA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,IAAI,CAGI;AACpB"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { RolldownPluginOption } from 'rolldown';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the TypeScript DTS generation plugin.
|
|
4
|
+
*/
|
|
2
5
|
type Props = {
|
|
3
6
|
exclude?: string | string[];
|
|
4
7
|
include?: Record<string, string>;
|
|
5
8
|
declarationMap?: boolean;
|
|
6
9
|
dir?: string;
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).
|
|
13
|
+
*
|
|
14
|
+
* @param props - Configuration options.
|
|
15
|
+
*
|
|
16
|
+
* @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
|
|
17
|
+
*/
|
|
8
18
|
export declare const typescript: ({ exclude, include, declarationMap, dir, }?: Props) => RolldownPluginOption;
|
|
9
19
|
export {};
|
|
@@ -11,6 +11,13 @@ _typescript_typescript6 = require_runtime.__toESM(_typescript_typescript6, 1);
|
|
|
11
11
|
let tsc_alias = require("tsc-alias");
|
|
12
12
|
let oxc_transform = require("oxc-transform");
|
|
13
13
|
//#region src/rolldown-config/plugins/typescript.fast.ts
|
|
14
|
+
/**
|
|
15
|
+
* Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
|
|
16
|
+
*
|
|
17
|
+
* @param props - Configuration options.
|
|
18
|
+
*
|
|
19
|
+
* @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
|
|
20
|
+
*/
|
|
14
21
|
const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
15
22
|
let done = false;
|
|
16
23
|
return {
|
|
@@ -34,7 +41,8 @@ const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
34
41
|
files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
|
|
35
42
|
const errors = [];
|
|
36
43
|
for (const file of files) try {
|
|
37
|
-
const
|
|
44
|
+
const content = (0, fs.readFileSync)(file, "utf-8");
|
|
45
|
+
const result = (0, oxc_transform.transformSync)(file, content, {
|
|
38
46
|
sourcemap: !!declarationMap,
|
|
39
47
|
typescript: { declaration: { sourcemap: !!declarationMap } }
|
|
40
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig","join","globSync","readFileSync","transformSync","relative","dirname","basename","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAA,oBAAAA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAeC,wBAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,eACF;IAEA,MAAM,aAAaC,kDAAAA,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,YAAA,GAAWC,KAAAA,KAAAA,CAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,SAAA,GAAQC,KAAAA,SAAAA,EAAAA,GAASD,KAAAA,KAAAA,CAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQJ,oBAAAA,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KACF,MAAM,WAAA,GAAUM,GAAAA,aAAAA,CAAa,MAAM,OAAO;KAC1C,MAAM,UAAA,GAASC,cAAAA,cAAAA,CAAc,MAAM,SAAS;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,gBAAA,GAAeC,KAAAA,SAAAA,CAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,WAAA,GAAUJ,KAAAA,KAAAA,CAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,CAAA,GAAA,GAAA,UAAA,EAAA,GAAUK,KAAAA,QAAAA,CAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,2BAAA,GAA0BC,KAAAA,SAAAA,CAAS,OAAO,EAAE;MACvD,CAAA,GAAA,GAAA,cAAA,CACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,CAAA,GAAA,GAAA,cAAA,CAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,OAAA,GAAMC,UAAAA,qBAAAA,CAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { RolldownPluginOption } from 'rolldown';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the fast TypeScript DTS generation plugin.
|
|
4
|
+
*/
|
|
2
5
|
type Props = {
|
|
3
6
|
exclude?: string | string[];
|
|
4
7
|
include?: Record<string, string>;
|
|
5
8
|
declarationMap?: boolean;
|
|
6
9
|
dir?: string;
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
|
|
13
|
+
*
|
|
14
|
+
* @param props - Configuration options.
|
|
15
|
+
*
|
|
16
|
+
* @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
|
|
17
|
+
*/
|
|
8
18
|
export declare const typescriptFast: ({ exclude, include, declarationMap, dir, }?: Props) => RolldownPluginOption;
|
|
9
19
|
export {};
|
|
@@ -8,6 +8,13 @@ import ts from "@typescript/typescript6";
|
|
|
8
8
|
import { replaceTscAliasPaths } from "tsc-alias";
|
|
9
9
|
import { transformSync } from "oxc-transform";
|
|
10
10
|
//#region src/rolldown-config/plugins/typescript.fast.ts
|
|
11
|
+
/**
|
|
12
|
+
* Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
|
|
13
|
+
*
|
|
14
|
+
* @param props - Configuration options.
|
|
15
|
+
*
|
|
16
|
+
* @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
|
|
17
|
+
*/
|
|
11
18
|
const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
12
19
|
let done = false;
|
|
13
20
|
return {
|
|
@@ -31,7 +38,8 @@ const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
31
38
|
files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
|
|
32
39
|
const errors = [];
|
|
33
40
|
for (const file of files) try {
|
|
34
|
-
const
|
|
41
|
+
const content = readFileSync(file, "utf-8");
|
|
42
|
+
const result = transformSync(file, content, {
|
|
35
43
|
sourcemap: !!declarationMap,
|
|
36
44
|
typescript: { declaration: { sourcemap: !!declarationMap } }
|
|
37
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,eACF;IAEA,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,WAAW,KAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,QAAQ,SAAS,KAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQ,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KACF,MAAM,UAAU,aAAa,MAAM,OAAO;KAC1C,MAAM,SAAS,cAAc,MAAM,SAAS;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,eAAe,SAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,UAAU,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,0BAA0B,SAAS,OAAO,EAAE;MACvD,cACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,cAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -5,6 +5,13 @@ import { existsSync } from "fs";
|
|
|
5
5
|
import ts from "@typescript/typescript6";
|
|
6
6
|
import { replaceTscAliasPaths } from "tsc-alias";
|
|
7
7
|
//#region src/rolldown-config/plugins/typescript.ts
|
|
8
|
+
/**
|
|
9
|
+
* Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).
|
|
10
|
+
*
|
|
11
|
+
* @param props - Configuration options.
|
|
12
|
+
*
|
|
13
|
+
* @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
|
|
14
|
+
*/
|
|
8
15
|
const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
9
16
|
let done = false;
|
|
10
17
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(\n ts.formatDiagnosticsWithColorAndContext(errors, host),\n );\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(\n ts.formatDiagnosticsWithColorAndContext(errors, host),\n );\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,eACF;IAEA,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,OAAO,GAAG,mBAAmB,WAAW,OAAO;IACrD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAAS,GAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAG,QAAQ,OAAO,GAAG,MAAM;KACrC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;KACF;IACF,GACA,GAAG,KACH,GACF;IAEA,MAAM,UAAU,GAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;IACF,GACA,IACF;IAEA,MAAM,aAAa,QAAQ,KAAK;IAEhC,MAAM,SAAS,GACZ,sBAAsB,OAAO,CAAC,CAC9B,OAAO,WAAW,WAAW,CAAC,CAC9B,QAAO,MAAK,EAAE,aAAa,GAAG,mBAAmB,KAAK;IAEzD,IAAI,OAAO,SAAS,GAClB,QAAQ,MACN,GAAG,qCAAqC,QAAQ,IAAI,CACtD;IAGF,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import type { RolldownPluginOption, RolldownOptions } from 'rolldown';
|
|
2
2
|
export type { RolldownOptions };
|
|
3
3
|
import type { PLUGIN_BUILDERS } from './plugins';
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes a single value, array, null, or undefined into an array.
|
|
6
|
+
*
|
|
7
|
+
* @template `T` - Item type.
|
|
8
|
+
*
|
|
9
|
+
* @param value - Optional single value or array.
|
|
10
|
+
*
|
|
11
|
+
* @returns Array containing the value(s).
|
|
12
|
+
*/
|
|
4
13
|
export type ToArray_F = <T>(value?: T | T[]) => T[];
|
|
14
|
+
/**
|
|
15
|
+
* Configuration parameters for Rolldown bundle generation.
|
|
16
|
+
*/
|
|
5
17
|
export type Params = {
|
|
6
18
|
circularDeps?: string | string[];
|
|
7
19
|
excludesTS?: string | string[];
|
|
@@ -12,7 +24,13 @@ export type Params = {
|
|
|
12
24
|
declarationMap?: boolean;
|
|
13
25
|
plugins?: (RolldownPluginOption | keyof typeof PLUGIN_BUILDERS)[];
|
|
14
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Function type building the input entry points record from glob patterns.
|
|
29
|
+
*/
|
|
15
30
|
export type BuildInput_F = (...ignores: string[]) => Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Rolldown configuration generator with predefined presets (`bemedev`, `fast`, `default`).
|
|
33
|
+
*/
|
|
16
34
|
export type Config_F = {
|
|
17
35
|
(additionals?: Params): RolldownOptions;
|
|
18
36
|
bemedev: (additionals?: Params) => RolldownOptions;
|
package/lib/utils/array.cjs
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils/array.ts
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a single value, array, null, or undefined into an array.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Value to normalize.
|
|
7
|
+
*
|
|
8
|
+
* @returns Array containing the value, or empty array if null/undefined.
|
|
9
|
+
*/
|
|
3
10
|
const toArray = (value) => {
|
|
4
11
|
if (value === void 0 || value === null) return [];
|
|
5
12
|
if (Array.isArray(value)) return value;
|
package/lib/utils/array.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.cjs","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.cjs","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\n/**\n * Normalizes a single value, array, null, or undefined into an array.\n *\n * @param value - Value to normalize.\n *\n * @returns Array containing the value, or empty array if null/undefined.\n */\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value] as any;\n};\n\nexport { type ToArray_F };\n"],"mappings":";;;;;;;;;AASA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,CAAC;CACpB,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CAEjC,OAAO,CAAC,KAAK;AACf"}
|
package/lib/utils/array.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { ToArray_F } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a single value, array, null, or undefined into an array.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to normalize.
|
|
6
|
+
*
|
|
7
|
+
* @returns Array containing the value, or empty array if null/undefined.
|
|
8
|
+
*/
|
|
2
9
|
export declare const toArray: ToArray_F;
|
|
10
|
+
export { type ToArray_F };
|
package/lib/utils/array.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
//#region src/utils/array.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a single value, array, null, or undefined into an array.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to normalize.
|
|
6
|
+
*
|
|
7
|
+
* @returns Array containing the value, or empty array if null/undefined.
|
|
8
|
+
*/
|
|
2
9
|
const toArray = (value) => {
|
|
3
10
|
if (value === void 0 || value === null) return [];
|
|
4
11
|
if (Array.isArray(value)) return value;
|
package/lib/utils/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.js","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\n/**\n * Normalizes a single value, array, null, or undefined into an array.\n *\n * @param value - Value to normalize.\n *\n * @returns Array containing the value, or empty array if null/undefined.\n */\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value] as any;\n};\n\nexport { type ToArray_F };\n"],"mappings":";;;;;;;;AASA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,CAAC;CACpB,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CAEjC,OAAO,CAAC,KAAK;AACf"}
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic function type signature.
|
|
3
|
+
*
|
|
4
|
+
* @template | {@linkcode any[]} `Args` - Function arguments tuple type.
|
|
5
|
+
* @template `R` - Return type.
|
|
6
|
+
*/
|
|
1
7
|
export type Fn<Args extends any[] = any[], R = any> = (...args: Args) => R;
|
|
8
|
+
/**
|
|
9
|
+
* Composite function type combined with additional properties.
|
|
10
|
+
*
|
|
11
|
+
* @template | {@linkcode Fn} `Main` - Base function type.
|
|
12
|
+
* @template | {@linkcode object} `Tr` - Extension properties object type.
|
|
13
|
+
*/
|
|
2
14
|
export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
|
|
15
|
+
/**
|
|
16
|
+
* Readonly unknown array alias.
|
|
17
|
+
*/
|
|
3
18
|
export type RuA = readonly unknown[];
|
|
19
|
+
/**
|
|
20
|
+
* Nullable or undefinable type wrapper.
|
|
21
|
+
*
|
|
22
|
+
* @template `T` - Inner type.
|
|
23
|
+
*/
|
|
4
24
|
export type Undefiny<T> = T | undefined | null;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils/bemedev/globals/utils/expandFn.ts
|
|
3
|
+
/**
|
|
4
|
+
* Augments a function with additional object properties.
|
|
5
|
+
*
|
|
6
|
+
* @template | {@linkcode Fn} `Main` - Base function type.
|
|
7
|
+
* @template | {@linkcode object} `Tr` - Extension properties shape.
|
|
8
|
+
*
|
|
9
|
+
* @param main - Base function to extend of type {@linkcode Fn}.
|
|
10
|
+
* @param extensions - Optional extension properties object.
|
|
11
|
+
*
|
|
12
|
+
* @returns Extended function of type {@linkcode FnBasic}.
|
|
13
|
+
*/
|
|
3
14
|
const expandFn = (main, extensions) => {
|
|
4
15
|
const out = main;
|
|
5
16
|
if (extensions) Object.assign(out, extensions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFn.cjs","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"expandFn.cjs","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,YAIX,MACA,eACsB;CACtB,MAAM,MAAW;CAEjB,IAAI,YACF,OAAO,OAAO,KAAK,UAAU;CAG/B,OAAO;AACT"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { Fn, FnBasic } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Augments a function with additional object properties.
|
|
4
|
+
*
|
|
5
|
+
* @template | {@linkcode Fn} `Main` - Base function type.
|
|
6
|
+
* @template | {@linkcode object} `Tr` - Extension properties shape.
|
|
7
|
+
*
|
|
8
|
+
* @param main - Base function to extend of type {@linkcode Fn}.
|
|
9
|
+
* @param extensions - Optional extension properties object.
|
|
10
|
+
*
|
|
11
|
+
* @returns Extended function of type {@linkcode FnBasic}.
|
|
12
|
+
*/
|
|
2
13
|
export declare const expandFn: <Main extends Fn, const Tr extends object = object>(main: Main, extensions?: Tr) => FnBasic<Main, Tr>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
//#region src/utils/bemedev/globals/utils/expandFn.ts
|
|
2
|
+
/**
|
|
3
|
+
* Augments a function with additional object properties.
|
|
4
|
+
*
|
|
5
|
+
* @template | {@linkcode Fn} `Main` - Base function type.
|
|
6
|
+
* @template | {@linkcode object} `Tr` - Extension properties shape.
|
|
7
|
+
*
|
|
8
|
+
* @param main - Base function to extend of type {@linkcode Fn}.
|
|
9
|
+
* @param extensions - Optional extension properties object.
|
|
10
|
+
*
|
|
11
|
+
* @returns Extended function of type {@linkcode FnBasic}.
|
|
12
|
+
*/
|
|
2
13
|
const expandFn = (main, extensions) => {
|
|
3
14
|
const out = main;
|
|
4
15
|
if (extensions) Object.assign(out, extensions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFn.js","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"expandFn.js","names":[],"sources":["../../../../../src/utils/bemedev/globals/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\n/**\n * Augments a function with additional object properties.\n *\n * @template | {@linkcode Fn} `Main` - Base function type.\n * @template | {@linkcode object} `Tr` - Extension properties shape.\n *\n * @param main - Base function to extend of type {@linkcode Fn}.\n * @param extensions - Optional extension properties object.\n *\n * @returns Extended function of type {@linkcode FnBasic}.\n */\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,YAIX,MACA,eACsB;CACtB,MAAM,MAAW;CAEjB,IAAI,YACF,OAAO,OAAO,KAAK,UAAU;CAG/B,OAAO;AACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/utils/clamp.ts
|
|
3
|
+
/**
|
|
4
|
+
* Restricts a number between a minimum and maximum boundary.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Value to clamp.
|
|
7
|
+
* @param min - Minimum allowed boundary.
|
|
8
|
+
* @param max - Maximum allowed boundary.
|
|
9
|
+
*
|
|
10
|
+
* @returns Clamped value within the range `[min, max]`.
|
|
11
|
+
*/
|
|
12
|
+
const clamp = (value, min, max) => {
|
|
13
|
+
return Math.min(Math.max(value, min), max);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.clamp = clamp;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=clamp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.cjs","names":[],"sources":["../../src/utils/clamp.ts"],"sourcesContent":["/**\n * Restricts a number between a minimum and maximum boundary.\n *\n * @param value - Value to clamp.\n * @param min - Minimum allowed boundary.\n * @param max - Maximum allowed boundary.\n *\n * @returns Clamped value within the range `[min, max]`.\n */\nexport const clamp = (value: number, min: number, max: number) => {\n return Math.min(Math.max(value, min), max);\n};\n"],"mappings":";;;;;;;;;;;AASA,MAAa,SAAS,OAAe,KAAa,QAAgB;CAChE,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricts a number between a minimum and maximum boundary.
|
|
3
|
+
*
|
|
4
|
+
* @param value - Value to clamp.
|
|
5
|
+
* @param min - Minimum allowed boundary.
|
|
6
|
+
* @param max - Maximum allowed boundary.
|
|
7
|
+
*
|
|
8
|
+
* @returns Clamped value within the range `[min, max]`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/utils/clamp.ts
|
|
2
|
+
/**
|
|
3
|
+
* Restricts a number between a minimum and maximum boundary.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to clamp.
|
|
6
|
+
* @param min - Minimum allowed boundary.
|
|
7
|
+
* @param max - Maximum allowed boundary.
|
|
8
|
+
*
|
|
9
|
+
* @returns Clamped value within the range `[min, max]`.
|
|
10
|
+
*/
|
|
11
|
+
const clamp = (value, min, max) => {
|
|
12
|
+
return Math.min(Math.max(value, min), max);
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { clamp };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=clamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.js","names":[],"sources":["../../src/utils/clamp.ts"],"sourcesContent":["/**\n * Restricts a number between a minimum and maximum boundary.\n *\n * @param value - Value to clamp.\n * @param min - Minimum allowed boundary.\n * @param max - Maximum allowed boundary.\n *\n * @returns Clamped value within the range `[min, max]`.\n */\nexport const clamp = (value: number, min: number, max: number) => {\n return Math.min(Math.max(value, min), max);\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,SAAS,OAAe,KAAa,QAAgB;CAChE,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C"}
|
package/lib/utils/identity.cjs
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils/identity.ts
|
|
3
|
+
/**
|
|
4
|
+
* Identity function returning the input value unchanged.
|
|
5
|
+
*
|
|
6
|
+
* @template `T` - Type of the input value.
|
|
7
|
+
*
|
|
8
|
+
* @param x - Input value.
|
|
9
|
+
*
|
|
10
|
+
* @returns The input value `x`.
|
|
11
|
+
*/
|
|
3
12
|
const identity = (x) => x;
|
|
4
13
|
//#endregion
|
|
5
14
|
exports.identity = identity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.cjs","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"identity.cjs","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["/**\n * Identity function returning the input value unchanged.\n *\n * @template `T` - Type of the input value.\n *\n * @param x - Input value.\n *\n * @returns The input value `x`.\n */\nexport const identity = <T>(x: T) => x;\n"],"mappings":";;;;;;;;;;;AASA,MAAa,YAAe,MAAS"}
|
package/lib/utils/identity.d.ts
CHANGED
package/lib/utils/identity.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
//#region src/utils/identity.ts
|
|
2
|
+
/**
|
|
3
|
+
* Identity function returning the input value unchanged.
|
|
4
|
+
*
|
|
5
|
+
* @template `T` - Type of the input value.
|
|
6
|
+
*
|
|
7
|
+
* @param x - Input value.
|
|
8
|
+
*
|
|
9
|
+
* @returns The input value `x`.
|
|
10
|
+
*/
|
|
2
11
|
const identity = (x) => x;
|
|
3
12
|
//#endregion
|
|
4
13
|
export { identity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["/**\n * Identity function returning the input value unchanged.\n *\n * @template `T` - Type of the input value.\n *\n * @param x - Input value.\n *\n * @returns The input value `x`.\n */\nexport const identity = <T>(x: T) => x;\n"],"mappings":";;;;;;;;;;AASA,MAAa,YAAe,MAAS"}
|
package/lib/utils/index.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_sleep = require("./sleep.cjs");
|
|
3
3
|
const require_utils_identity = require("./identity.cjs");
|
|
4
|
+
const require_utils_clamp = require("./clamp.cjs");
|
|
4
5
|
const require_utils_array = require("./array.cjs");
|
|
5
6
|
const require_utils_bemedev_globals_utils__unknown = require("./bemedev/globals/utils/_unknown.cjs");
|
|
6
7
|
exports._unknown = require_utils_bemedev_globals_utils__unknown._unknown;
|
|
8
|
+
exports.clamp = require_utils_clamp.clamp;
|
|
7
9
|
exports.identity = require_utils_identity.identity;
|
|
8
10
|
exports.sleep = require_utils_sleep.sleep;
|
|
9
11
|
exports.toArray = require_utils_array.toArray;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sleep } from "./sleep.js";
|
|
2
2
|
import { identity } from "./identity.js";
|
|
3
|
+
import { clamp } from "./clamp.js";
|
|
3
4
|
import { toArray } from "./array.js";
|
|
4
5
|
import { _unknown } from "./bemedev/globals/utils/_unknown.js";
|
|
5
|
-
export { _unknown, identity, sleep, toArray };
|
|
6
|
+
export { _unknown, clamp, identity, sleep, toArray };
|