@powerlines/plugin-unimport 0.1.342 → 0.1.343
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/README.md +14 -16
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/index.cjs +13 -14
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ This package is part of the <b>🔌 Powerlines</b> monorepo. Powerlines is the "
|
|
|
27
27
|
|
|
28
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
29
29
|
|
|
30
|
-
[](https://stormsoftware.com/projects/powerlines) [](http://commitizen.github.io/cz-cli/)  
|
|
31
31
|
|
|
32
32
|
<!-- prettier-ignore-start -->
|
|
33
33
|
<!-- markdownlint-disable -->
|
|
@@ -58,21 +58,19 @@ A Powerlines plugin to add imports to source code automatically via [unimport](h
|
|
|
58
58
|
|
|
59
59
|
## Table of Contents
|
|
60
60
|
|
|
61
|
-
- [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- [
|
|
65
|
-
- [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- [Contributing](#contributing)
|
|
75
|
-
- [Contributors](#contributors)
|
|
61
|
+
- [Installing](#installing)
|
|
62
|
+
- [Reduced Package Size](#reduced-package-size)
|
|
63
|
+
- [Development](#development)
|
|
64
|
+
- [Building](#building)
|
|
65
|
+
- [Running unit tests](#running-unit-tests)
|
|
66
|
+
- [Linting](#linting)
|
|
67
|
+
- [Storm Workspaces](#storm-workspaces)
|
|
68
|
+
- [Roadmap](#roadmap)
|
|
69
|
+
- [Support](#support)
|
|
70
|
+
- [License](#license)
|
|
71
|
+
- [Changelog](#changelog)
|
|
72
|
+
- [Contributing](#contributing)
|
|
73
|
+
- [Contributors](#contributors)
|
|
76
74
|
|
|
77
75
|
<!-- END doctoc -->
|
|
78
76
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _stryke_helpers_throttle = require("@stryke/helpers/throttle");
|
|
4
|
+
let _stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
5
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
6
6
|
let defu = require("defu");
|
|
7
|
-
defu =
|
|
7
|
+
defu = require_runtime.__toESM(defu);
|
|
8
8
|
let unimport = require("unimport");
|
|
9
9
|
|
|
10
10
|
//#region src/index.ts
|
|
@@ -38,18 +38,18 @@ const plugin = (options) => {
|
|
|
38
38
|
async configResolved() {
|
|
39
39
|
const { injectImports, init, ...rest } = (0, unimport.createUnimport)(this.config.unimport);
|
|
40
40
|
this.unimport = { ...rest };
|
|
41
|
-
this.unimport.dumpImports = (0,
|
|
41
|
+
this.unimport.dumpImports = (0, _stryke_helpers_throttle.throttle)(async () => {
|
|
42
42
|
this.trace("Dumping import file...");
|
|
43
43
|
const items = await this.unimport.getImports();
|
|
44
|
-
this.trace(`Writing imports-dump JSON file: ${(0,
|
|
45
|
-
const content =
|
|
44
|
+
this.trace(`Writing imports-dump JSON file: ${(0, _stryke_path_join.joinPaths)(this.dataPath, "imports-dump.json")}`);
|
|
45
|
+
const content = _stryke_json_storm_json.StormJSON.stringify(items);
|
|
46
46
|
if (content.trim() !== this.unimport.lastImportsDump?.trim()) {
|
|
47
47
|
this.unimport.lastImportsDump = content;
|
|
48
|
-
await this.fs.write((0,
|
|
48
|
+
await this.fs.write((0, _stryke_path_join.joinPaths)(this.dataPath, "imports-dump.json"), content);
|
|
49
49
|
}
|
|
50
50
|
}, 1e3);
|
|
51
|
-
this.unimport.injectImports = async (code, id, options
|
|
52
|
-
const result = await injectImports(code, id, options
|
|
51
|
+
this.unimport.injectImports = async (code, id, options) => {
|
|
52
|
+
const result = await injectImports(code, id, options);
|
|
53
53
|
if (!result.s.hasChanged()) return result;
|
|
54
54
|
await this.unimport.dumpImports();
|
|
55
55
|
return result;
|
|
@@ -75,8 +75,7 @@ const plugin = (options) => {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
-
var src_default = plugin;
|
|
79
78
|
|
|
80
79
|
//#endregion
|
|
81
|
-
exports.default =
|
|
80
|
+
exports.default = plugin;
|
|
82
81
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, __ΩUnimportContext, __ΩUnimportPluginContext, __ΩUnimportPluginOptions, __ΩUnimportPluginResolvedConfig, __ΩUnimportPluginUserConfig } from "./types/plugin.cjs";
|
|
2
|
-
import "./types/index.cjs";
|
|
3
2
|
import { Plugin } from "powerlines";
|
|
4
3
|
|
|
5
4
|
//#region src/index.d.ts
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAuCY,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
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UnimportContext, UnimportPluginContext, UnimportPluginOptions, UnimportPluginResolvedConfig, UnimportPluginUserConfig, __ΩUnimportContext, __ΩUnimportPluginContext, __ΩUnimportPluginOptions, __ΩUnimportPluginResolvedConfig, __ΩUnimportPluginUserConfig } from "./types/plugin.mjs";
|
|
2
|
-
import "./types/index.mjs";
|
|
3
2
|
import { Plugin } from "powerlines";
|
|
4
3
|
|
|
5
4
|
//#region src/index.d.ts
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAuCY,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
CHANGED
|
@@ -45,8 +45,8 @@ const plugin = (options) => {
|
|
|
45
45
|
await this.fs.write(joinPaths(this.dataPath, "imports-dump.json"), content);
|
|
46
46
|
}
|
|
47
47
|
}, 1e3);
|
|
48
|
-
this.unimport.injectImports = async (code, id, options
|
|
49
|
-
const result = await injectImports(code, id, options
|
|
48
|
+
this.unimport.injectImports = async (code, id, options) => {
|
|
49
|
+
const result = await injectImports(code, id, options);
|
|
50
50
|
if (!result.s.hasChanged()) return result;
|
|
51
51
|
await this.unimport.dumpImports();
|
|
52
52
|
return result;
|
|
@@ -72,8 +72,7 @@ const plugin = (options) => {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
-
var src_default = plugin;
|
|
76
75
|
|
|
77
76
|
//#endregion
|
|
78
|
-
export {
|
|
77
|
+
export { plugin as default, plugin };
|
|
79
78
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
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 UnimportPluginUserConfig\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 } 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,YACmC;IACnC,MAAM,SAAS,MAAM,cAAc,MAAM,IAAI,QAAQ;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"
|
|
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;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"
|
|
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;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-unimport",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.343",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to add imports to source code automatically via unimport.",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"default": "./dist/index.mjs"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"
|
|
58
|
+
"./package.json": "./package.json",
|
|
59
59
|
"./types": {
|
|
60
60
|
"require": {
|
|
61
61
|
"types": "./dist/types/index.d.cts",
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
"@stryke/path": "^0.26.19",
|
|
95
95
|
"defu": "^6.1.4",
|
|
96
96
|
"magic-string": "^0.30.21",
|
|
97
|
-
"powerlines": "^0.41.
|
|
97
|
+
"powerlines": "^0.41.7",
|
|
98
98
|
"unimport": "^5.7.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
101
|
+
"@powerlines/plugin-plugin": "^0.12.293",
|
|
102
102
|
"@types/node": "^25.4.0"
|
|
103
103
|
},
|
|
104
104
|
"publishConfig": { "access": "public" },
|
|
105
105
|
"types": "./dist/index.d.cts",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "2fb48143904805988bac9bdbc04cdc4a35ff398b"
|
|
107
107
|
}
|