@powerlines/plugin-unimport 0.1.432 → 0.1.433

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unimport",
3
- "version": "0.1.432",
3
+ "version": "0.1.433",
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.27.5",
95
95
  "defu": "^6.1.7",
96
96
  "magic-string": "^0.30.21",
97
- "powerlines": "^0.43.27",
97
+ "powerlines": "^0.43.28",
98
98
  "unimport": "^5.7.0"
99
99
  },
100
100
  "devDependencies": {
101
- "@powerlines/plugin-plugin": "^0.12.382",
101
+ "@powerlines/plugin-plugin": "^0.12.383",
102
102
  "@types/node": "^25.6.0"
103
103
  },
104
104
  "publishConfig": { "access": "public" },
105
105
  "types": "./dist/index.d.cts",
106
- "gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
106
+ "gitHead": "efeaec793549f37c700f2e876bf6097c37375c46"
107
107
  }
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
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;
package/dist/index.d.cts DELETED
@@ -1,19 +0,0 @@
1
- import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig } from "./types/plugin.cjs";
2
- import { Plugin } from "powerlines";
3
-
4
- //#region src/index.d.ts
5
- declare module "powerlines" {
6
- interface Config {
7
- unimport?: UnimportPluginOptions;
8
- }
9
- }
10
- /**
11
- * A Powerlines plugin to integrate Unimport for code generation.
12
- *
13
- * @param options - The plugin options.
14
- * @returns A Powerlines plugin instance.
15
- */
16
- declare const plugin: <TContext extends UnimportPluginContext = UnimportPluginContext>(options: UnimportPluginOptions) => Plugin<TContext>;
17
- //#endregion
18
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, plugin as default, plugin };
19
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAsCY,MAAA;IACR,QAAA,GAAW,qBAAA;EAAA;AAAA;;;;;;;cAUF,MAAA,oBACM,qBAAA,GAAwB,qBAAA,EAEzC,OAAA,EAAS,qBAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.d.mts DELETED
@@ -1,19 +0,0 @@
1
- import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig } from "./types/plugin.mjs";
2
- import { Plugin } from "powerlines";
3
-
4
- //#region src/index.d.ts
5
- declare module "powerlines" {
6
- interface Config {
7
- unimport?: UnimportPluginOptions;
8
- }
9
- }
10
- /**
11
- * A Powerlines plugin to integrate Unimport for code generation.
12
- *
13
- * @param options - The plugin options.
14
- * @returns A Powerlines plugin instance.
15
- */
16
- declare const plugin: <TContext extends UnimportPluginContext = UnimportPluginContext>(options: UnimportPluginOptions) => Plugin<TContext>;
17
- //#endregion
18
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, plugin as default, plugin };
19
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAsCY,MAAA;IACR,QAAA,GAAW,qBAAA;EAAA;AAAA;;;;;;;cAUF,MAAA,oBACM,qBAAA,GAAwB,qBAAA,EAEzC,OAAA,EAAS,qBAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
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};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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"}
File without changes
@@ -1,2 +0,0 @@
1
- import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig } from "./plugin.cjs";
2
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig };
@@ -1,2 +0,0 @@
1
- import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig } from "./plugin.mjs";
2
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig };
@@ -1 +0,0 @@
1
- export{};
File without changes
@@ -1,34 +0,0 @@
1
- import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
2
- import { Unimport, UnimportOptions } from "unimport";
3
-
4
- //#region src/types/plugin.d.ts
5
- type UnimportContext = Unimport & {
6
- lastImportsDump?: string;
7
- dumpImports: () => Promise<void>;
8
- };
9
- type UnimportPluginOptions = Partial<Omit<UnimportOptions, "presets">> & Required<Pick<UnimportOptions, "presets">> & {
10
- /**
11
- * Custom magic comments to be opt-out for auto import, per file/module
12
- *
13
- * @defaultValue ["\@unimport-disable", "\@unimport-ignore", "\@imports-disable", "\@imports-ignore", "\@powerlines-disable", "\@powerlines-ignore"]
14
- */
15
- commentsDisable?: string[];
16
- /**
17
- * Custom magic comments to debug auto import, printed to console
18
- *
19
- * @defaultValue ["\@unimport-debug", "\@imports-debug", "\@powerlines-debug"]
20
- */
21
- commentsDebug?: string[];
22
- };
23
- type UnimportPluginUserConfig = UserConfig & {
24
- unimport?: UnimportPluginOptions;
25
- };
26
- type UnimportPluginResolvedConfig = ResolvedConfig & {
27
- unimport: UnimportPluginOptions;
28
- };
29
- type UnimportPluginContext<TResolvedConfig extends UnimportPluginResolvedConfig = UnimportPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
30
- unimport: UnimportContext;
31
- };
32
- //#endregion
33
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig };
34
- //# sourceMappingURL=plugin.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAqBY,eAAA,GAAkB,QAAA;EAC5B,eAAA;EACA,WAAA,QAAmB,OAAA;AAAA;AAAA,KAGT,qBAAA,GAAwB,OAAA,CAAQ,IAAA,CAAK,eAAA,gBAC/C,QAAA,CAAS,IAAA,CAAK,eAAA;EAJY;;;;;EAUxB,eAAA;EAVwB;AAG5B;;;;EAcI,aAAA;AAAA;AAAA,KAGQ,wBAAA,GAA2B,UAAA;EACrC,QAAA,GAAW,qBAAA;AAAA;AAAA,KAGD,4BAAA,GAA+B,cAAA;EACzC,QAAA,EAAU,qBAAA;AAAA;AAAA,KAGA,qBAAA,yBACc,4BAAA,GACtB,4BAAA,IACA,aAAA,CAAc,eAAA;EAChB,QAAA,EAAU,eAAA;AAAA"}
@@ -1,34 +0,0 @@
1
- import { Unimport, UnimportOptions } from "unimport";
2
- import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
3
-
4
- //#region src/types/plugin.d.ts
5
- type UnimportContext = Unimport & {
6
- lastImportsDump?: string;
7
- dumpImports: () => Promise<void>;
8
- };
9
- type UnimportPluginOptions = Partial<Omit<UnimportOptions, "presets">> & Required<Pick<UnimportOptions, "presets">> & {
10
- /**
11
- * Custom magic comments to be opt-out for auto import, per file/module
12
- *
13
- * @defaultValue ["\@unimport-disable", "\@unimport-ignore", "\@imports-disable", "\@imports-ignore", "\@powerlines-disable", "\@powerlines-ignore"]
14
- */
15
- commentsDisable?: string[];
16
- /**
17
- * Custom magic comments to debug auto import, printed to console
18
- *
19
- * @defaultValue ["\@unimport-debug", "\@imports-debug", "\@powerlines-debug"]
20
- */
21
- commentsDebug?: string[];
22
- };
23
- type UnimportPluginUserConfig = UserConfig & {
24
- unimport?: UnimportPluginOptions;
25
- };
26
- type UnimportPluginResolvedConfig = ResolvedConfig & {
27
- unimport: UnimportPluginOptions;
28
- };
29
- type UnimportPluginContext<TResolvedConfig extends UnimportPluginResolvedConfig = UnimportPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
30
- unimport: UnimportContext;
31
- };
32
- //#endregion
33
- export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig };
34
- //# sourceMappingURL=plugin.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAqBY,eAAA,GAAkB,QAAA;EAC5B,eAAA;EACA,WAAA,QAAmB,OAAA;AAAA;AAAA,KAGT,qBAAA,GAAwB,OAAA,CAAQ,IAAA,CAAK,eAAA,gBAC/C,QAAA,CAAS,IAAA,CAAK,eAAA;EAJY;;;;;EAUxB,eAAA;EAVwB;AAG5B;;;;EAcI,aAAA;AAAA;AAAA,KAGQ,wBAAA,GAA2B,UAAA;EACrC,QAAA,GAAW,qBAAA;AAAA;AAAA,KAGD,4BAAA,GAA+B,cAAA;EACzC,QAAA,EAAU,qBAAA;AAAA;AAAA,KAGA,qBAAA,yBACc,4BAAA,GACtB,4BAAA,IACA,aAAA,CAAc,eAAA;EAChB,QAAA,EAAU,eAAA;AAAA"}
@@ -1 +0,0 @@
1
- export{};