@iebh/tera-fy 2.3.1 → 2.3.3
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/.vscode/settings.json +5 -0
- package/CHANGELOG.md +15 -0
- package/api.md +34 -35
- package/dist/lib/projectFile.d.ts +3 -3
- package/dist/lib/projectFile.js +4 -3
- package/dist/lib/projectFile.js.map +1 -1
- package/dist/lib/syncro/entities.js +11 -10
- package/dist/lib/syncro/entities.js.map +1 -1
- package/dist/lib/syncro/keyed.d.ts +2 -2
- package/dist/lib/syncro/keyed.js +23 -23
- package/dist/lib/syncro/keyed.js.map +1 -1
- package/dist/lib/syncro/syncro.d.ts +15 -13
- package/dist/lib/syncro/syncro.js +84 -59
- package/dist/lib/syncro/syncro.js.map +1 -1
- package/dist/lib/terafy.bootstrapper.d.ts +2 -2
- package/dist/lib/terafy.bootstrapper.js +15 -16
- package/dist/lib/terafy.bootstrapper.js.map +1 -1
- package/dist/lib/terafy.client.d.ts +24 -25
- package/dist/lib/terafy.client.js +50 -48
- package/dist/lib/terafy.client.js.map +1 -1
- package/dist/lib/terafy.proxy.js +4 -2
- package/dist/lib/terafy.proxy.js.map +1 -1
- package/dist/lib/terafy.server.d.ts +21 -7
- package/dist/lib/terafy.server.js +51 -53
- package/dist/lib/terafy.server.js.map +1 -1
- package/dist/plugin.vue2.es2019.js +210 -1224
- package/dist/plugins/base.d.ts +2 -2
- package/dist/plugins/base.js +1 -0
- package/dist/plugins/base.js.map +1 -1
- package/dist/plugins/firebase.d.ts +4 -4
- package/dist/plugins/firebase.js +7 -7
- package/dist/plugins/firebase.js.map +1 -1
- package/dist/plugins/vue2.d.ts +1 -1
- package/dist/plugins/vue2.js +6 -5
- package/dist/plugins/vue2.js.map +1 -1
- package/dist/plugins/vue3.js +6 -5
- package/dist/plugins/vue3.js.map +1 -1
- package/dist/terafy.bootstrapper.es2019.js +2 -2
- package/dist/terafy.bootstrapper.js +2 -2
- package/dist/terafy.es2019.js +2 -2
- package/dist/terafy.js +2 -2
- package/dist/utils/mixin.js +1 -1
- package/dist/utils/mixin.js.map +1 -1
- package/dist/utils/pDefer.d.ts +5 -1
- package/dist/utils/pDefer.js +6 -1
- package/dist/utils/pDefer.js.map +1 -1
- package/dist/utils/pathTools.d.ts +1 -1
- package/dist/utils/pathTools.js +2 -2
- package/dist/utils/pathTools.js.map +1 -1
- package/eslint.config.js +21 -10
- package/lib/projectFile.ts +5 -4
- package/lib/syncro/entities.ts +11 -10
- package/lib/syncro/keyed.ts +24 -24
- package/lib/syncro/syncro.ts +98 -61
- package/lib/terafy.bootstrapper.ts +15 -16
- package/lib/terafy.client.ts +64 -61
- package/lib/terafy.proxy.ts +8 -5
- package/lib/terafy.server.ts +81 -59
- package/package.json +23 -21
- package/plugins/base.ts +3 -2
- package/plugins/firebase.ts +12 -11
- package/plugins/vue2.ts +7 -6
- package/plugins/vue3.ts +6 -5
- package/utils/mixin.ts +1 -1
- package/utils/pDefer.ts +7 -2
- package/utils/pathTools.ts +3 -3
package/dist/lib/syncro/keyed.js
CHANGED
|
@@ -5,7 +5,7 @@ import SyncroEntities from './entities.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* @class SyncroKeyed
|
|
7
7
|
* TERA Isomorphic SyncroKeyed class
|
|
8
|
-
* Collate a single (
|
|
8
|
+
* Collate a single (potentially very large) single Syncro object by splitting it across multiple Syncros
|
|
9
9
|
* This makes the assumption that the Syncro content is a large object collection of objects - a keyed map collection
|
|
10
10
|
* The original impetus is to allow TERA citation libraries to be held in a Syncro object and flushed back to Supabase when editing has completed
|
|
11
11
|
*/
|
|
@@ -43,7 +43,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
43
43
|
this.members = [];
|
|
44
44
|
if (!/\*/.test(path))
|
|
45
45
|
throw new Error('SyncroKeyed paths must contain at least one asterisk as an object pagination indicator');
|
|
46
|
-
|
|
46
|
+
const { prefix, suffix } = /^(?<prefix>.+)\*(?<suffix>.*)$/.exec(path).groups;
|
|
47
47
|
this.keyedPath.getKey = (path, index) => `${prefix}${index}${suffix}`;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
@@ -65,15 +65,15 @@ export default class SyncroKeyed extends Syncro {
|
|
|
65
65
|
*/
|
|
66
66
|
mount() {
|
|
67
67
|
// Cast the result to the expected interface
|
|
68
|
-
|
|
68
|
+
const { entity, id, relation, fsCollection, fsId } = Syncro.pathSplit(this.path, { allowAsterisk: true });
|
|
69
69
|
return Promise.resolve()
|
|
70
70
|
.then(() => new Promise(resolve => {
|
|
71
71
|
this.members = []; // Reset member list
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const seekMember = async (index) => {
|
|
73
|
+
const memberId = fsId.replace('*', '' + index);
|
|
74
74
|
this.debug('Seek keyedMember', fsCollection, '#', memberId);
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const docRef = FirestoreDocRef(Syncro.firestore, fsCollection, memberId);
|
|
76
|
+
const doc = await FirestoreGetDoc(docRef);
|
|
77
77
|
if (doc.exists()) { // Found a matching entry
|
|
78
78
|
// Expand member lookup with the new member by its numeric index
|
|
79
79
|
await this.keyedMembersExpand(index);
|
|
@@ -97,14 +97,14 @@ export default class SyncroKeyed extends Syncro {
|
|
|
97
97
|
if (!SyncroEntities[entityKey])
|
|
98
98
|
throw new Error(`Unknown Sync entity "${entity}"`);
|
|
99
99
|
// Go fetch the initial state object
|
|
100
|
-
|
|
100
|
+
const state = await SyncroEntities[entityKey].initState({
|
|
101
101
|
supabasey: Syncro.supabasey,
|
|
102
102
|
id, relation,
|
|
103
103
|
});
|
|
104
104
|
await this.keyedAssign(state);
|
|
105
105
|
})
|
|
106
106
|
.then(() => {
|
|
107
|
-
|
|
107
|
+
const reactive = this.getReactive(this.proxy());
|
|
108
108
|
// Assuming this.value should hold the reactive proxy
|
|
109
109
|
// If this.value is inherited and has a specific type, this might need adjustment
|
|
110
110
|
this.value = reactive.doc;
|
|
@@ -129,13 +129,13 @@ export default class SyncroKeyed extends Syncro {
|
|
|
129
129
|
},
|
|
130
130
|
// Scope through members until we get a hit on the key
|
|
131
131
|
get(target, prop) {
|
|
132
|
-
|
|
132
|
+
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
133
133
|
// Access value via targetMember.value if found
|
|
134
134
|
return targetMember ? targetMember.value[prop] : undefined;
|
|
135
135
|
},
|
|
136
136
|
// Set the member key if one already exists, otherwise overflow onto the next member
|
|
137
137
|
set(target, prop, value) {
|
|
138
|
-
|
|
138
|
+
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
139
139
|
if (targetMember && targetMember.value) {
|
|
140
140
|
targetMember.value[prop] = value;
|
|
141
141
|
}
|
|
@@ -147,7 +147,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
147
147
|
},
|
|
148
148
|
// Remove a key
|
|
149
149
|
deleteProperty(target, prop) {
|
|
150
|
-
|
|
150
|
+
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
151
151
|
if (targetMember && targetMember.value) {
|
|
152
152
|
delete targetMember.value[prop];
|
|
153
153
|
return true; // Indicate success
|
|
@@ -165,7 +165,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
165
165
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
166
166
|
*/
|
|
167
167
|
async flush(options) {
|
|
168
|
-
|
|
168
|
+
const settings = {
|
|
169
169
|
destroy: false,
|
|
170
170
|
...options,
|
|
171
171
|
};
|
|
@@ -186,7 +186,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
186
186
|
* @returns {Promise<*>} A promise which resolves when the operation has completed with the set value
|
|
187
187
|
*/
|
|
188
188
|
async keyedSet(key, value) {
|
|
189
|
-
|
|
189
|
+
const candidateMember = this.members.find(m => m.value && Object.keys(m.value).length < this.keyedConfig.maxKeys);
|
|
190
190
|
if (candidateMember?.value) {
|
|
191
191
|
candidateMember.value[key] = value;
|
|
192
192
|
return value;
|
|
@@ -195,8 +195,8 @@ export default class SyncroKeyed extends Syncro {
|
|
|
195
195
|
// Extend members
|
|
196
196
|
await this.keyedMembersExpand(); // Call without index to append
|
|
197
197
|
// Get the newly added member
|
|
198
|
-
//
|
|
199
|
-
|
|
198
|
+
// eslint-disable-next-line unicorn/prefer-at
|
|
199
|
+
const newMember = this.members[this.members.length - 1];
|
|
200
200
|
if (!newMember || !newMember.value) {
|
|
201
201
|
throw new Error('Failed to expand members or new member has no value object');
|
|
202
202
|
}
|
|
@@ -210,7 +210,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
212
|
* Assign an entire in-memory object to members
|
|
213
|
-
* This can be thought of as the optimized
|
|
213
|
+
* This can be thought of as the optimized equivalent of Object.assign()
|
|
214
214
|
* Use this when merging large objects as it can make optimizations
|
|
215
215
|
*
|
|
216
216
|
* @param {Object} state The value to merge
|
|
@@ -218,9 +218,9 @@ export default class SyncroKeyed extends Syncro {
|
|
|
218
218
|
async keyedAssign(state) {
|
|
219
219
|
// Can we assume we have a blank state - this speeds up existing key checks significantly
|
|
220
220
|
// Ensure members[0] and its value exist
|
|
221
|
-
|
|
221
|
+
const isBlank = this.members.length === 1 && this.members[0]?.value && Object.keys(this.members[0].value).length === 0;
|
|
222
222
|
if (isBlank) {
|
|
223
|
-
|
|
223
|
+
const chunks = chunk(Object.entries(state), this.keyedConfig.maxKeys)
|
|
224
224
|
.map(chunk => Object.fromEntries(chunk));
|
|
225
225
|
await Promise.all(chunks.map(async (chunk, chunkIndex) => {
|
|
226
226
|
this.debug(`Assign chunk #${chunkIndex} content`, { chunk });
|
|
@@ -262,18 +262,18 @@ export default class SyncroKeyed extends Syncro {
|
|
|
262
262
|
}
|
|
263
263
|
return; // Exit if member already exists
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
const syncroPath = this.keyedPath.getKey(this.path, index);
|
|
266
266
|
// Pass empty options object {} or specify allowAsterisk: false if needed
|
|
267
|
-
|
|
267
|
+
const { fsCollection, fsId } = Syncro.pathSplit(syncroPath, {});
|
|
268
268
|
this.debug('Expand SyncroKeyed size to index=', index);
|
|
269
269
|
// Create a new Syncro member, inheriteing some details from this parent item
|
|
270
|
-
|
|
270
|
+
const syncro = new Syncro(`${fsCollection}::${fsId}`, {
|
|
271
271
|
debug: this.debug,
|
|
272
272
|
getReactive: this.getReactive,
|
|
273
273
|
});
|
|
274
274
|
// Wait for mount to complete
|
|
275
275
|
await syncro.mount({
|
|
276
|
-
initialState: {}, // Force
|
|
276
|
+
initialState: {}, // Force initial state to empty object so we don't get stuck in a loop
|
|
277
277
|
});
|
|
278
278
|
// Insert at the correct index if specified, otherwise push
|
|
279
279
|
if (index < this.members.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed.js","sourceRoot":"","sources":["../../../lib/syncro/keyed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAC;AAChC,OAAO,EAAC,GAAG,IAAI,eAAe,EAAE,MAAM,IAAI,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACrF,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,cAAc,MAAM,eAAe,CAAC;AAgB3C;;;;;;EAME;AACF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IA+B9C;;;;;MAKE;IACF,YAAY,IAAY,EAAE,OAA6B;QACtD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QApCtB;;;;;UAKE;QACF,gBAAW,GAAG;YACb,OAAO,EAAE,CAAC;SACV,CAAC;QAGF;;UAEE;QACF,cAAS,GAAG;YACX,MAAM,CAAC,IAAY,EAAE,KAAa;gBACjC,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC;YAC3B,CAAC;SACD,CAAC;QAGF;;;;UAIE;QACF,YAAO,GAAa,EAAE,CAAC;QAYtB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;QAEhI,
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C,IAAI,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACR,CAAC;CAED"}
|
|
@@ -47,7 +47,7 @@ export default class Syncro {
|
|
|
47
47
|
*/
|
|
48
48
|
static session: string | undefined;
|
|
49
49
|
/**
|
|
50
|
-
* OPTIONAL
|
|
50
|
+
* OPTIONAL SyncroEntries from './entities.ts' if its required
|
|
51
51
|
* This only gets populated if `config.forceLocalInit` is truthy and we've mounted at least one Syncro
|
|
52
52
|
*
|
|
53
53
|
* @type {Record<string, any>}
|
|
@@ -82,7 +82,7 @@ export default class Syncro {
|
|
|
82
82
|
* Various Misc config for the Syncro instance
|
|
83
83
|
*
|
|
84
84
|
* @type {Object}
|
|
85
|
-
* @property {Number}
|
|
85
|
+
* @property {Number} heartbeatInterval Time in milliseconds between heartbeat beacons
|
|
86
86
|
* @property {String} syncroRegistryUrl The prefix Sync worker URL, used to populate Syncros and determine their active status
|
|
87
87
|
* @property {Object} context Additional named parameters to pass to callbacks like initState
|
|
88
88
|
*/
|
|
@@ -93,7 +93,7 @@ export default class Syncro {
|
|
|
93
93
|
};
|
|
94
94
|
/**
|
|
95
95
|
* Whether the next heartbeat should be marked as 'dirty'
|
|
96
|
-
* This indicates that at least one change has
|
|
96
|
+
* This indicates that at least one change has occurred since the last heartbeat and the server should perform a flush (but not a clean)
|
|
97
97
|
* This flag is only transmitted once in the next heartbeat before being reset
|
|
98
98
|
*
|
|
99
99
|
* @see markDirty()
|
|
@@ -134,12 +134,12 @@ export default class Syncro {
|
|
|
134
134
|
* Actions to preform when we are destroying this instance
|
|
135
135
|
* This is an array of function callbacks to execute in parallel when `destroy()` is called
|
|
136
136
|
*
|
|
137
|
-
* @type {Array<
|
|
137
|
+
* @type {Array<function>}
|
|
138
138
|
*/
|
|
139
139
|
_destroyActions: Array<() => void>;
|
|
140
140
|
/**
|
|
141
141
|
* Function to return whatever the local framework uses as a reactive object
|
|
142
|
-
* This should respond with an object of mandatory functions to watch for changes and
|
|
142
|
+
* This should respond with an object of mandatory functions to watch for changes and re-merge them
|
|
143
143
|
*
|
|
144
144
|
* @param {Object} value Initial value of the reactive
|
|
145
145
|
*
|
|
@@ -152,7 +152,7 @@ export default class Syncro {
|
|
|
152
152
|
getReactive(value: any): ReactiveWrapper;
|
|
153
153
|
/**
|
|
154
154
|
* Returns the split entity + ID relationship from a given session path
|
|
155
|
-
* This
|
|
155
|
+
* This function checks for valid UUID format strings + that the entity is a known/supported entity (see `knownEntities`)
|
|
156
156
|
* NOTE: When used by itself (i.e. ignoring response) this function can also act as a guard that a path is valid
|
|
157
157
|
*
|
|
158
158
|
* INPUT: `widgets::UUID` -> `{entity:'widgets', id:UUID}`
|
|
@@ -170,7 +170,7 @@ export default class Syncro {
|
|
|
170
170
|
* This applies the following mutations to the incoming object:
|
|
171
171
|
*
|
|
172
172
|
* 1. Arrays are converted to Objects (Firestore cannot store nested arrays)
|
|
173
|
-
* 2. All non-POJO objects (e.g. Dates) to a
|
|
173
|
+
* 2. All non-POJO objects (e.g. Dates) to a symmetric object
|
|
174
174
|
*
|
|
175
175
|
* @param {Object} snapshot The current state to convert
|
|
176
176
|
* @returns {Object} A Firebase compatible object
|
|
@@ -211,7 +211,7 @@ export default class Syncro {
|
|
|
211
211
|
*
|
|
212
212
|
* @returns {Promise<Object|Null>} An eventual snapshot of the given path, if the entity doesn't exist null is returned
|
|
213
213
|
*/
|
|
214
|
-
static getSnapshot(path: string): Promise<
|
|
214
|
+
static getSnapshot(path: string): Promise<object | null>;
|
|
215
215
|
/**
|
|
216
216
|
* Perform a one-off set/merge operation against
|
|
217
217
|
*
|
|
@@ -230,7 +230,7 @@ export default class Syncro {
|
|
|
230
230
|
* Mount the remote Firestore document against this Syncro instance
|
|
231
231
|
*
|
|
232
232
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
233
|
-
* @param {Object} [options.
|
|
233
|
+
* @param {Object} [options.initialState] State to use if no state is already loaded, overrides the entities own `initState` function fetcher
|
|
234
234
|
* @param {Number} [options.retries=3] Number of times to retry if a mounted Syncro fails its sanity checks
|
|
235
235
|
* @returns {Promise<Syncro>} A promise which resolves as this syncro instance when completed
|
|
236
236
|
*/
|
|
@@ -260,14 +260,15 @@ export default class Syncro {
|
|
|
260
260
|
* Schedule Syncro heartbeats
|
|
261
261
|
* This populates the `sync` presence meta-information
|
|
262
262
|
*
|
|
263
|
-
* @param {Boolean} [enable=true] Whether to enable
|
|
263
|
+
* @param {Boolean} [enable=true] Whether to enable heartbeats
|
|
264
264
|
*
|
|
265
265
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
266
266
|
* @param {Boolean} [options.immediate=false] Fire a heartbeat as soon as this function is called, this is only really useful on mount
|
|
267
|
+
* @returns Promise that resolves to void or void
|
|
267
268
|
*/
|
|
268
269
|
setHeartbeat(enable?: boolean, options?: any): Promise<void> | void;
|
|
269
270
|
/**
|
|
270
|
-
* Perform one heartbeat pulse to the server to indicate
|
|
271
|
+
* Perform one heartbeat pulse to the server to indicate presence within this Syncro
|
|
271
272
|
* This function is automatically called by a timer if `setHeartbeat(true)` (the default behaviour)
|
|
272
273
|
*
|
|
273
274
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
@@ -280,6 +281,7 @@ export default class Syncro {
|
|
|
280
281
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
281
282
|
* @param {'merge'|'set'} [options.method='merge'] How to apply the new state. 'merge' (merge in partial data to an existing Syncro), 'set' (overwrite the entire Syncro state)
|
|
282
283
|
*
|
|
284
|
+
* @param {number} retries How many tries to take before erroring
|
|
283
285
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
284
286
|
*/
|
|
285
287
|
setFirestoreState(state: any, options?: {
|
|
@@ -318,11 +320,11 @@ export default class Syncro {
|
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
322
|
* Build a chaotic random tree structure based on dice rolls
|
|
321
|
-
* This
|
|
323
|
+
* This function is mainly used for sync testing
|
|
322
324
|
*
|
|
323
325
|
* @param {Number} [depth=0] The current depth we are starting at, changes the nature of branches based on probability
|
|
324
326
|
*
|
|
325
|
-
* @returns {*} The current branch
|
|
327
|
+
* @returns {*} The current branch contents
|
|
326
328
|
*/
|
|
327
329
|
export declare function randomBranch(depth?: number): any;
|
|
328
330
|
export {};
|