@easy-editor/core 1.0.2 → 1.0.3

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.
@@ -1,3 +1,4 @@
1
+ export * from './resource-consumer';
1
2
  export * from './simulator';
2
3
  export * from './simulator-renderer';
3
4
  export * from './viewport';
@@ -0,0 +1,17 @@
1
+ import type { Simulator } from './simulator';
2
+ import { type SimulatorRenderer } from './simulator-renderer';
3
+ export type MasterProvider = (master: Simulator) => any;
4
+ export type RendererConsumer<T> = (renderer: SimulatorRenderer, data: T) => Promise<any>;
5
+ export default class ResourceConsumer<T = any> {
6
+ private consumer?;
7
+ private emitter;
8
+ private accessor _data;
9
+ private _providing?;
10
+ private _consuming?;
11
+ private _firstConsumed;
12
+ private resolveFirst?;
13
+ constructor(provider: () => T, consumer?: RendererConsumer<T> | undefined);
14
+ consume(consumerOrRenderer: SimulatorRenderer | ((data: T) => any)): void;
15
+ dispose(): void;
16
+ waitFirstConsume(): Promise<any>;
17
+ }
@@ -4,6 +4,7 @@ import type { Scroller } from '../designer/scroller';
4
4
  import { type Node } from '../document';
5
5
  import type { Project } from '../project';
6
6
  import type { ComponentInstance, DataSourceEngine, Snippet } from '../types';
7
+ import type { Asset } from '../types/assets';
7
8
  import type { SimulatorRenderer } from './simulator-renderer';
8
9
  import { Viewport } from './viewport';
9
10
  export interface DropContainer {
@@ -43,6 +44,7 @@ export declare class Simulator {
43
44
  get excuteLifeCycleInDesignMode(): any;
44
45
  get notFoundComponent(): any;
45
46
  get faultComponent(): any;
47
+ get componentsAsset(): Asset | undefined;
46
48
  get deviceStyle(): DeviceStyleProps | undefined;
47
49
  get componentsMap(): {
48
50
  [key: string]: any;
@@ -72,7 +74,7 @@ export declare class Simulator {
72
74
  * force to rerender the viewport
73
75
  */
74
76
  rerender(): void;
75
- mountContentFrame(iframe: HTMLIFrameElement | HTMLElement | null): void;
77
+ mountContentFrame(iframe: HTMLIFrameElement | HTMLElement | null): Promise<void>;
76
78
  postEvent(eventName: string, ...data: any[]): void;
77
79
  linkSnippet(ref: HTMLElement, snippet: Snippet): () => void;
78
80
  setSuspense(suspended: boolean): boolean;
@@ -0,0 +1,32 @@
1
+ export declare enum AssetLevel {
2
+ Environment = 1,
3
+ Library = 2,
4
+ Theme = 3,
5
+ Runtime = 4,
6
+ Components = 5,
7
+ App = 6
8
+ }
9
+ export declare const AssetLevels: AssetLevel[];
10
+ export type URL = string;
11
+ export declare enum AssetType {
12
+ JSUrl = "jsUrl",
13
+ CSSUrl = "cssUrl",
14
+ CSSText = "cssText",
15
+ JSText = "jsText",
16
+ Bundle = "bundle"
17
+ }
18
+ export interface AssetItem {
19
+ type: AssetType;
20
+ content?: string | null;
21
+ device?: string;
22
+ level?: AssetLevel;
23
+ id?: string;
24
+ scriptType?: string;
25
+ }
26
+ export type AssetList = Array<Asset | undefined | null>;
27
+ export type Asset = AssetList | AssetBundle | AssetItem | URL;
28
+ export interface AssetBundle {
29
+ type: AssetType.Bundle;
30
+ level?: AssetLevel;
31
+ assets?: Asset | AssetList | null;
32
+ }
@@ -1,3 +1,4 @@
1
+ import { NpmInfo } from './npm-info';
1
2
  export type ComponentInstance = any;
2
3
  export type ComponentType<T = any> = any;
3
4
  /**
@@ -14,15 +15,11 @@ export interface LowCodeComponent {
14
15
  */
15
16
  componentName: string;
16
17
  }
17
- export interface ProCodeComponent {
18
+ export interface ProCodeComponent extends NpmInfo {
18
19
  /**
19
20
  * 研发模式
20
21
  */
21
22
  devMode: 'proCode';
22
- /**
23
- * 组件名称
24
- */
25
- componentName: string;
26
23
  }
27
24
  export type ComponentMap = ProCodeComponent | LowCodeComponent;
28
25
  export type ComponentsMap = ComponentMap[];
@@ -1,8 +1,10 @@
1
+ export * from './assets';
1
2
  export * from './common';
2
3
  export * from './component';
3
4
  export * from './data-source';
4
5
  export * from './editor';
5
6
  export * from './event';
6
7
  export * from './meta';
8
+ export * from './npm-info';
7
9
  export * from './schema';
8
10
  export * from './setter';
@@ -1,6 +1,7 @@
1
1
  import type { SettingField } from '../designer';
2
2
  import type { Node, PropKey } from '../document';
3
3
  import type { ComponentType } from './component';
4
+ import type { NpmInfo } from './npm-info';
4
5
  import type { NodeSchema } from './schema';
5
6
  import type { DynamicSetter, SetterType } from './setter';
6
7
  export interface ComponentMetadata {
@@ -17,6 +18,10 @@ export interface ComponentMetadata {
17
18
  * component dev mode
18
19
  */
19
20
  devMode?: 'proCode' | 'lowCode';
21
+ /**
22
+ * npm 源引入完整描述对象
23
+ */
24
+ npm?: NpmInfo;
20
25
  /**
21
26
  * component configure, for right panel to use setter to config component
22
27
  */
@@ -0,0 +1,37 @@
1
+ /**
2
+ * npm 源引入完整描述对象
3
+ */
4
+ export interface NpmInfo {
5
+ /**
6
+ * 源码组件名称
7
+ */
8
+ componentName?: string;
9
+ /**
10
+ * 源码组件库名
11
+ */
12
+ package: string;
13
+ /**
14
+ * 源码组件版本号
15
+ */
16
+ version?: string;
17
+ /**
18
+ * 是否解构
19
+ */
20
+ destructuring?: boolean;
21
+ /**
22
+ * 源码组件名称(导出名)
23
+ */
24
+ exportName?: string;
25
+ /**
26
+ * 子组件名
27
+ */
28
+ subName?: string;
29
+ /**
30
+ * 组件路径
31
+ */
32
+ main?: string;
33
+ /**
34
+ * UMD 全局变量名(扩展字段)
35
+ */
36
+ globalName?: string;
37
+ }
@@ -1,4 +1,5 @@
1
1
  import type { CompositeValue, JSExpression, JSFunction, JSONObject, PropsMap } from '../document';
2
+ import type { ComponentsMap } from './component';
2
3
  import type { DataSource } from './data-source';
3
4
  export interface ProjectSchema<T = RootSchema> {
4
5
  id?: string;
@@ -9,7 +10,7 @@ export interface ProjectSchema<T = RootSchema> {
9
10
  /**
10
11
  * 组件映射关系
11
12
  */
12
- componentsMap?: any;
13
+ componentsMap?: ComponentsMap;
13
14
  /**
14
15
  * 组件树
15
16
  */
@@ -1,5 +1,5 @@
1
1
  import type { Viewport } from '../simulator/viewport';
2
- import type { ComponentMap, LowCodeComponent, ProCodeComponent, SetterConfig } from '../types';
2
+ import type { ComponentMap, LowCodeComponent, NodeSchema, NpmInfo, ProCodeComponent, SetterConfig } from '../types';
3
3
  export declare const isObject: (value: any) => value is Record<string, unknown>;
4
4
  export declare const isPlainObject: (value: any) => value is any;
5
5
  export declare const isTextNode: (node: any) => node is Text;
@@ -16,3 +16,6 @@ export declare const isProCodeComponentType: (desc: ComponentMap) => desc is Pro
16
16
  export declare const isLowCodeComponentType: (desc: ComponentMap) => desc is LowCodeComponent;
17
17
  export declare const isSetterConfig: (obj: any) => obj is SetterConfig;
18
18
  export declare const isPluginEventName: (eventName: string) => boolean;
19
+ export declare const isRemoteComponent: (schema: NodeSchema | {
20
+ npm: NpmInfo;
21
+ }) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-editor/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A cross-framework low-code engine with scale-out design",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",