@edx/frontend-platform 4.6.0 → 4.6.2

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 (229) hide show
  1. package/.env.development +30 -0
  2. package/.env.test +30 -0
  3. package/.eslintignore +6 -0
  4. package/.eslintrc.js +28 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  6. package/.github/workflows/add-depr-ticket-to-depr-board.yml +19 -0
  7. package/.github/workflows/add-remove-label-on-comment.yml +20 -0
  8. package/.github/workflows/ci.yml +42 -0
  9. package/.github/workflows/commitlint.yml +10 -0
  10. package/.github/workflows/lockfileversion-check.yml +13 -0
  11. package/.github/workflows/manual-publish.yml +43 -0
  12. package/.github/workflows/npm-deprecate.yml +22 -0
  13. package/.github/workflows/release.yml +45 -0
  14. package/.github/workflows/self-assign-issue.yml +12 -0
  15. package/.github/workflows/update-browserslist-db.yml +12 -0
  16. package/.nvmrc +1 -0
  17. package/.releaserc +32 -0
  18. package/catalog-info.yaml +21 -0
  19. package/dist/LICENSE +661 -0
  20. package/dist/README.md +155 -0
  21. package/dist/package.json +86 -0
  22. package/docs/addTagsPlugin.js +10 -0
  23. package/docs/auth-API.md +114 -0
  24. package/docs/decisions/0001-record-architecture-decisions.rst +32 -0
  25. package/docs/decisions/0002-frontend-base-design-goals.rst +222 -0
  26. package/docs/decisions/0003-consolidation-into-frontend-platform.rst +71 -0
  27. package/docs/decisions/0004-axios-caching-implementation.rst +88 -0
  28. package/docs/decisions/0005-token-null-after-successful-refresh.rst +69 -0
  29. package/docs/decisions/0006-middleware-support-for-http-clients.rst +44 -0
  30. package/docs/decisions/0007-javascript-file-configuration.rst +143 -0
  31. package/docs/how_tos/automatic-case-conversion.rst +58 -0
  32. package/docs/how_tos/caching.rst +93 -0
  33. package/docs/how_tos/i18n.rst +305 -0
  34. package/docs/removeExport.js +24 -0
  35. package/docs/template/edx/README.md +12 -0
  36. package/docs/template/edx/publish.js +713 -0
  37. package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  38. package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.svg +1830 -0
  39. package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  40. package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  41. package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  42. package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  43. package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  44. package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.svg +1830 -0
  45. package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  46. package/docs/template/edx/static/fonts/OpenSans-Light-webfont.eot +0 -0
  47. package/docs/template/edx/static/fonts/OpenSans-Light-webfont.svg +1831 -0
  48. package/docs/template/edx/static/fonts/OpenSans-Light-webfont.woff +0 -0
  49. package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  50. package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  51. package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  52. package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  53. package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.svg +1831 -0
  54. package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  55. package/docs/template/edx/static/scripts/linenumber.js +25 -0
  56. package/docs/template/edx/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  57. package/docs/template/edx/static/scripts/prettify/lang-css.js +2 -0
  58. package/docs/template/edx/static/scripts/prettify/prettify.js +28 -0
  59. package/docs/template/edx/static/styles/jsdoc-default.css +356 -0
  60. package/docs/template/edx/static/styles/prettify-jsdoc.css +111 -0
  61. package/docs/template/edx/static/styles/prettify-tomorrow.css +132 -0
  62. package/docs/template/edx/tmpl/augments.tmpl +10 -0
  63. package/docs/template/edx/tmpl/container.tmpl +196 -0
  64. package/docs/template/edx/tmpl/details.tmpl +143 -0
  65. package/docs/template/edx/tmpl/example.tmpl +2 -0
  66. package/docs/template/edx/tmpl/examples.tmpl +13 -0
  67. package/docs/template/edx/tmpl/exceptions.tmpl +32 -0
  68. package/docs/template/edx/tmpl/layout.tmpl +39 -0
  69. package/docs/template/edx/tmpl/mainpage.tmpl +10 -0
  70. package/docs/template/edx/tmpl/members.tmpl +38 -0
  71. package/docs/template/edx/tmpl/method.tmpl +131 -0
  72. package/docs/template/edx/tmpl/modifies.tmpl +14 -0
  73. package/docs/template/edx/tmpl/params.tmpl +131 -0
  74. package/docs/template/edx/tmpl/properties.tmpl +108 -0
  75. package/docs/template/edx/tmpl/returns.tmpl +19 -0
  76. package/docs/template/edx/tmpl/source.tmpl +8 -0
  77. package/docs/template/edx/tmpl/tutorial.tmpl +19 -0
  78. package/docs/template/edx/tmpl/type.tmpl +7 -0
  79. package/env.config.js +8 -0
  80. package/jsdoc.json +36 -0
  81. package/openedx.yaml +12 -0
  82. package/package.json +6 -6
  83. package/service-interface.png +0 -0
  84. package/src/analytics/MockAnalyticsService.js +71 -0
  85. package/src/analytics/SegmentAnalyticsService.js +243 -0
  86. package/src/analytics/index.js +12 -0
  87. package/src/analytics/interface.js +142 -0
  88. package/src/auth/AxiosCsrfTokenService.js +60 -0
  89. package/src/auth/AxiosJwtAuthService.js +364 -0
  90. package/src/auth/AxiosJwtTokenService.js +134 -0
  91. package/src/auth/LocalForageCache.js +78 -0
  92. package/src/auth/MockAuthService.js +285 -0
  93. package/src/auth/index.js +19 -0
  94. package/src/auth/interceptors/createCsrfTokenProviderInterceptor.js +37 -0
  95. package/src/auth/interceptors/createJwtTokenProviderInterceptor.js +38 -0
  96. package/src/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +20 -0
  97. package/src/auth/interceptors/createRetryInterceptor.js +72 -0
  98. package/src/auth/interface.js +309 -0
  99. package/src/auth/utils.js +105 -0
  100. package/src/config.js +327 -0
  101. package/src/constants.js +66 -0
  102. package/src/i18n/countries.js +57 -0
  103. package/src/i18n/index.js +123 -0
  104. package/src/i18n/injectIntlWithShim.jsx +45 -0
  105. package/src/i18n/languages.js +60 -0
  106. package/src/i18n/lib.js +282 -0
  107. package/src/i18n/scripts/README.md +29 -0
  108. package/src/i18n/scripts/intl-imports.js +259 -0
  109. package/src/i18n/scripts/transifex-utils.js +75 -0
  110. package/src/index.js +42 -0
  111. package/src/initialize.js +357 -0
  112. package/src/logging/MockLoggingService.js +31 -0
  113. package/src/logging/NewRelicLoggingService.js +181 -0
  114. package/src/logging/index.js +9 -0
  115. package/src/logging/interface.js +110 -0
  116. package/src/pubSub.js +47 -0
  117. package/src/react/AppContext.jsx +24 -0
  118. package/src/react/AppProvider.jsx +93 -0
  119. package/src/react/AuthenticatedPageRoute.jsx +60 -0
  120. package/src/react/ErrorBoundary.jsx +44 -0
  121. package/src/react/ErrorPage.jsx +76 -0
  122. package/src/react/LoginRedirect.jsx +16 -0
  123. package/src/react/OptionalReduxProvider.jsx +28 -0
  124. package/src/react/PageRoute.jsx +31 -0
  125. package/src/react/hooks.js +50 -0
  126. package/src/react/index.js +16 -0
  127. package/src/scripts/GoogleAnalyticsLoader.js +53 -0
  128. package/src/scripts/index.js +2 -0
  129. package/src/testing/index.js +9 -0
  130. package/src/testing/initializeMockApp.js +77 -0
  131. package/src/testing/mockMessages.js +21 -0
  132. package/src/utils.js +167 -0
  133. /package/{analytics → dist/analytics}/MockAnalyticsService.js +0 -0
  134. /package/{analytics → dist/analytics}/MockAnalyticsService.js.map +0 -0
  135. /package/{analytics → dist/analytics}/SegmentAnalyticsService.js +0 -0
  136. /package/{analytics → dist/analytics}/SegmentAnalyticsService.js.map +0 -0
  137. /package/{analytics → dist/analytics}/index.js +0 -0
  138. /package/{analytics → dist/analytics}/index.js.map +0 -0
  139. /package/{analytics → dist/analytics}/interface.js +0 -0
  140. /package/{analytics → dist/analytics}/interface.js.map +0 -0
  141. /package/{auth → dist/auth}/AxiosCsrfTokenService.js +0 -0
  142. /package/{auth → dist/auth}/AxiosCsrfTokenService.js.map +0 -0
  143. /package/{auth → dist/auth}/AxiosJwtAuthService.js +0 -0
  144. /package/{auth → dist/auth}/AxiosJwtAuthService.js.map +0 -0
  145. /package/{auth → dist/auth}/AxiosJwtTokenService.js +0 -0
  146. /package/{auth → dist/auth}/AxiosJwtTokenService.js.map +0 -0
  147. /package/{auth → dist/auth}/LocalForageCache.js +0 -0
  148. /package/{auth → dist/auth}/LocalForageCache.js.map +0 -0
  149. /package/{auth → dist/auth}/MockAuthService.js +0 -0
  150. /package/{auth → dist/auth}/MockAuthService.js.map +0 -0
  151. /package/{auth → dist/auth}/index.js +0 -0
  152. /package/{auth → dist/auth}/index.js.map +0 -0
  153. /package/{auth → dist/auth}/interceptors/createCsrfTokenProviderInterceptor.js +0 -0
  154. /package/{auth → dist/auth}/interceptors/createCsrfTokenProviderInterceptor.js.map +0 -0
  155. /package/{auth → dist/auth}/interceptors/createJwtTokenProviderInterceptor.js +0 -0
  156. /package/{auth → dist/auth}/interceptors/createJwtTokenProviderInterceptor.js.map +0 -0
  157. /package/{auth → dist/auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -0
  158. /package/{auth → dist/auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +0 -0
  159. /package/{auth → dist/auth}/interceptors/createRetryInterceptor.js +0 -0
  160. /package/{auth → dist/auth}/interceptors/createRetryInterceptor.js.map +0 -0
  161. /package/{auth → dist/auth}/interface.js +0 -0
  162. /package/{auth → dist/auth}/interface.js.map +0 -0
  163. /package/{auth → dist/auth}/utils.js +0 -0
  164. /package/{auth → dist/auth}/utils.js.map +0 -0
  165. /package/{config.js → dist/config.js} +0 -0
  166. /package/{config.js.map → dist/config.js.map} +0 -0
  167. /package/{constants.js → dist/constants.js} +0 -0
  168. /package/{constants.js.map → dist/constants.js.map} +0 -0
  169. /package/{i18n → dist/i18n}/countries.js +0 -0
  170. /package/{i18n → dist/i18n}/countries.js.map +0 -0
  171. /package/{i18n → dist/i18n}/index.js +0 -0
  172. /package/{i18n → dist/i18n}/index.js.map +0 -0
  173. /package/{i18n → dist/i18n}/injectIntlWithShim.js +0 -0
  174. /package/{i18n → dist/i18n}/injectIntlWithShim.js.map +0 -0
  175. /package/{i18n → dist/i18n}/languages.js +0 -0
  176. /package/{i18n → dist/i18n}/languages.js.map +0 -0
  177. /package/{i18n → dist/i18n}/lib.js +0 -0
  178. /package/{i18n → dist/i18n}/lib.js.map +0 -0
  179. /package/{i18n → dist/i18n}/scripts/README.md +0 -0
  180. /package/{i18n → dist/i18n}/scripts/intl-imports.js +0 -0
  181. /package/{i18n → dist/i18n}/scripts/intl-imports.js.map +0 -0
  182. /package/{i18n → dist/i18n}/scripts/transifex-utils.js +0 -0
  183. /package/{i18n → dist/i18n}/scripts/transifex-utils.js.map +0 -0
  184. /package/{index.js → dist/index.js} +0 -0
  185. /package/{index.js.map → dist/index.js.map} +0 -0
  186. /package/{initialize.js → dist/initialize.js} +0 -0
  187. /package/{initialize.js.map → dist/initialize.js.map} +0 -0
  188. /package/{logging → dist/logging}/MockLoggingService.js +0 -0
  189. /package/{logging → dist/logging}/MockLoggingService.js.map +0 -0
  190. /package/{logging → dist/logging}/NewRelicLoggingService.js +0 -0
  191. /package/{logging → dist/logging}/NewRelicLoggingService.js.map +0 -0
  192. /package/{logging → dist/logging}/index.js +0 -0
  193. /package/{logging → dist/logging}/index.js.map +0 -0
  194. /package/{logging → dist/logging}/interface.js +0 -0
  195. /package/{logging → dist/logging}/interface.js.map +0 -0
  196. /package/{pubSub.js → dist/pubSub.js} +0 -0
  197. /package/{pubSub.js.map → dist/pubSub.js.map} +0 -0
  198. /package/{react → dist/react}/AppContext.js +0 -0
  199. /package/{react → dist/react}/AppContext.js.map +0 -0
  200. /package/{react → dist/react}/AppProvider.js +0 -0
  201. /package/{react → dist/react}/AppProvider.js.map +0 -0
  202. /package/{react → dist/react}/AuthenticatedPageRoute.js +0 -0
  203. /package/{react → dist/react}/AuthenticatedPageRoute.js.map +0 -0
  204. /package/{react → dist/react}/ErrorBoundary.js +0 -0
  205. /package/{react → dist/react}/ErrorBoundary.js.map +0 -0
  206. /package/{react → dist/react}/ErrorPage.js +0 -0
  207. /package/{react → dist/react}/ErrorPage.js.map +0 -0
  208. /package/{react → dist/react}/LoginRedirect.js +0 -0
  209. /package/{react → dist/react}/LoginRedirect.js.map +0 -0
  210. /package/{react → dist/react}/OptionalReduxProvider.js +0 -0
  211. /package/{react → dist/react}/OptionalReduxProvider.js.map +0 -0
  212. /package/{react → dist/react}/PageRoute.js +0 -0
  213. /package/{react → dist/react}/PageRoute.js.map +0 -0
  214. /package/{react → dist/react}/hooks.js +0 -0
  215. /package/{react → dist/react}/hooks.js.map +0 -0
  216. /package/{react → dist/react}/index.js +0 -0
  217. /package/{react → dist/react}/index.js.map +0 -0
  218. /package/{scripts → dist/scripts}/GoogleAnalyticsLoader.js +0 -0
  219. /package/{scripts → dist/scripts}/GoogleAnalyticsLoader.js.map +0 -0
  220. /package/{scripts → dist/scripts}/index.js +0 -0
  221. /package/{scripts → dist/scripts}/index.js.map +0 -0
  222. /package/{testing → dist/testing}/index.js +0 -0
  223. /package/{testing → dist/testing}/index.js.map +0 -0
  224. /package/{testing → dist/testing}/initializeMockApp.js +0 -0
  225. /package/{testing → dist/testing}/initializeMockApp.js.map +0 -0
  226. /package/{testing → dist/testing}/mockMessages.js +0 -0
  227. /package/{testing → dist/testing}/mockMessages.js.map +0 -0
  228. /package/{utils.js → dist/utils.js} +0 -0
  229. /package/{utils.js.map → dist/utils.js.map} +0 -0
@@ -0,0 +1,38 @@
1
+ <?js
2
+ var data = obj;
3
+ var self = this;
4
+ ?>
5
+ <h4 class="name" id="<?js= id ?>"><?js= data.attribs + name + (data.signature ? data.signature : '') ?></h4>
6
+
7
+ <?js if (data.summary) { ?>
8
+ <p class="summary"><?js= summary ?></p>
9
+ <?js } ?>
10
+
11
+ <?js if (data.description) { ?>
12
+ <div class="description">
13
+ <?js= data.description ?>
14
+ </div>
15
+ <?js } ?>
16
+
17
+ <?js if (data.type && data.type.names) {?>
18
+ <h5>Type:</h5>
19
+ <ul>
20
+ <li>
21
+ <?js= self.partial('type.tmpl', data.type.names) ?>
22
+ </li>
23
+ </ul>
24
+ <?js } ?>
25
+
26
+ <?js= this.partial('details.tmpl', data) ?>
27
+
28
+ <?js if (data.fires && fires.length) { ?>
29
+ <h5>Fires:</h5>
30
+ <ul><?js fires.forEach(function(f) { ?>
31
+ <li><?js= self.linkto(f) ?></li>
32
+ <?js }); ?></ul>
33
+ <?js } ?>
34
+
35
+ <?js if (data.examples && examples.length) { ?>
36
+ <h5>Example<?js= examples.length > 1? 's':'' ?></h5>
37
+ <?js= this.partial('examples.tmpl', examples) ?>
38
+ <?js } ?>
@@ -0,0 +1,131 @@
1
+ <?js
2
+ var data = obj;
3
+ var self = this;
4
+ ?>
5
+ <?js if (data.kind !== 'module' && !data.hideconstructor) { ?>
6
+ <?js if (data.kind === 'class' && data.classdesc) { ?>
7
+ <h2>Constructor</h2>
8
+ <?js } ?>
9
+
10
+ <?js if (data.kind !== 'namespace') { ?>
11
+ <h4 class="name" id="<?js= id ?>"><?js= data.attribs + (kind === 'class' ? 'new ' : '') +
12
+ name + (data.signature || '') ?></h4>
13
+ <?js } ?>
14
+
15
+ <?js if (data.summary) { ?>
16
+ <p class="summary"><?js= summary ?></p>
17
+ <?js } ?>
18
+ <?js } ?>
19
+
20
+ <?js if (data.kind !== 'module' && data.description && !data.hideconstructor) { ?>
21
+ <div class="description">
22
+ <?js= data.description ?>
23
+ </div>
24
+ <?js } ?>
25
+
26
+ <?js if (data.augments && data.alias && data.alias.indexOf('module:') === 0) { ?>
27
+ <h5>Extends:</h5>
28
+ <?js= self.partial('augments.tmpl', data) ?>
29
+ <?js } ?>
30
+
31
+ <?js if (kind === 'event' && data.type && data.type.names) {?>
32
+ <h5>Type:</h5>
33
+ <ul>
34
+ <li>
35
+ <?js= self.partial('type.tmpl', data.type.names) ?>
36
+ </li>
37
+ </ul>
38
+ <?js } ?>
39
+
40
+ <?js if (data['this']) { ?>
41
+ <h5>This:</h5>
42
+ <ul><li><?js= this.linkto(data['this'], data['this']) ?></li></ul>
43
+ <?js } ?>
44
+
45
+ <?js if (data.params && params.length && !data.hideconstructor) { ?>
46
+ <h5>Parameters:</h5>
47
+ <?js= this.partial('params.tmpl', params) ?>
48
+ <?js } ?>
49
+
50
+ <?js= this.partial('details.tmpl', data) ?>
51
+
52
+ <?js if (data.kind !== 'module' && data.requires && data.requires.length) { ?>
53
+ <h5>Requires:</h5>
54
+ <ul><?js data.requires.forEach(function(r) { ?>
55
+ <li><?js= self.linkto(r) ?></li>
56
+ <?js }); ?></ul>
57
+ <?js } ?>
58
+
59
+ <?js if (data.fires && fires.length) { ?>
60
+ <h5>Fires:</h5>
61
+ <ul><?js fires.forEach(function(f) { ?>
62
+ <li><?js= self.linkto(f) ?></li>
63
+ <?js }); ?></ul>
64
+ <?js } ?>
65
+
66
+ <?js if (data.listens && listens.length) { ?>
67
+ <h5>Listens to Events:</h5>
68
+ <ul><?js listens.forEach(function(f) { ?>
69
+ <li><?js= self.linkto(f) ?></li>
70
+ <?js }); ?></ul>
71
+ <?js } ?>
72
+
73
+ <?js if (data.listeners && listeners.length) { ?>
74
+ <h5>Listeners of This Event:</h5>
75
+ <ul><?js listeners.forEach(function(f) { ?>
76
+ <li><?js= self.linkto(f) ?></li>
77
+ <?js }); ?></ul>
78
+ <?js } ?>
79
+
80
+ <?js if (data.modifies && modifies.length) {?>
81
+ <h5>Modifies:</h5>
82
+ <?js if (modifies.length > 1) { ?><ul><?js
83
+ modifies.forEach(function(m) { ?>
84
+ <li><?js= self.partial('modifies.tmpl', m) ?></li>
85
+ <?js });
86
+ ?></ul><?js } else {
87
+ modifies.forEach(function(m) { ?>
88
+ <?js= self.partial('modifies.tmpl', m) ?>
89
+ <?js });
90
+ } } ?>
91
+
92
+ <?js if (data.exceptions && exceptions.length) { ?>
93
+ <h5>Throws:</h5>
94
+ <?js if (exceptions.length > 1) { ?><ul><?js
95
+ exceptions.forEach(function(r) { ?>
96
+ <li><?js= self.partial('exceptions.tmpl', r) ?></li>
97
+ <?js });
98
+ ?></ul><?js } else {
99
+ exceptions.forEach(function(r) { ?>
100
+ <?js= self.partial('exceptions.tmpl', r) ?>
101
+ <?js });
102
+ } } ?>
103
+
104
+ <?js if (data.returns && returns.length) { ?>
105
+ <h5>Returns:</h5>
106
+ <?js if (returns.length > 1) { ?><ul><?js
107
+ returns.forEach(function(r) { ?>
108
+ <li><?js= self.partial('returns.tmpl', r) ?></li>
109
+ <?js });
110
+ ?></ul><?js } else {
111
+ returns.forEach(function(r) { ?>
112
+ <?js= self.partial('returns.tmpl', r) ?>
113
+ <?js });
114
+ } } ?>
115
+
116
+ <?js if (data.yields && yields.length) { ?>
117
+ <h5>Yields:</h5>
118
+ <?js if (yields.length > 1) { ?><ul><?js
119
+ yields.forEach(function(r) { ?>
120
+ <li><?js= self.partial('returns.tmpl', r) ?></li>
121
+ <?js });
122
+ ?></ul><?js } else {
123
+ yields.forEach(function(r) { ?>
124
+ <?js= self.partial('returns.tmpl', r) ?>
125
+ <?js });
126
+ } } ?>
127
+
128
+ <?js if (data.examples && examples.length) { ?>
129
+ <h5>Example<?js= examples.length > 1? 's':'' ?></h5>
130
+ <?js= this.partial('examples.tmpl', examples) ?>
131
+ <?js } ?>
@@ -0,0 +1,14 @@
1
+ <?js
2
+ var data = obj || {};
3
+ ?>
4
+
5
+ <?js if (data.type && data.type.names) {?>
6
+ <dl>
7
+ <dt>
8
+ Type
9
+ </dt>
10
+ <dd>
11
+ <?js= this.partial('type.tmpl', data.type.names) ?>
12
+ </dd>
13
+ </dl>
14
+ <?js } ?>
@@ -0,0 +1,131 @@
1
+ <?js
2
+ var params = obj;
3
+
4
+ /* sort subparams under their parent params (like opts.classname) */
5
+ var parentParam = null;
6
+ params.forEach(function(param, i) {
7
+ var paramRegExp;
8
+
9
+ if (!param) {
10
+ return;
11
+ }
12
+
13
+ if (parentParam && parentParam.name && param.name) {
14
+ try {
15
+ paramRegExp = new RegExp('^(?:' + parentParam.name + '(?:\\[\\])*)\\.(.+)$');
16
+ }
17
+ catch (e) {
18
+ // there's probably a typo in the JSDoc comment that resulted in a weird
19
+ // parameter name
20
+ return;
21
+ }
22
+
23
+ if ( paramRegExp.test(param.name) ) {
24
+ param.name = RegExp.$1;
25
+ parentParam.subparams = parentParam.subparams || [];
26
+ parentParam.subparams.push(param);
27
+ params[i] = null;
28
+ }
29
+ else {
30
+ parentParam = param;
31
+ }
32
+ }
33
+ else {
34
+ parentParam = param;
35
+ }
36
+ });
37
+
38
+ /* determine if we need extra columns, "attributes" and "default" */
39
+ params.hasAttributes = false;
40
+ params.hasDefault = false;
41
+ params.hasName = false;
42
+
43
+ params.forEach(function(param) {
44
+ if (!param) { return; }
45
+
46
+ if (param.optional || param.nullable || param.variable) {
47
+ params.hasAttributes = true;
48
+ }
49
+
50
+ if (param.name) {
51
+ params.hasName = true;
52
+ }
53
+
54
+ if (typeof param.defaultvalue !== 'undefined') {
55
+ params.hasDefault = true;
56
+ }
57
+ });
58
+ ?>
59
+
60
+ <table class="params">
61
+ <thead>
62
+ <tr>
63
+ <?js if (params.hasName) {?>
64
+ <th>Name</th>
65
+ <?js } ?>
66
+
67
+ <th>Type</th>
68
+
69
+ <?js if (params.hasAttributes) {?>
70
+ <th>Attributes</th>
71
+ <?js } ?>
72
+
73
+ <?js if (params.hasDefault) {?>
74
+ <th>Default</th>
75
+ <?js } ?>
76
+
77
+ <th class="last">Description</th>
78
+ </tr>
79
+ </thead>
80
+
81
+ <tbody>
82
+ <?js
83
+ var self = this;
84
+ params.forEach(function(param) {
85
+ if (!param) { return; }
86
+ ?>
87
+
88
+ <tr>
89
+ <?js if (params.hasName) {?>
90
+ <td class="name"><code><?js= param.name ?></code></td>
91
+ <?js } ?>
92
+
93
+ <td class="type">
94
+ <?js if (param.type && param.type.names) {?>
95
+ <?js= self.partial('type.tmpl', param.type.names) ?>
96
+ <?js } ?>
97
+ </td>
98
+
99
+ <?js if (params.hasAttributes) {?>
100
+ <td class="attributes">
101
+ <?js if (param.optional) { ?>
102
+ &lt;optional><br>
103
+ <?js } ?>
104
+
105
+ <?js if (param.nullable) { ?>
106
+ &lt;nullable><br>
107
+ <?js } ?>
108
+
109
+ <?js if (param.variable) { ?>
110
+ &lt;repeatable><br>
111
+ <?js } ?>
112
+ </td>
113
+ <?js } ?>
114
+
115
+ <?js if (params.hasDefault) {?>
116
+ <td class="default">
117
+ <?js if (typeof param.defaultvalue !== 'undefined') { ?>
118
+ <?js= self.htmlsafe(param.defaultvalue) ?>
119
+ <?js } ?>
120
+ </td>
121
+ <?js } ?>
122
+
123
+ <td class="description last"><?js= param.description ?><?js if (param.subparams) { ?>
124
+ <h6>Properties</h6>
125
+ <?js= self.partial('params.tmpl', param.subparams) ?>
126
+ <?js } ?></td>
127
+ </tr>
128
+
129
+ <?js }); ?>
130
+ </tbody>
131
+ </table>
@@ -0,0 +1,108 @@
1
+ <?js
2
+ var data = obj;
3
+ var props = data.subprops || data.properties;
4
+
5
+ /* sort subprops under their parent props (like opts.classname) */
6
+ var parentProp = null;
7
+ props.forEach(function(prop, i) {
8
+ if (!prop) { return; }
9
+ if ( parentProp && prop.name && prop.name.indexOf(parentProp.name + '.') === 0 ) {
10
+ prop.name = prop.name.substr(parentProp.name.length+1);
11
+ parentProp.subprops = parentProp.subprops || [];
12
+ parentProp.subprops.push(prop);
13
+ props[i] = null;
14
+ }
15
+ else {
16
+ parentProp = prop;
17
+ }
18
+ });
19
+
20
+ /* determine if we need extra columns, "attributes" and "default" */
21
+ props.hasAttributes = false;
22
+ props.hasDefault = false;
23
+ props.hasName = false;
24
+
25
+ props.forEach(function(prop) {
26
+ if (!prop) { return; }
27
+
28
+ if (prop.optional || prop.nullable) {
29
+ props.hasAttributes = true;
30
+ }
31
+
32
+ if (prop.name) {
33
+ props.hasName = true;
34
+ }
35
+
36
+ if (typeof prop.defaultvalue !== 'undefined' && !data.isEnum) {
37
+ props.hasDefault = true;
38
+ }
39
+ });
40
+ ?>
41
+
42
+ <table class="props">
43
+ <thead>
44
+ <tr>
45
+ <?js if (props.hasName) {?>
46
+ <th>Name</th>
47
+ <?js } ?>
48
+
49
+ <th>Type</th>
50
+
51
+ <?js if (props.hasAttributes) {?>
52
+ <th>Attributes</th>
53
+ <?js } ?>
54
+
55
+ <?js if (props.hasDefault) {?>
56
+ <th>Default</th>
57
+ <?js } ?>
58
+
59
+ <th class="last">Description</th>
60
+ </tr>
61
+ </thead>
62
+
63
+ <tbody>
64
+ <?js
65
+ var self = this;
66
+ props.forEach(function(prop) {
67
+ if (!prop) { return; }
68
+ ?>
69
+
70
+ <tr>
71
+ <?js if (props.hasName) {?>
72
+ <td class="name"><code><?js= prop.name ?></code></td>
73
+ <?js } ?>
74
+
75
+ <td class="type">
76
+ <?js if (prop.type && prop.type.names) {?>
77
+ <?js= self.partial('type.tmpl', prop.type.names) ?>
78
+ <?js } ?>
79
+ </td>
80
+
81
+ <?js if (props.hasAttributes) {?>
82
+ <td class="attributes">
83
+ <?js if (prop.optional) { ?>
84
+ &lt;optional><br>
85
+ <?js } ?>
86
+
87
+ <?js if (prop.nullable) { ?>
88
+ &lt;nullable><br>
89
+ <?js } ?>
90
+ </td>
91
+ <?js } ?>
92
+
93
+ <?js if (props.hasDefault) {?>
94
+ <td class="default">
95
+ <?js if (typeof prop.defaultvalue !== 'undefined') { ?>
96
+ <?js= self.htmlsafe(prop.defaultvalue) ?>
97
+ <?js } ?>
98
+ </td>
99
+ <?js } ?>
100
+
101
+ <td class="description last"><?js= prop.description ?><?js if (prop.subprops) { ?>
102
+ <h6>Properties</h6><?js= self.partial('properties.tmpl', prop) ?>
103
+ <?js } ?></td>
104
+ </tr>
105
+
106
+ <?js }); ?>
107
+ </tbody>
108
+ </table>
@@ -0,0 +1,19 @@
1
+ <?js
2
+ var data = obj || {};
3
+ if (data.description) {
4
+ ?>
5
+ <div class="param-desc">
6
+ <?js= description ?>
7
+ </div>
8
+ <?js } ?>
9
+
10
+ <?js if (data.type && data.type.names) {?>
11
+ <dl>
12
+ <dt>
13
+ Type
14
+ </dt>
15
+ <dd>
16
+ <?js= this.partial('type.tmpl', data.type.names) ?>
17
+ </dd>
18
+ </dl>
19
+ <?js } ?>
@@ -0,0 +1,8 @@
1
+ <?js
2
+ var data = obj;
3
+ ?>
4
+ <section>
5
+ <article>
6
+ <pre class="prettyprint source linenums"><code><?js= data.code ?></code></pre>
7
+ </article>
8
+ </section>
@@ -0,0 +1,19 @@
1
+ <section>
2
+
3
+ <header>
4
+ <?js if (children.length > 0) { ?>
5
+ <ul><?js
6
+ var self = this;
7
+ children.forEach(function(t) { ?>
8
+ <li><?js= self.tutoriallink(t.name) ?></li>
9
+ <?js }); ?></ul>
10
+ <?js } ?>
11
+
12
+ <h2><?js= header ?></h2>
13
+ </header>
14
+
15
+ <article>
16
+ <?js= content ?>
17
+ </article>
18
+
19
+ </section>
@@ -0,0 +1,7 @@
1
+ <?js
2
+ var data = obj;
3
+ var self = this;
4
+ data.forEach(function(name, i) { ?>
5
+ <span class="param-type"><?js= self.linkto(name, self.htmlsafe(name)) ?></span>
6
+ <?js if (i < data.length-1) { ?>|<?js } ?>
7
+ <?js }); ?>
package/env.config.js ADDED
@@ -0,0 +1,8 @@
1
+ // NOTE: This file is used by the example app. frontend-build expects the file
2
+ // to be in the root of the repository. This is not used by the actual frontend-platform library.
3
+ // Also note that in an actual application this file would be added to .gitignore.
4
+ const config = {
5
+ JS_FILE_VAR: 'JS_FILE_VAR_VALUE_FOR_EXAMPLE_APP',
6
+ };
7
+
8
+ export default config;
package/jsdoc.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "tags": {
3
+ "allowUnknownTags": true,
4
+ "dictionaries": ["jsdoc"]
5
+ },
6
+ "source": {
7
+ "include": ["src", "package.json", "README.md"],
8
+ "includePattern": ".+\\.js(doc|x)?$",
9
+ "excludePattern": "(node_modules/|docs)"
10
+ },
11
+ "plugins": [
12
+ "plugins/markdown",
13
+ "docs/addTagsPlugin",
14
+ "docs/removeExport"
15
+ ],
16
+ "templates": {
17
+ "cleverLinks": false,
18
+ "monospaceLinks": true,
19
+ "useLongnameInNav": false,
20
+ "showInheritedInNav": true,
21
+ "default": {
22
+ "staticFiles": {
23
+ "include": [
24
+ "./service-interface.png"
25
+ ]
26
+ }
27
+ }
28
+ },
29
+ "opts": {
30
+ "destination": "./docs/api",
31
+ "encoding": "utf8",
32
+ "private": true,
33
+ "recurse": true,
34
+ "template": "docs/template/edx"
35
+ }
36
+ }
package/openedx.yaml ADDED
@@ -0,0 +1,12 @@
1
+ # openedx.yaml
2
+
3
+ ---
4
+ owner: edx/fedx-team
5
+ tags:
6
+ - library
7
+ - platform
8
+ - react
9
+ - i18n
10
+ - analytics
11
+ - logging
12
+ - authentication
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-platform",
3
- "version": "4.6.0",
3
+ "version": "4.6.2",
4
4
  "description": "Foundational application framework for Open edX micro-frontend applications.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -34,12 +34,12 @@
34
34
  "devDependencies": {
35
35
  "@edx/brand": "npm:@edx/brand-openedx@1.2.0",
36
36
  "@edx/browserslist-config": "1.2.0",
37
- "@edx/frontend-build": "12.8.57",
37
+ "@edx/frontend-build": "12.9.3",
38
38
  "@edx/paragon": "^20.44.0",
39
39
  "@testing-library/react-hooks": "^8.0.1",
40
40
  "@wojtekmaj/enzyme-adapter-react-17": "0.8.0",
41
- "axios-mock-adapter": "^1.21.3",
42
- "core-js": "3.31.0",
41
+ "axios-mock-adapter": "^1.21.5",
42
+ "core-js": "3.32.0",
43
43
  "enzyme": "3.11.0",
44
44
  "husky": "8.0.3",
45
45
  "jsdoc": "^4.0.0",
@@ -74,8 +74,8 @@
74
74
  "universal-cookie": "4.0.4"
75
75
  },
76
76
  "peerDependencies": {
77
- "@edx/frontend-build": ">= 8.1.0",
78
- "@edx/paragon": ">= 10.0.0 < 21.0.0",
77
+ "@edx/frontend-build": ">= 8.1.0 || ^12.9.0-alpha.1",
78
+ "@edx/paragon": ">= 10.0.0 < 22.0.0",
79
79
  "prop-types": "^15.7.2",
80
80
  "react": "^16.9.0 || ^17.0.0",
81
81
  "react-dom": "^16.9.0 || ^17.0.0",
Binary file
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The MockAnalyticsService implements all functions of AnalyticsService as Jest mocks (jest.fn())).
3
+ * It emulates the behavior of a real analytics service but witohut making any requests. It has no
4
+ * other functionality.
5
+ *
6
+ * @implements {AnalyticsService}
7
+ * @memberof module:Analytics
8
+ */
9
+ class MockAnalyticsService {
10
+ static hasIdentifyBeenCalled = false;
11
+
12
+ constructor({ httpClient, loggingService }) {
13
+ this.loggingService = loggingService;
14
+ this.httpClient = httpClient;
15
+ }
16
+
17
+ checkIdentifyCalled = jest.fn(() => {
18
+ if (!this.hasIdentifyBeenCalled) {
19
+ this.loggingService.logError('Identify must be called before other tracking events.');
20
+ }
21
+ });
22
+
23
+ /**
24
+ * Returns a resolved promise.
25
+ *
26
+ * @returns {Promise} The promise returned by HttpClient.post.
27
+ */
28
+ sendTrackingLogEvent = jest.fn(() => Promise.resolve());
29
+
30
+ /**
31
+ * No-op, but records that identify has been called.
32
+ *
33
+ * @param {string} userId
34
+ * @throws {Error} If userId argument is not supplied.
35
+ */
36
+ identifyAuthenticatedUser = jest.fn((userId) => {
37
+ if (!userId) {
38
+ throw new Error('UserId is required for identifyAuthenticatedUser.');
39
+ }
40
+ this.hasIdentifyBeenCalled = true;
41
+ });
42
+
43
+ /**
44
+ * No-op, but records that it has been called to prevent double-identification.
45
+ * @returns {Promise} A resolved promise.
46
+ */
47
+ identifyAnonymousUser = jest.fn(() => {
48
+ this.hasIdentifyBeenCalled = true;
49
+ return Promise.resolve();
50
+ });
51
+
52
+ /**
53
+ * Logs the event to the console.
54
+ *
55
+ * Checks whether identify has been called, logging an error to the logging service if not.
56
+ */
57
+ sendTrackEvent = jest.fn(() => {
58
+ this.checkIdentifyCalled();
59
+ });
60
+
61
+ /**
62
+ * Logs the event to the console.
63
+ *
64
+ * Checks whether identify has been called, logging an error to the logging service if not.
65
+ */
66
+ sendPageEvent = jest.fn(() => {
67
+ this.checkIdentifyCalled();
68
+ });
69
+ }
70
+
71
+ export default MockAnalyticsService;