@powerlines/core 0.44.2 → 0.44.4
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/constants/api.cjs +1 -0
- package/dist/constants/commands.cjs +3 -2
- package/dist/constants/environments.cjs +1 -0
- package/dist/constants/fs.cjs +1 -0
- package/dist/constants/hooks.cjs +1 -0
- package/dist/constants/index.cjs +34 -34
- package/dist/constants/index.mjs +1 -1
- package/dist/constants/log-level.cjs +1 -0
- package/dist/constants/meta.cjs +1 -0
- package/dist/constants/plugin.cjs +3 -2
- package/dist/constants/virtual-modules.cjs +1 -0
- package/dist/lib/unplugin/helpers.cjs +2 -2
- package/dist/lib/unplugin/module-resolution.cjs +10 -9
- package/dist/lib/unplugin/module-resolution.mjs +1 -0
- package/dist/lib/unplugin/module-resolution.mjs.map +1 -1
- package/dist/lib/unplugin/plugin.cjs +3 -2
- package/dist/lib/unplugin/plugin.mjs +1 -0
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/dist/plugin-utils/helpers.cjs +5 -5
- package/dist/plugin-utils/logging.cjs +5 -5
- package/dist/plugin-utils/logging.mjs +1 -1
- package/dist/types/logging.d.cts +1 -1
- package/dist/types/logging.d.cts.map +1 -1
- package/dist/types/logging.d.mts +1 -1
- package/dist/types/logging.d.mts.map +1 -1
- package/dist/types/logging.mjs.map +1 -1
- package/package.json +38 -2
package/dist/constants/api.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_constants_api = require('./api.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/constants/commands.ts
|
|
4
|
-
const SUPPORTED_COMMANDS = [...
|
|
5
|
+
const SUPPORTED_COMMANDS = [...require_constants_api.POWERLINES_API_FUNCTIONS, "finalize"];
|
|
5
6
|
|
|
6
7
|
//#endregion
|
|
7
8
|
exports.SUPPORTED_COMMANDS = SUPPORTED_COMMANDS;
|
package/dist/constants/fs.cjs
CHANGED
package/dist/constants/hooks.cjs
CHANGED
package/dist/constants/index.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
2
|
+
const require_constants_api = require('./api.cjs');
|
|
3
|
+
const require_constants_commands = require('./commands.cjs');
|
|
4
|
+
const require_constants_plugin = require('./plugin.cjs');
|
|
5
|
+
const require_constants_environments = require('./environments.cjs');
|
|
6
|
+
const require_constants_fs = require('./fs.cjs');
|
|
7
|
+
const require_constants_hooks = require('./hooks.cjs');
|
|
8
|
+
const require_constants_log_level = require('./log-level.cjs');
|
|
9
|
+
const require_constants_meta = require('./meta.cjs');
|
|
10
|
+
const require_constants_virtual_modules = require('./virtual-modules.cjs');
|
|
11
11
|
|
|
12
|
-
exports.BASE_API_FUNCTIONS =
|
|
13
|
-
exports.BUILDER_VARIANTS =
|
|
14
|
-
exports.CACHE_HASH_LENGTH =
|
|
15
|
-
exports.CLIENT_ENVIRONMENT =
|
|
16
|
-
exports.DEFAULT_DEVELOPMENT_LOG_LEVEL =
|
|
17
|
-
exports.DEFAULT_ENVIRONMENT =
|
|
18
|
-
exports.DEFAULT_PRODUCTION_LOG_LEVEL =
|
|
19
|
-
exports.DEFAULT_TEST_LOG_LEVEL =
|
|
20
|
-
exports.GLOBAL_ENVIRONMENT =
|
|
21
|
-
exports.HOOKS_LIST_ORDERS =
|
|
22
|
-
exports.KNOWN_PLUGIN_FIELDS =
|
|
23
|
-
exports.PLUGIN_HOOKS_FIELDS =
|
|
24
|
-
exports.PLUGIN_NON_HOOK_FIELDS =
|
|
25
|
-
exports.POWERLINES_API_FUNCTIONS =
|
|
26
|
-
exports.ROOT_HASH_LENGTH =
|
|
27
|
-
exports.RSC_ENVIRONMENT =
|
|
28
|
-
exports.SERVER_ENVIRONMENT =
|
|
29
|
-
exports.SSR_ENVIRONMENT =
|
|
30
|
-
exports.STORAGE_PRESETS =
|
|
31
|
-
exports.SUPPORTED_COMMANDS =
|
|
32
|
-
exports.UNPLUGIN_BUILDER_VARIANTS =
|
|
33
|
-
exports.VIRTUAL_MODULE_PREFIX =
|
|
34
|
-
exports.VIRTUAL_MODULE_PREFIX_REGEX =
|
|
35
|
-
exports.__VFS_PATCH__ =
|
|
36
|
-
exports.__VFS_REVERT__ =
|
|
12
|
+
exports.BASE_API_FUNCTIONS = require_constants_api.BASE_API_FUNCTIONS;
|
|
13
|
+
exports.BUILDER_VARIANTS = require_constants_plugin.BUILDER_VARIANTS;
|
|
14
|
+
exports.CACHE_HASH_LENGTH = require_constants_meta.CACHE_HASH_LENGTH;
|
|
15
|
+
exports.CLIENT_ENVIRONMENT = require_constants_environments.CLIENT_ENVIRONMENT;
|
|
16
|
+
exports.DEFAULT_DEVELOPMENT_LOG_LEVEL = require_constants_log_level.DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
17
|
+
exports.DEFAULT_ENVIRONMENT = require_constants_environments.DEFAULT_ENVIRONMENT;
|
|
18
|
+
exports.DEFAULT_PRODUCTION_LOG_LEVEL = require_constants_log_level.DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
19
|
+
exports.DEFAULT_TEST_LOG_LEVEL = require_constants_log_level.DEFAULT_TEST_LOG_LEVEL;
|
|
20
|
+
exports.GLOBAL_ENVIRONMENT = require_constants_environments.GLOBAL_ENVIRONMENT;
|
|
21
|
+
exports.HOOKS_LIST_ORDERS = require_constants_hooks.HOOKS_LIST_ORDERS;
|
|
22
|
+
exports.KNOWN_PLUGIN_FIELDS = require_constants_plugin.KNOWN_PLUGIN_FIELDS;
|
|
23
|
+
exports.PLUGIN_HOOKS_FIELDS = require_constants_plugin.PLUGIN_HOOKS_FIELDS;
|
|
24
|
+
exports.PLUGIN_NON_HOOK_FIELDS = require_constants_plugin.PLUGIN_NON_HOOK_FIELDS;
|
|
25
|
+
exports.POWERLINES_API_FUNCTIONS = require_constants_api.POWERLINES_API_FUNCTIONS;
|
|
26
|
+
exports.ROOT_HASH_LENGTH = require_constants_meta.ROOT_HASH_LENGTH;
|
|
27
|
+
exports.RSC_ENVIRONMENT = require_constants_environments.RSC_ENVIRONMENT;
|
|
28
|
+
exports.SERVER_ENVIRONMENT = require_constants_environments.SERVER_ENVIRONMENT;
|
|
29
|
+
exports.SSR_ENVIRONMENT = require_constants_environments.SSR_ENVIRONMENT;
|
|
30
|
+
exports.STORAGE_PRESETS = require_constants_fs.STORAGE_PRESETS;
|
|
31
|
+
exports.SUPPORTED_COMMANDS = require_constants_commands.SUPPORTED_COMMANDS;
|
|
32
|
+
exports.UNPLUGIN_BUILDER_VARIANTS = require_constants_plugin.UNPLUGIN_BUILDER_VARIANTS;
|
|
33
|
+
exports.VIRTUAL_MODULE_PREFIX = require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX;
|
|
34
|
+
exports.VIRTUAL_MODULE_PREFIX_REGEX = require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX;
|
|
35
|
+
exports.__VFS_PATCH__ = require_constants_fs.__VFS_PATCH__;
|
|
36
|
+
exports.__VFS_REVERT__ = require_constants_fs.__VFS_REVERT__;
|
package/dist/constants/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BASE_API_FUNCTIONS, POWERLINES_API_FUNCTIONS } from "./api.mjs";
|
|
2
2
|
import { SUPPORTED_COMMANDS } from "./commands.mjs";
|
|
3
3
|
import { BUILDER_VARIANTS, KNOWN_PLUGIN_FIELDS, PLUGIN_HOOKS_FIELDS, PLUGIN_NON_HOOK_FIELDS, UNPLUGIN_BUILDER_VARIANTS } from "./plugin.mjs";
|
|
4
|
-
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX } from "./virtual-modules.mjs";
|
|
5
4
|
import { CLIENT_ENVIRONMENT, DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT, RSC_ENVIRONMENT, SERVER_ENVIRONMENT, SSR_ENVIRONMENT } from "./environments.mjs";
|
|
6
5
|
import { STORAGE_PRESETS, __VFS_PATCH__, __VFS_REVERT__ } from "./fs.mjs";
|
|
7
6
|
import { HOOKS_LIST_ORDERS } from "./hooks.mjs";
|
|
8
7
|
import { DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL } from "./log-level.mjs";
|
|
9
8
|
import { CACHE_HASH_LENGTH, ROOT_HASH_LENGTH } from "./meta.mjs";
|
|
9
|
+
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX } from "./virtual-modules.mjs";
|
|
10
10
|
|
|
11
11
|
export { BASE_API_FUNCTIONS, BUILDER_VARIANTS, CACHE_HASH_LENGTH, CLIENT_ENVIRONMENT, DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_ENVIRONMENT, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL, GLOBAL_ENVIRONMENT, HOOKS_LIST_ORDERS, KNOWN_PLUGIN_FIELDS, PLUGIN_HOOKS_FIELDS, PLUGIN_NON_HOOK_FIELDS, POWERLINES_API_FUNCTIONS, ROOT_HASH_LENGTH, RSC_ENVIRONMENT, SERVER_ENVIRONMENT, SSR_ENVIRONMENT, STORAGE_PRESETS, SUPPORTED_COMMANDS, UNPLUGIN_BUILDER_VARIANTS, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __VFS_PATCH__, __VFS_REVERT__ };
|
package/dist/constants/meta.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_constants_commands = require('./commands.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/constants/plugin.ts
|
|
4
5
|
const UNPLUGIN_BUILDER_VARIANTS = [
|
|
@@ -26,7 +27,7 @@ const PLUGIN_NON_HOOK_FIELDS = [
|
|
|
26
27
|
"applyToEnvironment"
|
|
27
28
|
];
|
|
28
29
|
const PLUGIN_HOOKS_FIELDS = [
|
|
29
|
-
...
|
|
30
|
+
...require_constants_commands.SUPPORTED_COMMANDS,
|
|
30
31
|
"config",
|
|
31
32
|
"configEnvironment",
|
|
32
33
|
"configResolved",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_constants_plugin = require('../../constants/plugin.cjs');
|
|
4
4
|
let defu = require("defu");
|
|
5
5
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ function combineContexts(contextA, contextB) {
|
|
|
22
22
|
* @returns True if the value is a UnpluginBuilderVariant, false otherwise.
|
|
23
23
|
*/
|
|
24
24
|
function isUnpluginBuilderVariant(str) {
|
|
25
|
-
return (0, _stryke_type_checks_is_set_string.isSetString)(str) &&
|
|
25
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(str) && require_constants_plugin.UNPLUGIN_BUILDER_VARIANTS.includes(str);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_constants_virtual_modules = require('../../constants/virtual-modules.cjs');
|
|
4
|
+
require('../../constants/index.cjs');
|
|
4
5
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
5
6
|
let defu = require("defu");
|
|
6
7
|
defu = require_runtime.__toESM(defu, 1);
|
|
@@ -24,8 +25,8 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
24
25
|
const ctx = context;
|
|
25
26
|
return {
|
|
26
27
|
async resolveId(id, importer, opts = { isEntry: false }) {
|
|
27
|
-
const normalizedId = id.replace(
|
|
28
|
-
const normalizedImporter = importer ? importer.replace(
|
|
28
|
+
const normalizedId = id.replace(require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX, "");
|
|
29
|
+
const normalizedImporter = importer ? importer.replace(require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX, "") : void 0;
|
|
29
30
|
let result = await ctx.$$internal.callHook("resolveId", {
|
|
30
31
|
sequential: true,
|
|
31
32
|
result: "first",
|
|
@@ -34,7 +35,7 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
34
35
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
35
36
|
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
36
37
|
...result,
|
|
37
|
-
id: result.virtual && options.prefix !== false ? `${
|
|
38
|
+
id: result.virtual && options.prefix !== false ? `${require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
38
39
|
};
|
|
39
40
|
result = await ctx.$$internal.callHook("resolveId", {
|
|
40
41
|
sequential: true,
|
|
@@ -44,7 +45,7 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
44
45
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
45
46
|
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
46
47
|
...result,
|
|
47
|
-
id: result.virtual && options.prefix !== false ? `${
|
|
48
|
+
id: result.virtual && options.prefix !== false ? `${require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
48
49
|
};
|
|
49
50
|
result = await ctx.resolve(normalizedId, normalizedImporter, (0, defu.default)(options.overrides ?? {}, {
|
|
50
51
|
isFile: true,
|
|
@@ -52,7 +53,7 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
52
53
|
}));
|
|
53
54
|
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
54
55
|
...result,
|
|
55
|
-
id: result.virtual && options.prefix !== false ? `${
|
|
56
|
+
id: result.virtual && options.prefix !== false ? `${require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
56
57
|
};
|
|
57
58
|
result = await ctx.$$internal.callHook("resolveId", {
|
|
58
59
|
sequential: true,
|
|
@@ -62,14 +63,14 @@ function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
|
62
63
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
63
64
|
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
64
65
|
...result,
|
|
65
|
-
id: result.virtual && options.prefix !== false ? `${
|
|
66
|
+
id: result.virtual && options.prefix !== false ? `${require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
66
67
|
};
|
|
67
68
|
return null;
|
|
68
69
|
},
|
|
69
70
|
load: {
|
|
70
|
-
filter: options.prefix !== false ? { id: { include: [
|
|
71
|
+
filter: options.prefix !== false ? { id: { include: [require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX] } } : void 0,
|
|
71
72
|
async handler(id) {
|
|
72
|
-
const normalizedId = id.replace(
|
|
73
|
+
const normalizedId = id.replace(require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX, "");
|
|
73
74
|
let result = await ctx.$$internal.callHook("load", {
|
|
74
75
|
sequential: true,
|
|
75
76
|
result: "first",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX } from "../../constants/virtual-modules.mjs";
|
|
2
|
+
import "../../constants/index.mjs";
|
|
2
3
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
4
|
import defu from "defu";
|
|
4
5
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
@@ -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 defu from \"defu\";\nimport { LoadResult } from \"rollup\";\nimport type {\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginOptions\n} from \"unplugin\";\nimport {\n VIRTUAL_MODULE_PREFIX,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"../../constants
|
|
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 defu from \"defu\";\nimport { LoadResult } from \"rollup\";\nimport type {\n UnpluginBuildContext,\n UnpluginContext,\n UnpluginOptions\n} from \"unplugin\";\nimport {\n VIRTUAL_MODULE_PREFIX,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"../../constants\";\nimport { Unstable_PluginContext } from \"../../types/_internal\";\nimport { PluginContext, ResolveResult } from \"../../types/context\";\nimport { ResolveOptions } from \"../../types/fs\";\n\nexport interface CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * An indicator of whether to prefix virtual module IDs with a specific string. This is useful for ensuring that virtual modules are only processed by the plugin and not by other plugins or the bundler itself.\n *\n * @remarks\n * - If set to `true`, virtual module IDs will be prefixed with the string `__powerlines-virtual:`.\n * - If set to `false`, no prefix will be added to virtual module IDs.\n *\n * @defaultValue true\n */\n prefix?: boolean;\n\n /**\n * Optional overrides for the module resolution configuration.\n *\n * @remarks\n * This allows you to customize the behavior of the module resolution hooks by providing specific configuration options.\n */\n overrides?: Partial<ResolveOptions>;\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 * @param options - Options for creating the module resolution functions.\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 Unstable_PluginContext;\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 | ResolveResult | null | undefined> {\n const normalizedId = id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\");\n const normalizedImporter = importer\n ? importer.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\")\n : undefined;\n\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? `${VIRTUAL_MODULE_PREFIX}${result.id}`\n : 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 normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? `${VIRTUAL_MODULE_PREFIX}${result.id}`\n : result.id\n };\n }\n\n result = await ctx.resolve(\n normalizedId,\n normalizedImporter,\n defu(options.overrides ?? {}, {\n isFile: true,\n ...opts\n })\n );\n if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? `${VIRTUAL_MODULE_PREFIX}${result.id}`\n : 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 normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && options.prefix !== false\n ? `${VIRTUAL_MODULE_PREFIX}${result.id}`\n : result.id\n };\n }\n\n return null;\n },\n load: {\n filter:\n options.prefix !== false\n ? {\n id: {\n include: [VIRTUAL_MODULE_PREFIX_REGEX]\n }\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const normalizedId = id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\");\n\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId\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 normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await ctx.load(normalizedId);\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 normalizedId\n );\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqEA,SAAgB,wCAGd,SACA,UAA0D,EAAE,EACf;CAC7C,MAAM,MAAM;AAEZ,QAAO;EACL,MAAM,UAEJ,IACA,UACA,OAEI,EAAE,SAAS,OAAO,EAC8B;GACpD,MAAM,eAAe,GAAG,QAAQ,6BAA6B,GAAG;GAChE,MAAM,qBAAqB,WACvB,SAAS,QAAQ,6BAA6B,GAAG,GACjD;GAEJ,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,cACA,oBACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO;YACE,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,GAAG,wBAAwB,OAAO,OAClC,OAAO;IACd;AAGH,YAAS,MAAM,IAAI,WAAW,SAC5B,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,cACA,oBACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO;YACE,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,GAAG,wBAAwB,OAAO,OAClC,OAAO;IACd;AAGH,YAAS,MAAM,IAAI,QACjB,cACA,oBACA,KAAK,QAAQ,aAAa,EAAE,EAAE;IAC5B,QAAQ;IACR,GAAG;IACJ,CAAC,CACH;AACD,OAAI,YAAY,OAAO,CACrB,QAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,GAAG,wBAAwB,OAAO,OAClC,OAAO;IACd;AAGH,YAAS,MAAM,IAAI,WAAW,SAC5B,aACA;IACE,YAAY;IACZ,QAAQ;IACR,OAAO;IACR,EACD,cACA,oBACA,KACD;AACD,OAAI,YAAY,OAAO,CACrB,QAAO;YACE,YAAY,OAAO,CAC5B,QAAO;IACL,GAAG;IACH,IACE,OAAO,WAAW,QAAQ,WAAW,QACjC,GAAG,wBAAwB,OAAO,OAClC,OAAO;IACd;AAGH,UAAO;;EAET,MAAM;GACJ,QACE,QAAQ,WAAW,QACf,EACE,IAAI,EACF,SAAS,CAAC,4BAA4B,EACvC,EACF,GACD;GACN,MAAM,QAEJ,IACwC;IACxC,MAAM,eAAe,GAAG,QAAQ,6BAA6B,GAAG;IAEhE,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,aACD;AACD,QAAI,OACF,QAAO;AAGT,aAAS,MAAM,IAAI,WAAW,SAC5B,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,aACD;AACD,QAAI,OACF,QAAO;AAGT,aAAS,MAAM,IAAI,KAAK,aAAa;AACrC,QAAI,OACF,QAAO;AAGT,WAAO,IAAI,WAAW,SACpB,QACA;KACE,YAAY;KACZ,QAAQ;KACR,OAAO;KACR,EACD,aACD;;GAEJ;EACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_lib_unplugin_helpers = require('./helpers.cjs');
|
|
4
|
-
const
|
|
4
|
+
const require_constants_virtual_modules = require('../../constants/virtual-modules.cjs');
|
|
5
|
+
require('../../constants/index.cjs');
|
|
5
6
|
const require_lib_unplugin_module_resolution = require('./module-resolution.cjs');
|
|
6
7
|
const require_lib_utilities_source_file = require('../utilities/source-file.cjs');
|
|
7
8
|
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
@@ -58,7 +59,7 @@ function createUnplugin(context, options = {}) {
|
|
|
58
59
|
async function transform(code, id) {
|
|
59
60
|
let transformed = code;
|
|
60
61
|
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
61
|
-
const result = await hook.handler.apply(require_lib_unplugin_helpers.combineContexts(ctx, this), [require_lib_utilities_source_file.getString(transformed), id.replace(
|
|
62
|
+
const result = await hook.handler.apply(require_lib_unplugin_helpers.combineContexts(ctx, this), [require_lib_utilities_source_file.getString(transformed), id.replace(require_constants_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX, "")]);
|
|
62
63
|
if (result) transformed = result;
|
|
63
64
|
}
|
|
64
65
|
return transformed;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { combineContexts } from "./helpers.mjs";
|
|
2
2
|
import { VIRTUAL_MODULE_PREFIX_REGEX } from "../../constants/virtual-modules.mjs";
|
|
3
|
+
import "../../constants/index.mjs";
|
|
3
4
|
import { createUnpluginModuleResolutionFunctions } from "./module-resolution.mjs";
|
|
4
5
|
import { getString } from "../utilities/source-file.mjs";
|
|
5
6
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"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 {
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"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 { 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 { VIRTUAL_MODULE_PREFIX_REGEX } from \"../../constants\";\nimport { Unstable_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\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 \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\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 Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const logger = ctx.extendLogger({ source: name });\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\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 Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const logger = ctx.extendLogger({ source: name });\n logger.debug(`Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin starting...\");\n }\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.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\")\n ] as [code: string, id: string]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Powerlines build plugin finishing...\");\n }\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n logger.debug(\"Finalizing Powerlines project output...\");\n }\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\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 logger.error(error instanceof Error ? error.message : String(error));\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuDA,SAAgB,uBAGd,SACA,UAAyC,EAAE,EAChB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,SAAS,IAAI,aAAa,EAAE,QAAQ,MAAM,CAAC;AACjD,SAAO,MAAM,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAEtD,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;AAErE,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACD;WACM,OAAO;AACd,UAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;AAEpE,SAAM;;;;;;;;;;AAoBZ,SAAgB,eACd,SACA,UAAiC,EAAE,EACR;CAC3B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.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_constants_plugin = require('../constants/plugin.cjs');
|
|
4
4
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
5
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
6
6
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
@@ -15,7 +15,7 @@ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined
|
|
|
15
15
|
* @returns True if the object is a {@link Plugin}, false otherwise
|
|
16
16
|
*/
|
|
17
17
|
function isPlugin(value) {
|
|
18
|
-
return (0, _stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, _stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, _stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, _stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, _stryke_type_checks_is_function.isFunction)(value.dedupe)) &&
|
|
18
|
+
return (0, _stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, _stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, _stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, _stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, _stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, _stryke_type_checks_is_function.isFunction)(value.dedupe)) && require_constants_plugin.PLUGIN_HOOKS_FIELDS.every((hook) => (0, _stryke_type_checks_is_undefined.isUndefined)(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && (0, _stryke_type_checks_is_set_object.isSetObject)(value[hook])));
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Type guard to check if an object is a {@link PluginConfigObject}
|
|
@@ -100,7 +100,7 @@ function extractPluginHook(context, plugin, hook) {
|
|
|
100
100
|
* @returns True if the hook is external, false otherwise.
|
|
101
101
|
*/
|
|
102
102
|
function isUnpluginHookKey(keys) {
|
|
103
|
-
return
|
|
103
|
+
return require_constants_plugin.UNPLUGIN_BUILDER_VARIANTS.some((variant) => keys.startsWith(`${variant}:`));
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Check if a hook is internal.
|
|
@@ -109,7 +109,7 @@ function isUnpluginHookKey(keys) {
|
|
|
109
109
|
* @returns True if the hook is external, false otherwise.
|
|
110
110
|
*/
|
|
111
111
|
function isPluginHookField(keys) {
|
|
112
|
-
return !
|
|
112
|
+
return !require_constants_plugin.PLUGIN_NON_HOOK_FIELDS.includes(keys);
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Check if a hook is external.
|
|
@@ -118,7 +118,7 @@ function isPluginHookField(keys) {
|
|
|
118
118
|
* @returns True if the hook is external, false otherwise.
|
|
119
119
|
*/
|
|
120
120
|
function isUnpluginHookField(field) {
|
|
121
|
-
return !isPluginHookField(field) &&
|
|
121
|
+
return !isPluginHookField(field) && require_constants_plugin.UNPLUGIN_BUILDER_VARIANTS.includes(field);
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Check if a plugin should be deduplicated.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_constants_environments = require('../constants/environments.cjs');
|
|
4
|
+
const require_constants_log_level = require('../constants/log-level.cjs');
|
|
3
5
|
const require_logging = require('../types/logging.cjs');
|
|
4
|
-
const require_environments = require('../constants/environments.cjs');
|
|
5
|
-
const require_log_level = require('../constants/log-level.cjs');
|
|
6
6
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
7
7
|
let defu = require("defu");
|
|
8
8
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
@@ -59,9 +59,9 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
59
59
|
babel: "silent"
|
|
60
60
|
};
|
|
61
61
|
let defaultLogLevel;
|
|
62
|
-
if (mode === "development") defaultLogLevel =
|
|
63
|
-
else if (mode === "test") defaultLogLevel =
|
|
64
|
-
else defaultLogLevel =
|
|
62
|
+
if (mode === "development") defaultLogLevel = require_constants_log_level.DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
63
|
+
else if (mode === "test") defaultLogLevel = require_constants_log_level.DEFAULT_TEST_LOG_LEVEL;
|
|
64
|
+
else defaultLogLevel = require_constants_log_level.DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
65
65
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(logLevel)) return {
|
|
66
66
|
general: logLevel,
|
|
67
67
|
fs: defaultLogLevel.fs,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LOG_LEVELS, LogCategories, LogLevels } from "../types/logging.mjs";
|
|
2
1
|
import { DEFAULT_ENVIRONMENT } from "../constants/environments.mjs";
|
|
3
2
|
import { DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL } from "../constants/log-level.mjs";
|
|
3
|
+
import { LOG_LEVELS, LogCategories, LogLevels } from "../types/logging.mjs";
|
|
4
4
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
5
5
|
import { defu as defu$1 } from "defu";
|
|
6
6
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
package/dist/types/logging.d.cts
CHANGED
|
@@ -152,7 +152,7 @@ interface CustomLogger {
|
|
|
152
152
|
*/
|
|
153
153
|
trace?: (message: CustomLoggerMessage) => void;
|
|
154
154
|
}
|
|
155
|
-
type LogLevelUserConfig = LogLevel | RequiredKeys<Record<LogCategory, LogLevel | boolean | undefined
|
|
155
|
+
type LogLevelUserConfig = LogLevel | RequiredKeys<Partial<Record<LogCategory, LogLevel | boolean | undefined>>, "general">;
|
|
156
156
|
type LogLevelResolvedConfig = Record<LogCategory, LogLevel>;
|
|
157
157
|
declare type __ΩLogLevel = any[];
|
|
158
158
|
declare type __ΩLogCategory = any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/types/logging.ts"],"mappings":";;;;;cAsBa,SAAA;EAAA;;;;;;;cASA,UAAA;AAAA,KASD,QAAA,WAAmB,UAAA;AAAA,cAElB,aAAA;EAAA;;;;;;;;;;;cAaA,cAAA;AAAA,KAaD,WAAA,WAAsB,cAAA;AAAA,UAEjB,OAAA;EAjBP;;;EAqBR,KAAA;;;;EAIA,IAAA,EAAM,QAAA;;;;EAIN,QAAA,EAAU,WAAA;;;;EAIV,SAAA;EApBQ;;;EAwBR,IAAA;EAtBU;;;EA0BV,WAAA;EA1B8C;AAEhD;;EA4BE,cAAA;EAhBqB;;;EAoBrB,OAAA;EApBA;;;EAwBA,IAAA;EAZA;;;EAgBA,WAAA;EAAA;;;EAIA,MAAA;EAIM;AAGR;;EAHE,MAAA;AAAA;AAAA,KAGU,YAAA,GAAe,IAAA,CACzB,OAAA,CAAQ,OAAA;EAGR,IAAA,GAAO,IAAA;EACP,QAAA,GAAW,kBAAA;AAAA;AAAA,KAGD,SAAA,GACR,QAAA,GACA,WAAA,CAAY,OAAA;AAAA,KAEJ,KAAA,IAAS,IAAA,EAAM,SAAA,KAAc,IAAA;AAAA,KAE7B,UAAA,GAAa,WAAA,CACvB,IAAA,CAAK,OAAA;AAAA,KAIK,aAAA,GAAgB,IAAA,C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AA,EAAS,mBAAA;EAhDlB;;;;AAIF;;EAmDE,IAAA,IAAQ,OAAA,EAAS,mBAAA;EAnDc;;;;;;EA0D/B,IAAA,IAAQ,OAAA,EAAS,mBAAA;EA1Dc;;;;;;EAiE/B,KAAA,IAAS,OAAA,EAAS,mBAAA;EA5DH;;;;;;EAmEf,KAAA,IAAS,OAAA,EAAS,mBAAA;AAAA;AAAA,KAGR,kBAAA,GACR,QAAA,GACA,YAAA,CACE,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,QAAA;AAAA,KAItB,sBAAA,GAAyB,MAAA,CAAO,WAAA,EAAa,QAAA;AAAA"}
|
package/dist/types/logging.d.mts
CHANGED
|
@@ -152,7 +152,7 @@ interface CustomLogger {
|
|
|
152
152
|
*/
|
|
153
153
|
trace?: (message: CustomLoggerMessage) => void;
|
|
154
154
|
}
|
|
155
|
-
type LogLevelUserConfig = LogLevel | RequiredKeys<Record<LogCategory, LogLevel | boolean | undefined
|
|
155
|
+
type LogLevelUserConfig = LogLevel | RequiredKeys<Partial<Record<LogCategory, LogLevel | boolean | undefined>>, "general">;
|
|
156
156
|
type LogLevelResolvedConfig = Record<LogCategory, LogLevel>;
|
|
157
157
|
declare type __ΩLogLevel = any[];
|
|
158
158
|
declare type __ΩLogCategory = any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/types/logging.ts"],"mappings":";;;;;cAsBa,SAAA;EAAA;;;;;;;cASA,UAAA;AAAA,KASD,QAAA,WAAmB,UAAA;AAAA,cAElB,aAAA;EAAA;;;;;;;;;;;cAaA,cAAA;AAAA,KAaD,WAAA,WAAsB,cAAA;AAAA,UAEjB,OAAA;EAjBP;;;EAqBR,KAAA;;;;EAIA,IAAA,EAAM,QAAA;;;;EAIN,QAAA,EAAU,WAAA;;;;EAIV,SAAA;EApBQ;;;EAwBR,IAAA;EAtBU;;;EA0BV,WAAA;EA1B8C;AAEhD;;EA4BE,cAAA;EAhB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AkB,UAAA;;;;UAK7B,MAAA;EACf,OAAA,EAAS,aAAA;EACT,KAAA,GAAQ,OAAA,WAAkB,aAAA;EAC1B,IAAA,GAAO,OAAA,WAAkB,aAAA;EACzB,IAAA,GAAO,OAAA,WAAkB,aAAA;EACzB,KAAA,GAAQ,OAAA,WAAkB,aAAA;EAC1B,KAAA,GAAQ,OAAA,WAAkB,aAAA;EAC1B,GAAA,GAAM,IAAA,EAAM,QAAA,EAAU,OAAA,WAAkB,aAAA;AAAA;;;;KAM9B,mBAAA,GAAsB,iBAAA,CAAkB,IAAA,CAAK,OAAA;;;AArCzD;UA0CiB,YAAA;;;;;;;EAOf,KAAA,IAAS,OAAA,EAAS,mBAAA;EAhDlB;;;;AAIF;;EAmDE,IAAA,IAAQ,OAAA,EAAS,mBAAA;EAnDc;;;;;;EA0D/B,IAAA,IAAQ,OAAA,EAAS,mBAAA;EA1Dc;;;;;;EAiE/B,KAAA,IAAS,OAAA,EAAS,mBAAA;EA5DH;;;;;;EAmEf,KAAA,IAAS,OAAA,EAAS,mBAAA;AAAA;AAAA,KAGR,kBAAA,GACR,QAAA,GACA,YAAA,CACE,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,QAAA;AAAA,KAItB,sBAAA,GAAyB,MAAA,CAAO,WAAA,EAAa,QAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.mjs","names":[],"sources":["../../src/types/logging.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 { PartialKeys, RequiredKeys } from \"@stryke/types/base\";\nimport { UnpluginMessage } from \"unplugin\";\nimport { Mode } from \"./config\";\n\nexport const LogLevels = {\n SILENT: \"silent\",\n ERROR: \"error\",\n WARN: \"warn\",\n INFO: \"info\",\n DEBUG: \"debug\",\n TRACE: \"trace\"\n} as const;\n\nexport const LOG_LEVELS = [\n LogLevels.SILENT,\n LogLevels.ERROR,\n LogLevels.WARN,\n LogLevels.INFO,\n LogLevels.DEBUG,\n LogLevels.TRACE\n] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\nexport const LogCategories = {\n GENERAL: \"general\",\n FS: \"fs\",\n PERFORMANCE: \"performance\",\n CONFIG: \"config\",\n PLUGINS: \"plugins\",\n HOOKS: \"hooks\",\n ENV: \"env\",\n IPC: \"ipc\",\n BABEL: \"babel\",\n NETWORK: \"network\"\n} as const;\n\nexport const LOG_CATEGORIES = [\n LogCategories.GENERAL,\n LogCategories.FS,\n LogCategories.PERFORMANCE,\n LogCategories.CONFIG,\n LogCategories.PLUGINS,\n LogCategories.HOOKS,\n LogCategories.ENV,\n LogCategories.IPC,\n LogCategories.NETWORK,\n LogCategories.BABEL\n] as const;\n\nexport type LogCategory = (typeof LOG_CATEGORIES)[number];\n\nexport interface LogMeta {\n /**\n * A unique identifier for the log message, which can be used to correlate related log entries across different parts of the system or different executions.\n */\n logId: string;\n /**\n * The log level of the message, which indicates the severity or importance of the log entry. The log level can be used to filter log messages based on their importance, allowing users to focus on critical issues or relevant information while ignoring less important messages.\n */\n type: LogLevel;\n /**\n * The category of the log message, which can be used to classify and filter log entries based on their purpose or origin.\n */\n category: LogCategory;\n /**\n * The timestamp when the IPC message was created, represented as the number of milliseconds since the Unix epoch.\n */\n timestamp: number;\n /**\n * The name of the project or package associated with the log message, which can be used to identify the source of the log entry and provide context for the message.\n */\n name?: string;\n /**\n * A unique identifier for the current execution instance, which can be used for logging and other purposes to distinguish between different executions in the same process.\n */\n executionId?: string;\n /**\n * The zero-based index of the current execution within the sequence of executions in the same process.\n */\n executionIndex?: number;\n /**\n * Optional command identifier to specify the command or task associated with the log message, which can be used to provide additional context about the operation being performed when the log entry was generated.\n */\n command?: string;\n /**\n * Optional hook name to specify the plugin hook associated with the log message, which can be used to provide additional context about the specific plugin hook being executed when the log entry was generated.\n */\n hook?: string;\n /**\n * Optional environment identifier to specify the context or environment in which the message is being processed.\n */\n environment?: string;\n /**\n * Optional plugin name to specify the source plugin of the log message.\n */\n plugin?: string;\n /**\n * The name of the logger or source of the log message, which can be used to identify the origin of the log entry.\n */\n source?: string;\n}\n\nexport type LogFnOptions = Omit<\n Partial<LogMeta>,\n \"logId\" | \"timestamp\" | \"name\" | \"type\"\n> & {\n mode?: Mode;\n logLevel?: LogLevelUserConfig;\n};\n\nexport type LogFnMeta =\n | LogLevel\n | PartialKeys<LogMeta, \"logId\" | \"timestamp\" | \"name\" | \"category\">;\n\nexport type LogFn = (meta: LogFnMeta, ...args: string[]) => void;\n\nexport type LoggerMeta = PartialKeys<\n Omit<LogMeta, \"type\">,\n \"logId\" | \"timestamp\" | \"name\" | \"category\"\n>;\n\nexport type LoggerOptions = Omit<LoggerMeta, \"logId\" | \"timestamp\" | \"type\"> & {\n mode?: Mode;\n logLevel?: LogLevelUserConfig;\n};\n\nexport interface PowerlinesMessage<TMeta> extends UnpluginMessage {\n meta: TMeta;\n}\n\nexport type LogMessage = PowerlinesMessage<Partial<LogMeta>>;\n\n/**\n * A type representing a log message that can be passed to the logging methods defined in the {@link Logger} interface, which includes the log metadata and message content. This type is used as the parameter for the logging methods defined in the {@link Logger} interface, allowing users to log messages with rich metadata that can be used for filtering, formatting, or other purposes in the logging implementation.\n */\nexport type LoggerMessage = PowerlinesMessage<LoggerMeta>;\n\n/**\n * An internal interface representing a logger instance used within Powerlines for logging messages at various log levels, including \"error\", \"warn\", \"info\", \"debug\", and \"trace\". This interface defines methods for logging messages at each log level, which accept a message parameter that can be either a string or an object containing the log metadata and message content. The logger instance also includes an options property that contains the configuration options used for the logger, such as the source, command, environment, plugin, log level, and other relevant metadata. This interface is intended for internal use within Powerlines and is not meant to be implemented by users directly; instead, users can provide a custom logger that implements the {@link CustomLogger} interface to integrate with Powerlines' logging system.\n */\nexport interface Logger {\n options: LoggerOptions;\n error: (message: string | LoggerMessage) => void;\n warn: (message: string | LoggerMessage) => void;\n info: (message: string | LoggerMessage) => void;\n debug: (message: string | LoggerMessage) => void;\n trace: (message: string | LoggerMessage) => void;\n log: (type: LogLevel, message: string | LoggerMessage) => void;\n}\n\n/**\n * A type representing a log message that can be passed to a custom logger, which includes the log metadata and message content. This type is used as the parameter for the logging methods defined in the {@link CustomLogger} interface, allowing users to log messages with rich metadata that can be used for filtering, formatting, or other purposes in their custom logging implementation.\n */\nexport type CustomLoggerMessage = PowerlinesMessage<Omit<LogMeta, \"type\">>;\n\n/**\n * An interface representing a custom logger that can be provided by the user to override the default logging behavior of Powerlines. This interface defines methods for logging messages at different log levels, including \"error\", \"warn\", \"info\", \"debug\", and \"trace\". Each method accepts a message parameter, which can be either a string or an object containing the log metadata and message content. By implementing this interface, users can integrate their own logging system with Powerlines or customize the logging behavior to suit their specific needs.\n */\nexport interface CustomLogger {\n /**\n * A function to log messages at the \"error\" level, which indicates a serious issue that has caused a failure in the build process or a critical problem that needs immediate attention.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the error being reported.\n * @returns void\n */\n error?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"warn\" level, which indicates a potential issue or a situation that may require attention but does not necessarily cause a failure in the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the warning being reported.\n * @returns void\n */\n warn?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"info\" level, which indicates general informational messages about the build process, such as the start and completion of tasks, configuration details, or other relevant information that may be useful for monitoring the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the informational message being reported.\n * @returns void\n */\n info?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"debug\" level, which indicates detailed debugging information that may be useful for diagnosing issues during development or troubleshooting problems in the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the debug information being reported.\n * @returns void\n */\n debug?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"trace\" level, which indicates very detailed tracing information that may be useful for in-depth analysis of the build process or for tracking the flow of execution through various stages of the build.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the trace information being reported.\n * @returns void\n */\n trace?: (message: CustomLoggerMessage) => void;\n}\n\nexport type LogLevelUserConfig =\n | LogLevel\n | RequiredKeys<\n Record<LogCategory, LogLevel | boolean | undefined>,\n \"general\"\n >;\n\nexport type LogLevelResolvedConfig = Record<LogCategory, LogLevel>;\n"],"mappings":";AAsBA,MAAa,YAAY;CACvB,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACR;AAED,MAAa,aAAa;CACxB,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACX;AAID,MAAa,gBAAgB;CAC3B,SAAS;CACT,IAAI;CACJ,aAAa;CACb,QAAQ;CACR,SAAS;CACT,OAAO;CACP,KAAK;CACL,KAAK;CACL,OAAO;CACP,SAAS;CACV;AAED,MAAa,iBAAiB;CAC5B,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACf"}
|
|
1
|
+
{"version":3,"file":"logging.mjs","names":[],"sources":["../../src/types/logging.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 { PartialKeys, RequiredKeys } from \"@stryke/types/base\";\nimport { UnpluginMessage } from \"unplugin\";\nimport { Mode } from \"./config\";\n\nexport const LogLevels = {\n SILENT: \"silent\",\n ERROR: \"error\",\n WARN: \"warn\",\n INFO: \"info\",\n DEBUG: \"debug\",\n TRACE: \"trace\"\n} as const;\n\nexport const LOG_LEVELS = [\n LogLevels.SILENT,\n LogLevels.ERROR,\n LogLevels.WARN,\n LogLevels.INFO,\n LogLevels.DEBUG,\n LogLevels.TRACE\n] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\nexport const LogCategories = {\n GENERAL: \"general\",\n FS: \"fs\",\n PERFORMANCE: \"performance\",\n CONFIG: \"config\",\n PLUGINS: \"plugins\",\n HOOKS: \"hooks\",\n ENV: \"env\",\n IPC: \"ipc\",\n BABEL: \"babel\",\n NETWORK: \"network\"\n} as const;\n\nexport const LOG_CATEGORIES = [\n LogCategories.GENERAL,\n LogCategories.FS,\n LogCategories.PERFORMANCE,\n LogCategories.CONFIG,\n LogCategories.PLUGINS,\n LogCategories.HOOKS,\n LogCategories.ENV,\n LogCategories.IPC,\n LogCategories.NETWORK,\n LogCategories.BABEL\n] as const;\n\nexport type LogCategory = (typeof LOG_CATEGORIES)[number];\n\nexport interface LogMeta {\n /**\n * A unique identifier for the log message, which can be used to correlate related log entries across different parts of the system or different executions.\n */\n logId: string;\n /**\n * The log level of the message, which indicates the severity or importance of the log entry. The log level can be used to filter log messages based on their importance, allowing users to focus on critical issues or relevant information while ignoring less important messages.\n */\n type: LogLevel;\n /**\n * The category of the log message, which can be used to classify and filter log entries based on their purpose or origin.\n */\n category: LogCategory;\n /**\n * The timestamp when the IPC message was created, represented as the number of milliseconds since the Unix epoch.\n */\n timestamp: number;\n /**\n * The name of the project or package associated with the log message, which can be used to identify the source of the log entry and provide context for the message.\n */\n name?: string;\n /**\n * A unique identifier for the current execution instance, which can be used for logging and other purposes to distinguish between different executions in the same process.\n */\n executionId?: string;\n /**\n * The zero-based index of the current execution within the sequence of executions in the same process.\n */\n executionIndex?: number;\n /**\n * Optional command identifier to specify the command or task associated with the log message, which can be used to provide additional context about the operation being performed when the log entry was generated.\n */\n command?: string;\n /**\n * Optional hook name to specify the plugin hook associated with the log message, which can be used to provide additional context about the specific plugin hook being executed when the log entry was generated.\n */\n hook?: string;\n /**\n * Optional environment identifier to specify the context or environment in which the message is being processed.\n */\n environment?: string;\n /**\n * Optional plugin name to specify the source plugin of the log message.\n */\n plugin?: string;\n /**\n * The name of the logger or source of the log message, which can be used to identify the origin of the log entry.\n */\n source?: string;\n}\n\nexport type LogFnOptions = Omit<\n Partial<LogMeta>,\n \"logId\" | \"timestamp\" | \"name\" | \"type\"\n> & {\n mode?: Mode;\n logLevel?: LogLevelUserConfig;\n};\n\nexport type LogFnMeta =\n | LogLevel\n | PartialKeys<LogMeta, \"logId\" | \"timestamp\" | \"name\" | \"category\">;\n\nexport type LogFn = (meta: LogFnMeta, ...args: string[]) => void;\n\nexport type LoggerMeta = PartialKeys<\n Omit<LogMeta, \"type\">,\n \"logId\" | \"timestamp\" | \"name\" | \"category\"\n>;\n\nexport type LoggerOptions = Omit<LoggerMeta, \"logId\" | \"timestamp\" | \"type\"> & {\n mode?: Mode;\n logLevel?: LogLevelUserConfig;\n};\n\nexport interface PowerlinesMessage<TMeta> extends UnpluginMessage {\n meta: TMeta;\n}\n\nexport type LogMessage = PowerlinesMessage<Partial<LogMeta>>;\n\n/**\n * A type representing a log message that can be passed to the logging methods defined in the {@link Logger} interface, which includes the log metadata and message content. This type is used as the parameter for the logging methods defined in the {@link Logger} interface, allowing users to log messages with rich metadata that can be used for filtering, formatting, or other purposes in the logging implementation.\n */\nexport type LoggerMessage = PowerlinesMessage<LoggerMeta>;\n\n/**\n * An internal interface representing a logger instance used within Powerlines for logging messages at various log levels, including \"error\", \"warn\", \"info\", \"debug\", and \"trace\". This interface defines methods for logging messages at each log level, which accept a message parameter that can be either a string or an object containing the log metadata and message content. The logger instance also includes an options property that contains the configuration options used for the logger, such as the source, command, environment, plugin, log level, and other relevant metadata. This interface is intended for internal use within Powerlines and is not meant to be implemented by users directly; instead, users can provide a custom logger that implements the {@link CustomLogger} interface to integrate with Powerlines' logging system.\n */\nexport interface Logger {\n options: LoggerOptions;\n error: (message: string | LoggerMessage) => void;\n warn: (message: string | LoggerMessage) => void;\n info: (message: string | LoggerMessage) => void;\n debug: (message: string | LoggerMessage) => void;\n trace: (message: string | LoggerMessage) => void;\n log: (type: LogLevel, message: string | LoggerMessage) => void;\n}\n\n/**\n * A type representing a log message that can be passed to a custom logger, which includes the log metadata and message content. This type is used as the parameter for the logging methods defined in the {@link CustomLogger} interface, allowing users to log messages with rich metadata that can be used for filtering, formatting, or other purposes in their custom logging implementation.\n */\nexport type CustomLoggerMessage = PowerlinesMessage<Omit<LogMeta, \"type\">>;\n\n/**\n * An interface representing a custom logger that can be provided by the user to override the default logging behavior of Powerlines. This interface defines methods for logging messages at different log levels, including \"error\", \"warn\", \"info\", \"debug\", and \"trace\". Each method accepts a message parameter, which can be either a string or an object containing the log metadata and message content. By implementing this interface, users can integrate their own logging system with Powerlines or customize the logging behavior to suit their specific needs.\n */\nexport interface CustomLogger {\n /**\n * A function to log messages at the \"error\" level, which indicates a serious issue that has caused a failure in the build process or a critical problem that needs immediate attention.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the error being reported.\n * @returns void\n */\n error?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"warn\" level, which indicates a potential issue or a situation that may require attention but does not necessarily cause a failure in the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the warning being reported.\n * @returns void\n */\n warn?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"info\" level, which indicates general informational messages about the build process, such as the start and completion of tasks, configuration details, or other relevant information that may be useful for monitoring the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the informational message being reported.\n * @returns void\n */\n info?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"debug\" level, which indicates detailed debugging information that may be useful for diagnosing issues during development or troubleshooting problems in the build process.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the debug information being reported.\n * @returns void\n */\n debug?: (message: CustomLoggerMessage) => void;\n /**\n * A function to log messages at the \"trace\" level, which indicates very detailed tracing information that may be useful for in-depth analysis of the build process or for tracking the flow of execution through various stages of the build.\n *\n * @param message - The log message to be recorded, which can be a string or an object containing the log metadata and message content. The log message should provide sufficient information to understand the context and nature of the trace information being reported.\n * @returns void\n */\n trace?: (message: CustomLoggerMessage) => void;\n}\n\nexport type LogLevelUserConfig =\n | LogLevel\n | RequiredKeys<\n Partial<Record<LogCategory, LogLevel | boolean | undefined>>,\n \"general\"\n >;\n\nexport type LogLevelResolvedConfig = Record<LogCategory, LogLevel>;\n"],"mappings":";AAsBA,MAAa,YAAY;CACvB,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACR;AAED,MAAa,aAAa;CACxB,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACX;AAID,MAAa,gBAAgB;CAC3B,SAAS;CACT,IAAI;CACJ,aAAa;CACb,QAAQ;CACR,SAAS;CACT,OAAO;CACP,KAAK;CACL,KAAK;CACL,OAAO;CACP,SAAS;CACV;AAED,MAAa,iBAAiB;CAC5B,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.4",
|
|
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",
|
|
@@ -44,6 +44,42 @@
|
|
|
44
44
|
"import": "./dist/constants/index.mjs",
|
|
45
45
|
"require": "./dist/constants/index.cjs"
|
|
46
46
|
},
|
|
47
|
+
"./constants/api": {
|
|
48
|
+
"import": "./dist/constants/api.mjs",
|
|
49
|
+
"require": "./dist/constants/api.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./constants/commands": {
|
|
52
|
+
"import": "./dist/constants/commands.mjs",
|
|
53
|
+
"require": "./dist/constants/commands.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./constants/environments": {
|
|
56
|
+
"import": "./dist/constants/environments.mjs",
|
|
57
|
+
"require": "./dist/constants/environments.cjs"
|
|
58
|
+
},
|
|
59
|
+
"./constants/fs": {
|
|
60
|
+
"import": "./dist/constants/fs.mjs",
|
|
61
|
+
"require": "./dist/constants/fs.cjs"
|
|
62
|
+
},
|
|
63
|
+
"./constants/hooks": {
|
|
64
|
+
"import": "./dist/constants/hooks.mjs",
|
|
65
|
+
"require": "./dist/constants/hooks.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./constants/log-level": {
|
|
68
|
+
"import": "./dist/constants/log-level.mjs",
|
|
69
|
+
"require": "./dist/constants/log-level.cjs"
|
|
70
|
+
},
|
|
71
|
+
"./constants/meta": {
|
|
72
|
+
"import": "./dist/constants/meta.mjs",
|
|
73
|
+
"require": "./dist/constants/meta.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./constants/plugin": {
|
|
76
|
+
"import": "./dist/constants/plugin.mjs",
|
|
77
|
+
"require": "./dist/constants/plugin.cjs"
|
|
78
|
+
},
|
|
79
|
+
"./constants/virtual-modules": {
|
|
80
|
+
"import": "./dist/constants/virtual-modules.mjs",
|
|
81
|
+
"require": "./dist/constants/virtual-modules.cjs"
|
|
82
|
+
},
|
|
47
83
|
"./lib": {
|
|
48
84
|
"import": "./dist/lib/index.mjs",
|
|
49
85
|
"require": "./dist/lib/index.cjs"
|
|
@@ -201,5 +237,5 @@
|
|
|
201
237
|
"typescript": "^6.0.3"
|
|
202
238
|
},
|
|
203
239
|
"publishConfig": { "access": "public" },
|
|
204
|
-
"gitHead": "
|
|
240
|
+
"gitHead": "eb9eda0379dc4e0c15936117ed0df7137977aa0c"
|
|
205
241
|
}
|