@powerlines/plugin-unimport 0.1.303 → 0.1.304

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -3,8 +3,8 @@ import "./types/index.cjs";
3
3
  import { Plugin } from "powerlines";
4
4
 
5
5
  //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface UserConfig {
6
+ declare module "@powerlines/core" {
7
+ interface BaseConfig {
8
8
  unimport?: UnimportPluginOptions;
9
9
  }
10
10
  }
package/dist/index.d.mts CHANGED
@@ -3,8 +3,8 @@ import "./types/index.mjs";
3
3
  import { Plugin } from "powerlines";
4
4
 
5
5
  //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface UserConfig {
6
+ declare module "@powerlines/core" {
7
+ interface BaseConfig {
8
8
  unimport?: UnimportPluginOptions;
9
9
  }
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["options"],"sources":["../src/index.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 { throttle } from \"@stryke/helpers/throttle\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport MagicString from \"magic-string\";\nimport { Plugin } from \"powerlines\";\nimport {\n createUnimport,\n ImportInjectionResult,\n InjectImportsOptions\n} from \"unimport\";\nimport {\n UnimportContext,\n UnimportPluginContext,\n UnimportPluginOptions,\n UnimportPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n export interface UserConfig {\n unimport?: UnimportPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Unimport for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends UnimportPluginContext = UnimportPluginContext\n>(\n options: UnimportPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"unimport\",\n config() {\n return {\n unimport: defu(options, {\n commentsDisable: [\n \"@unimport-disable\",\n \"@unimport-ignore\",\n \"@imports-disable\",\n \"@imports-ignore\",\n \"@powerlines-disable\",\n \"@powerlines-ignore\"\n ],\n commentsDebug: [\n \"@unimport-debug\",\n \"@imports-debug\",\n \"@powerlines-debug\"\n ],\n injectAtEnd: true\n })\n } as Partial<UnimportPluginUserConfig>;\n },\n async configResolved() {\n const { injectImports, init, ...rest } = createUnimport(\n this.config.unimport\n );\n this.unimport = { ...rest } as UnimportContext;\n\n this.unimport.dumpImports = throttle(async () => {\n this.trace(\"Dumping import file...\");\n\n const items = await this.unimport.getImports();\n\n this.trace(\n `Writing imports-dump JSON file: ${joinPaths(this.dataPath, \"imports-dump.json\")}`\n );\n\n const content = StormJSON.stringify(items);\n if (content.trim() !== this.unimport.lastImportsDump?.trim()) {\n this.unimport.lastImportsDump = content;\n await this.fs.write(\n joinPaths(this.dataPath, \"imports-dump.json\"),\n content\n );\n }\n }, 1000);\n\n this.unimport.injectImports = async (\n code: string | MagicString,\n id?: string,\n options?: InjectImportsOptions\n ): Promise<ImportInjectionResult> => {\n const result = await injectImports(code, id, options);\n\n if (!result.s.hasChanged()) {\n return result;\n }\n\n await this.unimport.dumpImports();\n\n return result;\n };\n\n this.unimport.init = async () => {\n await init();\n await this.unimport.dumpImports();\n };\n\n await this.unimport.init();\n },\n async transform(code, id) {\n const result = await this.unimport.injectImports(code, id);\n if (!result.s.hasChanged()) {\n return null;\n }\n\n return {\n id,\n code: result.s.toString(),\n map: result.s.generateMap({\n source: id,\n includ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AM,OAAO,EAAE,UAAU;IACzB,KAAK,OAAO,EAAE,YAAY;KACxB,QAAQ;KACR,gBAAgB;KAChB,OAAO;KACR,CAAC;IACH;;EAEJ;;AAGH,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["options"],"sources":["../src/index.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 { throttle } from \"@stryke/helpers/throttle\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport MagicString from \"magic-string\";\nimport { Plugin } from \"powerlines\";\nimport {\n createUnimport,\n ImportInjectionResult,\n InjectImportsOptions\n} from \"unimport\";\nimport {\n UnimportContext,\n UnimportPluginContext,\n UnimportPluginOptions,\n UnimportPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface BaseConfig {\n unimport?: UnimportPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Unimport for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends UnimportPluginContext = UnimportPluginContext\n>(\n options: UnimportPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"unimport\",\n config() {\n return {\n unimport: defu(options, {\n commentsDisable: [\n \"@unimport-disable\",\n \"@unimport-ignore\",\n \"@imports-disable\",\n \"@imports-ignore\",\n \"@powerlines-disable\",\n \"@powerlines-ignore\"\n ],\n commentsDebug: [\n \"@unimport-debug\",\n \"@imports-debug\",\n \"@powerlines-debug\"\n ],\n injectAtEnd: true\n })\n } as Partial<UnimportPluginUserConfig>;\n },\n async configResolved() {\n const { injectImports, init, ...rest } = createUnimport(\n this.config.unimport\n );\n this.unimport = { ...rest } as UnimportContext;\n\n this.unimport.dumpImports = throttle(async () => {\n this.trace(\"Dumping import file...\");\n\n const items = await this.unimport.getImports();\n\n this.trace(\n `Writing imports-dump JSON file: ${joinPaths(this.dataPath, \"imports-dump.json\")}`\n );\n\n const content = StormJSON.stringify(items);\n if (content.trim() !== this.unimport.lastImportsDump?.trim()) {\n this.unimport.lastImportsDump = content;\n await this.fs.write(\n joinPaths(this.dataPath, \"imports-dump.json\"),\n content\n );\n }\n }, 1000);\n\n this.unimport.injectImports = async (\n code: string | MagicString,\n id?: string,\n options?: InjectImportsOptions\n ): Promise<ImportInjectionResult> => {\n const result = await injectImports(code, id, options);\n\n if (!result.s.hasChanged()) {\n return result;\n }\n\n await this.unimport.dumpImports();\n\n return result;\n };\n\n this.unimport.init = async () => {\n await init();\n await this.unimport.dumpImports();\n };\n\n await this.unimport.init();\n },\n async transform(code, id) {\n const result = await this.unimport.injectImports(code, id);\n if (!result.s.hasChanged()) {\n return null;\n }\n\n return {\n id,\n code: result.s.toString(),\n map: result.s.generateMap({\n source: id,\n includeContent: true,\n hires: true\n })\n };\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;AAkDA,MAAa,UAGX,YACqB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO,EACL,UAAU,KAAK,SAAS;IACtB,iBAAiB;KACf;KACA;KACA;KACA;KACA;KACA;KACD;IACD,eAAe;KACb;KACA;KACA;KACD;IACD,aAAa;IACd,CAAC,EACH;;EAEH,MAAM,iBAAiB;GACrB,MAAM,EAAE,eAAe,MAAM,GAAG,SAAS,eACvC,KAAK,OAAO,SACb;AACD,QAAK,WAAW,EAAE,GAAG,MAAM;AAE3B,QAAK,SAAS,cAAc,SAAS,YAAY;AAC/C,SAAK,MAAM,yBAAyB;IAEpC,MAAM,QAAQ,MAAM,KAAK,SAAS,YAAY;AAE9C,SAAK,MACH,mCAAmC,UAAU,KAAK,UAAU,oBAAoB,GACjF;IAED,MAAM,UAAU,UAAU,UAAU,MAAM;AAC1C,QAAI,QAAQ,MAAM,KAAK,KAAK,SAAS,iBAAiB,MAAM,EAAE;AAC5D,UAAK,SAAS,kBAAkB;AAChC,WAAM,KAAK,GAAG,MACZ,UAAU,KAAK,UAAU,oBAAoB,EAC7C,QACD;;MAEF,IAAK;AAER,QAAK,SAAS,gBAAgB,OAC5B,MACA,IACA,cACmC;IACnC,MAAM,SAAS,MAAM,cAAc,MAAM,IAAIA,UAAQ;AAErD,QAAI,CAAC,OAAO,EAAE,YAAY,CACxB,QAAO;AAGT,UAAM,KAAK,SAAS,aAAa;AAEjC,WAAO;;AAGT,QAAK,SAAS,OAAO,YAAY;AAC/B,UAAM,MAAM;AACZ,UAAM,KAAK,SAAS,aAAa;;AAGnC,SAAM,KAAK,SAAS,MAAM;;EAE5B,MAAM,UAAU,MAAM,IAAI;GACxB,MAAM,SAAS,MAAM,KAAK,SAAS,cAAc,MAAM,GAAG;AAC1D,OAAI,CAAC,OAAO,EAAE,YAAY,CACxB,QAAO;AAGT,UAAO;IACL;IACA,MAAM,OAAO,EAAE,UAAU;IACzB,KAAK,OAAO,EAAE,YAAY;KACxB,QAAQ;KACR,gBAAgB;KAChB,OAAO;KACR,CAAC;IACH;;EAEJ;;AAGH,kBAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unimport",
3
- "version": "0.1.303",
3
+ "version": "0.1.304",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to add imports to source code automatically via unimport.",
6
6
  "repository": {
@@ -94,14 +94,14 @@
94
94
  "@stryke/path": "^0.26.6",
95
95
  "defu": "^6.1.4",
96
96
  "magic-string": "^0.30.21",
97
- "powerlines": "^0.39.10",
97
+ "powerlines": "^0.39.11",
98
98
  "unimport": "^5.7.0"
99
99
  },
100
100
  "devDependencies": {
101
- "@powerlines/plugin-plugin": "^0.12.253",
101
+ "@powerlines/plugin-plugin": "^0.12.254",
102
102
  "@types/node": "^25.3.3"
103
103
  },
104
104
  "publishConfig": { "access": "public" },
105
105
  "types": "./dist/index.d.cts",
106
- "gitHead": "905dbeee1a9e2658cf70489e977cafac62733e46"
106
+ "gitHead": "e63eb5a0ecd0e5ee3e030388ad1c534b3ecb2136"
107
107
  }