@hocuspocus/provider 1.1.0 → 1.1.2

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.
@@ -2,7 +2,6 @@
2
2
  import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
3
  import { Doc } from 'yjs';
4
4
  import { Transformer } from '@hocuspocus/transformer';
5
- import { AxiosResponse } from 'axios';
6
5
  export declare enum Events {
7
6
  onChange = "change",
8
7
  onConnect = "connect",
@@ -41,7 +40,7 @@ export declare class Webhook implements Extension {
41
40
  /**
42
41
  * Send a request to the given url containing the given data
43
42
  */
44
- sendRequest(event: Events, payload: any): Promise<AxiosResponse<any, any>>;
43
+ sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any>>;
45
44
  /**
46
45
  * onChange hook
47
46
  */
@@ -0,0 +1,11 @@
1
+ import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider';
2
+ export declare type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & AdditionalTiptapCollabProviderConfiguration;
3
+ export interface AdditionalTiptapCollabProviderConfiguration {
4
+ /**
5
+ * A Hocuspocus Cloud App ID, get one here: https://tt-collab.de
6
+ */
7
+ appId: string;
8
+ }
9
+ export declare class TiptapCollabProvider extends HocuspocusProvider {
10
+ constructor(configuration: TiptapCollabProviderConfiguration);
11
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './HocuspocusProvider';
2
- export * from './HocuspocusCloudProvider';
2
+ export * from './TiptapCollabProvider';
3
3
  export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/provider",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "hocuspocus provider",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -28,7 +28,7 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@hocuspocus/common": "^1.1.0",
31
+ "@hocuspocus/common": "^1.1.2",
32
32
  "@lifeomic/attempt": "^3.0.2",
33
33
  "lib0": "^0.2.46"
34
34
  },
@@ -596,7 +596,11 @@ export class HocuspocusProvider extends EventEmitter {
596
596
 
597
597
  if (event.code === Unauthorized.code) {
598
598
  if (!this.configuration.quiet) {
599
- console.warn('[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again.')
599
+ if (event.reason === Unauthorized.reason) {
600
+ console.warn('[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again.')
601
+ } else {
602
+ console.warn(`[HocuspocusProvider] Connection closed with status Unauthorized: ${event.reason}`)
603
+ }
600
604
  }
601
605
 
602
606
  this.shouldConnect = false
@@ -0,0 +1,26 @@
1
+ import {
2
+ HocuspocusProvider,
3
+ HocuspocusProviderConfiguration,
4
+ } from './HocuspocusProvider'
5
+
6
+ export type TiptapCollabProviderConfiguration =
7
+ Required<Pick<HocuspocusProviderConfiguration, 'name'>> &
8
+ Partial<HocuspocusProviderConfiguration> &
9
+ AdditionalTiptapCollabProviderConfiguration
10
+
11
+ export interface AdditionalTiptapCollabProviderConfiguration {
12
+ /**
13
+ * A Hocuspocus Cloud App ID, get one here: https://tt-collab.de
14
+ */
15
+ appId: string,
16
+ }
17
+
18
+ export class TiptapCollabProvider extends HocuspocusProvider {
19
+ constructor(configuration: TiptapCollabProviderConfiguration) {
20
+ if (!configuration.url) {
21
+ configuration.url = `wss://${configuration.appId}.tt-collab.de`
22
+ }
23
+
24
+ super(configuration as HocuspocusProviderConfiguration)
25
+ }
26
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './HocuspocusProvider'
2
- export * from './HocuspocusCloudProvider'
2
+ export * from './TiptapCollabProvider'
3
3
  export * from './types'
@@ -1,11 +0,0 @@
1
- import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider';
2
- export declare type HocuspocusCloudProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & AdditionalHocuspocusCloudProviderConfiguration;
3
- export interface AdditionalHocuspocusCloudProviderConfiguration {
4
- /**
5
- * A Hocuspocus Cloud key, get one here: https://hocuspocus.cloud/
6
- */
7
- key: string;
8
- }
9
- export declare class HocuspocusCloudProvider extends HocuspocusProvider {
10
- constructor(configuration: HocuspocusCloudProviderConfiguration);
11
- }
@@ -1,34 +0,0 @@
1
- import {
2
- HocuspocusProvider,
3
- HocuspocusProviderConfiguration,
4
- } from './HocuspocusProvider'
5
-
6
- export type HocuspocusCloudProviderConfiguration =
7
- Required<Pick<HocuspocusProviderConfiguration, 'name'>> &
8
- Partial<HocuspocusProviderConfiguration> &
9
- AdditionalHocuspocusCloudProviderConfiguration
10
-
11
- export interface AdditionalHocuspocusCloudProviderConfiguration {
12
- /**
13
- * A Hocuspocus Cloud key, get one here: https://hocuspocus.cloud/
14
- */
15
- key: string,
16
- }
17
-
18
- export class HocuspocusCloudProvider extends HocuspocusProvider {
19
- constructor(configuration: HocuspocusCloudProviderConfiguration) {
20
- if (!configuration.url) {
21
- configuration.url = 'wss://connect.hocuspocus.cloud'
22
- }
23
-
24
- if (configuration.key) {
25
- if (!configuration.parameters) {
26
- configuration.parameters = {}
27
- }
28
-
29
- configuration.parameters.key = configuration.key
30
- }
31
-
32
- super(configuration as HocuspocusProviderConfiguration)
33
- }
34
- }