one 2.13.10 → 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.
Files changed (43) hide show
  1. package/android/src/main/java/dev/onejs/one/OneKotlinHostView.kt +53 -14
  2. package/android/src/main/java/dev/onejs/one/OneNativeSourceKeyedState.kt +23 -0
  3. package/android/src/main/java/dev/onejs/one/OneNativeSourceViewDispatch.kt +16 -3
  4. package/dist/cjs/platform/native-source/view.native.cjs +4 -4
  5. package/dist/cjs/platform/native-source/view.native.js +4 -4
  6. package/dist/cjs/platform/native-source/view.native.js.map +1 -1
  7. package/dist/cjs/platform/native-source/wire.native.cjs +152 -49
  8. package/dist/cjs/platform/native-source/wire.native.js +152 -49
  9. package/dist/cjs/platform/native-source/wire.native.js.map +1 -1
  10. package/dist/cjs/platform/native-source/wireProps.native.cjs +138 -0
  11. package/dist/cjs/platform/native-source/wireProps.native.js +140 -0
  12. package/dist/cjs/platform/native-source/wireProps.native.js.map +1 -0
  13. package/dist/cjs/platform/swift/index.native.cjs +12 -8
  14. package/dist/cjs/platform/swift/index.native.js +12 -8
  15. package/dist/cjs/platform/swift/index.native.js.map +1 -1
  16. package/dist/esm/platform/native-source/view.native.js +5 -5
  17. package/dist/esm/platform/native-source/view.native.js.map +1 -1
  18. package/dist/esm/platform/native-source/wire.native.js +149 -49
  19. package/dist/esm/platform/native-source/wire.native.js.map +1 -1
  20. package/dist/esm/platform/native-source/wireProps.native.js +113 -0
  21. package/dist/esm/platform/native-source/wireProps.native.js.map +1 -0
  22. package/dist/esm/platform/swift/index.native.js +13 -9
  23. package/dist/esm/platform/swift/index.native.js.map +1 -1
  24. package/ios/OneNativeComposition.swift +1 -0
  25. package/ios/OneNativeHostingController.swift +113 -0
  26. package/ios/OneSwiftHostComponentView.mm +28 -4
  27. package/ios/OneSwiftHostView.swift +63 -9
  28. package/ios/OneSwiftPackage.swift +6 -1
  29. package/package.json +13 -13
  30. package/src/platform/native-source/view.native.tsx +4 -5
  31. package/src/platform/native-source/wire.native.ts +108 -26
  32. package/src/platform/native-source/wireProps.native.test.ts +57 -0
  33. package/src/platform/native-source/wireProps.native.ts +124 -0
  34. package/src/platform/swift/index.native.tsx +9 -7
  35. package/src/platform/swift/types.ts +4 -2
  36. package/types/platform/native-source/view.native.d.ts.map +1 -1
  37. package/types/platform/native-source/wire.native.d.ts +3 -0
  38. package/types/platform/native-source/wire.native.d.ts.map +1 -1
  39. package/types/platform/native-source/wireProps.native.d.ts +15 -0
  40. package/types/platform/native-source/wireProps.native.d.ts.map +1 -0
  41. package/types/platform/swift/index.native.d.ts.map +1 -1
  42. package/types/platform/swift/types.d.ts +4 -1
  43. package/types/platform/swift/types.d.ts.map +1 -1
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var wireProps_native_exports = {};
24
+ __export(wireProps_native_exports, {
25
+ RESYNC_EVENT: () => RESYNC_EVENT,
26
+ nextDocument: () => nextDocument,
27
+ useNativeSourceProps: () => useNativeSourceProps
28
+ });
29
+ module.exports = __toCommonJS(wireProps_native_exports);
30
+ var import_react = require("react");
31
+ var import_wire = require("./wire.native.js");
32
+ var MIN_LIST = 32;
33
+ var RESYNC_EVENT = "$resync";
34
+ function listElement(wire) {
35
+ if (wire === void 0) return void 0;
36
+ if (wire.kind === "array") return wire.element;
37
+ if (wire.kind === "nullable") return listElement(wire.inner);
38
+ return null;
39
+ }
40
+ function nextDocument(props, wires, prev, full) {
41
+ var _ref;
42
+ var whole = full || prev === null;
43
+ var seq = ((_ref = prev === null || prev === void 0 ? void 0 : prev.seq) !== null && _ref !== void 0 ? _ref : 0) + 1;
44
+ var lists = {};
45
+ var texts = {};
46
+ var entries = [];
47
+ var patches = {};
48
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
49
+ try {
50
+ var _loop = function() {
51
+ var name2 = _step.value;
52
+ var value = props[name2];
53
+ if (value === void 0) return "continue";
54
+ var element = listElement(wires === null || wires === void 0 ? void 0 : wires.props[name2]);
55
+ if (Array.isArray(value) && value.length >= MIN_LIST && element !== null) {
56
+ lists[name2] = value;
57
+ var before = prev === null || prev === void 0 ? void 0 : prev.lists[name2];
58
+ if (!whole && before) {
59
+ var indices = [];
60
+ for (var i = 0; i < value.length; i++) {
61
+ if (i >= before.length || before[i] !== value[i]) indices.push(i);
62
+ }
63
+ if (indices.length === 0 && before.length === value.length) return "continue";
64
+ if (indices.length * 2 < value.length) {
65
+ patches[name2] = {
66
+ length: value.length,
67
+ set: indices.map(function(i2) {
68
+ return [i2, element === void 0 ? value[i2] : (0, import_wire.encodeNativeSourceListItem)(name2, i2, value[i2], element, wires.structs)];
69
+ })
70
+ };
71
+ return "continue";
72
+ }
73
+ }
74
+ entries.push(`${JSON.stringify(name2)}:${JSON.stringify((0, import_wire.encodeNativeSourceProp)(name2, value, wires))}`);
75
+ return "continue";
76
+ }
77
+ var text = typeof value === "function" ? "true" : JSON.stringify((0, import_wire.encodeNativeSourceProp)(name2, value, wires));
78
+ texts[name2] = text;
79
+ if (!whole && prev.texts[name2] === text) return "continue";
80
+ entries.push(`${JSON.stringify(name2)}:${text}`);
81
+ };
82
+ for (var _iterator = Object.keys(props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
83
+ } catch (err) {
84
+ _didIteratorError = true;
85
+ _iteratorError = err;
86
+ } finally {
87
+ try {
88
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
89
+ _iterator.return();
90
+ }
91
+ } finally {
92
+ if (_didIteratorError) {
93
+ throw _iteratorError;
94
+ }
95
+ }
96
+ }
97
+ if (!whole) {
98
+ for (var _i = 0, _iter = [...Object.keys(prev.texts), ...Object.keys(prev.lists)]; _i < _iter.length; _i++) {
99
+ var name = _iter[_i];
100
+ if (!(name in texts) && !(name in lists)) entries.push(`${JSON.stringify(name)}:null`);
101
+ }
102
+ if (entries.length === 0 && Object.keys(patches).length === 0) return null;
103
+ if (Object.keys(patches).length > 0) entries.push(`"$lists":${JSON.stringify(patches)}`);
104
+ }
105
+ var head = whole ? `"$seq":${seq}` : `"$seq":${seq},"$base":${prev.seq}`;
106
+ return {
107
+ seq,
108
+ text: `{${[head, ...entries].join(",")}}`,
109
+ lists,
110
+ texts
111
+ };
112
+ }
113
+ function useNativeSourceProps(props, wires, keyed) {
114
+ var sent = (0, import_react.useRef)(null);
115
+ var needFull = (0, import_react.useRef)(false);
116
+ var [, rerender] = (0, import_react.useState)(0);
117
+ var next = keyed ? nextDocument(props, wires, sent.current, needFull.current) : null;
118
+ (0, import_react.useLayoutEffect)(function() {
119
+ if (next) {
120
+ sent.current = next;
121
+ needFull.current = false;
122
+ }
123
+ });
124
+ var resync = function resync2() {
125
+ needFull.current = true;
126
+ rerender(function(n) {
127
+ return n + 1;
128
+ });
129
+ };
130
+ if (!keyed) return {
131
+ text: (0, import_wire.stringifyNativeSourceProps)(props, wires),
132
+ resync
133
+ };
134
+ return {
135
+ text: (next !== null && next !== void 0 ? next : sent.current).text,
136
+ resync
137
+ };
138
+ }
139
+
140
+ //# sourceMappingURL=wireProps.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireProps.native.js","names":[],"sources":["cjs/platform/native-source/wireProps.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar wireProps_native_exports = {};\n__export(wireProps_native_exports, {\n RESYNC_EVENT: () => RESYNC_EVENT,\n nextDocument: () => nextDocument,\n useNativeSourceProps: () => useNativeSourceProps\n});\nmodule.exports = __toCommonJS(wireProps_native_exports);\nvar import_react = require(\"react\");\nvar import_wire = require(\"./wire.native\");\nvar MIN_LIST = 32;\nvar RESYNC_EVENT = \"$resync\";\nfunction listElement(wire) {\n if (wire === void 0) return void 0;\n if (wire.kind === \"array\") return wire.element;\n if (wire.kind === \"nullable\") return listElement(wire.inner);\n return null;\n}\nfunction nextDocument(props, wires, prev, full) {\n var _ref;\n var whole = full || prev === null;\n var seq = ((_ref = prev === null || prev === void 0 ? void 0 : prev.seq) !== null && _ref !== void 0 ? _ref : 0) + 1;\n var lists = {};\n var texts = {};\n var entries = [];\n var patches = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n var _loop = function() {\n var name2 = _step.value;\n var value = props[name2];\n if (value === void 0) return \"continue\";\n var element = listElement(wires === null || wires === void 0 ? void 0 : wires.props[name2]);\n if (Array.isArray(value) && value.length >= MIN_LIST && element !== null) {\n lists[name2] = value;\n var before = prev === null || prev === void 0 ? void 0 : prev.lists[name2];\n if (!whole && before) {\n var indices = [];\n for (var i = 0; i < value.length; i++) {\n if (i >= before.length || before[i] !== value[i]) indices.push(i);\n }\n if (indices.length === 0 && before.length === value.length) return \"continue\";\n if (indices.length * 2 < value.length) {\n patches[name2] = {\n length: value.length,\n set: indices.map(function(i2) {\n return [\n i2,\n element === void 0 ? value[i2] : (0, import_wire.encodeNativeSourceListItem)(name2, i2, value[i2], element, wires.structs)\n ];\n })\n };\n return \"continue\";\n }\n }\n entries.push(`${JSON.stringify(name2)}:${JSON.stringify((0, import_wire.encodeNativeSourceProp)(name2, value, wires))}`);\n return \"continue\";\n }\n var text = typeof value === \"function\" ? \"true\" : JSON.stringify((0, import_wire.encodeNativeSourceProp)(name2, value, wires));\n texts[name2] = text;\n if (!whole && prev.texts[name2] === text) return \"continue\";\n entries.push(`${JSON.stringify(name2)}:${text}`);\n };\n for (var _iterator = Object.keys(props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (!whole) {\n for (var _i = 0, _iter = [\n ...Object.keys(prev.texts),\n ...Object.keys(prev.lists)\n ]; _i < _iter.length; _i++) {\n var name = _iter[_i];\n if (!(name in texts) && !(name in lists)) entries.push(`${JSON.stringify(name)}:null`);\n }\n if (entries.length === 0 && Object.keys(patches).length === 0) return null;\n if (Object.keys(patches).length > 0) entries.push(`\"$lists\":${JSON.stringify(patches)}`);\n }\n var head = whole ? `\"$seq\":${seq}` : `\"$seq\":${seq},\"$base\":${prev.seq}`;\n return {\n seq,\n text: `{${[\n head,\n ...entries\n ].join(\",\")}}`,\n lists,\n texts\n };\n}\nfunction useNativeSourceProps(props, wires, keyed) {\n var sent = (0, import_react.useRef)(null);\n var needFull = (0, import_react.useRef)(false);\n var [, rerender] = (0, import_react.useState)(0);\n var next = keyed ? nextDocument(props, wires, sent.current, needFull.current) : null;\n (0, import_react.useLayoutEffect)(function() {\n if (next) {\n sent.current = next;\n needFull.current = false;\n }\n });\n var resync = function resync2() {\n needFull.current = true;\n rerender(function(n) {\n return n + 1;\n });\n };\n if (!keyed) return {\n text: (0, import_wire.stringifyNativeSourceProps)(props, wires),\n resync\n };\n return {\n text: (next !== null && next !== void 0 ? next : sent.current).text,\n resync\n };\n}\n//# sourceMappingURL=wireProps.native.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,2BAA2B,CAAC;AAChC,SAAS,0BAA0B;CACjC,oBAAoB;CACpB,oBAAoB;CACpB,4BAA4B;AAC9B,CAAC;AACD,OAAO,UAAU,aAAa,wBAAwB;AACtD,IAAI,eAAe,QAAQ,OAAO;AAClC,IAAI,cAAc,QAAQ,kBAAe;AACzC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G,KAAK,UAAU,IAAI,EAAE,MAAM;EACvF;EACA,IAAI,QAAQ,WAAW,KAAK,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,GAAG,OAAO;EACtE,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,QAAQ,KAAK,YAAY,KAAK,UAAU,OAAO,GAAG;CACzF;CACA,IAAI,OAAO,QAAQ,UAAU,QAAQ,UAAU,IAAI,WAAW,KAAK;CACnE,OAAO;EACL;EACA,MAAM,IAAI,CACR,MACA,GAAG,OACL,CAAC,CAAC,KAAK,GAAG,EAAE;EACZ;EACA;CACF;AACF;AACA,SAAS,qBAAqB,OAAO,OAAO,OAAO;CACjD,IAAI,QAAQ,GAAG,aAAa,OAAM,CAAE,IAAI;CACxC,IAAI,YAAY,GAAG,aAAa,OAAM,CAAE,KAAK;CAC7C,IAAI,GAAG,aAAa,GAAG,aAAa,SAAQ,CAAE,CAAC;CAC/C,IAAI,OAAO,QAAQ,aAAa,OAAO,OAAO,KAAK,SAAS,SAAS,OAAO,IAAI;CAChF,CAAC,GAAG,aAAa,gBAAe,CAAE,WAAW;EAC3C,IAAI,MAAM;GACR,KAAK,UAAU;GACf,SAAS,UAAU;EACrB;CACF,CAAC;CACD,IAAI,SAAS,SAAS,UAAU;EAC9B,SAAS,UAAU;EACnB,SAAS,SAAS,GAAG;GACnB,OAAO,IAAI;EACb,CAAC;CACH;CACA,IAAI,CAAC,OAAO,OAAO;EACjB,OAAO,GAAG,YAAY,2BAA0B,CAAE,OAAO,KAAK;EAC9D;CACF;CACA,OAAO;EACL,OAAO,SAAS,QAAQ,SAAS,KAAK,IAAI,OAAO,KAAK,QAAO,CAAE;EAC/D;CACF;AACF"}
@@ -30,28 +30,32 @@ var index_native_exports = {};
30
30
  __export(index_native_exports, { SwiftPackageView: () => SwiftPackageView });
31
31
  module.exports = __toCommonJS(index_native_exports);
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
+ var import_react_native = require("react-native");
33
34
  var import_OneSwiftHostNativeComponent = __toESM(require("../specs/OneSwiftHostNativeComponent.native.js"), 1);
34
35
  var import_wire = require("../native-source/wire.native.js");
36
+ var import_wireProps = require("../native-source/wireProps.native.js");
35
37
  function SwiftPackageView(param) {
36
38
  var { packageName, view, contractHash, props, fill, wires } = param;
37
- var encoded = wires ? (0, import_wire.encodeNativeSourceProps)(props, wires.props, wires.structs) : props;
39
+ var _ref, _ref1;
40
+ var keyed = (0, import_wireProps.useNativeSourceProps)(props, wires, view !== "");
41
+ var style = import_react_native.StyleSheet.flatten(props.style);
42
+ var fills = fill || ((_ref = style === null || style === void 0 ? void 0 : style.flex) !== null && _ref !== void 0 ? _ref : 0) > 0 || ((_ref1 = style === null || style === void 0 ? void 0 : style.flexGrow) !== null && _ref1 !== void 0 ? _ref1 : 0) > 0;
38
43
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneSwiftHostNativeComponent.default, {
39
44
  packageName,
40
45
  view,
41
46
  contractHash,
42
- props: JSON.stringify(encoded, function(_key, value) {
43
- return typeof value === "function" ? true : value;
44
- }),
45
- fill,
47
+ props: keyed.text,
48
+ fill: fills,
46
49
  onHostEvent: function onHostEvent(event) {
50
+ if (event.nativeEvent.name === import_wireProps.RESYNC_EVENT) return keyed.resync();
47
51
  var callback = props[event.nativeEvent.name];
48
52
  if (typeof callback === "function") {
49
- var _ref;
53
+ var _ref2;
50
54
  var args = JSON.parse(event.nativeEvent.args);
51
55
  var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];
52
- callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);
56
+ callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref2 = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref2 !== void 0 ? _ref2 : {}, event.nativeEvent.name) : args);
53
57
  }
54
58
  },
55
- style: fill ? { flex: 1 } : void 0
59
+ style: fill ? { flex: 1 } : style
56
60
  });
57
61
  }
@@ -30,29 +30,33 @@ var index_native_exports = {};
30
30
  __export(index_native_exports, { SwiftPackageView: () => SwiftPackageView });
31
31
  module.exports = __toCommonJS(index_native_exports);
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
+ var import_react_native = require("react-native");
33
34
  var import_OneSwiftHostNativeComponent = __toESM(require("../specs/OneSwiftHostNativeComponent.native.js"), 1);
34
35
  var import_wire = require("../native-source/wire.native.js");
36
+ var import_wireProps = require("../native-source/wireProps.native.js");
35
37
  function SwiftPackageView(param) {
36
38
  var { packageName, view, contractHash, props, fill, wires } = param;
37
- var encoded = wires ? (0, import_wire.encodeNativeSourceProps)(props, wires.props, wires.structs) : props;
39
+ var _ref, _ref1;
40
+ var keyed = (0, import_wireProps.useNativeSourceProps)(props, wires, view !== "");
41
+ var style = import_react_native.StyleSheet.flatten(props.style);
42
+ var fills = fill || ((_ref = style === null || style === void 0 ? void 0 : style.flex) !== null && _ref !== void 0 ? _ref : 0) > 0 || ((_ref1 = style === null || style === void 0 ? void 0 : style.flexGrow) !== null && _ref1 !== void 0 ? _ref1 : 0) > 0;
38
43
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneSwiftHostNativeComponent.default, {
39
44
  packageName,
40
45
  view,
41
46
  contractHash,
42
- props: JSON.stringify(encoded, function(_key, value) {
43
- return typeof value === "function" ? true : value;
44
- }),
45
- fill,
47
+ props: keyed.text,
48
+ fill: fills,
46
49
  onHostEvent: function onHostEvent(event) {
50
+ if (event.nativeEvent.name === import_wireProps.RESYNC_EVENT) return keyed.resync();
47
51
  var callback = props[event.nativeEvent.name];
48
52
  if (typeof callback === "function") {
49
- var _ref;
53
+ var _ref2;
50
54
  var args = JSON.parse(event.nativeEvent.args);
51
55
  var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];
52
- callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);
56
+ callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref2 = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref2 !== void 0 ? _ref2 : {}, event.nativeEvent.name) : args);
53
57
  }
54
58
  },
55
- style: fill ? { flex: 1 } : void 0
59
+ style: fill ? { flex: 1 } : style
56
60
  });
57
61
  }
58
62
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["cjs/platform/swift/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_native_exports = {};\n__export(index_native_exports, {\n SwiftPackageView: () => SwiftPackageView\n});\nmodule.exports = __toCommonJS(index_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_OneSwiftHostNativeComponent = __toESM(require(\"../specs/OneSwiftHostNativeComponent\"), 1);\nvar import_wire = require(\"../native-source/wire.native\");\nfunction SwiftPackageView(param) {\n var { packageName, view, contractHash, props, fill, wires } = param;\n var encoded = wires ? (0, import_wire.encodeNativeSourceProps)(props, wires.props, wires.structs) : props;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneSwiftHostNativeComponent.default, {\n packageName,\n view,\n contractHash,\n // a typed view's host learns which callbacks the element passed\n props: JSON.stringify(encoded, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n fill,\n onHostEvent: function onHostEvent(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") {\n var _ref;\n var args = JSON.parse(event.nativeEvent.args);\n var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];\n callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);\n }\n },\n style: fill ? {\n flex: 1\n } : void 0\n });\n}\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAA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W,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,UAAU,MAAM,YAAY;IAC/F,SAAS,GAAG,YAAY,GAAG,YAAY,2BAA0B,CAAE,MAAM,WAAW,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,aAAa,QAAQ,SAAS,KAAK,IAAI,OAAO,CAAC,GAAG,MAAM,YAAY,IAAI,IAAI,IAAI;GACjO;EACF;EACA,OAAO,OAAO,EACZ,MAAM,EACR,IAAI,KAAK;CACX,CAAC;AACH"}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/platform/swift/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_native_exports = {};\n__export(index_native_exports, {\n SwiftPackageView: () => SwiftPackageView\n});\nmodule.exports = __toCommonJS(index_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_react_native = require(\"react-native\");\nvar import_OneSwiftHostNativeComponent = __toESM(require(\"../specs/OneSwiftHostNativeComponent\"), 1);\nvar import_wire = require(\"../native-source/wire.native\");\nvar import_wireProps = require(\"../native-source/wireProps.native\");\nfunction SwiftPackageView(param) {\n var { packageName, view, contractHash, props, fill, wires } = param;\n var _ref, _ref1;\n var keyed = (0, import_wireProps.useNativeSourceProps)(props, wires, view !== \"\");\n var style = import_react_native.StyleSheet.flatten(props.style);\n var fills = fill || ((_ref = style === null || style === void 0 ? void 0 : style.flex) !== null && _ref !== void 0 ? _ref : 0) > 0 || ((_ref1 = style === null || style === void 0 ? void 0 : style.flexGrow) !== null && _ref1 !== void 0 ? _ref1 : 0) > 0;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneSwiftHostNativeComponent.default, {\n packageName,\n view,\n contractHash,\n // a typed view's host learns which callbacks the element passed\n props: keyed.text,\n fill: fills,\n onHostEvent: function onHostEvent(event) {\n if (event.nativeEvent.name === import_wireProps.RESYNC_EVENT) return keyed.resync();\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") {\n var _ref2;\n var args = JSON.parse(event.nativeEvent.args);\n var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];\n callback(...argWires ? (0, import_wire.decodeNativeSourceCallback)(args, argWires, (_ref2 = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref2 !== void 0 ? _ref2 : {}, event.nativeEvent.name) : args);\n }\n },\n style: fill ? {\n flex: 1\n } : style\n });\n}\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,Q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,oBAAoB,WAAW,QAAQ,MAAM,KAAK;CAC9D,IAAI,QAAQ,UAAU,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,UAAU,QAAQ,SAAS,KAAK,IAAI,OAAO,KAAK,OAAO,QAAQ,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,cAAc,QAAQ,UAAU,KAAK,IAAI,QAAQ,KAAK;CAC1P,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,mCAAmC,SAAS;EAC7F;EACA;EACA;EAEA,OAAO,MAAM;EACb,MAAM;EACN,aAAa,SAAS,YAAY,OAAO;GACvC,IAAI,MAAM,YAAY,SAAS,iBAAiB,cAAc,OAAO,MAAM,OAAO;GAClF,IAAI,WAAW,MAAM,MAAM,YAAY;GACvC,IAAI,OAAO,aAAa,YAAY;IAClC,IAAI;IACJ,IAAI,OAAO,KAAK,MAAM,MAAM,YAAY,IAAI;IAC5C,IAAI,WAAW,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,UAAU,MAAM,YAAY;IAC/F,SAAS,GAAG,YAAY,GAAG,YAAY,2BAA0B,CAAE,MAAM,WAAW,QAAQ,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,aAAa,QAAQ,UAAU,KAAK,IAAI,QAAQ,CAAC,GAAG,MAAM,YAAY,IAAI,IAAI,IAAI;GACpO;EACF;EACA,OAAO,OAAO,EACZ,MAAM,EACR,IAAI;CACN,CAAC;AACH"}
@@ -2,12 +2,13 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { StyleSheet, View } from "react-native";
4
4
  import NativeKotlinHost from "../specs/OneKotlinHostNativeComponent.native.js";
5
- import { decodeNativeSourceCallback, encodeNativeSourceProps } from "./wire.native.js";
5
+ import { decodeNativeSourceCallback } from "./wire.native.js";
6
+ import { RESYNC_EVENT, useNativeSourceProps } from "./wireProps.native.js";
6
7
 
7
8
  function KotlinSourceView(param) {
8
9
  var { source, view, contractHash, props, wires } = param;
10
+ var keyed = useNativeSourceProps(props, wires, view !== "");
9
11
  var [contentSize, setContentSize] = useState();
10
- var encoded = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : props;
11
12
  return /* @__PURE__ */ jsxs(View, {
12
13
  style: props.style,
13
14
  collapsable: false,
@@ -18,10 +19,9 @@ function KotlinSourceView(param) {
18
19
  source,
19
20
  view,
20
21
  contractHash,
21
- props: JSON.stringify(encoded, function(_key, value) {
22
- return typeof value === "function" ? true : value;
23
- }),
22
+ props: keyed.text,
24
23
  onHostEvent: function onHostEvent(event) {
24
+ if (event.nativeEvent.name === RESYNC_EVENT) return keyed.resync();
25
25
  var callback = props[event.nativeEvent.name];
26
26
  if (typeof callback === "function") {
27
27
  var _ref;
@@ -1 +1 @@
1
- {"version":3,"file":"view.native.js","names":[],"sources":["esm/platform/native-source/view.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useState } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport NativeKotlinHost from \"../specs/OneKotlinHostNativeComponent\";\nimport { decodeNativeSourceCallback, encodeNativeSourceProps } from \"./wire.native\";\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props, wires } = param;\n var [contentSize, setContentSize] = useState();\n var encoded = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : props;\n return /* @__PURE__ */ _jsxs(View, {\n style: props.style,\n collapsable: false,\n children: [\n /* yoga uses the natural child size while retaining parent flex and stretch. */\n /* @__PURE__ */ _jsx(View, {\n pointerEvents: \"none\",\n style: contentSize\n }),\n /* @__PURE__ */ _jsx(NativeKotlinHost, {\n source,\n view,\n contractHash,\n props: JSON.stringify(encoded, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n onHostEvent: function onHostEvent(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") {\n var _ref;\n var args = JSON.parse(event.nativeEvent.args);\n var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];\n callback(...argWires ? decodeNativeSourceCallback(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);\n }\n },\n onHostSizeChange: function onHostSizeChange(event) {\n setContentSize({\n width: event.nativeEvent.width,\n height: event.nativeEvent.height\n });\n },\n style: StyleSheet.absoluteFill\n })\n ]\n });\n}\nexport {\n KotlinSourceView\n};\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,iBAAiB,OAAO;CAC/B,IAAI,EAAE,QAAQ,MAAM,cAAc,OAAO,UAAU;CACnD,IAAI,CAAC,aAAa,kBAAkB,SAAS;CAC7C,IAAI,UAAU,QAAQ,wBAAwB,OAAO,MAAM,OAAO,MAAM,OAAO,IAAI;CACnF,OAAuB,qBAAM,MAAM;EACjC,OAAO,MAAM;EACb,aAAa;EACb,UAAU,CAEQ,oBAAK,MAAM;GACzB,eAAe;GACf,OAAO;EACT,CAAC,GACe,oBAAK,kBAAkB;GACrC;GACA;GACA;GACA,OAAO,KAAK,UAAU,SAAS,SAAS,MAAM,OAAO;IACnD,OAAO,OAAO,UAAU,aAAa,OAAO;GAC9C,CAAC;GACD,aAAa,SAAS,YAAY,OAAO;IACvC,IAAI,WAAW,MAAM,MAAM,YAAY;IACvC,IAAI,OAAO,aAAa,YAAY;KAClC,IAAI;KACJ,IAAI,OAAO,KAAK,MAAM,MAAM,YAAY,IAAI;KAC5C,IAAI,WAAW,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,UAAU,MAAM,YAAY;KAC/F,SAAS,GAAG,WAAW,2BAA2B,MAAM,WAAW,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,aAAa,QAAQ,SAAS,KAAK,IAAI,OAAO,CAAC,GAAG,MAAM,YAAY,IAAI,IAAI,IAAI;IAChN;GACF;GACA,kBAAkB,SAAS,iBAAiB,OAAO;IACjD,eAAe;KACb,OAAO,MAAM,YAAY;KACzB,QAAQ,MAAM,YAAY;IAC5B,CAAC;GACH;GACA,OAAO,WAAW;EACpB,CAAC,CACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"view.native.js","names":[],"sources":["esm/platform/native-source/view.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useState } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport NativeKotlinHost from \"../specs/OneKotlinHostNativeComponent\";\nimport { decodeNativeSourceCallback } from \"./wire.native\";\nimport { RESYNC_EVENT, useNativeSourceProps } from \"./wireProps.native\";\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props, wires } = param;\n var keyed = useNativeSourceProps(props, wires, view !== \"\");\n var [contentSize, setContentSize] = useState();\n return /* @__PURE__ */ _jsxs(View, {\n style: props.style,\n collapsable: false,\n children: [\n /* yoga uses the natural child size while retaining parent flex and stretch. */\n /* @__PURE__ */ _jsx(View, {\n pointerEvents: \"none\",\n style: contentSize\n }),\n /* @__PURE__ */ _jsx(NativeKotlinHost, {\n source,\n view,\n contractHash,\n props: keyed.text,\n onHostEvent: function onHostEvent(event) {\n if (event.nativeEvent.name === RESYNC_EVENT) return keyed.resync();\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") {\n var _ref;\n var args = JSON.parse(event.nativeEvent.args);\n var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];\n callback(...argWires ? decodeNativeSourceCallback(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);\n }\n },\n onHostSizeChange: function onHostSizeChange(event) {\n setContentSize({\n width: event.nativeEvent.width,\n height: event.nativeEvent.height\n });\n },\n style: StyleSheet.absoluteFill\n })\n ]\n });\n}\nexport {\n KotlinSourceView\n};\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;;;;;;AAMA,SAAS,iBAAiB,OAAO;CAC/B,IAAI,EAAE,QAAQ,MAAM,cAAc,OAAO,UAAU;CACnD,IAAI,QAAQ,qBAAqB,OAAO,OAAO,SAAS,EAAE;CAC1D,IAAI,CAAC,aAAa,kBAAkB,SAAS;CAC7C,OAAuB,qBAAM,MAAM;EACjC,OAAO,MAAM;EACb,aAAa;EACb,UAAU,CAEQ,oBAAK,MAAM;GACzB,eAAe;GACf,OAAO;EACT,CAAC,GACe,oBAAK,kBAAkB;GACrC;GACA;GACA;GACA,OAAO,MAAM;GACb,aAAa,SAAS,YAAY,OAAO;IACvC,IAAI,MAAM,YAAY,SAAS,cAAc,OAAO,MAAM,OAAO;IACjE,IAAI,WAAW,MAAM,MAAM,YAAY;IACvC,IAAI,OAAO,aAAa,YAAY;KAClC,IAAI;KACJ,IAAI,OAAO,KAAK,MAAM,MAAM,YAAY,IAAI;KAC5C,IAAI,WAAW,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,UAAU,MAAM,YAAY;KAC/F,SAAS,GAAG,WAAW,2BAA2B,MAAM,WAAW,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,aAAa,QAAQ,SAAS,KAAK,IAAI,OAAO,CAAC,GAAG,MAAM,YAAY,IAAI,IAAI,IAAI;IAChN;GACF;GACA,kBAAkB,SAAS,iBAAiB,OAAO;IACjD,eAAe;KACb,OAAO,MAAM,YAAY;KACzB,QAAQ,MAAM,YAAY;IAC5B,CAAC;GACH;GACA,OAAO,WAAW;EACpB,CAAC,CACH;CACF,CAAC;AACH"}
@@ -34,105 +34,165 @@ function base64Decode(text) {
34
34
  function isRecord(value) {
35
35
  return typeof value === "object" && value !== null && !Array.isArray(value);
36
36
  }
37
- function encodeValue(value, wire, structs, path) {
37
+ var trail = [];
38
+ function trailText() {
39
+ var text = String(trail[0]);
40
+ for (var i = 1; i < trail.length; i++) {
41
+ text += typeof trail[i] === "number" ? `[${trail[i]}]` : `.${trail[i]}`;
42
+ }
43
+ return text;
44
+ }
45
+ var plainStructs = /* @__PURE__ */ new WeakMap();
46
+ function encodeValue(value, wire, structs) {
38
47
  switch (wire.kind) {
39
48
  case "date":
40
- if (!(value instanceof Date)) throw new TypeError(`${path}: expected Date`);
49
+ if (!(value instanceof Date)) throw new TypeError(`${trailText()}: expected Date`);
41
50
  return value;
42
51
  case "data":
43
- if (!(value instanceof Uint8Array)) throw new TypeError(`${path}: expected Uint8Array`);
52
+ if (!(value instanceof Uint8Array)) throw new TypeError(`${trailText()}: expected Uint8Array`);
44
53
  return base64Encode(value);
45
54
  case "enum":
46
55
  if (typeof value !== "string" && typeof value !== "number") {
47
- throw new TypeError(`${path}: expected an enum value`);
56
+ throw new TypeError(`${trailText()}: expected an enum value`);
48
57
  }
49
58
  return value;
50
59
  case "struct": {
51
- if (!isRecord(value)) throw new TypeError(`${path}: expected ${wire.name}`);
60
+ if (!isRecord(value)) throw new TypeError(`${trailText()}: expected ${wire.name}`);
52
61
  var table = structs[wire.name];
53
- if (!table) throw new TypeError(`${path}: unknown struct ${wire.name}`);
62
+ if (!table) throw new TypeError(`${trailText()}: unknown struct ${wire.name}`);
63
+ var plain = plainStructs.get(table);
64
+ if (plain === void 0) {
65
+ plain = table.fields.every(function(field2) {
66
+ return field2.wire === void 0;
67
+ });
68
+ plainStructs.set(table, plain);
69
+ }
70
+ if (plain) {
71
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
72
+ try {
73
+ for (var _iterator = table.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
74
+ var field = _step.value;
75
+ if (value[field.name] === void 0 && !field.optional) {
76
+ trail.push(field.name);
77
+ throw new TypeError(`${trailText()}: required`);
78
+ }
79
+ }
80
+ } catch (err) {
81
+ _didIteratorError = true;
82
+ _iteratorError = err;
83
+ } finally {
84
+ try {
85
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
86
+ _iterator.return();
87
+ }
88
+ } finally {
89
+ if (_didIteratorError) {
90
+ throw _iteratorError;
91
+ }
92
+ }
93
+ }
94
+ return value;
95
+ }
54
96
  var out = {};
55
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
97
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
56
98
  try {
57
99
  var _loop = function() {
58
- var key2 = _step.value;
100
+ var key2 = _step1.value;
59
101
  if (!table.fields.some(function(field2) {
60
102
  return field2.name === key2;
61
103
  })) out[key2] = value[key2];
62
104
  };
63
- for (var _iterator = Object.keys(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
105
+ for (var _iterator1 = Object.keys(value)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) _loop();
64
106
  } catch (err) {
65
- _didIteratorError = true;
66
- _iteratorError = err;
107
+ _didIteratorError1 = true;
108
+ _iteratorError1 = err;
67
109
  } finally {
68
110
  try {
69
- if (!_iteratorNormalCompletion && _iterator.return != null) {
70
- _iterator.return();
111
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
112
+ _iterator1.return();
71
113
  }
72
114
  } finally {
73
- if (_didIteratorError) {
74
- throw _iteratorError;
115
+ if (_didIteratorError1) {
116
+ throw _iteratorError1;
75
117
  }
76
118
  }
77
119
  }
78
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
120
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
79
121
  try {
80
- for (var _iterator1 = table.fields[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
81
- var field = _step1.value;
82
- var present = value[field.name] !== void 0;
122
+ for (var _iterator2 = table.fields[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
123
+ var field1 = _step2.value;
124
+ var present = value[field1.name] !== void 0;
83
125
  if (!present) {
84
- if (!field.optional) throw new TypeError(`${path}.${field.name}: required`);
126
+ if (!field1.optional) {
127
+ trail.push(field1.name);
128
+ throw new TypeError(`${trailText()}: required`);
129
+ }
130
+ continue;
131
+ }
132
+ if (field1.wire === void 0) {
133
+ out[field1.name] = value[field1.name];
85
134
  continue;
86
135
  }
87
- out[field.name] = field.wire === void 0 ? value[field.name] : encodeValue(value[field.name], field.wire, structs, `${path}.${field.name}`);
136
+ trail.push(field1.name);
137
+ out[field1.name] = encodeValue(value[field1.name], field1.wire, structs);
138
+ trail.pop();
88
139
  }
89
140
  } catch (err) {
90
- _didIteratorError1 = true;
91
- _iteratorError1 = err;
141
+ _didIteratorError2 = true;
142
+ _iteratorError2 = err;
92
143
  } finally {
93
144
  try {
94
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
95
- _iterator1.return();
145
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
146
+ _iterator2.return();
96
147
  }
97
148
  } finally {
98
- if (_didIteratorError1) {
99
- throw _iteratorError1;
149
+ if (_didIteratorError2) {
150
+ throw _iteratorError2;
100
151
  }
101
152
  }
102
153
  }
103
154
  return out;
104
155
  }
105
- case "array":
106
- if (!Array.isArray(value)) throw new TypeError(`${path}: expected an array`);
107
- return value.map(function(item, index) {
108
- return encodeValue(item, wire.element, structs, `${path}[${index}]`);
109
- });
156
+ case "array": {
157
+ if (!Array.isArray(value)) throw new TypeError(`${trailText()}: expected an array`);
158
+ var out1 = new Array(value.length);
159
+ trail.push(0);
160
+ var at = trail.length - 1;
161
+ for (var index = 0; index < value.length; index++) {
162
+ trail[at] = index;
163
+ out1[index] = encodeValue(value[index], wire.element, structs);
164
+ }
165
+ trail.pop();
166
+ return out1;
167
+ }
110
168
  case "map": {
111
- if (!isRecord(value)) throw new TypeError(`${path}: expected an object`);
112
- var out1 = {};
113
- var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
169
+ if (!isRecord(value)) throw new TypeError(`${trailText()}: expected an object`);
170
+ var out2 = {};
171
+ var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
114
172
  try {
115
- for (var _iterator2 = Object.keys(value)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
116
- var key = _step2.value;
117
- out1[key] = encodeValue(value[key], wire.value, structs, `${path}.${key}`);
173
+ for (var _iterator3 = Object.keys(value)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
174
+ var key = _step3.value;
175
+ trail.push(key);
176
+ out2[key] = encodeValue(value[key], wire.value, structs);
177
+ trail.pop();
118
178
  }
119
179
  } catch (err) {
120
- _didIteratorError2 = true;
121
- _iteratorError2 = err;
180
+ _didIteratorError3 = true;
181
+ _iteratorError3 = err;
122
182
  } finally {
123
183
  try {
124
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
125
- _iterator2.return();
184
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
185
+ _iterator3.return();
126
186
  }
127
187
  } finally {
128
- if (_didIteratorError2) {
129
- throw _iteratorError2;
188
+ if (_didIteratorError3) {
189
+ throw _iteratorError3;
130
190
  }
131
191
  }
132
192
  }
133
- return out1;
193
+ return out2;
134
194
  }
135
- case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs, path);
195
+ case "nullable": return value === null || value === void 0 ? null : encodeValue(value, wire.inner, structs);
136
196
  }
137
197
  }
138
198
  function decodeValue(value, wire, structs, path) {
@@ -249,10 +309,15 @@ function decodeValue(value, wire, structs, path) {
249
309
  case "nullable": return value === null || value === void 0 ? null : decodeValue(value, wire.inner, structs, path);
250
310
  }
251
311
  }
312
+ function encodeAt(path, value, wire, structs) {
313
+ trail.length = 0;
314
+ trail.push(...path);
315
+ return encodeValue(value, wire, structs);
316
+ }
252
317
  function encodeNativeSourceArgs(args, wires, structs) {
253
318
  return args.map(function(arg, index) {
254
319
  var wire = wires[index];
255
- return wire === void 0 || wire === null ? arg : encodeValue(arg, wire, structs, `args[${index}]`);
320
+ return wire === void 0 || wire === null ? arg : encodeAt(["args", index], arg, wire, structs);
256
321
  });
257
322
  }
258
323
  function decodeNativeSourceResult(value, wire, structs) {
@@ -265,7 +330,7 @@ function encodeNativeSourceProps(props, wires, structs) {
265
330
  for (var _iterator = Object.keys(wires)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
266
331
  var name = _step.value;
267
332
  if (out[name] === void 0) continue;
268
- out[name] = encodeValue(out[name], wires[name], structs, `props.${name}`);
333
+ out[name] = encodeAt(["props", name], out[name], wires[name], structs);
269
334
  }
270
335
  } catch (err) {
271
336
  _didIteratorError = true;
@@ -283,6 +348,41 @@ function encodeNativeSourceProps(props, wires, structs) {
283
348
  }
284
349
  return out;
285
350
  }
351
+ function encodeNativeSourceProp(name, value, wires) {
352
+ var wire = wires === null || wires === void 0 ? void 0 : wires.props[name];
353
+ return wire === void 0 ? value : encodeAt(["props", name], value, wire, wires.structs);
354
+ }
355
+ function encodeNativeSourceListItem(name, index, item, element, structs) {
356
+ return encodeAt([
357
+ "props",
358
+ name,
359
+ index
360
+ ], item, element, structs);
361
+ }
362
+ function stringifyNativeSourceProps(props, wires) {
363
+ var out = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : { ...props };
364
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
365
+ try {
366
+ for (var _iterator = Object.keys(out)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
367
+ var key = _step.value;
368
+ if (typeof out[key] === "function") out[key] = true;
369
+ }
370
+ } catch (err) {
371
+ _didIteratorError = true;
372
+ _iteratorError = err;
373
+ } finally {
374
+ try {
375
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
376
+ _iterator.return();
377
+ }
378
+ } finally {
379
+ if (_didIteratorError) {
380
+ throw _iteratorError;
381
+ }
382
+ }
383
+ }
384
+ return JSON.stringify(out);
385
+ }
286
386
  function decodeNativeSourceCallback(args, wires, structs, event) {
287
387
  return args.map(function(arg, index) {
288
388
  var wire = wires[index];
@@ -290,5 +390,5 @@ function decodeNativeSourceCallback(args, wires, structs, event) {
290
390
  });
291
391
  }
292
392
 
293
- export { base64Decode, base64Encode, decodeNativeSourceCallback, decodeNativeSourceResult, encodeNativeSourceArgs, encodeNativeSourceProps };
393
+ export { base64Decode, base64Encode, decodeNativeSourceCallback, decodeNativeSourceResult, encodeNativeSourceArgs, encodeNativeSourceListItem, encodeNativeSourceProp, encodeNativeSourceProps, stringifyNativeSourceProps };
294
394
  //# sourceMappingURL=wire.native.js.map