@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/api.md +8 -11
  3. package/dist/plugin.vue2.es2019.js +7 -7
  4. package/dist/terafy.bootstrapper.es2019.js +2 -2
  5. package/dist/terafy.bootstrapper.js +2 -2
  6. package/dist/terafy.es2019.js +5 -5
  7. package/dist/terafy.js +5 -5
  8. package/eslint.config.js +4 -66
  9. package/lib/{projectFile.ts → projectFile.js} +52 -76
  10. package/lib/syncro/{entities.ts → entities.js} +14 -83
  11. package/lib/syncro/{keyed.ts → keyed.js} +46 -68
  12. package/lib/syncro/{syncro.ts → syncro.js} +104 -136
  13. package/lib/{terafy.bootstrapper.ts → terafy.bootstrapper.js} +20 -30
  14. package/lib/{terafy.client.ts → terafy.client.js} +85 -84
  15. package/lib/{terafy.proxy.ts → terafy.proxy.js} +12 -26
  16. package/lib/{terafy.server.ts → terafy.server.js} +204 -229
  17. package/package.json +20 -39
  18. package/plugins/{base.ts → base.js} +3 -5
  19. package/plugins/{firebase.ts → firebase.js} +22 -21
  20. package/plugins/{vite.ts → vite.js} +3 -3
  21. package/plugins/{vue2.ts → vue2.js} +8 -10
  22. package/plugins/{vue3.ts → vue3.js} +7 -10
  23. package/utils/mixin.js +15 -0
  24. package/utils/{pathTools.ts → pathTools.js} +8 -9
  25. package/widgets/tera-file-select.vue +1 -1
  26. package/dist/lib/projectFile.d.ts +0 -190
  27. package/dist/lib/projectFile.js +0 -305
  28. package/dist/lib/projectFile.js.map +0 -1
  29. package/dist/lib/syncro/entities.d.ts +0 -34
  30. package/dist/lib/syncro/entities.js +0 -212
  31. package/dist/lib/syncro/entities.js.map +0 -1
  32. package/dist/lib/syncro/keyed (Rhino's conflicted copy 2026-05-10).js +0 -287
  33. package/dist/lib/syncro/keyed.d.ts +0 -95
  34. package/dist/lib/syncro/keyed.js +0 -288
  35. package/dist/lib/syncro/keyed.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  36. package/dist/lib/syncro/keyed.js.map +0 -1
  37. package/dist/lib/syncro/syncro (Rhino's conflicted copy 2026-05-10).js +0 -765
  38. package/dist/lib/syncro/syncro.d (Rhino's conflicted copy 2026-05-10).ts +0 -336
  39. package/dist/lib/syncro/syncro.d.ts +0 -343
  40. package/dist/lib/syncro/syncro.js +0 -771
  41. package/dist/lib/syncro/syncro.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  42. package/dist/lib/syncro/syncro.js.map +0 -1
  43. package/dist/lib/terafy.bootstrapper.d.ts +0 -42
  44. package/dist/lib/terafy.bootstrapper.js +0 -129
  45. package/dist/lib/terafy.bootstrapper.js.map +0 -1
  46. package/dist/lib/terafy.client.d.ts +0 -555
  47. package/dist/lib/terafy.client.js +0 -1153
  48. package/dist/lib/terafy.client.js.map +0 -1
  49. package/dist/lib/terafy.proxy.d.ts +0 -66
  50. package/dist/lib/terafy.proxy.js +0 -130
  51. package/dist/lib/terafy.proxy.js.map +0 -1
  52. package/dist/lib/terafy.server.d.ts +0 -697
  53. package/dist/lib/terafy.server.js +0 -2062
  54. package/dist/lib/terafy.server.js.map +0 -1
  55. package/dist/plugin.vue2.es2019 (Rhino's conflicted copy 2026-05-10).js +0 -1271
  56. package/dist/plugins/base.d.ts +0 -20
  57. package/dist/plugins/base.js +0 -22
  58. package/dist/plugins/base.js.map +0 -1
  59. package/dist/plugins/firebase.d.ts +0 -62
  60. package/dist/plugins/firebase.js +0 -123
  61. package/dist/plugins/firebase.js.map +0 -1
  62. package/dist/plugins/vite.d.ts +0 -12
  63. package/dist/plugins/vite.js +0 -22
  64. package/dist/plugins/vite.js.map +0 -1
  65. package/dist/plugins/vue2.d.ts +0 -67
  66. package/dist/plugins/vue2.js +0 -104
  67. package/dist/plugins/vue2.js.map +0 -1
  68. package/dist/plugins/vue3.d.ts +0 -63
  69. package/dist/plugins/vue3.js +0 -93
  70. package/dist/plugins/vue3.js.map +0 -1
  71. package/dist/utils/mixin.d.ts +0 -11
  72. package/dist/utils/mixin.js +0 -15
  73. package/dist/utils/mixin.js.map +0 -1
  74. package/dist/utils/pDefer.d.ts +0 -16
  75. package/dist/utils/pDefer.js +0 -19
  76. package/dist/utils/pDefer.js.map +0 -1
  77. package/dist/utils/pathTools.d.ts +0 -70
  78. package/dist/utils/pathTools.js +0 -120
  79. package/dist/utils/pathTools.js.map +0 -1
  80. package/tsconfig.json +0 -30
  81. package/utils/mixin.ts +0 -18
  82. 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: string, index: number): string {
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: Syncro[] = [];
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: string, options?: Record<string, any>) {
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)!.groups!;
70
- this.keyedPath.getKey = (path: string, index: number): string => `${prefix}${index}${suffix}`;
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(): Promise<never[]> { // Match base class signature
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 [] as never[]; // Return empty array cast to never[] to satisfy signature
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(): Promise<Syncro> {
99
- // Cast the result to the expected interface
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<void>(resolve => { // Mount all members by looking for similar keys
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 (index: number) => {
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(): Record<string | symbol, any> { // Return type can be more specific if needed
146
+ proxy() {
163
147
  return new Proxy(this, {
164
148
  // Return the full list of keys
165
- ownKeys(target: SyncroKeyed): ArrayLike<string | symbol> {
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: SyncroKeyed, prop: string | symbol): boolean {
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: SyncroKeyed, prop: string | symbol): any {
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: SyncroKeyed, prop: string | symbol, value: any): boolean {
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
- // Assuming keyedSet handles adding the value appropriately
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: SyncroKeyed, prop: string | symbol): boolean {
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?: FlushOptions): Promise<void> { // Match base class signature
216
- const settings: FlushOptions = {
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({ // Assuming member.flush returns Promise<void> now
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: string, value: any): Promise<any> {
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: Record<string, any>): Promise<void> {
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
- const member = this.members[chunkIndex];
295
- if (member && typeof (member as any).setFirestoreState === 'function') {
296
- // Populate its state - Cast to any temporarily if setFirestoreState is not public/recognized
297
- await (member as any).setFirestoreState(chunk, {method: 'set'});
298
- } else {
299
- console.warn(`Member at index ${chunkIndex} is missing or does not have setFirestoreState`);
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
- // Replace Array.fromAsync with a standard loop
306
- for (const [key, val] of Object.entries(state)) {
307
- await this.keyedSet(key, val);
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?: number): Promise<void> {
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
- // If member already exists (e.g., during initial seek), just ensure it's mounted.
323
- // If it was called intentionally with an existing index, maybe log a warning or skip.
324
- this.debug(`keyedMembersExpand called for existing index ${index}, ensuring mounted.`);
325
- if (!this.members[index].value) { // If it exists but isn't mounted somehow
326
- await this.members[index].mount({ initialState: {} });
327
- }
328
- return; // Exit if member already exists
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
- // Pass empty options object {} or specify allowAsterisk: false if needed
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
- if (index < this.members.length) {
349
- this.members.splice(index, 0, syncro);
350
- } else {
351
- this.members.push(syncro);
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
  }