@moh-sso/data-visualizer 1.13.0 → 1.15.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/_types/packages/microfrontend/src/extensions/ExtensionSlot.d.ts +51 -0
- package/dist/_types/packages/microfrontend/src/extensions/access.d.ts +7 -0
- package/dist/_types/packages/microfrontend/src/extensions/context.d.ts +12 -0
- package/dist/_types/packages/microfrontend/src/extensions/instance.d.ts +39 -0
- package/dist/_types/packages/microfrontend/src/extensions/parcel-roots.d.ts +15 -0
- package/dist/_types/packages/microfrontend/src/extensions/react-parcel.d.ts +15 -0
- package/dist/_types/packages/microfrontend/src/extensions/registry.d.ts +36 -0
- package/dist/_types/packages/microfrontend/src/extensions/types.d.ts +176 -0
- package/dist/_types/packages/microfrontend/src/index.d.ts +15 -1
- package/dist/_types/packages/microfrontend/src/props.d.ts +16 -0
- package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +4 -3
- package/package.json +5 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { MountParcel } from "../props";
|
|
3
|
+
import { type ExtensionRegistry } from "./registry";
|
|
4
|
+
import type { ExtensionAccessContext, ExtensionConfigurationLayer, ExtensionDiagnostic, ExtensionFailure, ExtensionRuntimeServices, ExtensionSettings, ResolvedExtensionInstance } from "./types";
|
|
5
|
+
export type ExtensionSlotServices = Omit<ExtensionRuntimeServices, "slotState" | "onRenderError">;
|
|
6
|
+
export type ExtensionSlotErrorProps = {
|
|
7
|
+
instance: ResolvedExtensionInstance;
|
|
8
|
+
failure: ExtensionFailure;
|
|
9
|
+
retry: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type ExtensionSlotProps = {
|
|
12
|
+
/** The registered slot to render. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Accessible name of the slot's region, e.g. "Widgets". */
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* Who is looking. Keep its identity stable (useMemo) and change it when the user,
|
|
18
|
+
* permissions or flags change; the slot re-resolves then.
|
|
19
|
+
*/
|
|
20
|
+
access: ExtensionAccessContext;
|
|
21
|
+
/** Configuration layers, lowest precedence first. Keep the array's identity stable. */
|
|
22
|
+
configuration?: readonly ExtensionConfigurationLayer[];
|
|
23
|
+
/** Runtime services passed to every instance. Keep the object's identity stable. */
|
|
24
|
+
services?: ExtensionSlotServices;
|
|
25
|
+
/** JSON data shared with every instance, e.g. a selected period. */
|
|
26
|
+
slotState?: ExtensionSettings;
|
|
27
|
+
/** Rendered instead of the slot when it has no instances. Nothing by default. */
|
|
28
|
+
fallback?: ReactNode;
|
|
29
|
+
renderLoading?: (instance: ResolvedExtensionInstance) => ReactNode;
|
|
30
|
+
renderError?: (props: ExtensionSlotErrorProps) => ReactNode;
|
|
31
|
+
/** Receives resolution problems (ids and messages only) whenever they change. */
|
|
32
|
+
onDiagnostics?: (diagnostics: readonly ExtensionDiagnostic[]) => void;
|
|
33
|
+
/** Logs resolution problems and instance failures to the console. */
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
itemClassName?: string;
|
|
37
|
+
/** Drop the default responsive grid and style the slot with `className` alone. */
|
|
38
|
+
unstyled?: boolean;
|
|
39
|
+
/** Defaults to the page's registry. */
|
|
40
|
+
registry?: ExtensionRegistry;
|
|
41
|
+
/** Defaults to the enclosing application's mountParcel (orchestrated mode). */
|
|
42
|
+
mountParcel?: MountParcel;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Renders the extension instances configured for a slot, in order. Each instance
|
|
46
|
+
* loads, mounts and fails on its own: one broken extension shows its own error
|
|
47
|
+
* and retry while the others keep working. Instances keep their mounted state
|
|
48
|
+
* across reordering, and are unmounted when they leave the slot or the slot is
|
|
49
|
+
* removed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ExtensionSlot({ name, label, access, configuration, services, slotState, fallback, renderLoading, renderError, onDiagnostics, debug, className, itemClassName, unstyled, registry: registryProp, mountParcel: mountParcelProp, }: ExtensionSlotProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AuthUser } from "../../../auth/src/index.js";
|
|
2
|
+
import type { ExtensionAccessContext } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Access context for a signed-in user, using the same checks as the shell's
|
|
5
|
+
* route guards. Without a user, nothing that has requirements is visible.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createExtensionAccessContext(user: AuthUser | null | undefined, isFeatureEnabled?: (flag: string) => boolean): ExtensionAccessContext;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MountParcel } from "../props";
|
|
2
|
+
/** What an application tells the extension slots rendered inside it. */
|
|
3
|
+
export type ExtensionHostContextValue = {
|
|
4
|
+
/** single-spa's mountParcel in orchestrated mode; undefined in hybrid mode. */
|
|
5
|
+
mountParcel?: MountParcel;
|
|
6
|
+
};
|
|
7
|
+
export declare const ExtensionHostContext: import("react").Context<ExtensionHostContextValue>;
|
|
8
|
+
/**
|
|
9
|
+
* The enclosing application's mountParcel, if single-spa orchestrates it.
|
|
10
|
+
* createReactMicrofrontendLifecycle provides it from the application's props.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useMountParcel(): MountParcel | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MountParcel } from "../props";
|
|
2
|
+
import type { ExtensionFailure, ExtensionMountProps, ExtensionParcel } from "./types";
|
|
3
|
+
export type ExtensionInstanceState = "loading" | "mounting" | "mounted" | "failed" | "unmounted";
|
|
4
|
+
export type MountExtensionInstanceOptions = {
|
|
5
|
+
/** Element the slot gives this instance. The instance mounts into a child element it creates. */
|
|
6
|
+
host: HTMLElement;
|
|
7
|
+
extensionId: string;
|
|
8
|
+
/** Loads the parcel, normally `() => registry.loadExtension(extensionId)`. */
|
|
9
|
+
load: () => Promise<ExtensionParcel>;
|
|
10
|
+
props: ExtensionMountProps;
|
|
11
|
+
/**
|
|
12
|
+
* single-spa's mountParcel from the enclosing orchestrated application. Without
|
|
13
|
+
* it (hybrid mode, or a slot in the shell), lifecycles are called directly.
|
|
14
|
+
*/
|
|
15
|
+
mountParcel?: MountParcel;
|
|
16
|
+
onError?: (failure: ExtensionFailure) => void;
|
|
17
|
+
onStateChange?: (state: ExtensionInstanceState) => void;
|
|
18
|
+
};
|
|
19
|
+
export type ExtensionInstanceHandle = {
|
|
20
|
+
readonly state: ExtensionInstanceState;
|
|
21
|
+
/** Applies new props once mounted; while loading, the mount uses the latest props. */
|
|
22
|
+
update: (props: ExtensionMountProps) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Unmounts and removes the instance's element. Safe at any point, including
|
|
25
|
+
* before the parcel has loaded, and more than once. Resolves when done.
|
|
26
|
+
*/
|
|
27
|
+
unmount: () => Promise<void>;
|
|
28
|
+
/** Settles once the first mount has succeeded or failed (never rejects). */
|
|
29
|
+
readonly ready: Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Loads and mounts one extension instance, and owns it until `unmount`. Every
|
|
33
|
+
* operation runs in order on one queue, so a late load, an update during mount
|
|
34
|
+
* or an unmount at any moment can never leave a mounted parcel or its element
|
|
35
|
+
* behind. Each instance mounts into its own new child element of `host`, so
|
|
36
|
+
* two instances, or a remount racing a previous unmount (React Strict Mode),
|
|
37
|
+
* never share a React root.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mountExtensionInstance(options: MountExtensionInstanceOptions): ExtensionInstanceHandle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtensionMountProps, ExtensionParcel } from "./types";
|
|
2
|
+
/** The part of a React root a parcel needs. */
|
|
3
|
+
export type ParcelRoot<N> = {
|
|
4
|
+
render: (node: N) => void;
|
|
5
|
+
unmount: () => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A parcel that keeps one root per mount element. One parcel object serves every
|
|
9
|
+
* instance of its extension, so roots are never shared between instances.
|
|
10
|
+
* `update` re-renders the same root with new props; `unmount` is idempotent, so a
|
|
11
|
+
* cleanup after a failed mount is always safe.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createParcelRoots<N, P extends ExtensionMountProps = ExtensionMountProps>(createRoot: (element: HTMLElement) => ParcelRoot<N>, render: (props: P) => N): ExtensionParcel<P> & {
|
|
14
|
+
readonly size: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
|
+
import { type ReactLifecycleOptions } from "../react-lifecycle";
|
|
3
|
+
import type { ExtensionMountProps, ExtensionParcel, ExtensionSettings } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Providers each extension root gets. Redux (the page's shared store) and the
|
|
6
|
+
* theme are on by default. Modal, toast and header-panel providers render their
|
|
7
|
+
* own containers, so they are off unless the extension needs them.
|
|
8
|
+
*/
|
|
9
|
+
export type ReactExtensionOptions = ReactLifecycleOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Turns a React component into an extension parcel. Each instance gets its own
|
|
12
|
+
* React root and providers, so instances never share component state; new props
|
|
13
|
+
* re-render the same root (`update`), and `unmount` removes the root.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createReactExtensionParcel<S extends ExtensionSettings = ExtensionSettings>(ExtensionComponent: ComponentType<ExtensionMountProps<S>>, options?: ReactExtensionOptions): ExtensionParcel;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExtensionAccessContext, ExtensionConfigurationLayer, ExtensionDefinition, ExtensionDiagnostic, ExtensionParcel, ExtensionRequirements, SlotDefinition, SlotResolution } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Version of the registry contract. An extension declares the version it was
|
|
4
|
+
* built against; a registry accepts only its own version.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EXTENSION_API_VERSION = 1;
|
|
7
|
+
export type ExtensionRegistry = {
|
|
8
|
+
readonly apiVersion: number;
|
|
9
|
+
/** Registers a slot; returns false (with a diagnostic) if it is rejected. */
|
|
10
|
+
registerSlot: (slot: SlotDefinition) => boolean;
|
|
11
|
+
/** Registers an extension; returns false (with a diagnostic) if it is rejected. */
|
|
12
|
+
registerExtension: (extension: ExtensionDefinition) => boolean;
|
|
13
|
+
getSlot: (name: string) => SlotDefinition | undefined;
|
|
14
|
+
getExtension: (id: string) => ExtensionDefinition | undefined;
|
|
15
|
+
/** Resolves what a slot renders for this user and configuration. */
|
|
16
|
+
resolveSlot: (slot: string, access: ExtensionAccessContext, layers?: readonly ExtensionConfigurationLayer[]) => SlotResolution;
|
|
17
|
+
/**
|
|
18
|
+
* Loads an extension's parcel once and caches it; a failed load is not cached,
|
|
19
|
+
* so a retry loads again. Mount state belongs to each instance, not to this cache.
|
|
20
|
+
*/
|
|
21
|
+
loadExtension: (id: string) => Promise<ExtensionParcel>;
|
|
22
|
+
/** Called after any registration change. Returns an unsubscribe function. */
|
|
23
|
+
subscribe: (listener: () => void) => () => void;
|
|
24
|
+
/** Problems found while registering. */
|
|
25
|
+
getDiagnostics: () => readonly ExtensionDiagnostic[];
|
|
26
|
+
};
|
|
27
|
+
/** Instance id of an extension in a slot: the extension id, plus ":key" for extra instances. */
|
|
28
|
+
export declare function extensionInstanceId(extensionId: string, key?: string): string;
|
|
29
|
+
/** Whether a user may see something with these requirements, as PermissionRoute decides. */
|
|
30
|
+
export declare function meetsExtensionRequirements(requirements: ExtensionRequirements | undefined, access: ExtensionAccessContext): boolean;
|
|
31
|
+
export declare function createExtensionRegistry(): ExtensionRegistry;
|
|
32
|
+
/**
|
|
33
|
+
* The page's one registry, shared by the shell and every module bundle, including
|
|
34
|
+
* modules loaded from the import map with their own copy of this package.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getExtensionRegistry(): ExtensionRegistry;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { EventBus, MicrofrontendRuntimeProps } from "../props";
|
|
2
|
+
/** A JSON value, so settings and configuration stay serializable data. */
|
|
3
|
+
export type ExtensionSettingValue = string | number | boolean | null | readonly ExtensionSettingValue[] | {
|
|
4
|
+
readonly [key: string]: ExtensionSettingValue;
|
|
5
|
+
};
|
|
6
|
+
export type ExtensionSettings = {
|
|
7
|
+
readonly [key: string]: ExtensionSettingValue;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Who may see an extension. Field names and meaning match MicrofrontendRoute and
|
|
11
|
+
* the shell's PermissionRoute: every listed condition must hold.
|
|
12
|
+
*/
|
|
13
|
+
export type ExtensionRequirements = {
|
|
14
|
+
/** All of these permissions. */
|
|
15
|
+
requiredPermissions?: readonly string[];
|
|
16
|
+
/** At least one of these permissions. */
|
|
17
|
+
requiredAnyPermissions?: readonly string[];
|
|
18
|
+
/** Access to every one of these systems. */
|
|
19
|
+
requiredSystems?: readonly string[];
|
|
20
|
+
requiredSystemRoles?: ReadonlyArray<{
|
|
21
|
+
system: string;
|
|
22
|
+
role: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Every one of these feature flags must be enabled. */
|
|
25
|
+
featureFlags?: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
/** What the host knows about the signed-in user, used to filter extensions. */
|
|
28
|
+
export type ExtensionAccessContext = {
|
|
29
|
+
hasAllPermissions: (permissions: readonly string[]) => boolean;
|
|
30
|
+
hasAnyPermission: (permissions: readonly string[]) => boolean;
|
|
31
|
+
hasSystem: (system: string) => boolean;
|
|
32
|
+
hasSystemRole: (system: string, role: string) => boolean;
|
|
33
|
+
/** Absent means no feature flag is enabled. */
|
|
34
|
+
isFeatureEnabled?: (flag: string) => boolean;
|
|
35
|
+
};
|
|
36
|
+
/** A named place in a host screen that renders extension instances. */
|
|
37
|
+
export type SlotDefinition = {
|
|
38
|
+
/** Dotted, stable name, e.g. "admin.home.widgets". */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Package that owns the host screen, e.g. "@moh-sso/shell". */
|
|
41
|
+
owner: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
/** Instances beyond this many, after ordering, are not rendered. */
|
|
44
|
+
maxInstances?: number;
|
|
45
|
+
};
|
|
46
|
+
/** Which instance is mounting, and its resolved settings. */
|
|
47
|
+
export type ExtensionInstanceProps<S extends ExtensionSettings = ExtensionSettings> = {
|
|
48
|
+
extensionId: string;
|
|
49
|
+
instanceId: string;
|
|
50
|
+
slotName: string;
|
|
51
|
+
settings: S;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Services the host passes to every instance. A parcel renders in its own React
|
|
55
|
+
* root, outside the host's React tree, so it gets these as props, never by
|
|
56
|
+
* reaching into the host's contexts or router.
|
|
57
|
+
*/
|
|
58
|
+
export type ExtensionRuntimeServices = {
|
|
59
|
+
auth?: MicrofrontendRuntimeProps["auth"];
|
|
60
|
+
apiBaseUrl?: string;
|
|
61
|
+
eventBus?: EventBus;
|
|
62
|
+
healthContext?: MicrofrontendRuntimeProps["healthContext"];
|
|
63
|
+
/** Navigate the portal to a path, through the host's router. */
|
|
64
|
+
navigate?: (to: string) => void;
|
|
65
|
+
/** Data the host shares with every instance in the slot, e.g. a selected period. */
|
|
66
|
+
slotState?: ExtensionSettings;
|
|
67
|
+
/** Reports an error a parcel caught while rendering; filled in by the mounting adapter. */
|
|
68
|
+
onRenderError?: (error: unknown) => void;
|
|
69
|
+
};
|
|
70
|
+
/** Everything a parcel lifecycle receives, apart from the element it mounts into. */
|
|
71
|
+
export type ExtensionMountProps<S extends ExtensionSettings = ExtensionSettings> = ExtensionInstanceProps<S> & ExtensionRuntimeServices;
|
|
72
|
+
/**
|
|
73
|
+
* The single-spa parcel an extension's `load` resolves to. `mount` and `unmount`
|
|
74
|
+
* are required. Without `update`, the host unmounts and remounts the instance
|
|
75
|
+
* when its props change. One parcel object serves every instance of its
|
|
76
|
+
* extension at once, so it keeps per-instance state by `domElement`.
|
|
77
|
+
*/
|
|
78
|
+
export type ExtensionParcel<P extends ExtensionMountProps = ExtensionMountProps> = {
|
|
79
|
+
bootstrap?: (props: P) => Promise<void> | void;
|
|
80
|
+
mount: (props: P & {
|
|
81
|
+
domElement: HTMLElement;
|
|
82
|
+
}) => Promise<void> | void;
|
|
83
|
+
unmount: (props: P & {
|
|
84
|
+
domElement: HTMLElement;
|
|
85
|
+
}) => Promise<void> | void;
|
|
86
|
+
update?: (props: P & {
|
|
87
|
+
domElement: HTMLElement;
|
|
88
|
+
}) => Promise<void> | void;
|
|
89
|
+
};
|
|
90
|
+
/** Where an extension appears when no configuration says otherwise. */
|
|
91
|
+
export type ExtensionDefaultSlot = {
|
|
92
|
+
slot: string;
|
|
93
|
+
/** Distinguishes several default instances of one extension in a slot. */
|
|
94
|
+
key?: string;
|
|
95
|
+
order?: number;
|
|
96
|
+
settings?: ExtensionSettings;
|
|
97
|
+
};
|
|
98
|
+
export type ExtensionDefinition = {
|
|
99
|
+
/** Dotted, stable id, e.g. "report-scheduler.scheduled-reports-summary". */
|
|
100
|
+
id: string;
|
|
101
|
+
/** Package that provides the extension. */
|
|
102
|
+
module: string;
|
|
103
|
+
/** EXTENSION_API_VERSION the extension was built against. */
|
|
104
|
+
apiVersion: number;
|
|
105
|
+
title: string;
|
|
106
|
+
requirements?: ExtensionRequirements;
|
|
107
|
+
defaultSettings?: ExtensionSettings;
|
|
108
|
+
/** Returns problems with the merged settings; any problem hides the instance. */
|
|
109
|
+
validateSettings?: (settings: ExtensionSettings) => readonly string[];
|
|
110
|
+
defaultSlots?: readonly ExtensionDefaultSlot[];
|
|
111
|
+
/** Loads the extension's UI. Called only for instances the user may see. */
|
|
112
|
+
load: () => Promise<ExtensionParcel>;
|
|
113
|
+
};
|
|
114
|
+
/** One configuration change set for a slot. Applied as remove, add, configure, order. */
|
|
115
|
+
export type SlotConfiguration = {
|
|
116
|
+
/** Instance ids to remove. */
|
|
117
|
+
remove?: readonly string[];
|
|
118
|
+
add?: ReadonlyArray<{
|
|
119
|
+
extension: string;
|
|
120
|
+
key?: string;
|
|
121
|
+
order?: number;
|
|
122
|
+
settings?: ExtensionSettings;
|
|
123
|
+
}>;
|
|
124
|
+
/** Settings merged (shallowly) onto an instance's current settings. */
|
|
125
|
+
configure?: {
|
|
126
|
+
readonly [instanceId: string]: ExtensionSettings;
|
|
127
|
+
};
|
|
128
|
+
/** New order for existing instances. */
|
|
129
|
+
order?: {
|
|
130
|
+
readonly [instanceId: string]: number;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Configuration from one source. Layers are applied in the order given, after
|
|
135
|
+
* the extensions' own defaults, so a later layer overrides an earlier one.
|
|
136
|
+
*/
|
|
137
|
+
export type ExtensionConfigurationLayer = {
|
|
138
|
+
/** Where this layer comes from, e.g. "deployment"; used in diagnostics. */
|
|
139
|
+
source: string;
|
|
140
|
+
slots: {
|
|
141
|
+
readonly [slotName: string]: SlotConfiguration;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/** An instance a slot should render, in order. */
|
|
145
|
+
export type ResolvedExtensionInstance = {
|
|
146
|
+
instanceId: string;
|
|
147
|
+
extensionId: string;
|
|
148
|
+
module: string;
|
|
149
|
+
title: string;
|
|
150
|
+
order: number | undefined;
|
|
151
|
+
settings: ExtensionSettings;
|
|
152
|
+
};
|
|
153
|
+
export type ExtensionDiagnosticCode = "incompatible-api-version" | "duplicate-extension" | "duplicate-slot" | "invalid-definition" | "unknown-slot" | "unknown-extension" | "unknown-instance" | "duplicate-instance" | "invalid-settings" | "slot-full";
|
|
154
|
+
/** A problem found while registering or resolving. Never contains user data or tokens. */
|
|
155
|
+
export type ExtensionDiagnostic = {
|
|
156
|
+
code: ExtensionDiagnosticCode;
|
|
157
|
+
message: string;
|
|
158
|
+
slot?: string;
|
|
159
|
+
extensionId?: string;
|
|
160
|
+
instanceId?: string;
|
|
161
|
+
source?: string;
|
|
162
|
+
};
|
|
163
|
+
export type SlotResolution = {
|
|
164
|
+
slot: string;
|
|
165
|
+
instances: ResolvedExtensionInstance[];
|
|
166
|
+
/** Instances configured for the slot that the user may not see. */
|
|
167
|
+
hiddenByAccess: string[];
|
|
168
|
+
diagnostics: ExtensionDiagnostic[];
|
|
169
|
+
};
|
|
170
|
+
/** Why an instance failed; used by slot hosts to show per-instance errors. */
|
|
171
|
+
export type ExtensionFailure = {
|
|
172
|
+
stage: "load" | "bootstrap" | "mount" | "update" | "unmount" | "render";
|
|
173
|
+
extensionId: string;
|
|
174
|
+
instanceId?: string;
|
|
175
|
+
error: unknown;
|
|
176
|
+
};
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
export type { AppEvent, EventBus, MicrofrontendMountProps, MicrofrontendRuntimeProps, } from "./props";
|
|
1
|
+
export type { AppEvent, EventBus, MicrofrontendMountProps, MicrofrontendRuntimeProps, MountParcel, SingleSpaParcel, } from "./props";
|
|
2
2
|
export type { MicrofrontendLifecycle } from "./lifecycle";
|
|
3
3
|
export type { MicrofrontendRoute } from "./routes";
|
|
4
4
|
export { resolveRuntimeBasename } from "./basename";
|
|
5
5
|
export { createReactMicrofrontendLifecycle } from "./react-lifecycle";
|
|
6
6
|
export { MICROFRONTEND_NAVIGATION_EVENT, notifyMicrofrontendNavigation } from "./navigation";
|
|
7
|
+
export type { ExtensionAccessContext, ExtensionConfigurationLayer, ExtensionDefaultSlot, ExtensionDefinition, ExtensionDiagnostic, ExtensionDiagnosticCode, ExtensionFailure, ExtensionInstanceProps, ExtensionMountProps, ExtensionParcel, ExtensionRequirements, ExtensionRuntimeServices, ExtensionSettings, ExtensionSettingValue, ResolvedExtensionInstance, SlotConfiguration, SlotDefinition, SlotResolution, } from "./extensions/types";
|
|
8
|
+
export type { ExtensionRegistry } from "./extensions/registry";
|
|
9
|
+
export { EXTENSION_API_VERSION, createExtensionRegistry, extensionInstanceId, getExtensionRegistry, meetsExtensionRequirements, } from "./extensions/registry";
|
|
10
|
+
export { createExtensionAccessContext } from "./extensions/access";
|
|
11
|
+
export type { ExtensionInstanceHandle, ExtensionInstanceState, MountExtensionInstanceOptions, } from "./extensions/instance";
|
|
12
|
+
export { mountExtensionInstance } from "./extensions/instance";
|
|
13
|
+
export type { ParcelRoot } from "./extensions/parcel-roots";
|
|
14
|
+
export { createParcelRoots } from "./extensions/parcel-roots";
|
|
15
|
+
export type { ReactExtensionOptions } from "./extensions/react-parcel";
|
|
16
|
+
export { createReactExtensionParcel } from "./extensions/react-parcel";
|
|
17
|
+
export type { ExtensionHostContextValue } from "./extensions/context";
|
|
18
|
+
export { ExtensionHostContext, useMountParcel } from "./extensions/context";
|
|
19
|
+
export type { ExtensionSlotErrorProps, ExtensionSlotProps, ExtensionSlotServices, } from "./extensions/ExtensionSlot";
|
|
20
|
+
export { ExtensionSlot } from "./extensions/ExtensionSlot";
|
|
@@ -7,8 +7,24 @@ export type EventBus = {
|
|
|
7
7
|
publish: (event: AppEvent) => void;
|
|
8
8
|
subscribe: (type: string, handler: (event: AppEvent) => void) => () => void;
|
|
9
9
|
};
|
|
10
|
+
/** A parcel mounted by single-spa's mountParcel. */
|
|
11
|
+
export type SingleSpaParcel = {
|
|
12
|
+
mountPromise: Promise<unknown>;
|
|
13
|
+
unmount: () => Promise<unknown>;
|
|
14
|
+
update?: (props: Record<string, unknown>) => Promise<unknown>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* single-spa's application-bound mountParcel. In orchestrated mode single-spa
|
|
18
|
+
* passes it to every application, and the parcels it mounts are unmounted with
|
|
19
|
+
* that application.
|
|
20
|
+
*/
|
|
21
|
+
export type MountParcel = (config: object, props: Record<string, unknown> & {
|
|
22
|
+
domElement: HTMLElement;
|
|
23
|
+
}) => SingleSpaParcel;
|
|
10
24
|
export type MicrofrontendRuntimeProps = {
|
|
11
25
|
basename: string;
|
|
26
|
+
/** Set in orchestrated mode; extension slots inside the app mount through it. */
|
|
27
|
+
mountParcel?: MountParcel;
|
|
12
28
|
auth?: {
|
|
13
29
|
isAuthenticated: boolean;
|
|
14
30
|
user?: unknown;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { ComponentType } from "react";
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import type { MicrofrontendLifecycle } from "./lifecycle";
|
|
3
4
|
import type { MicrofrontendRuntimeProps } from "./props";
|
|
4
|
-
type ReactLifecycleOptions = {
|
|
5
|
+
export type ReactLifecycleOptions = {
|
|
5
6
|
withRedux?: boolean;
|
|
6
7
|
withModal?: boolean;
|
|
7
8
|
withToast?: boolean;
|
|
8
9
|
withHeaderPanel?: boolean;
|
|
9
10
|
};
|
|
11
|
+
export declare function withProviders(children: ReactNode, options: Required<ReactLifecycleOptions>): React.JSX.Element;
|
|
10
12
|
export declare function createReactMicrofrontendLifecycle(RootComponent: ComponentType<MicrofrontendRuntimeProps>, lifecycleOptions?: ReactLifecycleOptions): MicrofrontendLifecycle;
|
|
11
|
-
export {};
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"import": "./dist/routes.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"version": "1.
|
|
20
|
+
"version": "1.15.0",
|
|
21
21
|
"license": "UNLICENSED",
|
|
22
22
|
"module": "./dist/index.js",
|
|
23
23
|
"files": [
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@moh-sso/api": "^1.
|
|
38
|
-
"@moh-sso/config": "^1.
|
|
39
|
-
"@moh-sso/microfrontend": "^1.
|
|
40
|
-
"@moh-sso/ui": "^1.
|
|
37
|
+
"@moh-sso/api": "^1.16.0",
|
|
38
|
+
"@moh-sso/config": "^1.16.0",
|
|
39
|
+
"@moh-sso/microfrontend": "^1.16.0",
|
|
40
|
+
"@moh-sso/ui": "^1.16.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@carbon/react": "^1.95.0",
|