@atlassian/atlassian-connect-js 5.3.190
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/.depcheckrc.json +16 -0
- package/.editorconfig +9 -0
- package/.envrc +5 -0
- package/.eslintignore +12 -0
- package/.eslintrc +31 -0
- package/.husky/pre-commit +11 -0
- package/.lintstagedrc.js +6 -0
- package/.netrc +1 -0
- package/.npmrc-public +4 -0
- package/.nvmrc +1 -0
- package/LICENSE +3 -0
- package/README.md +281 -0
- package/bitbucket-pipelines.yml +33 -0
- package/build/bin/bin-helper.js +29 -0
- package/build/bin/npm-postinstall.js +9 -0
- package/build/configs/append-sourcemapping.js +13 -0
- package/build/configs/availabletasks.js +15 -0
- package/build/configs/clean.js +12 -0
- package/build/configs/concat.js +44 -0
- package/build/configs/copy.js +32 -0
- package/build/configs/index.js +19 -0
- package/build/configs/jshint.js +9 -0
- package/build/configs/karma.js +11 -0
- package/build/configs/replace.js +10 -0
- package/build/configs/requirejs.js +187 -0
- package/build/configs/saucelabs-launchers.js +30 -0
- package/build/configs/shell.js +24 -0
- package/build/configs/uglify.js +15 -0
- package/build/configs/watch.js +45 -0
- package/build/end.frag +13 -0
- package/build/start.frag +18 -0
- package/bundlesize.config.json +14 -0
- package/dist/connect-host.css +225 -0
- package/dist/connect-host.js +13908 -0
- package/dist/connect-host.min.css +1 -0
- package/dist/iframe-fedramp.js +13663 -0
- package/dist/iframe.js +13663 -0
- package/dist/legacy-text-colors.css +245 -0
- package/dist/surfaces.css +11 -0
- package/dist/themes/atlaskit-tokens_dark-future.css +6 -0
- package/dist/themes/atlaskit-tokens_dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-light.css +394 -0
- package/dist/themes/atlaskit-tokens_light-future.css +6 -0
- package/dist/themes/atlaskit-tokens_light.css +394 -0
- package/dist/themes/atlaskit-tokens_shape.css +14 -0
- package/dist/themes/atlaskit-tokens_spacing.css +26 -0
- package/dist/themes/atlaskit-tokens_typography-adg3.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-modernized.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-refreshed.css +25 -0
- package/gulpfile.js +204 -0
- package/memleak-check/app.html +10 -0
- package/memleak-check/index.html +31 -0
- package/memleak-check/index.js +33 -0
- package/package.json +102 -0
- package/renovate.json +11 -0
- package/security-assistant.yml +2 -0
- package/spec/.eslintrc +10 -0
- package/spec/config/karma.base.conf.js +200 -0
- package/spec/config/karma.conf.js +20 -0
- package/spec/fixtures/base_dialog_component_tests.js +180 -0
- package/spec/mocks/mock_feature_flag.js +23 -0
- package/spec/tests/amd_spec.js +122 -0
- package/spec/tests/analytics_dispatcher_spec.js +429 -0
- package/spec/tests/analytics_performance_spec.js +41 -0
- package/spec/tests/button_spec.js +143 -0
- package/spec/tests/dialog_extension_spec.js +59 -0
- package/spec/tests/dialog_module_provider_spec.js +499 -0
- package/spec/tests/dialog_module_spec.js +395 -0
- package/spec/tests/dialog_spec.js +296 -0
- package/spec/tests/dialog_webitem_spec.js +183 -0
- package/spec/tests/dropdown_module_spec.js +77 -0
- package/spec/tests/env_module_spec.js +153 -0
- package/spec/tests/events_spec.js +77 -0
- package/spec/tests/extension_configuration_options_store_spec.js +25 -0
- package/spec/tests/flag_module_provider_spec.js +79 -0
- package/spec/tests/flag_module_spec.js +118 -0
- package/spec/tests/flag_spec.js +243 -0
- package/spec/tests/host-api_spec.js +220 -0
- package/spec/tests/iframe-create_spec.js +43 -0
- package/spec/tests/iframe_container_spec.js +19 -0
- package/spec/tests/iframe_spec.js +265 -0
- package/spec/tests/inline_dialog_spec.js +41 -0
- package/spec/tests/inline_dialog_webitem_spec.js +331 -0
- package/spec/tests/loading_indicator_spec.js +48 -0
- package/spec/tests/messages_module_spec.js +108 -0
- package/spec/tests/meta_spec.js +71 -0
- package/spec/tests/module_args_spec.js +52 -0
- package/spec/tests/observe_spec.js +73 -0
- package/spec/tests/public_events.spec.js +102 -0
- package/spec/tests/scroll_position_spec.js +109 -0
- package/spec/tests/theming_spec.js +594 -0
- package/spec/tests/util_spec.js +55 -0
- package/spec/tests/utils/base64_spec.js +20 -0
- package/spec/tests/utils/button_spec.js +11 -0
- package/spec/tests/utils/cookie_spec.js +19 -0
- package/spec/tests/utils/deprecate_spec.js +22 -0
- package/spec/tests/utils/dialog_spec.js +297 -0
- package/spec/tests/utils/host_util_spec.js +45 -0
- package/spec/tests/utils/iframe_spec.js +41 -0
- package/spec/tests/utils/jwt_spec.js +135 -0
- package/spec/tests/utils/url_spec.js +37 -0
- package/spec/tests/utils/waitUntilReadyNextTick.js +5 -0
- package/spec/tests/utils/webitem.js +219 -0
- package/spec/tests/webitem_spec.js +131 -0
- package/src/css/host/dialog.css +144 -0
- package/src/css/host/flags.css +5 -0
- package/src/css/host/host.css +64 -0
- package/src/css/host/messages.css +12 -0
- package/src/css/plugin/legacy-text-colors.less +55 -0
- package/src/css/plugin/surfaces.css +11 -0
- package/src/host/ACJSFrameworkAdaptor.js +44 -0
- package/src/host/actions/analytics_action.js +35 -0
- package/src/host/actions/button_actions.js +21 -0
- package/src/host/actions/dialog_actions.js +27 -0
- package/src/host/actions/dialog_extension_actions.js +25 -0
- package/src/host/actions/dom_event_actions.js +32 -0
- package/src/host/actions/dropdown_actions.js +12 -0
- package/src/host/actions/env_actions.js +57 -0
- package/src/host/actions/event_actions.js +33 -0
- package/src/host/actions/flag_actions.js +22 -0
- package/src/host/actions/iframe_actions.js +27 -0
- package/src/host/actions/inline_dialog_actions.js +26 -0
- package/src/host/actions/inline_dialog_webitem_actions.js +10 -0
- package/src/host/actions/jwt_actions.js +51 -0
- package/src/host/actions/loading_indicator_actions.js +10 -0
- package/src/host/actions/module_actions.js +14 -0
- package/src/host/actions/webitem_actions.js +29 -0
- package/src/host/components/button.js +112 -0
- package/src/host/components/dialog.js +447 -0
- package/src/host/components/dialog_extension.js +106 -0
- package/src/host/components/dialog_webitem.js +69 -0
- package/src/host/components/flag.js +102 -0
- package/src/host/components/iframe.js +130 -0
- package/src/host/components/iframe_container.js +38 -0
- package/src/host/components/inline_dialog.js +108 -0
- package/src/host/components/inline_dialog_webitem.js +157 -0
- package/src/host/components/loading_indicator.js +110 -0
- package/src/host/components/webitem.js +227 -0
- package/src/host/deprecate.js +20 -0
- package/src/host/dispatchers/analytics_dispatcher.js +512 -0
- package/src/host/dispatchers/event_dispatcher.js +46 -0
- package/src/host/dollar.js +8 -0
- package/src/host/host-api.js +325 -0
- package/src/host/iframe-create.js +7 -0
- package/src/host/index.js +108 -0
- package/src/host/module-providers.js +13 -0
- package/src/host/modules/_featureFlag.js +42 -0
- package/src/host/modules/_performance.js +54 -0
- package/src/host/modules/analytics.js +17 -0
- package/src/host/modules/dialog.js +496 -0
- package/src/host/modules/dropdown.js +255 -0
- package/src/host/modules/env.js +156 -0
- package/src/host/modules/events.js +28 -0
- package/src/host/modules/flag.js +170 -0
- package/src/host/modules/host.js +19 -0
- package/src/host/modules/inline-dialog.js +33 -0
- package/src/host/modules/messages.js +309 -0
- package/src/host/modules/page.js +29 -0
- package/src/host/modules/scroll-position.js +102 -0
- package/src/host/modules/theming.js +114 -0
- package/src/host/stores/extension_configuration_options_store.js +24 -0
- package/src/host/util.js +98 -0
- package/src/host/utils/access-narrowing-context.js +18 -0
- package/src/host/utils/base64.js +22 -0
- package/src/host/utils/button.js +10 -0
- package/src/host/utils/cookie.js +14 -0
- package/src/host/utils/dialog.js +239 -0
- package/src/host/utils/feature-flag.js +27 -0
- package/src/host/utils/iframe.js +23 -0
- package/src/host/utils/jwt.js +60 -0
- package/src/host/utils/observe.js +34 -0
- package/src/host/utils/removal-observer.js +30 -0
- package/src/host/utils/simplexdm.js +58 -0
- package/src/host/utils/url.js +23 -0
- package/src/host/utils/webitem.js +214 -0
- package/src/plugin/amd.js +115 -0
- package/src/plugin/analytics.js +84 -0
- package/src/plugin/deprecate.js +16 -0
- package/src/plugin/dialog.js +197 -0
- package/src/plugin/dollar.js +77 -0
- package/src/plugin/events-instance.js +2 -0
- package/src/plugin/events.js +246 -0
- package/src/plugin/extension_configuration_options_store.js +27 -0
- package/src/plugin/featureFlag.js +8 -0
- package/src/plugin/index.js +118 -0
- package/src/plugin/meta.js +14 -0
- package/src/plugin/public-events.js +73 -0
- package/src/plugin/theming.js +211 -0
- package/src/plugin/util.js +104 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import util from './util';
|
|
2
|
+
import EventDispatcher from './dispatchers/event_dispatcher';
|
|
3
|
+
import DialogExtensionActions from './actions/dialog_extension_actions';
|
|
4
|
+
import DomEventActions from './actions/dom_event_actions';
|
|
5
|
+
import IframeCreate from './iframe-create';
|
|
6
|
+
import jwtActions from './actions/jwt_actions';
|
|
7
|
+
import ModuleActions from './actions/module_actions';
|
|
8
|
+
import EventActions from './actions/event_actions';
|
|
9
|
+
import simpleXDM from 'simple-xdm/host';
|
|
10
|
+
import IframeActions from './actions/iframe_actions';
|
|
11
|
+
import AnalyticsAction from './actions/analytics_action';
|
|
12
|
+
import WebItemUtils from './utils/webitem';
|
|
13
|
+
import getBooleanFeatureFlag from './utils/feature-flag';
|
|
14
|
+
import ModuleProviders from './module-providers';
|
|
15
|
+
import { acjsFrameworkAdaptor } from './ACJSFrameworkAdaptor';
|
|
16
|
+
import Util from './util';
|
|
17
|
+
import simpleXdmUtils from './utils/simplexdm';
|
|
18
|
+
import UrlUtils from './utils/url';
|
|
19
|
+
import ExtensionConfigurationOptionsStore from './stores/extension_configuration_options_store';
|
|
20
|
+
import jwtUtil from './utils/jwt';
|
|
21
|
+
import dialogUtils from './utils/dialog';
|
|
22
|
+
import {isDialogWebItem, triggerWebItem} from './components/webitem';
|
|
23
|
+
|
|
24
|
+
class HostApi {
|
|
25
|
+
targetSpecNoDialogs = EventActions.targetSpecNoDialogs;
|
|
26
|
+
triggerWebItem = triggerWebItem;
|
|
27
|
+
isDialogWebItem = isDialogWebItem
|
|
28
|
+
|
|
29
|
+
constructor(){
|
|
30
|
+
this.create = (extension) => {
|
|
31
|
+
return IframeCreate(simpleXdmUtils.extensionConfigSanitizer(extension));
|
|
32
|
+
}
|
|
33
|
+
this.dialog = {
|
|
34
|
+
create: (extension, dialogOptions) => {
|
|
35
|
+
var dialogBeanOptions = WebItemUtils.getModuleOptionsByAddonAndModuleKey('dialog', extension.addon_key, extension.key);
|
|
36
|
+
var completeOptions = Util.extend({}, dialogBeanOptions || {}, dialogOptions);
|
|
37
|
+
DialogExtensionActions.open(extension, completeOptions);
|
|
38
|
+
},
|
|
39
|
+
close: (addon_key, closeData) => {
|
|
40
|
+
const frameworkAdaptor = this.getFrameworkAdaptor();
|
|
41
|
+
const dialogProvider = frameworkAdaptor.getProviderByModuleName('dialog');
|
|
42
|
+
if (dialogProvider) {
|
|
43
|
+
dialogUtils.assertActiveDialogOrThrow(dialogProvider, addon_key);
|
|
44
|
+
EventActions.broadcast('dialog.close', {
|
|
45
|
+
addon_key: addon_key
|
|
46
|
+
}, closeData);
|
|
47
|
+
dialogProvider.close();
|
|
48
|
+
} else {
|
|
49
|
+
DialogExtensionActions.close();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.registerContentResolver = {
|
|
54
|
+
// This function is not called when a product calls resolveByExtension
|
|
55
|
+
// This is just a wrapper for ACJS to be able to call the product implementation
|
|
56
|
+
// Calls from the product will bypass this method and call the product implementation directly
|
|
57
|
+
resolveByExtension: (callback) => {
|
|
58
|
+
this._contentResolver = callback;
|
|
59
|
+
jwtActions.registerContentResolver({callback: callback});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
this.getContentResolver = () => {
|
|
63
|
+
return this._contentResolver;
|
|
64
|
+
};
|
|
65
|
+
this.registerProvider = (componentName, component) => {
|
|
66
|
+
ModuleProviders.registerProvider(componentName, component);
|
|
67
|
+
};
|
|
68
|
+
this.getProvider = (componentName) => {
|
|
69
|
+
return ModuleProviders.getProvider(componentName);
|
|
70
|
+
};
|
|
71
|
+
// We are attaching an instance of ACJSAdaptor to the host so that products are able
|
|
72
|
+
// to retrieve the identical instance of ACJSAdaptor that ACJS is using.
|
|
73
|
+
// The product can override the framework adaptor by calling setFrameworkAdaptor().
|
|
74
|
+
this.frameworkAdaptor = acjsFrameworkAdaptor;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* creates an extension
|
|
78
|
+
* returns an object with extension and iframe attributes
|
|
79
|
+
* designed for use with non DOM implementations such as react.
|
|
80
|
+
*/
|
|
81
|
+
createExtension(extension) {
|
|
82
|
+
extension.options = extension.options || {};
|
|
83
|
+
extension.options.noDom = true;
|
|
84
|
+
let createdExtension = simpleXdmUtils.createSimpleXdmExtension(extension);
|
|
85
|
+
AnalyticsAction.trackIframeBridgeStart(createdExtension.extension);
|
|
86
|
+
return createdExtension;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* registers an existing extension with this host
|
|
91
|
+
* Used when the extension has been created by a sub host
|
|
92
|
+
*/
|
|
93
|
+
registerExistingExtension(extension_id, data){
|
|
94
|
+
return simpleXDM.registerExistingExtension(extension_id, data);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The product is responsible for setting the framework adaptor.
|
|
99
|
+
* @param frameworkAdaptor the framework adaptor to use.
|
|
100
|
+
*/
|
|
101
|
+
setFrameworkAdaptor(frameworkAdaptor) {
|
|
102
|
+
this.frameworkAdaptor = frameworkAdaptor;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getFrameworkAdaptor() {
|
|
106
|
+
return this.frameworkAdaptor;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_cleanExtension(extension){
|
|
110
|
+
return util.pick(extension, ['id', 'addon_key', 'key', 'options', 'url']);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onIframeEstablished (callback) {
|
|
114
|
+
var wrapper = function(data){
|
|
115
|
+
callback.call({}, {
|
|
116
|
+
$el: data.$el,
|
|
117
|
+
extension: this._cleanExtension(data.extension)
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
callback._wrapper = wrapper.bind(this);
|
|
121
|
+
EventDispatcher.register('after:iframe-bridge-established', callback._wrapper);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
offIframeEstablished (callback) {
|
|
125
|
+
if(callback._wrapper){
|
|
126
|
+
EventDispatcher.unregister('after:iframe-bridge-established', callback._wrapper);
|
|
127
|
+
} else {
|
|
128
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
onIframeUnload(callback){
|
|
133
|
+
EventDispatcher.register('after:iframe-unload', (data) => {
|
|
134
|
+
callback.call({}, {
|
|
135
|
+
$el: data.$el,
|
|
136
|
+
extension: this._cleanExtension(data.extension)
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onPublicEventDispatched(callback) {
|
|
142
|
+
var wrapper = function(data){
|
|
143
|
+
callback.call({}, {
|
|
144
|
+
type: data.type,
|
|
145
|
+
event: data.event,
|
|
146
|
+
extension: this._cleanExtension(data.sender)
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
callback._wrapper = wrapper.bind(this);
|
|
150
|
+
EventDispatcher.register('after:event-public-dispatch', callback._wrapper);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
offPublicEventDispatched(callback) {
|
|
154
|
+
if(callback._wrapper){
|
|
155
|
+
EventDispatcher.unregister('after:event-public-dispatch', callback._wrapper);
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
onKeyEvent (extension_id, key, modifiers, callback) {
|
|
162
|
+
DomEventActions.registerKeyEvent({extension_id, key, modifiers, callback});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
offKeyEvent (extension_id, key, modifiers, callback) {
|
|
166
|
+
DomEventActions.unregisterKeyEvent({extension_id, key, modifiers, callback});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
onFrameClick (handleIframeClick) {
|
|
170
|
+
if (typeof handleIframeClick !== 'function') {
|
|
171
|
+
throw new Error('handleIframeClick must be a function');
|
|
172
|
+
}
|
|
173
|
+
DomEventActions.registerClickHandler(handleIframeClick);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
offFrameClick () {
|
|
177
|
+
DomEventActions.unregisterClickHandler();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
destroy (extension_id){
|
|
181
|
+
IframeActions.notifyIframeDestroyed({id: extension_id});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
defineModule (name, methods) {
|
|
185
|
+
ModuleActions.defineCustomModule(name, methods);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
isModuleDefined (moduleName) {
|
|
189
|
+
return simpleXDM.isModuleDefined(moduleName);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
broadcastEvent (type, targetSpec, event) {
|
|
193
|
+
EventActions.broadcast(type, targetSpec, event);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
getExtensions (filter) {
|
|
197
|
+
return simpleXDM.getExtensions(filter);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
trackDeprecatedMethodUsed(methodUsed, extension) {
|
|
201
|
+
AnalyticsAction.trackDeprecatedMethodUsed(methodUsed, extension);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
trackAnalyticsEvent(name, values) {
|
|
205
|
+
AnalyticsAction.trackExternalEvent(name, values);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
trackContentResolverEvent(success, extra) {
|
|
209
|
+
AnalyticsAction.trackContentResolverEvent(success, extra);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
notifyContentResolverFailed(extension) {
|
|
213
|
+
EventDispatcher.dispatch('notify-content-resolver-failed', extension);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setJwtClockSkew(skew) {
|
|
217
|
+
jwtActions.setClockSkew(skew);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
isJwtExpired(jwtString, tokenOnly) {
|
|
221
|
+
if(tokenOnly) {
|
|
222
|
+
return jwtUtil.isJwtExpired(jwtString);
|
|
223
|
+
}
|
|
224
|
+
return UrlUtils.isJwtExpired(jwtString);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
hasJwt(url) {
|
|
228
|
+
return UrlUtils.hasJwt(url);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
getBooleanFeatureFlag(flagName) {
|
|
232
|
+
return getBooleanFeatureFlag(flagName);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// set configuration option system wide for all extensions
|
|
236
|
+
// can be either key,value or an object
|
|
237
|
+
setExtensionConfigurationOptions(obj, value) {
|
|
238
|
+
ExtensionConfigurationOptionsStore.set(obj, value);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
getExtensionConfigurationOption(val) {
|
|
242
|
+
return ExtensionConfigurationOptionsStore.get(val);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
onIframeTimeout (callback) {
|
|
246
|
+
var wrapper = function(data){
|
|
247
|
+
callback.call({}, {
|
|
248
|
+
extension: this._cleanExtension(data.extension)
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
callback._wrapper = wrapper.bind(this);
|
|
252
|
+
EventDispatcher.register('after:iframe-bridge-timeout', callback._wrapper);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
offIframeTimeout (callback) {
|
|
256
|
+
if(callback._wrapper){
|
|
257
|
+
EventDispatcher.unregister('after:iframe-bridge-timeout', callback._wrapper);
|
|
258
|
+
} else {
|
|
259
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
onIframePerformanceTelemetry (callback) {
|
|
264
|
+
var wrapper = function(data){
|
|
265
|
+
callback.call({}, {
|
|
266
|
+
metrics: data.metrics,
|
|
267
|
+
extension: this._cleanExtension(data.extension)
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
callback._wrapper = wrapper.bind(this);
|
|
271
|
+
EventDispatcher.register('after:analytics-iframe-performance', callback._wrapper);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
offIframePerformanceTelemetry (callback) {
|
|
275
|
+
if(callback._wrapper){
|
|
276
|
+
EventDispatcher.unregister('after:analytics-iframe-performance', callback._wrapper);
|
|
277
|
+
} else {
|
|
278
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
onIframeVisible (callback) {
|
|
283
|
+
var wrapper = function(extension){
|
|
284
|
+
callback.call({}, {
|
|
285
|
+
extension: this._cleanExtension(extension)
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
callback._wrapper = wrapper.bind(this);
|
|
289
|
+
EventDispatcher.register('after:iframe-visible', callback._wrapper);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
offIframeVisible (callback) {
|
|
293
|
+
if(callback._wrapper){
|
|
294
|
+
EventDispatcher.unregister('after:iframe-visible', callback._wrapper);
|
|
295
|
+
} else {
|
|
296
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
onContentResolverEvent (callback) {
|
|
301
|
+
var wrapper = function(data) {
|
|
302
|
+
callback.call({}, data);
|
|
303
|
+
};
|
|
304
|
+
callback._wrapper = wrapper.bind(this);
|
|
305
|
+
EventDispatcher.register('after:analytics-content-resolver-track', callback._wrapper);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
offContentResolverEvent (callback) {
|
|
309
|
+
if(callback._wrapper){
|
|
310
|
+
EventDispatcher.unregister('after:analytics-content-resolver-track', callback._wrapper);
|
|
311
|
+
} else {
|
|
312
|
+
throw new Error('cannot unregister event dispatch listener without _wrapper reference');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
onForwardAnalyticsEvent(callback) {
|
|
317
|
+
var wrapper = function(eventType, eventData) {
|
|
318
|
+
callback.call({}, eventType, eventData);
|
|
319
|
+
};
|
|
320
|
+
callback._wrapper = wrapper.bind(this);
|
|
321
|
+
EventDispatcher.register('after:analytics-forward-event', callback._wrapper);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export default new HostApi();
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import EventDispatcher from './dispatchers/event_dispatcher';
|
|
2
|
+
import './components/loading_indicator';
|
|
3
|
+
import events from './modules/events';
|
|
4
|
+
import dialog from './modules/dialog';
|
|
5
|
+
import env from './modules/env';
|
|
6
|
+
import inlineDialog from './modules/inline-dialog';
|
|
7
|
+
import messages from './modules/messages';
|
|
8
|
+
import flag from './modules/flag';
|
|
9
|
+
import analytics from './modules/analytics';
|
|
10
|
+
import scrollPosition from './modules/scroll-position';
|
|
11
|
+
import dropdown from './modules/dropdown';
|
|
12
|
+
import host from './modules/host';
|
|
13
|
+
import theming from './modules/theming';
|
|
14
|
+
import page from './modules/page';
|
|
15
|
+
import HostApi from './host-api';
|
|
16
|
+
import './components/inline_dialog_webitem';
|
|
17
|
+
import './components/dialog_webitem';
|
|
18
|
+
import './components/dialog_extension';
|
|
19
|
+
import simpleXDM from 'simple-xdm/host';
|
|
20
|
+
import getBooleanFeatureFlag from './utils/feature-flag';
|
|
21
|
+
import { observeIframeRemoval } from './utils/removal-observer';
|
|
22
|
+
import DomEventActions from './actions/dom_event_actions';
|
|
23
|
+
import AnalyticsAction from './actions/analytics_action';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Private namespace for host-side code.
|
|
27
|
+
* @type {*|{}}
|
|
28
|
+
* @private
|
|
29
|
+
* @deprecated use AMD instead of global namespaces. The only thing that should be on _AP is _AP.define and _AP.require.
|
|
30
|
+
*/
|
|
31
|
+
if (!window._AP) {
|
|
32
|
+
window._AP = {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* Add version
|
|
37
|
+
*/
|
|
38
|
+
if (!window._AP.version) {
|
|
39
|
+
window._AP.version = '%%GULP_INJECT_VERSION%%';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
simpleXDM.defineModule('messages', messages);
|
|
43
|
+
simpleXDM.defineModule('flag', flag);
|
|
44
|
+
simpleXDM.defineModule('dialog', dialog);
|
|
45
|
+
simpleXDM.defineModule('inlineDialog', inlineDialog);
|
|
46
|
+
simpleXDM.defineModule('env', env);
|
|
47
|
+
simpleXDM.defineModule('events', events);
|
|
48
|
+
simpleXDM.defineModule('_analytics', analytics);
|
|
49
|
+
simpleXDM.defineModule('scrollPosition', scrollPosition);
|
|
50
|
+
simpleXDM.defineModule('dropdown', dropdown);
|
|
51
|
+
simpleXDM.defineModule('host', host);
|
|
52
|
+
simpleXDM.defineModule('theming', theming);
|
|
53
|
+
simpleXDM.defineModule('page', page);
|
|
54
|
+
|
|
55
|
+
EventDispatcher.register('module-define-custom', function (data) {
|
|
56
|
+
simpleXDM.defineModule(data.name, data.methods);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
simpleXDM.registerRequestNotifier(function (data) {
|
|
60
|
+
var dispatchEvent = () => {
|
|
61
|
+
if (data.type === 'req') {
|
|
62
|
+
const registeredExtension = simpleXDM.getExtensions(
|
|
63
|
+
(ext) => ext.extension_id === data.extension_id
|
|
64
|
+
)[0];
|
|
65
|
+
if (registeredExtension) {
|
|
66
|
+
const extension = registeredExtension.extension;
|
|
67
|
+
EventDispatcher.dispatch('method-invoked', {
|
|
68
|
+
...data,
|
|
69
|
+
extension,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
if (typeof window.requestIdleCallback === 'function') {
|
|
76
|
+
window.requestIdleCallback(dispatchEvent, { timeout: 1000 });
|
|
77
|
+
} else {
|
|
78
|
+
dispatchEvent();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
function onDocumentReady() {
|
|
83
|
+
observeIframeRemoval();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (document.readyState === 'loading') {
|
|
87
|
+
document.addEventListener('DOMContentLoaded', onDocumentReady)
|
|
88
|
+
} else {
|
|
89
|
+
onDocumentReady();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (getBooleanFeatureFlag('acjs_iframe_click_analytics')) {
|
|
93
|
+
DomEventActions.registerClickHandler(function (iframe, data) {
|
|
94
|
+
var iframeInfo = JSON.parse(iframe.name || '{}')
|
|
95
|
+
var iframeInfoOptions = iframeInfo.options || {}
|
|
96
|
+
var analyticsData = {
|
|
97
|
+
moduleLocation: iframeInfoOptions.moduleLocation,
|
|
98
|
+
moduleType: iframeInfoOptions.moduleType,
|
|
99
|
+
addonKey: data.addon_key,
|
|
100
|
+
baseUrl: iframeInfoOptions.origin,
|
|
101
|
+
};
|
|
102
|
+
AnalyticsAction.trackIframeClick(analyticsData);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
simpleXDM.setFeatureFlagGetter(getBooleanFeatureFlag);
|
|
107
|
+
|
|
108
|
+
export default HostApi;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class ModuleProviders {
|
|
2
|
+
constructor(){
|
|
3
|
+
this._providers = {};
|
|
4
|
+
this.registerProvider = (name, provider) => {
|
|
5
|
+
this._providers[name] = provider;
|
|
6
|
+
};
|
|
7
|
+
this.getProvider = (name) => {
|
|
8
|
+
return this._providers[name];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default new ModuleProviders();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import simpleXDM from 'simple-xdm/host';
|
|
2
|
+
import getBooleanFeatureFlag from '../utils/feature-flag';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
|
|
5
|
+
const allowedPlatformFeatureFlags = [
|
|
6
|
+
'platform-visual-refresh-icons',
|
|
7
|
+
'acjs_new_font'
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
function isPlatformAllowedFeatureFlag(flagName) {
|
|
11
|
+
return allowedPlatformFeatureFlags.includes(flagName);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isAllowListedFeatureFlag(flagName) {
|
|
15
|
+
return flagName.indexOf('acjs-iframe-allowlist') === 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let defined = false;
|
|
19
|
+
export default function defineFeatureFlagModule() {
|
|
20
|
+
if (defined) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
defined = true;
|
|
24
|
+
|
|
25
|
+
const featureFlagModule = {
|
|
26
|
+
getBooleanFeatureFlag(flagName) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
if(isPlatformAllowedFeatureFlag(flagName)) {
|
|
29
|
+
resolve(fg(flagName))
|
|
30
|
+
} else {
|
|
31
|
+
if (!isAllowListedFeatureFlag(flagName)) {
|
|
32
|
+
reject(new Error('Only allowlisted flags can be accessed from the iframe.'))
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
resolve(getBooleanFeatureFlag(flagName))
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
simpleXDM.returnsPromise(featureFlagModule.getBooleanFeatureFlag);
|
|
41
|
+
simpleXDM.defineModule('_featureFlag', featureFlagModule)
|
|
42
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import simpleXDM from 'simple-xdm/host';
|
|
2
|
+
|
|
3
|
+
let performanceModuleDefined = false;
|
|
4
|
+
export const ADDON_KEY_CODEBARREL = 'com.codebarrel.addons.automation';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is a temporary module for Code Barrel that will be removed when no longer needed.
|
|
8
|
+
*/
|
|
9
|
+
export default function definePerformanceModule() {
|
|
10
|
+
if (performanceModuleDefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
performanceModuleDefined = true;
|
|
14
|
+
|
|
15
|
+
function isPerformanceModuleAllowed(cb) {
|
|
16
|
+
return cb._context.extension.addon_key === ADDON_KEY_CODEBARREL
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const performanceModule = {
|
|
20
|
+
/**
|
|
21
|
+
* @see https://developer.mozilla.org/en-US/docs/web/api/performance/timing
|
|
22
|
+
* @returns {Promise<PerformanceTiming>}
|
|
23
|
+
*/
|
|
24
|
+
getPerformanceTiming(cb) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
if (!isPerformanceModuleAllowed(cb)) {
|
|
27
|
+
reject(new Error('This is a restricted API'));
|
|
28
|
+
}
|
|
29
|
+
// We need to parse + stringify otherwise we get an empty object
|
|
30
|
+
resolve(JSON.parse(JSON.stringify(window.performance.timing)));
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming
|
|
35
|
+
* @returns {Promise<PerformanceNavigationTiming[] | void>}
|
|
36
|
+
*/
|
|
37
|
+
getPerformanceNavigationTiming(cb) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
if (!isPerformanceModuleAllowed(cb)) {
|
|
40
|
+
reject(new Error('This is a restricted API'));
|
|
41
|
+
}
|
|
42
|
+
if (!window.PerformanceNavigationTiming) {
|
|
43
|
+
resolve(undefined);
|
|
44
|
+
}
|
|
45
|
+
const timing = window.performance.getEntriesByType('navigation');
|
|
46
|
+
resolve(JSON.parse(JSON.stringify(timing)));
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
simpleXDM.returnsPromise(performanceModule.getPerformanceTiming);
|
|
52
|
+
simpleXDM.returnsPromise(performanceModule.getPerformanceNavigationTiming)
|
|
53
|
+
simpleXDM.defineModule('_performance', performanceModule)
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import AnalyticsAction from '../actions/analytics_action';
|
|
2
|
+
import util from '../util';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
trackDeprecatedMethodUsed: function (methodUsed, callback) {
|
|
6
|
+
callback = util.last(arguments);
|
|
7
|
+
AnalyticsAction.trackDeprecatedMethodUsed(methodUsed, callback._context.extension);
|
|
8
|
+
},
|
|
9
|
+
trackIframePerformanceMetrics: function trackIframePerformanceMetrics(metrics, callback) {
|
|
10
|
+
callback = util.last(arguments);
|
|
11
|
+
AnalyticsAction.trackIframePerformanceMetrics(metrics, callback._context.extension);
|
|
12
|
+
},
|
|
13
|
+
trackWebVitals(metrics, callback) {
|
|
14
|
+
callback = util.last(arguments);
|
|
15
|
+
AnalyticsAction.trackWebVitals(metrics, callback._context.extension);
|
|
16
|
+
}
|
|
17
|
+
}
|