@entur-partner/micro-frontend 2.1.5 → 2.3.0
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/dist/AppProvider.d.ts +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/micro-frontend.cjs.development.js +79 -0
- package/dist/micro-frontend.cjs.development.js.map +1 -1
- package/dist/micro-frontend.cjs.production.min.js +1 -1
- package/dist/micro-frontend.cjs.production.min.js.map +1 -1
- package/dist/micro-frontend.esm.js +72 -1
- package/dist/micro-frontend.esm.js.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import { Permission } from '@entur-partner/permission-client-node';
|
|
3
|
+
import { User } from './User';
|
|
4
|
+
interface AppContextType {
|
|
5
|
+
getToken: () => Promise<string>;
|
|
6
|
+
user: User;
|
|
7
|
+
logout?: () => void;
|
|
8
|
+
activeOrgId: number;
|
|
9
|
+
navigate: (path: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const AppContext: React.Context<AppContextType | undefined>;
|
|
12
|
+
export declare const useUser: () => User;
|
|
13
|
+
export declare const useActiveOrgId: () => number;
|
|
14
|
+
export interface AppProviderProps {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
getToken: () => Promise<string>;
|
|
17
|
+
user: User;
|
|
18
|
+
getPermissions: () => Promise<Permission[]>;
|
|
19
|
+
organisationId: string;
|
|
20
|
+
navigate: (path: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const useNavigate: () => (path: string) => void;
|
|
23
|
+
export declare const AppProvider: FC<AppProviderProps>;
|
|
24
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { User } from './User';
|
|
|
2
2
|
export { MicroFrontendPayload, MenuItem, NavigationFunction } from './Payload';
|
|
3
3
|
export { MountEvent, UnmountEvent, createMountEvent, createUnmountEvent, MOUNT_EVENT_TYPE, UNMOUNT_EVENT_TYPE, RouteChangeEvent, ROUTE_CHANGE_EVENT_TYPE, RouteAction, } from './events';
|
|
4
4
|
export { registerMicroFrontend } from './registerMicroFrontend';
|
|
5
|
+
export { AppProvider, AppProviderProps, useActiveOrgId, useNavigate, useUser, } from './AppProvider';
|
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var util = require('@entur-partner/util');
|
|
7
|
+
var reactQuery = require('react-query');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
function _extends() {
|
|
14
|
+
_extends = Object.assign || function (target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = arguments[i];
|
|
17
|
+
|
|
18
|
+
for (var key in source) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
|
+
target[key] = source[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return _extends.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
|
|
5
31
|
function _inheritsLoose(subClass, superClass) {
|
|
6
32
|
subClass.prototype = Object.create(superClass.prototype);
|
|
7
33
|
subClass.prototype.constructor = subClass;
|
|
@@ -93,6 +119,21 @@ function _wrapNativeSuper(Class) {
|
|
|
93
119
|
return _wrapNativeSuper(Class);
|
|
94
120
|
}
|
|
95
121
|
|
|
122
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
123
|
+
if (source == null) return {};
|
|
124
|
+
var target = {};
|
|
125
|
+
var sourceKeys = Object.keys(source);
|
|
126
|
+
var key, i;
|
|
127
|
+
|
|
128
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
129
|
+
key = sourceKeys[i];
|
|
130
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
131
|
+
target[key] = source[key];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return target;
|
|
135
|
+
}
|
|
136
|
+
|
|
96
137
|
var MOUNT_EVENT_TYPE = '@entur-partner:mount';
|
|
97
138
|
var UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';
|
|
98
139
|
function createMountEvent(detail) {
|
|
@@ -136,6 +177,41 @@ function registerMicroFrontend(config) {
|
|
|
136
177
|
});
|
|
137
178
|
}
|
|
138
179
|
|
|
180
|
+
var _excluded = ["children", "organisationId", "getPermissions"];
|
|
181
|
+
var AppContext = /*#__PURE__*/React__default["default"].createContext(undefined);
|
|
182
|
+
var useUser = function useUser() {
|
|
183
|
+
var context = React.useContext(AppContext);
|
|
184
|
+
util.assertIsDefined(context);
|
|
185
|
+
return context.user;
|
|
186
|
+
};
|
|
187
|
+
var useActiveOrgId = function useActiveOrgId() {
|
|
188
|
+
var context = React.useContext(AppContext);
|
|
189
|
+
util.assertIsDefined(context);
|
|
190
|
+
return context.activeOrgId;
|
|
191
|
+
};
|
|
192
|
+
var useNavigate = function useNavigate() {
|
|
193
|
+
var context = React.useContext(AppContext);
|
|
194
|
+
util.assertIsDefined(context);
|
|
195
|
+
return context.navigate;
|
|
196
|
+
};
|
|
197
|
+
var AppProvider = function AppProvider(_ref) {
|
|
198
|
+
var children = _ref.children,
|
|
199
|
+
organisationId = _ref.organisationId,
|
|
200
|
+
getPermissions = _ref.getPermissions,
|
|
201
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
202
|
+
|
|
203
|
+
var permissionsQuery = reactQuery.useQuery(['permissions'], getPermissions);
|
|
204
|
+
return React__default["default"].createElement(AppContext.Provider, {
|
|
205
|
+
value: _extends({}, rest, {
|
|
206
|
+
user: _extends({}, rest.user, {
|
|
207
|
+
permissions: permissionsQuery.data || []
|
|
208
|
+
}),
|
|
209
|
+
activeOrgId: Number(organisationId)
|
|
210
|
+
})
|
|
211
|
+
}, children);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
exports.AppProvider = AppProvider;
|
|
139
215
|
exports.MOUNT_EVENT_TYPE = MOUNT_EVENT_TYPE;
|
|
140
216
|
exports.ROUTE_CHANGE_EVENT_TYPE = ROUTE_CHANGE_EVENT_TYPE;
|
|
141
217
|
exports.RouteChangeEvent = RouteChangeEvent;
|
|
@@ -143,4 +219,7 @@ exports.UNMOUNT_EVENT_TYPE = UNMOUNT_EVENT_TYPE;
|
|
|
143
219
|
exports.createMountEvent = createMountEvent;
|
|
144
220
|
exports.createUnmountEvent = createUnmountEvent;
|
|
145
221
|
exports.registerMicroFrontend = registerMicroFrontend;
|
|
222
|
+
exports.useActiveOrgId = useActiveOrgId;
|
|
223
|
+
exports.useNavigate = useNavigate;
|
|
224
|
+
exports.useUser = useUser;
|
|
146
225
|
//# sourceMappingURL=micro-frontend.cjs.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro-frontend.cjs.development.js","sources":["../src/events.ts","../src/registerMicroFrontend.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n"],"names":["MOUNT_EVENT_TYPE","UNMOUNT_EVENT_TYPE","createMountEvent","detail","CustomEvent","createUnmountEvent","ROUTE_CHANGE_EVENT_TYPE","RouteChangeEvent","registerMicroFrontend","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload"],"mappings":"
|
|
1
|
+
{"version":3,"file":"micro-frontend.cjs.development.js","sources":["../src/events.ts","../src/registerMicroFrontend.tsx","../src/AppProvider.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n","import React, { FC, ReactNode, useContext } from 'react';\nimport { assertIsDefined } from '@entur-partner/util';\nimport { Permission } from '@entur-partner/permission-client-node';\nimport { useQuery } from 'react-query';\n\nimport { User } from './User';\n\ninterface AppContextType {\n getToken: () => Promise<string>;\n user: User;\n logout?: () => void;\n activeOrgId: number;\n navigate: (path: string) => void;\n}\n\nexport const AppContext = React.createContext<AppContextType | undefined>(\n undefined\n);\n\nexport const useUser = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.user;\n};\n\nexport const useActiveOrgId = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.activeOrgId;\n};\n\nexport interface AppProviderProps {\n children: ReactNode;\n getToken: () => Promise<string>;\n user: User;\n getPermissions: () => Promise<Permission[]>;\n organisationId: string;\n navigate: (path: string) => void;\n}\n\nexport const useNavigate = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.navigate;\n};\n\nexport const AppProvider: FC<AppProviderProps> = ({\n children,\n organisationId,\n getPermissions,\n ...rest\n}) => {\n const permissionsQuery = useQuery<Permission[]>(\n ['permissions'],\n getPermissions\n );\n return (\n <AppContext.Provider\n value={{\n ...rest,\n user: { ...rest.user, permissions: permissionsQuery.data || [] },\n activeOrgId: Number(organisationId),\n }}\n >\n {children}\n </AppContext.Provider>\n );\n};\n"],"names":["MOUNT_EVENT_TYPE","UNMOUNT_EVENT_TYPE","createMountEvent","detail","CustomEvent","createUnmountEvent","ROUTE_CHANGE_EVENT_TYPE","RouteChangeEvent","registerMicroFrontend","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload","AppContext","React","createContext","undefined","useUser","context","useContext","assertIsDefined","user","useActiveOrgId","activeOrgId","useNavigate","navigate","AppProvider","children","organisationId","getPermissions","rest","permissionsQuery","useQuery","createElement","Provider","value","permissions","data","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,IAAMA,gBAAgB,GAAG,uBAAzB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MAFHC,cAEG,QAFHA,cAEG;AAAA,MADAC,IACA,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACH,EAAMC,IAAAA,gBAAgB,GAAGC,mBAAQ,CAC/B,CAAC,aAAD,CAD+B,EAE/BH,cAF+B,CAAjC,CAAA;AAIA,EAAA,OACEf,yBAAC,CAAAmB,aAAD,CAACpB,UAAU,CAACqB,QAAZ,EAAoB;AAClBC,IAAAA,KAAK,eACAL,IADA,EAAA;AAEHT,MAAAA,IAAI,EAAA,QAAA,CAAA,EAAA,EAAOS,IAAI,CAACT,IAAZ,EAAA;AAAkBe,QAAAA,WAAW,EAAEL,gBAAgB,CAACM,IAAjB,IAAyB,EAAA;AAAxD,OAFD,CAAA;AAGHd,MAAAA,WAAW,EAAEe,MAAM,CAACV,cAAD,CAAA;AAHhB,KAAA,CAAA;AADa,GAApB,EAOGD,QAPH,CADF,CAAA;AAWD;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(e){return t=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},t
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("@entur-partner/util"),r=require("react-query");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=n(t);function u(){return u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},u.apply(this,arguments)}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function a(t,e){return a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},a(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function s(t,e,r){return s=c()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&a(o,r.prototype),o},s.apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return s(t,arguments,i(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},p(t)}var f=function(t){var e,r;function n(){return t.apply(this,arguments)||this}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,a(e,r),n}(p(CustomEvent)),l=["children","organisationId","getPermissions"],d=o.default.createContext(void 0);exports.AppProvider=function(t){var e=t.children,n=t.organisationId,i=t.getPermissions,a=function(t,e){if(null==t)return{};var r,n,o={},u=Object.keys(t);for(n=0;n<u.length;n++)e.indexOf(r=u[n])>=0||(o[r]=t[r]);return o}(t,l),c=r.useQuery(["permissions"],i);return o.default.createElement(d.Provider,{value:u({},a,{user:u({},a.user,{permissions:c.data||[]}),activeOrgId:Number(n)})},e)},exports.MOUNT_EVENT_TYPE="@entur-partner:mount",exports.ROUTE_CHANGE_EVENT_TYPE="@entur-partner:after-route-change",exports.RouteChangeEvent=f,exports.UNMOUNT_EVENT_TYPE="@entur-partner:unmount",exports.createMountEvent=function(t){return new CustomEvent("@entur-partner:mount",{detail:t})},exports.createUnmountEvent=function(t){return new CustomEvent("@entur-partner:unmount",{detail:t})},exports.registerMicroFrontend=function(t){var e=t.unmount,r=t.microFrontendId,n=t.mount;window.addEventListener("@entur-partner:mount",(function(t){t.detail.id.startsWith(r)&&n(t.detail.mountPoint,t.detail.payload,t.detail.mountPoint)})),window.addEventListener("@entur-partner:unmount",(function(t){t.detail.id.startsWith(r)&&e(t.detail.mountPoint)}))},exports.useActiveOrgId=function(){var r=t.useContext(d);return e.assertIsDefined(r),r.activeOrgId},exports.useNavigate=function(){var r=t.useContext(d);return e.assertIsDefined(r),r.navigate},exports.useUser=function(){var r=t.useContext(d);return e.assertIsDefined(r),r.user};
|
|
2
2
|
//# sourceMappingURL=micro-frontend.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro-frontend.cjs.production.min.js","sources":["../src/events.ts","../src/registerMicroFrontend.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n"],"names":["RouteChangeEvent","_CustomEvent","apply","this","arguments","_wrapNativeSuper","CustomEvent","detail","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload"],"mappings":"
|
|
1
|
+
{"version":3,"file":"micro-frontend.cjs.production.min.js","sources":["../src/events.ts","../src/AppProvider.tsx","../src/registerMicroFrontend.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","import React, { FC, ReactNode, useContext } from 'react';\nimport { assertIsDefined } from '@entur-partner/util';\nimport { Permission } from '@entur-partner/permission-client-node';\nimport { useQuery } from 'react-query';\n\nimport { User } from './User';\n\ninterface AppContextType {\n getToken: () => Promise<string>;\n user: User;\n logout?: () => void;\n activeOrgId: number;\n navigate: (path: string) => void;\n}\n\nexport const AppContext = React.createContext<AppContextType | undefined>(\n undefined\n);\n\nexport const useUser = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.user;\n};\n\nexport const useActiveOrgId = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.activeOrgId;\n};\n\nexport interface AppProviderProps {\n children: ReactNode;\n getToken: () => Promise<string>;\n user: User;\n getPermissions: () => Promise<Permission[]>;\n organisationId: string;\n navigate: (path: string) => void;\n}\n\nexport const useNavigate = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.navigate;\n};\n\nexport const AppProvider: FC<AppProviderProps> = ({\n children,\n organisationId,\n getPermissions,\n ...rest\n}) => {\n const permissionsQuery = useQuery<Permission[]>(\n ['permissions'],\n getPermissions\n );\n return (\n <AppContext.Provider\n value={{\n ...rest,\n user: { ...rest.user, permissions: permissionsQuery.data || [] },\n activeOrgId: Number(organisationId),\n }}\n >\n {children}\n </AppContext.Provider>\n );\n};\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n"],"names":["RouteChangeEvent","_CustomEvent","apply","this","arguments","_wrapNativeSuper","CustomEvent","AppContext","React","createContext","undefined","_ref","children","organisationId","getPermissions","rest","_objectWithoutPropertiesLoose","_excluded","permissionsQuery","useQuery","createElement","Provider","value","user","_extends","permissions","data","activeOrgId","Number","detail","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload","context","useContext","assertIsDefined","navigate"],"mappings":"yjDA2BO,IASMA,EAAb,SAAAC,WAAA,SAAAD,IAAA,OAAAC,EAAAC,MAAAC,KAAAC,YAAAD,KAAA,SAAAF,KAAAD,yEAAAA,EAAA,CAAAK,EAAsCC,+DCrBzBC,EAAaC,EAAK,QAACC,mBAC9BC,uBA8B+C,SAK5CC,GAJHC,IAAAA,IAAAA,SACAC,IAAAA,eACAC,IAAAA,eACGC,oIACAC,CAAAL,EAAAM,GACGC,EAAmBC,EAAQA,SAC/B,CAAC,eACDL,GAEF,OACEN,UAACY,cAAAb,EAAWc,SAAQ,CAClBC,WACKP,EADA,CAEHQ,KAAIC,EAAA,GAAOT,EAAKQ,KAAZ,CAAkBE,YAAaP,EAAiBQ,MAAQ,KAC5DC,YAAaC,OAAOf,MAGrBD,6BDnDyB,uDAcO,0FAbL,kDAK5B,SAA2BiB,GAC/B,OAAO,IAAIvB,YAPmB,uBAO6B,CAAEuB,OAAAA,gCAGzD,SAA6BA,GACjC,OAAO,IAAIvB,YAVqB,yBAU+B,CAAEuB,OAAAA,mCEL7D,SAAgCC,GACpC,IAAQC,EAAoCD,EAApCC,QAASC,EAA2BF,EAA3BE,gBAAiBC,EAAUH,EAAVG,MAElCC,OAAOC,iBFTuB,wBESa,SAACC,GACrCA,EAAMP,OAAOQ,GAAGC,WAAWN,IAGhCC,EACEG,EAAMP,OAAOU,WACbH,EAAMP,OAAOW,QACbJ,EAAMP,OAAOU,eAIjBL,OAAOC,iBFnByB,0BEmBa,SAACC,GACvCA,EAAMP,OAAOQ,GAAGC,WAAWN,IAGhCD,EAAQK,EAAMP,OAAOU,uCDZK,WAC5B,IAAME,EAAUC,aAAWnC,GAEpBkC,OADPE,EAAeA,gBAACF,GACTA,EAAQd,iCAYU,WACzB,IAAMc,EAAUC,aAAWnC,GAEpBkC,OADPE,EAAeA,gBAACF,GACTA,EAAQG,0BAxBM,WACrB,IAAMH,EAAUC,aAAWnC,GAEpBkC,OADPE,EAAeA,gBAACF,GACTA,EAAQlB"}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { assertIsDefined } from '@entur-partner/util';
|
|
3
|
+
import { useQuery } from 'react-query';
|
|
4
|
+
|
|
5
|
+
function _extends() {
|
|
6
|
+
_extends = Object.assign || function (target) {
|
|
7
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
8
|
+
var source = arguments[i];
|
|
9
|
+
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return _extends.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
|
|
1
23
|
function _inheritsLoose(subClass, superClass) {
|
|
2
24
|
subClass.prototype = Object.create(superClass.prototype);
|
|
3
25
|
subClass.prototype.constructor = subClass;
|
|
@@ -89,6 +111,21 @@ function _wrapNativeSuper(Class) {
|
|
|
89
111
|
return _wrapNativeSuper(Class);
|
|
90
112
|
}
|
|
91
113
|
|
|
114
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
115
|
+
if (source == null) return {};
|
|
116
|
+
var target = {};
|
|
117
|
+
var sourceKeys = Object.keys(source);
|
|
118
|
+
var key, i;
|
|
119
|
+
|
|
120
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
121
|
+
key = sourceKeys[i];
|
|
122
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
123
|
+
target[key] = source[key];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return target;
|
|
127
|
+
}
|
|
128
|
+
|
|
92
129
|
var MOUNT_EVENT_TYPE = '@entur-partner:mount';
|
|
93
130
|
var UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';
|
|
94
131
|
function createMountEvent(detail) {
|
|
@@ -132,5 +169,39 @@ function registerMicroFrontend(config) {
|
|
|
132
169
|
});
|
|
133
170
|
}
|
|
134
171
|
|
|
135
|
-
|
|
172
|
+
var _excluded = ["children", "organisationId", "getPermissions"];
|
|
173
|
+
var AppContext = /*#__PURE__*/React.createContext(undefined);
|
|
174
|
+
var useUser = function useUser() {
|
|
175
|
+
var context = useContext(AppContext);
|
|
176
|
+
assertIsDefined(context);
|
|
177
|
+
return context.user;
|
|
178
|
+
};
|
|
179
|
+
var useActiveOrgId = function useActiveOrgId() {
|
|
180
|
+
var context = useContext(AppContext);
|
|
181
|
+
assertIsDefined(context);
|
|
182
|
+
return context.activeOrgId;
|
|
183
|
+
};
|
|
184
|
+
var useNavigate = function useNavigate() {
|
|
185
|
+
var context = useContext(AppContext);
|
|
186
|
+
assertIsDefined(context);
|
|
187
|
+
return context.navigate;
|
|
188
|
+
};
|
|
189
|
+
var AppProvider = function AppProvider(_ref) {
|
|
190
|
+
var children = _ref.children,
|
|
191
|
+
organisationId = _ref.organisationId,
|
|
192
|
+
getPermissions = _ref.getPermissions,
|
|
193
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
194
|
+
|
|
195
|
+
var permissionsQuery = useQuery(['permissions'], getPermissions);
|
|
196
|
+
return React.createElement(AppContext.Provider, {
|
|
197
|
+
value: _extends({}, rest, {
|
|
198
|
+
user: _extends({}, rest.user, {
|
|
199
|
+
permissions: permissionsQuery.data || []
|
|
200
|
+
}),
|
|
201
|
+
activeOrgId: Number(organisationId)
|
|
202
|
+
})
|
|
203
|
+
}, children);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export { AppProvider, MOUNT_EVENT_TYPE, ROUTE_CHANGE_EVENT_TYPE, RouteChangeEvent, UNMOUNT_EVENT_TYPE, createMountEvent, createUnmountEvent, registerMicroFrontend, useActiveOrgId, useNavigate, useUser };
|
|
136
207
|
//# sourceMappingURL=micro-frontend.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro-frontend.esm.js","sources":["../src/events.ts","../src/registerMicroFrontend.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n"],"names":["MOUNT_EVENT_TYPE","UNMOUNT_EVENT_TYPE","createMountEvent","detail","CustomEvent","createUnmountEvent","ROUTE_CHANGE_EVENT_TYPE","RouteChangeEvent","registerMicroFrontend","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload"],"mappings":"
|
|
1
|
+
{"version":3,"file":"micro-frontend.esm.js","sources":["../src/events.ts","../src/registerMicroFrontend.tsx","../src/AppProvider.tsx"],"sourcesContent":["import { MicroFrontendPayload } from './Payload';\n\ntype MountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n payload: MicroFrontendPayload;\n};\n\ntype UnmountEventDetail = {\n id: string;\n mountPoint: HTMLDivElement;\n};\n\nexport const MOUNT_EVENT_TYPE = '@entur-partner:mount';\nexport const UNMOUNT_EVENT_TYPE = '@entur-partner:unmount';\n\nexport interface MountEvent extends CustomEvent<MountEventDetail> {}\nexport interface UnmountEvent extends CustomEvent<UnmountEventDetail> {}\n\nexport function createMountEvent(detail: MountEventDetail) {\n return new CustomEvent<MountEventDetail>(MOUNT_EVENT_TYPE, { detail });\n}\n\nexport function createUnmountEvent(detail: UnmountEventDetail) {\n return new CustomEvent<UnmountEventDetail>(UNMOUNT_EVENT_TYPE, { detail });\n}\n\nexport const ROUTE_CHANGE_EVENT_TYPE = '@entur-partner:after-route-change';\n\nexport type RouteAction = 'PUSH' | 'POP' | 'REPLACE';\n\ntype RouteChangeEventDetail = {\n location: Location;\n action: RouteAction;\n};\n\nexport class RouteChangeEvent extends CustomEvent<RouteChangeEventDetail> {}\n","/*global EventListener*/\nimport { MicroFrontendPayload } from './Payload';\nimport {\n MountEvent,\n UnmountEvent,\n MOUNT_EVENT_TYPE,\n UNMOUNT_EVENT_TYPE,\n} from './events';\n\ninterface Config {\n microFrontendId: string;\n mount: (\n mountPoint: HTMLDivElement,\n payload: MicroFrontendPayload,\n deprecatedMountPoint: HTMLDivElement\n ) => void;\n unmount: (mountPoint: HTMLDivElement) => void;\n}\n\nexport function registerMicroFrontend(config: Config): void {\n const { unmount, microFrontendId, mount } = config;\n\n window.addEventListener(MOUNT_EVENT_TYPE, ((event: MountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n mount(\n event.detail.mountPoint,\n event.detail.payload,\n event.detail.mountPoint\n );\n }) as EventListener);\n\n window.addEventListener(UNMOUNT_EVENT_TYPE, ((event: UnmountEvent) => {\n if (!event.detail.id.startsWith(microFrontendId)) {\n return;\n }\n unmount(event.detail.mountPoint);\n }) as EventListener);\n}\n","import React, { FC, ReactNode, useContext } from 'react';\nimport { assertIsDefined } from '@entur-partner/util';\nimport { Permission } from '@entur-partner/permission-client-node';\nimport { useQuery } from 'react-query';\n\nimport { User } from './User';\n\ninterface AppContextType {\n getToken: () => Promise<string>;\n user: User;\n logout?: () => void;\n activeOrgId: number;\n navigate: (path: string) => void;\n}\n\nexport const AppContext = React.createContext<AppContextType | undefined>(\n undefined\n);\n\nexport const useUser = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.user;\n};\n\nexport const useActiveOrgId = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.activeOrgId;\n};\n\nexport interface AppProviderProps {\n children: ReactNode;\n getToken: () => Promise<string>;\n user: User;\n getPermissions: () => Promise<Permission[]>;\n organisationId: string;\n navigate: (path: string) => void;\n}\n\nexport const useNavigate = () => {\n const context = useContext(AppContext);\n assertIsDefined(context);\n return context.navigate;\n};\n\nexport const AppProvider: FC<AppProviderProps> = ({\n children,\n organisationId,\n getPermissions,\n ...rest\n}) => {\n const permissionsQuery = useQuery<Permission[]>(\n ['permissions'],\n getPermissions\n );\n return (\n <AppContext.Provider\n value={{\n ...rest,\n user: { ...rest.user, permissions: permissionsQuery.data || [] },\n activeOrgId: Number(organisationId),\n }}\n >\n {children}\n </AppContext.Provider>\n );\n};\n"],"names":["MOUNT_EVENT_TYPE","UNMOUNT_EVENT_TYPE","createMountEvent","detail","CustomEvent","createUnmountEvent","ROUTE_CHANGE_EVENT_TYPE","RouteChangeEvent","registerMicroFrontend","config","unmount","microFrontendId","mount","window","addEventListener","event","id","startsWith","mountPoint","payload","AppContext","React","createContext","undefined","useUser","context","useContext","assertIsDefined","user","useActiveOrgId","activeOrgId","useNavigate","navigate","AppProvider","children","organisationId","getPermissions","rest","permissionsQuery","useQuery","createElement","Provider","value","permissions","data","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,IAAMA,gBAAgB,GAAG,uBAAzB;AACA,IAAMC,kBAAkB,GAAG,yBAA3B;AAKD,SAAUC,gBAAV,CAA2BC,MAA3B,EAAmD;AACvD,EAAA,OAAO,IAAIC,WAAJ,CAAkCJ,gBAAlC,EAAoD;AAAEG,IAAAA,MAAM,EAANA,MAAAA;AAAF,GAApD,CAAP,CAAA;AACD,CAAA;AAEK,SAAUE,kBAAV,CAA6BF,MAA7B,EAAuD;AAC3D,EAAA,OAAO,IAAIC,WAAJ,CAAoCH,kBA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AEHT,MAAAA,IAAI,EAAA,QAAA,CAAA,EAAA,EAAOS,IAAI,CAACT,IAAZ,EAAA;AAAkBe,QAAAA,WAAW,EAAEL,gBAAgB,CAACM,IAAjB,IAAyB,EAAA;AAAxD,OAFD,CAAA;AAGHd,MAAAA,WAAW,EAAEe,MAAM,CAACV,cAAD,CAAA;AAHhB,KAAA,CAAA;AADa,GAApB,EAOGD,QAPH,CADF,CAAA;AAWD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur-partner/micro-frontend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/micro-frontend.esm.js",
|
|
@@ -27,9 +27,13 @@
|
|
|
27
27
|
"react-dom": ">=16.8.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@auth0/auth0-spa-js": "1.
|
|
30
|
+
"@auth0/auth0-spa-js": "1.22.1",
|
|
31
31
|
"@entur-partner/permission-client-node": "1.3.4"
|
|
32
32
|
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@entur-partner/util": "^1.1.3",
|
|
35
|
+
"react-query": "^3.39.1"
|
|
36
|
+
},
|
|
33
37
|
"jest": {
|
|
34
38
|
"collectCoverageFrom": [
|
|
35
39
|
"<rootDir>/src/**/*.{js,jsx,ts,tsx}"
|
|
@@ -40,5 +44,5 @@
|
|
|
40
44
|
"reportFile": "jest-sonar-report.xml",
|
|
41
45
|
"indent": 4
|
|
42
46
|
},
|
|
43
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "de1191e2aa269becb99796071546356237943b96"
|
|
44
48
|
}
|