@chamn/engine 0.0.45 → 0.1.0

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.
Files changed (56) hide show
  1. package/README.md +5 -2
  2. package/dist/component/CSSEditor/index.d.ts +1 -1
  3. package/dist/component/CSSSizeInput/index.d.ts +1 -1
  4. package/dist/component/CSSUIPanel/BackgroundInput/index.d.ts +3 -1
  5. package/dist/component/CSSUIPanel/BorderInput/index.d.ts +3 -1
  6. package/dist/component/CSSUIPanel/FontInput/index.d.ts +3 -1
  7. package/dist/component/CSSUIPanel/MarginAndPaddingInput/index.d.ts +1 -1
  8. package/dist/component/CSSUIPanel/type.d.ts +1 -0
  9. package/dist/component/CustomColorPicker/index.d.ts +8 -0
  10. package/dist/component/CustomSchemaForm/components/Form/Field/index.d.ts +1 -1
  11. package/dist/component/CustomSchemaForm/components/SetterSwitcher/index.d.ts +1 -1
  12. package/dist/component/CustomSchemaForm/components/Setters/ArraySetter/ArrayItem.d.ts +1 -1
  13. package/dist/component/CustomSchemaForm/components/Setters/ArraySetter/SortItemOrderModal.d.ts +1 -2
  14. package/dist/component/CustomSchemaForm/components/Setters/ArraySetter/index.d.ts +1 -2
  15. package/dist/component/CustomSchemaForm/components/Setters/index.d.ts +1 -1
  16. package/dist/component/CustomSchemaForm/context.d.ts +2 -0
  17. package/dist/component/DesignerSizer/index.d.ts +4 -0
  18. package/dist/component/InputNumberPlus/index.d.ts +1 -2
  19. package/dist/component/MonacoEditor/index.d.ts +1 -2
  20. package/dist/component/Workbench/index.d.ts +1 -1
  21. package/dist/component/index.d.ts +8 -0
  22. package/dist/index.d.ts +8 -23
  23. package/dist/index.js +82 -63
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +17081 -15753
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/material/innerMaterial.d.ts +1 -1
  28. package/dist/plugins/AdvancePanel/index.d.ts +1 -2
  29. package/dist/plugins/ComponentLibrary/components/DragItem/index.d.ts +1 -1
  30. package/dist/plugins/ComponentLibrary/components/ListView/index.d.ts +1 -2
  31. package/dist/plugins/ComponentStatePanel/index.d.ts +1 -2
  32. package/dist/plugins/Designer/components/Canvas/advanceCustomHook.d.ts +1 -0
  33. package/dist/plugins/Designer/components/Canvas/index.d.ts +4 -6
  34. package/dist/plugins/Designer/components/DefaultSelectToolBar/index.d.ts +8 -6
  35. package/dist/plugins/Designer/components/GhostView/index.d.ts +1 -2
  36. package/dist/plugins/Designer/type.d.ts +4 -1
  37. package/dist/plugins/DisplaySourceSchema/index.d.ts +2 -2
  38. package/dist/plugins/GlobalStatePanel/index.d.ts +0 -1
  39. package/dist/plugins/Hotkeys/action.d.ts +11 -0
  40. package/dist/plugins/Hotkeys/hotKeyManager.d.ts +35 -0
  41. package/dist/plugins/Hotkeys/index.d.ts +2 -0
  42. package/dist/plugins/Hotkeys/keymap.d.ts +20 -0
  43. package/dist/plugins/Hotkeys/localize/en_US/index.d.ts +1 -0
  44. package/dist/plugins/Hotkeys/localize/index.d.ts +2 -0
  45. package/dist/plugins/Hotkeys/localize/zh_CN/index.d.ts +1 -0
  46. package/dist/plugins/Hotkeys/utils.d.ts +4 -0
  47. package/dist/plugins/OutlineTree/components/TreeView/index.d.ts +1 -1
  48. package/dist/plugins/OutlineTree/components/TreeView/treeNode.d.ts +1 -2
  49. package/dist/plugins/OutlineTree/index.d.ts +0 -1
  50. package/dist/plugins/PropertyPanel/index.d.ts +1 -2
  51. package/dist/plugins/RightPanel/view.d.ts +1 -1
  52. package/dist/plugins/VisualPanelPlus/index.d.ts +1 -2
  53. package/dist/plugins/index.d.ts +14 -1
  54. package/dist/style.css +1 -1
  55. package/dist/type.d.ts +25 -0
  56. package/package.json +12 -12
package/README.md CHANGED
@@ -16,9 +16,12 @@ npm i @chamn/engine @chamn/model @chamn/render
16
16
 
17
17
  [Example Project](https://github.com/ByteCrazy/chameleon-demo)
18
18
 
19
- ### ScreenSnapshoot
19
+ ### ScreenSnapshot
20
20
 
21
- ![image](https://user-images.githubusercontent.com/13299648/218920616-302a9eb6-a71a-4f4b-8e77-d892972eee2f.png)
21
+ <img width="1776" alt="image" src="https://github.com/user-attachments/assets/7b06dc4c-80a3-455d-bc91-14a1cf1fb331">
22
+
23
+
24
+ ![image](https://github.com/hlerenow/chameleon/blob/master/packages/engine/md-images/layout.gif)
22
25
 
23
26
  ![image](https://user-images.githubusercontent.com/13299648/218920783-0d1cc275-a238-4d80-a717-dbbbf54b4713.png)
24
27
 
@@ -12,5 +12,5 @@ export type CSSEditorProps = {
12
12
  initialValue?: CSSVal;
13
13
  handler?: MutableRefObject<CSSEditorRef | null>;
14
14
  };
15
- export declare const CSSEditor: (props: CSSEditorProps) => JSX.Element;
15
+ export declare const CSSEditor: (props: CSSEditorProps) => import("react/jsx-runtime").JSX.Element;
16
16
  export {};
@@ -35,5 +35,5 @@ export type CSSSizeInputProps = {
35
35
  cumulativeTransform?: (params: CumulativeInfoType) => CumulativeInfoType;
36
36
  unitList?: (keyof MinMaxType)[];
37
37
  };
38
- export declare const CSSSizeInput: (props: CSSSizeInputProps) => JSX.Element;
38
+ export declare const CSSSizeInput: (props: CSSSizeInputProps) => import("react/jsx-runtime").JSX.Element;
39
39
  export {};
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { InputCommonRef } from '../type';
3
- type Value = Record<'background-color' | 'background-image' | 'background-repeat' | 'background-size', string>;
3
+ declare const CSS_BACKGROUND_KEY_LIST: readonly ["background-color", "background-image", "background-repeat", "background-size"];
4
+ type CSSBackgroundKeyType = typeof CSS_BACKGROUND_KEY_LIST[number];
5
+ type Value = Record<CSSBackgroundKeyType, string>;
4
6
  export type BackgroundInputProps = {
5
7
  value?: Value;
6
8
  initialValue?: Value;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { InputCommonRef } from '../type';
3
- type Value = Record<'border' | 'border-radius', string>;
3
+ declare const CSS_BORDER_KEY_LIST: readonly ["border", "border-radius"];
4
+ type CSSBorderKeyType = typeof CSS_BORDER_KEY_LIST[number];
5
+ type Value = Record<CSSBorderKeyType, string>;
4
6
  export type BorderInputProps = {
5
7
  value?: Value;
6
8
  initialValue?: Value;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { InputCommonRef } from '../type';
3
- type Value = Record<'font-size' | 'color' | 'text-align' | 'font-weight', string>;
3
+ declare const FONT_CSS_KEY_LIST: readonly ["font-size", "color", "text-align", "font-weight"];
4
+ type FontKeyType = typeof FONT_CSS_KEY_LIST[number];
5
+ type Value = Record<FontKeyType, string>;
4
6
  export type FontInputProps = {
5
7
  initialValue?: Value;
6
8
  value?: Value;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { InputCommonRef } from '../type';
3
- type Value = Record<'left' | 'right' | 'top' | 'bottom' | 'all', string>;
3
+ type Value = Record<string, string>;
4
4
  export type MarginAndPaddingInputProps = {
5
5
  value?: Value;
6
6
  initialValue?: Value;
@@ -1,3 +1,4 @@
1
1
  export type InputCommonRef = {
2
2
  setValue: (newVal: Record<string, string>) => void;
3
+ setEmptyValue: () => void;
3
4
  };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ColorPickerProps } from 'antd';
3
+ export type CustomColorPickerRef = {
4
+ updateColor: (color: string) => void;
5
+ };
6
+ export declare const CustomColorPicker: import("react").ForwardRefExoticComponent<Omit<ColorPickerProps, "onChange"> & {
7
+ onChange: (color: string) => void;
8
+ } & import("react").RefAttributes<CustomColorPickerRef>>;
@@ -9,4 +9,4 @@ export type CFieldProps = {
9
9
  noStyle?: boolean;
10
10
  hiddenLabel?: boolean;
11
11
  };
12
- export declare const CField: (props: CFieldProps) => JSX.Element | null;
12
+ export declare const CField: (props: CFieldProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -11,4 +11,4 @@ export type SetterSwitcherProps = {
11
11
  style?: React.CSSProperties;
12
12
  useField?: boolean;
13
13
  } & Omit<CFieldProps, 'children'>;
14
- export declare const SetterSwitcher: ({ setters, keyPaths, condition, useField, ...props }: SetterSwitcherProps) => JSX.Element;
14
+ export declare const SetterSwitcher: ({ setters, keyPaths, condition, useField, ...props }: SetterSwitcherProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,4 +8,4 @@ export declare function ArrayItem(props: {
8
8
  style: React.CSSProperties;
9
9
  onValueChange: (val: Record<string, any>) => void;
10
10
  onDelete: () => void;
11
- }): JSX.Element;
11
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ModalProps } from 'antd';
3
2
  export type SortItemOrderProps = {
4
3
  list: any[];
@@ -7,4 +6,4 @@ export type SortItemOrderProps = {
7
6
  sortLabelKey?: string;
8
7
  onValueChange?: (newList: any[]) => void;
9
8
  } & ModalProps;
10
- export declare const SortItemOrderModal: ({ list, onValueChange, keyPaths, label, sortLabelKey, ...modalProps }: SortItemOrderProps) => JSX.Element;
9
+ export declare const SortItemOrderModal: ({ list, onValueChange, keyPaths, label, sortLabelKey, ...modalProps }: SortItemOrderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CSetterProps } from '../type';
3
2
  import { SetterType } from '@chamn/model';
4
3
  export type CArraySetterProps = {
@@ -9,6 +8,6 @@ export type CArraySetterProps = {
9
8
  sortLabelKey?: string;
10
9
  };
11
10
  export declare const ArraySetter: {
12
- ({ onValueChange, setterContext, item: { setters, initialValue: itemInitialValue }, sortLabelKey, initialValue, ...props }: CSetterProps<CArraySetterProps>): JSX.Element;
11
+ ({ onValueChange, setterContext, item: { setters, initialValue: itemInitialValue }, sortLabelKey, initialValue, ...props }: CSetterProps<CArraySetterProps>): import("react/jsx-runtime").JSX.Element;
13
12
  setterName: string;
14
13
  };
@@ -1,4 +1,4 @@
1
1
  import { CSetter } from './type';
2
- declare const _default: Record<string, CSetter<any>>;
2
+ declare const _default: Record<string, CSetter>;
3
3
  export default _default;
4
4
  export * from './type';
@@ -2,6 +2,7 @@ import React, { Ref } from 'react';
2
2
  import { CustomSchemaFormInstance } from '.';
3
3
  import { CPluginCtx } from '../../core/pluginManager';
4
4
  import { CForm } from './components/Form';
5
+ import { CFormContextData } from './components/Form/context';
5
6
  export type ContextState = Record<string, any>;
6
7
  export type CCustomSchemaFormContextData = {
7
8
  onSetterChange: (keyPaths: string[], setterName: string) => void;
@@ -9,6 +10,7 @@ export type CCustomSchemaFormContextData = {
9
10
  name: string;
10
11
  setter: string;
11
12
  }>;
13
+ customSetterMap: CFormContextData['customSetterMap'];
12
14
  formRef?: Ref<CustomSchemaFormInstance | CForm>;
13
15
  pluginCtx?: CPluginCtx;
14
16
  };
@@ -0,0 +1,4 @@
1
+ import { EnginContext } from '../../type';
2
+ export declare const DesignerSizer: (props: {
3
+ ctx: EnginContext;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { InputProps } from 'antd';
3
2
  export type InputNumberPlusProps = Omit<InputProps, 'onChange'> & {
4
3
  min?: number;
@@ -6,4 +5,4 @@ export type InputNumberPlusProps = Omit<InputProps, 'onChange'> & {
6
5
  value?: number;
7
6
  onChange?: (newVal: number | undefined) => void;
8
7
  };
9
- export declare const InputNumberPlus: ({ min, max, value, onChange, addonAfter, ...restProps }: InputNumberPlusProps) => JSX.Element;
8
+ export declare const InputNumberPlus: ({ min, max, value, onChange, addonAfter, ...restProps }: InputNumberPlusProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { EditorProps, Monaco } from '@monaco-editor/react';
3
2
  type EditorType = EditorProps;
4
3
  export type MonacoEditorInstance = Parameters<Required<EditorType>['onMount']>[0];
@@ -10,5 +9,5 @@ export type MonacoEditorProps = {
10
9
  initialValue?: string;
11
10
  language?: 'json' | 'javascript' | 'typescript';
12
11
  };
13
- export declare const MonacoEditor: (props: MonacoEditorProps) => JSX.Element;
12
+ export declare const MonacoEditor: (props: MonacoEditorProps) => import("react/jsx-runtime").JSX.Element;
14
13
  export {};
@@ -67,6 +67,6 @@ export declare class Workbench extends React.Component<WorkbenchPropsType, Workb
67
67
  onLeftBoxResizeStop: ResizeCallback;
68
68
  onGlobalClick: (e: MouseEvent) => void;
69
69
  componentDidMount(): void;
70
- render(): JSX.Element;
70
+ render(): import("react/jsx-runtime").JSX.Element;
71
71
  }
72
72
  export {};
@@ -0,0 +1,8 @@
1
+ export * from './CSSEditor';
2
+ export * from './CSSPropertiesEditor';
3
+ export * from './CSSPropertiesVariableBindEditor';
4
+ export * from './ClassNameEditor';
5
+ export * from './CustomSchemaForm';
6
+ export * from './MonacoEditor';
7
+ export * from './Workbench';
8
+ export * from './DesignerSizer';
package/dist/index.d.ts CHANGED
@@ -1,31 +1,11 @@
1
1
  import React from 'react';
2
2
  import { Workbench } from './component/Workbench';
3
- import { CPlugin, PluginManager } from './core/pluginManager';
3
+ import { PluginManager } from './core/pluginManager';
4
4
  import { Emitter } from 'mitt';
5
5
  import { AssetPackage, CMaterialType, CNode, CPage, CPageDataType, CRootNode } from '@chamn/model';
6
6
  import { ComponentsType } from '@chamn/render';
7
7
  import { AssetsPackageListManager } from './core/assetPackagesListManage';
8
- export type EnginContext = {
9
- pluginManager: PluginManager;
10
- engine: Engine;
11
- };
12
- export type EngineProps = {
13
- plugins: CPlugin[];
14
- schema: CPageDataType;
15
- material?: CMaterialType[];
16
- components?: Record<string, any>;
17
- assetPackagesList?: AssetPackage[];
18
- beforePluginRun?: (options: {
19
- pluginManager: PluginManager;
20
- }) => void;
21
- /** 所有的加插件加载完成 */
22
- onReady?: (ctx: EnginContext) => void;
23
- onMount?: (ctx: EnginContext) => void;
24
- /** 渲染器 umd 格式 js 地址, 默认 ./render.umd.js */
25
- renderJSUrl?: string;
26
- style?: React.CSSProperties;
27
- className?: string;
28
- };
8
+ import { EngineProps } from './type';
29
9
  export declare class Engine extends React.Component<EngineProps> {
30
10
  static version: string;
31
11
  currentSelectNode: CNode | CRootNode | null;
@@ -46,12 +26,17 @@ export declare class Engine extends React.Component<EngineProps> {
46
26
  } | undefined) => Promise<void>;
47
27
  refresh: () => Promise<void>;
48
28
  getWorkbench: () => Workbench | null;
49
- render(): JSX.Element;
29
+ /** return i18n object */
30
+ getI18n(): import("./i18n/index").CustomI18n;
31
+ render(): import("react/jsx-runtime").JSX.Element;
50
32
  }
51
33
  export * as plugins from './plugins';
34
+ export * from './plugins';
35
+ export * from './component';
52
36
  export * from '@chamn/layout';
53
37
  export * from './material/innerMaterial';
54
38
  export * from './component/CustomSchemaForm/components/Setters/type';
55
39
  export * from './utils/index';
56
40
  /** 注册自定义 setter */
57
41
  export { registerCustomSetter } from './component/CustomSchemaForm/components/Form';
42
+ export * from './type';