@powerlines/plugin-id 0.9.126 → 0.9.128

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.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1 +1,3 @@
1
- const e=require(`./nanoid.cjs`);exports.nanoidModule=e.nanoidModule;
1
+ const require_components_nanoid = require('./nanoid.cjs');
2
+
3
+ exports.nanoidModule = require_components_nanoid.nanoidModule;
@@ -1 +1,3 @@
1
- import{nanoidModule as e}from"./nanoid.mjs";export{e as nanoidModule};
1
+ import { nanoidModule } from "./nanoid.mjs";
2
+
3
+ export { nanoidModule };
@@ -1,11 +1,21 @@
1
- const e=require(`../powerlines/src/lib/utilities/file-header.cjs`);function t(t){return`
1
+ const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
2
+
3
+ //#region src/components/nanoid.ts
4
+ /**
5
+ * Generates the nanoid module content.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the nanoid module code.
9
+ */
10
+ function nanoidModule(context) {
11
+ return `
2
12
  /**
3
13
  * The ID module provides a set of utilities for generating unique identifiers.
4
14
  *
5
- * @module ${t.config.output.builtinPrefix}:id
15
+ * @module ${context.config.output.builtinPrefix}:id
6
16
  */
7
17
 
8
- ${e.getFileHeader(t)}
18
+ ${require_file_header.getFileHeader(context)}
9
19
 
10
20
  /**
11
21
  * Generate a random string
@@ -87,4 +97,8 @@ export function uniqueId(param?: string | number | undefined, size?: number | un
87
97
  return id;
88
98
  }, "");
89
99
  }
90
- `}exports.nanoidModule=t;
100
+ `;
101
+ }
102
+
103
+ //#endregion
104
+ exports.nanoidModule = nanoidModule;
@@ -1,11 +1,21 @@
1
- import{getFileHeader as e}from"../powerlines/src/lib/utilities/file-header.mjs";function t(t){return`
1
+ import { getFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
2
+
3
+ //#region src/components/nanoid.ts
4
+ /**
5
+ * Generates the nanoid module content.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the nanoid module code.
9
+ */
10
+ function nanoidModule(context) {
11
+ return `
2
12
  /**
3
13
  * The ID module provides a set of utilities for generating unique identifiers.
4
14
  *
5
- * @module ${t.config.output.builtinPrefix}:id
15
+ * @module ${context.config.output.builtinPrefix}:id
6
16
  */
7
17
 
8
- ${e(t)}
18
+ ${getFileHeader(context)}
9
19
 
10
20
  /**
11
21
  * Generate a random string
@@ -87,4 +97,8 @@ export function uniqueId(param?: string | number | undefined, size?: number | un
87
97
  return id;
88
98
  }, "");
89
99
  }
90
- `}export{t as nanoidModule};
100
+ `;
101
+ }
102
+
103
+ //#endregion
104
+ export { nanoidModule };
package/dist/index.cjs CHANGED
@@ -1 +1,44 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./components/nanoid.cjs`);require(`./components/index.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`defu`);r=e.__toESM(r);function i(e={}){return{name:`id`,async config(){this.log(n.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `id` build plugin.");let t={id:(0,r.default)(e,{type:`nanoid`})};return(!t.id.type||![`nanoid`].includes(t.id.type))&&(t.id.type&&this.log(n.LogLevelLabel.WARN,`Invalid ID generation type "${t.id.type}" specified. Defaulting to "nanoid".`),t.id.type=`nanoid`),this.log(n.LogLevelLabel.DEBUG,`Using ID generation library: ${t.id.type}`),t},async prepare(){this.log(n.LogLevelLabel.TRACE,`Preparing the ID runtime artifacts for the Powerlines project.`);let e;switch(this.config.id.type){case`nanoid`:default:e=t.nanoidModule;break}await this.emitBuiltin(await Promise.resolve(e(this)),`id`,`id.ts`)}}}var a=i;exports.default=a,exports.nanoidModule=t.nanoidModule,exports.plugin=i;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_components_nanoid = require('./components/nanoid.cjs');
4
+ require('./components/index.cjs');
5
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
6
+ let defu = require("defu");
7
+ defu = require_rolldown_runtime.__toESM(defu);
8
+
9
+ //#region src/index.ts
10
+ /**
11
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
12
+ */
13
+ function plugin(options = {}) {
14
+ return {
15
+ name: "id",
16
+ async config() {
17
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `id` build plugin.");
18
+ const config = { id: (0, defu.default)(options, { type: "nanoid" }) };
19
+ if (!config.id.type || !["nanoid"].includes(config.id.type)) {
20
+ if (config.id.type) this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Invalid ID generation type "${config.id.type}" specified. Defaulting to "nanoid".`);
21
+ config.id.type = "nanoid";
22
+ }
23
+ this.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Using ID generation library: ${config.id.type}`);
24
+ return config;
25
+ },
26
+ async prepare() {
27
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Preparing the ID runtime artifacts for the Powerlines project.`);
28
+ let idModule;
29
+ switch (this.config.id.type) {
30
+ case "nanoid":
31
+ default:
32
+ idModule = require_components_nanoid.nanoidModule;
33
+ break;
34
+ }
35
+ await this.emitBuiltin(await Promise.resolve(idModule(this)), "id", "id.ts");
36
+ }
37
+ };
38
+ }
39
+ var src_default = plugin;
40
+
41
+ //#endregion
42
+ exports.default = src_default;
43
+ exports.nanoidModule = require_components_nanoid.nanoidModule;
44
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,39 @@
1
- import{nanoidModule as e}from"./components/nanoid.mjs";import"./components/index.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import n from"defu";function r(r={}){return{name:`id`,async config(){this.log(t.TRACE,"Providing default configuration for the Powerlines `id` build plugin.");let e={id:n(r,{type:`nanoid`})};return(!e.id.type||![`nanoid`].includes(e.id.type))&&(e.id.type&&this.log(t.WARN,`Invalid ID generation type "${e.id.type}" specified. Defaulting to "nanoid".`),e.id.type=`nanoid`),this.log(t.DEBUG,`Using ID generation library: ${e.id.type}`),e},async prepare(){this.log(t.TRACE,`Preparing the ID runtime artifacts for the Powerlines project.`);let n;switch(this.config.id.type){case`nanoid`:default:n=e;break}await this.emitBuiltin(await Promise.resolve(n(this)),`id`,`id.ts`)}}}var i=r;export{i as default,e as nanoidModule,r as plugin};
1
+ import { nanoidModule } from "./components/nanoid.mjs";
2
+ import "./components/index.mjs";
3
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
4
+ import defu from "defu";
5
+
6
+ //#region src/index.ts
7
+ /**
8
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
9
+ */
10
+ function plugin(options = {}) {
11
+ return {
12
+ name: "id",
13
+ async config() {
14
+ this.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `id` build plugin.");
15
+ const config = { id: defu(options, { type: "nanoid" }) };
16
+ if (!config.id.type || !["nanoid"].includes(config.id.type)) {
17
+ if (config.id.type) this.log(LogLevelLabel.WARN, `Invalid ID generation type "${config.id.type}" specified. Defaulting to "nanoid".`);
18
+ config.id.type = "nanoid";
19
+ }
20
+ this.log(LogLevelLabel.DEBUG, `Using ID generation library: ${config.id.type}`);
21
+ return config;
22
+ },
23
+ async prepare() {
24
+ this.log(LogLevelLabel.TRACE, `Preparing the ID runtime artifacts for the Powerlines project.`);
25
+ let idModule;
26
+ switch (this.config.id.type) {
27
+ case "nanoid":
28
+ default:
29
+ idModule = nanoidModule;
30
+ break;
31
+ }
32
+ await this.emitBuiltin(await Promise.resolve(idModule(this)), "id", "id.ts");
33
+ }
34
+ };
35
+ }
36
+ var src_default = plugin;
37
+
38
+ //#endregion
39
+ export { src_default as default, nanoidModule, plugin };
@@ -1,10 +1,22 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/string-format/title-case`);function n(e){return`
2
- // Generated with ${(0,t.titleCase)(e.config.framework)}
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
3
+
4
+ //#region ../powerlines/src/lib/utilities/file-header.ts
5
+ function getBaseFileHeader(context) {
6
+ return `
7
+ // Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
3
8
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}function r(e,t={}){let{directive:r=null,prettierIgnore:i=!1}=t;return`/* eslint-disable */
9
+ `;
10
+ }
11
+ function getFileHeader(context, options = {}) {
12
+ const { directive = null, prettierIgnore = false } = options;
13
+ return `/* eslint-disable */
5
14
  // biome-ignore lint: disable
6
- ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
- `}
8
- ${n(e)}
15
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
16
+ ${getBaseFileHeader(context)}
17
+
18
+ `;
19
+ }
9
20
 
10
- `}exports.getFileHeader=r;
21
+ //#endregion
22
+ exports.getFileHeader = getFileHeader;
@@ -1,10 +1,21 @@
1
- import{titleCase as e}from"@stryke/string-format/title-case";function t(t){return`
2
- // Generated with ${e(t.config.framework)}
1
+ import { titleCase } from "@stryke/string-format/title-case";
2
+
3
+ //#region ../powerlines/src/lib/utilities/file-header.ts
4
+ function getBaseFileHeader(context) {
5
+ return `
6
+ // Generated with ${titleCase(context.config.framework)}
3
7
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}function n(e,n={}){let{directive:r=null,prettierIgnore:i=!1}=n;return`/* eslint-disable */
8
+ `;
9
+ }
10
+ function getFileHeader(context, options = {}) {
11
+ const { directive = null, prettierIgnore = false } = options;
12
+ return `/* eslint-disable */
5
13
  // biome-ignore lint: disable
6
- ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
- `}
8
- ${t(e)}
14
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
15
+ ${getBaseFileHeader(context)}
16
+
17
+ `;
18
+ }
9
19
 
10
- `}export{n as getFileHeader};
20
+ //#endregion
21
+ export { getFileHeader };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
304
328
  /**
305
329
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
306
330
  *
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
333
  * @param path - An optional path to write the builtin file to
310
334
  * @param options - Additional options for writing the builtin file
311
335
  */
312
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
313
337
  /**
314
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
315
339
  *
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
80
80
  */
81
81
  allowReturnOutsideFunction?: boolean;
82
82
  }
83
+ interface EmitOptions extends WriteOptions {
84
+ /**
85
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
86
+ */
87
+ emitWithBundler?: boolean;
88
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
89
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
90
+ }
83
91
  /**
84
92
  * Options for emitting entry virtual files
85
93
  */
86
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
94
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
87
95
  /**
88
96
  * The unresolved Powerlines context.
89
97
  *
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
294
302
  * The Powerlines builtin virtual files
295
303
  */
296
304
  getBuiltins: () => Promise<VirtualFile[]>;
305
+ /**
306
+ * Resolves a file and writes it to the VFS if it does not already exist
307
+ *
308
+ * @param code - The source code of the file
309
+ * @param path - The path to write the file to
310
+ * @param options - Additional options for writing the file
311
+ */
312
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
313
+ /**
314
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
315
+ *
316
+ * @param code - The source code of the file
317
+ * @param path - The path to write the file to
318
+ * @param options - Additional options for writing the file
319
+ */
320
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
297
321
  /**
298
322
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
299
323
  *
@@ -302,7 +326,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
302
326
  * @param path - An optional path to write the builtin file to
303
327
  * @param options - Additional options for writing the builtin file
304
328
  */
305
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
329
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
306
330
  /**
307
331
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
308
332
  *
@@ -311,7 +335,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
311
335
  * @param path - An optional path to write the builtin file to
312
336
  * @param options - Additional options for writing the builtin file
313
337
  */
314
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
338
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
315
339
  /**
316
340
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
317
341
  *
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-id",
3
- "version": "0.9.126",
3
+ "version": "0.9.128",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin that provides unique identifier generation capabilities at runtime by adding the `id` builtin module.",
6
6
  "repository": {
@@ -128,16 +128,16 @@
128
128
  "files": ["dist/**/*"],
129
129
  "keywords": ["powerlines", "storm-software", "powerlines-plugin"],
130
130
  "dependencies": {
131
- "@storm-software/config-tools": "^1.188.74",
132
- "@stryke/path": "^0.24.0",
131
+ "@storm-software/config-tools": "^1.188.75",
132
+ "@stryke/path": "^0.24.1",
133
133
  "defu": "^6.1.4",
134
- "powerlines": "^0.36.22"
134
+ "powerlines": "^0.36.24"
135
135
  },
136
136
  "devDependencies": {
137
- "@powerlines/nx": "^0.11.48",
138
- "@storm-software/tsup": "^0.2.72",
137
+ "@powerlines/nx": "^0.11.50",
138
+ "@storm-software/tsup": "^0.2.73",
139
139
  "@types/node": "^24.10.4"
140
140
  },
141
141
  "publishConfig": { "access": "public" },
142
- "gitHead": "f88fe8eb30f96536b83fc9af884972d48e31e63a"
142
+ "gitHead": "4b695d4b3476fd9dd79521f92258d52dab2b8d72"
143
143
  }