@tmagic/editor 1.5.7 → 1.5.8

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 (72) hide show
  1. package/dist/style.css +17 -0
  2. package/dist/tmagic-editor.js +463 -470
  3. package/dist/tmagic-editor.umd.cjs +471 -469
  4. package/package.json +7 -7
  5. package/src/components/CodeBlockEditor.vue +4 -4
  6. package/src/components/FloatingBox.vue +4 -4
  7. package/src/components/ToolButton.vue +6 -4
  8. package/src/components/TreeNode.vue +2 -2
  9. package/src/fields/CodeSelect.vue +6 -6
  10. package/src/fields/CodeSelectCol.vue +5 -4
  11. package/src/fields/CondOpSelect.vue +5 -4
  12. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +6 -5
  13. package/src/fields/DataSourceFieldSelect/Index.vue +4 -3
  14. package/src/fields/DataSourceFields.vue +3 -3
  15. package/src/fields/DataSourceInput.vue +4 -4
  16. package/src/fields/DataSourceMethodSelect.vue +8 -9
  17. package/src/fields/DataSourceMocks.vue +3 -3
  18. package/src/fields/DataSourceSelect.vue +6 -5
  19. package/src/fields/DisplayConds.vue +4 -4
  20. package/src/fields/EventSelect.vue +17 -23
  21. package/src/fields/PageFragmentSelect.vue +6 -5
  22. package/src/fields/UISelect.vue +16 -19
  23. package/src/hooks/index.ts +1 -0
  24. package/src/hooks/use-code-block-edit.ts +5 -10
  25. package/src/hooks/use-data-source-edit.ts +6 -6
  26. package/src/hooks/use-editor-content-height.ts +5 -5
  27. package/src/hooks/use-float-box.ts +5 -5
  28. package/src/hooks/use-next-float-box-position.ts +9 -9
  29. package/src/hooks/use-services.ts +13 -0
  30. package/src/hooks/use-stage.ts +2 -6
  31. package/src/layouts/AddPageBox.vue +3 -7
  32. package/src/layouts/Framework.vue +27 -27
  33. package/src/layouts/NavMenu.vue +16 -16
  34. package/src/layouts/page-bar/AddButton.vue +4 -7
  35. package/src/layouts/page-bar/PageBar.vue +10 -10
  36. package/src/layouts/page-bar/PageBarScrollContainer.vue +7 -8
  37. package/src/layouts/page-bar/PageList.vue +6 -8
  38. package/src/layouts/props-panel/FormPanel.vue +6 -4
  39. package/src/layouts/props-panel/PropsPanel.vue +39 -49
  40. package/src/layouts/props-panel/use-style-panel.ts +35 -19
  41. package/src/layouts/sidebar/ComponentListPanel.vue +5 -5
  42. package/src/layouts/sidebar/Sidebar.vue +15 -9
  43. package/src/layouts/sidebar/code-block/CodeBlockList.vue +13 -18
  44. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +4 -3
  45. package/src/layouts/sidebar/code-block/useContentMenu.ts +3 -3
  46. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +5 -5
  47. package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -17
  48. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -12
  49. package/src/layouts/sidebar/data-source/useContentMenu.ts +3 -3
  50. package/src/layouts/sidebar/layer/LayerMenu.vue +11 -8
  51. package/src/layouts/sidebar/layer/LayerNodeTool.vue +2 -6
  52. package/src/layouts/sidebar/layer/LayerPanel.vue +6 -12
  53. package/src/layouts/sidebar/layer/use-click.ts +16 -15
  54. package/src/layouts/sidebar/layer/use-drag.ts +6 -6
  55. package/src/layouts/sidebar/layer/use-keybinding.ts +6 -8
  56. package/src/layouts/sidebar/layer/use-node-status.ts +16 -7
  57. package/src/layouts/workspace/Breadcrumb.vue +8 -9
  58. package/src/layouts/workspace/Workspace.vue +4 -10
  59. package/src/layouts/workspace/viewer/NodeListMenu.vue +9 -8
  60. package/src/layouts/workspace/viewer/Stage.vue +24 -24
  61. package/src/layouts/workspace/viewer/StageOverlay.vue +15 -16
  62. package/src/layouts/workspace/viewer/ViewerMenu.vue +15 -14
  63. package/src/services/dep.ts +23 -8
  64. package/src/services/ui.ts +6 -2
  65. package/src/theme/common/var.scss +1 -0
  66. package/src/theme/sidebar.scss +20 -1
  67. package/src/type.ts +3 -9
  68. package/src/utils/const.ts +11 -0
  69. package/src/utils/content-menu.ts +28 -30
  70. package/src/utils/idle-task.ts +11 -0
  71. package/src/utils/index.ts +1 -0
  72. package/types/index.d.ts +28 -10
@@ -411,6 +411,14 @@ const _sfc_main$1o = /* @__PURE__ */ defineComponent({
411
411
  }
412
412
  });
413
413
 
414
+ const useServices = () => {
415
+ const services = inject("services");
416
+ if (!services) {
417
+ throw new Error("services is required");
418
+ }
419
+ return services;
420
+ };
421
+
414
422
  const _sfc_main$1n = /* @__PURE__ */ defineComponent({
415
423
  ...{
416
424
  name: "MFieldsCodeSelect"
@@ -430,7 +438,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
430
438
  emits: ["change"],
431
439
  setup(__props, { emit: __emit }) {
432
440
  const emit = __emit;
433
- const services = inject("services");
441
+ const { dataSourceService, codeBlockService } = useServices();
434
442
  const props = __props;
435
443
  const codeConfig = computed(() => ({
436
444
  type: "group-list",
@@ -443,7 +451,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
443
451
  if (model.codeId.length < 2) {
444
452
  return index;
445
453
  }
446
- const ds = services?.dataSourceService.getDataSourceById(model.codeId[0]);
454
+ const ds = dataSourceService.getDataSourceById(model.codeId[0]);
447
455
  return `${ds?.title} / ${model.codeId[1]}`;
448
456
  }
449
457
  return Array.isArray(model.codeId) ? model.codeId.join("/") : index;
@@ -480,7 +488,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
480
488
  span: 18,
481
489
  labelWidth: 0,
482
490
  display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
483
- notEditable: () => !services?.codeBlockService.getEditStatus()
491
+ notEditable: () => !codeBlockService.getEditStatus()
484
492
  },
485
493
  {
486
494
  type: "data-source-method-select",
@@ -488,7 +496,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
488
496
  span: 18,
489
497
  labelWidth: 0,
490
498
  display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
491
- notEditable: () => !services?.dataSourceService.get("editable")
499
+ notEditable: () => !dataSourceService.get("editable")
492
500
  }
493
501
  ]
494
502
  }
@@ -765,8 +773,6 @@ var Keys = /* @__PURE__ */ ((Keys2) => {
765
773
  Keys2["ESCAPE"] = "Space";
766
774
  return Keys2;
767
775
  })(Keys || {});
768
- const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
769
- const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
770
776
  var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
771
777
  CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
772
778
  CodeDeleteErrorType2["BIND"] = "bind";
@@ -800,7 +806,6 @@ var DragType = /* @__PURE__ */ ((DragType2) => {
800
806
  DragType2["LAYER_TREE"] = "layer-tree";
801
807
  return DragType2;
802
808
  })(DragType || {});
803
- const UI_SELECT_MODE_EVENT_NAME = "ui-select";
804
809
 
805
810
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
806
811
  const COPY_CODE_STORAGE_KEY = "$MagicEditorCopyCode";
@@ -2885,6 +2890,10 @@ class IdleTask extends EventEmitter {
2885
2890
  this.hightLevelTaskList = [];
2886
2891
  this.taskList = [];
2887
2892
  this.taskHandle = null;
2893
+ this.emit("update-task-length", {
2894
+ length: this.taskList.length + this.hightLevelTaskList.length,
2895
+ hightLevelLength: this.hightLevelTaskList.length
2896
+ });
2888
2897
  }
2889
2898
  on(eventName, listener) {
2890
2899
  return super.on(eventName, listener);
@@ -2928,6 +2937,10 @@ class IdleTask extends EventEmitter {
2928
2937
  this.taskHandle = 0;
2929
2938
  this.emit("finish");
2930
2939
  }
2940
+ this.emit("update-task-length", {
2941
+ length: taskList.length + hightLevelTaskList.length,
2942
+ hightLevelLength: hightLevelTaskList.length
2943
+ });
2931
2944
  }
2932
2945
  }
2933
2946
 
@@ -3068,6 +3081,18 @@ const updateStatus = (nodeStatusMap, id, status) => {
3068
3081
  });
3069
3082
  };
3070
3083
 
3084
+ const UI_SELECT_MODE_EVENT_NAME = "ui-select";
3085
+ const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
3086
+ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
3087
+ const PROPS_PANEL_WIDTH_STORAGE_KEY = "$MagicEditorPropsPanelWidthData";
3088
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3089
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3090
+ const MIN_LEFT_COLUMN_WIDTH = 200;
3091
+ const MIN_CENTER_COLUMN_WIDTH = 400;
3092
+ const MIN_RIGHT_COLUMN_WIDTH = 300;
3093
+ const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
3094
+ const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
3095
+
3071
3096
  const _sfc_main$1m = /* @__PURE__ */ defineComponent({
3072
3097
  ...{
3073
3098
  name: "MEditorCodeParams"
@@ -3148,13 +3173,13 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
3148
3173
  emits: ["change"],
3149
3174
  setup(__props, { emit: __emit }) {
3150
3175
  const mForm = inject("mForm");
3151
- const services = inject("services");
3176
+ const { codeBlockService, uiService } = useServices();
3152
3177
  const eventBus = inject("eventBus");
3153
3178
  const emit = __emit;
3154
3179
  const props = __props;
3155
3180
  const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
3156
3181
  const hasCodeBlockSidePanel = computed(
3157
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
3182
+ () => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
3158
3183
  );
3159
3184
  const getParamItemsConfig = (codeId) => {
3160
3185
  if (!codeDsl.value || !codeId) return [];
@@ -3166,7 +3191,7 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
3166
3191
  ...paramState
3167
3192
  }));
3168
3193
  };
3169
- const codeDsl = computed(() => services?.codeBlockService.getCodeDsl());
3194
+ const codeDsl = computed(() => codeBlockService.getCodeDsl());
3170
3195
  const paramsConfig = ref(getParamItemsConfig(props.model[props.name]));
3171
3196
  watch(
3172
3197
  () => props.model[props.name],
@@ -3284,12 +3309,12 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
3284
3309
  emits: ["change"],
3285
3310
  setup(__props, { emit: __emit }) {
3286
3311
  const emit = __emit;
3287
- const { dataSourceService } = inject("services") || {};
3312
+ const { dataSourceService } = useServices();
3288
3313
  const props = __props;
3289
3314
  const optionComponent = getDesignConfig("components")?.option;
3290
3315
  const options = computed(() => {
3291
3316
  const [id, ...fieldNames] = [...props.config.parentFields || [], ...props.model.field];
3292
- const ds = dataSourceService?.getDataSourceById(id);
3317
+ const ds = dataSourceService.getDataSourceById(id);
3293
3318
  let fields = ds?.fields || [];
3294
3319
  let type = "";
3295
3320
  (fieldNames || []).forEach((fieldName) => {
@@ -3402,8 +3427,8 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
3402
3427
  }
3403
3428
  return "auto";
3404
3429
  });
3405
- const services = inject("services");
3406
- const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
3430
+ const { uiService } = useServices();
3431
+ const frameworkWidth = computed(() => uiService.get("frameworkRect").width || 0);
3407
3432
  const style = computed(() => {
3408
3433
  let { left } = props.position;
3409
3434
  if (width.value) {
@@ -3566,10 +3591,6 @@ const useCodeBlockEdit = (codeBlockService) => {
3566
3591
  const codeId = ref();
3567
3592
  const codeBlockEditorRef = useTemplateRef("codeBlockEditor");
3568
3593
  const createCodeBlock = async () => {
3569
- if (!codeBlockService) {
3570
- tMagicMessage.error("新增代码块失败");
3571
- return;
3572
- }
3573
3594
  codeConfig.value = {
3574
3595
  name: "",
3575
3596
  content: `({app, params, flowState}) => {
@@ -3582,7 +3603,7 @@ const useCodeBlockEdit = (codeBlockService) => {
3582
3603
  codeBlockEditorRef.value?.show();
3583
3604
  };
3584
3605
  const editCode = async (id) => {
3585
- const codeBlock = await codeBlockService?.getCodeContentById(id);
3606
+ const codeBlock = await codeBlockService.getCodeContentById(id);
3586
3607
  if (!codeBlock) {
3587
3608
  tMagicMessage.error("获取代码块内容失败");
3588
3609
  return;
@@ -3600,11 +3621,11 @@ const useCodeBlockEdit = (codeBlockService) => {
3600
3621
  codeBlockEditorRef.value?.show();
3601
3622
  };
3602
3623
  const deleteCode = async (key) => {
3603
- codeBlockService?.deleteCodeDslByIds([key]);
3624
+ codeBlockService.deleteCodeDslByIds([key]);
3604
3625
  };
3605
3626
  const submitCodeBlockHandler = async (values) => {
3606
3627
  if (!codeId.value) return;
3607
- await codeBlockService?.setCodeDslById(codeId.value, values);
3628
+ await codeBlockService.setCodeDslById(codeId.value, values);
3608
3629
  codeBlockEditorRef.value?.hide();
3609
3630
  };
3610
3631
  return {
@@ -3618,11 +3639,6 @@ const useCodeBlockEdit = (codeBlockService) => {
3618
3639
  };
3619
3640
  };
3620
3641
 
3621
- const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
3622
- const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
3623
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3624
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3625
-
3626
3642
  const state = shallowReactive({
3627
3643
  uiSelectMode: false,
3628
3644
  showSrc: false,
@@ -3637,9 +3653,9 @@ const state = shallowReactive({
3637
3653
  height: 817
3638
3654
  },
3639
3655
  columnWidth: {
3640
- left: Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH,
3656
+ left: storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH,
3641
3657
  center: 0,
3642
- right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH
3658
+ right: storageService.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_RIGHT_COLUMN_WIDTH
3643
3659
  },
3644
3660
  showGuides: true,
3645
3661
  showRule: true,
@@ -3831,7 +3847,7 @@ const useStage = (stageOptions) => {
3831
3847
  };
3832
3848
 
3833
3849
  const useFloatBox = (slideKeys) => {
3834
- const services = inject("services");
3850
+ const { uiService } = useServices();
3835
3851
  const floatBoxStates = ref(
3836
3852
  slideKeys.value.reduce(
3837
3853
  (total, cur) => ({
@@ -3865,10 +3881,10 @@ const useFloatBox = (slideKeys) => {
3865
3881
  if (!dragState.isDragging) return;
3866
3882
  const { startOffset } = dragState;
3867
3883
  if (Math.abs(startOffset.x - e.clientX) > effectiveDistance || Math.abs(startOffset.y - e.clientY) > effectiveDistance) {
3868
- const navMenuRect = services?.uiService?.get("navMenuRect");
3884
+ const navMenuRect = uiService.get("navMenuRect");
3869
3885
  floatBoxStates.value[key] = {
3870
3886
  left: e.clientX,
3871
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
3887
+ top: navMenuRect.top + navMenuRect.height,
3872
3888
  status: true
3873
3889
  };
3874
3890
  }
@@ -3931,9 +3947,9 @@ const useWindowRect = () => {
3931
3947
  };
3932
3948
 
3933
3949
  const useEditorContentHeight = () => {
3934
- const services = inject("services");
3935
- const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
3936
- const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
3950
+ const { uiService } = useServices();
3951
+ const frameworkHeight = computed(() => uiService.get("frameworkRect").height);
3952
+ const navMenuHeight = computed(() => uiService.get("navMenuRect").height);
3937
3953
  const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
3938
3954
  const height = ref(0);
3939
3955
  watch(
@@ -4019,16 +4035,16 @@ const useNextFloatBoxPosition = (uiService, parent) => {
4019
4035
  top: 0
4020
4036
  });
4021
4037
  const calcBoxPosition = () => {
4022
- const columnWidth = uiService?.get("columnWidth");
4023
- const navMenuRect = uiService?.get("navMenuRect");
4024
- let left = columnWidth?.left ?? 0;
4038
+ const columnWidth = uiService.get("columnWidth");
4039
+ const navMenuRect = uiService.get("navMenuRect");
4040
+ let left = columnWidth.left ?? 0;
4025
4041
  if (parent?.value) {
4026
- const rect = parent?.value?.getBoundingClientRect();
4027
- left = (rect?.left ?? 0) + (rect?.width ?? 0);
4042
+ const rect = parent.value.getBoundingClientRect();
4043
+ left = rect.left + rect.width;
4028
4044
  }
4029
4045
  boxPosition.value = {
4030
4046
  left,
4031
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
4047
+ top: navMenuRect.top + navMenuRect.height
4032
4048
  };
4033
4049
  };
4034
4050
  return {
@@ -4100,7 +4116,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
4100
4116
  setup(__props, { emit: __emit }) {
4101
4117
  const props = __props;
4102
4118
  const emit = __emit;
4103
- const services = inject("services");
4119
+ const { uiService } = useServices();
4104
4120
  const fieldValues = ref({});
4105
4121
  const fieldTitle = ref("");
4106
4122
  const width = useModel(__props, "width");
@@ -4335,7 +4351,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
4335
4351
  const addFromJsonDialogVisible = useModel(__props, "visible1");
4336
4352
  const { height: editorHeight } = useEditorContentHeight();
4337
4353
  const parentFloating = inject("parentFloating", ref(null));
4338
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4354
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
4339
4355
  return (_ctx, _cache) => {
4340
4356
  return openBlock(), createElementBlock("div", _hoisted_1$X, [
4341
4357
  createVNode(unref(MagicTable), {
@@ -4439,10 +4455,10 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
4439
4455
  const emit = __emit;
4440
4456
  const modelValue = useModel(__props, "modelValue");
4441
4457
  const optionComponent = getDesignConfig("components")?.option;
4442
- const services = inject("services");
4458
+ const { dataSourceService, uiService } = useServices();
4443
4459
  const mForm = inject("mForm");
4444
4460
  const eventBus = inject("eventBus");
4445
- const dataSources = computed(() => services?.dataSourceService.get("dataSources") || []);
4461
+ const dataSources = computed(() => dataSourceService.get("dataSources") || []);
4446
4462
  const valueIsKey = computed(() => props.value === "key");
4447
4463
  const notEditable = computed(() => filterFunction(mForm, props.notEditable, props));
4448
4464
  const dataSourcesOptions = computed(
@@ -4495,7 +4511,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
4495
4511
  emit("change", v);
4496
4512
  };
4497
4513
  const hasDataSourceSidePanel = computed(
4498
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
4514
+ () => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
4499
4515
  );
4500
4516
  const editHandler = (id) => {
4501
4517
  eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
@@ -4639,9 +4655,9 @@ const _sfc_main$1g = /* @__PURE__ */ defineComponent({
4639
4655
  immediate: true
4640
4656
  }
4641
4657
  );
4642
- const services = inject("services");
4658
+ const { dataSourceService } = useServices();
4643
4659
  const mForm = inject("mForm");
4644
- const dataSources = computed(() => services?.dataSourceService.get("dataSources") || []);
4660
+ const dataSources = computed(() => dataSourceService.get("dataSources") || []);
4645
4661
  const type = computed(() => {
4646
4662
  let type2 = props.config.fieldConfig?.type;
4647
4663
  if (typeof type2 === "function") {
@@ -4779,13 +4795,13 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
4779
4795
  setup(__props, { emit: __emit }) {
4780
4796
  const props = __props;
4781
4797
  const emit = __emit;
4782
- const { dataSourceService } = inject("services") || {};
4798
+ const { dataSourceService } = useServices();
4783
4799
  const autocompleteRef = useTemplateRef("autocomplete");
4784
4800
  const isFocused = ref(false);
4785
4801
  const state = ref("");
4786
4802
  const displayState = ref([]);
4787
4803
  const input = computed(() => autocompleteRef.value?.inputRef?.input);
4788
- const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
4804
+ const dataSources = computed(() => dataSourceService.get("dataSources"));
4789
4805
  const setDisplayState = () => {
4790
4806
  displayState.value = getDisplayField(dataSources.value, state.value);
4791
4807
  };
@@ -5078,7 +5094,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5078
5094
  const boxVisible = useModel(__props, "visible");
5079
5095
  const props = __props;
5080
5096
  const emit = __emit;
5081
- const services = inject("services");
5097
+ const { codeBlockService, uiService } = useServices();
5082
5098
  const { height: codeBlockEditorHeight } = useEditorContentHeight();
5083
5099
  const difVisible = ref(false);
5084
5100
  const { rect: windowRect } = useWindowRect();
@@ -5165,7 +5181,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5165
5181
  label: "描述",
5166
5182
  name: "extra"
5167
5183
  },
5168
- services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
5184
+ codeBlockService.getParamsColConfig() || defaultParamColConfig
5169
5185
  ]
5170
5186
  },
5171
5187
  {
@@ -5217,7 +5233,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5217
5233
  changedValue.value = undefined;
5218
5234
  };
5219
5235
  const parentFloating = inject("parentFloating", ref(null));
5220
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5236
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
5221
5237
  __expose({
5222
5238
  async show() {
5223
5239
  calcBoxPosition();
@@ -5540,20 +5556,19 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
5540
5556
  },
5541
5557
  emits: ["change"],
5542
5558
  setup(__props, { emit: __emit }) {
5559
+ const { dataSourceService, uiService } = useServices();
5543
5560
  const mForm = inject("mForm");
5544
- const services = inject("services");
5545
5561
  const eventBus = inject("eventBus");
5546
5562
  const emit = __emit;
5547
- const dataSourceService = services?.dataSourceService;
5548
5563
  const props = __props;
5549
5564
  const hasDataSourceSidePanel = computed(
5550
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5565
+ () => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5551
5566
  );
5552
5567
  const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
5553
- const dataSources = computed(() => dataSourceService?.get("dataSources"));
5568
+ const dataSources = computed(() => dataSourceService.get("dataSources"));
5554
5569
  const isCustomMethod = computed(() => {
5555
5570
  const [id, name] = props.model[props.name];
5556
- const dataSource = dataSourceService?.getDataSourceById(id);
5571
+ const dataSource = dataSourceService.getDataSourceById(id);
5557
5572
  return Boolean(dataSource?.methods.find((method) => method.name === name));
5558
5573
  });
5559
5574
  const getParamItemsConfig = ([dataSourceId, methodName] = ["", ""]) => {
@@ -5575,7 +5590,7 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
5575
5590
  }
5576
5591
  };
5577
5592
  const methodsOptions = computed(
5578
- () => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length)?.map((ds) => ({
5593
+ () => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService.getFormMethod(ds.type).length)?.map((ds) => ({
5579
5594
  label: ds.title || ds.id,
5580
5595
  value: ds.id,
5581
5596
  children: [
@@ -5603,7 +5618,7 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
5603
5618
  };
5604
5619
  const editCodeHandler = () => {
5605
5620
  const [id] = props.model[props.name];
5606
- const dataSource = dataSourceService?.getDataSourceById(id);
5621
+ const dataSource = dataSourceService.getDataSourceById(id);
5607
5622
  if (!dataSource) return;
5608
5623
  eventBus?.emit("edit-data-source", id);
5609
5624
  };
@@ -5681,7 +5696,7 @@ const _sfc_main$1b = /* @__PURE__ */ defineComponent({
5681
5696
  setup(__props, { emit: __emit }) {
5682
5697
  const props = __props;
5683
5698
  const emit = __emit;
5684
- const services = inject("services");
5699
+ const { uiService } = useServices();
5685
5700
  const width = useModel(__props, "width");
5686
5701
  const drawerTitle = ref("");
5687
5702
  const formValues = ref({});
@@ -5858,7 +5873,7 @@ const _sfc_main$1b = /* @__PURE__ */ defineComponent({
5858
5873
  const addDialogVisible = useModel(__props, "visible");
5859
5874
  const { height: editorHeight } = useEditorContentHeight();
5860
5875
  const parentFloating = inject("parentFloating", ref(null));
5861
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5876
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
5862
5877
  return (_ctx, _cache) => {
5863
5878
  return openBlock(), createElementBlock("div", _hoisted_1$Q, [
5864
5879
  createVNode(unref(MagicTable), {
@@ -5930,12 +5945,12 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
5930
5945
  const emit = __emit;
5931
5946
  const props = __props;
5932
5947
  const mForm = inject("mForm");
5933
- const { dataSourceService, uiService } = inject("services") || {};
5948
+ const { dataSourceService, uiService } = useServices();
5934
5949
  const eventBus = inject("eventBus");
5935
- const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
5950
+ const dataSources = computed(() => dataSourceService.get("dataSources"));
5936
5951
  const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
5937
5952
  const hasDataSourceSidePanel = computed(
5938
- () => (uiService?.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5953
+ () => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
5939
5954
  );
5940
5955
  const selectConfig = computed(() => {
5941
5956
  const { type, dataSourceType, value, ...config } = props.config;
@@ -5961,7 +5976,7 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
5961
5976
  const value = props.model[props.name];
5962
5977
  if (!value) return;
5963
5978
  const id = typeof value === "string" ? value : value.dataSourceId;
5964
- const dataSource = dataSourceService?.getDataSourceById(id);
5979
+ const dataSource = dataSourceService.getDataSourceById(id);
5965
5980
  if (!dataSource) return;
5966
5981
  eventBus?.emit("edit-data-source", id);
5967
5982
  };
@@ -6024,7 +6039,7 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
6024
6039
  setup(__props, { emit: __emit }) {
6025
6040
  const emit = __emit;
6026
6041
  const props = __props;
6027
- const { dataSourceService } = inject("services") || {};
6042
+ const { dataSourceService } = useServices();
6028
6043
  const mForm = inject("mForm");
6029
6044
  const parentFields = computed(() => filterFunction(mForm, props.config.parentFields, props) || []);
6030
6045
  const config = computed(() => ({
@@ -6043,7 +6058,7 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
6043
6058
  type: "cascader",
6044
6059
  options: () => {
6045
6060
  const [dsId, ...keys] = parentFields.value;
6046
- const ds = dataSourceService?.getDataSourceById(dsId);
6061
+ const ds = dataSourceService.getDataSourceById(dsId);
6047
6062
  if (!ds) {
6048
6063
  return [];
6049
6064
  }
@@ -6081,7 +6096,7 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
6081
6096
  name: "value",
6082
6097
  type: (mForm2, { model }) => {
6083
6098
  const [id, ...fieldNames] = [...parentFields.value, ...model.field];
6084
- const ds = dataSourceService?.getDataSourceById(id);
6099
+ const ds = dataSourceService.getDataSourceById(id);
6085
6100
  let fields = ds?.fields || [];
6086
6101
  let type = "";
6087
6102
  (fieldNames || []).forEach((fieldName) => {
@@ -6161,11 +6176,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6161
6176
  setup(__props, { emit: __emit }) {
6162
6177
  const props = __props;
6163
6178
  const emit = __emit;
6164
- const services = inject("services");
6165
- const editorService = services?.editorService;
6166
- const dataSourceService = services?.dataSourceService;
6167
- const eventsService = services?.eventsService;
6168
- const codeBlockService = services?.codeBlockService;
6179
+ const { editorService, dataSourceService, eventsService, codeBlockService } = useServices();
6169
6180
  const eventNameConfig = computed(() => {
6170
6181
  const defaultEventNameConfig = {
6171
6182
  name: "name",
@@ -6181,11 +6192,10 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6181
6192
  valueSeparator: ".",
6182
6193
  options: (mForm, { formValue }) => {
6183
6194
  let events = [];
6184
- if (!eventsService || !dataSourceService) return events;
6185
6195
  if (props.config.src === "component") {
6186
6196
  events = eventsService.getEvent(formValue.type);
6187
6197
  if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
6188
- const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
6198
+ const pageFragment = editorService.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
6189
6199
  if (pageFragment) {
6190
6200
  events = [
6191
6201
  {
@@ -6247,13 +6257,13 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6247
6257
  {
6248
6258
  text: "代码",
6249
6259
  label: "代码",
6250
- disabled: !Object.keys(codeBlockService?.getCodeDsl() || {}).length,
6260
+ disabled: !Object.keys(codeBlockService.getCodeDsl() || {}).length,
6251
6261
  value: ActionType.CODE
6252
6262
  },
6253
6263
  {
6254
6264
  text: "数据源",
6255
6265
  label: "数据源",
6256
- disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length).length,
6266
+ disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService.getFormMethod(ds.type).length).length,
6257
6267
  value: ActionType.DATA_SOURCE
6258
6268
  }
6259
6269
  ]
@@ -6278,7 +6288,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6278
6288
  name: "method",
6279
6289
  text: "动作",
6280
6290
  type: (mForm, { model }) => {
6281
- const to = editorService?.getNodeById(model.to);
6291
+ const to = editorService.getNodeById(model.to);
6282
6292
  if (to && to.type === "page-fragment-container" && to.pageFragmentId) {
6283
6293
  return "cascader";
6284
6294
  }
@@ -6287,17 +6297,17 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6287
6297
  checkStrictly: () => props.config.src !== "component",
6288
6298
  display: (mForm, { model }) => model.actionType === ActionType.COMP,
6289
6299
  options: (mForm, { model }) => {
6290
- const node = editorService?.getNodeById(model.to);
6300
+ const node = editorService.getNodeById(model.to);
6291
6301
  if (!node?.type) return [];
6292
6302
  let methods = [];
6293
- methods = eventsService?.getMethod(node.type) || [];
6303
+ methods = eventsService.getMethod(node.type);
6294
6304
  if (node.type === "page-fragment-container" && node.pageFragmentId) {
6295
- const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
6305
+ const pageFragment = editorService.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
6296
6306
  if (pageFragment) {
6297
6307
  methods = [];
6298
6308
  pageFragment.items.forEach((node2) => {
6299
6309
  traverseNode(node2, (node3) => {
6300
- const nodeMethods = node3.type && eventsService?.getMethod(node3.type) || [];
6310
+ const nodeMethods = node3.type && eventsService.getMethod(node3.type) || [];
6301
6311
  if (nodeMethods.length) {
6302
6312
  methods.push({
6303
6313
  label: `${node3.name}_${node3.id}`,
@@ -6323,7 +6333,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6323
6333
  type: "code-select-col",
6324
6334
  text: "代码块",
6325
6335
  name: "codeId",
6326
- notEditable: () => !codeBlockService?.getEditStatus(),
6336
+ notEditable: () => !codeBlockService.getEditStatus(),
6327
6337
  display: (mForm, { model }) => model.actionType === ActionType.CODE
6328
6338
  };
6329
6339
  return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
@@ -6333,7 +6343,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6333
6343
  type: "data-source-method-select",
6334
6344
  text: "数据源方法",
6335
6345
  name: "dataSourceMethod",
6336
- notEditable: () => !services?.dataSourceService.get("editable"),
6346
+ notEditable: () => !dataSourceService.get("editable"),
6337
6347
  display: (mForm, { model }) => model.actionType === ActionType.DATA_SOURCE
6338
6348
  };
6339
6349
  return { ...defaultDataSourceActionConfig, ...props.config.dataSourceActionConfig };
@@ -6346,7 +6356,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6346
6356
  name: "name",
6347
6357
  label: "事件名",
6348
6358
  type: eventNameConfig.value.type,
6349
- options: (mForm, { formValue }) => eventsService?.getEvent(formValue.type).map((option) => ({
6359
+ options: (mForm, { formValue }) => eventsService.getEvent(formValue.type).map((option) => ({
6350
6360
  text: option.label,
6351
6361
  value: option.value
6352
6362
  }))
@@ -6361,9 +6371,9 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6361
6371
  label: "动作",
6362
6372
  type: compActionConfig.value.type,
6363
6373
  options: (mForm, { model }) => {
6364
- const node = editorService?.getNodeById(model.to);
6374
+ const node = editorService.getNodeById(model.to);
6365
6375
  if (!node?.type) return [];
6366
- return eventsService?.getMethod(node.type).map((option) => ({
6376
+ return eventsService.getMethod(node.type).map((option) => ({
6367
6377
  text: option.label,
6368
6378
  value: option.value
6369
6379
  }));
@@ -6677,11 +6687,11 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
6677
6687
  },
6678
6688
  emits: ["change"],
6679
6689
  setup(__props, { emit: __emit }) {
6680
- const services = inject("services");
6690
+ const { editorService } = useServices();
6681
6691
  const emit = __emit;
6682
6692
  const props = __props;
6683
6693
  const pageList = computed(
6684
- () => services?.editorService.get("root")?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT)
6694
+ () => editorService.get("root")?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT)
6685
6695
  );
6686
6696
  const selectConfig = {
6687
6697
  type: "select",
@@ -6701,7 +6711,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
6701
6711
  emit("change", props.model[props.name]);
6702
6712
  };
6703
6713
  const editPageFragment = (id) => {
6704
- services?.editorService.select(id);
6714
+ editorService.select(id);
6705
6715
  };
6706
6716
  return (_ctx, _cache) => {
6707
6717
  const _component_m_form_container = resolveComponent("m-form-container");
@@ -7674,7 +7684,7 @@ const _hoisted_2$a = { class: "border-icon-container" };
7674
7684
  const _hoisted_3$3 = { class: "border-icon-container-row" };
7675
7685
  const _hoisted_4$3 = { class: "border-icon-container-row" };
7676
7686
  const _hoisted_5$1 = { class: "border-icon-container-row" };
7677
- const _hoisted_6 = { class: "border-value-container" };
7687
+ const _hoisted_6$1 = { class: "border-value-container" };
7678
7688
  const _sfc_main$F = /* @__PURE__ */ defineComponent({
7679
7689
  __name: "Border",
7680
7690
  props: {
@@ -7787,7 +7797,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
7787
7797
  )
7788
7798
  ])
7789
7799
  ]),
7790
- createElementVNode("div", _hoisted_6, [
7800
+ createElementVNode("div", _hoisted_6$1, [
7791
7801
  createVNode(unref(MContainer), {
7792
7802
  config: config.value,
7793
7803
  model: _ctx.model,
@@ -7966,13 +7976,12 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
7966
7976
  setup(__props, { emit: __emit }) {
7967
7977
  const props = __props;
7968
7978
  const emit = __emit;
7969
- const services = inject("services");
7979
+ const { editorService, uiService, stageOverlayService } = useServices();
7970
7980
  const mForm = inject("mForm");
7971
7981
  const val = computed(() => props.model[props.name]);
7972
7982
  const uiSelectMode = ref(false);
7973
7983
  const cancelHandler = () => {
7974
- if (!services?.uiService) return;
7975
- services.uiService.set("uiSelectMode", false);
7984
+ uiService.set("uiSelectMode", false);
7976
7985
  uiSelectMode.value = false;
7977
7986
  globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
7978
7987
  };
@@ -7991,12 +8000,11 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
7991
8000
  }
7992
8001
  };
7993
8002
  const toName = computed(() => {
7994
- const config = services?.editorService.getNodeById(val.value);
8003
+ const config = editorService.getNodeById(val.value);
7995
8004
  return config?.name || "";
7996
8005
  });
7997
8006
  const startSelect = () => {
7998
- if (!services?.uiService) return;
7999
- services.uiService.set("uiSelectMode", true);
8007
+ uiService.set("uiSelectMode", true);
8000
8008
  uiSelectMode.value = true;
8001
8009
  globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
8002
8010
  };
@@ -8008,22 +8016,19 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
8008
8016
  }
8009
8017
  };
8010
8018
  const selectNode = async (id) => {
8011
- if (!services) return;
8012
- await services.editorService.select(id);
8013
- services.editorService.get("stage")?.select(id);
8014
- services.stageOverlayService.get("stage")?.select(id);
8019
+ await editorService.select(id);
8020
+ editorService.get("stage")?.select(id);
8021
+ stageOverlayService.get("stage")?.select(id);
8015
8022
  };
8016
8023
  const highlight = throttle((id) => {
8017
- if (!services) return;
8018
- services.editorService.highlight(id);
8019
- services.editorService.get("stage")?.highlight(id);
8020
- services.stageOverlayService.get("stage")?.highlight(id);
8024
+ editorService.highlight(id);
8025
+ editorService.get("stage")?.highlight(id);
8026
+ stageOverlayService.get("stage")?.highlight(id);
8021
8027
  }, 150);
8022
8028
  const unhighlight = () => {
8023
- if (!services) return;
8024
- services.editorService.set("highlightNode", null);
8025
- services.editorService.get("stage")?.clearHighlight();
8026
- services.stageOverlayService.get("stage")?.clearHighlight();
8029
+ editorService.set("highlightNode", null);
8030
+ editorService.get("stage")?.clearHighlight();
8031
+ stageOverlayService.get("stage")?.clearHighlight();
8027
8032
  };
8028
8033
  return (_ctx, _cache) => {
8029
8034
  return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
@@ -8373,7 +8378,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
8373
8378
  },
8374
8379
  setup(__props) {
8375
8380
  const props = __props;
8376
- const services = inject("services");
8381
+ const services = useServices();
8377
8382
  const disabled = computed(() => {
8378
8383
  if (typeof props.data === "string") return false;
8379
8384
  if (props.data.type === "component") return false;
@@ -8392,7 +8397,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
8392
8397
  });
8393
8398
  const buttonHandler = (item, event) => {
8394
8399
  if (disabled.value) return;
8395
- if (typeof item.handler === "function" && services) {
8400
+ if (typeof item.handler === "function") {
8396
8401
  item.handler?.(services, event);
8397
8402
  }
8398
8403
  };
@@ -8584,12 +8589,9 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
8584
8589
  },
8585
8590
  __name: "AddButton",
8586
8591
  setup(__props) {
8587
- const services = inject("services");
8588
- const uiService = services?.uiService;
8589
- const editorService = services?.editorService;
8590
- const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
8592
+ const { editorService, uiService } = useServices();
8593
+ const showAddPageButton = computed(() => uiService.get("showAddPageButton"));
8591
8594
  const addPage = (type) => {
8592
- if (!editorService) return;
8593
8595
  const root = toRaw(editorService.get("root"));
8594
8596
  if (!root) throw new Error("root 不能为空");
8595
8597
  const pageConfig = {
@@ -8653,13 +8655,11 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
8653
8655
  },
8654
8656
  setup(__props, { expose: __expose }) {
8655
8657
  const props = __props;
8656
- const services = inject("services");
8657
- const editorService = services?.editorService;
8658
- const uiService = services?.uiService;
8658
+ const { editorService, uiService } = useServices();
8659
8659
  const itemsContainerEl = useTemplateRef("itemsContainer");
8660
8660
  const canScroll = ref(false);
8661
- const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
8662
- const showPageListButton = computed(() => uiService?.get("showPageListButton"));
8661
+ const showAddPageButton = computed(() => uiService.get("showAddPageButton"));
8662
+ const showPageListButton = computed(() => uiService.get("showPageListButton"));
8663
8663
  const itemsContainerWidth = ref(0);
8664
8664
  const pageBarEl = useTemplateRef("pageBar");
8665
8665
  const setCanScroll = () => {
@@ -8731,7 +8731,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
8731
8731
  beforeDragList = sortable.toArray();
8732
8732
  },
8733
8733
  onUpdate: async (event) => {
8734
- await editorService?.sort(
8734
+ await editorService.sort(
8735
8735
  beforeDragList[event.oldIndex],
8736
8736
  beforeDragList[event.newIndex]
8737
8737
  );
@@ -8812,13 +8812,11 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
8812
8812
  list: {}
8813
8813
  },
8814
8814
  setup(__props) {
8815
- const services = inject("services");
8816
- const uiService = services?.uiService;
8817
- const editorService = services?.editorService;
8818
- const showPageListButton = computed(() => uiService?.get("showPageListButton"));
8819
- const page = computed(() => editorService?.get("page"));
8815
+ const { editorService, uiService } = useServices();
8816
+ const showPageListButton = computed(() => uiService.get("showPageListButton"));
8817
+ const page = computed(() => editorService.get("page"));
8820
8818
  const switchPage = async (id) => {
8821
- await editorService?.select(id);
8819
+ await editorService.select(id);
8822
8820
  };
8823
8821
  return (_ctx, _cache) => {
8824
8822
  return showPageListButton.value ? (openBlock(), createElementBlock("div", _hoisted_1$h, [
@@ -8949,10 +8947,9 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
8949
8947
  },
8950
8948
  setup(__props) {
8951
8949
  const props = __props;
8952
- const services = inject("services");
8953
- const editorService = services?.editorService;
8954
- const root = computed(() => editorService?.get("root"));
8955
- const page = computed(() => editorService?.get("page"));
8950
+ const { editorService } = useServices();
8951
+ const root = computed(() => editorService.get("root"));
8952
+ const page = computed(() => editorService.get("page"));
8956
8953
  const query = ref({
8957
8954
  pageType: [NodeType.PAGE, NodeType.PAGE_FRAGMENT],
8958
8955
  keyword: ""
@@ -8973,17 +8970,17 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
8973
8970
  });
8974
8971
  });
8975
8972
  const switchPage = (id) => {
8976
- editorService?.select(id);
8973
+ editorService.select(id);
8977
8974
  };
8978
8975
  const copy = (node) => {
8979
- node && editorService?.copy(node);
8980
- editorService?.paste({
8976
+ node && editorService.copy(node);
8977
+ editorService.paste({
8981
8978
  left: 0,
8982
8979
  top: 0
8983
8980
  });
8984
8981
  };
8985
8982
  const remove = (node) => {
8986
- editorService?.remove(node);
8983
+ editorService.remove(node);
8987
8984
  };
8988
8985
  const pageBarScrollContainerRef = useTemplateRef("pageBarScrollContainer");
8989
8986
  const pageBarItemEls = useTemplateRef("pageBarItems");
@@ -9127,10 +9124,8 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
9127
9124
  disabledPageFragment: { type: Boolean }
9128
9125
  },
9129
9126
  setup(__props) {
9130
- const services = inject("services");
9127
+ const { editorService } = useServices();
9131
9128
  const clickHandler = (type) => {
9132
- const { editorService } = services || {};
9133
- if (!editorService) return;
9134
9129
  const root = toRaw(editorService.get("root"));
9135
9130
  if (!root) throw new Error("root 不能为空");
9136
9131
  editorService.add({
@@ -9196,41 +9191,35 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9196
9191
  },
9197
9192
  setup(__props) {
9198
9193
  const codeOptions = inject("codeOptions", {});
9199
- const { editorService, uiService } = inject("services") || {};
9194
+ const { editorService, uiService, storageService } = useServices();
9200
9195
  const contentEl = useTemplateRef("content");
9201
9196
  const splitViewRef = useTemplateRef("splitView");
9202
- const root = computed(() => editorService?.get("root"));
9203
- const page = computed(() => editorService?.get("page"));
9204
- const pageLength = computed(() => editorService?.get("pageLength") || 0);
9205
- const showSrc = computed(() => uiService?.get("showSrc"));
9206
- const columnWidth = computed(
9207
- () => uiService?.get("columnWidth") || {
9208
- left: 0,
9209
- center: 0,
9210
- right: 0
9211
- }
9212
- );
9197
+ const root = computed(() => editorService.get("root"));
9198
+ const page = computed(() => editorService.get("page"));
9199
+ const pageLength = computed(() => editorService.get("pageLength") || 0);
9200
+ const showSrc = computed(() => uiService.get("showSrc"));
9201
+ const columnWidth = computed(() => uiService.get("columnWidth"));
9213
9202
  watch(pageLength, () => {
9214
9203
  splitViewRef.value?.updateWidth();
9215
9204
  });
9216
9205
  watch(
9217
- () => uiService?.get("hideSlideBar"),
9206
+ () => uiService.get("hideSlideBar"),
9218
9207
  (hideSlideBar) => {
9219
- uiService?.set("columnWidth", {
9208
+ uiService.set("columnWidth", {
9220
9209
  ...columnWidth.value,
9221
- left: hideSlideBar ? 0 : Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH
9210
+ left: hideSlideBar ? 0 : storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH
9222
9211
  });
9223
9212
  }
9224
9213
  );
9225
9214
  const columnWidthChange = (columnW) => {
9226
- globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.left}`);
9227
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.right}`);
9228
- uiService?.set("columnWidth", columnW);
9215
+ storageService.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, columnW.left, { protocol: Protocol.NUMBER });
9216
+ storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnW.right, { protocol: Protocol.NUMBER });
9217
+ uiService.set("columnWidth", columnW);
9229
9218
  };
9230
- const frameworkRect = computed(() => uiService?.get("frameworkRect"));
9219
+ const frameworkRect = computed(() => uiService.get("frameworkRect"));
9231
9220
  const resizerObserver = new ResizeObserver((entries) => {
9232
9221
  const { contentRect } = entries[0];
9233
- uiService?.set("frameworkRect", {
9222
+ uiService.set("frameworkRect", {
9234
9223
  width: contentRect.width,
9235
9224
  height: contentRect.height,
9236
9225
  left: contentRect.left,
@@ -9248,7 +9237,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9248
9237
  const saveCode = (value) => {
9249
9238
  try {
9250
9239
  const parseDSL = getEditorConfig("parseDSL");
9251
- editorService?.set("root", parseDSL(value));
9240
+ editorService.set("root", parseDSL(value));
9252
9241
  } catch (e) {
9253
9242
  console.error(e);
9254
9243
  }
@@ -9277,10 +9266,10 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9277
9266
  "right-class": "m-editor-framework-right",
9278
9267
  left: columnWidth.value.left,
9279
9268
  right: columnWidth.value.right,
9280
- "min-left": 200,
9281
- "min-right": 300,
9282
- "min-center": 400,
9283
- width: frameworkRect.value?.width || 0,
9269
+ "min-left": unref(MIN_LEFT_COLUMN_WIDTH),
9270
+ "min-right": unref(MIN_RIGHT_COLUMN_WIDTH),
9271
+ "min-center": unref(MIN_CENTER_COLUMN_WIDTH),
9272
+ width: frameworkRect.value.width,
9284
9273
  onChange: columnWidthChange
9285
9274
  }, createSlots({
9286
9275
  left: withCtx(() => [
@@ -9323,7 +9312,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9323
9312
  ]),
9324
9313
  key: "0"
9325
9314
  } : undefined
9326
- ]), 1032, ["left", "right", "width"])),
9315
+ ]), 1032, ["left", "right", "min-left", "min-right", "min-center", "width"])),
9327
9316
  renderSlot(_ctx.$slots, "content-after"),
9328
9317
  renderSlot(_ctx.$slots, "footer")
9329
9318
  ],
@@ -9345,13 +9334,12 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9345
9334
  },
9346
9335
  setup(__props) {
9347
9336
  const props = __props;
9348
- const services = inject("services");
9349
- const uiService = services?.uiService;
9350
- const columnWidth = computed(() => services?.uiService.get("columnWidth"));
9337
+ const { uiService, editorService, historyService } = useServices();
9338
+ const columnWidth = computed(() => uiService.get("columnWidth"));
9351
9339
  const keys = Object.values(ColumnLayout);
9352
- const showGuides = computed(() => uiService?.get("showGuides") ?? true);
9353
- const showRule = computed(() => uiService?.get("showRule") ?? true);
9354
- const zoom = computed(() => uiService?.get("zoom") ?? 1);
9340
+ const showGuides = computed(() => uiService.get("showGuides"));
9341
+ const showRule = computed(() => uiService.get("showRule"));
9342
+ const zoom = computed(() => uiService.get("zoom"));
9355
9343
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
9356
9344
  const ctrl = isMac ? "Command" : "Ctrl";
9357
9345
  const getConfig = (item) => {
@@ -9381,10 +9369,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9381
9369
  className: "delete",
9382
9370
  icon: markRaw(Delete),
9383
9371
  tooltip: `刪除(Delete)`,
9384
- disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
9372
+ disabled: () => editorService.get("node")?.type === NodeType.PAGE,
9385
9373
  handler: () => {
9386
- const node = services?.editorService.get("node");
9387
- node && services?.editorService.remove(node);
9374
+ const node = editorService.get("node");
9375
+ node && editorService.remove(node);
9388
9376
  }
9389
9377
  });
9390
9378
  break;
@@ -9394,8 +9382,8 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9394
9382
  className: "undo",
9395
9383
  icon: markRaw(Back),
9396
9384
  tooltip: `后退(${ctrl}+z)`,
9397
- disabled: () => !services?.historyService.state.canUndo,
9398
- handler: () => services?.editorService.undo()
9385
+ disabled: () => !historyService.state.canUndo,
9386
+ handler: () => editorService.undo()
9399
9387
  });
9400
9388
  break;
9401
9389
  case "redo":
@@ -9404,8 +9392,8 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9404
9392
  className: "redo",
9405
9393
  icon: markRaw(Right),
9406
9394
  tooltip: `前进(${ctrl}+Shift+z)`,
9407
- disabled: () => !services?.historyService.state.canRedo,
9408
- handler: () => services?.editorService.redo()
9395
+ disabled: () => !historyService.state.canRedo,
9396
+ handler: () => editorService.redo()
9409
9397
  });
9410
9398
  break;
9411
9399
  case "zoom-in":
@@ -9488,7 +9476,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9488
9476
  const resizeObserver = new ResizeObserver(() => {
9489
9477
  const rect = navMenuEl.value?.getBoundingClientRect();
9490
9478
  if (rect) {
9491
- uiService?.set("navMenuRect", {
9479
+ uiService.set("navMenuRect", {
9492
9480
  left: rect.left,
9493
9481
  top: rect.top,
9494
9482
  width: rect.width,
@@ -9570,12 +9558,13 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
9570
9558
  setup(__props, { expose: __expose, emit: __emit }) {
9571
9559
  const props = __props;
9572
9560
  const emit = __emit;
9573
- const services = inject("services");
9561
+ const services = useServices();
9562
+ const { editorService, uiService } = services;
9574
9563
  const codeOptions = inject("codeOptions", {});
9575
9564
  const showSrc = ref(false);
9576
- const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
9565
+ const propsPanelSize = computed(() => uiService.get("propsPanelSize") || "small");
9577
9566
  const { height: editorContentHeight } = useEditorContentHeight();
9578
- const stage = computed(() => services?.editorService.get("stage"));
9567
+ const stage = computed(() => editorService.get("stage"));
9579
9568
  const configFormRef = useTemplateRef("configForm");
9580
9569
  watchEffect(() => {
9581
9570
  if (configFormRef.value) {
@@ -9652,33 +9641,41 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
9652
9641
  }
9653
9642
  });
9654
9643
 
9655
- const useStylePanel = (services) => {
9644
+ const useStylePanel = ({ uiService, storageService }, propsPanelWidth) => {
9656
9645
  const showStylePanelStorageKey = "props-panel-show-style-panel";
9657
- const showStylePanelStorageValue = services?.storageService.getItem(showStylePanelStorageKey, {
9646
+ const showStylePanelStorageValue = storageService.getItem(showStylePanelStorageKey, {
9658
9647
  protocol: Protocol.BOOLEAN
9659
9648
  });
9660
9649
  if (typeof showStylePanelStorageValue === "boolean") {
9661
- services?.uiService.set("showStylePanel", showStylePanelStorageValue);
9662
- }
9663
- const showStylePanel = computed(
9664
- () => showStylePanelToggleButton.value && (services?.uiService.get("showStylePanel") ?? true)
9665
- );
9666
- const showStylePanelToggleButton = computed(
9667
- () => !(services && services.uiService.get("frameworkRect").width < 1280)
9668
- );
9669
- const showStylePanelHandler = () => {
9670
- services?.uiService.set("showStylePanel", true);
9671
- services?.storageService.setItem(showStylePanelStorageKey, true, { protocol: Protocol.BOOLEAN });
9672
- };
9673
- const closeStylePanelHandler = () => {
9674
- services?.uiService.set("showStylePanel", false);
9675
- services?.storageService.setItem(showStylePanelStorageKey, false, { protocol: Protocol.BOOLEAN });
9650
+ uiService.set("showStylePanel", showStylePanelStorageValue);
9651
+ }
9652
+ const showStylePanel = computed(() => showStylePanelToggleButton.value && (uiService.get("showStylePanel") ?? true));
9653
+ const showStylePanelToggleButton = computed(() => uiService.get("frameworkRect").width >= 1280);
9654
+ const toggleStylePanel = (showStylePanel2) => {
9655
+ uiService.set("showStylePanel", showStylePanel2);
9656
+ storageService.setItem(showStylePanelStorageKey, showStylePanel2, { protocol: Protocol.BOOLEAN });
9657
+ const columnWidth = {
9658
+ ...uiService.get("columnWidth")
9659
+ };
9660
+ if (showStylePanel2) {
9661
+ columnWidth.right += propsPanelWidth.value;
9662
+ columnWidth.center -= propsPanelWidth.value;
9663
+ } else {
9664
+ columnWidth.right -= propsPanelWidth.value;
9665
+ columnWidth.center += propsPanelWidth.value;
9666
+ }
9667
+ if (columnWidth.center < 0) {
9668
+ columnWidth.right = columnWidth.right + columnWidth.center - MIN_CENTER_COLUMN_WIDTH;
9669
+ columnWidth.center = MIN_CENTER_COLUMN_WIDTH;
9670
+ propsPanelWidth.value = columnWidth.right / 2;
9671
+ }
9672
+ storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnWidth.right, { protocol: Protocol.NUMBER });
9673
+ uiService.set("columnWidth", columnWidth);
9676
9674
  };
9677
9675
  return {
9678
9676
  showStylePanel,
9679
9677
  showStylePanelToggleButton,
9680
- showStylePanelHandler,
9681
- closeStylePanelHandler
9678
+ toggleStylePanel
9682
9679
  };
9683
9680
  };
9684
9681
 
@@ -9699,11 +9696,11 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9699
9696
  emits: ["submit-error", "form-error", "mounted"],
9700
9697
  setup(__props, { expose: __expose, emit: __emit }) {
9701
9698
  const emit = __emit;
9702
- const services = inject("services");
9699
+ const { editorService, uiService, propsService, storageService } = useServices();
9703
9700
  const values = ref({});
9704
9701
  const curFormConfig = ref([]);
9705
- const node = computed(() => services?.editorService.get("node"));
9706
- const nodes = computed(() => services?.editorService.get("nodes") || []);
9702
+ const node = computed(() => editorService.get("node"));
9703
+ const nodes = computed(() => editorService.get("nodes"));
9707
9704
  const styleFormConfig = [
9708
9705
  {
9709
9706
  tabPosition: "right",
@@ -9716,13 +9713,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9716
9713
  return;
9717
9714
  }
9718
9715
  const type = node.value.type || (node.value.items ? "container" : "text");
9719
- curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
9716
+ curFormConfig.value = await propsService.getPropsConfig(type);
9720
9717
  values.value = node.value;
9721
9718
  };
9722
9719
  watchEffect(init);
9723
- services?.propsService.on("props-configs-change", init);
9720
+ propsService.on("props-configs-change", init);
9724
9721
  onBeforeUnmount(() => {
9725
- services?.propsService.off("props-configs-change", init);
9722
+ propsService.off("props-configs-change", init);
9726
9723
  });
9727
9724
  const submit = async (v, eventData) => {
9728
9725
  try {
@@ -9745,7 +9742,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9745
9742
  }
9746
9743
  });
9747
9744
  }
9748
- services?.editorService.update(newValue, { changeRecords: eventData?.changeRecords });
9745
+ editorService.update(newValue, { changeRecords: eventData?.changeRecords });
9749
9746
  } catch (e) {
9750
9747
  emit("submit-error", e);
9751
9748
  }
@@ -9759,45 +9756,36 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9759
9756
  }
9760
9757
  };
9761
9758
  const propsPanelEl = useTemplateRef("propsPanel");
9759
+ const propsPanelWidth = ref(
9760
+ storageService.getItem(PROPS_PANEL_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || 300
9761
+ );
9762
+ onMounted(() => {
9763
+ propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${propsPanelWidth.value}px`);
9764
+ });
9762
9765
  const widthChange = ({ deltaX }) => {
9763
- if (!propsPanelEl.value || !services) {
9766
+ if (!propsPanelEl.value) {
9764
9767
  return;
9765
9768
  }
9766
9769
  const width = globalThis.parseFloat(
9767
9770
  getComputedStyle(propsPanelEl.value).getPropertyValue("--props-style-panel-width")
9768
9771
  );
9769
9772
  let value = width - deltaX;
9770
- if (value > services.uiService.get("columnWidth").right) {
9771
- value = services.uiService.get("columnWidth").right - 40;
9773
+ if (value > uiService.get("columnWidth").right) {
9774
+ value = uiService.get("columnWidth").right - 40;
9772
9775
  }
9773
- propsPanelEl.value.style.setProperty("--props-style-panel-width", `${value}px`);
9776
+ propsPanelWidth.value = value;
9774
9777
  };
9775
- const { showStylePanel, showStylePanelToggleButton, showStylePanelHandler, closeStylePanelHandler } = useStylePanel(services);
9776
- watch(showStylePanel, (showStylePanel2) => {
9777
- if (!propsPanelEl.value || !services) {
9778
- return;
9779
- }
9780
- const columnWidth = {
9781
- ...services.uiService.get("columnWidth")
9782
- };
9783
- const width = globalThis.parseFloat(
9784
- getComputedStyle(propsPanelEl.value).getPropertyValue("--props-style-panel-width")
9785
- );
9786
- if (showStylePanel2) {
9787
- columnWidth.right += width;
9788
- columnWidth.center -= width;
9789
- } else {
9790
- columnWidth.right -= width;
9791
- columnWidth.center += width;
9792
- }
9793
- if (columnWidth.center < 0) {
9794
- columnWidth.right = columnWidth.right + columnWidth.center - 400;
9795
- columnWidth.center = 400;
9796
- propsPanelEl.value.style.setProperty("--props-style-panel-width", `${columnWidth.right / 2}px`);
9797
- }
9798
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnWidth.right}`);
9799
- services.uiService.set("columnWidth", columnWidth);
9778
+ watch(propsPanelWidth, (value) => {
9779
+ propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${value}px`);
9780
+ storageService.setItem(PROPS_PANEL_WIDTH_STORAGE_KEY, value, { protocol: Protocol.NUMBER });
9800
9781
  });
9782
+ const { showStylePanel, showStylePanelToggleButton, toggleStylePanel } = useStylePanel(
9783
+ {
9784
+ storageService,
9785
+ uiService
9786
+ },
9787
+ propsPanelWidth
9788
+ );
9801
9789
  const propertyFormPanelRef = useTemplateRef("propertyFormPanel");
9802
9790
  __expose({
9803
9791
  getFormState() {
@@ -9842,7 +9830,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9842
9830
  }, {
9843
9831
  "props-form-panel-header": withCtx(() => [
9844
9832
  createElementVNode("div", _hoisted_2$4, [
9845
- _cache[0] || (_cache[0] = createElementVNode(
9833
+ _cache[2] || (_cache[2] = createElementVNode(
9846
9834
  "span",
9847
9835
  null,
9848
9836
  "样式",
@@ -9853,14 +9841,14 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9853
9841
  createVNode(unref(TMagicButton), {
9854
9842
  link: "",
9855
9843
  size: "small",
9856
- onClick: unref(closeStylePanelHandler)
9844
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(toggleStylePanel)(false))
9857
9845
  }, {
9858
9846
  default: withCtx(() => [
9859
9847
  createVNode(_sfc_main$1r, { icon: unref(Close) }, null, 8, ["icon"])
9860
9848
  ]),
9861
9849
  _: 1
9862
9850
  /* STABLE */
9863
- }, 8, ["onClick"])
9851
+ })
9864
9852
  ])
9865
9853
  ])
9866
9854
  ]),
@@ -9871,14 +9859,14 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
9871
9859
  key: 2,
9872
9860
  class: "m-editor-props-panel-style-icon",
9873
9861
  circle: "",
9874
- onClick: unref(showStylePanelHandler)
9862
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(toggleStylePanel)(true))
9875
9863
  }, {
9876
9864
  default: withCtx(() => [
9877
9865
  createVNode(_sfc_main$1r, { icon: unref(Sugar) }, null, 8, ["icon"])
9878
9866
  ]),
9879
9867
  _: 1
9880
9868
  /* STABLE */
9881
- }, 8, ["onClick"])) : createCommentVNode("v-if", true)
9869
+ })) : createCommentVNode("v-if", true)
9882
9870
  ],
9883
9871
  512
9884
9872
  /* NEED_PATCH */
@@ -10160,7 +10148,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
10160
10148
  const handleDragEnd = (event) => {
10161
10149
  treeEmit?.("node-dragend", event, props.data);
10162
10150
  };
10163
- const nodeContentmenuHandler = (event) => {
10151
+ const nodeContextmenuHandler = (event) => {
10164
10152
  treeEmit?.("node-contextmenu", event, props.data);
10165
10153
  };
10166
10154
  const mouseenterHandler = (event) => {
@@ -10192,7 +10180,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
10192
10180
  {
10193
10181
  class: normalizeClass(["tree-node", { selected: selected.value, expanded: expanded.value }]),
10194
10182
  style: normalizeStyle(`padding-left: ${_ctx.indent}px`),
10195
- onContextmenu: nodeContentmenuHandler,
10183
+ onContextmenu: nodeContextmenuHandler,
10196
10184
  onMouseenter: mouseenterHandler
10197
10185
  },
10198
10186
  [
@@ -10350,13 +10338,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10350
10338
  setup(__props, { expose: __expose, emit: __emit }) {
10351
10339
  const props = __props;
10352
10340
  const emit = __emit;
10353
- const services = inject("services");
10354
- const { codeBlockService, depService, editorService } = services || {};
10355
- const collecting = computed(() => depService?.get("collecting"));
10341
+ const { codeBlockService, depService, editorService } = useServices();
10356
10342
  const codeList = computed(
10357
- () => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
10358
- const target = depService?.getTarget(codeId, DepTargetType.CODE_BLOCK);
10359
- const pageList = editorService?.get("root")?.items.map((page) => ({
10343
+ () => Object.entries(codeBlockService.getCodeDsl() || {}).map(([codeId, code]) => {
10344
+ const target = depService.getTarget(codeId, DepTargetType.CODE_BLOCK);
10345
+ const pageList = editorService.get("root")?.items.map((page) => ({
10360
10346
  name: page.devconfig?.tabName || page.name,
10361
10347
  type: "node",
10362
10348
  id: `${codeId}_${page.id}`,
@@ -10383,7 +10369,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10383
10369
  key: codeId,
10384
10370
  name: code.name,
10385
10371
  type: "code",
10386
- codeBlockContent: codeBlockService?.getCodeContentById(codeId),
10372
+ codeBlockContent: codeBlockService.getCodeContentById(codeId),
10387
10373
  // 只有一个页面不显示页面分类
10388
10374
  items: pageList.length > 1 ? pageList.filter((page) => page.items?.length) : pageList[0]?.items || []
10389
10375
  };
@@ -10398,10 +10384,10 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10398
10384
  };
10399
10385
  const { nodeStatusMap } = useNodeStatus$1(codeList);
10400
10386
  const { filterTextChangeHandler } = useFilter(codeList, nodeStatusMap, filterNode);
10401
- const editable = computed(() => codeBlockService?.getEditStatus());
10387
+ const editable = computed(() => codeBlockService.getEditStatus());
10402
10388
  const selectComp = (compId) => {
10403
- const stage = editorService?.get("stage");
10404
- editorService?.select(compId);
10389
+ const stage = editorService.get("stage");
10390
+ editorService.select(compId);
10405
10391
  stage?.select(compId);
10406
10392
  };
10407
10393
  const clickHandler = (event, data) => {
@@ -10415,7 +10401,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10415
10401
  const deleteCode = async (id) => {
10416
10402
  const currentCode = codeList.value.find((codeItem) => codeItem.id === id);
10417
10403
  const existBinds = Boolean(currentCode?.items?.length);
10418
- const undeleteableList = codeBlockService?.getUndeletableList() || [];
10404
+ const undeleteableList = codeBlockService.getUndeletableList() || [];
10419
10405
  if (!existBinds && !undeleteableList.includes(id)) {
10420
10406
  await tMagicMessageBox.confirm("确定删除该代码块吗?", "提示", {
10421
10407
  confirmButtonText: "确定",
@@ -10467,20 +10453,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10467
10453
  )
10468
10454
  ]),
10469
10455
  "tree-node-tool": withCtx(({ data }) => [
10470
- collecting.value && data.type === "code" ? (openBlock(), createBlock(unref(TMagicTag), {
10471
- key: 0,
10472
- type: "info",
10473
- size: "small",
10474
- style: { "margin-right": "5px" }
10475
- }, {
10476
- default: withCtx(() => _cache[0] || (_cache[0] = [
10477
- createTextVNode("依赖收集中")
10478
- ])),
10479
- _: 1
10480
- /* STABLE */
10481
- })) : createCommentVNode("v-if", true),
10482
10456
  data.type === "code" ? (openBlock(), createBlock(unref(TMagicTooltip), {
10483
- key: 1,
10457
+ key: 0,
10484
10458
  effect: "dark",
10485
10459
  content: editable.value ? "编辑" : "查看",
10486
10460
  placement: "bottom"
@@ -10498,7 +10472,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10498
10472
  data.type === "code" && editable.value ? (openBlock(), createBlock(
10499
10473
  unref(TMagicTooltip),
10500
10474
  {
10501
- key: 2,
10475
+ key: 1,
10502
10476
  effect: "dark",
10503
10477
  content: "删除",
10504
10478
  placement: "bottom"
@@ -10538,7 +10512,7 @@ const useContentMenu$1 = (deleteCode) => {
10538
10512
  type: "button",
10539
10513
  text: "编辑",
10540
10514
  icon: Edit,
10541
- display: (services) => services?.codeBlockService?.getEditStatus() ?? true,
10515
+ display: ({ codeBlockService }) => codeBlockService.getEditStatus(),
10542
10516
  handler: () => {
10543
10517
  if (!selectId) {
10544
10518
  return;
@@ -10610,8 +10584,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
10610
10584
  setup(__props) {
10611
10585
  const props = __props;
10612
10586
  const eventBus = inject("eventBus");
10613
- const { codeBlockService } = inject("services") || {};
10614
- const editable = computed(() => codeBlockService?.getEditStatus());
10587
+ const { codeBlockService } = useServices();
10588
+ const editable = computed(() => codeBlockService.getEditStatus());
10615
10589
  const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
10616
10590
  const codeBlockListRef = useTemplateRef("codeBlockList");
10617
10591
  const filterTextChangeHandler = (val) => {
@@ -10706,20 +10680,20 @@ const useDataSourceEdit = (dataSourceService) => {
10706
10680
  const dialogTitle = ref("");
10707
10681
  const editDialog = ref();
10708
10682
  const dataSourceValues = ref({});
10709
- const editable = computed(() => dataSourceService?.get("editable") ?? true);
10683
+ const editable = computed(() => dataSourceService.get("editable"));
10710
10684
  const editHandler = (id) => {
10711
10685
  if (!editDialog.value) return;
10712
10686
  dataSourceValues.value = {
10713
- ...dataSourceService?.getDataSourceById(id)
10687
+ ...dataSourceService.getDataSourceById(id) || {}
10714
10688
  };
10715
10689
  dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
10716
10690
  editDialog.value.show();
10717
10691
  };
10718
10692
  const submitDataSourceHandler = (value, eventData) => {
10719
10693
  if (value.id) {
10720
- dataSourceService?.update(value, { changeRecords: eventData.changeRecords });
10694
+ dataSourceService.update(value, { changeRecords: eventData.changeRecords });
10721
10695
  } else {
10722
- dataSourceService?.add(value);
10696
+ dataSourceService.add(value);
10723
10697
  }
10724
10698
  editDialog.value?.hide();
10725
10699
  };
@@ -10754,15 +10728,15 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
10754
10728
  const boxVisible = useModel(__props, "visible");
10755
10729
  const width = useModel(__props, "width");
10756
10730
  const emit = __emit;
10757
- const services = inject("services");
10731
+ const { uiService, dataSourceService } = useServices();
10758
10732
  const initValues = ref({});
10759
10733
  const dataSourceConfig = ref([]);
10760
10734
  const { height: editorHeight } = useEditorContentHeight();
10761
10735
  const parentFloating = inject("parentFloating", ref(null));
10762
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
10736
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
10763
10737
  watchEffect(() => {
10764
10738
  initValues.value = props.values;
10765
- dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
10739
+ dataSourceConfig.value = dataSourceService.getFormConfig(initValues.value.type);
10766
10740
  });
10767
10741
  const submitHandler = (values, data) => {
10768
10742
  emit("submit", values, data);
@@ -10821,13 +10795,12 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10821
10795
  emits: ["edit", "remove", "node-contextmenu"],
10822
10796
  setup(__props, { expose: __expose, emit: __emit }) {
10823
10797
  const emit = __emit;
10824
- const { depService, editorService, dataSourceService } = inject("services") || {};
10825
- const collecting = computed(() => depService?.get("collecting"));
10826
- const editable = computed(() => dataSourceService?.get("editable") ?? true);
10827
- const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
10828
- const dsDep = computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE) || {});
10829
- const dsMethodDep = computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE_METHOD) || {});
10830
- const dsCondDep = computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE_COND) || {});
10798
+ const { depService, editorService, dataSourceService } = useServices();
10799
+ const editable = computed(() => dataSourceService.get("editable"));
10800
+ const dataSources = computed(() => dataSourceService.get("dataSources"));
10801
+ const dsDep = computed(() => depService.getTargets(DepTargetType.DATA_SOURCE));
10802
+ const dsMethodDep = computed(() => depService.getTargets(DepTargetType.DATA_SOURCE_METHOD));
10803
+ const dsCondDep = computed(() => depService.getTargets(DepTargetType.DATA_SOURCE_COND));
10831
10804
  const getKeyTreeConfig = (dep, type, parentKey) => dep.keys.map((key) => ({
10832
10805
  name: key,
10833
10806
  id: `${parentKey}_${key}`,
@@ -10858,7 +10831,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10858
10831
  const dsDeps = dsDep.value[ds.id]?.deps || {};
10859
10832
  const dsMethodDeps = dsMethodDep.value[ds.id]?.deps || {};
10860
10833
  const dsCondDeps = dsCondDep.value[ds.id]?.deps || {};
10861
- const items = editorService?.get("root")?.items.map((page) => ({
10834
+ const items = editorService.get("root")?.items.map((page) => ({
10862
10835
  name: page.devconfig?.tabName || page.name,
10863
10836
  type: "node",
10864
10837
  id: `${ds.id}_${page.id}`,
@@ -10893,8 +10866,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10893
10866
  emit("remove", id);
10894
10867
  };
10895
10868
  const selectComp = (compId) => {
10896
- const stage = editorService?.get("stage");
10897
- editorService?.select(compId);
10869
+ const stage = editorService.get("stage");
10870
+ editorService.select(compId);
10898
10871
  stage?.select(compId);
10899
10872
  };
10900
10873
  const clickHandler = (event, data) => {
@@ -10933,20 +10906,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10933
10906
  )
10934
10907
  ]),
10935
10908
  "tree-node-tool": withCtx(({ data }) => [
10936
- collecting.value && data.type === "ds" ? (openBlock(), createBlock(unref(TMagicTag), {
10937
- key: 0,
10938
- type: "info",
10939
- size: "small",
10940
- style: { "margin-right": "5px" }
10941
- }, {
10942
- default: withCtx(() => _cache[0] || (_cache[0] = [
10943
- createTextVNode("依赖收集中")
10944
- ])),
10945
- _: 1
10946
- /* STABLE */
10947
- })) : createCommentVNode("v-if", true),
10948
10909
  data.type === "ds" ? (openBlock(), createBlock(unref(TMagicTooltip), {
10949
- key: 1,
10910
+ key: 0,
10950
10911
  effect: "dark",
10951
10912
  content: editable.value ? "编辑" : "查看",
10952
10913
  placement: "bottom"
@@ -10964,7 +10925,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10964
10925
  data.type === "ds" && editable.value ? (openBlock(), createBlock(
10965
10926
  unref(TMagicTooltip),
10966
10927
  {
10967
- key: 2,
10928
+ key: 1,
10968
10929
  effect: "dark",
10969
10930
  content: "删除",
10970
10931
  placement: "bottom"
@@ -11001,7 +10962,7 @@ const useContentMenu = () => {
11001
10962
  type: "button",
11002
10963
  text: "编辑",
11003
10964
  icon: Edit,
11004
- display: (services) => services?.dataSourceService?.get("editable") ?? true,
10965
+ display: ({ dataSourceService }) => dataSourceService.get("editable"),
11005
10966
  handler: () => {
11006
10967
  if (!selectId) {
11007
10968
  return;
@@ -11071,20 +11032,20 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11071
11032
  setup(__props) {
11072
11033
  const props = __props;
11073
11034
  const eventBus = inject("eventBus");
11074
- const { dataSourceService } = inject("services") || {};
11035
+ const { dataSourceService } = useServices();
11075
11036
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
11076
11037
  const datasourceTypeList = computed(
11077
11038
  () => [
11078
11039
  { text: "基础", type: "base" },
11079
11040
  { text: "HTTP", type: "http" }
11080
- ].concat(dataSourceService?.get("datasourceTypeList") ?? [])
11041
+ ].concat(dataSourceService.get("datasourceTypeList"))
11081
11042
  );
11082
11043
  const addHandler = (type) => {
11083
11044
  if (!editDialog.value) return;
11084
11045
  const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
11085
11046
  dataSourceValues.value = mergeWith(
11086
11047
  { type, title: datasourceType?.text },
11087
- dataSourceService?.getFormValue(type) || {},
11048
+ dataSourceService.getFormValue(type),
11088
11049
  (objValue, srcValue) => {
11089
11050
  if (Array.isArray(srcValue)) {
11090
11051
  return srcValue;
@@ -11100,7 +11061,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11100
11061
  cancelButtonText: "取消",
11101
11062
  type: "warning"
11102
11063
  });
11103
- dataSourceService?.remove(id);
11064
+ dataSourceService.remove(id);
11104
11065
  };
11105
11066
  const dataSourceList = ref();
11106
11067
  const filterTextChangeHandler = (val) => {
@@ -11253,67 +11214,66 @@ const useDeleteMenu = () => ({
11253
11214
  type: "button",
11254
11215
  text: "删除",
11255
11216
  icon: Delete,
11256
- display: (services) => {
11257
- const node = services?.editorService?.get("node");
11217
+ display: ({ editorService }) => {
11218
+ const node = editorService.get("node");
11258
11219
  return node?.type !== NodeType.ROOT && !isPage(node) && !isPageFragment(node);
11259
11220
  },
11260
- handler: (services) => {
11261
- const nodes = services?.editorService?.get("nodes");
11262
- nodes && services?.editorService?.remove(nodes);
11221
+ handler: ({ editorService }) => {
11222
+ const nodes = editorService.get("nodes");
11223
+ nodes && editorService.remove(nodes);
11263
11224
  }
11264
11225
  });
11265
11226
  const useCopyMenu = () => ({
11266
11227
  type: "button",
11267
11228
  text: "复制",
11268
11229
  icon: markRaw(CopyDocument),
11269
- handler: (services) => {
11270
- const nodes = services?.editorService?.get("nodes");
11271
- nodes && services?.editorService?.copy(nodes);
11230
+ handler: ({ editorService }) => {
11231
+ const nodes = editorService?.get("nodes");
11232
+ nodes && editorService?.copy(nodes);
11272
11233
  }
11273
11234
  });
11274
11235
  const usePasteMenu = (menu) => ({
11275
11236
  type: "button",
11276
11237
  text: "粘贴",
11277
11238
  icon: markRaw(DocumentCopy),
11278
- display: (services) => !!services?.storageService?.getItem(COPY_STORAGE_KEY),
11279
- handler: (services) => {
11280
- const nodes = services?.editorService?.get("nodes");
11239
+ display: ({ storageService }) => !!storageService.getItem(COPY_STORAGE_KEY),
11240
+ handler: ({ editorService, uiService }) => {
11241
+ const nodes = editorService?.get("nodes");
11281
11242
  if (!nodes || nodes.length === 0) return;
11282
11243
  if (menu?.value?.$el) {
11283
- const stage = services?.editorService?.get("stage");
11244
+ const stage = editorService.get("stage");
11284
11245
  const rect = menu.value.$el.getBoundingClientRect();
11285
11246
  const parentRect = stage?.container?.getBoundingClientRect();
11286
- const initialLeft = calcValueByFontsize(stage?.renderer?.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / services.uiService.get("zoom");
11287
- const initialTop = calcValueByFontsize(stage?.renderer?.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / services.uiService.get("zoom");
11288
- services?.editorService?.paste({ left: initialLeft, top: initialTop });
11247
+ const initialLeft = calcValueByFontsize(stage?.renderer?.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / uiService.get("zoom");
11248
+ const initialTop = calcValueByFontsize(stage?.renderer?.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / uiService.get("zoom");
11249
+ editorService.paste({ left: initialLeft, top: initialTop });
11289
11250
  } else {
11290
- services?.editorService?.paste();
11251
+ editorService.paste();
11291
11252
  }
11292
11253
  }
11293
11254
  });
11294
- const moveTo = (id, services) => {
11295
- if (!services?.editorService) return;
11296
- const nodes = services.editorService.get("nodes") || [];
11297
- const parent = services.editorService.getNodeById(id);
11255
+ const moveTo = (id, { editorService }) => {
11256
+ const nodes = editorService.get("nodes") || [];
11257
+ const parent = editorService.getNodeById(id);
11298
11258
  if (!parent) return;
11299
- services?.editorService.add(nodes, parent);
11300
- services?.editorService.remove(nodes);
11259
+ editorService.add(nodes, parent);
11260
+ editorService.remove(nodes);
11301
11261
  };
11302
- const useMoveToMenu = (services) => {
11303
- const root = computed(() => services?.editorService?.get("root"));
11262
+ const useMoveToMenu = ({ editorService }) => {
11263
+ const root = computed(() => editorService.get("root"));
11304
11264
  return {
11305
11265
  type: "button",
11306
11266
  text: "移动至",
11307
- display: (services2) => {
11308
- const node = services2?.editorService?.get("node");
11309
- const pageLength = services2?.editorService?.get("pageLength") || 0;
11267
+ display: ({ editorService: editorService2 }) => {
11268
+ const node = editorService2.get("node");
11269
+ const pageLength = editorService2.get("pageLength");
11310
11270
  return !isPage(node) && pageLength > 1;
11311
11271
  },
11312
- items: (root.value?.items || []).filter((page) => page.id !== services?.editorService?.get("page")?.id).map((page) => ({
11272
+ items: (root.value?.items || []).filter((page) => page.id !== editorService.get("page")?.id).map((page) => ({
11313
11273
  text: `${page.name}(${page.id})`,
11314
11274
  type: "button",
11315
- handler: (services2) => {
11316
- moveTo(page.id, services2);
11275
+ handler: (services) => {
11276
+ moveTo(page.id, services);
11317
11277
  }
11318
11278
  }))
11319
11279
  };
@@ -11332,17 +11292,18 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
11332
11292
  setup(__props, { expose: __expose, emit: __emit }) {
11333
11293
  const props = __props;
11334
11294
  const emit = __emit;
11335
- const services = inject("services");
11295
+ const services = useServices();
11296
+ const { editorService, componentListService } = services;
11336
11297
  const menuRef = useTemplateRef("menu");
11337
- const node = computed(() => services?.editorService.get("node"));
11338
- const nodes = computed(() => services?.editorService.get("nodes"));
11339
- const componentList = computed(() => services?.componentListService.getList() || []);
11298
+ const node = computed(() => editorService.get("node"));
11299
+ const nodes = computed(() => editorService.get("nodes"));
11300
+ const componentList = computed(() => componentListService.getList());
11340
11301
  const createMenuItems = (group) => group.items.map((component) => ({
11341
11302
  text: component.text,
11342
11303
  type: "button",
11343
11304
  icon: component.icon,
11344
11305
  handler: () => {
11345
- services?.editorService.add({
11306
+ editorService.add({
11346
11307
  name: component.text,
11347
11308
  type: component.type,
11348
11309
  ...component.data || {}
@@ -11357,7 +11318,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
11357
11318
  type: "button",
11358
11319
  icon: Files,
11359
11320
  handler: () => {
11360
- services?.editorService.add({
11321
+ editorService.add({
11361
11322
  type: "tab-pane"
11362
11323
  });
11363
11324
  }
@@ -11431,10 +11392,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
11431
11392
  },
11432
11393
  setup(__props) {
11433
11394
  const props = __props;
11434
- const services = inject("services");
11435
- const editorService = services?.editorService;
11395
+ const { editorService } = useServices();
11436
11396
  const setNodeVisible = (visible) => {
11437
- if (!editorService) return;
11438
11397
  editorService.update({
11439
11398
  id: props.data.id,
11440
11399
  visible
@@ -11465,8 +11424,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
11465
11424
  }
11466
11425
  });
11467
11426
 
11468
- const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11469
- const isMultiSelect = computed(() => isCtrlKeyDown.value && !services?.editorService.get("disabledMultiSelect"));
11427
+ const useClick = ({ editorService, stageOverlayService, uiService }, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11428
+ const isMultiSelect = computed(() => isCtrlKeyDown.value && !editorService.get("disabledMultiSelect"));
11470
11429
  const select = async (data) => {
11471
11430
  if (!data.id) {
11472
11431
  throw new Error("没有id");
@@ -11474,16 +11433,16 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11474
11433
  if (isMultiSelect.value) {
11475
11434
  multiSelect(data);
11476
11435
  } else {
11477
- await services?.editorService.select(data);
11478
- services?.editorService.get("stage")?.select(data.id);
11479
- services?.stageOverlayService.get("stage")?.select(data.id);
11436
+ await editorService.select(data);
11437
+ editorService.get("stage")?.select(data.id);
11438
+ stageOverlayService.get("stage")?.select(data.id);
11480
11439
  }
11481
11440
  };
11482
11441
  const multiSelect = async (data) => {
11483
11442
  if (isPage(data) || isPageFragment(data)) {
11484
11443
  return;
11485
11444
  }
11486
- const nodes = services?.editorService.get("nodes") || [];
11445
+ const nodes = editorService.get("nodes") || [];
11487
11446
  const newNodes = [];
11488
11447
  let isCancel = false;
11489
11448
  nodes.forEach((node) => {
@@ -11499,9 +11458,9 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11499
11458
  if (!isCancel || newNodes.length === 0) {
11500
11459
  newNodes.push(data.id);
11501
11460
  }
11502
- await services?.editorService.multiSelect(newNodes);
11503
- services?.editorService.get("stage")?.multiSelect(newNodes);
11504
- services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
11461
+ await editorService.multiSelect(newNodes);
11462
+ editorService.get("stage")?.multiSelect(newNodes);
11463
+ stageOverlayService.get("stage")?.multiSelect(newNodes);
11505
11464
  };
11506
11465
  const throttleTime = 300;
11507
11466
  const highlightHandler = throttle(
@@ -11511,13 +11470,13 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11511
11470
  throttleTime
11512
11471
  );
11513
11472
  const highlight = (data) => {
11514
- services?.editorService?.highlight(data);
11515
- services?.editorService?.get("stage")?.highlight(data.id);
11516
- services?.stageOverlayService?.get("stage")?.highlight(data.id);
11473
+ editorService.highlight(data);
11474
+ editorService.get("stage")?.highlight(data.id);
11475
+ stageOverlayService.get("stage")?.highlight(data.id);
11517
11476
  };
11518
11477
  const nodeClickHandler = (event, data) => {
11519
11478
  if (!nodeStatusMap?.value) return;
11520
- if (services?.uiService.get("uiSelectMode")) {
11479
+ if (uiService.get("uiSelectMode")) {
11521
11480
  document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
11522
11481
  return;
11523
11482
  }
@@ -11535,7 +11494,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
11535
11494
  nodeClickHandler,
11536
11495
  nodeContentMenuHandler(event, data) {
11537
11496
  event.preventDefault();
11538
- const nodes = services?.editorService.get("nodes") || [];
11497
+ const nodes = editorService.get("nodes") || [];
11539
11498
  if (nodes.length < 2 || !nodes.includes(data)) {
11540
11499
  nodeClickHandler(event, data);
11541
11500
  }
@@ -11566,7 +11525,7 @@ const removeStatusClass = (el) => {
11566
11525
  });
11567
11526
  });
11568
11527
  };
11569
- const useDrag = (services) => {
11528
+ const useDrag = ({ editorService }) => {
11570
11529
  const handleDragStart = (event) => {
11571
11530
  if (!event.dataTransfer || !event.target || !event.currentTarget) return;
11572
11531
  const targetEl = getNodeEl(event.target);
@@ -11640,11 +11599,11 @@ const useDrag = (services) => {
11640
11599
  const targetEl = getNodeEl(event.target);
11641
11600
  if (!targetEl || targetEl !== event.currentTarget) return;
11642
11601
  removeStatusClass(dragState.container);
11643
- if (node && dragState.dragOverNodeId && dragState.dropType && services) {
11602
+ if (node && dragState.dragOverNodeId && dragState.dropType) {
11644
11603
  if (dragState.dragOverNodeId === node.id) {
11645
11604
  return;
11646
11605
  }
11647
- const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
11606
+ const targetInfo = editorService.getNodeInfo(dragState.dragOverNodeId, false);
11648
11607
  const targetNode = targetInfo.node;
11649
11608
  let targetParent = targetInfo.parent;
11650
11609
  if (!targetParent || !targetNode) return;
@@ -11658,11 +11617,11 @@ const useDrag = (services) => {
11658
11617
  if (dragState.dropType === "after") {
11659
11618
  targetIndex += 1;
11660
11619
  }
11661
- const selectedNodes = services.editorService.get("nodes");
11620
+ const selectedNodes = editorService.get("nodes");
11662
11621
  if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) {
11663
- services.editorService.dragTo(selectedNodes, targetParent, targetIndex);
11622
+ editorService.dragTo(selectedNodes, targetParent, targetIndex);
11664
11623
  } else {
11665
- services.editorService.dragTo([node], targetParent, targetIndex);
11624
+ editorService.dragTo([node], targetParent, targetIndex);
11666
11625
  }
11667
11626
  }
11668
11627
  dragState.dragOverNodeId = "";
@@ -11801,19 +11760,18 @@ const keybindingConfig = [
11801
11760
  }
11802
11761
  ];
11803
11762
 
11804
- const useKeybinding = (services, container) => {
11805
- const keybindingService = services?.keybindingService;
11763
+ const useKeybinding = ({ keybindingService }, container) => {
11806
11764
  const isCtrlKeyDown = ref(false);
11807
11765
  const windowBlurHandler = () => {
11808
11766
  isCtrlKeyDown.value = false;
11809
11767
  };
11810
- keybindingService?.registerCommand("layer-panel-global-keyup", () => {
11768
+ keybindingService.registerCommand("layer-panel-global-keyup", () => {
11811
11769
  isCtrlKeyDown.value = false;
11812
11770
  });
11813
- keybindingService?.registerCommand("layer-panel-global-keydown", () => {
11771
+ keybindingService.registerCommand("layer-panel-global-keydown", () => {
11814
11772
  isCtrlKeyDown.value = true;
11815
11773
  });
11816
- keybindingService?.register([
11774
+ keybindingService.register([
11817
11775
  {
11818
11776
  command: "layer-panel-global-keydown",
11819
11777
  keybinding: "ctrl",
@@ -11828,10 +11786,10 @@ const useKeybinding = (services, container) => {
11828
11786
  watchEffect(() => {
11829
11787
  if (container.value) {
11830
11788
  globalThis.addEventListener("blur", windowBlurHandler);
11831
- keybindingService?.registerEl(KeyBindingContainerKey.LAYER_PANEL, container.value.$el);
11789
+ keybindingService.registerEl(KeyBindingContainerKey.LAYER_PANEL, container.value.$el);
11832
11790
  } else {
11833
11791
  globalThis.removeEventListener("blur", windowBlurHandler);
11834
- keybindingService?.unregisterEl(KeyBindingContainerKey.LAYER_PANEL);
11792
+ keybindingService.unregisterEl(KeyBindingContainerKey.LAYER_PANEL);
11835
11793
  }
11836
11794
  });
11837
11795
  return {
@@ -11862,9 +11820,9 @@ const createPageNodeStatus = (page, initialLayerNodeStatus) => {
11862
11820
  );
11863
11821
  return map;
11864
11822
  };
11865
- const useNodeStatus = (services) => {
11866
- const page = computed(() => services?.editorService.get("page"));
11867
- const nodes = computed(() => services?.editorService.get("nodes") || []);
11823
+ const useNodeStatus = ({ editorService }) => {
11824
+ const page = computed(() => editorService.get("page"));
11825
+ const nodes = computed(() => editorService.get("nodes"));
11868
11826
  const nodeStatusMaps = ref(/* @__PURE__ */ new Map());
11869
11827
  const nodeStatusMap = computed(
11870
11828
  () => page.value ? nodeStatusMaps.value.get(page.value.id) : /* @__PURE__ */ new Map()
@@ -11900,7 +11858,7 @@ const useNodeStatus = (services) => {
11900
11858
  immediate: true
11901
11859
  }
11902
11860
  );
11903
- services?.editorService.on("add", (newNodes) => {
11861
+ const addHandler = (newNodes) => {
11904
11862
  newNodes.forEach((node) => {
11905
11863
  if (isPage(node) || isPageFragment(node)) return;
11906
11864
  traverseNode(node, (node2) => {
@@ -11912,13 +11870,19 @@ const useNodeStatus = (services) => {
11912
11870
  });
11913
11871
  });
11914
11872
  });
11915
- });
11916
- services?.editorService.on("remove", (nodes2) => {
11873
+ };
11874
+ editorService.on("add", addHandler);
11875
+ const removeHandler = (nodes2) => {
11917
11876
  nodes2.forEach((node) => {
11918
11877
  traverseNode(node, (node2) => {
11919
11878
  nodeStatusMap.value?.delete(node2.id);
11920
11879
  });
11921
11880
  });
11881
+ };
11882
+ editorService.on("remove", removeHandler);
11883
+ onBeforeUnmount(() => {
11884
+ editorService.off("remove", removeHandler);
11885
+ editorService.off("add", addHandler);
11922
11886
  });
11923
11887
  return {
11924
11888
  nodeStatusMaps,
@@ -11938,10 +11902,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
11938
11902
  customContentMenu: { type: Function }
11939
11903
  },
11940
11904
  setup(__props) {
11941
- const services = inject("services");
11942
- const editorService = services?.editorService;
11905
+ const services = useServices();
11906
+ const { editorService } = services;
11943
11907
  const treeRef = useTemplateRef("tree");
11944
- const page = computed(() => editorService?.get("page"));
11908
+ const page = computed(() => editorService.get("page"));
11945
11909
  const nodeData = computed(() => !page.value ? [] : [page.value]);
11946
11910
  const { nodeStatusMap } = useNodeStatus(services);
11947
11911
  const { isCtrlKeyDown } = useKeybinding(services, treeRef);
@@ -12035,11 +11999,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
12035
11999
  const filterTextChangeHandler = (v) => {
12036
12000
  searchText.value = v;
12037
12001
  };
12038
- const services = inject("services");
12002
+ const { editorService, componentListService } = useServices();
12039
12003
  const stageOptions = inject("stageOptions");
12040
- const stage = computed(() => services?.editorService.get("stage"));
12004
+ const stage = computed(() => editorService.get("stage"));
12041
12005
  const list = computed(
12042
- () => (services?.componentListService.getList() || []).map((group) => ({
12006
+ () => componentListService.getList().map((group) => ({
12043
12007
  ...group,
12044
12008
  items: group.items.filter((item) => item.text.includes(searchText.value))
12045
12009
  }))
@@ -12051,7 +12015,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
12051
12015
  let clientX;
12052
12016
  let clientY;
12053
12017
  const appendComponent = ({ text, type, data = {} }) => {
12054
- services?.editorService.add({
12018
+ editorService.add({
12055
12019
  name: text,
12056
12020
  type,
12057
12021
  ...data
@@ -12198,7 +12162,11 @@ const _hoisted_4 = {
12198
12162
  key: 1,
12199
12163
  class: "magic-editor-tab-panel-title"
12200
12164
  };
12201
- const _hoisted_5 = { class: "m-editor-slide-list-box" };
12165
+ const _hoisted_5 = {
12166
+ key: 0,
12167
+ class: "m-editor-sidebar-tips"
12168
+ };
12169
+ const _hoisted_6 = { class: "m-editor-slide-list-box" };
12202
12170
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
12203
12171
  ...{
12204
12172
  name: "MEditorSidebar"
@@ -12217,9 +12185,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12217
12185
  },
12218
12186
  setup(__props, { expose: __expose }) {
12219
12187
  const props = __props;
12220
- const services = inject("services");
12221
- const collecting = computed(() => services?.depService.get("collecting"));
12222
- const columnLeftWidth = computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
12188
+ const { depService, uiService } = useServices();
12189
+ const collecting = computed(() => depService.get("collecting"));
12190
+ const taskLength = computed(() => depService.get("taskLength"));
12191
+ const tipsBarVisible = ref(true);
12192
+ const columnLeftWidth = computed(() => uiService.get("columnWidth")[ColumnLayout.LEFT]);
12223
12193
  const { height: editorContentHeight } = useEditorContentHeight();
12224
12194
  const columnLeftHeight = ref(0);
12225
12195
  const unWatchEditorContentHeight = watch(
@@ -12294,7 +12264,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12294
12264
  watch(
12295
12265
  sideBarItems,
12296
12266
  (items) => {
12297
- services?.uiService.set("sideBarItems", items);
12267
+ uiService.set("sideBarItems", items);
12298
12268
  },
12299
12269
  {
12300
12270
  immediate: true
@@ -12318,10 +12288,10 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12318
12288
  const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
12319
12289
  if (!nextSlideBarItem) {
12320
12290
  activeTabName.value = "";
12321
- services?.uiService.set("hideSlideBar", true);
12291
+ uiService.set("hideSlideBar", true);
12322
12292
  return;
12323
12293
  }
12324
- services?.uiService.set("hideSlideBar", false);
12294
+ uiService.set("hideSlideBar", false);
12325
12295
  activeTabName.value = nextSlideBarItem?.text;
12326
12296
  }
12327
12297
  );
@@ -12528,7 +12498,21 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12528
12498
  }),
12529
12499
  128
12530
12500
  /* KEYED_FRAGMENT */
12531
- ))
12501
+ )),
12502
+ tipsBarVisible.value && collecting.value && taskLength.value > 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
12503
+ createElementVNode(
12504
+ "span",
12505
+ null,
12506
+ "依赖收集中(剩余任务:" + toDisplayString(taskLength.value) + ")",
12507
+ 1
12508
+ /* TEXT */
12509
+ ),
12510
+ createVNode(_sfc_main$1r, {
12511
+ icon: unref(Close),
12512
+ class: "close-icon",
12513
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => tipsBarVisible.value = false, ["stop"]))
12514
+ }, null, 8, ["icon"])
12515
+ ])) : createCommentVNode("v-if", true)
12532
12516
  ])) : createCommentVNode("v-if", true),
12533
12517
  (openBlock(), createBlock(Teleport, { to: "body" }, [
12534
12518
  (openBlock(true), createElementBlock(
@@ -12544,7 +12528,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12544
12528
  visible: unref(floatBoxStates)[config.$key].status,
12545
12529
  "onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
12546
12530
  height: columnLeftHeight.value,
12547
- "onUpdate:height": _cache[1] || (_cache[1] = ($event) => columnLeftHeight.value = $event),
12531
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => columnLeftHeight.value = $event),
12548
12532
  width: columnLeftWidth.value,
12549
12533
  title: config.text,
12550
12534
  position: {
@@ -12553,7 +12537,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12553
12537
  }
12554
12538
  }, {
12555
12539
  body: withCtx(() => [
12556
- createElementVNode("div", _hoisted_5, [
12540
+ createElementVNode("div", _hoisted_6, [
12557
12541
  config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(
12558
12542
  resolveDynamicComponent(config.component),
12559
12543
  mergeProps({
@@ -12801,15 +12785,15 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
12801
12785
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
12802
12786
  __name: "NodeListMenu",
12803
12787
  setup(__props) {
12804
- const services = inject("services");
12805
- const editorService = services?.editorService;
12788
+ const services = useServices();
12789
+ const { editorService } = services;
12806
12790
  const visible = ref(false);
12807
12791
  const buttonVisible = ref(false);
12808
12792
  const buttonEl = useTemplateRef("button");
12809
12793
  const boxRef = useTemplateRef("box");
12810
- const stage = computed(() => editorService?.get("stage"));
12811
- const page = computed(() => editorService?.get("page"));
12812
- const nodes = computed(() => editorService?.get("nodes") || []);
12794
+ const stage = computed(() => editorService.get("stage"));
12795
+ const page = computed(() => editorService.get("page"));
12796
+ const nodes = computed(() => editorService.get("nodes"));
12813
12797
  const nodeData = computed(() => !page.value ? [] : [page.value]);
12814
12798
  const { nodeStatusMap } = useNodeStatus(services);
12815
12799
  const filterNodeMethod = (value, data) => data.id === value;
@@ -12843,7 +12827,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
12843
12827
  }
12844
12828
  );
12845
12829
  const clickHandler = async (event, data) => {
12846
- await editorService?.select(data.id);
12830
+ await editorService.select(data.id);
12847
12831
  stage.value?.select(data.id);
12848
12832
  };
12849
12833
  const menuPosition = ref({
@@ -12917,13 +12901,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
12917
12901
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
12918
12902
  __name: "StageOverlay",
12919
12903
  setup(__props) {
12920
- const services = inject("services");
12904
+ const { stageOverlayService, editorService } = useServices();
12921
12905
  const stageOptions = inject("stageOptions");
12922
12906
  const stageOverlayEl = useTemplateRef("stageOverlay");
12923
- const stageOverlayVisible = computed(() => services?.stageOverlayService.get("stageOverlayVisible"));
12924
- const wrapWidth = computed(() => services?.stageOverlayService.get("wrapWidth") || 0);
12925
- const wrapHeight = computed(() => services?.stageOverlayService.get("wrapHeight") || 0);
12926
- const stage = computed(() => services?.editorService.get("stage"));
12907
+ const stageOverlayVisible = computed(() => stageOverlayService.get("stageOverlayVisible"));
12908
+ const wrapWidth = computed(() => stageOverlayService.get("wrapWidth"));
12909
+ const wrapHeight = computed(() => stageOverlayService.get("wrapHeight"));
12910
+ const stage = computed(() => editorService.get("stage"));
12927
12911
  const style = computed(() => ({
12928
12912
  width: `${wrapWidth.value}px`,
12929
12913
  height: `${wrapHeight.value}px`
@@ -12932,31 +12916,30 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
12932
12916
  if (stage2) {
12933
12917
  stage2.on("dblclick", async (event) => {
12934
12918
  const el = await stage2.actionManager?.getElementFromPoint(event) || null;
12935
- services?.stageOverlayService.openOverlay(el);
12919
+ stageOverlayService.openOverlay(el);
12936
12920
  });
12937
12921
  } else {
12938
- services?.stageOverlayService.closeOverlay();
12922
+ stageOverlayService.closeOverlay();
12939
12923
  }
12940
12924
  });
12941
12925
  watch(stageOverlayEl, (stageOverlay) => {
12942
- if (!services) return;
12943
- const subStage = services.stageOverlayService.createStage(stageOptions);
12944
- services?.stageOverlayService.set("stage", subStage);
12926
+ const subStage = stageOverlayService.createStage(stageOptions);
12927
+ stageOverlayService.set("stage", subStage);
12945
12928
  if (stageOverlay && subStage) {
12946
12929
  subStage.mount(stageOverlay);
12947
12930
  const { mask, renderer } = subStage;
12948
12931
  const { contentWindow } = renderer;
12949
12932
  mask?.showRule(false);
12950
- services?.stageOverlayService.updateOverlay();
12933
+ stageOverlayService.updateOverlay();
12951
12934
  contentWindow?.magic.onRuntimeReady({});
12952
12935
  }
12953
12936
  });
12954
12937
  onBeforeUnmount(() => {
12955
- services?.stageOverlayService.get("stage")?.destroy();
12956
- services?.stageOverlayService.set("stage", null);
12938
+ stageOverlayService.get("stage")?.destroy();
12939
+ stageOverlayService.set("stage", null);
12957
12940
  });
12958
12941
  const closeOverlayHandler = () => {
12959
- services?.stageOverlayService.closeOverlay();
12942
+ stageOverlayService.closeOverlay();
12960
12943
  };
12961
12944
  return (_ctx, _cache) => {
12962
12945
  return stageOverlayVisible.value ? (openBlock(), createElementBlock("div", {
@@ -13062,13 +13045,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13062
13045
  },
13063
13046
  setup(__props, { expose: __expose }) {
13064
13047
  const props = __props;
13065
- const services = inject("services");
13066
- const editorService = services?.editorService;
13048
+ const services = useServices();
13049
+ const { editorService } = services;
13067
13050
  const menuRef = useTemplateRef("menu");
13068
13051
  const canCenter = ref(false);
13069
- const node = computed(() => editorService?.get("node"));
13070
- const nodes = computed(() => editorService?.get("nodes"));
13071
- const parent = computed(() => editorService?.get("parent"));
13052
+ const node = computed(() => editorService.get("node"));
13053
+ const nodes = computed(() => editorService.get("nodes"));
13054
+ const parent = computed(() => editorService.get("parent"));
13072
13055
  const menuData = computed(
13073
13056
  () => props.customContentMenu(
13074
13057
  [
@@ -13079,7 +13062,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13079
13062
  display: () => canCenter.value,
13080
13063
  handler: () => {
13081
13064
  if (!nodes.value) return;
13082
- editorService?.alignCenter(nodes.value);
13065
+ editorService.alignCenter(nodes.value);
13083
13066
  }
13084
13067
  },
13085
13068
  useCopyMenu(),
@@ -13098,7 +13081,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13098
13081
  icon: markRaw(Top),
13099
13082
  display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
13100
13083
  handler: () => {
13101
- editorService?.moveLayer(1);
13084
+ editorService.moveLayer(1);
13102
13085
  }
13103
13086
  },
13104
13087
  {
@@ -13107,7 +13090,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13107
13090
  icon: markRaw(Bottom),
13108
13091
  display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
13109
13092
  handler: () => {
13110
- editorService?.moveLayer(-1);
13093
+ editorService.moveLayer(-1);
13111
13094
  }
13112
13095
  },
13113
13096
  {
@@ -13116,7 +13099,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13116
13099
  icon: markRaw(Top),
13117
13100
  display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
13118
13101
  handler: () => {
13119
- editorService?.moveLayer(LayerOffset.TOP);
13102
+ editorService.moveLayer(LayerOffset.TOP);
13120
13103
  }
13121
13104
  },
13122
13105
  {
@@ -13125,7 +13108,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13125
13108
  icon: markRaw(Bottom),
13126
13109
  display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
13127
13110
  handler: () => {
13128
- editorService?.moveLayer(LayerOffset.BOTTOM);
13111
+ editorService.moveLayer(LayerOffset.BOTTOM);
13129
13112
  }
13130
13113
  },
13131
13114
  useMoveToMenu(services),
@@ -13143,7 +13126,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13143
13126
  type: "button",
13144
13127
  text: "清空参考线",
13145
13128
  handler: () => {
13146
- editorService?.get("stage")?.clearGuides();
13129
+ editorService.get("stage")?.clearGuides();
13147
13130
  }
13148
13131
  },
13149
13132
  ...props.stageContentMenu
@@ -13154,7 +13137,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
13154
13137
  watch(
13155
13138
  parent,
13156
13139
  async () => {
13157
- if (!parent.value || !editorService) return canCenter.value = false;
13140
+ if (!parent.value) return canCenter.value = false;
13158
13141
  const layout = await editorService.getLayout(parent.value);
13159
13142
  const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
13160
13143
  const isTypeConform = nodes.value?.every(
@@ -13192,19 +13175,19 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13192
13175
  const props = __props;
13193
13176
  let stage = null;
13194
13177
  let runtime = null;
13195
- const services = inject("services");
13196
- const stageLoading = computed(() => services?.editorService.get("stageLoading") || false);
13178
+ const { editorService, uiService, keybindingService } = useServices();
13179
+ const stageLoading = computed(() => editorService.get("stageLoading"));
13197
13180
  const stageWrapRef = useTemplateRef("stageWrap");
13198
13181
  const stageContainerEl = useTemplateRef("stageContainer");
13199
13182
  const menuRef = useTemplateRef("menu");
13200
- const nodes = computed(() => services?.editorService.get("nodes") || []);
13183
+ const nodes = computed(() => editorService.get("nodes"));
13201
13184
  const isMultiSelect = computed(() => nodes.value.length > 1);
13202
- const stageRect = computed(() => services?.uiService.get("stageRect"));
13203
- const stageContainerRect = computed(() => services?.uiService.get("stageContainerRect"));
13204
- const root = computed(() => services?.editorService.get("root"));
13205
- const page = computed(() => services?.editorService.get("page"));
13206
- const zoom = computed(() => services?.uiService.get("zoom") || 1);
13207
- const node = computed(() => services?.editorService.get("node"));
13185
+ const stageRect = computed(() => uiService.get("stageRect"));
13186
+ const stageContainerRect = computed(() => uiService.get("stageContainerRect"));
13187
+ const root = computed(() => editorService.get("root"));
13188
+ const page = computed(() => editorService.get("page"));
13189
+ const zoom = computed(() => uiService.get("zoom"));
13190
+ const node = computed(() => editorService.get("node"));
13208
13191
  watchEffect(() => {
13209
13192
  if (stage || !page.value) return;
13210
13193
  if (!stageContainerEl.value) return;
@@ -13213,7 +13196,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13213
13196
  stage.on("select", () => {
13214
13197
  stageWrapRef.value?.container?.focus();
13215
13198
  });
13216
- services?.editorService.set("stage", markRaw(stage));
13199
+ editorService.set("stage", markRaw(stage));
13217
13200
  stage.mount(stageContainerEl.value);
13218
13201
  if (!node.value?.id) {
13219
13202
  return;
@@ -13229,7 +13212,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13229
13212
  });
13230
13213
  onBeforeUnmount(() => {
13231
13214
  stage?.destroy();
13232
- services?.editorService.set("stage", null);
13215
+ editorService.set("stage", null);
13233
13216
  });
13234
13217
  watch(zoom, (zoom2) => {
13235
13218
  if (!stage || !zoom2) return;
@@ -13238,12 +13221,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13238
13221
  let timeoutId = null;
13239
13222
  watch(page, (page2) => {
13240
13223
  if (runtime && page2) {
13241
- services?.editorService.set("stageLoading", true);
13224
+ editorService.set("stageLoading", true);
13242
13225
  if (timeoutId) {
13243
13226
  globalThis.clearTimeout(timeoutId);
13244
13227
  }
13245
13228
  timeoutId = globalThis.setTimeout(() => {
13246
- services?.editorService.set("stageLoading", false);
13229
+ editorService.set("stageLoading", false);
13247
13230
  timeoutId = null;
13248
13231
  }, 3e3);
13249
13232
  runtime.updatePageId?.(page2.id);
@@ -13257,10 +13240,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13257
13240
  runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
13258
13241
  }
13259
13242
  };
13260
- services?.editorService.on("root-change", rootChangeHandler);
13243
+ editorService.on("root-change", rootChangeHandler);
13261
13244
  const resizeObserver = new ResizeObserver((entries) => {
13262
13245
  for (const { contentRect } of entries) {
13263
- services?.uiService.set("stageContainerRect", {
13246
+ uiService.set("stageContainerRect", {
13264
13247
  width: contentRect.width,
13265
13248
  height: contentRect.height
13266
13249
  });
@@ -13269,15 +13252,15 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13269
13252
  onMounted(() => {
13270
13253
  if (stageWrapRef.value?.container) {
13271
13254
  resizeObserver.observe(stageWrapRef.value.container);
13272
- services?.keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
13255
+ keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
13273
13256
  }
13274
13257
  });
13275
13258
  onBeforeUnmount(() => {
13276
13259
  stage?.destroy();
13277
13260
  resizeObserver.disconnect();
13278
- services?.editorService.set("stage", null);
13279
- services?.keybindingService.unregisterEl("stage");
13280
- services?.editorService.off("root-change", rootChangeHandler);
13261
+ editorService.set("stage", null);
13262
+ keybindingService.unregisterEl("stage");
13263
+ editorService.off("root-change", rootChangeHandler);
13281
13264
  });
13282
13265
  const parseDSL = getEditorConfig("parseDSL");
13283
13266
  const contextmenuHandler = (e) => {
@@ -13303,10 +13286,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13303
13286
  let parent = page.value;
13304
13287
  const parentId = getIdFromEl()(parentEl);
13305
13288
  if (parentId) {
13306
- parent = services?.editorService.getNodeById(parentId, false);
13289
+ parent = editorService.getNodeById(parentId, false);
13307
13290
  }
13308
13291
  if (parent && stageContainerEl.value && stage) {
13309
- const layout = await services?.editorService.getLayout(parent);
13292
+ const layout = await editorService.getLayout(parent);
13310
13293
  const containerRect = stageContainerEl.value.getBoundingClientRect();
13311
13294
  const { scrollTop, scrollLeft } = stage.mask;
13312
13295
  const { style = {} } = config.data;
@@ -13334,7 +13317,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
13334
13317
  left: calcValueByFontsize(doc, left / zoom.value)
13335
13318
  };
13336
13319
  config.data.inputEvent = e;
13337
- services?.editorService.add(config.data, parent);
13320
+ editorService.add(config.data, parent);
13338
13321
  }
13339
13322
  };
13340
13323
  return (_ctx, _cache) => {
@@ -13403,15 +13386,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
13403
13386
  },
13404
13387
  __name: "Breadcrumb",
13405
13388
  setup(__props) {
13406
- const services = inject("services");
13407
- const editorService = services?.editorService;
13408
- const node = computed(() => editorService?.get("node"));
13409
- const nodes = computed(() => editorService?.get("nodes") || []);
13410
- const root = computed(() => editorService?.get("root"));
13389
+ const { editorService } = useServices();
13390
+ const node = computed(() => editorService.get("node"));
13391
+ const nodes = computed(() => editorService.get("nodes"));
13392
+ const root = computed(() => editorService.get("root"));
13411
13393
  const path = computed(() => getNodePath(node.value?.id || "", root.value?.items || []));
13412
13394
  const select = async (node2) => {
13413
- await editorService?.select(node2);
13414
- editorService?.get("stage")?.select(node2.id);
13395
+ await editorService.select(node2);
13396
+ editorService.get("stage")?.select(node2.id);
13415
13397
  };
13416
13398
  return (_ctx, _cache) => {
13417
13399
  return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
@@ -13467,8 +13449,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
13467
13449
  },
13468
13450
  setup(__props) {
13469
13451
  const stageOptions = inject("stageOptions");
13470
- const services = inject("services");
13471
- const page = computed(() => services?.editorService.get("page"));
13452
+ const { editorService } = useServices();
13453
+ const page = computed(() => editorService.get("page"));
13472
13454
  return (_ctx, _cache) => {
13473
13455
  return openBlock(), createElementBlock("div", _hoisted_1, [
13474
13456
  createVNode(_sfc_main$2),
@@ -13913,12 +13895,22 @@ class DataSource extends BaseService {
13913
13895
  }
13914
13896
  const dataSourceService = new DataSource();
13915
13897
 
13916
- const idleTask = new IdleTask();
13917
13898
  class Dep extends BaseService {
13918
13899
  state = shallowReactive({
13919
- collecting: false
13900
+ collecting: false,
13901
+ taskLength: 0
13920
13902
  });
13903
+ idleTask = new IdleTask();
13921
13904
  watcher = new Watcher({ initialTargets: reactive({}) });
13905
+ constructor() {
13906
+ super();
13907
+ this.idleTask.on(
13908
+ "update-task-length",
13909
+ throttle(({ length }) => {
13910
+ this.set("taskLength", length);
13911
+ }, 1e3)
13912
+ );
13913
+ }
13922
13914
  set(name, value) {
13923
13915
  this.state[name] = value;
13924
13916
  }
@@ -13973,11 +13965,11 @@ class Dep extends BaseService {
13973
13965
  resolve();
13974
13966
  return;
13975
13967
  }
13976
- idleTask.once("finish", () => {
13968
+ this.idleTask.once("finish", () => {
13977
13969
  this.emit("collected", nodes, deep);
13978
13970
  this.set("collecting", false);
13979
13971
  });
13980
- idleTask.once("hight-level-finish", () => {
13972
+ this.idleTask.once("hight-level-finish", () => {
13981
13973
  this.emit("ds-collected", nodes, deep);
13982
13974
  resolve();
13983
13975
  });
@@ -14008,7 +14000,7 @@ class Dep extends BaseService {
14008
14000
  return this.watcher.hasSpecifiedTypeTarget(type);
14009
14001
  }
14010
14002
  clearIdleTasks() {
14011
- idleTask.clearTasks();
14003
+ this.idleTask.clearTasks();
14012
14004
  }
14013
14005
  on(eventName, listener) {
14014
14006
  return super.on(eventName, listener);
@@ -14017,8 +14009,8 @@ class Dep extends BaseService {
14017
14009
  return super.once(eventName, listener);
14018
14010
  }
14019
14011
  reset() {
14020
- idleTask.removeAllListeners();
14021
- idleTask.clearTasks();
14012
+ this.idleTask.removeAllListeners();
14013
+ this.idleTask.clearTasks();
14022
14014
  for (const type of Object.keys(this.watcher.getTargetsList())) {
14023
14015
  this.removeTargets(type);
14024
14016
  }
@@ -14028,12 +14020,13 @@ class Dep extends BaseService {
14028
14020
  this.removeAllListeners();
14029
14021
  this.reset();
14030
14022
  this.removeAllPlugins();
14023
+ this.idleTask.removeAllListeners();
14031
14024
  }
14032
14025
  emit(eventName, ...args) {
14033
14026
  return super.emit(eventName, ...args);
14034
14027
  }
14035
14028
  enqueueTask(node, target, depExtendedData, deep) {
14036
- idleTask.enqueueTask(
14029
+ this.idleTask.enqueueTask(
14037
14030
  ({ node: node2, deep: deep2, target: target2 }) => {
14038
14031
  this.collectNode(node2, target2, depExtendedData, deep2);
14039
14032
  },
@@ -15227,4 +15220,4 @@ const index = {
15227
15220
  }
15228
15221
  };
15229
15222
 
15230
- export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$1e as CodeBlockEditor, _sfc_main$k as CodeBlockList, _sfc_main$j as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$1n as CodeSelect, _sfc_main$1l as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$1k as CondOpSelect, _sfc_main$o as ContentMenu, _sfc_main$i as DataSourceConfigPanel, _sfc_main$1g as DataSourceFieldSelect, _sfc_main$1i as DataSourceFields, _sfc_main$1f as DataSourceInput, _sfc_main$1c as DataSourceMethodSelect, _sfc_main$1d as DataSourceMethods, _sfc_main$1b as DataSourceMocks, _sfc_main$1a as DataSourceSelect, _sfc_main$19 as DisplayConds, DragType, _sfc_main$18 as EventSelect, Fixed2Other, _sfc_main$1j as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$1r as Icon, IdleTask, KeyBindingCommand, _sfc_main$16 as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$A as LayoutContainer, _sfc_main$15 as PageFragmentSelect, _sfc_main$q as PropsFormPanel, _sfc_main$p as PropsPanel, _sfc_main$B as Resizer, ScrollViewer, SideItemKey, _sfc_main$A as SplitView, _sfc_main$D as StyleSetter, _sfc_main$1q as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$z as ToolButton, _sfc_main$l as Tree, _sfc_main$m as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, eqOptions, error, eventTabConfig, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getDefaultConfig, getDisplayField, getEditorConfig, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isIncludeDataSource, log, moveItemsInContainer, numberOptions, propsService, removeDataSourceFieldPrefix, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, stageOverlayService, storageService, styleTabConfig, uiService, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus$1 as useNodeStatus, useStage, useWindowRect, warn };
15223
+ export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$1e as CodeBlockEditor, _sfc_main$k as CodeBlockList, _sfc_main$j as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$1n as CodeSelect, _sfc_main$1l as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$1k as CondOpSelect, _sfc_main$o as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, _sfc_main$i as DataSourceConfigPanel, _sfc_main$1g as DataSourceFieldSelect, _sfc_main$1i as DataSourceFields, _sfc_main$1f as DataSourceInput, _sfc_main$1c as DataSourceMethodSelect, _sfc_main$1d as DataSourceMethods, _sfc_main$1b as DataSourceMocks, _sfc_main$1a as DataSourceSelect, _sfc_main$19 as DisplayConds, DragType, _sfc_main$18 as EventSelect, Fixed2Other, _sfc_main$1j as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$1r as Icon, IdleTask, KeyBindingCommand, _sfc_main$16 as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$A as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, _sfc_main$15 as PageFragmentSelect, _sfc_main$q as PropsFormPanel, _sfc_main$p as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, _sfc_main$B as Resizer, ScrollViewer, SideItemKey, _sfc_main$A as SplitView, _sfc_main$D as StyleSetter, _sfc_main$1q as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$z as ToolButton, _sfc_main$l as Tree, _sfc_main$m as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, eqOptions, error, eventTabConfig, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getDefaultConfig, getDisplayField, getEditorConfig, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isIncludeDataSource, log, moveItemsInContainer, numberOptions, propsService, removeDataSourceFieldPrefix, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, stageOverlayService, storageService, styleTabConfig, uiService, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus$1 as useNodeStatus, useServices, useStage, useWindowRect, warn };