update
This commit is contained in:
Binary file not shown.
Vendored
+4
-58
@@ -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
|
// node_modules/bloatless-react/index.ts
|
||||||
function UUID() {
|
|
||||||
return v4_default();
|
|
||||||
}
|
|
||||||
var State = class {
|
var State = class {
|
||||||
_value;
|
_value;
|
||||||
_bindings = /* @__PURE__ */ new Set();
|
_bindings = /* @__PURE__ */ new Set();
|
||||||
@@ -99,10 +47,9 @@
|
|||||||
remove(...items) {
|
remove(...items) {
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
this.value.delete(item);
|
this.value.delete(item);
|
||||||
const id = item.id;
|
if (!this.removalHandlers.has(item)) return;
|
||||||
if (!this.removalHandlers.has(id)) return;
|
this.removalHandlers.get(item)(item);
|
||||||
this.removalHandlers.get(id)(item);
|
this.removalHandlers.delete(item);
|
||||||
this.removalHandlers.delete(id);
|
|
||||||
});
|
});
|
||||||
this.callSubscriptions();
|
this.callSubscriptions();
|
||||||
}
|
}
|
||||||
@@ -115,7 +62,7 @@
|
|||||||
[...this.value.values()].forEach(handler);
|
[...this.value.values()].forEach(handler);
|
||||||
}
|
}
|
||||||
handleRemoval(item, handler) {
|
handleRemoval(item, handler) {
|
||||||
this.removalHandlers.set(item.id, handler);
|
this.removalHandlers.set(item, handler);
|
||||||
}
|
}
|
||||||
// stringification
|
// stringification
|
||||||
toString() {
|
toString() {
|
||||||
@@ -425,7 +372,6 @@
|
|||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
id = UUID();
|
|
||||||
};
|
};
|
||||||
var isDisconnected = new State(true);
|
var isDisconnected = new State(true);
|
||||||
var mailboxId = restoreState("mailbox-id", "");
|
var mailboxId = restoreState("mailbox-id", "");
|
||||||
|
|||||||
+8
-9
@@ -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 additionHandlers = new Set<AdditionSubscription<T>>();
|
||||||
private removalHandlers = new Map<string, RemovalSubscription<T>>();
|
private removalHandlers = new Map<T, RemovalSubscription<T>>();
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(initialItems?: T[]) {
|
constructor(initialItems?: T[]) {
|
||||||
@@ -79,11 +79,10 @@ export class ListState<T extends Identifiable> extends State<Set<T>> {
|
|||||||
remove(...items: T[]): void {
|
remove(...items: T[]): void {
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
this.value.delete(item);
|
this.value.delete(item);
|
||||||
const id = item.id;
|
|
||||||
|
|
||||||
if (!this.removalHandlers.has(id)) return;
|
if (!this.removalHandlers.has(item)) return;
|
||||||
this.removalHandlers.get(id)!(item);
|
this.removalHandlers.get(item)!(item);
|
||||||
this.removalHandlers.delete(id);
|
this.removalHandlers.delete(item);
|
||||||
});
|
});
|
||||||
this.callSubscriptions();
|
this.callSubscriptions();
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,7 @@ export class ListState<T extends Identifiable> extends State<Set<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleRemoval(item: T, handler: RemovalSubscription<T>): void {
|
handleRemoval(item: T, handler: RemovalSubscription<T>): void {
|
||||||
this.removalHandlers.set(item.id, handler);
|
this.removalHandlers.set(item, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stringification
|
// stringification
|
||||||
@@ -144,7 +143,7 @@ export function restoreState<T>(
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function restoreListState<T extends Identifiable>(
|
export function restoreListState<T>(
|
||||||
localStorageKey: string
|
localStorageKey: string
|
||||||
): ListState<T> {
|
): ListState<T> {
|
||||||
const storedString = localStorage.getItem(localStorageKey) ?? "";
|
const storedString = localStorage.getItem(localStorageKey) ?? "";
|
||||||
@@ -163,7 +162,7 @@ export function restoreListState<T extends Identifiable>(
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ListItemConverter<T extends Identifiable> = (
|
export type ListItemConverter<T> = (
|
||||||
item: T
|
item: T
|
||||||
) => HTMLElement;
|
) => HTMLElement;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bloatless-react",
|
"name": "bloatless-react",
|
||||||
"version": "1.2.5-beta1",
|
"version": "1.2.6",
|
||||||
"description": "very minimal and flexible react alternative",
|
"description": "very minimal and flexible react alternative",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bloatless-react": "1.2.5-beta1",
|
"bloatless-react": "^1.2.6",
|
||||||
"esbuild": "latest",
|
"esbuild": "latest",
|
||||||
"udn-frontend": "^1.0.6"
|
"udn-frontend": "^1.0.6"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ import * as React from "bloatless-react";
|
|||||||
import UDNFrontend from "udn-frontend";
|
import UDNFrontend from "udn-frontend";
|
||||||
import { translations } from "./translations";
|
import { translations } from "./translations";
|
||||||
|
|
||||||
export class Message implements React.Identifiable {
|
export class Message {
|
||||||
id = React.UUID();
|
|
||||||
|
|
||||||
constructor(public channel: string, public body: string) {}
|
constructor(public channel: string, public body: string) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user