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,96 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { AppHostOptions, Trace, StatisticsMemoization } from '../API'
|
|
3
|
+
|
|
4
|
+
export function getPerformanceDebug(options: AppHostOptions, trace: Trace[], memoized: StatisticsMemoization[]) {
|
|
5
|
+
const getMemoizedTable = () => {
|
|
6
|
+
return _.map(memoized, memoize => {
|
|
7
|
+
const { calls, hit, miss } = memoize.func
|
|
8
|
+
const hitRate = `${((hit / calls) * 100).toFixed(2)}%`
|
|
9
|
+
const { name } = memoize
|
|
10
|
+
return { name, hitRate, calls, hit, miss }
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getGroups = (apiName: string) => {
|
|
15
|
+
const api = _.groupBy(trace, 'name')[apiName]
|
|
16
|
+
try {
|
|
17
|
+
const groupedArgs = _.groupBy(api, a => JSON.stringify(a.args))
|
|
18
|
+
const groupedRes = _.groupBy(api, a => JSON.stringify(a.res))
|
|
19
|
+
const groupedArgsAndRes = _.groupBy(api, a => JSON.stringify(a.args) + JSON.stringify(a.res))
|
|
20
|
+
return { groupedArgs, groupedRes, groupedArgsAndRes }
|
|
21
|
+
} catch (err) {
|
|
22
|
+
return { groupedArgs: [], groupedRes: [], groupedArgsAndRes: [] }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const printMemoizeTable = () => {
|
|
26
|
+
console.table(getMemoizedTable())
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
getSortedMeasurments: () => {
|
|
30
|
+
return _(trace)
|
|
31
|
+
.map(measurement => _.pick(measurement, ['name', 'duration']))
|
|
32
|
+
.sortBy('duration')
|
|
33
|
+
.reverse()
|
|
34
|
+
.value()
|
|
35
|
+
},
|
|
36
|
+
start: () => {
|
|
37
|
+
if (!options.monitoring.disableMonitoring) {
|
|
38
|
+
options.monitoring.enablePerformance = true
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Remove "disableMonitoring" in order to use trace')
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
stop: () => {
|
|
44
|
+
options.monitoring.enablePerformance = false
|
|
45
|
+
},
|
|
46
|
+
clean: () => {
|
|
47
|
+
trace.length = 0
|
|
48
|
+
},
|
|
49
|
+
getTrace: () => {
|
|
50
|
+
return trace
|
|
51
|
+
},
|
|
52
|
+
getGroupedTrace: () => {
|
|
53
|
+
return _.groupBy(trace, 'name')
|
|
54
|
+
},
|
|
55
|
+
getGroupedSumTrace: () => {
|
|
56
|
+
const traceData = _(trace)
|
|
57
|
+
.groupBy('name')
|
|
58
|
+
.mapValues((arr, name) => {
|
|
59
|
+
const totalDuration = Number(_.sumBy(arr, 'duration').toFixed(2))
|
|
60
|
+
const times = arr.length
|
|
61
|
+
const avgDuration = Number((totalDuration / times).toFixed(2))
|
|
62
|
+
const groups = _(getGroups(name))
|
|
63
|
+
.mapValues((obj, group) => {
|
|
64
|
+
const keys = Object.keys(obj)
|
|
65
|
+
const length = keys.length
|
|
66
|
+
if (group !== 'groupedRes' || length === 0) {
|
|
67
|
+
return length
|
|
68
|
+
}
|
|
69
|
+
const joined = keys.join(' ')
|
|
70
|
+
return joined.length < 15 ? `${length}: ${joined}` : length
|
|
71
|
+
})
|
|
72
|
+
.value()
|
|
73
|
+
|
|
74
|
+
return { name, times, totalDuration, avgDuration, ...groups }
|
|
75
|
+
})
|
|
76
|
+
.orderBy(x => x.totalDuration, 'desc')
|
|
77
|
+
.value()
|
|
78
|
+
|
|
79
|
+
_.forEach(getMemoizedTable(), memoizeData => {
|
|
80
|
+
_.assign(_.find(traceData, { name: memoizeData.name }), memoizeData)
|
|
81
|
+
})
|
|
82
|
+
console.table(traceData)
|
|
83
|
+
},
|
|
84
|
+
analyseAPI: (apiName: string) => {
|
|
85
|
+
const groups = getGroups(apiName)
|
|
86
|
+
if (groups) {
|
|
87
|
+
const { groupedArgs, groupedRes, groupedArgsAndRes } = groups
|
|
88
|
+
console.log(`groupedArgs: ${Object.keys(groupedArgs).length}`, groupedArgs)
|
|
89
|
+
console.log(`groupedRes: ${Object.keys(groupedRes).length}`, groupedRes)
|
|
90
|
+
console.log(`groupedArgsAndRes: ${Object.keys(groupedArgsAndRes).length}`, groupedArgsAndRes)
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
getMemoized: () => memoized,
|
|
94
|
+
printMemoizeTable
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { getPerformanceDebug } from './performanceDebugInfo'
|
|
2
|
+
import { AnySlotKey, AppHost, EntryPoint, LazyEntryPointFactory, PrivateShell, SlotKey, StatisticsMemoization, Trace } from '../API'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import { hot } from '../hot'
|
|
5
|
+
import { AppHostServicesProvider } from '../appHostServices'
|
|
6
|
+
import { AnyExtensionSlot } from '../extensionSlot'
|
|
7
|
+
|
|
8
|
+
interface PerformanceDebugParams {
|
|
9
|
+
options: AppHost['options']
|
|
10
|
+
trace: Trace[]
|
|
11
|
+
memoizedArr: StatisticsMemoization[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SetupDebugInfoParams {
|
|
15
|
+
readyAPIs: Set<AnySlotKey>
|
|
16
|
+
host: AppHost & AppHostServicesProvider
|
|
17
|
+
uniqueShellNames: Set<string>
|
|
18
|
+
extensionSlots: Map<AnySlotKey, AnyExtensionSlot>
|
|
19
|
+
addedShells: Map<string, PrivateShell>
|
|
20
|
+
shellInstallers: WeakMap<PrivateShell, string[]>
|
|
21
|
+
lazyShells: Map<string, LazyEntryPointFactory>
|
|
22
|
+
|
|
23
|
+
performance: PerformanceDebugParams
|
|
24
|
+
|
|
25
|
+
getUnreadyEntryPoints(): EntryPoint[]
|
|
26
|
+
getOwnSlotKey(key: SlotKey<any>): SlotKey<any>
|
|
27
|
+
getAPI: AppHost['getAPI']
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function mapApiToEntryPoint(allPackages: EntryPoint[]) {
|
|
31
|
+
const apiToEntryPoint = new Map<string, EntryPoint | undefined>()
|
|
32
|
+
_.forEach(allPackages, (entryPoint: EntryPoint) => {
|
|
33
|
+
_.forEach(entryPoint.declareAPIs ? entryPoint.declareAPIs() : [], dependency => {
|
|
34
|
+
apiToEntryPoint.set(dependency.name, entryPoint)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
return apiToEntryPoint
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* a function that returns all the entry points in the system with their declared APIs and dependencies
|
|
42
|
+
*/
|
|
43
|
+
const getAllEntryPoints = () => {
|
|
44
|
+
return [
|
|
45
|
+
...globalThis.repluggableAppDebug.utils.unReadyEntryPoints(),
|
|
46
|
+
...[...globalThis.repluggableAppDebug.addedShells].map(([_, shell]) => shell.entryPoint)
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* this function is used to get the root unready API in case there are too many to understand.
|
|
52
|
+
* for example if you have 200 unready entry points, running this function will give you the first unready API that
|
|
53
|
+
* will unblock the rest of the entry point (note that there might be more than one)
|
|
54
|
+
*
|
|
55
|
+
* this function basically takes the first unready entry point, get its dependencies and iterates over them to find an API that is not ready
|
|
56
|
+
* at this point it follows the same process recursively until it reaced the target API.
|
|
57
|
+
*/
|
|
58
|
+
const getRootUnreadyAPI = (host: AppHost) => {
|
|
59
|
+
return () => {
|
|
60
|
+
// get all unready entry points
|
|
61
|
+
const allEntryPoints = getAllEntryPoints()
|
|
62
|
+
const unReadyAPIsArray = []
|
|
63
|
+
// get the depdenencies of the first unready entry point
|
|
64
|
+
let dependenciesOfUnreadyEntryPoint = allEntryPoints?.[0]?.getDependencyAPIs?.()
|
|
65
|
+
|
|
66
|
+
while (dependenciesOfUnreadyEntryPoint?.length) {
|
|
67
|
+
const currentAPI = dependenciesOfUnreadyEntryPoint.pop()
|
|
68
|
+
|
|
69
|
+
if (!currentAPI) {
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
// try to get the API from this host, we are looking for an API that is not ready
|
|
73
|
+
try {
|
|
74
|
+
const api = host.getAPI(currentAPI as SlotKey<any>)
|
|
75
|
+
if (api) {
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
unReadyAPIsArray.push(currentAPI)
|
|
80
|
+
// we found an API that is unready, lets find which entry point declares it
|
|
81
|
+
const declarer = allEntryPoints.find(entryPointData =>
|
|
82
|
+
entryPointData.declareAPIs?.().some(api => currentAPI?.name === api.name)
|
|
83
|
+
)
|
|
84
|
+
dependenciesOfUnreadyEntryPoint = declarer?.getDependencyAPIs?.()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return unReadyAPIsArray.reverse()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const getAPIOrEntryPointsDependencies = (
|
|
92
|
+
apisOrEntryPointsNames: string[],
|
|
93
|
+
entryPoints: EntryPoint[]
|
|
94
|
+
): { entryPoints: EntryPoint[]; apis: AnySlotKey[] } => {
|
|
95
|
+
const apiToEntryPoint = mapApiToEntryPoint(entryPoints)
|
|
96
|
+
|
|
97
|
+
const loadedEntryPoints = new Set<string>()
|
|
98
|
+
const packagesList: EntryPoint[] = []
|
|
99
|
+
const allDependencies = new Set<AnySlotKey>()
|
|
100
|
+
const apisOrEntryPointsSet = new Set(apisOrEntryPointsNames)
|
|
101
|
+
const entryPointsQueue: EntryPoint[] = entryPoints.filter(x => apisOrEntryPointsSet.has(x.name))
|
|
102
|
+
|
|
103
|
+
apisOrEntryPointsNames.forEach(x => {
|
|
104
|
+
const ep = apiToEntryPoint.get(x)
|
|
105
|
+
ep && entryPointsQueue.push(ep)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
while (entryPointsQueue.length) {
|
|
109
|
+
const currEntryPoint = entryPointsQueue.shift()
|
|
110
|
+
if (!currEntryPoint || loadedEntryPoints.has(currEntryPoint.name)) {
|
|
111
|
+
continue
|
|
112
|
+
}
|
|
113
|
+
loadedEntryPoints.add(currEntryPoint.name)
|
|
114
|
+
packagesList.push(currEntryPoint)
|
|
115
|
+
const dependencies = currEntryPoint.getDependencyAPIs ? currEntryPoint.getDependencyAPIs() : []
|
|
116
|
+
dependencies.forEach(x => allDependencies.add(x))
|
|
117
|
+
const dependencyEntryPoints = dependencies.map((API: AnySlotKey) => apiToEntryPoint.get(API.name))
|
|
118
|
+
entryPointsQueue.push(..._.compact(dependencyEntryPoints))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
entryPoints: packagesList,
|
|
123
|
+
apis: [...allDependencies]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function setupDebugInfo({
|
|
128
|
+
host,
|
|
129
|
+
uniqueShellNames,
|
|
130
|
+
readyAPIs,
|
|
131
|
+
getAPI,
|
|
132
|
+
getOwnSlotKey,
|
|
133
|
+
getUnreadyEntryPoints,
|
|
134
|
+
extensionSlots,
|
|
135
|
+
addedShells,
|
|
136
|
+
lazyShells,
|
|
137
|
+
shellInstallers,
|
|
138
|
+
performance: { options, trace, memoizedArr }
|
|
139
|
+
}: SetupDebugInfoParams) {
|
|
140
|
+
const utils = {
|
|
141
|
+
apis: () => {
|
|
142
|
+
return Array.from(readyAPIs).map((apiKey: AnySlotKey) => {
|
|
143
|
+
return {
|
|
144
|
+
key: apiKey,
|
|
145
|
+
impl: () => getAPI(apiKey)
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
},
|
|
149
|
+
getRootUnreadyAPI: getRootUnreadyAPI(host),
|
|
150
|
+
unReadyEntryPoints: (): EntryPoint[] => getUnreadyEntryPoints(),
|
|
151
|
+
whyEntryPointUnready: (name: string) => {
|
|
152
|
+
const unreadyEntryPoint = _.find(
|
|
153
|
+
utils.unReadyEntryPoints(),
|
|
154
|
+
(entryPoint: EntryPoint) => entryPoint.name.toLowerCase() === name.toLowerCase()
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
const dependencies = _.invoke(unreadyEntryPoint, 'getDependencyAPIs')
|
|
158
|
+
|
|
159
|
+
const unreadyDependencies = _.filter(dependencies, key => !readyAPIs.has(getOwnSlotKey(key)))
|
|
160
|
+
if (!_.isEmpty(unreadyDependencies)) {
|
|
161
|
+
const unreadyDependenciesNames = _(unreadyDependencies).map('name').join(',')
|
|
162
|
+
console.log(`There are unready dependencies for ${name}: ${unreadyDependenciesNames}`)
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
findAPI: (name: string) => {
|
|
166
|
+
return _.filter(utils.apis(), (api: any) => api.key.name.toLowerCase().indexOf(name.toLowerCase()) !== -1)
|
|
167
|
+
},
|
|
168
|
+
getAPIOrEntryPointsDependencies: (
|
|
169
|
+
apisOrEntryPointsNames: string[],
|
|
170
|
+
entryPoints = [...addedShells.values()].map(x => x.entryPoint)
|
|
171
|
+
) => getAPIOrEntryPointsDependencies(apisOrEntryPointsNames, entryPoints),
|
|
172
|
+
performance: getPerformanceDebug(options, trace, memoizedArr)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (typeof globalThis === 'undefined') {
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
globalThis.repluggableAppDebug = {
|
|
180
|
+
host,
|
|
181
|
+
uniqueShellNames,
|
|
182
|
+
extensionSlots,
|
|
183
|
+
addedShells,
|
|
184
|
+
lazyShells,
|
|
185
|
+
readyAPIs,
|
|
186
|
+
shellInstallers,
|
|
187
|
+
utils,
|
|
188
|
+
hmr: {
|
|
189
|
+
hot
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Based on:
|
|
3
|
+
https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
|
|
4
|
+
https://gist.github.com/chadhutchins/1440602
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export class Graph {
|
|
8
|
+
private readonly map = new Map<string, Vertex>()
|
|
9
|
+
private addOrGetVertex(value: string) {
|
|
10
|
+
let vertex = this.map.get(value)
|
|
11
|
+
if (!vertex) {
|
|
12
|
+
vertex = new Vertex(value)
|
|
13
|
+
this.map.set(value, vertex)
|
|
14
|
+
}
|
|
15
|
+
return vertex
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getVertices() {
|
|
19
|
+
return this.map.values()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
addConnection(source: string, target: string) {
|
|
23
|
+
this.addOrGetVertex(source).connections.push(this.addOrGetVertex(target))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class Vertex {
|
|
28
|
+
connections: Vertex[] = []
|
|
29
|
+
index = -1
|
|
30
|
+
lowLink = -1
|
|
31
|
+
constructor(public name: string) {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getCycle(dependentGraph: { [key: string]: string[] }) {
|
|
35
|
+
let queue = Object.keys(dependentGraph).map(node => [node])
|
|
36
|
+
while (queue.length) {
|
|
37
|
+
const batch = []
|
|
38
|
+
for (const path of queue) {
|
|
39
|
+
const parents = dependentGraph[path[0]] || []
|
|
40
|
+
for (const node of parents) {
|
|
41
|
+
if (node === path[path.length - 1]) {
|
|
42
|
+
return [node, ...path]
|
|
43
|
+
}
|
|
44
|
+
batch.push([node, ...path])
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
queue = batch
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class Tarjan {
|
|
52
|
+
private index = 0
|
|
53
|
+
private readonly stack: Vertex[] = []
|
|
54
|
+
private readonly scc: Vertex[][] = []
|
|
55
|
+
constructor(private readonly graph: Graph) {}
|
|
56
|
+
|
|
57
|
+
run() {
|
|
58
|
+
for (const v of this.graph.getVertices()) {
|
|
59
|
+
if (v.index < 0) {
|
|
60
|
+
this.strongConnect(v)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return this.scc
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private strongConnect(vertex: Vertex) {
|
|
67
|
+
vertex.index = this.index
|
|
68
|
+
vertex.lowLink = this.index
|
|
69
|
+
this.index = this.index + 1
|
|
70
|
+
this.stack.push(vertex)
|
|
71
|
+
|
|
72
|
+
for (const w of vertex.connections) {
|
|
73
|
+
const v = vertex
|
|
74
|
+
if (w.index < 0) {
|
|
75
|
+
this.strongConnect(w)
|
|
76
|
+
v.lowLink = Math.min(v.lowLink, w.lowLink)
|
|
77
|
+
} else if (this.stack.some(x => x.name === w.name)) {
|
|
78
|
+
v.lowLink = Math.min(v.lowLink, w.index)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (vertex.lowLink === vertex.index) {
|
|
83
|
+
const vertices = []
|
|
84
|
+
let w = null
|
|
85
|
+
if (this.stack.length > 0) {
|
|
86
|
+
do {
|
|
87
|
+
w = this.stack.pop()
|
|
88
|
+
w && vertices.push(w)
|
|
89
|
+
} while (vertex.name !== w?.name)
|
|
90
|
+
}
|
|
91
|
+
if (vertices.length > 0) {
|
|
92
|
+
this.scc.push(vertices)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|