From 9dfbcae134ba093246ff0e3f9fa1592e59ba2d4c Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Fri, 8 Mar 2024 19:56:19 -0500 Subject: [PATCH] Hotfix: Replace calls to `crypto.randomUUID` (#82) `crypto.randomUUID` is only available in secure contexts (HTTPS), which throws an error when trying to run in certain situations/browsers. --- framework/src/lib/di/types.ts | 3 ++- image-generator-demo/src/app/app.element.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/lib/di/types.ts b/framework/src/lib/di/types.ts index 112076f..a882de9 100644 --- a/framework/src/lib/di/types.ts +++ b/framework/src/lib/di/types.ts @@ -1,5 +1,6 @@ import { type AbstractCtor, type Ctor, type Fn } from "@storyteller/utility"; import { type PropertyValues } from "lit"; +import { v4 as uuid } from "uuid"; export class UniqueToken { get id() { return this.#id; } @@ -10,7 +11,7 @@ export class UniqueToken { } static create(name?: string): Token { - return new UniqueToken(name ?? crypto.randomUUID()); + return new UniqueToken(name ?? uuid()); } toString(): string { diff --git a/image-generator-demo/src/app/app.element.ts b/image-generator-demo/src/app/app.element.ts index 853f6d6..3ea93a9 100644 --- a/image-generator-demo/src/app/app.element.ts +++ b/image-generator-demo/src/app/app.element.ts @@ -12,6 +12,7 @@ import { customElement, state } from "lit/decorators.js"; import { classMap } from "lit/directives/class-map.js"; import { createRef, ref } from "lit/directives/ref.js"; import { styleMap } from "lit/directives/style-map.js"; +import { v4 as uuid } from "uuid"; import { ImageInfo, LcmClient } from "./lcm-client"; @@ -38,7 +39,7 @@ export class AppElement extends LitElement { @state() inputUrl?: string; @state() outputUrl?: string; - #lcmClient = new LcmClient(crypto.randomUUID()); + #lcmClient = new LcmClient(uuid()); #outputImageRef = createRef(); constructor () {