@atlaskit/editor-plugin-base 0.3.3 → 0.3.5

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.
@@ -8,7 +8,6 @@ import { countNodes, getAnalyticsEventSeverity, isPerformanceAPIAvailable, isPer
8
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { setInteractionType } from '../utils/frozen-editor';
10
10
  import InputLatencyTracker from '../utils/input-latency-tracking';
11
- import { getContextIdentifier } from './context-identifier';
12
11
  export var frozenEditorPluginKey = new PluginKey('frozenEditor');
13
12
  var DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
14
13
  var DEFAULT_SLOW_THRESHOLD = 300;
@@ -18,234 +17,238 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
18
17
  var DEFAULT_TRACK_SEVERITY_ENABLED = false;
19
18
  export var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
20
19
  export var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
21
- var dispatchLongTaskEvent = function dispatchLongTaskEvent(dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
22
- var _getContextIdentifier;
23
- var state = view.state;
24
- var nodesCount = getNodeCount(state);
25
- return dispatchAnalyticsEvent({
26
- action: ACTION.BROWSER_FREEZE,
27
- actionSubject: ACTION_SUBJECT.EDITOR,
28
- attributes: _objectSpread(_objectSpread({
29
- objectId: (_getContextIdentifier = getContextIdentifier(state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
30
- freezeTime: time,
31
- nodeSize: state.doc.nodeSize
32
- }, nodesCount), {}, {
33
- interactionType: interactionType,
34
- severity: severity
35
- }),
36
- eventType: EVENT_TYPE.OPERATIONAL
37
- });
20
+ var dispatchLongTaskEvent = function dispatchLongTaskEvent(contextIdentifierPlugin) {
21
+ return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
22
+ var _contextIdentifierPlu;
23
+ var state = view.state;
24
+ var nodesCount = getNodeCount(state);
25
+ return dispatchAnalyticsEvent({
26
+ action: ACTION.BROWSER_FREEZE,
27
+ actionSubject: ACTION_SUBJECT.EDITOR,
28
+ attributes: _objectSpread(_objectSpread({
29
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu === void 0 || (_contextIdentifierPlu = _contextIdentifierPlu.contextIdentifierProvider) === null || _contextIdentifierPlu === void 0 ? void 0 : _contextIdentifierPlu.objectId,
30
+ freezeTime: time,
31
+ nodeSize: state.doc.nodeSize
32
+ }, nodesCount), {}, {
33
+ interactionType: interactionType,
34
+ severity: severity
35
+ }),
36
+ eventType: EVENT_TYPE.OPERATIONAL
37
+ });
38
+ };
38
39
  };
39
- export default (function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
40
- var interactionType;
41
- var inputLatencyTracker = null;
42
- var inputLatencySingleKeyTracker = null;
43
- var inputLatencyRenderedTracker = null;
44
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
45
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
46
- }
47
- var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
48
- var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
49
- var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
50
- var allowCountNodes = inputTracking && inputTracking.countNodes;
51
- var prevNodeCountState = null;
52
- var prevNodeCount = {};
40
+ export default (function (contextIdentifierPlugin) {
41
+ return function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
42
+ var interactionType;
43
+ var inputLatencyTracker = null;
44
+ var inputLatencySingleKeyTracker = null;
45
+ var inputLatencyRenderedTracker = null;
46
+ if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
47
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
48
+ }
49
+ var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
50
+ var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
51
+ var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
52
+ var allowCountNodes = inputTracking && inputTracking.countNodes;
53
+ var prevNodeCountState = null;
54
+ var prevNodeCount = {};
53
55
 
54
- // Cache the result as we were calling this multiple times
55
- // and has potential to be expensive
56
- var getNodeCount = function getNodeCount(state) {
57
- if (state === prevNodeCountState) {
56
+ // Cache the result as we were calling this multiple times
57
+ // and has potential to be expensive
58
+ var getNodeCount = function getNodeCount(state) {
59
+ if (state === prevNodeCountState) {
60
+ return prevNodeCount;
61
+ }
62
+ prevNodeCount = allowCountNodes ? countNodes(state) : {};
63
+ prevNodeCountState = state;
58
64
  return prevNodeCount;
59
- }
60
- prevNodeCount = allowCountNodes ? countNodes(state) : {};
61
- prevNodeCountState = state;
62
- return prevNodeCount;
63
- };
64
- var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
65
- var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
66
- var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
67
- var createDispatchSample = function createDispatchSample(action, view) {
68
- return function (time, severity) {
69
- var _getContextIdentifier2;
70
- var state = view.state;
71
- var nodesCount = getNodeCount(state);
72
- var samplePayload = {
73
- action: action,
74
- actionSubject: ACTION_SUBJECT.EDITOR,
75
- attributes: _objectSpread(_objectSpread({
76
- time: time,
77
- nodeSize: state.doc.nodeSize
78
- }, nodesCount), {}, {
79
- objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
80
- severity: shouldTrackSeverity ? severity : undefined
81
- }),
82
- eventType: EVENT_TYPE.OPERATIONAL
65
+ };
66
+ var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
67
+ var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
68
+ var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
69
+ var createDispatchSample = function createDispatchSample(action, view) {
70
+ return function (time, severity) {
71
+ var _contextIdentifierPlu2;
72
+ var state = view.state;
73
+ var nodesCount = getNodeCount(state);
74
+ var samplePayload = {
75
+ action: action,
76
+ actionSubject: ACTION_SUBJECT.EDITOR,
77
+ attributes: _objectSpread(_objectSpread({
78
+ time: time,
79
+ nodeSize: state.doc.nodeSize
80
+ }, nodesCount), {}, {
81
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu2 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu2 === void 0 || (_contextIdentifierPlu2 = _contextIdentifierPlu2.contextIdentifierProvider) === null || _contextIdentifierPlu2 === void 0 ? void 0 : _contextIdentifierPlu2.objectId,
82
+ severity: shouldTrackSeverity ? severity : undefined
83
+ }),
84
+ eventType: EVENT_TYPE.OPERATIONAL
85
+ };
86
+ dispatchAnalyticsEvent(samplePayload);
83
87
  };
84
- dispatchAnalyticsEvent(samplePayload);
85
88
  };
86
- };
87
- var createDispatchAverage = function createDispatchAverage(action, view) {
88
- return function (_ref, severity) {
89
- var _getContextIdentifier3;
90
- var mean = _ref.mean,
91
- median = _ref.median,
92
- sampleSize = _ref.sampleSize;
93
- var state = view.state;
94
- var nodeCount = getNodeCount(state);
95
- var averagePayload = {
96
- action: action,
97
- actionSubject: ACTION_SUBJECT.EDITOR,
98
- attributes: _objectSpread(_objectSpread({
99
- mean: mean,
100
- median: median,
101
- sampleSize: sampleSize
102
- }, nodeCount), {}, {
103
- nodeSize: state.doc.nodeSize,
104
- severity: shouldTrackSeverity ? severity : undefined,
105
- objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
106
- }),
107
- eventType: EVENT_TYPE.OPERATIONAL
89
+ var createDispatchAverage = function createDispatchAverage(action, view) {
90
+ return function (_ref, severity) {
91
+ var _contextIdentifierPlu3;
92
+ var mean = _ref.mean,
93
+ median = _ref.median,
94
+ sampleSize = _ref.sampleSize;
95
+ var state = view.state;
96
+ var nodeCount = getNodeCount(state);
97
+ var averagePayload = {
98
+ action: action,
99
+ actionSubject: ACTION_SUBJECT.EDITOR,
100
+ attributes: _objectSpread(_objectSpread({
101
+ mean: mean,
102
+ median: median,
103
+ sampleSize: sampleSize
104
+ }, nodeCount), {}, {
105
+ nodeSize: state.doc.nodeSize,
106
+ severity: shouldTrackSeverity ? severity : undefined,
107
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu3 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu3 === void 0 || (_contextIdentifierPlu3 = _contextIdentifierPlu3.contextIdentifierProvider) === null || _contextIdentifierPlu3 === void 0 ? void 0 : _contextIdentifierPlu3.objectId
108
+ }),
109
+ eventType: EVENT_TYPE.OPERATIONAL
110
+ };
111
+ dispatchAnalyticsEvent(averagePayload);
108
112
  };
109
- dispatchAnalyticsEvent(averagePayload);
110
113
  };
111
- };
112
- return new SafePlugin({
113
- key: frozenEditorPluginKey,
114
- props: isPerformanceAPIAvailable() ? {
115
- handleTextInput: function handleTextInput(view) {
116
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
117
- interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
118
- }
119
- if (inputLatencyTracker) {
120
- var end = inputLatencyTracker.start();
114
+ return new SafePlugin({
115
+ key: frozenEditorPluginKey,
116
+ props: isPerformanceAPIAvailable() ? {
117
+ handleTextInput: function handleTextInput(view) {
118
+ if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
119
+ interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
120
+ }
121
+ if (inputLatencyTracker) {
122
+ var end = inputLatencyTracker.start();
121
123
 
122
- // This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
123
- // Also this is called before browser rendering so it doesn't count it.
124
- requestAnimationFrame(end);
125
- }
126
- if (inputLatencySingleKeyTracker) {
127
- var _end = inputLatencySingleKeyTracker.start();
124
+ // This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
125
+ // Also this is called before browser rendering so it doesn't count it.
126
+ requestAnimationFrame(end);
127
+ }
128
+ if (inputLatencySingleKeyTracker) {
129
+ var _end = inputLatencySingleKeyTracker.start();
128
130
 
129
- // This is executed before next handleTextInput when multiple keypress events are in one animation frame
130
- // so it tracks individual keypress processing time
131
- Promise.resolve().then(_end);
132
- }
133
- if (inputLatencyRenderedTracker) {
134
- var _end2 = inputLatencyRenderedTracker.start();
131
+ // This is executed before next handleTextInput when multiple keypress events are in one animation frame
132
+ // so it tracks individual keypress processing time
133
+ Promise.resolve().then(_end);
134
+ }
135
+ if (inputLatencyRenderedTracker) {
136
+ var _end2 = inputLatencyRenderedTracker.start();
135
137
 
136
- // This is called at the next event loop so it counts browser rendering time.
137
- setTimeout(_end2);
138
- }
139
- return false;
140
- },
141
- handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
142
- click: function click() {
143
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
138
+ // This is called at the next event loop so it counts browser rendering time.
139
+ setTimeout(_end2);
140
+ }
144
141
  return false;
145
142
  },
146
- paste: function paste() {
147
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
148
- return false;
149
- }
150
- } : undefined
151
- } : undefined,
152
- view: function view(_view) {
153
- if (!isPerformanceObserverAvailable()) {
154
- return {};
155
- }
156
- var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
157
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
158
- inputLatencyTracker = new InputLatencyTracker({
159
- samplingRate: samplingRate,
160
- slowThreshold: slowThreshold,
161
- normalThreshold: severityThresholdNormal,
162
- degradedThreshold: severityThresholdDegraded,
163
- onSampleStart: function onSampleStart() {
164
- experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
165
- },
166
- onSampleEnd: function onSampleEnd(time, _ref2) {
167
- var _getContextIdentifier4;
168
- var isSlow = _ref2.isSlow,
169
- severity = _ref2.severity;
170
- var state = _view.state;
171
- var nodesCount = getNodeCount(state);
172
- if (isSlow) {
173
- experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
174
- slowInput: true
175
- });
176
- }
177
- experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
178
- nodeSize: state.doc.nodeSize
179
- }, nodesCount), {}, {
180
- objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
181
- time: time,
182
- severity: shouldTrackSeverity ? severity : undefined
183
- }));
143
+ handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
144
+ click: function click() {
145
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
146
+ return false;
184
147
  },
185
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
186
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
187
- onSlowInput: function onSlowInput(time) {
188
- var _getContextIdentifier5;
189
- var state = _view.state;
190
- var nodesCount = getNodeCount(state);
191
- dispatchAnalyticsEvent({
192
- action: ACTION.SLOW_INPUT,
193
- actionSubject: ACTION_SUBJECT.EDITOR,
194
- attributes: _objectSpread(_objectSpread({
195
- time: time,
148
+ paste: function paste() {
149
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
150
+ return false;
151
+ }
152
+ } : undefined
153
+ } : undefined,
154
+ view: function view(_view) {
155
+ if (!isPerformanceObserverAvailable()) {
156
+ return {};
157
+ }
158
+ var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
159
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
160
+ inputLatencyTracker = new InputLatencyTracker({
161
+ samplingRate: samplingRate,
162
+ slowThreshold: slowThreshold,
163
+ normalThreshold: severityThresholdNormal,
164
+ degradedThreshold: severityThresholdDegraded,
165
+ onSampleStart: function onSampleStart() {
166
+ experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
167
+ },
168
+ onSampleEnd: function onSampleEnd(time, _ref2) {
169
+ var _contextIdentifierPlu4;
170
+ var isSlow = _ref2.isSlow,
171
+ severity = _ref2.severity;
172
+ var state = _view.state;
173
+ var nodesCount = getNodeCount(state);
174
+ if (isSlow) {
175
+ experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
176
+ slowInput: true
177
+ });
178
+ }
179
+ experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
196
180
  nodeSize: state.doc.nodeSize
197
181
  }, nodesCount), {}, {
198
- objectId: (_getContextIdentifier5 = getContextIdentifier(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
199
- }),
200
- eventType: EVENT_TYPE.OPERATIONAL
201
- });
202
- }
203
- });
204
- }
205
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
206
- inputLatencySingleKeyTracker = new InputLatencyTracker({
207
- samplingRate: samplingRate,
208
- slowThreshold: slowThreshold,
209
- normalThreshold: severityThresholdNormal,
210
- degradedThreshold: severityThresholdDegraded,
211
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
212
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
213
- });
214
- }
215
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
216
- inputLatencyRenderedTracker = new InputLatencyTracker({
217
- samplingRate: samplingRate,
218
- slowThreshold: slowThreshold,
219
- normalThreshold: severityThresholdNormal,
220
- degradedThreshold: severityThresholdDegraded,
221
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
222
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
223
- });
224
- }
225
- var observer;
226
- try {
227
- observer = new PerformanceObserver(function (list) {
228
- var perfEntries = list.getEntries();
229
- for (var i = 0; i < perfEntries.length; i++) {
230
- var duration = perfEntries[i].duration;
231
- if (duration > freezeThreshold) {
232
- dispatchLongTaskEvent(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
182
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu4 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu4 === void 0 || (_contextIdentifierPlu4 = _contextIdentifierPlu4.contextIdentifierProvider) === null || _contextIdentifierPlu4 === void 0 ? void 0 : _contextIdentifierPlu4.objectId,
183
+ time: time,
184
+ severity: shouldTrackSeverity ? severity : undefined
185
+ }));
186
+ },
187
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
188
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
189
+ onSlowInput: function onSlowInput(time) {
190
+ var _contextIdentifierPlu5;
191
+ var state = _view.state;
192
+ var nodesCount = getNodeCount(state);
193
+ dispatchAnalyticsEvent({
194
+ action: ACTION.SLOW_INPUT,
195
+ actionSubject: ACTION_SUBJECT.EDITOR,
196
+ attributes: _objectSpread(_objectSpread({
197
+ time: time,
198
+ nodeSize: state.doc.nodeSize
199
+ }, nodesCount), {}, {
200
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu5 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu5 === void 0 || (_contextIdentifierPlu5 = _contextIdentifierPlu5.contextIdentifierProvider) === null || _contextIdentifierPlu5 === void 0 ? void 0 : _contextIdentifierPlu5.objectId
201
+ }),
202
+ eventType: EVENT_TYPE.OPERATIONAL
203
+ });
233
204
  }
234
- }
235
- });
236
-
237
- // register observer for long task notifications
238
- observer.observe({
239
- entryTypes: ['longtask']
240
- });
241
- } catch (e) {}
242
- return {
243
- destroy: function destroy() {
244
- var _inputLatencyTracker, _observer;
245
- (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
246
- (_observer = observer) === null || _observer === void 0 || _observer.disconnect();
205
+ });
247
206
  }
248
- };
249
- }
250
- });
207
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
208
+ inputLatencySingleKeyTracker = new InputLatencyTracker({
209
+ samplingRate: samplingRate,
210
+ slowThreshold: slowThreshold,
211
+ normalThreshold: severityThresholdNormal,
212
+ degradedThreshold: severityThresholdDegraded,
213
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
214
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
215
+ });
216
+ }
217
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
218
+ inputLatencyRenderedTracker = new InputLatencyTracker({
219
+ samplingRate: samplingRate,
220
+ slowThreshold: slowThreshold,
221
+ normalThreshold: severityThresholdNormal,
222
+ degradedThreshold: severityThresholdDegraded,
223
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
224
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
225
+ });
226
+ }
227
+ var observer;
228
+ try {
229
+ observer = new PerformanceObserver(function (list) {
230
+ var perfEntries = list.getEntries();
231
+ for (var i = 0; i < perfEntries.length; i++) {
232
+ var duration = perfEntries[i].duration;
233
+ if (duration > freezeThreshold) {
234
+ dispatchLongTaskEvent(contextIdentifierPlugin)(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
235
+ }
236
+ }
237
+ });
238
+
239
+ // register observer for long task notifications
240
+ observer.observe({
241
+ entryTypes: ['longtask']
242
+ });
243
+ } catch (e) {}
244
+ return {
245
+ destroy: function destroy() {
246
+ var _inputLatencyTracker, _observer;
247
+ (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
248
+ (_observer = observer) === null || _observer === void 0 || _observer.disconnect();
249
+ }
250
+ };
251
+ }
252
+ });
253
+ };
251
254
  });
@@ -210,7 +210,7 @@ export default (function () {
210
210
  gutter.addGutter(editorParentElement);
211
211
  }
212
212
  };
213
- var toggleGutter = function toggleGutter(viewPortSize, contentSize) {
213
+ var toggleGutter = function toggleGutter(contentSize, threshold) {
214
214
  if (pluginOptions.persistScrollGutter) {
215
215
  if (!isEmptyDocument(view.state.doc)) {
216
216
  addAndObserveGutter();
@@ -223,8 +223,7 @@ export default (function () {
223
223
  // Add or remove the gutter based on whether the content is about to exceed the viewport height.
224
224
  // We do this to ensure there is sufficient white space below the last content node in order to
225
225
  // see any UI control elements which may sit beneath it.
226
- var gutterThresholdHeight = viewPortSize - gutterSize;
227
- if (contentSize >= gutterThresholdHeight) {
226
+ if (contentSize >= threshold) {
228
227
  addAndObserveGutter();
229
228
  } else {
230
229
  if (gutter.isMounted()) {
@@ -252,7 +251,7 @@ export default (function () {
252
251
  } finally {
253
252
  _iterator.f();
254
253
  }
255
- toggleGutter(viewportElementHeight, contentElementHeight);
254
+ toggleGutter(contentElementHeight, viewportElementHeight);
256
255
  };
257
256
 
258
257
  // Subscribe to updates of the height of the viewport and content elements
@@ -282,7 +281,8 @@ export default (function () {
282
281
  // No need to recheck if the selected node hasn't changed.
283
282
  return;
284
283
  }
285
- toggleGutter(viewportElementHeight, contentElementHeight);
284
+ var gutterThresholdHeight = viewportElementHeight - gutterSize;
285
+ toggleGutter(contentElementHeight, gutterThresholdHeight);
286
286
  }
287
287
  };
288
288
  })
@@ -1,5 +1,5 @@
1
- import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
2
1
  import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { setKeyboardHeight } from './commands';
5
5
  import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter';
@@ -11,13 +11,15 @@ export interface BasePluginOptions {
11
11
  ufo?: boolean;
12
12
  }
13
13
  export type BasePluginState = {
14
- contextIdentifier: ContextIdentifierProvider | undefined;
15
14
  /** Current height of keyboard (+ custom toolbar) in iOS app */
16
15
  keyboardHeight: number | undefined;
17
16
  };
18
17
  export type BasePlugin = NextEditorPlugin<'base', {
19
18
  pluginConfiguration: BasePluginOptions | undefined;
20
- dependencies: [OptionalPlugin<FeatureFlagsPlugin>];
19
+ dependencies: [
20
+ OptionalPlugin<FeatureFlagsPlugin>,
21
+ OptionalPlugin<ContextIdentifierPlugin>
22
+ ];
21
23
  sharedState: BasePluginState;
22
24
  actions: {
23
25
  setKeyboardHeight: typeof setKeyboardHeight;
@@ -1,12 +1,13 @@
1
1
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { BrowserFreezetracking, InputTracking } from '@atlaskit/editor-common/types';
3
+ import type { BrowserFreezetracking, ExtractInjectionAPI, InputTracking } from '@atlaskit/editor-common/types';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { BasePlugin } from '../index';
5
6
  export declare const frozenEditorPluginKey: PluginKey<any>;
6
7
  export declare const DEFAULT_FREEZE_THRESHOLD = 600;
7
8
  export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
8
9
  export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
9
10
  export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
10
11
  export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
11
- declare const _default: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
12
+ declare const _default: (contextIdentifierPlugin: ExtractInjectionAPI<BasePlugin>['contextIdentifier'] | undefined) => (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
12
13
  export default _default;
@@ -1,5 +1,5 @@
1
- import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
2
1
  import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { setKeyboardHeight } from './commands';
5
5
  import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter';
@@ -11,14 +11,14 @@ export interface BasePluginOptions {
11
11
  ufo?: boolean;
12
12
  }
13
13
  export type BasePluginState = {
14
- contextIdentifier: ContextIdentifierProvider | undefined;
15
14
  /** Current height of keyboard (+ custom toolbar) in iOS app */
16
15
  keyboardHeight: number | undefined;
17
16
  };
18
17
  export type BasePlugin = NextEditorPlugin<'base', {
19
18
  pluginConfiguration: BasePluginOptions | undefined;
20
19
  dependencies: [
21
- OptionalPlugin<FeatureFlagsPlugin>
20
+ OptionalPlugin<FeatureFlagsPlugin>,
21
+ OptionalPlugin<ContextIdentifierPlugin>
22
22
  ];
23
23
  sharedState: BasePluginState;
24
24
  actions: {
@@ -1,12 +1,13 @@
1
1
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { BrowserFreezetracking, InputTracking } from '@atlaskit/editor-common/types';
3
+ import type { BrowserFreezetracking, ExtractInjectionAPI, InputTracking } from '@atlaskit/editor-common/types';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { BasePlugin } from '../index';
5
6
  export declare const frozenEditorPluginKey: PluginKey<any>;
6
7
  export declare const DEFAULT_FREEZE_THRESHOLD = 600;
7
8
  export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
8
9
  export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
9
10
  export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
10
11
  export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
11
- declare const _default: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
12
+ declare const _default: (contextIdentifierPlugin: ExtractInjectionAPI<BasePlugin>['contextIdentifier'] | undefined) => (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
12
13
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-base",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Base plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,19 +33,19 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^35.3.0",
36
- "@atlaskit/editor-common": "^77.0.0",
36
+ "@atlaskit/editor-common": "^77.1.0",
37
+ "@atlaskit/editor-plugin-context-identifier": "^0.1.0",
37
38
  "@atlaskit/editor-plugin-feature-flags": "^1.0.1",
38
39
  "@atlaskit/editor-prosemirror": "1.1.0",
39
- "@atlaskit/platform-feature-flags": "^0.2.0",
40
40
  "@babel/runtime": "^7.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
44
44
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
45
- "@atlaskit/editor-plugin-emoji": "^1.0.0",
45
+ "@atlaskit/editor-plugin-emoji": "^1.1.0",
46
46
  "@atlaskit/editor-plugin-guideline": "^0.5.0",
47
47
  "@atlaskit/editor-plugin-selection": "^0.2.0",
48
- "@atlaskit/editor-plugin-table": "^6.1.0",
48
+ "@atlaskit/editor-plugin-table": "^7.1.0",
49
49
  "@atlaskit/editor-plugin-type-ahead": "^0.9.0",
50
50
  "@atlaskit/editor-plugin-width": "^0.2.0",
51
51
  "@atlaskit/util-data-test": "^17.8.0",
@@ -86,11 +86,6 @@
86
86
  }
87
87
  },
88
88
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
89
- "platform-feature-flags": {
90
- "platform.editor.scroll-gutter.reflow-optimisation": {
91
- "type": "boolean"
92
- }
93
- },
94
89
  "stricter": {
95
90
  "no-unused-dependencies": {
96
91
  "checkDevDependencies": true