Skip to content
Merged

Dev #176

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ sst.pyi
# flatc
build_logs

.claude
.claude


tsconfig.tsbuildinfo
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions memory-bank/activeContext.md

This file was deleted.

22 changes: 0 additions & 22 deletions memory-bank/productContext.md

This file was deleted.

26 changes: 0 additions & 26 deletions memory-bank/progress.md

This file was deleted.

21 changes: 0 additions & 21 deletions memory-bank/projectbrief.md

This file was deleted.

27 changes: 0 additions & 27 deletions memory-bank/systemPatterns.md

This file was deleted.

34 changes: 0 additions & 34 deletions memory-bank/techContext.md

This file was deleted.

9 changes: 5 additions & 4 deletions packages/ducjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
"undici-types": "^6.21.0"
},
"dependencies": {
"flatbuffers": "^24.12.23",
"nanoid": "5.1.5",
"tinycolor2": "1.6.0",
"@braintree/sanitize-url": "6.0.2",
"browser-fs-access": "0.35.0",
"perfect-freehand": "1.2.2"
"fflate": "^0.8.2",
"flatbuffers": "^24.12.23",
"nanoid": "5.1.5",
"perfect-freehand": "1.2.2",
"tinycolor2": "1.6.0"
},
"files": [
"dist",
Expand Down
38 changes: 26 additions & 12 deletions packages/ducjs/src/flatbuffers/duc/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import * as flatbuffers from 'flatbuffers';

import { JSONPatchOperation } from '../duc/jsonpatch-operation';
import { VersionBase } from '../duc/version-base';


Expand All @@ -31,48 +30,63 @@ base(obj?:VersionBase):VersionBase|null {
return offset ? (obj || new VersionBase()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

patch(index: number, obj?:JSONPatchOperation):JSONPatchOperation|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new JSONPatchOperation()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
sizeBytes():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

patch(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
}

patchLength():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

patchArray():Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}

static startDelta(builder:flatbuffers.Builder) {
builder.startObject(2);
builder.startObject(4);
}

static addBase(builder:flatbuffers.Builder, baseOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, baseOffset, 0);
}

static addSizeBytes(builder:flatbuffers.Builder, sizeBytes:bigint) {
builder.addFieldInt64(2, sizeBytes, BigInt('0'));
}

static addPatch(builder:flatbuffers.Builder, patchOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, patchOffset, 0);
builder.addFieldOffset(3, patchOffset, 0);
}

static createPatchVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
static createPatchVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
builder.startVector(1, data.length, 1);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
builder.addInt8(data[i]!);
}
return builder.endVector();
}

static startPatchVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
builder.startVector(1, numElems, 1);
}

static endDelta(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}

static createDelta(builder:flatbuffers.Builder, baseOffset:flatbuffers.Offset, patchOffset:flatbuffers.Offset):flatbuffers.Offset {
static createDelta(builder:flatbuffers.Builder, baseOffset:flatbuffers.Offset, sizeBytes:bigint, patchOffset:flatbuffers.Offset):flatbuffers.Offset {
Delta.startDelta(builder);
Delta.addBase(builder, baseOffset);
Delta.addSizeBytes(builder, sizeBytes);
Delta.addPatch(builder, patchOffset);
return Delta.endDelta(builder);
}
Expand Down
34 changes: 27 additions & 7 deletions packages/ducjs/src/flatbuffers/duc/duc-block-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,23 @@ updatedAt():bigint {
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

localization():string|null
localization(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
localization(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
localization(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
}

localizationLength():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

localizationArray():Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}

static startDucBlockMetadata(builder:flatbuffers.Builder) {
builder.startObject(5);
builder.startObject(6);
}

static addSource(builder:flatbuffers.Builder, sourceOffset:flatbuffers.Offset) {
Expand All @@ -72,7 +80,19 @@ static addUpdatedAt(builder:flatbuffers.Builder, updatedAt:bigint) {
}

static addLocalization(builder:flatbuffers.Builder, localizationOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, localizationOffset, 0);
builder.addFieldOffset(5, localizationOffset, 0);
}

static createLocalizationVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
builder.startVector(1, data.length, 1);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt8(data[i]!);
}
return builder.endVector();
}

static startLocalizationVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(1, numElems, 1);
}

static endDucBlockMetadata(builder:flatbuffers.Builder):flatbuffers.Offset {
Expand Down
Loading
Loading