@ibiz-template/runtime 0.0.1-beta.1 → 0.0.1-beta.130

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 (186) hide show
  1. package/dist/system/index.system.js +1 -1
  2. package/out/command/app/app-func/app-func.d.ts +10 -11
  3. package/out/command/app/app-func/app-func.d.ts.map +1 -1
  4. package/out/command/app/app-func/app-func.js +19 -20
  5. package/out/command/app/open-app-view/open-app-view.d.ts +12 -13
  6. package/out/command/app/open-app-view/open-app-view.d.ts.map +1 -1
  7. package/out/command/app/open-app-view/open-app-view.js +6 -6
  8. package/out/config/global-config.d.ts +18 -0
  9. package/out/config/global-config.d.ts.map +1 -0
  10. package/out/config/global-config.js +18 -0
  11. package/out/index.d.ts +1 -0
  12. package/out/index.d.ts.map +1 -1
  13. package/out/index.js +1 -0
  14. package/out/install.d.ts.map +1 -1
  15. package/out/install.js +6 -0
  16. package/out/interface/i-global-config/i-global-config.d.ts +62 -0
  17. package/out/interface/i-global-config/i-global-config.d.ts.map +1 -0
  18. package/out/interface/i-global-config/i-global-config.js +1 -0
  19. package/out/interface/i-modal/i-modal.d.ts +7 -0
  20. package/out/interface/i-modal/i-modal.d.ts.map +1 -1
  21. package/out/interface/i-modal-options/i-modal-options.d.ts +8 -0
  22. package/out/interface/i-modal-options/i-modal-options.d.ts.map +1 -1
  23. package/out/interface/i-plugin-factory/i-plugin-factory.d.ts +32 -5
  24. package/out/interface/i-plugin-factory/i-plugin-factory.d.ts.map +1 -1
  25. package/out/interface/i-plugin-item/i-plugin-item.d.ts +28 -0
  26. package/out/interface/i-plugin-item/i-plugin-item.d.ts.map +1 -0
  27. package/out/interface/i-plugin-item/i-plugin-item.js +1 -0
  28. package/out/interface/i-ui-action-handler/i-ui-action-handler.d.ts +2 -3
  29. package/out/interface/i-ui-action-handler/i-ui-action-handler.d.ts.map +1 -1
  30. package/out/interface/i-ui-action-result/i-ui-action-result.d.ts +17 -0
  31. package/out/interface/i-ui-action-result/i-ui-action-result.d.ts.map +1 -1
  32. package/out/interface/i-ui-logic-params/i-ui-logic-params.d.ts +31 -0
  33. package/out/interface/i-ui-logic-params/i-ui-logic-params.d.ts.map +1 -0
  34. package/out/interface/i-ui-logic-params/i-ui-logic-params.js +1 -0
  35. package/out/interface/index.d.ts +4 -0
  36. package/out/interface/index.d.ts.map +1 -1
  37. package/out/interface/index.js +1 -0
  38. package/out/interface/logic-scheduler/i-scheduler-logic.d.ts +35 -0
  39. package/out/interface/logic-scheduler/i-scheduler-logic.d.ts.map +1 -0
  40. package/out/interface/logic-scheduler/i-scheduler-logic.js +1 -0
  41. package/out/interface/logic-scheduler/i-trigger-match-params.d.ts +17 -0
  42. package/out/interface/logic-scheduler/i-trigger-match-params.d.ts.map +1 -0
  43. package/out/interface/logic-scheduler/i-trigger-match-params.js +1 -0
  44. package/out/interface/logic-scheduler/index.d.ts +3 -0
  45. package/out/interface/logic-scheduler/index.d.ts.map +1 -0
  46. package/out/interface/logic-scheduler/index.js +1 -0
  47. package/out/interface/util/i-modal-util/i-modal-util.d.ts +8 -0
  48. package/out/interface/util/i-modal-util/i-modal-util.d.ts.map +1 -1
  49. package/out/interface/util/i-open-view-util/i-open-view-util.d.ts +10 -11
  50. package/out/interface/util/i-open-view-util/i-open-view-util.d.ts.map +1 -1
  51. package/out/logic-scheduler/executor/logic-executor-factory.d.ts +34 -0
  52. package/out/logic-scheduler/executor/logic-executor-factory.d.ts.map +1 -0
  53. package/out/logic-scheduler/executor/logic-executor-factory.js +42 -0
  54. package/out/logic-scheduler/executor/logic-executor.d.ts +32 -0
  55. package/out/logic-scheduler/executor/logic-executor.d.ts.map +1 -0
  56. package/out/logic-scheduler/executor/logic-executor.js +30 -0
  57. package/out/logic-scheduler/executor/script-executor.d.ts +39 -0
  58. package/out/logic-scheduler/executor/script-executor.d.ts.map +1 -0
  59. package/out/logic-scheduler/executor/script-executor.js +53 -0
  60. package/out/logic-scheduler/index.d.ts +12 -0
  61. package/out/logic-scheduler/index.d.ts.map +1 -0
  62. package/out/logic-scheduler/index.js +17 -0
  63. package/out/logic-scheduler/logic-scheduler-center.d.ts +45 -0
  64. package/out/logic-scheduler/logic-scheduler-center.d.ts.map +1 -0
  65. package/out/logic-scheduler/logic-scheduler-center.js +49 -0
  66. package/out/logic-scheduler/scheduler/control-logic-scheduler.d.ts +14 -0
  67. package/out/logic-scheduler/scheduler/control-logic-scheduler.d.ts.map +1 -0
  68. package/out/logic-scheduler/scheduler/control-logic-scheduler.js +16 -0
  69. package/out/logic-scheduler/scheduler/logic-scheduler.d.ts +105 -0
  70. package/out/logic-scheduler/scheduler/logic-scheduler.d.ts.map +1 -0
  71. package/out/logic-scheduler/scheduler/logic-scheduler.js +148 -0
  72. package/out/logic-scheduler/scheduler/view-logic-scheduler.d.ts +14 -0
  73. package/out/logic-scheduler/scheduler/view-logic-scheduler.d.ts.map +1 -0
  74. package/out/logic-scheduler/scheduler/view-logic-scheduler.js +14 -0
  75. package/out/logic-scheduler/trigger/item-dyna-logic-trigger.d.ts +12 -0
  76. package/out/logic-scheduler/trigger/item-dyna-logic-trigger.d.ts.map +1 -0
  77. package/out/logic-scheduler/trigger/item-dyna-logic-trigger.js +26 -0
  78. package/out/logic-scheduler/trigger/logic-trigger-factory.d.ts +34 -0
  79. package/out/logic-scheduler/trigger/logic-trigger-factory.d.ts.map +1 -0
  80. package/out/logic-scheduler/trigger/logic-trigger-factory.js +42 -0
  81. package/out/logic-scheduler/trigger/logic-trigger.d.ts +55 -0
  82. package/out/logic-scheduler/trigger/logic-trigger.d.ts.map +1 -0
  83. package/out/logic-scheduler/trigger/logic-trigger.js +52 -0
  84. package/out/plugin/plugin-static-resource/plugin-static-resource.d.ts +18 -0
  85. package/out/plugin/plugin-static-resource/plugin-static-resource.d.ts.map +1 -1
  86. package/out/plugin/plugin-static-resource/plugin-static-resource.js +36 -0
  87. package/out/plugin/remote-plugin-item/remote-plugin-item.d.ts +12 -3
  88. package/out/plugin/remote-plugin-item/remote-plugin-item.d.ts.map +1 -1
  89. package/out/plugin/remote-plugin-item/remote-plugin-item.js +5 -3
  90. package/out/provider/ui-action/index.d.ts +2 -1
  91. package/out/provider/ui-action/index.d.ts.map +1 -1
  92. package/out/provider/ui-action/index.js +5 -1
  93. package/out/provider/ui-action/wf-withdraw-ui-action-provider.d.ts +15 -0
  94. package/out/provider/ui-action/wf-withdraw-ui-action-provider.d.ts.map +1 -0
  95. package/out/provider/ui-action/wf-withdraw-ui-action-provider.js +18 -0
  96. package/out/types.d.ts +17 -1
  97. package/out/types.d.ts.map +1 -1
  98. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts +2 -3
  99. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts.map +1 -1
  100. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.js +1 -1
  101. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.d.ts +1 -2
  102. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.d.ts.map +1 -1
  103. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.js +7 -4
  104. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.d.ts +1 -2
  105. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.d.ts.map +1 -1
  106. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.js +1 -1
  107. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.d.ts +1 -2
  108. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.d.ts.map +1 -1
  109. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.js +31 -8
  110. package/out/utils/app-de-ui-action-util/handler/index.d.ts +1 -0
  111. package/out/utils/app-de-ui-action-util/handler/index.d.ts.map +1 -1
  112. package/out/utils/app-de-ui-action-util/handler/index.js +1 -0
  113. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.d.ts +10 -20
  114. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.d.ts.map +1 -1
  115. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.js +82 -59
  116. package/out/utils/app-de-ui-action-util/handler/wf-withdraw-handler.d.ts +16 -0
  117. package/out/utils/app-de-ui-action-util/handler/wf-withdraw-handler.d.ts.map +1 -0
  118. package/out/utils/app-de-ui-action-util/handler/wf-withdraw-handler.js +27 -0
  119. package/out/utils/index.d.ts +3 -1
  120. package/out/utils/index.d.ts.map +1 -1
  121. package/out/utils/index.js +3 -1
  122. package/out/utils/nav-params/calc-nav-params.d.ts +29 -0
  123. package/out/utils/nav-params/calc-nav-params.d.ts.map +1 -0
  124. package/out/utils/nav-params/calc-nav-params.js +34 -0
  125. package/out/utils/nav-params/nav-params.d.ts +20 -1
  126. package/out/utils/nav-params/nav-params.d.ts.map +1 -1
  127. package/out/utils/nav-params/nav-params.js +58 -4
  128. package/out/utils/open-redirect-view/open-redirect-view.d.ts +19 -8
  129. package/out/utils/open-redirect-view/open-redirect-view.d.ts.map +1 -1
  130. package/out/utils/open-redirect-view/open-redirect-view.js +107 -14
  131. package/out/utils/wf-helper/wf-helper.d.ts +9 -0
  132. package/out/utils/wf-helper/wf-helper.d.ts.map +1 -0
  133. package/out/utils/wf-helper/wf-helper.js +14 -0
  134. package/out/view-logic/view-logic.d.ts +6 -7
  135. package/out/view-logic/view-logic.d.ts.map +1 -1
  136. package/out/view-logic/view-logic.js +102 -29
  137. package/package.json +14 -13
  138. package/src/command/app/app-func/app-func.ts +24 -24
  139. package/src/command/app/open-app-view/open-app-view.ts +12 -13
  140. package/src/config/global-config.ts +22 -0
  141. package/src/index.ts +1 -0
  142. package/src/install.ts +6 -0
  143. package/src/interface/i-global-config/i-global-config.ts +65 -0
  144. package/src/interface/i-modal/i-modal.ts +8 -0
  145. package/src/interface/i-modal-options/i-modal-options.ts +9 -0
  146. package/src/interface/i-plugin-factory/i-plugin-factory.ts +32 -5
  147. package/src/interface/i-plugin-item/i-plugin-item.ts +27 -0
  148. package/src/interface/i-ui-action-handler/i-ui-action-handler.ts +2 -3
  149. package/src/interface/i-ui-action-result/i-ui-action-result.ts +20 -0
  150. package/src/interface/i-ui-logic-params/i-ui-logic-params.ts +31 -0
  151. package/src/interface/index.ts +5 -0
  152. package/src/interface/logic-scheduler/i-scheduler-logic.ts +58 -0
  153. package/src/interface/logic-scheduler/i-trigger-match-params.ts +18 -0
  154. package/src/interface/logic-scheduler/index.ts +7 -0
  155. package/src/interface/util/i-modal-util/i-modal-util.ts +8 -0
  156. package/src/interface/util/i-open-view-util/i-open-view-util.ts +10 -11
  157. package/src/logic-scheduler/executor/logic-executor-factory.ts +48 -0
  158. package/src/logic-scheduler/executor/logic-executor.ts +43 -0
  159. package/src/logic-scheduler/executor/script-executor.ts +63 -0
  160. package/src/logic-scheduler/index.ts +41 -0
  161. package/src/logic-scheduler/logic-scheduler-center.ts +52 -0
  162. package/src/logic-scheduler/scheduler/control-logic-scheduler.ts +21 -0
  163. package/src/logic-scheduler/scheduler/logic-scheduler.ts +192 -0
  164. package/src/logic-scheduler/scheduler/view-logic-scheduler.ts +17 -0
  165. package/src/logic-scheduler/trigger/item-dyna-logic-trigger.ts +41 -0
  166. package/src/logic-scheduler/trigger/logic-trigger-factory.ts +48 -0
  167. package/src/logic-scheduler/trigger/logic-trigger.ts +77 -0
  168. package/src/plugin/plugin-static-resource/plugin-static-resource.ts +38 -0
  169. package/src/plugin/remote-plugin-item/remote-plugin-item.ts +14 -3
  170. package/src/provider/ui-action/index.ts +6 -0
  171. package/src/provider/ui-action/wf-withdraw-ui-action-provider.ts +22 -0
  172. package/src/types.ts +19 -0
  173. package/src/utils/app-de-ui-action-util/app-de-ui-action-util.ts +2 -3
  174. package/src/utils/app-de-ui-action-util/handler/backend-ui-action-handler.ts +13 -5
  175. package/src/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.ts +2 -3
  176. package/src/utils/app-de-ui-action-util/handler/front-ui-action-handler.ts +46 -23
  177. package/src/utils/app-de-ui-action-util/handler/index.ts +1 -0
  178. package/src/utils/app-de-ui-action-util/handler/ui-action-handler.ts +113 -75
  179. package/src/utils/app-de-ui-action-util/handler/wf-withdraw-handler.ts +36 -0
  180. package/src/utils/index.ts +6 -1
  181. package/src/utils/nav-params/calc-nav-params.ts +59 -0
  182. package/src/utils/nav-params/nav-params.ts +66 -5
  183. package/src/utils/open-redirect-view/open-redirect-view.ts +142 -14
  184. package/src/utils/wf-helper/wf-helper.ts +14 -0
  185. package/src/view-logic/view-logic.ts +111 -31
  186. package/LICENSE +0 -21
@@ -0,0 +1,43 @@
1
+ import { RuntimeError } from '@ibiz-template/core';
2
+ import type {
3
+ ISchedulerLogic,
4
+ IUILogicParams,
5
+ LogicType,
6
+ } from '../../interface';
7
+
8
+ /**
9
+ * 逻辑执行器实例
10
+ * @author lxm
11
+ * @date 2023-06-25 06:07:24
12
+ * @export
13
+ * @class LogicExecutor
14
+ */
15
+ export class LogicExecutor {
16
+ /**
17
+ * 执行逻辑类型
18
+ * @author lxm
19
+ * @date 2023-06-25 07:32:04
20
+ */
21
+ type: LogicType;
22
+
23
+ /**
24
+ * @author lxm
25
+ * @date 2023-06-25 07:32:57
26
+ * @param {ISchedulerLogic} logic 逻辑
27
+ */
28
+ constructor(protected logic: ISchedulerLogic) {
29
+ this.type = logic.logicType;
30
+ }
31
+
32
+ /**
33
+ * 执行逻辑
34
+ * @author lxm
35
+ * @date 2023-06-26 02:55:40
36
+ * @param {IUILogicParams} _executeParams 执行参数
37
+ * @return {*} {*}
38
+ */
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ execute(_executeParams: IUILogicParams): any {
41
+ throw new RuntimeError('Method not implemented.');
42
+ }
43
+ }
@@ -0,0 +1,63 @@
1
+ import { RuntimeError } from '@ibiz-template/core';
2
+ import { IUILogicParams } from '../../interface';
3
+ import { LogicExecutor } from './logic-executor';
4
+
5
+ /**
6
+ * 脚本代码执行器
7
+ * @author lxm
8
+ * @date 2023-06-25 08:36:00
9
+ * @export
10
+ * @class ScriptExecutor
11
+ * @extends {LogicExecutor}
12
+ */
13
+ export class ScriptExecutor extends LogicExecutor {
14
+ declare type: 'SCRIPT';
15
+
16
+ // eslint-disable-next-line @typescript-eslint/ban-types
17
+ scriptFn?: Function;
18
+
19
+ /**
20
+ * 是否单行返回,脚本只是单行的且默认把值返回
21
+ * @author lxm
22
+ * @date 2023-06-25 10:06:32
23
+ * @type {boolean}
24
+ */
25
+ isRowReturn: boolean = false;
26
+
27
+ /**
28
+ * 执行参数转换成脚本执行作用域参数
29
+ * @author lxm
30
+ * @date 2023-06-26 03:29:24
31
+ * @param {IUILogicParams} _executeParams
32
+ * @return {*} {IData[]}
33
+ */
34
+ convertScriptArgs(_executeParams: IUILogicParams): IData[] {
35
+ throw new RuntimeError('未设置脚本执行参数转换方法');
36
+ }
37
+
38
+ /**
39
+ * 初始化脚本执行器
40
+ * @author lxm
41
+ * @date 2023-06-26 03:27:50
42
+ * @param {string[]} paramKeys 脚本作用域参数键值和顺序
43
+ * @param {(executeParams: IUILogicParams) => IData[]} convertFun 脚本参数转换方法
44
+ */
45
+ init(
46
+ paramKeys: string[],
47
+ convertFun: (executeParams: IUILogicParams) => IData[],
48
+ ) {
49
+ this.convertScriptArgs = convertFun;
50
+ let code = this.logic.scriptCode!;
51
+ if (this.isRowReturn) {
52
+ code = `return (${code})`;
53
+ }
54
+ // eslint-disable-next-line no-new-func
55
+ this.scriptFn = new Function(...paramKeys, code);
56
+ }
57
+
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ execute(executeParams: IUILogicParams): any {
60
+ const scriptArgs = this.convertScriptArgs(executeParams);
61
+ return this.scriptFn!(...scriptArgs);
62
+ }
63
+ }
@@ -0,0 +1,41 @@
1
+ import { LogicExecutor } from './executor/logic-executor';
2
+ import { LogicExecutorFactory } from './executor/logic-executor-factory';
3
+ import { ScriptExecutor } from './executor/script-executor';
4
+ import { LogicSchedulerCenter } from './logic-scheduler-center';
5
+ import { ControlLogicScheduler } from './scheduler/control-logic-scheduler';
6
+ import { ViewLogicScheduler } from './scheduler/view-logic-scheduler';
7
+ import { ItemDynaLogicTrigger } from './trigger/item-dyna-logic-trigger';
8
+ import { LogicTrigger } from './trigger/logic-trigger';
9
+ import { LogicTriggerFactory } from './trigger/logic-trigger-factory';
10
+
11
+ export {
12
+ LogicSchedulerCenter,
13
+ ViewLogicScheduler,
14
+ ControlLogicScheduler,
15
+ ItemDynaLogicTrigger,
16
+ LogicTriggerFactory,
17
+ LogicTrigger,
18
+ LogicExecutorFactory,
19
+ LogicExecutor,
20
+ ScriptExecutor,
21
+ };
22
+
23
+ export function installLogicSchedule() {
24
+ ibiz.scheduler = new LogicSchedulerCenter();
25
+ ibiz.scheduler.triggerFactory.register(
26
+ 'ITEMVISIBLE',
27
+ logic => new ItemDynaLogicTrigger(logic),
28
+ );
29
+ ibiz.scheduler.triggerFactory.register(
30
+ 'ITEMENABLE',
31
+ logic => new ItemDynaLogicTrigger(logic),
32
+ );
33
+ ibiz.scheduler.triggerFactory.register(
34
+ 'ITEMBLANK',
35
+ logic => new ItemDynaLogicTrigger(logic),
36
+ );
37
+ ibiz.scheduler.executorFactory.register(
38
+ 'SCRIPT',
39
+ logic => new ScriptExecutor(logic),
40
+ );
41
+ }
@@ -0,0 +1,52 @@
1
+ import { IPSAppDEViewLogic, IPSControlLogic } from '@ibiz-template/model';
2
+ import { LogicExecutorFactory } from './executor/logic-executor-factory';
3
+ import { ControlLogicScheduler } from './scheduler/control-logic-scheduler';
4
+ import { ViewLogicScheduler } from './scheduler/view-logic-scheduler';
5
+ import { LogicTriggerFactory } from './trigger/logic-trigger-factory';
6
+
7
+ /**
8
+ * 调度器中心
9
+ * @author lxm
10
+ * @date 2023-06-25 03:30:21
11
+ * @export
12
+ * @class LogicSchedulerFactory
13
+ */
14
+ export class LogicSchedulerCenter {
15
+ /**
16
+ * 执行器工厂
17
+ * @author lxm
18
+ * @date 2023-06-25 06:41:42
19
+ * @type {LogicExecutorFactory}
20
+ */
21
+ executorFactory: LogicExecutorFactory = new LogicExecutorFactory();
22
+
23
+ /**
24
+ * 触发器工厂
25
+ * @author lxm
26
+ * @date 2023-06-25 06:44:12
27
+ * @type {LogicTriggerFactory}
28
+ */
29
+ triggerFactory: LogicTriggerFactory = new LogicTriggerFactory();
30
+
31
+ /**
32
+ * 创建视图逻辑调度器实例
33
+ * @author lxm
34
+ * @date 2023-06-25 03:41:43
35
+ * @param {IAppDEViewLogic} logics
36
+ * @return {*} {ViewLogicScheduler}
37
+ */
38
+ createViewScheduler(logics: IPSAppDEViewLogic[]): ViewLogicScheduler {
39
+ return new ViewLogicScheduler(logics);
40
+ }
41
+
42
+ /**
43
+ * 创建部件逻辑调度器实例
44
+ * @author lxm
45
+ * @date 2023-06-25 03:48:30
46
+ * @param {IControlLogic} logics
47
+ * @return {*} {ControlLogicScheduler}
48
+ */
49
+ createControlScheduler(logics: IPSControlLogic[]): ControlLogicScheduler {
50
+ return new ControlLogicScheduler(logics);
51
+ }
52
+ }
@@ -0,0 +1,21 @@
1
+ import { IPSControlLogic } from '@ibiz-template/model';
2
+ import type { ISchedulerLogic } from '../../interface';
3
+ import { LogicScheduler } from './logic-scheduler';
4
+
5
+ /**
6
+ * 部件逻辑调度器实例类
7
+ * @author lxm
8
+ * @date 2023-06-25 03:36:32
9
+ * @export
10
+ * @class ViewLogicScheduler
11
+ * @extends {LogicScheduler}
12
+ */
13
+ export class ControlLogicScheduler extends LogicScheduler {
14
+ constructor(logics: IPSControlLogic[]) {
15
+ // 部件逻辑把APPVIEWENGINE排除掉。
16
+ const filterLogics = logics.filter(
17
+ item => item.triggerType !== 'APPVIEWENGINE',
18
+ );
19
+ super(filterLogics as ISchedulerLogic[]);
20
+ }
21
+ }
@@ -0,0 +1,192 @@
1
+ import { mergeLeft } from 'ramda';
2
+ import type {
3
+ IUILogicParams,
4
+ ISchedulerLogic,
5
+ ITriggerMatchParams,
6
+ } from '../../interface';
7
+ import { LogicExecutor } from '../executor/logic-executor';
8
+ import { LogicTrigger } from '../trigger/logic-trigger';
9
+
10
+ /**
11
+ * 逻辑调度器实例类
12
+ * @author lxm
13
+ * @date 2023-06-25 03:35:46
14
+ * @export
15
+ * @class LogicScheduler
16
+ */
17
+ export class LogicScheduler {
18
+ logics: ISchedulerLogic[];
19
+
20
+ triggers = new Map<string, LogicTrigger>();
21
+
22
+ executors = new Map<string, LogicExecutor>();
23
+
24
+ constructor(logics: ISchedulerLogic[]) {
25
+ this.logics = logics;
26
+ logics.forEach(logic => {
27
+ try {
28
+ const executor = this.createExecutor(logic);
29
+ this.executors.set(logic.id, executor);
30
+ const trigger = this.createTrigger(logic);
31
+ this.triggers.set(logic.id, trigger);
32
+ trigger.bindExecutor(executor);
33
+ } catch (error) {
34
+ ibiz.log.error((error as IData).message);
35
+ }
36
+ });
37
+ }
38
+
39
+ /**
40
+ * 默认参数回调
41
+ * @author lxm
42
+ * @date 2023-06-25 08:25:51
43
+ */
44
+ defaultParamsCb?: () => IUILogicParams;
45
+
46
+ /**
47
+ * 获取执行参数,把默认参数和调用参数合并
48
+ * @author lxm
49
+ * @date 2023-06-25 08:28:34
50
+ * @param {IData} args
51
+ * @return {*}
52
+ */
53
+ getExecuteParams(executeParams: Partial<IUILogicParams>): IUILogicParams {
54
+ let defaultParams = {};
55
+ if (this.defaultParamsCb) {
56
+ defaultParams = this.defaultParamsCb();
57
+ }
58
+ return mergeLeft(executeParams, defaultParams) as IUILogicParams;
59
+ }
60
+
61
+ /**
62
+ * 创建触发器实例
63
+ * @author lxm
64
+ * @date 2023-06-26 02:33:35
65
+ * @protected
66
+ * @param {ISchedulerLogic} logic
67
+ * @return {*} {LogicTrigger}
68
+ */
69
+ protected createTrigger(logic: ISchedulerLogic): LogicTrigger {
70
+ return ibiz.scheduler.triggerFactory.createTrigger(logic);
71
+ }
72
+
73
+ /**
74
+ * 创建执行器实例
75
+ * @author lxm
76
+ * @date 2023-06-26 02:33:52
77
+ * @protected
78
+ * @param {ISchedulerLogic} logic
79
+ * @return {*} {LogicExecutor}
80
+ */
81
+ protected createExecutor(logic: ISchedulerLogic): LogicExecutor {
82
+ return ibiz.scheduler.executorFactory.createExecutor(logic);
83
+ }
84
+
85
+ /**
86
+ * 获取匹配的触发器。
87
+ * @author lxm
88
+ * @date 2023-06-26 02:32:24
89
+ * @param {ITriggerMatchParams} matchParams
90
+ * @return {*} {LogicTrigger[]}
91
+ */
92
+ protected getMatchTriggers(matchParams: ITriggerMatchParams): LogicTrigger[] {
93
+ const triggers: LogicTrigger[] = [];
94
+ this.triggers.forEach(trigger => {
95
+ if (trigger.match(matchParams)) {
96
+ triggers.push(trigger);
97
+ }
98
+ });
99
+ return triggers;
100
+ }
101
+
102
+ /**
103
+ * 找到匹配的触发器并执行对应的执行器,并返回结果。
104
+ * 返回undefined表示没有匹配的触发器。
105
+ * @author lxm
106
+ * @date 2023-06-26 02:30:24
107
+ * @param {ITriggerMatchParams} matchParams 匹配参数
108
+ * @param {Partial<IUILogicParams>} [executeParams={}] 执行参数
109
+ * @return {*} {(any[] | undefined)}
110
+ */
111
+ triggerAndExecute(
112
+ matchParams: ITriggerMatchParams,
113
+ executeParams: Partial<IUILogicParams> = {},
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ ): any[] | undefined {
116
+ const triggers = this.getMatchTriggers(matchParams);
117
+ if (triggers.length > 0) {
118
+ const params = this.getExecuteParams(executeParams);
119
+ const result = triggers.map(trigger => {
120
+ return trigger.execute(params);
121
+ });
122
+ return result;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * 预定义项的动态逻辑
128
+ * @author lxm
129
+ * @date 2023-06-26 02:29:08
130
+ * @protected
131
+ * @param {string} itemName 子项名称
132
+ * @param {('ITEMVISIBLE' | 'ITEMENABLE' | 'ITEMBLANK')} triggerType 预定义逻辑类型
133
+ * @param {Partial<IUILogicParams>} executeParams 执行参数
134
+ * @return {*} {(boolean | undefined)}
135
+ */
136
+ protected triggerItemDynaLogic(
137
+ itemName: string,
138
+ triggerType: 'ITEMVISIBLE' | 'ITEMENABLE' | 'ITEMBLANK',
139
+ executeParams: Partial<IUILogicParams>,
140
+ ): boolean | undefined {
141
+ const matchParams = { itemName, triggerType };
142
+ const result = this.triggerAndExecute(matchParams, executeParams);
143
+ if (result?.length) {
144
+ return result.pop();
145
+ }
146
+ }
147
+
148
+ /**
149
+ * 预定义项显示逻辑
150
+ * @author lxm
151
+ * @date 2023-06-26 02:26:36
152
+ * @param {string} itemName 子项名称
153
+ * @param {Partial<IUILogicParams>} executeParams 执行参数
154
+ * @return {*} {(boolean | undefined)}
155
+ */
156
+ triggerItemVisible(
157
+ itemName: string,
158
+ executeParams: Partial<IUILogicParams>,
159
+ ): boolean | undefined {
160
+ return this.triggerItemDynaLogic(itemName, 'ITEMVISIBLE', executeParams);
161
+ }
162
+
163
+ /**
164
+ * 预定义项启用逻辑
165
+ * @author lxm
166
+ * @date 2023-06-26 02:26:35
167
+ * @param {string} itemName 子项名称
168
+ * @param {Partial<IUILogicParams>} executeParams 执行参数
169
+ * @return {*} {(boolean | undefined)}
170
+ */
171
+ triggerItemEnable(
172
+ itemName: string,
173
+ executeParams: Partial<IUILogicParams>,
174
+ ): boolean | undefined {
175
+ return this.triggerItemDynaLogic(itemName, 'ITEMENABLE', executeParams);
176
+ }
177
+
178
+ /**
179
+ * 预定义项空输入逻辑
180
+ * @author lxm
181
+ * @date 2023-06-26 02:26:33
182
+ * @param {string} itemName 子项名称
183
+ * @param {Partial<IUILogicParams>} executeParams 执行参数
184
+ * @return {*} {(boolean | undefined)}
185
+ */
186
+ triggerItemBlank(
187
+ itemName: string,
188
+ executeParams: Partial<IUILogicParams>,
189
+ ): boolean | undefined {
190
+ return this.triggerItemDynaLogic(itemName, 'ITEMBLANK', executeParams);
191
+ }
192
+ }
@@ -0,0 +1,17 @@
1
+ import { IPSAppDEViewLogic } from '@ibiz-template/model';
2
+ import type { ISchedulerLogic } from '../../interface';
3
+ import { LogicScheduler } from './logic-scheduler';
4
+
5
+ /**
6
+ * 视图逻辑调度器实例类
7
+ * @author lxm
8
+ * @date 2023-06-25 03:36:32
9
+ * @export
10
+ * @class ViewLogicScheduler
11
+ * @extends {LogicScheduler}
12
+ */
13
+ export class ViewLogicScheduler extends LogicScheduler {
14
+ constructor(logics: IPSAppDEViewLogic[]) {
15
+ super(logics as IData as ISchedulerLogic[]);
16
+ }
17
+ }
@@ -0,0 +1,41 @@
1
+ import { RuntimeError } from '@ibiz-template/core';
2
+ import type { ITriggerMatchParams, IUILogicParams } from '../../interface';
3
+ import { LogicExecutor } from '../executor/logic-executor';
4
+ import { ScriptExecutor } from '../executor/script-executor';
5
+ import { LogicTrigger } from './logic-trigger';
6
+
7
+ export class ItemDynaLogicTrigger extends LogicTrigger {
8
+ declare type: 'ITEMVISIBLE' | 'ITEMENABLE' | 'ITEMBLANK';
9
+
10
+ declare executor: ScriptExecutor;
11
+
12
+ bindExecutor(executor: LogicExecutor) {
13
+ super.bindExecutor(executor);
14
+ if (this.executor.type !== 'SCRIPT') {
15
+ throw new RuntimeError(
16
+ `预定义逻辑类型${this.type}的触发器类型只能是脚本`,
17
+ );
18
+ }
19
+ this.executor.isRowReturn = true;
20
+ this.executor.init(
21
+ ['context', 'viewparams', 'data', 'env'],
22
+ executeParams => {
23
+ const { context, params, data } = executeParams;
24
+ return [context, params, data?.[0] || {}, ibiz.env];
25
+ },
26
+ );
27
+ }
28
+
29
+ match(matchParams: ITriggerMatchParams): boolean {
30
+ const superResult = super.match(matchParams);
31
+ return superResult && matchParams.itemName === this.logic.itemName;
32
+ }
33
+
34
+ execute(executeParams: IUILogicParams): boolean {
35
+ const result = this.executor.execute(executeParams);
36
+ if (typeof result === 'boolean') {
37
+ return result;
38
+ }
39
+ throw new RuntimeError(`${this.logic.id}逻辑返回值不是布尔值`);
40
+ }
41
+ }
@@ -0,0 +1,48 @@
1
+ import { IPSModelObject, UnsupportedModelError } from '@ibiz-template/model';
2
+ import type { ISchedulerLogic } from '../../interface';
3
+ import { LogicTrigger } from './logic-trigger';
4
+
5
+ /**
6
+ * 逻辑触发器工厂
7
+ * @author lxm
8
+ * @date 2023-06-25 06:37:54
9
+ * @export
10
+ * @class LogicTriggerFactory
11
+ */
12
+ export class LogicTriggerFactory {
13
+ /**
14
+ * 构造回调方法集合
15
+ * @author lxm
16
+ * @date 2023-06-25 06:53:31
17
+ */
18
+ constructorMap = new Map<string, (logic: ISchedulerLogic) => LogicTrigger>();
19
+
20
+ /**
21
+ * 注册
22
+ * @author lxm
23
+ * @date 2023-06-25 06:54:17
24
+ * @param {string} key 注册标识
25
+ * @param {(logic: ISchedulerLogic) => LogicTrigger} callback
26
+ */
27
+ register(key: string, callback: (logic: ISchedulerLogic) => LogicTrigger) {
28
+ this.constructorMap.set(key, callback);
29
+ }
30
+
31
+ /**
32
+ * 创建触发器实例
33
+ * @author lxm
34
+ * @date 2023-06-25 06:56:32
35
+ * @param {ISchedulerLogic} logic
36
+ * @return {*}
37
+ */
38
+ createTrigger(logic: ISchedulerLogic) {
39
+ const constructor = this.constructorMap.get(logic.triggerType);
40
+ if (!constructor) {
41
+ throw new UnsupportedModelError(
42
+ logic as IData as IPSModelObject,
43
+ `触发器类型 ${logic.triggerType} 暂未支持!`,
44
+ );
45
+ }
46
+ return constructor(logic);
47
+ }
48
+ }
@@ -0,0 +1,77 @@
1
+ import { RuntimeError } from '@ibiz-template/core';
2
+ import type {
3
+ IUILogicParams,
4
+ ISchedulerLogic,
5
+ ITriggerMatchParams,
6
+ TriggerType,
7
+ } from '../../interface';
8
+ import { LogicExecutor } from '../executor/logic-executor';
9
+
10
+ /**
11
+ * 逻辑触发器
12
+ * @author lxm
13
+ * @date 2023-06-25 06:09:22
14
+ * @export
15
+ * @class LogicTrigger
16
+ */
17
+ export class LogicTrigger {
18
+ /**
19
+ *
20
+ * @author lxm
21
+ * @date 2023-06-25 07:32:04
22
+ */
23
+ type: TriggerType;
24
+
25
+ /**
26
+ * @author lxm
27
+ * @date 2023-06-25 07:32:57
28
+ * @param {ISchedulerLogic} logic 逻辑
29
+ */
30
+ constructor(protected logic: ISchedulerLogic) {
31
+ this.type = logic.triggerType;
32
+ }
33
+
34
+ /**
35
+ * 执行器
36
+ * @author lxm
37
+ * @date 2023-06-25 07:25:05
38
+ * @type {LogicExecutor}
39
+ */
40
+ executor?: LogicExecutor;
41
+
42
+ /**
43
+ * 绑定执行器
44
+ * @author lxm
45
+ * @date 2023-06-25 07:25:13
46
+ * @param {LogicExecutor} executor
47
+ */
48
+ bindExecutor(executor: LogicExecutor) {
49
+ this.executor = executor;
50
+ }
51
+
52
+ /**
53
+ * 匹配触发器,返回true表示该触发器满足触发条件。
54
+ * @author lxm
55
+ * @date 2023-06-25 07:49:00
56
+ * @param {IData} _args
57
+ * @return {*} {boolean}
58
+ */
59
+ match(matchParams: ITriggerMatchParams): boolean {
60
+ return matchParams.triggerType === this.type;
61
+ }
62
+
63
+ /**
64
+ * 执行对应的执行器
65
+ * @author lxm
66
+ * @date 2023-06-26 01:45:42
67
+ * @param {Partial<IUILogicParams>} executeParams
68
+ * @return {*}
69
+ */
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
+ execute(executeParams: IUILogicParams): any {
72
+ if (this.executor) {
73
+ return this.executor.execute(executeParams);
74
+ }
75
+ throw new RuntimeError(`${this.logic.id}没有绑定executor`);
76
+ }
77
+ }
@@ -17,6 +17,16 @@ export class PluginStaticResource {
17
17
  */
18
18
  protected baseDir: string;
19
19
 
20
+ /**
21
+ * 已经输出过路径的 style 标签
22
+ *
23
+ * @author chitanda
24
+ * @date 2023-03-23 10:03:38
25
+ * @protected
26
+ * @type {Map<string, null>}
27
+ */
28
+ protected styleElementMap: Map<string, null> = new Map();
29
+
20
30
  /**
21
31
  * 插件静态资源工具类.
22
32
  *
@@ -39,4 +49,32 @@ export class PluginStaticResource {
39
49
  dir(path: string): string {
40
50
  return this.baseDir + path;
41
51
  }
52
+
53
+ /**
54
+ * 加载样式静态资源
55
+ *
56
+ * @author chitanda
57
+ * @date 2023-03-23 10:03:49
58
+ * @param {string[]} urls
59
+ * @return {*} {Promise<void>}
60
+ */
61
+ async loadStyle(urls: string[]): Promise<void> {
62
+ const all = urls.map(styleUrl => {
63
+ const url = this.dir(styleUrl);
64
+ if (this.styleElementMap.has(url)) {
65
+ return false;
66
+ }
67
+ this.styleElementMap.set(url, null);
68
+ return new Promise((resolve, reject) => {
69
+ const linkDom = document.createElement('link');
70
+ linkDom.setAttribute('type', 'text/css');
71
+ linkDom.setAttribute('rel', 'stylesheet');
72
+ linkDom.setAttribute('href', url);
73
+ linkDom.onload = resolve;
74
+ linkDom.onerror = reject;
75
+ document.head.appendChild(linkDom);
76
+ });
77
+ });
78
+ await Promise.all(all);
79
+ }
42
80
  }
@@ -83,6 +83,15 @@ export class RemotePluginItem {
83
83
  */
84
84
  readonly tag: string;
85
85
 
86
+ /**
87
+ * 插件模型
88
+ *
89
+ * @author chitanda
90
+ * @date 2023-01-30 15:01:37
91
+ * @type {IPSAppPFPluginRef}
92
+ */
93
+ readonly repo: string;
94
+
86
95
  /**
87
96
  * 配置参数
88
97
  *
@@ -96,12 +105,14 @@ export class RemotePluginItem {
96
105
  * Creates an instance of RemotePluginItem.
97
106
  *
98
107
  * @author chitanda
99
- * @date 2022-10-31 12:10:28
100
- * @param {string} tag 插件唯一标识
108
+ * @date 2023-02-02 15:02:13
109
+ * @param {string} tag 插件标识名称
110
+ * @param {string} repo 插件路径
101
111
  * @param {RemotePluginConfig} config
102
112
  */
103
- constructor(tag: string, config: RemotePluginConfig) {
113
+ constructor(tag: string, repo: string, config: RemotePluginConfig) {
104
114
  this.tag = tag;
115
+ this.repo = repo;
105
116
  this.config = config;
106
117
  }
107
118
  }