@powerlines/plugin-id 0.9.510 → 0.9.512
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/components/nanoid.d.cts.map +1 -1
- package/dist/components/nanoid.d.mts.map +1 -1
- package/dist/components/nanoid.mjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nanoid.d.cts","names":[],"sources":["../../src/components/nanoid.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,
|
|
1
|
+
{"version":3,"file":"nanoid.d.cts","names":[],"sources":["../../src/components/nanoid.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAwB,EAAf,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nanoid.d.mts","names":[],"sources":["../../src/components/nanoid.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,
|
|
1
|
+
{"version":3,"file":"nanoid.d.mts","names":[],"sources":["../../src/components/nanoid.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAwB,EAAf,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nanoid.mjs","names":[],"sources":["../../src/components/nanoid.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 { getTypescriptFileHeader } from \"powerlines/utils\";\nimport { IdPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the nanoid module content.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the nanoid module code.\n */\nexport function nanoidModule(context: IdPluginContext) {\n return `\n/**\n * The ID module provides a set of utilities for generating unique identifiers.\n *\n * @module ${context.config.framework?.name || \"powerlines\"}:id\n */\n\n${getTypescriptFileHeader(context)}\n\n/**\n * Generate a random string\n *\n * @param array - The array to fill with random values\n * @returns The array filled with random values\n */\nexport function getRandom(array: Uint8Array) {\n if (array === null) {\n throw new StormError({ type: \"general\", code: 9 });\n }\n\n // Fill the array with random values\n for (let i = 0; i < array.length; i++) {\n array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)\n }\n\n return array;\n}\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(size?: number | undefined): string;\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param prefix - The prefix to use for the unique identifier\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(prefix?: string, size?: number | undefined): string;\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param param - The parameter to use for the unique identifier, can be a string or number\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(param?: string | number | undefined, size?: number | undefined): string {\n if (typeof param === \"number\") {\n size = param;\n } else if (!param || !size) {\n size = 21; // Default size if not provided\n }\n\n // Use our custom getRandom function to fill a Uint8Array with random values.\n const randomBytes = getRandom(new Uint8Array(typeof param === \"string\" ? size - (param.length + 1) : size));\n\n let result = \"\";\n if (typeof param === \"string\") {\n // If the parameter is a string, use it as a prefix.\n result = param + \"_\";\n }\n\n return result + randomBytes.reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unnecessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63;\n if (byte < 36) {\n // \\`0-9a-z\\`\n id += byte.toString(36);\n } else if (byte < 62) {\n // \\`A-Z\\`\n id += (byte - 26).toString(36).toUpperCase();\n } else if (byte > 62) {\n id += \"-\";\n } else {\n id += \"_\";\n }\n return id;\n }, \"\");\n}\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA0B;
|
|
1
|
+
{"version":3,"file":"nanoid.mjs","names":[],"sources":["../../src/components/nanoid.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 { getTypescriptFileHeader } from \"powerlines/utils\";\nimport { IdPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the nanoid module content.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the nanoid module code.\n */\nexport function nanoidModule(context: IdPluginContext) {\n return `\n/**\n * The ID module provides a set of utilities for generating unique identifiers.\n *\n * @module ${context.config.framework?.name || \"powerlines\"}:id\n */\n\n${getTypescriptFileHeader(context)}\n\n/**\n * Generate a random string\n *\n * @param array - The array to fill with random values\n * @returns The array filled with random values\n */\nexport function getRandom(array: Uint8Array) {\n if (array === null) {\n throw new StormError({ type: \"general\", code: 9 });\n }\n\n // Fill the array with random values\n for (let i = 0; i < array.length; i++) {\n array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)\n }\n\n return array;\n}\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(size?: number | undefined): string;\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param prefix - The prefix to use for the unique identifier\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(prefix?: string, size?: number | undefined): string;\n\n/**\n * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param param - The parameter to use for the unique identifier, can be a string or number\n * @param size - The size of the string to generate. Defaults to 21 if not provided.\n * @returns A unique identifier following the nanoid format\n */\nexport function uniqueId(param?: string | number | undefined, size?: number | undefined): string {\n if (typeof param === \"number\") {\n size = param;\n } else if (!param || !size) {\n size = 21; // Default size if not provided\n }\n\n // Use our custom getRandom function to fill a Uint8Array with random values.\n const randomBytes = getRandom(new Uint8Array(typeof param === \"string\" ? size - (param.length + 1) : size));\n\n let result = \"\";\n if (typeof param === \"string\") {\n // If the parameter is a string, use it as a prefix.\n result = param + \"_\";\n }\n\n return result + randomBytes.reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unnecessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63;\n if (byte < 36) {\n // \\`0-9a-z\\`\n id += byte.toString(36);\n } else if (byte < 62) {\n // \\`A-Z\\`\n id += (byte - 26).toString(36).toUpperCase();\n } else if (byte > 62) {\n id += \"-\";\n } else {\n id += \"_\";\n }\n return id;\n }, \"\");\n}\n`;\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA0B;CACrD,OAAO;;;;aAII,QAAQ,OAAO,WAAW,QAAQ,aAAa;;;EAG1D,wBAAwB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFnC"}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA+BY,MAAA;IACR,EAAA,GAAK,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA+BY,MAAA;IACR,EAAA,GAAK,eAAe;EAAA;AAAA;;;;iBAOR,MAAA,CAAO,OAAA,GAAS,eAAA,GAAuB,MAAA,CAAO,eAAA"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA+BY,MAAA;IACR,EAAA,GAAK,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA+BY,MAAA;IACR,EAAA,GAAK,eAAe;EAAA;AAAA;;;;iBAOR,MAAA,CAAO,OAAA,GAAS,eAAA,GAAuB,MAAA,CAAO,eAAA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { nanoidModule } from \"./components/nanoid\";\nimport {\n IdPluginContext,\n IdPluginOptions,\n IdPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n id?: IdPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin(options: IdPluginOptions = {}): Plugin<IdPluginContext> {\n return {\n name: \"id\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `id` build plugin.\"\n );\n\n const config = {\n id: defu(options, {\n type: \"nanoid\"\n })\n } as Partial<IdPluginUserConfig>;\n\n if (!config.id!.type || ![\"nanoid\"].includes(config.id!.type)) {\n if (config.id!.type) {\n this.warn(\n `Invalid ID generation type \"${config.id!.type}\" specified. Defaulting to \"nanoid\".`\n );\n }\n\n config.id!.type = \"nanoid\";\n }\n\n this.debug(`Using ID generation library: ${config.id!.type}`);\n\n return config;\n },\n async prepare() {\n this.debug(\n \"Preparing the ID runtime artifacts for the Powerlines project.\"\n );\n\n let idModule!: (context: IdPluginContext) => string;\n switch (this.config.id.type) {\n case \"nanoid\":\n default:\n // Default to nanoid if no type is specified or if the type is not recognized\n idModule = nanoidModule;\n break;\n }\n\n await this.emitBuiltin(await Promise.resolve(idModule(this)), \"id\");\n }\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;AAuCA,SAAgB,OAAO,UAA2B,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { nanoidModule } from \"./components/nanoid\";\nimport {\n IdPluginContext,\n IdPluginOptions,\n IdPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n id?: IdPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin(options: IdPluginOptions = {}): Plugin<IdPluginContext> {\n return {\n name: \"id\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `id` build plugin.\"\n );\n\n const config = {\n id: defu(options, {\n type: \"nanoid\"\n })\n } as Partial<IdPluginUserConfig>;\n\n if (!config.id!.type || ![\"nanoid\"].includes(config.id!.type)) {\n if (config.id!.type) {\n this.warn(\n `Invalid ID generation type \"${config.id!.type}\" specified. Defaulting to \"nanoid\".`\n );\n }\n\n config.id!.type = \"nanoid\";\n }\n\n this.debug(`Using ID generation library: ${config.id!.type}`);\n\n return config;\n },\n async prepare() {\n this.debug(\n \"Preparing the ID runtime artifacts for the Powerlines project.\"\n );\n\n let idModule!: (context: IdPluginContext) => string;\n switch (this.config.id.type) {\n case \"nanoid\":\n default:\n // Default to nanoid if no type is specified or if the type is not recognized\n idModule = nanoidModule;\n break;\n }\n\n await this.emitBuiltin(await Promise.resolve(idModule(this)), \"id\");\n }\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;AAuCA,SAAgB,OAAO,UAA2B,CAAC,GAA4B;CAC7E,OAAO;EACL,MAAM;EACN,MAAM,SAAS;GACb,KAAK,MACH,uEACF;GAEA,MAAM,SAAS,EACb,IAAI,KAAK,SAAS,EAChB,MAAM,SACR,CAAC,EACH;GAEA,IAAI,CAAC,OAAO,GAAI,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,OAAO,GAAI,IAAI,GAAG;IAC7D,IAAI,OAAO,GAAI,MACb,KAAK,KACH,+BAA+B,OAAO,GAAI,KAAK,qCACjD;IAGF,OAAO,GAAI,OAAO;GACpB;GAEA,KAAK,MAAM,gCAAgC,OAAO,GAAI,MAAM;GAE5D,OAAO;EACT;EACA,MAAM,UAAU;GACd,KAAK,MACH,gEACF;GAEA,IAAI;GACJ,QAAQ,KAAK,OAAO,GAAG,MAAvB;IAEE;KAEE,WAAW;KACX;GACJ;GAEA,MAAM,KAAK,YAAY,MAAM,QAAQ,QAAQ,SAAS,IAAI,CAAC,GAAG,IAAI;EACpE;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAoBY,kBAAA;AAAA,UAEK,eAAA;EAFL
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAoBY,kBAAA;AAAA,UAEK,eAAA;EAFL;;;;AAAkB;AAE9B;;;;EAUE,IAAA,GAAO,kBAAkB;AAAA;AAAA,UAGV,kBAAA,SAA2B,UAAU;;;;EAIpD,EAAA,GAAK,eAAA;AAAA;AAAA,UAGU,sBAAA,SAA+B,cAAA;EAH1B;AAGtB;;EAIE,EAAA,EAAI,QAAA,CAAS,eAAA;AAAA;AAAA,KAGH,eAAA,yBACc,sBAAA,GAAyB,sBAAA,IAC/C,aAAA,CAAc,eAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAoBY,kBAAA;AAAA,UAEK,eAAA;EAFL
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAoBY,kBAAA;AAAA,UAEK,eAAA;EAFL;;;;AAAkB;AAE9B;;;;EAUE,IAAA,GAAO,kBAAkB;AAAA;AAAA,UAGV,kBAAA,SAA2B,UAAU;;;;EAIpD,EAAA,GAAK,eAAA;AAAA;AAAA,UAGU,sBAAA,SAA+B,cAAA;EAH1B;AAGtB;;EAIE,EAAA,EAAI,QAAA,CAAS,eAAA;AAAA;AAAA,KAGH,eAAA,yBACc,sBAAA,GAAyB,sBAAA,IAC/C,aAAA,CAAc,eAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-id",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.512",
|
|
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": {
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"@storm-software/config-tools": "^1.190.20",
|
|
65
65
|
"@stryke/path": "^0.29.3",
|
|
66
66
|
"defu": "^6.1.7",
|
|
67
|
-
"powerlines": "^0.47.
|
|
67
|
+
"powerlines": "^0.47.42"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
71
|
-
"@types/node": "^25.
|
|
70
|
+
"@powerlines/plugin-plugin": "^0.12.454",
|
|
71
|
+
"@types/node": "^25.9.0"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": { "access": "public" },
|
|
74
74
|
"main": "./dist/index.cjs",
|
|
75
75
|
"module": "./dist/index.mjs",
|
|
76
76
|
"types": "./dist/index.d.cts",
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "2dbbdb2f6fde8f0f49208757c7c1b18deb96ff97"
|
|
78
78
|
}
|