@ones-editor/editor 2.3.0-beta.7 → 2.3.0-beta.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.
Files changed (39) hide show
  1. package/@ones-editor/core/src/core/doc/doc.d.ts +0 -1
  2. package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +0 -1
  3. package/@ones-editor/drawio-embed/src/lang/en-us.d.ts +8 -0
  4. package/@ones-editor/drawio-embed/src/lang/ja-jp.d.ts +8 -0
  5. package/@ones-editor/drawio-embed/src/lang/zh-cn.d.ts +8 -0
  6. package/@ones-editor/misc/src/index.d.ts +0 -1
  7. package/@ones-editor/misc/src/re-auth/index.d.ts +0 -23
  8. package/@ones-editor/sharedb-doc/src/doc/auth-connection.d.ts +41 -31
  9. package/@ones-editor/sharedb-doc/src/doc/auto-renew-token.d.ts +16 -0
  10. package/@ones-editor/sharedb-doc/src/doc/connection-status.d.ts +19 -0
  11. package/@ones-editor/sharedb-doc/src/doc/edit-status.d.ts +13 -0
  12. package/@ones-editor/sharedb-doc/src/doc/sharedb-client.d.ts +6 -13
  13. package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +4 -4
  14. package/@ones-editor/sharedb-doc/src/types.d.ts +16 -2
  15. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  16. package/@ones-editor/ui-base/src/dialog/alert-dialog.d.ts +19 -0
  17. package/@ones-editor/ui-base/src/dialog/confirm-dialog.d.ts +20 -0
  18. package/@ones-editor/ui-base/src/dialog/dialog-button.d.ts +10 -0
  19. package/@ones-editor/ui-base/src/dialog/dialog-check.d.ts +15 -0
  20. package/@ones-editor/ui-base/src/dialog/dialog-input.d.ts +9 -0
  21. package/@ones-editor/ui-base/src/dialog/dialog-radio.d.ts +12 -0
  22. package/@ones-editor/ui-base/src/dialog/index.d.ts +15 -0
  23. package/@ones-editor/ui-base/src/dialog/modal-dialog.d.ts +21 -0
  24. package/@ones-editor/ui-base/src/dialog/popup-dialog.d.ts +31 -0
  25. package/@ones-editor/ui-base/src/dialog/standard-dialog.d.ts +25 -0
  26. package/@ones-editor/ui-base/src/dialog/standard-modal-dialog.d.ts +7 -0
  27. package/@ones-editor/ui-base/src/dialog/standard-popup-dialog.d.ts +17 -0
  28. package/@ones-editor/ui-base/src/dialog/types.d.ts +1 -0
  29. package/@ones-editor/ui-base/src/locale/en-us.d.ts +5 -0
  30. package/@ones-editor/ui-base/src/locale/ja-jp.d.ts +5 -0
  31. package/@ones-editor/ui-base/src/locale/zh-cn.d.ts +5 -0
  32. package/dist/error-handler/error-info-bar.d.ts +20 -0
  33. package/dist/error-handler/index.d.ts +29 -0
  34. package/dist/index.js +2699 -1889
  35. package/dist/lang/en-us.d.ts +3 -0
  36. package/dist/lang/ja-jp.d.ts +3 -0
  37. package/dist/lang/zh-cn.d.ts +3 -0
  38. package/dist/types.d.ts +16 -1
  39. package/package.json +1 -1
@@ -132,7 +132,6 @@ export interface OnesEditorDocCallbacks {
132
132
  onCustomMessage?: (msg: unknown) => void;
133
133
  onStatusChanged?: (status: OnesEditorDocStatus) => void;
134
134
  onError?: (error: Error) => void;
135
- onAuthRecover?: () => void;
136
135
  }
137
136
  export interface UploadResourceOptions {
138
137
  onProgress?: (progress: number) => void;
@@ -34,7 +34,6 @@ export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> im
34
34
  onCustomMessage(msg: unknown): void;
35
35
  onStatusChanged(status: OnesEditorDocStatus): void;
36
36
  onError(error: Error): void;
37
- onAuthRecover(): void;
38
37
  uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
39
38
  addResources(resourceIds: string[]): Promise<string[]>;
40
39
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
@@ -8,6 +8,14 @@ declare const _default: {
8
8
  errorSubTips: string;
9
9
  retry: string;
10
10
  save: string;
11
+ exit: string;
12
+ error: {
13
+ network: string;
14
+ networkDisconnected: string;
15
+ networkDisconnectedMessage: string;
16
+ exitConfirm: string;
17
+ exitMessage: string;
18
+ };
11
19
  };
12
20
  };
13
21
  export default _default;
@@ -8,6 +8,14 @@ declare const _default: {
8
8
  errorSubTips: string;
9
9
  retry: string;
10
10
  save: string;
11
+ exit: string;
12
+ error: {
13
+ network: string;
14
+ networkDisconnected: string;
15
+ networkDisconnectedMessage: string;
16
+ exitConfirm: string;
17
+ exitMessage: string;
18
+ };
11
19
  };
12
20
  };
13
21
  export default _default;
@@ -8,6 +8,14 @@ declare const _default: {
8
8
  errorSubTips: string;
9
9
  retry: string;
10
10
  save: string;
11
+ exit: string;
12
+ error: {
13
+ network: string;
14
+ networkDisconnected: string;
15
+ networkDisconnectedMessage: string;
16
+ exitConfirm: string;
17
+ exitMessage: string;
18
+ };
11
19
  };
12
20
  };
13
21
  export default _default;
@@ -1,4 +1,3 @@
1
1
  export * from './image';
2
2
  export * from './title';
3
3
  export * from './image-downloader';
4
- export * from './re-auth';
@@ -1,23 +0,0 @@
1
- import { TypedEmitter } from 'tiny-typed-emitter';
2
- import { OnesEditor, OnesEditorCustom, OnesEditorDocCallbacks } from '../../../../@ones-editor/core';
3
- import ReAuthToolbar from './ui/toolbar';
4
- import './locale';
5
- type EventCallback = (() => void) | undefined;
6
- declare const DOC_RE_AUTH_KEYS = "doc-re-auth-event";
7
- type ReAuthEvent = {
8
- tokenExpired: () => void;
9
- };
10
- declare class DocReAuthCallbacks extends TypedEmitter<ReAuthEvent> implements OnesEditorCustom, OnesEditorDocCallbacks {
11
- private editor;
12
- private authErrorCallback;
13
- private authRecoverCallback;
14
- reAuthToolbar: ReAuthToolbar;
15
- constructor(editor: OnesEditor);
16
- handleReAuth: () => void;
17
- addAuthListen(event: 'authError' | 'authRecover', callback: EventCallback): void;
18
- removeListeners(): void;
19
- destroy: () => void;
20
- onError: (error: Error) => void;
21
- onAuthRecover: () => void;
22
- }
23
- export { ReAuthToolbar, DocReAuthCallbacks, DOC_RE_AUTH_KEYS, };
@@ -1,50 +1,60 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { Connection, Doc } from 'sharedb/lib/client';
4
- import ReconnectingWebSocket, { Event } from 'reconnecting-websocket';
5
- import { AuthMessage, ReauthFunc } from '../types';
1
+ import { Doc } from 'sharedb/lib/client';
2
+ import { TypedEmitter } from 'tiny-typed-emitter';
3
+ import { AuthMessage, RenewTokenFunc } from '../types';
6
4
  import './sharedb-ext';
7
- export declare class AuthConnection {
5
+ export interface AutoConnectionEvents {
6
+ renewingToken: (count: number) => void;
7
+ renewedToken: (auth: AuthMessage) => void;
8
+ renewTokenError: (error: Error) => void;
9
+ reauthing: (count: number) => void;
10
+ authError: (error: Error) => void;
11
+ authRecover: (auth: AuthMessage) => void;
12
+ unknownError: (error: Error) => void;
13
+ connectionError: (error: Error) => void;
14
+ disconnected: (reason: string) => void;
15
+ writeConflictError: (error: Error) => void;
16
+ maxUsersError: () => void;
17
+ requestReloadError: (error: Error) => void;
18
+ ready: () => void;
19
+ }
20
+ export declare class AuthConnection extends TypedEmitter<AutoConnectionEvents> {
8
21
  url: string;
9
- private reauthFunc?;
10
- enabled: boolean;
11
- connection?: Connection;
12
- ws?: ReconnectingWebSocket;
13
- retryCount: number;
14
- events: EventEmitter;
15
- token: string | null;
16
- resourceToken: string | null;
22
+ private renewTokenFunc?;
23
+ private closed;
24
+ private connection?;
25
+ private ws?;
26
+ private token;
27
+ private resourceToken;
28
+ private authMessage;
29
+ private autoRenewToken;
30
+ private connectionStatus;
31
+ private reauthing;
32
+ private ready;
17
33
  pingOptions: {
18
34
  interval: number;
19
35
  timeout: number;
20
36
  };
21
- constructor(url: string, reauthFunc?: ReauthFunc | undefined);
37
+ constructor(authMessage: AuthMessage, url: string, renewTokenFunc?: RenewTokenFunc | undefined);
22
38
  getBaseURL(): string;
23
39
  getBase64BaseURL(): string;
24
- auth(auth: AuthMessage): Promise<{
40
+ getToken(): string;
41
+ getResourceToken(): string;
42
+ getAuthMessage(): AuthMessage;
43
+ verifyAuth(authMessage: AuthMessage): Promise<{
25
44
  read: string;
26
45
  user: string;
27
46
  }>;
28
47
  logout(): Promise<void>;
29
- init(auth: AuthMessage): Promise<void>;
30
- reConnect(token: string): Promise<void>;
31
- _autoReAuth(): Promise<void>;
32
- autoReAuth(): Promise<void>;
33
- handleAuthError(): Promise<void>;
34
- reAuth: () => Promise<void>;
48
+ init(): Promise<void>;
49
+ private handleAuthError;
50
+ private handleUnknownError;
51
+ private handleConnectionError;
52
+ private handleDisconnected;
35
53
  private emitPermissionError;
36
- private emitAuthRecover;
37
- private emitAuthError;
38
54
  private emitRequestReloadError;
39
55
  private emitWriteConflictError;
40
56
  private emitMaxUsersError;
41
- handleMessage(message: object): void;
57
+ private handleMessage;
42
58
  get(collectionName: string, documentID: string): Doc;
43
- addEventListener(event: 'open' | 'close' | 'error', callback: (e: Event | Error) => void): void;
44
- onAuthError(callback: (error: Error) => void): void;
45
- onAuthRecover(callback: () => void): void;
46
- onWriteConflictError(callback: (error: Error) => void): void;
47
- onMaxUsersError(callback: () => void): void;
48
- onRequestReloadError(callback: (error: Error) => void): void;
49
59
  end(logout: boolean): void;
50
60
  }
@@ -0,0 +1,16 @@
1
+ import { TypedEmitter } from 'tiny-typed-emitter';
2
+ import { AuthMessage, RenewTokenFunc } from '../types';
3
+ export interface AutoRenewTokenEvents {
4
+ 'renewingToken': (count: number) => void;
5
+ 'renewedToken': (auth: AuthMessage) => void;
6
+ 'renewTokenError': (error: Error) => void;
7
+ }
8
+ export declare class AutoRenewToken extends TypedEmitter<AutoRenewTokenEvents> {
9
+ private renewToken;
10
+ private retryCount;
11
+ private stop;
12
+ private running;
13
+ constructor(renewToken: RenewTokenFunc);
14
+ start(): Promise<void>;
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,19 @@
1
+ import { Connection, Error as ShareDBError } from 'sharedb/lib/client';
2
+ import type { ConnectionState } from 'sharedb/lib/sharedb';
3
+ import { TypedEmitter } from 'tiny-typed-emitter';
4
+ export interface ConnectionStatusEvents {
5
+ 'connectionError': (error: ShareDBError) => void;
6
+ 'unknownError': (error: ShareDBError) => void;
7
+ 'disconnected': (reason: string) => void;
8
+ }
9
+ export declare class ConnectionStatus extends TypedEmitter<ConnectionStatusEvents> {
10
+ private connection;
11
+ constructor(connection: Connection);
12
+ handleClosed: () => void;
13
+ handleCommonError: (error: ShareDBError) => void;
14
+ handleConnecting: () => void;
15
+ handleConnected: () => void;
16
+ handleConnectionError: (error: ShareDBError) => void;
17
+ handleStateChanged: (newState: ConnectionState, reason: string) => void;
18
+ destroy(): void;
19
+ }
@@ -0,0 +1,13 @@
1
+ export interface EditStatusOptions {
2
+ dirtyTimeout?: number;
3
+ onDirtyTimeoutError?: () => void;
4
+ onClean?: () => void;
5
+ }
6
+ export declare class EditStatus {
7
+ private options;
8
+ private dirtyTimeout;
9
+ private waitingForSave;
10
+ constructor(options: EditStatusOptions);
11
+ setStatus(status: 'clean' | 'dirty'): void;
12
+ destroy(): void;
13
+ }
@@ -1,34 +1,28 @@
1
1
  import { BuildResourceUrlOptions, DocVersion, OnesEditorDocVersionExtra } from '../../../../@ones-editor/core';
2
2
  import { Doc } from 'sharedb/lib/client';
3
- import { Event } from 'reconnecting-websocket';
4
3
  import type { AxiosResponse } from 'axios';
5
4
  import { AuthConnection } from './auth-connection';
6
- import { EditorDoc, ReauthFunc, AuthMessage, OnProgress, EditorOp, LinkDetails } from '../types';
5
+ import { EditorDoc, RenewTokenFunc, AuthMessage, OnProgress, EditorOp, LinkDetails } from '../types';
7
6
  export default class ShareDBClient {
8
7
  connection: AuthConnection;
9
- auth: AuthMessage;
10
8
  private doc;
11
9
  private reauthFunc?;
12
- clientId: string;
13
- constructor(auth: AuthMessage, serverUrl: string, reauthFunc?: ReauthFunc);
10
+ private _clientId;
11
+ constructor(auth: AuthMessage, serverUrl: string, reauthFunc?: RenewTokenFunc);
12
+ get clientId(): string;
14
13
  token(): string;
15
14
  resourceToken(): string;
15
+ authMessage(): AuthMessage;
16
16
  docId(): string;
17
17
  editorServer(): string;
18
18
  close(logout: boolean): void;
19
- on(event: 'open' | 'close' | 'error', callback: (event: Event | Error) => void): void;
20
- onAuthError(callback: (error: Error) => void): void;
21
- onAuthRecover(callback: () => void): void;
22
- onWriteConflictError(callback: (error: Error) => void): void;
23
- onMaxUsersError(callback: () => void): void;
24
- onRequestReloadError(callback: (error: Error) => void): void;
25
19
  /**
26
20
  * 根据Id生成一个文档对象,如果文档不存在,则创建一个新的。
27
21
  * @param id 待获取的containerId
28
22
  */
29
23
  getDoc: () => Promise<Doc<any>>;
30
24
  authOnly(): Promise<void>;
31
- getResourceToken(): string | null;
25
+ getResourceToken(): string;
32
26
  hasDocContainer(): boolean;
33
27
  apiServer(): string;
34
28
  getFileUrlByHash(uploadFileUrl: string, hash: string, name: string, size: number, headers: {
@@ -57,5 +51,4 @@ export default class ShareDBClient {
57
51
  recognizeLink(url: string): Promise<LinkDetails>;
58
52
  getResourceId(url: string): string;
59
53
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
60
- reAuth(auto?: boolean): void;
61
54
  }
@@ -4,7 +4,9 @@ import { LocalPresence } from 'sharedb/lib/sharedb';
4
4
  import RemoteCaretsHandler from './remote-caret-handler';
5
5
  import { EditorDoc, ShareDBDocCallbacks, ShareDBDocOptions } from '../types';
6
6
  import ShareDBClient from './sharedb-client';
7
+ import { EditStatus } from './edit-status';
7
8
  export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> implements OnesEditorDoc, OnesEditorDocVersionHelper {
9
+ private options;
8
10
  doc: Doc;
9
11
  client: ShareDBClient;
10
12
  localPresence?: LocalPresence;
@@ -13,8 +15,8 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
13
15
  status: OnesEditorDocStatus;
14
16
  disableLogout: boolean;
15
17
  destroyed: boolean;
16
- options: ShareDBDocOptions | null;
17
- constructor(client: ShareDBClient, doc: Doc, disableLogout?: boolean);
18
+ editStatus: EditStatus;
19
+ constructor(options: ShareDBDocOptions, client: ShareDBClient, doc: Doc, disableLogout?: boolean);
18
20
  beginBatchUpdate(): number;
19
21
  endBatchUpdate(): number;
20
22
  static load(options: ShareDBDocOptions): Promise<ShareDBDoc>;
@@ -76,7 +78,6 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
76
78
  onCreateComment(commentId: string, local: boolean): void;
77
79
  onUpdateComment(commentId: string, local: boolean): void;
78
80
  onCustomMessage(msg: unknown): void;
79
- onAuthRecover(): void;
80
81
  addResources(resourceIds: string[]): Promise<string[]>;
81
82
  uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
82
83
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
@@ -108,5 +109,4 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
108
109
  recognizeLink(url: string): Promise<import("../types").LinkDetails>;
109
110
  parseHistoryData(historyData: OnesEditorDocHistoryData, handler: OnesEditorHistoryDataParseHandler): void;
110
111
  getServerMeta(): OnesEditorDocServerMeta;
111
- triggerReAuth(auto?: boolean): void;
112
112
  }
@@ -62,18 +62,32 @@ export declare const FileExtError: {
62
62
  };
63
63
  export declare const AuthHeader = "x-live-editor-token";
64
64
  export declare const BaseURLHeader = "x-live-editor-base-url";
65
- export type ReauthFunc = () => Promise<AuthMessage>;
65
+ export type RenewTokenFunc = () => Promise<AuthMessage>;
66
66
  export type OnProgress = (percentage: number) => void;
67
67
  export interface ShareDBDocOptions {
68
68
  auth: AuthMessage;
69
69
  serverUrl: string;
70
- reauthFunc?: ReauthFunc;
71
70
  autoCreateDoc?: boolean;
72
71
  templateData?: EditorDoc;
73
72
  disableLogout?: boolean;
73
+ dirtyTimeout?: number;
74
74
  onMaxUsersError?: () => void;
75
+ onDirtyTimeoutError?: () => void;
76
+ onClean?: () => void;
77
+ onRenewingToken?: (count: number) => void;
78
+ onRenewedToken?: (auth: AuthMessage) => void;
79
+ onRenewTokenError?: (error: Error) => void;
80
+ onReauthing?: () => void;
81
+ onReauthError?: (error: Error) => void;
82
+ onReauthRecovered?: (auth: AuthMessage) => void;
83
+ onUnknownError?: (error: Error) => void;
84
+ onDisconnected?: (reason: string) => void;
85
+ onConnectionError?: (error: Error) => void;
86
+ onUploadResourceError?: (error: Error) => void;
87
+ renewTokenFunc?: RenewTokenFunc;
75
88
  buildResourceUrl?: (doc: OnesEditorDoc, resourceId: string, options?: BuildResourceUrlOptions) => string;
76
89
  uploadResource?: (doc: OnesEditorDoc, file: File, options?: UploadResourceOptions) => Promise<UploadResourceResult>;
90
+ onReady?: () => void;
77
91
  }
78
92
  export interface EditorOp {
79
93
  c: string;