@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,227 @@
|
|
|
1
|
+
import $ from '../dollar';
|
|
2
|
+
import EventDispatcher from '../dispatchers/event_dispatcher';
|
|
3
|
+
import WebItemActions from '../actions/webitem_actions';
|
|
4
|
+
import WebItemUtils, {collectParentElementAttributes, isDialogTrigger, isInlineDialogTrigger} from '../utils/webitem';
|
|
5
|
+
import Util from '../util';
|
|
6
|
+
import HostApi from '../host-api';
|
|
7
|
+
|
|
8
|
+
const addedTriggersSet = new WeakSet();
|
|
9
|
+
class WebItem {
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this._webitems = {};
|
|
13
|
+
this._contentResolver = function noop(){};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setContentResolver(resolver) {
|
|
17
|
+
this._contentResolver = resolver;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
requestContent(extension) {
|
|
21
|
+
if(extension.addon_key && extension.key) {
|
|
22
|
+
return this._contentResolver.call(null, Util.extend({classifier: 'json'}, extension));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// originally i had this written nicely with Object.values but
|
|
26
|
+
// ie11 didn't like it and i couldn't find a nice pollyfill
|
|
27
|
+
getWebItemsBySelector(selector) {
|
|
28
|
+
let returnVal;
|
|
29
|
+
const keys = Object.getOwnPropertyNames(this._webitems).some((key) => {
|
|
30
|
+
let obj = this._webitems[key];
|
|
31
|
+
if(obj.selector) {
|
|
32
|
+
if(obj.selector.trim() === selector.trim()) {
|
|
33
|
+
returnVal = obj;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
return returnVal;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setWebItem(potentialWebItem) {
|
|
43
|
+
return this._webitems[potentialWebItem.name] = {
|
|
44
|
+
name: potentialWebItem.name,
|
|
45
|
+
selector: potentialWebItem.selector,
|
|
46
|
+
triggers: potentialWebItem.triggers
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_removeTriggers(webitem) {
|
|
52
|
+
var onTriggers = WebItemUtils.sanitizeTriggers(webitem.triggers);
|
|
53
|
+
$(() => {
|
|
54
|
+
$('body').off(onTriggers, webitem.selector, this._webitems[webitem.name]._on);
|
|
55
|
+
});
|
|
56
|
+
delete this._webitems[webitem.name]._on;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_addTriggers (webitem) {
|
|
60
|
+
var onTriggers = WebItemUtils.sanitizeTriggers(webitem.triggers);
|
|
61
|
+
/**
|
|
62
|
+
* @param event {Event}
|
|
63
|
+
*/
|
|
64
|
+
webitem._on = (event) => {
|
|
65
|
+
if (event.defaultPrevented) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
/** @type {JQuery} */
|
|
69
|
+
const $target = $(event.target).closest(webitem.selector);
|
|
70
|
+
if ($target.hasClass('ap-dialog-ignore')) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
_triggerWebItem($target, event.type);
|
|
75
|
+
};
|
|
76
|
+
$(() => {
|
|
77
|
+
const attachHandlers = (node) => {
|
|
78
|
+
if (addedTriggersSet.has(node)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
addedTriggersSet.add(node);
|
|
82
|
+
$(node).on(onTriggers, webitem._on);
|
|
83
|
+
}
|
|
84
|
+
// First, add handlers for any nodes already in the document
|
|
85
|
+
document.querySelectorAll(webitem.selector).forEach((node) => {
|
|
86
|
+
attachHandlers(node)
|
|
87
|
+
})
|
|
88
|
+
// Next, set up a MutationObserver to add handlers for any nodes added to the document later
|
|
89
|
+
const observer = new MutationObserver(function(mutationsList, observer) {
|
|
90
|
+
mutationsList.forEach(function(mutation) {
|
|
91
|
+
if (mutation.type !== 'childList') {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
mutation.addedNodes.forEach(function (node) {
|
|
95
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (node.matches(webitem.selector)) {
|
|
99
|
+
// The element is being added directly
|
|
100
|
+
attachHandlers(node);
|
|
101
|
+
} else {
|
|
102
|
+
// We need to check children of the added node as well, because a whole subtree can be added at once
|
|
103
|
+
node.querySelectorAll(webitem.selector).forEach((childNode) => {
|
|
104
|
+
attachHandlers(childNode);
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
// Start observing the target node for configured mutations
|
|
111
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
112
|
+
|
|
113
|
+
// Append styles to make the webitem clickable
|
|
114
|
+
$('head').append(`<style type="text/css">${webitem.selector}.ap-link-webitem {pointer-events: auto;cursor: pointer;}</style>`);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @param {Element} target The webItem trigger element, used for relatively positioning the inline dialog popup.
|
|
122
|
+
* @param {string|undefined} [cssClass] The webItem's class name as returned by the Connect plugin. Will be taken from the target if not provided.
|
|
123
|
+
* @param {string|undefined} [href] The webItem's href as returned by the Connect plugin. Will be taken from the target if not provided.
|
|
124
|
+
* @param {'click' | 'mouseenter'} [eventType] The trigger type that we want to invoke.
|
|
125
|
+
*/
|
|
126
|
+
export function triggerWebItem(
|
|
127
|
+
target,
|
|
128
|
+
cssClass,
|
|
129
|
+
href,
|
|
130
|
+
eventType,
|
|
131
|
+
) {
|
|
132
|
+
eventType = eventType || 'click';
|
|
133
|
+
const $target = $(target);
|
|
134
|
+
cssClass = cssClass || $target.attr('class');
|
|
135
|
+
|
|
136
|
+
// ACJS would only listen for events on these specific classes.
|
|
137
|
+
// However, this function could be called for any webItem, even if it is not a dialog.
|
|
138
|
+
// In that case, we should just do nothing and let the default link behaviour occur.
|
|
139
|
+
if (!isDialogWebItem(cssClass) || (eventType === 'mouseenter' && !isInlineDialogTrigger(cssClass))) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
_triggerWebItem($target, eventType, cssClass, href, true);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* We export this function so that consumers can check if Connect will handle the event.
|
|
147
|
+
* If so, they can prevent the default behaviour.
|
|
148
|
+
* @param {string|string[]|null} classes
|
|
149
|
+
* @returns {boolean}
|
|
150
|
+
*/
|
|
151
|
+
export function isDialogWebItem(classes) {
|
|
152
|
+
return isDialogTrigger(classes) || isInlineDialogTrigger(classes);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @private
|
|
157
|
+
* @param {JQuery} $target The webItem trigger element. It is expected to have an href or data-href property, and class names representing the trigger type (ap-dialog, ap-inline-dialog, etc).
|
|
158
|
+
* @param {'click' | 'mouseenter'} eventType The trigger type that we want to invoke.
|
|
159
|
+
* @param {string|undefined} [cssClass] The webItem's class name as returned by the Connect plugin.
|
|
160
|
+
* @param {string|undefined} [href] The webItem's href as returned by the Connect plugin.
|
|
161
|
+
* @param {boolean} isModernApi Whether this was triggered via the modern imperative API, used for analytics.
|
|
162
|
+
*/
|
|
163
|
+
function _triggerWebItem(
|
|
164
|
+
$target,
|
|
165
|
+
eventType,
|
|
166
|
+
cssClass,
|
|
167
|
+
href,
|
|
168
|
+
isModernApi
|
|
169
|
+
) {
|
|
170
|
+
cssClass = cssClass || $target.attr('class');
|
|
171
|
+
isModernApi = isModernApi || false;
|
|
172
|
+
const convertedOptions = WebItemUtils.getConfigFromTarget($target, cssClass, href);
|
|
173
|
+
const extensionUrl = convertedOptions && convertedOptions.url ? convertedOptions.url : undefined;
|
|
174
|
+
const extension = {
|
|
175
|
+
addon_key: WebItemUtils.getExtensionKey(cssClass),
|
|
176
|
+
key: WebItemUtils.getKey(cssClass),
|
|
177
|
+
options: WebItemUtils.getOptionsForWebItem($target, cssClass, href),
|
|
178
|
+
url: extensionUrl
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
if (extension.addon_key === 'com.addonengine.analytics' && !HostApi.isModuleDefined('analytics')) {
|
|
182
|
+
console.log(`ACJS-1164 Dropping event ${eventType} for plugin ${extension.addon_key} until AP.analytics loads...`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const isInlineDialog = isInlineDialogTrigger(cssClass);
|
|
186
|
+
if (!isModernApi) {
|
|
187
|
+
EventDispatcher.dispatch('analytics-legacy-dialog-opened', {
|
|
188
|
+
extension,
|
|
189
|
+
eventType,
|
|
190
|
+
parentIds: collectParentElementAttributes($target.get(0), [
|
|
191
|
+
'data-testid',
|
|
192
|
+
'data-component-selector',
|
|
193
|
+
'data-fullscreen-id'
|
|
194
|
+
]),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
WebItemActions.webitemInvoked(isInlineDialog, {
|
|
198
|
+
$target,
|
|
199
|
+
eventType,
|
|
200
|
+
extension,
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
var webItemInstance = new WebItem();
|
|
205
|
+
|
|
206
|
+
EventDispatcher.register('webitem-added', (data) => {
|
|
207
|
+
webItemInstance._addTriggers(data.webitem);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
EventDispatcher.register('content-resolver-register-by-extension', function(data){
|
|
211
|
+
webItemInstance.setContentResolver(data.callback);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
document.addEventListener('aui-responsive-menu-item-created', (e) => {
|
|
215
|
+
var oldWebItem = e.detail.originalItem.querySelector('a[class*="ap-"]');
|
|
216
|
+
if (oldWebItem) {
|
|
217
|
+
var newWebItem = e.detail.newItem.querySelector('a');
|
|
218
|
+
let classList = [].slice.call(oldWebItem.classList);
|
|
219
|
+
classList.forEach(cls => {
|
|
220
|
+
if (/^ap-/.test(cls)) {
|
|
221
|
+
newWebItem.classList.add(cls);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
export default webItemInstance;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Analytics from './modules/analytics';
|
|
2
|
+
import util from './util';
|
|
3
|
+
|
|
4
|
+
function deprecateHost (fn, name, alternate, sinceVersion) {
|
|
5
|
+
let called = false;
|
|
6
|
+
return (...args) => {
|
|
7
|
+
if (!called && typeof console !== 'undefined' && console.warn) {
|
|
8
|
+
called = true;
|
|
9
|
+
console.warn(`DEPRECATED API - ${name} has been deprecated ${sinceVersion ? `since ACJS ${sinceVersion}` : 'in ACJS'}` +
|
|
10
|
+
` and will be removed in a future release. ${ alternate ? `Use ${alternate} instead.` : 'No alternative will be provided.' }`);
|
|
11
|
+
|
|
12
|
+
const callback = util.last(args);
|
|
13
|
+
if (callback && callback._context && callback._context.extension) {
|
|
14
|
+
Analytics.trackDeprecatedMethodUsed(name, callback);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return fn(...args);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default deprecateHost;
|