@fidscript/instant-react-native 0.1.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 (96) hide show
  1. package/dist/EventSourceImpl.d.ts +10 -0
  2. package/dist/EventSourceImpl.d.ts.map +1 -0
  3. package/dist/EventSourceImpl.js +9 -0
  4. package/dist/EventSourceImpl.js.map +1 -0
  5. package/dist/EventSourceShim.d.ts +31 -0
  6. package/dist/EventSourceShim.d.ts.map +1 -0
  7. package/dist/EventSourceShim.js +228 -0
  8. package/dist/EventSourceShim.js.map +1 -0
  9. package/dist/NetworkListener.d.ts +5 -0
  10. package/dist/NetworkListener.d.ts.map +1 -0
  11. package/dist/NetworkListener.js +19 -0
  12. package/dist/NetworkListener.js.map +1 -0
  13. package/dist/Storage.d.ts +3 -0
  14. package/dist/Storage.d.ts.map +1 -0
  15. package/dist/Storage.js +5 -0
  16. package/dist/Storage.js.map +1 -0
  17. package/dist/Storage.native.d.ts +22 -0
  18. package/dist/Storage.native.d.ts.map +1 -0
  19. package/dist/Storage.native.js +79 -0
  20. package/dist/Storage.native.js.map +1 -0
  21. package/dist/Streams.d.ts +15 -0
  22. package/dist/Streams.d.ts.map +1 -0
  23. package/dist/Streams.js +9 -0
  24. package/dist/Streams.js.map +1 -0
  25. package/dist/Streams.native.d.ts +6 -0
  26. package/dist/Streams.native.d.ts.map +1 -0
  27. package/dist/Streams.native.js +9 -0
  28. package/dist/Streams.native.js.map +1 -0
  29. package/dist/cli.d.ts +2 -0
  30. package/dist/cli.d.ts.map +1 -0
  31. package/dist/cli.js +18 -0
  32. package/dist/cli.js.map +1 -0
  33. package/dist/index.d.ts +56 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +87 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/module/EventSourceImpl.d.ts +10 -0
  38. package/dist/module/EventSourceImpl.d.ts.map +1 -0
  39. package/dist/module/EventSourceImpl.js +4 -0
  40. package/dist/module/EventSourceImpl.js.map +1 -0
  41. package/dist/module/EventSourceShim.d.ts +31 -0
  42. package/dist/module/EventSourceShim.d.ts.map +1 -0
  43. package/dist/module/EventSourceShim.js +226 -0
  44. package/dist/module/EventSourceShim.js.map +1 -0
  45. package/dist/module/NetworkListener.d.ts +5 -0
  46. package/dist/module/NetworkListener.d.ts.map +1 -0
  47. package/dist/module/NetworkListener.js +13 -0
  48. package/dist/module/NetworkListener.js.map +1 -0
  49. package/dist/module/Storage.d.ts +3 -0
  50. package/dist/module/Storage.d.ts.map +1 -0
  51. package/dist/module/Storage.js +3 -0
  52. package/dist/module/Storage.js.map +1 -0
  53. package/dist/module/Storage.native.d.ts +22 -0
  54. package/dist/module/Storage.native.d.ts.map +1 -0
  55. package/dist/module/Storage.native.js +75 -0
  56. package/dist/module/Storage.native.js.map +1 -0
  57. package/dist/module/Streams.d.ts +15 -0
  58. package/dist/module/Streams.d.ts.map +1 -0
  59. package/dist/module/Streams.js +6 -0
  60. package/dist/module/Streams.js.map +1 -0
  61. package/dist/module/Streams.native.d.ts +6 -0
  62. package/dist/module/Streams.native.d.ts.map +1 -0
  63. package/dist/module/Streams.native.js +6 -0
  64. package/dist/module/Streams.native.js.map +1 -0
  65. package/dist/module/cli.d.ts +2 -0
  66. package/dist/module/cli.d.ts.map +1 -0
  67. package/dist/module/cli.js +2 -0
  68. package/dist/module/cli.js.map +1 -0
  69. package/dist/module/index.d.ts +56 -0
  70. package/dist/module/index.d.ts.map +1 -0
  71. package/dist/module/index.js +76 -0
  72. package/dist/module/index.js.map +1 -0
  73. package/dist/module/version.d.ts +3 -0
  74. package/dist/module/version.d.ts.map +1 -0
  75. package/dist/module/version.js +3 -0
  76. package/dist/module/version.js.map +1 -0
  77. package/dist/version.d.ts +3 -0
  78. package/dist/version.d.ts.map +1 -0
  79. package/dist/version.js +5 -0
  80. package/dist/version.js.map +1 -0
  81. package/package.json +49 -0
  82. package/src/EventSourceImpl.ts +6 -0
  83. package/src/EventSourceShim.ts +285 -0
  84. package/src/NetworkListener.js +13 -0
  85. package/src/Storage.js +3 -0
  86. package/src/Storage.native.ts +91 -0
  87. package/src/Streams.native.ts +6 -0
  88. package/src/Streams.ts +5 -0
  89. package/src/__types__/typeUtils.ts +39 -0
  90. package/src/__types__/typesTests.ts +86 -0
  91. package/src/cli.ts +1 -0
  92. package/src/index.ts +290 -0
  93. package/src/version.ts +2 -0
  94. package/tsconfig.json +16 -0
  95. package/tsconfig.module.json +13 -0
  96. package/tsconfig.test.json +5 -0
@@ -0,0 +1,56 @@
1
+ import 'react-native-get-random-values';
2
+ import Store from './Storage';
3
+ import NetworkListener from './NetworkListener';
4
+ import { InstantReactAbstractDatabase } from '@fidscript/instant-react-common';
5
+ import { i, id, tx, lookup, InstantAPIError, setInstantWarningsEnabled, SyncTableCallbackEventType, createInstantRouteHandler, type RoomSchemaShape, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type ConnectionStatus, type BackwardsCompatibleSchema, type IInstantDatabase, type Config, type Query, type QueryResponse, type InstantObject, type AuthState, type User, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type InstantUnknownSchemaDef, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstantEntity, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type CreateParams, type InstantConfig, type InstantSchemaDef, type InstantUnknownSchema, type TransactionChunk, type InstantRules, type UpdateParams, type LinkParams, type ValidQuery, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, type StoreInterfaceStoreName, CreateReadStreamOpts, CreateWriteStreamOpts, InstantWritableStream, InstantReadableStream, type Logger } from '@fidscript/instant-sdk';
6
+ /**
7
+ *
8
+ * The first step: init your application!
9
+ *
10
+ * Visit https://instantdb.com/dash to get your `appId` :)
11
+ *
12
+ * @example
13
+ * import { init } from "@instantdb/react-native"
14
+ *
15
+ * const db = init({ appId: "my-app-id" })
16
+ *
17
+ * // You can also provide a schema for type safety and editor autocomplete!
18
+ *
19
+ * import { init } from "@instantdb/react-native"
20
+ * import schema from ""../instant.schema.ts";
21
+ *
22
+ * const db = init({ appId: "my-app-id", schema })
23
+ *
24
+ * // To learn more: https://instantdb.com/docs/modeling-data
25
+ */
26
+ declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
27
+ useDateObjects?: UseDates;
28
+ }): InstantReactNativeDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>>;
29
+ /**
30
+ * @deprecated
31
+ * `init_experimental` is deprecated. You can replace it with `init`.
32
+ *
33
+ * @example
34
+ *
35
+ * // Before
36
+ * import { init_experimental } from "@instantdb/react-native"
37
+ * const db = init_experimental({ ... });
38
+ *
39
+ * // After
40
+ * import { init } from "@instantdb/react-native"
41
+ * const db = init({ ... });
42
+ */
43
+ declare const init_experimental: typeof init;
44
+ declare class InstantReactNativeDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean, Config extends InstantConfig<Schema, UseDates> = InstantConfig<Schema, UseDates>> extends InstantReactAbstractDatabase<Schema, UseDates, Config> {
45
+ static Store: typeof Store;
46
+ static NetworkListener: typeof NetworkListener;
47
+ static EventSourceImpl: typeof import("./EventSourceShim").default | {
48
+ new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
49
+ prototype: EventSource;
50
+ readonly CONNECTING: 0;
51
+ readonly OPEN: 1;
52
+ readonly CLOSED: 2;
53
+ };
54
+ }
55
+ export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantReactNativeDatabase, InstantAPIError, setInstantWarningsEnabled, SyncTableCallbackEventType, type Config, type Query, type QueryResponse, type InstantObject, type User, type AuthState, type ConnectionStatus, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantEntity, type RoomSchemaShape, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type CreateParams, type LinkAttrDef, type InstantConfig, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type RoomHandle, type PresenceOf, type TopicsOf, type TopicOf, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantSchemaDef, type InstantUnknownSchema, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type ValidQuery, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type TransactionChunk, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type InstantWritableStream, type InstantReadableStream, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, type Logger, };
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAIhD,O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,qBAAqB,EAC1B,KAAK,qBAAqB,EAG1B,cAAc,EACd,KAAK,uBAAuB,EAG5B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAGxB,KAAK,MAAM,GACZ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StoreInterface = exports.SyncTableCallbackEventType = exports.setInstantWarningsEnabled = exports.InstantAPIError = exports.InstantReactNativeDatabase = exports.createInstantRouteHandler = exports.i = exports.lookup = exports.tx = exports.id = exports.init_experimental = void 0;
7
+ exports.init = init;
8
+ require("react-native-get-random-values");
9
+ const Storage_1 = __importDefault(require("./Storage"));
10
+ const EventSourceImpl_1 = __importDefault(require("./EventSourceImpl"));
11
+ const NetworkListener_1 = __importDefault(require("./NetworkListener"));
12
+ const version_1 = __importDefault(require("./version"));
13
+ const Streams_1 = require("./Streams");
14
+ const instant_react_common_1 = require("@fidscript/instant-react-common");
15
+ const instant_sdk_1 = require("@fidscript/instant-sdk");
16
+ Object.defineProperty(exports, "i", { enumerable: true, get: function () { return instant_sdk_1.i; } });
17
+ Object.defineProperty(exports, "id", { enumerable: true, get: function () { return instant_sdk_1.id; } });
18
+ Object.defineProperty(exports, "tx", { enumerable: true, get: function () { return instant_sdk_1.tx; } });
19
+ Object.defineProperty(exports, "lookup", { enumerable: true, get: function () { return instant_sdk_1.lookup; } });
20
+ Object.defineProperty(exports, "InstantAPIError", { enumerable: true, get: function () { return
21
+ // error
22
+ instant_sdk_1.InstantAPIError; } });
23
+ Object.defineProperty(exports, "setInstantWarningsEnabled", { enumerable: true, get: function () { return instant_sdk_1.setInstantWarningsEnabled; } });
24
+ Object.defineProperty(exports, "SyncTableCallbackEventType", { enumerable: true, get: function () { return
25
+ // sync table enums
26
+ instant_sdk_1.SyncTableCallbackEventType; } });
27
+ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true, get: function () { return
28
+ // types
29
+ instant_sdk_1.createInstantRouteHandler; } });
30
+ Object.defineProperty(exports, "StoreInterface", { enumerable: true, get: function () { return instant_sdk_1.StoreInterface; } });
31
+ /**
32
+ *
33
+ * The first step: init your application!
34
+ *
35
+ * Visit https://instantdb.com/dash to get your `appId` :)
36
+ *
37
+ * @example
38
+ * import { init } from "@instantdb/react-native"
39
+ *
40
+ * const db = init({ appId: "my-app-id" })
41
+ *
42
+ * // You can also provide a schema for type safety and editor autocomplete!
43
+ *
44
+ * import { init } from "@instantdb/react-native"
45
+ * import schema from ""../instant.schema.ts";
46
+ *
47
+ * const db = init({ appId: "my-app-id", schema })
48
+ *
49
+ * // To learn more: https://instantdb.com/docs/modeling-data
50
+ */
51
+ function init(
52
+ // Allows config with missing `useDateObjects`, but keeps `UseDates`
53
+ // as a non-nullable in the InstantConfig type.
54
+ config) {
55
+ const configStrict = {
56
+ ReadableStream: Streams_1.streamConstructors.ReadableStream,
57
+ WritableStream: Streams_1.streamConstructors.WritableStream,
58
+ ...config,
59
+ useDateObjects: (config.useDateObjects ?? false),
60
+ };
61
+ return new InstantReactNativeDatabase(configStrict, {
62
+ '@fidscript/react-native': version_1.default,
63
+ });
64
+ }
65
+ /**
66
+ * @deprecated
67
+ * `init_experimental` is deprecated. You can replace it with `init`.
68
+ *
69
+ * @example
70
+ *
71
+ * // Before
72
+ * import { init_experimental } from "@instantdb/react-native"
73
+ * const db = init_experimental({ ... });
74
+ *
75
+ * // After
76
+ * import { init } from "@instantdb/react-native"
77
+ * const db = init({ ... });
78
+ */
79
+ const init_experimental = init;
80
+ exports.init_experimental = init_experimental;
81
+ class InstantReactNativeDatabase extends instant_react_common_1.InstantReactAbstractDatabase {
82
+ static Store = Storage_1.default;
83
+ static NetworkListener = NetworkListener_1.default;
84
+ static EventSourceImpl = EventSourceImpl_1.default;
85
+ }
86
+ exports.InstantReactNativeDatabase = InstantReactNativeDatabase;
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA0LE,oBAAI;AA1LN,0CAAwC;AAExC,wDAA8B;AAC9B,wEAAgD;AAChD,wEAAgD;AAChD,wDAAgC;AAChC,uCAA+C;AAE/C,0EAA+E;AAE/E,wDA+FgC;AAsF9B,kFApLA,eAAC,OAoLA;AAHD,mFAhLA,gBAAE,OAgLA;AACF,mFAhLA,gBAAE,OAgLA;AACF,uFAhLA,oBAAM,OAgLA;AAMN;IArLA,QAAQ;IACR,6BAAe,OAoLA;AACf,0GApLA,uCAAyB,OAoLA;AAGzB;IArLA,mBAAmB;IACnB,wCAA0B,OAoLA;AAR1B;IA1KA,QAAQ;IACR,uCAAyB,OAyKA;AAmFzB,+FAjLA,4BAAc,OAiLA;AAxKhB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,IAAI;AAIX,oEAAoE;AACpE,+CAA+C;AAC/C,MAEC;IAMD,MAAM,YAAY,GAAG;QACnB,cAAc,EAAE,4BAAkB,CAAC,cAAc;QACjD,cAAc,EAAE,4BAAkB,CAAC,cAAc;QACjD,GAAG,MAAM;QACT,cAAc,EAAE,CAAC,MAAM,CAAC,cAAc,IAAI,KAAK,CAAa;KAC7D,CAAC;IACF,OAAO,IAAI,0BAA0B,CAInC,YAAY,EAAE;QACd,yBAAyB,EAAE,iBAAO;KACnC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAiB7B,8CAAiB;AAfnB,MAAM,0BAOJ,SAAQ,mDAAsD;IAC9D,MAAM,CAAC,KAAK,GAAG,iBAAK,CAAC;IACrB,MAAM,CAAC,eAAe,GAAG,yBAAe,CAAC;IACzC,MAAM,CAAC,eAAe,GAAG,yBAAe,CAAC;;AAWzC,gEAA0B","sourcesContent":["import 'react-native-get-random-values';\n\nimport Store from './Storage';\nimport EventSourceImpl from './EventSourceImpl';\nimport NetworkListener from './NetworkListener';\nimport version from './version';\nimport { streamConstructors } from './Streams';\n\nimport { InstantReactAbstractDatabase } from '@fidscript/instant-react-common';\n\nimport {\n i,\n id,\n tx,\n lookup,\n // error\n InstantAPIError,\n setInstantWarningsEnabled,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // types\n createInstantRouteHandler,\n type RoomSchemaShape,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type ConnectionStatus,\n type BackwardsCompatibleSchema,\n type IInstantDatabase,\n type Config,\n type Query,\n type QueryResponse,\n type InstantObject,\n type AuthState,\n type User,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type InstantUnknownSchemaDef,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type InstantEntity,\n type ConfigWithSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type CreateParams,\n type InstantConfig,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type TransactionChunk,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type ValidQuery,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n StoreInterface,\n type StoreInterfaceStoreName,\n CreateReadStreamOpts,\n CreateWriteStreamOpts,\n InstantWritableStream,\n InstantReadableStream,\n type Logger,\n} from '@fidscript/instant-sdk';\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` :)\n *\n * @example\n * import { init } from \"@instantdb/react-native\"\n *\n * const db = init({ appId: \"my-app-id\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/react-native\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", schema })\n *\n * // To learn more: https://instantdb.com/docs/modeling-data\n */\nfunction init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantReactNativeDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n> {\n const configStrict = {\n ReadableStream: streamConstructors.ReadableStream,\n WritableStream: streamConstructors.WritableStream,\n ...config,\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n return new InstantReactNativeDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict, {\n '@fidscript/react-native': version,\n });\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@instantdb/react-native\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/react-native\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nclass InstantReactNativeDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n Config extends InstantConfig<Schema, UseDates> = InstantConfig<\n Schema,\n UseDates\n >,\n> extends InstantReactAbstractDatabase<Schema, UseDates, Config> {\n static Store = Store;\n static NetworkListener = NetworkListener;\n static EventSourceImpl = EventSourceImpl;\n}\n\nexport {\n init,\n init_experimental,\n id,\n tx,\n lookup,\n i,\n createInstantRouteHandler,\n InstantReactNativeDatabase,\n\n // error\n InstantAPIError,\n setInstantWarningsEnabled,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // types\n type Config,\n type Query,\n type QueryResponse,\n type InstantObject,\n type User,\n type AuthState,\n type ConnectionStatus,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstantEntity,\n type RoomSchemaShape,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type CreateParams,\n type LinkAttrDef,\n type InstantConfig,\n type LinkDef,\n type InstantUnknownSchemaDef,\n type LinksDef,\n type RoomsOf,\n type RoomsDef,\n type RoomHandle,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type ResolveAttrs,\n type ValueTypes,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type ValidQuery,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type TransactionChunk,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // stream types\n type CreateReadStreamOpts,\n type CreateWriteStreamOpts,\n type InstantWritableStream,\n type InstantReadableStream,\n\n // custom store\n StoreInterface,\n type StoreInterfaceStoreName,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // logger\n type Logger,\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import EventSourceShim from './EventSourceShim';
2
+ declare const EventSourceImpl: typeof EventSourceShim | {
3
+ new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
4
+ prototype: EventSource;
5
+ readonly CONNECTING: 0;
6
+ readonly OPEN: 1;
7
+ readonly CLOSED: 2;
8
+ };
9
+ export default EventSourceImpl;
10
+ //# sourceMappingURL=EventSourceImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventSourceImpl.d.ts","sourceRoot":"","sources":["../../src/EventSourceImpl.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,QAAA,MAAM,eAAe;;;;;;CAC+C,CAAC;AAErE,eAAe,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ import EventSourceShim from './EventSourceShim';
2
+ const EventSourceImpl = typeof EventSource === 'undefined' ? EventSourceShim : EventSource;
3
+ export default EventSourceImpl;
4
+ //# sourceMappingURL=EventSourceImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventSourceImpl.js","sourceRoot":"","sources":["../../src/EventSourceImpl.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,eAAe,GACnB,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC;AAErE,eAAe,eAAe,CAAC","sourcesContent":["import EventSourceShim from './EventSourceShim';\n\nconst EventSourceImpl =\n typeof EventSource === 'undefined' ? EventSourceShim : EventSource;\n\nexport default EventSourceImpl;\n"]}
@@ -0,0 +1,31 @@
1
+ import { type EventSourceType } from '@fidscript/instant-sdk';
2
+ declare class EventSource implements EventSourceType {
3
+ private ERROR;
4
+ static CONNECTING: number;
5
+ static OPEN: number;
6
+ static CLOSED: number;
7
+ private CRLF;
8
+ private LF;
9
+ private CR;
10
+ readonly url: string;
11
+ onopen: any;
12
+ onerror: any;
13
+ onmessage: any;
14
+ debug: boolean;
15
+ private status;
16
+ private headers;
17
+ private _xhr;
18
+ private lineEndingCharacter;
19
+ private _lastIndexProcessed;
20
+ constructor(url: any);
21
+ get readyState(): number;
22
+ open(): void;
23
+ _logDebug(...msg: any[]): void;
24
+ _handleEvent(response: any): void;
25
+ _detectNewlineChar(response: any): string | null;
26
+ _getLastDoubleNewlineIndex(response: any): any;
27
+ dispatch(type: any, data: any): void;
28
+ close(): void;
29
+ }
30
+ export default EventSource;
31
+ //# sourceMappingURL=EventSourceShim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventSourceShim.d.ts","sourceRoot":"","sources":["../../src/EventSourceShim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAa9D,cAAM,WAAY,YAAW,eAAe;IAC1C,OAAO,CAAC,KAAK,CAAM;IACnB,MAAM,CAAC,UAAU,SAAK;IACtB,MAAM,CAAC,IAAI,SAAK;IAChB,MAAM,CAAC,MAAM,SAAK;IAElB,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,EAAE,CAAQ;IAElB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,MAAM,MAAC;IACP,OAAO,MAAC;IACR,SAAS,MAAC;IAEV,KAAK,EAAE,OAAO,CAAC;IAEf,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,OAAO,CAIb;IAEF,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,mBAAmB,CAAS;gBAExB,GAAG,KAAA;IAiBf,IAAW,UAAU,WAKpB;IAED,IAAI;IA8FJ,SAAS,CAAC,GAAG,GAAG,OAAA;IAMhB,YAAY,CAAC,QAAQ,KAAA;IA8DrB,kBAAkB,CAAC,QAAQ,KAAA;IAU3B,0BAA0B,CAAC,QAAQ,KAAA;IAWnC,QAAQ,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA;IAuBnB,KAAK;CASN;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,226 @@
1
+ // Modified version of https://github.com/binaryminds/react-native-sse/blob/master/src/EventSource.js
2
+ // that conforms to our `EventSourceType` subset of the browser-native `EventSource`.
3
+ const XMLReadyStateMap = [
4
+ 'UNSENT',
5
+ 'OPENED',
6
+ 'HEADERS_RECEIVED',
7
+ 'LOADING',
8
+ 'DONE',
9
+ ];
10
+ class EventSource {
11
+ ERROR = -1;
12
+ static CONNECTING = 0;
13
+ static OPEN = 1;
14
+ static CLOSED = 2;
15
+ CRLF = '\r\n';
16
+ LF = '\n';
17
+ CR = '\r';
18
+ url;
19
+ onopen;
20
+ onerror;
21
+ onmessage;
22
+ debug;
23
+ status;
24
+ headers = {
25
+ Accept: 'text/event-stream',
26
+ 'Cache-Control': 'no-cache',
27
+ 'X-Requested-With': 'XMLHttpRequest',
28
+ };
29
+ _xhr;
30
+ lineEndingCharacter;
31
+ _lastIndexProcessed;
32
+ constructor(url) {
33
+ this.status = EventSource.CONNECTING;
34
+ this.lineEndingCharacter = null;
35
+ this._xhr = null;
36
+ this._lastIndexProcessed = 0;
37
+ this.debug = false;
38
+ if (!url || typeof url !== 'string') {
39
+ throw new SyntaxError('[EventSource] Invalid URL argument.');
40
+ }
41
+ this.url = url;
42
+ this.open();
43
+ }
44
+ get readyState() {
45
+ if (this.status === this.ERROR) {
46
+ return EventSource.CLOSED;
47
+ }
48
+ return this.status;
49
+ }
50
+ open() {
51
+ try {
52
+ this.status = EventSource.CONNECTING;
53
+ this._lastIndexProcessed = 0;
54
+ this._xhr = new XMLHttpRequest();
55
+ this._xhr.open('GET', this.url, true);
56
+ for (const [key, value] of Object.entries(this.headers)) {
57
+ if (value !== undefined && value !== null) {
58
+ this._xhr.setRequestHeader(key, value);
59
+ }
60
+ }
61
+ this._xhr.onreadystatechange = () => {
62
+ if (this.status === EventSource.CLOSED) {
63
+ return;
64
+ }
65
+ const xhr = this._xhr;
66
+ this._logDebug(`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'}(${xhr.readyState}), status: ${xhr.status}`);
67
+ if (xhr.readyState !== XMLHttpRequest.DONE &&
68
+ xhr.readyState !== XMLHttpRequest.LOADING) {
69
+ return;
70
+ }
71
+ if (xhr.status >= 200 && xhr.status < 400) {
72
+ if (this.status === EventSource.CONNECTING) {
73
+ this.status = EventSource.OPEN;
74
+ this.dispatch('open', { type: 'open' });
75
+ this._logDebug('[EventSource][onreadystatechange][OPEN] Connection opened.');
76
+ }
77
+ this._handleEvent(xhr.responseText || '');
78
+ if (xhr.readyState === XMLHttpRequest.DONE) {
79
+ this._logDebug('[EventSource][onreadystatechange][DONE] Operation done.');
80
+ this.dispatch('error', { type: 'error' });
81
+ }
82
+ }
83
+ else if (xhr.status !== 0) {
84
+ this.status = this.ERROR;
85
+ this.dispatch('error', {
86
+ type: 'error',
87
+ message: xhr.responseText,
88
+ xhrStatus: xhr.status,
89
+ xhrState: xhr.readyState,
90
+ });
91
+ if (xhr.readyState === XMLHttpRequest.DONE) {
92
+ this._logDebug('[EventSource][onreadystatechange][ERROR] Response status error.');
93
+ }
94
+ }
95
+ };
96
+ this._xhr.onerror = () => {
97
+ if (this.status === EventSource.CLOSED) {
98
+ return;
99
+ }
100
+ this.status = this.ERROR;
101
+ this.dispatch('error', {
102
+ type: 'error',
103
+ message: this._xhr.responseText,
104
+ xhrStatus: this._xhr.status,
105
+ xhrState: this._xhr.readyState,
106
+ });
107
+ };
108
+ this._xhr.send();
109
+ }
110
+ catch (e) {
111
+ this.status = this.ERROR;
112
+ this.dispatch('error', {
113
+ type: 'exception',
114
+ message: e.message,
115
+ error: e,
116
+ });
117
+ }
118
+ }
119
+ _logDebug(...msg) {
120
+ if (this.debug) {
121
+ console.debug(...msg);
122
+ }
123
+ }
124
+ _handleEvent(response) {
125
+ if (this.lineEndingCharacter === null) {
126
+ const detectedNewlineChar = this._detectNewlineChar(response);
127
+ if (detectedNewlineChar !== null) {
128
+ this._logDebug(`[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(detectedNewlineChar).slice(1, -1)}`);
129
+ this.lineEndingCharacter = detectedNewlineChar;
130
+ }
131
+ else {
132
+ console.warn("[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\r\\n, \\n, \\r, or specify your custom character using the 'lineEndingCharacter' option.");
133
+ return;
134
+ }
135
+ }
136
+ const indexOfDoubleNewline = this._getLastDoubleNewlineIndex(response);
137
+ if (indexOfDoubleNewline <= this._lastIndexProcessed) {
138
+ return;
139
+ }
140
+ const parts = response
141
+ .substring(this._lastIndexProcessed, indexOfDoubleNewline)
142
+ .split(this.lineEndingCharacter);
143
+ this._lastIndexProcessed = indexOfDoubleNewline;
144
+ let type = undefined;
145
+ let data = [];
146
+ let line = '';
147
+ for (let i = 0; i < parts.length; i++) {
148
+ line = parts[i].trim();
149
+ if (line.startsWith('event')) {
150
+ type = line.replace(/event:?\s*/, '');
151
+ }
152
+ else if (line.startsWith('retry')) {
153
+ // Ignore for our use case, we'll reconnect with a new
154
+ // instance on error
155
+ }
156
+ else if (line.startsWith('data')) {
157
+ data.push(line.replace(/data:?\s*/, ''));
158
+ }
159
+ else if (line.startsWith('id')) {
160
+ // Ignore this, not used for our use case
161
+ }
162
+ else if (line === '') {
163
+ if (data.length > 0) {
164
+ const eventType = type || 'message';
165
+ const event = {
166
+ type: eventType,
167
+ data: data.join('\n'),
168
+ url: this.url,
169
+ };
170
+ this.dispatch(eventType, event);
171
+ data = [];
172
+ type = undefined;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ _detectNewlineChar(response) {
178
+ const supportedLineEndings = [this.CRLF, this.LF, this.CR];
179
+ for (const char of supportedLineEndings) {
180
+ if (response.includes(char)) {
181
+ return char;
182
+ }
183
+ }
184
+ return null;
185
+ }
186
+ _getLastDoubleNewlineIndex(response) {
187
+ const doubleLineEndingCharacter = this.lineEndingCharacter + this.lineEndingCharacter;
188
+ const lastIndex = response.lastIndexOf(doubleLineEndingCharacter);
189
+ if (lastIndex === -1) {
190
+ return -1;
191
+ }
192
+ return lastIndex + doubleLineEndingCharacter.length;
193
+ }
194
+ dispatch(type, data) {
195
+ switch (type) {
196
+ case 'open': {
197
+ if (this.onopen) {
198
+ this.onopen(data);
199
+ }
200
+ break;
201
+ }
202
+ case 'error': {
203
+ if (this.onerror) {
204
+ this.onerror(data);
205
+ }
206
+ break;
207
+ }
208
+ case 'message': {
209
+ if (this.onmessage) {
210
+ this.onmessage(data);
211
+ }
212
+ break;
213
+ }
214
+ }
215
+ }
216
+ close() {
217
+ if (this.status !== EventSource.CLOSED) {
218
+ this.status = EventSource.CLOSED;
219
+ }
220
+ if (this._xhr) {
221
+ this._xhr.abort();
222
+ }
223
+ }
224
+ }
225
+ export default EventSource;
226
+ //# sourceMappingURL=EventSourceShim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventSourceShim.js","sourceRoot":"","sources":["../../src/EventSourceShim.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,qFAAqF;AAErF,MAAM,gBAAgB,GAAG;IACvB,QAAQ;IACR,QAAQ;IACR,kBAAkB;IAClB,SAAS;IACT,MAAM;CACP,CAAC;AAEF,MAAM,WAAW;IACP,KAAK,GAAG,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;IAChB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAEV,IAAI,GAAG,MAAM,CAAC;IACd,EAAE,GAAG,IAAI,CAAC;IACV,EAAE,GAAG,IAAI,CA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,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QACnC,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;;AAGH,eAAe,WAAW,CAAC","sourcesContent":["import { type EventSourceType } from '@fidscript/instant-sdk';\n\n// Modified version of https://github.com/binaryminds/react-native-sse/blob/master/src/EventSource.js\n// that conforms to our `EventSourceType` subset of the browser-native `EventSource`.\n\nconst XMLReadyStateMap = [\n 'UNSENT',\n 'OPENED',\n 'HEADERS_RECEIVED',\n 'LOADING',\n 'DONE',\n];\n\nclass EventSource implements EventSourceType {\n private ERROR = -1;\n static CONNECTING = 0;\n static OPEN = 1;\n static CLOSED = 2;\n\n private CRLF = '\\r\\n';\n private LF = '\\n';\n private CR = '\\r';\n\n readonly url: string;\n\n onopen;\n onerror;\n onmessage;\n\n debug: boolean;\n\n private status: number;\n\n private headers = {\n Accept: 'text/event-stream',\n 'Cache-Control': 'no-cache',\n 'X-Requested-With': 'XMLHttpRequest',\n };\n\n private _xhr: XMLHttpRequest | null;\n private lineEndingCharacter: string | null;\n private _lastIndexProcessed: number;\n\n constructor(url) {\n this.status = EventSource.CONNECTING;\n\n this.lineEndingCharacter = null;\n this._xhr = null;\n this._lastIndexProcessed = 0;\n this.debug = false;\n\n if (!url || typeof url !== 'string') {\n throw new SyntaxError('[EventSource] Invalid URL argument.');\n }\n\n this.url = url;\n\n this.open();\n }\n\n public get readyState() {\n if (this.status === this.ERROR) {\n return EventSource.CLOSED;\n }\n return this.status;\n }\n\n open() {\n try {\n this.status = EventSource.CONNECTING;\n\n this._lastIndexProcessed = 0;\n\n this._xhr = new XMLHttpRequest();\n this._xhr.open('GET', this.url, true);\n\n for (const [key, value] of Object.entries(this.headers)) {\n if (value !== undefined && value !== null) {\n this._xhr.setRequestHeader(key, value);\n }\n }\n\n this._xhr.onreadystatechange = () => {\n if (this.status === EventSource.CLOSED) {\n return;\n }\n\n const xhr = this._xhr!;\n\n this._logDebug(\n `[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'}(${\n xhr.readyState\n }), status: ${xhr.status}`,\n );\n\n if (\n xhr.readyState !== XMLHttpRequest.DONE &&\n xhr.readyState !== XMLHttpRequest.LOADING\n ) {\n return;\n }\n\n if (xhr.status >= 200 && xhr.status < 400) {\n if (this.status === EventSource.CONNECTING) {\n this.status = EventSource.OPEN;\n this.dispatch('open', { type: 'open' });\n this._logDebug(\n '[EventSource][onreadystatechange][OPEN] Connection opened.',\n );\n }\n\n this._handleEvent(xhr.responseText || '');\n\n if (xhr.readyState === XMLHttpRequest.DONE) {\n this._logDebug(\n '[EventSource][onreadystatechange][DONE] Operation done.',\n );\n this.dispatch('error', { type: 'error' });\n }\n } else if (xhr.status !== 0) {\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'error',\n message: xhr.responseText,\n xhrStatus: xhr.status,\n xhrState: xhr.readyState,\n });\n\n if (xhr.readyState === XMLHttpRequest.DONE) {\n this._logDebug(\n '[EventSource][onreadystatechange][ERROR] Response status error.',\n );\n }\n }\n };\n\n this._xhr.onerror = () => {\n if (this.status === EventSource.CLOSED) {\n return;\n }\n\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'error',\n message: this._xhr!.responseText,\n xhrStatus: this._xhr!.status,\n xhrState: this._xhr!.readyState,\n });\n };\n\n this._xhr.send();\n } catch (e) {\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'exception',\n message: e.message,\n error: e,\n });\n }\n }\n\n _logDebug(...msg) {\n if (this.debug) {\n console.debug(...msg);\n }\n }\n\n _handleEvent(response) {\n if (this.lineEndingCharacter === null) {\n const detectedNewlineChar = this._detectNewlineChar(response);\n if (detectedNewlineChar !== null) {\n this._logDebug(\n `[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(\n detectedNewlineChar,\n ).slice(1, -1)}`,\n );\n this.lineEndingCharacter = detectedNewlineChar;\n } else {\n console.warn(\n \"[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\\\r\\\\n, \\\\n, \\\\r, or specify your custom character using the 'lineEndingCharacter' option.\",\n );\n return;\n }\n }\n\n const indexOfDoubleNewline = this._getLastDoubleNewlineIndex(response);\n if (indexOfDoubleNewline <= this._lastIndexProcessed) {\n return;\n }\n\n const parts = response\n .substring(this._lastIndexProcessed, indexOfDoubleNewline)\n .split(this.lineEndingCharacter);\n\n this._lastIndexProcessed = indexOfDoubleNewline;\n\n let type: string | undefined = undefined;\n let data: string[] = [];\n let line = '';\n\n for (let i = 0; i < parts.length; i++) {\n line = parts[i].trim();\n if (line.startsWith('event')) {\n type = line.replace(/event:?\\s*/, '');\n } else if (line.startsWith('retry')) {\n // Ignore for our use case, we'll reconnect with a new\n // instance on error\n } else if (line.startsWith('data')) {\n data.push(line.replace(/data:?\\s*/, ''));\n } else if (line.startsWith('id')) {\n // Ignore this, not used for our use case\n } else if (line === '') {\n if (data.length > 0) {\n const eventType = type || 'message';\n const event = {\n type: eventType,\n data: data.join('\\n'),\n url: this.url,\n };\n\n this.dispatch(eventType, event);\n\n data = [];\n type = undefined;\n }\n }\n }\n }\n\n _detectNewlineChar(response) {\n const supportedLineEndings = [this.CRLF, this.LF, this.CR];\n for (const char of supportedLineEndings) {\n if (response.includes(char)) {\n return char;\n }\n }\n return null;\n }\n\n _getLastDoubleNewlineIndex(response) {\n const doubleLineEndingCharacter =\n this.lineEndingCharacter! + this.lineEndingCharacter!;\n const lastIndex = response.lastIndexOf(doubleLineEndingCharacter);\n if (lastIndex === -1) {\n return -1;\n }\n\n return lastIndex + doubleLineEndingCharacter.length;\n }\n\n dispatch(type, data) {\n switch (type) {\n case 'open': {\n if (this.onopen) {\n this.onopen(data);\n }\n break;\n }\n case 'error': {\n if (this.onerror) {\n this.onerror(data);\n }\n break;\n }\n case 'message': {\n if (this.onmessage) {\n this.onmessage(data);\n }\n break;\n }\n }\n }\n\n close() {\n if (this.status !== EventSource.CLOSED) {\n this.status = EventSource.CLOSED;\n }\n\n if (this._xhr) {\n this._xhr.abort();\n }\n }\n}\n\nexport default EventSource;\n"]}
@@ -0,0 +1,5 @@
1
+ export default class NetworkListener {
2
+ static getIsOnline(): Promise<boolean | null>;
3
+ static listen(f: any): import("@react-native-community/netinfo").NetInfoSubscription;
4
+ }
5
+ //# sourceMappingURL=NetworkListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkListener.d.ts","sourceRoot":"","sources":["../../src/NetworkListener.js"],"names":[],"mappings":"AAEA;IACE,8CAGC;IACD,qFAIC;CACF"}
@@ -0,0 +1,13 @@
1
+ import NetInfo from '@react-native-community/netinfo';
2
+ export default class NetworkListener {
3
+ static async getIsOnline() {
4
+ const network = await NetInfo.fetch();
5
+ return network.isConnected;
6
+ }
7
+ static listen(f) {
8
+ return NetInfo.addEventListener((state) => {
9
+ f(state.isConnected);
10
+ });
11
+ }
12
+ }
13
+ //# sourceMappingURL=NetworkListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkListener.js","sourceRoot":"","sources":["../../src/NetworkListener.js"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,iCAAiC,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,MAAM,CAAC,KAAK,CAAC,WAAW;QACtB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC,WAAW,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,CAAC;QACb,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE,EAAE;YACxC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import NetInfo from '@react-native-community/netinfo';\n\nexport default class NetworkListener {\n static async getIsOnline() {\n const network = await NetInfo.fetch();\n return network.isConnected;\n }\n static listen(f) {\n return NetInfo.addEventListener((state) => {\n f(state.isConnected);\n });\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export default IndexedDBStorage;
2
+ import { IndexedDBStorage } from '@fidscript/instant-sdk';
3
+ //# sourceMappingURL=Storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../src/Storage.js"],"names":[],"mappings":";iCAAiC,wBAAwB"}
@@ -0,0 +1,3 @@
1
+ import { IndexedDBStorage } from '@fidscript/instant-sdk';
2
+ export default IndexedDBStorage;
3
+ //# sourceMappingURL=Storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../src/Storage.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,eAAe,gBAAgB,CAAC","sourcesContent":["import { IndexedDBStorage } from '@fidscript/instant-sdk';\n\nexport default IndexedDBStorage;\n"]}
@@ -0,0 +1,22 @@
1
+ import { StoreInterface, StoreInterfaceStoreName } from '@fidscript/instant-sdk';
2
+ export declare class AsyncStorageStore extends StoreInterface {
3
+ private appId;
4
+ private dbName;
5
+ constructor(appId: string, dbName: StoreInterfaceStoreName);
6
+ private makeKey;
7
+ getItem(k: any): Promise<any>;
8
+ setItem(k: any, v: any): Promise<void>;
9
+ removeItem(k: string): Promise<void>;
10
+ getAllKeys(): Promise<string[]>;
11
+ multiSet(keyValuePairs: Array<[string, any]>): Promise<void>;
12
+ }
13
+ declare class MissingStore extends StoreInterface {
14
+ constructor(appId: string, dbName: StoreInterfaceStoreName);
15
+ getItem(_k: string): Promise<any>;
16
+ removeItem(_k: string): Promise<void>;
17
+ multiSet(_keyValuePairs: Array<[string, any]>): Promise<void>;
18
+ getAllKeys(): Promise<string[]>;
19
+ }
20
+ declare const _default: typeof MissingStore;
21
+ export default _default;
22
+ //# sourceMappingURL=Storage.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.native.d.ts","sourceRoot":"","sources":["../../src/Storage.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAkBjF,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAA0B;gBAC5B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB;IAM1D,OAAO,CAAC,OAAO;IAIT,OAAO,CAAC,CAAC,KAAA;IAMT,OAAO,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;IAIZ,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAY/B,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnE;AAED,cAAM,YAAa,SAAQ,cAAc;gBAC3B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB;IAYpD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIjC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAErC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7D,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGtC;;AAED,wBAA+D"}