@tanstack/db-sqlite-persistence-core 0.4.4 → 0.4.7
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/README.md +14 -6
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/persisted.cjs +12 -10
- package/dist/cjs/persisted.cjs.map +1 -1
- package/dist/cjs/persisted.d.cts +7 -1
- package/dist/cjs/remote-subset-wire.cjs +100 -73
- package/dist/cjs/remote-subset-wire.cjs.map +1 -1
- package/dist/cjs/remote-subset-wire.d.cts +2 -0
- package/dist/cjs/sqlite-core-adapter.cjs +136 -28
- package/dist/cjs/sqlite-core-adapter.cjs.map +1 -1
- package/dist/cjs/sqlite-value.cjs +51 -0
- package/dist/cjs/sqlite-value.cjs.map +1 -1
- package/dist/cjs/sqlite-value.d.cts +12 -0
- package/dist/esm/index.js +8 -3
- package/dist/esm/persisted.d.ts +7 -1
- package/dist/esm/persisted.js +14 -12
- package/dist/esm/persisted.js.map +1 -1
- package/dist/esm/remote-subset-wire.d.ts +2 -0
- package/dist/esm/remote-subset-wire.js +101 -74
- package/dist/esm/remote-subset-wire.js.map +1 -1
- package/dist/esm/sqlite-core-adapter.js +138 -30
- package/dist/esm/sqlite-core-adapter.js.map +1 -1
- package/dist/esm/sqlite-value.d.ts +12 -0
- package/dist/esm/sqlite-value.js +53 -2
- package/dist/esm/sqlite-value.js.map +1 -1
- package/package.json +4 -3
- package/src/persisted.ts +31 -16
- package/src/remote-subset-wire.ts +149 -79
- package/src/sqlite-core-adapter.ts +221 -34
- package/src/sqlite-value.ts +98 -1
|
@@ -55,5 +55,7 @@ export declare class RemoteSubsetWireValueError extends TypeError {
|
|
|
55
55
|
* Validation happens before callers choose a local-leader or transported path.
|
|
56
56
|
*/
|
|
57
57
|
export declare function toTransportedLoadSubsetOptions(options: LoadSubsetOptions): TransportedLoadSubsetOptions;
|
|
58
|
+
/** Checks wire admission without constructing a detached request snapshot. */
|
|
59
|
+
export declare function validateRemoteSubsetOptions(options: LoadSubsetOptions): void;
|
|
58
60
|
/** Adds live lifecycle references only to an already validated local request. */
|
|
59
61
|
export declare function toProcessLocalLoadSubsetOptions(options: LoadSubsetOptions, transported?: TransportedLoadSubsetOptions): TransportedLoadSubsetOptions & Pick<LoadSubsetOptions, `signal` | `subscription`>;
|
|
@@ -22,6 +22,12 @@ const typedArrayConstructors = [
|
|
|
22
22
|
const NativeDate = Date;
|
|
23
23
|
const identifierPattern = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
24
24
|
function toTransportedLoadSubsetOptions(options) {
|
|
25
|
+
return visitLoadSubsetOptions(options, false);
|
|
26
|
+
}
|
|
27
|
+
function validateRemoteSubsetOptions(options) {
|
|
28
|
+
visitLoadSubsetOptions(options, true);
|
|
29
|
+
}
|
|
30
|
+
function visitLoadSubsetOptions(options, validateOnly) {
|
|
25
31
|
assertPlainContainer(options, `options`);
|
|
26
32
|
assertAllowedProperties(options, `options`, [
|
|
27
33
|
`where`,
|
|
@@ -33,6 +39,7 @@ function toTransportedLoadSubsetOptions(options) {
|
|
|
33
39
|
`subscription`
|
|
34
40
|
]);
|
|
35
41
|
const state = {
|
|
42
|
+
validateOnly,
|
|
36
43
|
expressions: /* @__PURE__ */ new WeakMap(),
|
|
37
44
|
expressionArrays: /* @__PURE__ */ new WeakMap(),
|
|
38
45
|
stringArrays: /* @__PURE__ */ new WeakMap(),
|
|
@@ -42,26 +49,31 @@ function toTransportedLoadSubsetOptions(options) {
|
|
|
42
49
|
cursors: /* @__PURE__ */ new WeakMap(),
|
|
43
50
|
wireValues: /* @__PURE__ */ new WeakMap()
|
|
44
51
|
};
|
|
45
|
-
const projected = {};
|
|
52
|
+
const projected = validateOnly ? options : {};
|
|
46
53
|
const where = readDataProperty(options, `where`, `options.where`);
|
|
47
54
|
const orderBy = readDataProperty(options, `orderBy`, `options.orderBy`);
|
|
48
55
|
const limit = readDataProperty(options, `limit`, `options.limit`);
|
|
49
56
|
const cursor = readDataProperty(options, `cursor`, `options.cursor`);
|
|
50
57
|
const offset = readDataProperty(options, `offset`, `options.offset`);
|
|
51
58
|
if (where.present && where.value !== void 0) {
|
|
52
|
-
|
|
59
|
+
const result = projectExpression(where.value, `options.where`, state);
|
|
60
|
+
if (!state.validateOnly) projected.where = result;
|
|
53
61
|
}
|
|
54
62
|
if (orderBy.present && orderBy.value !== void 0) {
|
|
55
|
-
|
|
63
|
+
const result = projectOrderBy(orderBy.value, `options.orderBy`, state);
|
|
64
|
+
if (!state.validateOnly) projected.orderBy = result;
|
|
56
65
|
}
|
|
57
66
|
if (limit.present && limit.value !== void 0) {
|
|
58
|
-
|
|
67
|
+
const result = projectNumber(limit.value, `options.limit`);
|
|
68
|
+
if (!state.validateOnly) projected.limit = result;
|
|
59
69
|
}
|
|
60
70
|
if (cursor.present && cursor.value !== void 0) {
|
|
61
|
-
|
|
71
|
+
const result = projectCursor(cursor.value, `options.cursor`, state);
|
|
72
|
+
if (!state.validateOnly) projected.cursor = result;
|
|
62
73
|
}
|
|
63
74
|
if (offset.present && offset.value !== void 0) {
|
|
64
|
-
|
|
75
|
+
const result = projectNumber(offset.value, `options.offset`);
|
|
76
|
+
if (!state.validateOnly) projected.offset = result;
|
|
65
77
|
}
|
|
66
78
|
return projected;
|
|
67
79
|
}
|
|
@@ -95,65 +107,58 @@ function projectExpression(value, path, state) {
|
|
|
95
107
|
case `ref`: {
|
|
96
108
|
assertExpressionPrototype(object, path, IR.PropRef.prototype);
|
|
97
109
|
assertAllowedProperties(object, path, [`type`, `path`, `sourceAlias`]);
|
|
98
|
-
const projected = {
|
|
99
|
-
type: `ref`,
|
|
100
|
-
path: []
|
|
101
|
-
};
|
|
110
|
+
const projected = state.validateOnly ? object : { type: `ref`, path: [] };
|
|
102
111
|
state.expressions.set(object, projected);
|
|
103
112
|
const sourcePath = readRequiredDataProperty(
|
|
104
113
|
object,
|
|
105
114
|
`path`,
|
|
106
115
|
`${path}.path`
|
|
107
116
|
);
|
|
108
|
-
|
|
117
|
+
const result = projectStringArray(sourcePath, `${path}.path`, state);
|
|
118
|
+
if (!state.validateOnly) projected.path = result;
|
|
109
119
|
const sourceAlias = readDataProperty(
|
|
110
120
|
object,
|
|
111
121
|
`sourceAlias`,
|
|
112
122
|
`${path}.sourceAlias`
|
|
113
123
|
);
|
|
114
124
|
if (sourceAlias.present) {
|
|
115
|
-
if (typeof sourceAlias.value !== `string` ||
|
|
125
|
+
if (typeof sourceAlias.value !== `string` || result[0] !== sourceAlias.value) {
|
|
116
126
|
throw new RemoteSubsetWireValueError(
|
|
117
127
|
`${path}.sourceAlias`,
|
|
118
128
|
`source alias must match the first path segment`
|
|
119
129
|
);
|
|
120
130
|
}
|
|
121
|
-
projected.sourceAlias = sourceAlias.value;
|
|
131
|
+
if (!state.validateOnly) projected.sourceAlias = sourceAlias.value;
|
|
122
132
|
}
|
|
123
133
|
return projected;
|
|
124
134
|
}
|
|
125
135
|
case `val`: {
|
|
126
136
|
assertExpressionPrototype(object, path, IR.Value.prototype);
|
|
127
137
|
assertAllowedProperties(object, path, [`type`, `value`]);
|
|
128
|
-
const projected = {
|
|
129
|
-
type: `val`,
|
|
130
|
-
value: void 0
|
|
131
|
-
};
|
|
138
|
+
const projected = state.validateOnly ? object : { type: `val`, value: void 0 };
|
|
132
139
|
state.expressions.set(object, projected);
|
|
133
140
|
const sourceValue = readRequiredDataProperty(
|
|
134
141
|
object,
|
|
135
142
|
`value`,
|
|
136
143
|
`${path}.value`
|
|
137
144
|
);
|
|
138
|
-
|
|
145
|
+
const result = projectWireValue(sourceValue, `${path}.value`, state);
|
|
146
|
+
if (!state.validateOnly) projected.value = result;
|
|
139
147
|
return projected;
|
|
140
148
|
}
|
|
141
149
|
case `func`: {
|
|
142
150
|
assertExpressionPrototype(object, path, IR.Func.prototype);
|
|
143
151
|
assertAllowedProperties(object, path, [`type`, `name`, `args`]);
|
|
144
|
-
const projected = {
|
|
145
|
-
type: `func`,
|
|
146
|
-
name: ``,
|
|
147
|
-
args: []
|
|
148
|
-
};
|
|
152
|
+
const projected = state.validateOnly ? object : { type: `func`, name: ``, args: [] };
|
|
149
153
|
state.expressions.set(object, projected);
|
|
150
154
|
const name = readRequiredDataProperty(object, `name`, `${path}.name`);
|
|
151
155
|
if (typeof name !== `string`) {
|
|
152
156
|
throw new RemoteSubsetWireValueError(`${path}.name`, describe(name));
|
|
153
157
|
}
|
|
154
|
-
projected.name = name;
|
|
158
|
+
if (!state.validateOnly) projected.name = name;
|
|
155
159
|
const args = readRequiredDataProperty(object, `args`, `${path}.args`);
|
|
156
|
-
|
|
160
|
+
const result = projectExpressionArray(args, `${path}.args`, state);
|
|
161
|
+
if (!state.validateOnly) projected.args = result;
|
|
157
162
|
return projected;
|
|
158
163
|
}
|
|
159
164
|
default:
|
|
@@ -165,7 +170,7 @@ function projectExpressionArray(value, path, state) {
|
|
|
165
170
|
const existing = state.expressionArrays.get(array);
|
|
166
171
|
if (existing) return existing;
|
|
167
172
|
assertArrayShape(array, path);
|
|
168
|
-
const projected = new Array(array.length);
|
|
173
|
+
const projected = state.validateOnly ? array : new Array(array.length);
|
|
169
174
|
state.expressionArrays.set(array, projected);
|
|
170
175
|
for (let index = 0; index < array.length; index++) {
|
|
171
176
|
if (!(index in array)) {
|
|
@@ -174,11 +179,8 @@ function projectExpressionArray(value, path, state) {
|
|
|
174
179
|
`missing expression`
|
|
175
180
|
);
|
|
176
181
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
`${path}[${index}]`,
|
|
180
|
-
state
|
|
181
|
-
);
|
|
182
|
+
const result = projectExpression(array[index], `${path}[${index}]`, state);
|
|
183
|
+
if (!state.validateOnly) projected[index] = result;
|
|
182
184
|
}
|
|
183
185
|
return projected;
|
|
184
186
|
}
|
|
@@ -187,14 +189,14 @@ function projectStringArray(value, path, state) {
|
|
|
187
189
|
const existing = state.stringArrays.get(array);
|
|
188
190
|
if (existing) return existing;
|
|
189
191
|
assertArrayShape(array, path);
|
|
190
|
-
const projected = new Array(array.length);
|
|
192
|
+
const projected = state.validateOnly ? array : new Array(array.length);
|
|
191
193
|
state.stringArrays.set(array, projected);
|
|
192
194
|
for (let index = 0; index < array.length; index++) {
|
|
193
195
|
const entry = array[index];
|
|
194
196
|
if (!(index in array) || typeof entry !== `string`) {
|
|
195
197
|
throw new RemoteSubsetWireValueError(`${path}[${index}]`, describe(entry));
|
|
196
198
|
}
|
|
197
|
-
projected[index] = entry;
|
|
199
|
+
if (!state.validateOnly) projected[index] = entry;
|
|
198
200
|
}
|
|
199
201
|
return projected;
|
|
200
202
|
}
|
|
@@ -203,27 +205,27 @@ function projectOrderBy(value, path, state) {
|
|
|
203
205
|
const existing = state.orderByArrays.get(array);
|
|
204
206
|
if (existing) return existing;
|
|
205
207
|
assertArrayShape(array, path);
|
|
206
|
-
const projected = new Array(array.length);
|
|
208
|
+
const projected = state.validateOnly ? array : new Array(array.length);
|
|
207
209
|
state.orderByArrays.set(array, projected);
|
|
208
210
|
for (let index = 0; index < array.length; index++) {
|
|
209
211
|
const clausePath = `${path}[${index}]`;
|
|
210
212
|
const clause = requirePlainRecord(array[index], clausePath);
|
|
211
213
|
const existingClause = state.orderByClauses.get(clause);
|
|
212
214
|
if (existingClause) {
|
|
213
|
-
projected[index] = existingClause;
|
|
215
|
+
if (!state.validateOnly) projected[index] = existingClause;
|
|
214
216
|
continue;
|
|
215
217
|
}
|
|
216
218
|
assertAllowedProperties(clause, clausePath, [
|
|
217
219
|
`expression`,
|
|
218
220
|
`compareOptions`
|
|
219
221
|
]);
|
|
220
|
-
const projectedClause = {
|
|
222
|
+
const projectedClause = state.validateOnly ? clause : {
|
|
221
223
|
expression: void 0,
|
|
222
224
|
compareOptions: void 0
|
|
223
225
|
};
|
|
224
|
-
projected[index] = projectedClause;
|
|
226
|
+
if (!state.validateOnly) projected[index] = projectedClause;
|
|
225
227
|
state.orderByClauses.set(clause, projectedClause);
|
|
226
|
-
|
|
228
|
+
const expression = projectExpression(
|
|
227
229
|
readRequiredDataProperty(
|
|
228
230
|
clause,
|
|
229
231
|
`expression`,
|
|
@@ -232,7 +234,7 @@ function projectOrderBy(value, path, state) {
|
|
|
232
234
|
`${clausePath}.expression`,
|
|
233
235
|
state
|
|
234
236
|
);
|
|
235
|
-
|
|
237
|
+
const compareOptions = projectCompareOptions(
|
|
236
238
|
readRequiredDataProperty(
|
|
237
239
|
clause,
|
|
238
240
|
`compareOptions`,
|
|
@@ -241,6 +243,10 @@ function projectOrderBy(value, path, state) {
|
|
|
241
243
|
`${clausePath}.compareOptions`,
|
|
242
244
|
state
|
|
243
245
|
);
|
|
246
|
+
if (!state.validateOnly) {
|
|
247
|
+
projectedClause.expression = expression;
|
|
248
|
+
projectedClause.compareOptions = compareOptions;
|
|
249
|
+
}
|
|
244
250
|
}
|
|
245
251
|
return projected;
|
|
246
252
|
}
|
|
@@ -255,7 +261,7 @@ function projectCompareOptions(value, path, state) {
|
|
|
255
261
|
`locale`,
|
|
256
262
|
`localeOptions`
|
|
257
263
|
]);
|
|
258
|
-
const projected = {};
|
|
264
|
+
const projected = state.validateOnly ? source : {};
|
|
259
265
|
const direction = readRequiredDataProperty(
|
|
260
266
|
source,
|
|
261
267
|
`direction`,
|
|
@@ -267,12 +273,12 @@ function projectCompareOptions(value, path, state) {
|
|
|
267
273
|
describe(direction)
|
|
268
274
|
);
|
|
269
275
|
}
|
|
270
|
-
projected.direction = direction;
|
|
276
|
+
if (!state.validateOnly) projected.direction = direction;
|
|
271
277
|
const nulls = readRequiredDataProperty(source, `nulls`, `${path}.nulls`);
|
|
272
278
|
if (nulls !== `first` && nulls !== `last`) {
|
|
273
279
|
throw new RemoteSubsetWireValueError(`${path}.nulls`, describe(nulls));
|
|
274
280
|
}
|
|
275
|
-
projected.nulls = nulls;
|
|
281
|
+
if (!state.validateOnly) projected.nulls = nulls;
|
|
276
282
|
const stringSort = readDataProperty(
|
|
277
283
|
source,
|
|
278
284
|
`stringSort`,
|
|
@@ -285,7 +291,7 @@ function projectCompareOptions(value, path, state) {
|
|
|
285
291
|
describe(stringSort.value)
|
|
286
292
|
);
|
|
287
293
|
}
|
|
288
|
-
projected.stringSort = stringSort.value;
|
|
294
|
+
if (!state.validateOnly) projected.stringSort = stringSort.value;
|
|
289
295
|
}
|
|
290
296
|
if (projected.stringSort !== `lexical`) {
|
|
291
297
|
const locale = readDataProperty(source, `locale`, `${path}.locale`);
|
|
@@ -296,7 +302,7 @@ function projectCompareOptions(value, path, state) {
|
|
|
296
302
|
describe(locale.value)
|
|
297
303
|
);
|
|
298
304
|
}
|
|
299
|
-
projected.locale = locale.value;
|
|
305
|
+
if (!state.validateOnly) projected.locale = locale.value;
|
|
300
306
|
}
|
|
301
307
|
const localeOptions = readDataProperty(
|
|
302
308
|
source,
|
|
@@ -304,11 +310,12 @@ function projectCompareOptions(value, path, state) {
|
|
|
304
310
|
`${path}.localeOptions`
|
|
305
311
|
);
|
|
306
312
|
if (localeOptions.present && localeOptions.value !== void 0) {
|
|
307
|
-
|
|
313
|
+
const result2 = projectWireRecord(
|
|
308
314
|
localeOptions.value,
|
|
309
315
|
`${path}.localeOptions`,
|
|
310
316
|
state
|
|
311
317
|
);
|
|
318
|
+
if (!state.validateOnly) projected.localeOptions = result2;
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
321
|
const result = projected;
|
|
@@ -324,21 +331,25 @@ function projectCursor(value, path, state) {
|
|
|
324
331
|
`whereCurrent`,
|
|
325
332
|
`lastKey`
|
|
326
333
|
]);
|
|
327
|
-
const projected = {
|
|
334
|
+
const projected = state.validateOnly ? source : {
|
|
328
335
|
whereFrom: void 0,
|
|
329
336
|
whereCurrent: void 0
|
|
330
337
|
};
|
|
331
338
|
state.cursors.set(source, projected);
|
|
332
|
-
|
|
339
|
+
const whereFrom = projectExpression(
|
|
333
340
|
readRequiredDataProperty(source, `whereFrom`, `${path}.whereFrom`),
|
|
334
341
|
`${path}.whereFrom`,
|
|
335
342
|
state
|
|
336
343
|
);
|
|
337
|
-
|
|
344
|
+
const whereCurrent = projectExpression(
|
|
338
345
|
readRequiredDataProperty(source, `whereCurrent`, `${path}.whereCurrent`),
|
|
339
346
|
`${path}.whereCurrent`,
|
|
340
347
|
state
|
|
341
348
|
);
|
|
349
|
+
if (!state.validateOnly) {
|
|
350
|
+
projected.whereFrom = whereFrom;
|
|
351
|
+
projected.whereCurrent = whereCurrent;
|
|
352
|
+
}
|
|
342
353
|
const lastKey = readDataProperty(source, `lastKey`, `${path}.lastKey`);
|
|
343
354
|
if (lastKey.present && lastKey.value !== void 0) {
|
|
344
355
|
if (typeof lastKey.value !== `string` && typeof lastKey.value !== `number`) {
|
|
@@ -347,7 +358,7 @@ function projectCursor(value, path, state) {
|
|
|
347
358
|
describe(lastKey.value)
|
|
348
359
|
);
|
|
349
360
|
}
|
|
350
|
-
projected.lastKey = lastKey.value;
|
|
361
|
+
if (!state.validateOnly) projected.lastKey = lastKey.value;
|
|
351
362
|
}
|
|
352
363
|
return projected;
|
|
353
364
|
}
|
|
@@ -366,14 +377,16 @@ function projectWireValue(value, path, state) {
|
|
|
366
377
|
if (value instanceof NativeDate) {
|
|
367
378
|
assertExactPrototype(value, NativeDate.prototype, path);
|
|
368
379
|
assertNoOwnProperties(value, path);
|
|
369
|
-
const
|
|
380
|
+
const time = value.getTime();
|
|
381
|
+
const projected = state.validateOnly ? value : new NativeDate(time);
|
|
370
382
|
state.wireValues.set(value, projected);
|
|
371
383
|
return projected;
|
|
372
384
|
}
|
|
373
385
|
if (value instanceof RegExp) {
|
|
374
386
|
assertExactPrototype(value, RegExp.prototype, path);
|
|
375
387
|
assertRegExpShape(value, path);
|
|
376
|
-
const
|
|
388
|
+
const { source, flags } = value;
|
|
389
|
+
const projected = state.validateOnly ? value : new RegExp(source, flags);
|
|
377
390
|
state.wireValues.set(value, projected);
|
|
378
391
|
return projected;
|
|
379
392
|
}
|
|
@@ -383,7 +396,12 @@ function projectWireValue(value, path, state) {
|
|
|
383
396
|
assertFixedArrayBuffer(value, path);
|
|
384
397
|
let projected;
|
|
385
398
|
try {
|
|
386
|
-
|
|
399
|
+
if (state.validateOnly) {
|
|
400
|
+
new Uint8Array(value, 0, 0);
|
|
401
|
+
projected = value;
|
|
402
|
+
} else {
|
|
403
|
+
projected = value.slice(0);
|
|
404
|
+
}
|
|
387
405
|
} catch {
|
|
388
406
|
throw new RemoteSubsetWireValueError(path, `detached ArrayBuffer`);
|
|
389
407
|
}
|
|
@@ -407,7 +425,7 @@ function projectWireValue(value, path, state) {
|
|
|
407
425
|
if (!(projectedBuffer instanceof ArrayBuffer)) {
|
|
408
426
|
throw new RemoteSubsetWireValueError(path, `shared DataView buffer`);
|
|
409
427
|
}
|
|
410
|
-
const projected = new DataView(projectedBuffer, byteOffset, byteLength);
|
|
428
|
+
const projected = state.validateOnly ? value : new DataView(projectedBuffer, byteOffset, byteLength);
|
|
411
429
|
state.wireValues.set(value, projected);
|
|
412
430
|
return projected;
|
|
413
431
|
}
|
|
@@ -434,7 +452,7 @@ function projectWireValue(value, path, state) {
|
|
|
434
452
|
}
|
|
435
453
|
let projected;
|
|
436
454
|
try {
|
|
437
|
-
projected = new typedArrayConstructor(projectedBuffer, byteOffset, length);
|
|
455
|
+
projected = state.validateOnly ? typedArray : new typedArrayConstructor(projectedBuffer, byteOffset, length);
|
|
438
456
|
} catch {
|
|
439
457
|
throw new RemoteSubsetWireValueError(path, `detached typed array`);
|
|
440
458
|
}
|
|
@@ -451,15 +469,12 @@ function projectWireValue(value, path, state) {
|
|
|
451
469
|
}
|
|
452
470
|
function projectWireArray(value, path, state) {
|
|
453
471
|
assertArrayShape(value, path);
|
|
454
|
-
const projected = new Array(value.length);
|
|
472
|
+
const projected = state.validateOnly ? value : new Array(value.length);
|
|
455
473
|
state.wireValues.set(value, projected);
|
|
456
474
|
for (let index = 0; index < value.length; index++) {
|
|
457
475
|
if (index in value) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
`${path}[${index}]`,
|
|
461
|
-
state
|
|
462
|
-
);
|
|
476
|
+
const result = projectWireValue(value[index], `${path}[${index}]`, state);
|
|
477
|
+
if (!state.validateOnly) projected[index] = result;
|
|
463
478
|
}
|
|
464
479
|
}
|
|
465
480
|
return projected;
|
|
@@ -467,14 +482,21 @@ function projectWireArray(value, path, state) {
|
|
|
467
482
|
function projectWireMap(value, path, state) {
|
|
468
483
|
assertExactPrototype(value, Map.prototype, path);
|
|
469
484
|
assertNoOwnProperties(value, path);
|
|
470
|
-
const projected = /* @__PURE__ */ new Map();
|
|
485
|
+
const projected = state.validateOnly ? value : /* @__PURE__ */ new Map();
|
|
471
486
|
state.wireValues.set(value, projected);
|
|
472
487
|
let index = 0;
|
|
473
488
|
for (const [key, entry] of value) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
489
|
+
const projectedKey = projectWireValue(
|
|
490
|
+
key,
|
|
491
|
+
`${path}.entries[${index}].key`,
|
|
492
|
+
state
|
|
477
493
|
);
|
|
494
|
+
const projectedValue = projectWireValue(
|
|
495
|
+
entry,
|
|
496
|
+
`${path}.entries[${index}].value`,
|
|
497
|
+
state
|
|
498
|
+
);
|
|
499
|
+
if (!state.validateOnly) projected.set(projectedKey, projectedValue);
|
|
478
500
|
index++;
|
|
479
501
|
}
|
|
480
502
|
return projected;
|
|
@@ -482,11 +504,12 @@ function projectWireMap(value, path, state) {
|
|
|
482
504
|
function projectWireSet(value, path, state) {
|
|
483
505
|
assertExactPrototype(value, Set.prototype, path);
|
|
484
506
|
assertNoOwnProperties(value, path);
|
|
485
|
-
const projected = /* @__PURE__ */ new Set();
|
|
507
|
+
const projected = state.validateOnly ? value : /* @__PURE__ */ new Set();
|
|
486
508
|
state.wireValues.set(value, projected);
|
|
487
509
|
let index = 0;
|
|
488
510
|
for (const entry of value) {
|
|
489
|
-
|
|
511
|
+
const result = projectWireValue(entry, `${path}.values[${index}]`, state);
|
|
512
|
+
if (!state.validateOnly) projected.add(result);
|
|
490
513
|
index++;
|
|
491
514
|
}
|
|
492
515
|
return projected;
|
|
@@ -495,7 +518,7 @@ function projectWireRecord(value, path, state) {
|
|
|
495
518
|
const source = requirePlainRecord(value, path);
|
|
496
519
|
const existing = state.wireValues.get(source);
|
|
497
520
|
if (existing) return existing;
|
|
498
|
-
const projected = {};
|
|
521
|
+
const projected = state.validateOnly ? source : {};
|
|
499
522
|
state.wireValues.set(source, projected);
|
|
500
523
|
for (const key of ownKeys(source, path)) {
|
|
501
524
|
const childPath = propertyPath(path, key);
|
|
@@ -506,12 +529,15 @@ function projectWireRecord(value, path, state) {
|
|
|
506
529
|
if (!descriptor || !descriptor.enumerable || !(`value` in descriptor)) {
|
|
507
530
|
throw new RemoteSubsetWireValueError(childPath, `non-data property`);
|
|
508
531
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
532
|
+
const result = projectWireValue(descriptor.value, childPath, state);
|
|
533
|
+
if (!state.validateOnly) {
|
|
534
|
+
Object.defineProperty(projected, key, {
|
|
535
|
+
value: result,
|
|
536
|
+
enumerable: true,
|
|
537
|
+
writable: true,
|
|
538
|
+
configurable: true
|
|
539
|
+
});
|
|
540
|
+
}
|
|
515
541
|
}
|
|
516
542
|
return projected;
|
|
517
543
|
}
|
|
@@ -676,6 +702,7 @@ function describe(value) {
|
|
|
676
702
|
export {
|
|
677
703
|
RemoteSubsetWireValueError,
|
|
678
704
|
toProcessLocalLoadSubsetOptions,
|
|
679
|
-
toTransportedLoadSubsetOptions
|
|
705
|
+
toTransportedLoadSubsetOptions,
|
|
706
|
+
validateRemoteSubsetOptions
|
|
680
707
|
};
|
|
681
708
|
//# sourceMappingURL=remote-subset-wire.js.map
|