local-lite 2.0.7 → 3.0.1
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 +8 -30
- package/dist/adapters/local/index.d.ts +1 -0
- package/dist/adapters/local/index.js +1 -0
- package/dist/adapters/local/sqlite-wasm.d.ts +25 -0
- package/dist/adapters/local/sqlite-wasm.js +55 -0
- package/dist/adapters/remote/convex.d.ts +1 -1
- package/dist/adapters/remote/convex.js +25 -3
- package/dist/adapters/remote/demo.d.ts +3 -3
- package/dist/adapters/remote/demo.js +11 -3
- package/dist/adapters/remote/firestore.d.ts +1 -1
- package/dist/adapters/remote/firestore.js +57 -91
- package/dist/adapters/remote/index.d.ts +2 -1
- package/dist/adapters/remote/index.js +1 -0
- package/dist/adapters/remote/postgres.d.ts +37 -0
- package/dist/adapters/remote/postgres.js +119 -0
- package/dist/adapters/remote/self-hosted.d.ts +12 -0
- package/dist/adapters/remote/self-hosted.js +55 -4
- package/dist/adapters/remote/supabase.d.ts +1 -1
- package/dist/adapters/remote/supabase.js +22 -5
- package/dist/auth/apple.js +0 -6
- package/dist/auth/github.js +0 -3
- package/dist/auth/google.js +0 -3
- package/dist/auth/identity.d.ts +0 -5
- package/dist/auth/identity.js +0 -3
- package/dist/auth/microsoft.js +0 -3
- package/dist/auth/unified.d.ts +5 -5
- package/dist/auth/unified.js +1 -1
- package/dist/config/index.d.ts +0 -12
- package/dist/config/index.js +3 -26
- package/dist/config/types.d.ts +3 -2
- package/dist/core/audit.d.ts +52 -0
- package/dist/core/audit.js +153 -0
- package/dist/core/client.d.ts +4 -0
- package/dist/core/client.js +7 -0
- package/dist/core/conflict.d.ts +24 -0
- package/dist/core/conflict.js +77 -0
- package/dist/core/field-encryption.d.ts +25 -0
- package/dist/core/field-encryption.js +128 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/query-builder.d.ts +51 -0
- package/dist/core/query-builder.js +278 -35
- package/dist/core/query.js +6 -1
- package/dist/core/types.d.ts +2 -1
- package/dist/devtools/BenchmarkModal.js +285 -1
- package/dist/email/index.d.ts +1 -1
- package/dist/email/index.js +2 -2
- package/dist/index.d.ts +2 -27
- package/dist/index.js +2 -27
- package/dist/presence/index.d.ts +45 -0
- package/dist/presence/index.js +142 -0
- package/dist/reactive/event-emitter.d.ts +10 -1
- package/dist/reactive/event-emitter.js +44 -1
- package/dist/reactive/live-query.d.ts +18 -0
- package/dist/reactive/live-query.js +71 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/typed.d.ts +38 -0
- package/dist/schema/typed.js +33 -0
- package/dist/server/dashboard.d.ts +2 -0
- package/dist/server/dashboard.js +182 -2
- package/dist/solid/index.d.ts +24 -0
- package/dist/solid/index.js +35 -0
- package/dist/storage/firebase.d.ts +3 -3
- package/dist/storage/firebase.js +40 -94
- package/dist/svelte/index.d.ts +15 -0
- package/dist/svelte/index.js +27 -0
- package/dist/testing/index.d.ts +22 -0
- package/dist/testing/index.js +74 -0
- package/dist/vue/index.d.ts +27 -0
- package/dist/vue/index.js +37 -0
- package/package.json +46 -9
- package/skills/local-lite-auth/SKILL.md +1 -1
- package/skills/local-lite-custom-adapter/SKILL.md +7 -4
- package/skills/local-lite-react/SKILL.md +1 -1
- package/skills/local-lite-setup/SKILL.md +3 -2
- package/skills/local-lite-upgrade/SKILL.md +16 -0
- package/dist/kv/index.d.ts +0 -3
- package/dist/kv/index.js +0 -19
- package/dist/kv/manager.d.ts +0 -52
- package/dist/kv/manager.js +0 -167
- package/dist/kv/store.d.ts +0 -13
- package/dist/kv/store.js +0 -85
- package/dist/kv/types.d.ts +0 -27
- package/dist/kv/types.js +0 -2
- package/dist/react/kv.d.ts +0 -9
- package/dist/react/kv.js +0 -53
|
@@ -38,6 +38,7 @@ exports.BenchmarkModal = BenchmarkModal;
|
|
|
38
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
39
|
const react_1 = __importStar(require("react"));
|
|
40
40
|
const theme_js_1 = require("../react/theme.js");
|
|
41
|
+
const index_js_1 = require("../keys/index.js");
|
|
41
42
|
const sql_js_1 = require("../utils/sql.js");
|
|
42
43
|
const shared_js_1 = require("./shared.js");
|
|
43
44
|
const now = () => typeof performance !== 'undefined' && typeof performance.now === 'function'
|
|
@@ -494,6 +495,288 @@ async function runSQLiteBenchmark(clientOrDb, onProgress) {
|
|
|
494
495
|
opsPerSec: Math.round((fuzzCount / t8Duration) * 1000),
|
|
495
496
|
status: 'success',
|
|
496
497
|
});
|
|
498
|
+
// 11b. client.from() QueryBuilder & SQL Aggregations
|
|
499
|
+
if (client?.from) {
|
|
500
|
+
const qbIterations = 15;
|
|
501
|
+
onProgress?.('Benchmarking QueryBuilder & SQL aggregations...', 0.975);
|
|
502
|
+
const tQbStart = now();
|
|
503
|
+
for (let i = 0; i < qbIterations; i++) {
|
|
504
|
+
await client
|
|
505
|
+
.from('_sync_bench_temp')
|
|
506
|
+
.where('score', '$gt', 100)
|
|
507
|
+
.orderBy('score', 'DESC')
|
|
508
|
+
.limit(25)
|
|
509
|
+
.execute();
|
|
510
|
+
await client
|
|
511
|
+
.from('_sync_bench_temp')
|
|
512
|
+
.where('score', '$gte', 0)
|
|
513
|
+
.count();
|
|
514
|
+
}
|
|
515
|
+
const tQbDuration = elapsed(tQbStart);
|
|
516
|
+
const qbOps = qbIterations * 2;
|
|
517
|
+
list.push({
|
|
518
|
+
name: 'client.from() QueryBuilder & Count',
|
|
519
|
+
category: 'Local-Lite Client',
|
|
520
|
+
description: `${qbOps} fluent .where().orderBy().limit().execute() and .count() queries`,
|
|
521
|
+
operations: qbOps,
|
|
522
|
+
durationMs: tQbDuration,
|
|
523
|
+
opsPerSec: Math.round((qbOps / tQbDuration) * 1000),
|
|
524
|
+
status: 'success',
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
// 11c. client.kvStore Set / Get / Delete
|
|
528
|
+
if (client?.kvStore) {
|
|
529
|
+
const kvCount = scaleWorkload(25);
|
|
530
|
+
onProgress?.(`Benchmarking client.kvStore (${kvCount} keys)...`, 0.98);
|
|
531
|
+
const tKvStart = now();
|
|
532
|
+
for (let i = 0; i < kvCount; i++) {
|
|
533
|
+
await client.kvStore.set(`_sync_bench_kv_${i}`, { i, ok: true });
|
|
534
|
+
}
|
|
535
|
+
for (let i = 0; i < kvCount; i++) {
|
|
536
|
+
await client.kvStore.get(`_sync_bench_kv_${i}`);
|
|
537
|
+
}
|
|
538
|
+
for (let i = 0; i < kvCount; i++) {
|
|
539
|
+
await client.kvStore.delete(`_sync_bench_kv_${i}`);
|
|
540
|
+
}
|
|
541
|
+
const tKvDuration = elapsed(tKvStart);
|
|
542
|
+
const kvOps = kvCount * 3;
|
|
543
|
+
list.push({
|
|
544
|
+
name: 'client.kvStore Set / Get / Delete',
|
|
545
|
+
category: 'Local-Lite Client',
|
|
546
|
+
description: `${kvOps.toLocaleString()} JSON preference writes, reads & deletes`,
|
|
547
|
+
operations: kvOps,
|
|
548
|
+
durationMs: tKvDuration,
|
|
549
|
+
opsPerSec: Math.round((kvOps / tKvDuration) * 1000),
|
|
550
|
+
status: 'success',
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
// 11d. client.storage Blob Save / Get / Delete (SHA-256)
|
|
554
|
+
if (client?.storage) {
|
|
555
|
+
const blobCount = 10;
|
|
556
|
+
onProgress?.(`Benchmarking client.storage (${blobCount} blobs)...`, 0.985);
|
|
557
|
+
const tBlobStart = now();
|
|
558
|
+
for (let i = 0; i < blobCount; i++) {
|
|
559
|
+
const key = `_sync_bench_blob_${i}.txt`;
|
|
560
|
+
await client.storage.save(key, `bench-payload-${i}`, {
|
|
561
|
+
mimeType: 'text/plain',
|
|
562
|
+
autoUpload: false,
|
|
563
|
+
});
|
|
564
|
+
await client.storage.get(key);
|
|
565
|
+
await client.storage.delete(key);
|
|
566
|
+
}
|
|
567
|
+
const tBlobDuration = elapsed(tBlobStart);
|
|
568
|
+
const blobOps = blobCount * 3;
|
|
569
|
+
list.push({
|
|
570
|
+
name: 'client.storage Blob & SHA-256 Roundtrip',
|
|
571
|
+
category: 'Local-Lite Client',
|
|
572
|
+
description: `${blobOps} blob save (with SHA-256), read & delete operations`,
|
|
573
|
+
operations: blobOps,
|
|
574
|
+
durationMs: tBlobDuration,
|
|
575
|
+
opsPerSec: Math.round((blobOps / tBlobDuration) * 1000),
|
|
576
|
+
status: 'success',
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
// 11e. API Keys & Signed Tokens (HMAC-SHA256)
|
|
580
|
+
const keyOpsCount = 25;
|
|
581
|
+
onProgress?.('Benchmarking API keys & HMAC-SHA256 tokens...', 0.99);
|
|
582
|
+
const tKeysStart = now();
|
|
583
|
+
const tokenSecret = 'bench-secret-key';
|
|
584
|
+
for (let i = 0; i < keyOpsCount; i++) {
|
|
585
|
+
const generated = (0, index_js_1.generateApiKey)({ prefix: 'll_bench' });
|
|
586
|
+
(0, index_js_1.verifyApiKey)(generated.key, generated.keyHash);
|
|
587
|
+
const token = (0, index_js_1.createSignedToken)({
|
|
588
|
+
secret: tokenSecret,
|
|
589
|
+
payload: { i },
|
|
590
|
+
expiresInMs: 60_000,
|
|
591
|
+
});
|
|
592
|
+
(0, index_js_1.verifySignedToken)(token, tokenSecret);
|
|
593
|
+
}
|
|
594
|
+
const tKeysDuration = elapsed(tKeysStart);
|
|
595
|
+
const totalKeyOps = keyOpsCount * 4;
|
|
596
|
+
list.push({
|
|
597
|
+
name: 'API Keys & Signed Tokens (HMAC-SHA256)',
|
|
598
|
+
category: 'Memory / JSON',
|
|
599
|
+
description: `${totalKeyOps} cryptographic API key generations, checksum/hash checks & token sign/verify cycles`,
|
|
600
|
+
operations: totalKeyOps,
|
|
601
|
+
durationMs: tKeysDuration,
|
|
602
|
+
opsPerSec: Math.round((totalKeyOps / tKeysDuration) * 1000),
|
|
603
|
+
status: 'success',
|
|
604
|
+
});
|
|
605
|
+
// 11f. client.actions Outbox Enqueue & Cancel
|
|
606
|
+
if (client?.actions) {
|
|
607
|
+
const actionCount = 20;
|
|
608
|
+
onProgress?.(`Benchmarking client.actions outbox (${actionCount})...`, 0.992);
|
|
609
|
+
const tActStart = now();
|
|
610
|
+
for (let i = 0; i < actionCount; i++) {
|
|
611
|
+
const rec = await client.actions.enqueue({
|
|
612
|
+
action: '_sync_bench_action',
|
|
613
|
+
payload: { i },
|
|
614
|
+
});
|
|
615
|
+
await client.actions.cancel(rec.id);
|
|
616
|
+
}
|
|
617
|
+
await client.actions.prune({
|
|
618
|
+
cancelledOlderThanMs: 0,
|
|
619
|
+
});
|
|
620
|
+
const tActDuration = elapsed(tActStart);
|
|
621
|
+
const actOps = actionCount * 2;
|
|
622
|
+
list.push({
|
|
623
|
+
name: 'client.actions Outbox Enqueue & Cancel',
|
|
624
|
+
category: 'Outbox / Sync',
|
|
625
|
+
description: `${actOps} offline action outbox enqueue, cancel & prune operations`,
|
|
626
|
+
operations: actOps,
|
|
627
|
+
durationMs: tActDuration,
|
|
628
|
+
opsPerSec: Math.round((actOps / tActDuration) * 1000),
|
|
629
|
+
status: 'success',
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
// 11g. Multi-Table Relational JOIN + Aggregation Torture
|
|
633
|
+
if (client?.from && client?.batch) {
|
|
634
|
+
const orderCount = scaleWorkload(100);
|
|
635
|
+
onProgress?.(`Running relational JOIN + aggregation torture (${orderCount} orders)...`, 0.993);
|
|
636
|
+
await db.execute('CREATE TABLE IF NOT EXISTS "_sync_bench_orders" (id TEXT PRIMARY KEY, user_id TEXT, amount REAL, status TEXT, created_at INTEGER)');
|
|
637
|
+
await db.execute('CREATE INDEX IF NOT EXISTS "_sync_bench_orders_uid" ON "_sync_bench_orders" (user_id)');
|
|
638
|
+
const tJoinStart = now();
|
|
639
|
+
const orderMutations = Array.from({ length: orderCount }, (_, i) => ({
|
|
640
|
+
tableName: '_sync_bench_orders',
|
|
641
|
+
id: `ord-${i}`,
|
|
642
|
+
operation: 'INSERT',
|
|
643
|
+
payload: {
|
|
644
|
+
user_id: `b-batch-${50 + (i % 50)}`,
|
|
645
|
+
amount: (i + 1) * 12.5,
|
|
646
|
+
status: i % 3 === 0 ? 'paid' : i % 3 === 1 ? 'pending' : 'refunded',
|
|
647
|
+
created_at: Date.now(),
|
|
648
|
+
},
|
|
649
|
+
skipOutbox: true,
|
|
650
|
+
}));
|
|
651
|
+
await client.batch(orderMutations);
|
|
652
|
+
for (let i = 0; i < 10; i++) {
|
|
653
|
+
await client
|
|
654
|
+
.from('_sync_bench_orders')
|
|
655
|
+
.join('_sync_bench_temp', '_sync_bench_orders.user_id', '_sync_bench_temp.id')
|
|
656
|
+
.where('status', '$in', ['paid', 'pending'])
|
|
657
|
+
.orderBy('amount', 'DESC')
|
|
658
|
+
.limit(30)
|
|
659
|
+
.execute();
|
|
660
|
+
await client
|
|
661
|
+
.from('_sync_bench_orders')
|
|
662
|
+
.where('status', '$eq', 'paid')
|
|
663
|
+
.sum('amount');
|
|
664
|
+
await client
|
|
665
|
+
.from('_sync_bench_orders')
|
|
666
|
+
.where('status', '$ne', 'refunded')
|
|
667
|
+
.avg('amount');
|
|
668
|
+
}
|
|
669
|
+
const tJoinDuration = elapsed(tJoinStart);
|
|
670
|
+
const joinOps = orderCount + 30;
|
|
671
|
+
list.push({
|
|
672
|
+
name: 'Relational JOIN + Sum/Avg Torture',
|
|
673
|
+
category: 'Local-Lite Client',
|
|
674
|
+
description: `${orderCount.toLocaleString()} relational inserts + 30 INNER JOIN, $in, sum() & avg() queries`,
|
|
675
|
+
operations: joinOps,
|
|
676
|
+
durationMs: tJoinDuration,
|
|
677
|
+
opsPerSec: Math.round((joinOps / tJoinDuration) * 1000),
|
|
678
|
+
status: 'success',
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
// 11h. Outbox Coalescing & Rapid Mutation Storm
|
|
682
|
+
if (client?.insert && client?.update && client?.delete) {
|
|
683
|
+
const stormEntities = 20;
|
|
684
|
+
onProgress?.(`Running outbox coalescing mutation storm (${stormEntities * 6} ops)...`, 0.994);
|
|
685
|
+
const tStormStart = now();
|
|
686
|
+
for (let i = 0; i < stormEntities; i++) {
|
|
687
|
+
const id = `storm-${i}`;
|
|
688
|
+
await client.insert('_sync_bench_temp', id, {
|
|
689
|
+
title: `Storm ${i}`,
|
|
690
|
+
score: i,
|
|
691
|
+
metadata: '{}',
|
|
692
|
+
created_at: Date.now(),
|
|
693
|
+
});
|
|
694
|
+
for (let u = 1; u <= 4; u++) {
|
|
695
|
+
await client.update('_sync_bench_temp', id, {
|
|
696
|
+
title: `Storm ${i} v${u}`,
|
|
697
|
+
score: i + u * 10,
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
await client.delete('_sync_bench_temp', id);
|
|
701
|
+
}
|
|
702
|
+
const tStormDuration = elapsed(tStormStart);
|
|
703
|
+
const stormOps = stormEntities * 6;
|
|
704
|
+
list.push({
|
|
705
|
+
name: 'Outbox Coalescing Mutation Storm',
|
|
706
|
+
category: 'Outbox / Sync',
|
|
707
|
+
description: `${stormOps} rapid insert -> 4x update -> delete cycles through live outbox coalescing`,
|
|
708
|
+
operations: stormOps,
|
|
709
|
+
durationMs: tStormDuration,
|
|
710
|
+
opsPerSec: Math.round((stormOps / tStormDuration) * 1000),
|
|
711
|
+
status: 'success',
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
// 11i. Large 10KB Unicode/JSON Payload Stress
|
|
715
|
+
if (client?.insert && client?.findById && client?.delete) {
|
|
716
|
+
const largeCount = 15;
|
|
717
|
+
onProgress?.('Stress-testing 10KB+ nested Unicode JSON payloads...', 0.9945);
|
|
718
|
+
const bigBlob = JSON.stringify({
|
|
719
|
+
emoji: '⚡🔐🧪🌍🚀'.repeat(40),
|
|
720
|
+
nested: Array.from({ length: 40 }, (_, k) => ({
|
|
721
|
+
idx: k,
|
|
722
|
+
text: `Payload-"quoted"-\\escaped\\-日本語-${k}`,
|
|
723
|
+
})),
|
|
724
|
+
});
|
|
725
|
+
const tBigStart = now();
|
|
726
|
+
for (let i = 0; i < largeCount; i++) {
|
|
727
|
+
const id = `big-${i}`;
|
|
728
|
+
await client.insert('_sync_bench_temp', id, {
|
|
729
|
+
title: `Large Unicode #${i}`,
|
|
730
|
+
score: i,
|
|
731
|
+
metadata: bigBlob,
|
|
732
|
+
created_at: Date.now(),
|
|
733
|
+
}, { skipOutbox: true });
|
|
734
|
+
await client.findById('_sync_bench_temp', id);
|
|
735
|
+
await client.delete('_sync_bench_temp', id, { skipOutbox: true });
|
|
736
|
+
}
|
|
737
|
+
const tBigDuration = elapsed(tBigStart);
|
|
738
|
+
const bigOps = largeCount * 3;
|
|
739
|
+
list.push({
|
|
740
|
+
name: '10KB+ Unicode JSON Payload Stress',
|
|
741
|
+
category: 'Memory / JSON',
|
|
742
|
+
description: `${bigOps} insert, point-lookup & delete cycles with 10KB+ nested unicode JSON`,
|
|
743
|
+
operations: bigOps,
|
|
744
|
+
durationMs: tBigDuration,
|
|
745
|
+
opsPerSec: Math.round((bigOps / tBigDuration) * 1000),
|
|
746
|
+
status: 'success',
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
// 11j. FTS5 Full-Text Search & BM25 Ranking
|
|
750
|
+
if (client?.search) {
|
|
751
|
+
onProgress?.('Benchmarking FTS5 full-text indexing & BM25 search...', 0.9948);
|
|
752
|
+
const tFtsStart = now();
|
|
753
|
+
try {
|
|
754
|
+
await client.search.createIndex({
|
|
755
|
+
table: '_sync_bench_temp',
|
|
756
|
+
columns: ['title'],
|
|
757
|
+
});
|
|
758
|
+
const ftsRows = await client.findMany('_sync_bench_temp', {
|
|
759
|
+
limit: 100,
|
|
760
|
+
});
|
|
761
|
+
await client.search.rebuildIndex('_sync_bench_temp', ftsRows);
|
|
762
|
+
for (let i = 0; i < 20; i++) {
|
|
763
|
+
await client.search.query('_sync_bench_temp', 'Batch', { limit: 20 });
|
|
764
|
+
}
|
|
765
|
+
const tFtsDuration = elapsed(tFtsStart);
|
|
766
|
+
list.push({
|
|
767
|
+
name: 'FTS5 Full-Text Index & BM25 Search',
|
|
768
|
+
category: 'Local-Lite Client',
|
|
769
|
+
description: 'FTS5 index creation, full rebuild & 20 ranked prefix queries',
|
|
770
|
+
operations: 22,
|
|
771
|
+
durationMs: tFtsDuration,
|
|
772
|
+
opsPerSec: Math.round((22 / tFtsDuration) * 1000),
|
|
773
|
+
status: 'success',
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
finally {
|
|
777
|
+
await client.search.dropIndex('_sync_bench_temp').catch(() => { });
|
|
778
|
+
}
|
|
779
|
+
}
|
|
497
780
|
// 12. Read-only benchmarks against the app's real tables (never writes app data)
|
|
498
781
|
const realTables = [...appTables].sort((a, b) => b[1] - a[1]).slice(0, 3);
|
|
499
782
|
for (const [tableName, rowCount] of realTables) {
|
|
@@ -539,13 +822,14 @@ async function runSQLiteBenchmark(clientOrDb, onProgress) {
|
|
|
539
822
|
onProgress?.('Benchmark complete!', 1);
|
|
540
823
|
}
|
|
541
824
|
finally {
|
|
825
|
+
await db.execute('DROP TABLE IF EXISTS "_sync_bench_orders"').catch(() => { });
|
|
542
826
|
await db.execute('DROP TABLE IF EXISTS "_sync_bench_tags"').catch(() => { });
|
|
543
827
|
await db.execute('DROP TABLE IF EXISTS "_sync_bench_temp"').catch(() => { });
|
|
544
828
|
await db
|
|
545
829
|
.execute('DROP TABLE IF EXISTS "_sync_bench_outbox"')
|
|
546
830
|
.catch(() => { });
|
|
547
831
|
await db
|
|
548
|
-
.execute('DELETE FROM "sync_outbox" WHERE "
|
|
832
|
+
.execute('DELETE FROM "sync_outbox" WHERE "table_name" LIKE ?', ['_sync%'])
|
|
549
833
|
.catch(() => { });
|
|
550
834
|
}
|
|
551
835
|
return list;
|
package/dist/email/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ActionHandlerContext, ActionRecord, EmailAttachment, EmailPayload } from '../actions/types.js';
|
|
2
|
-
export type EmailProviderType = 'nodemailer' | 'resend' | 'sendgrid' | 'postmark' | 'http' | '
|
|
2
|
+
export type EmailProviderType = 'nodemailer' | 'resend' | 'sendgrid' | 'postmark' | 'http' | 'preview' | 'custom';
|
|
3
3
|
export interface EmailHandlerOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Default sender address (e.g. '"Support" <support@example.com>')
|
package/dist/email/index.js
CHANGED
|
@@ -382,7 +382,7 @@ function createDevEmailHandler(options = {}) {
|
|
|
382
382
|
* local dev mailbox, or custom webhooks.
|
|
383
383
|
*/
|
|
384
384
|
function createEmailHandler(config) {
|
|
385
|
-
if (config.provider === '
|
|
385
|
+
if (config.provider === 'preview') {
|
|
386
386
|
return createDevEmailHandler({ ...config, silent: config.silentDev });
|
|
387
387
|
}
|
|
388
388
|
if (config.transport || config.provider === 'nodemailer') {
|
|
@@ -401,5 +401,5 @@ function createEmailHandler(config) {
|
|
|
401
401
|
provider: 'resend',
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
throw new Error("Invalid email configuration: Provide 'transport' (for Nodemailer/SMTP), 'provider' ('resend'|'sendgrid'|'postmark'|'
|
|
404
|
+
throw new Error("Invalid email configuration: Provide 'transport' (for Nodemailer/SMTP), 'provider' ('resend'|'sendgrid'|'postmark'|'preview'), or 'endpoint' (for HTTP delivery).");
|
|
405
405
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
export * from './core/
|
|
2
|
-
export * from './core/types.js';
|
|
3
|
-
export * from './core/query.js';
|
|
4
|
-
export * from './core/sync-worker.js';
|
|
5
|
-
export * from './core/conflict.js';
|
|
6
|
-
export * from './core/outbox-store.js';
|
|
7
|
-
export * from './core/meta-store.js';
|
|
8
|
-
export * from './core/table-manager.js';
|
|
9
|
-
export * from './core/schema-manager.js';
|
|
10
|
-
export * from './core/query-builder.js';
|
|
11
|
-
export * from './core/maintenance.js';
|
|
12
|
-
export * from './reactive/event-emitter.js';
|
|
13
|
-
export * from './adapters/local/index.js';
|
|
14
|
-
export * from './adapters/remote/index.js';
|
|
15
|
-
export * from './adapters/network/index.js';
|
|
1
|
+
export * from './core/index.js';
|
|
16
2
|
export * from './config/index.js';
|
|
17
|
-
export * from './
|
|
3
|
+
export * from './schema/index.js';
|
|
18
4
|
export * from './utils/uuid.js';
|
|
19
5
|
export * from './utils/sql.js';
|
|
20
|
-
export * from './utils/logger.js';
|
|
21
6
|
export * from './utils/portability.js';
|
|
22
|
-
export * from './schema/index.js';
|
|
23
|
-
export * from './auth/index.js';
|
|
24
|
-
export * from './backups/index.js';
|
|
25
|
-
export * from './actions/index.js';
|
|
26
|
-
export * from './keys/index.js';
|
|
27
|
-
export * from './kv-store/index.js';
|
|
28
|
-
export * from './search/index.js';
|
|
29
|
-
export * from './storage/index.js';
|
|
30
|
-
export * from './scheduler/index.js';
|
|
31
|
-
export * from './payments/index.js';
|
package/dist/index.js
CHANGED
|
@@ -14,34 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./core/
|
|
18
|
-
__exportStar(require("./core/types.js"), exports);
|
|
19
|
-
__exportStar(require("./core/query.js"), exports);
|
|
20
|
-
__exportStar(require("./core/sync-worker.js"), exports);
|
|
21
|
-
__exportStar(require("./core/conflict.js"), exports);
|
|
22
|
-
__exportStar(require("./core/outbox-store.js"), exports);
|
|
23
|
-
__exportStar(require("./core/meta-store.js"), exports);
|
|
24
|
-
__exportStar(require("./core/table-manager.js"), exports);
|
|
25
|
-
__exportStar(require("./core/schema-manager.js"), exports);
|
|
26
|
-
__exportStar(require("./core/query-builder.js"), exports);
|
|
27
|
-
__exportStar(require("./core/maintenance.js"), exports);
|
|
28
|
-
__exportStar(require("./reactive/event-emitter.js"), exports);
|
|
29
|
-
__exportStar(require("./adapters/local/index.js"), exports);
|
|
30
|
-
__exportStar(require("./adapters/remote/index.js"), exports);
|
|
31
|
-
__exportStar(require("./adapters/network/index.js"), exports);
|
|
17
|
+
__exportStar(require("./core/index.js"), exports);
|
|
32
18
|
__exportStar(require("./config/index.js"), exports);
|
|
33
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./schema/index.js"), exports);
|
|
34
20
|
__exportStar(require("./utils/uuid.js"), exports);
|
|
35
21
|
__exportStar(require("./utils/sql.js"), exports);
|
|
36
|
-
__exportStar(require("./utils/logger.js"), exports);
|
|
37
22
|
__exportStar(require("./utils/portability.js"), exports);
|
|
38
|
-
__exportStar(require("./schema/index.js"), exports);
|
|
39
|
-
__exportStar(require("./auth/index.js"), exports);
|
|
40
|
-
__exportStar(require("./backups/index.js"), exports);
|
|
41
|
-
__exportStar(require("./actions/index.js"), exports);
|
|
42
|
-
__exportStar(require("./keys/index.js"), exports);
|
|
43
|
-
__exportStar(require("./kv-store/index.js"), exports);
|
|
44
|
-
__exportStar(require("./search/index.js"), exports);
|
|
45
|
-
__exportStar(require("./storage/index.js"), exports);
|
|
46
|
-
__exportStar(require("./scheduler/index.js"), exports);
|
|
47
|
-
__exportStar(require("./payments/index.js"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface PresencePeer<TState = Record<string, any>> {
|
|
2
|
+
peerId: string;
|
|
3
|
+
state: TState;
|
|
4
|
+
lastSeen: number;
|
|
5
|
+
}
|
|
6
|
+
export interface PresenceTransport {
|
|
7
|
+
send(message: any): void;
|
|
8
|
+
onMessage(handler: (message: any) => void): () => void;
|
|
9
|
+
close?(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface PresenceChannelOptions {
|
|
12
|
+
room: string;
|
|
13
|
+
peerId: string;
|
|
14
|
+
ttlMs?: number;
|
|
15
|
+
transport?: PresenceTransport;
|
|
16
|
+
channelPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a BroadcastChannel-backed PresenceTransport for same-origin browser tabs.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createBroadcastPresenceTransport(channelName: string): PresenceTransport;
|
|
22
|
+
/**
|
|
23
|
+
* Ephemeral, non-persisted presence channel for live cursors, typing indicators, and active record locks.
|
|
24
|
+
*/
|
|
25
|
+
export declare class PresenceChannel<TState = Record<string, any>> {
|
|
26
|
+
readonly room: string;
|
|
27
|
+
readonly peerId: string;
|
|
28
|
+
private ttlMs;
|
|
29
|
+
private transport;
|
|
30
|
+
private peers;
|
|
31
|
+
private listeners;
|
|
32
|
+
private unsubTransport?;
|
|
33
|
+
private localState;
|
|
34
|
+
private joined;
|
|
35
|
+
constructor(options: PresenceChannelOptions);
|
|
36
|
+
join(initialState?: TState): void;
|
|
37
|
+
updateState(patch: Partial<TState>): void;
|
|
38
|
+
leave(): void;
|
|
39
|
+
getPeers(now?: number): PresencePeer<TState>[];
|
|
40
|
+
onPeersChange(callback: (peers: PresencePeer<TState>[]) => void): () => void;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
private broadcast;
|
|
43
|
+
private handleMessage;
|
|
44
|
+
private notify;
|
|
45
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresenceChannel = void 0;
|
|
4
|
+
exports.createBroadcastPresenceTransport = createBroadcastPresenceTransport;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a BroadcastChannel-backed PresenceTransport for same-origin browser tabs.
|
|
7
|
+
*/
|
|
8
|
+
function createBroadcastPresenceTransport(channelName) {
|
|
9
|
+
const BC = globalThis.BroadcastChannel;
|
|
10
|
+
if (typeof BC !== 'function') {
|
|
11
|
+
return {
|
|
12
|
+
send() { },
|
|
13
|
+
onMessage() {
|
|
14
|
+
return () => { };
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const channel = new BC(channelName);
|
|
19
|
+
return {
|
|
20
|
+
send(message) {
|
|
21
|
+
channel.postMessage(message);
|
|
22
|
+
},
|
|
23
|
+
onMessage(handler) {
|
|
24
|
+
const listener = (ev) => handler(ev.data);
|
|
25
|
+
channel.addEventListener('message', listener);
|
|
26
|
+
return () => channel.removeEventListener('message', listener);
|
|
27
|
+
},
|
|
28
|
+
close() {
|
|
29
|
+
channel.close();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Ephemeral, non-persisted presence channel for live cursors, typing indicators, and active record locks.
|
|
35
|
+
*/
|
|
36
|
+
class PresenceChannel {
|
|
37
|
+
room;
|
|
38
|
+
peerId;
|
|
39
|
+
ttlMs;
|
|
40
|
+
transport;
|
|
41
|
+
peers = new Map();
|
|
42
|
+
listeners = new Set();
|
|
43
|
+
unsubTransport;
|
|
44
|
+
localState = {};
|
|
45
|
+
joined = false;
|
|
46
|
+
constructor(options) {
|
|
47
|
+
this.room = options.room;
|
|
48
|
+
this.peerId = options.peerId;
|
|
49
|
+
this.ttlMs = options.ttlMs ?? 30_000;
|
|
50
|
+
const prefix = options.channelPrefix ?? 'local-lite:presence:';
|
|
51
|
+
this.transport =
|
|
52
|
+
options.transport ??
|
|
53
|
+
createBroadcastPresenceTransport(`${prefix}${options.room}`);
|
|
54
|
+
}
|
|
55
|
+
join(initialState = {}) {
|
|
56
|
+
this.localState = initialState;
|
|
57
|
+
if (!this.joined) {
|
|
58
|
+
this.joined = true;
|
|
59
|
+
this.unsubTransport = this.transport.onMessage((msg) => {
|
|
60
|
+
this.handleMessage(msg);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
this.broadcast('presence:join', this.localState);
|
|
64
|
+
}
|
|
65
|
+
updateState(patch) {
|
|
66
|
+
this.localState = { ...this.localState, ...patch };
|
|
67
|
+
if (this.joined) {
|
|
68
|
+
this.broadcast('presence:update', this.localState);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
leave() {
|
|
72
|
+
if (!this.joined)
|
|
73
|
+
return;
|
|
74
|
+
this.broadcast('presence:leave', null);
|
|
75
|
+
this.joined = false;
|
|
76
|
+
this.unsubTransport?.();
|
|
77
|
+
this.unsubTransport = undefined;
|
|
78
|
+
this.peers.clear();
|
|
79
|
+
this.notify();
|
|
80
|
+
}
|
|
81
|
+
getPeers(now = Date.now()) {
|
|
82
|
+
let pruned = false;
|
|
83
|
+
for (const [id, peer] of this.peers.entries()) {
|
|
84
|
+
if (now - peer.lastSeen > this.ttlMs) {
|
|
85
|
+
this.peers.delete(id);
|
|
86
|
+
pruned = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (pruned) {
|
|
90
|
+
this.notify();
|
|
91
|
+
}
|
|
92
|
+
return Array.from(this.peers.values());
|
|
93
|
+
}
|
|
94
|
+
onPeersChange(callback) {
|
|
95
|
+
this.listeners.add(callback);
|
|
96
|
+
return () => {
|
|
97
|
+
this.listeners.delete(callback);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
dispose() {
|
|
101
|
+
this.leave();
|
|
102
|
+
this.transport.close?.();
|
|
103
|
+
this.listeners.clear();
|
|
104
|
+
}
|
|
105
|
+
broadcast(type, state) {
|
|
106
|
+
this.transport.send({
|
|
107
|
+
type,
|
|
108
|
+
room: this.room,
|
|
109
|
+
peerId: this.peerId,
|
|
110
|
+
state,
|
|
111
|
+
ts: Date.now(),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
handleMessage(msg) {
|
|
115
|
+
if (!msg || msg.room !== this.room || msg.peerId === this.peerId)
|
|
116
|
+
return;
|
|
117
|
+
if (msg.type === 'presence:leave') {
|
|
118
|
+
if (this.peers.delete(msg.peerId)) {
|
|
119
|
+
this.notify();
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (msg.type === 'presence:join' || msg.type === 'presence:update') {
|
|
124
|
+
this.peers.set(msg.peerId, {
|
|
125
|
+
peerId: msg.peerId,
|
|
126
|
+
state: msg.state ?? {},
|
|
127
|
+
lastSeen: typeof msg.ts === 'number' ? msg.ts : Date.now(),
|
|
128
|
+
});
|
|
129
|
+
this.notify();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
notify() {
|
|
133
|
+
const snapshot = Array.from(this.peers.values());
|
|
134
|
+
for (const cb of this.listeners) {
|
|
135
|
+
try {
|
|
136
|
+
cb(snapshot);
|
|
137
|
+
}
|
|
138
|
+
catch { }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.PresenceChannel = PresenceChannel;
|
|
@@ -3,6 +3,15 @@ export declare class EventEmitter {
|
|
|
3
3
|
private listeners;
|
|
4
4
|
on(event: string, callback: EventCallback): () => void;
|
|
5
5
|
off(event: string, callback: EventCallback): void;
|
|
6
|
-
emit(event: string, data: any
|
|
6
|
+
emit(event: string, data: any, options?: {
|
|
7
|
+
skipBroadcast?: boolean;
|
|
8
|
+
}): void;
|
|
9
|
+
private broadcastChannel;
|
|
10
|
+
private tabId;
|
|
11
|
+
/**
|
|
12
|
+
* Bridges emitted events across browser tabs/windows via BroadcastChannel.
|
|
13
|
+
* No-ops safely in environments without BroadcastChannel (Node, React Native).
|
|
14
|
+
*/
|
|
15
|
+
enableCrossTab(channelName?: string): () => void;
|
|
7
16
|
}
|
|
8
17
|
export {};
|
|
@@ -20,7 +20,7 @@ class EventEmitter {
|
|
|
20
20
|
this.listeners.delete(event);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
emit(event, data) {
|
|
23
|
+
emit(event, data, options) {
|
|
24
24
|
const eventSet = this.listeners.get(event);
|
|
25
25
|
if (eventSet) {
|
|
26
26
|
eventSet.forEach((callback) => {
|
|
@@ -32,6 +32,49 @@ class EventEmitter {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
if (!options?.skipBroadcast && this.broadcastChannel) {
|
|
36
|
+
try {
|
|
37
|
+
this.broadcastChannel.postMessage({
|
|
38
|
+
sourceTabId: this.tabId,
|
|
39
|
+
event,
|
|
40
|
+
data,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Ignore serialization errors for non-cloneable payloads
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
broadcastChannel = null;
|
|
49
|
+
tabId = Math.random().toString(36).slice(2);
|
|
50
|
+
/**
|
|
51
|
+
* Bridges emitted events across browser tabs/windows via BroadcastChannel.
|
|
52
|
+
* No-ops safely in environments without BroadcastChannel (Node, React Native).
|
|
53
|
+
*/
|
|
54
|
+
enableCrossTab(channelName = 'local-lite-events') {
|
|
55
|
+
const BC = globalThis.BroadcastChannel;
|
|
56
|
+
if (typeof BC !== 'function') {
|
|
57
|
+
return () => { };
|
|
58
|
+
}
|
|
59
|
+
if (this.broadcastChannel) {
|
|
60
|
+
this.broadcastChannel.close();
|
|
61
|
+
}
|
|
62
|
+
const channel = new BC(channelName);
|
|
63
|
+
this.broadcastChannel = channel;
|
|
64
|
+
channel.onmessage = (msg) => {
|
|
65
|
+
const payload = msg?.data;
|
|
66
|
+
if (payload &&
|
|
67
|
+
payload.sourceTabId !== this.tabId &&
|
|
68
|
+
typeof payload.event === 'string') {
|
|
69
|
+
this.emit(payload.event, payload.data, { skipBroadcast: true });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return () => {
|
|
73
|
+
if (this.broadcastChannel === channel) {
|
|
74
|
+
this.broadcastChannel = null;
|
|
75
|
+
}
|
|
76
|
+
channel.close();
|
|
77
|
+
};
|
|
35
78
|
}
|
|
36
79
|
}
|
|
37
80
|
exports.EventEmitter = EventEmitter;
|