Compare commits
3 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 5ace8cf52f | |
Derrick Hammer | f3c81e0375 | |
Derrick Hammer | 3fa96aa05a |
|
@ -1,3 +1,10 @@
|
||||||
|
# [0.1.0-develop.68](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.67...v0.1.0-develop.68) (2023-11-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update how maps are packed and add missing serialization for media, directory, and files ([3fa96aa](https://git.lumeweb.com/LumeWeb/libs5/commit/3fa96aa05acf292311faa5fbbc83f1f1bd120f68))
|
||||||
|
|
||||||
# [0.1.0-develop.67](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.66...v0.1.0-develop.67) (2023-11-18)
|
# [0.1.0-develop.67](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.66...v0.1.0-develop.67) (2023-11-18)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.67",
|
"version": "0.1.0-develop.68",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.67",
|
"version": "0.1.0-develop.68",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
"@noble/hashes": "^1.3.1",
|
"@noble/hashes": "^1.3.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.67",
|
"version": "0.1.0-develop.68",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -141,7 +141,7 @@ class DirectoryMetadataDetails {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectoryReference {
|
export class DirectoryReference {
|
||||||
created: number;
|
created: number;
|
||||||
name: string;
|
name: string;
|
||||||
encryptedWriteKey: Uint8Array;
|
encryptedWriteKey: Uint8Array;
|
||||||
|
@ -214,7 +214,7 @@ class DirectoryReference {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class FileReference {
|
export class FileReference {
|
||||||
created: number;
|
created: number;
|
||||||
file: FileVersion;
|
file: FileVersion;
|
||||||
history: Map<number, FileVersion> | null;
|
history: Map<number, FileVersion> | null;
|
||||||
|
@ -315,7 +315,7 @@ class FileReference {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileVersion {
|
export class FileVersion {
|
||||||
ts: number;
|
ts: number;
|
||||||
encryptedCID?: EncryptedCID;
|
encryptedCID?: EncryptedCID;
|
||||||
plaintextCID?: CID;
|
plaintextCID?: CID;
|
||||||
|
@ -382,7 +382,7 @@ class FileVersion {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class FileVersionThumbnail {
|
export class FileVersionThumbnail {
|
||||||
imageType: string | null;
|
imageType: string | null;
|
||||||
aspectRatio: number;
|
aspectRatio: number;
|
||||||
cid: EncryptedCID;
|
cid: EncryptedCID;
|
||||||
|
|
|
@ -153,7 +153,7 @@ class MediaMetadataDetails {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MediaFormat {
|
export class MediaFormat {
|
||||||
subtype: string;
|
subtype: string;
|
||||||
role: string | null;
|
role: string | null;
|
||||||
ext: string | null;
|
ext: string | null;
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
import NodeId from "../nodeId.js";
|
import NodeId from "../nodeId.js";
|
||||||
|
import CID from "#cid.js";
|
||||||
|
import { MediaFormat } from "#serialization/metadata/media.js";
|
||||||
|
import {
|
||||||
|
DirectoryReference,
|
||||||
|
FileReference,
|
||||||
|
FileVersion,
|
||||||
|
FileVersionThumbnail,
|
||||||
|
} from "#serialization/metadata/directory.js";
|
||||||
|
import { Buffer } from "buffer";
|
||||||
|
|
||||||
export default class Packer {
|
export default class Packer {
|
||||||
private _bufSize: number;
|
private _bufSize: number;
|
||||||
|
@ -236,7 +245,7 @@ export default class Packer {
|
||||||
return Buffer.concat(this._builder);
|
return Buffer.concat(this._builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public pack(v: any) {
|
public pack(v: any): this {
|
||||||
if (v === null) {
|
if (v === null) {
|
||||||
this.packNull();
|
this.packNull();
|
||||||
} else if (typeof v === "number") {
|
} else if (typeof v === "number") {
|
||||||
|
@ -258,14 +267,24 @@ export default class Packer {
|
||||||
}
|
}
|
||||||
} else if (v instanceof Map) {
|
} else if (v instanceof Map) {
|
||||||
this.packMapLength(v.size);
|
this.packMapLength(v.size);
|
||||||
for (const [key, value] of v.entries()) {
|
v.forEach((value, key) => {
|
||||||
this.pack(key);
|
this.pack(key);
|
||||||
this.pack(value);
|
this.pack(value);
|
||||||
}
|
});
|
||||||
|
} else if (
|
||||||
|
v instanceof MediaFormat ||
|
||||||
|
v instanceof DirectoryReference ||
|
||||||
|
v instanceof FileReference ||
|
||||||
|
v instanceof FileVersion ||
|
||||||
|
v instanceof FileVersionThumbnail
|
||||||
|
) {
|
||||||
|
this.pack(v.encode());
|
||||||
|
} else if (v instanceof CID) {
|
||||||
|
this.pack(v.toBytes());
|
||||||
} else if (v instanceof NodeId) {
|
} else if (v instanceof NodeId) {
|
||||||
this.pack(v.bytes);
|
this.pack(v.bytes);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Could not pack ${v.constructor.name}`);
|
throw new Error(`Could not pack type: ${typeof v}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue