@openmrs/esm-extensions 3.4.1-pre.96 → 4.0.0-pre.1
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/.turbo/turbo-build.log +14 -14
- package/.turbo/turbo-lint.log +2 -0
- package/.turbo/turbo-test.log +11 -0
- package/.turbo/turbo-typescript.log +2 -0
- package/dist/extensions.d.ts +73 -0
- package/dist/extensions.test.d.ts +1 -0
- package/dist/helpers.d.ts +3 -0
- package/dist/index.d.ts +7 -0
- package/dist/public.d.ts +3 -0
- package/dist/render.d.ts +11 -0
- package/dist/store.d.ts +87 -0
- package/jest.config.js +1 -0
- package/package.json +8 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
[34m@openmrs/esm-extensions:build: [0mcache hit, replaying output [
|
|
1
|
+
[34m@openmrs/esm-extensions:build: [0mcache hit, replaying output [2m0a81417206c990fd[0m
|
|
2
2
|
[34m@openmrs/esm-extensions:build: [0m$ webpack --mode=production
|
|
3
|
-
[34m@openmrs/esm-extensions:build: [0masset
|
|
4
|
-
[34m@openmrs/esm-extensions:build: [0morphan modules 88 KiB
|
|
3
|
+
[34m@openmrs/esm-extensions:build: [0masset openmrs-esm-extensions.js 22.5 KiB [emitted] [minimized] (name: main) 1 related asset
|
|
4
|
+
[34m@openmrs/esm-extensions:build: [0morphan modules 88 KiB [orphan] 93 modules
|
|
5
5
|
[34m@openmrs/esm-extensions:build: [0mruntime modules 1.76 KiB 6 modules
|
|
6
|
-
[34m@openmrs/esm-extensions:build: [0mbuilt modules 91.8 KiB
|
|
6
|
+
[34m@openmrs/esm-extensions:build: [0mbuilt modules 91.8 KiB [built]
|
|
7
7
|
[34m@openmrs/esm-extensions:build: [0m cacheable modules 91.7 KiB
|
|
8
|
-
[34m@openmrs/esm-extensions:build: [0m modules by path
|
|
9
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
10
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
11
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
12
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
13
|
-
[34m@openmrs/esm-extensions:build: [0m modules by path
|
|
14
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
15
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
16
|
-
[34m@openmrs/esm-extensions:build: [0m
|
|
17
|
-
[34m@openmrs/esm-extensions:build: [0mwebpack 5.70.0 compiled
|
|
8
|
+
[34m@openmrs/esm-extensions:build: [0m modules by path ../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js 935 bytes
|
|
9
|
+
[34m@openmrs/esm-extensions:build: [0m ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
|
|
10
|
+
[34m@openmrs/esm-extensions:build: [0m ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
|
|
11
|
+
[34m@openmrs/esm-extensions:build: [0m ./src/index.ts + 93 modules 88.4 KiB [built] [code generated]
|
|
12
|
+
[34m@openmrs/esm-extensions:build: [0m ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
|
|
13
|
+
[34m@openmrs/esm-extensions:build: [0m modules by path external "@openmrs/ 84 bytes
|
|
14
|
+
[34m@openmrs/esm-extensions:build: [0m external "@openmrs/esm-config" 42 bytes [built] [code generated]
|
|
15
|
+
[34m@openmrs/esm-extensions:build: [0m external "@openmrs/esm-state" 42 bytes [built] [code generated]
|
|
16
|
+
[34m@openmrs/esm-extensions:build: [0m external "single-spa" 42 bytes [built] [code generated]
|
|
17
|
+
[34m@openmrs/esm-extensions:build: [0mwebpack 5.70.0 compiled successfully in 14185 ms
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[33m@openmrs/esm-extensions:test: [0mcache hit, replaying output [2mf89b505cbba66733[0m
|
|
2
|
+
[33m@openmrs/esm-extensions:test: [0m$ jest --config jest.config.js --passWithNoTests
|
|
3
|
+
[33m@openmrs/esm-extensions:test: [0mPASS src/extensions.test.ts
|
|
4
|
+
[33m@openmrs/esm-extensions:test: [0m extensions system
|
|
5
|
+
[33m@openmrs/esm-extensions:test: [0m ✓ shouldn't crash when a slot is registered before the extensions that go in it (30 ms)
|
|
6
|
+
[33m@openmrs/esm-extensions:test: [0m
|
|
7
|
+
[33m@openmrs/esm-extensions:test: [0mTest Suites: 1 passed, 1 total
|
|
8
|
+
[33m@openmrs/esm-extensions:test: [0mTests: 1 passed, 1 total
|
|
9
|
+
[33m@openmrs/esm-extensions:test: [0mSnapshots: 0 total
|
|
10
|
+
[33m@openmrs/esm-extensions:test: [0mTime: 6.626 s
|
|
11
|
+
[33m@openmrs/esm-extensions:test: [0mRan all test suites.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** @module @category Extension */
|
|
2
|
+
import { AssignedExtension, ConnectedExtension } from ".";
|
|
3
|
+
import { ExtensionRegistration, ExtensionInternalStore } from "./store";
|
|
4
|
+
/**
|
|
5
|
+
* Given an extension ID, which is a string uniquely identifying
|
|
6
|
+
* an instance of an extension within an extension slot, this
|
|
7
|
+
* returns the extension name.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* getExtensionNameFromId("foo#bar")
|
|
12
|
+
* --> "foo"
|
|
13
|
+
* getExtensionNameFromId("baz")
|
|
14
|
+
* --> "baz"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function getExtensionNameFromId(extensionId: string): string;
|
|
18
|
+
export declare function getExtensionRegistrationFrom(state: ExtensionInternalStore, extensionId: string): ExtensionRegistration | undefined;
|
|
19
|
+
export declare function getExtensionRegistration(extensionId: string): ExtensionRegistration | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Extensions must be registered in order to be rendered.
|
|
22
|
+
* This is handled by the app shell, when extensions are provided
|
|
23
|
+
* via the `setupOpenMRS` return object.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const registerExtension: (extensionRegistration: ExtensionRegistration) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Attach an extension to an extension slot.
|
|
29
|
+
*
|
|
30
|
+
* This will cause the extension to be rendered into the specified
|
|
31
|
+
* extension slot, unless it is removed by configuration. Using
|
|
32
|
+
* `attach` is an alternative to specifying the `slot` or `slots`
|
|
33
|
+
* in the extension declaration.
|
|
34
|
+
*
|
|
35
|
+
* It is particularly useful when creating a slot into which
|
|
36
|
+
* you want to render an existing extension. This enables you
|
|
37
|
+
* to do so without modifying the extension's declaration, which
|
|
38
|
+
* may be impractical or inappropriate, for example if you are
|
|
39
|
+
* writing a module for a specific implementation.
|
|
40
|
+
*
|
|
41
|
+
* @param slotName a name uniquely identifying the slot
|
|
42
|
+
* @param extensionId an extension name, with an optional #-suffix
|
|
43
|
+
* to distinguish it from other instances of the same extension
|
|
44
|
+
* attached to the same slot.
|
|
45
|
+
*/
|
|
46
|
+
export declare function attach(slotName: string, extensionId: string): void;
|
|
47
|
+
/** Avoid using this. Extension attachments should be considered declarative. */
|
|
48
|
+
export declare function detach(extensionSlotName: string, extensionId: string): void;
|
|
49
|
+
/** Avoid using this. Extension attachments should be considered declarative. */
|
|
50
|
+
export declare function detachAll(extensionSlotName: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Filters a list of extensions according to whether they support the
|
|
53
|
+
* current connectivity status.
|
|
54
|
+
*
|
|
55
|
+
* @param assignedExtensions The list of extensions to filter.
|
|
56
|
+
* @param online Whether the app is currently online. If `null`, uses `navigator.onLine`.
|
|
57
|
+
* @returns A list of extensions that should be rendered
|
|
58
|
+
*/
|
|
59
|
+
export declare function getConnectedExtensions(assignedExtensions: Array<AssignedExtension>, online?: boolean | null): Array<ConnectedExtension>;
|
|
60
|
+
export declare function getAssignedExtensions(slotName: string): Array<AssignedExtension>;
|
|
61
|
+
/**
|
|
62
|
+
* Used by by extension slots at mount time.
|
|
63
|
+
*
|
|
64
|
+
* @param moduleName The name of the module that contains the extension slot
|
|
65
|
+
* @param slotName The extension slot name that is actually used
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare const registerExtensionSlot: (moduleName: string, slotName: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
* Just for testing.
|
|
72
|
+
*/
|
|
73
|
+
export declare const reset: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function checkStatus(online?: boolean | object, offline?: boolean | object): boolean;
|
|
2
|
+
export declare function checkStatusFor(status: boolean, online?: boolean | object, offline?: boolean | object): boolean;
|
|
3
|
+
export declare function getCustomProps(online: boolean | object | undefined, offline: boolean | object | undefined): object;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./store";
|
|
2
|
+
export * from "./extensions";
|
|
3
|
+
export * from "./helpers";
|
|
4
|
+
export * from "./render";
|
|
5
|
+
/** @deprecated Use `getExtensionStore`. The structure of this store has also changed. */
|
|
6
|
+
declare const internalStore: import("unistore").Store<import("./store").ExtensionInternalStore>;
|
|
7
|
+
export { internalStore as extensionStore };
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getExtensionNameFromId, registerExtension, attach, detach, detachAll, getConnectedExtensions, getAssignedExtensions, registerExtensionSlot, } from "./extensions";
|
|
2
|
+
export { renderExtension, CancelLoading } from "./render";
|
|
3
|
+
export { ExtensionMeta, ExtensionRegistration, AssignedExtension, ConnectedExtension, ExtensionStore, ExtensionSlotState, getExtensionStore, } from "./store";
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @module @category Extension */
|
|
2
|
+
import { Lifecycle } from "@openmrs/esm-globals";
|
|
3
|
+
export interface CancelLoading {
|
|
4
|
+
(): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Mounts into a DOM node (representing an extension slot)
|
|
8
|
+
* a lazy-loaded component from *any* frontend module
|
|
9
|
+
* that registered an extension component for this slot.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderExtension(domElement: HTMLElement, extensionSlotName: string, extensionSlotModuleName: string, extensionId: string, renderFunction?: (lifecycle: Lifecycle) => Lifecycle, additionalProps?: Record<string, any>): CancelLoading;
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ConfigObject, ExtensionSlotConfigObject } from "@openmrs/esm-config";
|
|
2
|
+
export interface ExtensionMeta {
|
|
3
|
+
[_: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface ExtensionRegistration {
|
|
6
|
+
name: string;
|
|
7
|
+
load(): Promise<any>;
|
|
8
|
+
moduleName: string;
|
|
9
|
+
meta: ExtensionMeta;
|
|
10
|
+
order?: number;
|
|
11
|
+
online?: boolean | object;
|
|
12
|
+
offline?: boolean | object;
|
|
13
|
+
}
|
|
14
|
+
export interface ExtensionInfo extends ExtensionRegistration {
|
|
15
|
+
/**
|
|
16
|
+
* The instances where the extension has been rendered using `renderExtension`.
|
|
17
|
+
*/
|
|
18
|
+
instances: Array<ExtensionInstance>;
|
|
19
|
+
}
|
|
20
|
+
export interface ExtensionInstance {
|
|
21
|
+
id: string;
|
|
22
|
+
slotName: string;
|
|
23
|
+
slotModuleName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ExtensionInternalStore {
|
|
26
|
+
/** Slots indexed by name */
|
|
27
|
+
slots: Record<string, ExtensionSlotInfo>;
|
|
28
|
+
/** Extensions indexed by name */
|
|
29
|
+
extensions: Record<string, ExtensionInfo>;
|
|
30
|
+
}
|
|
31
|
+
export interface ExtensionSlotInfo {
|
|
32
|
+
/**
|
|
33
|
+
* The module in which the extension slot exists. Undefined if the slot
|
|
34
|
+
* hasn't been registered yet (but it has been attached or assigned to
|
|
35
|
+
* an extension.
|
|
36
|
+
*/
|
|
37
|
+
moduleName?: string;
|
|
38
|
+
/** The name under which the extension slot has been registered. */
|
|
39
|
+
name: string;
|
|
40
|
+
/**
|
|
41
|
+
* The set of extension IDs which have been attached to this slot using `attach`.
|
|
42
|
+
* However, not all of these extension IDs should be rendered.
|
|
43
|
+
* `assignedIds` is the set defining those.
|
|
44
|
+
*/
|
|
45
|
+
attachedIds: Array<string>;
|
|
46
|
+
/** The configuration provided for this slot. `null` if not yet loaded. */
|
|
47
|
+
config: ExtensionSlotConfigObject | null;
|
|
48
|
+
}
|
|
49
|
+
export interface ExtensionStore {
|
|
50
|
+
slots: Record<string, ExtensionSlotState>;
|
|
51
|
+
}
|
|
52
|
+
export interface ExtensionSlotState {
|
|
53
|
+
moduleName?: string;
|
|
54
|
+
assignedExtensions: Array<AssignedExtension>;
|
|
55
|
+
}
|
|
56
|
+
export interface AssignedExtension {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
moduleName: string;
|
|
60
|
+
meta: ExtensionMeta;
|
|
61
|
+
/** The extension's config. Note that this will be `null` until the slot is mounted. */
|
|
62
|
+
config: ConfigObject | null;
|
|
63
|
+
online?: boolean | object;
|
|
64
|
+
offline?: boolean | object;
|
|
65
|
+
}
|
|
66
|
+
export interface ConnectedExtension {
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
meta: ExtensionMeta;
|
|
70
|
+
/** The extension's config. Note that this will be `null` until the slot is mounted. */
|
|
71
|
+
config: ConfigObject | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* This gets the extension system's internal store. It is subject
|
|
75
|
+
* to change radically and without warning. It should not be used
|
|
76
|
+
* outside esm-core.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare const getExtensionInternalStore: () => import("unistore").Store<ExtensionInternalStore>;
|
|
80
|
+
/** @internal */
|
|
81
|
+
export declare function updateInternalExtensionStore(updater: (state: ExtensionInternalStore) => ExtensionInternalStore): void;
|
|
82
|
+
/**
|
|
83
|
+
* This returns a [store](https://github.com/developit/unistore#store)
|
|
84
|
+
* that modules can use to get information about the state of the
|
|
85
|
+
* extension system.
|
|
86
|
+
*/
|
|
87
|
+
export declare const getExtensionStore: () => import("unistore").Store<ExtensionStore>;
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-extensions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-pre.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Coordinates extensions and extension points in the OpenMRS Frontend",
|
|
6
6
|
"browser": "dist/openmrs-esm-extensions.js",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@openmrs/esm-api": "
|
|
40
|
-
"@openmrs/esm-config": "
|
|
41
|
-
"@openmrs/esm-state": "
|
|
39
|
+
"@openmrs/esm-api": "4.x",
|
|
40
|
+
"@openmrs/esm-config": "4.x",
|
|
41
|
+
"@openmrs/esm-state": "4.x",
|
|
42
42
|
"single-spa": "5.x"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@openmrs/esm-api": "^
|
|
46
|
-
"@openmrs/esm-config": "^
|
|
47
|
-
"@openmrs/esm-state": "^
|
|
45
|
+
"@openmrs/esm-api": "^4.0.0-pre.1",
|
|
46
|
+
"@openmrs/esm-config": "^4.0.0-pre.1",
|
|
47
|
+
"@openmrs/esm-state": "^4.0.0-pre.1",
|
|
48
48
|
"single-spa": "^5.9.2"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"lodash-es": "^4.17.21"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9f58b801f07526083a9edc1cc5a1e58660d71eb0"
|
|
54
54
|
}
|