feat: support passing Uint8Array as island props (#1225)
This commit adds support for passing Uint8Array's to islands in component props.
This commit is contained in:
@@ -8,6 +8,16 @@ interface Signal<T> {
|
||||
value: T;
|
||||
}
|
||||
|
||||
function b64decode(b64: string): Uint8Array {
|
||||
const binString = atob(b64);
|
||||
const size = binString.length;
|
||||
const bytes = new Uint8Array(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
bytes[i] = binString.charCodeAt(i);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
export function deserialize(
|
||||
str: string,
|
||||
signal?: <T>(a: T) => Signal<T>,
|
||||
@@ -19,6 +29,9 @@ export function deserialize(
|
||||
if (v[KEY] === "s") {
|
||||
return signal!(v.v);
|
||||
}
|
||||
if (v[KEY] === "u8a") {
|
||||
return b64decode(v.d);
|
||||
}
|
||||
if (v[KEY] === "l") {
|
||||
const val = v.v;
|
||||
val[KEY] = v.k;
|
||||
|
||||
Reference in New Issue
Block a user