From cee7726652cb7abb7e9807fffa2df7e5777dbb40 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 27 Jul 2023 16:43:08 +0100 Subject: [PATCH] nanoid instead of cyrpto.randomUUID --- package-lock.json | 45 +++++++++++++++++++++++++++---- package.json | 1 + src/lib/commandCenter/commands.ts | 9 ++++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2c15647f..8276179cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "dotenv": "^16.0.3", "echarts": "^5.4.1", "logrocket": "^3.0.1", + "nanoid": "^4.0.2", "pretty-bytes": "^6.1.0", "prismjs": "^1.29.0", "tippy.js": "^6.3.7", @@ -2841,6 +2842,23 @@ } } }, + "node_modules/ai/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -6638,9 +6656,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", + "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", "funding": [ { "type": "github", @@ -6648,10 +6666,10 @@ } ], "bin": { - "nanoid": "bin/nanoid.cjs" + "nanoid": "bin/nanoid.js" }, "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + "node": "^14 || ^16 || >=18" } }, "node_modules/natural-compare": { @@ -7141,6 +7159,23 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/pre-commit": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/pre-commit/-/pre-commit-1.2.2.tgz", diff --git a/package.json b/package.json index 015a252d9..83f5967ca 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dotenv": "^16.0.3", "echarts": "^5.4.1", "logrocket": "^3.0.1", + "nanoid": "^4.0.2", "pretty-bytes": "^6.1.0", "prismjs": "^1.29.0", "tippy.js": "^6.3.7", diff --git a/src/lib/commandCenter/commands.ts b/src/lib/commandCenter/commands.ts index 5fd52af27..852fb81a5 100644 --- a/src/lib/commandCenter/commands.ts +++ b/src/lib/commandCenter/commands.ts @@ -2,6 +2,7 @@ import { debounce } from '$lib/helpers/debounce'; import { isMac } from '$lib/helpers/platform'; import { onMount } from 'svelte'; import { derived, writable } from 'svelte/store'; +import { nanoid } from 'nanoid/non-secure'; const groups = [ 'ungrouped', @@ -206,7 +207,7 @@ export const commandCenterKeyDownHandler = derived( // Methods export const registerCommands = { subscribe(runner: (cb: (newCommands: Command[]) => void) => void) { - const uuid = crypto.randomUUID(); + const uuid = nanoid(); runner((newCommands: Command[]) => { commandMap.update((curr) => { @@ -226,7 +227,7 @@ export const registerCommands = { export const disableCommands = { subscribe(runner: (cb: (disabled: boolean) => void) => void) { - const uuid = crypto.randomUUID(); + const uuid = nanoid(); runner((disabled: boolean) => { disabledMap.update((curr) => { @@ -251,7 +252,7 @@ const groupRanksMap = writable(new Map()); export const updateCommandGroupRanks = { subscribe(runner: (cb: (updater: CommandGroupRanks) => void) => void) { - const uuid = crypto.randomUUID(); + const uuid = nanoid(); runner((groupRank: CommandGroupRanks) => { groupRanksMap.update((curr) => { @@ -289,7 +290,7 @@ const searchersMap = writable>(new Map()); export const registerSearchers = { subscribe(runner: (cb: (...searchers: Searcher[]) => void) => void) { - const uuid = crypto.randomUUID(); + const uuid = nanoid(); runner((...searchers: Searcher[]) => { searchersMap.update((curr) => {