@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.
Files changed (190) hide show
  1. package/.depcheckrc.json +16 -0
  2. package/.editorconfig +9 -0
  3. package/.envrc +5 -0
  4. package/.eslintignore +12 -0
  5. package/.eslintrc +31 -0
  6. package/.husky/pre-commit +11 -0
  7. package/.lintstagedrc.js +6 -0
  8. package/.netrc +1 -0
  9. package/.npmrc-public +4 -0
  10. package/.nvmrc +1 -0
  11. package/LICENSE +3 -0
  12. package/README.md +281 -0
  13. package/bitbucket-pipelines.yml +33 -0
  14. package/build/bin/bin-helper.js +29 -0
  15. package/build/bin/npm-postinstall.js +9 -0
  16. package/build/configs/append-sourcemapping.js +13 -0
  17. package/build/configs/availabletasks.js +15 -0
  18. package/build/configs/clean.js +12 -0
  19. package/build/configs/concat.js +44 -0
  20. package/build/configs/copy.js +32 -0
  21. package/build/configs/index.js +19 -0
  22. package/build/configs/jshint.js +9 -0
  23. package/build/configs/karma.js +11 -0
  24. package/build/configs/replace.js +10 -0
  25. package/build/configs/requirejs.js +187 -0
  26. package/build/configs/saucelabs-launchers.js +30 -0
  27. package/build/configs/shell.js +24 -0
  28. package/build/configs/uglify.js +15 -0
  29. package/build/configs/watch.js +45 -0
  30. package/build/end.frag +13 -0
  31. package/build/start.frag +18 -0
  32. package/bundlesize.config.json +14 -0
  33. package/dist/connect-host.css +225 -0
  34. package/dist/connect-host.js +13908 -0
  35. package/dist/connect-host.min.css +1 -0
  36. package/dist/iframe-fedramp.js +13663 -0
  37. package/dist/iframe.js +13663 -0
  38. package/dist/legacy-text-colors.css +245 -0
  39. package/dist/surfaces.css +11 -0
  40. package/dist/themes/atlaskit-tokens_dark-future.css +6 -0
  41. package/dist/themes/atlaskit-tokens_dark.css +394 -0
  42. package/dist/themes/atlaskit-tokens_legacy-dark.css +394 -0
  43. package/dist/themes/atlaskit-tokens_legacy-light.css +394 -0
  44. package/dist/themes/atlaskit-tokens_light-future.css +6 -0
  45. package/dist/themes/atlaskit-tokens_light.css +394 -0
  46. package/dist/themes/atlaskit-tokens_shape.css +14 -0
  47. package/dist/themes/atlaskit-tokens_spacing.css +26 -0
  48. package/dist/themes/atlaskit-tokens_typography-adg3.css +25 -0
  49. package/dist/themes/atlaskit-tokens_typography-modernized.css +25 -0
  50. package/dist/themes/atlaskit-tokens_typography-refreshed.css +25 -0
  51. package/gulpfile.js +204 -0
  52. package/memleak-check/app.html +10 -0
  53. package/memleak-check/index.html +31 -0
  54. package/memleak-check/index.js +33 -0
  55. package/package.json +102 -0
  56. package/renovate.json +11 -0
  57. package/security-assistant.yml +2 -0
  58. package/spec/.eslintrc +10 -0
  59. package/spec/config/karma.base.conf.js +200 -0
  60. package/spec/config/karma.conf.js +20 -0
  61. package/spec/fixtures/base_dialog_component_tests.js +180 -0
  62. package/spec/mocks/mock_feature_flag.js +23 -0
  63. package/spec/tests/amd_spec.js +122 -0
  64. package/spec/tests/analytics_dispatcher_spec.js +429 -0
  65. package/spec/tests/analytics_performance_spec.js +41 -0
  66. package/spec/tests/button_spec.js +143 -0
  67. package/spec/tests/dialog_extension_spec.js +59 -0
  68. package/spec/tests/dialog_module_provider_spec.js +499 -0
  69. package/spec/tests/dialog_module_spec.js +395 -0
  70. package/spec/tests/dialog_spec.js +296 -0
  71. package/spec/tests/dialog_webitem_spec.js +183 -0
  72. package/spec/tests/dropdown_module_spec.js +77 -0
  73. package/spec/tests/env_module_spec.js +153 -0
  74. package/spec/tests/events_spec.js +77 -0
  75. package/spec/tests/extension_configuration_options_store_spec.js +25 -0
  76. package/spec/tests/flag_module_provider_spec.js +79 -0
  77. package/spec/tests/flag_module_spec.js +118 -0
  78. package/spec/tests/flag_spec.js +243 -0
  79. package/spec/tests/host-api_spec.js +220 -0
  80. package/spec/tests/iframe-create_spec.js +43 -0
  81. package/spec/tests/iframe_container_spec.js +19 -0
  82. package/spec/tests/iframe_spec.js +265 -0
  83. package/spec/tests/inline_dialog_spec.js +41 -0
  84. package/spec/tests/inline_dialog_webitem_spec.js +331 -0
  85. package/spec/tests/loading_indicator_spec.js +48 -0
  86. package/spec/tests/messages_module_spec.js +108 -0
  87. package/spec/tests/meta_spec.js +71 -0
  88. package/spec/tests/module_args_spec.js +52 -0
  89. package/spec/tests/observe_spec.js +73 -0
  90. package/spec/tests/public_events.spec.js +102 -0
  91. package/spec/tests/scroll_position_spec.js +109 -0
  92. package/spec/tests/theming_spec.js +594 -0
  93. package/spec/tests/util_spec.js +55 -0
  94. package/spec/tests/utils/base64_spec.js +20 -0
  95. package/spec/tests/utils/button_spec.js +11 -0
  96. package/spec/tests/utils/cookie_spec.js +19 -0
  97. package/spec/tests/utils/deprecate_spec.js +22 -0
  98. package/spec/tests/utils/dialog_spec.js +297 -0
  99. package/spec/tests/utils/host_util_spec.js +45 -0
  100. package/spec/tests/utils/iframe_spec.js +41 -0
  101. package/spec/tests/utils/jwt_spec.js +135 -0
  102. package/spec/tests/utils/url_spec.js +37 -0
  103. package/spec/tests/utils/waitUntilReadyNextTick.js +5 -0
  104. package/spec/tests/utils/webitem.js +219 -0
  105. package/spec/tests/webitem_spec.js +131 -0
  106. package/src/css/host/dialog.css +144 -0
  107. package/src/css/host/flags.css +5 -0
  108. package/src/css/host/host.css +64 -0
  109. package/src/css/host/messages.css +12 -0
  110. package/src/css/plugin/legacy-text-colors.less +55 -0
  111. package/src/css/plugin/surfaces.css +11 -0
  112. package/src/host/ACJSFrameworkAdaptor.js +44 -0
  113. package/src/host/actions/analytics_action.js +35 -0
  114. package/src/host/actions/button_actions.js +21 -0
  115. package/src/host/actions/dialog_actions.js +27 -0
  116. package/src/host/actions/dialog_extension_actions.js +25 -0
  117. package/src/host/actions/dom_event_actions.js +32 -0
  118. package/src/host/actions/dropdown_actions.js +12 -0
  119. package/src/host/actions/env_actions.js +57 -0
  120. package/src/host/actions/event_actions.js +33 -0
  121. package/src/host/actions/flag_actions.js +22 -0
  122. package/src/host/actions/iframe_actions.js +27 -0
  123. package/src/host/actions/inline_dialog_actions.js +26 -0
  124. package/src/host/actions/inline_dialog_webitem_actions.js +10 -0
  125. package/src/host/actions/jwt_actions.js +51 -0
  126. package/src/host/actions/loading_indicator_actions.js +10 -0
  127. package/src/host/actions/module_actions.js +14 -0
  128. package/src/host/actions/webitem_actions.js +29 -0
  129. package/src/host/components/button.js +112 -0
  130. package/src/host/components/dialog.js +447 -0
  131. package/src/host/components/dialog_extension.js +106 -0
  132. package/src/host/components/dialog_webitem.js +69 -0
  133. package/src/host/components/flag.js +102 -0
  134. package/src/host/components/iframe.js +130 -0
  135. package/src/host/components/iframe_container.js +38 -0
  136. package/src/host/components/inline_dialog.js +108 -0
  137. package/src/host/components/inline_dialog_webitem.js +157 -0
  138. package/src/host/components/loading_indicator.js +110 -0
  139. package/src/host/components/webitem.js +227 -0
  140. package/src/host/deprecate.js +20 -0
  141. package/src/host/dispatchers/analytics_dispatcher.js +512 -0
  142. package/src/host/dispatchers/event_dispatcher.js +46 -0
  143. package/src/host/dollar.js +8 -0
  144. package/src/host/host-api.js +325 -0
  145. package/src/host/iframe-create.js +7 -0
  146. package/src/host/index.js +108 -0
  147. package/src/host/module-providers.js +13 -0
  148. package/src/host/modules/_featureFlag.js +42 -0
  149. package/src/host/modules/_performance.js +54 -0
  150. package/src/host/modules/analytics.js +17 -0
  151. package/src/host/modules/dialog.js +496 -0
  152. package/src/host/modules/dropdown.js +255 -0
  153. package/src/host/modules/env.js +156 -0
  154. package/src/host/modules/events.js +28 -0
  155. package/src/host/modules/flag.js +170 -0
  156. package/src/host/modules/host.js +19 -0
  157. package/src/host/modules/inline-dialog.js +33 -0
  158. package/src/host/modules/messages.js +309 -0
  159. package/src/host/modules/page.js +29 -0
  160. package/src/host/modules/scroll-position.js +102 -0
  161. package/src/host/modules/theming.js +114 -0
  162. package/src/host/stores/extension_configuration_options_store.js +24 -0
  163. package/src/host/util.js +98 -0
  164. package/src/host/utils/access-narrowing-context.js +18 -0
  165. package/src/host/utils/base64.js +22 -0
  166. package/src/host/utils/button.js +10 -0
  167. package/src/host/utils/cookie.js +14 -0
  168. package/src/host/utils/dialog.js +239 -0
  169. package/src/host/utils/feature-flag.js +27 -0
  170. package/src/host/utils/iframe.js +23 -0
  171. package/src/host/utils/jwt.js +60 -0
  172. package/src/host/utils/observe.js +34 -0
  173. package/src/host/utils/removal-observer.js +30 -0
  174. package/src/host/utils/simplexdm.js +58 -0
  175. package/src/host/utils/url.js +23 -0
  176. package/src/host/utils/webitem.js +214 -0
  177. package/src/plugin/amd.js +115 -0
  178. package/src/plugin/analytics.js +84 -0
  179. package/src/plugin/deprecate.js +16 -0
  180. package/src/plugin/dialog.js +197 -0
  181. package/src/plugin/dollar.js +77 -0
  182. package/src/plugin/events-instance.js +2 -0
  183. package/src/plugin/events.js +246 -0
  184. package/src/plugin/extension_configuration_options_store.js +27 -0
  185. package/src/plugin/featureFlag.js +8 -0
  186. package/src/plugin/index.js +118 -0
  187. package/src/plugin/meta.js +14 -0
  188. package/src/plugin/public-events.js +73 -0
  189. package/src/plugin/theming.js +211 -0
  190. package/src/plugin/util.js +104 -0
@@ -0,0 +1,180 @@
1
+ function unit(str){
2
+ return (str.search(/px/) > 0) ? 'px' : '%';
3
+ }
4
+
5
+ function size($el, options){
6
+ if(options.size){
7
+ expect($el.hasClass('aui-dialog2-' + options.size), 'size is set').toEqual(true);
8
+ } else if(options.width){
9
+ expect($el.width() + unit(options.width)).toEqual(options.width);
10
+ expect($el.height() + unit(options.height)).toEqual(options.height);
11
+ }
12
+ }
13
+
14
+ function chrome($el, options){
15
+ expect($el.hasClass('aui-dialog2')).toEqual(true);
16
+ expect($el.hasClass('ap-aui-dialog2')).toEqual(true);
17
+ expect($el.hasClass('aui-layer')).toEqual(true);
18
+ header($el, options);
19
+ hint($el, options);
20
+ footer($el, options);
21
+ buttons($el, options);
22
+ customButtons($el, options);
23
+ size($el, options);
24
+ }
25
+
26
+ function chromeless($el, options){
27
+ expect($el.hasClass('aui-dialog2')).toEqual(true);
28
+ expect($el.hasClass('ap-aui-dialog2')).toEqual(true);
29
+ expect($el.hasClass('aui-layer')).toEqual(true);
30
+ expect($el.hasClass('aui-dialog2-chromeless')).toEqual(true);
31
+ size($el, options);
32
+ }
33
+
34
+ function fullscreen($el, options){
35
+ expect($el.hasClass('aui-dialog2')).toEqual(true);
36
+ expect($el.hasClass('ap-aui-dialog2')).toEqual(true);
37
+ expect($el.hasClass('aui-layer')).toEqual(true);
38
+ expect($el.hasClass('aui-dialog2-chromeless')).toEqual(false);
39
+ expect($el.hasClass('aui-dialog2-fullscreen')).toEqual(true);
40
+ expect($el.hasClass('ap-header-controls')).toEqual(true);
41
+ expect($el.hasClass('aui-dialog2-maximum')).toEqual(true);
42
+ expect($el.height()).toEqual($(window).height());
43
+ expect($el.width()).toEqual($(window).width());
44
+ fullscreenHeader($el, options);
45
+ hint($el, options);
46
+ footer($el, options);
47
+ fullscreenButtons($el, options);
48
+ customButtons($el, options);
49
+ }
50
+
51
+ function fullscreenHeader($el, options){
52
+ expect($el.find('.header-title').text()).toEqual(options.header.value);
53
+ }
54
+
55
+ function fullscreenButtons($el, options){
56
+ var $controlPanel = $el.find('.header-control-panel');
57
+ expect($controlPanel.length).toEqual(1);
58
+ // 4 buttons, 2 default + 2 user custom buttons
59
+ expect($controlPanel.find('button').length).toEqual(4);
60
+ var $primary = $controlPanel.find('.aui-button-primary');
61
+ var $cancel = $controlPanel.find('.aui-button-link');
62
+ expect($primary.length).toEqual(1);
63
+ expect($primary.text()).toEqual(options.submitText);
64
+ expect($cancel.length).toEqual(1);
65
+ expect($cancel.text()).toEqual(options.cancelText);
66
+ }
67
+
68
+ function customButtons($el, options) {
69
+ function buttonByIdentifier($dialog, identifier) {
70
+ return $el.find('.aui-button-secondary').filter(function(index, button){
71
+ return $(button).data('identifier') === identifier;
72
+ });
73
+ }
74
+ if(options.buttons) {
75
+ options.buttons.forEach(function(button) {
76
+ var $btn = buttonByIdentifier($el, button.identifier);
77
+ expect($btn.length).toEqual(1);
78
+ expect($btn.hasClass('ap-dialog-custom-button')).toEqual(true);
79
+ expect($btn.hasClass('aui-button-secondary')).toEqual(true);
80
+ expect($btn.text()).toEqual(button.text);
81
+ });
82
+ }
83
+ }
84
+
85
+
86
+ function header($el, options){
87
+ expect($el.find('.aui-dialog2-header-main').text()).toEqual(options.header.value);
88
+ }
89
+
90
+ function hint($el, options){
91
+ expect($el.find('.aui-dialog2-footer-hint').text()).toEqual(options.hint);
92
+ }
93
+
94
+ function footer($el, options){
95
+ expect($el.find('.aui-dialog2-footer').length).toEqual(1);
96
+ }
97
+
98
+ function buttons($el, options){
99
+ // 2 default + 2 custom buttons specified in the options
100
+ expect($el.find('button').length).toEqual(4);
101
+ var $primary = $el.find('.aui-dialog2-footer .aui-button-primary');
102
+ var $cancel = $el.find('.aui-dialog2-footer .aui-button-link');
103
+ expect($primary.length).toEqual(1);
104
+ expect($primary.text()).toEqual(options.submitText);
105
+ expect($cancel.length).toEqual(1);
106
+ expect($cancel.text()).toEqual(options.cancelText);
107
+ }
108
+
109
+ module.exports = {
110
+ getChromeOptions: function(){
111
+ return {
112
+ chrome: true,
113
+ header: {
114
+ value: 'a header'
115
+ },
116
+ hint: 'a hint',
117
+ size: 'large',
118
+ submitText: 'my submit text',
119
+ cancelText: 'some cancel text',
120
+ buttons: [
121
+ {
122
+ text: 'some button text',
123
+ identifier: 'abc123'
124
+ },
125
+ {
126
+ text: 'second button text',
127
+ identifier: 'zxy321'
128
+ }
129
+ ]
130
+ };
131
+ },
132
+ getChromelessOptions: function(){
133
+ return {
134
+ chrome: false,
135
+ size: 'small'
136
+ };
137
+ },
138
+ getFullscreenOptions: function(){
139
+ return {
140
+ size: 'fullscreen',
141
+ header: {
142
+ value: 'a fullscreen header'
143
+ },
144
+ width: 1000,
145
+ height: 321,
146
+ submitText: 'a submit text',
147
+ cancelText: 'a cancel text',
148
+ hint: 'fullscreen hint',
149
+ buttons: [
150
+ {
151
+ text: 'first btn text',
152
+ identifier: 'ab12'
153
+ },
154
+ {
155
+ text: 'second btn text',
156
+ identifier: 'zx32'
157
+ }
158
+ ]
159
+
160
+ };
161
+ },
162
+ testFullScreen: function(options, $el){
163
+ if(!$el){
164
+ $el = $('.aui-dialog2');
165
+ }
166
+ return fullscreen($el, options);
167
+ },
168
+ testChrome: function(options, $el){
169
+ if(!$el){
170
+ $el = $('.aui-dialog2');
171
+ }
172
+ return chrome($el, options);
173
+ },
174
+ testChromeless: function(options, $el){
175
+ if(!$el){
176
+ $el = $('.aui-dialog2');
177
+ }
178
+ return chromeless($el, options);
179
+ },
180
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @param name {string}
3
+ * @param value {boolean}
4
+ */
5
+ export function mockFeatureFlag(name, value) {
6
+ window.featureFlags = window.featureFlags || {}
7
+ window.featureFlags[name] = { value }
8
+ }
9
+ export function resetFeatureFlags() {
10
+ window.featureFlags = {}
11
+ }
12
+
13
+ let mockIframeFlags = {}
14
+ export function mockIframeFeatureFlag(name, value) {
15
+ mockIframeFlags[name] = value
16
+ window.AP = window.AP || {}
17
+ window.AP._featureFlag = window.AP._featureFlag || {}
18
+ window.AP._featureFlag.getBooleanFeatureFlag = window.AP._featureFlag.getBooleanFeatureFlag || function() {}
19
+ window.AP._featureFlag.getBooleanFeatureFlag = async (flagName) => mockIframeFlags[flagName]
20
+ }
21
+ export function resetIframeFeatureFlags() {
22
+ mockIframeFlags = {}
23
+ }
@@ -0,0 +1,122 @@
1
+ import AP from 'simple-xdm/combined';
2
+ import AMD from 'src/plugin/amd';
3
+
4
+ var testFunctionSpy = jasmine.createSpy('testFunction').and.callFake(() => 1337);
5
+ var otherThingSpy = jasmine.createSpy('otherThing').and.callFake((thing) => thing);
6
+ var newThingSpy = jasmine.createSpy('newThing').and.callFake((thing) => thing);
7
+
8
+ describe('AMD', () => {
9
+ beforeEach(() => {
10
+ AP._hostModules = {
11
+ existingModule: {
12
+ testFunction: testFunctionSpy
13
+ },
14
+ otherThing: otherThingSpy
15
+ };
16
+
17
+ AP.define = AMD.define;
18
+ AP.require = AMD.require;
19
+
20
+ AP._hostModules.newThing = {
21
+ newHostFunction: newThingSpy
22
+ };
23
+ });
24
+
25
+ afterEach(() => {
26
+ window.AP = null;
27
+ });
28
+
29
+ describe('define', () => {
30
+ it('creates a module', () => {
31
+ var bonusFunctionSpy = jasmine.createSpy('bonusFunction').and.callFake(() => '+1');
32
+ AP.define('myObject', () => {
33
+ return {
34
+ bonusFunction: bonusFunctionSpy
35
+ }
36
+ });
37
+ AP.require('myObject', function(myObject) {
38
+ expect(myObject).not.toBeUndefined();
39
+ expect(myObject.hasOwnProperty('bonusFunction')).toBe(true);
40
+ expect(myObject.bonusFunction()).toEqual('+1');
41
+ expect(bonusFunctionSpy).toHaveBeenCalled();
42
+ });
43
+ });
44
+
45
+ it('create module with a dependency', () => {
46
+ AP.define('newThing', ['existingModule'], (existingModule) => {
47
+ expect(existingModule).not.toBeUndefined();
48
+ expect(existingModule.hasOwnProperty('testFunction')).toBe(true);
49
+ existingModule.testFunction();
50
+ expect(testFunctionSpy).toHaveBeenCalled();
51
+ });
52
+ });
53
+
54
+ it('create module with multiple dependencies', () => {
55
+ AP.define('newThing', ['existingModule', 'otherThing'], (existingModule, otherThing) => {
56
+ var testVal = Date.now();
57
+ expect(existingModule).not.toBeUndefined();
58
+ expect(existingModule.hasOwnProperty('testFunction')).toBe(true);
59
+ expect(otherThing).not.toBeUndefined();
60
+ expect(existingModule.testFunction()).toEqual(1337);
61
+ expect(otherThing(testVal)).toEqual(testVal);
62
+ expect(testFunctionSpy).toHaveBeenCalled();
63
+ expect(otherThingSpy).toHaveBeenCalledWith(testVal);
64
+ });
65
+ });
66
+
67
+ it('overwrite an existing module', () => {
68
+ var bonusFunctionSpy = jasmine.createSpy('bonusFunction').and.callFake(() => '+1');
69
+ AP.define('existingModule', () => {
70
+ return {
71
+ bonusFunction: bonusFunctionSpy
72
+ }
73
+ });
74
+
75
+ AP.require('existingModule', (existingModule) => {
76
+ expect(existingModule.hasOwnProperty('bonusFunction')).toBe(true);
77
+ expect(existingModule.bonusFunction()).toEqual('+1');
78
+ expect(bonusFunctionSpy).toHaveBeenCalled();
79
+ });
80
+ });
81
+ });
82
+
83
+ describe('require', () => {
84
+ it('existing host modules', () => {
85
+ AP.require('existingModule', (existingModule) => {
86
+ expect(existingModule).not.toBeUndefined();
87
+ expect(existingModule.hasOwnProperty('testFunction')).toBe(true);
88
+ expect(existingModule.testFunction()).toEqual(1337);
89
+ expect(testFunctionSpy).toHaveBeenCalled();
90
+ });
91
+ });
92
+
93
+ it('multiple modules', () => {
94
+ AP.require(['existingModule', 'otherThing'], (existingModule, otherThing) => {
95
+ var testVal = Date.now();
96
+ expect(existingModule).not.toBeUndefined();
97
+ expect(existingModule.hasOwnProperty('testFunction')).toBe(true);
98
+ expect(existingModule.testFunction()).toEqual(1337);
99
+ expect(otherThing).not.toBeUndefined();
100
+ expect(otherThing(testVal)).toEqual(testVal);
101
+ expect(testFunctionSpy).toHaveBeenCalled();
102
+ expect(otherThingSpy).toHaveBeenCalledWith(testVal);
103
+ });
104
+ });
105
+
106
+ it('undefined module', () => {
107
+ AP.require('nonExistentModule', (notAThing) => {
108
+ expect(notAThing()).toBeUndefined();
109
+ });
110
+ });
111
+
112
+ it('new host module after initialisation', () => {
113
+ AP.require('newThing', (newThing) => {
114
+ var testVal = Date.now();
115
+ expect(newThing).not.toBeUndefined();
116
+ expect(newThing.hasOwnProperty('newHostFunction')).toBe(true);
117
+ expect(newThing.newHostFunction(testVal)).toEqual(testVal);
118
+ expect(newThingSpy).toHaveBeenCalledWith(testVal);
119
+ });
120
+ })
121
+ });
122
+ });