This commit is contained in:
marlon-erler
2024-07-09 04:43:05 +02:00
parent 53a309b02c
commit 464fc54a0b
6 changed files with 15 additions and 72 deletions
BIN
View File
Binary file not shown.
+4 -58
View File
@@ -1,57 +1,5 @@
(() => {
// node_modules/uuid/dist/esm-browser/stringify.js
var byteToHex = [];
for (i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).slice(1));
}
var i;
function unsafeStringify(arr, offset = 0) {
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
}
// node_modules/uuid/dist/esm-browser/rng.js
var getRandomValues;
var rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues) {
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
if (!getRandomValues) {
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
}
}
return getRandomValues(rnds8);
}
// node_modules/uuid/dist/esm-browser/native.js
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
var native_default = {
randomUUID
};
// node_modules/uuid/dist/esm-browser/v4.js
function v4(options, buf, offset) {
if (native_default.randomUUID && !buf && !options) {
return native_default.randomUUID();
}
options = options || {};
var rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (var i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return unsafeStringify(rnds);
}
var v4_default = v4;
// node_modules/bloatless-react/index.ts
function UUID() {
return v4_default();
}
var State = class {
_value;
_bindings = /* @__PURE__ */ new Set();
@@ -99,10 +47,9 @@
remove(...items) {
items.forEach((item) => {
this.value.delete(item);
const id = item.id;
if (!this.removalHandlers.has(id)) return;
this.removalHandlers.get(id)(item);
this.removalHandlers.delete(id);
if (!this.removalHandlers.has(item)) return;
this.removalHandlers.get(item)(item);
this.removalHandlers.delete(item);
});
this.callSubscriptions();
}
@@ -115,7 +62,7 @@
[...this.value.values()].forEach(handler);
}
handleRemoval(item, handler) {
this.removalHandlers.set(item.id, handler);
this.removalHandlers.set(item, handler);
}
// stringification
toString() {
@@ -425,7 +372,6 @@
this.channel = channel;
this.body = body;
}
id = UUID();
};
var isDisconnected = new State(true);
var mailboxId = restoreState("mailbox-id", "");
+8 -9
View File
@@ -58,9 +58,9 @@ export class State<T> {
}
}
export class ListState<T extends Identifiable> extends State<Set<T>> {
export class ListState<T> extends State<Set<T>> {
private additionHandlers = new Set<AdditionSubscription<T>>();
private removalHandlers = new Map<string, RemovalSubscription<T>>();
private removalHandlers = new Map<T, RemovalSubscription<T>>();
// init
constructor(initialItems?: T[]) {
@@ -79,11 +79,10 @@ export class ListState<T extends Identifiable> extends State<Set<T>> {
remove(...items: T[]): void {
items.forEach((item) => {
this.value.delete(item);
const id = item.id;
if (!this.removalHandlers.has(id)) return;
this.removalHandlers.get(id)!(item);
this.removalHandlers.delete(id);
if (!this.removalHandlers.has(item)) return;
this.removalHandlers.get(item)!(item);
this.removalHandlers.delete(item);
});
this.callSubscriptions();
}
@@ -99,7 +98,7 @@ export class ListState<T extends Identifiable> extends State<Set<T>> {
}
handleRemoval(item: T, handler: RemovalSubscription<T>): void {
this.removalHandlers.set(item.id, handler);
this.removalHandlers.set(item, handler);
}
// stringification
@@ -144,7 +143,7 @@ export function restoreState<T>(
return state;
}
export function restoreListState<T extends Identifiable>(
export function restoreListState<T>(
localStorageKey: string
): ListState<T> {
const storedString = localStorage.getItem(localStorageKey) ?? "";
@@ -163,7 +162,7 @@ export function restoreListState<T extends Identifiable>(
return state;
}
export type ListItemConverter<T extends Identifiable> = (
export type ListItemConverter<T> = (
item: T
) => HTMLElement;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "bloatless-react",
"version": "1.2.5-beta1",
"version": "1.2.6",
"description": "very minimal and flexible react alternative",
"repository": {
"type": "git",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"dependencies": {
"bloatless-react": "1.2.5-beta1",
"bloatless-react": "^1.2.6",
"esbuild": "latest",
"udn-frontend": "^1.0.6"
},
+1 -3
View File
@@ -3,9 +3,7 @@ import * as React from "bloatless-react";
import UDNFrontend from "udn-frontend";
import { translations } from "./translations";
export class Message implements React.Identifiable {
id = React.UUID();
export class Message {
constructor(public channel: string, public body: string) {}
}