Skip to content

Commit

Permalink
Remove devtools dependency from runtime.ts (PolymerLabs#4194)
Browse files Browse the repository at this point in the history
Having issues importing devtools into Google at the moment, so I'm
removing this direct dependency for now. The shell code now injects the
devtools inspect into Runtime.spawnArc() call.
  • Loading branch information
csilvestrini authored Nov 29, 2019
1 parent b4128ca commit f74d6f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
11 changes: 10 additions & 1 deletion shells/lib/components/arc-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ArcType} from '../../../build/runtime/type.js';
import {logsFactory} from '../../../build/platform/logs-factory.js';
import {Runtime} from '../../../build/runtime/runtime.js';
import {SyntheticStores} from '../synthetic-stores.js';
import {devtoolsArcInspectorFactory} from '../../../build/devtools-connector/devtools-arc-inspector.js';

const {log, warn, error} = logsFactory('ArcHost', '#cade57');

Expand Down Expand Up @@ -71,7 +72,15 @@ export class ArcHost {
return serialization;
}
async _spawn(context, composer, storage, id, serialization, portFactories) {
return await Runtime.spawnArc({id, context, composer, serialization, storage: `${storage}/${id}`, portFactories});
return await Runtime.spawnArc({
id,
context,
composer,
serialization,
storage: `${storage}/${id}`,
portFactories,
inspectorFactory: devtoolsArcInspectorFactory,
});
}
async instantiateDefaultRecipe(arc, manifest) {
log('instantiateDefaultRecipe');
Expand Down
5 changes: 3 additions & 2 deletions shells/pipes-shell/source/verbs/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {Runtime} from '../../../../build/runtime/runtime.js';
import {recipeByName, instantiateRecipe} from '../lib/utils.js';
import {portIndustry} from '../pec-port.js';
import {logsFactory} from '../../../../build/platform/logs-factory.js';
import {devtoolsArcInspectorFactory} from '../../../../build/devtools-connector/devtools-arc-inspector.js';

const {warn} = logsFactory('pipe');

Expand All @@ -28,7 +29,8 @@ export const spawn = async ({modality, recipe}, tid, bus, composerFactory, stora
//storage,
id: generateId(),
composer: composerFactory(modality, bus, tid),
portFactories: [portIndustry(bus)]
portFactories: [portIndustry(bus)],
inspectorFactory: devtoolsArcInspectorFactory,
});
if (contextRecipe) {
// instantiate optional recipe
Expand All @@ -37,4 +39,3 @@ export const spawn = async ({modality, recipe}, tid, bus, composerFactory, stora
return arc;
}
};

10 changes: 4 additions & 6 deletions src/runtime/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {RecipeResolver} from './recipe/recipe-resolver.js';
import {Loader} from '../platform/loader.js';
import {pecIndustry} from '../platform/pec-industry.js';
import {logsFactory} from '../platform/logs-factory.js';
import {devtoolsArcInspectorFactory} from '../devtools-connector/devtools-arc-inspector.js';

const {warn} = logsFactory('Runtime', 'orange');

Expand All @@ -48,7 +47,8 @@ type SpawnArgs = {
context: Manifest,
composer: SlotComposer,
storage: string,
portFactories: []
portFactories: [],
inspectorFactory?: ArcInspectorFactory
};

let runtime: Runtime | null = null;
Expand Down Expand Up @@ -300,7 +300,7 @@ export class Runtime {

// TODO(sjmiles): redundant vs. newArc, but has some impedance mismatch
// strategy is to merge first, unify second
async spawnArc({id, serialization, context, composer, storage, portFactories}: SpawnArgs): Promise<Arc> {
async spawnArc({id, serialization, context, composer, storage, portFactories, inspectorFactory}: SpawnArgs): Promise<Arc> {
const params = {
id: IdGenerator.newSession().newArcId(id),
fileName: './serialized.manifest',
Expand All @@ -310,9 +310,7 @@ export class Runtime {
slotComposer: composer,
pecFactories: [this.pecFactory, ...(portFactories || [])],
loader: this.loader,
// TODO(sjmiles): maybe doesn't belong here, but empirically it's
// wanted in (almost?) all Arc instantiations
inspectorFactory: devtoolsArcInspectorFactory
inspectorFactory,
};
return serialization ? Arc.deserialize(params) : new Arc(params);
}
Expand Down

0 comments on commit f74d6f6

Please sign in to comment.