@prabhask5/stellar-engine 1.1.17 → 1.2.0
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 +55 -1
- package/dist/bin/install-pwa.js +234 -317
- package/dist/bin/install-pwa.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -2
- package/dist/config.js.map +1 -1
- package/dist/crdt/awareness.d.ts +128 -0
- package/dist/crdt/awareness.d.ts.map +1 -0
- package/dist/crdt/awareness.js +284 -0
- package/dist/crdt/awareness.js.map +1 -0
- package/dist/crdt/channel.d.ts +165 -0
- package/dist/crdt/channel.d.ts.map +1 -0
- package/dist/crdt/channel.js +522 -0
- package/dist/crdt/channel.js.map +1 -0
- package/dist/crdt/config.d.ts +58 -0
- package/dist/crdt/config.d.ts.map +1 -0
- package/dist/crdt/config.js +123 -0
- package/dist/crdt/config.js.map +1 -0
- package/dist/crdt/helpers.d.ts +104 -0
- package/dist/crdt/helpers.d.ts.map +1 -0
- package/dist/crdt/helpers.js +116 -0
- package/dist/crdt/helpers.js.map +1 -0
- package/dist/crdt/offline.d.ts +58 -0
- package/dist/crdt/offline.d.ts.map +1 -0
- package/dist/crdt/offline.js +130 -0
- package/dist/crdt/offline.js.map +1 -0
- package/dist/crdt/persistence.d.ts +65 -0
- package/dist/crdt/persistence.d.ts.map +1 -0
- package/dist/crdt/persistence.js +171 -0
- package/dist/crdt/persistence.js.map +1 -0
- package/dist/crdt/provider.d.ts +109 -0
- package/dist/crdt/provider.d.ts.map +1 -0
- package/dist/crdt/provider.js +543 -0
- package/dist/crdt/provider.js.map +1 -0
- package/dist/crdt/store.d.ts +111 -0
- package/dist/crdt/store.d.ts.map +1 -0
- package/dist/crdt/store.js +158 -0
- package/dist/crdt/store.js.map +1 -0
- package/dist/crdt/types.d.ts +281 -0
- package/dist/crdt/types.d.ts.map +1 -0
- package/dist/crdt/types.js +26 -0
- package/dist/crdt/types.js.map +1 -0
- package/dist/database.d.ts +1 -1
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +28 -7
- package/dist/database.js.map +1 -1
- package/dist/diagnostics.d.ts +75 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +114 -2
- package/dist/diagnostics.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +21 -1
- package/dist/engine.js.map +1 -1
- package/dist/entries/crdt.d.ts +32 -0
- package/dist/entries/crdt.d.ts.map +1 -0
- package/dist/entries/crdt.js +52 -0
- package/dist/entries/crdt.js.map +1 -0
- package/dist/entries/types.d.ts +1 -0
- package/dist/entries/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
- package/dist/operations.d.ts +0 -73
- package/dist/operations.d.ts.map +0 -1
- package/dist/operations.js +0 -227
- package/dist/operations.js.map +0 -1
- package/dist/reconnectHandler.d.ts +0 -16
- package/dist/reconnectHandler.d.ts.map +0 -1
- package/dist/reconnectHandler.js +0 -21
- package/dist/reconnectHandler.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @prabhask5/stellar-engine [](https://www.npmjs.com/package/@prabhask5/stellar-engine)
|
|
1
|
+
# @prabhask5/stellar-engine [](https://www.npmjs.com/package/@prabhask5/stellar-engine) [](https://supabase.com)
|
|
2
2
|
|
|
3
3
|
A local-first, offline-capable sync engine for **SvelteKit + Supabase + Dexie** applications. All reads come from IndexedDB, all writes land locally first, and a background sync loop ships changes to Supabase -- so your app stays fast and functional regardless of network state.
|
|
4
4
|
|
|
@@ -480,6 +480,60 @@ window.location.href = '/'; // Full reload required
|
|
|
480
480
|
|
|
481
481
|
The `stellar-engine install pwa` scaffolding generates demo files automatically.
|
|
482
482
|
|
|
483
|
+
## CRDT Collaborative Editing (optional)
|
|
484
|
+
|
|
485
|
+
The engine includes an optional Yjs-based CRDT subsystem for real-time collaborative document editing. Enable it by adding `crdt` to your `initEngine()` config:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
initEngine({
|
|
489
|
+
prefix: 'myapp',
|
|
490
|
+
tables: [...],
|
|
491
|
+
database: { name: 'myapp-db', versions: [...] },
|
|
492
|
+
crdt: {
|
|
493
|
+
persistIntervalMs: 30000, // Persist to Supabase every 30s
|
|
494
|
+
maxOfflineDocuments: 50, // Max docs stored offline
|
|
495
|
+
},
|
|
496
|
+
});
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
Then use the `@prabhask5/stellar-engine/crdt` subpath:
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
import {
|
|
503
|
+
openDocument, closeDocument,
|
|
504
|
+
createSharedText, createBlockDocument,
|
|
505
|
+
updateCursor, getCollaborators, onCollaboratorsChange,
|
|
506
|
+
enableOffline, disableOffline,
|
|
507
|
+
type YDoc, type YText,
|
|
508
|
+
} from '@prabhask5/stellar-engine/crdt';
|
|
509
|
+
|
|
510
|
+
// Open a collaborative document
|
|
511
|
+
const provider = await openDocument('doc-1', 'page-1', {
|
|
512
|
+
offlineEnabled: true,
|
|
513
|
+
initialPresence: { name: 'Alice' },
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// Use with any Yjs-compatible editor (Tiptap, BlockNote, etc.)
|
|
517
|
+
const { content, meta } = createBlockDocument(provider.doc);
|
|
518
|
+
meta.set('title', 'My Page');
|
|
519
|
+
|
|
520
|
+
// Track collaborator cursors
|
|
521
|
+
const unsub = onCollaboratorsChange('doc-1', (collaborators) => {
|
|
522
|
+
// Update avatar list, cursor positions, etc.
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// Close when done
|
|
526
|
+
await closeDocument('doc-1');
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
Key features:
|
|
530
|
+
- **Real-time multi-user editing** via Supabase Broadcast (zero DB writes per keystroke)
|
|
531
|
+
- **Cursor/presence awareness** via Supabase Presence
|
|
532
|
+
- **Offline-first** with IndexedDB persistence and crash recovery
|
|
533
|
+
- **Periodic Supabase persistence** (every 30s) for durable cross-device storage
|
|
534
|
+
- **Cross-tab sync** via browser BroadcastChannel API (avoids network for same-device)
|
|
535
|
+
- **Consumers never import yjs** -- all Yjs types are re-exported from the engine
|
|
536
|
+
|
|
483
537
|
## License
|
|
484
538
|
|
|
485
539
|
Private -- not yet published under an open-source license.
|