@powerlines/plugin-unimport 0.1.46 → 0.1.48

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.
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,7 +1 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var types$1=require('@storm-software/config-tools/types'),throttle=require('@stryke/helpers/throttle'),stormJson=require('@stryke/json/storm-json'),join=require('@stryke/path/join'),h=require('defu'),unimport=require('unimport'),types=require('./types');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var h__default=/*#__PURE__*/_interopDefault(h);/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- var g=Object.defineProperty;var e=(r,t)=>g(r,"name",{value:t,configurable:true});const d=e(r=>({name:"unimport",config(){return {unimport:h__default.default(r,{commentsDisable:["@unimport-disable","@unimport-ignore","@imports-disable","@imports-ignore","@powerlines-disable","@powerlines-ignore"],commentsDebug:["@unimport-debug","@imports-debug","@powerlines-debug"],injectAtEnd:true})}},async configResolved(){const{injectImports:t,init:i,...o}=unimport.createUnimport(this.config.unimport);this.unimport={...o},this.unimport.dumpImports=throttle.throttle(async()=>{this.log(types$1.LogLevelLabel.TRACE,"Dumping import file...");const s=await this.unimport.getImports();this.log(types$1.LogLevelLabel.TRACE,`Writing imports-dump JSON file: ${join.joinPaths(this.dataPath,"imports-dump.json")}`);const n=stormJson.StormJSON.stringify(s);n.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=n,await this.fs.write(join.joinPaths(this.dataPath,"imports-dump.json"),n));},1e3),this.unimport.injectImports=async(s,n,a)=>{const m=await t(s,n,a);return m.s.hasChanged()&&await this.unimport.dumpImports(),m},this.unimport.init=async()=>{await i(),await this.unimport.dumpImports();},await this.unimport.init();},async transform(t,i){const o=await this.unimport.injectImports(t,i);return o.s.hasChanged()?{id:i,code:o.s.toString(),map:o.s.generateMap({source:i,includeContent:true,hires:true})}:null}}),"plugin");var J=d;exports.default=J;exports.plugin=d;Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});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));require(`./plugin-DHXHjv16.cjs`),require(`./types-DHkg7xmX.cjs`);let c=require(`@storm-software/config-tools/types`),l=require(`@stryke/helpers/throttle`),u=require(`@stryke/json/storm-json`),d=require(`@stryke/path/join`),f=require(`defu`);f=s(f);let p=require(`unimport`);const m=e=>({name:`unimport`,config(){return{unimport:(0,f.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:t,...n}=(0,p.createUnimport)(this.config.unimport);this.unimport={...n},this.unimport.dumpImports=(0,l.throttle)(async()=>{this.log(c.LogLevelLabel.TRACE,`Dumping import file...`);let e=await this.unimport.getImports();this.log(c.LogLevelLabel.TRACE,`Writing imports-dump JSON file: ${(0,d.joinPaths)(this.dataPath,`imports-dump.json`)}`);let t=u.StormJSON.stringify(e);t.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=t,await this.fs.write((0,d.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 t(),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}});var h=m;exports.default=h,exports.plugin=m;
package/dist/index.d.cts CHANGED
@@ -1,24 +1,7 @@
1
- import { U as UnimportPluginContext, a as UnimportPluginOptions, P as Plugin } from './index-MrToIHHr.cjs';
2
- export { b as UnimportContext, d as UnimportPluginResolvedConfig, c as UnimportPluginUserConfig, _ as __ΩUnimportContext, h as __ΩUnimportPluginContext, e as __ΩUnimportPluginOptions, g as __ΩUnimportPluginResolvedConfig, f as __ΩUnimportPluginUserConfig } from './index-MrToIHHr.cjs';
3
- import '@storm-software/build-tools/types';
4
- import '@storm-software/config-tools/types';
5
- import '@storm-software/config/types';
6
- import '@stryke/types/base';
7
- import '@stryke/types/configuration';
8
- import '@stryke/types/file';
9
- import 'vite';
10
- import '@stryke/env/get-env-paths';
11
- import '@stryke/types/package-json';
12
- import 'jiti';
13
- import 'magic-string';
14
- import 'semver';
15
- import 'ts-morph';
16
- import 'unplugin';
17
- import '@stryke/fs/resolve';
18
- import '@stryke/types/tsconfig';
19
- import 'typescript';
20
- import '@stryke/types/array';
21
- import 'unimport';
1
+ import { a as UnimportPluginUserConfig, c as __ΩUnimportPluginOptions, d as Plugin, i as UnimportPluginResolvedConfig, l as __ΩUnimportPluginResolvedConfig, n as UnimportPluginContext, o as __ΩUnimportContext, r as UnimportPluginOptions, s as __ΩUnimportPluginContext, t as UnimportContext, u as __ΩUnimportPluginUserConfig } from "./plugin-nd1nmmeZ.cjs";
2
+ import "./index-CEgs-Dz2.cjs";
3
+
4
+ //#region src/index.d.ts
22
5
 
23
6
  /**
24
7
  * A Powerlines plugin to integrate Unimport for code generation.
@@ -27,5 +10,6 @@ import 'unimport';
27
10
  * @returns A Powerlines plugin instance.
28
11
  */
29
12
  declare const plugin: <TContext extends UnimportPluginContext = UnimportPluginContext>(options: UnimportPluginOptions) => Plugin<TContext>;
30
-
31
- export { UnimportPluginContext, UnimportPluginOptions, plugin as default, plugin };
13
+ //#endregion
14
+ export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, __ΩUnimportContext, __ΩUnimportPluginContext, __ΩUnimportPluginOptions, __ΩUnimportPluginResolvedConfig, __ΩUnimportPluginUserConfig, plugin as default, plugin };
15
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AA6CA;;;;;AAIG,cAJU,MAIV,EAAA,CAAA,iBAHgB,qBAGhB,GAHwC,qBAGxC,CAAA,CAAA,OAAA,EADQ,qBACR,EAAA,GAAA,MAAA,CAAO,QAAP,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { a as UnimportPluginUserConfig, c as __ΩUnimportPluginOptions, d as Plugin, i as UnimportPluginResolvedConfig, l as __ΩUnimportPluginResolvedConfig, n as UnimportPluginContext, o as __ΩUnimportContext, r as UnimportPluginOptions, s as __ΩUnimportPluginContext, t as UnimportContext, u as __ΩUnimportPluginUserConfig } from "./plugin-CCAMJiDO.mjs";
2
+ import "./index-BgAdqTbb.mjs";
3
+
4
+ //#region src/index.d.ts
5
+
6
+ /**
7
+ * A Powerlines plugin to integrate Unimport for code generation.
8
+ *
9
+ * @param options - The plugin options.
10
+ * @returns A Powerlines plugin instance.
11
+ */
12
+ declare const plugin: <TContext extends UnimportPluginContext = UnimportPluginContext>(options: UnimportPluginOptions) => Plugin<TContext>;
13
+ //#endregion
14
+ export { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, __ΩUnimportContext, __ΩUnimportPluginContext, __ΩUnimportPluginOptions, __ΩUnimportPluginResolvedConfig, __ΩUnimportPluginUserConfig, plugin as default, plugin };
15
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AA6CA;;;;;AAIG,cAJU,MAIV,EAAA,CAAA,iBAHgB,qBAGhB,GAHwC,qBAGxC,CAAA,CAAA,OAAA,EADQ,qBACR,EAAA,GAAA,MAAA,CAAO,QAAP,CAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import"./plugin-Bvn-he2n.mjs";import"./types-B7VYa_Pp.mjs";import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{throttle as t}from"@stryke/helpers/throttle";import{StormJSON as n}from"@stryke/json/storm-json";import{joinPaths as r}from"@stryke/path/join";import i from"defu";import{createUnimport as a}from"unimport";const o=o=>({name:`unimport`,config(){return{unimport:i(o,{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:i,init:o,...s}=a(this.config.unimport);this.unimport={...s},this.unimport.dumpImports=t(async()=>{this.log(e.TRACE,`Dumping import file...`);let t=await this.unimport.getImports();this.log(e.TRACE,`Writing imports-dump JSON file: ${r(this.dataPath,`imports-dump.json`)}`);let i=n.stringify(t);i.trim()!==this.unimport.lastImportsDump?.trim()&&(this.unimport.lastImportsDump=i,await this.fs.write(r(this.dataPath,`imports-dump.json`),i))},1e3),this.unimport.injectImports=async(e,t,n)=>{let r=await i(e,t,n);return r.s.hasChanged()&&await this.unimport.dumpImports(),r},this.unimport.init=async()=>{await o(),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}});var s=o;export{s as default,o as plugin};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 { LogLevelLabel } from \"@storm-software/config-tools/types\";\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/types/plugin\";\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\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.log(LogLevelLabel.TRACE, \"Dumping import file...\");\n\n const items = await this.unimport.getImports();\n\n this.log(\n LogLevelLabel.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":"kVA6CA,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,IAAI,EAAc,MAAO,yBAAyB,CAEvD,IAAM,EAAQ,MAAM,KAAK,SAAS,YAAY,CAE9C,KAAK,IACH,EAAc,MACd,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,EAAIA,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,EAGH,IAAA,EAAe"}
@@ -0,0 +1 @@
1
+ export{};