Skip to content

Commit

Permalink
pseudo code for loading np browser shims
Browse files Browse the repository at this point in the history
  • Loading branch information
epixa committed Mar 10, 2019
1 parent 889457d commit e720b27
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CoreSystem {
});
}

public start() {
public async start() {
try {
// ensure the rootDomElement is empty
this.rootDomElement.textContent = '';
Expand All @@ -125,7 +125,7 @@ export class CoreSystem {
notifications,
});

this.legacyPlatform.start({
await this.legacyPlatform.start({
i18n,
injectedMetadata,
fatalErrors,
Expand Down
24 changes: 23 additions & 1 deletion src/core/public/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface LegacyPlatformParams {
export class LegacyPlatformService {
constructor(private readonly params: LegacyPlatformParams) {}

public start(deps: Deps) {
public async start(deps: Deps) {
const {
i18n,
injectedMetadata,
Expand Down Expand Up @@ -86,6 +86,28 @@ export class LegacyPlatformService {
// the bootstrap module can modify the environment a bit first
const bootstrapModule = this.loadBootstrapModule();

// emulates new platform-like loading cycle
// can replace hacks and chrome uiExports

// shim plugin instantiation
// @ts-ignore
const plugins = injectedMetadata.getSortedPluginNames().map((name: string) => {
const { shim } = require(`plugins/${name}/np_plugin`);
return { name, plugin: shim() };
});

// shim setup task
for (const { name, plugin } of plugins) {
const { shim } = require(`plugins/${name}/np_plugin_setup`);
await shim(plugin);
}

// shim start task
for (const { name, plugin } of plugins) {
const { shim } = require(`plugins/${name}/np_plugin_start`);
await shim(plugin);
}

// require the files that will tie into the legacy platform
this.params.requireLegacyFiles();

Expand Down

0 comments on commit e720b27

Please sign in to comment.