reflectdb 0.1.2 → 0.1.3
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/cjs/client/index.cjs +0 -1
- package/dist/cjs/client/storage/indexeddb.cjs +0 -1
- package/dist/cjs/core/index.cjs +0 -1
- package/dist/cjs/react/index.cjs +0 -1
- package/dist/cjs/server/drizzle.cjs +15 -4
- package/dist/cjs/server/ephemeral/index.cjs +0 -1
- package/dist/cjs/server/ephemeral/redis.cjs +0 -1
- package/dist/cjs/server/index.cjs +22 -13
- package/dist/cjs/svelte/index.cjs +0 -1
- package/dist/cjs/transport/bun-ws.cjs +0 -1
- package/dist/cjs/transport/polling.cjs +0 -1
- package/dist/cjs/transport/sse.cjs +0 -1
- package/dist/cjs/transport/ws.cjs +0 -1
- package/dist/cjs/vanilla/index.cjs +0 -1
- package/dist/client/index.js +1 -1
- package/dist/client/storage/indexeddb.js +1 -1
- package/dist/core/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/server/drizzle.js +2 -2
- package/dist/server/ephemeral/index.js +1 -1
- package/dist/server/ephemeral/redis.js +1 -1
- package/dist/server/index.js +6 -7
- package/dist/shared/{esm-z1xse19c.js → esm-77ndhmpv.js} +15 -5
- package/dist/shared/esm-g5h4a88j.js +9 -0
- package/dist/shared/{esm-ck88h30s.js → esm-xtkhzxg2.js} +1 -1
- package/dist/svelte/index.js +1 -1
- package/dist/transport/bun-ws.js +1 -1
- package/dist/transport/polling.js +1 -1
- package/dist/transport/sse.js +1 -1
- package/dist/transport/ws.js +1 -1
- package/dist/vanilla/index.js +1 -1
- package/package.json +4 -3
- package/dist/shared/esm-k7kedp3y.js +0 -4
package/dist/cjs/core/index.cjs
CHANGED
package/dist/cjs/react/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var import_node_module = require("node:module");
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -45,7 +44,20 @@ __export(exports_drizzle, {
|
|
|
45
44
|
drizzleTxAtomic: () => drizzleTxAtomic
|
|
46
45
|
});
|
|
47
46
|
module.exports = __toCommonJS(exports_drizzle);
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
// src/server/node-require.ts
|
|
49
|
+
var cached;
|
|
50
|
+
function nodeRequire(id) {
|
|
51
|
+
if (!cached) {
|
|
52
|
+
const proc = globalThis.process;
|
|
53
|
+
const mod = proc?.getBuiltinModule?.("node:module");
|
|
54
|
+
if (!mod?.createRequire) {
|
|
55
|
+
throw new Error(`Cannot resolve "${id}": this runtime has no CommonJS resolver (process.getBuiltinModule is unavailable). reflectdb requires Node >= 22.3 or Bun >= 1.1.30 on the server.`);
|
|
56
|
+
}
|
|
57
|
+
cached = mod.createRequire(module.filename);
|
|
58
|
+
}
|
|
59
|
+
return cached(id);
|
|
60
|
+
}
|
|
49
61
|
|
|
50
62
|
// src/server/factory.ts
|
|
51
63
|
function getByDottedPath(root, path) {
|
|
@@ -272,12 +284,11 @@ function defineTable(adapter, opts = {}) {
|
|
|
272
284
|
}
|
|
273
285
|
|
|
274
286
|
// src/server/drizzle.ts
|
|
275
|
-
var requireFn = import_node_module2.createRequire(module.filename);
|
|
276
287
|
var cachedDrizzle;
|
|
277
288
|
function loadDrizzleSync() {
|
|
278
289
|
if (cachedDrizzle === undefined) {
|
|
279
290
|
try {
|
|
280
|
-
const mod =
|
|
291
|
+
const mod = nodeRequire("drizzle-orm");
|
|
281
292
|
cachedDrizzle = { eq: mod.eq, sql: mod.sql, getTableName: mod.getTableName };
|
|
282
293
|
} catch {
|
|
283
294
|
cachedDrizzle = null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var import_node_module = require("node:module");
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -111,7 +110,20 @@ __export(exports_drizzle, {
|
|
|
111
110
|
drizzleTxAtomic: () => drizzleTxAtomic
|
|
112
111
|
});
|
|
113
112
|
module.exports = __toCommonJS(exports_drizzle);
|
|
114
|
-
|
|
113
|
+
|
|
114
|
+
// src/server/node-require.ts
|
|
115
|
+
var cached;
|
|
116
|
+
function nodeRequire(id) {
|
|
117
|
+
if (!cached) {
|
|
118
|
+
const proc = globalThis.process;
|
|
119
|
+
const mod = proc?.getBuiltinModule?.("node:module");
|
|
120
|
+
if (!mod?.createRequire) {
|
|
121
|
+
throw new Error(`Cannot resolve "${id}": this runtime has no CommonJS resolver (process.getBuiltinModule is unavailable). reflectdb requires Node >= 22.3 or Bun >= 1.1.30 on the server.`);
|
|
122
|
+
}
|
|
123
|
+
cached = mod.createRequire(module.filename);
|
|
124
|
+
}
|
|
125
|
+
return cached(id);
|
|
126
|
+
}
|
|
115
127
|
|
|
116
128
|
// src/server/factory.ts
|
|
117
129
|
function getByDottedPath(root, path) {
|
|
@@ -338,12 +350,11 @@ function defineTable(adapter, opts = {}) {
|
|
|
338
350
|
}
|
|
339
351
|
|
|
340
352
|
// src/server/drizzle.ts
|
|
341
|
-
var requireFn = import_node_module2.createRequire(module.filename);
|
|
342
353
|
var cachedDrizzle;
|
|
343
354
|
function loadDrizzleSync() {
|
|
344
355
|
if (cachedDrizzle === undefined) {
|
|
345
356
|
try {
|
|
346
|
-
const mod =
|
|
357
|
+
const mod = nodeRequire("drizzle-orm");
|
|
347
358
|
cachedDrizzle = { eq: mod.eq, sql: mod.sql, getTableName: mod.getTableName };
|
|
348
359
|
} catch {
|
|
349
360
|
cachedDrizzle = null;
|
|
@@ -1664,9 +1675,9 @@ class OpProcessor {
|
|
|
1664
1675
|
return { freshOpIds, rows };
|
|
1665
1676
|
}
|
|
1666
1677
|
async readRow(table, rowId, batchCtx) {
|
|
1667
|
-
const
|
|
1668
|
-
if (
|
|
1669
|
-
return
|
|
1678
|
+
const cached2 = batchCtx?.rows.get(OpProcessor.rowKey(table, rowId));
|
|
1679
|
+
if (cached2)
|
|
1680
|
+
return cached2;
|
|
1670
1681
|
if (!this.storage)
|
|
1671
1682
|
return { row: null, rowHlc: null, colClocks: {} };
|
|
1672
1683
|
const existing = await this.storage.getRow(table, rowId);
|
|
@@ -3090,11 +3101,11 @@ class MessageHandler {
|
|
|
3090
3101
|
return;
|
|
3091
3102
|
if (this.authCallback) {
|
|
3092
3103
|
try {
|
|
3093
|
-
const
|
|
3104
|
+
const cached2 = this.authCache.get(message.token);
|
|
3094
3105
|
let auth;
|
|
3095
3106
|
const now = Date.now();
|
|
3096
|
-
if (
|
|
3097
|
-
auth =
|
|
3107
|
+
if (cached2 && cached2.expiresAt > now) {
|
|
3108
|
+
auth = cached2.auth;
|
|
3098
3109
|
} else {
|
|
3099
3110
|
const req = new Request("https://sync/ops", {
|
|
3100
3111
|
headers: { authorization: `Bearer ${message.token}` }
|
|
@@ -3900,11 +3911,9 @@ function parseDuration(str) {
|
|
|
3900
3911
|
init_types();
|
|
3901
3912
|
|
|
3902
3913
|
// src/server/storage/sqlite.ts
|
|
3903
|
-
var import_node_module3 = require("node:module");
|
|
3904
|
-
var requireFn2 = import_node_module3.createRequire(module.filename);
|
|
3905
3914
|
function loadDatabase() {
|
|
3906
3915
|
try {
|
|
3907
|
-
return
|
|
3916
|
+
return nodeRequire("bun:sqlite").Database;
|
|
3908
3917
|
} catch {
|
|
3909
3918
|
throw new Error("createSqliteStorage requires the Bun runtime (bun:sqlite is unavailable). Use createPostgresStorage on Node.");
|
|
3910
3919
|
}
|
package/dist/client/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../shared/esm-8qbr4y0d.js";
|
|
7
7
|
import"../shared/esm-rw7jjtrv.js";
|
|
8
8
|
import"../shared/esm-3tkwvysa.js";
|
|
9
|
-
import"../shared/esm-
|
|
9
|
+
import"../shared/esm-g5h4a88j.js";
|
|
10
10
|
// src/client/storage/memory.ts
|
|
11
11
|
function createMemoryStorage() {
|
|
12
12
|
const rows = new Map;
|
package/dist/core/index.js
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../shared/esm-8qbr4y0d.js";
|
|
5
5
|
import"../shared/esm-rw7jjtrv.js";
|
|
6
6
|
import"../shared/esm-3tkwvysa.js";
|
|
7
|
-
import"../shared/esm-
|
|
7
|
+
import"../shared/esm-g5h4a88j.js";
|
|
8
8
|
|
|
9
9
|
// src/react/context.tsx
|
|
10
10
|
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
package/dist/server/drizzle.js
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
defineTable,
|
|
14
14
|
drizzleTable,
|
|
15
|
-
drizzleTxAtomic
|
|
16
|
-
|
|
15
|
+
drizzleTxAtomic,
|
|
16
|
+
nodeRequire
|
|
17
|
+
} from "../shared/esm-77ndhmpv.js";
|
|
17
18
|
import {
|
|
18
19
|
MAX_BATCH_SIZE,
|
|
19
20
|
MAX_CLOCK_DRIFT_MS,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
} from "../shared/esm-3tkwvysa.js";
|
|
25
26
|
import {
|
|
26
27
|
__require
|
|
27
|
-
} from "../shared/esm-
|
|
28
|
+
} from "../shared/esm-g5h4a88j.js";
|
|
28
29
|
|
|
29
30
|
// src/server/enforcement.ts
|
|
30
31
|
function enforceClockDrift(hlc) {
|
|
@@ -3217,11 +3218,9 @@ function parseDuration(str) {
|
|
|
3217
3218
|
}
|
|
3218
3219
|
}
|
|
3219
3220
|
// src/server/storage/sqlite.ts
|
|
3220
|
-
import { createRequire } from "node:module";
|
|
3221
|
-
var requireFn = createRequire(import.meta.url);
|
|
3222
3221
|
function loadDatabase() {
|
|
3223
3222
|
try {
|
|
3224
|
-
return
|
|
3223
|
+
return nodeRequire("bun:sqlite").Database;
|
|
3225
3224
|
} catch {
|
|
3226
3225
|
throw new Error("createSqliteStorage requires the Bun runtime (bun:sqlite is unavailable). Use createPostgresStorage on Node.");
|
|
3227
3226
|
}
|
|
@@ -3779,7 +3778,7 @@ function createSyncServer(config) {
|
|
|
3779
3778
|
server.query(name, fn, {
|
|
3780
3779
|
tables,
|
|
3781
3780
|
mutate: async () => {
|
|
3782
|
-
const { MutationError: MutationError2 } = await import("../shared/esm-
|
|
3781
|
+
const { MutationError: MutationError2 } = await import("../shared/esm-xtkhzxg2.js");
|
|
3783
3782
|
throw new MutationError2("readonly_query", `"${name}" is a view and is read-only`);
|
|
3784
3783
|
}
|
|
3785
3784
|
});
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
// src/server/
|
|
2
|
-
|
|
1
|
+
// src/server/node-require.ts
|
|
2
|
+
var cached;
|
|
3
|
+
function nodeRequire(id) {
|
|
4
|
+
if (!cached) {
|
|
5
|
+
const proc = globalThis.process;
|
|
6
|
+
const mod = proc?.getBuiltinModule?.("node:module");
|
|
7
|
+
if (!mod?.createRequire) {
|
|
8
|
+
throw new Error(`Cannot resolve "${id}": this runtime has no CommonJS resolver (process.getBuiltinModule is unavailable). reflectdb requires Node >= 22.3 or Bun >= 1.1.30 on the server.`);
|
|
9
|
+
}
|
|
10
|
+
cached = mod.createRequire(import.meta.url);
|
|
11
|
+
}
|
|
12
|
+
return cached(id);
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
// src/server/factory.ts
|
|
5
16
|
function getByDottedPath(root, path) {
|
|
@@ -226,12 +237,11 @@ function defineTable(adapter, opts = {}) {
|
|
|
226
237
|
}
|
|
227
238
|
|
|
228
239
|
// src/server/drizzle.ts
|
|
229
|
-
var requireFn = createRequire(import.meta.url);
|
|
230
240
|
var cachedDrizzle;
|
|
231
241
|
function loadDrizzleSync() {
|
|
232
242
|
if (cachedDrizzle === undefined) {
|
|
233
243
|
try {
|
|
234
|
-
const mod =
|
|
244
|
+
const mod = nodeRequire("drizzle-orm");
|
|
235
245
|
cachedDrizzle = { eq: mod.eq, sql: mod.sql, getTableName: mod.getTableName };
|
|
236
246
|
} catch {
|
|
237
247
|
cachedDrizzle = null;
|
|
@@ -366,4 +376,4 @@ var drizzleTxAtomic = {
|
|
|
366
376
|
}
|
|
367
377
|
};
|
|
368
378
|
|
|
369
|
-
export { defineTable, drizzleTable, drizzleTxAtomic };
|
|
379
|
+
export { nodeRequire, defineTable, drizzleTable, drizzleTxAtomic };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { __require };
|
package/dist/svelte/index.js
CHANGED
package/dist/transport/bun-ws.js
CHANGED
package/dist/transport/sse.js
CHANGED
package/dist/transport/ws.js
CHANGED
package/dist/vanilla/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reflectdb",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Real-time sync engine for TypeScript — a server database and offline-first browser clients stay in sync, with optimistic writes and typed queries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -231,7 +231,8 @@
|
|
|
231
231
|
"type-check": "tsc --noEmit",
|
|
232
232
|
"verify:exports": "bun scripts/verify-exports.ts",
|
|
233
233
|
"verify:jsx": "bun scripts/verify-jsx.ts",
|
|
234
|
-
"verify:node": "bun scripts/verify-node-consumer.ts"
|
|
234
|
+
"verify:node": "bun scripts/verify-node-consumer.ts",
|
|
235
|
+
"verify:presence": "bun scripts/verify-presence.ts"
|
|
235
236
|
},
|
|
236
237
|
"devDependencies": {
|
|
237
238
|
"@types/bun": "^1.3.10",
|
|
@@ -270,6 +271,6 @@
|
|
|
270
271
|
"pre-commit": "bun run lint && bun run type-check"
|
|
271
272
|
},
|
|
272
273
|
"engines": {
|
|
273
|
-
"node": ">=22"
|
|
274
|
+
"node": ">=22.3"
|
|
274
275
|
}
|
|
275
276
|
}
|