@verdant-web/common 1.11.0 → 1.11.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/dist/cjs/EventSubscriber.d.ts +17 -17
- package/dist/cjs/EventSubscriber.js +66 -66
- package/dist/cjs/baseline.d.ts +5 -5
- package/dist/cjs/baseline.js +2 -2
- package/dist/cjs/batching.d.ts +41 -41
- package/dist/cjs/batching.js +88 -88
- package/dist/cjs/files.d.ts +19 -19
- package/dist/cjs/files.js +18 -18
- package/dist/cjs/index.d.ts +18 -18
- package/dist/cjs/index.js +35 -35
- package/dist/cjs/indexes.d.ts +14 -14
- package/dist/cjs/indexes.js +115 -115
- package/dist/cjs/indexes.test.d.ts +1 -1
- package/dist/cjs/indexes.test.js +127 -127
- package/dist/cjs/migration.d.ts +98 -98
- package/dist/cjs/migration.js +127 -127
- package/dist/cjs/oids.d.ts +87 -87
- package/dist/cjs/oids.js +374 -374
- package/dist/cjs/oids.test.d.ts +1 -1
- package/dist/cjs/oids.test.js +245 -245
- package/dist/cjs/operation.d.ts +139 -139
- package/dist/cjs/operation.js +532 -532
- package/dist/cjs/operation.test.d.ts +1 -1
- package/dist/cjs/operation.test.js +484 -484
- package/dist/cjs/patch.d.ts +26 -26
- package/dist/cjs/patch.js +226 -226
- package/dist/cjs/presence.d.ts +27 -27
- package/dist/cjs/presence.js +2 -2
- package/dist/cjs/protocol.d.ts +145 -145
- package/dist/cjs/protocol.js +3 -3
- package/dist/cjs/refs.d.ts +5 -5
- package/dist/cjs/refs.js +21 -21
- package/dist/cjs/replica.d.ts +28 -28
- package/dist/cjs/replica.js +28 -28
- package/dist/cjs/schema/defaults.d.ts +4 -4
- package/dist/cjs/schema/defaults.js +71 -71
- package/dist/cjs/schema/defaults.test.d.ts +1 -1
- package/dist/cjs/schema/defaults.test.js +20 -20
- package/dist/cjs/schema/index.d.ts +8 -8
- package/dist/cjs/schema/index.js +28 -28
- package/dist/cjs/schema/indexFilters.d.ts +6 -6
- package/dist/cjs/schema/indexFilters.js +30 -30
- package/dist/cjs/schema/types/collection.d.ts +51 -51
- package/dist/cjs/schema/types/collection.js +2 -2
- package/dist/cjs/schema/types/compounds.d.ts +12 -12
- package/dist/cjs/schema/types/compounds.js +2 -2
- package/dist/cjs/schema/types/fields.d.ts +59 -59
- package/dist/cjs/schema/types/fields.js +2 -2
- package/dist/cjs/schema/types/filters.d.ts +29 -29
- package/dist/cjs/schema/types/filters.js +2 -2
- package/dist/cjs/schema/types/shapes.d.ts +21 -21
- package/dist/cjs/schema/types/shapes.js +2 -2
- package/dist/cjs/schema/types/synthetics.d.ts +28 -28
- package/dist/cjs/schema/types/synthetics.js +2 -2
- package/dist/cjs/schema/types.d.ts +18 -18
- package/dist/cjs/schema/types.js +22 -22
- package/dist/cjs/timestamp.d.ts +48 -48
- package/dist/cjs/timestamp.js +243 -243
- package/dist/cjs/timestamp.test.d.ts +1 -1
- package/dist/cjs/timestamp.test.js +93 -93
- package/dist/cjs/undo.d.ts +3 -3
- package/dist/cjs/undo.js +198 -198
- package/dist/cjs/utils.d.ts +15 -15
- package/dist/cjs/utils.js +127 -127
- package/dist/cjs/utils.test.d.ts +1 -1
- package/dist/cjs/utils.test.js +36 -36
- package/dist/esm/EventSubscriber.d.ts +17 -17
- package/dist/esm/EventSubscriber.js +62 -62
- package/dist/esm/baseline.d.ts +5 -5
- package/dist/esm/baseline.js +1 -1
- package/dist/esm/batching.d.ts +41 -41
- package/dist/esm/batching.js +83 -83
- package/dist/esm/files.d.ts +19 -19
- package/dist/esm/files.js +12 -12
- package/dist/esm/index.d.ts +18 -18
- package/dist/esm/index.js +15 -15
- package/dist/esm/indexes.d.ts +14 -14
- package/dist/esm/indexes.js +105 -105
- package/dist/esm/indexes.test.d.ts +1 -1
- package/dist/esm/indexes.test.js +125 -125
- package/dist/esm/migration.d.ts +98 -98
- package/dist/esm/migration.js +121 -121
- package/dist/esm/oids.d.ts +87 -87
- package/dist/esm/oids.js +347 -347
- package/dist/esm/oids.test.d.ts +1 -1
- package/dist/esm/oids.test.js +243 -243
- package/dist/esm/operation.d.ts +139 -139
- package/dist/esm/operation.js +517 -517
- package/dist/esm/operation.test.d.ts +1 -1
- package/dist/esm/operation.test.js +482 -482
- package/dist/esm/patch.d.ts +26 -26
- package/dist/esm/patch.js +222 -222
- package/dist/esm/presence.d.ts +27 -27
- package/dist/esm/presence.js +1 -1
- package/dist/esm/protocol.d.ts +145 -145
- package/dist/esm/protocol.js +2 -2
- package/dist/esm/refs.d.ts +5 -5
- package/dist/esm/refs.js +16 -16
- package/dist/esm/replica.d.ts +28 -28
- package/dist/esm/replica.js +25 -25
- package/dist/esm/schema/defaults.d.ts +4 -4
- package/dist/esm/schema/defaults.js +65 -65
- package/dist/esm/schema/defaults.test.d.ts +1 -1
- package/dist/esm/schema/defaults.test.js +18 -18
- package/dist/esm/schema/index.d.ts +8 -8
- package/dist/esm/schema/index.js +9 -9
- package/dist/esm/schema/indexFilters.d.ts +6 -6
- package/dist/esm/schema/indexFilters.js +22 -22
- package/dist/esm/schema/types/collection.d.ts +51 -51
- package/dist/esm/schema/types/collection.js +1 -1
- package/dist/esm/schema/types/compounds.d.ts +12 -12
- package/dist/esm/schema/types/compounds.js +1 -1
- package/dist/esm/schema/types/fields.d.ts +59 -59
- package/dist/esm/schema/types/fields.js +1 -1
- package/dist/esm/schema/types/filters.d.ts +29 -29
- package/dist/esm/schema/types/filters.js +1 -1
- package/dist/esm/schema/types/shapes.d.ts +21 -21
- package/dist/esm/schema/types/shapes.js +1 -1
- package/dist/esm/schema/types/synthetics.d.ts +28 -28
- package/dist/esm/schema/types/synthetics.js +1 -1
- package/dist/esm/schema/types.d.ts +18 -18
- package/dist/esm/schema/types.js +6 -6
- package/dist/esm/timestamp.d.ts +48 -48
- package/dist/esm/timestamp.js +228 -228
- package/dist/esm/timestamp.test.d.ts +1 -1
- package/dist/esm/timestamp.test.js +91 -91
- package/dist/esm/undo.d.ts +3 -3
- package/dist/esm/undo.js +194 -194
- package/dist/esm/utils.d.ts +15 -15
- package/dist/esm/utils.js +113 -113
- package/dist/esm/utils.test.d.ts +1 -1
- package/dist/esm/utils.test.js +34 -34
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/files.test.d.ts +0 -1
- package/dist/cjs/files.test.js +0 -81
- package/dist/cjs/files.test.js.map +0 -1
- package/dist/esm/files.test.d.ts +0 -1
- package/dist/esm/files.test.js +0 -79
- package/dist/esm/files.test.js.map +0 -1
package/dist/esm/patch.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-level patch creation for use with complex nested objects.
|
|
3
|
-
*/
|
|
4
|
-
import { KeyPath, ObjectIdentifier } from './oids.js';
|
|
5
|
-
import { ObjectRef, Operation, PropertyName } from './operation.js';
|
|
6
|
-
export declare class PatchCreator {
|
|
7
|
-
private getNow;
|
|
8
|
-
private createSubId?;
|
|
9
|
-
constructor(getNow: () => string, createSubId?: (() => string) | undefined);
|
|
10
|
-
createDiff: (from: any, to: any, keyPath: KeyPath, options?: {
|
|
11
|
-
mergeUnknownObjects?: boolean;
|
|
12
|
-
defaultUndefined?: boolean;
|
|
13
|
-
}) => Operation[];
|
|
14
|
-
createInitialize: (obj: any, oid: ObjectIdentifier) => Operation[];
|
|
15
|
-
createSet: (oid: ObjectIdentifier, key: PropertyName, value: any, keyPath: KeyPath) => Operation[];
|
|
16
|
-
createRemove: (oid: ObjectIdentifier, key: PropertyName) => Operation[];
|
|
17
|
-
createListPush: (oid: ObjectIdentifier, value: any) => Operation[];
|
|
18
|
-
createListAdd: (oid: ObjectIdentifier, value: any) => Operation[];
|
|
19
|
-
createListInsert: (oid: ObjectIdentifier, index: number, value: any) => Operation[];
|
|
20
|
-
createListRemove: (oid: ObjectIdentifier, value: any, only?: 'first' | 'last') => Operation[];
|
|
21
|
-
createListDelete: (oid: ObjectIdentifier, index: number, count?: number) => Operation[];
|
|
22
|
-
createListMoveByRef: (oid: ObjectIdentifier, value: ObjectRef, index: number) => Operation[];
|
|
23
|
-
createListMoveByIndex: (oid: ObjectIdentifier, fromIndex: number, toIndex: number) => Operation[];
|
|
24
|
-
createDelete: (oid: ObjectIdentifier) => Operation[];
|
|
25
|
-
createDeleteAll: (oids: ObjectIdentifier[]) => Operation[];
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* High-level patch creation for use with complex nested objects.
|
|
3
|
+
*/
|
|
4
|
+
import { KeyPath, ObjectIdentifier } from './oids.js';
|
|
5
|
+
import { ObjectRef, Operation, PropertyName } from './operation.js';
|
|
6
|
+
export declare class PatchCreator {
|
|
7
|
+
private getNow;
|
|
8
|
+
private createSubId?;
|
|
9
|
+
constructor(getNow: () => string, createSubId?: (() => string) | undefined);
|
|
10
|
+
createDiff: (from: any, to: any, keyPath: KeyPath, options?: {
|
|
11
|
+
mergeUnknownObjects?: boolean;
|
|
12
|
+
defaultUndefined?: boolean;
|
|
13
|
+
}) => Operation[];
|
|
14
|
+
createInitialize: (obj: any, oid: ObjectIdentifier) => Operation[];
|
|
15
|
+
createSet: (oid: ObjectIdentifier, key: PropertyName, value: any, keyPath: KeyPath) => Operation[];
|
|
16
|
+
createRemove: (oid: ObjectIdentifier, key: PropertyName) => Operation[];
|
|
17
|
+
createListPush: (oid: ObjectIdentifier, value: any) => Operation[];
|
|
18
|
+
createListAdd: (oid: ObjectIdentifier, value: any) => Operation[];
|
|
19
|
+
createListInsert: (oid: ObjectIdentifier, index: number, value: any) => Operation[];
|
|
20
|
+
createListRemove: (oid: ObjectIdentifier, value: any, only?: 'first' | 'last') => Operation[];
|
|
21
|
+
createListDelete: (oid: ObjectIdentifier, index: number, count?: number) => Operation[];
|
|
22
|
+
createListMoveByRef: (oid: ObjectIdentifier, value: ObjectRef, index: number) => Operation[];
|
|
23
|
+
createListMoveByIndex: (oid: ObjectIdentifier, fromIndex: number, toIndex: number) => Operation[];
|
|
24
|
+
createDelete: (oid: ObjectIdentifier) => Operation[];
|
|
25
|
+
createDeleteAll: (oids: ObjectIdentifier[]) => Operation[];
|
|
26
|
+
}
|
package/dist/esm/patch.js
CHANGED
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-level patch creation for use with complex nested objects.
|
|
3
|
-
*/
|
|
4
|
-
import { createRef, createSubOid } from './oids.js';
|
|
5
|
-
import { diffToPatches, initialToPatches, } from './operation.js';
|
|
6
|
-
import { isRef } from './refs.js';
|
|
7
|
-
import { isObject } from './utils.js';
|
|
8
|
-
export class PatchCreator {
|
|
9
|
-
constructor(getNow, createSubId) {
|
|
10
|
-
this.getNow = getNow;
|
|
11
|
-
this.createSubId = createSubId;
|
|
12
|
-
this.createDiff = (from, to, keyPath, options = {}) => {
|
|
13
|
-
return diffToPatches(from, to, this.getNow, keyPath, this.createSubId, [], options);
|
|
14
|
-
};
|
|
15
|
-
this.createInitialize = (obj, oid) => {
|
|
16
|
-
return initialToPatches(obj, oid, this.getNow, this.createSubId);
|
|
17
|
-
};
|
|
18
|
-
this.createSet = (oid, key, value, keyPath) => {
|
|
19
|
-
// incoming value must be normalized. if it's not a primitive, it and all sub-objects
|
|
20
|
-
// must be created
|
|
21
|
-
if (!isObject(value) || isRef(value)) {
|
|
22
|
-
return [
|
|
23
|
-
{
|
|
24
|
-
oid,
|
|
25
|
-
timestamp: this.getNow(),
|
|
26
|
-
data: {
|
|
27
|
-
op: 'set',
|
|
28
|
-
name: key,
|
|
29
|
-
value,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const itemOid = createSubOid(oid, key, this.createSubId);
|
|
36
|
-
return [
|
|
37
|
-
// since we're setting a complex nested object, we can initialize it wholesale.
|
|
38
|
-
// no diffing to do.
|
|
39
|
-
...initialToPatches(value, itemOid, this.getNow),
|
|
40
|
-
// then set the reference to the object
|
|
41
|
-
{
|
|
42
|
-
oid,
|
|
43
|
-
timestamp: this.getNow(),
|
|
44
|
-
data: {
|
|
45
|
-
op: 'set',
|
|
46
|
-
value: createRef(itemOid),
|
|
47
|
-
name: key,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this.createRemove = (oid, key) => {
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
oid,
|
|
57
|
-
timestamp: this.getNow(),
|
|
58
|
-
data: {
|
|
59
|
-
op: 'remove',
|
|
60
|
-
name: key,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
};
|
|
65
|
-
this.createListPush = (oid, value) => {
|
|
66
|
-
if (!isObject(value)) {
|
|
67
|
-
return [
|
|
68
|
-
{
|
|
69
|
-
oid,
|
|
70
|
-
timestamp: this.getNow(),
|
|
71
|
-
data: {
|
|
72
|
-
op: 'list-push',
|
|
73
|
-
value,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const itemOid = createSubOid(oid, 0, this.createSubId);
|
|
80
|
-
return [
|
|
81
|
-
...initialToPatches(value, itemOid, this.getNow),
|
|
82
|
-
{
|
|
83
|
-
oid,
|
|
84
|
-
timestamp: this.getNow(),
|
|
85
|
-
data: {
|
|
86
|
-
op: 'list-push',
|
|
87
|
-
value: createRef(itemOid),
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
this.createListAdd = (oid, value) => {
|
|
94
|
-
if (isObject(value)) {
|
|
95
|
-
return [
|
|
96
|
-
{
|
|
97
|
-
oid,
|
|
98
|
-
timestamp: this.getNow(),
|
|
99
|
-
data: {
|
|
100
|
-
op: 'list-add',
|
|
101
|
-
value: createRef(value),
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return [
|
|
108
|
-
{
|
|
109
|
-
oid,
|
|
110
|
-
timestamp: this.getNow(),
|
|
111
|
-
data: {
|
|
112
|
-
op: 'list-add',
|
|
113
|
-
value,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
];
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
this.createListInsert = (oid, index, value) => {
|
|
120
|
-
if (!isObject(value)) {
|
|
121
|
-
return [
|
|
122
|
-
{
|
|
123
|
-
oid,
|
|
124
|
-
timestamp: this.getNow(),
|
|
125
|
-
data: {
|
|
126
|
-
op: 'list-insert',
|
|
127
|
-
value,
|
|
128
|
-
index,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const itemOid = createSubOid(oid, index, this.createSubId);
|
|
135
|
-
return [
|
|
136
|
-
...initialToPatches(value, itemOid, this.getNow),
|
|
137
|
-
{
|
|
138
|
-
oid,
|
|
139
|
-
timestamp: this.getNow(),
|
|
140
|
-
data: {
|
|
141
|
-
op: 'list-insert',
|
|
142
|
-
value: createRef(itemOid),
|
|
143
|
-
index,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
this.createListRemove = (oid, value, only) => {
|
|
150
|
-
return [
|
|
151
|
-
{
|
|
152
|
-
oid,
|
|
153
|
-
timestamp: this.getNow(),
|
|
154
|
-
data: {
|
|
155
|
-
op: 'list-remove',
|
|
156
|
-
value,
|
|
157
|
-
only,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
};
|
|
162
|
-
this.createListDelete = (oid, index, count = 1) => {
|
|
163
|
-
return [
|
|
164
|
-
{
|
|
165
|
-
oid,
|
|
166
|
-
timestamp: this.getNow(),
|
|
167
|
-
data: {
|
|
168
|
-
op: 'list-delete',
|
|
169
|
-
index,
|
|
170
|
-
count,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
];
|
|
174
|
-
};
|
|
175
|
-
this.createListMoveByRef = (oid, value, index) => {
|
|
176
|
-
return [
|
|
177
|
-
{
|
|
178
|
-
oid,
|
|
179
|
-
timestamp: this.getNow(),
|
|
180
|
-
data: {
|
|
181
|
-
op: 'list-move-by-ref',
|
|
182
|
-
value,
|
|
183
|
-
index,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
];
|
|
187
|
-
};
|
|
188
|
-
this.createListMoveByIndex = (oid, fromIndex, toIndex) => {
|
|
189
|
-
return [
|
|
190
|
-
{
|
|
191
|
-
oid,
|
|
192
|
-
timestamp: this.getNow(),
|
|
193
|
-
data: {
|
|
194
|
-
op: 'list-move-by-index',
|
|
195
|
-
from: fromIndex,
|
|
196
|
-
to: toIndex,
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
];
|
|
200
|
-
};
|
|
201
|
-
this.createDelete = (oid) => {
|
|
202
|
-
return [
|
|
203
|
-
{
|
|
204
|
-
oid,
|
|
205
|
-
timestamp: this.getNow(),
|
|
206
|
-
data: {
|
|
207
|
-
op: 'delete',
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
];
|
|
211
|
-
};
|
|
212
|
-
this.createDeleteAll = (oids) => {
|
|
213
|
-
return oids.map((oid) => ({
|
|
214
|
-
oid,
|
|
215
|
-
timestamp: this.getNow(),
|
|
216
|
-
data: {
|
|
217
|
-
op: 'delete',
|
|
218
|
-
},
|
|
219
|
-
}));
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* High-level patch creation for use with complex nested objects.
|
|
3
|
+
*/
|
|
4
|
+
import { createRef, createSubOid } from './oids.js';
|
|
5
|
+
import { diffToPatches, initialToPatches, } from './operation.js';
|
|
6
|
+
import { isRef } from './refs.js';
|
|
7
|
+
import { isObject } from './utils.js';
|
|
8
|
+
export class PatchCreator {
|
|
9
|
+
constructor(getNow, createSubId) {
|
|
10
|
+
this.getNow = getNow;
|
|
11
|
+
this.createSubId = createSubId;
|
|
12
|
+
this.createDiff = (from, to, keyPath, options = {}) => {
|
|
13
|
+
return diffToPatches(from, to, this.getNow, keyPath, this.createSubId, [], options);
|
|
14
|
+
};
|
|
15
|
+
this.createInitialize = (obj, oid) => {
|
|
16
|
+
return initialToPatches(obj, oid, this.getNow, this.createSubId);
|
|
17
|
+
};
|
|
18
|
+
this.createSet = (oid, key, value, keyPath) => {
|
|
19
|
+
// incoming value must be normalized. if it's not a primitive, it and all sub-objects
|
|
20
|
+
// must be created
|
|
21
|
+
if (!isObject(value) || isRef(value)) {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
oid,
|
|
25
|
+
timestamp: this.getNow(),
|
|
26
|
+
data: {
|
|
27
|
+
op: 'set',
|
|
28
|
+
name: key,
|
|
29
|
+
value,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const itemOid = createSubOid(oid, key, this.createSubId);
|
|
36
|
+
return [
|
|
37
|
+
// since we're setting a complex nested object, we can initialize it wholesale.
|
|
38
|
+
// no diffing to do.
|
|
39
|
+
...initialToPatches(value, itemOid, this.getNow),
|
|
40
|
+
// then set the reference to the object
|
|
41
|
+
{
|
|
42
|
+
oid,
|
|
43
|
+
timestamp: this.getNow(),
|
|
44
|
+
data: {
|
|
45
|
+
op: 'set',
|
|
46
|
+
value: createRef(itemOid),
|
|
47
|
+
name: key,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.createRemove = (oid, key) => {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
oid,
|
|
57
|
+
timestamp: this.getNow(),
|
|
58
|
+
data: {
|
|
59
|
+
op: 'remove',
|
|
60
|
+
name: key,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
};
|
|
65
|
+
this.createListPush = (oid, value) => {
|
|
66
|
+
if (!isObject(value)) {
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
oid,
|
|
70
|
+
timestamp: this.getNow(),
|
|
71
|
+
data: {
|
|
72
|
+
op: 'list-push',
|
|
73
|
+
value,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const itemOid = createSubOid(oid, 0, this.createSubId);
|
|
80
|
+
return [
|
|
81
|
+
...initialToPatches(value, itemOid, this.getNow),
|
|
82
|
+
{
|
|
83
|
+
oid,
|
|
84
|
+
timestamp: this.getNow(),
|
|
85
|
+
data: {
|
|
86
|
+
op: 'list-push',
|
|
87
|
+
value: createRef(itemOid),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
this.createListAdd = (oid, value) => {
|
|
94
|
+
if (isObject(value)) {
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
oid,
|
|
98
|
+
timestamp: this.getNow(),
|
|
99
|
+
data: {
|
|
100
|
+
op: 'list-add',
|
|
101
|
+
value: createRef(value),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
oid,
|
|
110
|
+
timestamp: this.getNow(),
|
|
111
|
+
data: {
|
|
112
|
+
op: 'list-add',
|
|
113
|
+
value,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
this.createListInsert = (oid, index, value) => {
|
|
120
|
+
if (!isObject(value)) {
|
|
121
|
+
return [
|
|
122
|
+
{
|
|
123
|
+
oid,
|
|
124
|
+
timestamp: this.getNow(),
|
|
125
|
+
data: {
|
|
126
|
+
op: 'list-insert',
|
|
127
|
+
value,
|
|
128
|
+
index,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const itemOid = createSubOid(oid, index, this.createSubId);
|
|
135
|
+
return [
|
|
136
|
+
...initialToPatches(value, itemOid, this.getNow),
|
|
137
|
+
{
|
|
138
|
+
oid,
|
|
139
|
+
timestamp: this.getNow(),
|
|
140
|
+
data: {
|
|
141
|
+
op: 'list-insert',
|
|
142
|
+
value: createRef(itemOid),
|
|
143
|
+
index,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
this.createListRemove = (oid, value, only) => {
|
|
150
|
+
return [
|
|
151
|
+
{
|
|
152
|
+
oid,
|
|
153
|
+
timestamp: this.getNow(),
|
|
154
|
+
data: {
|
|
155
|
+
op: 'list-remove',
|
|
156
|
+
value,
|
|
157
|
+
only,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
};
|
|
162
|
+
this.createListDelete = (oid, index, count = 1) => {
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
oid,
|
|
166
|
+
timestamp: this.getNow(),
|
|
167
|
+
data: {
|
|
168
|
+
op: 'list-delete',
|
|
169
|
+
index,
|
|
170
|
+
count,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
};
|
|
175
|
+
this.createListMoveByRef = (oid, value, index) => {
|
|
176
|
+
return [
|
|
177
|
+
{
|
|
178
|
+
oid,
|
|
179
|
+
timestamp: this.getNow(),
|
|
180
|
+
data: {
|
|
181
|
+
op: 'list-move-by-ref',
|
|
182
|
+
value,
|
|
183
|
+
index,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
};
|
|
188
|
+
this.createListMoveByIndex = (oid, fromIndex, toIndex) => {
|
|
189
|
+
return [
|
|
190
|
+
{
|
|
191
|
+
oid,
|
|
192
|
+
timestamp: this.getNow(),
|
|
193
|
+
data: {
|
|
194
|
+
op: 'list-move-by-index',
|
|
195
|
+
from: fromIndex,
|
|
196
|
+
to: toIndex,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
};
|
|
201
|
+
this.createDelete = (oid) => {
|
|
202
|
+
return [
|
|
203
|
+
{
|
|
204
|
+
oid,
|
|
205
|
+
timestamp: this.getNow(),
|
|
206
|
+
data: {
|
|
207
|
+
op: 'delete',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
};
|
|
212
|
+
this.createDeleteAll = (oids) => {
|
|
213
|
+
return oids.map((oid) => ({
|
|
214
|
+
oid,
|
|
215
|
+
timestamp: this.getNow(),
|
|
216
|
+
data: {
|
|
217
|
+
op: 'delete',
|
|
218
|
+
},
|
|
219
|
+
}));
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
223
|
//# sourceMappingURL=patch.js.map
|
package/dist/esm/presence.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export interface UserInfo<Profile, Presence> {
|
|
2
|
-
/**
|
|
3
|
-
* This is the ID representing the user who is utilizing a
|
|
4
|
-
* replica client to connect to the storage network.
|
|
5
|
-
* One user may have multiple replica clients active at once,
|
|
6
|
-
* but their presence will only reflect the most recent
|
|
7
|
-
* replica used.
|
|
8
|
-
*/
|
|
9
|
-
id: string;
|
|
10
|
-
/**
|
|
11
|
-
* This is the ID representing the replica client that is
|
|
12
|
-
* connected to the storage network. This is used to
|
|
13
|
-
* identify the client when sending messages to it.
|
|
14
|
-
*/
|
|
15
|
-
replicaId: string;
|
|
16
|
-
/**
|
|
17
|
-
* This is the user's server profile. This data is associated
|
|
18
|
-
* with the logged in user of the app and cannot be modified
|
|
19
|
-
* by the local replica directly.
|
|
20
|
-
*/
|
|
21
|
-
profile: Profile;
|
|
22
|
-
/**
|
|
23
|
-
* Presence info which can update frequently as a replica
|
|
24
|
-
* makes changes. The shape of presence is up to you.
|
|
25
|
-
*/
|
|
26
|
-
presence: Presence;
|
|
27
|
-
}
|
|
1
|
+
export interface UserInfo<Profile, Presence> {
|
|
2
|
+
/**
|
|
3
|
+
* This is the ID representing the user who is utilizing a
|
|
4
|
+
* replica client to connect to the storage network.
|
|
5
|
+
* One user may have multiple replica clients active at once,
|
|
6
|
+
* but their presence will only reflect the most recent
|
|
7
|
+
* replica used.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* This is the ID representing the replica client that is
|
|
12
|
+
* connected to the storage network. This is used to
|
|
13
|
+
* identify the client when sending messages to it.
|
|
14
|
+
*/
|
|
15
|
+
replicaId: string;
|
|
16
|
+
/**
|
|
17
|
+
* This is the user's server profile. This data is associated
|
|
18
|
+
* with the logged in user of the app and cannot be modified
|
|
19
|
+
* by the local replica directly.
|
|
20
|
+
*/
|
|
21
|
+
profile: Profile;
|
|
22
|
+
/**
|
|
23
|
+
* Presence info which can update frequently as a replica
|
|
24
|
+
* makes changes. The shape of presence is up to you.
|
|
25
|
+
*/
|
|
26
|
+
presence: Presence;
|
|
27
|
+
}
|
package/dist/esm/presence.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=presence.js.map
|