dexie 3.2.1-beta.1 → 3.2.2

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 CHANGED
@@ -44,7 +44,38 @@ Dexie provides a neat database API with a well thought-through API design, robus
44
44
  </head>
45
45
  </html>
46
46
  ```
47
- Yes, it's that simple.
47
+ Yes, it's that simple.
48
+
49
+ An equivalent modern version (works in all modern browsers):
50
+
51
+ ```html
52
+ <!doctype html>
53
+ <html>
54
+ <head>
55
+ <script type="module">
56
+ import Dexie from "https://unpkg.com/dexie@latest/dist/modern/dexie.mjs";
57
+ //
58
+ // Declare Database
59
+ //
60
+ const db = new Dexie("FriendDatabase");
61
+ db.version(1).stores({
62
+ friends: "++id,name,age"
63
+ });
64
+
65
+ //
66
+ // Manipulate and Query Database
67
+ //
68
+ try {
69
+ await db.friends.add({name: "Josephine", age: 21});
70
+ const youngFriends = await db.friends.where("age").below(25).toArray();
71
+ alert (`My young friends: ${JSON.stringify(youngFriends)}`);
72
+ } catch (e) {
73
+ alert (`Error: ${e}`);
74
+ }
75
+ </script>
76
+ </head>
77
+ </html>
78
+ ```
48
79
 
49
80
  [Tutorial](https://dexie.org/docs/Tutorial)
50
81
 
@@ -110,40 +141,10 @@ update(key: Key, changes: { [keyPath: string]: any }): Promise;
110
141
  ```
111
142
  This is a mix of methods from [WhereClause](https://dexie.org/docs/WhereClause/WhereClause), [Table](https://dexie.org/docs/Table/Table) and [Collection](https://dexie.org/docs/Collection/Collection). Dive into the [API reference](https://dexie.org/docs/API-Reference) to see the details.
112
143
 
113
- #### Hello World (ES2016 / ES7)
114
- ```js
115
- import Dexie from 'dexie';
116
-
117
- //
118
- // Declare Database
119
- //
120
- const db = new Dexie("FriendDatabase");
121
- db.version(1).stores({ friends: "++id,name,age" });
122
-
123
- db.transaction('rw', db.friends, async() => {
124
-
125
- // Make sure we have something in DB:
126
- if ((await db.friends.where({name: 'Josephine'}).count()) === 0) {
127
- const id = await db.friends.add({name: "Josephine", age: 21});
128
- alert (`Addded friend with id ${id}`);
129
- }
130
-
131
- // Query:
132
- const youngFriends = await db.friends.where("age").below(25).toArray();
133
-
134
- // Show result:
135
- alert ("My young friends: " + JSON.stringify(youngFriends));
136
-
137
- }).catch(e => {
138
- alert(e.stack || e);
139
- });
140
-
141
- ```
142
-
143
144
  #### Hello World (Typescript)
144
145
 
145
146
  ```js
146
- import Dexie from 'dexie';
147
+ import Dexie, { Table } from 'dexie';
147
148
 
148
149
  interface Friend {
149
150
  id?: number;
@@ -155,14 +156,13 @@ interface Friend {
155
156
  // Declare Database
156
157
  //
157
158
  class FriendDatabase extends Dexie {
158
- public friends: Dexie.Table<Friend, number>; // id is number in this case
159
+ public friends!: Table<Friend, number>; // id is number in this case
159
160
 
160
161
  public constructor() {
161
162
  super("FriendDatabase");
162
163
  this.version(1).stores({
163
164
  friends: "++id,name,age"
164
165
  });
165
- this.friends = this.table("friends");
166
166
  }
167
167
  }
168
168
 
@@ -212,13 +212,21 @@ Download
212
212
  --------
213
213
  For those who don't like package managers, here's the download links:
214
214
 
215
- https://unpkg.com/dexie@latest/dist/dexie.js
215
+ ### Legacy:
216
+ https://unpkg.com/dexie@latest/dist/dexie.min.js
216
217
 
217
- https://unpkg.com/dexie@latest/dist/dexie.js.map
218
+ https://unpkg.com/dexie@latest/dist/dexie.min.js.map
218
219
 
220
+ ### Modern:
221
+ https://unpkg.com/dexie@latest/dist/modern/dexie.min.mjs
222
+
223
+ https://unpkg.com/dexie@latest/dist/modern/dexie.min.mjs.map
224
+
225
+ ### Typings:
219
226
  https://unpkg.com/dexie@latest/dist/dexie.d.ts
220
227
 
221
228
 
229
+
222
230
  Contributing
223
231
  ============
224
232
  Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie --save` for the app your are developing.
package/dist/dexie.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 3.2.1-beta.1, Fri Nov 19 2021
7
+ * Version 3.2.2, Wed Apr 27 2022
8
8
  *
9
9
  * https://dexie.org
10
10
  *
package/dist/dexie.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 3.2.1-beta.1, Fri Nov 19 2021
7
+ * Version 3.2.2, Wed Apr 27 2022
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -182,7 +182,7 @@
182
182
  obj[currentKeyPath] = value;
183
183
  else {
184
184
  var innerObj = obj[currentKeyPath];
185
- if (!innerObj)
185
+ if (!innerObj || !hasOwn(obj, currentKeyPath))
186
186
  innerObj = (obj[currentKeyPath] = {});
187
187
  setByKeyPath(innerObj, remainingKeyPath, value);
188
188
  }
@@ -1287,7 +1287,7 @@
1287
1287
  }
1288
1288
  }
1289
1289
 
1290
- var DEXIE_VERSION = '3.2.1-beta.1';
1290
+ var DEXIE_VERSION = '3.2.2';
1291
1291
  var maxString = String.fromCharCode(65535);
1292
1292
  var minKey = -Infinity;
1293
1293
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -5147,13 +5147,15 @@
5147
5147
  }
5148
5148
  catch (_a) { }
5149
5149
  });
5150
- addEventListener('storage', function (ev) {
5151
- if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
5152
- var data = JSON.parse(ev.newValue);
5153
- if (data)
5154
- propagateLocally(data.changedParts);
5155
- }
5156
- });
5150
+ if (typeof addEventListener !== 'undefined') {
5151
+ addEventListener('storage', function (ev) {
5152
+ if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
5153
+ var data = JSON.parse(ev.newValue);
5154
+ if (data)
5155
+ propagateLocally(data.changedParts);
5156
+ }
5157
+ });
5158
+ }
5157
5159
  var swContainer = self.document && navigator.serviceWorker;
5158
5160
  if (swContainer) {
5159
5161
  swContainer.addEventListener('message', propagateMessageLocally);