repluggable-core 0.0.0-pr343.49 → 0.0.0-pr345.55
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/debug/src/API.d.ts +7 -1
- package/dist/es/src/API.d.ts +7 -1
- package/dist/es/src/API.d.ts.map +1 -1
- package/dist/es/src/appHost.d.ts +2 -1
- package/dist/es/src/appHost.d.ts.map +1 -1
- package/dist/es/src/appHost.js +24 -2
- package/dist/es/src/appHost.js.map +1 -1
- package/dist/es/src/index.d.ts +1 -1
- package/dist/es/src/index.d.ts.map +1 -1
- package/dist/es/src/index.js +1 -1
- package/dist/es/src/index.js.map +1 -1
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts +3 -2
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +1 -1
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js +2 -1
- package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js.map +1 -1
- package/dist/es/test/appHost.spec.js +6 -1
- package/dist/es/test/appHost.spec.js.map +1 -1
- package/dist/src/API.d.ts +7 -1
- package/dist/src/API.d.ts.map +1 -1
- package/dist/src/appHost.d.ts +2 -1
- package/dist/src/appHost.d.ts.map +1 -1
- package/dist/src/appHost.js +26 -3
- package/dist/src/appHost.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts +3 -2
- package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +1 -1
- package/dist/src/repluggableAppDebug/repluggableAppDebug.js +2 -1
- package/dist/src/repluggableAppDebug/repluggableAppDebug.js.map +1 -1
- package/dist/test/appHost.spec.js +5 -0
- package/dist/test/appHost.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/API.ts +9 -1
- package/src/appHost.ts +34 -2
- package/src/index.ts +1 -1
- package/src/repluggableAppDebug/debug.d.ts +2 -1
- package/src/repluggableAppDebug/repluggableAppDebug.ts +4 -1
- package/test/appHost.spec.ts +7 -1
package/src/API.ts
CHANGED
|
@@ -50,11 +50,17 @@ export type ContributionPredicate = () => boolean
|
|
|
50
50
|
export interface EntryPointTags {
|
|
51
51
|
[name: string]: string
|
|
52
52
|
}
|
|
53
|
+
export type LazyEntryPointFactory = () => Promise<EntryPoint> //TODO: get rid of these
|
|
53
54
|
export type ShellsChangedCallback = (shellNames: string[]) => void
|
|
54
55
|
export type DeclarationsChangedCallback = () => void
|
|
55
56
|
export type UnsubscribeFromDeclarationsChanged = () => void
|
|
56
57
|
export type ShellBoundaryAspect = React.FunctionComponent<React.PropsWithChildren<unknown>>
|
|
57
58
|
|
|
59
|
+
export interface LazyEntryPointDescriptor {
|
|
60
|
+
readonly name: string
|
|
61
|
+
readonly factory: LazyEntryPointFactory
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
/**
|
|
59
65
|
* Application part that will receive a {Shell} when loaded into the {AppHost}
|
|
60
66
|
* @export
|
|
@@ -100,7 +106,7 @@ export interface EntryPoint {
|
|
|
100
106
|
detach?(shell: Shell): void
|
|
101
107
|
}
|
|
102
108
|
|
|
103
|
-
export type AnyEntryPoint = EntryPoint
|
|
109
|
+
export type AnyEntryPoint = EntryPoint | LazyEntryPointDescriptor
|
|
104
110
|
export type EntryPointOrPackage = AnyEntryPoint | AnyEntryPoint[]
|
|
105
111
|
export interface EntryPointOrPackagesMap {
|
|
106
112
|
[name: string]: EntryPointOrPackage
|
|
@@ -264,6 +270,8 @@ export interface AppHost {
|
|
|
264
270
|
* @return {boolean}
|
|
265
271
|
*/
|
|
266
272
|
hasShell(name: string): boolean
|
|
273
|
+
// TODO: Deprecate
|
|
274
|
+
isLazyEntryPoint(name: string): boolean
|
|
267
275
|
/**
|
|
268
276
|
* Dynamically add {Shell}s after the host is created
|
|
269
277
|
*
|
package/src/appHost.ts
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
ExtensionSlot,
|
|
19
19
|
FunctionWithSameArgs,
|
|
20
20
|
Lazy,
|
|
21
|
+
LazyEntryPointDescriptor,
|
|
22
|
+
LazyEntryPointFactory,
|
|
21
23
|
MemoizeMissHit,
|
|
22
24
|
ObservableState,
|
|
23
25
|
PrivateAppHost,
|
|
@@ -60,6 +62,13 @@ function castMultiArray<T>(v: T[] | T[][]): T[][] {
|
|
|
60
62
|
return isMultiArray(v) ? v : [v]
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
export const makeLazyEntryPoint = (name: string, factory: LazyEntryPointFactory): LazyEntryPointDescriptor => {
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
factory
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
export const mainViewSlotKey: SlotKey<ReactComponentContributor> = {
|
|
64
73
|
name: 'mainView'
|
|
65
74
|
}
|
|
@@ -173,6 +182,7 @@ export function createAppHost(initialEntryPointsOrPackages: EntryPointOrPackage[
|
|
|
173
182
|
const slotKeysByName = new Map<string, AnySlotKey>()
|
|
174
183
|
const addedShells = new Map<string, PrivateShell>()
|
|
175
184
|
const shellInstallers = new WeakMap<PrivateShell, string[]>()
|
|
185
|
+
const lazyShells = new Map<string, LazyEntryPointFactory>()
|
|
176
186
|
const shellsChangedCallbacks = new Map<string, ShellsChangedCallback>()
|
|
177
187
|
const declarationsChangedCallbacks = new Map<string, DeclarationsChangedCallback>()
|
|
178
188
|
const APILayers = new WeakMap<AnySlotKey, APILayer[] | undefined>()
|
|
@@ -194,6 +204,7 @@ export function createAppHost(initialEntryPointsOrPackages: EntryPointOrPackage[
|
|
|
194
204
|
getAllSlotKeys,
|
|
195
205
|
getAllEntryPoints,
|
|
196
206
|
hasShell,
|
|
207
|
+
isLazyEntryPoint,
|
|
197
208
|
addShells,
|
|
198
209
|
removeShells,
|
|
199
210
|
onShellsChanged,
|
|
@@ -213,6 +224,7 @@ export function createAppHost(initialEntryPointsOrPackages: EntryPointOrPackage[
|
|
|
213
224
|
extensionSlots,
|
|
214
225
|
addedShells,
|
|
215
226
|
shellInstallers,
|
|
227
|
+
lazyShells,
|
|
216
228
|
|
|
217
229
|
performance: {
|
|
218
230
|
options,
|
|
@@ -288,6 +300,11 @@ export function createAppHost(initialEntryPointsOrPackages: EntryPointOrPackage[
|
|
|
288
300
|
|
|
289
301
|
return host
|
|
290
302
|
|
|
303
|
+
//TODO: get rid of LazyEntryPointDescriptor
|
|
304
|
+
function isLazyEntryPointDescriptor(value: AnyEntryPoint): value is LazyEntryPointDescriptor {
|
|
305
|
+
return typeof (value as LazyEntryPointDescriptor).factory === 'function'
|
|
306
|
+
}
|
|
307
|
+
|
|
291
308
|
function enrichMemoization<T extends _.MemoizedFunction & Partial<MemoizeMissHit>>(memoized: T): T & MemoizeMissHit {
|
|
292
309
|
const memoizedWithMissHit = _.assign(memoized, {
|
|
293
310
|
miss: 0,
|
|
@@ -387,9 +404,15 @@ miss: ${memoizedWithMissHit.miss}
|
|
|
387
404
|
validateUniqueShellNames(entryPoints)
|
|
388
405
|
!options.disableCheckCircularDependencies && !options.experimentalCyclicMode && validateCircularDependency(allEntryPoints)
|
|
389
406
|
|
|
390
|
-
|
|
407
|
+
const [lazyEntryPointsList, readyEntryPointsList] = _.partition(entryPoints, isLazyEntryPointDescriptor) as [
|
|
408
|
+
LazyEntryPointDescriptor[],
|
|
409
|
+
EntryPoint[]
|
|
410
|
+
]
|
|
391
411
|
|
|
392
|
-
|
|
412
|
+
executeInstallShell(readyEntryPointsList)
|
|
413
|
+
lazyEntryPointsList.forEach(registerLazyEntryPoint)
|
|
414
|
+
|
|
415
|
+
setInstalledShellNames(getInstalledShellNames().concat(_.map(lazyEntryPointsList, 'name')))
|
|
393
416
|
return Promise.resolve()
|
|
394
417
|
}
|
|
395
418
|
|
|
@@ -639,6 +662,14 @@ miss: ${memoizedWithMissHit.miss}
|
|
|
639
662
|
return installedShellsSet[name] === true
|
|
640
663
|
}
|
|
641
664
|
|
|
665
|
+
function isLazyEntryPoint(name: string): boolean {
|
|
666
|
+
return lazyShells.has(name)
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function registerLazyEntryPoint(descriptor: LazyEntryPointDescriptor): void {
|
|
670
|
+
lazyShells.set(descriptor.name, descriptor.factory)
|
|
671
|
+
}
|
|
672
|
+
|
|
642
673
|
function getOwnSlotKey<T>(key: SlotKey<T>): SlotKey<T> {
|
|
643
674
|
if (key.public === true) {
|
|
644
675
|
const ownKey = slotKeysByName.get(slotKeyToName(key))
|
|
@@ -968,6 +999,7 @@ miss: ${memoizedWithMissHit.miss}
|
|
|
968
999
|
getAllSlotKeys: host.getAllSlotKeys,
|
|
969
1000
|
getAllEntryPoints: host.getAllEntryPoints,
|
|
970
1001
|
hasShell: host.hasShell,
|
|
1002
|
+
isLazyEntryPoint: host.isLazyEntryPoint,
|
|
971
1003
|
onShellsChanged: host.onShellsChanged,
|
|
972
1004
|
onDeclarationsChanged: host.onDeclarationsChanged,
|
|
973
1005
|
removeShellsChangedCallback: host.removeShellsChangedCallback,
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ export {
|
|
|
29
29
|
|
|
30
30
|
export { ConsoleHostLogger } from './loggers'
|
|
31
31
|
|
|
32
|
-
export { createAppHost, mainViewSlotKey, stateSlotKey } from './appHost'
|
|
32
|
+
export { createAppHost, makeLazyEntryPoint, mainViewSlotKey, stateSlotKey } from './appHost'
|
|
33
33
|
|
|
34
34
|
export { AppHostServicesProvider } from './appHostServices'
|
|
35
35
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntryPoint, AppHost, AnySlotKey, PrivateShell, SlotKey } from '../API'
|
|
1
|
+
import { EntryPoint, AppHost, AnySlotKey, LazyEntryPointFactory, PrivateShell, SlotKey } from '../API'
|
|
2
2
|
import { AnyExtensionSlot } from '../extensionSlot'
|
|
3
3
|
import { Hot } from '../hot'
|
|
4
4
|
|
|
@@ -12,6 +12,7 @@ export interface RepluggableAppDebugInfo {
|
|
|
12
12
|
uniqueShellNames: Set<string>
|
|
13
13
|
extensionSlots: Map<AnySlotKey, AnyExtensionSlot>
|
|
14
14
|
addedShells: Map<string, PrivateShell>
|
|
15
|
+
lazyShells: Map<string, LazyEntryPointFactory>
|
|
15
16
|
readyAPIs: Set<AnySlotKey>
|
|
16
17
|
shellInstallers: WeakMap<PrivateShell, string[]>
|
|
17
18
|
utils: RepluggableDebugUtils
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPerformanceDebug } from './performanceDebugInfo'
|
|
2
|
-
import { AnySlotKey, AppHost, EntryPoint, PrivateShell, SlotKey, StatisticsMemoization, Trace } from '../API'
|
|
2
|
+
import { AnySlotKey, AppHost, EntryPoint, LazyEntryPointFactory, PrivateShell, SlotKey, StatisticsMemoization, Trace } from '../API'
|
|
3
3
|
import _ from 'lodash'
|
|
4
4
|
import { hot } from '../hot'
|
|
5
5
|
import { AppHostServicesProvider } from '../appHostServices'
|
|
@@ -18,6 +18,7 @@ interface SetupDebugInfoParams {
|
|
|
18
18
|
extensionSlots: Map<AnySlotKey, AnyExtensionSlot>
|
|
19
19
|
addedShells: Map<string, PrivateShell>
|
|
20
20
|
shellInstallers: WeakMap<PrivateShell, string[]>
|
|
21
|
+
lazyShells: Map<string, LazyEntryPointFactory>
|
|
21
22
|
|
|
22
23
|
performance: PerformanceDebugParams
|
|
23
24
|
|
|
@@ -132,6 +133,7 @@ export function setupDebugInfo({
|
|
|
132
133
|
getUnreadyEntryPoints,
|
|
133
134
|
extensionSlots,
|
|
134
135
|
addedShells,
|
|
136
|
+
lazyShells,
|
|
135
137
|
shellInstallers,
|
|
136
138
|
performance: { options, trace, memoizedArr }
|
|
137
139
|
}: SetupDebugInfoParams) {
|
|
@@ -179,6 +181,7 @@ export function setupDebugInfo({
|
|
|
179
181
|
uniqueShellNames,
|
|
180
182
|
extensionSlots,
|
|
181
183
|
addedShells,
|
|
184
|
+
lazyShells,
|
|
182
185
|
readyAPIs,
|
|
183
186
|
shellInstallers,
|
|
184
187
|
utils,
|
package/test/appHost.spec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
2
|
|
|
3
|
-
import { createAppHost, mainViewSlotKey, stateSlotKey } from '../src/appHost'
|
|
3
|
+
import { createAppHost, mainViewSlotKey, makeLazyEntryPoint, stateSlotKey } from '../src/appHost'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
AnySlotKey,
|
|
@@ -207,6 +207,12 @@ describe('App Host', () => {
|
|
|
207
207
|
it('should not install multiple shells with the same name', () => {
|
|
208
208
|
expect(() => createAppHost([mockPackage, _.pick(mockPackage, 'name')], testHostOptions)).toThrow()
|
|
209
209
|
})
|
|
210
|
+
|
|
211
|
+
it('should install lazy shells', () => {
|
|
212
|
+
const lazyEntryPoint = makeLazyEntryPoint(mockPackage.name, async () => mockPackage)
|
|
213
|
+
const host = createAppHost([lazyEntryPoint], testHostOptions)
|
|
214
|
+
expect(host.hasShell(lazyEntryPoint.name)).toBe(true)
|
|
215
|
+
})
|
|
210
216
|
})
|
|
211
217
|
|
|
212
218
|
describe('EntryPoint lifecycle state', () => {
|