@dovetail-ts/ember 0.0.0-stage → 1.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +180 -2
  4. package/addon-main.cjs +4 -0
  5. package/declarations/-private/status-dot.d.ts +14 -0
  6. package/declarations/-private/status-dot.d.ts.map +1 -0
  7. package/declarations/-private/visually-hidden.d.ts +6 -0
  8. package/declarations/-private/visually-hidden.d.ts.map +1 -0
  9. package/declarations/components/dovetail/avatar-stack.d.ts +31 -0
  10. package/declarations/components/dovetail/avatar-stack.d.ts.map +1 -0
  11. package/declarations/components/dovetail/connection-badge.d.ts +24 -0
  12. package/declarations/components/dovetail/connection-badge.d.ts.map +1 -0
  13. package/declarations/components/dovetail/dead-letters.d.ts +25 -0
  14. package/declarations/components/dovetail/dead-letters.d.ts.map +1 -0
  15. package/declarations/components/dovetail/editor.d.ts +58 -0
  16. package/declarations/components/dovetail/editor.d.ts.map +1 -0
  17. package/declarations/components/dovetail/live-cursors.d.ts +31 -0
  18. package/declarations/components/dovetail/live-cursors.d.ts.map +1 -0
  19. package/declarations/components/dovetail/presence.d.ts +27 -0
  20. package/declarations/components/dovetail/presence.d.ts.map +1 -0
  21. package/declarations/components/dovetail/sync-status.d.ts +25 -0
  22. package/declarations/components/dovetail/sync-status.d.ts.map +1 -0
  23. package/declarations/components/dovetail/typing.d.ts +17 -0
  24. package/declarations/components/dovetail/typing.d.ts.map +1 -0
  25. package/declarations/editor.d.ts +3 -0
  26. package/declarations/editor.d.ts.map +1 -0
  27. package/declarations/index.d.ts +25 -0
  28. package/declarations/index.d.ts.map +1 -0
  29. package/declarations/live.d.ts +46 -0
  30. package/declarations/live.d.ts.map +1 -0
  31. package/declarations/people.d.ts +51 -0
  32. package/declarations/people.d.ts.map +1 -0
  33. package/declarations/services/dovetail.d.ts +90 -0
  34. package/declarations/services/dovetail.d.ts.map +1 -0
  35. package/declarations/status.d.ts +16 -0
  36. package/declarations/status.d.ts.map +1 -0
  37. package/dist/_app_/components/dovetail/avatar-stack.js +1 -0
  38. package/dist/_app_/components/dovetail/connection-badge.js +1 -0
  39. package/dist/_app_/components/dovetail/dead-letters.js +1 -0
  40. package/dist/_app_/components/dovetail/editor.js +1 -0
  41. package/dist/_app_/components/dovetail/live-cursors.js +1 -0
  42. package/dist/_app_/components/dovetail/presence.js +1 -0
  43. package/dist/_app_/components/dovetail/sync-status.js +1 -0
  44. package/dist/_app_/components/dovetail/typing.js +1 -0
  45. package/dist/_app_/services/dovetail.js +1 -0
  46. package/dist/components/dovetail/avatar-stack.js +52 -0
  47. package/dist/components/dovetail/avatar-stack.js.map +1 -0
  48. package/dist/components/dovetail/connection-badge.js +43 -0
  49. package/dist/components/dovetail/connection-badge.js.map +1 -0
  50. package/dist/components/dovetail/dead-letters.js +47 -0
  51. package/dist/components/dovetail/dead-letters.js.map +1 -0
  52. package/dist/components/dovetail/editor.js +107 -0
  53. package/dist/components/dovetail/editor.js.map +1 -0
  54. package/dist/components/dovetail/live-cursors.js +46 -0
  55. package/dist/components/dovetail/live-cursors.js.map +1 -0
  56. package/dist/components/dovetail/presence.js +35 -0
  57. package/dist/components/dovetail/presence.js.map +1 -0
  58. package/dist/components/dovetail/sync-status.js +39 -0
  59. package/dist/components/dovetail/sync-status.js.map +1 -0
  60. package/dist/components/dovetail/typing.js +23 -0
  61. package/dist/components/dovetail/typing.js.map +1 -0
  62. package/dist/css.d.ts +2 -0
  63. package/dist/css.d.ts.map +1 -0
  64. package/dist/editor.js +2 -0
  65. package/dist/editor.js.map +1 -0
  66. package/dist/index.js +12 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/live-u5cQDrwU.js +93 -0
  69. package/dist/live-u5cQDrwU.js.map +1 -0
  70. package/dist/people-GBjAG7ZI.js +105 -0
  71. package/dist/people-GBjAG7ZI.js.map +1 -0
  72. package/dist/services/dovetail.js +233 -0
  73. package/dist/services/dovetail.js.map +1 -0
  74. package/dist/status-CYJBlnG7.js +59 -0
  75. package/dist/status-CYJBlnG7.js.map +1 -0
  76. package/dist/status-dot-DSQMdQhW.js +31 -0
  77. package/dist/status-dot-DSQMdQhW.js.map +1 -0
  78. package/dist/styles/editor.css +27 -0
  79. package/dist/visually-hidden-BFhJXHGu.js +10 -0
  80. package/dist/visually-hidden-BFhJXHGu.js.map +1 -0
  81. package/package.json +121 -3
@@ -0,0 +1,233 @@
1
+ import Service from '@ember/service';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { registerDestructor } from '@ember/destroyable';
4
+ import { waitForPromise } from '@ember/test-waiters';
5
+ import { Connection, SyncClient, WriteQueue, openDovetailDB, PresenceRoom, IndexedDBDocStorage, DocSession } from '@dovetail-ts/core';
6
+ import { a as connectionStatus } from '../status-CYJBlnG7.js';
7
+ import { L as LivePresence, a as LiveDoc } from '../live-u5cQDrwU.js';
8
+ import { g, i } from 'decorator-transforms/runtime';
9
+
10
+ // The `dovetail` service: one connection and one sync client for the app, with tracked state
11
+ // for the components, and the live objects of a room (presence, store feed, documents) that
12
+ // stop when their owner is destroyed.
13
+ /** Counts the owners of a shared object, and calls `release` when the last owner goes. */
14
+ function hold(map, key, owner, make, release) {
15
+ let entry = map.get(key);
16
+ if (!entry) {
17
+ entry = {
18
+ value: make(),
19
+ count: 0
20
+ };
21
+ map.set(key, entry);
22
+ }
23
+ entry.count++;
24
+ const held = entry;
25
+ registerDestructor(owner, () => {
26
+ if (--held.count > 0) return;
27
+ map.delete(key);
28
+ release(held.value);
29
+ });
30
+ return held.value;
31
+ }
32
+ class DovetailService extends Service {
33
+ static {
34
+ g(this.prototype, "connectionState", [tracked], function () {
35
+ return 'idle';
36
+ });
37
+ }
38
+ #connectionState = (i(this, "connectionState"), void 0);
39
+ /** The state of the connection: `idle`, `connecting`, `open`, `reconnecting`, `offline` or `closed`. */
40
+ static {
41
+ g(this.prototype, "online", [tracked], function () {
42
+ return true;
43
+ });
44
+ }
45
+ #online = (i(this, "online"), void 0);
46
+ /** True when the device is online. */
47
+ static {
48
+ g(this.prototype, "queued", [tracked], function () {
49
+ return 0;
50
+ });
51
+ }
52
+ #queued = (i(this, "queued"), void 0);
53
+ /** The number of writes in the queue. */
54
+ static {
55
+ g(this.prototype, "deadLetters", [tracked], function () {
56
+ return [];
57
+ });
58
+ }
59
+ #deadLetters = (i(this, "deadLetters"), void 0);
60
+ /** The writes that the server rejected. */
61
+ static {
62
+ g(this.prototype, "errors", [tracked], function () {
63
+ return [];
64
+ });
65
+ }
66
+ #errors = (i(this, "errors"), void 0);
67
+ /** The rejected local changes of this tab, which rolled back. */
68
+ connection;
69
+ sync;
70
+ #config;
71
+ #db;
72
+ #stops = [];
73
+ #presences = new Map();
74
+ #docs = new Map();
75
+ /** The documents that stop. The database closes after them. */
76
+ #closing = new Set();
77
+
78
+ /** The status that the components show: `online`, `connecting`, `reconnecting` or `offline`. */
79
+ get status() {
80
+ return connectionStatus(this.connectionState, this.online);
81
+ }
82
+
83
+ /** The local user. */
84
+ get user() {
85
+ return this.#configured().user;
86
+ }
87
+
88
+ /**
89
+ * Makes the connection and connects, then starts the sync client when there is a `sink`.
90
+ * Call it once, for example in the application route.
91
+ */
92
+ async configure(config) {
93
+ if (this.#config) throw new Error('Dovetail: the service is already configured.');
94
+ this.#config = config;
95
+ const connection = new Connection({
96
+ ...config.connection,
97
+ transport: config.transport,
98
+ ...(config.getToken ? {
99
+ getToken: config.getToken
100
+ } : {})
101
+ });
102
+ this.connection = connection;
103
+ const read = () => {
104
+ this.connectionState = connection.state.value;
105
+ this.online = connection.isOnline;
106
+ };
107
+ this.#stops.push(connection.onStateChange(read));
108
+ read();
109
+ connection.connect();
110
+ if (!config.sink) return;
111
+ const sync = new SyncClient({
112
+ ...config.sync,
113
+ connection,
114
+ sink: config.sink,
115
+ queue: config.queue ?? new WriteQueue(await this.#database())
116
+ });
117
+ this.sync = sync;
118
+ this.#stops.push(sync.onChange(state => {
119
+ this.queued = state.queued;
120
+ this.deadLetters = state.deadLetters;
121
+ this.errors = state.errors;
122
+ }));
123
+ await sync.start();
124
+ }
125
+
126
+ /** Applies `op` at once, and puts it in the queue for `room`. Resolves with the id of the write. */
127
+ write(room, op) {
128
+ return this.#sync().write(room, op);
129
+ }
130
+
131
+ /** Sends a dead letter again. */
132
+ retry(id) {
133
+ return this.#sync().retry(id);
134
+ }
135
+
136
+ /** Removes a dead letter and the writes that depend on it. Their changes roll back. */
137
+ discard(id) {
138
+ return this.#sync().discard(id);
139
+ }
140
+
141
+ /** Puts the store feed of `room` in the store until `owner` is destroyed. */
142
+ subscribe(owner, room) {
143
+ registerDestructor(owner, this.#sync().subscribe(room));
144
+ }
145
+
146
+ /**
147
+ * The presence of `room` until `owner` is destroyed. All owners of a room share one presence
148
+ * room. When a `doc()` of the room exists, the presence uses the awareness of its document,
149
+ * so call `doc()` first for a room with a document.
150
+ */
151
+ presence(owner, room) {
152
+ return hold(this.#presences, room, owner, () => {
153
+ const config = this.#configured();
154
+ const doc = [...this.#docs.values()].find(entry => entry.value.room === room)?.value;
155
+ const options = doc ? {
156
+ ...config.presence,
157
+ user: config.user,
158
+ awareness: doc.handle.awareness
159
+ } : {
160
+ ...config.presence,
161
+ user: config.user,
162
+ connection: this.#connection(),
163
+ room
164
+ };
165
+ return new LivePresence(room, new PresenceRoom(options));
166
+ }, live => live.destroy());
167
+ }
168
+
169
+ /**
170
+ * A CRDT document of `room` (`engine.create()`), synced by a `DocSession` until `owner` is
171
+ * destroyed. The local updates wait in `docStorage` until the server has them.
172
+ */
173
+ doc(owner, room, engine, options = {}) {
174
+ const name = options.doc ?? 'body';
175
+ return hold(this.#docs, `${room}\n${name}`, owner, () => {
176
+ const config = this.#configured();
177
+ const connection = this.#connection();
178
+ const handle = engine.create();
179
+ // The session listens to the document at once, so an edit before the database opens
180
+ // waits in the storage and is not lost.
181
+ const storage = config.docStorage ?? new IndexedDBDocStorage(this.#database());
182
+ const session = new DocSession({
183
+ connection,
184
+ room,
185
+ doc: name,
186
+ handle,
187
+ storage
188
+ });
189
+ return new LiveDoc(room, handle, () => Promise.resolve(session));
190
+ }, live => {
191
+ const closing = live.destroy();
192
+ this.#closing.add(closing);
193
+ void closing.finally(() => this.#closing.delete(closing));
194
+ });
195
+ }
196
+ willDestroy() {
197
+ super.willDestroy();
198
+ for (const stop of this.#stops.splice(0)) stop();
199
+ const sync = this.sync;
200
+ const connection = this.connection;
201
+ const db = this.#db;
202
+ // `stop()` waits for the queue reads, and the documents for their storage writes, so the
203
+ // database can close after them.
204
+ void waitForPromise((async () => {
205
+ await sync?.stop();
206
+ for (const {
207
+ value
208
+ } of this.#docs.values()) this.#closing.add(value.destroy());
209
+ await Promise.allSettled([...this.#closing]);
210
+ connection?.close();
211
+ (await db)?.close();
212
+ })());
213
+ }
214
+ #configured() {
215
+ if (!this.#config) throw new Error('Dovetail: call `configure()` on the service first.');
216
+ return this.#config;
217
+ }
218
+ #connection() {
219
+ if (!this.connection) throw new Error('Dovetail: call `configure()` on the service first.');
220
+ return this.connection;
221
+ }
222
+ #sync() {
223
+ if (!this.sync) throw new Error('Dovetail: give a `sink` to `configure()` to write.');
224
+ return this.sync;
225
+ }
226
+ #database() {
227
+ this.#db ??= openDovetailDB(this.#config?.dbName);
228
+ return this.#db;
229
+ }
230
+ }
231
+
232
+ export { DovetailService as default };
233
+ //# sourceMappingURL=dovetail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dovetail.js","sources":["../../src/services/dovetail.ts"],"sourcesContent":["// The `dovetail` service: one connection and one sync client for the app, with tracked state\n// for the components, and the live objects of a room (presence, store feed, documents) that\n// stop when their owner is destroyed.\nimport Service from '@ember/service'\nimport { tracked } from '@glimmer/tracking'\nimport { registerDestructor } from '@ember/destroyable'\nimport { waitForPromise } from '@ember/test-waiters'\nimport {\n Connection,\n DocSession,\n IndexedDBDocStorage,\n PresenceRoom,\n SyncClient,\n WriteQueue,\n openDovetailDB,\n} from '@dovetail-ts/core'\nimport type {\n ConnectionOptions,\n DeadLetter,\n DovetailDB,\n LedgerError,\n PresenceRoomOptions,\n PresenceUser,\n StoreSink,\n SyncClientOptions,\n} from '@dovetail-ts/core'\nimport type { DocEngine, DocStorage } from '@dovetail-ts/crdt'\nimport type { StoreOp } from '@dovetail-ts/protocol'\nimport { connectionStatus } from '../status.ts'\nimport type { ConnectionStatus } from '../status.ts'\nimport { LiveDoc, LivePresence } from '../live.ts'\n\n/** The presence timings: the options of `PresenceRoom` without the room and the user. */\nexport type PresenceTimings = Pick<\n PresenceRoomOptions,\n 'clock' | 'awayAfter' | 'typingTimeout' | 'pointerThrottle'\n>\n\n/** What the host gives to `configure()`. */\nexport interface DovetailConfig {\n /** Makes a new transport for each attempt: `() => new WebSocketTransport({ url })`. */\n transport: ConnectionOptions['transport']\n /** The auth hook (ADR 0007). The connection calls it before each attempt. */\n getToken?: ConnectionOptions['getToken']\n /** The local user, for presence and for the editor carets. */\n user: PresenceUser\n /**\n * Where the records of the store feed go: `storeSink(store)` of `@dovetail-ts/warp-drive`.\n * Without it, the service has no sync client: no writes, no queue and no dead letters.\n */\n sink?: StoreSink\n /** The write queue. The default is a `WriteQueue` on the IndexedDB database `dbName`. */\n queue?: WriteQueue\n /** Where the local doc updates wait. The default is IndexedDB, in the database `dbName`. */\n docStorage?: DocStorage\n /** The name of the IndexedDB database. The default is `dovetail`. */\n dbName?: string\n /** The other options of the connection: `network`, `clock`, `heartbeatInterval` and more. */\n connection?: Omit<ConnectionOptions, 'transport' | 'getToken'>\n /** The other options of the sync client: `locks`, `channel`, `lockName` and more. */\n sync?: Omit<SyncClientOptions, 'connection' | 'sink' | 'queue'>\n /** The timings of each presence room. */\n presence?: PresenceTimings\n}\n\n/** The options of `doc()`. */\nexport interface DocOptions {\n /** The name of the document in the room. The default is `body`. */\n doc?: string\n}\n\ninterface Shared<T> {\n value: T\n count: number\n}\n\n/** Counts the owners of a shared object, and calls `release` when the last owner goes. */\nfunction hold<T>(\n map: Map<string, Shared<T>>,\n key: string,\n owner: object,\n make: () => T,\n release: (value: T) => void,\n): T {\n let entry = map.get(key)\n if (!entry) {\n entry = { value: make(), count: 0 }\n map.set(key, entry)\n }\n entry.count++\n const held = entry\n registerDestructor(owner, () => {\n if (--held.count > 0) return\n map.delete(key)\n release(held.value)\n })\n return held.value\n}\n\nexport default class DovetailService extends Service {\n /** The state of the connection: `idle`, `connecting`, `open`, `reconnecting`, `offline` or `closed`. */\n @tracked connectionState = 'idle'\n /** True when the device is online. */\n @tracked online = true\n /** The number of writes in the queue. */\n @tracked queued = 0\n /** The writes that the server rejected. */\n @tracked deadLetters: DeadLetter[] = []\n /** The rejected local changes of this tab, which rolled back. */\n @tracked errors: readonly LedgerError[] = []\n\n connection: Connection | undefined\n sync: SyncClient | undefined\n #config: DovetailConfig | undefined\n #db: Promise<DovetailDB> | undefined\n #stops: (() => void)[] = []\n #presences = new Map<string, Shared<LivePresence>>()\n #docs = new Map<string, Shared<LiveDoc>>()\n /** The documents that stop. The database closes after them. */\n #closing = new Set<Promise<void>>()\n\n /** The status that the components show: `online`, `connecting`, `reconnecting` or `offline`. */\n get status(): ConnectionStatus {\n return connectionStatus(this.connectionState, this.online)\n }\n\n /** The local user. */\n get user(): PresenceUser {\n return this.#configured().user\n }\n\n /**\n * Makes the connection and connects, then starts the sync client when there is a `sink`.\n * Call it once, for example in the application route.\n */\n async configure(config: DovetailConfig): Promise<void> {\n if (this.#config) throw new Error('Dovetail: the service is already configured.')\n this.#config = config\n const connection = new Connection({\n ...config.connection,\n transport: config.transport,\n ...(config.getToken ? { getToken: config.getToken } : {}),\n })\n this.connection = connection\n const read = () => {\n this.connectionState = connection.state.value\n this.online = connection.isOnline\n }\n this.#stops.push(connection.onStateChange(read))\n read()\n connection.connect()\n if (!config.sink) return\n const sync = new SyncClient({\n ...config.sync,\n connection,\n sink: config.sink,\n queue: config.queue ?? new WriteQueue(await this.#database()),\n })\n this.sync = sync\n this.#stops.push(\n sync.onChange(state => {\n this.queued = state.queued\n this.deadLetters = state.deadLetters\n this.errors = state.errors\n }),\n )\n await sync.start()\n }\n\n /** Applies `op` at once, and puts it in the queue for `room`. Resolves with the id of the write. */\n write(room: string, op: StoreOp): Promise<string> {\n return this.#sync().write(room, op)\n }\n\n /** Sends a dead letter again. */\n retry(id: string): Promise<void> {\n return this.#sync().retry(id)\n }\n\n /** Removes a dead letter and the writes that depend on it. Their changes roll back. */\n discard(id: string): Promise<void> {\n return this.#sync().discard(id)\n }\n\n /** Puts the store feed of `room` in the store until `owner` is destroyed. */\n subscribe(owner: object, room: string): void {\n registerDestructor(owner, this.#sync().subscribe(room))\n }\n\n /**\n * The presence of `room` until `owner` is destroyed. All owners of a room share one presence\n * room. When a `doc()` of the room exists, the presence uses the awareness of its document,\n * so call `doc()` first for a room with a document.\n */\n presence(owner: object, room: string): LivePresence {\n return hold(\n this.#presences,\n room,\n owner,\n () => {\n const config = this.#configured()\n const doc = [...this.#docs.values()].find(entry => entry.value.room === room)?.value\n const options: PresenceRoomOptions = doc\n ? { ...config.presence, user: config.user, awareness: doc.handle.awareness }\n : { ...config.presence, user: config.user, connection: this.#connection(), room }\n return new LivePresence(room, new PresenceRoom(options))\n },\n live => live.destroy(),\n )\n }\n\n /**\n * A CRDT document of `room` (`engine.create()`), synced by a `DocSession` until `owner` is\n * destroyed. The local updates wait in `docStorage` until the server has them.\n */\n doc(owner: object, room: string, engine: DocEngine, options: DocOptions = {}): LiveDoc {\n const name = options.doc ?? 'body'\n return hold(\n this.#docs,\n `${room}\\n${name}`,\n owner,\n () => {\n const config = this.#configured()\n const connection = this.#connection()\n const handle = engine.create()\n // The session listens to the document at once, so an edit before the database opens\n // waits in the storage and is not lost.\n const storage = config.docStorage ?? new IndexedDBDocStorage(this.#database())\n const session = new DocSession({ connection, room, doc: name, handle, storage })\n return new LiveDoc(room, handle, () => Promise.resolve(session))\n },\n live => {\n const closing = live.destroy()\n this.#closing.add(closing)\n void closing.finally(() => this.#closing.delete(closing))\n },\n )\n }\n\n willDestroy(): void {\n super.willDestroy()\n for (const stop of this.#stops.splice(0)) stop()\n const sync = this.sync\n const connection = this.connection\n const db = this.#db\n // `stop()` waits for the queue reads, and the documents for their storage writes, so the\n // database can close after them.\n void waitForPromise(\n (async () => {\n await sync?.stop()\n for (const { value } of this.#docs.values()) this.#closing.add(value.destroy())\n await Promise.allSettled([...this.#closing])\n connection?.close()\n ;(await db)?.close()\n })(),\n )\n }\n\n #configured(): DovetailConfig {\n if (!this.#config) throw new Error('Dovetail: call `configure()` on the service first.')\n return this.#config\n }\n\n #connection(): Connection {\n if (!this.connection) throw new Error('Dovetail: call `configure()` on the service first.')\n return this.connection\n }\n\n #sync(): SyncClient {\n if (!this.sync) throw new Error('Dovetail: give a `sink` to `configure()` to write.')\n return this.sync\n }\n\n #database(): Promise<DovetailDB> {\n this.#db ??= openDovetailDB(this.#config?.dbName)\n return this.#db\n }\n}\n\ndeclare module '@ember/service' {\n interface Registry {\n dovetail: DovetailService\n }\n}\n"],"names":["hold","map","key","owner","make","release","entry","get","value","count","set","held","registerDestructor","delete","DovetailService","Service","g","prototype","tracked","i","connection","sync","Map","Set","status","connectionStatus","connectionState","online","user","configure","config","Error","Connection","transport","getToken","read","state","isOnline","push","onStateChange","connect","sink","SyncClient","queue","WriteQueue","onChange","queued","deadLetters","errors","start","write","room","op","retry","id","discard","subscribe","presence","doc","values","find","options","awareness","handle","LivePresence","PresenceRoom","live","destroy","engine","name","create","storage","docStorage","IndexedDBDocStorage","session","DocSession","LiveDoc","Promise","resolve","closing","add","finally","willDestroy","stop","splice","db","waitForPromise","allSettled","close","#configured","#connection","#sync","#database","openDovetailDB","dbName"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AA0EA;AACA,SAASA,IAAIA,CACXC,GAA2B,EAC3BC,GAAW,EACXC,KAAa,EACbC,IAAa,EACbC,OAA2B,EACxB;AACH,EAAA,IAAIC,KAAK,GAAGL,GAAG,CAACM,GAAG,CAACL,GAAG,CAAC;EACxB,IAAI,CAACI,KA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OAAO,IAAI,CAACV,IAAI;AAClB,EAAA;EAEA,SAASuE,GAAwB;AAC/B,IAAA,IAAI,CAAC,GAAG,KAAKC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAEC,MAAM,CAAC;IACjD,OAAO,IAAI,CAAC,GAAG;AACjB,EAAA;AACF;;"}
@@ -0,0 +1,59 @@
1
+ // The texts of the status components. They are plain functions, so the unit tests check each
2
+ // case without a browser.
3
+
4
+ /** What the connection badge shows. */
5
+
6
+ /** The status of a connection state (`Connection.state.value`) and the online state of the device. */
7
+ function connectionStatus(state, online) {
8
+ if (!online) return 'offline';
9
+ if (state === 'open') return 'online';
10
+ if (state === 'reconnecting') return 'reconnecting';
11
+ if (state === 'offline' || state === 'closed') return 'offline';
12
+ return 'connecting';
13
+ }
14
+ const CONNECTION_LABELS = {
15
+ online: 'Online',
16
+ connecting: 'Connecting',
17
+ reconnecting: 'Reconnecting',
18
+ offline: 'Offline'
19
+ };
20
+
21
+ /** The text of the connection badge: `Online`, or `Offline · 3 queued`. */
22
+ function connectionLabel(status, queued) {
23
+ const label = CONNECTION_LABELS[status];
24
+ return queued > 0 ? `${label} · ${queued} queued` : label;
25
+ }
26
+
27
+ /** What the sync status shows. */
28
+
29
+ const changes = count => count === 1 ? '1 change' : `${count} changes`;
30
+
31
+ /** The state and the text of the sync status, from the connection status and the queued count. */
32
+ function syncStatus(status, queued) {
33
+ if (status === 'offline') {
34
+ const text = queued === 0 ? 'Offline: all changes saved' : `Offline: ${changes(queued)} ${queued === 1 ? 'waits' : 'wait'}`;
35
+ return {
36
+ state: 'offline',
37
+ text
38
+ };
39
+ }
40
+ if (queued === 0) return {
41
+ state: 'saved',
42
+ text: 'Saved'
43
+ };
44
+ return {
45
+ state: 'syncing',
46
+ text: `Syncing ${changes(queued)}`
47
+ };
48
+ }
49
+
50
+ /** The text of the typing indicator: `Ana is typing`, `Ana and Ben are typing`, `3 people are typing`. */
51
+ function typingText(names) {
52
+ if (names.length === 0) return '';
53
+ if (names.length === 1) return `${names[0]} is typing`;
54
+ if (names.length === 2) return `${names[0]} and ${names[1]} are typing`;
55
+ return `${names.length} people are typing`;
56
+ }
57
+
58
+ export { connectionStatus as a, connectionLabel as c, syncStatus as s, typingText as t };
59
+ //# sourceMappingURL=status-CYJBlnG7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-CYJBlnG7.js","sources":["../src/status.ts"],"sourcesContent":["// The texts of the status components. They are plain functions, so the unit tests check each\n// case without a browser.\n\n/** What the connection badge shows. */\nexport type ConnectionStatus = 'online' | 'connecting' | 'reconnecting' | 'offline'\n\n/** The status of a connection state (`Connection.state.value`) and the online state of the device. */\nexport function connectionStatus(state: string, online: boolean): ConnectionStatus {\n if (!online) return 'offline'\n if (state === 'open') return 'online'\n if (state === 'reconnecting') return 'reconnecting'\n if (state === 'offline' || state === 'closed') return 'offline'\n return 'connecting'\n}\n\nconst CONNECTION_LABELS: Record<ConnectionStatus, string> = {\n online: 'Online',\n connecting: 'Connecting',\n reconnecting: 'Reconnecting',\n offline: 'Offline',\n}\n\n/** The text of the connection badge: `Online`, or `Offline · 3 queued`. */\nexport function connectionLabel(status: ConnectionStatus, queued: number): string {\n const label = CONNECTION_LABELS[status]\n return queued > 0 ? `${label} · ${queued} queued` : label\n}\n\n/** What the sync status shows. */\nexport type SyncStatusState = 'saved' | 'syncing' | 'offline'\n\nconst changes = (count: number) => (count === 1 ? '1 change' : `${count} changes`)\n\n/** The state and the text of the sync status, from the connection status and the queued count. */\nexport function syncStatus(\n status: ConnectionStatus,\n queued: number,\n): { state: SyncStatusState; text: string } {\n if (status === 'offline') {\n const text =\n queued === 0\n ? 'Offline: all changes saved'\n : `Offline: ${changes(queued)} ${queued === 1 ? 'waits' : 'wait'}`\n return { state: 'offline', text }\n }\n if (queued === 0) return { state: 'saved', text: 'Saved' }\n return { state: 'syncing', text: `Syncing ${changes(queued)}` }\n}\n\n/** The text of the typing indicator: `Ana is typing`, `Ana and Ben are typing`, `3 people are typing`. */\nexport function typingText(names: readonly string[]): string {\n if (names.length === 0) return ''\n if (names.length === 1) return `${names[0]} is typing`\n if (names.length === 2) return `${names[0]} and ${names[1]} are typing`\n return `${names.length} people are typing`\n}\n"],"names":["connectionStatus","state","online","CONNECTION_LABELS","connecting","reconnecting","offline","connectionLabel","status","queued","label","changes","count","syncStatus","text","typingText","names","length"],"mappings":"AAAA;AACA;;AAEA;;AAGA;AACO,SAASA,gBAAgBA,CAACC,KAAa,EAAEC,MAAe,EAAoB;AACjF,EAAA,IAAI,CAACA,MAAM,EAAE,OAAO,SAAS;AAC7B,EAAA,IAAID,KAAK,KAAK,MAAM,EAAE,OAAO,QAAQ;AACrC,EAAA,IAAIA,KAAK,KAAK,cAAc,EAAE,OAAO,cAAc;EACnD,IAAIA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,QAAQ,EAAE,OAAO,SAAS;AAC/D,EAAA,OAAO,YAAY;AACrB;AAEA,MAAME,iBAAmD,GAAG;AAC1DD,EAAAA,MAAM,EAAE,QAAQ;AAChBE,EAAAA,UAAU,EAAE,YAAY;AACxBC,EAAAA,YAAY,EAAE,cAAc;AAC5BC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAED;AACO,SAASC,eAAeA,CAACC,MAAwB,EAAEC,MAAc,EAAU;AAChF,EAAA,MAAMC,KAAK,GAAGP,iBAAiB,CAACK,MAAM,CAAC;EACvC,OAAOC,MAAM,GAAG,CAAC,GAAG,CAAA,EAAGC,KAAK,CAAA,GAAA,EAAMD,MAAM,CAAA,OAAA,CAAS,GAAGC,KAAK;AAC3D;;AAEA;;AAGA,MAAMC,OAAO,GAAIC,KAAa,IAAMA,KAAK,KAAK,CAAC,GAAG,UAAU,GAAG,CAAA,EAAGA,KAAK,CAAA,QAAA,CAAW;;AAElF;AACO,SAASC,UAAUA,CACxBL,MAAwB,EACxBC,MAAc,EAC4B;EAC1C,IAAID,MAAM,KAAK,SAAS,EAAE;IACxB,MAAMM,IAAI,GACRL,MAAM,KAAK,CAAC,GACR,4BAA4B,GAC5B,CAAA,SAAA,EAAYE,OAAO,CAACF,MAAM,CAAC,IAAIA,MAAM,KAAK,CAAC,GAAG,OAAO,GAAG,MAAM,CAAA,CAAE;IACtE,OAAO;AAAER,MAAAA,KAAK,EAAE,SAAS;AAAEa,MAAAA;KAAM;AACnC,EAAA;AACA,EAAA,IAAIL,MAAM,KAAK,CAAC,EAAE,OAAO;AAAER,IAAAA,KAAK,EAAE,OAAO;AAAEa,IAAAA,IAAI,EAAE;GAAS;EAC1D,OAAO;AAAEb,IAAAA,KAAK,EAAE,SAAS;AAAEa,IAAAA,IAAI,EAAE,CAAA,QAAA,EAAWH,OAAO,CAACF,MAAM,CAAC,CAAA;GAAI;AACjE;;AAEA;AACO,SAASM,UAAUA,CAACC,KAAwB,EAAU;AAC3D,EAAA,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE;AACjC,EAAA,IAAID,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAA,EAAGD,KAAK,CAAC,CAAC,CAAC,CAAA,UAAA,CAAY;AACtD,EAAA,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAA,EAAGD,KAAK,CAAC,CAAC,CAAC,CAAA,KAAA,EAAQA,KAAK,CAAC,CAAC,CAAC,CAAA,WAAA,CAAa;AACvE,EAAA,OAAO,CAAA,EAAGA,KAAK,CAACC,MAAM,CAAA,kBAAA,CAAoB;AAC5C;;"}
@@ -0,0 +1,31 @@
1
+ import { htmlSafe } from '@ember/template';
2
+ import { precompileTemplate } from '@ember/template-compilation';
3
+ import { setComponentTemplate } from '@ember/component';
4
+ import templateOnly from '@ember/component/template-only';
5
+
6
+ const AMBER = 'var(--dovetail-away, oklch(0.769 0.188 70.08))';
7
+ const COLORS = {
8
+ online: 'var(--dovetail-online, oklch(0.627 0.194 149.214))',
9
+ away: AMBER,
10
+ connecting: AMBER,
11
+ reconnecting: AMBER,
12
+ offline: 'var(--muted-foreground)'
13
+ };
14
+ /** The background of a dot. The values are constants, not user input, so they are safe. */
15
+ function dotColor(status) {
16
+ return htmlSafe(`background: ${COLORS[status] ?? COLORS['offline']}`);
17
+ }
18
+ /** The style of a dot. */
19
+ function dotStyle(status) {
20
+ return htmlSafe(`display: inline-block; inline-size: 0.5rem; block-size: 0.5rem; border-radius: 9999px; ${dotColor(status).toString()}`);
21
+ }
22
+ /** A small colored dot for a status. It is only decoration: the text says the status. */
23
+ const StatusDot = setComponentTemplate(precompileTemplate("<span aria-hidden=\"true\" data-status={{@status}} style={{dotStyle @status}} ...attributes></span>", {
24
+ strictMode: true,
25
+ scope: () => ({
26
+ dotStyle
27
+ })
28
+ }), templateOnly());
29
+
30
+ export { StatusDot as S, dotColor as d };
31
+ //# sourceMappingURL=status-dot-DSQMdQhW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-dot-DSQMdQhW.js","sources":["../src/-private/status-dot.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only'\nimport { htmlSafe } from '@ember/template'\n\n// The colors of the dots. Joinery has no token for a green or an amber, so each one is a\n// Dovetail token with a default that the host can change.\nconst AMBER = 'var(--dovetail-away, oklch(0.769 0.188 70.08))'\nconst COLORS: Record<string, string> = {\n online: 'var(--dovetail-online, oklch(0.627 0.194 149.214))',\n away: AMBER,\n connecting: AMBER,\n reconnecting: AMBER,\n offline: 'var(--muted-foreground)',\n}\n\n/** The background of a dot. The values are constants, not user input, so they are safe. */\nexport function dotColor(status: string) {\n return htmlSafe(`background: ${COLORS[status] ?? COLORS['offline']}`)\n}\n\n/** The style of a dot. */\nexport function dotStyle(status: string) {\n return htmlSafe(\n `display: inline-block; inline-size: 0.5rem; block-size: 0.5rem; border-radius: 9999px; ${dotColor(status).toString()}`,\n )\n}\n\n/** A small colored dot for a status. It is only decoration: the text says the status. */\nconst StatusDot: TOC<{ Args: { status: string }; Element: HTMLSpanElement }> = <template>\n <span aria-hidden='true' data-status={{@status}} style={{dotStyle @status}} ...attributes></span>\n</template>\n\nexport default StatusDot\n"],"names":["AMBER","COLORS","online","away","connecting","reconnecting","offline","dotColor","status","htmlSafe","dotStyle","toString","StatusDot","precompileTemplate","strictMode","scope","templateOnly"],"mappings":";;;;;AAKA,MAAMA,KAAA,GAAQ,gDAAA;AACd,MAAMC,MAA6B,GAAI;AACrCC,EAAAA,MAAA,EAAQ,oDAAA;AACRC,EAAAA,IAAA,EAAMH,KAAA;AACNI,EAAAA,UAAA,EAAYJ,KAAA;AACZK,EAAAA,YAAA,EAAcL,KAAA;AACdM,EAAAA,OAAA,EAAS;AACX,CAAA;AAEA;AACO,SAASC,QAAAA,CAASC,MAAc,EAAA;AACrC,EAAA,OAAOC,QAAA,CAAS,CAAA,YAAA,EAAeR,MAAM,CAACO,MAAA,CAAO,IAAIP,MAAM,CAAC,SAAA,CAAU,EAAE,CAAA;AACtE;AAEA;AACO,SAASS,QAAAA,CAASF,MAAc,EAAA;AACrC,EAAA,OAAOC,SACL,CAAA,uFAAA,EAA0FF,QAAA,CAASC,MAAA,CAAA,CAAQG,QAAQ,EAAA,CAAA,CAAI,CAAA;AAE3H;AAEA;AACA,MAAMC,iCAAyEC,kBAAA,CAAA,qGAAA,EAE/E;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAL,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAM,YAAA,EAAA;;"}
@@ -0,0 +1,27 @@
1
+ /* The remote carets of <Dovetail::Editor> (the classes of @tiptap/extension-collaboration-caret),
2
+ and the comment anchors of @dovetail-ts/tiptap. */
3
+ .collaboration-carets__caret {
4
+ position: relative;
5
+ margin-inline: -1px;
6
+ border-inline: 1px solid currentColor;
7
+ word-break: normal;
8
+ pointer-events: none;
9
+ }
10
+
11
+ .collaboration-carets__label {
12
+ position: absolute;
13
+ inset-block-start: -1.4em;
14
+ inset-inline-start: -1px;
15
+ padding: 0.1rem 0.3rem;
16
+ border-radius: 0.25rem 0.25rem 0.25rem 0;
17
+ font-size: 0.75rem;
18
+ font-weight: 600;
19
+ line-height: normal;
20
+ white-space: nowrap;
21
+ color: white;
22
+ user-select: none;
23
+ }
24
+
25
+ .dovetail-comment {
26
+ background: color-mix(in oklch, var(--dovetail-away, oklch(0.769 0.188 70.08)) 30%, transparent);
27
+ }
@@ -0,0 +1,10 @@
1
+ import { htmlSafe } from '@ember/template';
2
+
3
+ /**
4
+ * The style of text that a screen reader reads but the screen does not show. It is inline, so
5
+ * the host needs no `.sr-only` class and no CSS of the addon.
6
+ */
7
+ const VISUALLY_HIDDEN = htmlSafe('position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap');
8
+
9
+ export { VISUALLY_HIDDEN as V };
10
+ //# sourceMappingURL=visually-hidden-BFhJXHGu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visually-hidden-BFhJXHGu.js","sources":["../src/-private/visually-hidden.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template'\n\n/**\n * The style of text that a screen reader reads but the screen does not show. It is inline, so\n * the host needs no `.sr-only` class and no CSS of the addon.\n */\nexport const VISUALLY_HIDDEN = htmlSafe(\n 'position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap',\n)\n"],"names":["VISUALLY_HIDDEN","htmlSafe"],"mappings":";;AAEA;AACA;AACA;AACA;MACaA,eAAe,GAAGC,QAAQ,CACrC,gJACF;;"}
package/package.json CHANGED
@@ -1,6 +1,124 @@
1
1
  {
2
2
  "name": "@dovetail-ts/ember",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "Dovetail for Ember: services, resources and the Joinery-based presence and status components.",
5
+ "license": "MIT",
6
+ "author": "Joe Gaudet <joe@joegaudet.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/joegaudet/dovetail.git",
10
+ "directory": "packages/ember"
11
+ },
12
+ "homepage": "https://joegaudet.com/dovetail/",
13
+ "bugs": "https://github.com/joegaudet/dovetail/issues",
14
+ "keywords": [
15
+ "ember-addon",
16
+ "ember",
17
+ "realtime",
18
+ "offline",
19
+ "sync"
20
+ ],
21
+ "exports": {
22
+ ".": {
23
+ "types": "./declarations/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./*": {
27
+ "types": "./declarations/*.d.ts",
28
+ "default": "./dist/*.js"
29
+ },
30
+ "./addon-main.js": "./addon-main.cjs"
31
+ },
32
+ "typesVersions": {
33
+ "*": {
34
+ "*": [
35
+ "declarations/*"
36
+ ]
37
+ }
38
+ },
39
+ "files": [
40
+ "addon-main.cjs",
41
+ "declarations",
42
+ "dist",
43
+ "README.md",
44
+ "CHANGELOG.md",
45
+ "LICENSE"
46
+ ],
47
+ "dependencies": {
48
+ "@dovetail-ts/core": "1.0.1",
49
+ "@dovetail-ts/crdt": "1.0.1",
50
+ "@dovetail-ts/crdt-yjs": "1.0.1",
51
+ "@dovetail-ts/protocol": "1.0.1",
52
+ "@dovetail-ts/tiptap": "1.0.1",
53
+ "@dovetail-ts/warp-drive": "1.0.1",
54
+ "@ember-joinery/ember": "^1.0.1",
55
+ "@ember/test-waiters": "^4.1.2",
56
+ "@embroider/addon-shim": "^1.10.3",
57
+ "decorator-transforms": "^2.4.0",
58
+ "ember-modifier": "^4.3.0"
59
+ },
60
+ "peerDependencies": {
61
+ "@glimmer/component": ">= 2.0.0",
62
+ "@tiptap/core": "^3.35.1",
63
+ "@tiptap/extension-collaboration": "^3.35.1",
64
+ "@tiptap/extension-collaboration-caret": "^3.35.1",
65
+ "@tiptap/pm": "^3.35.1",
66
+ "@tiptap/starter-kit": "^3.35.1",
67
+ "@tiptap/y-tiptap": "^3.3.1",
68
+ "ember-source": ">= 6.12.0",
69
+ "yjs": "^13.6.33"
70
+ },
71
+ "devDependencies": {
72
+ "@babel/core": "^7.29.7",
73
+ "@babel/plugin-transform-typescript": "^7.29.7",
74
+ "@babel/runtime": "^7.29.7",
75
+ "@ember/library-tsconfig": "^3.0.0",
76
+ "@embroider/addon-dev": "^8.4.2",
77
+ "@glimmer/component": "^2.2.1",
78
+ "@glimmer/tracking": "^1.1.2",
79
+ "@glint/ember-tsc": "^1.14.2",
80
+ "@glint/template": "^1.9.0",
81
+ "@rollup/plugin-babel": "^7.1.0",
82
+ "@tiptap/core": "^3.35.1",
83
+ "@tiptap/extension-collaboration": "^3.35.1",
84
+ "@tiptap/extension-collaboration-caret": "^3.35.1",
85
+ "@tiptap/pm": "^3.35.1",
86
+ "@tiptap/starter-kit": "^3.35.1",
87
+ "@tiptap/y-tiptap": "^3.3.1",
88
+ "babel-plugin-ember-template-compilation": "^4.0.1",
89
+ "ember-source": "~7.3.0",
90
+ "rollup": "^4.64.6",
91
+ "typescript": "~6.0.3",
92
+ "yjs": "^13.6.33"
93
+ },
94
+ "publishConfig": {
95
+ "access": "public"
96
+ },
97
+ "engines": {
98
+ "node": ">=22.12.0"
99
+ },
100
+ "ember": {
101
+ "edition": "octane"
102
+ },
103
+ "ember-addon": {
104
+ "version": 2,
105
+ "type": "addon",
106
+ "main": "addon-main.cjs",
107
+ "app-js": {
108
+ "./components/dovetail/avatar-stack.js": "./dist/_app_/components/dovetail/avatar-stack.js",
109
+ "./components/dovetail/connection-badge.js": "./dist/_app_/components/dovetail/connection-badge.js",
110
+ "./components/dovetail/dead-letters.js": "./dist/_app_/components/dovetail/dead-letters.js",
111
+ "./components/dovetail/editor.js": "./dist/_app_/components/dovetail/editor.js",
112
+ "./components/dovetail/live-cursors.js": "./dist/_app_/components/dovetail/live-cursors.js",
113
+ "./components/dovetail/presence.js": "./dist/_app_/components/dovetail/presence.js",
114
+ "./components/dovetail/sync-status.js": "./dist/_app_/components/dovetail/sync-status.js",
115
+ "./components/dovetail/typing.js": "./dist/_app_/components/dovetail/typing.js",
116
+ "./services/dovetail.js": "./dist/_app_/services/dovetail.js"
117
+ }
118
+ },
119
+ "scripts": {
120
+ "build": "rm -rf declarations && rollup --config",
121
+ "start": "rm -rf declarations && rollup --config --watch",
122
+ "typecheck": "ember-tsc --noEmit && ember-tsc --noEmit -p tests/tsconfig.json"
123
+ }
6
124
  }