mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-26 08:38:10 +00:00
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.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { type AbstractCtor, type Ctor, type Fn } from "@storyteller/utility";
|
import { type AbstractCtor, type Ctor, type Fn } from "@storyteller/utility";
|
||||||
import { type PropertyValues } from "lit";
|
import { type PropertyValues } from "lit";
|
||||||
|
import { v4 as uuid } from "uuid";
|
||||||
|
|
||||||
export class UniqueToken {
|
export class UniqueToken {
|
||||||
get id() { return this.#id; }
|
get id() { return this.#id; }
|
||||||
@@ -10,7 +11,7 @@ export class UniqueToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static create<T>(name?: string): Token<T> {
|
static create<T>(name?: string): Token<T> {
|
||||||
return new UniqueToken(name ?? crypto.randomUUID());
|
return new UniqueToken(name ?? uuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { customElement, state } from "lit/decorators.js";
|
|||||||
import { classMap } from "lit/directives/class-map.js";
|
import { classMap } from "lit/directives/class-map.js";
|
||||||
import { createRef, ref } from "lit/directives/ref.js";
|
import { createRef, ref } from "lit/directives/ref.js";
|
||||||
import { styleMap } from "lit/directives/style-map.js";
|
import { styleMap } from "lit/directives/style-map.js";
|
||||||
|
import { v4 as uuid } from "uuid";
|
||||||
|
|
||||||
import { ImageInfo, LcmClient } from "./lcm-client";
|
import { ImageInfo, LcmClient } from "./lcm-client";
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ export class AppElement extends LitElement {
|
|||||||
@state() inputUrl?: string;
|
@state() inputUrl?: string;
|
||||||
@state() outputUrl?: string;
|
@state() outputUrl?: string;
|
||||||
|
|
||||||
#lcmClient = new LcmClient(crypto.randomUUID());
|
#lcmClient = new LcmClient(uuid());
|
||||||
#outputImageRef = createRef<HTMLImageElement>();
|
#outputImageRef = createRef<HTMLImageElement>();
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
|
|||||||
Reference in New Issue
Block a user