ffi-bindings 1.0.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.
@@ -0,0 +1,345 @@
1
+ var _process;
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
10
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
11
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
13
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
14
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
17
+ // Trust me, you don't want to mess with it!
18
+ /* tslint:disable */
19
+ /* eslint-disable */
20
+ // @ts-nocheck
21
+ import * as wasmBundle from "./wasm-bindgen/index.js";
22
+ import { AbstractFfiConverterByteArray, FfiConverterBool, FfiConverterInt32, UniffiEnum, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiTypeNameSymbol } from "uniffi-bindgen-react-native";
23
+ // Get converters from the other files, if any.
24
+ var nativeModule = function nativeModule() {
25
+ return wasmBundle;
26
+ };
27
+ var uniffiCaller = new UniffiRustCaller(function () {
28
+ return new wasmBundle.RustCallStatus();
29
+ });
30
+ var uniffiIsDebug =
31
+ // @ts-ignore -- The process global might not be defined
32
+ (typeof process === "undefined" ? "undefined" : _typeof(process)) !== "object" ||
33
+ // @ts-ignore -- The process global might not be defined
34
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) !== "production" || false;
35
+ // Public interface members begin here.
36
+ var stringConverter = function () {
37
+ var encoder = new TextEncoder();
38
+ var decoder = new TextDecoder();
39
+ return {
40
+ stringToBytes: function stringToBytes(s) {
41
+ return encoder.encode(s);
42
+ },
43
+ bytesToString: function bytesToString(ab) {
44
+ return decoder.decode(ab);
45
+ },
46
+ stringByteLength: function stringByteLength(s) {
47
+ return encoder.encode(s).byteLength;
48
+ }
49
+ };
50
+ }();
51
+ var FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
52
+ /**
53
+ * Where this event came.
54
+ */
55
+ export var EventItemOrigin;
56
+ (function (EventItemOrigin) {
57
+ /**
58
+ * The event was created locally.
59
+ */
60
+ EventItemOrigin[EventItemOrigin["Local"] = 0] = "Local";
61
+ /**
62
+ * The event came from a sync response.
63
+ */
64
+ EventItemOrigin[EventItemOrigin["Sync"] = 1] = "Sync";
65
+ /**
66
+ * The event came from pagination.
67
+ */
68
+ EventItemOrigin[EventItemOrigin["Pagination"] = 2] = "Pagination";
69
+ /**
70
+ * The event came from a cache.
71
+ */
72
+ EventItemOrigin[EventItemOrigin["Cache"] = 3] = "Cache";
73
+ })(EventItemOrigin || (EventItemOrigin = {}));
74
+ var FfiConverterTypeEventItemOrigin = function () {
75
+ var ordinalConverter = FfiConverterInt32;
76
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter) {
77
+ function FFIConverter() {
78
+ _classCallCheck(this, FFIConverter);
79
+ return _callSuper(this, FFIConverter, arguments);
80
+ }
81
+ _inherits(FFIConverter, _AbstractFfiConverter);
82
+ return _createClass(FFIConverter, [{
83
+ key: "read",
84
+ value: function read(from) {
85
+ switch (ordinalConverter.read(from)) {
86
+ case 1:
87
+ return EventItemOrigin.Local;
88
+ case 2:
89
+ return EventItemOrigin.Sync;
90
+ case 3:
91
+ return EventItemOrigin.Pagination;
92
+ case 4:
93
+ return EventItemOrigin.Cache;
94
+ default:
95
+ throw new UniffiInternalError.UnexpectedEnumCase();
96
+ }
97
+ }
98
+ }, {
99
+ key: "write",
100
+ value: function write(value, into) {
101
+ switch (value) {
102
+ case EventItemOrigin.Local:
103
+ return ordinalConverter.write(1, into);
104
+ case EventItemOrigin.Sync:
105
+ return ordinalConverter.write(2, into);
106
+ case EventItemOrigin.Pagination:
107
+ return ordinalConverter.write(3, into);
108
+ case EventItemOrigin.Cache:
109
+ return ordinalConverter.write(4, into);
110
+ }
111
+ }
112
+ }, {
113
+ key: "allocationSize",
114
+ value: function allocationSize(value) {
115
+ return ordinalConverter.allocationSize(0);
116
+ }
117
+ }]);
118
+ }(AbstractFfiConverterByteArray);
119
+ return new FFIConverter();
120
+ }();
121
+ /**
122
+ * The type of change between the previous and current pinned events.
123
+ */
124
+ export var RoomPinnedEventsChange;
125
+ (function (RoomPinnedEventsChange) {
126
+ /**
127
+ * Only new event ids were added.
128
+ */
129
+ RoomPinnedEventsChange[RoomPinnedEventsChange["Added"] = 0] = "Added";
130
+ /**
131
+ * Only event ids were removed.
132
+ */
133
+ RoomPinnedEventsChange[RoomPinnedEventsChange["Removed"] = 1] = "Removed";
134
+ /**
135
+ * Some change other than only adding or only removing ids happened.
136
+ */
137
+ RoomPinnedEventsChange[RoomPinnedEventsChange["Changed"] = 2] = "Changed";
138
+ })(RoomPinnedEventsChange || (RoomPinnedEventsChange = {}));
139
+ var FfiConverterTypeRoomPinnedEventsChange = function () {
140
+ var ordinalConverter = FfiConverterInt32;
141
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter2) {
142
+ function FFIConverter() {
143
+ _classCallCheck(this, FFIConverter);
144
+ return _callSuper(this, FFIConverter, arguments);
145
+ }
146
+ _inherits(FFIConverter, _AbstractFfiConverter2);
147
+ return _createClass(FFIConverter, [{
148
+ key: "read",
149
+ value: function read(from) {
150
+ switch (ordinalConverter.read(from)) {
151
+ case 1:
152
+ return RoomPinnedEventsChange.Added;
153
+ case 2:
154
+ return RoomPinnedEventsChange.Removed;
155
+ case 3:
156
+ return RoomPinnedEventsChange.Changed;
157
+ default:
158
+ throw new UniffiInternalError.UnexpectedEnumCase();
159
+ }
160
+ }
161
+ }, {
162
+ key: "write",
163
+ value: function write(value, into) {
164
+ switch (value) {
165
+ case RoomPinnedEventsChange.Added:
166
+ return ordinalConverter.write(1, into);
167
+ case RoomPinnedEventsChange.Removed:
168
+ return ordinalConverter.write(2, into);
169
+ case RoomPinnedEventsChange.Changed:
170
+ return ordinalConverter.write(3, into);
171
+ }
172
+ }
173
+ }, {
174
+ key: "allocationSize",
175
+ value: function allocationSize(value) {
176
+ return ordinalConverter.allocationSize(0);
177
+ }
178
+ }]);
179
+ }(AbstractFfiConverterByteArray);
180
+ return new FFIConverter();
181
+ }();
182
+ // Enum: SpaceRoomListPaginationState
183
+ export var SpaceRoomListPaginationState_Tags;
184
+ (function (SpaceRoomListPaginationState_Tags) {
185
+ SpaceRoomListPaginationState_Tags["Idle"] = "Idle";
186
+ SpaceRoomListPaginationState_Tags["Loading"] = "Loading";
187
+ })(SpaceRoomListPaginationState_Tags || (SpaceRoomListPaginationState_Tags = {}));
188
+ export var SpaceRoomListPaginationState = function () {
189
+ var Idle_ = /*#__PURE__*/function (_UniffiEnum) {
190
+ function Idle_(inner) {
191
+ var _this;
192
+ _classCallCheck(this, Idle_);
193
+ _this = _callSuper(this, Idle_, ["SpaceRoomListPaginationState", "Idle"]);
194
+ /**
195
+ * @private
196
+ * This field is private and should not be used, use `tag` instead.
197
+ */
198
+ _defineProperty(_this, uniffiTypeNameSymbol, "SpaceRoomListPaginationState");
199
+ _defineProperty(_this, "tag", SpaceRoomListPaginationState_Tags.Idle);
200
+ _defineProperty(_this, "inner", void 0);
201
+ _this.inner = Object.freeze(inner);
202
+ return _this;
203
+ }
204
+ _inherits(Idle_, _UniffiEnum);
205
+ return _createClass(Idle_, null, [{
206
+ key: "new",
207
+ value: function _new(inner) {
208
+ return new Idle_(inner);
209
+ }
210
+ }, {
211
+ key: "instanceOf",
212
+ value: function instanceOf(obj) {
213
+ return obj.tag === SpaceRoomListPaginationState_Tags.Idle;
214
+ }
215
+ }]);
216
+ }(UniffiEnum);
217
+ var Loading_ = /*#__PURE__*/function (_UniffiEnum2) {
218
+ function Loading_() {
219
+ var _this2;
220
+ _classCallCheck(this, Loading_);
221
+ _this2 = _callSuper(this, Loading_, ["SpaceRoomListPaginationState", "Loading"]);
222
+ /**
223
+ * @private
224
+ * This field is private and should not be used, use `tag` instead.
225
+ */
226
+ _defineProperty(_this2, uniffiTypeNameSymbol, "SpaceRoomListPaginationState");
227
+ _defineProperty(_this2, "tag", SpaceRoomListPaginationState_Tags.Loading);
228
+ return _this2;
229
+ }
230
+ _inherits(Loading_, _UniffiEnum2);
231
+ return _createClass(Loading_, null, [{
232
+ key: "new",
233
+ value: function _new() {
234
+ return new Loading_();
235
+ }
236
+ }, {
237
+ key: "instanceOf",
238
+ value: function instanceOf(obj) {
239
+ return obj.tag === SpaceRoomListPaginationState_Tags.Loading;
240
+ }
241
+ }]);
242
+ }(UniffiEnum);
243
+ function instanceOf(obj) {
244
+ return obj[uniffiTypeNameSymbol] === "SpaceRoomListPaginationState";
245
+ }
246
+ return Object.freeze({
247
+ instanceOf: instanceOf,
248
+ Idle: Idle_,
249
+ Loading: Loading_
250
+ });
251
+ }();
252
+ // FfiConverter for enum SpaceRoomListPaginationState
253
+ var FfiConverterTypeSpaceRoomListPaginationState = function () {
254
+ var ordinalConverter = FfiConverterInt32;
255
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter3) {
256
+ function FFIConverter() {
257
+ _classCallCheck(this, FFIConverter);
258
+ return _callSuper(this, FFIConverter, arguments);
259
+ }
260
+ _inherits(FFIConverter, _AbstractFfiConverter3);
261
+ return _createClass(FFIConverter, [{
262
+ key: "read",
263
+ value: function read(from) {
264
+ switch (ordinalConverter.read(from)) {
265
+ case 1:
266
+ return new SpaceRoomListPaginationState.Idle({
267
+ endReached: FfiConverterBool.read(from)
268
+ });
269
+ case 2:
270
+ return new SpaceRoomListPaginationState.Loading();
271
+ default:
272
+ throw new UniffiInternalError.UnexpectedEnumCase();
273
+ }
274
+ }
275
+ }, {
276
+ key: "write",
277
+ value: function write(value, into) {
278
+ switch (value.tag) {
279
+ case SpaceRoomListPaginationState_Tags.Idle:
280
+ {
281
+ ordinalConverter.write(1, into);
282
+ var inner = value.inner;
283
+ FfiConverterBool.write(inner.endReached, into);
284
+ return;
285
+ }
286
+ case SpaceRoomListPaginationState_Tags.Loading:
287
+ {
288
+ ordinalConverter.write(2, into);
289
+ return;
290
+ }
291
+ default:
292
+ // Throwing from here means that SpaceRoomListPaginationState_Tags hasn't matched an ordinal.
293
+ throw new UniffiInternalError.UnexpectedEnumCase();
294
+ }
295
+ }
296
+ }, {
297
+ key: "allocationSize",
298
+ value: function allocationSize(value) {
299
+ switch (value.tag) {
300
+ case SpaceRoomListPaginationState_Tags.Idle:
301
+ {
302
+ var inner = value.inner;
303
+ var size = ordinalConverter.allocationSize(1);
304
+ size += FfiConverterBool.allocationSize(inner.endReached);
305
+ return size;
306
+ }
307
+ case SpaceRoomListPaginationState_Tags.Loading:
308
+ {
309
+ return ordinalConverter.allocationSize(2);
310
+ }
311
+ default:
312
+ throw new UniffiInternalError.UnexpectedEnumCase();
313
+ }
314
+ }
315
+ }]);
316
+ }(AbstractFfiConverterByteArray);
317
+ return new FFIConverter();
318
+ }();
319
+ /**
320
+ * This should be called before anything else.
321
+ *
322
+ * It is likely that this is being done for you by the library's `index.ts`.
323
+ *
324
+ * It checks versions of uniffi between when the Rust scaffolding was generated
325
+ * and when the bindings were generated.
326
+ *
327
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
328
+ */
329
+ function uniffiEnsureInitialized() {
330
+ // Get the bindings contract version from our ComponentInterface
331
+ var bindingsContractVersion = 29;
332
+ // Get the scaffolding contract version by calling the into the dylib
333
+ var scaffoldingContractVersion = nativeModule().ubrn_ffi_matrix_sdk_ui_uniffi_contract_version();
334
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
335
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
336
+ }
337
+ }
338
+ export default Object.freeze({
339
+ initialize: uniffiEnsureInitialized,
340
+ converters: {
341
+ FfiConverterTypeEventItemOrigin: FfiConverterTypeEventItemOrigin,
342
+ FfiConverterTypeRoomPinnedEventsChange: FfiConverterTypeRoomPinnedEventsChange,
343
+ FfiConverterTypeSpaceRoomListPaginationState: FfiConverterTypeSpaceRoomListPaginationState
344
+ }
345
+ });