@iebh/tera-fy 2.3.11 → 2.3.12
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/CHANGELOG.md +25 -0
- package/api.md +8 -11
- package/dist/plugin.vue2.es2019.js +7 -7
- package/dist/terafy.bootstrapper.es2019.js +2 -2
- package/dist/terafy.bootstrapper.js +2 -2
- package/dist/terafy.es2019.js +5 -5
- package/dist/terafy.js +5 -5
- package/eslint.config.js +4 -66
- package/lib/{projectFile.ts → projectFile.js} +52 -76
- package/lib/syncro/{entities.ts → entities.js} +14 -83
- package/lib/syncro/{keyed.ts → keyed.js} +46 -68
- package/lib/syncro/{syncro.ts → syncro.js} +104 -136
- package/lib/{terafy.bootstrapper.ts → terafy.bootstrapper.js} +20 -30
- package/lib/{terafy.client.ts → terafy.client.js} +85 -84
- package/lib/{terafy.proxy.ts → terafy.proxy.js} +12 -26
- package/lib/{terafy.server.ts → terafy.server.js} +204 -229
- package/package.json +20 -39
- package/plugins/{base.ts → base.js} +3 -5
- package/plugins/{firebase.ts → firebase.js} +22 -21
- package/plugins/{vite.ts → vite.js} +3 -3
- package/plugins/{vue2.ts → vue2.js} +8 -10
- package/plugins/{vue3.ts → vue3.js} +7 -10
- package/utils/mixin.js +15 -0
- package/utils/{pathTools.ts → pathTools.js} +8 -9
- package/widgets/tera-file-select.vue +1 -1
- package/dist/lib/projectFile.d.ts +0 -190
- package/dist/lib/projectFile.js +0 -305
- package/dist/lib/projectFile.js.map +0 -1
- package/dist/lib/syncro/entities.d.ts +0 -34
- package/dist/lib/syncro/entities.js +0 -212
- package/dist/lib/syncro/entities.js.map +0 -1
- package/dist/lib/syncro/keyed (Rhino's conflicted copy 2026-05-10).js +0 -287
- package/dist/lib/syncro/keyed.d.ts +0 -95
- package/dist/lib/syncro/keyed.js +0 -288
- package/dist/lib/syncro/keyed.js (Rhino's conflicted copy 2026-05-10).map +0 -1
- package/dist/lib/syncro/keyed.js.map +0 -1
- package/dist/lib/syncro/syncro (Rhino's conflicted copy 2026-05-10).js +0 -765
- package/dist/lib/syncro/syncro.d (Rhino's conflicted copy 2026-05-10).ts +0 -336
- package/dist/lib/syncro/syncro.d.ts +0 -343
- package/dist/lib/syncro/syncro.js +0 -771
- package/dist/lib/syncro/syncro.js (Rhino's conflicted copy 2026-05-10).map +0 -1
- package/dist/lib/syncro/syncro.js.map +0 -1
- package/dist/lib/terafy.bootstrapper.d.ts +0 -42
- package/dist/lib/terafy.bootstrapper.js +0 -129
- package/dist/lib/terafy.bootstrapper.js.map +0 -1
- package/dist/lib/terafy.client.d.ts +0 -555
- package/dist/lib/terafy.client.js +0 -1153
- package/dist/lib/terafy.client.js.map +0 -1
- package/dist/lib/terafy.proxy.d.ts +0 -66
- package/dist/lib/terafy.proxy.js +0 -130
- package/dist/lib/terafy.proxy.js.map +0 -1
- package/dist/lib/terafy.server.d.ts +0 -697
- package/dist/lib/terafy.server.js +0 -2062
- package/dist/lib/terafy.server.js.map +0 -1
- package/dist/plugin.vue2.es2019 (Rhino's conflicted copy 2026-05-10).js +0 -1271
- package/dist/plugins/base.d.ts +0 -20
- package/dist/plugins/base.js +0 -22
- package/dist/plugins/base.js.map +0 -1
- package/dist/plugins/firebase.d.ts +0 -62
- package/dist/plugins/firebase.js +0 -123
- package/dist/plugins/firebase.js.map +0 -1
- package/dist/plugins/vite.d.ts +0 -12
- package/dist/plugins/vite.js +0 -22
- package/dist/plugins/vite.js.map +0 -1
- package/dist/plugins/vue2.d.ts +0 -67
- package/dist/plugins/vue2.js +0 -104
- package/dist/plugins/vue2.js.map +0 -1
- package/dist/plugins/vue3.d.ts +0 -63
- package/dist/plugins/vue3.js +0 -93
- package/dist/plugins/vue3.js.map +0 -1
- package/dist/utils/mixin.d.ts +0 -11
- package/dist/utils/mixin.js +0 -15
- package/dist/utils/mixin.js.map +0 -1
- package/dist/utils/pDefer.d.ts +0 -16
- package/dist/utils/pDefer.js +0 -19
- package/dist/utils/pDefer.js.map +0 -1
- package/dist/utils/pathTools.d.ts +0 -70
- package/dist/utils/pathTools.js +0 -120
- package/dist/utils/pathTools.js.map +0 -1
- package/tsconfig.json +0 -30
- package/utils/mixin.ts +0 -18
- package/utils/pDefer.ts +0 -27
|
@@ -3,19 +3,6 @@ import {doc as FirestoreDocRef, getDoc as FirestoreGetDoc} from 'firebase/firest
|
|
|
3
3
|
import Syncro from './syncro.js';
|
|
4
4
|
import SyncroEntities from './entities.js';
|
|
5
5
|
|
|
6
|
-
// Define a basic structure for what pathSplit should return
|
|
7
|
-
interface PathSplitResult {
|
|
8
|
-
entity: string;
|
|
9
|
-
id: string;
|
|
10
|
-
relation?: string; // Making relation optional
|
|
11
|
-
fsCollection: string;
|
|
12
|
-
fsId: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Define a structure for options passed to flush
|
|
16
|
-
interface FlushOptions {
|
|
17
|
-
destroy?: boolean;
|
|
18
|
-
}
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* @class SyncroKeyed
|
|
@@ -41,7 +28,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
41
28
|
* Various storage about keyed path
|
|
42
29
|
*/
|
|
43
30
|
keyedPath = {
|
|
44
|
-
getKey(path
|
|
31
|
+
getKey(path, index) {
|
|
45
32
|
return path + '_' + index;
|
|
46
33
|
},
|
|
47
34
|
};
|
|
@@ -52,7 +39,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
52
39
|
*
|
|
53
40
|
* @type {Array<Syncro>}
|
|
54
41
|
*/
|
|
55
|
-
members
|
|
42
|
+
members = [];
|
|
56
43
|
|
|
57
44
|
|
|
58
45
|
/**
|
|
@@ -61,13 +48,13 @@ export default class SyncroKeyed extends Syncro {
|
|
|
61
48
|
* @param {String} path Mount path for the Syncro. Should be in the form `${ENTITY}::${ID}(::${RELATION})?_*` (must contain a '*' operator)
|
|
62
49
|
* @param {Object} [options] Additional instance setters (mutates instance directly)
|
|
63
50
|
*/
|
|
64
|
-
constructor(path
|
|
51
|
+
constructor(path, options) {
|
|
65
52
|
super(path, options);
|
|
66
53
|
|
|
67
54
|
if (!/\*/.test(path)) throw new Error('SyncroKeyed paths must contain at least one asterisk as an object pagination indicator');
|
|
68
55
|
|
|
69
|
-
const {prefix, suffix} = /^(?<prefix>.+)\*(?<suffix>.*)$/.exec(path)
|
|
70
|
-
this.keyedPath.getKey = (path
|
|
56
|
+
const {prefix, suffix} = /^(?<prefix>.+)\*(?<suffix>.*)$/.exec(path).groups;
|
|
57
|
+
this.keyedPath.getKey = (path, index) => `${prefix}${index}${suffix}`;
|
|
71
58
|
}
|
|
72
59
|
|
|
73
60
|
|
|
@@ -76,7 +63,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
76
63
|
*
|
|
77
64
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
78
65
|
*/
|
|
79
|
-
async destroy()
|
|
66
|
+
async destroy() {
|
|
80
67
|
this.debug('Destroy!');
|
|
81
68
|
await Promise.all(
|
|
82
69
|
this.members.map(member =>
|
|
@@ -85,7 +72,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
85
72
|
);
|
|
86
73
|
|
|
87
74
|
this.members = [];
|
|
88
|
-
return []
|
|
75
|
+
return [];
|
|
89
76
|
}
|
|
90
77
|
|
|
91
78
|
|
|
@@ -95,15 +82,14 @@ export default class SyncroKeyed extends Syncro {
|
|
|
95
82
|
*
|
|
96
83
|
* @returns {Promise<Syncro>} A promise which resolves as this SyncroKeyed instance when completed
|
|
97
84
|
*/
|
|
98
|
-
mount()
|
|
99
|
-
|
|
100
|
-
const {entity, id, relation, fsCollection, fsId} = Syncro.pathSplit(this.path, {allowAsterisk: true}) as PathSplitResult;
|
|
85
|
+
mount() {
|
|
86
|
+
const {entity, id, relation, fsCollection, fsId} = Syncro.pathSplit(this.path, {allowAsterisk: true});
|
|
101
87
|
|
|
102
88
|
return Promise.resolve()
|
|
103
|
-
.then(()=> new Promise
|
|
89
|
+
.then(()=> new Promise(resolve => { // Mount all members by looking for similar keys
|
|
104
90
|
this.members = []; // Reset member list
|
|
105
91
|
|
|
106
|
-
const seekMember = async
|
|
92
|
+
const seekMember = async index => {
|
|
107
93
|
const memberId = fsId.replace('*', ''+index);
|
|
108
94
|
this.debug('Seek keyedMember', fsCollection, '#', memberId);
|
|
109
95
|
|
|
@@ -146,8 +132,6 @@ export default class SyncroKeyed extends Syncro {
|
|
|
146
132
|
})
|
|
147
133
|
.then(()=> { // Create the reactive
|
|
148
134
|
const reactive = this.getReactive(this.proxy());
|
|
149
|
-
// Assuming this.value should hold the reactive proxy
|
|
150
|
-
// If this.value is inherited and has a specific type, this might need adjustment
|
|
151
135
|
this.value = reactive.doc;
|
|
152
136
|
})
|
|
153
137
|
.then(()=> this)
|
|
@@ -159,40 +143,39 @@ export default class SyncroKeyed extends Syncro {
|
|
|
159
143
|
*
|
|
160
144
|
* @returns {Proxy} A proxy of all combined members
|
|
161
145
|
*/
|
|
162
|
-
proxy()
|
|
146
|
+
proxy() {
|
|
163
147
|
return new Proxy(this, {
|
|
164
148
|
// Return the full list of keys
|
|
165
|
-
ownKeys(target
|
|
149
|
+
ownKeys(target) {
|
|
166
150
|
return target.members.flatMap(m => Object.keys(m.value || {}));
|
|
167
151
|
},
|
|
168
152
|
|
|
169
153
|
// Return if we have a lookup key
|
|
170
|
-
has(target
|
|
154
|
+
has(target, prop) {
|
|
171
155
|
// Ensure m.value exists before checking property
|
|
172
156
|
return target.members.some(m => m.value && prop in m.value);
|
|
173
157
|
},
|
|
174
158
|
|
|
175
159
|
// Scope through members until we get a hit on the key
|
|
176
|
-
get(target
|
|
160
|
+
get(target, prop) {
|
|
177
161
|
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
178
162
|
// Access value via targetMember.value if found
|
|
179
163
|
return targetMember ? targetMember.value[prop] : undefined;
|
|
180
164
|
},
|
|
181
165
|
|
|
182
166
|
// Set the member key if one already exists, otherwise overflow onto the next member
|
|
183
|
-
set(target
|
|
167
|
+
set(target, prop, value) {
|
|
184
168
|
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
185
169
|
if (targetMember && targetMember.value) {
|
|
186
170
|
targetMember.value[prop] = value;
|
|
187
171
|
} else {
|
|
188
|
-
|
|
189
|
-
target.keyedSet(prop as string, value); // Cast prop to string if keyedSet expects string
|
|
172
|
+
target.keyedSet(prop, value);
|
|
190
173
|
}
|
|
191
174
|
return true; // Proxy set must return boolean
|
|
192
175
|
},
|
|
193
176
|
|
|
194
177
|
// Remove a key
|
|
195
|
-
deleteProperty(target
|
|
178
|
+
deleteProperty(target, prop) {
|
|
196
179
|
const targetMember = target.members.find(m => m.value && prop in m.value);
|
|
197
180
|
if (targetMember && targetMember.value) {
|
|
198
181
|
delete targetMember.value[prop];
|
|
@@ -212,22 +195,21 @@ export default class SyncroKeyed extends Syncro {
|
|
|
212
195
|
*
|
|
213
196
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
214
197
|
*/
|
|
215
|
-
async flush(options
|
|
216
|
-
const settings
|
|
198
|
+
async flush(options) {
|
|
199
|
+
const settings = {
|
|
217
200
|
destroy: false,
|
|
218
201
|
...options,
|
|
219
202
|
};
|
|
220
203
|
|
|
221
204
|
await Promise.all(
|
|
222
205
|
this.members.map(member =>
|
|
223
|
-
member.flush({
|
|
206
|
+
member.flush({
|
|
224
207
|
destroy: settings.destroy,
|
|
225
208
|
})
|
|
226
209
|
)
|
|
227
210
|
);
|
|
228
211
|
|
|
229
212
|
if (settings.destroy) await this.destroy();
|
|
230
|
-
return; // Return void to match signature
|
|
231
213
|
}
|
|
232
214
|
|
|
233
215
|
|
|
@@ -240,7 +222,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
240
222
|
*
|
|
241
223
|
* @returns {Promise<*>} A promise which resolves when the operation has completed with the set value
|
|
242
224
|
*/
|
|
243
|
-
async keyedSet(key
|
|
225
|
+
async keyedSet(key, value) {
|
|
244
226
|
const candidateMember = this.members.find(m => m.value && Object.keys(m.value).length < this.keyedConfig.maxKeys);
|
|
245
227
|
if (candidateMember?.value) {
|
|
246
228
|
candidateMember.value[key] = value;
|
|
@@ -274,7 +256,7 @@ export default class SyncroKeyed extends Syncro {
|
|
|
274
256
|
*
|
|
275
257
|
* @param {Object} state The value to merge
|
|
276
258
|
*/
|
|
277
|
-
async keyedAssign(state
|
|
259
|
+
async keyedAssign(state) {
|
|
278
260
|
// Can we assume we have a blank state - this speeds up existing key checks significantly
|
|
279
261
|
// Ensure members[0] and its value exist
|
|
280
262
|
const isBlank = this.members.length === 1 && this.members[0]?.value && Object.keys(this.members[0].value).length === 0;
|
|
@@ -291,21 +273,19 @@ export default class SyncroKeyed extends Syncro {
|
|
|
291
273
|
if (!this.members[chunkIndex]) await this.keyedMembersExpand(chunkIndex);
|
|
292
274
|
|
|
293
275
|
// Ensure the member exists and has setFirestoreState method
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
276
|
+
const member = this.members[chunkIndex];
|
|
277
|
+
if (member && typeof member.setFirestoreState === 'function') {
|
|
278
|
+
await member.setFirestoreState(chunk, {method: 'set'});
|
|
279
|
+
} else {
|
|
280
|
+
console.warn(`Member at index ${chunkIndex} is missing or does not have setFirestoreState`);
|
|
281
|
+
}
|
|
301
282
|
})
|
|
302
283
|
);
|
|
303
284
|
|
|
304
285
|
} else { // Non-blank - call keyedSet() on each key of state, merging slowly
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
286
|
+
for (const [key, val] of Object.entries(state)) {
|
|
287
|
+
await this.keyedSet(key, val);
|
|
288
|
+
}
|
|
309
289
|
}
|
|
310
290
|
}
|
|
311
291
|
|
|
@@ -316,21 +296,19 @@ export default class SyncroKeyed extends Syncro {
|
|
|
316
296
|
* @param {Number} [index] The index to use when expanding, if omitted the next index offset is used
|
|
317
297
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
318
298
|
*/
|
|
319
|
-
async keyedMembersExpand(index
|
|
299
|
+
async keyedMembersExpand(index) {
|
|
320
300
|
index = index ?? this.members.length; // Use provided index or next available slot
|
|
321
301
|
if (this.members[index]) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
302
|
+
// If member already exists (e.g., during initial seek), just ensure it's mounted.
|
|
303
|
+
this.debug(`keyedMembersExpand called for existing index ${index}, ensuring mounted.`);
|
|
304
|
+
if (!this.members[index].value) { // If it exists but isn't mounted somehow
|
|
305
|
+
await this.members[index].mount({initialState: {}});
|
|
306
|
+
}
|
|
307
|
+
return; // Exit if member already exists
|
|
308
|
+
}
|
|
330
309
|
|
|
331
310
|
const syncroPath = this.keyedPath.getKey(this.path, index);
|
|
332
|
-
|
|
333
|
-
const {fsCollection, fsId} = Syncro.pathSplit(syncroPath, {}) as PathSplitResult;
|
|
311
|
+
const {fsCollection, fsId} = Syncro.pathSplit(syncroPath, {});
|
|
334
312
|
this.debug('Expand SyncroKeyed size to index=', index);
|
|
335
313
|
|
|
336
314
|
// Create a new Syncro member, inheriteing some details from this parent item
|
|
@@ -345,11 +323,11 @@ export default class SyncroKeyed extends Syncro {
|
|
|
345
323
|
});
|
|
346
324
|
|
|
347
325
|
// Insert at the correct index if specified, otherwise push
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
326
|
+
if (index < this.members.length) {
|
|
327
|
+
this.members.splice(index, 0, syncro);
|
|
328
|
+
} else {
|
|
329
|
+
this.members.push(syncro);
|
|
330
|
+
}
|
|
353
331
|
}
|
|
354
332
|
|
|
355
333
|
}
|