taladb 0.10.1 → 0.10.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/dist/index.browser.mjs +22 -6
- package/dist/index.js +22 -6
- package/dist/index.mjs +22 -6
- package/dist/index.react-native.mjs +22 -6
- package/package.json +1 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -1171,6 +1171,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1171
1171
|
return JSON.parse(json);
|
|
1172
1172
|
},
|
|
1173
1173
|
subscribe: (filter, callback, onError) => nudgedPoller(
|
|
1174
|
+
name,
|
|
1174
1175
|
() => proxy.send("find", {
|
|
1175
1176
|
collection: name,
|
|
1176
1177
|
filterJson: filter ? s(filter) : "null"
|
|
@@ -1179,6 +1180,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1179
1180
|
onError
|
|
1180
1181
|
),
|
|
1181
1182
|
subscribeAggregate: (pipeline, callback, onError) => nudgedPoller(
|
|
1183
|
+
name,
|
|
1182
1184
|
() => proxy.send("aggregate", {
|
|
1183
1185
|
collection: name,
|
|
1184
1186
|
pipelineJson: s(pipeline)
|
|
@@ -1189,9 +1191,11 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1189
1191
|
};
|
|
1190
1192
|
return opts ? applySchema(wrapped, opts) : wrapped;
|
|
1191
1193
|
}
|
|
1192
|
-
function nudgedPoller(fetchJson, callback, onError) {
|
|
1194
|
+
function nudgedPoller(collection, fetchJson, callback, onError) {
|
|
1193
1195
|
let active = true;
|
|
1194
1196
|
let lastJson = "";
|
|
1197
|
+
let lastGeneration = -1;
|
|
1198
|
+
let generationSupported = true;
|
|
1195
1199
|
let timer = null;
|
|
1196
1200
|
let running = false;
|
|
1197
1201
|
let rerun = false;
|
|
@@ -1207,11 +1211,23 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1207
1211
|
timer = null;
|
|
1208
1212
|
}
|
|
1209
1213
|
try {
|
|
1210
|
-
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1214
|
+
let unchanged = false;
|
|
1215
|
+
if (generationSupported) {
|
|
1216
|
+
try {
|
|
1217
|
+
const gen = await proxy.send("writeGeneration", { collection });
|
|
1218
|
+
if (gen === lastGeneration) unchanged = true;
|
|
1219
|
+
else lastGeneration = gen;
|
|
1220
|
+
} catch {
|
|
1221
|
+
generationSupported = false;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
if (!unchanged) {
|
|
1225
|
+
const json = await fetchJson();
|
|
1226
|
+
if (!active) return;
|
|
1227
|
+
if (json !== lastJson) {
|
|
1228
|
+
lastJson = json;
|
|
1229
|
+
callback(JSON.parse(json));
|
|
1230
|
+
}
|
|
1215
1231
|
}
|
|
1216
1232
|
} catch (error) {
|
|
1217
1233
|
if (active) onError?.(error);
|
package/dist/index.js
CHANGED
|
@@ -1280,6 +1280,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1280
1280
|
return JSON.parse(json);
|
|
1281
1281
|
},
|
|
1282
1282
|
subscribe: (filter, callback, onError) => nudgedPoller(
|
|
1283
|
+
name,
|
|
1283
1284
|
() => proxy.send("find", {
|
|
1284
1285
|
collection: name,
|
|
1285
1286
|
filterJson: filter ? s(filter) : "null"
|
|
@@ -1288,6 +1289,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1288
1289
|
onError
|
|
1289
1290
|
),
|
|
1290
1291
|
subscribeAggregate: (pipeline, callback, onError) => nudgedPoller(
|
|
1292
|
+
name,
|
|
1291
1293
|
() => proxy.send("aggregate", {
|
|
1292
1294
|
collection: name,
|
|
1293
1295
|
pipelineJson: s(pipeline)
|
|
@@ -1298,9 +1300,11 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1298
1300
|
};
|
|
1299
1301
|
return opts ? applySchema(wrapped, opts) : wrapped;
|
|
1300
1302
|
}
|
|
1301
|
-
function nudgedPoller(fetchJson, callback, onError) {
|
|
1303
|
+
function nudgedPoller(collection, fetchJson, callback, onError) {
|
|
1302
1304
|
let active = true;
|
|
1303
1305
|
let lastJson = "";
|
|
1306
|
+
let lastGeneration = -1;
|
|
1307
|
+
let generationSupported = true;
|
|
1304
1308
|
let timer = null;
|
|
1305
1309
|
let running = false;
|
|
1306
1310
|
let rerun = false;
|
|
@@ -1316,11 +1320,23 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1316
1320
|
timer = null;
|
|
1317
1321
|
}
|
|
1318
1322
|
try {
|
|
1319
|
-
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1323
|
+
let unchanged = false;
|
|
1324
|
+
if (generationSupported) {
|
|
1325
|
+
try {
|
|
1326
|
+
const gen = await proxy.send("writeGeneration", { collection });
|
|
1327
|
+
if (gen === lastGeneration) unchanged = true;
|
|
1328
|
+
else lastGeneration = gen;
|
|
1329
|
+
} catch {
|
|
1330
|
+
generationSupported = false;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
if (!unchanged) {
|
|
1334
|
+
const json = await fetchJson();
|
|
1335
|
+
if (!active) return;
|
|
1336
|
+
if (json !== lastJson) {
|
|
1337
|
+
lastJson = json;
|
|
1338
|
+
callback(JSON.parse(json));
|
|
1339
|
+
}
|
|
1324
1340
|
}
|
|
1325
1341
|
} catch (error) {
|
|
1326
1342
|
if (active) onError?.(error);
|
package/dist/index.mjs
CHANGED
|
@@ -1228,6 +1228,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1228
1228
|
return JSON.parse(json);
|
|
1229
1229
|
},
|
|
1230
1230
|
subscribe: (filter, callback, onError) => nudgedPoller(
|
|
1231
|
+
name,
|
|
1231
1232
|
() => proxy.send("find", {
|
|
1232
1233
|
collection: name,
|
|
1233
1234
|
filterJson: filter ? s(filter) : "null"
|
|
@@ -1236,6 +1237,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1236
1237
|
onError
|
|
1237
1238
|
),
|
|
1238
1239
|
subscribeAggregate: (pipeline, callback, onError) => nudgedPoller(
|
|
1240
|
+
name,
|
|
1239
1241
|
() => proxy.send("aggregate", {
|
|
1240
1242
|
collection: name,
|
|
1241
1243
|
pipelineJson: s(pipeline)
|
|
@@ -1246,9 +1248,11 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1246
1248
|
};
|
|
1247
1249
|
return opts ? applySchema(wrapped, opts) : wrapped;
|
|
1248
1250
|
}
|
|
1249
|
-
function nudgedPoller(fetchJson, callback, onError) {
|
|
1251
|
+
function nudgedPoller(collection, fetchJson, callback, onError) {
|
|
1250
1252
|
let active = true;
|
|
1251
1253
|
let lastJson = "";
|
|
1254
|
+
let lastGeneration = -1;
|
|
1255
|
+
let generationSupported = true;
|
|
1252
1256
|
let timer = null;
|
|
1253
1257
|
let running = false;
|
|
1254
1258
|
let rerun = false;
|
|
@@ -1264,11 +1268,23 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1264
1268
|
timer = null;
|
|
1265
1269
|
}
|
|
1266
1270
|
try {
|
|
1267
|
-
|
|
1268
|
-
if (
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1271
|
+
let unchanged = false;
|
|
1272
|
+
if (generationSupported) {
|
|
1273
|
+
try {
|
|
1274
|
+
const gen = await proxy.send("writeGeneration", { collection });
|
|
1275
|
+
if (gen === lastGeneration) unchanged = true;
|
|
1276
|
+
else lastGeneration = gen;
|
|
1277
|
+
} catch {
|
|
1278
|
+
generationSupported = false;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
if (!unchanged) {
|
|
1282
|
+
const json = await fetchJson();
|
|
1283
|
+
if (!active) return;
|
|
1284
|
+
if (json !== lastJson) {
|
|
1285
|
+
lastJson = json;
|
|
1286
|
+
callback(JSON.parse(json));
|
|
1287
|
+
}
|
|
1272
1288
|
}
|
|
1273
1289
|
} catch (error) {
|
|
1274
1290
|
if (active) onError?.(error);
|
|
@@ -1171,6 +1171,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1171
1171
|
return JSON.parse(json);
|
|
1172
1172
|
},
|
|
1173
1173
|
subscribe: (filter, callback, onError) => nudgedPoller(
|
|
1174
|
+
name,
|
|
1174
1175
|
() => proxy.send("find", {
|
|
1175
1176
|
collection: name,
|
|
1176
1177
|
filterJson: filter ? s(filter) : "null"
|
|
@@ -1179,6 +1180,7 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1179
1180
|
onError
|
|
1180
1181
|
),
|
|
1181
1182
|
subscribeAggregate: (pipeline, callback, onError) => nudgedPoller(
|
|
1183
|
+
name,
|
|
1182
1184
|
() => proxy.send("aggregate", {
|
|
1183
1185
|
collection: name,
|
|
1184
1186
|
pipelineJson: s(pipeline)
|
|
@@ -1189,9 +1191,11 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1189
1191
|
};
|
|
1190
1192
|
return opts ? applySchema(wrapped, opts) : wrapped;
|
|
1191
1193
|
}
|
|
1192
|
-
function nudgedPoller(fetchJson, callback, onError) {
|
|
1194
|
+
function nudgedPoller(collection, fetchJson, callback, onError) {
|
|
1193
1195
|
let active = true;
|
|
1194
1196
|
let lastJson = "";
|
|
1197
|
+
let lastGeneration = -1;
|
|
1198
|
+
let generationSupported = true;
|
|
1195
1199
|
let timer = null;
|
|
1196
1200
|
let running = false;
|
|
1197
1201
|
let rerun = false;
|
|
@@ -1207,11 +1211,23 @@ async function createBrowserDB(dbName, config, passphrase, migrations) {
|
|
|
1207
1211
|
timer = null;
|
|
1208
1212
|
}
|
|
1209
1213
|
try {
|
|
1210
|
-
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1214
|
+
let unchanged = false;
|
|
1215
|
+
if (generationSupported) {
|
|
1216
|
+
try {
|
|
1217
|
+
const gen = await proxy.send("writeGeneration", { collection });
|
|
1218
|
+
if (gen === lastGeneration) unchanged = true;
|
|
1219
|
+
else lastGeneration = gen;
|
|
1220
|
+
} catch {
|
|
1221
|
+
generationSupported = false;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
if (!unchanged) {
|
|
1225
|
+
const json = await fetchJson();
|
|
1226
|
+
if (!active) return;
|
|
1227
|
+
if (json !== lastJson) {
|
|
1228
|
+
lastJson = json;
|
|
1229
|
+
callback(JSON.parse(json));
|
|
1230
|
+
}
|
|
1215
1231
|
}
|
|
1216
1232
|
} catch (error) {
|
|
1217
1233
|
if (active) onError?.(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taladb",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "The embedded vector database for on-device AI — documents, similarity search, and offline sync for browser, React Native, and Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|