@powerlines/plugin-unimport 0.1.432 → 0.1.435

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.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@stryke/helpers/throttle`),n=require(`@stryke/json/storm-json`),r=require(`@stryke/path/join`),i=require(`defu`);i=e.__toESM(i,1);let a=require(`unimport`);const o=e=>({name:`unimport`,config(){return{unimport:(0,i.default)(e,{commentsDisable:[`@unimport-disable`,`@unimport-ignore`,`@imports-disable`,`@imports-ignore`,`@powerlines-disable`,`@powerlines-ignore`],commentsDebug:[`@unimport-debug`,`@imports-debug`,`@powerlines-debug`],injectAtEnd:!0})}},async configResolved(){let{injectImports:e,init:i,...o}=(0,a.createUnimport)(this.config.unimport);this.unimport={...o},this.unimport.dumpImports=(0,t.throttle)(async()=>{this.trace(`Dumping import file...`);let e=await this.unimport.getImports();this.trace(`Writing imports-dump JSON file: ${(0,r.joinPaths)(this.dataPath,`imports-dump.json`)}`);let t=n.StormJSON.stringify(e);t.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=t,await this.fs.write((0,r.joinPaths)(this.dataPath,`imports-dump.json`),t))},1e3),this.unimport.injectImports=async(t,n,r)=>{let i=await e(t,n,r);return i.s.hasChanged()&&await this.unimport.dumpImports(),i},this.unimport.init=async()=>{await i(),await this.unimport.dumpImports()},await this.unimport.init()},async transform(e,t){let n=await this.unimport.injectImports(e,t);return n.s.hasChanged()?{id:t,code:n.s.toString(),map:n.s.generateMap({source:t,includeContent:!0,hires:!0})}:null}});exports.default=o,exports.plugin=o;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@stryke/async`),n=require(`@stryke/json/storm-json`),r=require(`@stryke/path/join`),i=require(`defu`);i=e.__toESM(i,1);let a=require(`unimport`);const o=e=>({name:`unimport`,config(){return{unimport:(0,i.default)(e,{commentsDisable:[`@unimport-disable`,`@unimport-ignore`,`@imports-disable`,`@imports-ignore`,`@powerlines-disable`,`@powerlines-ignore`],commentsDebug:[`@unimport-debug`,`@imports-debug`,`@powerlines-debug`],injectAtEnd:!0})}},async configResolved(){let{injectImports:e,init:i,...o}=(0,a.createUnimport)(this.config.unimport);this.unimport={...o},this.unimport.dumpImports=(0,t.throttle)(async()=>{this.trace(`Dumping import file...`);let e=await this.unimport.getImports();this.trace(`Writing imports-dump JSON file: ${(0,r.joinPaths)(this.dataPath,`imports-dump.json`)}`);let t=n.StormJSON.stringify(e);t.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=t,await this.fs.write((0,r.joinPaths)(this.dataPath,`imports-dump.json`),t))},1e3),this.unimport.injectImports=async(t,n,r)=>{let i=await e(t,n,r);return i.s.hasChanged()&&await this.unimport.dumpImports(),i},this.unimport.init=async()=>{await i(),await this.unimport.dumpImports()},await this.unimport.init()},async transform(e,t){let n=await this.unimport.injectImports(e,t);return n.s.hasChanged()?{id:t,code:n.s.toString(),map:n.s.generateMap({source:t,includeContent:!0,hires:!0})}:null}});exports.default=o,exports.plugin=o;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{throttle as e}from"@stryke/helpers/throttle";import{StormJSON as t}from"@stryke/json/storm-json";import{joinPaths as n}from"@stryke/path/join";import r from"defu";import{createUnimport as i}from"unimport";const a=a=>({name:`unimport`,config(){return{unimport:r(a,{commentsDisable:[`@unimport-disable`,`@unimport-ignore`,`@imports-disable`,`@imports-ignore`,`@powerlines-disable`,`@powerlines-ignore`],commentsDebug:[`@unimport-debug`,`@imports-debug`,`@powerlines-debug`],injectAtEnd:!0})}},async configResolved(){let{injectImports:r,init:a,...o}=i(this.config.unimport);this.unimport={...o},this.unimport.dumpImports=e(async()=>{this.trace(`Dumping import file...`);let e=await this.unimport.getImports();this.trace(`Writing imports-dump JSON file: ${n(this.dataPath,`imports-dump.json`)}`);let r=t.stringify(e);r.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=r,await this.fs.write(n(this.dataPath,`imports-dump.json`),r))},1e3),this.unimport.injectImports=async(e,t,n)=>{let i=await r(e,t,n);return i.s.hasChanged()&&await this.unimport.dumpImports(),i},this.unimport.init=async()=>{await a(),await this.unimport.dumpImports()},await this.unimport.init()},async transform(e,t){let n=await this.unimport.injectImports(e,t);return n.s.hasChanged()?{id:t,code:n.s.toString(),map:n.s.generateMap({source:t,includeContent:!0,hires:!0})}:null}});export{a as default,a as plugin};
1
+ import{throttle as e}from"@stryke/async";import{StormJSON as t}from"@stryke/json/storm-json";import{joinPaths as n}from"@stryke/path/join";import r from"defu";import{createUnimport as i}from"unimport";const a=a=>({name:`unimport`,config(){return{unimport:r(a,{commentsDisable:[`@unimport-disable`,`@unimport-ignore`,`@imports-disable`,`@imports-ignore`,`@powerlines-disable`,`@powerlines-ignore`],commentsDebug:[`@unimport-debug`,`@imports-debug`,`@powerlines-debug`],injectAtEnd:!0})}},async configResolved(){let{injectImports:r,init:a,...o}=i(this.config.unimport);this.unimport={...o},this.unimport.dumpImports=e(async()=>{this.trace(`Dumping import file...`);let e=await this.unimport.getImports();this.trace(`Writing imports-dump JSON file: ${n(this.dataPath,`imports-dump.json`)}`);let r=t.stringify(e);r.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=r,await this.fs.write(n(this.dataPath,`imports-dump.json`),r))},1e3),this.unimport.injectImports=async(e,t,n)=>{let i=await r(e,t,n);return i.s.hasChanged()&&await this.unimport.dumpImports(),i},this.unimport.init=async()=>{await a(),await this.unimport.dumpImports()},await this.unimport.init()},async transform(e,t){let n=await this.unimport.injectImports(e,t);return n.s.hasChanged()?{id:t,code:n.s.toString(),map:n.s.generateMap({source:t,includeContent:!0,hires:!0})}:null}});export{a as default,a as plugin};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"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} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\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 };\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":"oNAiDA,MAAa,EAGX,IAEO,CACL,KAAM,WACN,QAAS,CACP,MAAO,CACL,SAAU,EAAK,EAAS,CACtB,gBAAiB,CACf,oBACA,mBACA,mBACA,kBACA,sBACA,qBACD,CACD,cAAe,CACb,kBACA,iBACA,oBACD,CACD,YAAa,GACd,CAAC,CACH,EAEH,MAAM,gBAAiB,CACrB,GAAM,CAAE,gBAAe,OAAM,GAAG,GAAS,EACvC,KAAK,OAAO,SACb,CACD,KAAK,SAAW,CAAE,GAAG,EAAM,CAE3B,KAAK,SAAS,YAAc,EAAS,SAAY,CAC/C,KAAK,MAAM,yBAAyB,CAEpC,IAAM,EAAQ,MAAM,KAAK,SAAS,YAAY,CAE9C,KAAK,MACH,mCAAmC,EAAU,KAAK,SAAU,oBAAoB,GACjF,CAED,IAAM,EAAU,EAAU,UAAU,EAAM,CACtC,EAAQ,MAAM,GAAK,KAAK,SAAS,iBAAiB,MAAM,GAC1D,KAAK,SAAS,gBAAkB,EAChC,MAAM,KAAK,GAAG,MACZ,EAAU,KAAK,SAAU,oBAAoB,CAC7C,EACD,GAEF,IAAK,CAER,KAAK,SAAS,cAAgB,MAC5B,EACA,EACA,IACmC,CACnC,IAAM,EAAS,MAAM,EAAc,EAAM,EAAI,EAAQ,CAQrD,OANK,EAAO,EAAE,YAAY,EAI1B,MAAM,KAAK,SAAS,aAAa,CAHxB,GAQX,KAAK,SAAS,KAAO,SAAY,CAC/B,MAAM,GAAM,CACZ,MAAM,KAAK,SAAS,aAAa,EAGnC,MAAM,KAAK,SAAS,MAAM,EAE5B,MAAM,UAAU,EAAM,EAAI,CACxB,IAAM,EAAS,MAAM,KAAK,SAAS,cAAc,EAAM,EAAG,CAK1D,OAJK,EAAO,EAAE,YAAY,CAInB,CACL,KACA,KAAM,EAAO,EAAE,UAAU,CACzB,IAAK,EAAO,EAAE,YAAY,CACxB,OAAQ,EACR,eAAgB,GAChB,MAAO,GACR,CAAC,CACH,CAXQ,MAaZ"}
1
+ {"version":3,"file":"index.mjs","names":[],"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/async\";\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} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\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 };\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":"yMAiDA,MAAa,EAGX,IAEO,CACL,KAAM,WACN,QAAS,CACP,MAAO,CACL,SAAU,EAAK,EAAS,CACtB,gBAAiB,CACf,oBACA,mBACA,mBACA,kBACA,sBACA,qBACD,CACD,cAAe,CACb,kBACA,iBACA,oBACD,CACD,YAAa,GACd,CAAC,CACH,EAEH,MAAM,gBAAiB,CACrB,GAAM,CAAE,gBAAe,OAAM,GAAG,GAAS,EACvC,KAAK,OAAO,SACb,CACD,KAAK,SAAW,CAAE,GAAG,EAAM,CAE3B,KAAK,SAAS,YAAc,EAAS,SAAY,CAC/C,KAAK,MAAM,yBAAyB,CAEpC,IAAM,EAAQ,MAAM,KAAK,SAAS,YAAY,CAE9C,KAAK,MACH,mCAAmC,EAAU,KAAK,SAAU,oBAAoB,GACjF,CAED,IAAM,EAAU,EAAU,UAAU,EAAM,CACtC,EAAQ,MAAM,GAAK,KAAK,SAAS,iBAAiB,MAAM,GAC1D,KAAK,SAAS,gBAAkB,EAChC,MAAM,KAAK,GAAG,MACZ,EAAU,KAAK,SAAU,oBAAoB,CAC7C,EACD,GAEF,IAAK,CAER,KAAK,SAAS,cAAgB,MAC5B,EACA,EACA,IACmC,CACnC,IAAM,EAAS,MAAM,EAAc,EAAM,EAAI,EAAQ,CAQrD,OANK,EAAO,EAAE,YAAY,EAI1B,MAAM,KAAK,SAAS,aAAa,CAHxB,GAQX,KAAK,SAAS,KAAO,SAAY,CAC/B,MAAM,GAAM,CACZ,MAAM,KAAK,SAAS,aAAa,EAGnC,MAAM,KAAK,SAAS,MAAM,EAE5B,MAAM,UAAU,EAAM,EAAI,CACxB,IAAM,EAAS,MAAM,KAAK,SAAS,cAAc,EAAM,EAAG,CAK1D,OAJK,EAAO,EAAE,YAAY,CAInB,CACL,KACA,KAAM,EAAO,EAAE,UAAU,CACzB,IAAK,EAAO,EAAE,YAAY,CACxB,OAAQ,EACR,eAAgB,GAChB,MAAO,GACR,CAAC,CACH,CAXQ,MAaZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unimport",
3
- "version": "0.1.432",
3
+ "version": "0.1.435",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to add imports to source code automatically via unimport.",
6
6
  "repository": {
@@ -89,19 +89,20 @@
89
89
  "files": ["dist/**/*"],
90
90
  "keywords": ["unimport", "powerlines", "storm-software", "powerlines-plugin"],
91
91
  "dependencies": {
92
- "@stryke/helpers": "^0.10.9",
93
- "@stryke/json": "^0.14.13",
94
- "@stryke/path": "^0.27.5",
92
+ "@stryke/async": "^0.1.0",
93
+ "@stryke/helpers": "^0.10.11",
94
+ "@stryke/json": "^0.14.15",
95
+ "@stryke/path": "^0.28.1",
95
96
  "defu": "^6.1.7",
96
97
  "magic-string": "^0.30.21",
97
- "powerlines": "^0.43.27",
98
+ "powerlines": "^0.43.30",
98
99
  "unimport": "^5.7.0"
99
100
  },
100
101
  "devDependencies": {
101
- "@powerlines/plugin-plugin": "^0.12.382",
102
+ "@powerlines/plugin-plugin": "^0.12.385",
102
103
  "@types/node": "^25.6.0"
103
104
  },
104
105
  "publishConfig": { "access": "public" },
105
106
  "types": "./dist/index.d.cts",
106
- "gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
107
+ "gitHead": "36f3385b33024e00aafb6c4a10e7a2e3c896aad5"
107
108
  }