@powerlines/core 0.48.53 → 0.48.54

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.
Files changed (67) hide show
  1. package/dist/constants/api.mjs.map +1 -1
  2. package/dist/constants/commands.mjs.map +1 -1
  3. package/dist/constants/devtools.mjs.map +1 -1
  4. package/dist/constants/environments.mjs.map +1 -1
  5. package/dist/constants/extensions.mjs.map +1 -1
  6. package/dist/constants/fs.mjs.map +1 -1
  7. package/dist/constants/hooks.mjs.map +1 -1
  8. package/dist/constants/log-level.mjs.map +1 -1
  9. package/dist/constants/meta.mjs.map +1 -1
  10. package/dist/constants/plugin.mjs.map +1 -1
  11. package/dist/context/base-context.mjs.map +1 -1
  12. package/dist/context/context.mjs.map +1 -1
  13. package/dist/context/environment-context.mjs.map +1 -1
  14. package/dist/context/execution-context.mjs.map +1 -1
  15. package/dist/context/plugin-context.mjs.map +1 -1
  16. package/dist/lib/config.mjs.map +1 -1
  17. package/dist/lib/context-helpers.mjs.map +1 -1
  18. package/dist/lib/entry.mjs.map +1 -1
  19. package/dist/lib/environment.mjs.map +1 -1
  20. package/dist/lib/events.mjs.map +1 -1
  21. package/dist/lib/generate-types.mjs.map +1 -1
  22. package/dist/lib/hooks.mjs.map +1 -1
  23. package/dist/lib/install-dependencies.mjs.map +1 -1
  24. package/dist/lib/meta.mjs.map +1 -1
  25. package/dist/lib/plugins.mjs.map +1 -1
  26. package/dist/lib/resolver.mjs.map +1 -1
  27. package/dist/lib/streaming-channel.mjs.map +1 -1
  28. package/dist/lib/typescript/ts-morph.mjs.map +1 -1
  29. package/dist/lib/typescript/tsconfig.mjs.map +1 -1
  30. package/dist/lib/unplugin/helpers.mjs.map +1 -1
  31. package/dist/lib/unplugin/module-resolution.mjs.map +1 -1
  32. package/dist/lib/unplugin/plugin.mjs.map +1 -1
  33. package/dist/lib/utilities/file-header.mjs.map +1 -1
  34. package/dist/lib/utilities/format.cjs +7 -1
  35. package/dist/lib/utilities/format.d.cts.map +1 -1
  36. package/dist/lib/utilities/format.d.mts.map +1 -1
  37. package/dist/lib/utilities/format.mjs +6 -1
  38. package/dist/lib/utilities/format.mjs.map +1 -1
  39. package/dist/lib/utilities/source-file.mjs.map +1 -1
  40. package/dist/lib/utilities/source-map.mjs.map +1 -1
  41. package/dist/lib/utilities/write-file.mjs.map +1 -1
  42. package/dist/lib/vfs.cjs +1 -1
  43. package/dist/lib/vfs.mjs +1 -1
  44. package/dist/lib/vfs.mjs.map +1 -1
  45. package/dist/plugin-base.mjs.map +1 -1
  46. package/dist/plugin-utils/build-helpers.mjs.map +1 -1
  47. package/dist/plugin-utils/combine-plugins.mjs.map +1 -1
  48. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  49. package/dist/plugin-utils/docs-helper.mjs.map +1 -1
  50. package/dist/plugin-utils/enable-plugin.mjs.map +1 -1
  51. package/dist/plugin-utils/extend.mjs.map +1 -1
  52. package/dist/plugin-utils/filter.mjs.map +1 -1
  53. package/dist/plugin-utils/format-package-json.mjs.map +1 -1
  54. package/dist/plugin-utils/format.mjs.map +1 -1
  55. package/dist/plugin-utils/get-config-path.mjs.map +1 -1
  56. package/dist/plugin-utils/helpers.mjs.map +1 -1
  57. package/dist/plugin-utils/install.mjs.map +1 -1
  58. package/dist/plugin-utils/logging.mjs.map +1 -1
  59. package/dist/plugin-utils/merge.mjs.map +1 -1
  60. package/dist/plugin-utils/modules.mjs.map +1 -1
  61. package/dist/plugin-utils/paths.mjs.map +1 -1
  62. package/dist/plugin-utils/virtual.mjs.map +1 -1
  63. package/dist/storage/base.mjs.map +1 -1
  64. package/dist/storage/file-system.mjs.map +1 -1
  65. package/dist/storage/helpers.mjs.map +1 -1
  66. package/dist/storage/virtual.mjs.map +1 -1
  67. package/package.json +10 -7
@@ -1 +1 @@
1
- {"version":3,"file":"ts-morph.mjs","names":["#context"],"sources":["../../../src/lib/typescript/ts-morph.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport {\n CompilerOptions,\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n ProjectOptions,\n RuntimeDirEntry\n} from \"ts-morph\";\nimport type { Context } from \"../../types/context\";\n\nexport class VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #context: Context;\n\n public constructor(context: Context) {\n super();\n\n this.#context = context;\n }\n\n public override deleteSync(path: string) {\n this.#context.fs.removeSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n if (!this.#context.fs.isDirectorySync(dirPath)) {\n return [];\n }\n\n return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#context.fs.resolveSync(entry);\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#context.fs.isDirectorySync(fullPath),\n isFile: this.#context.fs.isFileSync(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return (await this.#context.fs.read(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return this.#context.fs.readSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#context.fs.write(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#context.fs.writeSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#context.fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#context.fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#context.fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#context.fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#context.fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#context.fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#context.fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#context.fs.isFileSync(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#context.fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#context.fs.isDirectorySync(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#context.fs.resolveSync(path) || path;\n }\n\n public override getCurrentDirectory() {\n return this.#context.config.cwd;\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#context.fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#context.fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @param context - The Powerlines context\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(\n context: Context,\n override: Partial<ProjectOptions>\n): Project {\n context.debug(\n `Creating ts-morph Project instance with configuration from: ${\n context.tsconfig.tsconfigFilePath\n }.`\n );\n\n const project = new Project(\n defu(override ?? {}, {\n skipAddingFilesFromTsConfig: false,\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context),\n compilerOptions: defu(context.tsconfig.options ?? {}, {\n lib: [\"lib.esnext.full.d.ts\"]\n }) as CompilerOptions\n })\n );\n\n return project;\n}\n"],"mappings":";;;;AA6BA,IAAa,wBAAb,cACU,uBAEV;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AACf"}
1
+ {"version":3,"file":"ts-morph.mjs","names":["#context"],"sources":["../../../src/lib/typescript/ts-morph.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport {\n CompilerOptions,\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n ProjectOptions,\n RuntimeDirEntry\n} from \"ts-morph\";\nimport type { Context } from \"../../types/context\";\n\nexport class VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #context: Context;\n\n public constructor(context: Context) {\n super();\n\n this.#context = context;\n }\n\n public override deleteSync(path: string) {\n this.#context.fs.removeSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n if (!this.#context.fs.isDirectorySync(dirPath)) {\n return [];\n }\n\n return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#context.fs.resolveSync(entry);\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#context.fs.isDirectorySync(fullPath),\n isFile: this.#context.fs.isFileSync(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return (await this.#context.fs.read(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return this.#context.fs.readSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#context.fs.write(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#context.fs.writeSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#context.fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#context.fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#context.fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#context.fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#context.fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#context.fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#context.fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#context.fs.isFileSync(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#context.fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#context.fs.isDirectorySync(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#context.fs.resolveSync(path) || path;\n }\n\n public override getCurrentDirectory() {\n return this.#context.config.cwd;\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#context.fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#context.fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @param context - The Powerlines context\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(\n context: Context,\n override: Partial<ProjectOptions>\n): Project {\n context.debug(\n `Creating ts-morph Project instance with configuration from: ${\n context.tsconfig.tsconfigFilePath\n }.`\n );\n\n const project = new Project(\n defu(override ?? {}, {\n skipAddingFilesFromTsConfig: false,\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context),\n compilerOptions: defu(context.tscon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sBAAsB,OAAO;EAC7C,iBAAiB,KAAK,QAAQ,SAAS,WAAW,CAAC,GAAG,EACpD,KAAK,CAAC,sBAAsB,EAC9B,CAAC;CACH,CAAC,CAGU;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.mjs","names":[],"sources":["../../../src/lib/typescript/tsconfig.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Diff, ObjectData } from \"@donedeal0/superdiff\";\nimport { getObjectDiff } from \"@donedeal0/superdiff\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile, readJsonFileSync } from \"@stryke/fs/json\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport {\n findFileName,\n findFilePath,\n relativePath\n} from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { FilterPattern } from \"@stryke/types/file\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport chalk from \"chalk\";\nimport defu from \"defu\";\nimport ts from \"typescript\";\nimport { ResolvedConfig } from \"../../types/config\";\nimport { EnvironmentContext } from \"../../types/context\";\nimport type { ParsedTypeScriptConfig, TSConfig } from \"../../types/tsconfig\";\n\nexport function getTsconfigDtsPath<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(context: EnvironmentContext<TResolvedConfig, TSystemContext>): string {\n const dtsRelativePath = joinPaths(\n relativePath(\n joinPaths(context.config.cwd, context.config.root),\n findFilePath(context.typesPath)\n ),\n findFileName(context.typesPath)\n );\n\n return dtsRelativePath;\n}\n\nasync function resolveTsconfigChanges<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(\n context: EnvironmentContext<TResolvedConfig, TSystemContext>\n): Promise<TsConfigJson> {\n const tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw\n );\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n const tsconfigJson = await readJsonFile<TsConfigJson>(tsconfigFilePath);\n tsconfigJson.compilerOptions ??= {};\n\n if (context.config.output.dts !== false) {\n const dtsRelativePath = getTsconfigDtsPath(context);\n\n if (\n !tsconfigJson.include?.some(filePattern =>\n isIncludeMatchFound(filePattern, [context.typesPath, dtsRelativePath])\n )\n ) {\n tsconfigJson.include ??= [];\n tsconfigJson.include.push(\n dtsRelativePath.startsWith(\"./\")\n ? dtsRelativePath.slice(2)\n : dtsRelativePath\n );\n }\n }\n\n if (\n !tsconfig.options.lib?.some(lib =>\n [\n \"lib.esnext.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2023.d.ts\"\n ].includes(lib.toLowerCase())\n )\n ) {\n tsconfigJson.compilerOptions.lib ??= [];\n tsconfigJson.compilerOptions.lib.push(\"esnext\");\n }\n\n // if (tsconfig.options.module !== ts.ModuleKind.ESNext) {\n // tsconfigJson.compilerOptions.module = \"ESNext\";\n // }\n\n // if (\n // !tsconfig.options.target ||\n // ![\n // ts.ScriptTarget.ESNext,\n // ts.ScriptTarget.ES2024,\n // ts.ScriptTarget.ES2023,\n // ts.ScriptTarget.ES2022,\n // ts.ScriptTarget.ES2021\n // ].includes(tsconfig.options.target)\n // ) {\n // tsconfigJson.compilerOptions.target = \"ESNext\";\n // }\n\n // if (tsconfig.options.moduleResolution !== ts.ModuleResolutionKind.Bundler) {\n // tsconfigJson.compilerOptions.moduleResolution = \"Bundler\";\n // }\n\n // if (tsconfig.options.moduleDetection !== ts.ModuleDetectionKind.Force) {\n // tsconfigJson.compilerOptions.moduleDetection = \"force\";\n // }\n\n // if (tsconfig.options.allowSyntheticDefaultImports !== true) {\n // tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;\n // }\n\n // if (tsconfig.options.noImplicitOverride !== true) {\n // tsconfigJson.compilerOptions.noImplicitOverride = true;\n // }\n\n // if (tsconfig.options.noUncheckedIndexedAccess !== true) {\n // tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;\n // }\n\n // if (tsconfig.options.skipLibCheck !== true) {\n // tsconfigJson.compilerOptions.skipLibCheck = true;\n // }\n\n // if (tsconfig.options.resolveJsonModule !== true) {\n // tsconfigJson.compilerOptions.resolveJsonModule = true;\n // }\n\n // if (tsconfig.options.verbatimModuleSyntax !== false) {\n // tsconfigJson.compilerOptions.verbatimModuleSyntax = false;\n // }\n\n // if (tsconfig.options.allowJs !== true) {\n // tsconfigJson.compilerOptions.allowJs = true;\n // }\n\n // if (tsconfig.options.declaration !== true) {\n // tsconfigJson.compilerOptions.declaration = true;\n // }\n\n if (tsconfig.options.esModuleInterop !== true) {\n tsconfigJson.compilerOptions.esModuleInterop = true;\n }\n\n if (tsconfig.options.isolatedModules !== true) {\n tsconfigJson.compilerOptions.isolatedModules = true;\n }\n\n if (context.config.platform === \"node\") {\n if (\n !tsconfig.options.types?.some(\n type =>\n type.toLowerCase() === \"node\" || type.toLowerCase() === \"@types/node\"\n )\n ) {\n tsconfigJson.compilerOptions.types ??= [];\n tsconfigJson.compilerOptions.types.push(\"node\");\n }\n }\n\n return tsconfigJson;\n}\n\nexport async function initializeTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends EnvironmentContext<TResolvedConfig, TSystemContext> =\n EnvironmentContext<TResolvedConfig, TSystemContext>\n>(context: TContext): Promise<void> {\n context.debug(\n \"Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.\"\n );\n\n if (!isPackageExists(\"typescript\")) {\n throw new Error(\n 'The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"'\n );\n }\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n context.tsconfig.originalTsconfigJson =\n await readJsonFile<TsConfigJson>(tsconfigFilePath);\n\n context.tsconfig.tsconfigJson = await resolveTsconfigChanges<\n TResolvedConfig,\n TSystemContext\n >(context);\n\n context.debug(\n \"Writing updated TypeScript configuration (tsconfig.json) file to disk.\"\n );\n\n await context.fs.write(\n tsconfigFilePath,\n StormJSON.stringify(context.tsconfig.tsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw,\n context.tsconfig.originalTsconfigJson\n );\n}\n\nexport async function resolveTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends EnvironmentContext<TResolvedConfig, TSystemContext> =\n EnvironmentContext<TResolvedConfig, TSystemContext>\n>(context: TContext): Promise<void> {\n const updateTsconfigJson = await readJsonFile<TsConfigJson>(\n context.tsconfig.tsconfigFilePath\n );\n if (\n updateTsconfigJson?.compilerOptions?.types &&\n Array.isArray(updateTsconfigJson.compilerOptions.types) &&\n !updateTsconfigJson.compilerOptions.types.length\n ) {\n // If the types array is empty, we can safely remove it\n delete updateTsconfigJson.compilerOptions.types;\n }\n\n const result = getObjectDiff(\n context.tsconfig.originalTsconfigJson as NonNullable<ObjectData>,\n updateTsconfigJson as ObjectData,\n {\n ignoreArrayOrder: true,\n showOnly: {\n statuses: [\"added\", \"deleted\", \"updated\"],\n granularity: \"deep\"\n }\n }\n );\n\n const changes = [] as {\n field: string;\n status: \"added\" | \"deleted\" | \"updated\";\n previous: string;\n current: string;\n }[];\n const getChanges = (difference: Diff, property?: string) => {\n if (\n difference.status === \"added\" ||\n difference.status === \"deleted\" ||\n difference.status === \"updated\"\n ) {\n if (difference.diff) {\n for (const diff of difference.diff) {\n getChanges(\n diff,\n property\n ? `${property}.${difference.property}`\n : difference.property\n );\n }\n } else {\n changes.push({\n field: property\n ? `${property}.${difference.property}`\n : difference.property,\n status: difference.status,\n previous:\n difference.status === \"added\"\n ? \"---\"\n : StormJSON.stringify(difference.previousValue),\n current:\n difference.status === \"deleted\"\n ? \"---\"\n : StormJSON.stringify(difference.currentValue)\n });\n }\n }\n };\n\n for (const diff of result.diff) {\n getChanges(diff);\n }\n\n if (changes.length > 0) {\n context.warn(\n `Updating the following configuration values in \"${context.tsconfig.tsconfigFilePath}\" file:\n\n ${changes\n .map(\n (change, i) => `${chalk.bold.whiteBright(\n `${i + 1}. ${titleCase(change.status)} the ${change.field} field: `\n )}\n ${chalk.red(` - Previous: ${change.previous} `)}\n ${chalk.green(` - Updated: ${change.current} `)}\n `\n )\n .join(\"\\n\")}\n `\n );\n }\n\n await context.fs.write(\n context.tsconfig.tsconfigFilePath,\n StormJSON.stringify(updateTsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n if (!context.tsconfig) {\n throw new Error(\"Failed to parse the TypeScript configuration file.\");\n }\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function getTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig?: string\n): string {\n let tsconfigFilePath: string | undefined;\n if (tsconfig) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, tsconfig);\n } else {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.app.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.lib.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.json\");\n }\n }\n }\n\n if (!tsconfigFilePath) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file for the project at ${\n root\n }.`\n );\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function tryTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig: string\n): string | undefined {\n let tsconfigFilePath = tsconfig;\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, root);\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, appendPath(root, cwd));\n if (!existsSync(tsconfigFilePath)) {\n return undefined;\n }\n }\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[],\n extensions: string[] = [\".ts\", \".tsx\", \".d.ts\"]\n): string | RegExp | null | undefined {\n return types.find(\n type =>\n tsconfigType?.toString().toLowerCase() ===\n type?.toString().toLowerCase() ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}` ||\n `./${tsconfigType?.toString().toLowerCase()}` ===\n type?.toString().toLowerCase() ||\n extensions.some(\n ext =>\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n type?.toString().toLowerCase() ||\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n `./${type?.toString().toLowerCase()}` ||\n `${type?.toString().toLowerCase()}${ext}` ===\n `./${tsconfigType?.toString().toLowerCase()}` ||\n tsconfigType?.toString().toLowerCase() ===\n `${type?.toString().toLowerCase()}${ext}` ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}${ext}` ||\n type?.toString().toLowerCase() ===\n `./${tsconfigType?.toString().toLowerCase()}${ext}`\n )\n );\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findIncludeMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): string | RegExp | null | undefined {\n return findMatch(tsconfigType, types, [\n \".ts\",\n \".tsx\",\n \".d.ts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".mts\",\n \".cts\",\n \"/*.ts\",\n \"/*.tsx\",\n \"/*.d.ts\",\n \"/*.js\",\n \"/*.jsx\",\n \"/*.mjs\",\n \"/*.cjs\",\n \"/*.mts\",\n \"/*.cts\",\n \"/**/*.ts\",\n \"/**/*.tsx\",\n \"/**/*.d.ts\",\n \"/**/*.js\",\n \"/**/*.jsx\",\n \"/**/*.mjs\",\n \"/**/*.cjs\",\n \"/**/*.mts\",\n \"/**/*.cts\"\n ]);\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isMatchFound(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): boolean {\n return findMatch(tsconfigType, types) !== undefined;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isIncludeMatchFound(\n tsconfigType: FilterPattern,\n types: FilterPattern[]\n): boolean {\n return (\n findIncludeMatch(\n tsconfigType as string | RegExp | null,\n types as (string | RegExp | null)[]\n ) !== undefined\n );\n}\n\n/**\n * Get the parsed TypeScript configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @param tsconfigRaw - The raw tsconfig.json content.\n * @param originalTsconfigJson - The original tsconfig.json content.\n * @param host - The TypeScript parse config host.\n * @returns The resolved TypeScript configuration.\n */\nexport function getParsedTypeScriptConfig(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string,\n tsconfigRaw: TSConfig = {},\n originalTsconfigJson?: TSConfig,\n host: ts.ParseConfigHost = ts.sys\n): ParsedTypeScriptConfig {\n const tsconfigFilePath = getTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n const tsconfigJson = readJsonFileSync<TSConfig>(tsconfigFilePath);\n if (!tsconfigJson) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file at ${joinPaths(\n projectRoot,\n tsconfig ?? \"tsconfig.json\"\n )}`\n );\n }\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n defu(tsconfigRaw ?? {}, tsconfigJson),\n host,\n appendPath(projectRoot, workspaceRoot)\n );\n if (parsedCommandLine.errors.length > 0) {\n const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:\n${parsedCommandLine.errors\n .map(\n error =>\n `- ${\n (error.category !== undefined && error.code\n ? `[${error.category}-${error.code}]: `\n : \"\") + error.messageText.toString()\n }`\n )\n .join(\"\\n\")}\n `;\n\n throw new Error(errorMessage);\n }\n\n return {\n ...parsedCommandLine,\n originalTsconfigJson: (originalTsconfigJson ??\n tsconfigJson) as TsConfigJson,\n tsconfigJson,\n tsconfigFilePath\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAgB,mBAGd,SAAsE;CAStE,OARwB,UACtB,aACE,UAAU,QAAQ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,aACd,cACA,OACS;CACT,OAAO,UAAU,cAAc,KAAK,MAAM;AAC5C;;;;;;;;AASA,SAAgB,oBACd,cACA,OACS;CACT,OACE,iBACE,cACA,KACF,MAAM;AAEV;;;;;;;;;;;;AAaA,SAAgB,0BACd,eACA,aACA,UACA,cAAwB,CAAC,GACzB,sBACA,OAA2B,GAAG,KACN;CACxB,MAAM,mBAAmB,oBACvB,eACA,aACA,QACF;CACA,MAAM,eAAe,iBAA2B,gBAAgB;CAChE,IAAI,CAAC,cACH,MAAM,IAAI,MACR,2DAA2D,UACzD,aACA,YAAY,eACd,GACF;CAGF,MAAM,oBAAoB,GAAG,2BAC3B,KAAK,eAAe,CAAC,GAAG,YAAY,GACpC,MACA,WAAW,aAAa,aAAa,CACvC;CACA,IAAI,kBAAkB,OAAO,SAAS,GAAG;EACvC,MAAM,eAAe;EACvB,kBAAkB,OACjB,KACC,UACE,MACG,MAAM,aAAa,UAAa,MAAM,OACnC,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK,OACjC,MAAM,MAAM,YAAY,SAAS,GAE3C,CAAC,CACA,KAAK,IAAI,EAAE;;EAGV,MAAM,IAAI,MAAM,YAAY;CAC9B;CAEA,OAAO;EACL,GAAG;EACH,sBAAuB,wBACrB;EACF;EACA;CACF;AACF"}
1
+ {"version":3,"file":"tsconfig.mjs","names":[],"sources":["../../../src/lib/typescript/tsconfig.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Diff, ObjectData } from \"@donedeal0/superdiff\";\nimport { getObjectDiff } from \"@donedeal0/superdiff\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile, readJsonFileSync } from \"@stryke/fs/json\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport {\n findFileName,\n findFilePath,\n relativePath\n} from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { FilterPattern } from \"@stryke/types/file\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport chalk from \"chalk\";\nimport defu from \"defu\";\nimport ts from \"typescript\";\nimport { ResolvedConfig } from \"../../types/config\";\nimport { EnvironmentContext } from \"../../types/context\";\nimport type { ParsedTypeScriptConfig, TSConfig } from \"../../types/tsconfig\";\n\nexport function getTsconfigDtsPath<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(context: EnvironmentContext<TResolvedConfig, TSystemContext>): string {\n const dtsRelativePath = joinPaths(\n relativePath(\n joinPaths(context.config.cwd, context.config.root),\n findFilePath(context.typesPath)\n ),\n findFileName(context.typesPath)\n );\n\n return dtsRelativePath;\n}\n\nasync function resolveTsconfigChanges<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>(\n context: EnvironmentContext<TResolvedConfig, TSystemContext>\n): Promise<TsConfigJson> {\n const tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw\n );\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n const tsconfigJson = await readJsonFile<TsConfigJson>(tsconfigFilePath);\n tsconfigJson.compilerOptions ??= {};\n\n if (context.config.output.dts !== false) {\n const dtsRelativePath = getTsconfigDtsPath(context);\n\n if (\n !tsconfigJson.include?.some(filePattern =>\n isIncludeMatchFound(filePattern, [context.typesPath, dtsRelativePath])\n )\n ) {\n tsconfigJson.include ??= [];\n tsconfigJson.include.push(\n dtsRelativePath.startsWith(\"./\")\n ? dtsRelativePath.slice(2)\n : dtsRelativePath\n );\n }\n }\n\n if (\n !tsconfig.options.lib?.some(lib =>\n [\n \"lib.esnext.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2023.d.ts\"\n ].includes(lib.toLowerCase())\n )\n ) {\n tsconfigJson.compilerOptions.lib ??= [];\n tsconfigJson.compilerOptions.lib.push(\"esnext\");\n }\n\n // if (tsconfig.options.module !== ts.ModuleKind.ESNext) {\n // tsconfigJson.compilerOptions.module = \"ESNext\";\n // }\n\n // if (\n // !tsconfig.options.target ||\n // ![\n // ts.ScriptTarget.ESNext,\n // ts.ScriptTarget.ES2024,\n // ts.ScriptTarget.ES2023,\n // ts.ScriptTarget.ES2022,\n // ts.ScriptTarget.ES2021\n // ].includes(tsconfig.options.target)\n // ) {\n // tsconfigJson.compilerOptions.target = \"ESNext\";\n // }\n\n // if (tsconfig.options.moduleResolution !== ts.ModuleResolutionKind.Bundler) {\n // tsconfigJson.compilerOptions.moduleResolution = \"Bundler\";\n // }\n\n // if (tsconfig.options.moduleDetection !== ts.ModuleDetectionKind.Force) {\n // tsconfigJson.compilerOptions.moduleDetection = \"force\";\n // }\n\n // if (tsconfig.options.allowSyntheticDefaultImports !== true) {\n // tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;\n // }\n\n // if (tsconfig.options.noImplicitOverride !== true) {\n // tsconfigJson.compilerOptions.noImplicitOverride = true;\n // }\n\n // if (tsconfig.options.noUncheckedIndexedAccess !== true) {\n // tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;\n // }\n\n // if (tsconfig.options.skipLibCheck !== true) {\n // tsconfigJson.compilerOptions.skipLibCheck = true;\n // }\n\n // if (tsconfig.options.resolveJsonModule !== true) {\n // tsconfigJson.compilerOptions.resolveJsonModule = true;\n // }\n\n // if (tsconfig.options.verbatimModuleSyntax !== false) {\n // tsconfigJson.compilerOptions.verbatimModuleSyntax = false;\n // }\n\n // if (tsconfig.options.allowJs !== true) {\n // tsconfigJson.compilerOptions.allowJs = true;\n // }\n\n // if (tsconfig.options.declaration !== true) {\n // tsconfigJson.compilerOptions.declaration = true;\n // }\n\n if (tsconfig.options.esModuleInterop !== true) {\n tsconfigJson.compilerOptions.esModuleInterop = true;\n }\n\n if (tsconfig.options.isolatedModules !== true) {\n tsconfigJson.compilerOptions.isolatedModules = true;\n }\n\n if (context.config.platform === \"node\") {\n if (\n !tsconfig.options.types?.some(\n type =>\n type.toLowerCase() === \"node\" || type.toLowerCase() === \"@types/node\"\n )\n ) {\n tsconfigJson.compilerOptions.types ??= [];\n tsconfigJson.compilerOptions.types.push(\"node\");\n }\n }\n\n return tsconfigJson;\n}\n\nexport async function initializeTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends EnvironmentContext<TResolvedConfig, TSystemContext> =\n EnvironmentContext<TResolvedConfig, TSystemContext>\n>(context: TContext): Promise<void> {\n context.debug(\n \"Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.\"\n );\n\n if (!isPackageExists(\"typescript\")) {\n throw new Error(\n 'The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"'\n );\n }\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n context.tsconfig.originalTsconfigJson =\n await readJsonFile<TsConfigJson>(tsconfigFilePath);\n\n context.tsconfig.tsconfigJson = await resolveTsconfigChanges<\n TResolvedConfig,\n TSystemContext\n >(context);\n\n context.debug(\n \"Writing updated TypeScript configuration (tsconfig.json) file to disk.\"\n );\n\n await context.fs.write(\n tsconfigFilePath,\n StormJSON.stringify(context.tsconfig.tsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw,\n context.tsconfig.originalTsconfigJson\n );\n}\n\nexport async function resolveTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown,\n TContext extends EnvironmentContext<TResolvedConfig, TSystemContext> =\n EnvironmentContext<TResolvedConfig, TSystemContext>\n>(context: TContext): Promise<void> {\n const updateTsconfigJson = await readJsonFile<TsConfigJson>(\n context.tsconfig.tsconfigFilePath\n );\n if (\n updateTsconfigJson?.compilerOptions?.types &&\n Array.isArray(updateTsconfigJson.compilerOptions.types) &&\n !updateTsconfigJson.compilerOptions.types.length\n ) {\n // If the types array is empty, we can safely remove it\n delete updateTsconfigJson.compilerOptions.types;\n }\n\n const result = getObjectDiff(\n context.tsconfig.originalTsconfigJson as NonNullable<ObjectData>,\n updateTsconfigJson as ObjectData,\n {\n ignoreArrayOrder: true,\n showOnly: {\n statuses: [\"added\", \"deleted\", \"updated\"],\n granularity: \"deep\"\n }\n }\n );\n\n const changes = [] as {\n field: string;\n status: \"added\" | \"deleted\" | \"updated\";\n previous: string;\n current: string;\n }[];\n const getChanges = (difference: Diff, property?: string) => {\n if (\n difference.status === \"added\" ||\n difference.status === \"deleted\" ||\n difference.status === \"updated\"\n ) {\n if (difference.diff) {\n for (const diff of difference.diff) {\n getChanges(\n diff,\n property\n ? `${property}.${difference.property}`\n : difference.property\n );\n }\n } else {\n changes.push({\n field: property\n ? `${property}.${difference.property}`\n : difference.property,\n status: difference.status,\n previous:\n difference.status === \"added\"\n ? \"---\"\n : StormJSON.stringify(difference.previousValue),\n current:\n difference.status === \"deleted\"\n ? \"---\"\n : StormJSON.stringify(difference.currentValue)\n });\n }\n }\n };\n\n for (const diff of result.diff) {\n getChanges(diff);\n }\n\n if (changes.length > 0) {\n context.warn(\n `Updating the following configuration values in \"${context.tsconfig.tsconfigFilePath}\" file:\n\n ${changes\n .map(\n (change, i) => `${chalk.bold.whiteBright(\n `${i + 1}. ${titleCase(change.status)} the ${change.field} field: `\n )}\n ${chalk.red(` - Previous: ${change.previous} `)}\n ${chalk.green(` - Updated: ${change.current} `)}\n `\n )\n .join(\"\\n\")}\n `\n );\n }\n\n await context.fs.write(\n context.tsconfig.tsconfigFilePath,\n StormJSON.stringify(updateTsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n if (!context.tsconfig) {\n throw new Error(\"Failed to parse the TypeScript configuration file.\");\n }\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function getTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig?: string\n): string {\n let tsconfigFilePath: string | undefined;\n if (tsconfig) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, tsconfig);\n } else {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.app.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.lib.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.json\");\n }\n }\n }\n\n if (!tsconfigFilePath) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file for the project at ${\n root\n }.`\n );\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function tryTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig: string\n): string | undefined {\n let tsconfigFilePath = tsconfig;\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, root);\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, appendPath(root, cwd));\n if (!existsSync(tsconfigFilePath)) {\n return undefined;\n }\n }\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[],\n extensions: string[] = [\".ts\", \".tsx\", \".d.ts\"]\n): string | RegExp | null | undefined {\n return types.find(\n type =>\n tsconfigType?.toString().toLowerCase() ===\n type?.toString().toLowerCase() ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}` ||\n `./${tsconfigType?.toString().toLowerCase()}` ===\n type?.toString().toLowerCase() ||\n extensions.some(\n ext =>\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n type?.toString().toLowerCase() ||\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n `./${type?.toString().toLowerCase()}` ||\n `${type?.toString().toLowerCase()}${ext}` ===\n `./${tsconfigType?.toString().toLowerCase()}` ||\n tsconfigType?.toString().toLowerCase() ===\n `${type?.toString().toLowerCase()}${ext}` ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}${ext}` ||\n type?.toString().toLowerCase() ===\n `./${tsconfigType?.toString().toLowerCase()}${ext}`\n )\n );\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findIncludeMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): string | RegExp | null | undefined {\n return findMatch(tsconfigType, types, [\n \".ts\",\n \".tsx\",\n \".d.ts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".mts\",\n \".cts\",\n \"/*.ts\",\n \"/*.tsx\",\n \"/*.d.ts\",\n \"/*.js\",\n \"/*.jsx\",\n \"/*.mjs\",\n \"/*.cjs\",\n \"/*.mts\",\n \"/*.cts\",\n \"/**/*.ts\",\n \"/**/*.tsx\",\n \"/**/*.d.ts\",\n \"/**/*.js\",\n \"/**/*.jsx\",\n \"/**/*.mjs\",\n \"/**/*.cjs\",\n \"/**/*.mts\",\n \"/**/*.cts\"\n ]);\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isMatchFound(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): boolean {\n return findMatch(tsconfigType, types) !== undefined;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isIncludeMatchFound(\n tsconfigType: FilterPattern,\n types: FilterPattern[]\n): boolean {\n return (\n findIncludeMatch(\n tsconfigType as string | RegExp | null,\n types as (string | RegExp | null)[]\n ) !== undefined\n );\n}\n\n/**\n * Get the parsed TypeScript configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @param tsconfigRaw - The raw tsconfig.json content.\n * @param originalTsconfigJson - The original tsconfig.json content.\n * @param host - The TypeScript parse config host.\n * @returns The resolved TypeScript configuration.\n */\nexport function getParsedTypeScriptConfig(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string,\n tsconfigRaw: TSConfig = {},\n originalTsconfigJson?: TSConfig,\n host: ts.ParseConfigHost = ts.sys\n): ParsedTypeScriptConfig {\n const tsconfigFilePath = getTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n const tsconfigJson = readJsonFileSync<TSConfig>(tsconfigFilePath);\n if (!tsconfigJson) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file at ${joinPaths(\n projectRoot,\n tsconfig ?? \"tsconfig.json\"\n )}`\n );\n }\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n defu(tsconfigRaw ?? {}, tsconfigJson),\n host,\n appendPath(projectRoot, workspaceRoot)\n );\n if (parsedCommandLine.errors.length > 0) {\n const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:\n${parsedCommandLine.errors\n .map(\n error =>\n `- ${\n (error.category !== undefined && error.code\n ? `[${error.category}-${error.code}]: `\n : \"\") + error.messageText.toString()\n }`\n )\n .join(\"\\n\")}\n `;\n\n throw new Error(errorMessage);\n }\n\n return {\n ...parsedCommandLine,\n originalTsconfigJson: (originalTsconfigJson ??\n tsconfigJson) as TsConfigJson,\n tsconfigJson,\n tsconfigFilePath\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAgB,mBAGd,SAAsE;CAStE,OARwB,UACtB,aACE,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI,GACjD,aAAa,QAAQ,SAAS,CAChC,GACA,aAAa,QAAQ,SAAS,CAGX;AACvB;AAEA,eAAe,uBAIb,SACuB;CACvB,MAAM,WAAW,0BACf,QAAQ,OAAO,KACf,QAAQ,OAAO,MACf,QAAQ,OAAO,UACf,QAAQ,OAAO,WACjB;CAQA,MAAM,eAAe,MAAM,aANF,oBACvB,QAAQ,OAAO,KACf,QAAQ,OAAO,MACf,QAAQ,OAAO,QAGoD,CAAC;CACtE,aAAa,oBAAoB,CAAC;CAElC,IAAI,QAAQ,OAAO,OAAO,QAAQ,OAAO;EACvC,MAAM,kBAAkB,mBAAmB,OAAO;EAElD,IACE,CAAC,aAAa,SAAS,MAAK,gBAC1B,oBAAoB,aAAa,CAAC,QAAQ,WAAW,eAAe,CAAC,CACvE,GACA;GACA,aAAa,YAAY,CAAC;GAC1B,aAAa,QAAQ,KACnB,g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,MAAM,OACnC,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK,OACjC,MAAM,MAAM,YAAY,SAAS,GAE3C,CAAC,CACA,KAAK,IAAI,EAAE;;EAGV,MAAM,IAAI,MAAM,YAAY;CAC9B;CAEA,OAAO;EACL,GAAG;EACH,sBAAuB,wBACrB;EACF;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":["defu"],"sources":["../../../src/lib/unplugin/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { UnpluginBuildContext } from \"unplugin\";\nimport { UNPLUGIN_BUILDER_VARIANTS } from \"../../constants/plugin\";\nimport type { UnresolvedContext } from \"../../types/context\";\nimport type { UnpluginBuilderVariant } from \"../../types/unplugin\";\n\n/**\n * Merges a base plugin context with an unplugin context, combining their properties.\n *\n * @param contextA - The base plugin context to merge into.\n * @param contextB - The unplugin context to merge from.\n * @returns The merged context.\n */\nexport function combineContexts<\n TContextA extends UnresolvedContext | UnpluginBuildContext,\n TContextB extends UnresolvedContext | UnpluginBuildContext\n>(contextA: TContextA, contextB: TContextB): TContextA & TContextB {\n return defu(contextA, contextB) as TContextA & TContextB;\n}\n\n/**\n * Checks if a value is a valid UnpluginBuilderVariant.\n *\n * @param str - The value to check.\n * @returns True if the value is a UnpluginBuilderVariant, false otherwise.\n */\nexport function isUnpluginBuilderVariant(\n str: unknown\n): str is UnpluginBuilderVariant {\n return (\n isSetString(str) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(str as UnpluginBuilderVariant)\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,gBAGd,UAAqB,UAA4C;CACjE,OAAOA,OAAK,UAAU,QAAQ;AAChC;;;;;;;AAQA,SAAgB,yBACd,KAC+B;CAC/B,OACE,YAAY,GAAG,KACf,0BAA0B,SAAS,GAA6B;AAEpE"}
1
+ {"version":3,"file":"helpers.mjs","names":["defu"],"sources":["../../../src/lib/unplugin/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { UnpluginBuildContext } from \"unplugin\";\nimport { UNPLUGIN_BUILDER_VARIANTS } from \"../../constants/plugin\";\nimport type { UnresolvedContext } from \"../../types/context\";\nimport type { UnpluginBuilderVariant } from \"../../types/unplugin\";\n\n/**\n * Merges a base plugin context with an unplugin context, combining their properties.\n *\n * @param contextA - The base plugin context to merge into.\n * @param contextB - The unplugin context to merge from.\n * @returns The merged context.\n */\nexport function combineContexts<\n TContextA extends UnresolvedContext | UnpluginBuildContext,\n TContextB extends UnresolvedContext | UnpluginBuildContext\n>(contextA: TContextA, contextB: TContextB): TContextA & TContextB {\n return defu(contextA, contextB) as TContextA & TContextB;\n}\n\n/**\n * Checks if a value is a valid UnpluginBuilderVariant.\n *\n * @param str - The value to check.\n * @returns True if the value is a UnpluginBuilderVariant, false otherwise.\n */\nexport function isUnpluginBuilderVariant(\n str: unknown\n): str is UnpluginBuilderVariant {\n return (\n isSetString(str) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(str as UnpluginBuilderVariant)\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,gBAGd,UAAqB,UAA4C;CACjE,OAAOA,OAAK,UAAU,QAAQ;AAChC;;;;;;;AAQA,SAAgB,yBACd,KAC+B;CAC/B,OACE,YAAY,GAAG,KACf,0BAA0B,SAAS,GAA6B;AAEpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"module-resolution.mjs","names":[],"sources":["../../../src/lib/unplugin/module-resolution.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { LoadResult } from \"rollup\";\nimport type {\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginOptions\n} from \"unplugin\";\nimport {\n addVirtualPrefix,\n removeVirtualPrefix,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"../../plugin-utils\";\nimport { ResolveResult, UnresolvedContext } from \"../../types/context\";\nimport { ResolveOptions } from \"../../types/fs\";\n\nexport interface CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * An indicator of whether to prefix virtual module IDs with a specific string. This is useful for ensuring that virtual modules are only processed by the plugin and not by other plugins or the bundler itself.\n *\n * @remarks\n * - If set to `true`, virtual module IDs will be prefixed with the string `__powerlines-virtual:`.\n * - If set to `false`, no prefix will be added to virtual module IDs.\n *\n * @defaultValue true\n */\n prefix?: boolean;\n\n /**\n * Optional overrides for the module resolution configuration.\n *\n * @remarks\n * This allows you to customize the behavior of the module resolution hooks by providing specific configuration options.\n */\n overrides?: Partial<ResolveOptions>;\n}\n\n/**\n * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.\n *\n * @remarks\n * This includes the `resolveId` and `load` hooks.\n *\n * @see https://rollupjs.org/plugin-development/#resolveid\n * @see https://rollupjs.org/plugin-development/#load\n *\n * @param context - The plugin context.\n * @param options - Options for creating the module resolution functions.\n * @returns The module resolution hooks (`resolveId` and `load`).\n */\nexport function createUnpluginModuleResolutionFunctions<\n TContext extends UnresolvedContext\n>(\n context: TContext,\n options: CreateUnpluginModuleResolutionFunctionsOptions = {}\n): Pick<UnpluginOptions, \"resolveId\" | \"load\"> {\n return {\n async resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ResolveResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n const normalizedImporter = importer\n ? removeVirtualPrefix(importer)\n : undefined;\n\n let result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.resolve(\n normalizedId,\n normalizedImporter,\n defu(options.overrides ?? {}, {\n isFile: true,\n ...opts\n })\n );\n if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n return null;\n },\n load: {\n filter:\n options.prefix !== false\n ? {\n id: VIRTUAL_MODULE_PREFIX_REGEX\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n\n let result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.load(normalizedId);\n if (result) {\n return result;\n }\n\n return context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId\n );\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqEA,SAAgB,wCAGd,SACA,UAA0D,CAAC,GACd;CAC7C,OAAO;EACL,MAAM,UAEJ,IACA,UACA,OAEI,EAAE,SAAS,MAAM,GAC+B;GACpD,MAAM,eAAe,oBAAoB,EAAE;GAC3C,MAAM,qBAAqB,WACvB,oBAAoB,QAAQ,IAC5B;GAEJ,IAAI,SAAS,MAAM,QAAQ,SACzB,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;GACT,GACA,cACA,oBACA,IACF;GACA,IAAI,YAAY,MAAM,GACpB,OAAO;QACF,IAAI,YAAY,MAAM,GAC3B,OAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,Q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,SACb,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;IACT,GACA,YACF;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"module-resolution.mjs","names":[],"sources":["../../../src/lib/unplugin/module-resolution.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { LoadResult } from \"rollup\";\nimport type {\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginOptions\n} from \"unplugin\";\nimport {\n addVirtualPrefix,\n removeVirtualPrefix,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"../../plugin-utils\";\nimport { ResolveResult, UnresolvedContext } from \"../../types/context\";\nimport { ResolveOptions } from \"../../types/fs\";\n\nexport interface CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * An indicator of whether to prefix virtual module IDs with a specific string. This is useful for ensuring that virtual modules are only processed by the plugin and not by other plugins or the bundler itself.\n *\n * @remarks\n * - If set to `true`, virtual module IDs will be prefixed with the string `__powerlines-virtual:`.\n * - If set to `false`, no prefix will be added to virtual module IDs.\n *\n * @defaultValue true\n */\n prefix?: boolean;\n\n /**\n * Optional overrides for the module resolution configuration.\n *\n * @remarks\n * This allows you to customize the behavior of the module resolution hooks by providing specific configuration options.\n */\n overrides?: Partial<ResolveOptions>;\n}\n\n/**\n * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.\n *\n * @remarks\n * This includes the `resolveId` and `load` hooks.\n *\n * @see https://rollupjs.org/plugin-development/#resolveid\n * @see https://rollupjs.org/plugin-development/#load\n *\n * @param context - The plugin context.\n * @param options - Options for creating the module resolution functions.\n * @returns The module resolution hooks (`resolveId` and `load`).\n */\nexport function createUnpluginModuleResolutionFunctions<\n TContext extends UnresolvedContext\n>(\n context: TContext,\n options: CreateUnpluginModuleResolutionFunctionsOptions = {}\n): Pick<UnpluginOptions, \"resolveId\" | \"load\"> {\n return {\n async resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ResolveResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n const normalizedImporter = importer\n ? removeVirtualPrefix(importer)\n : undefined;\n\n let result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.resolve(\n normalizedId,\n normalizedImporter,\n defu(options.overrides ?? {}, {\n isFile: true,\n ...opts\n })\n );\n if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n return null;\n },\n load: {\n filter:\n options.prefix !== false\n ? {\n id: VIRTUAL_MODULE_PREFIX_REGEX\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n\n let result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.load(normalizedId);\n if (result) {\n return result;\n }\n\n return context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId\n );\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqEA,SAAgB,wCAGd,SACA,UAA0D,CAAC,GACd;CAC7C,OAAO;EACL,MAAM,UAEJ,IACA,UACA,OAEI,EAAE,SAAS,MAAM,GAC+B;GACpD,MAAM,eAAe,oBAAoB,EAAE;GAC3C,MAAM,qBAAqB,WACvB,oBAAoB,QAAQ,IAC5B;GAEJ,IAAI,SAAS,MAAM,QAAQ,SACzB,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;GACT,GACA,cACA,oBACA,IACF;GACA,IAAI,YAAY,MAAM,GACpB,OAAO;QACF,IAAI,YAAY,MAAM,GAC3B,OAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,iBAAiB,OAAO,EAAE,IAC1B,OAAO;GACf;GAGF,SAAS,MAAM,QAAQ,SACrB,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;GACT,GACA,cACA,oBACA,IACF;GACA,IAAI,YAAY,MAAM,GACpB,OAAO;QACF,IAAI,YAAY,MAAM,GAC3B,OAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,iBAAiB,OAAO,EAAE,IAC1B,OAAO;GACf;GAGF,SAAS,MAAM,QAAQ,QACrB,cACA,oBACA,KAAK,QAAQ,aAAa,CAAC,GAAG;IAC5B,QAAQ;IACR,GAAG;GACL,CAAC,CACH;GACA,IAAI,YAAY,MAAM,GACpB,OAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,iBAAiB,OAAO,EAAE,IAC1B,OAAO;GACf;GAGF,SAAS,MAAM,QAAQ,SACrB,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;GACT,GACA,cACA,oBACA,IACF;GACA,IAAI,YAAY,MAAM,GACpB,OAAO;QACF,IAAI,YAAY,MAAM,GAC3B,OAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,iBAAiB,OAAO,EAAE,IAC1B,OAAO;GACf;GAGF,OAAO;EACT;EACA,MAAM;GACJ,QACE,QAAQ,WAAW,QACf,EACE,IAAI,4BACN,IACA;GACN,MAAM,QAEJ,IACwC;IACxC,MAAM,eAAe,oBAAoB,EAAE;IAE3C,IAAI,SAAS,MAAM,QAAQ,SACzB,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;IACT,GACA,YACF;IACA,IAAI,QACF,OAAO;IAGT,SAAS,MAAM,QAAQ,SACrB,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;IACT,GACA,YACF;IACA,IAAI,QACF,OAAO;IAGT,SAAS,MAAM,QAAQ,KAAK,YAAY;IACxC,IAAI,QACF,OAAO;IAGT,OAAO,QAAQ,SACb,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;IACT,GACA,YACF;GACF;EACF;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { removeVirtualPrefix } from \"../../plugin-utils\";\nimport type { PluginContext, UnresolvedContext } from \"../../types/context\";\nimport type { UnpluginOptions } from \"../../types/unplugin\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<TContext extends UnresolvedContext>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): () => UnpluginOptions<TContext> {\n setParseImpl(context.parse);\n\n const name = options.name || \"powerlines\";\n\n const logger = context.extendLogger(\n !options.silenceHookLogging && name !== \"powerlines\" ? { source: name } : {}\n );\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return () => ({\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n context,\n resolveId,\n load\n });\n } catch (error) {\n logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): () => UnpluginOptions<TContext> {\n setParseImpl(context.parse.bind(context));\n\n const name = options.name || \"powerlines\";\n\n const logger = context.extendLogger(\n !options.silenceHookLogging && name !== \"powerlines\" ? { source: name } : {}\n );\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin starting...\");\n }\n\n await context.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of context.environment.selectHooks(\"transform\")) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(context, this), [\n getString(transformed),\n removeVirtualPrefix(id)\n ] as [code: string, id: string]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin finishing...\");\n }\n\n return context.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Finalizing Powerlines project output...\");\n }\n\n return context.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return () => ({\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n context,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n });\n } catch (error) {\n logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6DA,SAAgB,uBACd,SACA,UAAyC,CAAC,GACT;CACjC,aAAa,QAAQ,KAAK;CAE1B,MAAM,OAAO,QAAQ,QAAQ;CAE7B,MAAM,SAAS,QAAQ,aACrB,CAAC,QAAQ,sBAAsB,SAAS,eAAe,EAAE,QAAQ,KAAK,IAAI,CAAC,CAC7E;CACA,OAAO,MAAM,gBAAgB,UAAU,IAAI,EAAE,QAAQ;CAErD,IAAI;EACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,OAAO;EAEpE,cAAc;GACZ,MACE,KAAK,YAAY,MAAM,eACnB,eACA,cAAc,UAAU,IAAI;GAClC;GACA;GACA;EACF;CACF,SAAS,OAAO;EACd,OAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EAEnE,MAAM;CACR;AACF;;;;;;;AAUA,SAAgB,eACd,SACA,UAAiC,CAAC,GACD;CACjC,aAAa,QAAQ,MAAM,KAAK,OAAO,CAAC;CAExC,MAAM,OAAO,QAAQ,QAAQ;CAE7B,MAAM,SAAS,QAAQ,aACrB,CAAC,QAAQ,sBAAsB,SAAS,eAAe,EAAE,QAAQ,KAAK,IAAI,CAAC,CAC7E;CACA,OAAO,MAAM,gBAAgB,UAAU,IAAI,EAAE,QAAQ;CAErD,IAAI;EACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,OAAO;EAEpE,eAAe,aAAuC;GACpD,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,qCAAqC;GAGpD,MAAM,QAAQ,SAAS,cAAc,EACnC,YAAY,KACd,CAAC;EACH;EAEA,eAAe,UAEb,MACA,IAC6C;GAC7C,IAAI,cAAwC;GAE5C,KAAK,MAAM,QAAQ,QAAQ,YAAY,YAAY,WAAW,GAAG;IAC/D,MAAM,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,SAAS,IAAI,GAAG,CACvD,UAAU,WAAW,GACrB,oBAAoB,EAAE,CACxB,CAA+B;IACjC,IAAI,QACF,cAAc;GAElB;GAEA,OAAO;EACT;EAEA,eAAe,WAAoD;GACjE,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,sCAAsC;GAGrD,OAAO,QAAQ,SAAS,YAAY,EAClC,YAAY,KACd,CAAC;EACH;EAEA,eAAe,cAA6B;GAC1C,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,yCAAyC;GAGxD,OAAO,QAAQ,SAAS,eAAe,EACrC,YAAY,KACd,CAAC;EACH;EAEA,cAAc;GACZ,MACE,KAAK,YAAY,MAAM,eACnB,eACA,cAAc,UAAU,IAAI;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA,MAAM,EACJ,mBAAmB,KACrB;EACF;CACF,SAAS,OAAO;EACd,OAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EAEnE,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { removeVirtualPrefix } from \"../../plugin-utils\";\nimport type { PluginContext, UnresolvedContext } from \"../../types/context\";\nimport type { UnpluginOptions } from \"../../types/unplugin\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<TContext extends UnresolvedContext>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): () => UnpluginOptions<TContext> {\n setParseImpl(context.parse);\n\n const name = options.name || \"powerlines\";\n\n const logger = context.extendLogger(\n !options.silenceHookLogging && name !== \"powerlines\" ? { source: name } : {}\n );\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return () => ({\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n context,\n resolveId,\n load\n });\n } catch (error) {\n logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): () => UnpluginOptions<TContext> {\n setParseImpl(context.parse.bind(context));\n\n const name = options.name || \"powerlines\";\n\n const logger = context.extendLogger(\n !options.silenceHookLogging && name !== \"powerlines\" ? { source: name } : {}\n );\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin starting...\");\n }\n\n await context.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of context.environment.selectHooks(\"transform\")) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(context, this), [\n getString(transformed),\n removeVirtualPrefix(id)\n ] as [code: string, id: string]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin finishing...\");\n }\n\n return context.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Finalizing Powerlines project output...\");\n }\n\n return context.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return () => ({\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n context,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n });\n } catch (error) {\n logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6DA,SAAgB,uBACd,SACA,UAAyC,CAAC,GACT;CACjC,aAAa,QAAQ,KAAK;CAE1B,MAAM,OAAO,QAAQ,QAAQ;CAE7B,MAAM,SAAS,QAAQ,aACrB,CAAC,QAAQ,sBAAsB,SAAS,eAAe,EAAE,QAAQ,KAAK,IAAI,CAAC,CAC7E;CACA,OAAO,MAAM,gBAAgB,UAAU,IAAI,EAAE,QAAQ;CAErD,IAAI;EACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,OAAO;EAEpE,cAAc;GACZ,MACE,KAAK,YAAY,MAAM,eACnB,eACA,cAAc,UAAU,IAAI;GAClC;GACA;GACA;EACF;CACF,SAAS,OAAO;EACd,OAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EAEnE,MAAM;CACR;AACF;;;;;;;AAUA,SAAgB,eACd,SACA,UAAiC,CAAC,GACD;CACjC,aAAa,QAAQ,MAAM,KAAK,OAAO,CAAC;CAExC,MAAM,OAAO,QAAQ,QAAQ;CAE7B,MAAM,SAAS,QAAQ,aACrB,CAAC,QAAQ,sBAAsB,SAAS,eAAe,EAAE,QAAQ,KAAK,IAAI,CAAC,CAC7E;CACA,OAAO,MAAM,gBAAgB,UAAU,IAAI,EAAE,QAAQ;CAErD,IAAI;EACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,OAAO;EAEpE,eAAe,aAAuC;GACpD,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,qCAAqC;GAGpD,MAAM,QAAQ,SAAS,cAAc,EACnC,YAAY,KACd,CAAC;EACH;EAEA,eAAe,UAEb,MACA,IAC6C;GAC7C,IAAI,cAAwC;GAE5C,KAAK,MAAM,QAAQ,QAAQ,YAAY,YAAY,WAAW,GAAG;IAC/D,MAAM,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,SAAS,IAAI,GAAG,CACvD,UAAU,WAAW,GACrB,oBAAoB,EAAE,CACxB,CAA+B;IACjC,IAAI,QACF,cAAc;GAElB;GAEA,OAAO;EACT;EAEA,eAAe,WAAoD;GACjE,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,sCAAsC;GAGrD,OAAO,QAAQ,SAAS,YAAY,EAClC,YAAY,KACd,CAAC;EACH;EAEA,eAAe,cAA6B;GAC1C,IAAI,CAAC,QAAQ,oBACX,OAAO,MAAM,yCAAyC;GAGxD,OAAO,QAAQ,SAAS,eAAe,EACrC,YAAY,KACd,CAAC;EACH;EAEA,cAAc;GACZ,MACE,KAAK,YAAY,MAAM,eACnB,eACA,cAAc,UAAU,IAAI;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA,MAAM,EACJ,mBAAmB,KACrB;EACF;CACF,SAAS,OAAO;EACd,OAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EAEnE,MAAM;CACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"file-header.mjs","names":[],"sources":["../../../src/lib/utilities/file-header.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\n/**\n * Generates a file header comment with a warning about automatic overwriting.\n *\n * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.\n * @param framework - The name of the framework to include in the warning message. Defaults to \"powerlines\".\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarningText(\n overwrite = true,\n framework = \"powerlines\"\n): string {\n return overwrite !== false\n ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`;\n}\n\n/**\n * Generates a file header warning message based on the provided context.\n *\n * @param context - The Powerlines context.\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarning(context: Context): string {\n return getFileHeaderWarningText(\n context.config.output?.overwrite,\n context.config.framework?.name\n );\n}\n\n/**\n * Generates a file header comment for a generated source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.\n * @returns A string containing the file header comment.\n */\nexport function getFileHeader(context: Context, comment = \"//\"): string {\n return `\n${comment} Generated by ${titleCase(context.config.framework?.name) || \"Powerlines\"}\n${comment} ${getFileHeaderWarning(context)}\n`;\n}\n\n/**\n * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.\n * @returns A string containing the file header comment for a TypeScript file.\n */\nexport function getTypescriptFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getFileHeader(context)}\n\n`;\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgB,yBACd,YAAY,MACZ,YAAY,cACJ;CACR,OAAO,cAAc,QACjB,0JACA,+CAA8B,IAAI,KAAK,EAAC,CAAC,eAAe,EAAE,mCAAmC,UAAU,SAAS,EAAE;AACxH;;;;;;;AAQA,SAAgB,qBAAqB,SAA0B;CAC7D,OAAO,yBACL,QAAQ,OAAO,QAAQ,WACvB,QAAQ,OAAO,WAAW,IAC5B;AACF;;;;;;;;AASA,SAAgB,cAAc,SAAkB,UAAU,MAAc;CACtE,OAAO;EACP,QAAQ,gBAAgB,UAAU,QAAQ,OAAO,WAAW,IAAI,KAAK,aAAa;EAClF,QAAQ,GAAG,qBAAqB,OAAO,EAAE;;AAE3C;;;;;;;;AASA,SAAgB,wBACd,SACA,UAA6B,CAAC,GACtB;CACR,MAAM,EAAE,YAAY,MAAM,iBAAiB,UAAU;CAErD,OAAO;;EAEP,iBAAiB,uBAAuB,KAAK,YAAY,OAAO,UAAU,MAAM,KAAK;EACrF,cAAc,OAAO,EAAE;;;AAGzB"}
1
+ {"version":3,"file":"file-header.mjs","names":[],"sources":["../../../src/lib/utilities/file-header.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\n/**\n * Generates a file header comment with a warning about automatic overwriting.\n *\n * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.\n * @param framework - The name of the framework to include in the warning message. Defaults to \"powerlines\".\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarningText(\n overwrite = true,\n framework = \"powerlines\"\n): string {\n return overwrite !== false\n ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`;\n}\n\n/**\n * Generates a file header warning message based on the provided context.\n *\n * @param context - The Powerlines context.\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarning(context: Context): string {\n return getFileHeaderWarningText(\n context.config.output?.overwrite,\n context.config.framework?.name\n );\n}\n\n/**\n * Generates a file header comment for a generated source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.\n * @returns A string containing the file header comment.\n */\nexport function getFileHeader(context: Context, comment = \"//\"): string {\n return `\n${comment} Generated by ${titleCase(context.config.framework?.name) || \"Powerlines\"}\n${comment} ${getFileHeaderWarning(context)}\n`;\n}\n\n/**\n * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.\n * @returns A string containing the file header comment for a TypeScript file.\n */\nexport function getTypescriptFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getFileHeader(context)}\n\n`;\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgB,yBACd,YAAY,MACZ,YAAY,cACJ;CACR,OAAO,cAAc,QACjB,0JACA,+CAA8B,IAAI,KAAK,EAAC,CAAC,eAAe,EAAE,mCAAmC,UAAU,SAAS,EAAE;AACxH;;;;;;;AAQA,SAAgB,qBAAqB,SAA0B;CAC7D,OAAO,yBACL,QAAQ,OAAO,QAAQ,WACvB,QAAQ,OAAO,WAAW,IAC5B;AACF;;;;;;;;AASA,SAAgB,cAAc,SAAkB,UAAU,MAAc;CACtE,OAAO;EACP,QAAQ,gBAAgB,UAAU,QAAQ,OAAO,WAAW,IAAI,KAAK,aAAa;EAClF,QAAQ,GAAG,qBAAqB,OAAO,EAAE;;AAE3C;;;;;;;;AASA,SAAgB,wBACd,SACA,UAA6B,CAAC,GACtB;CACR,MAAM,EAAE,YAAY,MAAM,iBAAiB,UAAU;CAErD,OAAO;;EAEP,iBAAiB,uBAAuB,KAAK,YAAY,OAAO,UAAU,MAAM,KAAK;EACrF,cAAc,OAAO,EAAE;;;AAGzB"}
@@ -3,6 +3,8 @@ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
3
  let _stryke_path_append = require("@stryke/path/append");
4
4
  let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
5
5
  let defu = require("defu");
6
+ let _storm_software_prettier_config = require("@storm-software/prettier/config");
7
+ _storm_software_prettier_config = require_runtime.__toESM(_storm_software_prettier_config, 1);
6
8
  let _stryke_fs_list_files = require("@stryke/fs/list-files");
7
9
  let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
8
10
  let prettier = require("prettier");
@@ -23,7 +25,11 @@ async function format(context, path, data, force = false) {
23
25
  if (!force && (context.config.output.copy && (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.config.cwd)) || (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.path, context.config.cwd)))) return data;
24
26
  let code = data;
25
27
  try {
26
- const resolvedConfig = await (0, prettier.resolveConfig)(path);
28
+ let resolvedConfig = null;
29
+ try {
30
+ resolvedConfig = await (0, prettier.resolveConfig)(path);
31
+ } catch {}
32
+ resolvedConfig ??= _storm_software_prettier_config.default;
27
33
  if (resolvedConfig) code = await (0, prettier.format)(data, (0, defu.defu)({
28
34
  absolutePath: path,
29
35
  ...resolvedConfig
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.cts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAO;;;;AAAA;AAoDV;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
1
+ {"version":3,"file":"format.d.cts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAqCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAO;;;;AAAA;AA6DV;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.mts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAO;;;;AAAA;AAoDV;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
1
+ {"version":3,"file":"format.d.mts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAqCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAO;;;;AAAA;AA6DV;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
@@ -1,6 +1,7 @@
1
1
  import { appendPath } from "@stryke/path/append";
2
2
  import { findFileExtension } from "@stryke/path/file-path-fns";
3
3
  import { defu as defu$1 } from "defu";
4
+ import prettierConfig from "@storm-software/prettier/config";
4
5
  import { listFiles } from "@stryke/fs/list-files";
5
6
  import { isParentPath } from "@stryke/path/is-parent-path";
6
7
  import { format as format$1, resolveConfig } from "prettier";
@@ -20,7 +21,11 @@ async function format(context, path, data, force = false) {
20
21
  if (!force && (context.config.output.copy && isParentPath(path, appendPath(context.config.output.copy.path, context.config.cwd)) || isParentPath(path, appendPath(context.config.output.path, context.config.cwd)))) return data;
21
22
  let code = data;
22
23
  try {
23
- const resolvedConfig = await resolveConfig(path);
24
+ let resolvedConfig = null;
25
+ try {
26
+ resolvedConfig = await resolveConfig(path);
27
+ } catch {}
28
+ resolvedConfig ??= prettierConfig;
24
29
  if (resolvedConfig) code = await format$1(data, defu$1({
25
30
  absolutePath: path,
26
31
  ...resolvedConfig
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/format.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) ||\n isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n return data;\n }\n\n let code = data;\n try {\n const resolvedConfig = await resolveConfig(path);\n if (resolvedConfig) {\n code = await prettier(\n data,\n defu(\n {\n absolutePath: path,\n ...resolvedConfig\n },\n findFileExtension(path) === \"ts\" || findFileExtension(path) === \"tsx\"\n ? { plugins: [importsPlugin] }\n : {}\n )\n );\n }\n } catch (error) {\n throw new Error(\n `Failed to format file at ${path} with Prettier: ${\n (error as Error).message\n }`,\n { cause: error }\n );\n }\n\n return code;\n}\n\n/**\n * Formats all files in a folder using Prettier based on their file paths.\n *\n * @param context - The Powerlines context.\n * @param path - The folder path containing files to format.\n * @returns A promise that resolves when all files have been formatted.\n */\nexport async function formatFolder(context: Context, path: string) {\n if (\n !context.config.output.copy ||\n (!isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n ) &&\n !isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n await Promise.allSettled(\n (await listFiles(path)).map(async file => {\n if (\n (!context.config.output.copy ||\n !isParentPath(\n file,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) &&\n !isParentPath(\n file,\n appendPath(context.config.output.path, context.config.cwd)\n )\n ) {\n const data = await context.fs.read(file);\n if (data) {\n const formatted = await format(context, file, data);\n\n return context.fs.write(file, formatted);\n }\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,eAAsB,OACpB,SACA,MACA,MACA,QAAQ,OACS;CAC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MAAM,MAAM,SAAS;GACzC;EACF;CACF,CAAC,CACH;AAEJ"}
1
+ {"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/format.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport prettierConfig from \"@storm-software/prettier/config\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { Options, format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) ||\n isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n return data;\n }\n\n let code = data;\n try {\n let resolvedConfig = null as Options | null;\n try {\n resolvedConfig = await resolveConfig(path);\n } catch {\n // If resolving the config fails, we can ignore it and use the default Prettier settings\n }\n\n // If no config was found, we can use the default Prettier settings\n resolvedConfig ??= prettierConfig;\n\n if (resolvedConfig) {\n code = await prettier(\n data,\n defu(\n {\n absolutePath: path,\n ...resolvedConfig\n },\n findFileExtension(path) === \"ts\" || findFileExtension(path) === \"tsx\"\n ? { plugins: [importsPlugin] }\n : {}\n )\n );\n }\n } catch (error) {\n throw new Error(\n `Failed to format file at ${path} with Prettier: ${\n (error as Error).message\n }`,\n { cause: error }\n );\n }\n\n return code;\n}\n\n/**\n * Formats all files in a folder using Prettier based on their file paths.\n *\n * @param context - The Powerlines context.\n * @param path - The folder path containing files to format.\n * @returns A promise that resolves when all files have been formatted.\n */\nexport async function formatFolder(context: Context, path: string) {\n if (\n !context.config.output.copy ||\n (!isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n ) &&\n !isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n await Promise.allSettled(\n (await listFiles(path)).map(async file => {\n if (\n (!context.config.output.copy ||\n !isParentPath(\n file,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) &&\n !isParentPath(\n file,\n appendPath(context.config.output.path, context.config.cwd)\n )\n ) {\n const data = await context.fs.read(file);\n if (data) {\n const formatted = await format(context, file, data);\n\n return context.fs.write(file, formatted);\n }\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,OACpB,SACA,MACA,MACA,QAAQ,OACS;CACjB,IACE,CAAC,UACC,QAAQ,OAAO,OAAO,QACtB,aACE,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,GAAG,CAChE,KACA,aACE,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,GAAG,CAC3D,IAEF,OAAO;CAGT,IAAI,OAAO;CACX,IAAI;EACF,IAAI,iBAAiB;EACrB,IAAI;GACF,iBAAiB,MAAM,cAAc,IAAI;EAC3C,QAAQ,CAER;EAGA,mBAAmB;EAEnB,IAAI,gBACF,OAAO,MAAMA,SACX,MACAC,OACE;GACE,cAAc;GACd,GAAG;EACL,GACA,kBAAkB,IAAI,MAAM,QAAQ,kBAAkB,IAAI,MAAM,QAC5D,EAAE,SAAS,CAAC,aAAa,EAAE,IAC3B,CAAC,CACP,CACF;CAEJ,SAAS,OAAO;EACd,MAAM,IAAI,MACR,4BAA4B,KAAK,kBAC9B,MAAgB,WAEnB,EAAE,OAAO,MAAM,CACjB;CACF;CAEA,OAAO;AACT;;;;;;;;AASA,eAAsB,aAAa,SAAkB,MAAc;CACjE,IACE,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACA,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,GAAG,CAChE,KACE,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,GAAG,CAC3D,GAEF,MAAM,QAAQ,YACX,MAAM,UAAU,IAAI,EAAC,CAAE,IAAI,OAAM,SAAQ;EACxC,KACG,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,GAAG,CAChE,MACF,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,GAAG,CAC3D,GACA;GACA,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,IAAI;GACvC,IAAI,MAAM;IACR,MAAM,YAAY,MAAM,OAAO,SAAS,MAAM,IAAI;IAElD,OAAO,QAAQ,GAAG,MAAM,MAAM,SAAS;GACzC;EACF;CACF,CAAC,CACH;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"source-file.mjs","names":[],"sources":["../../../src/lib/utilities/source-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,UACd,MACQ;CACR,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,SAAS,IAAI,GACf,OAAO;CAGT,IAAI,YAAY,IAAI,KAAK,UAAU,MACjC,OAAO,KAAK;CAGd,OAAO,KAAK,SAAS;AACvB;;;;;;;AAQA,SAAgB,eAAe,MAAyC;CACtE,IAAI,SAAS,IAAI,GACf,OAAO,IAAI,YAAY,IAAI;CAG7B,OAAO;AACT;;;;;;;;AASA,SAAgB,cACd,MACA,IACY;CAGZ,OAAO;EACL;EACA,MAAM,eAJQ,QAAQ,uBAAuB,EAAE,CAInB;EAC5B,KAAK,CAAC;CACR;AACF"}
1
+ {"version":3,"file":"source-file.mjs","names":[],"sources":["../../../src/lib/utilities/source-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,UACd,MACQ;CACR,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,SAAS,IAAI,GACf,OAAO;CAGT,IAAI,YAAY,IAAI,KAAK,UAAU,MACjC,OAAO,KAAK;CAGd,OAAO,KAAK,SAAS;AACvB;;;;;;;AAQA,SAAgB,eAAe,MAAyC;CACtE,IAAI,SAAS,IAAI,GACf,OAAO,IAAI,YAAY,IAAI;CAG7B,OAAO;AACT;;;;;;;;AASA,SAAgB,cACd,MACA,IACY;CAGZ,OAAO;EACL;EACA,MAAM,eAJQ,QAAQ,uBAAuB,EAAE,CAInB;EAC5B,KAAK,CAAC;CACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"source-map.mjs","names":[],"sources":["../../../src/lib/utilities/source-map.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n"],"mappings":";;;AAsBA,MAAM,MAAM,IAAI,KAAK;;;;;;;;;AAUrB,SAAgB,kBACd,MACA,IACA,YAC6B;CAC7B,IAAI,CAAC,YACH;CAGF,MAAM,OAAO,IAAI,UAAU,KAAK,SAAS,GAAG,UAAU;CACtD,IAAI,qBAAqB,IAAI;CAE7B,IAAI,SAAS;CAEb,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SACvC,IAAI,KAAK,QAAQ;EACf,MAAM,CAAC,MAAM,QAAQ,KAAK;EAC1B,MAAM,aAAa,KAAK;EAExB,QAAQ,MAAR;GACE,KAAK;IACH,UAAU;IACV;GAEF,KAAK;IACH,KAAK,YAAY,QAAQ,IAAI;IAC7B;GAEF,KAAK,IAAI;IACP,MAAM,OAAO,KAAK,GAAG,QAAQ,CAAC;IAE9B,IAAI,QAAQ,KAAK,OAAO,GAAG;KACzB,MAAM,cAAc,KAAK;KAEzB,MAAM,gCAAgC,KAAK,OAAO,IAAI;KACtD,MAAM,cACJ,SAAS,KAAK,IAAI,+BAA+B,CAAC;KAEpD,KAAK,OAAO,aAAa,SAAS,YAAY,WAAW;KACzD,SAAS;IACX,OACE,KAAK,OAAO,QAAQ,SAAS,UAAU;IAGzC,UAAU;IAEV;GACF;EACF;CACF;CAGF,IAAI,CAAC,KAAK,WAAW,GACnB;CAGF,OAAO;EACL,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;EAClB,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"source-map.mjs","names":[],"sources":["../../../src/lib/utilities/source-map.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n"],"mappings":";;;AAsBA,MAAM,MAAM,IAAI,KAAK;;;;;;;;;AAUrB,SAAgB,kBACd,MACA,IACA,YAC6B;CAC7B,IAAI,CAAC,YACH;CAGF,MAAM,OAAO,IAAI,UAAU,KAAK,SAAS,GAAG,UAAU;CACtD,IAAI,qBAAqB,IAAI;CAE7B,IAAI,SAAS;CAEb,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SACvC,IAAI,KAAK,QAAQ;EACf,MAAM,CAAC,MAAM,QAAQ,KAAK;EAC1B,MAAM,aAAa,KAAK;EAExB,QAAQ,MAAR;GACE,KAAK;IACH,UAAU;IACV;GAEF,KAAK;IACH,KAAK,YAAY,QAAQ,IAAI;IAC7B;GAEF,KAAK,IAAI;IACP,MAAM,OAAO,KAAK,GAAG,QAAQ,CAAC;IAE9B,IAAI,QAAQ,KAAK,OAAO,GAAG;KACzB,MAAM,cAAc,KAAK;KAEzB,MAAM,gCAAgC,KAAK,OAAO,IAAI;KACtD,MAAM,cACJ,SAAS,KAAK,IAAI,+BAA+B,CAAC;KAEpD,KAAK,OAAO,aAAa,SAAS,YAAY,WAAW;KACzD,SAAS;IACX,OACE,KAAK,OAAO,QAAQ,SAAS,UAAU;IAGzC,UAAU;IAEV;GACF;EACF;CACF;CAGF,IAAI,CAAC,KAAK,WAAW,GACnB;CAGF,OAAO;EACL,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;EAClB,CAAC;CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"write-file.mjs","names":["writeFileBase"],"sources":["../../../src/lib/utilities/write-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/logging\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n \"error\",\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,eAAsB,UACpB,KACA,UACA,SACA,aAAa,OACb;CACA,IAAI;EACF,IAAI,YACF,MAAMA,YAAc,UAAU,OAAO;OAQrC,MAAMA,YAAc,UAAU,MALN,OAAO,SAAS;GACtC,GAAI,MAFe,cAAc,QAAQ,KAE3B,CAAC;GACf;EACF,CAAC,KAE0C,EAAE;CAEjD,SAAS,OAAO;EACd,IACE,SACA,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,IACvG;CACF;AACF"}
1
+ {"version":3,"file":"write-file.mjs","names":["writeFileBase"],"sources":["../../../src/lib/utilities/write-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/logging\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n \"error\",\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,eAAsB,UACpB,KACA,UACA,SACA,aAAa,OACb;CACA,IAAI;EACF,IAAI,YACF,MAAMA,YAAc,UAAU,OAAO;OAQrC,MAAMA,YAAc,UAAU,MALN,OAAO,SAAS;GACtC,GAAI,MAFe,cAAc,QAAQ,KAE3B,CAAC;GACf;EACF,CAAC,KAE0C,EAAE;CAEjD,SAAS,OAAO;EACd,IACE,SACA,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,IACvG;CACF;AACF"}
package/dist/lib/vfs.cjs CHANGED
@@ -875,7 +875,7 @@ var VirtualFileSystem = class VirtualFileSystem {
875
875
  try {
876
876
  if (!options.skipFormat) code = await require_lib_utilities_format.format(this.#context, resolvedPath, data);
877
877
  } catch (err) {
878
- if (require_constants_extensions.DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
878
+ if (require_constants_extensions.DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: false }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
879
879
  code = data;
880
880
  }
881
881
  this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(code)).size)})`);
package/dist/lib/vfs.mjs CHANGED
@@ -872,7 +872,7 @@ var VirtualFileSystem = class VirtualFileSystem {
872
872
  try {
873
873
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
874
874
  } catch (err) {
875
- if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
875
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: false }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
876
876
  code = data;
877
877
  }
878
878
  this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);