@atlaskit/collab-provider 18.1.6 → 18.2.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 18.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`efed9a7ddd2cd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/efed9a7ddd2cd) -
8
+ Use websocket transport only for socket connections on GCP tenants
9
+
3
10
  ## 18.1.6
4
11
 
5
12
  ### Patch Changes
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "extends": "../../../../tsconfig.local-consumption.json",
3
3
  "compilerOptions": {
4
- "target": "es5",
5
4
  "outDir": "../../../../../confluence/tsDist/@atlaskit__collab-provider",
6
5
  "rootDir": "../",
7
6
  "composite": true,
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.isAIProviderID = exports.getSubProduct = exports.getStepsAdfWithObfuscation = exports.getStepUGCFreeDetails = exports.getStepTypes = exports.getStepPositions = exports.getProduct = exports.getObfuscatedSteps = exports.getDocAdfWithObfuscationFromJSON = exports.getDocAdfWithObfuscation = exports.createLogger = void 0;
8
+ exports.isGCPtenant = isGCPtenant;
8
9
  exports.logObfuscatedSteps = logObfuscatedSteps;
9
10
  exports.sleep = sleep;
10
11
  exports.toObfuscatedSteps = toObfuscatedSteps;
@@ -267,6 +268,12 @@ function _logObfuscatedSteps() {
267
268
  function toObfuscatedSteps(_x3) {
268
269
  return _toObfuscatedSteps.apply(this, arguments);
269
270
  }
271
+ /**
272
+ * Copied from confluence/next/packages/graphql/src/utils/gcpDomainUtils.ts
273
+ * Checks if the current domain is a GCP tenant matching the pattern: .*-cdp-{cdp-id}\.jira-dev\.com
274
+ * @param {string | undefined} hostname optional hostname to evaluate
275
+ * @returns {boolean} true if the domain matches the GCP tenant pattern
276
+ */
270
277
  function _toObfuscatedSteps() {
271
278
  _toObfuscatedSteps = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(steps) {
272
279
  var _steps;
@@ -287,4 +294,13 @@ function _toObfuscatedSteps() {
287
294
  }, _callee2);
288
295
  }));
289
296
  return _toObfuscatedSteps.apply(this, arguments);
297
+ }
298
+ function isGCPtenant(hostname) {
299
+ if (!hostname) {
300
+ return false;
301
+ }
302
+
303
+ // eslint-disable-next-line require-unicode-regexp
304
+ var gcpTenantPattern = /^.*-cdp-\w+\.jira-dev\.com$/;
305
+ return gcpTenantPattern.test(hostname);
290
306
  }
@@ -17,7 +17,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
17
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, analyticsHelper, path, documentAri) {
19
19
  var _URL = new URL(url),
20
- pathname = _URL.pathname;
20
+ pathname = _URL.pathname,
21
+ hostname = _URL.hostname;
21
22
  var socketIOOptions = _config.SOCKET_IO_OPTIONS;
22
23
  // Polling first
23
24
  var transports = ['polling', 'websocket'];
@@ -36,6 +37,9 @@ function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, analyticsH
36
37
  if ((0, _expValEquals.expValEquals)('platform_editor_to_use_pmr_for_collab_edit_none_ic', 'isEnabled', true, false)) {
37
38
  usePMR = true;
38
39
  }
40
+ if ((0, _utils.isGCPtenant)(hostname) && (0, _platformFeatureFlags.fg)('collab_edit_via_websocket_only_for_gcp')) {
41
+ transports = ['websocket'];
42
+ }
39
43
  }
40
44
  var extraHeaders = {
41
45
  'x-product': (0, _utils.getProduct)(productInfo),
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "18.1.5";
8
+ var version = exports.version = "18.1.6";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -217,4 +217,20 @@ export async function logObfuscatedSteps(oldState, newState) {
217
217
  export async function toObfuscatedSteps(steps) {
218
218
  const _steps = await Promise.resolve(steps.slice().map(s => s.toJSON()));
219
219
  return JSON.stringify(getObfuscatedSteps(_steps));
220
+ }
221
+
222
+ /**
223
+ * Copied from confluence/next/packages/graphql/src/utils/gcpDomainUtils.ts
224
+ * Checks if the current domain is a GCP tenant matching the pattern: .*-cdp-{cdp-id}\.jira-dev\.com
225
+ * @param {string | undefined} hostname optional hostname to evaluate
226
+ * @returns {boolean} true if the domain matches the GCP tenant pattern
227
+ */
228
+ export function isGCPtenant(hostname) {
229
+ if (!hostname) {
230
+ return false;
231
+ }
232
+
233
+ // eslint-disable-next-line require-unicode-regexp
234
+ const gcpTenantPattern = /^.*-cdp-\w+\.jira-dev\.com$/;
235
+ return gcpTenantPattern.test(hostname);
220
236
  }
@@ -2,11 +2,12 @@ import { io } from 'socket.io-client';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
4
  import { Provider } from './provider';
5
- import { getProduct, getSubProduct } from './helpers/utils';
5
+ import { getProduct, getSubProduct, isGCPtenant } from './helpers/utils';
6
6
  import { SOCKET_IO_OPTIONS, SOCKET_IO_OPTIONS_WITH_HIGH_JITTER } from './config';
7
7
  export function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, analyticsHelper, path, documentAri) {
8
8
  const {
9
- pathname
9
+ pathname,
10
+ hostname
10
11
  } = new URL(url);
11
12
  let socketIOOptions = SOCKET_IO_OPTIONS;
12
13
  // Polling first
@@ -26,6 +27,9 @@ export function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, ana
26
27
  if (expValEquals('platform_editor_to_use_pmr_for_collab_edit_none_ic', 'isEnabled', true, false)) {
27
28
  usePMR = true;
28
29
  }
30
+ if (isGCPtenant(hostname) && fg('collab_edit_via_websocket_only_for_gcp')) {
31
+ transports = ['websocket'];
32
+ }
29
33
  }
30
34
  const extraHeaders = {
31
35
  'x-product': getProduct(productInfo),
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "18.1.5";
2
+ export const version = "18.1.6";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -257,6 +257,13 @@ function _logObfuscatedSteps() {
257
257
  export function toObfuscatedSteps(_x3) {
258
258
  return _toObfuscatedSteps.apply(this, arguments);
259
259
  }
260
+
261
+ /**
262
+ * Copied from confluence/next/packages/graphql/src/utils/gcpDomainUtils.ts
263
+ * Checks if the current domain is a GCP tenant matching the pattern: .*-cdp-{cdp-id}\.jira-dev\.com
264
+ * @param {string | undefined} hostname optional hostname to evaluate
265
+ * @returns {boolean} true if the domain matches the GCP tenant pattern
266
+ */
260
267
  function _toObfuscatedSteps() {
261
268
  _toObfuscatedSteps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(steps) {
262
269
  var _steps;
@@ -277,4 +284,13 @@ function _toObfuscatedSteps() {
277
284
  }, _callee2);
278
285
  }));
279
286
  return _toObfuscatedSteps.apply(this, arguments);
287
+ }
288
+ export function isGCPtenant(hostname) {
289
+ if (!hostname) {
290
+ return false;
291
+ }
292
+
293
+ // eslint-disable-next-line require-unicode-regexp
294
+ var gcpTenantPattern = /^.*-cdp-\w+\.jira-dev\.com$/;
295
+ return gcpTenantPattern.test(hostname);
280
296
  }
@@ -5,11 +5,12 @@ import { io } from 'socket.io-client';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  import { Provider } from './provider';
8
- import { getProduct, getSubProduct } from './helpers/utils';
8
+ import { getProduct, getSubProduct, isGCPtenant } from './helpers/utils';
9
9
  import { SOCKET_IO_OPTIONS, SOCKET_IO_OPTIONS_WITH_HIGH_JITTER } from './config';
10
10
  export function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, analyticsHelper, path, documentAri) {
11
11
  var _URL = new URL(url),
12
- pathname = _URL.pathname;
12
+ pathname = _URL.pathname,
13
+ hostname = _URL.hostname;
13
14
  var socketIOOptions = SOCKET_IO_OPTIONS;
14
15
  // Polling first
15
16
  var transports = ['polling', 'websocket'];
@@ -28,6 +29,9 @@ export function createSocketIOSocket(url, auth, productInfo, isPresenceOnly, ana
28
29
  if (expValEquals('platform_editor_to_use_pmr_for_collab_edit_none_ic', 'isEnabled', true, false)) {
29
30
  usePMR = true;
30
31
  }
32
+ if (isGCPtenant(hostname) && fg('collab_edit_via_websocket_only_for_gcp')) {
33
+ transports = ['websocket'];
34
+ }
31
35
  }
32
36
  var extraHeaders = {
33
37
  'x-product': getProduct(productInfo),
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "18.1.5";
2
+ export var version = "18.1.6";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -18,34 +18,22 @@ export type UGCFreeStepDetails = {
18
18
  };
19
19
  export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
20
20
  export declare const getStepTypes: (stepJson: StepJson) => {
21
- type: string;
22
21
  contentTypes: string | null;
22
+ type: string;
23
23
  };
24
24
  export declare const getStepsAdfWithObfuscation: (stepJson: StepJson) => ADFEntity[] | null;
25
25
  export declare const getDocAdfWithObfuscation: (doc: ProseMirrorNode) => ADFEntity | null;
26
26
  export declare const getDocAdfWithObfuscationFromJSON: (docJson: JSONDocNode) => ADFEntity | null;
27
27
  export declare const getStepPositions: (stepJson: StepJson) => {
28
- pos?: number | undefined;
29
- insert?: number | undefined;
28
+ from?: number | undefined;
30
29
  gapFrom?: number | undefined;
31
30
  gapTo?: number | undefined;
32
- from?: number | undefined;
31
+ insert?: number | undefined;
32
+ pos?: number | undefined;
33
33
  to?: number | undefined;
34
34
  };
35
35
  export declare const getObfuscatedSteps: (steps: StepJson[], endIndex?: number | undefined) => {
36
- stepType: {
37
- type: string;
38
- contentTypes: string | null;
39
- };
40
36
  stepContent: ADFEntity[] | null;
41
- stepPositions: {
42
- pos?: number | undefined;
43
- insert?: number | undefined;
44
- gapFrom?: number | undefined;
45
- gapTo?: number | undefined;
46
- from?: number | undefined;
47
- to?: number | undefined;
48
- };
49
37
  stepMetadata: {
50
38
  createdOffline?: boolean;
51
39
  prevStepId?: string;
@@ -57,9 +45,28 @@ export declare const getObfuscatedSteps: (steps: StepJson[], endIndex?: number |
57
45
  traceId?: string;
58
46
  unconfirmedStepAfterRecovery?: boolean;
59
47
  } | undefined;
48
+ stepPositions: {
49
+ from?: number | undefined;
50
+ gapFrom?: number | undefined;
51
+ gapTo?: number | undefined;
52
+ insert?: number | undefined;
53
+ pos?: number | undefined;
54
+ to?: number | undefined;
55
+ };
56
+ stepType: {
57
+ contentTypes: string | null;
58
+ type: string;
59
+ };
60
60
  }[];
61
61
  export declare function logObfuscatedSteps(oldState: EditorState | null, newState: EditorState): Promise<CustomError | {
62
- stepsFromOldState: string;
63
62
  stepsFromNewState: string;
63
+ stepsFromOldState: string;
64
64
  }>;
65
65
  export declare function toObfuscatedSteps(steps: readonly ProseMirrorStep[]): Promise<string>;
66
+ /**
67
+ * Copied from confluence/next/packages/graphql/src/utils/gcpDomainUtils.ts
68
+ * Checks if the current domain is a GCP tenant matching the pattern: .*-cdp-{cdp-id}\.jira-dev\.com
69
+ * @param {string | undefined} hostname optional hostname to evaluate
70
+ * @returns {boolean} true if the domain matches the GCP tenant pattern
71
+ */
72
+ export declare function isGCPtenant(hostname?: string): boolean;
@@ -18,34 +18,22 @@ export type UGCFreeStepDetails = {
18
18
  };
19
19
  export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
20
20
  export declare const getStepTypes: (stepJson: StepJson) => {
21
- type: string;
22
21
  contentTypes: string | null;
22
+ type: string;
23
23
  };
24
24
  export declare const getStepsAdfWithObfuscation: (stepJson: StepJson) => ADFEntity[] | null;
25
25
  export declare const getDocAdfWithObfuscation: (doc: ProseMirrorNode) => ADFEntity | null;
26
26
  export declare const getDocAdfWithObfuscationFromJSON: (docJson: JSONDocNode) => ADFEntity | null;
27
27
  export declare const getStepPositions: (stepJson: StepJson) => {
28
- pos?: number | undefined;
29
- insert?: number | undefined;
28
+ from?: number | undefined;
30
29
  gapFrom?: number | undefined;
31
30
  gapTo?: number | undefined;
32
- from?: number | undefined;
31
+ insert?: number | undefined;
32
+ pos?: number | undefined;
33
33
  to?: number | undefined;
34
34
  };
35
35
  export declare const getObfuscatedSteps: (steps: StepJson[], endIndex?: number | undefined) => {
36
- stepType: {
37
- type: string;
38
- contentTypes: string | null;
39
- };
40
36
  stepContent: ADFEntity[] | null;
41
- stepPositions: {
42
- pos?: number | undefined;
43
- insert?: number | undefined;
44
- gapFrom?: number | undefined;
45
- gapTo?: number | undefined;
46
- from?: number | undefined;
47
- to?: number | undefined;
48
- };
49
37
  stepMetadata: {
50
38
  createdOffline?: boolean;
51
39
  prevStepId?: string;
@@ -57,9 +45,28 @@ export declare const getObfuscatedSteps: (steps: StepJson[], endIndex?: number |
57
45
  traceId?: string;
58
46
  unconfirmedStepAfterRecovery?: boolean;
59
47
  } | undefined;
48
+ stepPositions: {
49
+ from?: number | undefined;
50
+ gapFrom?: number | undefined;
51
+ gapTo?: number | undefined;
52
+ insert?: number | undefined;
53
+ pos?: number | undefined;
54
+ to?: number | undefined;
55
+ };
56
+ stepType: {
57
+ contentTypes: string | null;
58
+ type: string;
59
+ };
60
60
  }[];
61
61
  export declare function logObfuscatedSteps(oldState: EditorState | null, newState: EditorState): Promise<CustomError | {
62
- stepsFromOldState: string;
63
62
  stepsFromNewState: string;
63
+ stepsFromOldState: string;
64
64
  }>;
65
65
  export declare function toObfuscatedSteps(steps: readonly ProseMirrorStep[]): Promise<string>;
66
+ /**
67
+ * Copied from confluence/next/packages/graphql/src/utils/gcpDomainUtils.ts
68
+ * Checks if the current domain is a GCP tenant matching the pattern: .*-cdp-{cdp-id}\.jira-dev\.com
69
+ * @param {string | undefined} hostname optional hostname to evaluate
70
+ * @returns {boolean} true if the domain matches the GCP tenant pattern
71
+ */
72
+ export declare function isGCPtenant(hostname?: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "18.1.6",
3
+ "version": "18.2.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/platform-feature-flags": "^1.1.0",
38
38
  "@atlaskit/prosemirror-collab": "^0.22.0",
39
39
  "@atlaskit/react-ufo": "^5.19.0",
40
- "@atlaskit/tmp-editor-statsig": "^77.0.0",
40
+ "@atlaskit/tmp-editor-statsig": "^77.1.0",
41
41
  "@atlaskit/ufo": "^0.4.0",
42
42
  "@atlaskit/util-service-support": "^6.3.0",
43
43
  "@babel/runtime": "^7.0.0",
@@ -70,9 +70,12 @@
70
70
  "platform-feature-flags": {
71
71
  "platform-editor-presence-websocket-only": {
72
72
  "type": "boolean"
73
+ },
74
+ "collab_edit_via_websocket_only_for_gcp": {
75
+ "type": "boolean"
73
76
  }
74
77
  },
75
78
  "peerDependencies": {
76
- "@atlaskit/editor-common": "^114.20.0"
79
+ "@atlaskit/editor-common": "^114.21.0"
77
80
  }
78
81
  }
@@ -1,72 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.local-consumption.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../jira/tsDist/@atlaskit__collab-provider/app",
6
- "rootDir": "../",
7
- "composite": true,
8
- "noCheck": true
9
- },
10
- "include": [
11
- "../src/**/*.ts",
12
- "../src/**/*.tsx"
13
- ],
14
- "exclude": [
15
- "../src/**/__tests__/*",
16
- "../src/**/*.test.*",
17
- "../src/**/test.*",
18
- "../src/**/examples.*",
19
- "../src/**/examples/*",
20
- "../src/**/examples/**/*",
21
- "../src/**/*.stories.*",
22
- "../src/**/stories/*",
23
- "../src/**/stories/**/*"
24
- ],
25
- "references": [
26
- {
27
- "path": "../../adf-utils/afm-jira/tsconfig.json"
28
- },
29
- {
30
- "path": "../../../analytics/analytics-gas-types/afm-jira/tsconfig.json"
31
- },
32
- {
33
- "path": "../../../analytics/analytics-listeners/afm-jira/tsconfig.json"
34
- },
35
- {
36
- "path": "../../../elements/anonymous-assets/afm-jira/tsconfig.json"
37
- },
38
- {
39
- "path": "../../../uip/atlassian-context/afm-jira/tsconfig.json"
40
- },
41
- {
42
- "path": "../../editor-json-transformer/afm-jira/tsconfig.json"
43
- },
44
- {
45
- "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
46
- },
47
- {
48
- "path": "../../../measurement/feature-gate-js-client/afm-jira/tsconfig.json"
49
- },
50
- {
51
- "path": "../../../platform/feature-flags/afm-jira/tsconfig.json"
52
- },
53
- {
54
- "path": "../../prosemirror-collab/afm-jira/tsconfig.json"
55
- },
56
- {
57
- "path": "../../../react-ufo/atlaskit/afm-jira/tsconfig.json"
58
- },
59
- {
60
- "path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
61
- },
62
- {
63
- "path": "../../../data/ufo-external/afm-jira/tsconfig.json"
64
- },
65
- {
66
- "path": "../../../elements/util-service-support/afm-jira/tsconfig.json"
67
- },
68
- {
69
- "path": "../../editor-common/afm-jira/tsconfig.json"
70
- }
71
- ]
72
- }