@done-coding/forge-feedback 0.0.0-stage → 0.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/es/components/modal-porter/ModalPorter.vue.mjs +87 -0
  4. package/es/components/modal-porter/ModalPorter.vue2.mjs +4 -0
  5. package/es/components/modal-porter/index.mjs +6 -0
  6. package/es/components/modal-porter/modal-global-symbol.mjs +6 -0
  7. package/es/components/modal-porter/use-porter-global-config.mjs +54 -0
  8. package/es/components/modal-porter/use-slot-misuse-warn.mjs +22 -0
  9. package/es/components/modal-shelf/ModalShelf.vue.mjs +57 -0
  10. package/es/components/modal-shelf/ModalShelf.vue2.mjs +4 -0
  11. package/es/components/modal-shelf/index.mjs +4 -0
  12. package/es/components/modal-shelf/modal-shelf-core.mjs +137 -0
  13. package/es/components/modal-shelf/modal-shelf-hierarchy.mjs +21 -0
  14. package/es/components/modal-shelf/use-shelf-controller.mjs +22 -0
  15. package/es/index.mjs +7 -0
  16. package/es/style.css +1 -0
  17. package/package.json +83 -4
  18. package/types/components/modal-porter/ModalPorter.vue.d.ts +31 -0
  19. package/types/components/modal-porter/index.d.ts +2 -0
  20. package/types/components/modal-porter/modal-global-symbol.d.ts +8 -0
  21. package/types/components/modal-porter/use-porter-global-config.d.ts +7 -0
  22. package/types/components/modal-porter/use-slot-misuse-warn.d.ts +21 -0
  23. package/types/components/modal-shelf/ModalShelf.vue.d.ts +40 -0
  24. package/types/components/modal-shelf/index.d.ts +1 -0
  25. package/types/components/modal-shelf/modal-shelf-core.d.ts +23 -0
  26. package/types/components/modal-shelf/modal-shelf-hierarchy.d.ts +6 -0
  27. package/types/components/modal-shelf/use-shelf-controller.d.ts +4 -0
  28. package/types/index.d.ts +3 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) JustSoSu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @done-coding/forge-feedback
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ forge 的 feedback L2 组件;当前本机候选版本 0.100.0-dev.1(未发布)。组件行为、配置、事件契约沿用原实现;应用聚合 forge 保留原导出与别名。仅依赖 forge-core,不能引用其他 L2/pro/聚合包。
4
+
5
+ ```ts
6
+ import * as components from "@done-coding/forge-feedback";
7
+ import "@done-coding/forge-feedback/style.css";
8
+ ```
9
+
10
+ 根入口提供本族公开组件与类型;职责桶子路径供实现包组合,准确列表见 package.json exports,内部 report hooks 不出根。共享键单一定义在 forge-core;样式须显式引入。专属 hooks/types/tests/API 随组件同迁,API见 src/components/README.md;不含模板示例 bridge/demo。
11
+
12
+ `pnpm -F @done-coding/forge-feedback build` / `pnpm -F @done-coding/forge-feedback test --run`。模板生成后已按仓库库包工作流适配,保留 preserveModules、ESM 和声明注释;不使用模板demo的dev服务。
13
+
14
+ ## 本机同版候选(id5nov)
15
+
16
+ 12公开包现已统一为 `0.100.0-dev.1`,内部依赖保持 `workspace:*` 并在真实pack中转换为精确同版。候选仅用于/tmp可丢弃宿主;没有发布到registry,正式消费项目不写dev字面版本。组件API不因起版改变,迁移见 [发布前身份调整](migrations/v0.100.0-dev.1.md)。第一方许可为 MIT,署名 `Copyright (c) JustSoSu`,完整正文见本包 LICENSE。
17
+
18
+ <!-- repo-map:start -->
19
+
20
+ ## 目录导航
21
+
22
+ - `src/components/`:本族组件、职责桶与API文档,去掉重复 feedback 层。
23
+ - `src/index.ts`:应用公开白名单。
24
+ - `vite.config.ts`:根/公共桶产物输入与真实测试发现。
25
+ - `migrations/`:版本迁移说明。
26
+
27
+ <!-- repo-map:end -->
28
+
29
+ ## 自动验证与消费边界(tc7f1a)
30
+
31
+ 仓根 `pnpm verify` 检查受影响包,`pnpm verify --all` 检查全量;`pnpm test:consumer` 用十二个真实 tgz 建仓外宿主;`pnpm verify:release` 绑定当前 HEAD 与工作树生成发行戳。任何失败均非零退出,未通过不得发布。本包 prepublishOnly 校验发行戳,不执行发布。exports 的 types 条件优先于运行时条件。ESM 产物的 lodash 子路径使用 `.js` 扩展名;不改变组件 API。消费配置和已知失败见 `scripts/forge-testing.md`,既有工程验证说明保留于 `migrations/v1.0.0-dev.2.md`(历史文件);当前候选为 `0.100.0-dev.1`,不发行。
@@ -0,0 +1,87 @@
1
+ import { defineComponent, getCurrentInstance, inject, renderSlot } from "vue";
2
+ import { getModalShelfInjectionKey } from "@done-coding/forge-core/inject";
3
+ import { usePorterGlobalConfig } from "./use-porter-global-config.mjs";
4
+ import { useActivated } from "@done-coding/forge-core/hooks";
5
+ import { APP_GLOBAL_MODAL_PORTER_SYMBOL } from "./modal-global-symbol.mjs";
6
+ import { useModalPorterSlotMisuseWarn } from "./use-slot-misuse-warn.mjs";
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ __name: "ModalPorter",
9
+ props: {
10
+ modalList: {},
11
+ globalOnly: {}
12
+ },
13
+ setup(__props, { expose: __expose }) {
14
+ var _a;
15
+ const props = __props;
16
+ useModalPorterSlotMisuseWarn();
17
+ const uid = ((_a = getCurrentInstance()) == null ? void 0 : _a.uid) ?? Math.floor(Math.random() * 1e9);
18
+ const namedShelves = {
19
+ app: inject(getModalShelfInjectionKey("app"), null),
20
+ page: inject(getModalShelfInjectionKey("page"), null)
21
+ };
22
+ const isGlobalOnly = props.globalOnly === APP_GLOBAL_MODAL_PORTER_SYMBOL;
23
+ function nsOf(key) {
24
+ return `p${uid}:${key}`;
25
+ }
26
+ function resolveShelf(shelf) {
27
+ if (shelf === "app" || shelf === "page") {
28
+ const c = namedShelves[shelf];
29
+ if (!c) {
30
+ console.error(`[ModalPorter] 未找到 level="${shelf}" 的 ModalShelf`);
31
+ return null;
32
+ }
33
+ return c;
34
+ }
35
+ return shelf;
36
+ }
37
+ function globalOnlyEntries() {
38
+ const bad = props.modalList.filter((e) => e.shelf !== "app");
39
+ bad.forEach((e) => {
40
+ console.error(
41
+ `[ModalPorter] globalOnly 专用模式只接受 shelf:"app" 条目,忽略: ${String(
42
+ e.key
43
+ )}(shelf=${String(e.shelf)})——page 级弹窗注册不得逃逸到全局面`
44
+ );
45
+ });
46
+ return props.modalList.filter((e) => e.shelf === "app");
47
+ }
48
+ usePorterGlobalConfig(isGlobalOnly, {
49
+ getEntries: globalOnlyEntries,
50
+ getSource: () => props.modalList,
51
+ getShelf: () => namedShelves.app
52
+ });
53
+ function evoke(key, payload) {
54
+ const entry = props.modalList.find((e) => e.key === key);
55
+ if (!entry) {
56
+ console.error(`[ModalPorter] 未配置的弹窗 key: ${String(key)}`);
57
+ return null;
58
+ }
59
+ const shelf = resolveShelf(entry.shelf);
60
+ if (!shelf) return null;
61
+ return shelf.evoke(nsOf(String(key)), entry.component, {
62
+ payload,
63
+ sameKeyStrategy: entry.sameKeyStrategy
64
+ });
65
+ }
66
+ useActivated((info) => {
67
+ if (info.isActivated) return;
68
+ if (isGlobalOnly) return;
69
+ const byShelf = /* @__PURE__ */ new Map();
70
+ props.modalList.forEach((e) => {
71
+ const s = resolveShelf(e.shelf);
72
+ if (!s) return;
73
+ const arr = byShelf.get(s) ?? [];
74
+ arr.push(nsOf(String(e.key)));
75
+ byShelf.set(s, arr);
76
+ });
77
+ byShelf.forEach((keys, s) => s.remove(keys));
78
+ });
79
+ __expose({ evoke });
80
+ return (_ctx, _cache) => {
81
+ return renderSlot(_ctx.$slots, "default");
82
+ };
83
+ }
84
+ });
85
+ export {
86
+ _sfc_main as default
87
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./ModalPorter.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,6 @@
1
+ import { default as default2 } from "./ModalPorter.vue.mjs";
2
+ import { APP_GLOBAL_MODAL_PORTER_SYMBOL } from "./modal-global-symbol.mjs";
3
+ export {
4
+ APP_GLOBAL_MODAL_PORTER_SYMBOL,
5
+ default2 as ModalPorter
6
+ };
@@ -0,0 +1,6 @@
1
+ const APP_GLOBAL_MODAL_PORTER_SYMBOL = Symbol(
2
+ "admin-core:global-modal-porter"
3
+ );
4
+ export {
5
+ APP_GLOBAL_MODAL_PORTER_SYMBOL
6
+ };
@@ -0,0 +1,54 @@
1
+ import { watch } from "vue";
2
+ import { useActivated } from "@done-coding/forge-core/hooks";
3
+ function usePorterGlobalConfig(enabled, {
4
+ getEntries,
5
+ getSource,
6
+ getShelf
7
+ }) {
8
+ if (!enabled) return;
9
+ let keys = [];
10
+ const unregister = () => {
11
+ var _a;
12
+ (_a = getShelf()) == null ? void 0 : _a.unregisterConfig(keys);
13
+ keys = [];
14
+ };
15
+ const register = () => {
16
+ const shelf = getShelf();
17
+ if (!shelf) {
18
+ console.error(
19
+ "[ModalPorter] globalOnly 专用模式需要 app 级 ModalShelf(未找到)"
20
+ );
21
+ return;
22
+ }
23
+ const entries = getEntries();
24
+ keys = entries.map((entry) => String(entry.key));
25
+ shelf.registerConfig(
26
+ entries.map((entry) => ({
27
+ key: String(entry.key),
28
+ component: entry.component,
29
+ sameKeyStrategy: entry.sameKeyStrategy
30
+ }))
31
+ );
32
+ };
33
+ const observe = () => watch(getSource, () => {
34
+ unregister();
35
+ register();
36
+ });
37
+ register();
38
+ let stop = observe();
39
+ useActivated(({ isActivated }) => {
40
+ if (isActivated) {
41
+ if (!stop) {
42
+ register();
43
+ stop = observe();
44
+ }
45
+ } else {
46
+ stop == null ? void 0 : stop();
47
+ stop = void 0;
48
+ unregister();
49
+ }
50
+ });
51
+ }
52
+ export {
53
+ usePorterGlobalConfig
54
+ };
@@ -0,0 +1,22 @@
1
+ import { getCurrentInstance } from "vue";
2
+ import { DC_SLOT_ATTR, resolveAppPageSlotName, parseSlotRegion } from "@done-coding/forge-core/config";
3
+ import { useActivated } from "@done-coding/forge-core/hooks";
4
+ const useModalPorterSlotMisuseWarn = () => {
5
+ const instance = getCurrentInstance();
6
+ let reported = false;
7
+ useActivated((info) => {
8
+ var _a, _b;
9
+ if (!info.isActivated || reported) return;
10
+ const el = (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$el;
11
+ const raw = (_b = el == null ? void 0 : el.parentElement) == null ? void 0 : _b.getAttribute(DC_SLOT_ATTR);
12
+ const slot = resolveAppPageSlotName(parseSlotRegion(raw));
13
+ if (!slot) return;
14
+ reported = true;
15
+ console.error(
16
+ `[ModalPorter] 它被放在 AppPage 的 #${slot} 槽里 —— 方位槽是 ModalShelf 的兄弟节点,provide 够不到,evoke() 恒为 null(表现为「点按钮毫无反应」,不报错不崩)。[MUST] 移到**默认槽**(page 架子就住在默认槽里;与 AppPage 并列同样够不到)。Porter 自身零 DOM 输出,放默认槽里不占任何版面。`
17
+ );
18
+ });
19
+ };
20
+ export {
21
+ useModalPorterSlotMisuseWarn
22
+ };
@@ -0,0 +1,57 @@
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";
3
+ import { useShelfController } from "./use-shelf-controller.mjs";
4
+ import { assertLevelHierarchy } from "./modal-shelf-hierarchy.mjs";
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ __name: "ModalShelf",
7
+ props: /* @__PURE__ */ mergeModels({
8
+ level: {}
9
+ }, {
10
+ "remote": {
11
+ // 初始空壳即带 modalKey 清单(挂载前 remote.modalKey 恒存在,消费方零判空)。
12
+ // 字面量直注 GlobalModalRemote 被 Record 索引签名拒绝,断言只作用于类型。
13
+ default: () => ({ modalKey: [] })
14
+ },
15
+ "remoteModifiers": {}
16
+ }),
17
+ emits: ["update:remote"],
18
+ setup(__props, { expose: __expose }) {
19
+ const props = __props;
20
+ const level = props.level;
21
+ const remote = useModel(__props, "remote");
22
+ const controller = useShelfController(level, remote);
23
+ __expose(controller);
24
+ provide(getModalShelfInjectionKey(level), controller);
25
+ function resolveComp(c) {
26
+ return typeof c === "function" ? defineAsyncComponent(c) : c;
27
+ }
28
+ onMounted(() => {
29
+ const ancestors = [];
30
+ ["app", "page", "custom"].forEach((lv) => {
31
+ if (lv === level) return;
32
+ if (inject(getModalShelfInjectionKey(lv), null)) ancestors.push(lv);
33
+ });
34
+ const sameLevel = inject(getModalShelfInjectionKey(level), null);
35
+ if (sameLevel && sameLevel !== controller) ancestors.push(level);
36
+ assertLevelHierarchy(level, ancestors);
37
+ });
38
+ return (_ctx, _cache) => {
39
+ return openBlock(), createElementBlock(Fragment, null, [
40
+ renderSlot(_ctx.$slots, "default"),
41
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(controller).items.value, (item) => {
42
+ return openBlock(), createBlock(resolveDynamicComponent(resolveComp(item.component)), {
43
+ key: item.id,
44
+ show: item.show,
45
+ payload: item.payload,
46
+ closeFn: () => unref(controller).close(item),
47
+ removeFn: () => unref(controller).remove(item.nsKey),
48
+ "onUpdate:show": (v) => !v && unref(controller).close(item)
49
+ }, null, 40, ["show", "payload", "closeFn", "removeFn", "onUpdate:show"]);
50
+ }), 128))
51
+ ], 64);
52
+ };
53
+ }
54
+ });
55
+ export {
56
+ _sfc_main as default
57
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./ModalShelf.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./ModalShelf.vue.mjs";
2
+ export {
3
+ default2 as ModalShelf
4
+ };
@@ -0,0 +1,137 @@
1
+ import { ref, markRaw } from "vue";
2
+ const CLOSE_ANIM_MS = 300;
3
+ function createShelfController(level, remoteRef, {
4
+ report,
5
+ isActive = () => true
6
+ } = {}) {
7
+ let seq = 0;
8
+ const items = ref([]);
9
+ const configs = /* @__PURE__ */ new Map();
10
+ function reportItem(event, nsKey) {
11
+ report == null ? void 0 : report(event, () => ({
12
+ nsKey,
13
+ key: configs.has(nsKey) ? nsKey : nsKey.replace(/^p\d+:/, "")
14
+ }));
15
+ }
16
+ function indexByNsKey(nsKey) {
17
+ return items.value.findIndex((it) => it.nsKey === nsKey);
18
+ }
19
+ function clearItemTimer(item) {
20
+ if (item.timer !== void 0) {
21
+ clearTimeout(item.timer);
22
+ item.timer = void 0;
23
+ }
24
+ }
25
+ function remove(nsKey) {
26
+ const keys = Array.isArray(nsKey) ? nsKey : [nsKey];
27
+ keys.forEach((k) => {
28
+ const i = indexByNsKey(k);
29
+ if (i > -1) {
30
+ const item = items.value[i];
31
+ clearItemTimer(item);
32
+ items.value.splice(i, 1);
33
+ if (item.show) reportItem("modal-close", k);
34
+ }
35
+ });
36
+ }
37
+ function close(item) {
38
+ const target = items.value.find((it) => it.id === item.id);
39
+ if (!target) return;
40
+ if (!target.show || target.timer !== void 0) return;
41
+ target.show = false;
42
+ if (!isActive()) {
43
+ remove(target.nsKey);
44
+ reportItem("modal-close", target.nsKey);
45
+ return;
46
+ }
47
+ target.timer = setTimeout(() => {
48
+ const i = items.value.findIndex((it) => it.id === item.id);
49
+ if (i > -1) items.value.splice(i, 1);
50
+ }, CLOSE_ANIM_MS);
51
+ reportItem("modal-close", target.nsKey);
52
+ }
53
+ function handleFor(nsKey) {
54
+ return {
55
+ close: () => {
56
+ const cur = items.value.find((it) => it.nsKey === nsKey);
57
+ if (cur) close(cur);
58
+ },
59
+ update: (partial) => {
60
+ const cur = items.value.find((it) => it.nsKey === nsKey);
61
+ if (cur) {
62
+ cur.payload = { ...cur.payload, ...partial };
63
+ reportItem("modal-update", nsKey);
64
+ }
65
+ }
66
+ };
67
+ }
68
+ function evoke(nsKey, component, options) {
69
+ const { payload, sameKeyStrategy = "recreate" } = options;
70
+ if (sameKeyStrategy === "update") {
71
+ const existing = items.value.find((it) => it.nsKey === nsKey);
72
+ if (existing) {
73
+ const wasVisible = existing.show;
74
+ clearItemTimer(existing);
75
+ existing.show = true;
76
+ existing.payload = payload;
77
+ reportItem(wasVisible ? "modal-update" : "modal-open", nsKey);
78
+ return handleFor(nsKey);
79
+ }
80
+ }
81
+ remove(nsKey);
82
+ const id = ++seq;
83
+ const item = {
84
+ id,
85
+ nsKey,
86
+ component: markRaw(component),
87
+ payload,
88
+ show: true
89
+ };
90
+ items.value.push(item);
91
+ reportItem("modal-open", nsKey);
92
+ return handleFor(nsKey);
93
+ }
94
+ function syncRemote() {
95
+ if (!remoteRef) return;
96
+ const handles = {};
97
+ configs.forEach((cfg, key) => {
98
+ handles[key] = {
99
+ evoke: (payload) => evoke(key, cfg.component, {
100
+ payload: payload ?? {},
101
+ sameKeyStrategy: cfg.sameKeyStrategy
102
+ }),
103
+ close: () => {
104
+ const cur = items.value.find((it) => it.nsKey === key);
105
+ if (cur) close(cur);
106
+ },
107
+ update: (payload) => handleFor(key).update(payload)
108
+ };
109
+ });
110
+ remoteRef.value = Object.assign(handles, {
111
+ modalKey: [...configs.keys()]
112
+ });
113
+ }
114
+ function registerConfig(entries) {
115
+ entries.forEach((e) => configs.set(e.key, e));
116
+ syncRemote();
117
+ }
118
+ function unregisterConfig(keys) {
119
+ keys.forEach((k) => {
120
+ remove(k);
121
+ configs.delete(k);
122
+ });
123
+ syncRemote();
124
+ }
125
+ return {
126
+ level,
127
+ items,
128
+ evoke,
129
+ remove,
130
+ close,
131
+ registerConfig,
132
+ unregisterConfig
133
+ };
134
+ }
135
+ export {
136
+ createShelfController
137
+ };
@@ -0,0 +1,21 @@
1
+ function assertLevelHierarchy(level, ancestorLevels) {
2
+ if (level === "app" && ancestorLevels.length > 0) {
3
+ console.error(
4
+ `[ModalShelf] level="app" 必须最顶层,但其上存在: ${ancestorLevels.join(
5
+ ", "
6
+ )}`
7
+ );
8
+ return;
9
+ }
10
+ if (level === "page") {
11
+ const bad = ancestorLevels.filter((l) => l === "custom");
12
+ if (bad.length > 0) {
13
+ console.error(
14
+ `[ModalShelf] level="page" 之上不得套 custom,发现: ${bad.join(", ")}`
15
+ );
16
+ }
17
+ }
18
+ }
19
+ export {
20
+ assertLevelHierarchy
21
+ };
@@ -0,0 +1,22 @@
1
+ import { useBridgeReport, useActivated } from "@done-coding/forge-core/hooks";
2
+ import { createShelfController } from "./modal-shelf-core.mjs";
3
+ function useShelfController(level, remote) {
4
+ const report = useBridgeReport();
5
+ let active = true;
6
+ useActivated((info) => {
7
+ active = info.isActivated;
8
+ if (info.isActivated) return;
9
+ const keys = controller.items.value.filter((item) => !item.show || info.triggerType === "unmounted").map((item) => item.nsKey);
10
+ controller.remove(keys);
11
+ });
12
+ const controller = createShelfController(level, remote, {
13
+ report: (event, data) => {
14
+ if (active) report(event, data);
15
+ },
16
+ isActive: () => active
17
+ });
18
+ return controller;
19
+ }
20
+ export {
21
+ useShelfController
22
+ };
package/es/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ /* empty css */
2
+ import { default as default2 } from "./components/modal-porter/ModalPorter.vue.mjs";
3
+ import { default as default3 } from "./components/modal-shelf/ModalShelf.vue.mjs";
4
+ export {
5
+ default2 as ModalPorter,
6
+ default3 as ModalShelf
7
+ };
package/es/style.css ADDED
@@ -0,0 +1 @@
1
+ /*! forge-feedback 无组件自有样式;显式保留 CSS 入口供宿主汇总。 */
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@done-coding/forge-feedback",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.100.0",
4
+ "description": "Forge 反馈组件:全局弹窗的调度与承载",
5
+ "private": false,
6
+ "main": "es/index.mjs",
7
+ "module": "es/index.mjs",
8
+ "types": "types/index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./types/index.d.ts",
13
+ "import": "./es/index.mjs"
14
+ },
15
+ "./style.css": "./es/style.css",
16
+ "./components/modal-porter": {
17
+ "types": "./types/components/modal-porter/index.d.ts",
18
+ "import": "./es/components/modal-porter/index.mjs"
19
+ },
20
+ "./components/modal-shelf": {
21
+ "types": "./types/components/modal-shelf/index.d.ts",
22
+ "import": "./es/components/modal-shelf/index.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "es",
27
+ "types"
28
+ ],
29
+ "scripts": {
30
+ "serve": "vite",
31
+ "dev": "vite build -w -m hotBuild",
32
+ "hotBuild": "vite build -w",
33
+ "build": "vue-tsc && vite build",
34
+ "build:test": "pnpm run build",
35
+ "test": "vitest",
36
+ "coverage": "vitest run --coverage",
37
+ "prebuild:test": "rimraf types",
38
+ "lint": "node ../../scripts/core-boundary-lint.mjs",
39
+ "prebuild": "rimraf types",
40
+ "typecheck": "vue-tsc --noEmit",
41
+ "prepublishOnly": "node ../../scripts/forge-release.mjs --check-stamp"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/done-coding/done-coding-forge.git",
46
+ "directory": "packages/forge-feedback"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "author": "JustSoSu",
53
+ "license": "MIT",
54
+ "sideEffects": [
55
+ "**/*.css",
56
+ "**/*.less"
57
+ ],
58
+ "devDependencies": {
59
+ "@types/lodash": "^4.17.24",
60
+ "@types/node": "^18.0.0",
61
+ "@vitejs/plugin-vue": "^5.0.4",
62
+ "@vitejs/plugin-vue-jsx": "^4.1.2",
63
+ "@vitest/coverage-istanbul": "^1.6.1",
64
+ "@vue/test-utils": "^2.4.10",
65
+ "jsdom": "^29.1.0",
66
+ "less": "^4.2.0",
67
+ "rimraf": "^5.0.1",
68
+ "typescript": "^5.2.2",
69
+ "vite": "^5.2.0",
70
+ "vite-plugin-dts": "^4.5.4",
71
+ "vitest": "^1.6.1",
72
+ "vue-tsc": "^2.2.12"
73
+ },
74
+ "peerDependencies": {
75
+ "vue": "^3.4.0"
76
+ },
77
+ "dependencies": {
78
+ "@done-coding/forge-core": "0.100.0"
79
+ },
80
+ "engines": {
81
+ "node": ">=18.0.0",
82
+ "pnpm": ">=9.0.0"
83
+ },
84
+ "gitHead": "2eb50e25a430fe59d79c19c32ecdcfd6cb11608d"
85
+ }
@@ -0,0 +1,31 @@
1
+ import { EvokeHandle, ModalShelfMap, RegisterEntry } from '@done-coding/forge-core/components/feedback/shelf-contracts';
2
+ type __VLS_Props = {
3
+ modalList: RegisterEntry[];
4
+ /**
5
+ * 专用模式标识(core 内部):=== `APP_GLOBAL_MODAL_PORTER_SYMBOL` 时本 Porter 为
6
+ * AppLayout 内部全局弹窗专用——只接受 shelf:"app" 条目,非 app 条目 console.error +
7
+ * 过滤;配置经架子 `registerConfig` 推送(挂载进 globalModalRemote)。外部拿不到
8
+ * Symbol 即无法误用。[MUST NOT] 业务侧传入。
9
+ */
10
+ globalOnly?: symbol;
11
+ };
12
+ declare function evoke<K extends keyof ModalShelfMap>(key: K, payload: ModalShelfMap[K]): EvokeHandle | null;
13
+ declare function __VLS_template(): {
14
+ attrs: Partial<{}>;
15
+ slots: {
16
+ default?(_: {}): any;
17
+ };
18
+ refs: {};
19
+ rootEl: any;
20
+ };
21
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
22
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
23
+ evoke: typeof evoke;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
26
+ export default _default;
27
+ type __VLS_WithTemplateSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,2 @@
1
+ export { default as ModalPorter } from './ModalPorter.vue';
2
+ export * from './modal-global-symbol';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 全局弹窗专用 Porter 标识(core 内部私有,[MUST NOT] 经 modal/index.ts 导出)。
3
+ *
4
+ * 只有持有本 Symbol 的调用方(= AppLayout 内部专用 ModalPorter)才能启用
5
+ * `globalOnly` 模式推送 app 级弹窗配置——外部拿不到 Symbol 即无法伪造专用模式。
6
+ * AppLayout 经 forge-feedback 的 modal-porter 实现契约桶取同一 binding;不出应用根。
7
+ */
8
+ export declare const APP_GLOBAL_MODAL_PORTER_SYMBOL: unique symbol;
@@ -0,0 +1,7 @@
1
+ import { RegisterEntry, ShelfController } from '@done-coding/forge-core/components/feedback/shelf-contracts';
2
+ /** 全局配置保持同步首注册;缓存失活撤销,重激活按最新配置恢复。 */
3
+ export declare function usePorterGlobalConfig(enabled: boolean, { getEntries, getSource, getShelf, }: {
4
+ getEntries: () => RegisterEntry[];
5
+ getSource: () => RegisterEntry[];
6
+ getShelf: () => ShelfController | null;
7
+ }): void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ModalPorter 落错槽的运行期检测(**非主干功能**,规则 22:删掉本文件 + 组件里那一行
3
+ * 委托即零残留;[MUST NOT] 出桶导出)。
4
+ *
5
+ * 要防的错:把 Porter 放进 `AppPage` 的 `#top`/`#bottom`/`#left`/`#right`。
6
+ * 方位槽是页面内置 `ModalShelf` 的**兄弟节点**而非后代 ⇒ provide 够不到,
7
+ * `evoke()` 恒返回 `null`——表现为「点按钮毫无反应」,**不报错也不崩**。
8
+ *
9
+ * 🔴 为什么非报不可:此前只有 `evoke` 里那句「未找到 ModalShelf」,那说的是**症状**不是病因,
10
+ * 读的人不会想到是槽位问题。实证:消费方规范 + 守卫俱在,仍一次排查出 8 个页面犯同一条
11
+ * (理由都是「弹窗经弹层挂载、不占版面 ⇒ 放哪都行」——只对了一半,**槽本身**照样渲染)。
12
+ * ⇒ 这类错 [MUST] 由运行期报出来,[MUST NOT] 指望下一份规范写得更清楚。
13
+ *
14
+ * 机制同 `use-context-defaults`:挂载后读 `$el.parentElement` 上的 `DC_SLOT_ATTR`。
15
+ * ModalPorter 根是 `<slot/>`(fragment)⇒ `$el` 是锚点文本 / 注释节点,`parentElement`
16
+ * 照样是槽 shim,可用。
17
+ *
18
+ * **恒报不限 dev**:方位槽里出现 Porter **没有任何正当用法**,零误报
19
+ * (对照 AppPage 的空壳槽检测:那条有合法动态状态,故 dev-only + 去重)。
20
+ */
21
+ export declare const useModalPorterSlotMisuseWarn: () => void;
@@ -0,0 +1,40 @@
1
+ import { Component } from 'vue';
2
+ import { GlobalModalRemote, ModalLevel } from '@done-coding/forge-core/components/feedback/shelf-contracts';
3
+ type __VLS_Props = {
4
+ level: ModalLevel;
5
+ };
6
+ type __VLS_PublicProps = {
7
+ "remote"?: GlobalModalRemote;
8
+ } & __VLS_Props;
9
+ declare function __VLS_template(): {
10
+ attrs: Partial<{}>;
11
+ slots: {
12
+ default?(_: {}): any;
13
+ };
14
+ refs: {};
15
+ rootEl: any;
16
+ };
17
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
18
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {
19
+ items: import('vue').Ref<import('@done-coding/forge-core/types').ShelfItem[]>;
20
+ level: ModalLevel;
21
+ evoke: (nsKey: string, component: Component | (() => Promise<Component>), options: {
22
+ payload: Record<string, unknown>;
23
+ sameKeyStrategy?: import('@done-coding/forge-core/types').ModalSameKeyStrategy;
24
+ }) => import('@done-coding/forge-core/types').EvokeHandle;
25
+ remove: (nsKey: string | string[]) => void;
26
+ close: (item: import('@done-coding/forge-core/types').ShelfItem) => void;
27
+ registerConfig: (entries: import('@done-coding/forge-core/types').ShelfConfigEntry[]) => void;
28
+ unregisterConfig: (keys: string[]) => void;
29
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
30
+ "update:remote": (value: GlobalModalRemote) => any;
31
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
32
+ "onUpdate:remote"?: ((value: GlobalModalRemote) => any) | undefined;
33
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
34
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
35
+ export default _default;
36
+ type __VLS_WithTemplateSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
@@ -0,0 +1 @@
1
+ export { default as ModalShelf } from './ModalShelf.vue';
@@ -0,0 +1,23 @@
1
+ import { Ref } from 'vue';
2
+ import { GlobalModalRemote, ModalLevel, ShelfController, ShelfItem } from '@done-coding/forge-core/components/feedback/shelf-contracts';
3
+ /** ShelfController 内部扩展:额外暴露渲染用活跃实例列表 */
4
+ export interface ShelfControllerInternal extends ShelfController {
5
+ /** 渲染用:当前活跃实例列表(多例数组) */
6
+ items: Ref<ShelfItem[]>;
7
+ }
8
+ /**
9
+ * 创建一个架子逻辑控制器(纯逻辑,无 DOM 依赖,可单测)。
10
+ *
11
+ * `remoteRef` 可选——仅 app 级架子传入(v-model:remote 的 model ref):收到
12
+ * `registerConfig` 推送的全局弹窗配置后,把 key → {evoke, close, update} 句柄
13
+ * 挂进遥控器对象(整体替换 model 值触发响应式 + 链式 v-model 传播);配置移除
14
+ * (`unregisterConfig`)时同步移除对应 key + 清掉该 key 活跃实例。page/custom
15
+ * 架子不传 remoteRef——registerConfig 只存配置不挂遥控器。
16
+ */
17
+ export declare function createShelfController(level: ModalLevel, remoteRef?: Ref<GlobalModalRemote>, { report, isActive, }?: {
18
+ report?: (event: "modal-open" | "modal-close" | "modal-update", data: () => {
19
+ nsKey: string;
20
+ key: string;
21
+ }) => void;
22
+ isActive?: () => boolean;
23
+ }): ShelfControllerInternal;
@@ -0,0 +1,6 @@
1
+ import { ModalLevel } from '@done-coding/forge-core/components/feedback/shelf-contracts';
2
+ /**
3
+ * 层级合法性:app 必最顶层;page 祖先允许 app/page(父子页面嵌套场景),仅禁止 custom;custom 可嵌套任何(含 custom 套 custom)。
4
+ * 非法仅开发期 console.error,不抛、不静默。
5
+ */
6
+ export declare function assertLevelHierarchy(level: ModalLevel, ancestorLevels: ModalLevel[]): void;
@@ -0,0 +1,4 @@
1
+ import { Ref } from 'vue';
2
+ import { GlobalModalRemote, ModalLevel } from '@done-coding/forge-core/components/feedback/shelf-contracts';
3
+ /** setup 接线与激活资源清理;纯工厂不依赖 Vue inject。 */
4
+ export declare function useShelfController(level: ModalLevel, remote: Ref<GlobalModalRemote>): import('./modal-shelf-core').ShelfControllerInternal;
@@ -0,0 +1,3 @@
1
+ export { ModalPorter } from './components/modal-porter';
2
+ export { ModalShelf } from './components/modal-shelf';
3
+ export type * from '@done-coding/forge-core/components/feedback/shelf-contracts';