@instructure/uid 11.7.8 → 11.7.9-pr-snapshot-1792147648392
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/CHANGELOG.md +13 -0
- package/es/index.js +1 -24
- package/es/uid.js +18 -67
- package/package.json +5 -8
- package/tsconfig.build.json +1 -5
- package/lib/index.js +0 -37
- package/lib/package.json +0 -1
- package/lib/uid.js +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
|
|
7
|
+
|
|
8
|
+
### Build System
|
|
9
|
+
|
|
10
|
+
* **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* **many:** `@instructure/ui-babel-preset` and
|
|
15
|
+
`@instructure/browserslist-config-instui` are removed and will no longer be
|
|
16
|
+
published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @instructure/uid
|
package/es/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
1
|
import { uid } from './uid.js';
|
|
25
2
|
export default uid;
|
|
26
|
-
export { uid };
|
|
3
|
+
export { uid };
|
package/es/uid.js
CHANGED
|
@@ -1,76 +1,27 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
// based on: https://github.com/ai/nanoid/blob/main/non-secure/index.js
|
|
26
|
-
|
|
27
1
|
const dictionary = 'getRandomVcryp0123456789bfhijklqsuvwxzABCDEFGHIJKLMNOPQSTUWXYZ';
|
|
28
2
|
const dictionaryLengthMinus1 = dictionary.length - 1;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* ---
|
|
32
|
-
* category: utilities/Misc
|
|
33
|
-
* ---
|
|
34
|
-
* Generate a unique (CSS-safe) id string
|
|
35
|
-
*
|
|
36
|
-
* NOTE: this is `Math.random()`-based, so it is **not** SSR-safe and must not be
|
|
37
|
-
* called during render — the server and the client produce different values,
|
|
38
|
-
* which React reports as a hydration mismatch, and the id changes on every
|
|
39
|
-
* re-render. For ids that end up in the DOM, use `useDeterministicId` or the
|
|
40
|
-
* `withDeterministicId` decorator from `@instructure/ui-react-utils`. Reach for
|
|
41
|
-
* `uid` only for client-side, non-rendered identifiers (e.g. keying an entry in
|
|
42
|
-
* a runtime registry).
|
|
43
|
-
*
|
|
44
|
-
* @module uid
|
|
45
|
-
* @param {String} prefix a string to prefix the id for debugging in non-production env
|
|
46
|
-
* @param {Number} length id length (in characters, minus the prefix). Default is 12
|
|
47
|
-
* @returns {String} a unique id
|
|
48
|
-
*/
|
|
49
3
|
function uid(prefix = '', length = 12) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
const id = `u${_uid(length - 1)}`;
|
|
5
|
+
if (prefix && typeof process !== 'undefined' && process?.env?.NODE_ENV !== 'production') {
|
|
6
|
+
return `${prefix}__${id}`;
|
|
7
|
+
} else {
|
|
8
|
+
return id;
|
|
9
|
+
}
|
|
56
10
|
}
|
|
57
11
|
function _random(size) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
result
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
12
|
+
const result = [];
|
|
13
|
+
while(0 < size--){
|
|
14
|
+
result.push(Math.random() * 256 | 0);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
65
17
|
}
|
|
66
18
|
function _uid(idLength) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return id;
|
|
19
|
+
let id = '';
|
|
20
|
+
const bytes = _random(idLength);
|
|
21
|
+
while(0 < idLength--){
|
|
22
|
+
id += dictionary[bytes[idLength] & dictionaryLengthMinus1];
|
|
23
|
+
}
|
|
24
|
+
return id;
|
|
74
25
|
}
|
|
75
26
|
export default uid;
|
|
76
|
-
export { uid };
|
|
27
|
+
export { uid };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/uid",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.9-pr-snapshot-1792147648392",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A unique (CSS-safe) id generator made by Instructure Inc.",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
"bugs": "https://github.com/instructure/instructure-ui/issues",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@swc/helpers": "^0.5.23"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"vitest": "^5.0.0"
|
|
21
|
-
"@instructure/ui-babel-preset": "11.7.8"
|
|
20
|
+
"vitest": "^5.0.0"
|
|
22
21
|
},
|
|
23
22
|
"publishConfig": {
|
|
24
23
|
"access": "public"
|
|
@@ -29,10 +28,8 @@
|
|
|
29
28
|
"src": "./src/index.ts",
|
|
30
29
|
"types": "./types/index.d.ts",
|
|
31
30
|
"import": "./es/index.js",
|
|
32
|
-
"require": "./lib/index.js",
|
|
33
31
|
"default": "./es/index.js"
|
|
34
32
|
},
|
|
35
|
-
"./lib/*": "./lib/*",
|
|
36
33
|
"./es/*": "./es/*",
|
|
37
34
|
"./types/*": "./types/*",
|
|
38
35
|
"./package.json": "./package.json",
|
|
@@ -42,7 +39,7 @@
|
|
|
42
39
|
"lint": "ui-scripts lint",
|
|
43
40
|
"lint:fix": "ui-scripts lint --fix",
|
|
44
41
|
"clean": "ui-scripts clean",
|
|
45
|
-
"build": "ui-scripts build
|
|
42
|
+
"build": "ui-scripts build",
|
|
46
43
|
"build:watch": "ui-scripts build --watch",
|
|
47
44
|
"build:types": "tsc -p tsconfig.build.json"
|
|
48
45
|
}
|
package/tsconfig.build.json
CHANGED
package/lib/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
Object.defineProperty(exports, "uid", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _uid.uid;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _uid = require("./uid.js");
|
|
14
|
-
/*
|
|
15
|
-
* The MIT License (MIT)
|
|
16
|
-
*
|
|
17
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
18
|
-
*
|
|
19
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
21
|
-
* in the Software without restriction, including without limitation the rights
|
|
22
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
24
|
-
* furnished to do so, subject to the following conditions:
|
|
25
|
-
*
|
|
26
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
27
|
-
* copies or substantial portions of the Software.
|
|
28
|
-
*
|
|
29
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
-
* SOFTWARE.
|
|
36
|
-
*/
|
|
37
|
-
var _default = exports.default = _uid.uid;
|
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
package/lib/uid.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.uid = uid;
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
// based on: https://github.com/ai/nanoid/blob/main/non-secure/index.js
|
|
33
|
-
|
|
34
|
-
const dictionary = 'getRandomVcryp0123456789bfhijklqsuvwxzABCDEFGHIJKLMNOPQSTUWXYZ';
|
|
35
|
-
const dictionaryLengthMinus1 = dictionary.length - 1;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* ---
|
|
39
|
-
* category: utilities/Misc
|
|
40
|
-
* ---
|
|
41
|
-
* Generate a unique (CSS-safe) id string
|
|
42
|
-
*
|
|
43
|
-
* NOTE: this is `Math.random()`-based, so it is **not** SSR-safe and must not be
|
|
44
|
-
* called during render — the server and the client produce different values,
|
|
45
|
-
* which React reports as a hydration mismatch, and the id changes on every
|
|
46
|
-
* re-render. For ids that end up in the DOM, use `useDeterministicId` or the
|
|
47
|
-
* `withDeterministicId` decorator from `@instructure/ui-react-utils`. Reach for
|
|
48
|
-
* `uid` only for client-side, non-rendered identifiers (e.g. keying an entry in
|
|
49
|
-
* a runtime registry).
|
|
50
|
-
*
|
|
51
|
-
* @module uid
|
|
52
|
-
* @param {String} prefix a string to prefix the id for debugging in non-production env
|
|
53
|
-
* @param {Number} length id length (in characters, minus the prefix). Default is 12
|
|
54
|
-
* @returns {String} a unique id
|
|
55
|
-
*/
|
|
56
|
-
function uid(prefix = '', length = 12) {
|
|
57
|
-
const id = `u${_uid(length - 1)}`;
|
|
58
|
-
if (prefix && typeof process !== 'undefined' && process?.env?.NODE_ENV !== 'production') {
|
|
59
|
-
return `${prefix}__${id}`;
|
|
60
|
-
} else {
|
|
61
|
-
return id;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function _random(size) {
|
|
65
|
-
const result = [];
|
|
66
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
67
|
-
while (0 < size--) {
|
|
68
|
-
// `| 0` is faster than `Math.floor()`.
|
|
69
|
-
result.push(Math.random() * 256 | 0);
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
function _uid(idLength) {
|
|
74
|
-
let id = '';
|
|
75
|
-
const bytes = _random(idLength);
|
|
76
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
77
|
-
while (0 < idLength--) {
|
|
78
|
-
id += dictionary[bytes[idLength] & dictionaryLengthMinus1];
|
|
79
|
-
}
|
|
80
|
-
return id;
|
|
81
|
-
}
|
|
82
|
-
var _default = exports.default = uid;
|