@lark-sh/client 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +31 -4
- package/dist/index.d.ts +31 -4
- package/dist/index.js +473 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +473 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport factory - creates appropriate transport based on availability and options.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
type TransportType = 'auto' | 'websocket' | 'webtransport';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* OnDisconnect - registers operations to perform on the server when this client disconnects.
|
|
3
9
|
*/
|
|
@@ -336,11 +342,17 @@ interface TxDeleteOp {
|
|
|
336
342
|
o: 'd';
|
|
337
343
|
p: string;
|
|
338
344
|
}
|
|
339
|
-
interface
|
|
345
|
+
interface TxConditionValueOp {
|
|
340
346
|
o: 'c';
|
|
341
347
|
p: string;
|
|
342
348
|
v: unknown;
|
|
343
349
|
}
|
|
350
|
+
interface TxConditionHashOp {
|
|
351
|
+
o: 'c';
|
|
352
|
+
p: string;
|
|
353
|
+
h: string;
|
|
354
|
+
}
|
|
355
|
+
type TxConditionOp = TxConditionValueOp | TxConditionHashOp;
|
|
344
356
|
type TxOperation = TxSetOp | TxUpdateOp | TxDeleteOp | TxConditionOp;
|
|
345
357
|
|
|
346
358
|
/**
|
|
@@ -372,6 +384,13 @@ interface ConnectOptions {
|
|
|
372
384
|
anonymous?: boolean;
|
|
373
385
|
/** Coordinator URL (default: https://db.lark.dev) */
|
|
374
386
|
coordinator?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Transport type preference.
|
|
389
|
+
* - 'auto': Try WebTransport first, fall back to WebSocket (default)
|
|
390
|
+
* - 'websocket': Force WebSocket only
|
|
391
|
+
* - 'webtransport': Force WebTransport only (fails if unavailable)
|
|
392
|
+
*/
|
|
393
|
+
transport?: TransportType;
|
|
375
394
|
}
|
|
376
395
|
interface AuthInfo {
|
|
377
396
|
uid: string;
|
|
@@ -412,12 +431,13 @@ declare class LarkDatabase {
|
|
|
412
431
|
private _databaseId;
|
|
413
432
|
private _coordinatorUrl;
|
|
414
433
|
private _volatilePaths;
|
|
434
|
+
private _transportType;
|
|
415
435
|
private _connectionId;
|
|
416
436
|
private _connectOptions;
|
|
417
437
|
private _intentionalDisconnect;
|
|
418
438
|
private _reconnectAttempt;
|
|
419
439
|
private _reconnectTimer;
|
|
420
|
-
private
|
|
440
|
+
private transport;
|
|
421
441
|
private messageQueue;
|
|
422
442
|
private subscriptionManager;
|
|
423
443
|
private pendingWrites;
|
|
@@ -449,9 +469,13 @@ declare class LarkDatabase {
|
|
|
449
469
|
/**
|
|
450
470
|
* Get the volatile path patterns from the server.
|
|
451
471
|
* These patterns indicate which paths should use unreliable transport.
|
|
452
|
-
* WebSocket always uses reliable transport, but this is stored for future UDP support.
|
|
453
472
|
*/
|
|
454
473
|
get volatilePaths(): string[];
|
|
474
|
+
/**
|
|
475
|
+
* Get the current transport type.
|
|
476
|
+
* Returns 'websocket' or 'webtransport', or null if not connected.
|
|
477
|
+
*/
|
|
478
|
+
get transportType(): 'websocket' | 'webtransport' | null;
|
|
455
479
|
/**
|
|
456
480
|
* Check if there are any pending writes waiting for acknowledgment.
|
|
457
481
|
* Useful for showing "saving..." indicators in UI.
|
|
@@ -543,6 +567,7 @@ declare class LarkDatabase {
|
|
|
543
567
|
transaction(operations: TransactionOp[] | TransactionObject): Promise<void>;
|
|
544
568
|
/**
|
|
545
569
|
* Convert a public TransactionOp to wire format TxOperation.
|
|
570
|
+
* Async because condition operations may require hash computation.
|
|
546
571
|
*/
|
|
547
572
|
private convertToTxOp;
|
|
548
573
|
/**
|
|
@@ -603,6 +628,8 @@ declare class LarkDatabase {
|
|
|
603
628
|
*
|
|
604
629
|
* The write is applied optimistically to local cache for UI feedback,
|
|
605
630
|
* but we don't await server confirmation.
|
|
631
|
+
*
|
|
632
|
+
* When using WebTransport, volatile writes are sent via datagrams (UDP).
|
|
606
633
|
*/
|
|
607
634
|
_sendVolatileSet(path: string, value: unknown): void;
|
|
608
635
|
/**
|
|
@@ -773,4 +800,4 @@ declare function generatePushId(): string;
|
|
|
773
800
|
*/
|
|
774
801
|
declare function isVolatilePath(path: string, patterns: string[] | null | undefined): boolean;
|
|
775
802
|
|
|
776
|
-
export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };
|
|
803
|
+
export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type TransportType, type WriteOperation, generatePushId, isVolatilePath };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport factory - creates appropriate transport based on availability and options.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
type TransportType = 'auto' | 'websocket' | 'webtransport';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* OnDisconnect - registers operations to perform on the server when this client disconnects.
|
|
3
9
|
*/
|
|
@@ -336,11 +342,17 @@ interface TxDeleteOp {
|
|
|
336
342
|
o: 'd';
|
|
337
343
|
p: string;
|
|
338
344
|
}
|
|
339
|
-
interface
|
|
345
|
+
interface TxConditionValueOp {
|
|
340
346
|
o: 'c';
|
|
341
347
|
p: string;
|
|
342
348
|
v: unknown;
|
|
343
349
|
}
|
|
350
|
+
interface TxConditionHashOp {
|
|
351
|
+
o: 'c';
|
|
352
|
+
p: string;
|
|
353
|
+
h: string;
|
|
354
|
+
}
|
|
355
|
+
type TxConditionOp = TxConditionValueOp | TxConditionHashOp;
|
|
344
356
|
type TxOperation = TxSetOp | TxUpdateOp | TxDeleteOp | TxConditionOp;
|
|
345
357
|
|
|
346
358
|
/**
|
|
@@ -372,6 +384,13 @@ interface ConnectOptions {
|
|
|
372
384
|
anonymous?: boolean;
|
|
373
385
|
/** Coordinator URL (default: https://db.lark.dev) */
|
|
374
386
|
coordinator?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Transport type preference.
|
|
389
|
+
* - 'auto': Try WebTransport first, fall back to WebSocket (default)
|
|
390
|
+
* - 'websocket': Force WebSocket only
|
|
391
|
+
* - 'webtransport': Force WebTransport only (fails if unavailable)
|
|
392
|
+
*/
|
|
393
|
+
transport?: TransportType;
|
|
375
394
|
}
|
|
376
395
|
interface AuthInfo {
|
|
377
396
|
uid: string;
|
|
@@ -412,12 +431,13 @@ declare class LarkDatabase {
|
|
|
412
431
|
private _databaseId;
|
|
413
432
|
private _coordinatorUrl;
|
|
414
433
|
private _volatilePaths;
|
|
434
|
+
private _transportType;
|
|
415
435
|
private _connectionId;
|
|
416
436
|
private _connectOptions;
|
|
417
437
|
private _intentionalDisconnect;
|
|
418
438
|
private _reconnectAttempt;
|
|
419
439
|
private _reconnectTimer;
|
|
420
|
-
private
|
|
440
|
+
private transport;
|
|
421
441
|
private messageQueue;
|
|
422
442
|
private subscriptionManager;
|
|
423
443
|
private pendingWrites;
|
|
@@ -449,9 +469,13 @@ declare class LarkDatabase {
|
|
|
449
469
|
/**
|
|
450
470
|
* Get the volatile path patterns from the server.
|
|
451
471
|
* These patterns indicate which paths should use unreliable transport.
|
|
452
|
-
* WebSocket always uses reliable transport, but this is stored for future UDP support.
|
|
453
472
|
*/
|
|
454
473
|
get volatilePaths(): string[];
|
|
474
|
+
/**
|
|
475
|
+
* Get the current transport type.
|
|
476
|
+
* Returns 'websocket' or 'webtransport', or null if not connected.
|
|
477
|
+
*/
|
|
478
|
+
get transportType(): 'websocket' | 'webtransport' | null;
|
|
455
479
|
/**
|
|
456
480
|
* Check if there are any pending writes waiting for acknowledgment.
|
|
457
481
|
* Useful for showing "saving..." indicators in UI.
|
|
@@ -543,6 +567,7 @@ declare class LarkDatabase {
|
|
|
543
567
|
transaction(operations: TransactionOp[] | TransactionObject): Promise<void>;
|
|
544
568
|
/**
|
|
545
569
|
* Convert a public TransactionOp to wire format TxOperation.
|
|
570
|
+
* Async because condition operations may require hash computation.
|
|
546
571
|
*/
|
|
547
572
|
private convertToTxOp;
|
|
548
573
|
/**
|
|
@@ -603,6 +628,8 @@ declare class LarkDatabase {
|
|
|
603
628
|
*
|
|
604
629
|
* The write is applied optimistically to local cache for UI feedback,
|
|
605
630
|
* but we don't await server confirmation.
|
|
631
|
+
*
|
|
632
|
+
* When using WebTransport, volatile writes are sent via datagrams (UDP).
|
|
606
633
|
*/
|
|
607
634
|
_sendVolatileSet(path: string, value: unknown): void;
|
|
608
635
|
/**
|
|
@@ -773,4 +800,4 @@ declare function generatePushId(): string;
|
|
|
773
800
|
*/
|
|
774
801
|
declare function isVolatilePath(path: string, patterns: string[] | null | undefined): boolean;
|
|
775
802
|
|
|
776
|
-
export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };
|
|
803
|
+
export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type TransportType, type WriteOperation, generatePushId, isVolatilePath };
|