one 2.13.9 → 2.14.0
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/android/src/main/java/dev/onejs/one/OneKotlinHostView.kt +53 -14
- package/android/src/main/java/dev/onejs/one/OneNativeSourceKeyedState.kt +23 -0
- package/android/src/main/java/dev/onejs/one/OneNativeSourceViewDispatch.kt +16 -3
- package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +4 -10
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.cjs +4 -10
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +4 -10
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/cjs/platform/native-source/view.native.cjs +4 -4
- package/dist/cjs/platform/native-source/view.native.js +4 -4
- package/dist/cjs/platform/native-source/view.native.js.map +1 -1
- package/dist/cjs/platform/native-source/wire.native.cjs +152 -49
- package/dist/cjs/platform/native-source/wire.native.js +152 -49
- package/dist/cjs/platform/native-source/wire.native.js.map +1 -1
- package/dist/cjs/platform/native-source/wireProps.native.cjs +138 -0
- package/dist/cjs/platform/native-source/wireProps.native.js +140 -0
- package/dist/cjs/platform/native-source/wireProps.native.js.map +1 -0
- package/dist/cjs/platform/swift/index.native.cjs +12 -8
- package/dist/cjs/platform/swift/index.native.js +12 -8
- package/dist/cjs/platform/swift/index.native.js.map +1 -1
- package/dist/cjs/router/useScreens.cjs +1 -1
- package/dist/cjs/router/useScreens.native.cjs +2 -1
- package/dist/cjs/router/useScreens.native.js +2 -1
- package/dist/cjs/router/useScreens.native.js.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +4 -10
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +4 -10
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/esm/platform/native-source/view.native.js +5 -5
- package/dist/esm/platform/native-source/view.native.js.map +1 -1
- package/dist/esm/platform/native-source/wire.native.js +149 -49
- package/dist/esm/platform/native-source/wire.native.js.map +1 -1
- package/dist/esm/platform/native-source/wireProps.native.js +113 -0
- package/dist/esm/platform/native-source/wireProps.native.js.map +1 -0
- package/dist/esm/platform/swift/index.native.js +13 -9
- package/dist/esm/platform/swift/index.native.js.map +1 -1
- package/dist/esm/router/useScreens.mjs +1 -1
- package/dist/esm/router/useScreens.mjs.map +1 -1
- package/dist/esm/router/useScreens.native.js +2 -1
- package/dist/esm/router/useScreens.native.js.map +1 -1
- package/ios/Generated/OneNativeTabViewView.swift +2 -1
- package/ios/OneNativeComposition.swift +1 -0
- package/ios/OneNativeHostingController.swift +113 -0
- package/ios/OneSwiftHostComponentView.mm +28 -4
- package/ios/OneSwiftHostView.swift +63 -9
- package/ios/OneSwiftPackage.swift +6 -1
- package/package.json +13 -13
- package/src/metro-config/getViteMetroPluginOptions.integration.test.ts +33 -3
- package/src/metro-config/getViteMetroPluginOptions.ts +5 -11
- package/src/native/packedClosure.test.ts +59 -22
- package/src/platform/native-source/view.native.tsx +4 -5
- package/src/platform/native-source/wire.native.ts +108 -26
- package/src/platform/native-source/wireProps.native.test.ts +57 -0
- package/src/platform/native-source/wireProps.native.ts +124 -0
- package/src/platform/swift/index.native.tsx +9 -7
- package/src/platform/swift/types.ts +4 -2
- package/src/router/useScreens.tsx +1 -1
- package/types/metro-config/getViteMetroPluginOptions.d.ts +1 -1
- package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
- package/types/platform/native-source/view.native.d.ts.map +1 -1
- package/types/platform/native-source/wire.native.d.ts +3 -0
- package/types/platform/native-source/wire.native.d.ts.map +1 -1
- package/types/platform/native-source/wireProps.native.d.ts +15 -0
- package/types/platform/native-source/wireProps.native.d.ts.map +1 -0
- package/types/platform/swift/index.native.d.ts.map +1 -1
- package/types/platform/swift/types.d.ts +4 -1
- package/types/platform/swift/types.d.ts.map +1 -1
|
@@ -27,7 +27,10 @@ __export(wire_native_exports, {
|
|
|
27
27
|
decodeNativeSourceCallback: () => decodeNativeSourceCallback,
|
|
28
28
|
decodeNativeSourceResult: () => decodeNativeSourceResult,
|
|
29
29
|
encodeNativeSourceArgs: () => encodeNativeSourceArgs,
|
|
30
|
-
|
|
30
|
+
encodeNativeSourceListItem: () => encodeNativeSourceListItem,
|
|
31
|
+
encodeNativeSourceProp: () => encodeNativeSourceProp,
|
|
32
|
+
encodeNativeSourceProps: () => encodeNativeSourceProps,
|
|
33
|
+
stringifyNativeSourceProps: () => stringifyNativeSourceProps
|
|
31
34
|
});
|
|
32
35
|
module.exports = __toCommonJS(wire_native_exports);
|
|
33
36
|
var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -66,105 +69,165 @@ function base64Decode(text) {
|
|
|
66
69
|
function isRecord(value) {
|
|
67
70
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
var trail = [];
|
|
73
|
+
function trailText() {
|
|
74
|
+
var text = String(trail[0]);
|
|
75
|
+
for (var i = 1; i < trail.length; i++) {
|
|
76
|
+
text += typeof trail[i] === "number" ? `[${trail[i]}]` : `.${trail[i]}`;
|
|
77
|
+
}
|
|
78
|
+
return text;
|
|
79
|
+
}
|
|
80
|
+
var plainStructs = /* @__PURE__ */ new WeakMap();
|
|
81
|
+
function encodeValue(value, wire, structs) {
|
|
70
82
|
switch (wire.kind) {
|
|
71
83
|
case "date":
|
|
72
|
-
if (!(value instanceof Date)) throw new TypeError(`${
|
|
84
|
+
if (!(value instanceof Date)) throw new TypeError(`${trailText()}: expected Date`);
|
|
73
85
|
return value;
|
|
74
86
|
case "data":
|
|
75
|
-
if (!(value instanceof Uint8Array)) throw new TypeError(`${
|
|
87
|
+
if (!(value instanceof Uint8Array)) throw new TypeError(`${trailText()}: expected Uint8Array`);
|
|
76
88
|
return base64Encode(value);
|
|
77
89
|
case "enum":
|
|
78
90
|
if (typeof value !== "string" && typeof value !== "number") {
|
|
79
|
-
throw new TypeError(`${
|
|
91
|
+
throw new TypeError(`${trailText()}: expected an enum value`);
|
|
80
92
|
}
|
|
81
93
|
return value;
|
|
82
94
|
case "struct": {
|
|
83
|
-
if (!isRecord(value)) throw new TypeError(`${
|
|
95
|
+
if (!isRecord(value)) throw new TypeError(`${trailText()}: expected ${wire.name}`);
|
|
84
96
|
var table = structs[wire.name];
|
|
85
|
-
if (!table) throw new TypeError(`${
|
|
97
|
+
if (!table) throw new TypeError(`${trailText()}: unknown struct ${wire.name}`);
|
|
98
|
+
var plain = plainStructs.get(table);
|
|
99
|
+
if (plain === void 0) {
|
|
100
|
+
plain = table.fields.every(function(field2) {
|
|
101
|
+
return field2.wire === void 0;
|
|
102
|
+
});
|
|
103
|
+
plainStructs.set(table, plain);
|
|
104
|
+
}
|
|
105
|
+
if (plain) {
|
|
106
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
107
|
+
try {
|
|
108
|
+
for (var _iterator = table.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
109
|
+
var field = _step.value;
|
|
110
|
+
if (value[field.name] === void 0 && !field.optional) {
|
|
111
|
+
trail.push(field.name);
|
|
112
|
+
throw new TypeError(`${trailText()}: required`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
_didIteratorError = true;
|
|
117
|
+
_iteratorError = err;
|
|
118
|
+
} finally {
|
|
119
|
+
try {
|
|
120
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
121
|
+
_iterator.return();
|
|
122
|
+
}
|
|
123
|
+
} finally {
|
|
124
|
+
if (_didIteratorError) {
|
|
125
|
+
throw _iteratorError;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
86
131
|
var out = {};
|
|
87
|
-
var
|
|
132
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
88
133
|
try {
|
|
89
134
|
var _loop = function() {
|
|
90
|
-
var key2 =
|
|
135
|
+
var key2 = _step1.value;
|
|
91
136
|
if (!table.fields.some(function(field2) {
|
|
92
137
|
return field2.name === key2;
|
|
93
138
|
})) out[key2] = value[key2];
|
|
94
139
|
};
|
|
95
|
-
for (var
|
|
140
|
+
for (var _iterator1 = Object.keys(value)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) _loop();
|
|
96
141
|
} catch (err) {
|
|
97
|
-
|
|
98
|
-
|
|
142
|
+
_didIteratorError1 = true;
|
|
143
|
+
_iteratorError1 = err;
|
|
99
144
|
} finally {
|
|
100
145
|
try {
|
|
101
|
-
if (!
|
|
102
|
-
|
|
146
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
147
|
+
_iterator1.return();
|
|
103
148
|
}
|
|
104
149
|
} finally {
|
|
105
|
-
if (
|
|
106
|
-
throw
|
|
150
|
+
if (_didIteratorError1) {
|
|
151
|
+
throw _iteratorError1;
|
|
107
152
|
}
|
|
108
153
|
}
|
|
109
154
|
}
|
|
110
|
-
var
|
|
155
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
111
156
|
try {
|
|
112
|
-
for (var
|
|
113
|
-
var
|
|
114
|
-
var present = value[
|
|
157
|
+
for (var _iterator2 = table.fields[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
158
|
+
var field1 = _step2.value;
|
|
159
|
+
var present = value[field1.name] !== void 0;
|
|
115
160
|
if (!present) {
|
|
116
|
-
if (!
|
|
161
|
+
if (!field1.optional) {
|
|
162
|
+
trail.push(field1.name);
|
|
163
|
+
throw new TypeError(`${trailText()}: required`);
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (field1.wire === void 0) {
|
|
168
|
+
out[field1.name] = value[field1.name];
|
|
117
169
|
continue;
|
|
118
170
|
}
|
|
119
|
-
|
|
171
|
+
trail.push(field1.name);
|
|
172
|
+
out[field1.name] = encodeValue(value[field1.name], field1.wire, structs);
|
|
173
|
+
trail.pop();
|
|
120
174
|
}
|
|
121
175
|
} catch (err) {
|
|
122
|
-
|
|
123
|
-
|
|
176
|
+
_didIteratorError2 = true;
|
|
177
|
+
_iteratorError2 = err;
|
|
124
178
|
} finally {
|
|
125
179
|
try {
|
|
126
|
-
if (!
|
|
127
|
-
|
|
180
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
181
|
+
_iterator2.return();
|
|
128
182
|
}
|
|
129
183
|
} finally {
|
|
130
|
-
if (
|
|
131
|
-
throw
|
|
184
|
+
if (_didIteratorError2) {
|
|
185
|
+
throw _iteratorError2;
|
|
132
186
|
}
|
|
133
187
|
}
|
|
134
188
|
}
|
|
135
189
|
return out;
|
|
136
190
|
}
|
|
137
|
-
case "array":
|
|
138
|
-
if (!Array.isArray(value)) throw new TypeError(`${
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
191
|
+
case "array": {
|
|
192
|
+
if (!Array.isArray(value)) throw new TypeError(`${trailText()}: expected an array`);
|
|
193
|
+
var out1 = new Array(value.length);
|
|
194
|
+
trail.push(0);
|
|
195
|
+
var at = trail.length - 1;
|
|
196
|
+
for (var index = 0; index < value.length; index++) {
|
|
197
|
+
trail[at] = index;
|
|
198
|
+
out1[index] = encodeValue(value[index], wire.element, structs);
|
|
199
|
+
}
|
|
200
|
+
trail.pop();
|
|
201
|
+
return out1;
|
|
202
|
+
}
|
|
142
203
|
case "map": {
|
|
143
|
-
if (!isRecord(value)) throw new TypeError(`${
|
|
144
|
-
var
|
|
145
|
-
var
|
|
204
|
+
if (!isRecord(value)) throw new TypeError(`${trailText()}: expected an object`);
|
|
205
|
+
var out2 = {};
|
|
206
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
146
207
|
try {
|
|
147
|
-
for (var
|
|
148
|
-
var key =
|
|
149
|
-
|
|
208
|
+
for (var _iterator3 = Object.keys(value)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
209
|
+
var key = _step3.value;
|
|
210
|
+
trail.push(key);
|
|
211
|
+
out2[key] = encodeValue(value[key], wire.value, structs);
|
|
212
|
+
trail.pop();
|
|
150
213
|
}
|
|
151
214
|
} catch (err) {
|
|
152
|
-
|
|
153
|
-
|
|
215
|
+
_didIteratorError3 = true;
|
|
216
|
+
_iteratorError3 = err;
|
|
154
217
|
} finally {
|
|
155
218
|
try {
|
|
156
|
-
if (!
|
|
157
|
-
|
|
219
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
220
|
+
_iterator3.return();
|
|
158
221
|
}
|
|
159
222
|
} finally {
|
|
160
|
-
if (
|
|
161
|
-
throw
|
|
223
|
+
if (_didIteratorError3) {
|
|
224
|
+
throw _iteratorError3;
|
|
162
225
|
}
|
|
163
226
|
}
|
|
164
227
|
}
|
|
165
|
-
return
|
|
228
|
+
return out2;
|
|
166
229
|
}
|
|
167
|
-
case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs
|
|
230
|
+
case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs);
|
|
168
231
|
}
|
|
169
232
|
}
|
|
170
233
|
function decodeValue(value, wire, structs, path) {
|
|
@@ -281,10 +344,15 @@ function decodeValue(value, wire, structs, path) {
|
|
|
281
344
|
case "nullable": return value === null || value === void 0 ? null : decodeValue(value, wire.inner, structs, path);
|
|
282
345
|
}
|
|
283
346
|
}
|
|
347
|
+
function encodeAt(path, value, wire, structs) {
|
|
348
|
+
trail.length = 0;
|
|
349
|
+
trail.push(...path);
|
|
350
|
+
return encodeValue(value, wire, structs);
|
|
351
|
+
}
|
|
284
352
|
function encodeNativeSourceArgs(args, wires, structs) {
|
|
285
353
|
return args.map(function(arg, index) {
|
|
286
354
|
var wire = wires[index];
|
|
287
|
-
return wire === void 0 || wire === null ? arg :
|
|
355
|
+
return wire === void 0 || wire === null ? arg : encodeAt(["args", index], arg, wire, structs);
|
|
288
356
|
});
|
|
289
357
|
}
|
|
290
358
|
function decodeNativeSourceResult(value, wire, structs) {
|
|
@@ -297,7 +365,7 @@ function encodeNativeSourceProps(props, wires, structs) {
|
|
|
297
365
|
for (var _iterator = Object.keys(wires)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
298
366
|
var name = _step.value;
|
|
299
367
|
if (out[name] === void 0) continue;
|
|
300
|
-
out[name] =
|
|
368
|
+
out[name] = encodeAt(["props", name], out[name], wires[name], structs);
|
|
301
369
|
}
|
|
302
370
|
} catch (err) {
|
|
303
371
|
_didIteratorError = true;
|
|
@@ -315,6 +383,41 @@ function encodeNativeSourceProps(props, wires, structs) {
|
|
|
315
383
|
}
|
|
316
384
|
return out;
|
|
317
385
|
}
|
|
386
|
+
function encodeNativeSourceProp(name, value, wires) {
|
|
387
|
+
var wire = wires === null || wires === void 0 ? void 0 : wires.props[name];
|
|
388
|
+
return wire === void 0 ? value : encodeAt(["props", name], value, wire, wires.structs);
|
|
389
|
+
}
|
|
390
|
+
function encodeNativeSourceListItem(name, index, item, element, structs) {
|
|
391
|
+
return encodeAt([
|
|
392
|
+
"props",
|
|
393
|
+
name,
|
|
394
|
+
index
|
|
395
|
+
], item, element, structs);
|
|
396
|
+
}
|
|
397
|
+
function stringifyNativeSourceProps(props, wires) {
|
|
398
|
+
var out = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : { ...props };
|
|
399
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
400
|
+
try {
|
|
401
|
+
for (var _iterator = Object.keys(out)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
402
|
+
var key = _step.value;
|
|
403
|
+
if (typeof out[key] === "function") out[key] = true;
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
_didIteratorError = true;
|
|
407
|
+
_iteratorError = err;
|
|
408
|
+
} finally {
|
|
409
|
+
try {
|
|
410
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
411
|
+
_iterator.return();
|
|
412
|
+
}
|
|
413
|
+
} finally {
|
|
414
|
+
if (_didIteratorError) {
|
|
415
|
+
throw _iteratorError;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return JSON.stringify(out);
|
|
420
|
+
}
|
|
318
421
|
function decodeNativeSourceCallback(args, wires, structs, event) {
|
|
319
422
|
return args.map(function(arg, index) {
|
|
320
423
|
var wire = wires[index];
|
|
@@ -27,7 +27,10 @@ __export(wire_native_exports, {
|
|
|
27
27
|
decodeNativeSourceCallback: () => decodeNativeSourceCallback,
|
|
28
28
|
decodeNativeSourceResult: () => decodeNativeSourceResult,
|
|
29
29
|
encodeNativeSourceArgs: () => encodeNativeSourceArgs,
|
|
30
|
-
|
|
30
|
+
encodeNativeSourceListItem: () => encodeNativeSourceListItem,
|
|
31
|
+
encodeNativeSourceProp: () => encodeNativeSourceProp,
|
|
32
|
+
encodeNativeSourceProps: () => encodeNativeSourceProps,
|
|
33
|
+
stringifyNativeSourceProps: () => stringifyNativeSourceProps
|
|
31
34
|
});
|
|
32
35
|
module.exports = __toCommonJS(wire_native_exports);
|
|
33
36
|
var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -66,105 +69,165 @@ function base64Decode(text) {
|
|
|
66
69
|
function isRecord(value) {
|
|
67
70
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
var trail = [];
|
|
73
|
+
function trailText() {
|
|
74
|
+
var text = String(trail[0]);
|
|
75
|
+
for (var i = 1; i < trail.length; i++) {
|
|
76
|
+
text += typeof trail[i] === "number" ? `[${trail[i]}]` : `.${trail[i]}`;
|
|
77
|
+
}
|
|
78
|
+
return text;
|
|
79
|
+
}
|
|
80
|
+
var plainStructs = /* @__PURE__ */ new WeakMap();
|
|
81
|
+
function encodeValue(value, wire, structs) {
|
|
70
82
|
switch (wire.kind) {
|
|
71
83
|
case "date":
|
|
72
|
-
if (!(value instanceof Date)) throw new TypeError(`${
|
|
84
|
+
if (!(value instanceof Date)) throw new TypeError(`${trailText()}: expected Date`);
|
|
73
85
|
return value;
|
|
74
86
|
case "data":
|
|
75
|
-
if (!(value instanceof Uint8Array)) throw new TypeError(`${
|
|
87
|
+
if (!(value instanceof Uint8Array)) throw new TypeError(`${trailText()}: expected Uint8Array`);
|
|
76
88
|
return base64Encode(value);
|
|
77
89
|
case "enum":
|
|
78
90
|
if (typeof value !== "string" && typeof value !== "number") {
|
|
79
|
-
throw new TypeError(`${
|
|
91
|
+
throw new TypeError(`${trailText()}: expected an enum value`);
|
|
80
92
|
}
|
|
81
93
|
return value;
|
|
82
94
|
case "struct": {
|
|
83
|
-
if (!isRecord(value)) throw new TypeError(`${
|
|
95
|
+
if (!isRecord(value)) throw new TypeError(`${trailText()}: expected ${wire.name}`);
|
|
84
96
|
var table = structs[wire.name];
|
|
85
|
-
if (!table) throw new TypeError(`${
|
|
97
|
+
if (!table) throw new TypeError(`${trailText()}: unknown struct ${wire.name}`);
|
|
98
|
+
var plain = plainStructs.get(table);
|
|
99
|
+
if (plain === void 0) {
|
|
100
|
+
plain = table.fields.every(function(field2) {
|
|
101
|
+
return field2.wire === void 0;
|
|
102
|
+
});
|
|
103
|
+
plainStructs.set(table, plain);
|
|
104
|
+
}
|
|
105
|
+
if (plain) {
|
|
106
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
107
|
+
try {
|
|
108
|
+
for (var _iterator = table.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
109
|
+
var field = _step.value;
|
|
110
|
+
if (value[field.name] === void 0 && !field.optional) {
|
|
111
|
+
trail.push(field.name);
|
|
112
|
+
throw new TypeError(`${trailText()}: required`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
_didIteratorError = true;
|
|
117
|
+
_iteratorError = err;
|
|
118
|
+
} finally {
|
|
119
|
+
try {
|
|
120
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
121
|
+
_iterator.return();
|
|
122
|
+
}
|
|
123
|
+
} finally {
|
|
124
|
+
if (_didIteratorError) {
|
|
125
|
+
throw _iteratorError;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
86
131
|
var out = {};
|
|
87
|
-
var
|
|
132
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
88
133
|
try {
|
|
89
134
|
var _loop = function() {
|
|
90
|
-
var key2 =
|
|
135
|
+
var key2 = _step1.value;
|
|
91
136
|
if (!table.fields.some(function(field2) {
|
|
92
137
|
return field2.name === key2;
|
|
93
138
|
})) out[key2] = value[key2];
|
|
94
139
|
};
|
|
95
|
-
for (var
|
|
140
|
+
for (var _iterator1 = Object.keys(value)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) _loop();
|
|
96
141
|
} catch (err) {
|
|
97
|
-
|
|
98
|
-
|
|
142
|
+
_didIteratorError1 = true;
|
|
143
|
+
_iteratorError1 = err;
|
|
99
144
|
} finally {
|
|
100
145
|
try {
|
|
101
|
-
if (!
|
|
102
|
-
|
|
146
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
147
|
+
_iterator1.return();
|
|
103
148
|
}
|
|
104
149
|
} finally {
|
|
105
|
-
if (
|
|
106
|
-
throw
|
|
150
|
+
if (_didIteratorError1) {
|
|
151
|
+
throw _iteratorError1;
|
|
107
152
|
}
|
|
108
153
|
}
|
|
109
154
|
}
|
|
110
|
-
var
|
|
155
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
111
156
|
try {
|
|
112
|
-
for (var
|
|
113
|
-
var
|
|
114
|
-
var present = value[
|
|
157
|
+
for (var _iterator2 = table.fields[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
158
|
+
var field1 = _step2.value;
|
|
159
|
+
var present = value[field1.name] !== void 0;
|
|
115
160
|
if (!present) {
|
|
116
|
-
if (!
|
|
161
|
+
if (!field1.optional) {
|
|
162
|
+
trail.push(field1.name);
|
|
163
|
+
throw new TypeError(`${trailText()}: required`);
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (field1.wire === void 0) {
|
|
168
|
+
out[field1.name] = value[field1.name];
|
|
117
169
|
continue;
|
|
118
170
|
}
|
|
119
|
-
|
|
171
|
+
trail.push(field1.name);
|
|
172
|
+
out[field1.name] = encodeValue(value[field1.name], field1.wire, structs);
|
|
173
|
+
trail.pop();
|
|
120
174
|
}
|
|
121
175
|
} catch (err) {
|
|
122
|
-
|
|
123
|
-
|
|
176
|
+
_didIteratorError2 = true;
|
|
177
|
+
_iteratorError2 = err;
|
|
124
178
|
} finally {
|
|
125
179
|
try {
|
|
126
|
-
if (!
|
|
127
|
-
|
|
180
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
181
|
+
_iterator2.return();
|
|
128
182
|
}
|
|
129
183
|
} finally {
|
|
130
|
-
if (
|
|
131
|
-
throw
|
|
184
|
+
if (_didIteratorError2) {
|
|
185
|
+
throw _iteratorError2;
|
|
132
186
|
}
|
|
133
187
|
}
|
|
134
188
|
}
|
|
135
189
|
return out;
|
|
136
190
|
}
|
|
137
|
-
case "array":
|
|
138
|
-
if (!Array.isArray(value)) throw new TypeError(`${
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
191
|
+
case "array": {
|
|
192
|
+
if (!Array.isArray(value)) throw new TypeError(`${trailText()}: expected an array`);
|
|
193
|
+
var out1 = new Array(value.length);
|
|
194
|
+
trail.push(0);
|
|
195
|
+
var at = trail.length - 1;
|
|
196
|
+
for (var index = 0; index < value.length; index++) {
|
|
197
|
+
trail[at] = index;
|
|
198
|
+
out1[index] = encodeValue(value[index], wire.element, structs);
|
|
199
|
+
}
|
|
200
|
+
trail.pop();
|
|
201
|
+
return out1;
|
|
202
|
+
}
|
|
142
203
|
case "map": {
|
|
143
|
-
if (!isRecord(value)) throw new TypeError(`${
|
|
144
|
-
var
|
|
145
|
-
var
|
|
204
|
+
if (!isRecord(value)) throw new TypeError(`${trailText()}: expected an object`);
|
|
205
|
+
var out2 = {};
|
|
206
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
146
207
|
try {
|
|
147
|
-
for (var
|
|
148
|
-
var key =
|
|
149
|
-
|
|
208
|
+
for (var _iterator3 = Object.keys(value)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
209
|
+
var key = _step3.value;
|
|
210
|
+
trail.push(key);
|
|
211
|
+
out2[key] = encodeValue(value[key], wire.value, structs);
|
|
212
|
+
trail.pop();
|
|
150
213
|
}
|
|
151
214
|
} catch (err) {
|
|
152
|
-
|
|
153
|
-
|
|
215
|
+
_didIteratorError3 = true;
|
|
216
|
+
_iteratorError3 = err;
|
|
154
217
|
} finally {
|
|
155
218
|
try {
|
|
156
|
-
if (!
|
|
157
|
-
|
|
219
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
220
|
+
_iterator3.return();
|
|
158
221
|
}
|
|
159
222
|
} finally {
|
|
160
|
-
if (
|
|
161
|
-
throw
|
|
223
|
+
if (_didIteratorError3) {
|
|
224
|
+
throw _iteratorError3;
|
|
162
225
|
}
|
|
163
226
|
}
|
|
164
227
|
}
|
|
165
|
-
return
|
|
228
|
+
return out2;
|
|
166
229
|
}
|
|
167
|
-
case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs
|
|
230
|
+
case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs);
|
|
168
231
|
}
|
|
169
232
|
}
|
|
170
233
|
function decodeValue(value, wire, structs, path) {
|
|
@@ -281,10 +344,15 @@ function decodeValue(value, wire, structs, path) {
|
|
|
281
344
|
case "nullable": return value === null || value === void 0 ? null : decodeValue(value, wire.inner, structs, path);
|
|
282
345
|
}
|
|
283
346
|
}
|
|
347
|
+
function encodeAt(path, value, wire, structs) {
|
|
348
|
+
trail.length = 0;
|
|
349
|
+
trail.push(...path);
|
|
350
|
+
return encodeValue(value, wire, structs);
|
|
351
|
+
}
|
|
284
352
|
function encodeNativeSourceArgs(args, wires, structs) {
|
|
285
353
|
return args.map(function(arg, index) {
|
|
286
354
|
var wire = wires[index];
|
|
287
|
-
return wire === void 0 || wire === null ? arg :
|
|
355
|
+
return wire === void 0 || wire === null ? arg : encodeAt(["args", index], arg, wire, structs);
|
|
288
356
|
});
|
|
289
357
|
}
|
|
290
358
|
function decodeNativeSourceResult(value, wire, structs) {
|
|
@@ -297,7 +365,7 @@ function encodeNativeSourceProps(props, wires, structs) {
|
|
|
297
365
|
for (var _iterator = Object.keys(wires)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
298
366
|
var name = _step.value;
|
|
299
367
|
if (out[name] === void 0) continue;
|
|
300
|
-
out[name] =
|
|
368
|
+
out[name] = encodeAt(["props", name], out[name], wires[name], structs);
|
|
301
369
|
}
|
|
302
370
|
} catch (err) {
|
|
303
371
|
_didIteratorError = true;
|
|
@@ -315,6 +383,41 @@ function encodeNativeSourceProps(props, wires, structs) {
|
|
|
315
383
|
}
|
|
316
384
|
return out;
|
|
317
385
|
}
|
|
386
|
+
function encodeNativeSourceProp(name, value, wires) {
|
|
387
|
+
var wire = wires === null || wires === void 0 ? void 0 : wires.props[name];
|
|
388
|
+
return wire === void 0 ? value : encodeAt(["props", name], value, wire, wires.structs);
|
|
389
|
+
}
|
|
390
|
+
function encodeNativeSourceListItem(name, index, item, element, structs) {
|
|
391
|
+
return encodeAt([
|
|
392
|
+
"props",
|
|
393
|
+
name,
|
|
394
|
+
index
|
|
395
|
+
], item, element, structs);
|
|
396
|
+
}
|
|
397
|
+
function stringifyNativeSourceProps(props, wires) {
|
|
398
|
+
var out = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : { ...props };
|
|
399
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
400
|
+
try {
|
|
401
|
+
for (var _iterator = Object.keys(out)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
402
|
+
var key = _step.value;
|
|
403
|
+
if (typeof out[key] === "function") out[key] = true;
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
_didIteratorError = true;
|
|
407
|
+
_iteratorError = err;
|
|
408
|
+
} finally {
|
|
409
|
+
try {
|
|
410
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
411
|
+
_iterator.return();
|
|
412
|
+
}
|
|
413
|
+
} finally {
|
|
414
|
+
if (_didIteratorError) {
|
|
415
|
+
throw _iteratorError;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return JSON.stringify(out);
|
|
420
|
+
}
|
|
318
421
|
function decodeNativeSourceCallback(args, wires, structs, event) {
|
|
319
422
|
return args.map(function(arg, index) {
|
|
320
423
|
var wire = wires[index];
|