tevrocsdk 0.1.30 → 0.1.31
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 +132 -68
- package/package.json +4 -2
- package/tevroc-sdk.esm.js +2155 -143
- package/tevroc-sdk.min.js +1 -1
- package/tevroc-sdk.umd.js +2157 -143
package/tevroc-sdk.esm.js
CHANGED
|
@@ -225,8 +225,8 @@ var init_dist = __esm({
|
|
|
225
225
|
}
|
|
226
226
|
addListener(eventName, listenerFunc) {
|
|
227
227
|
let firstListener = false;
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
228
|
+
const listeners2 = this.listeners[eventName];
|
|
229
|
+
if (!listeners2) {
|
|
230
230
|
this.listeners[eventName] = [];
|
|
231
231
|
firstListener = true;
|
|
232
232
|
}
|
|
@@ -250,8 +250,8 @@ var init_dist = __esm({
|
|
|
250
250
|
this.windowListeners = {};
|
|
251
251
|
}
|
|
252
252
|
notifyListeners(eventName, data, retainUntilConsumed) {
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
253
|
+
const listeners2 = this.listeners[eventName];
|
|
254
|
+
if (!listeners2) {
|
|
255
255
|
if (retainUntilConsumed) {
|
|
256
256
|
let args = this.retainedEventArguments[eventName];
|
|
257
257
|
if (!args) {
|
|
@@ -262,7 +262,7 @@ var init_dist = __esm({
|
|
|
262
262
|
}
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
listeners2.forEach((listener) => listener(data));
|
|
266
266
|
}
|
|
267
267
|
hasListeners(eventName) {
|
|
268
268
|
var _a;
|
|
@@ -285,11 +285,11 @@ var init_dist = __esm({
|
|
|
285
285
|
return new Capacitor.Exception(msg, ExceptionCode.Unavailable);
|
|
286
286
|
}
|
|
287
287
|
async removeListener(eventName, listenerFunc) {
|
|
288
|
-
const
|
|
289
|
-
if (!
|
|
288
|
+
const listeners2 = this.listeners[eventName];
|
|
289
|
+
if (!listeners2) {
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
|
-
const index =
|
|
292
|
+
const index = listeners2.indexOf(listenerFunc);
|
|
293
293
|
this.listeners[eventName].splice(index, 1);
|
|
294
294
|
if (!this.listeners[eventName].length) {
|
|
295
295
|
this.removeWindowListener(this.windowListeners[eventName]);
|
|
@@ -555,19 +555,1592 @@ var init_dist = __esm({
|
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
557
|
|
|
558
|
+
// node_modules/@capacitor-community/sqlite/dist/esm/definitions.js
|
|
559
|
+
var SQLiteConnection, SQLiteDBConnection;
|
|
560
|
+
var init_definitions = __esm({
|
|
561
|
+
"node_modules/@capacitor-community/sqlite/dist/esm/definitions.js"() {
|
|
562
|
+
SQLiteConnection = class {
|
|
563
|
+
constructor(sqlite) {
|
|
564
|
+
this.sqlite = sqlite;
|
|
565
|
+
this._connectionDict = /* @__PURE__ */ new Map();
|
|
566
|
+
}
|
|
567
|
+
async initWebStore() {
|
|
568
|
+
try {
|
|
569
|
+
await this.sqlite.initWebStore();
|
|
570
|
+
return Promise.resolve();
|
|
571
|
+
} catch (err) {
|
|
572
|
+
return Promise.reject(err);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
async saveToStore(database) {
|
|
576
|
+
try {
|
|
577
|
+
await this.sqlite.saveToStore({ database });
|
|
578
|
+
return Promise.resolve();
|
|
579
|
+
} catch (err) {
|
|
580
|
+
return Promise.reject(err);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async saveToLocalDisk(database) {
|
|
584
|
+
try {
|
|
585
|
+
await this.sqlite.saveToLocalDisk({ database });
|
|
586
|
+
return Promise.resolve();
|
|
587
|
+
} catch (err) {
|
|
588
|
+
return Promise.reject(err);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
async getFromLocalDiskToStore(overwrite) {
|
|
592
|
+
const mOverwrite = overwrite != null ? overwrite : true;
|
|
593
|
+
try {
|
|
594
|
+
await this.sqlite.getFromLocalDiskToStore({ overwrite: mOverwrite });
|
|
595
|
+
return Promise.resolve();
|
|
596
|
+
} catch (err) {
|
|
597
|
+
return Promise.reject(err);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async echo(value) {
|
|
601
|
+
try {
|
|
602
|
+
const res = await this.sqlite.echo({ value });
|
|
603
|
+
return Promise.resolve(res);
|
|
604
|
+
} catch (err) {
|
|
605
|
+
return Promise.reject(err);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
async isSecretStored() {
|
|
609
|
+
try {
|
|
610
|
+
const res = await this.sqlite.isSecretStored();
|
|
611
|
+
return Promise.resolve(res);
|
|
612
|
+
} catch (err) {
|
|
613
|
+
return Promise.reject(err);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async setEncryptionSecret(passphrase) {
|
|
617
|
+
try {
|
|
618
|
+
await this.sqlite.setEncryptionSecret({ passphrase });
|
|
619
|
+
return Promise.resolve();
|
|
620
|
+
} catch (err) {
|
|
621
|
+
return Promise.reject(err);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
async changeEncryptionSecret(passphrase, oldpassphrase) {
|
|
625
|
+
try {
|
|
626
|
+
await this.sqlite.changeEncryptionSecret({
|
|
627
|
+
passphrase,
|
|
628
|
+
oldpassphrase
|
|
629
|
+
});
|
|
630
|
+
return Promise.resolve();
|
|
631
|
+
} catch (err) {
|
|
632
|
+
return Promise.reject(err);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async clearEncryptionSecret() {
|
|
636
|
+
try {
|
|
637
|
+
await this.sqlite.clearEncryptionSecret();
|
|
638
|
+
return Promise.resolve();
|
|
639
|
+
} catch (err) {
|
|
640
|
+
return Promise.reject(err);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
async checkEncryptionSecret(passphrase) {
|
|
644
|
+
try {
|
|
645
|
+
const res = await this.sqlite.checkEncryptionSecret({
|
|
646
|
+
passphrase
|
|
647
|
+
});
|
|
648
|
+
return Promise.resolve(res);
|
|
649
|
+
} catch (err) {
|
|
650
|
+
return Promise.reject(err);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
async addUpgradeStatement(database, upgrade) {
|
|
654
|
+
try {
|
|
655
|
+
if (database.endsWith(".db"))
|
|
656
|
+
database = database.slice(0, -3);
|
|
657
|
+
await this.sqlite.addUpgradeStatement({
|
|
658
|
+
database,
|
|
659
|
+
upgrade
|
|
660
|
+
});
|
|
661
|
+
return Promise.resolve();
|
|
662
|
+
} catch (err) {
|
|
663
|
+
return Promise.reject(err);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
async createConnection(database, encrypted, mode, version, readonly) {
|
|
667
|
+
try {
|
|
668
|
+
if (database.endsWith(".db"))
|
|
669
|
+
database = database.slice(0, -3);
|
|
670
|
+
await this.sqlite.createConnection({
|
|
671
|
+
database,
|
|
672
|
+
encrypted,
|
|
673
|
+
mode,
|
|
674
|
+
version,
|
|
675
|
+
readonly
|
|
676
|
+
});
|
|
677
|
+
const conn = new SQLiteDBConnection(database, readonly, this.sqlite);
|
|
678
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
679
|
+
this._connectionDict.set(connName, conn);
|
|
680
|
+
return Promise.resolve(conn);
|
|
681
|
+
} catch (err) {
|
|
682
|
+
return Promise.reject(err);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async closeConnection(database, readonly) {
|
|
686
|
+
try {
|
|
687
|
+
if (database.endsWith(".db"))
|
|
688
|
+
database = database.slice(0, -3);
|
|
689
|
+
await this.sqlite.closeConnection({ database, readonly });
|
|
690
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
691
|
+
this._connectionDict.delete(connName);
|
|
692
|
+
return Promise.resolve();
|
|
693
|
+
} catch (err) {
|
|
694
|
+
return Promise.reject(err);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async isConnection(database, readonly) {
|
|
698
|
+
const res = {};
|
|
699
|
+
if (database.endsWith(".db"))
|
|
700
|
+
database = database.slice(0, -3);
|
|
701
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
702
|
+
res.result = this._connectionDict.has(connName);
|
|
703
|
+
return Promise.resolve(res);
|
|
704
|
+
}
|
|
705
|
+
async retrieveConnection(database, readonly) {
|
|
706
|
+
if (database.endsWith(".db"))
|
|
707
|
+
database = database.slice(0, -3);
|
|
708
|
+
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
709
|
+
if (this._connectionDict.has(connName)) {
|
|
710
|
+
const conn = this._connectionDict.get(connName);
|
|
711
|
+
if (typeof conn != "undefined")
|
|
712
|
+
return Promise.resolve(conn);
|
|
713
|
+
else {
|
|
714
|
+
return Promise.reject(`Connection ${database} is undefined`);
|
|
715
|
+
}
|
|
716
|
+
} else {
|
|
717
|
+
return Promise.reject(`Connection ${database} does not exist`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
async getNCDatabasePath(path, database) {
|
|
721
|
+
try {
|
|
722
|
+
const databasePath = await this.sqlite.getNCDatabasePath({
|
|
723
|
+
path,
|
|
724
|
+
database
|
|
725
|
+
});
|
|
726
|
+
return Promise.resolve(databasePath);
|
|
727
|
+
} catch (err) {
|
|
728
|
+
return Promise.reject(err);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
async createNCConnection(databasePath, version) {
|
|
732
|
+
try {
|
|
733
|
+
await this.sqlite.createNCConnection({
|
|
734
|
+
databasePath,
|
|
735
|
+
version
|
|
736
|
+
});
|
|
737
|
+
const conn = new SQLiteDBConnection(databasePath, true, this.sqlite);
|
|
738
|
+
const connName = `RO_${databasePath})`;
|
|
739
|
+
this._connectionDict.set(connName, conn);
|
|
740
|
+
return Promise.resolve(conn);
|
|
741
|
+
} catch (err) {
|
|
742
|
+
return Promise.reject(err);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
async closeNCConnection(databasePath) {
|
|
746
|
+
try {
|
|
747
|
+
await this.sqlite.closeNCConnection({ databasePath });
|
|
748
|
+
const connName = `RO_${databasePath})`;
|
|
749
|
+
this._connectionDict.delete(connName);
|
|
750
|
+
return Promise.resolve();
|
|
751
|
+
} catch (err) {
|
|
752
|
+
return Promise.reject(err);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
async isNCConnection(databasePath) {
|
|
756
|
+
const res = {};
|
|
757
|
+
const connName = `RO_${databasePath})`;
|
|
758
|
+
res.result = this._connectionDict.has(connName);
|
|
759
|
+
return Promise.resolve(res);
|
|
760
|
+
}
|
|
761
|
+
async retrieveNCConnection(databasePath) {
|
|
762
|
+
if (this._connectionDict.has(databasePath)) {
|
|
763
|
+
const connName = `RO_${databasePath})`;
|
|
764
|
+
const conn = this._connectionDict.get(connName);
|
|
765
|
+
if (typeof conn != "undefined")
|
|
766
|
+
return Promise.resolve(conn);
|
|
767
|
+
else {
|
|
768
|
+
return Promise.reject(`Connection ${databasePath} is undefined`);
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
return Promise.reject(`Connection ${databasePath} does not exist`);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
async isNCDatabase(databasePath) {
|
|
775
|
+
try {
|
|
776
|
+
const res = await this.sqlite.isNCDatabase({ databasePath });
|
|
777
|
+
return Promise.resolve(res);
|
|
778
|
+
} catch (err) {
|
|
779
|
+
return Promise.reject(err);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
async retrieveAllConnections() {
|
|
783
|
+
return this._connectionDict;
|
|
784
|
+
}
|
|
785
|
+
async closeAllConnections() {
|
|
786
|
+
const delDict = /* @__PURE__ */ new Map();
|
|
787
|
+
try {
|
|
788
|
+
for (const key of this._connectionDict.keys()) {
|
|
789
|
+
const database = key.substring(3);
|
|
790
|
+
const readonly = key.substring(0, 3) === "RO_" ? true : false;
|
|
791
|
+
await this.sqlite.closeConnection({ database, readonly });
|
|
792
|
+
delDict.set(key, null);
|
|
793
|
+
}
|
|
794
|
+
for (const key of delDict.keys()) {
|
|
795
|
+
this._connectionDict.delete(key);
|
|
796
|
+
}
|
|
797
|
+
return Promise.resolve();
|
|
798
|
+
} catch (err) {
|
|
799
|
+
return Promise.reject(err);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
async checkConnectionsConsistency() {
|
|
803
|
+
try {
|
|
804
|
+
const keys = [...this._connectionDict.keys()];
|
|
805
|
+
const openModes = [];
|
|
806
|
+
const dbNames = [];
|
|
807
|
+
for (const key of keys) {
|
|
808
|
+
openModes.push(key.substring(0, 2));
|
|
809
|
+
dbNames.push(key.substring(3));
|
|
810
|
+
}
|
|
811
|
+
const res = await this.sqlite.checkConnectionsConsistency({
|
|
812
|
+
dbNames,
|
|
813
|
+
openModes
|
|
814
|
+
});
|
|
815
|
+
if (!res.result)
|
|
816
|
+
this._connectionDict = /* @__PURE__ */ new Map();
|
|
817
|
+
return Promise.resolve(res);
|
|
818
|
+
} catch (err) {
|
|
819
|
+
this._connectionDict = /* @__PURE__ */ new Map();
|
|
820
|
+
return Promise.reject(err);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
async importFromJson(jsonstring) {
|
|
824
|
+
try {
|
|
825
|
+
const ret = await this.sqlite.importFromJson({ jsonstring });
|
|
826
|
+
return Promise.resolve(ret);
|
|
827
|
+
} catch (err) {
|
|
828
|
+
return Promise.reject(err);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async isJsonValid(jsonstring) {
|
|
832
|
+
try {
|
|
833
|
+
const ret = await this.sqlite.isJsonValid({ jsonstring });
|
|
834
|
+
return Promise.resolve(ret);
|
|
835
|
+
} catch (err) {
|
|
836
|
+
return Promise.reject(err);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
async copyFromAssets(overwrite) {
|
|
840
|
+
const mOverwrite = overwrite != null ? overwrite : true;
|
|
841
|
+
try {
|
|
842
|
+
await this.sqlite.copyFromAssets({ overwrite: mOverwrite });
|
|
843
|
+
return Promise.resolve();
|
|
844
|
+
} catch (err) {
|
|
845
|
+
return Promise.reject(err);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
async getFromHTTPRequest(url, overwrite) {
|
|
849
|
+
const mOverwrite = overwrite != null ? overwrite : true;
|
|
850
|
+
try {
|
|
851
|
+
await this.sqlite.getFromHTTPRequest({ url, overwrite: mOverwrite });
|
|
852
|
+
return Promise.resolve();
|
|
853
|
+
} catch (err) {
|
|
854
|
+
return Promise.reject(err);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async isDatabaseEncrypted(database) {
|
|
858
|
+
if (database.endsWith(".db"))
|
|
859
|
+
database = database.slice(0, -3);
|
|
860
|
+
try {
|
|
861
|
+
const res = await this.sqlite.isDatabaseEncrypted({ database });
|
|
862
|
+
return Promise.resolve(res);
|
|
863
|
+
} catch (err) {
|
|
864
|
+
return Promise.reject(err);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
async isInConfigEncryption() {
|
|
868
|
+
try {
|
|
869
|
+
const res = await this.sqlite.isInConfigEncryption();
|
|
870
|
+
return Promise.resolve(res);
|
|
871
|
+
} catch (err) {
|
|
872
|
+
return Promise.reject(err);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
async isInConfigBiometricAuth() {
|
|
876
|
+
try {
|
|
877
|
+
const res = await this.sqlite.isInConfigBiometricAuth();
|
|
878
|
+
return Promise.resolve(res);
|
|
879
|
+
} catch (err) {
|
|
880
|
+
return Promise.reject(err);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
async isDatabase(database) {
|
|
884
|
+
if (database.endsWith(".db"))
|
|
885
|
+
database = database.slice(0, -3);
|
|
886
|
+
try {
|
|
887
|
+
const res = await this.sqlite.isDatabase({ database });
|
|
888
|
+
return Promise.resolve(res);
|
|
889
|
+
} catch (err) {
|
|
890
|
+
return Promise.reject(err);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
async getDatabaseList() {
|
|
894
|
+
try {
|
|
895
|
+
const res = await this.sqlite.getDatabaseList();
|
|
896
|
+
const values = res.values;
|
|
897
|
+
values.sort();
|
|
898
|
+
const ret = { values };
|
|
899
|
+
return Promise.resolve(ret);
|
|
900
|
+
} catch (err) {
|
|
901
|
+
return Promise.reject(err);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
async getMigratableDbList(folderPath) {
|
|
905
|
+
const path = folderPath ? folderPath : "default";
|
|
906
|
+
try {
|
|
907
|
+
const res = await this.sqlite.getMigratableDbList({
|
|
908
|
+
folderPath: path
|
|
909
|
+
});
|
|
910
|
+
return Promise.resolve(res);
|
|
911
|
+
} catch (err) {
|
|
912
|
+
return Promise.reject(err);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
async addSQLiteSuffix(folderPath, dbNameList) {
|
|
916
|
+
const path = folderPath ? folderPath : "default";
|
|
917
|
+
const dbList = dbNameList ? dbNameList : [];
|
|
918
|
+
try {
|
|
919
|
+
const res = await this.sqlite.addSQLiteSuffix({
|
|
920
|
+
folderPath: path,
|
|
921
|
+
dbNameList: dbList
|
|
922
|
+
});
|
|
923
|
+
return Promise.resolve(res);
|
|
924
|
+
} catch (err) {
|
|
925
|
+
return Promise.reject(err);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
async deleteOldDatabases(folderPath, dbNameList) {
|
|
929
|
+
const path = folderPath ? folderPath : "default";
|
|
930
|
+
const dbList = dbNameList ? dbNameList : [];
|
|
931
|
+
try {
|
|
932
|
+
const res = await this.sqlite.deleteOldDatabases({
|
|
933
|
+
folderPath: path,
|
|
934
|
+
dbNameList: dbList
|
|
935
|
+
});
|
|
936
|
+
return Promise.resolve(res);
|
|
937
|
+
} catch (err) {
|
|
938
|
+
return Promise.reject(err);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
async moveDatabasesAndAddSuffix(folderPath, dbNameList) {
|
|
942
|
+
const path = folderPath ? folderPath : "default";
|
|
943
|
+
const dbList = dbNameList ? dbNameList : [];
|
|
944
|
+
return this.sqlite.moveDatabasesAndAddSuffix({
|
|
945
|
+
folderPath: path,
|
|
946
|
+
dbNameList: dbList
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
SQLiteDBConnection = class {
|
|
951
|
+
constructor(dbName2, readonly, sqlite) {
|
|
952
|
+
this.dbName = dbName2;
|
|
953
|
+
this.readonly = readonly;
|
|
954
|
+
this.sqlite = sqlite;
|
|
955
|
+
}
|
|
956
|
+
getConnectionDBName() {
|
|
957
|
+
return this.dbName;
|
|
958
|
+
}
|
|
959
|
+
getConnectionReadOnly() {
|
|
960
|
+
return this.readonly;
|
|
961
|
+
}
|
|
962
|
+
async open() {
|
|
963
|
+
try {
|
|
964
|
+
await this.sqlite.open({
|
|
965
|
+
database: this.dbName,
|
|
966
|
+
readonly: this.readonly
|
|
967
|
+
});
|
|
968
|
+
return Promise.resolve();
|
|
969
|
+
} catch (err) {
|
|
970
|
+
return Promise.reject(err);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
async close() {
|
|
974
|
+
try {
|
|
975
|
+
await this.sqlite.close({
|
|
976
|
+
database: this.dbName,
|
|
977
|
+
readonly: this.readonly
|
|
978
|
+
});
|
|
979
|
+
return Promise.resolve();
|
|
980
|
+
} catch (err) {
|
|
981
|
+
return Promise.reject(err);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
async beginTransaction() {
|
|
985
|
+
try {
|
|
986
|
+
const changes = await this.sqlite.beginTransaction({
|
|
987
|
+
database: this.dbName
|
|
988
|
+
});
|
|
989
|
+
return Promise.resolve(changes);
|
|
990
|
+
} catch (err) {
|
|
991
|
+
return Promise.reject(err);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
async commitTransaction() {
|
|
995
|
+
try {
|
|
996
|
+
const changes = await this.sqlite.commitTransaction({
|
|
997
|
+
database: this.dbName
|
|
998
|
+
});
|
|
999
|
+
return Promise.resolve(changes);
|
|
1000
|
+
} catch (err) {
|
|
1001
|
+
return Promise.reject(err);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
async rollbackTransaction() {
|
|
1005
|
+
try {
|
|
1006
|
+
const changes = await this.sqlite.rollbackTransaction({
|
|
1007
|
+
database: this.dbName
|
|
1008
|
+
});
|
|
1009
|
+
return Promise.resolve(changes);
|
|
1010
|
+
} catch (err) {
|
|
1011
|
+
return Promise.reject(err);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
async isTransactionActive() {
|
|
1015
|
+
try {
|
|
1016
|
+
const result = await this.sqlite.isTransactionActive({
|
|
1017
|
+
database: this.dbName
|
|
1018
|
+
});
|
|
1019
|
+
return Promise.resolve(result);
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
return Promise.reject(err);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
async loadExtension(path) {
|
|
1025
|
+
try {
|
|
1026
|
+
await this.sqlite.loadExtension({
|
|
1027
|
+
database: this.dbName,
|
|
1028
|
+
path,
|
|
1029
|
+
readonly: this.readonly
|
|
1030
|
+
});
|
|
1031
|
+
return Promise.resolve();
|
|
1032
|
+
} catch (err) {
|
|
1033
|
+
return Promise.reject(err);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
async enableLoadExtension(toggle) {
|
|
1037
|
+
try {
|
|
1038
|
+
await this.sqlite.enableLoadExtension({
|
|
1039
|
+
database: this.dbName,
|
|
1040
|
+
toggle,
|
|
1041
|
+
readonly: this.readonly
|
|
1042
|
+
});
|
|
1043
|
+
return Promise.resolve();
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
return Promise.reject(err);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
async getUrl() {
|
|
1049
|
+
try {
|
|
1050
|
+
const res = await this.sqlite.getUrl({
|
|
1051
|
+
database: this.dbName,
|
|
1052
|
+
readonly: this.readonly
|
|
1053
|
+
});
|
|
1054
|
+
return Promise.resolve(res);
|
|
1055
|
+
} catch (err) {
|
|
1056
|
+
return Promise.reject(err);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
async getVersion() {
|
|
1060
|
+
try {
|
|
1061
|
+
const version = await this.sqlite.getVersion({
|
|
1062
|
+
database: this.dbName,
|
|
1063
|
+
readonly: this.readonly
|
|
1064
|
+
});
|
|
1065
|
+
return Promise.resolve(version);
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
return Promise.reject(err);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
async getTableList() {
|
|
1071
|
+
try {
|
|
1072
|
+
const res = await this.sqlite.getTableList({
|
|
1073
|
+
database: this.dbName,
|
|
1074
|
+
readonly: this.readonly
|
|
1075
|
+
});
|
|
1076
|
+
return Promise.resolve(res);
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
return Promise.reject(err);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
async execute(statements, transaction = true, isSQL92 = true) {
|
|
1082
|
+
try {
|
|
1083
|
+
if (!this.readonly) {
|
|
1084
|
+
const res = await this.sqlite.execute({
|
|
1085
|
+
database: this.dbName,
|
|
1086
|
+
statements,
|
|
1087
|
+
transaction,
|
|
1088
|
+
readonly: false,
|
|
1089
|
+
isSQL92
|
|
1090
|
+
});
|
|
1091
|
+
return Promise.resolve(res);
|
|
1092
|
+
} else {
|
|
1093
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1094
|
+
}
|
|
1095
|
+
} catch (err) {
|
|
1096
|
+
return Promise.reject(err);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
async query(statement, values, isSQL92 = true) {
|
|
1100
|
+
let res;
|
|
1101
|
+
try {
|
|
1102
|
+
if (values && values.length > 0) {
|
|
1103
|
+
res = await this.sqlite.query({
|
|
1104
|
+
database: this.dbName,
|
|
1105
|
+
statement,
|
|
1106
|
+
values,
|
|
1107
|
+
readonly: this.readonly,
|
|
1108
|
+
isSQL92: true
|
|
1109
|
+
});
|
|
1110
|
+
} else {
|
|
1111
|
+
res = await this.sqlite.query({
|
|
1112
|
+
database: this.dbName,
|
|
1113
|
+
statement,
|
|
1114
|
+
values: [],
|
|
1115
|
+
readonly: this.readonly,
|
|
1116
|
+
isSQL92
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
res = await this.reorderRows(res);
|
|
1120
|
+
return Promise.resolve(res);
|
|
1121
|
+
} catch (err) {
|
|
1122
|
+
return Promise.reject(err);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
async run(statement, values, transaction = true, returnMode = "no", isSQL92 = true) {
|
|
1126
|
+
let res;
|
|
1127
|
+
try {
|
|
1128
|
+
if (!this.readonly) {
|
|
1129
|
+
if (values && values.length > 0) {
|
|
1130
|
+
res = await this.sqlite.run({
|
|
1131
|
+
database: this.dbName,
|
|
1132
|
+
statement,
|
|
1133
|
+
values,
|
|
1134
|
+
transaction,
|
|
1135
|
+
readonly: false,
|
|
1136
|
+
returnMode,
|
|
1137
|
+
isSQL92: true
|
|
1138
|
+
});
|
|
1139
|
+
} else {
|
|
1140
|
+
res = await this.sqlite.run({
|
|
1141
|
+
database: this.dbName,
|
|
1142
|
+
statement,
|
|
1143
|
+
values: [],
|
|
1144
|
+
transaction,
|
|
1145
|
+
readonly: false,
|
|
1146
|
+
returnMode,
|
|
1147
|
+
isSQL92
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
res.changes = await this.reorderRows(res.changes);
|
|
1151
|
+
return Promise.resolve(res);
|
|
1152
|
+
} else {
|
|
1153
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1154
|
+
}
|
|
1155
|
+
} catch (err) {
|
|
1156
|
+
return Promise.reject(err);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
async executeSet(set, transaction = true, returnMode = "no", isSQL92 = true) {
|
|
1160
|
+
let res;
|
|
1161
|
+
try {
|
|
1162
|
+
if (!this.readonly) {
|
|
1163
|
+
res = await this.sqlite.executeSet({
|
|
1164
|
+
database: this.dbName,
|
|
1165
|
+
set,
|
|
1166
|
+
transaction,
|
|
1167
|
+
readonly: false,
|
|
1168
|
+
returnMode,
|
|
1169
|
+
isSQL92
|
|
1170
|
+
});
|
|
1171
|
+
res.changes = await this.reorderRows(res.changes);
|
|
1172
|
+
return Promise.resolve(res);
|
|
1173
|
+
} else {
|
|
1174
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1175
|
+
}
|
|
1176
|
+
} catch (err) {
|
|
1177
|
+
return Promise.reject(err);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
async isExists() {
|
|
1181
|
+
try {
|
|
1182
|
+
const res = await this.sqlite.isDBExists({
|
|
1183
|
+
database: this.dbName,
|
|
1184
|
+
readonly: this.readonly
|
|
1185
|
+
});
|
|
1186
|
+
return Promise.resolve(res);
|
|
1187
|
+
} catch (err) {
|
|
1188
|
+
return Promise.reject(err);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
async isTable(table) {
|
|
1192
|
+
try {
|
|
1193
|
+
const res = await this.sqlite.isTableExists({
|
|
1194
|
+
database: this.dbName,
|
|
1195
|
+
table,
|
|
1196
|
+
readonly: this.readonly
|
|
1197
|
+
});
|
|
1198
|
+
return Promise.resolve(res);
|
|
1199
|
+
} catch (err) {
|
|
1200
|
+
return Promise.reject(err);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
async isDBOpen() {
|
|
1204
|
+
try {
|
|
1205
|
+
const res = await this.sqlite.isDBOpen({
|
|
1206
|
+
database: this.dbName,
|
|
1207
|
+
readonly: this.readonly
|
|
1208
|
+
});
|
|
1209
|
+
return Promise.resolve(res);
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
return Promise.reject(err);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
async delete() {
|
|
1215
|
+
try {
|
|
1216
|
+
if (!this.readonly) {
|
|
1217
|
+
await this.sqlite.deleteDatabase({
|
|
1218
|
+
database: this.dbName,
|
|
1219
|
+
readonly: false
|
|
1220
|
+
});
|
|
1221
|
+
return Promise.resolve();
|
|
1222
|
+
} else {
|
|
1223
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1224
|
+
}
|
|
1225
|
+
} catch (err) {
|
|
1226
|
+
return Promise.reject(err);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
async createSyncTable() {
|
|
1230
|
+
try {
|
|
1231
|
+
if (!this.readonly) {
|
|
1232
|
+
const res = await this.sqlite.createSyncTable({
|
|
1233
|
+
database: this.dbName,
|
|
1234
|
+
readonly: false
|
|
1235
|
+
});
|
|
1236
|
+
return Promise.resolve(res);
|
|
1237
|
+
} else {
|
|
1238
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1239
|
+
}
|
|
1240
|
+
} catch (err) {
|
|
1241
|
+
return Promise.reject(err);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
async setSyncDate(syncdate) {
|
|
1245
|
+
try {
|
|
1246
|
+
if (!this.readonly) {
|
|
1247
|
+
await this.sqlite.setSyncDate({
|
|
1248
|
+
database: this.dbName,
|
|
1249
|
+
syncdate,
|
|
1250
|
+
readonly: false
|
|
1251
|
+
});
|
|
1252
|
+
return Promise.resolve();
|
|
1253
|
+
} else {
|
|
1254
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1255
|
+
}
|
|
1256
|
+
} catch (err) {
|
|
1257
|
+
return Promise.reject(err);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
async getSyncDate() {
|
|
1261
|
+
try {
|
|
1262
|
+
const res = await this.sqlite.getSyncDate({
|
|
1263
|
+
database: this.dbName,
|
|
1264
|
+
readonly: this.readonly
|
|
1265
|
+
});
|
|
1266
|
+
let retDate = "";
|
|
1267
|
+
if (res.syncDate > 0)
|
|
1268
|
+
retDate = new Date(res.syncDate * 1e3).toISOString();
|
|
1269
|
+
return Promise.resolve(retDate);
|
|
1270
|
+
} catch (err) {
|
|
1271
|
+
return Promise.reject(err);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
async exportToJson(mode, encrypted = false) {
|
|
1275
|
+
try {
|
|
1276
|
+
const res = await this.sqlite.exportToJson({
|
|
1277
|
+
database: this.dbName,
|
|
1278
|
+
jsonexportmode: mode,
|
|
1279
|
+
readonly: this.readonly,
|
|
1280
|
+
encrypted
|
|
1281
|
+
});
|
|
1282
|
+
return Promise.resolve(res);
|
|
1283
|
+
} catch (err) {
|
|
1284
|
+
return Promise.reject(err);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
async deleteExportedRows() {
|
|
1288
|
+
try {
|
|
1289
|
+
if (!this.readonly) {
|
|
1290
|
+
await this.sqlite.deleteExportedRows({
|
|
1291
|
+
database: this.dbName,
|
|
1292
|
+
readonly: false
|
|
1293
|
+
});
|
|
1294
|
+
return Promise.resolve();
|
|
1295
|
+
} else {
|
|
1296
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1297
|
+
}
|
|
1298
|
+
} catch (err) {
|
|
1299
|
+
return Promise.reject(err);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
async executeTransaction(txn, isSQL92 = true) {
|
|
1303
|
+
let changes = 0;
|
|
1304
|
+
let isActive = false;
|
|
1305
|
+
if (!this.readonly) {
|
|
1306
|
+
await this.sqlite.beginTransaction({
|
|
1307
|
+
database: this.dbName
|
|
1308
|
+
});
|
|
1309
|
+
isActive = await this.sqlite.isTransactionActive({
|
|
1310
|
+
database: this.dbName
|
|
1311
|
+
});
|
|
1312
|
+
if (!isActive) {
|
|
1313
|
+
return Promise.reject("After Begin Transaction, no transaction active");
|
|
1314
|
+
}
|
|
1315
|
+
try {
|
|
1316
|
+
for (const task of txn) {
|
|
1317
|
+
if (typeof task !== "object" || !("statement" in task)) {
|
|
1318
|
+
throw new Error("Error a task.statement must be provided");
|
|
1319
|
+
}
|
|
1320
|
+
if ("values" in task && task.values && task.values.length > 0) {
|
|
1321
|
+
const retMode = task.statement.toUpperCase().includes("RETURNING") ? "all" : "no";
|
|
1322
|
+
const ret = await this.sqlite.run({
|
|
1323
|
+
database: this.dbName,
|
|
1324
|
+
statement: task.statement,
|
|
1325
|
+
values: task.values,
|
|
1326
|
+
transaction: false,
|
|
1327
|
+
readonly: false,
|
|
1328
|
+
returnMode: retMode,
|
|
1329
|
+
isSQL92
|
|
1330
|
+
});
|
|
1331
|
+
if (ret.changes.changes < 0) {
|
|
1332
|
+
throw new Error("Error in transaction method run ");
|
|
1333
|
+
}
|
|
1334
|
+
changes += ret.changes.changes;
|
|
1335
|
+
} else {
|
|
1336
|
+
const ret = await this.sqlite.execute({
|
|
1337
|
+
database: this.dbName,
|
|
1338
|
+
statements: task.statement,
|
|
1339
|
+
transaction: false,
|
|
1340
|
+
readonly: false
|
|
1341
|
+
});
|
|
1342
|
+
if (ret.changes.changes < 0) {
|
|
1343
|
+
throw new Error("Error in transaction method execute ");
|
|
1344
|
+
}
|
|
1345
|
+
changes += ret.changes.changes;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
const retC = await this.sqlite.commitTransaction({
|
|
1349
|
+
database: this.dbName
|
|
1350
|
+
});
|
|
1351
|
+
changes += retC.changes.changes;
|
|
1352
|
+
const retChanges = { changes: { changes } };
|
|
1353
|
+
return Promise.resolve(retChanges);
|
|
1354
|
+
} catch (err) {
|
|
1355
|
+
const msg = err.message ? err.message : err;
|
|
1356
|
+
await this.sqlite.rollbackTransaction({
|
|
1357
|
+
database: this.dbName
|
|
1358
|
+
});
|
|
1359
|
+
return Promise.reject(msg);
|
|
1360
|
+
}
|
|
1361
|
+
} else {
|
|
1362
|
+
return Promise.reject("not allowed in read-only mode");
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
async reorderRows(res) {
|
|
1366
|
+
const retRes = res;
|
|
1367
|
+
if (res?.values && typeof res.values[0] === "object") {
|
|
1368
|
+
if (Object.keys(res.values[0]).includes("ios_columns")) {
|
|
1369
|
+
const columnList = res.values[0]["ios_columns"];
|
|
1370
|
+
const iosRes = [];
|
|
1371
|
+
for (let i = 1; i < res.values.length; i++) {
|
|
1372
|
+
const rowJson = res.values[i];
|
|
1373
|
+
const resRowJson = {};
|
|
1374
|
+
for (const item of columnList) {
|
|
1375
|
+
resRowJson[item] = rowJson[item];
|
|
1376
|
+
}
|
|
1377
|
+
iosRes.push(resRowJson);
|
|
1378
|
+
}
|
|
1379
|
+
retRes["values"] = iosRes;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return Promise.resolve(retRes);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
|
|
1388
|
+
// node_modules/@capacitor-community/sqlite/dist/esm/web.js
|
|
1389
|
+
var web_exports = {};
|
|
1390
|
+
__export(web_exports, {
|
|
1391
|
+
CapacitorSQLiteWeb: () => CapacitorSQLiteWeb
|
|
1392
|
+
});
|
|
1393
|
+
var CapacitorSQLiteWeb;
|
|
1394
|
+
var init_web = __esm({
|
|
1395
|
+
"node_modules/@capacitor-community/sqlite/dist/esm/web.js"() {
|
|
1396
|
+
init_dist();
|
|
1397
|
+
CapacitorSQLiteWeb = class extends WebPlugin {
|
|
1398
|
+
constructor() {
|
|
1399
|
+
super(...arguments);
|
|
1400
|
+
this.jeepSqliteElement = null;
|
|
1401
|
+
this.isWebStoreOpen = false;
|
|
1402
|
+
}
|
|
1403
|
+
async initWebStore() {
|
|
1404
|
+
await customElements.whenDefined("jeep-sqlite");
|
|
1405
|
+
this.jeepSqliteElement = document.querySelector("jeep-sqlite");
|
|
1406
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1407
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteImportProgress", (event) => {
|
|
1408
|
+
this.notifyListeners("sqliteImportProgressEvent", event.detail);
|
|
1409
|
+
});
|
|
1410
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteExportProgress", (event) => {
|
|
1411
|
+
this.notifyListeners("sqliteExportProgressEvent", event.detail);
|
|
1412
|
+
});
|
|
1413
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteHTTPRequestEnded", (event) => {
|
|
1414
|
+
this.notifyListeners("sqliteHTTPRequestEndedEvent", event.detail);
|
|
1415
|
+
});
|
|
1416
|
+
this.jeepSqliteElement.addEventListener("jeepSqlitePickDatabaseEnded", (event) => {
|
|
1417
|
+
this.notifyListeners("sqlitePickDatabaseEndedEvent", event.detail);
|
|
1418
|
+
});
|
|
1419
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteSaveDatabaseToDisk", (event) => {
|
|
1420
|
+
this.notifyListeners("sqliteSaveDatabaseToDiskEvent", event.detail);
|
|
1421
|
+
});
|
|
1422
|
+
if (!this.isWebStoreOpen) {
|
|
1423
|
+
this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
|
|
1424
|
+
}
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
async saveToStore(options) {
|
|
1428
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1429
|
+
this.ensureWebstoreIsOpen();
|
|
1430
|
+
try {
|
|
1431
|
+
await this.jeepSqliteElement.saveToStore(options);
|
|
1432
|
+
return;
|
|
1433
|
+
} catch (err) {
|
|
1434
|
+
throw new Error(`${err}`);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
async getFromLocalDiskToStore(options) {
|
|
1438
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1439
|
+
this.ensureWebstoreIsOpen();
|
|
1440
|
+
try {
|
|
1441
|
+
await this.jeepSqliteElement.getFromLocalDiskToStore(options);
|
|
1442
|
+
return;
|
|
1443
|
+
} catch (err) {
|
|
1444
|
+
throw new Error(`${err}`);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
async saveToLocalDisk(options) {
|
|
1448
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1449
|
+
this.ensureWebstoreIsOpen();
|
|
1450
|
+
try {
|
|
1451
|
+
await this.jeepSqliteElement.saveToLocalDisk(options);
|
|
1452
|
+
return;
|
|
1453
|
+
} catch (err) {
|
|
1454
|
+
throw new Error(`${err}`);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
async echo(options) {
|
|
1458
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1459
|
+
const echoResult = await this.jeepSqliteElement.echo(options);
|
|
1460
|
+
return echoResult;
|
|
1461
|
+
}
|
|
1462
|
+
async createConnection(options) {
|
|
1463
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1464
|
+
this.ensureWebstoreIsOpen();
|
|
1465
|
+
try {
|
|
1466
|
+
await this.jeepSqliteElement.createConnection(options);
|
|
1467
|
+
return;
|
|
1468
|
+
} catch (err) {
|
|
1469
|
+
throw new Error(`${err}`);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
async open(options) {
|
|
1473
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1474
|
+
this.ensureWebstoreIsOpen();
|
|
1475
|
+
try {
|
|
1476
|
+
await this.jeepSqliteElement.open(options);
|
|
1477
|
+
return;
|
|
1478
|
+
} catch (err) {
|
|
1479
|
+
throw new Error(`${err}`);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
async closeConnection(options) {
|
|
1483
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1484
|
+
this.ensureWebstoreIsOpen();
|
|
1485
|
+
try {
|
|
1486
|
+
await this.jeepSqliteElement.closeConnection(options);
|
|
1487
|
+
return;
|
|
1488
|
+
} catch (err) {
|
|
1489
|
+
throw new Error(`${err}`);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
async getVersion(options) {
|
|
1493
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1494
|
+
this.ensureWebstoreIsOpen();
|
|
1495
|
+
try {
|
|
1496
|
+
const versionResult = await this.jeepSqliteElement.getVersion(options);
|
|
1497
|
+
return versionResult;
|
|
1498
|
+
} catch (err) {
|
|
1499
|
+
throw new Error(`${err}`);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
async checkConnectionsConsistency(options) {
|
|
1503
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1504
|
+
try {
|
|
1505
|
+
const consistencyResult = await this.jeepSqliteElement.checkConnectionsConsistency(options);
|
|
1506
|
+
return consistencyResult;
|
|
1507
|
+
} catch (err) {
|
|
1508
|
+
throw new Error(`${err}`);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
async close(options) {
|
|
1512
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1513
|
+
this.ensureWebstoreIsOpen();
|
|
1514
|
+
try {
|
|
1515
|
+
await this.jeepSqliteElement.close(options);
|
|
1516
|
+
return;
|
|
1517
|
+
} catch (err) {
|
|
1518
|
+
throw new Error(`${err}`);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
async beginTransaction(options) {
|
|
1522
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1523
|
+
this.ensureWebstoreIsOpen();
|
|
1524
|
+
try {
|
|
1525
|
+
const changes = await this.jeepSqliteElement.beginTransaction(options);
|
|
1526
|
+
return changes;
|
|
1527
|
+
} catch (err) {
|
|
1528
|
+
throw new Error(`${err}`);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
async commitTransaction(options) {
|
|
1532
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1533
|
+
this.ensureWebstoreIsOpen();
|
|
1534
|
+
try {
|
|
1535
|
+
const changes = await this.jeepSqliteElement.commitTransaction(options);
|
|
1536
|
+
return changes;
|
|
1537
|
+
} catch (err) {
|
|
1538
|
+
throw new Error(`${err}`);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
async rollbackTransaction(options) {
|
|
1542
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1543
|
+
this.ensureWebstoreIsOpen();
|
|
1544
|
+
try {
|
|
1545
|
+
const changes = await this.jeepSqliteElement.rollbackTransaction(options);
|
|
1546
|
+
return changes;
|
|
1547
|
+
} catch (err) {
|
|
1548
|
+
throw new Error(`${err}`);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
async isTransactionActive(options) {
|
|
1552
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1553
|
+
this.ensureWebstoreIsOpen();
|
|
1554
|
+
try {
|
|
1555
|
+
const result = await this.jeepSqliteElement.isTransactionActive(options);
|
|
1556
|
+
return result;
|
|
1557
|
+
} catch (err) {
|
|
1558
|
+
throw new Error(`${err}`);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
async getTableList(options) {
|
|
1562
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1563
|
+
this.ensureWebstoreIsOpen();
|
|
1564
|
+
try {
|
|
1565
|
+
const tableListResult = await this.jeepSqliteElement.getTableList(options);
|
|
1566
|
+
return tableListResult;
|
|
1567
|
+
} catch (err) {
|
|
1568
|
+
throw new Error(`${err}`);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
async execute(options) {
|
|
1572
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1573
|
+
this.ensureWebstoreIsOpen();
|
|
1574
|
+
try {
|
|
1575
|
+
const executeResult = await this.jeepSqliteElement.execute(options);
|
|
1576
|
+
return executeResult;
|
|
1577
|
+
} catch (err) {
|
|
1578
|
+
throw new Error(`${err}`);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
async executeSet(options) {
|
|
1582
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1583
|
+
this.ensureWebstoreIsOpen();
|
|
1584
|
+
try {
|
|
1585
|
+
const executeResult = await this.jeepSqliteElement.executeSet(options);
|
|
1586
|
+
return executeResult;
|
|
1587
|
+
} catch (err) {
|
|
1588
|
+
throw new Error(`${err}`);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
async run(options) {
|
|
1592
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1593
|
+
this.ensureWebstoreIsOpen();
|
|
1594
|
+
try {
|
|
1595
|
+
const runResult = await this.jeepSqliteElement.run(options);
|
|
1596
|
+
return runResult;
|
|
1597
|
+
} catch (err) {
|
|
1598
|
+
throw new Error(`${err}`);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
async query(options) {
|
|
1602
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1603
|
+
this.ensureWebstoreIsOpen();
|
|
1604
|
+
try {
|
|
1605
|
+
const queryResult = await this.jeepSqliteElement.query(options);
|
|
1606
|
+
return queryResult;
|
|
1607
|
+
} catch (err) {
|
|
1608
|
+
throw new Error(`${err}`);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
async isDBExists(options) {
|
|
1612
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1613
|
+
this.ensureWebstoreIsOpen();
|
|
1614
|
+
try {
|
|
1615
|
+
const dbExistsResult = await this.jeepSqliteElement.isDBExists(options);
|
|
1616
|
+
return dbExistsResult;
|
|
1617
|
+
} catch (err) {
|
|
1618
|
+
throw new Error(`${err}`);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
async isDBOpen(options) {
|
|
1622
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1623
|
+
this.ensureWebstoreIsOpen();
|
|
1624
|
+
try {
|
|
1625
|
+
const isDBOpenResult = await this.jeepSqliteElement.isDBOpen(options);
|
|
1626
|
+
return isDBOpenResult;
|
|
1627
|
+
} catch (err) {
|
|
1628
|
+
throw new Error(`${err}`);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
async isDatabase(options) {
|
|
1632
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1633
|
+
this.ensureWebstoreIsOpen();
|
|
1634
|
+
try {
|
|
1635
|
+
const isDatabaseResult = await this.jeepSqliteElement.isDatabase(options);
|
|
1636
|
+
return isDatabaseResult;
|
|
1637
|
+
} catch (err) {
|
|
1638
|
+
throw new Error(`${err}`);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
async isTableExists(options) {
|
|
1642
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1643
|
+
this.ensureWebstoreIsOpen();
|
|
1644
|
+
try {
|
|
1645
|
+
const tableExistsResult = await this.jeepSqliteElement.isTableExists(options);
|
|
1646
|
+
return tableExistsResult;
|
|
1647
|
+
} catch (err) {
|
|
1648
|
+
throw new Error(`${err}`);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
async deleteDatabase(options) {
|
|
1652
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1653
|
+
this.ensureWebstoreIsOpen();
|
|
1654
|
+
try {
|
|
1655
|
+
await this.jeepSqliteElement.deleteDatabase(options);
|
|
1656
|
+
return;
|
|
1657
|
+
} catch (err) {
|
|
1658
|
+
throw new Error(`${err}`);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
async isJsonValid(options) {
|
|
1662
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1663
|
+
this.ensureWebstoreIsOpen();
|
|
1664
|
+
try {
|
|
1665
|
+
const isJsonValidResult = await this.jeepSqliteElement.isJsonValid(options);
|
|
1666
|
+
return isJsonValidResult;
|
|
1667
|
+
} catch (err) {
|
|
1668
|
+
throw new Error(`${err}`);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
async importFromJson(options) {
|
|
1672
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1673
|
+
this.ensureWebstoreIsOpen();
|
|
1674
|
+
try {
|
|
1675
|
+
const importFromJsonResult = await this.jeepSqliteElement.importFromJson(options);
|
|
1676
|
+
return importFromJsonResult;
|
|
1677
|
+
} catch (err) {
|
|
1678
|
+
throw new Error(`${err}`);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
async exportToJson(options) {
|
|
1682
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1683
|
+
this.ensureWebstoreIsOpen();
|
|
1684
|
+
try {
|
|
1685
|
+
const exportToJsonResult = await this.jeepSqliteElement.exportToJson(options);
|
|
1686
|
+
return exportToJsonResult;
|
|
1687
|
+
} catch (err) {
|
|
1688
|
+
throw new Error(`${err}`);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
async createSyncTable(options) {
|
|
1692
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1693
|
+
this.ensureWebstoreIsOpen();
|
|
1694
|
+
try {
|
|
1695
|
+
const createSyncTableResult = await this.jeepSqliteElement.createSyncTable(options);
|
|
1696
|
+
return createSyncTableResult;
|
|
1697
|
+
} catch (err) {
|
|
1698
|
+
throw new Error(`${err}`);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
async setSyncDate(options) {
|
|
1702
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1703
|
+
this.ensureWebstoreIsOpen();
|
|
1704
|
+
try {
|
|
1705
|
+
await this.jeepSqliteElement.setSyncDate(options);
|
|
1706
|
+
return;
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
throw new Error(`${err}`);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
async getSyncDate(options) {
|
|
1712
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1713
|
+
this.ensureWebstoreIsOpen();
|
|
1714
|
+
try {
|
|
1715
|
+
const getSyncDateResult = await this.jeepSqliteElement.getSyncDate(options);
|
|
1716
|
+
return getSyncDateResult;
|
|
1717
|
+
} catch (err) {
|
|
1718
|
+
throw new Error(`${err}`);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
async deleteExportedRows(options) {
|
|
1722
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1723
|
+
this.ensureWebstoreIsOpen();
|
|
1724
|
+
try {
|
|
1725
|
+
await this.jeepSqliteElement.deleteExportedRows(options);
|
|
1726
|
+
return;
|
|
1727
|
+
} catch (err) {
|
|
1728
|
+
throw new Error(`${err}`);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
async addUpgradeStatement(options) {
|
|
1732
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1733
|
+
this.ensureWebstoreIsOpen();
|
|
1734
|
+
try {
|
|
1735
|
+
await this.jeepSqliteElement.addUpgradeStatement(options);
|
|
1736
|
+
return;
|
|
1737
|
+
} catch (err) {
|
|
1738
|
+
throw new Error(`${err}`);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
async copyFromAssets(options) {
|
|
1742
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1743
|
+
this.ensureWebstoreIsOpen();
|
|
1744
|
+
try {
|
|
1745
|
+
await this.jeepSqliteElement.copyFromAssets(options);
|
|
1746
|
+
return;
|
|
1747
|
+
} catch (err) {
|
|
1748
|
+
throw new Error(`${err}`);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
async getFromHTTPRequest(options) {
|
|
1752
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1753
|
+
this.ensureWebstoreIsOpen();
|
|
1754
|
+
try {
|
|
1755
|
+
await this.jeepSqliteElement.getFromHTTPRequest(options);
|
|
1756
|
+
return;
|
|
1757
|
+
} catch (err) {
|
|
1758
|
+
throw new Error(`${err}`);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
async getDatabaseList() {
|
|
1762
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1763
|
+
this.ensureWebstoreIsOpen();
|
|
1764
|
+
try {
|
|
1765
|
+
const databaseListResult = await this.jeepSqliteElement.getDatabaseList();
|
|
1766
|
+
return databaseListResult;
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
throw new Error(`${err}`);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Checks if the `jeep-sqlite` element is present in the DOM.
|
|
1773
|
+
* If it's not in the DOM, this method throws an Error.
|
|
1774
|
+
*
|
|
1775
|
+
* Attention: This will always fail, if the `intWebStore()` method wasn't called before.
|
|
1776
|
+
*/
|
|
1777
|
+
ensureJeepSqliteIsAvailable() {
|
|
1778
|
+
if (this.jeepSqliteElement === null) {
|
|
1779
|
+
throw new Error(`The jeep-sqlite element is not present in the DOM! Please check the @capacitor-community/sqlite documentation for instructions regarding the web platform.`);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
ensureWebstoreIsOpen() {
|
|
1783
|
+
if (!this.isWebStoreOpen) {
|
|
1784
|
+
throw new Error('WebStore is not open yet. You have to call "initWebStore()" first.');
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
////////////////////////////////////
|
|
1788
|
+
////// UNIMPLEMENTED METHODS
|
|
1789
|
+
////////////////////////////////////
|
|
1790
|
+
async getUrl() {
|
|
1791
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1792
|
+
}
|
|
1793
|
+
async getMigratableDbList(options) {
|
|
1794
|
+
console.log("getMigratableDbList", options);
|
|
1795
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1796
|
+
}
|
|
1797
|
+
async addSQLiteSuffix(options) {
|
|
1798
|
+
console.log("addSQLiteSuffix", options);
|
|
1799
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1800
|
+
}
|
|
1801
|
+
async deleteOldDatabases(options) {
|
|
1802
|
+
console.log("deleteOldDatabases", options);
|
|
1803
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1804
|
+
}
|
|
1805
|
+
async moveDatabasesAndAddSuffix(options) {
|
|
1806
|
+
console.log("moveDatabasesAndAddSuffix", options);
|
|
1807
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1808
|
+
}
|
|
1809
|
+
async isSecretStored() {
|
|
1810
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1811
|
+
}
|
|
1812
|
+
async setEncryptionSecret(options) {
|
|
1813
|
+
console.log("setEncryptionSecret", options);
|
|
1814
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1815
|
+
}
|
|
1816
|
+
async changeEncryptionSecret(options) {
|
|
1817
|
+
console.log("changeEncryptionSecret", options);
|
|
1818
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1819
|
+
}
|
|
1820
|
+
async clearEncryptionSecret() {
|
|
1821
|
+
console.log("clearEncryptionSecret");
|
|
1822
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1823
|
+
}
|
|
1824
|
+
async checkEncryptionSecret(options) {
|
|
1825
|
+
console.log("checkEncryptionPassPhrase", options);
|
|
1826
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1827
|
+
}
|
|
1828
|
+
async getNCDatabasePath(options) {
|
|
1829
|
+
console.log("getNCDatabasePath", options);
|
|
1830
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1831
|
+
}
|
|
1832
|
+
async createNCConnection(options) {
|
|
1833
|
+
console.log("createNCConnection", options);
|
|
1834
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1835
|
+
}
|
|
1836
|
+
async closeNCConnection(options) {
|
|
1837
|
+
console.log("closeNCConnection", options);
|
|
1838
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1839
|
+
}
|
|
1840
|
+
async isNCDatabase(options) {
|
|
1841
|
+
console.log("isNCDatabase", options);
|
|
1842
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1843
|
+
}
|
|
1844
|
+
async isDatabaseEncrypted(options) {
|
|
1845
|
+
console.log("isDatabaseEncrypted", options);
|
|
1846
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1847
|
+
}
|
|
1848
|
+
async isInConfigEncryption() {
|
|
1849
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1850
|
+
}
|
|
1851
|
+
async isInConfigBiometricAuth() {
|
|
1852
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1853
|
+
}
|
|
1854
|
+
async loadExtension(options) {
|
|
1855
|
+
console.log("loadExtension", options);
|
|
1856
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1857
|
+
}
|
|
1858
|
+
async enableLoadExtension(options) {
|
|
1859
|
+
console.log("enableLoadExtension", options);
|
|
1860
|
+
throw this.unimplemented("Not implemented on web.");
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1866
|
+
// node_modules/@capacitor-community/sqlite/dist/esm/index.js
|
|
1867
|
+
var esm_exports = {};
|
|
1868
|
+
__export(esm_exports, {
|
|
1869
|
+
CapacitorSQLite: () => CapacitorSQLite,
|
|
1870
|
+
SQLiteConnection: () => SQLiteConnection,
|
|
1871
|
+
SQLiteDBConnection: () => SQLiteDBConnection
|
|
1872
|
+
});
|
|
1873
|
+
var CapacitorSQLite;
|
|
1874
|
+
var init_esm = __esm({
|
|
1875
|
+
"node_modules/@capacitor-community/sqlite/dist/esm/index.js"() {
|
|
1876
|
+
init_dist();
|
|
1877
|
+
init_definitions();
|
|
1878
|
+
CapacitorSQLite = registerPlugin("CapacitorSQLite", {
|
|
1879
|
+
web: () => Promise.resolve().then(() => (init_web(), web_exports)).then((m) => new m.CapacitorSQLiteWeb()),
|
|
1880
|
+
electron: () => window.CapacitorCustomPlatform.plugins.CapacitorSQLite
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1885
|
+
// node_modules/@tauri-apps/api/external/tslib/tslib.es6.js
|
|
1886
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
1887
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1888
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1889
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1890
|
+
}
|
|
1891
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
1892
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1893
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1894
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1895
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1896
|
+
}
|
|
1897
|
+
var init_tslib_es6 = __esm({
|
|
1898
|
+
"node_modules/@tauri-apps/api/external/tslib/tslib.es6.js"() {
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1902
|
+
// node_modules/@tauri-apps/api/core.js
|
|
1903
|
+
function transformCallback(callback, once2 = false) {
|
|
1904
|
+
return window.__TAURI_INTERNALS__.transformCallback(callback, once2);
|
|
1905
|
+
}
|
|
1906
|
+
async function invoke(cmd, args = {}, options) {
|
|
1907
|
+
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
|
1908
|
+
}
|
|
1909
|
+
var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid, SERIALIZE_TO_IPC_FN, Channel, Resource;
|
|
1910
|
+
var init_core = __esm({
|
|
1911
|
+
"node_modules/@tauri-apps/api/core.js"() {
|
|
1912
|
+
init_tslib_es6();
|
|
1913
|
+
SERIALIZE_TO_IPC_FN = "__TAURI_TO_IPC_KEY__";
|
|
1914
|
+
Channel = class {
|
|
1915
|
+
constructor(onmessage) {
|
|
1916
|
+
_Channel_onmessage.set(this, void 0);
|
|
1917
|
+
_Channel_nextMessageIndex.set(this, 0);
|
|
1918
|
+
_Channel_pendingMessages.set(this, []);
|
|
1919
|
+
_Channel_messageEndIndex.set(this, void 0);
|
|
1920
|
+
__classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => {
|
|
1921
|
+
}), "f");
|
|
1922
|
+
this.id = transformCallback((rawMessage) => {
|
|
1923
|
+
const index = rawMessage.index;
|
|
1924
|
+
if ("end" in rawMessage) {
|
|
1925
|
+
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
|
1926
|
+
this.cleanupCallback();
|
|
1927
|
+
} else {
|
|
1928
|
+
__classPrivateFieldSet(this, _Channel_messageEndIndex, index, "f");
|
|
1929
|
+
}
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
const message = rawMessage.message;
|
|
1933
|
+
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
|
1934
|
+
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
|
1935
|
+
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
|
1936
|
+
while (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") in __classPrivateFieldGet(this, _Channel_pendingMessages, "f")) {
|
|
1937
|
+
const message2 = __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
|
1938
|
+
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message2);
|
|
1939
|
+
delete __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
|
1940
|
+
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
|
1941
|
+
}
|
|
1942
|
+
if (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") === __classPrivateFieldGet(this, _Channel_messageEndIndex, "f")) {
|
|
1943
|
+
this.cleanupCallback();
|
|
1944
|
+
}
|
|
1945
|
+
} else {
|
|
1946
|
+
__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[index] = message;
|
|
1947
|
+
}
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
cleanupCallback() {
|
|
1951
|
+
window.__TAURI_INTERNALS__.unregisterCallback(this.id);
|
|
1952
|
+
}
|
|
1953
|
+
set onmessage(handler) {
|
|
1954
|
+
__classPrivateFieldSet(this, _Channel_onmessage, handler, "f");
|
|
1955
|
+
}
|
|
1956
|
+
get onmessage() {
|
|
1957
|
+
return __classPrivateFieldGet(this, _Channel_onmessage, "f");
|
|
1958
|
+
}
|
|
1959
|
+
[(_Channel_onmessage = /* @__PURE__ */ new WeakMap(), _Channel_nextMessageIndex = /* @__PURE__ */ new WeakMap(), _Channel_pendingMessages = /* @__PURE__ */ new WeakMap(), _Channel_messageEndIndex = /* @__PURE__ */ new WeakMap(), SERIALIZE_TO_IPC_FN)]() {
|
|
1960
|
+
return `__CHANNEL__:${this.id}`;
|
|
1961
|
+
}
|
|
1962
|
+
toJSON() {
|
|
1963
|
+
return this[SERIALIZE_TO_IPC_FN]();
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
Resource = class {
|
|
1967
|
+
get rid() {
|
|
1968
|
+
return __classPrivateFieldGet(this, _Resource_rid, "f");
|
|
1969
|
+
}
|
|
1970
|
+
constructor(rid) {
|
|
1971
|
+
_Resource_rid.set(this, void 0);
|
|
1972
|
+
__classPrivateFieldSet(this, _Resource_rid, rid, "f");
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Destroys and cleans up this resource from memory.
|
|
1976
|
+
* **You should not call any method on this object anymore and should drop any reference to it.**
|
|
1977
|
+
*/
|
|
1978
|
+
async close() {
|
|
1979
|
+
return invoke("plugin:resources|close", {
|
|
1980
|
+
rid: this.rid
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
_Resource_rid = /* @__PURE__ */ new WeakMap();
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1988
|
+
// node_modules/@tauri-apps/plugin-sql/dist-js/index.js
|
|
1989
|
+
var dist_js_exports = {};
|
|
1990
|
+
__export(dist_js_exports, {
|
|
1991
|
+
default: () => Database
|
|
1992
|
+
});
|
|
1993
|
+
var Database;
|
|
1994
|
+
var init_dist_js = __esm({
|
|
1995
|
+
"node_modules/@tauri-apps/plugin-sql/dist-js/index.js"() {
|
|
1996
|
+
init_core();
|
|
1997
|
+
Database = class _Database {
|
|
1998
|
+
constructor(path) {
|
|
1999
|
+
this.path = path;
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* **load**
|
|
2003
|
+
*
|
|
2004
|
+
* A static initializer which connects to the underlying database and
|
|
2005
|
+
* returns a `Database` instance once a connection to the database is established.
|
|
2006
|
+
*
|
|
2007
|
+
* # Sqlite
|
|
2008
|
+
*
|
|
2009
|
+
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
2010
|
+
*
|
|
2011
|
+
* @example
|
|
2012
|
+
* ```ts
|
|
2013
|
+
* const db = await Database.load("sqlite:test.db");
|
|
2014
|
+
* ```
|
|
2015
|
+
*/
|
|
2016
|
+
static async load(path) {
|
|
2017
|
+
const _path = await invoke("plugin:sql|load", {
|
|
2018
|
+
db: path
|
|
2019
|
+
});
|
|
2020
|
+
return new _Database(_path);
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* **get**
|
|
2024
|
+
*
|
|
2025
|
+
* A static initializer which synchronously returns an instance of
|
|
2026
|
+
* the Database class while deferring the actual database connection
|
|
2027
|
+
* until the first invocation or selection on the database.
|
|
2028
|
+
*
|
|
2029
|
+
* # Sqlite
|
|
2030
|
+
*
|
|
2031
|
+
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
2032
|
+
*
|
|
2033
|
+
* @example
|
|
2034
|
+
* ```ts
|
|
2035
|
+
* const db = Database.get("sqlite:test.db");
|
|
2036
|
+
* ```
|
|
2037
|
+
*/
|
|
2038
|
+
static get(path) {
|
|
2039
|
+
return new _Database(path);
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* **execute**
|
|
2043
|
+
*
|
|
2044
|
+
* Passes a SQL expression to the database for execution.
|
|
2045
|
+
*
|
|
2046
|
+
* @example
|
|
2047
|
+
* ```ts
|
|
2048
|
+
* // for sqlite & postgres
|
|
2049
|
+
* // INSERT example
|
|
2050
|
+
* const result = await db.execute(
|
|
2051
|
+
* "INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
|
2052
|
+
* [ todos.id, todos.title, todos.status ]
|
|
2053
|
+
* );
|
|
2054
|
+
* // UPDATE example
|
|
2055
|
+
* const result = await db.execute(
|
|
2056
|
+
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
|
2057
|
+
* [ todos.title, todos.status, todos.id ]
|
|
2058
|
+
* );
|
|
2059
|
+
*
|
|
2060
|
+
* // for mysql
|
|
2061
|
+
* // INSERT example
|
|
2062
|
+
* const result = await db.execute(
|
|
2063
|
+
* "INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
|
2064
|
+
* [ todos.id, todos.title, todos.status ]
|
|
2065
|
+
* );
|
|
2066
|
+
* // UPDATE example
|
|
2067
|
+
* const result = await db.execute(
|
|
2068
|
+
* "UPDATE todos SET title = ?, completed = ? WHERE id = ?",
|
|
2069
|
+
* [ todos.title, todos.status, todos.id ]
|
|
2070
|
+
* );
|
|
2071
|
+
* ```
|
|
2072
|
+
*/
|
|
2073
|
+
async execute(query, bindValues) {
|
|
2074
|
+
const [rowsAffected, lastInsertId] = await invoke("plugin:sql|execute", {
|
|
2075
|
+
db: this.path,
|
|
2076
|
+
query,
|
|
2077
|
+
values: bindValues ?? []
|
|
2078
|
+
});
|
|
2079
|
+
return {
|
|
2080
|
+
lastInsertId,
|
|
2081
|
+
rowsAffected
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* **select**
|
|
2086
|
+
*
|
|
2087
|
+
* Passes in a SELECT query to the database for execution.
|
|
2088
|
+
*
|
|
2089
|
+
* @example
|
|
2090
|
+
* ```ts
|
|
2091
|
+
* // for sqlite & postgres
|
|
2092
|
+
* const result = await db.select(
|
|
2093
|
+
* "SELECT * from todos WHERE id = $1", [ id ]
|
|
2094
|
+
* );
|
|
2095
|
+
*
|
|
2096
|
+
* // for mysql
|
|
2097
|
+
* const result = await db.select(
|
|
2098
|
+
* "SELECT * from todos WHERE id = ?", [ id ]
|
|
2099
|
+
* );
|
|
2100
|
+
* ```
|
|
2101
|
+
*/
|
|
2102
|
+
async select(query, bindValues) {
|
|
2103
|
+
const result = await invoke("plugin:sql|select", {
|
|
2104
|
+
db: this.path,
|
|
2105
|
+
query,
|
|
2106
|
+
values: bindValues ?? []
|
|
2107
|
+
});
|
|
2108
|
+
return result;
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* **close**
|
|
2112
|
+
*
|
|
2113
|
+
* Closes the database connection pool.
|
|
2114
|
+
*
|
|
2115
|
+
* @example
|
|
2116
|
+
* ```ts
|
|
2117
|
+
* const success = await db.close()
|
|
2118
|
+
* ```
|
|
2119
|
+
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
2120
|
+
*/
|
|
2121
|
+
async close(db) {
|
|
2122
|
+
const success = await invoke("plugin:sql|close", {
|
|
2123
|
+
db
|
|
2124
|
+
});
|
|
2125
|
+
return success;
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
|
|
558
2131
|
// node_modules/@capacitor/app/dist/esm/definitions.js
|
|
559
|
-
var
|
|
2132
|
+
var init_definitions2 = __esm({
|
|
560
2133
|
"node_modules/@capacitor/app/dist/esm/definitions.js"() {
|
|
561
2134
|
}
|
|
562
2135
|
});
|
|
563
2136
|
|
|
564
2137
|
// node_modules/@capacitor/app/dist/esm/web.js
|
|
565
|
-
var
|
|
566
|
-
__export(
|
|
2138
|
+
var web_exports2 = {};
|
|
2139
|
+
__export(web_exports2, {
|
|
567
2140
|
AppWeb: () => AppWeb
|
|
568
2141
|
});
|
|
569
2142
|
var AppWeb;
|
|
570
|
-
var
|
|
2143
|
+
var init_web2 = __esm({
|
|
571
2144
|
"node_modules/@capacitor/app/dist/esm/web.js"() {
|
|
572
2145
|
init_dist();
|
|
573
2146
|
AppWeb = class extends WebPlugin {
|
|
@@ -615,30 +2188,30 @@ var init_web = __esm({
|
|
|
615
2188
|
|
|
616
2189
|
// node_modules/@capacitor/app/dist/esm/index.js
|
|
617
2190
|
var App;
|
|
618
|
-
var
|
|
2191
|
+
var init_esm2 = __esm({
|
|
619
2192
|
"node_modules/@capacitor/app/dist/esm/index.js"() {
|
|
620
2193
|
init_dist();
|
|
621
|
-
|
|
2194
|
+
init_definitions2();
|
|
622
2195
|
App = registerPlugin("App", {
|
|
623
|
-
web: () => Promise.resolve().then(() => (
|
|
2196
|
+
web: () => Promise.resolve().then(() => (init_web2(), web_exports2)).then((m) => new m.AppWeb())
|
|
624
2197
|
});
|
|
625
2198
|
}
|
|
626
2199
|
});
|
|
627
2200
|
|
|
628
2201
|
// node_modules/@capacitor/browser/dist/esm/definitions.js
|
|
629
|
-
var
|
|
2202
|
+
var init_definitions3 = __esm({
|
|
630
2203
|
"node_modules/@capacitor/browser/dist/esm/definitions.js"() {
|
|
631
2204
|
}
|
|
632
2205
|
});
|
|
633
2206
|
|
|
634
2207
|
// node_modules/@capacitor/browser/dist/esm/web.js
|
|
635
|
-
var
|
|
636
|
-
__export(
|
|
2208
|
+
var web_exports3 = {};
|
|
2209
|
+
__export(web_exports3, {
|
|
637
2210
|
Browser: () => Browser,
|
|
638
2211
|
BrowserWeb: () => BrowserWeb
|
|
639
2212
|
});
|
|
640
2213
|
var BrowserWeb, Browser;
|
|
641
|
-
var
|
|
2214
|
+
var init_web3 = __esm({
|
|
642
2215
|
"node_modules/@capacitor/browser/dist/esm/web.js"() {
|
|
643
2216
|
init_dist();
|
|
644
2217
|
BrowserWeb = class extends WebPlugin {
|
|
@@ -667,119 +2240,16 @@ var init_web2 = __esm({
|
|
|
667
2240
|
|
|
668
2241
|
// node_modules/@capacitor/browser/dist/esm/index.js
|
|
669
2242
|
var Browser2;
|
|
670
|
-
var
|
|
2243
|
+
var init_esm3 = __esm({
|
|
671
2244
|
"node_modules/@capacitor/browser/dist/esm/index.js"() {
|
|
672
2245
|
init_dist();
|
|
673
|
-
|
|
2246
|
+
init_definitions3();
|
|
674
2247
|
Browser2 = registerPlugin("Browser", {
|
|
675
|
-
web: () => Promise.resolve().then(() => (
|
|
2248
|
+
web: () => Promise.resolve().then(() => (init_web3(), web_exports3)).then((m) => new m.BrowserWeb())
|
|
676
2249
|
});
|
|
677
2250
|
}
|
|
678
2251
|
});
|
|
679
2252
|
|
|
680
|
-
// node_modules/@tauri-apps/api/external/tslib/tslib.es6.js
|
|
681
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
682
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
683
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
684
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
685
|
-
}
|
|
686
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
687
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
688
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
689
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
690
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
691
|
-
}
|
|
692
|
-
var init_tslib_es6 = __esm({
|
|
693
|
-
"node_modules/@tauri-apps/api/external/tslib/tslib.es6.js"() {
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
// node_modules/@tauri-apps/api/core.js
|
|
698
|
-
function transformCallback(callback, once2 = false) {
|
|
699
|
-
return window.__TAURI_INTERNALS__.transformCallback(callback, once2);
|
|
700
|
-
}
|
|
701
|
-
async function invoke(cmd, args = {}, options) {
|
|
702
|
-
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
|
703
|
-
}
|
|
704
|
-
var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid, SERIALIZE_TO_IPC_FN, Channel, Resource;
|
|
705
|
-
var init_core = __esm({
|
|
706
|
-
"node_modules/@tauri-apps/api/core.js"() {
|
|
707
|
-
init_tslib_es6();
|
|
708
|
-
SERIALIZE_TO_IPC_FN = "__TAURI_TO_IPC_KEY__";
|
|
709
|
-
Channel = class {
|
|
710
|
-
constructor(onmessage) {
|
|
711
|
-
_Channel_onmessage.set(this, void 0);
|
|
712
|
-
_Channel_nextMessageIndex.set(this, 0);
|
|
713
|
-
_Channel_pendingMessages.set(this, []);
|
|
714
|
-
_Channel_messageEndIndex.set(this, void 0);
|
|
715
|
-
__classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => {
|
|
716
|
-
}), "f");
|
|
717
|
-
this.id = transformCallback((rawMessage) => {
|
|
718
|
-
const index = rawMessage.index;
|
|
719
|
-
if ("end" in rawMessage) {
|
|
720
|
-
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
|
721
|
-
this.cleanupCallback();
|
|
722
|
-
} else {
|
|
723
|
-
__classPrivateFieldSet(this, _Channel_messageEndIndex, index, "f");
|
|
724
|
-
}
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
const message = rawMessage.message;
|
|
728
|
-
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
|
729
|
-
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
|
730
|
-
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
|
731
|
-
while (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") in __classPrivateFieldGet(this, _Channel_pendingMessages, "f")) {
|
|
732
|
-
const message2 = __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
|
733
|
-
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message2);
|
|
734
|
-
delete __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
|
735
|
-
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
|
736
|
-
}
|
|
737
|
-
if (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") === __classPrivateFieldGet(this, _Channel_messageEndIndex, "f")) {
|
|
738
|
-
this.cleanupCallback();
|
|
739
|
-
}
|
|
740
|
-
} else {
|
|
741
|
-
__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[index] = message;
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
cleanupCallback() {
|
|
746
|
-
window.__TAURI_INTERNALS__.unregisterCallback(this.id);
|
|
747
|
-
}
|
|
748
|
-
set onmessage(handler) {
|
|
749
|
-
__classPrivateFieldSet(this, _Channel_onmessage, handler, "f");
|
|
750
|
-
}
|
|
751
|
-
get onmessage() {
|
|
752
|
-
return __classPrivateFieldGet(this, _Channel_onmessage, "f");
|
|
753
|
-
}
|
|
754
|
-
[(_Channel_onmessage = /* @__PURE__ */ new WeakMap(), _Channel_nextMessageIndex = /* @__PURE__ */ new WeakMap(), _Channel_pendingMessages = /* @__PURE__ */ new WeakMap(), _Channel_messageEndIndex = /* @__PURE__ */ new WeakMap(), SERIALIZE_TO_IPC_FN)]() {
|
|
755
|
-
return `__CHANNEL__:${this.id}`;
|
|
756
|
-
}
|
|
757
|
-
toJSON() {
|
|
758
|
-
return this[SERIALIZE_TO_IPC_FN]();
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
Resource = class {
|
|
762
|
-
get rid() {
|
|
763
|
-
return __classPrivateFieldGet(this, _Resource_rid, "f");
|
|
764
|
-
}
|
|
765
|
-
constructor(rid) {
|
|
766
|
-
_Resource_rid.set(this, void 0);
|
|
767
|
-
__classPrivateFieldSet(this, _Resource_rid, rid, "f");
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* Destroys and cleans up this resource from memory.
|
|
771
|
-
* **You should not call any method on this object anymore and should drop any reference to it.**
|
|
772
|
-
*/
|
|
773
|
-
async close() {
|
|
774
|
-
return invoke("plugin:resources|close", {
|
|
775
|
-
rid: this.rid
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
_Resource_rid = /* @__PURE__ */ new WeakMap();
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
|
|
783
2253
|
// node_modules/@tauri-apps/api/dpi.js
|
|
784
2254
|
var LogicalSize, PhysicalSize, Size, LogicalPosition, PhysicalPosition, Position;
|
|
785
2255
|
var init_dpi = __esm({
|
|
@@ -1294,8 +2764,8 @@ var init_window = __esm({
|
|
|
1294
2764
|
async listen(event, handler) {
|
|
1295
2765
|
if (this._handleTauriEvent(event, handler)) {
|
|
1296
2766
|
return () => {
|
|
1297
|
-
const
|
|
1298
|
-
|
|
2767
|
+
const listeners2 = this.listeners[event];
|
|
2768
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
1299
2769
|
};
|
|
1300
2770
|
}
|
|
1301
2771
|
return listen(event, handler, {
|
|
@@ -1324,8 +2794,8 @@ var init_window = __esm({
|
|
|
1324
2794
|
async once(event, handler) {
|
|
1325
2795
|
if (this._handleTauriEvent(event, handler)) {
|
|
1326
2796
|
return () => {
|
|
1327
|
-
const
|
|
1328
|
-
|
|
2797
|
+
const listeners2 = this.listeners[event];
|
|
2798
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
1329
2799
|
};
|
|
1330
2800
|
}
|
|
1331
2801
|
return once(event, handler, {
|
|
@@ -2993,8 +4463,8 @@ var init_webview = __esm({
|
|
|
2993
4463
|
async listen(event, handler) {
|
|
2994
4464
|
if (this._handleTauriEvent(event, handler)) {
|
|
2995
4465
|
return () => {
|
|
2996
|
-
const
|
|
2997
|
-
|
|
4466
|
+
const listeners2 = this.listeners[event];
|
|
4467
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
2998
4468
|
};
|
|
2999
4469
|
}
|
|
3000
4470
|
return listen(event, handler, {
|
|
@@ -3023,8 +4493,8 @@ var init_webview = __esm({
|
|
|
3023
4493
|
async once(event, handler) {
|
|
3024
4494
|
if (this._handleTauriEvent(event, handler)) {
|
|
3025
4495
|
return () => {
|
|
3026
|
-
const
|
|
3027
|
-
|
|
4496
|
+
const listeners2 = this.listeners[event];
|
|
4497
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3028
4498
|
};
|
|
3029
4499
|
}
|
|
3030
4500
|
return once(event, handler, {
|
|
@@ -3492,8 +4962,8 @@ var init_webviewWindow = __esm({
|
|
|
3492
4962
|
async listen(event, handler) {
|
|
3493
4963
|
if (this._handleTauriEvent(event, handler)) {
|
|
3494
4964
|
return () => {
|
|
3495
|
-
const
|
|
3496
|
-
|
|
4965
|
+
const listeners2 = this.listeners[event];
|
|
4966
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3497
4967
|
};
|
|
3498
4968
|
}
|
|
3499
4969
|
return listen(event, handler, {
|
|
@@ -3522,8 +4992,8 @@ var init_webviewWindow = __esm({
|
|
|
3522
4992
|
async once(event, handler) {
|
|
3523
4993
|
if (this._handleTauriEvent(event, handler)) {
|
|
3524
4994
|
return () => {
|
|
3525
|
-
const
|
|
3526
|
-
|
|
4995
|
+
const listeners2 = this.listeners[event];
|
|
4996
|
+
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3527
4997
|
};
|
|
3528
4998
|
}
|
|
3529
4999
|
return once(event, handler, {
|
|
@@ -3582,8 +5052,8 @@ function subscribeGoogleLogin2(cb) {
|
|
|
3582
5052
|
var googleInitialized, googleListeners, authWindowRef, handleCallback, initializeGoogleLogin, createGoogleLogin2;
|
|
3583
5053
|
var init_useGoogleAuth = __esm({
|
|
3584
5054
|
"src/services/useGoogleAuth.js"() {
|
|
3585
|
-
init_esm();
|
|
3586
5055
|
init_esm2();
|
|
5056
|
+
init_esm3();
|
|
3587
5057
|
init_webviewWindow();
|
|
3588
5058
|
init_usePlatform();
|
|
3589
5059
|
googleInitialized = false;
|
|
@@ -3754,8 +5224,8 @@ function PaymentHandler({
|
|
|
3754
5224
|
var paymentInitialized, paymentStatusListeners, paymentWindowRef, logs, addLog, handlePaymentCallback, initializePayment, createPayment;
|
|
3755
5225
|
var init_useYocoPayment = __esm({
|
|
3756
5226
|
"src/services/useYocoPayment.js"() {
|
|
3757
|
-
init_esm();
|
|
3758
5227
|
init_esm2();
|
|
5228
|
+
init_esm3();
|
|
3759
5229
|
init_webviewWindow();
|
|
3760
5230
|
init_usePlatform();
|
|
3761
5231
|
paymentInitialized = false;
|
|
@@ -3869,6 +5339,537 @@ var init_useYocoPayment = __esm({
|
|
|
3869
5339
|
}
|
|
3870
5340
|
});
|
|
3871
5341
|
|
|
5342
|
+
// src/services/useEntities.js
|
|
5343
|
+
init_usePlatform();
|
|
5344
|
+
var isMobile = platform === "android" || platform === "ios";
|
|
5345
|
+
var isDesktop = platform === "tauri";
|
|
5346
|
+
var sqliteReady = null;
|
|
5347
|
+
var sqliteDb = null;
|
|
5348
|
+
function dbName(appId = "default") {
|
|
5349
|
+
return `tevroc_${String(appId || "default").replace(/[^a-z0-9_-]/gi, "_")}`;
|
|
5350
|
+
}
|
|
5351
|
+
function memoryKey(appId) {
|
|
5352
|
+
return `tevroc_native_db_${appId || "default"}`;
|
|
5353
|
+
}
|
|
5354
|
+
async function openSqlite(appId) {
|
|
5355
|
+
if (sqliteDb) return sqliteDb;
|
|
5356
|
+
if (sqliteReady) return sqliteReady;
|
|
5357
|
+
sqliteReady = (async () => {
|
|
5358
|
+
if (isMobile) {
|
|
5359
|
+
const mod = await Promise.resolve().then(() => (init_esm(), esm_exports));
|
|
5360
|
+
const sqlite = new mod.SQLiteConnection(mod.CapacitorSQLite);
|
|
5361
|
+
const name = dbName(appId);
|
|
5362
|
+
const db = await sqlite.createConnection(name, false, "no-encryption", 1, false);
|
|
5363
|
+
await db.open();
|
|
5364
|
+
await db.execute("CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)");
|
|
5365
|
+
return {
|
|
5366
|
+
async get(key) {
|
|
5367
|
+
const res = await db.query("SELECT value FROM kv WHERE key = ? LIMIT 1", [key]);
|
|
5368
|
+
return res.values?.[0]?.value ?? null;
|
|
5369
|
+
},
|
|
5370
|
+
async set(key, value) {
|
|
5371
|
+
await db.run("INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)", [key, value]);
|
|
5372
|
+
}
|
|
5373
|
+
};
|
|
5374
|
+
}
|
|
5375
|
+
if (isDesktop) {
|
|
5376
|
+
const mod = await Promise.resolve().then(() => (init_dist_js(), dist_js_exports));
|
|
5377
|
+
const Database2 = mod.default || mod.Database;
|
|
5378
|
+
const db = await Database2.load(`sqlite:${dbName(appId)}.db`);
|
|
5379
|
+
await db.execute("CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)");
|
|
5380
|
+
return {
|
|
5381
|
+
async get(key) {
|
|
5382
|
+
const rows = await db.select("SELECT value FROM kv WHERE key = ? LIMIT 1", [key]);
|
|
5383
|
+
return rows?.[0]?.value ?? null;
|
|
5384
|
+
},
|
|
5385
|
+
async set(key, value) {
|
|
5386
|
+
await db.execute("INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)", [key, value]);
|
|
5387
|
+
}
|
|
5388
|
+
};
|
|
5389
|
+
}
|
|
5390
|
+
return null;
|
|
5391
|
+
})();
|
|
5392
|
+
sqliteDb = await sqliteReady;
|
|
5393
|
+
return sqliteDb;
|
|
5394
|
+
}
|
|
5395
|
+
async function readDB(appId) {
|
|
5396
|
+
try {
|
|
5397
|
+
const db = await openSqlite(appId);
|
|
5398
|
+
if (db) return parseStoredJson(await db.get("db"));
|
|
5399
|
+
return parseStoredJson(globalThis.localStorage?.getItem(memoryKey(appId)));
|
|
5400
|
+
} catch (error) {
|
|
5401
|
+
console.warn("Tevroc native SQLite unavailable; using localStorage fallback", error);
|
|
5402
|
+
return parseStoredJson(globalThis.localStorage?.getItem(memoryKey(appId)));
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
async function writeDB(appId, data) {
|
|
5406
|
+
const json = JSON.stringify(data || {}, null, 2);
|
|
5407
|
+
try {
|
|
5408
|
+
const db = await openSqlite(appId);
|
|
5409
|
+
if (db) {
|
|
5410
|
+
await db.set("db", json);
|
|
5411
|
+
return;
|
|
5412
|
+
}
|
|
5413
|
+
} catch (error) {
|
|
5414
|
+
console.warn("Tevroc native SQLite write failed; using localStorage fallback", error);
|
|
5415
|
+
}
|
|
5416
|
+
globalThis.localStorage?.setItem(memoryKey(appId), json);
|
|
5417
|
+
}
|
|
5418
|
+
function parseStoredJson(value) {
|
|
5419
|
+
if (!value) return {};
|
|
5420
|
+
if (typeof value === "object") return value;
|
|
5421
|
+
if (typeof value !== "string") return {};
|
|
5422
|
+
try {
|
|
5423
|
+
return JSON.parse(value);
|
|
5424
|
+
} catch {
|
|
5425
|
+
}
|
|
5426
|
+
try {
|
|
5427
|
+
return JSON.parse(atob(value));
|
|
5428
|
+
} catch {
|
|
5429
|
+
}
|
|
5430
|
+
return {};
|
|
5431
|
+
}
|
|
5432
|
+
function resolvePath(obj, path, create = false) {
|
|
5433
|
+
const parts = String(path || "").split("/").filter(Boolean);
|
|
5434
|
+
let ref = obj;
|
|
5435
|
+
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
5436
|
+
const part = parts[i];
|
|
5437
|
+
if (!(part in ref)) {
|
|
5438
|
+
if (!create) return null;
|
|
5439
|
+
ref[part] = {};
|
|
5440
|
+
}
|
|
5441
|
+
ref = ref[part];
|
|
5442
|
+
}
|
|
5443
|
+
return { ref, key: parts.at(-1) };
|
|
5444
|
+
}
|
|
5445
|
+
function deepMerge(target = {}, source = {}) {
|
|
5446
|
+
for (const key of Object.keys(source || {})) {
|
|
5447
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
5448
|
+
if (!target[key] || typeof target[key] !== "object") target[key] = {};
|
|
5449
|
+
deepMerge(target[key], source[key]);
|
|
5450
|
+
} else {
|
|
5451
|
+
target[key] = source[key];
|
|
5452
|
+
}
|
|
5453
|
+
}
|
|
5454
|
+
return target;
|
|
5455
|
+
}
|
|
5456
|
+
var listeners = /* @__PURE__ */ new Map();
|
|
5457
|
+
var lastSnapshot = /* @__PURE__ */ new Map();
|
|
5458
|
+
function isEqual(a, b) {
|
|
5459
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
5460
|
+
}
|
|
5461
|
+
function snap(value) {
|
|
5462
|
+
return {
|
|
5463
|
+
exists: () => value !== void 0 && value !== null,
|
|
5464
|
+
val: () => value ?? null
|
|
5465
|
+
};
|
|
5466
|
+
}
|
|
5467
|
+
function createNativeStore(appId = "default") {
|
|
5468
|
+
async function getValue(pathRef) {
|
|
5469
|
+
const db = await readDB(appId);
|
|
5470
|
+
const path = pathRef?.path || pathRef || "";
|
|
5471
|
+
const parts = String(path).split("/").filter(Boolean);
|
|
5472
|
+
let value = db;
|
|
5473
|
+
for (const part of parts) {
|
|
5474
|
+
value = value?.[part];
|
|
5475
|
+
if (value === void 0) break;
|
|
5476
|
+
}
|
|
5477
|
+
return snap(value);
|
|
5478
|
+
}
|
|
5479
|
+
async function setValue(pathRef, value) {
|
|
5480
|
+
const db = await readDB(appId);
|
|
5481
|
+
const path = pathRef?.path || pathRef || "";
|
|
5482
|
+
const node = resolvePath(db, path, true);
|
|
5483
|
+
if (!node) return;
|
|
5484
|
+
if (isEqual(node.ref[node.key], value)) return;
|
|
5485
|
+
node.ref[node.key] = value;
|
|
5486
|
+
await writeDB(appId, db);
|
|
5487
|
+
}
|
|
5488
|
+
async function updateValue(pathRef, value) {
|
|
5489
|
+
const db = await readDB(appId);
|
|
5490
|
+
const path = pathRef?.path || pathRef || "";
|
|
5491
|
+
const node = resolvePath(db, path, true);
|
|
5492
|
+
if (!node) return;
|
|
5493
|
+
const prev = node.ref[node.key] || {};
|
|
5494
|
+
const next = deepMerge(structuredClone(prev), value);
|
|
5495
|
+
if (isEqual(prev, next)) return;
|
|
5496
|
+
node.ref[node.key] = next;
|
|
5497
|
+
await writeDB(appId, db);
|
|
5498
|
+
}
|
|
5499
|
+
async function removeValue(pathRef) {
|
|
5500
|
+
const db = await readDB(appId);
|
|
5501
|
+
const path = pathRef?.path || pathRef || "";
|
|
5502
|
+
const node = resolvePath(db, path);
|
|
5503
|
+
if (!node || node.ref[node.key] === void 0) return;
|
|
5504
|
+
delete node.ref[node.key];
|
|
5505
|
+
await writeDB(appId, db);
|
|
5506
|
+
}
|
|
5507
|
+
function ref(_db, path) {
|
|
5508
|
+
return { path };
|
|
5509
|
+
}
|
|
5510
|
+
function child(pathRef, childPath) {
|
|
5511
|
+
const base = pathRef?.path || pathRef || "";
|
|
5512
|
+
return { path: `${base}/${childPath}` };
|
|
5513
|
+
}
|
|
5514
|
+
function push(pathRef) {
|
|
5515
|
+
const path = pathRef?.path || pathRef || "";
|
|
5516
|
+
const key = `id_${crypto.randomUUID?.().replaceAll("-", "") || Math.random().toString(36).slice(2)}`;
|
|
5517
|
+
return { key, path: `${path}/${key}` };
|
|
5518
|
+
}
|
|
5519
|
+
function onValue(pathRef, callback) {
|
|
5520
|
+
const path = pathRef?.path || pathRef || "";
|
|
5521
|
+
getValue(path).then((snapshot) => {
|
|
5522
|
+
lastSnapshot.set(path, snapshot.val());
|
|
5523
|
+
callback(snapshot);
|
|
5524
|
+
});
|
|
5525
|
+
if (listeners.has(path)) {
|
|
5526
|
+
listeners.get(path).add(callback);
|
|
5527
|
+
return () => listeners.get(path)?.delete(callback);
|
|
5528
|
+
}
|
|
5529
|
+
const group = /* @__PURE__ */ new Set([callback]);
|
|
5530
|
+
group.interval = setInterval(async () => {
|
|
5531
|
+
const snapshot = await getValue(path);
|
|
5532
|
+
const value = snapshot.val();
|
|
5533
|
+
if (isEqual(lastSnapshot.get(path), value)) return;
|
|
5534
|
+
lastSnapshot.set(path, value);
|
|
5535
|
+
group.forEach((cb) => cb(snapshot));
|
|
5536
|
+
}, 1e3);
|
|
5537
|
+
listeners.set(path, group);
|
|
5538
|
+
return () => {
|
|
5539
|
+
group.delete(callback);
|
|
5540
|
+
if (group.size === 0) {
|
|
5541
|
+
clearInterval(group.interval);
|
|
5542
|
+
listeners.delete(path);
|
|
5543
|
+
lastSnapshot.delete(path);
|
|
5544
|
+
}
|
|
5545
|
+
};
|
|
5546
|
+
}
|
|
5547
|
+
function off(pathRef, _event, callback) {
|
|
5548
|
+
const path = pathRef?.path || pathRef || "";
|
|
5549
|
+
if (!listeners.has(path)) return;
|
|
5550
|
+
if (callback) listeners.get(path).delete(callback);
|
|
5551
|
+
}
|
|
5552
|
+
return {
|
|
5553
|
+
ref,
|
|
5554
|
+
child,
|
|
5555
|
+
push,
|
|
5556
|
+
get: getValue,
|
|
5557
|
+
set: setValue,
|
|
5558
|
+
update: updateValue,
|
|
5559
|
+
remove: removeValue,
|
|
5560
|
+
onValue,
|
|
5561
|
+
off,
|
|
5562
|
+
serverTimestamp: () => Date.now(),
|
|
5563
|
+
increment: (num = 1) => ({ __increment__: num }),
|
|
5564
|
+
runTransaction: async (pathRef, updater) => {
|
|
5565
|
+
const current = await getValue(pathRef);
|
|
5566
|
+
const updated = await updater(current.val());
|
|
5567
|
+
await setValue(pathRef, updated);
|
|
5568
|
+
return { committed: true, snapshot: snap(updated) };
|
|
5569
|
+
},
|
|
5570
|
+
exportDB: () => readDB(appId),
|
|
5571
|
+
importDB: (data) => writeDB(appId, data || {}),
|
|
5572
|
+
exists: async (pathRef) => (await getValue(pathRef)).exists()
|
|
5573
|
+
};
|
|
5574
|
+
}
|
|
5575
|
+
function nowIso() {
|
|
5576
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
5577
|
+
}
|
|
5578
|
+
function normalizeListArgs(sortOrOptions, limit) {
|
|
5579
|
+
if (sortOrOptions && typeof sortOrOptions === "object") return sortOrOptions;
|
|
5580
|
+
const options = {};
|
|
5581
|
+
if (sortOrOptions) options.sort = sortOrOptions;
|
|
5582
|
+
if (limit !== void 0) options.limit = limit;
|
|
5583
|
+
return options;
|
|
5584
|
+
}
|
|
5585
|
+
function sortRecords(records, sort) {
|
|
5586
|
+
if (!sort) return records;
|
|
5587
|
+
const desc = String(sort).startsWith("-");
|
|
5588
|
+
const field = desc ? String(sort).slice(1) : String(sort);
|
|
5589
|
+
return [...records].sort((a, b) => {
|
|
5590
|
+
const av = a?.[field] ?? "";
|
|
5591
|
+
const bv = b?.[field] ?? "";
|
|
5592
|
+
if (av === bv) return 0;
|
|
5593
|
+
return (av > bv ? 1 : -1) * (desc ? -1 : 1);
|
|
5594
|
+
});
|
|
5595
|
+
}
|
|
5596
|
+
function getFilters(input = {}) {
|
|
5597
|
+
return input.filter || input.filters || input.where || {};
|
|
5598
|
+
}
|
|
5599
|
+
function matchesFilter(record, filter = {}) {
|
|
5600
|
+
return Object.entries(filter).every(([key, expected]) => {
|
|
5601
|
+
const actual = record?.[key];
|
|
5602
|
+
if (expected && typeof expected === "object" && !Array.isArray(expected)) {
|
|
5603
|
+
if ("$eq" in expected && actual !== expected.$eq) return false;
|
|
5604
|
+
if ("$ne" in expected && actual === expected.$ne) return false;
|
|
5605
|
+
if ("$in" in expected && Array.isArray(expected.$in) && !expected.$in.includes(actual)) return false;
|
|
5606
|
+
if ("$contains" in expected && typeof actual === "string" && typeof expected.$contains === "string") return actual.includes(expected.$contains);
|
|
5607
|
+
return true;
|
|
5608
|
+
}
|
|
5609
|
+
return actual === expected;
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
function createEntityApi(store, entity) {
|
|
5613
|
+
const base = `entities/${entity}`;
|
|
5614
|
+
return {
|
|
5615
|
+
list: async (sortOrOptions, limit) => {
|
|
5616
|
+
const options = normalizeListArgs(sortOrOptions, limit);
|
|
5617
|
+
const snapshot = await store.get(base);
|
|
5618
|
+
const rows = Object.values(snapshot.val() || {});
|
|
5619
|
+
const sorted = sortRecords(rows, options.sort);
|
|
5620
|
+
return { data: sorted.slice(options.offset || 0, options.limit ? (options.offset || 0) + options.limit : void 0), limit: options.limit, offset: options.offset || 0 };
|
|
5621
|
+
},
|
|
5622
|
+
get: async (id) => ({ data: (await store.get(`${base}/${id}`)).val() }),
|
|
5623
|
+
create: async (record = {}) => {
|
|
5624
|
+
const id = typeof record.id === "string" ? record.id : `ent_${crypto.randomUUID?.().replaceAll("-", "") || Date.now()}`;
|
|
5625
|
+
const time = nowIso();
|
|
5626
|
+
const data = { ...record, id, createdAt: record.createdAt || time, updatedAt: time, created_date: record.created_date || time, updated_date: time };
|
|
5627
|
+
await store.set(`${base}/${id}`, data);
|
|
5628
|
+
return { data };
|
|
5629
|
+
},
|
|
5630
|
+
update: async (id, patch = {}) => {
|
|
5631
|
+
const existing = (await store.get(`${base}/${id}`)).val() || { id };
|
|
5632
|
+
const time = nowIso();
|
|
5633
|
+
const data = { ...existing, ...patch, id, updatedAt: time, updated_date: time };
|
|
5634
|
+
await store.set(`${base}/${id}`, data);
|
|
5635
|
+
return { data };
|
|
5636
|
+
},
|
|
5637
|
+
delete: async (id) => {
|
|
5638
|
+
await store.remove(`${base}/${id}`);
|
|
5639
|
+
return { deleted: true, id };
|
|
5640
|
+
},
|
|
5641
|
+
query: async (input = {}) => {
|
|
5642
|
+
const options = normalizeListArgs(input, input.limit);
|
|
5643
|
+
const snapshot = await store.get(base);
|
|
5644
|
+
const rows = Object.values(snapshot.val() || {}).filter((record) => matchesFilter(record, getFilters(input)));
|
|
5645
|
+
const sorted = sortRecords(rows, input.sort || options.sort);
|
|
5646
|
+
return { data: sorted.slice(0, input.limit || 200), limit: input.limit };
|
|
5647
|
+
},
|
|
5648
|
+
filter: async (filter = {}, sortOrOptions, limit) => {
|
|
5649
|
+
const options = normalizeListArgs(sortOrOptions, limit);
|
|
5650
|
+
return createEntityApi(store, entity).query({ ...options, filter });
|
|
5651
|
+
},
|
|
5652
|
+
bulkCreate: async (records = []) => ({ inserted: (await Promise.all(records.map((record) => createEntityApi(store, entity).create(record)))).length }),
|
|
5653
|
+
bulkUpdate: async (records = []) => {
|
|
5654
|
+
let updated = 0;
|
|
5655
|
+
for (const record of records) {
|
|
5656
|
+
if (!record?.id) continue;
|
|
5657
|
+
await createEntityApi(store, entity).update(record.id, record);
|
|
5658
|
+
updated += 1;
|
|
5659
|
+
}
|
|
5660
|
+
return { updated };
|
|
5661
|
+
},
|
|
5662
|
+
bulkDelete: async (ids = []) => {
|
|
5663
|
+
for (const id of ids) await store.remove(`${base}/${id}`);
|
|
5664
|
+
return { deleted: ids.length };
|
|
5665
|
+
},
|
|
5666
|
+
import: async (records = []) => ({ imported: (await Promise.all(records.map((record) => createEntityApi(store, entity).create(record)))).length })
|
|
5667
|
+
};
|
|
5668
|
+
}
|
|
5669
|
+
function createNativeEntityRegistry(appId) {
|
|
5670
|
+
const store = createNativeStore(appId);
|
|
5671
|
+
return new Proxy({}, {
|
|
5672
|
+
get(_target, entity) {
|
|
5673
|
+
if (typeof entity !== "string") return void 0;
|
|
5674
|
+
return createEntityApi(store, entity);
|
|
5675
|
+
}
|
|
5676
|
+
});
|
|
5677
|
+
}
|
|
5678
|
+
async function resolveFileContext(store, userId) {
|
|
5679
|
+
const ownedCache = (await store.get(`drive/${userId}`)).val() || {};
|
|
5680
|
+
const collabCache = (await store.get(`collaborators/${userId}`)).val() || {};
|
|
5681
|
+
const result = [];
|
|
5682
|
+
for (const projectId of Object.keys(ownedCache)) {
|
|
5683
|
+
const project = ownedCache[projectId];
|
|
5684
|
+
if (project?.fileId && !project.deleted) {
|
|
5685
|
+
result.push({ fileId: project.fileId, projectId, ownerUid: userId, isOwner: true, isNew: false, collaborators: Object.keys(project.collaborators || {}).filter((key) => key !== userId).length });
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5689
|
+
for (const [projectId, ownersObj] of Object.entries(collabCache || {})) {
|
|
5690
|
+
for (const ownerUid of Object.keys(ownersObj || {})) {
|
|
5691
|
+
const key = `${ownerUid}_${projectId}`;
|
|
5692
|
+
if (seen.has(key)) continue;
|
|
5693
|
+
seen.add(key);
|
|
5694
|
+
const project = (await store.get(`drive/${ownerUid}/${projectId}`)).val();
|
|
5695
|
+
if (!project?.fileId || project.deleted) continue;
|
|
5696
|
+
result.push({ fileId: project.fileId, projectId, ownerUid, isOwner: false, isNew: false, collaborators: 0 });
|
|
5697
|
+
}
|
|
5698
|
+
}
|
|
5699
|
+
return result;
|
|
5700
|
+
}
|
|
5701
|
+
function createNativeFileApi(appId) {
|
|
5702
|
+
const store = createNativeStore(appId);
|
|
5703
|
+
return {
|
|
5704
|
+
saveJsonToDrive: async (filename, jsonData, existingFileId, userId = "local") => {
|
|
5705
|
+
const context = (await resolveFileContext(store, userId)).filter((item) => item.fileId === existingFileId);
|
|
5706
|
+
const isNew = !existingFileId || context.length === 0;
|
|
5707
|
+
const fileId = existingFileId || `file_${Date.now()}`;
|
|
5708
|
+
const ownerUid = isNew ? userId : context[0].ownerUid;
|
|
5709
|
+
const path = `drive/${ownerUid}/${fileId}`;
|
|
5710
|
+
const existing = (await store.get(path)).val() || {};
|
|
5711
|
+
const time = nowIso();
|
|
5712
|
+
await store.set(path, { ...existing, name: filename, data: jsonData, updatedAt: time, createdAt: existing.createdAt || time });
|
|
5713
|
+
await store.set(`files/${ownerUid}/${context[0]?.projectId || fileId}`, { fileId, name: filename, ownerUid, collaborators: existing.collaborators || { [userId]: "admin" }, deleted: false });
|
|
5714
|
+
return { fileId, fileName: filename, webViewLink: `filebase://${path}`, downloadLink: `filebase://${path}` };
|
|
5715
|
+
},
|
|
5716
|
+
readJsonFromDrive: async (fileId, userId = "local") => {
|
|
5717
|
+
const own = (await store.get(`drive/${userId}/${fileId}`)).val();
|
|
5718
|
+
if (own?.data) return own.data;
|
|
5719
|
+
const contexts = await resolveFileContext(store, userId);
|
|
5720
|
+
const context = contexts.find((item) => item.fileId === fileId);
|
|
5721
|
+
if (!context) return {};
|
|
5722
|
+
return (await store.get(`drive/${context.ownerUid}/${fileId}`)).val()?.data || {};
|
|
5723
|
+
},
|
|
5724
|
+
deleteFromDrive: async (fileId, userId = "local") => {
|
|
5725
|
+
const contexts = await resolveFileContext(store, userId);
|
|
5726
|
+
const context = contexts.find((item) => item.fileId === fileId) || { ownerUid: userId };
|
|
5727
|
+
const path = `drive/${context.ownerUid}/${fileId}`;
|
|
5728
|
+
const file = (await store.get(path)).val() || {};
|
|
5729
|
+
await store.set(path, { ...file, deleted: true, deletedAt: nowIso() });
|
|
5730
|
+
},
|
|
5731
|
+
grantDriveAccess: async (fileId, email, role = "reader", userId = "local") => {
|
|
5732
|
+
const contexts = await resolveFileContext(store, userId);
|
|
5733
|
+
const context = contexts.find((item) => item.fileId === fileId);
|
|
5734
|
+
if (!context) return;
|
|
5735
|
+
await store.update(`drive/${context.ownerUid}/${context.projectId}`, { collaborators: { [email]: role } });
|
|
5736
|
+
await store.update(`collaborators/${email}/${context.projectId}`, { [context.ownerUid]: role });
|
|
5737
|
+
},
|
|
5738
|
+
revokeDriveAccess: async (fileId, email, userId = "local") => {
|
|
5739
|
+
const contexts = await resolveFileContext(store, userId);
|
|
5740
|
+
const context = contexts.find((item) => item.fileId === fileId);
|
|
5741
|
+
if (!context) return;
|
|
5742
|
+
const project = (await store.get(`drive/${context.ownerUid}/${context.projectId}`)).val() || {};
|
|
5743
|
+
delete project.collaborators?.[email];
|
|
5744
|
+
await store.set(`drive/${context.ownerUid}/${context.projectId}`, project);
|
|
5745
|
+
await store.remove(`collaborators/${email}/${context.projectId}/${context.ownerUid}`);
|
|
5746
|
+
},
|
|
5747
|
+
ref: store.ref,
|
|
5748
|
+
child: store.child,
|
|
5749
|
+
push: store.push,
|
|
5750
|
+
get: store.get,
|
|
5751
|
+
set: store.set,
|
|
5752
|
+
update: store.update,
|
|
5753
|
+
remove: store.remove,
|
|
5754
|
+
onValue: store.onValue,
|
|
5755
|
+
off: store.off,
|
|
5756
|
+
serverTimestamp: store.serverTimestamp,
|
|
5757
|
+
increment: store.increment,
|
|
5758
|
+
runTransaction: store.runTransaction,
|
|
5759
|
+
exportDB: store.exportDB,
|
|
5760
|
+
importDB: store.importDB,
|
|
5761
|
+
exists: store.exists
|
|
5762
|
+
};
|
|
5763
|
+
}
|
|
5764
|
+
var DRIVE_API = "https://www.googleapis.com/drive/v3";
|
|
5765
|
+
var UPLOAD_API = "https://www.googleapis.com/upload/drive/v3";
|
|
5766
|
+
function getGoogleToken() {
|
|
5767
|
+
return globalThis.sessionStorage?.getItem("gAccessToken") || globalThis.localStorage?.getItem("gAccessToken");
|
|
5768
|
+
}
|
|
5769
|
+
function createGoogleDriveApi(appId) {
|
|
5770
|
+
const localFiles = createNativeFileApi(appId);
|
|
5771
|
+
return {
|
|
5772
|
+
...localFiles,
|
|
5773
|
+
saveJsonToDrive: async (filename, jsonData, existingFileId, userId) => {
|
|
5774
|
+
const token = getGoogleToken();
|
|
5775
|
+
if (!token) return localFiles.saveJsonToDrive(filename, jsonData, existingFileId, userId);
|
|
5776
|
+
const content = JSON.stringify(jsonData, null, 2);
|
|
5777
|
+
const blob = new Blob([content], { type: "application/json" });
|
|
5778
|
+
const form = new FormData();
|
|
5779
|
+
form.append("metadata", new Blob([JSON.stringify({ name: `${filename}.json`, mimeType: "application/json" })], { type: "application/json" }));
|
|
5780
|
+
form.append("file", blob);
|
|
5781
|
+
const url = existingFileId ? `${UPLOAD_API}/files/${existingFileId}?uploadType=multipart` : `${UPLOAD_API}/files?uploadType=multipart`;
|
|
5782
|
+
const res = await fetch(url, { method: existingFileId ? "PATCH" : "POST", headers: { Authorization: `Bearer ${token}` }, body: form });
|
|
5783
|
+
if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error?.message || "Drive upload failed");
|
|
5784
|
+
const file = await res.json();
|
|
5785
|
+
return { fileId: file.id, fileName: file.name, webViewLink: `https://drive.google.com/file/d/${file.id}/view`, downloadLink: `${DRIVE_API}/files/${file.id}?alt=media` };
|
|
5786
|
+
},
|
|
5787
|
+
readJsonFromDrive: async (fileId, userId) => {
|
|
5788
|
+
const token = getGoogleToken();
|
|
5789
|
+
if (!token) return localFiles.readJsonFromDrive(fileId, userId);
|
|
5790
|
+
const res = await fetch(`${DRIVE_API}/files/${fileId}?alt=media`, { headers: { Authorization: `Bearer ${token}` } });
|
|
5791
|
+
if (!res.ok) throw new Error("Could not read file from Drive");
|
|
5792
|
+
return res.json();
|
|
5793
|
+
},
|
|
5794
|
+
deleteFromDrive: async (fileId, userId) => {
|
|
5795
|
+
const token = getGoogleToken();
|
|
5796
|
+
if (!token) return localFiles.deleteFromDrive(fileId, userId);
|
|
5797
|
+
const res = await fetch(`${DRIVE_API}/files/${fileId}`, { method: "DELETE", headers: { Authorization: `Bearer ${token}` } });
|
|
5798
|
+
if (!res.ok && res.status !== 404) throw new Error("Failed to delete file from Drive");
|
|
5799
|
+
}
|
|
5800
|
+
};
|
|
5801
|
+
}
|
|
5802
|
+
function createProjectStore(appId) {
|
|
5803
|
+
const store = createNativeStore(appId);
|
|
5804
|
+
const encodeEmail = (email) => typeof email === "string" && email ? email.replace(/\./g, "_").replace(/@/g, "__at__") : "";
|
|
5805
|
+
return {
|
|
5806
|
+
encodeEmail,
|
|
5807
|
+
upsertUser: async (user) => {
|
|
5808
|
+
await store.set(`users/${user.uid}`, { email: user.email, displayName: user.displayName, photoURL: user.photoURL || "" });
|
|
5809
|
+
await store.set(`usersByEmail/${encodeEmail(user.email)}`, user.uid);
|
|
5810
|
+
},
|
|
5811
|
+
resolveOrCreateUser: async (email) => (await store.get(`usersByEmail/${encodeEmail(email)}`)).val() || `email:${encodeEmail(email)}`,
|
|
5812
|
+
saveProjectMeta: (ownerUid, projectId, meta) => store.set(`projects/${ownerUid}/${projectId}`, meta),
|
|
5813
|
+
getProject: async (ownerUid, projectId) => (await store.get(`projects/${ownerUid}/${projectId}`)).val(),
|
|
5814
|
+
deleteProject: async (ownerUid, projectId) => store.remove(`projects/${ownerUid}/${projectId}`),
|
|
5815
|
+
addCollaborator: (ownerUid, projectId, uid, role) => store.set(`projects/${ownerUid}/${projectId}/collaborators/${uid}`, role),
|
|
5816
|
+
removeCollaborator: (ownerUid, projectId, uid) => store.remove(`projects/${ownerUid}/${projectId}/collaborators/${uid}`),
|
|
5817
|
+
getUser: async (uid) => (await store.get(`users/${uid}`)).val(),
|
|
5818
|
+
subscribeProjects: (currentUid, callback, email) => {
|
|
5819
|
+
const emailKey = `email:${encodeEmail(email?.trim().toLowerCase())}`;
|
|
5820
|
+
let ownedCache = {};
|
|
5821
|
+
let collabCache = {};
|
|
5822
|
+
let collabCache2 = {};
|
|
5823
|
+
const emit2 = async () => {
|
|
5824
|
+
const visible = [];
|
|
5825
|
+
const loaded = /* @__PURE__ */ new Set();
|
|
5826
|
+
Object.entries(ownedCache || {}).forEach(([projectId, project]) => {
|
|
5827
|
+
if (!project || project.deleted) return;
|
|
5828
|
+
visible.push({ ...project, projectId, ownerUid: currentUid, isOwner: true });
|
|
5829
|
+
loaded.add(`${currentUid}_${projectId}`);
|
|
5830
|
+
});
|
|
5831
|
+
for (const cache of [collabCache, collabCache2]) {
|
|
5832
|
+
for (const [projectId, ownersObj] of Object.entries(cache || {})) {
|
|
5833
|
+
for (const ownerUid of Object.keys(ownersObj || {})) {
|
|
5834
|
+
const key = `${ownerUid}_${projectId}`;
|
|
5835
|
+
if (loaded.has(key)) continue;
|
|
5836
|
+
loaded.add(key);
|
|
5837
|
+
const project = (await store.get(`projects/${ownerUid}/${projectId}`)).val();
|
|
5838
|
+
if (project && !project.deleted) visible.push({ ...project, projectId, ownerUid, isOwner: false });
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
callback(visible);
|
|
5843
|
+
};
|
|
5844
|
+
const unsub1 = store.onValue(`projects/${currentUid}`, (snapshot) => {
|
|
5845
|
+
ownedCache = snapshot.val() || {};
|
|
5846
|
+
emit2();
|
|
5847
|
+
});
|
|
5848
|
+
const unsub2 = store.onValue(`collaborators/${currentUid}`, (snapshot) => {
|
|
5849
|
+
collabCache = snapshot.val() || {};
|
|
5850
|
+
emit2();
|
|
5851
|
+
});
|
|
5852
|
+
const unsub3 = store.onValue(`collaborators/${emailKey}`, (snapshot) => {
|
|
5853
|
+
collabCache2 = snapshot.val() || {};
|
|
5854
|
+
emit2();
|
|
5855
|
+
});
|
|
5856
|
+
return () => {
|
|
5857
|
+
unsub1?.();
|
|
5858
|
+
unsub2?.();
|
|
5859
|
+
unsub3?.();
|
|
5860
|
+
};
|
|
5861
|
+
},
|
|
5862
|
+
subscribePresence: (roomId, uid, userInfo, callback) => {
|
|
5863
|
+
store.set(`presence/${roomId}/${uid}`, { ...userInfo, ts: Date.now() });
|
|
5864
|
+
const unsub = store.onValue(`presence/${roomId}`, (snapshot) => callback(Object.values(snapshot.val() || {})));
|
|
5865
|
+
return () => {
|
|
5866
|
+
store.remove(`presence/${roomId}/${uid}`);
|
|
5867
|
+
unsub?.();
|
|
5868
|
+
};
|
|
5869
|
+
}
|
|
5870
|
+
};
|
|
5871
|
+
}
|
|
5872
|
+
|
|
3872
5873
|
// src/index.js
|
|
3873
5874
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
3874
5875
|
var platformModule = null;
|
|
@@ -3914,6 +5915,7 @@ var TevrocClient = class {
|
|
|
3914
5915
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
3915
5916
|
this.appId = options.appId;
|
|
3916
5917
|
this.appName = options.appName;
|
|
5918
|
+
this.isNative = options.isNative ?? false;
|
|
3917
5919
|
this.transport = options.axios ?? null;
|
|
3918
5920
|
this.fetch = options.fetch ?? globalThis.fetch;
|
|
3919
5921
|
if (!this.transport && typeof this.fetch !== "function") {
|
|
@@ -3923,7 +5925,7 @@ var TevrocClient = class {
|
|
|
3923
5925
|
this.defaultHeaders = normalizeHeaders(options.headers);
|
|
3924
5926
|
this.token = options.token ?? null;
|
|
3925
5927
|
this.auth = createAuthApi(this);
|
|
3926
|
-
this.entities = createEntityRegistry(this);
|
|
5928
|
+
this.entities = this.isNative ? createNativeEntityRegistry(this.appId) : createEntityRegistry(this);
|
|
3927
5929
|
this.functions = createFunctionRegistry(this);
|
|
3928
5930
|
this.integrations = createIntegrationApi(this);
|
|
3929
5931
|
this.agents = createAgentRegistry(this);
|
|
@@ -3931,7 +5933,13 @@ var TevrocClient = class {
|
|
|
3931
5933
|
this.connectors = createConnectorApi(this);
|
|
3932
5934
|
this.customIntegrations = createCustomIntegrationRegistry(this);
|
|
3933
5935
|
this.sso = createSsoApi(this);
|
|
3934
|
-
this.files = createFileApi(this);
|
|
5936
|
+
this.files = this.isNative ? createNativeFileApi(this.appId) : createFileApi(this);
|
|
5937
|
+
this.native = {
|
|
5938
|
+
store: createNativeStore(this.appId),
|
|
5939
|
+
files: createNativeFileApi(this.appId),
|
|
5940
|
+
googleDrive: createGoogleDriveApi(this.appId),
|
|
5941
|
+
projects: createProjectStore(this.appId)
|
|
5942
|
+
};
|
|
3935
5943
|
this.payments = createPaymentApi(this);
|
|
3936
5944
|
this.platform = createPlatformApi(this);
|
|
3937
5945
|
}
|
|
@@ -4083,6 +6091,10 @@ function createAuthApi(client) {
|
|
|
4083
6091
|
return result;
|
|
4084
6092
|
},
|
|
4085
6093
|
loginViaEmailPassword: (email, password) => client.auth.login({ email, password }),
|
|
6094
|
+
loginWithGoogle: (input) => client.request("/auth/google", { method: "POST", body: input, auth: false }).then((result) => {
|
|
6095
|
+
if (result.token) client.setToken(result.token);
|
|
6096
|
+
return result;
|
|
6097
|
+
}),
|
|
4086
6098
|
async logout() {
|
|
4087
6099
|
const result = await client.request("/auth/logout", { method: "POST" });
|
|
4088
6100
|
client.clearToken();
|
|
@@ -4101,12 +6113,12 @@ function createEntityRegistry(client) {
|
|
|
4101
6113
|
{
|
|
4102
6114
|
get(_target, entity) {
|
|
4103
6115
|
if (typeof entity !== "string") return void 0;
|
|
4104
|
-
return
|
|
6116
|
+
return createEntityApi2(client, entity);
|
|
4105
6117
|
}
|
|
4106
6118
|
}
|
|
4107
6119
|
);
|
|
4108
6120
|
}
|
|
4109
|
-
function
|
|
6121
|
+
function createEntityApi2(client, entity) {
|
|
4110
6122
|
const base = `/entities/${encodeURIComponent(entity)}`;
|
|
4111
6123
|
return {
|
|
4112
6124
|
list: (options) => client.request(base, { query: options }),
|