@powerlines/core 0.2.8 → 0.2.10
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/lib/unplugin/module-resolution.cjs +26 -23
- package/dist/lib/unplugin/module-resolution.d.cts +4 -4
- package/dist/lib/unplugin/module-resolution.d.mts +4 -4
- package/dist/lib/unplugin/module-resolution.mjs +26 -23
- package/dist/lib/unplugin/module-resolution.mjs.map +1 -1
- package/dist/lib/unplugin/plugin.cjs +4 -16
- package/dist/lib/unplugin/plugin.d.cts.map +1 -1
- package/dist/lib/unplugin/plugin.d.mts.map +1 -1
- package/dist/lib/unplugin/plugin.mjs +4 -16
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -18,8 +18,8 @@ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-str
|
|
|
18
18
|
function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
19
19
|
const ctx = context;
|
|
20
20
|
let prefix = "";
|
|
21
|
-
if (options.prefix
|
|
22
|
-
else if (
|
|
21
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(options.prefix)) prefix = options.prefix;
|
|
22
|
+
else if (options.prefix !== false) prefix = "\0powerlines:";
|
|
23
23
|
return {
|
|
24
24
|
async resolveId(id, importer, opts = { isEntry: false }) {
|
|
25
25
|
let result = await ctx.$$internal.callHook("resolveId", {
|
|
@@ -63,27 +63,30 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
63
63
|
};
|
|
64
64
|
return null;
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
result
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
result
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
load: {
|
|
67
|
+
filter: prefix ? { id: { include: [/* @__PURE__ */ new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`)] } } : void 0,
|
|
68
|
+
async handler(id) {
|
|
69
|
+
const moduleId = prefix ? id.replace(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g"), "") : id;
|
|
70
|
+
let result = await ctx.$$internal.callHook("load", {
|
|
71
|
+
sequential: true,
|
|
72
|
+
result: "first",
|
|
73
|
+
order: "pre"
|
|
74
|
+
}, moduleId);
|
|
75
|
+
if (result) return result;
|
|
76
|
+
result = await ctx.$$internal.callHook("load", {
|
|
77
|
+
sequential: true,
|
|
78
|
+
result: "first",
|
|
79
|
+
order: "normal"
|
|
80
|
+
}, moduleId);
|
|
81
|
+
if (result) return result;
|
|
82
|
+
result = await ctx.load(moduleId);
|
|
83
|
+
if (result) return result;
|
|
84
|
+
return ctx.$$internal.callHook("load", {
|
|
85
|
+
sequential: true,
|
|
86
|
+
result: "first",
|
|
87
|
+
order: "post"
|
|
88
|
+
}, moduleId);
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
91
|
};
|
|
89
92
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../types/context.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { UnpluginOptions } from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/unplugin/module-resolution.d.ts
|
|
5
5
|
interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
@@ -7,9 +7,9 @@ interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
|
7
7
|
* A prefix to apply to all resolved module IDs. This can be used to create virtual modules by prefixing them with a specific string (e.g., `\0`).
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
-
* If set to `false`, no prefix will be applied, and resolved module IDs will be returned as-is. By default, this is set to `\
|
|
10
|
+
* If set to `false`, no prefix will be applied, and resolved module IDs will be returned as-is. By default, this is set to `\0powerlines:`, which is a common convention for virtual modules in Rollup and Vite plugins.
|
|
11
11
|
*
|
|
12
|
-
* @defaultValue "\\
|
|
12
|
+
* @defaultValue "\\0powerlines:"
|
|
13
13
|
*/
|
|
14
14
|
prefix?: string | boolean;
|
|
15
15
|
}
|
|
@@ -25,7 +25,7 @@ interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
|
25
25
|
* @param context - The plugin context.
|
|
26
26
|
* @returns The module resolution hooks (`resolveId` and `load`).
|
|
27
27
|
*/
|
|
28
|
-
declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext, options?: CreateUnpluginModuleResolutionFunctionsOptions): Pick<
|
|
28
|
+
declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext, options?: CreateUnpluginModuleResolutionFunctionsOptions): Pick<UnpluginOptions, "resolveId" | "load">;
|
|
29
29
|
declare type __ΩCreateUnpluginModuleResolutionFunctionsOptions = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { CreateUnpluginModuleResolutionFunctionsOptions, __ΩCreateUnpluginModuleResolutionFunctionsOptions, createUnpluginModuleResolutionFunctions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../types/context.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { UnpluginOptions } from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/unplugin/module-resolution.d.ts
|
|
5
5
|
interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
@@ -7,9 +7,9 @@ interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
|
7
7
|
* A prefix to apply to all resolved module IDs. This can be used to create virtual modules by prefixing them with a specific string (e.g., `\0`).
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
-
* If set to `false`, no prefix will be applied, and resolved module IDs will be returned as-is. By default, this is set to `\
|
|
10
|
+
* If set to `false`, no prefix will be applied, and resolved module IDs will be returned as-is. By default, this is set to `\0powerlines:`, which is a common convention for virtual modules in Rollup and Vite plugins.
|
|
11
11
|
*
|
|
12
|
-
* @defaultValue "\\
|
|
12
|
+
* @defaultValue "\\0powerlines:"
|
|
13
13
|
*/
|
|
14
14
|
prefix?: string | boolean;
|
|
15
15
|
}
|
|
@@ -25,7 +25,7 @@ interface CreateUnpluginModuleResolutionFunctionsOptions {
|
|
|
25
25
|
* @param context - The plugin context.
|
|
26
26
|
* @returns The module resolution hooks (`resolveId` and `load`).
|
|
27
27
|
*/
|
|
28
|
-
declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext, options?: CreateUnpluginModuleResolutionFunctionsOptions): Pick<
|
|
28
|
+
declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext, options?: CreateUnpluginModuleResolutionFunctionsOptions): Pick<UnpluginOptions, "resolveId" | "load">;
|
|
29
29
|
declare type __ΩCreateUnpluginModuleResolutionFunctionsOptions = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { CreateUnpluginModuleResolutionFunctionsOptions, __ΩCreateUnpluginModuleResolutionFunctionsOptions, createUnpluginModuleResolutionFunctions };
|
|
@@ -17,8 +17,8 @@ import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
|
17
17
|
function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
18
18
|
const ctx = context;
|
|
19
19
|
let prefix = "";
|
|
20
|
-
if (options.prefix
|
|
21
|
-
else if (
|
|
20
|
+
if (isSetString(options.prefix)) prefix = options.prefix;
|
|
21
|
+
else if (options.prefix !== false) prefix = "\0powerlines:";
|
|
22
22
|
return {
|
|
23
23
|
async resolveId(id, importer, opts = { isEntry: false }) {
|
|
24
24
|
let result = await ctx.$$internal.callHook("resolveId", {
|
|
@@ -62,27 +62,30 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
62
62
|
};
|
|
63
63
|
return null;
|
|
64
64
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
result
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
result
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
65
|
+
load: {
|
|
66
|
+
filter: prefix ? { id: { include: [/* @__PURE__ */ new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`)] } } : void 0,
|
|
67
|
+
async handler(id) {
|
|
68
|
+
const moduleId = prefix ? id.replace(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g"), "") : id;
|
|
69
|
+
let result = await ctx.$$internal.callHook("load", {
|
|
70
|
+
sequential: true,
|
|
71
|
+
result: "first",
|
|
72
|
+
order: "pre"
|
|
73
|
+
}, moduleId);
|
|
74
|
+
if (result) return result;
|
|
75
|
+
result = await ctx.$$internal.callHook("load", {
|
|
76
|
+
sequential: true,
|
|
77
|
+
result: "first",
|
|
78
|
+
order: "normal"
|
|
79
|
+
}, moduleId);
|
|
80
|
+
if (result) return result;
|
|
81
|
+
result = await ctx.load(moduleId);
|
|
82
|
+
if (result) return result;
|
|
83
|
+
return ctx.$$internal.callHook("load", {
|
|
84
|
+
sequential: true,
|
|
85
|
+
result: "first",
|
|
86
|
+
order: "post"
|
|
87
|
+
}, moduleId);
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-resolution.mjs","names":[],"sources":["../../../src/lib/unplugin/module-resolution.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 { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { LoadResult } from \"rollup\";\nimport type {\n ExternalIdResult,\n
|
|
1
|
+
{"version":3,"file":"module-resolution.mjs","names":[],"sources":["../../../src/lib/unplugin/module-resolution.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 { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { LoadResult } from \"rollup\";\nimport type {\n ExternalIdResult,\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginOptions\n} from \"unplugin\";\nimport { UNSAFE_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\n\nexport interface CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A prefix to apply to all resolved module IDs. This can be used to create virtual modules by prefixing them with a specific string (e.g., `\\0`).\n *\n * @remarks\n * If set to `false`, no prefix will be applied, and resolved module IDs will be returned as-is. By default, this is set to `\\0powerlines:`, which is a common convention for virtual modules in Rollup and Vite plugins.\n *\n * @defaultValue \"\\\\0powerlines:\"\n */\n prefix?: string | boolean;\n}\n\n/**\n * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.\n *\n * @remarks\n * This includes the `resolveId` and `load` hooks.\n *\n * @see https://rollupjs.org/plugin-development/#resolveid\n * @see https://rollupjs.org/plugin-development/#load\n *\n * @param context - The plugin context.\n * @returns The module resolution hooks (`resolveId` and `load`).\n */\nexport function createUnpluginModuleResolutionFunctions<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginModuleResolutionFunctionsOptions = {}\n): Pick<UnpluginOptions, \"resolveId\" | \"load\"> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n\n let prefix = \"\";\n if (isSetString(options.prefix)) {\n prefix = options.prefix;\n } else if (options.prefix !== false) {\n prefix = \"\\0powerlines:\";\n }\n\n return {\n async resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ExternalIdResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id,\n importer,\n opts\n );\n if (isSetString(result)) {\n return `${prefix}${result}`;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id: `${prefix}${result.id}`\n };\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id,\n importer,\n opts\n );\n if (isSetString(result)) {\n return `${prefix}${result}`;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id: `${prefix}${result.id}`\n };\n }\n\n result = await ctx.resolve(id, importer, { isFile: true, ...opts });\n if (isSetString(result)) {\n return `${prefix}${result}`;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id: `${prefix}${result.id}`\n };\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id,\n importer,\n opts\n );\n if (isSetString(result)) {\n return `${prefix}${result}`;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id: `${prefix}${result.id}`\n };\n }\n\n return null;\n },\n load: {\n filter: prefix\n ? {\n id: {\n include: [\n new RegExp(`^${prefix.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}`)\n ]\n }\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const moduleId = prefix\n ? id.replace(\n new RegExp(\n `^${prefix.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}`,\n \"g\"\n ),\n \"\"\n )\n : id;\n\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n moduleId\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n moduleId\n );\n if (result) {\n return result;\n }\n\n result = await ctx.load(moduleId);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n moduleId\n );\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsDA,SAAgB,wCAGd,SACA,UAA0D,EAAE,EACf;CAC7C,MAAM,MAAM;CAEZ,IAAI,SAAS;AACb,KAAI,YAAY,QAAQ,OAAO,CAC7B,UAAS,QAAQ;UACR,QAAQ,WAAW,MAC5B,UAAS;AAGX,QAAO;EACL,MAAM,UAEJ,IACA,UACA,OAEI,EAAE,SAAS,OAAO,EACiC;GACvD,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,IACA,UACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO,GAAG,SAAS;YACV,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IAAI,GAAG,SAAS,OAAO;IACxB;AAGH,YAAS,MAAM,IAAI,WAAW,SAC5B,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,IACA,UACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO,GAAG,SAAS;YACV,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IAAI,GAAG,SAAS,OAAO;IACxB;AAGH,YAAS,MAAM,IAAI,QAAQ,IAAI,UAAU;IAAE,QAAQ;IAAM,GAAG;IAAM,CAAC;AACnE,OAAI,YAAY,OAAO,CACrB,QAAO,GAAG,SAAS;YACV,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IAAI,GAAG,SAAS,OAAO;IACxB;AAGH,YAAS,MAAM,IAAI,WAAW,SAC5B,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,IACA,UACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO,GAAG,SAAS;YACV,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IAAI,GAAG,SAAS,OAAO;IACxB;AAGH,UAAO;;EAET,MAAM;GACJ,QAAQ,SACJ,EACE,IAAI,EACF,SAAS,iBACP,IAAI,OAAO,IAAI,OAAO,QAAQ,uBAAuB,OAAO,GAAG,CAChE,EACF,EACF,GACD;GACJ,MAAM,QAEJ,IACwC;IACxC,MAAM,WAAW,SACb,GAAG,QACD,IAAI,OACF,IAAI,OAAO,QAAQ,uBAAuB,OAAO,IACjD,IACD,EACD,GACD,GACD;IAEJ,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,SACD;AACD,QAAI,OACF,QAAO;AAGT,aAAS,MAAM,IAAI,WAAW,SAC5B,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,SACD;AACD,QAAI,OACF,QAAO;AAGT,aAAS,MAAM,IAAI,KAAK,SAAS;AACjC,QAAI,OACF,QAAO;AAGT,WAAO,IAAI,WAAW,SACpB,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,SACD;;GAEJ;EACF"}
|
|
@@ -27,14 +27,8 @@ function createUnpluginResolver(context, options = {}) {
|
|
|
27
27
|
return {
|
|
28
28
|
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${(0, __stryke_string_format_kebab_case.kebabCase)(name)}`,
|
|
29
29
|
api: ctx.$$internal.api,
|
|
30
|
-
resolveId
|
|
31
|
-
|
|
32
|
-
handler: resolveId
|
|
33
|
-
},
|
|
34
|
-
load: {
|
|
35
|
-
filter: { id: { include: [/.*/] } },
|
|
36
|
-
handler: load
|
|
37
|
-
}
|
|
30
|
+
resolveId,
|
|
31
|
+
load
|
|
38
32
|
};
|
|
39
33
|
} catch (error) {
|
|
40
34
|
log(__storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
|
|
@@ -80,14 +74,8 @@ function createUnplugin(context, options = {}) {
|
|
|
80
74
|
return {
|
|
81
75
|
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${(0, __stryke_string_format_kebab_case.kebabCase)(name)}`,
|
|
82
76
|
api: ctx.$$internal.api,
|
|
83
|
-
resolveId
|
|
84
|
-
|
|
85
|
-
handler: resolveId
|
|
86
|
-
},
|
|
87
|
-
load: {
|
|
88
|
-
filter: { id: { include: [/.*/] } },
|
|
89
|
-
handler: load
|
|
90
|
-
},
|
|
77
|
+
resolveId,
|
|
78
|
+
load,
|
|
91
79
|
transform,
|
|
92
80
|
buildStart,
|
|
93
81
|
buildEnd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":[],"mappings":";;;;;UAsCiB,6BAAA,SAAsC;;AAAvD;AAkBA;;;;;;EAKG,IAAA,CAAA,EAAA,MAAA;;
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":[],"mappings":";;;;;UAsCiB,6BAAA,SAAsC;;AAAvD;AAkBA;;;;;;EAKG,IAAA,CAAA,EAAA,MAAA;;AAsCH;AAQA;;;;;AAGmB,iBAtDH,sBAsDG,CAAA,iBArDA,aAqDA,GArDgB,aAqDhB,CAAA,CAAA,OAAA,EAnDR,QAmDQ,EAAA,OAAA,CAAA,EAlDR,6BAkDQ,CAAA,EAjDhB,eAiDgB,CAjDA,QAiDA,CAAA;AAAhB,UAXc,qBAAA,SAA8B,6BAW5C,CAAA;;;;;;;iBAHa,gCAAgC,gBAAgB,wBACrD,oBACA,wBACR,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":[],"mappings":";;;;;UAsCiB,6BAAA,SAAsC;;AAAvD;AAkBA;;;;;;EAKG,IAAA,CAAA,EAAA,MAAA;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":[],"mappings":";;;;;UAsCiB,6BAAA,SAAsC;;AAAvD;AAkBA;;;;;;EAKG,IAAA,CAAA,EAAA,MAAA;;AAsCH;AAQA;;;;;AAGmB,iBAtDH,sBAsDG,CAAA,iBArDA,aAqDA,GArDgB,aAqDhB,CAAA,CAAA,OAAA,EAnDR,QAmDQ,EAAA,OAAA,CAAA,EAlDR,6BAkDQ,CAAA,EAjDhB,eAiDgB,CAjDA,QAiDA,CAAA;AAAhB,UAXc,qBAAA,SAA8B,6BAW5C,CAAA;;;;;;;iBAHa,gCAAgC,gBAAgB,wBACrD,oBACA,wBACR,gBAAgB"}
|
|
@@ -26,14 +26,8 @@ function createUnpluginResolver(context, options = {}) {
|
|
|
26
26
|
return {
|
|
27
27
|
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name)}`,
|
|
28
28
|
api: ctx.$$internal.api,
|
|
29
|
-
resolveId
|
|
30
|
-
|
|
31
|
-
handler: resolveId
|
|
32
|
-
},
|
|
33
|
-
load: {
|
|
34
|
-
filter: { id: { include: [/.*/] } },
|
|
35
|
-
handler: load
|
|
36
|
-
}
|
|
29
|
+
resolveId,
|
|
30
|
+
load
|
|
37
31
|
};
|
|
38
32
|
} catch (error) {
|
|
39
33
|
log(LogLevelLabel.FATAL, error?.message);
|
|
@@ -79,14 +73,8 @@ function createUnplugin(context, options = {}) {
|
|
|
79
73
|
return {
|
|
80
74
|
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name)}`,
|
|
81
75
|
api: ctx.$$internal.api,
|
|
82
|
-
resolveId
|
|
83
|
-
|
|
84
|
-
handler: resolveId
|
|
85
|
-
},
|
|
86
|
-
load: {
|
|
87
|
-
filter: { id: { include: [/.*/] } },
|
|
88
|
-
handler: load
|
|
89
|
-
},
|
|
76
|
+
resolveId,
|
|
77
|
+
load,
|
|
90
78
|
transform,
|
|
91
79
|
buildStart,
|
|
92
80
|
buildEnd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":["transformed: TransformResult | string","result: TransformResult | string | undefined"],"sources":["../../../src/lib/unplugin/plugin.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { UNSAFE_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"unplugin\". If provided, the plugin will be named `${name} - Unplugin` (e.g., \"MyPlugin - Unplugin\").\n *\n * @defaultValue \"unplugin\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"unplugin\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(\n LogLevelLabel.DEBUG,\n `Initializing ${\n name.toLowerCase() === \"unplugin\"\n ? \"Unplugin\"\n : `${titleCase(name)} - Unplugin`\n } plugin`\n );\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"unplugin\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":["transformed: TransformResult | string","result: TransformResult | string | undefined"],"sources":["../../../src/lib/unplugin/plugin.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { UNSAFE_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"unplugin\". If provided, the plugin will be named `${name} - Unplugin` (e.g., \"MyPlugin - Unplugin\").\n *\n * @defaultValue \"unplugin\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"unplugin\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(\n LogLevelLabel.DEBUG,\n `Initializing ${\n name.toLowerCase() === \"unplugin\"\n ? \"Unplugin\"\n : `${titleCase(name)} - Unplugin`\n } plugin`\n );\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"unplugin\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"unplugin\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(\n LogLevelLabel.DEBUG,\n `Initializing ${\n name.toLowerCase() === \"unplugin\"\n ? \"Unplugin\"\n : `${titleCase(name)} - Unplugin`\n } plugin`\n );\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"unplugin\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,SAAgB,uBAGd,SACA,UAAyC,EAAE,EAChB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MACE,cAAc,OACd,gBACE,KAAK,aAAa,KAAK,aACnB,aACA,GAAG,UAAU,KAAK,CAAC,aACxB,SACF;AAED,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;AAErE,UAAO;IACL,MACE,KAAK,aAAa,KAAK,aACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACD;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM;;;;;;;;;;AAaZ,SAAgB,eACd,SACA,UAAiC,EAAE,EACR;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MACE,cAAc,OACd,gBACE,KAAK,aAAa,KAAK,aACnB,aACA,GAAG,UAAU,KAAK,CAAC,aACxB,SACF;AAED,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;GAErE,eAAe,aAAuC;AACpD,QAAI,cAAc,OAAO,sCAAsC;AAE/D,UAAM,IAAI,WAAW,SAAS,cAAc,EAC1C,YAAY,MACb,CAAC;;GAGJ,eAAe,UAEb,MACA,IAC6C;IAC7C,IAAIA,cAAwC;AAE5C,SAAK,MAAM,QAAQ,IAAI,WAAW,YAAY,YAC5C,YACD,EAAE;KACD,MAAMC,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,KAAK,KAAK,EAAE,CACnD,UAAU,YAAY,EACtB,GACD,CAAC;AACJ,SAAI,OACF,eAAc;;AAIlB,WAAO;;GAGT,eAAe,WAAoD;AACjE,QAAI,cAAc,OAAO,uCAAuC;AAEhE,WAAO,IAAI,WAAW,SAAS,YAAY,EACzC,YAAY,MACb,CAAC;;GAGJ,eAAe,cAA6B;AAC1C,QAAI,cAAc,OAAO,0CAA0C;AAEnE,WAAO,IAAI,WAAW,SAAS,eAAe,EAC5C,YAAY,MACb,CAAC;;AAGJ,UAAO;IACL,MACE,KAAK,aAAa,KAAK,aACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACA;IACA;IACA;IACA;IACA,MAAM,EACJ,mBAAmB,MACpB;IACF;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -524,5 +524,5 @@
|
|
|
524
524
|
"typescript": "^5.9.3"
|
|
525
525
|
},
|
|
526
526
|
"publishConfig": { "access": "public" },
|
|
527
|
-
"gitHead": "
|
|
527
|
+
"gitHead": "b46efba9e26b5ffdad2143baf6079762363d8a27"
|
|
528
528
|
}
|