logisheets-core 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/dist/utils/uuid.js +12 -2
  2. package/package.json +2 -2
@@ -1,4 +1,14 @@
1
1
  export function simpleUuid() {
2
- return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^
3
- (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16));
2
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16));
3
+ }
4
+ // `crypto` isn't a typed global here (this package targets ES2020 with no DOM
5
+ // lib, and it must run on both the browser and Node). Reach it through
6
+ // `globalThis` when available (browsers, Node >= 19) and fall back to
7
+ // Math.random otherwise — these ids aren't security-sensitive.
8
+ function randomByte() {
9
+ const webcrypto = globalThis.crypto;
10
+ if (webcrypto?.getRandomValues) {
11
+ return webcrypto.getRandomValues(new Uint8Array(1))[0];
12
+ }
13
+ return Math.floor(Math.random() * 256);
4
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logisheets-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "UI-free LogiSheets logic — runs in the browser or on Node. Depends on logisheets-web only for types; the engine Client is injected by the host.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "author": "Jeremy He",
45
45
  "license": "MIT",
46
46
  "peerDependencies": {
47
- "logisheets-web": "^1.1.0"
47
+ "logisheets-web": "^1.3.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "logisheets-web": "workspace:*",