@done-coding/forge-feedback 0.103.1-alpha.0 → 0.104.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, getCurrentInstance, inject, renderSlot } from "vue";
2
- import { getModalShelfInjectionKey } from "@done-coding/forge-core/inject";
2
+ import { MODAL_SHELF_INJECTION_KEYS } from "@done-coding/forge-core/inject";
3
3
  import { usePorterGlobalConfig } from "./use-porter-global-config.mjs";
4
4
  import { useActivated } from "@done-coding/forge-core/hooks";
5
5
  import { APP_GLOBAL_MODAL_PORTER_SYMBOL } from "./modal-global-symbol.mjs";
@@ -16,8 +16,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  useModalPorterSlotMisuseWarn();
17
17
  const uid = ((_a = getCurrentInstance()) == null ? void 0 : _a.uid) ?? Math.floor(Math.random() * 1e9);
18
18
  const namedShelves = {
19
- app: inject(getModalShelfInjectionKey("app"), null),
20
- page: inject(getModalShelfInjectionKey("page"), null)
19
+ app: inject(MODAL_SHELF_INJECTION_KEYS.app, null),
20
+ page: inject(MODAL_SHELF_INJECTION_KEYS.page, null)
21
21
  };
22
22
  const isGlobalOnly = props.globalOnly === APP_GLOBAL_MODAL_PORTER_SYMBOL;
23
23
  function nsOf(key) {
@@ -1,5 +1,5 @@
1
1
  const APP_GLOBAL_MODAL_PORTER_SYMBOL = Symbol(
2
- "admin-core:global-modal-porter"
2
+ "@done-coding/forge-feedback:global-modal-porter"
3
3
  );
4
4
  export {
5
5
  APP_GLOBAL_MODAL_PORTER_SYMBOL
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, useModel, provide, onMounted, inject, openBlock, createElementBlock, Fragment, renderSlot, renderList, unref, createBlock, resolveDynamicComponent, mergeModels, defineAsyncComponent } from "vue";
2
- import { getModalShelfInjectionKey } from "@done-coding/forge-core/inject";
2
+ import { MODAL_SHELF_INJECTION_KEYS } from "@done-coding/forge-core/inject";
3
3
  import { useShelfController } from "./use-shelf-controller.mjs";
4
4
  import { assertLevelHierarchy } from "./modal-shelf-hierarchy.mjs";
5
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -8,8 +8,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  level: {}
9
9
  }, {
10
10
  "remote": {
11
- // 初始空壳即带 modalKey 清单(挂载前 remote.modalKey 恒存在,消费方零判空)。
12
- // 字面量直注 GlobalModalRemote 被 Record 索引签名拒绝,断言只作用于类型。
11
+ // 初始空壳即带 modalKey 清单(挂载前 remote.modalKey 恒存在,消费方零判空);架子创建即补上 open。
13
12
  default: () => ({ modalKey: [] })
14
13
  },
15
14
  "remoteModifiers": {}
@@ -21,17 +20,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
20
  const remote = useModel(__props, "remote");
22
21
  const controller = useShelfController(level, remote);
23
22
  __expose(controller);
24
- provide(getModalShelfInjectionKey(level), controller);
23
+ provide(MODAL_SHELF_INJECTION_KEYS[level], controller);
24
+ const asyncByLoader = /* @__PURE__ */ new WeakMap();
25
25
  function resolveComp(c) {
26
- return typeof c === "function" ? defineAsyncComponent(c) : c;
26
+ if (typeof c !== "function") return c;
27
+ const loader = c;
28
+ let comp = asyncByLoader.get(loader);
29
+ if (!comp) {
30
+ comp = defineAsyncComponent(loader);
31
+ asyncByLoader.set(loader, comp);
32
+ }
33
+ return comp;
27
34
  }
28
35
  onMounted(() => {
29
36
  const ancestors = [];
30
37
  ["app", "page", "custom"].forEach((lv) => {
31
38
  if (lv === level) return;
32
- if (inject(getModalShelfInjectionKey(lv), null)) ancestors.push(lv);
39
+ if (inject(MODAL_SHELF_INJECTION_KEYS[lv], null)) ancestors.push(lv);
33
40
  });
34
- const sameLevel = inject(getModalShelfInjectionKey(level), null);
41
+ const sameLevel = inject(MODAL_SHELF_INJECTION_KEYS[level], null);
35
42
  if (sameLevel && sameLevel !== controller) ancestors.push(level);
36
43
  assertLevelHierarchy(level, ancestors);
37
44
  });
@@ -2,7 +2,8 @@ import { ref, markRaw } from "vue";
2
2
  const CLOSE_ANIM_MS = 300;
3
3
  function createShelfController(level, remoteRef, {
4
4
  report,
5
- isActive = () => true
5
+ isActive = () => true,
6
+ warn
6
7
  } = {}) {
7
8
  let seq = 0;
8
9
  const items = ref([]);
@@ -107,9 +108,23 @@ function createShelfController(level, remoteRef, {
107
108
  update: (payload) => handleFor(key).update(payload)
108
109
  };
109
110
  });
110
- remoteRef.value = Object.assign(handles, {
111
+ const remote = Object.assign(handles, {
111
112
  modalKey: [...configs.keys()]
112
113
  });
114
+ Object.defineProperty(remote, "open", {
115
+ enumerable: false,
116
+ value: (key, payload) => {
117
+ const handle = handles[key];
118
+ if (handle) {
119
+ handle.evoke(payload);
120
+ return;
121
+ }
122
+ warn == null ? void 0 : warn(
123
+ `[forge] 弹窗「${key}」没拉起:没有登记。已登记:${[...configs.keys()].join("、") || "(无)"}。`
124
+ );
125
+ }
126
+ });
127
+ remoteRef.value = remote;
113
128
  }
114
129
  function registerConfig(entries) {
115
130
  entries.forEach((e) => configs.set(e.key, e));
@@ -122,6 +137,7 @@ function createShelfController(level, remoteRef, {
122
137
  });
123
138
  syncRemote();
124
139
  }
140
+ syncRemote();
125
141
  return {
126
142
  level,
127
143
  items,
@@ -1,7 +1,9 @@
1
1
  import { useBridgeReport, useActivated } from "@done-coding/forge-core/hooks";
2
+ import { useIsDev } from "@done-coding/forge-core/internals";
2
3
  import { createShelfController } from "./modal-shelf-core.mjs";
3
4
  function useShelfController(level, remote) {
4
5
  const report = useBridgeReport();
6
+ const isDev = useIsDev();
5
7
  let active = true;
6
8
  useActivated((info) => {
7
9
  active = info.isActivated;
@@ -13,7 +15,10 @@ function useShelfController(level, remote) {
13
15
  report: (event, data) => {
14
16
  if (active) report(event, data);
15
17
  },
16
- isActive: () => active
18
+ isActive: () => active,
19
+ warn: (message) => {
20
+ if (isDev()) console.warn(message);
21
+ }
17
22
  });
18
23
  return controller;
19
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/forge-feedback",
3
- "version": "0.103.1-alpha.0",
3
+ "version": "0.104.1-alpha.0",
4
4
  "description": "Forge 反馈组件:全局弹窗的调度与承载",
5
5
  "private": false,
6
6
  "main": "es/index.mjs",
@@ -75,11 +75,11 @@
75
75
  "vue": "^3.4.0"
76
76
  },
77
77
  "dependencies": {
78
- "@done-coding/forge-core": "0.103.1-alpha.0"
78
+ "@done-coding/forge-core": "0.104.1-alpha.0"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=18.0.0",
82
82
  "pnpm": ">=9.0.0"
83
83
  },
84
- "gitHead": "acfdb27377e0c8e392834dfe585378a69eec05e9"
84
+ "gitHead": "e731df1c116c6e96ba2ef27042efefedbe565de3"
85
85
  }
@@ -14,10 +14,12 @@ export interface ShelfControllerInternal extends ShelfController {
14
14
  * (`unregisterConfig`)时同步移除对应 key + 清掉该 key 活跃实例。page/custom
15
15
  * 架子不传 remoteRef——registerConfig 只存配置不挂遥控器。
16
16
  */
17
- export declare function createShelfController(level: ModalLevel, remoteRef?: Ref<GlobalModalRemote>, { report, isActive, }?: {
17
+ export declare function createShelfController(level: ModalLevel, remoteRef?: Ref<Pick<GlobalModalRemote, "modalKey">>, { report, isActive, warn, }?: {
18
18
  report?: (event: "modal-open" | "modal-close" | "modal-update", data: () => {
19
19
  nsKey: string;
20
20
  key: string;
21
21
  }) => void;
22
22
  isActive?: () => boolean;
23
+ /** 开发期诊断输出(调用方按 dev 闸决定是否传):遥控器 `open` 拉起未登记的名字时提示 */
24
+ warn?: (message: string) => void;
23
25
  }): ShelfControllerInternal;
@@ -1,4 +1,4 @@
1
1
  import { Ref } from 'vue';
2
2
  import { GlobalModalRemote, ModalLevel } from '@done-coding/forge-core/components/feedback/shelf-contracts';
3
3
  /** setup 接线与激活资源清理;纯工厂不依赖 Vue inject。 */
4
- export declare function useShelfController(level: ModalLevel, remote: Ref<GlobalModalRemote>): import('./modal-shelf-core').ShelfControllerInternal;
4
+ export declare function useShelfController(level: ModalLevel, remote: Ref<Pick<GlobalModalRemote, "modalKey">>): import('./modal-shelf-core').ShelfControllerInternal;