arethesis 0.0.0-stage → 0.1.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/CHANGELOG.md +34 -0
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/dist/arethesis-z8eGA7mL.js +5177 -0
- package/dist/arethesis-z8eGA7mL.js.map +1 -0
- package/dist/arethesis.js +147 -0
- package/dist/arethesis.js.map +1 -0
- package/dist/binding/data-binder.d.ts +82 -0
- package/dist/binding/data-binder.d.ts.map +1 -0
- package/dist/binding/types.d.ts +119 -0
- package/dist/binding/types.d.ts.map +1 -0
- package/dist/binding/validation-engine.d.ts +22 -0
- package/dist/binding/validation-engine.d.ts.map +1 -0
- package/dist/components/component.d.ts +93 -0
- package/dist/components/component.d.ts.map +1 -0
- package/dist/components/decorators.d.ts +9 -0
- package/dist/components/decorators.d.ts.map +1 -0
- package/dist/components/runtime.d.ts +17 -0
- package/dist/components/runtime.d.ts.map +1 -0
- package/dist/components/template-loader.d.ts +37 -0
- package/dist/components/template-loader.d.ts.map +1 -0
- package/dist/components/types.d.ts +22 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components.js +568 -0
- package/dist/components.js.map +1 -0
- package/dist/core/arethesis.d.ts +96 -0
- package/dist/core/arethesis.d.ts.map +1 -0
- package/dist/core/types.d.ts +40 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/data/list-view-registry.d.ts +69 -0
- package/dist/data/list-view-registry.d.ts.map +1 -0
- package/dist/data/object-store.d.ts +88 -0
- package/dist/data/object-store.d.ts.map +1 -0
- package/dist/data/optimistic-updates.d.ts +59 -0
- package/dist/data/optimistic-updates.d.ts.map +1 -0
- package/dist/data/persistence-manager.d.ts +56 -0
- package/dist/data/persistence-manager.d.ts.map +1 -0
- package/dist/data/types.d.ts +145 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/http/auth-manager.d.ts +60 -0
- package/dist/http/auth-manager.d.ts.map +1 -0
- package/dist/http/http-client.d.ts +77 -0
- package/dist/http/http-client.d.ts.map +1 -0
- package/dist/http/http-error.d.ts +35 -0
- package/dist/http/http-error.d.ts.map +1 -0
- package/dist/http/mapping.d.ts +21 -0
- package/dist/http/mapping.d.ts.map +1 -0
- package/dist/http/types.d.ts +237 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/kit/data-table.d.ts +57 -0
- package/dist/kit/data-table.d.ts.map +1 -0
- package/dist/kit/flex-view.d.ts +42 -0
- package/dist/kit/flex-view.d.ts.map +1 -0
- package/dist/kit/form.d.ts +13 -0
- package/dist/kit/form.d.ts.map +1 -0
- package/dist/kit/index.d.ts +18 -0
- package/dist/kit/index.d.ts.map +1 -0
- package/dist/kit/list.d.ts +10 -0
- package/dist/kit/list.d.ts.map +1 -0
- package/dist/mixins/context-menu.d.ts +3 -0
- package/dist/mixins/context-menu.d.ts.map +1 -0
- package/dist/mixins/draggable.d.ts +3 -0
- package/dist/mixins/draggable.d.ts.map +1 -0
- package/dist/mixins/dropdown.d.ts +3 -0
- package/dist/mixins/dropdown.d.ts.map +1 -0
- package/dist/mixins/editable.d.ts +3 -0
- package/dist/mixins/editable.d.ts.map +1 -0
- package/dist/mixins/grid-navigation.d.ts +3 -0
- package/dist/mixins/grid-navigation.d.ts.map +1 -0
- package/dist/mixins/index.d.ts +19 -0
- package/dist/mixins/index.d.ts.map +1 -0
- package/dist/mixins/infinite-scroll.d.ts +3 -0
- package/dist/mixins/infinite-scroll.d.ts.map +1 -0
- package/dist/mixins/registry.d.ts +41 -0
- package/dist/mixins/registry.d.ts.map +1 -0
- package/dist/mixins/resizable.d.ts +3 -0
- package/dist/mixins/resizable.d.ts.map +1 -0
- package/dist/mixins/sortable.d.ts +3 -0
- package/dist/mixins/sortable.d.ts.map +1 -0
- package/dist/mixins/tooltip.d.ts +3 -0
- package/dist/mixins/tooltip.d.ts.map +1 -0
- package/dist/mixins/types.d.ts +165 -0
- package/dist/mixins/types.d.ts.map +1 -0
- package/dist/mixins/utils.d.ts +22 -0
- package/dist/mixins/utils.d.ts.map +1 -0
- package/dist/plugins/async-validators.d.ts +9 -0
- package/dist/plugins/async-validators.d.ts.map +1 -0
- package/dist/plugins/builtins.d.ts +9 -0
- package/dist/plugins/builtins.d.ts.map +1 -0
- package/dist/plugins/date-utils.d.ts +16 -0
- package/dist/plugins/date-utils.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +29 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/rich-text.d.ts +15 -0
- package/dist/plugins/rich-text.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +50 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/realtime/azure-pubsub-manager.d.ts +49 -0
- package/dist/realtime/azure-pubsub-manager.d.ts.map +1 -0
- package/dist/realtime/collab/collab-session.d.ts +75 -0
- package/dist/realtime/collab/collab-session.d.ts.map +1 -0
- package/dist/realtime/collab/cursor-overlay.d.ts +20 -0
- package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -0
- package/dist/realtime/collab/textarea-adapter.d.ts +27 -0
- package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -0
- package/dist/realtime/ot/client.d.ts +27 -0
- package/dist/realtime/ot/client.d.ts.map +1 -0
- package/dist/realtime/ot/server.d.ts +36 -0
- package/dist/realtime/ot/server.d.ts.map +1 -0
- package/dist/realtime/ot/text-operation.d.ts +55 -0
- package/dist/realtime/ot/text-operation.d.ts.map +1 -0
- package/dist/realtime/reconnect.d.ts +22 -0
- package/dist/realtime/reconnect.d.ts.map +1 -0
- package/dist/realtime/sse-manager.d.ts +37 -0
- package/dist/realtime/sse-manager.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +122 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/websocket-manager.d.ts +34 -0
- package/dist/realtime/websocket-manager.d.ts.map +1 -0
- package/dist/theme.css +516 -0
- package/dist/utils/backoff.d.ts +18 -0
- package/dist/utils/backoff.d.ts.map +1 -0
- package/dist/utils/dates.d.ts +22 -0
- package/dist/utils/dates.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +16 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/emitter.d.ts +17 -0
- package/dist/utils/emitter.d.ts.map +1 -0
- package/dist/utils/path.d.ts +33 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/sanitize.d.ts +20 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/url.d.ts +16 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/package.json +95 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArethesisPlugin } from './types';
|
|
2
|
+
export interface DatePickerOptions {
|
|
3
|
+
min?: Date | string;
|
|
4
|
+
max?: Date | string;
|
|
5
|
+
onChange?: (date: Date | null) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface DateRangeOptions {
|
|
8
|
+
startSelector?: string;
|
|
9
|
+
endSelector?: string;
|
|
10
|
+
onChange?: (range: {
|
|
11
|
+
start: Date | null;
|
|
12
|
+
end: Date | null;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function dateUtilsPlugin(): ArethesisPlugin;
|
|
16
|
+
//# sourceMappingURL=date-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../src/plugins/date-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;CACtE;AA6DD,wBAAgB,eAAe,IAAI,eAAe,CA2DjD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ArethesisPlugin, PluginRef, PluginRegistrationOptions } from './types';
|
|
2
|
+
import { Arethesis } from '../core/arethesis';
|
|
3
|
+
import { ArethesisConfig } from '../core/types';
|
|
4
|
+
/** Make a plugin loadable by name (`plugins: ['my-plugin']`). */
|
|
5
|
+
export declare function registerBuiltInPlugin(name: string, factory: () => ArethesisPlugin): void;
|
|
6
|
+
export declare class PluginManager {
|
|
7
|
+
private app;
|
|
8
|
+
private plugins;
|
|
9
|
+
private pending;
|
|
10
|
+
private initialized;
|
|
11
|
+
constructor(app: Arethesis);
|
|
12
|
+
/** Resolve a reference to a plugin object and its options. */
|
|
13
|
+
resolve(ref: PluginRef, options?: unknown): {
|
|
14
|
+
plugin: ArethesisPlugin;
|
|
15
|
+
options: unknown;
|
|
16
|
+
};
|
|
17
|
+
/** Register a plugin. Mixins and validators are available immediately. */
|
|
18
|
+
use(ref: PluginRef, options?: unknown, registration?: PluginRegistrationOptions): void;
|
|
19
|
+
/** Run `beforeInit` hooks in registration order, threading the config through. */
|
|
20
|
+
beforeInit(config: ArethesisConfig): Promise<ArethesisConfig>;
|
|
21
|
+
afterInit(): Promise<void>;
|
|
22
|
+
/** Wait for async `install` hooks. */
|
|
23
|
+
settle(): Promise<void>;
|
|
24
|
+
get(name: string): ArethesisPlugin | undefined;
|
|
25
|
+
has(name: string): boolean;
|
|
26
|
+
names(): string[];
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
29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IAIjB,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ArethesisPlugin } from './types';
|
|
2
|
+
import { MixinInstance } from '../mixins/types';
|
|
3
|
+
import { SanitizeOptions } from '../utils/sanitize';
|
|
4
|
+
export type RichTextCommand = 'bold' | 'italic' | 'underline' | 'strike' | 'h2' | 'h3' | 'paragraph' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'clear' | 'undo' | 'redo';
|
|
5
|
+
export interface RichTextOptions {
|
|
6
|
+
toolbar?: RichTextCommand[];
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Accessible name for the editor. */
|
|
9
|
+
label?: string;
|
|
10
|
+
sanitize?: SanitizeOptions;
|
|
11
|
+
}
|
|
12
|
+
declare function richTextMixin(host: HTMLElement, options?: RichTextOptions): MixinInstance;
|
|
13
|
+
export declare function richTextPlugin(): ArethesisPlugin;
|
|
14
|
+
export { richTextMixin };
|
|
15
|
+
//# sourceMappingURL=rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/plugins/rich-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKnF,MAAM,MAAM,eAAe,GACvB,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,GACtE,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9F,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAgCD,iBAAS,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,aAAa,CAsOtF;AAED,wBAAgB,cAAc,IAAI,eAAe,CAuBhD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MixinDefinition, MixinFunction } from '../mixins/types';
|
|
2
|
+
import { ValidatorFn } from '../binding/types';
|
|
3
|
+
import { Arethesis } from '../core/arethesis';
|
|
4
|
+
import { ArethesisConfig } from '../core/types';
|
|
5
|
+
import { Component } from '../components/component';
|
|
6
|
+
export interface ValidatorDefinition {
|
|
7
|
+
fn: ValidatorFn;
|
|
8
|
+
/** Default message (supports `{param}` placeholders). */
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A plugin bundles mixins, validators and lifecycle hooks.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const companyEmail: ArethesisPlugin = {
|
|
17
|
+
* name: 'company-email',
|
|
18
|
+
* validators: {
|
|
19
|
+
* companyEmail: { fn: v => !v || String(v).endsWith('@example.org'), message: 'Use your company address' },
|
|
20
|
+
* },
|
|
21
|
+
* };
|
|
22
|
+
* app.use(companyEmail);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface ArethesisPlugin<Options = unknown> {
|
|
26
|
+
name: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
mixins?: Record<string, MixinDefinition | MixinFunction>;
|
|
29
|
+
validators?: Record<string, ValidatorDefinition | ValidatorFn>;
|
|
30
|
+
/** Runs when the plugin is registered. */
|
|
31
|
+
install?(app: Arethesis, options: Options): void | Promise<void>;
|
|
32
|
+
/** Runs at the start of `init()`; may return an updated config. */
|
|
33
|
+
beforeInit?(config: ArethesisConfig, app: Arethesis): ArethesisConfig | void | Promise<ArethesisConfig | void>;
|
|
34
|
+
/** Runs at the end of `init()` (or right away for plugins added later). */
|
|
35
|
+
afterInit?(app: Arethesis): void | Promise<void>;
|
|
36
|
+
/** Add behavior to every component, e.g. by patching `Component.prototype`. */
|
|
37
|
+
extendComponent?(base: typeof Component): void;
|
|
38
|
+
/** Runs on `app.destroy()`. */
|
|
39
|
+
destroy?(app: Arethesis): void;
|
|
40
|
+
}
|
|
41
|
+
/** A plugin object, the name of a built-in plugin, or either with options. */
|
|
42
|
+
export type PluginRef = ArethesisPlugin | string | {
|
|
43
|
+
plugin: ArethesisPlugin | string;
|
|
44
|
+
options?: unknown;
|
|
45
|
+
};
|
|
46
|
+
export interface PluginRegistrationOptions {
|
|
47
|
+
/** Replace a plugin (and its mixins/validators) that is already registered. */
|
|
48
|
+
override?: boolean;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,WAAW,CAAC;IAChB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,OAAO;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,WAAW,CAAC,CAAC;IAC/D,0CAA0C;IAC1C,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,mEAAmE;IACnE,UAAU,CAAC,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,GAAG,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAC/G,2EAA2E;IAC3E,SAAS,CAAC,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,+EAA+E;IAC/E,eAAe,CAAC,CAAC,IAAI,EAAE,OAAO,SAAS,GAAG,IAAI,CAAC;IAC/C,+BAA+B;IAC/B,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;CAChC;AAED,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,MAAM,GACN;IAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AzurePubSubConfig, AzurePubSubMessage, ChannelCallback, ConnectionStatus } from './types';
|
|
2
|
+
import { ObjectStore } from '../data/object-store';
|
|
3
|
+
import { ListViewRegistry } from '../data/list-view-registry';
|
|
4
|
+
export declare class AzurePubSubManager {
|
|
5
|
+
readonly config: AzurePubSubConfig;
|
|
6
|
+
private socket;
|
|
7
|
+
private channels;
|
|
8
|
+
private joined;
|
|
9
|
+
private joining;
|
|
10
|
+
private queue;
|
|
11
|
+
private acks;
|
|
12
|
+
private ackId;
|
|
13
|
+
private store;
|
|
14
|
+
private listViews;
|
|
15
|
+
private getToken;
|
|
16
|
+
private policy;
|
|
17
|
+
private generation;
|
|
18
|
+
private connectionId;
|
|
19
|
+
private userId;
|
|
20
|
+
constructor(config: AzurePubSubConfig);
|
|
21
|
+
connectStore(store: ObjectStore, listViews?: ListViewRegistry): void;
|
|
22
|
+
setTokenProvider(getter: () => Promise<string | null> | string | null): void;
|
|
23
|
+
get status(): ConnectionStatus;
|
|
24
|
+
get isConnected(): boolean;
|
|
25
|
+
onStatusChange(handler: (status: ConnectionStatus) => void): () => void;
|
|
26
|
+
getConnectionId(): string | null;
|
|
27
|
+
getUserId(): string | null;
|
|
28
|
+
connect(): Promise<void>;
|
|
29
|
+
private negotiate;
|
|
30
|
+
private handle;
|
|
31
|
+
private applyCacheMessage;
|
|
32
|
+
private dispatch;
|
|
33
|
+
/** Subscribe to a group (`'*'` for every message). Joins the group if needed. */
|
|
34
|
+
subscribe(group: string, callback: ChannelCallback<AzurePubSubMessage>): () => void;
|
|
35
|
+
/** Join a group (deduplicated while in flight). */
|
|
36
|
+
joinGroup(group: string): Promise<void>;
|
|
37
|
+
leaveGroup(group: string): Promise<void>;
|
|
38
|
+
/** Send JSON data to a group. Resolves when acknowledged. */
|
|
39
|
+
sendToGroup(group: string, data: unknown, options?: {
|
|
40
|
+
noEcho?: boolean;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
/** Send a custom event to the server-side handler. */
|
|
43
|
+
sendEvent(event: string, data: unknown): Promise<void>;
|
|
44
|
+
private sendWithAck;
|
|
45
|
+
private flush;
|
|
46
|
+
private failAcks;
|
|
47
|
+
disconnect(): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=azure-pub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,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI;IAIvE,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,SAAS,IAAI,MAAM,GAAG,IAAI;IAIpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA2ChB,SAAS;IAevB,OAAO,CAAC,MAAM;IAoCd,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,QAAQ;IAahB,iFAAiF;IACjF,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,kBAAkB,CAAC,GAAG,MAAM,IAAI;IAkBnF,mDAAmD;IACnD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAajC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9C,6DAA6D;IAC7D,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5F,sDAAsD;IACtD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,QAAQ;IAQhB,UAAU,IAAI,IAAI;CAiBnB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { WebSocketManager } from '../websocket-manager';
|
|
2
|
+
import { CollabUser, RemoteCursor } from '../types';
|
|
3
|
+
import { Emitter } from '../../utils/emitter';
|
|
4
|
+
import { EditorAdapter } from './textarea-adapter';
|
|
5
|
+
export type CollabStatus = 'connecting' | 'synced' | 'syncing' | 'offline';
|
|
6
|
+
export interface CollabEvents extends Record<string, unknown> {
|
|
7
|
+
/** The document content changed (locally or remotely). */
|
|
8
|
+
change: {
|
|
9
|
+
content: string;
|
|
10
|
+
remote: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Remote collaborators and their selections. */
|
|
13
|
+
presence: RemoteCursor[];
|
|
14
|
+
status: CollabStatus;
|
|
15
|
+
error: {
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
/** Initial content arrived. */
|
|
19
|
+
ready: {
|
|
20
|
+
content: string;
|
|
21
|
+
revision: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface CollabOptions {
|
|
25
|
+
user?: CollabUser;
|
|
26
|
+
/** Draw remote cursors over a textarea. @default true */
|
|
27
|
+
cursors?: boolean;
|
|
28
|
+
/** Presence update throttle in ms. @default 50 */
|
|
29
|
+
presenceInterval?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class CollabSession extends Emitter<CollabEvents> {
|
|
32
|
+
private ws;
|
|
33
|
+
private options;
|
|
34
|
+
readonly docId: string;
|
|
35
|
+
readonly channel: string;
|
|
36
|
+
private client;
|
|
37
|
+
private adapter;
|
|
38
|
+
private overlay;
|
|
39
|
+
private cursors;
|
|
40
|
+
private unsubscribe;
|
|
41
|
+
private offOpen;
|
|
42
|
+
private offStatus;
|
|
43
|
+
private outstandingOpId;
|
|
44
|
+
private opCounter;
|
|
45
|
+
private presenceTimer;
|
|
46
|
+
private _status;
|
|
47
|
+
clientId: string | null;
|
|
48
|
+
constructor(ws: WebSocketManager, docId: string, target: HTMLTextAreaElement | HTMLInputElement | EditorAdapter, options?: CollabOptions);
|
|
49
|
+
get status(): CollabStatus;
|
|
50
|
+
get content(): string;
|
|
51
|
+
get revision(): number;
|
|
52
|
+
/** Remote collaborators. */
|
|
53
|
+
get peers(): RemoteCursor[];
|
|
54
|
+
private setStatus;
|
|
55
|
+
private join;
|
|
56
|
+
private handleMessage;
|
|
57
|
+
private handleInit;
|
|
58
|
+
private sendOp;
|
|
59
|
+
private applyRemote;
|
|
60
|
+
private handleLocalEdit;
|
|
61
|
+
private toLocal;
|
|
62
|
+
private queuePresence;
|
|
63
|
+
private emitPresence;
|
|
64
|
+
private updateStatus;
|
|
65
|
+
/** Leave the document and clean up. */
|
|
66
|
+
close(): void;
|
|
67
|
+
}
|
|
68
|
+
/** Opens collaboration sessions on a WebSocketManager. */
|
|
69
|
+
export declare class CollabManager {
|
|
70
|
+
private getWs;
|
|
71
|
+
constructor(getWs: () => WebSocketManager | null);
|
|
72
|
+
/** Start collaborating on `docId` in a textarea/input (or a custom adapter). */
|
|
73
|
+
open(docId: string, target: HTMLTextAreaElement | HTMLInputElement | EditorAdapter, options?: CollabOptions): CollabSession;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=collab-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collab-session.d.ts","sourceRoot":"","sources":["../../../src/realtime/collab/collab-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAkC,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGzE,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE3E,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,0DAA0D;IAC1D,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC7C,iDAAiD;IACjD,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,+BAA+B;IAC/B,KAAK,EAAE;QA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U;IA+BlB,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,YAAY;IAKpB,uCAAuC;IACvC,KAAK,IAAI,IAAI;CAUd;AAED,0DAA0D;AAC1D,qBAAa,aAAa;IACZ,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM,gBAAgB,GAAG,IAAI;IAExD,gFAAgF;IAChF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,aAAa,EAAE,OAAO,GAAE,aAAkB,GAAG,aAAa;CAKhI"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RemoteCursor } from '../types';
|
|
2
|
+
/** Pixel position of a character index inside a textarea, relative to its padding box. */
|
|
3
|
+
export declare function caretCoordinates(textarea: HTMLTextAreaElement | HTMLInputElement, index: number): {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class CursorOverlay {
|
|
9
|
+
private textarea;
|
|
10
|
+
private layer;
|
|
11
|
+
private cursors;
|
|
12
|
+
private controller;
|
|
13
|
+
private frame;
|
|
14
|
+
constructor(textarea: HTMLTextAreaElement | HTMLInputElement);
|
|
15
|
+
update(cursors: RemoteCursor[]): void;
|
|
16
|
+
private schedule;
|
|
17
|
+
private render;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cursor-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-overlay.d.ts","sourceRoot":"","sources":["../../../src/realtime/collab/cursor-overlay.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAS7C,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAkB/I;AAED,qBAAa,aAAa;IAMZ,OAAO,CAAC,QAAQ;IAL5B,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,KAAK,CAAK;gBAEE,QAAQ,EAAE,mBAAmB,GAAG,gBAAgB;IAcpE,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI;IAKrC,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,MAAM;IAyBd,OAAO,IAAI,IAAI;CAKhB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TextOperation } from '../ot/text-operation';
|
|
2
|
+
import { CollabSelection } from '../types';
|
|
3
|
+
export interface EditorAdapter {
|
|
4
|
+
getValue(): string;
|
|
5
|
+
/** Replace the content (initial sync). */
|
|
6
|
+
setValue(value: string): void;
|
|
7
|
+
/** Apply a remote operation. */
|
|
8
|
+
applyOperation(op: TextOperation): void;
|
|
9
|
+
getSelection(): CollabSelection;
|
|
10
|
+
/** Register the local-edit and selection-change callbacks. */
|
|
11
|
+
attach(onEdit: (op: TextOperation) => void, onSelect: (selection: CollabSelection) => void): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class TextareaAdapter implements EditorAdapter {
|
|
15
|
+
readonly element: HTMLTextAreaElement | HTMLInputElement;
|
|
16
|
+
private previous;
|
|
17
|
+
private composing;
|
|
18
|
+
private controller;
|
|
19
|
+
constructor(element: HTMLTextAreaElement | HTMLInputElement);
|
|
20
|
+
getValue(): string;
|
|
21
|
+
setValue(value: string): void;
|
|
22
|
+
applyOperation(op: TextOperation): void;
|
|
23
|
+
getSelection(): CollabSelection;
|
|
24
|
+
attach(onEdit: (op: TextOperation) => void, onSelect: (selection: CollabSelection) => void): void;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=textarea-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea-adapter.d.ts","sourceRoot":"","sources":["../../../src/realtime/collab/textarea-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,QAAQ,IAAI,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gCAAgC;IAChC,cAAc,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,YAAY,IAAI,eAAe,CAAC;IAChC,8DAA8D;IAC9D,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI,CAAC;IAClG,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,qBAAa,eAAgB,YAAW,aAAa;IAKvC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,gBAAgB;IAJpE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAyB;gBAEtB,OAAO,EAAE,mBAAmB,GAAG,gBAAgB;IAIpE,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,cAAc,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAgBvC,YAAY,IAAI,eAAe;IAM/B,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI;IAuBjG,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TextOperation } from './text-operation';
|
|
2
|
+
export type OTClientState = 'synchronized' | 'awaiting' | 'buffering';
|
|
3
|
+
export interface OTClientCallbacks {
|
|
4
|
+
/** Send an operation made against `revision` to the server. */
|
|
5
|
+
send(revision: number, operation: TextOperation): void;
|
|
6
|
+
/** Apply a (transformed) remote operation to the local document. */
|
|
7
|
+
apply(operation: TextOperation): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class OTClient {
|
|
10
|
+
private callbacks;
|
|
11
|
+
revision: number;
|
|
12
|
+
private outstanding;
|
|
13
|
+
private buffer;
|
|
14
|
+
constructor(revision: number, callbacks: OTClientCallbacks);
|
|
15
|
+
get state(): OTClientState;
|
|
16
|
+
/** The user edited the document. */
|
|
17
|
+
applyClient(operation: TextOperation): void;
|
|
18
|
+
/** The server broadcast another client's operation. */
|
|
19
|
+
applyServer(operation: TextOperation): void;
|
|
20
|
+
/** The server acknowledged our in-flight operation. */
|
|
21
|
+
serverAck(): void;
|
|
22
|
+
/** Re-send the in-flight operation (after a reconnect). */
|
|
23
|
+
resend(): void;
|
|
24
|
+
/** Map a position in the server document to the local document (for remote cursors). */
|
|
25
|
+
transformIndex(index: number): number;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/realtime/ot/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IACvD,oEAAoE;IACpE,KAAK,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;CACvC;AAED,qBAAa,QAAQ;IAKW,OAAO,CAAC,SAAS;IAJ/C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,MAAM,CAA8B;gBAEhC,QAAQ,EAAE,MAAM,EAAU,SAAS,EAAE,iBAAiB;IAIlE,IAAI,KAAK,IAAI,aAAa,CAEzB;IAED,oCAAoC;IACpC,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAY3C,uDAAuD;IACvD,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAgB3C,uDAAuD;IACvD,SAAS,IAAI,IAAI;IAQjB,2DAA2D;IAC3D,MAAM,IAAI,IAAI;IAId,wFAAwF;IACxF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAMtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TextOperation } from './text-operation';
|
|
2
|
+
import { CollabMessage } from '../types';
|
|
3
|
+
export declare class OTDocumentServer {
|
|
4
|
+
document: string;
|
|
5
|
+
readonly operations: TextOperation[];
|
|
6
|
+
/** Client op ids, parallel to `operations` (lets reconnecting clients spot their own ops). */
|
|
7
|
+
readonly opIds: Array<string | undefined>;
|
|
8
|
+
constructor(document?: string);
|
|
9
|
+
get revision(): number;
|
|
10
|
+
/**
|
|
11
|
+
* Accept an operation made against `revision`. Returns the transformed
|
|
12
|
+
* operation that was applied (broadcast it to the other clients).
|
|
13
|
+
*/
|
|
14
|
+
receive(revision: number, operation: TextOperation, opId?: string): TextOperation;
|
|
15
|
+
}
|
|
16
|
+
export declare class CollabServer {
|
|
17
|
+
private send;
|
|
18
|
+
private loadDocument;
|
|
19
|
+
private docs;
|
|
20
|
+
private clients;
|
|
21
|
+
/**
|
|
22
|
+
* @param send Deliver a message to one client.
|
|
23
|
+
* @param loadDocument Initial content for a document opened for the first time.
|
|
24
|
+
*/
|
|
25
|
+
constructor(send: (clientId: string, message: CollabMessage) => void, loadDocument?: (docId: string) => string);
|
|
26
|
+
/** Access (or create) a document. */
|
|
27
|
+
document(docId: string): OTDocumentServer;
|
|
28
|
+
private membersOf;
|
|
29
|
+
private broadcast;
|
|
30
|
+
/** Handle one incoming message from a client. */
|
|
31
|
+
handle(clientId: string, message: CollabMessage): void;
|
|
32
|
+
private leave;
|
|
33
|
+
/** A client went away: leave every document. */
|
|
34
|
+
disconnect(clientId: string): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/realtime/ot/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,UAAU,CAAC;AAE3E,qBAAa,gBAAgB;IAKR,QAAQ;IAJ3B,QAAQ,CAAC,UAAU,EAAE,aAAa,EAAE,CAAM;IAC1C,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAM;gBAE5B,QAAQ,SAAK;IAEhC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa;CAWlF;AAQD,qBAAa,YAAY;IASrB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,YAAY;IATtB,OAAO,CAAC,IAAI,CAAuC;IACnD,OAAO,CAAC,OAAO,CAAiC;IAEhD;;;OAGG;gBAEO,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,KAAK,IAAI,EACxD,YAAY,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAiB;IAG5D,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;IASzC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAIjB,iDAAiD;IACjD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAsDtD,OAAO,CAAC,KAAK;IAMb,gDAAgD;IAChD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAMnC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextOperation: a convergent operational-transform type for plain text.
|
|
3
|
+
*
|
|
4
|
+
* An operation is a list of components that walks the whole document:
|
|
5
|
+
* - a positive integer **retains** that many characters
|
|
6
|
+
* - a string **inserts** it
|
|
7
|
+
* - a negative integer **deletes** that many characters
|
|
8
|
+
*
|
|
9
|
+
* `transform(a, b)` returns `[a', b']` such that `apply(apply(doc, a), b') ===
|
|
10
|
+
* apply(apply(doc, b), a')`, which is what makes concurrent editing converge.
|
|
11
|
+
* Positions count UTF-16 code units, like JavaScript strings.
|
|
12
|
+
*
|
|
13
|
+
* @module realtime/ot/text-operation
|
|
14
|
+
*/
|
|
15
|
+
export type OpComponent = number | string;
|
|
16
|
+
export declare class TextOperation {
|
|
17
|
+
/** Components; adjacent components of the same kind are always merged. */
|
|
18
|
+
readonly ops: OpComponent[];
|
|
19
|
+
/** Length of the document this operation applies to. */
|
|
20
|
+
baseLength: number;
|
|
21
|
+
/** Length of the document after applying it. */
|
|
22
|
+
targetLength: number;
|
|
23
|
+
/** Skip over `n` characters. */
|
|
24
|
+
retain(n: number): this;
|
|
25
|
+
/** Insert text at the current position. */
|
|
26
|
+
insert(text: string): this;
|
|
27
|
+
/** Delete `n` characters. */
|
|
28
|
+
delete(n: number): this;
|
|
29
|
+
/** Whether the operation changes nothing. */
|
|
30
|
+
isNoop(): boolean;
|
|
31
|
+
/** Apply to a string. Throws if the lengths don't match. */
|
|
32
|
+
apply(doc: string): string;
|
|
33
|
+
/** The operation that undoes this one on `doc` (the pre-image). */
|
|
34
|
+
invert(doc: string): TextOperation;
|
|
35
|
+
/** Combine with an operation that follows this one: `apply(apply(d, a), b) === apply(d, a.compose(b))`. */
|
|
36
|
+
compose(next: TextOperation): TextOperation;
|
|
37
|
+
/**
|
|
38
|
+
* Transform two concurrent operations. When both insert at the same position,
|
|
39
|
+
* `a`'s text goes first. The client and server both pass the *client's*
|
|
40
|
+
* operation as `a`, so every replica breaks ties the same way.
|
|
41
|
+
*/
|
|
42
|
+
static transform(a: TextOperation, b: TextOperation): [TextOperation, TextOperation];
|
|
43
|
+
/**
|
|
44
|
+
* Map a cursor position through this operation. Inserts exactly at the cursor
|
|
45
|
+
* push it forward unless `stickLeft` is true (use that for your own cursor).
|
|
46
|
+
*/
|
|
47
|
+
transformIndex(index: number, stickLeft?: boolean): number;
|
|
48
|
+
/** Operation that turns `before` into `after` (one changed region). */
|
|
49
|
+
static fromDiff(before: string, after: string): TextOperation;
|
|
50
|
+
equals(other: TextOperation): boolean;
|
|
51
|
+
toJSON(): OpComponent[];
|
|
52
|
+
static fromJSON(ops: unknown): TextOperation;
|
|
53
|
+
toString(): string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=text-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-operation.d.ts","sourceRoot":"","sources":["../../../src/realtime/ot/text-operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAY1C,qBAAa,aAAa;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,CAAM;IACjC,wDAAwD;IACxD,UAAU,SAAK;IACf,gDAAgD;IAChD,YAAY,SAAK;IAEjB,gCAAgC;IAChC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAWvB,2CAA2C;IAC3C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAqB1B,6BAA6B;IAC7B,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAUvB,6CAA6C;IAC7C,MAAM,IAAI,OAAO;IAIjB,4DAA4D;IAC5D,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAmB1B,mEAAmE;IACnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAiBlC,2GAA2G;IAC3G,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa;IA6F3C;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC;IAuDpF;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,MAAM;IAiBxD,uEAAuE;IACvE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa;IAiB7D,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAKrC,MAAM,IAAI,WAAW,EAAE;IAIvB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa;IAa5C,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConnectionStatus, ReconnectOptions } from './types';
|
|
2
|
+
import { Emitter } from '../utils/emitter';
|
|
3
|
+
export interface StatusEvents extends Record<string, unknown> {
|
|
4
|
+
status: ConnectionStatus;
|
|
5
|
+
}
|
|
6
|
+
export declare class ReconnectPolicy extends Emitter<StatusEvents> {
|
|
7
|
+
private options;
|
|
8
|
+
private attempts;
|
|
9
|
+
private timer;
|
|
10
|
+
private _status;
|
|
11
|
+
constructor(options: ReconnectOptions);
|
|
12
|
+
get status(): ConnectionStatus;
|
|
13
|
+
set status(next: ConnectionStatus);
|
|
14
|
+
get attempt(): number;
|
|
15
|
+
/** Call on a successful connection. */
|
|
16
|
+
succeeded(): void;
|
|
17
|
+
/** Schedule `connect` after a backoff; returns false if giving up. */
|
|
18
|
+
schedule(connect: () => void): boolean;
|
|
19
|
+
/** Cancel a pending reconnect and reset. */
|
|
20
|
+
cancel(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=reconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect.d.ts","sourceRoot":"","sources":["../../src/realtime/reconnect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,qBAAa,eAAgB,SAAQ,OAAO,CAAC,YAAY,CAAC;IAK5C,OAAO,CAAC,OAAO;IAJ3B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,OAAO,CAA4B;gBAEvB,OAAO,EAAE,gBAAgB;IAI7C,IAAI,MAAM,IAAI,gBAAgB,CAE7B;IAED,IAAI,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAIhC;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,uCAAuC;IACvC,SAAS,IAAI,IAAI;IAKjB,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO;IAoBtC,4CAA4C;IAC5C,MAAM,IAAI,IAAI;CAKf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ConnectionStatus, SSEConfig } from './types';
|
|
2
|
+
import { ObjectStore } from '../data/object-store';
|
|
3
|
+
import { ListViewRegistry } from '../data/list-view-registry';
|
|
4
|
+
type Handler = (data: unknown, event: MessageEvent) => void;
|
|
5
|
+
export declare class SSEManager {
|
|
6
|
+
readonly config: SSEConfig;
|
|
7
|
+
private source;
|
|
8
|
+
private store;
|
|
9
|
+
private listViews;
|
|
10
|
+
private getToken;
|
|
11
|
+
private policy;
|
|
12
|
+
private generation;
|
|
13
|
+
private lastEventId;
|
|
14
|
+
private handlers;
|
|
15
|
+
private customEvents;
|
|
16
|
+
constructor(config: SSEConfig);
|
|
17
|
+
connectStore(store: ObjectStore, listViews?: ListViewRegistry): void;
|
|
18
|
+
setTokenProvider(getter: () => Promise<string | null> | string | null): void;
|
|
19
|
+
get status(): ConnectionStatus;
|
|
20
|
+
get isConnected(): boolean;
|
|
21
|
+
/** Listen for status changes. */
|
|
22
|
+
onStatusChange(handler: (status: ConnectionStatus) => void): () => void;
|
|
23
|
+
/** Listen for a named event (including built-ins). Returns an unsubscribe function. */
|
|
24
|
+
on(event: string, handler: Handler): () => void;
|
|
25
|
+
/** Open the stream. Safe to call repeatedly. */
|
|
26
|
+
connect(): Promise<void>;
|
|
27
|
+
private buildUrl;
|
|
28
|
+
private parse;
|
|
29
|
+
private dispatch;
|
|
30
|
+
/** Generic `message` events: `{ action: 'invalidate' | 'delete' | 'upsert', type, ... }`. */
|
|
31
|
+
private handleGeneric;
|
|
32
|
+
private applyBuiltIn;
|
|
33
|
+
/** Close the stream and stop reconnecting. */
|
|
34
|
+
disconnect(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=sse-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-manager.d.ts","sourceRoot":"","sources":["../../src/realtime/sse-manager.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