@daasboard/doc 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2026 Spotworks AI LLC. All rights reserved.
2
+
3
+ This software is proprietary. No license or other right to use, copy, modify,
4
+ merge, publish, distribute, sublicense or sell it, in whole or in part, is
5
+ granted except under a separate written agreement with Spotworks AI LLC.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # @daasboard/doc
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Document adapters, text data and collaboration transport for daasboard. Includes local memory documents and Loro-backed documents.
4
+
5
+ Hosts normally start from [`@daasboard/embed`](https://www.npmjs.com/package/@daasboard/embed), which mounts the editor and documents the required wasm and font assets. Keep every `@daasboard` package on the same exact release version.
6
+
7
+ This package provides ES modules and TypeScript declarations through its root entry point. Public availability grants no license; see `LICENSE`. Third-party components retain their own licenses.
@@ -0,0 +1,41 @@
1
+ import type { ChangeSet, SceneObject } from "@daasboard/render-core";
2
+ export type PropPath = string;
3
+ export type TextDeltaOp = {
4
+ insert: string;
5
+ attributes?: Record<string, unknown>;
6
+ } | {
7
+ delete: number;
8
+ } | {
9
+ retain: number;
10
+ attributes?: Record<string, unknown>;
11
+ };
12
+ export type TextDelta = TextDeltaOp[];
13
+ export interface Transaction {
14
+ set(id: string, path: PropPath, value: unknown): void;
15
+ move(id: string, parent: string | null, index?: number): void;
16
+ create(obj: SceneObject): void;
17
+ delete(id: string): void;
18
+ editText(id: string, delta: TextDelta): void;
19
+ }
20
+ export declare const TYPING_MERGE_MS = 500;
21
+ export declare const MAX_UNDO_ENTRIES = 200;
22
+ export interface ChangeMeta {
23
+ label: string;
24
+ origin: "local" | "undo" | "redo" | "remote";
25
+ textDeltas?: ReadonlyMap<string, readonly TextDelta[]>;
26
+ }
27
+ export interface DocumentAdapter {
28
+ readonly carriesDescendants?: boolean;
29
+ get(id: string): SceneObject | undefined;
30
+ order(): readonly string[];
31
+ transact(label: string, fn: (tx: Transaction) => void): void;
32
+ endTyping(): void;
33
+ undo(): boolean;
34
+ redo(): boolean;
35
+ canUndo(): boolean;
36
+ canRedo(): boolean;
37
+ subscribe(listener: (cs: ChangeSet, meta: ChangeMeta) => void): () => void;
38
+ }
39
+ export declare function getPath(o: SceneObject, path: PropPath): unknown;
40
+ export declare function stripUndefined<T extends object>(v: T): T;
41
+ export declare function setPath(o: SceneObject, path: PropPath, value: unknown): void;
@@ -0,0 +1,34 @@
1
+ export const TYPING_MERGE_MS = 500;
2
+ export const MAX_UNDO_ENTRIES = 200;
3
+ export function getPath(o, path) {
4
+ let cur = o;
5
+ for (const part of path.split(".")) {
6
+ if (cur === null || cur === undefined)
7
+ return undefined;
8
+ cur = cur[part];
9
+ }
10
+ return cur;
11
+ }
12
+ export function stripUndefined(v) {
13
+ const out = {};
14
+ for (const [k, x] of Object.entries(v))
15
+ if (x !== undefined)
16
+ out[k] = x;
17
+ return out;
18
+ }
19
+ export function setPath(o, path, value) {
20
+ const parts = path.split(".");
21
+ let cur = o;
22
+ for (let i = 0; i < parts.length - 1; i++) {
23
+ const p = parts[i];
24
+ const next = cur[p];
25
+ const clone = next && typeof next === "object" ? { ...next } : {};
26
+ cur[p] = clone;
27
+ cur = clone;
28
+ }
29
+ const last = parts[parts.length - 1];
30
+ if (value === undefined)
31
+ delete cur[last];
32
+ else
33
+ cur[last] = value;
34
+ }
@@ -0,0 +1,137 @@
1
+ import { LoroDoc, type LoroTree } from "loro-crdt";
2
+ import type { SceneObject } from "@daasboard/render-core";
3
+ import { type PageState, type Problem } from "./normalize.js";
4
+ import { MAX_UNDO_ENTRIES, type DocumentAdapter, type Transaction } from "./DocumentAdapter.js";
5
+ export declare const SCHEMA_VERSION = 2;
6
+ export type ObjectId = string;
7
+ export { MAX_UNDO_ENTRIES };
8
+ type Listener = Parameters<DocumentAdapter["subscribe"]>[0];
9
+ export interface LoroPageDocOptions {
10
+ peerId?: number;
11
+ now?: () => number;
12
+ onFatal?: (err: unknown) => void;
13
+ }
14
+ export declare class LoroPageDoc implements DocumentAdapter {
15
+ readonly carriesDescendants = true;
16
+ private loroDoc;
17
+ private loroTree;
18
+ private unsubscribeRoot;
19
+ private trashId;
20
+ private trashRoots;
21
+ private problemsById;
22
+ private emptyGroups;
23
+ private objects;
24
+ private textSlots;
25
+ private orderIds;
26
+ private childrenOf;
27
+ private parentOf;
28
+ private attachedTo;
29
+ private listeners;
30
+ private undoStack;
31
+ private redoStack;
32
+ private applying;
33
+ private pendingLabel;
34
+ private pendingOrigin;
35
+ private undoManager;
36
+ private readonly now;
37
+ private readonly onFatal;
38
+ private dead;
39
+ private loading;
40
+ private pending;
41
+ private opDepth;
42
+ private delivering;
43
+ private nextSerial;
44
+ private pushSerial;
45
+ private countingPushes;
46
+ private textPushes;
47
+ private pops;
48
+ private lastTyping;
49
+ private versions;
50
+ private inflight;
51
+ private constructor();
52
+ get doc(): LoroDoc;
53
+ get tree(): LoroTree;
54
+ private newUndoManager;
55
+ static create(opts?: LoroPageDocOptions): LoroPageDoc;
56
+ static empty(opts?: LoroPageDocOptions): LoroPageDoc;
57
+ isInitialized(): boolean;
58
+ init(): void;
59
+ private refreshTrashId;
60
+ static open(bytes: Uint8Array, opts?: LoroPageDocOptions): LoroPageDoc;
61
+ adoptSnapshot(staged: LoroDoc): void;
62
+ snapshot(): Uint8Array;
63
+ shallowSnapshot(): Uint8Array;
64
+ version(): import("loro-crdt").VersionVector;
65
+ exportSince(vv: ReturnType<LoroDoc["version"]>): Uint8Array;
66
+ exportAll(): Uint8Array;
67
+ import(bytes: Uint8Array): void;
68
+ isDead(): boolean;
69
+ private die;
70
+ private markDead;
71
+ get(id: ObjectId): SceneObject | undefined;
72
+ order(): readonly ObjectId[];
73
+ allObjects(): SceneObject[];
74
+ problems(): readonly Problem[];
75
+ state(): PageState;
76
+ static stateOf(doc: LoroDoc): PageState;
77
+ get trash(): ObjectId;
78
+ private node;
79
+ private isTrashRoot;
80
+ private inTrash;
81
+ private inTrashJS;
82
+ private parentIdOf;
83
+ private counters;
84
+ private bumpVersion;
85
+ private materializeNode;
86
+ private materializeAll;
87
+ private sceneView;
88
+ private trackAttachment;
89
+ private untrackAttachment;
90
+ private absOriginOfParent;
91
+ private mutationSiblings;
92
+ private originFromObjects;
93
+ private applyTreeItem;
94
+ private ensureChildrenKnown;
95
+ private applyTreeItems;
96
+ private metaFor;
97
+ private freezeChangedText;
98
+ private onBatch;
99
+ private applyBatch;
100
+ private resync;
101
+ private materializeDirty;
102
+ private spliceOrder;
103
+ private computeOrder;
104
+ private changeSet;
105
+ private flush;
106
+ private op;
107
+ subscribe(l: Listener): () => void;
108
+ private commit;
109
+ private pushUndo;
110
+ transact(label: string, fn: (tx: Transaction) => void): void;
111
+ load(fn: () => void): void;
112
+ private transactImpl;
113
+ private commitTextEdits;
114
+ private ensureMap;
115
+ private readKey;
116
+ private writeKey;
117
+ private writeKeyValue;
118
+ private rebaseXywh;
119
+ private positionOf;
120
+ private isTrashMove;
121
+ private someContainerOrigin;
122
+ private ensureText;
123
+ private drawnPointOf;
124
+ private anchorOf;
125
+ private liveAbsBox;
126
+ private refreshAnchors;
127
+ private writeAnchors;
128
+ private refreshInverseAnchors;
129
+ private anchorBeforeTrash;
130
+ canUndo(): boolean;
131
+ canRedo(): boolean;
132
+ private applyInverse;
133
+ private walk;
134
+ undo(): boolean;
135
+ endTyping(): void;
136
+ redo(): boolean;
137
+ }