supastash 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/desktop/adapters/appstate.d.ts +2 -0
- package/dist/desktop/adapters/appstate.d.ts.map +1 -0
- package/dist/desktop/adapters/appstate.js +10 -0
- package/dist/desktop/adapters/crypto.d.ts +3 -0
- package/dist/desktop/adapters/crypto.d.ts.map +1 -0
- package/dist/desktop/adapters/crypto.js +16 -0
- package/dist/{core → desktop/core}/schemaManager/index.d.ts +1 -1
- package/dist/desktop/core/schemaManager/index.d.ts.map +1 -0
- package/dist/{core → desktop/core}/schemaManager/index.js +3 -3
- package/dist/{hooks/supastashData/index.d.ts → desktop/hooks/supastashData.d.ts} +2 -2
- package/dist/desktop/hooks/supastashData.d.ts.map +1 -0
- package/dist/desktop/hooks/supastashData.js +139 -0
- package/dist/{hooks → desktop/hooks}/supastashLogic.d.ts +1 -1
- package/dist/desktop/hooks/supastashLogic.d.ts.map +1 -0
- package/dist/{hooks → desktop/hooks}/supastashLogic.js +11 -12
- package/dist/{hooks/syncEngine/index.d.ts → desktop/hooks/syncEngine.d.ts} +1 -1
- package/dist/desktop/hooks/syncEngine.d.ts.map +1 -0
- package/dist/desktop/hooks/syncEngine.js +233 -0
- package/dist/desktop/index.d.ts +28 -0
- package/dist/desktop/index.d.ts.map +1 -0
- package/dist/desktop/index.js +21 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/eventQueues.d.ts +2 -2
- package/dist/desktop/utils/fetchData/eventQueues.d.ts.map +1 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/eventQueues.js +3 -3
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/fetchCalls.d.ts +1 -1
- package/dist/desktop/utils/fetchData/fetchCalls.d.ts.map +1 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/fetchCalls.js +5 -5
- package/dist/{utils → desktop/utils}/fetchData/initialFetch.d.ts +1 -1
- package/dist/desktop/utils/fetchData/initialFetch.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/fetchData/initialFetch.js +2 -2
- package/dist/{utils → desktop/utils}/fetchData/receiveData.d.ts +1 -1
- package/dist/desktop/utils/fetchData/receiveData.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/fetchData/receiveData.js +6 -6
- package/dist/desktop/utils/query/index.d.ts +73 -0
- package/dist/desktop/utils/query/index.d.ts.map +1 -0
- package/dist/desktop/utils/query/index.js +139 -0
- package/dist/desktop/utils/schema/wipeTables.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/schema/wipeTables.js +4 -4
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlder.d.ts +2 -2
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlder.js +2 -2
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlderHelpers.d.ts +3 -3
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlderHelpers.js +8 -14
- package/dist/desktop/utils/sync/pullFromRemote/index.d.ts.map +1 -0
- package/dist/{hooks/syncEngine → desktop/utils/sync}/pullFromRemote/index.js +7 -7
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/pullData.d.ts +2 -2
- package/dist/desktop/utils/sync/pullFromRemote/pullData.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/pullData.js +6 -6
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.d.ts +46 -0
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +1 -0
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.js +284 -0
- package/dist/desktop/utils/sync/pushLocal/index.d.ts.map +1 -0
- package/dist/{hooks/syncEngine → desktop/utils/sync}/pushLocal/index.js +7 -10
- package/dist/desktop/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/sendUnsyncedToSupabase.js +5 -8
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadChunk.d.ts +1 -1
- package/dist/desktop/utils/sync/pushLocal/uploadChunk.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadChunk.js +8 -12
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadHelpers.d.ts +2 -2
- package/dist/desktop/utils/sync/pushLocal/uploadHelpers.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadHelpers.js +6 -6
- package/dist/{utils → desktop/utils}/sync/status/filterKey.d.ts +1 -1
- package/dist/desktop/utils/sync/status/filterKey.d.ts.map +1 -0
- package/dist/desktop/utils/sync/status/filterKey.js +48 -0
- package/dist/{utils → desktop/utils}/sync/status/repo.d.ts +3 -3
- package/dist/desktop/utils/sync/status/repo.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/repo.js +3 -3
- package/dist/{utils → desktop/utils}/sync/status/services.d.ts +2 -2
- package/dist/desktop/utils/sync/status/services.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/services.js +3 -3
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.d.ts +2 -2
- package/dist/desktop/utils/sync/status/syncStatus.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.js +4 -4
- package/dist/index.d.ts +18 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -22
- package/dist/native/core/schemaManager/index.d.ts +40 -0
- package/dist/native/core/schemaManager/index.d.ts.map +1 -0
- package/dist/native/core/schemaManager/index.js +141 -0
- package/dist/native/hooks/supastashData.d.ts +67 -0
- package/dist/native/hooks/supastashData.d.ts.map +1 -0
- package/dist/{hooks/supastashData/index.js → native/hooks/supastashData.js} +12 -10
- package/dist/native/hooks/supastashLogic.d.ts +19 -0
- package/dist/native/hooks/supastashLogic.d.ts.map +1 -0
- package/dist/native/hooks/supastashLogic.js +101 -0
- package/dist/native/hooks/syncEngine.d.ts +28 -0
- package/dist/native/hooks/syncEngine.d.ts.map +1 -0
- package/dist/{hooks/syncEngine/index.js → native/hooks/syncEngine.js} +18 -18
- package/dist/native/index.d.ts +28 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +21 -0
- package/dist/native/utils/fetchData/eventQueues.d.ts +5 -0
- package/dist/native/utils/fetchData/eventQueues.d.ts.map +1 -0
- package/dist/native/utils/fetchData/eventQueues.js +52 -0
- package/dist/native/utils/fetchData/fetchCalls.d.ts +9 -0
- package/dist/native/utils/fetchData/fetchCalls.d.ts.map +1 -0
- package/dist/native/utils/fetchData/fetchCalls.js +88 -0
- package/dist/native/utils/fetchData/initialFetch.d.ts +3 -0
- package/dist/native/utils/fetchData/initialFetch.d.ts.map +1 -0
- package/dist/native/utils/fetchData/initialFetch.js +21 -0
- package/dist/native/utils/fetchData/receiveData.d.ts +3 -0
- package/dist/native/utils/fetchData/receiveData.d.ts.map +1 -0
- package/dist/native/utils/fetchData/receiveData.js +39 -0
- package/dist/native/utils/query/index.d.ts +73 -0
- package/dist/native/utils/query/index.d.ts.map +1 -0
- package/dist/native/utils/query/index.js +139 -0
- package/dist/native/utils/schema/wipeTables.d.ts +98 -0
- package/dist/native/utils/schema/wipeTables.d.ts.map +1 -0
- package/dist/native/utils/schema/wipeTables.js +188 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.d.ts +44 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.js +55 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts +33 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.js +104 -0
- package/dist/native/utils/sync/pullFromRemote/index.d.ts +5 -0
- package/dist/native/utils/sync/pullFromRemote/index.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/index.js +73 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.d.ts +21 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.js +80 -0
- package/dist/native/utils/sync/pullFromRemote/updateLocalDb.d.ts +46 -0
- package/dist/native/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +1 -0
- package/dist/{utils → native/utils}/sync/pullFromRemote/updateLocalDb.js +120 -47
- package/dist/native/utils/sync/pushLocal/index.d.ts +5 -0
- package/dist/native/utils/sync/pushLocal/index.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/index.js +101 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts +6 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.js +57 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.d.ts +8 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.js +173 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.d.ts +41 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.js +243 -0
- package/dist/native/utils/sync/status/filterKey.d.ts +15 -0
- package/dist/native/utils/sync/status/filterKey.d.ts.map +1 -0
- package/dist/{utils → native/utils}/sync/status/filterKey.js +0 -14
- package/dist/native/utils/sync/status/repo.d.ts +10 -0
- package/dist/native/utils/sync/status/repo.d.ts.map +1 -0
- package/dist/native/utils/sync/status/repo.js +97 -0
- package/dist/native/utils/sync/status/services.d.ts +31 -0
- package/dist/native/utils/sync/status/services.d.ts.map +1 -0
- package/dist/native/utils/sync/status/services.js +107 -0
- package/dist/native/utils/sync/status/syncStatus.d.ts +109 -0
- package/dist/native/utils/sync/status/syncStatus.d.ts.map +1 -0
- package/dist/native/utils/sync/status/syncStatus.js +161 -0
- package/dist/shared/constants/syncDefaults.d.ts.map +1 -0
- package/dist/{core → shared/core}/config/index.d.ts +2 -0
- package/dist/shared/core/config/index.d.ts.map +1 -0
- package/dist/{core → shared/core}/config/index.js +4 -0
- package/dist/shared/core/platform/appState.d.ts +12 -0
- package/dist/shared/core/platform/appState.d.ts.map +1 -0
- package/dist/shared/core/platform/appState.js +11 -0
- package/dist/shared/db/adapters/expo_sqlite.d.ts +3 -0
- package/dist/shared/db/adapters/expo_sqlite.d.ts.map +1 -0
- package/dist/shared/db/adapters/expo_sqlite.js +72 -0
- package/dist/shared/db/adapters/rn_nitro.d.ts +3 -0
- package/dist/shared/db/adapters/rn_nitro.d.ts.map +1 -0
- package/dist/shared/db/adapters/rn_nitro.js +111 -0
- package/dist/shared/db/adapters/rn_sqlite_storage.d.ts +3 -0
- package/dist/shared/db/adapters/rn_sqlite_storage.d.ts.map +1 -0
- package/dist/{db → shared/db}/adapters/rn_sqlite_storage.js +41 -0
- package/dist/shared/db/adapters/tauri.d.ts +3 -0
- package/dist/shared/db/adapters/tauri.d.ts.map +1 -0
- package/dist/shared/db/adapters/tauri.js +100 -0
- package/dist/shared/db/dbErrorMsg.d.ts.map +1 -0
- package/dist/{db → shared/db}/dbErrorMsg.js +7 -0
- package/dist/{db → shared/db}/dbInitializer.d.ts +1 -1
- package/dist/shared/db/dbInitializer.d.ts.map +1 -0
- package/dist/{db → shared/db}/dbInitializer.js +28 -15
- package/dist/shared/db/normalizer.d.ts +6 -0
- package/dist/shared/db/normalizer.d.ts.map +1 -0
- package/dist/shared/db/normalizer.js +26 -0
- package/dist/{hooks → shared/hooks}/supastashFilters/index.d.ts +1 -1
- package/dist/shared/hooks/supastashFilters/index.d.ts.map +1 -0
- package/dist/{hooks → shared/hooks}/syncStatus/index.d.ts +1 -1
- package/dist/shared/hooks/syncStatus/index.d.ts.map +1 -0
- package/dist/shared/store/localCache.d.ts.map +1 -0
- package/dist/shared/store/sharedDb.d.ts +6 -0
- package/dist/shared/store/sharedDb.d.ts.map +1 -0
- package/dist/shared/store/sharedDb.js +17 -0
- package/dist/shared/store/syncCalls.d.ts.map +1 -0
- package/dist/{store → shared/store}/syncStatus.d.ts +1 -1
- package/dist/shared/store/syncStatus.d.ts.map +1 -0
- package/dist/shared/store/tableFilters.d.ts.map +1 -0
- package/dist/shared/store/tableSchemaData.d.ts.map +1 -0
- package/dist/shared/store/tx.d.ts.map +1 -0
- package/dist/shared/types/adapters.types.d.ts +8 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/{types → shared/types}/supastashConfig.types.d.ts +180 -2
- package/dist/shared/utils/connection.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/connection.js +6 -6
- package/dist/shared/utils/errorHandler.d.ts.map +1 -0
- package/dist/shared/utils/events/eventBus.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/addPayloadToUI.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/createTable.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/dataState.d.ts.map +1 -0
- package/dist/{hooks/supastashData → shared/utils/fetchData}/dataState.js +1 -1
- package/dist/shared/utils/fetchData/deleteData.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/fetchData/deleteData.js +2 -2
- package/dist/shared/utils/fetchData/fetchLocalData.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/getKeyType.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/liteHelpers.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/realTimeCall.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/realTimeManager.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/registerSub.d.ts.map +1 -0
- package/dist/{hooks/supastashData → shared/utils/fetchData}/registerSub.js +1 -1
- package/dist/shared/utils/fetchData/setDataInBatches.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/snapShot.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/validatePayload.d.ts.map +1 -0
- package/dist/shared/utils/genUUID.d.ts.map +1 -0
- package/dist/shared/utils/getSafeValues.d.ts.map +1 -0
- package/dist/shared/utils/getTableSchema.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/logs.d.ts +1 -0
- package/dist/shared/utils/logs.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/logs.js +6 -1
- package/dist/shared/utils/query/builder/crud.d.ts.map +1 -0
- package/dist/shared/utils/query/builder/filters.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/builder/filters.js +1 -1
- package/dist/shared/utils/query/builder/index.d.ts.map +1 -0
- package/dist/shared/utils/query/builder/mainQuery.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/getLocalMethod.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/insertMany.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/upsertMany.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/mainQueryHelpers.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/mainQueryHelpers.js +1 -1
- package/dist/shared/utils/query/helpers/queryValidator.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/queueRemote.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/queueRemote.js +4 -4
- package/dist/shared/utils/query/helpers/remoteDb/queryFilterBuilder.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/remoteDb/queryUtils.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/delete.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/index.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/insert.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/select.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/update.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/update.js +2 -2
- package/dist/shared/utils/query/localDbQuery/upsert.d.ts.map +1 -0
- package/dist/shared/utils/query/remoteQuery/supabaseQuery.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/remoteQuery/supabaseQuery.js +1 -1
- package/dist/shared/utils/refreshScreenCalls.d.ts.map +1 -0
- package/dist/shared/utils/reusedHelpers.d.ts.map +1 -0
- package/dist/shared/utils/schema/createSyncStatus.d.ts.map +1 -0
- package/dist/shared/utils/serializer.d.ts.map +1 -0
- package/dist/shared/utils/supabaseClientErr.d.ts.map +1 -0
- package/dist/shared/utils/supastashMode.d.ts.map +1 -0
- package/dist/shared/utils/sync/getAllTables.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/getAllTables.js +1 -1
- package/dist/shared/utils/sync/pullFromRemote/getLastCreatedInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/getLastDeletedInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/getLastPulledInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/helpers.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/runLimitedConcurrency.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pullFromRemote/runLimitedConcurrency.js +1 -1
- package/dist/shared/utils/sync/pullFromRemote/stringifyFields.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/updateFilter.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/validateFilters.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/deleteChunks.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pushLocal/getAllUnsyncedData.js +2 -2
- package/dist/shared/utils/sync/pushLocal/normalize.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/parseFields.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/queryStatus.d.ts +1 -1
- package/dist/shared/utils/sync/queryStatus.d.ts.map +1 -0
- package/dist/shared/utils/sync/refreshTables.d.ts.map +1 -0
- package/dist/shared/utils/sync/registration/syncCalls.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/registration/syncCalls.js +1 -1
- package/dist/shared/utils/sync/status/remoteSchema.d.ts.map +1 -0
- package/dist/shared/utils/sync/status/syncUpdate.d.ts.map +1 -0
- package/dist/shared/utils/tableValidator.d.ts.map +1 -0
- package/package.json +28 -11
- package/dist/constants/syncDefaults.d.ts.map +0 -1
- package/dist/core/config/index.d.ts.map +0 -1
- package/dist/core/schemaManager/index.d.ts.map +0 -1
- package/dist/db/adapters/expo_sqlite.d.ts +0 -3
- package/dist/db/adapters/expo_sqlite.d.ts.map +0 -1
- package/dist/db/adapters/expo_sqlite.js +0 -35
- package/dist/db/adapters/rn_nitro.d.ts +0 -3
- package/dist/db/adapters/rn_nitro.d.ts.map +0 -1
- package/dist/db/adapters/rn_nitro.js +0 -54
- package/dist/db/adapters/rn_sqlite_storage.d.ts +0 -3
- package/dist/db/adapters/rn_sqlite_storage.d.ts.map +0 -1
- package/dist/db/dbErrorMsg.d.ts.map +0 -1
- package/dist/db/dbInitializer.d.ts.map +0 -1
- package/dist/hooks/supastashData/addPayloadToUI.d.ts.map +0 -1
- package/dist/hooks/supastashData/dataState.d.ts.map +0 -1
- package/dist/hooks/supastashData/eventQueues.d.ts.map +0 -1
- package/dist/hooks/supastashData/fetchCalls.d.ts.map +0 -1
- package/dist/hooks/supastashData/index.d.ts.map +0 -1
- package/dist/hooks/supastashData/realtimeSubscription.d.ts +0 -5
- package/dist/hooks/supastashData/realtimeSubscription.d.ts.map +0 -1
- package/dist/hooks/supastashData/realtimeSubscription.js +0 -96
- package/dist/hooks/supastashData/registerSub.d.ts.map +0 -1
- package/dist/hooks/supastashFilters/index.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.d.ts +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.js +0 -122
- package/dist/hooks/supastashLiteQuery/index.d.ts +0 -53
- package/dist/hooks/supastashLiteQuery/index.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/index.js +0 -127
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.d.ts +0 -1
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.js +0 -1
- package/dist/hooks/supastashLogic.d.ts.map +0 -1
- package/dist/hooks/syncEngine/index.d.ts.map +0 -1
- package/dist/hooks/syncEngine/pullFromRemote/index.d.ts.map +0 -1
- package/dist/hooks/syncEngine/pushLocal/index.d.ts.map +0 -1
- package/dist/hooks/syncStatus/index.d.ts.map +0 -1
- package/dist/store/localCache.d.ts.map +0 -1
- package/dist/store/syncCalls.d.ts.map +0 -1
- package/dist/store/syncStatus.d.ts.map +0 -1
- package/dist/store/tableFilters.d.ts.map +0 -1
- package/dist/store/tableSchemaData.d.ts.map +0 -1
- package/dist/store/tx.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/connection.d.ts.map +0 -1
- package/dist/utils/createIndexes.d.ts +0 -9
- package/dist/utils/createIndexes.d.ts.map +0 -1
- package/dist/utils/createIndexes.js +0 -74
- package/dist/utils/errorHandler.d.ts.map +0 -1
- package/dist/utils/events/eventBus.d.ts.map +0 -1
- package/dist/utils/fetchData/buildFilter.d.ts +0 -8
- package/dist/utils/fetchData/buildFilter.d.ts.map +0 -1
- package/dist/utils/fetchData/buildFilter.js +0 -58
- package/dist/utils/fetchData/createTable.d.ts.map +0 -1
- package/dist/utils/fetchData/deleteData.d.ts.map +0 -1
- package/dist/utils/fetchData/fetchLocalData.d.ts.map +0 -1
- package/dist/utils/fetchData/getKeyType.d.ts.map +0 -1
- package/dist/utils/fetchData/initialFetch.d.ts.map +0 -1
- package/dist/utils/fetchData/liteHelpers.d.ts.map +0 -1
- package/dist/utils/fetchData/liteReducer.d.ts +0 -3
- package/dist/utils/fetchData/liteReducer.d.ts.map +0 -1
- package/dist/utils/fetchData/liteReducer.js +0 -103
- package/dist/utils/fetchData/realTimeCall.d.ts.map +0 -1
- package/dist/utils/fetchData/realTimeManager.d.ts.map +0 -1
- package/dist/utils/fetchData/receiveData.d.ts.map +0 -1
- package/dist/utils/fetchData/setDataInBatches.d.ts.map +0 -1
- package/dist/utils/fetchData/snapShot.d.ts.map +0 -1
- package/dist/utils/fetchData/validatePayload.d.ts.map +0 -1
- package/dist/utils/genUUID.d.ts.map +0 -1
- package/dist/utils/getSafeValues.d.ts.map +0 -1
- package/dist/utils/getTableSchema.d.ts.map +0 -1
- package/dist/utils/logs.d.ts.map +0 -1
- package/dist/utils/query/builder/crud.d.ts.map +0 -1
- package/dist/utils/query/builder/filters.d.ts.map +0 -1
- package/dist/utils/query/builder/index.d.ts.map +0 -1
- package/dist/utils/query/builder/mainQuery.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/getLocalMethod.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/insertMany.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/upsertMany.d.ts.map +0 -1
- package/dist/utils/query/helpers/mainQueryHelpers.d.ts.map +0 -1
- package/dist/utils/query/helpers/queryValidator.d.ts.map +0 -1
- package/dist/utils/query/helpers/queueRemote.d.ts.map +0 -1
- package/dist/utils/query/helpers/remoteDb/queryFilterBuilder.d.ts.map +0 -1
- package/dist/utils/query/helpers/remoteDb/queryUtils.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/delete.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/index.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/insert.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/select.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/update.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/upsert.d.ts.map +0 -1
- package/dist/utils/query/remoteQuery/supabaseQuery.d.ts.map +0 -1
- package/dist/utils/refreshScreenCalls.d.ts.map +0 -1
- package/dist/utils/reusedHelpers.d.ts.map +0 -1
- package/dist/utils/schema/createSyncStatus.d.ts.map +0 -1
- package/dist/utils/schema/wipeTables.d.ts.map +0 -1
- package/dist/utils/serializer.d.ts.map +0 -1
- package/dist/utils/supabaseClientErr.d.ts.map +0 -1
- package/dist/utils/supastashMode.d.ts.map +0 -1
- package/dist/utils/sync/getAllTables.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/fetchOlder.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastCreatedInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastDeletedInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastPulledInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/helpers.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullData.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullDeletedData.d.ts +0 -15
- package/dist/utils/sync/pullFromRemote/pullDeletedData.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullDeletedData.js +0 -51
- package/dist/utils/sync/pullFromRemote/runLimitedConcurrency.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/stringifyFields.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/updateFilter.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts +0 -15
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/deleteChunks.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/normalize.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/parseFields.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/uploadChunk.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/uploadHelpers.d.ts.map +0 -1
- package/dist/utils/sync/queryStatus.d.ts.map +0 -1
- package/dist/utils/sync/refreshTables.d.ts.map +0 -1
- package/dist/utils/sync/registration/syncCalls.d.ts.map +0 -1
- package/dist/utils/sync/status/filterKey.d.ts.map +0 -1
- package/dist/utils/sync/status/remoteSchema.d.ts.map +0 -1
- package/dist/utils/sync/status/repo.d.ts.map +0 -1
- package/dist/utils/sync/status/services.d.ts.map +0 -1
- package/dist/utils/sync/status/syncStatus.d.ts.map +0 -1
- package/dist/utils/sync/status/syncUpdate.d.ts.map +0 -1
- package/dist/utils/syncStatus.d.ts +0 -69
- package/dist/utils/syncStatus.d.ts.map +0 -1
- package/dist/utils/syncStatus.js +0 -129
- package/dist/utils/syncUpdate.d.ts +0 -7
- package/dist/utils/syncUpdate.d.ts.map +0 -1
- package/dist/utils/syncUpdate.js +0 -18
- package/dist/utils/tableValidator.d.ts.map +0 -1
- package/dist/utils/toggleSupastashMode.d.ts +0 -28
- package/dist/utils/toggleSupastashMode.d.ts.map +0 -1
- package/dist/utils/toggleSupastashMode.js +0 -46
- /package/dist/{utils → desktop/utils}/schema/wipeTables.d.ts +0 -0
- /package/dist/{hooks/syncEngine → desktop/utils/sync}/pullFromRemote/index.d.ts +0 -0
- /package/dist/{hooks/syncEngine → desktop/utils/sync}/pushLocal/index.d.ts +0 -0
- /package/dist/{utils → desktop/utils}/sync/pushLocal/sendUnsyncedToSupabase.d.ts +0 -0
- /package/dist/{constants → shared/constants}/syncDefaults.d.ts +0 -0
- /package/dist/{constants → shared/constants}/syncDefaults.js +0 -0
- /package/dist/{db → shared/db}/dbErrorMsg.d.ts +0 -0
- /package/dist/{hooks → shared/hooks}/supastashFilters/index.js +0 -0
- /package/dist/{hooks → shared/hooks}/syncStatus/index.js +0 -0
- /package/dist/{store → shared/store}/localCache.d.ts +0 -0
- /package/dist/{store → shared/store}/localCache.js +0 -0
- /package/dist/{store → shared/store}/syncCalls.d.ts +0 -0
- /package/dist/{store → shared/store}/syncCalls.js +0 -0
- /package/dist/{store → shared/store}/syncStatus.js +0 -0
- /package/dist/{store → shared/store}/tableFilters.d.ts +0 -0
- /package/dist/{store → shared/store}/tableFilters.js +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.d.ts +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.js +0 -0
- /package/dist/{store → shared/store}/tx.d.ts +0 -0
- /package/dist/{store → shared/store}/tx.js +0 -0
- /package/dist/{types → shared/types}/expoSqlite.types.d.ts +0 -0
- /package/dist/{types → shared/types}/index.d.ts +0 -0
- /package/dist/{types → shared/types}/index.js +0 -0
- /package/dist/{types → shared/types}/liteQuery.types.d.ts +0 -0
- /package/dist/{types → shared/types}/query.types.d.ts +0 -0
- /package/dist/{types → shared/types}/realtimeData.types.d.ts +0 -0
- /package/dist/{types → shared/types}/rnNitroSqlite.types.d.ts +0 -0
- /package/dist/{types → shared/types}/rnSqliteStorage.types.d.ts +0 -0
- /package/dist/{types → shared/types}/schemaManager.types.d.ts +0 -0
- /package/dist/{types → shared/types}/syncEngine.types.d.ts +0 -0
- /package/dist/{utils → shared/utils}/connection.d.ts +0 -0
- /package/dist/{utils → shared/utils}/errorHandler.d.ts +0 -0
- /package/dist/{utils → shared/utils}/errorHandler.js +0 -0
- /package/dist/{utils → shared/utils}/events/eventBus.d.ts +0 -0
- /package/dist/{utils → shared/utils}/events/eventBus.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/addPayloadToUI.d.ts +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/addPayloadToUI.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/createTable.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/createTable.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/dataState.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/deleteData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/fetchLocalData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/fetchLocalData.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/getKeyType.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/getKeyType.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/liteHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/liteHelpers.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeCall.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeCall.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeManager.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeManager.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/registerSub.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/setDataInBatches.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/setDataInBatches.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/snapShot.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/snapShot.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/validatePayload.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/validatePayload.js +0 -0
- /package/dist/{utils → shared/utils}/genUUID.d.ts +0 -0
- /package/dist/{utils → shared/utils}/genUUID.js +0 -0
- /package/dist/{utils → shared/utils}/getSafeValues.d.ts +0 -0
- /package/dist/{utils → shared/utils}/getSafeValues.js +0 -0
- /package/dist/{utils → shared/utils}/getTableSchema.d.ts +0 -0
- /package/dist/{utils → shared/utils}/getTableSchema.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/crud.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/crud.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/filters.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/index.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/mainQuery.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/mainQuery.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/getLocalMethod.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/getLocalMethod.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/localQueryBuilder.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/localQueryBuilder.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/mainQueryHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queryValidator.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queryValidator.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queueRemote.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryFilterBuilder.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryFilterBuilder.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryUtils.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryUtils.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/delete.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/delete.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/index.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/insert.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/insert.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/select.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/select.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/update.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/upsert.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/upsert.js +0 -0
- /package/dist/{utils → shared/utils}/query/remoteQuery/supabaseQuery.d.ts +0 -0
- /package/dist/{utils → shared/utils}/refreshScreenCalls.d.ts +0 -0
- /package/dist/{utils → shared/utils}/refreshScreenCalls.js +0 -0
- /package/dist/{utils → shared/utils}/reusedHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/reusedHelpers.js +0 -0
- /package/dist/{utils → shared/utils}/schema/createSyncStatus.d.ts +0 -0
- /package/dist/{utils → shared/utils}/schema/createSyncStatus.js +0 -0
- /package/dist/{utils → shared/utils}/serializer.d.ts +0 -0
- /package/dist/{utils → shared/utils}/serializer.js +0 -0
- /package/dist/{utils → shared/utils}/supabaseClientErr.d.ts +0 -0
- /package/dist/{utils → shared/utils}/supabaseClientErr.js +0 -0
- /package/dist/{utils → shared/utils}/supastashMode.d.ts +0 -0
- /package/dist/{utils → shared/utils}/supastashMode.js +0 -0
- /package/dist/{utils → shared/utils}/sync/getAllTables.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastCreatedInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastCreatedInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastDeletedInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastDeletedInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastPulledInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastPulledInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/helpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/helpers.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/runLimitedConcurrency.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/stringifyFields.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/stringifyFields.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/updateFilter.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/updateFilter.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/validateFilters.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/validateFilters.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/deleteChunks.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/deleteChunks.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/getAllUnsyncedData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/normalize.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/normalize.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/parseFields.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/parseFields.js +0 -0
- /package/dist/{utils → shared/utils}/sync/queryStatus.js +0 -0
- /package/dist/{utils → shared/utils}/sync/refreshTables.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/refreshTables.js +0 -0
- /package/dist/{utils → shared/utils}/sync/registration/syncCalls.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/remoteSchema.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/remoteSchema.js +0 -0
- /package/dist/{utils → shared/utils}/sync/status/syncUpdate.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/syncUpdate.js +0 -0
- /package/dist/{utils → shared/utils}/tableValidator.d.ts +0 -0
- /package/dist/{utils → shared/utils}/tableValidator.js +0 -0
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/supastash)
|
|
4
4
|
|
|
5
|
-
**Offline-First Sync Engine for Supabase + React Native**
|
|
5
|
+
**Offline-First Sync Engine for Supabase + React Native & Desktop**
|
|
6
6
|
|
|
7
|
-
> Supastash syncs your Supabase data with SQLite — live, offline, and conflict-safe. No boilerplate. Built for React Native and
|
|
7
|
+
> Supastash syncs your Supabase data with SQLite — live, offline, and conflict-safe. No boilerplate. Built for React Native, Expo, and (experimentally) Tauri desktop apps.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
>
|
|
23
23
|
> 👉 Learn more: https://0xzekea.github.io/supastash/docs/replication-mode
|
|
24
24
|
|
|
25
|
+
> 🖥️ **NEW (v0.2.1+, experimental) — Desktop Support via Tauri**
|
|
26
|
+
>
|
|
27
|
+
> Supastash now works in Tauri desktop apps using the `tauri-plugin-sql` adapter.
|
|
28
|
+
> Same sync engine, same API — now available beyond mobile.
|
|
29
|
+
> ⚠️ Desktop support is experimental. Expect rough edges and breaking changes.
|
|
30
|
+
|
|
25
31
|
---
|
|
26
32
|
|
|
27
33
|
## ✨ Features
|
|
@@ -34,6 +40,7 @@
|
|
|
34
40
|
- `expo-sqlite`
|
|
35
41
|
- `react-native-nitro-sqlite`
|
|
36
42
|
- `react-native-sqlite-storage` (beta)
|
|
43
|
+
- `tauri-plugin-sql` (desktop, experimental)
|
|
37
44
|
|
|
38
45
|
- 🧠 Built-in:
|
|
39
46
|
|
|
@@ -60,6 +67,14 @@ npm install @supabase/supabase-js \
|
|
|
60
67
|
react-native
|
|
61
68
|
```
|
|
62
69
|
|
|
70
|
+
> **Breaking change (v0.2.1+):** You must now pass `networkAdapter: NetInfo` explicitly in `configureSupastash`. Import it as:
|
|
71
|
+
>
|
|
72
|
+
> ```ts
|
|
73
|
+
> import * as NetInfo from "@react-native-community/netinfo"; // React Native only
|
|
74
|
+
> ```
|
|
75
|
+
>
|
|
76
|
+
> For Tauri desktop apps, `networkAdapter` is not required — network detection is handled natively.
|
|
77
|
+
|
|
63
78
|
### 🧱 Choose a SQLite Adapter
|
|
64
79
|
|
|
65
80
|
Choose **only one**, based on your stack:
|
|
@@ -75,7 +90,7 @@ npm install react-native-nitro-sqlite
|
|
|
75
90
|
npm install react-native-sqlite-storage
|
|
76
91
|
```
|
|
77
92
|
|
|
78
|
-
> Match with `sqliteClientType`: `"expo"`, `"rn-nitro"`,
|
|
93
|
+
> Match with `sqliteClientType`: `"expo"`, `"rn-nitro"`, `"rn-storage"`, or `"tauri"` (experimental)
|
|
79
94
|
|
|
80
95
|
---
|
|
81
96
|
|
|
@@ -88,12 +103,14 @@ npm install react-native-sqlite-storage
|
|
|
88
103
|
import { configureSupastash, defineLocalSchema } from "supastash";
|
|
89
104
|
import { supabase } from "./supabase";
|
|
90
105
|
import { openDatabaseAsync } from "expo-sqlite"; // or your adapter
|
|
106
|
+
import * as NetInfo from "@react-native-community/netinfo"; // react-native only
|
|
91
107
|
|
|
92
108
|
configureSupastash({
|
|
93
109
|
supabaseClient: supabase,
|
|
94
110
|
dbName: "supastash_db",
|
|
95
111
|
sqliteClient: { openDatabaseAsync },
|
|
96
112
|
sqliteClientType: "expo",
|
|
113
|
+
networkAdapter: NetInfo,
|
|
97
114
|
|
|
98
115
|
onSchemaInit: () => {
|
|
99
116
|
defineLocalSchema("users", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appstate.d.ts","sourceRoot":"","sources":["../../../src/desktop/adapters/appstate.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,IAAI,6BAQtD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const subscribeToAppVisibility = (cb) => {
|
|
2
|
+
if (typeof document !== "undefined") {
|
|
3
|
+
const handler = () => {
|
|
4
|
+
if (document.visibilityState === "visible")
|
|
5
|
+
cb();
|
|
6
|
+
};
|
|
7
|
+
document.addEventListener("visibilitychange", handler);
|
|
8
|
+
return () => document.removeEventListener("visibilitychange", handler);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/desktop/adapters/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,eAAO,MAAM,gBAAgB,EAAE,aAmB9B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const webCryptoAdapter = {
|
|
2
|
+
async sha256(input) {
|
|
3
|
+
// Web Crypto (preferred)
|
|
4
|
+
if (globalThis.crypto?.subtle) {
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
const data = encoder.encode(input);
|
|
7
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
8
|
+
return Array.from(new Uint8Array(hashBuffer))
|
|
9
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
10
|
+
.join("");
|
|
11
|
+
}
|
|
12
|
+
// Node fallback
|
|
13
|
+
const { createHash } = await import("crypto");
|
|
14
|
+
return createHash("sha256").update(input).digest("hex");
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/desktop/core/schemaManager/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAMlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,EAC7B,oBAAoB,UAAQ,iBAyF7B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSupastashDb } from "
|
|
2
|
-
import { clearSchemaCache } from "
|
|
3
|
-
import log, { logError } from "
|
|
1
|
+
import { getSupastashDb } from "../../../shared/db/dbInitializer";
|
|
2
|
+
import { clearSchemaCache } from "../../../shared/utils/getTableSchema";
|
|
3
|
+
import log, { logError } from "../../../shared/utils/logs";
|
|
4
4
|
import { resetSupastashSyncStatus } from "../../utils/sync/status/services";
|
|
5
5
|
/**
|
|
6
6
|
* 🧱 defineLocalSchema
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RealtimeOptions, SupastashDataResult } from "../../types/realtimeData.types";
|
|
1
|
+
import { RealtimeOptions, SupastashDataResult } from "../../shared/types/realtimeData.types";
|
|
2
2
|
/**
|
|
3
3
|
* @description
|
|
4
4
|
* React hook to sync and subscribe to local-first data from a Supabase table using Supastash.
|
|
@@ -64,4 +64,4 @@ import { RealtimeOptions, SupastashDataResult } from "../../types/realtimeData.t
|
|
|
64
64
|
* }
|
|
65
65
|
*/
|
|
66
66
|
export declare function useSupastashData<R = any>(table: string, options?: RealtimeOptions): SupastashDataResult<R>;
|
|
67
|
-
//# sourceMappingURL=
|
|
67
|
+
//# sourceMappingURL=supastashData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supastashData.d.ts","sourceRoot":"","sources":["../../../src/desktop/hooks/supastashData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,mBAAmB,EAEpB,MAAM,uCAAuC,CAAC;AAY/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EACtC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,mBAAmB,CAAC,CAAC,CAAC,CA6GxB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { localCache } from "../../shared/store/localCache";
|
|
3
|
+
import { supastashEventBus } from "../../shared/utils/events/eventBus";
|
|
4
|
+
import useDataState from "../../shared/utils/fetchData/dataState";
|
|
5
|
+
import useRealtimeData from "../../shared/utils/fetchData/realTimeCall";
|
|
6
|
+
import { ReusedHelpers } from "../../shared/utils/reusedHelpers";
|
|
7
|
+
import { isTrulyNullish } from "../../shared/utils/serializer";
|
|
8
|
+
import { subscribeToAppVisibility } from "../adapters/appstate";
|
|
9
|
+
import useEventQueues from "../utils/fetchData/eventQueues";
|
|
10
|
+
import { fetchCalls } from "../utils/fetchData/fetchCalls";
|
|
11
|
+
const tableSubscriptions = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* React hook to sync and subscribe to local-first data from a Supabase table using Supastash.
|
|
15
|
+
*
|
|
16
|
+
* Use `useSupastashData` when you want:
|
|
17
|
+
* - Offline-first reads from local SQLite.
|
|
18
|
+
* - Optional realtime syncing via Supabase `postgres_changes`.
|
|
19
|
+
* - Batching, lazy loading, and event-driven updates.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { data, dataMap, trigger, cancel } = useSupastashData("users", {
|
|
24
|
+
* shouldFetch: !!session?.user,
|
|
25
|
+
* lazy: true,
|
|
26
|
+
* limit: 100,
|
|
27
|
+
* orderBy: "created_at",
|
|
28
|
+
* orderDesc: true,
|
|
29
|
+
* sqlFilter: [
|
|
30
|
+
* { column: "user_id", operator: "eq", value: 1 },
|
|
31
|
+
* { column: "is_active", operator: "eq", value: true },
|
|
32
|
+
* ],
|
|
33
|
+
* onInsert: (user) => console.log("New user:", user),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* useEffect(() => {
|
|
37
|
+
* trigger(); // Manually start sync
|
|
38
|
+
* }, []);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param table - Name of the table (must match local SQLite schema).
|
|
42
|
+
* @param options - Configuration object.
|
|
43
|
+
*
|
|
44
|
+
* ## Fetch Options
|
|
45
|
+
* @param options.shouldFetch - If false, disables initial fetch. Defaults to `true`.
|
|
46
|
+
* @param options.lazy - If true, skips auto-fetch. Call `trigger()` manually.
|
|
47
|
+
* @param options.limit - Max records to load. Defaults to `200`.
|
|
48
|
+
* @param options.orderBy - Column to sort by. Defaults to `"created_at"`.
|
|
49
|
+
* @param options.orderDesc - If true, sorts descending. Defaults to `true`.
|
|
50
|
+
* @param options.sqlFilter - Optional SQL-level filters (`WHERE` clause).
|
|
51
|
+
* @param options.useFilterWhileSyncing - Applies filter during sync. Defaults to `true`.
|
|
52
|
+
* @param options.extraMapKey - Additional field to group `dataMap` by.
|
|
53
|
+
* @param options.clearCacheOnMount - Clears in-memory cache on mount. Defaults to `false`.
|
|
54
|
+
*
|
|
55
|
+
* ## Realtime Options
|
|
56
|
+
* @param options.realtime - Enables Supabase `postgres_changes` subscription. Defaults to `true`.
|
|
57
|
+
* @param options.filter - Realtime filter (column/operator/value).
|
|
58
|
+
* @param options.flushIntervalMs - Flush interval (in ms) for UI updates. Defaults to `100`.
|
|
59
|
+
*
|
|
60
|
+
* ## Event Callbacks
|
|
61
|
+
* @param options.onInsert - Called on `INSERT` event.
|
|
62
|
+
* @param options.onUpdate - Called on `UPDATE` event.
|
|
63
|
+
* @param options.onDelete - Called on `DELETE` event.
|
|
64
|
+
* @param options.onInsertAndUpdate - Called on both `INSERT` and `UPDATE`.
|
|
65
|
+
* @param options.onPushToRemote - Called after pushing a local change to Supabase.
|
|
66
|
+
*
|
|
67
|
+
* @returns {
|
|
68
|
+
* data: Array of records,
|
|
69
|
+
* dataMap: Map of records by ID,
|
|
70
|
+
* groupedBy: Optional maps grouped by field,
|
|
71
|
+
* trigger: Manually trigger sync,
|
|
72
|
+
* cancel: Cancel pending fetch or
|
|
73
|
+
* isFetching: Whether the data is being fetched
|
|
74
|
+
* }
|
|
75
|
+
*/
|
|
76
|
+
export function useSupastashData(table, options = {}) {
|
|
77
|
+
const { filter, lazy = false, flushIntervalMs = 100, shouldFetch = true, realtime = true, clearCacheOnMount = false, } = options;
|
|
78
|
+
const hasTriggeredRef = useRef(false);
|
|
79
|
+
const unsub = useRef(null);
|
|
80
|
+
const { dataMap, data, groupedBy, } = useDataState(table);
|
|
81
|
+
const queueHandler = useEventQueues(table, options, flushIntervalMs);
|
|
82
|
+
const { triggerRefresh, trigger, cancel, initialFetchAndSync, isFetching } = fetchCalls(table, options, hasTriggeredRef);
|
|
83
|
+
const subKey = useMemo(() => `${table}:${ReusedHelpers.buildFilterString(filter)}`, [table, filter]);
|
|
84
|
+
const isAnyNullish = useMemo(() => {
|
|
85
|
+
if (!options.sqlFilter?.length)
|
|
86
|
+
return false;
|
|
87
|
+
const check = (filter) => {
|
|
88
|
+
if (!filter || typeof filter !== "object")
|
|
89
|
+
return false;
|
|
90
|
+
if ("or" in filter) {
|
|
91
|
+
return filter.or?.some(check) ?? false;
|
|
92
|
+
}
|
|
93
|
+
return isTrulyNullish(filter.value) && filter.operator !== "is";
|
|
94
|
+
};
|
|
95
|
+
return options.sqlFilter.some(check);
|
|
96
|
+
}, [options.sqlFilter]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
let unsubscribeVisibility;
|
|
99
|
+
const handler = () => {
|
|
100
|
+
if (!isAnyNullish) {
|
|
101
|
+
void initialFetchAndSync();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
if (!shouldFetch || (lazy && !hasTriggeredRef.current))
|
|
105
|
+
return;
|
|
106
|
+
if (!tableSubscriptions.get(subKey)) {
|
|
107
|
+
tableSubscriptions.set(subKey, true);
|
|
108
|
+
if (!isAnyNullish) {
|
|
109
|
+
initialFetchAndSync();
|
|
110
|
+
}
|
|
111
|
+
unsubscribeVisibility = subscribeToAppVisibility(handler);
|
|
112
|
+
supastashEventBus.on(`refresh:${table}`, triggerRefresh);
|
|
113
|
+
supastashEventBus.on(`refresh:all`, triggerRefresh);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
initialFetchAndSync();
|
|
117
|
+
}
|
|
118
|
+
return () => {
|
|
119
|
+
supastashEventBus.off?.(`refresh:${table}`, triggerRefresh);
|
|
120
|
+
supastashEventBus.off?.(`refresh:all`, triggerRefresh);
|
|
121
|
+
unsub.current?.();
|
|
122
|
+
tableSubscriptions.delete(subKey);
|
|
123
|
+
if (clearCacheOnMount) {
|
|
124
|
+
localCache.delete(table);
|
|
125
|
+
}
|
|
126
|
+
unsubscribeVisibility?.();
|
|
127
|
+
};
|
|
128
|
+
}, [lazy, shouldFetch, subKey, isAnyNullish]);
|
|
129
|
+
// TEMP
|
|
130
|
+
useRealtimeData(table, queueHandler, options, hasTriggeredRef.current, realtime);
|
|
131
|
+
return useMemo(() => ({
|
|
132
|
+
data,
|
|
133
|
+
dataMap,
|
|
134
|
+
trigger,
|
|
135
|
+
cancel,
|
|
136
|
+
groupedBy,
|
|
137
|
+
isFetching,
|
|
138
|
+
}), [data, isFetching]);
|
|
139
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supastashLogic.d.ts","sourceRoot":"","sources":["../../../src/desktop/hooks/supastashLogic.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAO/E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,OAAe,GAAG,mBAAmB,CAkFvE"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { getSupastashConfig } from "
|
|
3
|
-
import { supastashDbErrorMsg } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { getSupastashConfig } from "../../shared/core/config";
|
|
3
|
+
import { supastashDbErrorMsg } from "../../shared/db/dbErrorMsg";
|
|
4
|
+
import { localCache } from "../../shared/store/localCache";
|
|
5
|
+
import { filterTracker, tableFilters, tableFiltersUsed, } from "../../shared/store/tableFilters";
|
|
6
|
+
import { supastashEventBus } from "../../shared/utils/events/eventBus";
|
|
7
|
+
import { logError, logWarn } from "../../shared/utils/logs";
|
|
8
|
+
import { createSyncStatusTable } from "../../shared/utils/schema/createSyncStatus";
|
|
9
|
+
import { supabaseClientErr } from "../../shared/utils/supabaseClientErr";
|
|
10
|
+
import { useSyncEngine } from "./syncEngine";
|
|
11
11
|
/**
|
|
12
12
|
* React hook to initialize and manage Supastash.
|
|
13
13
|
*
|
|
@@ -58,13 +58,12 @@ export function useSupastash(lazy = false) {
|
|
|
58
58
|
if (config.onSchemaInit) {
|
|
59
59
|
await config.onSchemaInit();
|
|
60
60
|
}
|
|
61
|
+
// If init fails, db will not be ready
|
|
62
|
+
setDbReady(true);
|
|
61
63
|
}
|
|
62
64
|
catch (error) {
|
|
63
65
|
logError(`[Supastash] Error initializing: ${error}`);
|
|
64
66
|
}
|
|
65
|
-
finally {
|
|
66
|
-
setDbReady(true);
|
|
67
|
-
}
|
|
68
67
|
}
|
|
69
68
|
init();
|
|
70
69
|
return () => {
|
|
@@ -25,4 +25,4 @@ export declare function syncTable(table: string): Promise<void>;
|
|
|
25
25
|
* Force a global sync pass now (push then pull if due).
|
|
26
26
|
*/
|
|
27
27
|
export declare function syncAllTables(): Promise<void>;
|
|
28
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=syncEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncEngine.d.ts","sourceRoot":"","sources":["../../../src/desktop/hooks/syncEngine.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqCnE;AAuDD;;;;;GAKG;AACH,wBAAgB,aAAa;;;EA2D5B;AAMD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC5D;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnD"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { getSupastashConfig } from "../../shared/core/config";
|
|
3
|
+
import { syncCalls } from "../../shared/store/syncCalls";
|
|
4
|
+
import { isSyncGateClosed } from "../../shared/store/syncStatus";
|
|
5
|
+
import { tableFilters } from "../../shared/store/tableFilters";
|
|
6
|
+
import { isOnline } from "../../shared/utils/connection";
|
|
7
|
+
import log from "../../shared/utils/logs";
|
|
8
|
+
import { subscribeToAppVisibility } from "../adapters/appstate";
|
|
9
|
+
import { pullFromRemote as doPullFromRemote } from "../utils/sync/pullFromRemote";
|
|
10
|
+
import { updateLocalDb } from "../utils/sync/pullFromRemote/updateLocalDb";
|
|
11
|
+
import { pushLocalData as doPushLocalData } from "../utils/sync/pushLocal";
|
|
12
|
+
import { pushLocalDataToRemote } from "../utils/sync/pushLocal/sendUnsyncedToSupabase";
|
|
13
|
+
// -----------------------------
|
|
14
|
+
// Module-scoped state & tunables
|
|
15
|
+
// -----------------------------
|
|
16
|
+
let isSyncing = false;
|
|
17
|
+
let isPushing = false;
|
|
18
|
+
let isPulling = false;
|
|
19
|
+
let lastPullAt = 0;
|
|
20
|
+
let lastPushAt = 0;
|
|
21
|
+
const MIN_FOREGROUND_GAP = 5000; // ms
|
|
22
|
+
// -----------------------------
|
|
23
|
+
// Core orchestration
|
|
24
|
+
// -----------------------------
|
|
25
|
+
/**
|
|
26
|
+
* Push then (optionally) pull.
|
|
27
|
+
* - Single flight across entire app via module-scoped flags.
|
|
28
|
+
* - Both directions gated on connectivity.
|
|
29
|
+
* - "force" ignores pull cadence timing.
|
|
30
|
+
*/
|
|
31
|
+
export async function syncAll(force = false) {
|
|
32
|
+
const isGateClosed = isSyncGateClosed();
|
|
33
|
+
if (isGateClosed)
|
|
34
|
+
return;
|
|
35
|
+
if (isSyncing)
|
|
36
|
+
return;
|
|
37
|
+
if (!(await isOnline()))
|
|
38
|
+
return;
|
|
39
|
+
// If in ghost mode, don't sync
|
|
40
|
+
const cfg = getSupastashConfig();
|
|
41
|
+
if (cfg.supastashMode === "ghost")
|
|
42
|
+
return;
|
|
43
|
+
isSyncing = true;
|
|
44
|
+
const started = Date.now();
|
|
45
|
+
try {
|
|
46
|
+
// PUSH
|
|
47
|
+
if (cfg.syncEngine?.push) {
|
|
48
|
+
await pushLocalDataSafe();
|
|
49
|
+
}
|
|
50
|
+
// PULL
|
|
51
|
+
if (cfg.syncEngine?.pull) {
|
|
52
|
+
const pullInterval = cfg.pollingInterval?.pull ?? 30000;
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
const due = force || now - lastPullAt >= pullInterval;
|
|
55
|
+
if (due) {
|
|
56
|
+
await pullFromRemoteSafe();
|
|
57
|
+
lastPullAt = now;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
log("[Supastash] Error in syncAll", {
|
|
63
|
+
msg: String(e),
|
|
64
|
+
code: e?.code ?? e?.name ?? "UNKNOWN",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
isSyncing = false;
|
|
69
|
+
log(`[Supastash] syncAll finished in ${Date.now() - started}ms`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// -----------------------------
|
|
73
|
+
// Directional helpers
|
|
74
|
+
// -----------------------------
|
|
75
|
+
async function pushLocalDataSafe() {
|
|
76
|
+
if (isPushing)
|
|
77
|
+
return;
|
|
78
|
+
if (!(await isOnline()))
|
|
79
|
+
return;
|
|
80
|
+
const cfg = getSupastashConfig();
|
|
81
|
+
if (!cfg.syncEngine?.push)
|
|
82
|
+
return;
|
|
83
|
+
// If in ghost mode, don't push
|
|
84
|
+
if (cfg.supastashMode === "ghost")
|
|
85
|
+
return;
|
|
86
|
+
isPushing = true;
|
|
87
|
+
try {
|
|
88
|
+
await doPushLocalData();
|
|
89
|
+
lastPushAt = Date.now();
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
log("[Supastash] push error", {
|
|
93
|
+
msg: String(e),
|
|
94
|
+
code: e?.code ?? e?.name ?? "UNKNOWN",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
isPushing = false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function pullFromRemoteSafe() {
|
|
102
|
+
if (isPulling)
|
|
103
|
+
return;
|
|
104
|
+
if (!(await isOnline()))
|
|
105
|
+
return;
|
|
106
|
+
// If in ghost mode, don't pull
|
|
107
|
+
const cfg = getSupastashConfig();
|
|
108
|
+
if (cfg.supastashMode === "ghost")
|
|
109
|
+
return;
|
|
110
|
+
if (!cfg.syncEngine?.pull)
|
|
111
|
+
return;
|
|
112
|
+
isPulling = true;
|
|
113
|
+
try {
|
|
114
|
+
await doPullFromRemote();
|
|
115
|
+
lastPullAt = Date.now();
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
log("[Supastash] pull error", {
|
|
119
|
+
msg: String(e),
|
|
120
|
+
code: e?.code ?? e?.name ?? "UNKNOWN",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
isPulling = false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// -----------------------------
|
|
128
|
+
// React hook: timer & lifecycle management
|
|
129
|
+
// -----------------------------
|
|
130
|
+
/**
|
|
131
|
+
* Hook to start/stop the periodic sync engine.
|
|
132
|
+
* - Staggers push & pull timers.
|
|
133
|
+
* - Debounced foreground trigger.
|
|
134
|
+
* - Shares module-level single-flight guards with syncAll().
|
|
135
|
+
*/
|
|
136
|
+
export function useSyncEngine() {
|
|
137
|
+
// Timers & lifecycle
|
|
138
|
+
const intervalRefPush = useRef(null);
|
|
139
|
+
const intervalRefPull = useRef(null);
|
|
140
|
+
const unsubscribeVisibility = useRef(undefined);
|
|
141
|
+
// Debounce foreground re-entry
|
|
142
|
+
const lastForeground = useRef(0);
|
|
143
|
+
function startSync() {
|
|
144
|
+
if (intervalRefPush.current || intervalRefPull.current) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Kick a one-shot global sync on start
|
|
148
|
+
void syncAll(true);
|
|
149
|
+
const cfg = getSupastashConfig();
|
|
150
|
+
const pushEvery = cfg.pollingInterval?.push ?? 30000;
|
|
151
|
+
const pullEvery = cfg.pollingInterval?.pull ?? 30000;
|
|
152
|
+
// Push ticker
|
|
153
|
+
intervalRefPush.current = setInterval(() => {
|
|
154
|
+
void pushLocalDataSafe();
|
|
155
|
+
}, pushEvery);
|
|
156
|
+
// Pull ticker
|
|
157
|
+
intervalRefPull.current = setInterval(() => {
|
|
158
|
+
void pullFromRemoteSafe();
|
|
159
|
+
}, pullEvery + 500);
|
|
160
|
+
// Foreground trigger
|
|
161
|
+
unsubscribeVisibility.current = subscribeToAppVisibility(() => {
|
|
162
|
+
if (document.visibilityState === "visible") {
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
if (now - lastForeground.current < MIN_FOREGROUND_GAP)
|
|
165
|
+
return;
|
|
166
|
+
lastForeground.current = now;
|
|
167
|
+
void syncAll(true);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function stopSync() {
|
|
172
|
+
if (intervalRefPush.current) {
|
|
173
|
+
clearInterval(intervalRefPush.current);
|
|
174
|
+
intervalRefPush.current = null;
|
|
175
|
+
}
|
|
176
|
+
if (intervalRefPull.current) {
|
|
177
|
+
clearInterval(intervalRefPull.current);
|
|
178
|
+
intervalRefPull.current = null;
|
|
179
|
+
}
|
|
180
|
+
unsubscribeVisibility.current?.();
|
|
181
|
+
unsubscribeVisibility.current = undefined;
|
|
182
|
+
}
|
|
183
|
+
// Auto-cleanup if the hook lives in a component lifecycle
|
|
184
|
+
useEffect(() => stopSync, []);
|
|
185
|
+
return { startSync, stopSync };
|
|
186
|
+
}
|
|
187
|
+
// -----------------------------
|
|
188
|
+
// Manual triggers
|
|
189
|
+
// -----------------------------
|
|
190
|
+
/**
|
|
191
|
+
* Manually sync a single table (pull then push for that table).
|
|
192
|
+
* - Uses table-specific handlers from syncCalls if provided.
|
|
193
|
+
* - Respects configured filters when enabled.
|
|
194
|
+
*/
|
|
195
|
+
export async function syncTable(table) {
|
|
196
|
+
if (!(await isOnline()))
|
|
197
|
+
return;
|
|
198
|
+
const cfg = getSupastashConfig();
|
|
199
|
+
const { useFiltersFromStore = true } = cfg?.syncEngine || {};
|
|
200
|
+
const filter = useFiltersFromStore ? tableFilters.get(table) : undefined;
|
|
201
|
+
// Pull
|
|
202
|
+
if (cfg.syncEngine?.pull) {
|
|
203
|
+
try {
|
|
204
|
+
await updateLocalDb(table, filter, syncCalls.get(table)?.pull);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
log("[Supastash] syncTable pull error", {
|
|
208
|
+
table,
|
|
209
|
+
msg: String(e),
|
|
210
|
+
code: e?.code ?? e?.name ?? "UNKNOWN",
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Push (use table handler if present)
|
|
215
|
+
if (cfg.syncEngine?.push) {
|
|
216
|
+
try {
|
|
217
|
+
await pushLocalDataToRemote(table, syncCalls.get(table)?.push);
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
log("[Supastash] syncTable push error", {
|
|
221
|
+
table,
|
|
222
|
+
msg: String(e),
|
|
223
|
+
code: e?.code ?? e?.name ?? "UNKNOWN",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Force a global sync pass now (push then pull if due).
|
|
230
|
+
*/
|
|
231
|
+
export async function syncAllTables() {
|
|
232
|
+
await syncAll(true);
|
|
233
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { configureSupastash, getSupastashConfig } from "../shared/core/config";
|
|
2
|
+
export { getSupastashDb } from "../shared/db/dbInitializer";
|
|
3
|
+
export { useSupastashFilters } from "../shared/hooks/supastashFilters";
|
|
4
|
+
export { useSupastashSyncStatus } from "../shared/hooks/syncStatus";
|
|
5
|
+
export { closeSyncGate, isSyncGateClosed, openSyncGate, } from "../shared/store/syncStatus";
|
|
6
|
+
export { supastashEventBus } from "../shared/utils/events/eventBus";
|
|
7
|
+
export { supastash } from "../shared/utils/query/builder";
|
|
8
|
+
export { refreshScreen } from "../shared/utils/refreshScreenCalls";
|
|
9
|
+
export { getSupastashRuntimeMode, reinitializeSupastash, } from "../shared/utils/supastashMode";
|
|
10
|
+
export { getAllTables } from "../shared/utils/sync/getAllTables";
|
|
11
|
+
export { updateFilters } from "../shared/utils/sync/pullFromRemote/updateFilter";
|
|
12
|
+
export { refreshAllTables, refreshTable, refreshTableWithPayload, } from "../shared/utils/sync/refreshTables";
|
|
13
|
+
export { clearSyncCalls, getAllSyncTables, getSyncCall, registerSyncCall, unregisterSyncCall, } from "../shared/utils/sync/registration/syncCalls";
|
|
14
|
+
export { defineLocalSchema } from "./core/schemaManager";
|
|
15
|
+
export { useSupastashData } from "./hooks/supastashData";
|
|
16
|
+
export { useSupastash } from "./hooks/supastashLogic";
|
|
17
|
+
export { syncAllTables, syncTable } from "./hooks/syncEngine";
|
|
18
|
+
export { dropAllTables, dropTable, wipeAllTables, wipeOldDataForAllTables, wipeOldDataForATable, wipeTable, } from "./utils/schema/wipeTables";
|
|
19
|
+
export { fetchOlderPage } from "./utils/sync/pullFromRemote/fetchOlder";
|
|
20
|
+
export { updateLocalDb, upsertChunkData, upsertData, } from "./utils/sync/pullFromRemote/updateLocalDb";
|
|
21
|
+
export { clearAllLocalDeleteLog, clearAllLocalSyncLog, clearLocalDeleteLog, clearLocalSyncLog, clearSyncLog, getLocalDeleteLog, getSyncLog, resetSyncLog, setLocalDeleteLog, setLocalSyncLog, setSyncLog, } from "./utils/sync/status/syncStatus";
|
|
22
|
+
export type { CrudMethods } from "../shared/types/query.types";
|
|
23
|
+
export type { RealtimeOptions, SupastashDataResult, SupastashFilter, } from "../shared/types/realtimeData.types";
|
|
24
|
+
export type { ExpoSQLiteClient, RNSqliteNitroClient, RNStorageSQLiteClient, SupastashConfig, SupastashHookReturn, SupastashSQLiteClientTypes, SupastashSQLiteDatabase, SupastashSQLiteExecutor, TauriSQLiteClient, } from "../shared/types/supastashConfig.types";
|
|
25
|
+
export type { LocalSchemaDefinition } from "../shared/types/schemaManager.types";
|
|
26
|
+
export type { SyncInfo } from "../shared/types/syncEngine.types";
|
|
27
|
+
export type { SupastashClient, SupastashTransactionClient, } from "../shared/utils/query/builder";
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/desktop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AACjF,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,SAAS,EACT,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,GACX,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,gCAAgC,CAAC;AAExC,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAE/C,YAAY,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,YAAY,EACV,eAAe,EACf,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { configureSupastash, getSupastashConfig } from "../shared/core/config";
|
|
2
|
+
export { getSupastashDb } from "../shared/db/dbInitializer";
|
|
3
|
+
export { useSupastashFilters } from "../shared/hooks/supastashFilters";
|
|
4
|
+
export { useSupastashSyncStatus } from "../shared/hooks/syncStatus";
|
|
5
|
+
export { closeSyncGate, isSyncGateClosed, openSyncGate, } from "../shared/store/syncStatus";
|
|
6
|
+
export { supastashEventBus } from "../shared/utils/events/eventBus";
|
|
7
|
+
export { supastash } from "../shared/utils/query/builder";
|
|
8
|
+
export { refreshScreen } from "../shared/utils/refreshScreenCalls";
|
|
9
|
+
export { getSupastashRuntimeMode, reinitializeSupastash, } from "../shared/utils/supastashMode";
|
|
10
|
+
export { getAllTables } from "../shared/utils/sync/getAllTables";
|
|
11
|
+
export { updateFilters } from "../shared/utils/sync/pullFromRemote/updateFilter";
|
|
12
|
+
export { refreshAllTables, refreshTable, refreshTableWithPayload, } from "../shared/utils/sync/refreshTables";
|
|
13
|
+
export { clearSyncCalls, getAllSyncTables, getSyncCall, registerSyncCall, unregisterSyncCall, } from "../shared/utils/sync/registration/syncCalls";
|
|
14
|
+
export { defineLocalSchema } from "./core/schemaManager";
|
|
15
|
+
export { useSupastashData } from "./hooks/supastashData";
|
|
16
|
+
export { useSupastash } from "./hooks/supastashLogic";
|
|
17
|
+
export { syncAllTables, syncTable } from "./hooks/syncEngine";
|
|
18
|
+
export { dropAllTables, dropTable, wipeAllTables, wipeOldDataForAllTables, wipeOldDataForATable, wipeTable, } from "./utils/schema/wipeTables";
|
|
19
|
+
export { fetchOlderPage } from "./utils/sync/pullFromRemote/fetchOlder";
|
|
20
|
+
export { updateLocalDb, upsertChunkData, upsertData, } from "./utils/sync/pullFromRemote/updateLocalDb";
|
|
21
|
+
export { clearAllLocalDeleteLog, clearAllLocalSyncLog, clearLocalDeleteLog, clearLocalSyncLog, clearSyncLog, getLocalDeleteLog, getSyncLog, resetSyncLog, setLocalDeleteLog, setLocalSyncLog, setSyncLog, } from "./utils/sync/status/syncStatus";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PayloadData } from "
|
|
2
|
-
import { RealtimeOptions } from "
|
|
1
|
+
import { PayloadData } from "../../../shared/types/query.types";
|
|
2
|
+
import { RealtimeOptions } from "../../../shared/types/realtimeData.types";
|
|
3
3
|
declare function useEventQueues<R>(table: string, options: RealtimeOptions<R>, flushIntervalMs: number): (eventType: string, data: PayloadData) => void;
|
|
4
4
|
export default useEventQueues;
|
|
5
5
|
//# sourceMappingURL=eventQueues.d.ts.map
|