@powerlines/plugin-id 0.2.0 → 0.4.0
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/package.json +6 -6
- package/dist/components/index.cjs +0 -1
- package/dist/components/index.d.cts +0 -22
- package/dist/components/index.d.ts +0 -22
- package/dist/components/index.js +0 -1
- package/dist/components/nanoid.cjs +0 -96
- package/dist/components/nanoid.d.cts +0 -31
- package/dist/components/nanoid.d.ts +0 -31
- package/dist/components/nanoid.js +0 -96
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.cts +0 -21
- package/dist/types/index.d.ts +0 -21
- package/dist/types/index.js +0 -1
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +0 -2840
- package/dist/types/plugin.d.ts +0 -2840
- package/dist/types/plugin.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-id",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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": {
|
|
@@ -117,15 +117,15 @@
|
|
|
117
117
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@storm-software/config-tools": "^1.188.6",
|
|
120
|
-
"@stryke/path": "^0.
|
|
120
|
+
"@stryke/path": "^0.16.0",
|
|
121
121
|
"defu": "^6.1.4",
|
|
122
|
-
"powerlines": "^0.
|
|
122
|
+
"powerlines": "^0.5.0"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
|
-
"@powerlines/nx": "^0.
|
|
125
|
+
"@powerlines/nx": "^0.5.0",
|
|
126
126
|
"@storm-software/tsup": "^0.2.4",
|
|
127
|
-
"@types/node": "^22.18.
|
|
127
|
+
"@types/node": "^22.18.12"
|
|
128
128
|
},
|
|
129
129
|
"publishConfig": { "access": "public" },
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "8ec5ff52ffc87cfbf2807e077209ea5745a95d43"
|
|
131
131
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var nanoid=require('./nanoid');Object.keys(nanoid).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return nanoid[k]}})});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { nanoidModule } from './nanoid.cjs';
|
|
2
|
-
import '../types/plugin.cjs';
|
|
3
|
-
import '@storm-software/build-tools/types';
|
|
4
|
-
import '@storm-software/config-tools/types';
|
|
5
|
-
import '@storm-software/config/types';
|
|
6
|
-
import '@stryke/types/configuration';
|
|
7
|
-
import '@stryke/types/file';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import '@stryke/env/get-env-paths';
|
|
10
|
-
import '@stryke/types/package-json';
|
|
11
|
-
import 'jiti';
|
|
12
|
-
import '@deepkit/type';
|
|
13
|
-
import 'semver';
|
|
14
|
-
import 'unplugin';
|
|
15
|
-
import '@stryke/capnp';
|
|
16
|
-
import '@stryke/types/base';
|
|
17
|
-
import '@stryke/types/tsconfig';
|
|
18
|
-
import 'typescript';
|
|
19
|
-
import 'memfs';
|
|
20
|
-
import 'node:fs';
|
|
21
|
-
import 'unionfs';
|
|
22
|
-
import '@stryke/types/array';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { nanoidModule } from './nanoid.js';
|
|
2
|
-
import '../types/plugin.js';
|
|
3
|
-
import '@storm-software/build-tools/types';
|
|
4
|
-
import '@storm-software/config-tools/types';
|
|
5
|
-
import '@storm-software/config/types';
|
|
6
|
-
import '@stryke/types/configuration';
|
|
7
|
-
import '@stryke/types/file';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import '@stryke/env/get-env-paths';
|
|
10
|
-
import '@stryke/types/package-json';
|
|
11
|
-
import 'jiti';
|
|
12
|
-
import '@deepkit/type';
|
|
13
|
-
import 'semver';
|
|
14
|
-
import 'unplugin';
|
|
15
|
-
import '@stryke/capnp';
|
|
16
|
-
import '@stryke/types/base';
|
|
17
|
-
import '@stryke/types/tsconfig';
|
|
18
|
-
import 'typescript';
|
|
19
|
-
import 'memfs';
|
|
20
|
-
import 'node:fs';
|
|
21
|
-
import 'unionfs';
|
|
22
|
-
import '@stryke/types/array';
|
package/dist/components/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from'./nanoid';
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';var fileHeader=require('powerlines/lib/utilities/file-header');/*****************************************
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
var r=Object.defineProperty;var i=(e,t)=>r(e,"name",{value:t,configurable:true});function f(e){return `
|
|
8
|
-
/**
|
|
9
|
-
* The ID module provides a set of utilities for generating unique identifiers.
|
|
10
|
-
*
|
|
11
|
-
* @module ${e.config.output.builtinPrefix}:id
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
${fileHeader.getFileHeader(e)}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate a random string
|
|
18
|
-
*
|
|
19
|
-
* @param array - The array to fill with random values
|
|
20
|
-
* @returns The array filled with random values
|
|
21
|
-
*/
|
|
22
|
-
export function getRandom(array: Uint8Array) {
|
|
23
|
-
if (array === null) {
|
|
24
|
-
throw new StormError({ type: "general", code: 9 });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Fill the array with random values
|
|
28
|
-
for (let i = 0; i < array.length; i++) {
|
|
29
|
-
array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return array;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
37
|
-
*
|
|
38
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
39
|
-
* @returns A unique identifier following the nanoid format
|
|
40
|
-
*/
|
|
41
|
-
export function uniqueId(size?: number | undefined): string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
45
|
-
*
|
|
46
|
-
* @param prefix - The prefix to use for the unique identifier
|
|
47
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
48
|
-
* @returns A unique identifier following the nanoid format
|
|
49
|
-
*/
|
|
50
|
-
export function uniqueId(prefix?: string, size?: number | undefined): string;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
54
|
-
*
|
|
55
|
-
* @param param - The parameter to use for the unique identifier, can be a string or number
|
|
56
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
57
|
-
* @returns A unique identifier following the nanoid format
|
|
58
|
-
*/
|
|
59
|
-
export function uniqueId(param?: string | number | undefined, size?: number | undefined): string {
|
|
60
|
-
if (typeof param === "number") {
|
|
61
|
-
size = param;
|
|
62
|
-
} else if (!param || !size) {
|
|
63
|
-
size = 21; // Default size if not provided
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Use our custom getRandom function to fill a Uint8Array with random values.
|
|
67
|
-
const randomBytes = getRandom(new Uint8Array(typeof param === "string" ? size - (param.length + 1) : size));
|
|
68
|
-
|
|
69
|
-
let result = "";
|
|
70
|
-
if (typeof param === "string") {
|
|
71
|
-
// If the parameter is a string, use it as a prefix.
|
|
72
|
-
result = param + "_";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return result + randomBytes.reduce((id, byte) => {
|
|
76
|
-
// It is incorrect to use bytes exceeding the alphabet size.
|
|
77
|
-
// The following mask reduces the random byte in the 0-255 value
|
|
78
|
-
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
79
|
-
// as empty string fallback or magic numbers, is unnecessary because
|
|
80
|
-
// the bitmask trims bytes down to the alphabet size.
|
|
81
|
-
byte &= 63;
|
|
82
|
-
if (byte < 36) {
|
|
83
|
-
// \`0-9a-z\`
|
|
84
|
-
id += byte.toString(36);
|
|
85
|
-
} else if (byte < 62) {
|
|
86
|
-
// \`A-Z\`
|
|
87
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
88
|
-
} else if (byte > 62) {
|
|
89
|
-
id += "-";
|
|
90
|
-
} else {
|
|
91
|
-
id += "_";
|
|
92
|
-
}
|
|
93
|
-
return id;
|
|
94
|
-
}, "");
|
|
95
|
-
}
|
|
96
|
-
`}i(f,"nanoidModule");exports.nanoidModule=f;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { IdPluginContext } from '../types/plugin.cjs';
|
|
2
|
-
import '@storm-software/build-tools/types';
|
|
3
|
-
import '@storm-software/config-tools/types';
|
|
4
|
-
import '@storm-software/config/types';
|
|
5
|
-
import '@stryke/types/configuration';
|
|
6
|
-
import '@stryke/types/file';
|
|
7
|
-
import 'vite';
|
|
8
|
-
import '@stryke/env/get-env-paths';
|
|
9
|
-
import '@stryke/types/package-json';
|
|
10
|
-
import 'jiti';
|
|
11
|
-
import '@deepkit/type';
|
|
12
|
-
import 'semver';
|
|
13
|
-
import 'unplugin';
|
|
14
|
-
import '@stryke/capnp';
|
|
15
|
-
import '@stryke/types/base';
|
|
16
|
-
import '@stryke/types/tsconfig';
|
|
17
|
-
import 'typescript';
|
|
18
|
-
import 'memfs';
|
|
19
|
-
import 'node:fs';
|
|
20
|
-
import 'unionfs';
|
|
21
|
-
import '@stryke/types/array';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Generates the nanoid module content.
|
|
25
|
-
*
|
|
26
|
-
* @param context - The build context containing runtime information.
|
|
27
|
-
* @returns A string representing the nanoid module code.
|
|
28
|
-
*/
|
|
29
|
-
declare function nanoidModule(context: IdPluginContext): string;
|
|
30
|
-
|
|
31
|
-
export { nanoidModule };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { IdPluginContext } from '../types/plugin.js';
|
|
2
|
-
import '@storm-software/build-tools/types';
|
|
3
|
-
import '@storm-software/config-tools/types';
|
|
4
|
-
import '@storm-software/config/types';
|
|
5
|
-
import '@stryke/types/configuration';
|
|
6
|
-
import '@stryke/types/file';
|
|
7
|
-
import 'vite';
|
|
8
|
-
import '@stryke/env/get-env-paths';
|
|
9
|
-
import '@stryke/types/package-json';
|
|
10
|
-
import 'jiti';
|
|
11
|
-
import '@deepkit/type';
|
|
12
|
-
import 'semver';
|
|
13
|
-
import 'unplugin';
|
|
14
|
-
import '@stryke/capnp';
|
|
15
|
-
import '@stryke/types/base';
|
|
16
|
-
import '@stryke/types/tsconfig';
|
|
17
|
-
import 'typescript';
|
|
18
|
-
import 'memfs';
|
|
19
|
-
import 'node:fs';
|
|
20
|
-
import 'unionfs';
|
|
21
|
-
import '@stryke/types/array';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Generates the nanoid module content.
|
|
25
|
-
*
|
|
26
|
-
* @param context - The build context containing runtime information.
|
|
27
|
-
* @returns A string representing the nanoid module code.
|
|
28
|
-
*/
|
|
29
|
-
declare function nanoidModule(context: IdPluginContext): string;
|
|
30
|
-
|
|
31
|
-
export { nanoidModule };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import {getFileHeader}from'powerlines/lib/utilities/file-header';/*****************************************
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
var r=Object.defineProperty;var i=(e,t)=>r(e,"name",{value:t,configurable:true});function m(e){return `
|
|
8
|
-
/**
|
|
9
|
-
* The ID module provides a set of utilities for generating unique identifiers.
|
|
10
|
-
*
|
|
11
|
-
* @module ${e.config.output.builtinPrefix}:id
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
${getFileHeader(e)}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate a random string
|
|
18
|
-
*
|
|
19
|
-
* @param array - The array to fill with random values
|
|
20
|
-
* @returns The array filled with random values
|
|
21
|
-
*/
|
|
22
|
-
export function getRandom(array: Uint8Array) {
|
|
23
|
-
if (array === null) {
|
|
24
|
-
throw new StormError({ type: "general", code: 9 });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Fill the array with random values
|
|
28
|
-
for (let i = 0; i < array.length; i++) {
|
|
29
|
-
array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return array;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
37
|
-
*
|
|
38
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
39
|
-
* @returns A unique identifier following the nanoid format
|
|
40
|
-
*/
|
|
41
|
-
export function uniqueId(size?: number | undefined): string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
45
|
-
*
|
|
46
|
-
* @param prefix - The prefix to use for the unique identifier
|
|
47
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
48
|
-
* @returns A unique identifier following the nanoid format
|
|
49
|
-
*/
|
|
50
|
-
export function uniqueId(prefix?: string, size?: number | undefined): string;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
|
|
54
|
-
*
|
|
55
|
-
* @param param - The parameter to use for the unique identifier, can be a string or number
|
|
56
|
-
* @param size - The size of the string to generate. Defaults to 21 if not provided.
|
|
57
|
-
* @returns A unique identifier following the nanoid format
|
|
58
|
-
*/
|
|
59
|
-
export function uniqueId(param?: string | number | undefined, size?: number | undefined): string {
|
|
60
|
-
if (typeof param === "number") {
|
|
61
|
-
size = param;
|
|
62
|
-
} else if (!param || !size) {
|
|
63
|
-
size = 21; // Default size if not provided
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Use our custom getRandom function to fill a Uint8Array with random values.
|
|
67
|
-
const randomBytes = getRandom(new Uint8Array(typeof param === "string" ? size - (param.length + 1) : size));
|
|
68
|
-
|
|
69
|
-
let result = "";
|
|
70
|
-
if (typeof param === "string") {
|
|
71
|
-
// If the parameter is a string, use it as a prefix.
|
|
72
|
-
result = param + "_";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return result + randomBytes.reduce((id, byte) => {
|
|
76
|
-
// It is incorrect to use bytes exceeding the alphabet size.
|
|
77
|
-
// The following mask reduces the random byte in the 0-255 value
|
|
78
|
-
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
79
|
-
// as empty string fallback or magic numbers, is unnecessary because
|
|
80
|
-
// the bitmask trims bytes down to the alphabet size.
|
|
81
|
-
byte &= 63;
|
|
82
|
-
if (byte < 36) {
|
|
83
|
-
// \`0-9a-z\`
|
|
84
|
-
id += byte.toString(36);
|
|
85
|
-
} else if (byte < 62) {
|
|
86
|
-
// \`A-Z\`
|
|
87
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
88
|
-
} else if (byte > 62) {
|
|
89
|
-
id += "-";
|
|
90
|
-
} else {
|
|
91
|
-
id += "_";
|
|
92
|
-
}
|
|
93
|
-
return id;
|
|
94
|
-
}, "");
|
|
95
|
-
}
|
|
96
|
-
`}i(m,"nanoidModule");export{m as nanoidModule};
|
package/dist/types/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var plugin=require('./plugin');Object.keys(plugin).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return plugin[k]}})});
|
package/dist/types/index.d.cts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { IdPluginContext, IdPluginOptions, IdPluginResolvedConfig, IdPluginUserConfig, UniqueIdFormatType, __ΩIdPluginContext, __ΩIdPluginOptions, __ΩIdPluginResolvedConfig, __ΩIdPluginUserConfig, __ΩUniqueIdFormatType } from './plugin.cjs';
|
|
2
|
-
import '@storm-software/build-tools/types';
|
|
3
|
-
import '@storm-software/config-tools/types';
|
|
4
|
-
import '@storm-software/config/types';
|
|
5
|
-
import '@stryke/types/configuration';
|
|
6
|
-
import '@stryke/types/file';
|
|
7
|
-
import 'vite';
|
|
8
|
-
import '@stryke/env/get-env-paths';
|
|
9
|
-
import '@stryke/types/package-json';
|
|
10
|
-
import 'jiti';
|
|
11
|
-
import '@deepkit/type';
|
|
12
|
-
import 'semver';
|
|
13
|
-
import 'unplugin';
|
|
14
|
-
import '@stryke/capnp';
|
|
15
|
-
import '@stryke/types/base';
|
|
16
|
-
import '@stryke/types/tsconfig';
|
|
17
|
-
import 'typescript';
|
|
18
|
-
import 'memfs';
|
|
19
|
-
import 'node:fs';
|
|
20
|
-
import 'unionfs';
|
|
21
|
-
import '@stryke/types/array';
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { IdPluginContext, IdPluginOptions, IdPluginResolvedConfig, IdPluginUserConfig, UniqueIdFormatType, __ΩIdPluginContext, __ΩIdPluginOptions, __ΩIdPluginResolvedConfig, __ΩIdPluginUserConfig, __ΩUniqueIdFormatType } from './plugin.js';
|
|
2
|
-
import '@storm-software/build-tools/types';
|
|
3
|
-
import '@storm-software/config-tools/types';
|
|
4
|
-
import '@storm-software/config/types';
|
|
5
|
-
import '@stryke/types/configuration';
|
|
6
|
-
import '@stryke/types/file';
|
|
7
|
-
import 'vite';
|
|
8
|
-
import '@stryke/env/get-env-paths';
|
|
9
|
-
import '@stryke/types/package-json';
|
|
10
|
-
import 'jiti';
|
|
11
|
-
import '@deepkit/type';
|
|
12
|
-
import 'semver';
|
|
13
|
-
import 'unplugin';
|
|
14
|
-
import '@stryke/capnp';
|
|
15
|
-
import '@stryke/types/base';
|
|
16
|
-
import '@stryke/types/tsconfig';
|
|
17
|
-
import 'typescript';
|
|
18
|
-
import 'memfs';
|
|
19
|
-
import 'node:fs';
|
|
20
|
-
import 'unionfs';
|
|
21
|
-
import '@stryke/types/array';
|
package/dist/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from'./plugin';
|
package/dist/types/plugin.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';
|