repluggable-core 0.0.0-pr280.413 → 0.0.0-pr282.418
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/__tests__/spec-setup.js +3 -0
- package/dist/es/{API.d.ts → src/API.d.ts} +31 -10
- package/dist/es/src/API.d.ts.map +1 -0
- package/dist/es/src/API.js +2 -0
- package/dist/es/src/API.js.map +1 -0
- package/dist/es/src/IterableWeakMap.d.ts +20 -0
- package/dist/es/src/IterableWeakMap.d.ts.map +1 -0
- package/dist/es/src/IterableWeakMap.js +92 -0
- package/dist/es/src/IterableWeakMap.js.map +1 -0
- package/dist/es/src/appHost.d.ts +7 -0
- package/dist/es/src/appHost.d.ts.map +1 -0
- package/dist/es/src/appHost.js +848 -0
- package/dist/es/src/appHost.js.map +1 -0
- package/dist/es/src/appHostServices.d.ts +12 -0
- package/dist/es/src/appHostServices.d.ts.map +1 -0
- package/dist/es/src/appHostServices.js +25 -0
- package/dist/es/src/appHostServices.js.map +1 -0
- package/dist/es/src/appHostUtils.d.ts +4 -0
- package/dist/es/src/appHostUtils.d.ts.map +1 -0
- package/dist/es/src/appHostUtils.js +8 -0
- package/dist/es/src/appHostUtils.js.map +1 -0
- package/dist/es/src/extensionSlot.d.ts +8 -0
- package/dist/es/src/extensionSlot.d.ts.map +1 -0
- package/dist/es/src/extensionSlot.js +59 -0
- package/dist/es/src/extensionSlot.js.map +1 -0
- package/dist/es/src/hot.d.ts +14 -0
- package/dist/es/src/hot.d.ts.map +1 -0
- package/dist/es/src/hot.js +52 -0
- package/dist/es/src/hot.js.map +1 -0
- package/dist/es/src/index.d.ts +11 -0
- package/dist/es/src/index.d.ts.map +1 -0
- package/dist/es/src/index.js +10 -0
- package/dist/es/src/index.js.map +1 -0
- package/dist/es/src/installedShellsState.d.ts +19 -0
- package/dist/es/src/installedShellsState.d.ts.map +1 -0
- package/dist/es/src/installedShellsState.js +30 -0
- package/dist/es/src/installedShellsState.js.map +1 -0
- package/dist/es/src/interceptAnyObject.d.ts +7 -0
- package/dist/es/src/interceptAnyObject.d.ts.map +1 -0
- package/dist/es/src/interceptAnyObject.js +21 -0
- package/dist/es/src/interceptAnyObject.js.map +1 -0
- package/dist/es/src/interceptEntryPoints.d.ts +6 -0
- package/dist/es/src/interceptEntryPoints.d.ts.map +1 -0
- package/dist/es/src/interceptEntryPoints.js +22 -0
- package/dist/es/src/interceptEntryPoints.js.map +1 -0
- package/dist/es/src/invokeSlotCallbacks.d.ts +3 -0
- package/dist/es/src/invokeSlotCallbacks.d.ts.map +1 -0
- package/dist/es/src/invokeSlotCallbacks.js +20 -0
- package/dist/es/src/invokeSlotCallbacks.js.map +1 -0
- package/dist/es/src/loggers.d.ts +4 -0
- package/dist/es/src/loggers.d.ts.map +1 -0
- package/dist/es/src/loggers.js +100 -0
- package/dist/es/src/loggers.js.map +1 -0
- package/dist/es/src/monitorAPI.d.ts +3 -0
- package/dist/es/src/monitorAPI.d.ts.map +1 -0
- package/dist/es/src/monitorAPI.js +53 -0
- package/dist/es/src/monitorAPI.js.map +1 -0
- package/dist/es/src/repluggableAppDebug/index.d.ts +2 -0
- package/dist/es/src/repluggableAppDebug/index.d.ts.map +1 -0
- package/dist/es/src/repluggableAppDebug/index.js +2 -0
- package/dist/es/src/repluggableAppDebug/index.js.map +1 -0
- package/dist/es/src/repluggableAppDebug/performanceDebugInfo.d.ts +15 -0
- package/dist/es/src/repluggableAppDebug/performanceDebugInfo.d.ts.map +1 -0
- package/dist/es/src/repluggableAppDebug/performanceDebugInfo.js +94 -0
- package/dist/es/src/repluggableAppDebug/performanceDebugInfo.js.map +1 -0
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts +24 -0
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +1 -0
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js +132 -0
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js.map +1 -0
- package/dist/es/src/tarjanGraph.d.ts +27 -0
- package/dist/es/src/tarjanGraph.d.ts.map +1 -0
- package/dist/es/src/tarjanGraph.js +94 -0
- package/dist/es/src/tarjanGraph.js.map +1 -0
- package/dist/es/src/throttledStore.d.ts +32 -0
- package/dist/es/src/throttledStore.d.ts.map +1 -0
- package/dist/es/src/throttledStore.js +240 -0
- package/dist/es/src/throttledStore.js.map +1 -0
- package/dist/es/test/IterableWeakMap.spec.d.ts +2 -0
- package/dist/es/test/IterableWeakMap.spec.d.ts.map +1 -0
- package/dist/es/test/IterableWeakMap.spec.js +218 -0
- package/dist/es/test/IterableWeakMap.spec.js.map +1 -0
- package/dist/es/test/appHost.mock.d.ts +4 -0
- package/dist/es/test/appHost.mock.d.ts.map +1 -0
- package/dist/es/test/appHost.mock.js +54 -0
- package/dist/es/test/appHost.mock.js.map +1 -0
- package/dist/es/test/appHost.spec.d.ts +2 -0
- package/dist/es/test/appHost.spec.d.ts.map +1 -0
- package/dist/es/test/appHost.spec.js +1323 -0
- package/dist/es/test/appHost.spec.js.map +1 -0
- package/dist/es/test/customExtensionSlot.spec.d.ts +2 -0
- package/dist/es/test/customExtensionSlot.spec.d.ts.map +1 -0
- package/dist/es/test/customExtensionSlot.spec.js +112 -0
- package/dist/es/test/customExtensionSlot.spec.js.map +1 -0
- package/dist/es/test/extensionSlot.spec.d.ts +2 -0
- package/dist/es/test/extensionSlot.spec.d.ts.map +1 -0
- package/dist/es/test/extensionSlot.spec.js +73 -0
- package/dist/es/test/extensionSlot.spec.js.map +1 -0
- package/dist/es/test/installedShellsState.spec.d.ts +2 -0
- package/dist/es/test/installedShellsState.spec.d.ts.map +1 -0
- package/dist/es/test/installedShellsState.spec.js +28 -0
- package/dist/es/test/installedShellsState.spec.js.map +1 -0
- package/dist/es/test/interceptAnyObject.spec.d.ts +2 -0
- package/dist/es/test/interceptAnyObject.spec.d.ts.map +1 -0
- package/dist/es/test/interceptAnyObject.spec.js +166 -0
- package/dist/es/test/interceptAnyObject.spec.js.map +1 -0
- package/dist/es/test/interceptEntryPoints.spec.d.ts +2 -0
- package/dist/es/test/interceptEntryPoints.spec.d.ts.map +1 -0
- package/dist/es/test/interceptEntryPoints.spec.js +244 -0
- package/dist/es/test/interceptEntryPoints.spec.js.map +1 -0
- package/dist/es/test/loggers.spec.d.ts +2 -0
- package/dist/es/test/loggers.spec.d.ts.map +1 -0
- package/dist/es/test/loggers.spec.js +218 -0
- package/dist/es/test/loggers.spec.js.map +1 -0
- package/dist/es/test/repluggableAppDebug.spec.d.ts +2 -0
- package/dist/es/test/repluggableAppDebug.spec.d.ts.map +1 -0
- package/dist/es/test/repluggableAppDebug.spec.js +107 -0
- package/dist/es/test/repluggableAppDebug.spec.js.map +1 -0
- package/dist/es/test/testKit.spec.d.ts +2 -0
- package/dist/es/test/testKit.spec.d.ts.map +1 -0
- package/dist/es/test/testKit.spec.js +129 -0
- package/dist/es/test/testKit.spec.js.map +1 -0
- package/dist/es/testKit/emptyLoggerOptions.d.ts +3 -0
- package/dist/es/testKit/emptyLoggerOptions.d.ts.map +1 -0
- package/dist/es/testKit/emptyLoggerOptions.js +15 -0
- package/dist/es/testKit/emptyLoggerOptions.js.map +1 -0
- package/dist/es/testKit/index.d.ts +25 -0
- package/dist/es/testKit/index.d.ts.map +1 -0
- package/dist/es/testKit/index.js +130 -0
- package/dist/es/testKit/index.js.map +1 -0
- package/dist/es/testKit/mockPackage.d.ts +21 -0
- package/dist/es/testKit/mockPackage.d.ts.map +1 -0
- package/dist/es/testKit/mockPackage.js +85 -0
- package/dist/es/testKit/mockPackage.js.map +1 -0
- package/dist/es/testKit/withConsoleErrors.d.ts +2 -0
- package/dist/es/testKit/withConsoleErrors.d.ts.map +1 -0
- package/dist/es/testKit/withConsoleErrors.js +12 -0
- package/dist/es/testKit/withConsoleErrors.js.map +1 -0
- package/dist/es/testKit/withThrowOnError.d.ts +3 -0
- package/dist/es/testKit/withThrowOnError.d.ts.map +1 -0
- package/dist/es/testKit/withThrowOnError.js +27 -0
- package/dist/es/testKit/withThrowOnError.js.map +1 -0
- package/dist/src/API.d.ts +31 -10
- package/dist/src/API.d.ts.map +1 -1
- package/dist/src/API.js +3 -0
- package/dist/src/API.js.map +1 -1
- package/dist/src/IterableWeakMap.d.ts +20 -0
- package/dist/src/IterableWeakMap.d.ts.map +1 -0
- package/dist/src/IterableWeakMap.js +96 -0
- package/dist/src/IterableWeakMap.js.map +1 -0
- package/dist/src/appHost.d.ts +7 -0
- package/dist/src/appHost.d.ts.map +1 -0
- package/dist/src/appHost.js +856 -0
- package/dist/src/appHost.js.map +1 -0
- package/dist/src/appHostServices.d.ts +12 -0
- package/dist/src/appHostServices.d.ts.map +1 -0
- package/dist/src/appHostServices.js +29 -0
- package/dist/src/appHostServices.js.map +1 -0
- package/dist/src/appHostUtils.d.ts +4 -0
- package/dist/src/appHostUtils.d.ts.map +1 -0
- package/dist/src/appHostUtils.js +16 -0
- package/dist/src/appHostUtils.js.map +1 -0
- package/dist/src/extensionSlot.d.ts +8 -0
- package/dist/src/extensionSlot.d.ts.map +1 -0
- package/dist/src/extensionSlot.js +67 -0
- package/dist/src/extensionSlot.js.map +1 -0
- package/dist/src/hot.d.ts +14 -0
- package/dist/src/hot.d.ts.map +1 -0
- package/dist/src/hot.js +56 -0
- package/dist/src/hot.js.map +1 -0
- package/dist/src/index.d.ts +10 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/installedShellsState.d.ts +19 -0
- package/dist/src/installedShellsState.d.ts.map +1 -0
- package/dist/src/installedShellsState.js +38 -0
- package/dist/src/installedShellsState.js.map +1 -0
- package/dist/src/interceptAnyObject.d.ts +7 -0
- package/dist/src/interceptAnyObject.d.ts.map +1 -0
- package/dist/src/interceptAnyObject.js +28 -0
- package/dist/src/interceptAnyObject.js.map +1 -0
- package/dist/src/interceptEntryPoints.d.ts +6 -0
- package/dist/src/interceptEntryPoints.d.ts.map +1 -0
- package/dist/src/interceptEntryPoints.js +30 -0
- package/dist/src/interceptEntryPoints.js.map +1 -0
- package/dist/src/invokeSlotCallbacks.d.ts +3 -0
- package/dist/src/invokeSlotCallbacks.d.ts.map +1 -0
- package/dist/src/invokeSlotCallbacks.js +24 -0
- package/dist/src/invokeSlotCallbacks.js.map +1 -0
- package/dist/src/loggers.d.ts +4 -0
- package/dist/src/loggers.d.ts.map +1 -0
- package/dist/src/loggers.js +104 -0
- package/dist/src/loggers.js.map +1 -0
- package/dist/src/monitorAPI.d.ts +3 -0
- package/dist/src/monitorAPI.d.ts.map +1 -0
- package/dist/src/monitorAPI.js +57 -0
- package/dist/src/monitorAPI.js.map +1 -0
- package/dist/src/repluggableAppDebug/index.d.ts +2 -0
- package/dist/src/repluggableAppDebug/index.d.ts.map +1 -0
- package/dist/src/repluggableAppDebug/index.js +6 -0
- package/dist/src/repluggableAppDebug/index.js.map +1 -0
- package/dist/src/repluggableAppDebug/performanceDebugInfo.d.ts +15 -0
- package/dist/src/repluggableAppDebug/performanceDebugInfo.d.ts.map +1 -0
- package/dist/src/repluggableAppDebug/performanceDebugInfo.js +101 -0
- package/dist/src/repluggableAppDebug/performanceDebugInfo.js.map +1 -0
- package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts +24 -0
- package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +1 -0
- package/dist/src/repluggableAppDebug/repluggableAppDebug.js +139 -0
- package/dist/src/repluggableAppDebug/repluggableAppDebug.js.map +1 -0
- package/dist/src/tarjanGraph.d.ts +27 -0
- package/dist/src/tarjanGraph.d.ts.map +1 -0
- package/dist/src/tarjanGraph.js +100 -0
- package/dist/src/tarjanGraph.js.map +1 -0
- package/dist/src/throttledStore.d.ts +32 -0
- package/dist/src/throttledStore.d.ts.map +1 -0
- package/dist/src/throttledStore.js +249 -0
- package/dist/src/throttledStore.js.map +1 -0
- package/dist/test/IterableWeakMap.spec.d.ts +2 -0
- package/dist/test/IterableWeakMap.spec.d.ts.map +1 -0
- package/dist/test/IterableWeakMap.spec.js +220 -0
- package/dist/test/IterableWeakMap.spec.js.map +1 -0
- package/dist/test/appHost.mock.d.ts +4 -0
- package/dist/test/appHost.mock.d.ts.map +1 -0
- package/dist/test/appHost.mock.js +59 -0
- package/dist/test/appHost.mock.js.map +1 -0
- package/dist/test/appHost.spec.d.ts +2 -0
- package/dist/test/appHost.spec.d.ts.map +1 -0
- package/dist/test/appHost.spec.js +1328 -0
- package/dist/test/appHost.spec.js.map +1 -0
- package/dist/test/customExtensionSlot.spec.d.ts +2 -0
- package/dist/test/customExtensionSlot.spec.d.ts.map +1 -0
- package/dist/test/customExtensionSlot.spec.js +117 -0
- package/dist/test/customExtensionSlot.spec.js.map +1 -0
- package/dist/test/extensionSlot.spec.d.ts +2 -0
- package/dist/test/extensionSlot.spec.d.ts.map +1 -0
- package/dist/test/extensionSlot.spec.js +75 -0
- package/dist/test/extensionSlot.spec.js.map +1 -0
- package/dist/test/installedShellsState.spec.d.ts +2 -0
- package/dist/test/installedShellsState.spec.d.ts.map +1 -0
- package/dist/test/installedShellsState.spec.js +30 -0
- package/dist/test/installedShellsState.spec.js.map +1 -0
- package/dist/test/interceptAnyObject.spec.d.ts +2 -0
- package/dist/test/interceptAnyObject.spec.d.ts.map +1 -0
- package/dist/test/interceptAnyObject.spec.js +171 -0
- package/dist/test/interceptAnyObject.spec.js.map +1 -0
- package/dist/test/interceptEntryPoints.spec.d.ts +2 -0
- package/dist/test/interceptEntryPoints.spec.d.ts.map +1 -0
- package/dist/test/interceptEntryPoints.spec.js +249 -0
- package/dist/test/interceptEntryPoints.spec.js.map +1 -0
- package/dist/test/loggers.spec.d.ts +2 -0
- package/dist/test/loggers.spec.d.ts.map +1 -0
- package/dist/test/loggers.spec.js +220 -0
- package/dist/test/loggers.spec.js.map +1 -0
- package/dist/test/repluggableAppDebug.spec.d.ts +2 -0
- package/dist/test/repluggableAppDebug.spec.d.ts.map +1 -0
- package/dist/test/repluggableAppDebug.spec.js +109 -0
- package/dist/test/repluggableAppDebug.spec.js.map +1 -0
- package/dist/test/testKit.spec.d.ts +2 -0
- package/dist/test/testKit.spec.d.ts.map +1 -0
- package/dist/test/testKit.spec.js +134 -0
- package/dist/test/testKit.spec.js.map +1 -0
- package/dist/testKit/emptyLoggerOptions.d.ts +3 -0
- package/dist/testKit/emptyLoggerOptions.d.ts.map +1 -0
- package/dist/testKit/emptyLoggerOptions.js +18 -0
- package/dist/testKit/emptyLoggerOptions.js.map +1 -0
- package/dist/testKit/index.d.ts +25 -0
- package/dist/testKit/index.d.ts.map +1 -0
- package/dist/testKit/index.js +158 -0
- package/dist/testKit/index.js.map +1 -0
- package/dist/testKit/mockPackage.d.ts +21 -0
- package/dist/testKit/mockPackage.d.ts.map +1 -0
- package/dist/testKit/mockPackage.js +91 -0
- package/dist/testKit/mockPackage.js.map +1 -0
- package/dist/testKit/withConsoleErrors.d.ts +2 -0
- package/dist/testKit/withConsoleErrors.d.ts.map +1 -0
- package/dist/testKit/withConsoleErrors.js +16 -0
- package/dist/testKit/withConsoleErrors.js.map +1 -0
- package/dist/testKit/withThrowOnError.d.ts +3 -0
- package/dist/testKit/withThrowOnError.d.ts.map +1 -0
- package/dist/testKit/withThrowOnError.js +31 -0
- package/dist/testKit/withThrowOnError.js.map +1 -0
- package/jest.config.js +16 -0
- package/package.json +5 -3
- package/src/API.ts +474 -378
- package/src/IterableWeakMap.ts +121 -0
- package/src/appHost.ts +1383 -0
- package/src/appHostServices.ts +42 -0
- package/src/appHostUtils.ts +11 -0
- package/src/extensionSlot.ts +96 -0
- package/src/hot.ts +53 -0
- package/src/index.ts +55 -3
- package/src/installedShellsState.ts +54 -0
- package/src/interceptAnyObject.ts +39 -0
- package/src/interceptEntryPoints.ts +25 -0
- package/src/invokeSlotCallbacks.ts +20 -0
- package/src/loggers.ts +112 -0
- package/src/monitorAPI.ts +71 -0
- package/src/repluggableAppDebug/debug.d.ts +37 -0
- package/src/repluggableAppDebug/index.ts +1 -0
- package/src/repluggableAppDebug/performanceDebugInfo.ts +96 -0
- package/src/repluggableAppDebug/repluggableAppDebug.ts +192 -0
- package/src/tarjanGraph.ts +96 -0
- package/src/throttledStore.ts +355 -0
- package/test/IterableWeakMap.spec.ts +284 -0
- package/test/appHost.mock.ts +58 -0
- package/test/appHost.spec.ts +1629 -0
- package/test/customExtensionSlot.spec.ts +153 -0
- package/test/extensionSlot.spec.ts +94 -0
- package/test/installedShellsState.spec.ts +39 -0
- package/test/interceptAnyObject.spec.ts +217 -0
- package/test/interceptEntryPoints.spec.ts +291 -0
- package/test/loggers.spec.ts +288 -0
- package/test/repluggableAppDebug.spec.ts +118 -0
- package/test/testKit.spec.tsx +153 -0
- package/testKit/emptyLoggerOptions.ts +16 -0
- package/testKit/index.ts +172 -0
- package/testKit/mockPackage.ts +99 -0
- package/testKit/package.json +3 -0
- package/testKit/withConsoleErrors.ts +12 -0
- package/testKit/withThrowOnError.ts +34 -0
- package/tsconfig.json +11 -1
- package/dist/es/API.d.ts.map +0 -1
- package/dist/es/API.js +0 -2
- package/dist/es/API.js.map +0 -1
- package/dist/es/index.d.ts +0 -2
- package/dist/es/index.d.ts.map +0 -1
- package/dist/es/index.js +0 -2
- package/dist/es/index.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import {
|
|
3
|
+
EntryPoint,
|
|
4
|
+
SlotKey,
|
|
5
|
+
Shell,
|
|
6
|
+
CustomExtensionSlot,
|
|
7
|
+
CustomExtensionSlotHandler,
|
|
8
|
+
ExtensionItem,
|
|
9
|
+
} from "../src";
|
|
10
|
+
import { createAppHost, addMockShell } from "../testKit";
|
|
11
|
+
|
|
12
|
+
interface TestItem {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const slotKey: SlotKey<TestItem> = { name: "TEST_SLOT" };
|
|
17
|
+
|
|
18
|
+
describe("Custom Extension Slot", () => {
|
|
19
|
+
let slotUnderTest: CustomExtensionSlot<TestItem>;
|
|
20
|
+
let slotHandler: CustomExtensionSlotHandler<TestItem>;
|
|
21
|
+
let ownerShell: Shell | undefined;
|
|
22
|
+
|
|
23
|
+
const testEntryPoint: EntryPoint = {
|
|
24
|
+
name: "TEST",
|
|
25
|
+
attach(shell) {
|
|
26
|
+
ownerShell = shell;
|
|
27
|
+
slotUnderTest = shell.declareCustomSlot<TestItem>(slotKey, slotHandler);
|
|
28
|
+
},
|
|
29
|
+
detach(shell) {
|
|
30
|
+
ownerShell = undefined;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
slotHandler = {
|
|
36
|
+
contribute: jest.fn(),
|
|
37
|
+
discardBy: jest.fn(),
|
|
38
|
+
};
|
|
39
|
+
ownerShell = undefined;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("can be declared", () => {
|
|
43
|
+
createAppHost([testEntryPoint]);
|
|
44
|
+
|
|
45
|
+
expect(slotUnderTest).toBeDefined();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("can be retrieved by key", async () => {
|
|
49
|
+
createAppHost([testEntryPoint]);
|
|
50
|
+
|
|
51
|
+
expect(ownerShell).toBeDefined();
|
|
52
|
+
expect(ownerShell && ownerShell.getSlot(slotKey)).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("invokes callback on contribute", () => {
|
|
56
|
+
const host = createAppHost([testEntryPoint]);
|
|
57
|
+
const contributorShell = addMockShell(host);
|
|
58
|
+
const item = { value: "abc" };
|
|
59
|
+
|
|
60
|
+
slotUnderTest.contribute(contributorShell, item);
|
|
61
|
+
|
|
62
|
+
expect(slotHandler.contribute).toBeCalledTimes(1);
|
|
63
|
+
expect(slotHandler.contribute).toBeCalledWith(contributorShell, item);
|
|
64
|
+
expect(slotHandler.discardBy).not.toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("invokes callback on discard", () => {
|
|
68
|
+
createAppHost([testEntryPoint]);
|
|
69
|
+
const predicate = (item: ExtensionItem<TestItem>) => true;
|
|
70
|
+
|
|
71
|
+
slotUnderTest.discardBy(predicate);
|
|
72
|
+
|
|
73
|
+
expect(slotHandler.contribute).not.toHaveBeenCalled();
|
|
74
|
+
expect(slotHandler.discardBy).toBeCalledTimes(1);
|
|
75
|
+
expect(slotHandler.discardBy).toBeCalledWith(predicate);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("cannot create two slots with same key: custom and standard", () => {
|
|
79
|
+
const beforeTestEntryPoint: EntryPoint = {
|
|
80
|
+
name: "BEFORE_TEST",
|
|
81
|
+
attach(shell) {
|
|
82
|
+
shell.declareSlot(slotKey);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
expect(() =>
|
|
87
|
+
createAppHost([beforeTestEntryPoint, testEntryPoint])
|
|
88
|
+
).toThrowError();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("cannot create two slots with same key: custom and custom", () => {
|
|
92
|
+
const beforeTestEntryPoint: EntryPoint = {
|
|
93
|
+
name: "BEFORE_TEST",
|
|
94
|
+
attach(shell) {
|
|
95
|
+
shell.declareCustomSlot(slotKey, {
|
|
96
|
+
contribute: () => {},
|
|
97
|
+
discardBy: () => {},
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
expect(() =>
|
|
103
|
+
createAppHost([beforeTestEntryPoint, testEntryPoint])
|
|
104
|
+
).toThrowError();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("cannot create two slots with same name: custom and standard", () => {
|
|
108
|
+
const beforeTestEntryPoint: EntryPoint = {
|
|
109
|
+
name: "BEFORE_TEST",
|
|
110
|
+
attach(shell) {
|
|
111
|
+
shell.declareSlot({ name: slotKey.name });
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
expect(() =>
|
|
116
|
+
createAppHost([beforeTestEntryPoint, testEntryPoint])
|
|
117
|
+
).toThrowError();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("cannot create two slots with same name: custom and custom", () => {
|
|
121
|
+
const beforeTestEntryPoint: EntryPoint = {
|
|
122
|
+
name: "BEFORE_TEST",
|
|
123
|
+
attach(shell) {
|
|
124
|
+
shell.declareCustomSlot(
|
|
125
|
+
{ name: slotKey.name },
|
|
126
|
+
{
|
|
127
|
+
contribute: () => {},
|
|
128
|
+
discardBy: () => {},
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
expect(() =>
|
|
135
|
+
createAppHost([beforeTestEntryPoint, testEntryPoint])
|
|
136
|
+
).toThrowError();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("can reload entry point that declares custom slots", async () => {
|
|
140
|
+
const host = createAppHost([testEntryPoint]);
|
|
141
|
+
|
|
142
|
+
expect(ownerShell).toBeDefined();
|
|
143
|
+
|
|
144
|
+
await host.removeShells([testEntryPoint.name]);
|
|
145
|
+
|
|
146
|
+
expect(ownerShell).toBeUndefined();
|
|
147
|
+
|
|
148
|
+
await host.addShells([_.cloneDeep(testEntryPoint)]);
|
|
149
|
+
|
|
150
|
+
expect(ownerShell).toBeDefined();
|
|
151
|
+
expect(ownerShell && ownerShell.getSlot(slotKey)).toBeDefined();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SlotKey } from '../src'
|
|
2
|
+
import { addMockShell, createAppHost } from '../testKit'
|
|
3
|
+
import { PrivateExtensionSlot, Shell, EntryPoint } from '../src/API'
|
|
4
|
+
|
|
5
|
+
describe('ExtensionSlot', () => {
|
|
6
|
+
describe('Subscribe', () => {
|
|
7
|
+
it('should be invoked on contribution', () => {
|
|
8
|
+
const slotKey: SlotKey<{}> = {
|
|
9
|
+
name: 'mock_key'
|
|
10
|
+
}
|
|
11
|
+
const host = createAppHost([])
|
|
12
|
+
const shell = addMockShell(host)
|
|
13
|
+
const spy = jest.fn()
|
|
14
|
+
const slot = shell.declareSlot(slotKey) as PrivateExtensionSlot<{}>
|
|
15
|
+
|
|
16
|
+
slot.subscribe(spy)
|
|
17
|
+
|
|
18
|
+
slot.contribute(shell, () => ({}))
|
|
19
|
+
|
|
20
|
+
expect(spy).toBeCalledTimes(1)
|
|
21
|
+
|
|
22
|
+
slot.contribute(shell, () => ({}))
|
|
23
|
+
|
|
24
|
+
expect(spy).toBeCalledTimes(2)
|
|
25
|
+
})
|
|
26
|
+
it('should be invoked once when contribution is during installation phase', () => {
|
|
27
|
+
interface SlotItem {
|
|
28
|
+
name: string
|
|
29
|
+
}
|
|
30
|
+
const slotKey: SlotKey<SlotItem> = {
|
|
31
|
+
name: 'MOCK_SLOT'
|
|
32
|
+
}
|
|
33
|
+
interface MockContributionAPI {
|
|
34
|
+
contributeItem(fromShell: Shell, item: SlotItem): void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ContributionAPI: SlotKey<MockContributionAPI> = {
|
|
38
|
+
name: 'CONTRIBUTION_API'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const spy = jest.fn()
|
|
42
|
+
|
|
43
|
+
const contributionEntryPoint: EntryPoint = {
|
|
44
|
+
name: 'PRIVATE CONTRIBUTION ENTRY POINT',
|
|
45
|
+
declareAPIs() {
|
|
46
|
+
return [ContributionAPI]
|
|
47
|
+
},
|
|
48
|
+
attach(shell) {
|
|
49
|
+
const slot = shell.declareSlot(slotKey) as PrivateExtensionSlot<SlotItem>
|
|
50
|
+
slot.subscribe(spy)
|
|
51
|
+
shell.contributeAPI(ContributionAPI, () => ({
|
|
52
|
+
contributeItem(fromShell, item) {
|
|
53
|
+
shell.getSlot(slotKey).contribute(fromShell, item)
|
|
54
|
+
}
|
|
55
|
+
}))
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const API_A: SlotKey<{}> = { name: 'API_A' }
|
|
60
|
+
|
|
61
|
+
const itemContributionEntryPointA: EntryPoint = {
|
|
62
|
+
name: 'ITEM CONTRIBUTION ENTRY POINT A',
|
|
63
|
+
getDependencyAPIs() {
|
|
64
|
+
return [ContributionAPI]
|
|
65
|
+
},
|
|
66
|
+
declareAPIs(): SlotKey<{}>[] {
|
|
67
|
+
return [API_A]
|
|
68
|
+
},
|
|
69
|
+
attach(shell: Shell) {
|
|
70
|
+
shell.contributeAPI(API_A, () => ({}))
|
|
71
|
+
},
|
|
72
|
+
extend(shell: Shell) {
|
|
73
|
+
shell.getAPI(ContributionAPI).contributeItem(shell, { name: 'A.1' })
|
|
74
|
+
shell.getAPI(ContributionAPI).contributeItem(shell, { name: 'A.2' })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const itemContributionEntryPointB: EntryPoint = {
|
|
79
|
+
name: 'ITEM CONTRIBUTION ENTRY POINT B',
|
|
80
|
+
getDependencyAPIs() {
|
|
81
|
+
return [ContributionAPI, API_A]
|
|
82
|
+
},
|
|
83
|
+
extend(shell: Shell) {
|
|
84
|
+
shell.getAPI(ContributionAPI).contributeItem(shell, { name: 'B.1' })
|
|
85
|
+
shell.getAPI(ContributionAPI).contributeItem(shell, { name: 'B.2' })
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
createAppHost([contributionEntryPoint, itemContributionEntryPointA, itemContributionEntryPointB])
|
|
90
|
+
|
|
91
|
+
expect(spy).toBeCalledTimes(1)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InstalledShellsActions,
|
|
3
|
+
installedShellsReducer,
|
|
4
|
+
InstalledShellsSelectors,
|
|
5
|
+
InstalledShellsState,
|
|
6
|
+
ShellToggleSet
|
|
7
|
+
} from '../src/installedShellsState'
|
|
8
|
+
|
|
9
|
+
const initialState: InstalledShellsState = {
|
|
10
|
+
installedShells: {
|
|
11
|
+
shellA: true,
|
|
12
|
+
shellB: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const shellsToggleSet: ShellToggleSet = {
|
|
17
|
+
shellB: false,
|
|
18
|
+
shellC: true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const expectedState: InstalledShellsState = {
|
|
22
|
+
installedShells: {
|
|
23
|
+
shellA: true,
|
|
24
|
+
shellC: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('Installed Shells State', () => {
|
|
29
|
+
it('should toggle shells according to shell toggles', () => {
|
|
30
|
+
const actualState = installedShellsReducer(initialState, InstalledShellsActions.updateInstalledShells(shellsToggleSet))
|
|
31
|
+
|
|
32
|
+
expect(actualState).toEqual(expectedState)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should select installed shells from state', () => {
|
|
36
|
+
const rootState = { $installedShells: initialState }
|
|
37
|
+
expect(InstalledShellsSelectors.getInstalledShellsSet(rootState)).toEqual(initialState.installedShells)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { FunctionInterceptor, interceptAnyObject, PropertyInterceptor } from '../src/interceptAnyObject'
|
|
3
|
+
|
|
4
|
+
type LogSpy = jest.Mock<void, string[]>
|
|
5
|
+
|
|
6
|
+
function takeLog(spy: LogSpy): string[] {
|
|
7
|
+
return _.flatten(spy.mock.calls)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface StringDict {
|
|
11
|
+
[key: string]: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function dictToString(dict: StringDict): string {
|
|
15
|
+
return Object.keys(dict)
|
|
16
|
+
.map(key => ({
|
|
17
|
+
key,
|
|
18
|
+
value: dict[key]
|
|
19
|
+
}))
|
|
20
|
+
.filter(kvp => typeof kvp.value === 'string')
|
|
21
|
+
.map(kvp => `${kvp.key}:${kvp.value}`)
|
|
22
|
+
.join(';')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function argToString(arg: any): string {
|
|
26
|
+
switch (typeof arg) {
|
|
27
|
+
case 'number':
|
|
28
|
+
case 'string':
|
|
29
|
+
return `${arg}`
|
|
30
|
+
case 'object':
|
|
31
|
+
return dictToString(arg)
|
|
32
|
+
case 'undefined':
|
|
33
|
+
return 'undefined'
|
|
34
|
+
default:
|
|
35
|
+
return '???'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface TestTarget {
|
|
40
|
+
voidFunc(): void
|
|
41
|
+
voidFuncWithArgs(str: string, num: number, obj: StringDict): void
|
|
42
|
+
nonVoidFunc(): StringDict
|
|
43
|
+
nonVoidFuncWithArgs(str: string, num: number): StringDict
|
|
44
|
+
scalarProp: string
|
|
45
|
+
objectProp: TestTargetNested
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface TestTargetNested {
|
|
49
|
+
nestedFunc(): void
|
|
50
|
+
nestedProp: string
|
|
51
|
+
nestedObject: TestTargetNestedLevelTwo
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface TestTargetNestedLevelTwo {
|
|
55
|
+
nestedFuncLevelTwo(): number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function createTestTarget(spy: LogSpy): TestTarget {
|
|
59
|
+
return {
|
|
60
|
+
voidFunc() {
|
|
61
|
+
spy('voidFunc')
|
|
62
|
+
},
|
|
63
|
+
voidFuncWithArgs(str: string, num: number, dict: StringDict): void {
|
|
64
|
+
spy(`voidFuncWithArgs(str=${str},num=${num},dict=${dictToString(dict)})`)
|
|
65
|
+
},
|
|
66
|
+
nonVoidFunc() {
|
|
67
|
+
spy('nonVoidFunc')
|
|
68
|
+
return {
|
|
69
|
+
aaa: '111'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
nonVoidFuncWithArgs(str: string, num: number): StringDict {
|
|
73
|
+
spy(`nonVoidFuncWithArgs(str=${str},num=${num})`)
|
|
74
|
+
return {
|
|
75
|
+
bbb: '222'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
scalarProp: 'original-scalar',
|
|
79
|
+
objectProp: {
|
|
80
|
+
nestedProp: 'original-nested',
|
|
81
|
+
nestedFunc() {
|
|
82
|
+
spy('objectProp.nestedFunc')
|
|
83
|
+
},
|
|
84
|
+
nestedObject: {
|
|
85
|
+
nestedFuncLevelTwo() {
|
|
86
|
+
spy('objectProp.nestedObject.nestedFuncLevelTwo')
|
|
87
|
+
return 12345
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('interceptAnyObject', () => {
|
|
95
|
+
function createFuncInterceptor(spy: LogSpy): FunctionInterceptor {
|
|
96
|
+
return (name, func) => {
|
|
97
|
+
return (...args: any[]) => {
|
|
98
|
+
spy(`BEFORE:${name}(${args.map(argToString).join(';')})`)
|
|
99
|
+
const retVal = func.apply(null, args)
|
|
100
|
+
spy(`AFTER:${name}(${argToString(retVal)})`)
|
|
101
|
+
return retVal
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function createPropInterceptor(spy: LogSpy): PropertyInterceptor {
|
|
107
|
+
return (name, value) => {
|
|
108
|
+
return typeof value === 'string' ? value.replace('original', `INTERCEPTED[${name}]`) : value
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
it('should return same members if no interceptors passed', () => {
|
|
113
|
+
const spy: LogSpy = jest.fn()
|
|
114
|
+
const real = createTestTarget(spy)
|
|
115
|
+
const intercepted = interceptAnyObject(real)
|
|
116
|
+
|
|
117
|
+
expect(intercepted.voidFunc).toBe(real.voidFunc)
|
|
118
|
+
expect(intercepted.scalarProp).toBe(real.scalarProp)
|
|
119
|
+
expect(intercepted.objectProp.nestedFunc).toBe(real.objectProp.nestedFunc)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('should intercept void functions', () => {
|
|
123
|
+
const spy: LogSpy = jest.fn()
|
|
124
|
+
const real = createTestTarget(spy)
|
|
125
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy))
|
|
126
|
+
|
|
127
|
+
intercepted.voidFunc()
|
|
128
|
+
|
|
129
|
+
const log = takeLog(spy)
|
|
130
|
+
expect(log).toEqual(['BEFORE:voidFunc()', 'voidFunc', 'AFTER:voidFunc(undefined)'])
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('should intercept non-void functions with arguments', () => {
|
|
134
|
+
const spy: LogSpy = jest.fn()
|
|
135
|
+
const real = createTestTarget(spy)
|
|
136
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy))
|
|
137
|
+
|
|
138
|
+
const retVal = intercepted.nonVoidFuncWithArgs('abc', 123)
|
|
139
|
+
|
|
140
|
+
const log = takeLog(spy)
|
|
141
|
+
expect(log).toEqual([
|
|
142
|
+
'BEFORE:nonVoidFuncWithArgs(abc;123)',
|
|
143
|
+
'nonVoidFuncWithArgs(str=abc,num=123)',
|
|
144
|
+
'AFTER:nonVoidFuncWithArgs(bbb:222)'
|
|
145
|
+
])
|
|
146
|
+
expect(dictToString(retVal)).toBe('bbb:222')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should intercept scalar props', () => {
|
|
150
|
+
const spy: LogSpy = jest.fn()
|
|
151
|
+
const real = createTestTarget(spy)
|
|
152
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy))
|
|
153
|
+
|
|
154
|
+
const propValue = intercepted.scalarProp
|
|
155
|
+
|
|
156
|
+
expect(propValue).toBe('INTERCEPTED[scalarProp]-scalar')
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('should intercept nested objects', () => {
|
|
160
|
+
const spy: LogSpy = jest.fn()
|
|
161
|
+
const real = createTestTarget(spy)
|
|
162
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy), 10)
|
|
163
|
+
|
|
164
|
+
const nestedPropValue = intercepted.objectProp.nestedProp
|
|
165
|
+
intercepted.objectProp.nestedFunc()
|
|
166
|
+
|
|
167
|
+
const log = takeLog(spy)
|
|
168
|
+
expect(log).toEqual(['BEFORE:objectProp.nestedFunc()', 'objectProp.nestedFunc', 'AFTER:objectProp.nestedFunc(undefined)'])
|
|
169
|
+
expect(nestedPropValue).toBe('INTERCEPTED[objectProp.nestedProp]-nested')
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('should intercept multiple levels of nested objects', () => {
|
|
173
|
+
const spy: LogSpy = jest.fn()
|
|
174
|
+
const real = createTestTarget(spy)
|
|
175
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy), 10)
|
|
176
|
+
|
|
177
|
+
const nestedFuncLevelTwoRetVal = intercepted.objectProp.nestedObject.nestedFuncLevelTwo()
|
|
178
|
+
|
|
179
|
+
const log = takeLog(spy)
|
|
180
|
+
expect(log).toEqual([
|
|
181
|
+
'BEFORE:objectProp.nestedObject.nestedFuncLevelTwo()',
|
|
182
|
+
'objectProp.nestedObject.nestedFuncLevelTwo',
|
|
183
|
+
'AFTER:objectProp.nestedObject.nestedFuncLevelTwo(12345)'
|
|
184
|
+
])
|
|
185
|
+
expect(nestedFuncLevelTwoRetVal).toBe(12345)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('should not intercept non object-like values - functions', () => {
|
|
189
|
+
const spy: LogSpy = jest.fn()
|
|
190
|
+
function real() {
|
|
191
|
+
return 'real'
|
|
192
|
+
}
|
|
193
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy))
|
|
194
|
+
expect(intercepted()).toBe('real')
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('should not intercept non object-like values - primitives', () => {
|
|
198
|
+
const spy: LogSpy = jest.fn()
|
|
199
|
+
const real = 'real'
|
|
200
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy))
|
|
201
|
+
expect(intercepted).toBe('real')
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('should not intercept non object-like values - arrays', () => {
|
|
205
|
+
const spy: LogSpy = jest.fn()
|
|
206
|
+
const real = ['real']
|
|
207
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy))
|
|
208
|
+
expect(intercepted).toEqual(['real'])
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('should not intercept non object-like values - maps', () => {
|
|
212
|
+
const spy: LogSpy = jest.fn()
|
|
213
|
+
const real = new Map<string, string>([['key', 'value']])
|
|
214
|
+
const intercepted = interceptAnyObject(real, createFuncInterceptor(spy), createPropInterceptor(spy))
|
|
215
|
+
expect(intercepted.get('key')).toEqual('value')
|
|
216
|
+
})
|
|
217
|
+
})
|