From 9058ac82d5564c9640c62179b1b542b60a4d33f7 Mon Sep 17 00:00:00 2001 From: kangwei Date: Mon, 22 Jun 2020 11:09:01 +0800 Subject: [PATCH] fix: add extraEnv --- packages/designer/src/builtin-simulator/host.ts | 3 +++ packages/editor-preset-vision/src/bundle/bundle.ts | 6 +++--- packages/editor-preset-vision/src/bundle/prototype.ts | 2 +- packages/editor-preset-vision/src/bundle/trunk.ts | 2 +- packages/plugin-designer/src/index.tsx | 8 ++++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index bc5b70e1c..1283d1e53 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -40,6 +40,7 @@ export interface BuiltinSimulatorProps { device?: 'mobile' | 'iphone' | string; deviceClassName?: string; environment?: Asset; + extraEnvironment?: Asset; library?: LibraryItem[]; simulatorUrl?: Asset; theme?: Asset; @@ -187,6 +188,8 @@ export class BuiltinSimulatorHost implements ISimulatorHost { + propList.forEach((proto: any, index: number) => { if (Array.isArray(proto)) { this.recursivelyRegisterPrototypes(proto, cp); return; } - if (proto instanceof Prototype) { + if (isPrototype(proto)) { const componentName = proto.getComponentName()!; if (!proto.getView() && this.viewsMap[componentName]) { proto.setView(this.viewsMap[componentName]); diff --git a/packages/editor-preset-vision/src/bundle/prototype.ts b/packages/editor-preset-vision/src/bundle/prototype.ts index fa715382e..90553cb73 100644 --- a/packages/editor-preset-vision/src/bundle/prototype.ts +++ b/packages/editor-preset-vision/src/bundle/prototype.ts @@ -217,7 +217,7 @@ class Prototype { } readonly isPrototype = true; - private meta: ComponentMeta; + readonly meta: ComponentMeta; readonly options: OldPrototypeConfig | ComponentMetadata; constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta) { diff --git a/packages/editor-preset-vision/src/bundle/trunk.ts b/packages/editor-preset-vision/src/bundle/trunk.ts index e4e41e35d..f38f1db2c 100644 --- a/packages/editor-preset-vision/src/bundle/trunk.ts +++ b/packages/editor-preset-vision/src/bundle/trunk.ts @@ -35,7 +35,7 @@ export class Trunk { bundle = this.trunk[i]; prototype = bundle.get(name); if (prototype) { - return prototype; + return (prototype.meta as any).prototype; } } return this.metaBundle.getFromMeta(name); diff --git a/packages/plugin-designer/src/index.tsx b/packages/plugin-designer/src/index.tsx index 88647e809..aac7dab28 100644 --- a/packages/plugin-designer/src/index.tsx +++ b/packages/plugin-designer/src/index.tsx @@ -10,6 +10,7 @@ export interface PluginProps { interface DesignerPluginState { componentMetadatas?: any[] | null; library?: any[] | null; + extraEnvironment?: any[] | null; } export default class DesignerPlugin extends PureComponent { @@ -18,6 +19,7 @@ export default class DesignerPlugin extends PureComponent );