mol_db 0.0.229 → 0.0.232

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/node.esm.js CHANGED
@@ -79,240 +79,6 @@ require = (req => Object.assign(function require(name) {
79
79
  ;
80
80
  "use strict";
81
81
  var $;
82
- (function ($) {
83
- $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
84
- })($ || ($ = {}));
85
- //mol/dom/context/context.node.ts
86
- ;
87
- "use strict";
88
- var $;
89
- (function ($) {
90
- function $mol_db_response(request) {
91
- return new Promise((done, fail) => {
92
- request.onerror = () => fail(new Error(request.error.message));
93
- request.onsuccess = () => done(request.result);
94
- });
95
- }
96
- $.$mol_db_response = $mol_db_response;
97
- })($ || ($ = {}));
98
- //mol/db/response/response.ts
99
- ;
100
- "use strict";
101
- var $;
102
- (function ($) {
103
- async function $mol_db(name, ...migrations) {
104
- const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
105
- request.onupgradeneeded = event => {
106
- migrations.splice(0, event.oldVersion - 1);
107
- const transaction = new $mol_db_transaction(request.transaction);
108
- for (const migrate of migrations)
109
- migrate(transaction);
110
- };
111
- const db = await $mol_db_response(request);
112
- return new $mol_db_database(db);
113
- }
114
- $.$mol_db = $mol_db;
115
- })($ || ($ = {}));
116
- //mol/db/db.ts
117
- ;
118
- "use strict";
119
- var $;
120
- (function ($) {
121
- class $mol_db_store {
122
- native;
123
- constructor(native) {
124
- this.native = native;
125
- }
126
- get name() {
127
- return this.native.name;
128
- }
129
- get path() {
130
- return this.native.keyPath;
131
- }
132
- get incremental() {
133
- return this.native.autoIncrement;
134
- }
135
- get indexes() {
136
- return new Proxy({}, {
137
- ownKeys: () => [...this.native.indexNames],
138
- has: (_, name) => this.native.indexNames.contains(name),
139
- get: (_, name) => new $mol_db_index(this.native.index(name))
140
- });
141
- }
142
- index_make(name, path = [], unique = false, multiEntry = false) {
143
- return this.native.createIndex(name, path, { multiEntry, unique });
144
- }
145
- index_drop(name) {
146
- this.native.deleteIndex(name);
147
- return this;
148
- }
149
- get transaction() {
150
- return new $mol_db_transaction(this.native.transaction);
151
- }
152
- get db() {
153
- return this.transaction.db;
154
- }
155
- clear() {
156
- return $mol_db_response(this.native.clear());
157
- }
158
- count(keys) {
159
- return $mol_db_response(this.native.count(keys));
160
- }
161
- put(doc, key) {
162
- return $mol_db_response(this.native.put(doc, key));
163
- }
164
- get(key) {
165
- return $mol_db_response(this.native.get(key));
166
- }
167
- select(key, count) {
168
- return $mol_db_response(this.native.getAll(key, count));
169
- }
170
- drop(keys) {
171
- return $mol_db_response(this.native.delete(keys));
172
- }
173
- }
174
- $.$mol_db_store = $mol_db_store;
175
- })($ || ($ = {}));
176
- //mol/db/store/store.ts
177
- ;
178
- "use strict";
179
- //mol/db/store/store_schema.ts
180
- ;
181
- "use strict";
182
- var $;
183
- (function ($) {
184
- $mol_dom_context.indexedDB = $node['fake-indexeddb'];
185
- })($ || ($ = {}));
186
- //mol/db/db.node.ts
187
- ;
188
- "use strict";
189
- //mol/db/db_schema.ts
190
- ;
191
- "use strict";
192
- var $;
193
- (function ($) {
194
- class $mol_db_database {
195
- native;
196
- constructor(native) {
197
- this.native = native;
198
- }
199
- get name() {
200
- return this.native.name;
201
- }
202
- get version() {
203
- return this.native.version;
204
- }
205
- get stores() {
206
- return [...this.native.objectStoreNames];
207
- }
208
- read(...names) {
209
- return new $mol_db_transaction(this.native.transaction(names, 'readonly')).stores;
210
- }
211
- change(...names) {
212
- return new $mol_db_transaction(this.native.transaction(names, 'readwrite'));
213
- }
214
- kill() {
215
- this.native.close();
216
- const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
217
- request.onblocked = console.error;
218
- return $mol_db_response(request).then(() => { });
219
- }
220
- destructor() {
221
- this.native.close();
222
- }
223
- }
224
- $.$mol_db_database = $mol_db_database;
225
- })($ || ($ = {}));
226
- //mol/db/database/database.ts
227
- ;
228
- "use strict";
229
- var $;
230
- (function ($) {
231
- class $mol_db_transaction {
232
- native;
233
- constructor(native) {
234
- this.native = native;
235
- }
236
- get stores() {
237
- return new Proxy({}, {
238
- ownKeys: () => [...this.native.objectStoreNames],
239
- has: (_, name) => this.native.objectStoreNames.contains(name),
240
- get: (_, name) => new $mol_db_store(this.native.objectStore(name)),
241
- });
242
- }
243
- store_make(name) {
244
- return this.native.db.createObjectStore(name, { autoIncrement: true });
245
- }
246
- store_drop(name) {
247
- this.native.db.deleteObjectStore(name);
248
- return this;
249
- }
250
- abort() {
251
- this.native.abort();
252
- }
253
- commit() {
254
- this.native.commit();
255
- return new Promise((done, fail) => {
256
- this.native.onerror = () => fail(new Error(this.native.error.message));
257
- this.native.oncomplete = () => done();
258
- });
259
- }
260
- get db() {
261
- return new $mol_db_database(this.native.db);
262
- }
263
- }
264
- $.$mol_db_transaction = $mol_db_transaction;
265
- })($ || ($ = {}));
266
- //mol/db/transaction/transaction.ts
267
- ;
268
- "use strict";
269
- var $;
270
- (function ($) {
271
- class $mol_db_index {
272
- native;
273
- constructor(native) {
274
- this.native = native;
275
- }
276
- get name() {
277
- return this.native.name;
278
- }
279
- get paths() {
280
- return this.native.keyPath;
281
- }
282
- get unique() {
283
- return this.native.unique;
284
- }
285
- get multiple() {
286
- return this.native.multiEntry;
287
- }
288
- get store() {
289
- return new $mol_db_store(this.native.objectStore);
290
- }
291
- get transaction() {
292
- return this.store.transaction;
293
- }
294
- get db() {
295
- return this.store.db;
296
- }
297
- count(keys) {
298
- return $mol_db_response(this.native.count(keys));
299
- }
300
- get(key) {
301
- return $mol_db_response(this.native.get(key));
302
- }
303
- select(key, count) {
304
- return $mol_db_response(this.native.getAll(key, count));
305
- }
306
- }
307
- $.$mol_db_index = $mol_db_index;
308
- })($ || ($ = {}));
309
- //mol/db/index/index.ts
310
- ;
311
- "use strict";
312
- //mol/db/index/index_schema.ts
313
- ;
314
- "use strict";
315
- var $;
316
82
  (function ($) {
317
83
  function $mol_log3_area_lazy(event) {
318
84
  const self = this;
@@ -936,5 +702,239 @@ var $;
936
702
  })($ || ($ = {}));
937
703
  //mol/exec/exec.node.ts
938
704
  ;
705
+ "use strict";
706
+ var $;
707
+ (function ($) {
708
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
709
+ })($ || ($ = {}));
710
+ //mol/dom/context/context.node.ts
711
+ ;
712
+ "use strict";
713
+ var $;
714
+ (function ($) {
715
+ function $mol_db_response(request) {
716
+ return new Promise((done, fail) => {
717
+ request.onerror = () => fail(new Error(request.error.message));
718
+ request.onsuccess = () => done(request.result);
719
+ });
720
+ }
721
+ $.$mol_db_response = $mol_db_response;
722
+ })($ || ($ = {}));
723
+ //mol/db/response/response.ts
724
+ ;
725
+ "use strict";
726
+ var $;
727
+ (function ($) {
728
+ async function $mol_db(name, ...migrations) {
729
+ const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
730
+ request.onupgradeneeded = event => {
731
+ migrations.splice(0, event.oldVersion - 1);
732
+ const transaction = new $mol_db_transaction(request.transaction);
733
+ for (const migrate of migrations)
734
+ migrate(transaction);
735
+ };
736
+ const db = await $mol_db_response(request);
737
+ return new $mol_db_database(db);
738
+ }
739
+ $.$mol_db = $mol_db;
740
+ })($ || ($ = {}));
741
+ //mol/db/db.ts
742
+ ;
743
+ "use strict";
744
+ var $;
745
+ (function ($) {
746
+ class $mol_db_store {
747
+ native;
748
+ constructor(native) {
749
+ this.native = native;
750
+ }
751
+ get name() {
752
+ return this.native.name;
753
+ }
754
+ get path() {
755
+ return this.native.keyPath;
756
+ }
757
+ get incremental() {
758
+ return this.native.autoIncrement;
759
+ }
760
+ get indexes() {
761
+ return new Proxy({}, {
762
+ ownKeys: () => [...this.native.indexNames],
763
+ has: (_, name) => this.native.indexNames.contains(name),
764
+ get: (_, name) => new $mol_db_index(this.native.index(name))
765
+ });
766
+ }
767
+ index_make(name, path = [], unique = false, multiEntry = false) {
768
+ return this.native.createIndex(name, path, { multiEntry, unique });
769
+ }
770
+ index_drop(name) {
771
+ this.native.deleteIndex(name);
772
+ return this;
773
+ }
774
+ get transaction() {
775
+ return new $mol_db_transaction(this.native.transaction);
776
+ }
777
+ get db() {
778
+ return this.transaction.db;
779
+ }
780
+ clear() {
781
+ return $mol_db_response(this.native.clear());
782
+ }
783
+ count(keys) {
784
+ return $mol_db_response(this.native.count(keys));
785
+ }
786
+ put(doc, key) {
787
+ return $mol_db_response(this.native.put(doc, key));
788
+ }
789
+ get(key) {
790
+ return $mol_db_response(this.native.get(key));
791
+ }
792
+ select(key, count) {
793
+ return $mol_db_response(this.native.getAll(key, count));
794
+ }
795
+ drop(keys) {
796
+ return $mol_db_response(this.native.delete(keys));
797
+ }
798
+ }
799
+ $.$mol_db_store = $mol_db_store;
800
+ })($ || ($ = {}));
801
+ //mol/db/store/store.ts
802
+ ;
803
+ "use strict";
804
+ //mol/db/store/store_schema.ts
805
+ ;
806
+ "use strict";
807
+ var $;
808
+ (function ($) {
809
+ class $mol_db_index {
810
+ native;
811
+ constructor(native) {
812
+ this.native = native;
813
+ }
814
+ get name() {
815
+ return this.native.name;
816
+ }
817
+ get paths() {
818
+ return this.native.keyPath;
819
+ }
820
+ get unique() {
821
+ return this.native.unique;
822
+ }
823
+ get multiple() {
824
+ return this.native.multiEntry;
825
+ }
826
+ get store() {
827
+ return new $mol_db_store(this.native.objectStore);
828
+ }
829
+ get transaction() {
830
+ return this.store.transaction;
831
+ }
832
+ get db() {
833
+ return this.store.db;
834
+ }
835
+ count(keys) {
836
+ return $mol_db_response(this.native.count(keys));
837
+ }
838
+ get(key) {
839
+ return $mol_db_response(this.native.get(key));
840
+ }
841
+ select(key, count) {
842
+ return $mol_db_response(this.native.getAll(key, count));
843
+ }
844
+ }
845
+ $.$mol_db_index = $mol_db_index;
846
+ })($ || ($ = {}));
847
+ //mol/db/index/index.ts
848
+ ;
849
+ "use strict";
850
+ //mol/db/index/index_schema.ts
851
+ ;
852
+ "use strict";
853
+ var $;
854
+ (function ($) {
855
+ $mol_dom_context.indexedDB = $node['fake-indexeddb'];
856
+ })($ || ($ = {}));
857
+ //mol/db/db.node.ts
858
+ ;
859
+ "use strict";
860
+ //mol/db/db_schema.ts
861
+ ;
862
+ "use strict";
863
+ var $;
864
+ (function ($) {
865
+ class $mol_db_database {
866
+ native;
867
+ constructor(native) {
868
+ this.native = native;
869
+ }
870
+ get name() {
871
+ return this.native.name;
872
+ }
873
+ get version() {
874
+ return this.native.version;
875
+ }
876
+ get stores() {
877
+ return [...this.native.objectStoreNames];
878
+ }
879
+ read(...names) {
880
+ return new $mol_db_transaction(this.native.transaction(names, 'readonly')).stores;
881
+ }
882
+ change(...names) {
883
+ return new $mol_db_transaction(this.native.transaction(names, 'readwrite'));
884
+ }
885
+ kill() {
886
+ this.native.close();
887
+ const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
888
+ request.onblocked = console.error;
889
+ return $mol_db_response(request).then(() => { });
890
+ }
891
+ destructor() {
892
+ this.native.close();
893
+ }
894
+ }
895
+ $.$mol_db_database = $mol_db_database;
896
+ })($ || ($ = {}));
897
+ //mol/db/database/database.ts
898
+ ;
899
+ "use strict";
900
+ var $;
901
+ (function ($) {
902
+ class $mol_db_transaction {
903
+ native;
904
+ constructor(native) {
905
+ this.native = native;
906
+ }
907
+ get stores() {
908
+ return new Proxy({}, {
909
+ ownKeys: () => [...this.native.objectStoreNames],
910
+ has: (_, name) => this.native.objectStoreNames.contains(name),
911
+ get: (_, name) => new $mol_db_store(this.native.objectStore(name)),
912
+ });
913
+ }
914
+ store_make(name) {
915
+ return this.native.db.createObjectStore(name, { autoIncrement: true });
916
+ }
917
+ store_drop(name) {
918
+ this.native.db.deleteObjectStore(name);
919
+ return this;
920
+ }
921
+ abort() {
922
+ this.native.abort();
923
+ }
924
+ commit() {
925
+ this.native.commit();
926
+ return new Promise((done, fail) => {
927
+ this.native.onerror = () => fail(new Error(this.native.error.message));
928
+ this.native.oncomplete = () => done();
929
+ });
930
+ }
931
+ get db() {
932
+ return new $mol_db_database(this.native.db);
933
+ }
934
+ }
935
+ $.$mol_db_transaction = $mol_db_transaction;
936
+ })($ || ($ = {}));
937
+ //mol/db/transaction/transaction.ts
938
+ ;
939
939
  export default $
940
940
  //# sourceMappingURL=node.esm.js.map