@we-debug/core 0.50.0 → 0.51.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.
- package/CHANGELOG.md +18 -0
- package/dist/api/launcher.d.ts +7 -0
- package/dist/api/launcher.js +55 -0
- package/dist/api/ui.d.ts +24 -0
- package/dist/api/ui.js +196 -0
- package/dist/index.d.ts +31 -7
- package/dist/index.js +45 -1
- package/dist/model/badge.d.ts +2 -1
- package/dist/model/badge.js +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +2 -0
- package/dist/model/overlay.d.ts +10 -0
- package/dist/model/overlay.js +45 -0
- package/dist/model/panelview.d.ts +13 -0
- package/dist/model/panelview.js +48 -0
- package/dist/store/index.d.ts +2 -1
- package/dist/store/index.js +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/version.js +1 -1
- package/package.json +17 -11
- package/test/ui.test.ts +151 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.51.0](https://github.com/dlhandsome/we-debug/compare/v0.50.0...v0.51.0) (2026-12-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** correct custom UI state handling ([749439d](https://github.com/dlhandsome/we-debug/commit/749439ddbf199bdb34f7e25f0e5109038768ba18))
|
|
12
|
+
* **core:** 跳转同步异常不 reject、面板重复添加去重 ([f534662](https://github.com/dlhandsome/we-debug/commit/f534662538cf74d6909a691bfcadf9724bdae8f9))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **core:** 新增自定义 UI 插件运行时 API ([3718755](https://github.com/dlhandsome/we-debug/commit/371875548239361668b3605cb36cd13d94bbb347))
|
|
18
|
+
* **miniprogram:** responsive debug panel and floating launcher ([eb08b8c](https://github.com/dlhandsome/we-debug/commit/eb08b8c6b09faab4ad2cb4aa25ae0141c347c912))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
# [0.50.0](https://github.com/dlhandsome/we-debug/compare/v0.49.2...v0.50.0) (2026-11-27)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ILauncherDotOption } from '../types';
|
|
2
|
+
export declare const LAUNCHER_DOT_UPDATE = "launcher:dot:update";
|
|
3
|
+
export declare function hasLauncherDot(): boolean;
|
|
4
|
+
export declare function getLauncherDotGroups(): string[];
|
|
5
|
+
export declare function showLauncherDot(key: string, option?: ILauncherDotOption): void;
|
|
6
|
+
export declare function hideLauncherDot(key: string): void;
|
|
7
|
+
export declare function readLauncherDotGroup(group: string): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readLauncherDotGroup = exports.hideLauncherDot = exports.showLauncherDot = exports.getLauncherDotGroups = exports.hasLauncherDot = exports.LAUNCHER_DOT_UPDATE = void 0;
|
|
7
|
+
var index_1 = __importDefault(require("../store/index"));
|
|
8
|
+
exports.LAUNCHER_DOT_UPDATE = 'launcher:dot:update';
|
|
9
|
+
var sources = {};
|
|
10
|
+
var seq = 0;
|
|
11
|
+
var emitUpdate = function () { return index_1.default.event.emit(exports.LAUNCHER_DOT_UPDATE, hasLauncherDot()); };
|
|
12
|
+
function hasLauncherDot() {
|
|
13
|
+
return Object.keys(sources).length > 0;
|
|
14
|
+
}
|
|
15
|
+
exports.hasLauncherDot = hasLauncherDot;
|
|
16
|
+
function getLauncherDotGroups() {
|
|
17
|
+
var groups = [];
|
|
18
|
+
Object.keys(sources)
|
|
19
|
+
.map(function (key) { return sources[key]; })
|
|
20
|
+
.sort(function (a, b) { return b.time - a.time; })
|
|
21
|
+
.forEach(function (_a) {
|
|
22
|
+
var group = _a.group;
|
|
23
|
+
if (group && groups.indexOf(group) === -1)
|
|
24
|
+
groups.push(group);
|
|
25
|
+
});
|
|
26
|
+
return groups;
|
|
27
|
+
}
|
|
28
|
+
exports.getLauncherDotGroups = getLauncherDotGroups;
|
|
29
|
+
function showLauncherDot(key, option) {
|
|
30
|
+
if (option === void 0) { option = {}; }
|
|
31
|
+
sources[key] = { group: option.group, time: ++seq };
|
|
32
|
+
emitUpdate();
|
|
33
|
+
}
|
|
34
|
+
exports.showLauncherDot = showLauncherDot;
|
|
35
|
+
function hideLauncherDot(key) {
|
|
36
|
+
if (!(key in sources))
|
|
37
|
+
return;
|
|
38
|
+
delete sources[key];
|
|
39
|
+
emitUpdate();
|
|
40
|
+
}
|
|
41
|
+
exports.hideLauncherDot = hideLauncherDot;
|
|
42
|
+
function clearWhere(match) {
|
|
43
|
+
var keys = Object.keys(sources).filter(function (key) { return match(sources[key]); });
|
|
44
|
+
if (!keys.length)
|
|
45
|
+
return;
|
|
46
|
+
keys.forEach(function (key) { return delete sources[key]; });
|
|
47
|
+
emitUpdate();
|
|
48
|
+
}
|
|
49
|
+
function readLauncherDotGroup(group) {
|
|
50
|
+
clearWhere(function (source) { return source.group === group; });
|
|
51
|
+
}
|
|
52
|
+
exports.readLauncherDotGroup = readLauncherDotGroup;
|
|
53
|
+
index_1.default.event.on('debug:mask:show-modal', function () {
|
|
54
|
+
clearWhere(function (source) { return !source.group; });
|
|
55
|
+
});
|
package/dist/api/ui.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PanelView, Overlay } from '../model/index';
|
|
2
|
+
import { IAnyObject, IUIManifest, IAddPanelViewOption, IUpdatePanelViewOption, IPageOverlay, IScopePanelOption, IScopeOverlayOption, IScopeNavigateOption } from '../types';
|
|
3
|
+
export declare function registerUIManifest(m: IUIManifest): void;
|
|
4
|
+
export declare function getUIManifest(): IUIManifest | null;
|
|
5
|
+
export declare function getCurrentPageId(): string;
|
|
6
|
+
export declare function addPanelView(panel: PanelView, options?: IAddPanelViewOption): void;
|
|
7
|
+
export declare function updatePanelView(panel: PanelView, patch?: IUpdatePanelViewOption): void;
|
|
8
|
+
export declare function removePanelView(panel: PanelView): void;
|
|
9
|
+
export declare function showOverlay(overlay: Overlay, props?: IAnyObject): Promise<any>;
|
|
10
|
+
export declare function hideOverlay(overlay: Overlay): void;
|
|
11
|
+
export declare function getPageOverlays(pageId: string): IPageOverlay[];
|
|
12
|
+
export declare function closeOverlay(pageId: string, componentId: string, result?: any): void;
|
|
13
|
+
export declare function releasePageOverlays(pageId: string): void;
|
|
14
|
+
export declare function scope(pkg: string): {
|
|
15
|
+
createPanel(opt: IScopePanelOption): PanelView;
|
|
16
|
+
addPanel: typeof addPanelView;
|
|
17
|
+
updatePanel: typeof updatePanelView;
|
|
18
|
+
removePanel: typeof removePanelView;
|
|
19
|
+
createOverlay(opt: IScopeOverlayOption): Overlay;
|
|
20
|
+
showOverlay: typeof showOverlay;
|
|
21
|
+
hideOverlay: typeof hideOverlay;
|
|
22
|
+
navigateTo(page: string, query?: IAnyObject, options?: IScopeNavigateOption): Promise<any>;
|
|
23
|
+
createCache(key: string): import("../base/cache").CacheData;
|
|
24
|
+
};
|
package/dist/api/ui.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.scope = exports.releasePageOverlays = exports.closeOverlay = exports.getPageOverlays = exports.hideOverlay = exports.showOverlay = exports.removePanelView = exports.updatePanelView = exports.addPanelView = exports.getCurrentPageId = exports.getUIManifest = exports.registerUIManifest = void 0;
|
|
7
|
+
var index_1 = __importDefault(require("../store/index"));
|
|
8
|
+
var group_1 = require("./group");
|
|
9
|
+
var cache_1 = require("./cache");
|
|
10
|
+
var index_2 = require("../model/index");
|
|
11
|
+
var LOG_PREFIX = '[we-debug]';
|
|
12
|
+
var manifest = null;
|
|
13
|
+
var manifestWarned = false;
|
|
14
|
+
var activeOverlays = [];
|
|
15
|
+
function registerUIManifest(m) {
|
|
16
|
+
manifest = m;
|
|
17
|
+
}
|
|
18
|
+
exports.registerUIManifest = registerUIManifest;
|
|
19
|
+
function getUIManifest() {
|
|
20
|
+
return manifest;
|
|
21
|
+
}
|
|
22
|
+
exports.getUIManifest = getUIManifest;
|
|
23
|
+
function ensureManifest() {
|
|
24
|
+
if (!manifest && !manifestWarned) {
|
|
25
|
+
manifestWarned = true;
|
|
26
|
+
console.warn("".concat(LOG_PREFIX, " \u672A\u68C0\u6D4B\u5230 UI \u63D2\u4EF6\u6E05\u5355\uFF0C\u81EA\u5B9A\u4E49 UI \u63D2\u4EF6\u9700\u8981\u901A\u8FC7 @we-debug/cli \u6216 @we-debug/gulp-tool \u7F16\u8BD1\u63A5\u5165"));
|
|
27
|
+
}
|
|
28
|
+
return manifest;
|
|
29
|
+
}
|
|
30
|
+
function resolveComponentId(pkg, name) {
|
|
31
|
+
var m = ensureManifest();
|
|
32
|
+
if (!m)
|
|
33
|
+
return '';
|
|
34
|
+
var p = m.packages[pkg];
|
|
35
|
+
var id = p ? p.components[name] : '';
|
|
36
|
+
if (!id) {
|
|
37
|
+
var declared = p ? Object.keys(p.components).join(', ') || '无' : '该包未被编译工具识别';
|
|
38
|
+
console.error("".concat(LOG_PREFIX, " \u63D2\u4EF6 ").concat(pkg, " \u672A\u58F0\u660E\u7EC4\u4EF6 ").concat(name, "\uFF0C\u5DF2\u58F0\u660E\u7684\u7EC4\u4EF6\uFF1A").concat(declared));
|
|
39
|
+
}
|
|
40
|
+
return id || '';
|
|
41
|
+
}
|
|
42
|
+
function getCurrentPageId() {
|
|
43
|
+
var pages = typeof getCurrentPages === 'function' ? getCurrentPages() : [];
|
|
44
|
+
var top = pages[pages.length - 1];
|
|
45
|
+
return top && typeof top.getPageId === 'function' ? String(top.getPageId()) : '';
|
|
46
|
+
}
|
|
47
|
+
exports.getCurrentPageId = getCurrentPageId;
|
|
48
|
+
function emitPanelUpdate() {
|
|
49
|
+
index_1.default.event.emit('panelview:update');
|
|
50
|
+
index_1.default.event.emit('group:update');
|
|
51
|
+
}
|
|
52
|
+
function addPanelView(panel, options) {
|
|
53
|
+
if (!panel.componentId)
|
|
54
|
+
return;
|
|
55
|
+
var group = (options && options.group && options.group.name) || panel.title;
|
|
56
|
+
if (panel.group && panel.group !== group)
|
|
57
|
+
(0, group_1.removeGroupView)(panel.group, panel);
|
|
58
|
+
panel.group = group;
|
|
59
|
+
if (!index_1.default.panelviews.getById(panel.id))
|
|
60
|
+
index_1.default.panelviews.add(panel);
|
|
61
|
+
(0, group_1.addViewByGroup)(panel.group, panel);
|
|
62
|
+
emitPanelUpdate();
|
|
63
|
+
}
|
|
64
|
+
exports.addPanelView = addPanelView;
|
|
65
|
+
function updatePanelView(panel, patch) {
|
|
66
|
+
if (patch === void 0) { patch = {}; }
|
|
67
|
+
if (patch.title !== undefined)
|
|
68
|
+
panel.title = patch.title;
|
|
69
|
+
if (patch.props !== undefined)
|
|
70
|
+
panel.props = patch.props;
|
|
71
|
+
index_1.default.panelviews.update(panel);
|
|
72
|
+
emitPanelUpdate();
|
|
73
|
+
}
|
|
74
|
+
exports.updatePanelView = updatePanelView;
|
|
75
|
+
function removePanelView(panel) {
|
|
76
|
+
index_1.default.panelviews.remove(panel);
|
|
77
|
+
if (panel.group)
|
|
78
|
+
(0, group_1.removeGroupView)(panel.group, panel);
|
|
79
|
+
emitPanelUpdate();
|
|
80
|
+
}
|
|
81
|
+
exports.removePanelView = removePanelView;
|
|
82
|
+
function settle(entry, result) {
|
|
83
|
+
activeOverlays = activeOverlays.filter(function (o) { return o !== entry; });
|
|
84
|
+
entry.resolve(result);
|
|
85
|
+
}
|
|
86
|
+
function showOverlay(overlay, props) {
|
|
87
|
+
if (!overlay.componentId)
|
|
88
|
+
return Promise.resolve(undefined);
|
|
89
|
+
var pageId = getCurrentPageId();
|
|
90
|
+
var existing = activeOverlays.filter(function (o) { return o.overlay.id === overlay.id && o.pageId === pageId; })[0];
|
|
91
|
+
if (existing) {
|
|
92
|
+
if (props)
|
|
93
|
+
existing.props = props;
|
|
94
|
+
index_1.default.event.emit('overlay:update');
|
|
95
|
+
return existing.promise;
|
|
96
|
+
}
|
|
97
|
+
activeOverlays
|
|
98
|
+
.filter(function (o) { return o.pageId === pageId && o.overlay.componentId === overlay.componentId; })
|
|
99
|
+
.forEach(function (o) { return settle(o, undefined); });
|
|
100
|
+
var resolve = function () { };
|
|
101
|
+
var promise = new Promise(function (r) {
|
|
102
|
+
resolve = r;
|
|
103
|
+
});
|
|
104
|
+
activeOverlays.push({ overlay: overlay, pageId: pageId, props: props || overlay.props, resolve: resolve, promise: promise });
|
|
105
|
+
index_1.default.event.emit('overlay:update');
|
|
106
|
+
return promise;
|
|
107
|
+
}
|
|
108
|
+
exports.showOverlay = showOverlay;
|
|
109
|
+
function hideOverlay(overlay) {
|
|
110
|
+
activeOverlays.filter(function (o) { return o.overlay.id === overlay.id; }).forEach(function (o) { return settle(o, undefined); });
|
|
111
|
+
index_1.default.event.emit('overlay:update');
|
|
112
|
+
}
|
|
113
|
+
exports.hideOverlay = hideOverlay;
|
|
114
|
+
function getPageOverlays(pageId) {
|
|
115
|
+
return activeOverlays
|
|
116
|
+
.filter(function (o) { return o.pageId === pageId; })
|
|
117
|
+
.map(function (o) { return ({ overlayId: o.overlay.id, componentId: o.overlay.componentId, props: o.props }); });
|
|
118
|
+
}
|
|
119
|
+
exports.getPageOverlays = getPageOverlays;
|
|
120
|
+
function closeOverlay(pageId, componentId, result) {
|
|
121
|
+
activeOverlays
|
|
122
|
+
.filter(function (o) { return o.pageId === pageId && o.overlay.componentId === componentId; })
|
|
123
|
+
.forEach(function (o) { return settle(o, result); });
|
|
124
|
+
index_1.default.event.emit('overlay:update');
|
|
125
|
+
}
|
|
126
|
+
exports.closeOverlay = closeOverlay;
|
|
127
|
+
function releasePageOverlays(pageId) {
|
|
128
|
+
activeOverlays.filter(function (o) { return o.pageId === pageId; }).forEach(function (o) { return settle(o, undefined); });
|
|
129
|
+
index_1.default.event.emit('overlay:update');
|
|
130
|
+
}
|
|
131
|
+
exports.releasePageOverlays = releasePageOverlays;
|
|
132
|
+
function navigateToPluginPage(pkg, page, query, options) {
|
|
133
|
+
var m = ensureManifest();
|
|
134
|
+
if (!m)
|
|
135
|
+
return Promise.resolve(undefined);
|
|
136
|
+
var p = m.packages[pkg];
|
|
137
|
+
if (!p || p.pages.indexOf(page) === -1) {
|
|
138
|
+
var declared = p ? p.pages.join(', ') || '无' : '该包未被编译工具识别';
|
|
139
|
+
console.error("".concat(LOG_PREFIX, " \u63D2\u4EF6 ").concat(pkg, " \u672A\u58F0\u660E\u9875\u9762 ").concat(page, "\uFF0C\u5DF2\u58F0\u660E\u7684\u9875\u9762\uFF1A").concat(declared));
|
|
140
|
+
return Promise.resolve(undefined);
|
|
141
|
+
}
|
|
142
|
+
var q = query || {};
|
|
143
|
+
var qs = Object.keys(q)
|
|
144
|
+
.filter(function (k) { return q[k] !== undefined; })
|
|
145
|
+
.map(function (k) { return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(String(q[k]))); })
|
|
146
|
+
.join('&');
|
|
147
|
+
var url = "/".concat(m.npmDirname, "/").concat(pkg, "/").concat(page).concat(qs ? "?".concat(qs) : '');
|
|
148
|
+
return new Promise(function (resolve) {
|
|
149
|
+
try {
|
|
150
|
+
wx.navigateTo({
|
|
151
|
+
url: url,
|
|
152
|
+
events: options && options.events,
|
|
153
|
+
success: function (res) { return resolve(res); },
|
|
154
|
+
fail: function (err) {
|
|
155
|
+
console.error("".concat(LOG_PREFIX, " \u8DF3\u8F6C\u63D2\u4EF6\u9875\u9762\u5931\u8D25\uFF1A").concat(url), err);
|
|
156
|
+
resolve(undefined);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
console.error("".concat(LOG_PREFIX, " \u8DF3\u8F6C\u63D2\u4EF6\u9875\u9762\u5931\u8D25\uFF1A").concat(url), err);
|
|
162
|
+
resolve(undefined);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function scope(pkg) {
|
|
167
|
+
return {
|
|
168
|
+
createPanel: function (opt) {
|
|
169
|
+
return (0, index_2.createPanelView)({
|
|
170
|
+
key: "".concat(pkg, "/").concat(opt.component),
|
|
171
|
+
componentId: resolveComponentId(pkg, opt.component),
|
|
172
|
+
title: opt.title,
|
|
173
|
+
props: opt.props
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
addPanel: addPanelView,
|
|
177
|
+
updatePanel: updatePanelView,
|
|
178
|
+
removePanel: removePanelView,
|
|
179
|
+
createOverlay: function (opt) {
|
|
180
|
+
return (0, index_2.createOverlay)({
|
|
181
|
+
key: "".concat(pkg, "/").concat(opt.component),
|
|
182
|
+
componentId: resolveComponentId(pkg, opt.component),
|
|
183
|
+
props: opt.props
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
showOverlay: showOverlay,
|
|
187
|
+
hideOverlay: hideOverlay,
|
|
188
|
+
navigateTo: function (page, query, options) {
|
|
189
|
+
return navigateToPluginPage(pkg, page, query, options);
|
|
190
|
+
},
|
|
191
|
+
createCache: function (key) {
|
|
192
|
+
return (0, cache_1.createCache)("".concat(pkg, ":").concat(key));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
exports.scope = scope;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { use } from './api/use';
|
|
|
6
6
|
import { init } from './api/init';
|
|
7
7
|
import { createCache } from './api/cache';
|
|
8
8
|
import { createBadge, getBadge, addBadge, removeBadge } from './api/badge';
|
|
9
|
+
import { hasLauncherDot, showLauncherDot, hideLauncherDot, getLauncherDotGroups, readLauncherDotGroup, LAUNCHER_DOT_UPDATE } from './api/launcher';
|
|
9
10
|
import { createFormRule, getFormRule, addFormRule, removeFormRule } from './api/rule';
|
|
10
11
|
import { createJsonView, getJsonView, addJsonView, updateJsonView, removeJsonView } from './api/jsonview';
|
|
11
12
|
import { createTableView, getTableView, addTableView, updateTableView, removeTableView } from './api/tableview';
|
|
@@ -17,9 +18,11 @@ import { ENV_TYPE, getEnv } from './utils/env';
|
|
|
17
18
|
import { silent, isSilent } from './utils/silent';
|
|
18
19
|
import { DEFAULT_GROUP } from './config/group';
|
|
19
20
|
import { version } from './version';
|
|
21
|
+
import { registerUIManifest, getUIManifest, scope, getCurrentPageId, addPanelView, updatePanelView, removePanelView, showOverlay, hideOverlay, closeOverlay, getPageOverlays, releasePageOverlays } from './api/ui';
|
|
22
|
+
import { createPanelView, createOverlay } from './model/index';
|
|
20
23
|
declare const event: import("./base/event").Event;
|
|
21
24
|
export * from './types';
|
|
22
|
-
export { ENV_TYPE, DEFAULT_GROUP, getEnv, silent, isSilent, use, init, createCache, event, store, util, textEncoder, createBadge, getBadge, addBadge, removeBadge, createFormRule, getFormRule, addFormRule, removeFormRule, createJsonView, getJsonView, addJsonView, updateJsonView, removeJsonView, createTableView, getTableView, addTableView, updateTableView, removeTableView, createNetworkView, getNetworkView, addNetworkView, updateNetworkView, removeNetworkView, createApiView, getApiView, addApiView, updateApiView, removeApiView, getGroupsAllKeys, addRuleByGroup, getRuleByGroup, removeGroupRule, addJsonViewByGroup, getJsonViewByGroup, removeGroupJsonView, setBridgeInfo, getBridgeInfo, version };
|
|
25
|
+
export { ENV_TYPE, DEFAULT_GROUP, getEnv, silent, isSilent, use, init, createCache, event, store, util, textEncoder, createBadge, getBadge, addBadge, removeBadge, hasLauncherDot, showLauncherDot, hideLauncherDot, getLauncherDotGroups, readLauncherDotGroup, LAUNCHER_DOT_UPDATE, createFormRule, getFormRule, addFormRule, removeFormRule, createJsonView, getJsonView, addJsonView, updateJsonView, removeJsonView, createTableView, getTableView, addTableView, updateTableView, removeTableView, createNetworkView, getNetworkView, addNetworkView, updateNetworkView, removeNetworkView, createApiView, getApiView, addApiView, updateApiView, removeApiView, getGroupsAllKeys, addRuleByGroup, getRuleByGroup, removeGroupRule, addJsonViewByGroup, getJsonViewByGroup, removeGroupJsonView, setBridgeInfo, getBridgeInfo, registerUIManifest, getUIManifest, scope, getCurrentPageId, createPanelView, addPanelView, updatePanelView, removePanelView, createOverlay, showOverlay, hideOverlay, closeOverlay, getPageOverlays, releasePageOverlays, version };
|
|
23
26
|
declare const _default: {
|
|
24
27
|
ENV_TYPE: typeof ENV_TYPE;
|
|
25
28
|
DEFAULT_GROUP: {
|
|
@@ -40,12 +43,13 @@ declare const _default: {
|
|
|
40
43
|
set: (sys: WechatMiniprogram.SystemInfo) => void;
|
|
41
44
|
};
|
|
42
45
|
event: import("./base/event").Event;
|
|
43
|
-
badges: import("./base/set").MySet<import("./model").Badge>;
|
|
44
|
-
rules: import("./base/set").MySet<import("./model").FormRule>;
|
|
45
|
-
jsonviews: import("./base/set").MySet<import("./model").JsonView>;
|
|
46
|
-
tableviews: import("./base/set").MySet<import("./model").TableView>;
|
|
47
|
-
networkviews: import("./base/set").MySet<import("./model").NetworkView>;
|
|
48
|
-
apiviews: import("./base/set").MySet<import("./model").ApiView>;
|
|
46
|
+
badges: import("./base/set").MySet<import("./model/badge").Badge>;
|
|
47
|
+
rules: import("./base/set").MySet<import("./model/rule").FormRule>;
|
|
48
|
+
jsonviews: import("./base/set").MySet<import("./model/jsonview").JsonView>;
|
|
49
|
+
tableviews: import("./base/set").MySet<import("./model/tableview").TableView>;
|
|
50
|
+
networkviews: import("./base/set").MySet<import("./model/networkview").NetworkView>;
|
|
51
|
+
apiviews: import("./base/set").MySet<import("./model/apiview").ApiView>;
|
|
52
|
+
panelviews: import("./base/set").MySet<import("./model/panelview").PanelView>;
|
|
49
53
|
group: import("./store/group").Group;
|
|
50
54
|
bridge: import("./base/store").Store;
|
|
51
55
|
};
|
|
@@ -55,6 +59,12 @@ declare const _default: {
|
|
|
55
59
|
getBadge: typeof getBadge;
|
|
56
60
|
addBadge: typeof addBadge;
|
|
57
61
|
removeBadge: typeof removeBadge;
|
|
62
|
+
hasLauncherDot: typeof hasLauncherDot;
|
|
63
|
+
showLauncherDot: typeof showLauncherDot;
|
|
64
|
+
hideLauncherDot: typeof hideLauncherDot;
|
|
65
|
+
getLauncherDotGroups: typeof getLauncherDotGroups;
|
|
66
|
+
readLauncherDotGroup: typeof readLauncherDotGroup;
|
|
67
|
+
LAUNCHER_DOT_UPDATE: string;
|
|
58
68
|
createFormRule: typeof createFormRule;
|
|
59
69
|
getFormRule: typeof getFormRule;
|
|
60
70
|
addFormRule: typeof addFormRule;
|
|
@@ -88,6 +98,20 @@ declare const _default: {
|
|
|
88
98
|
removeGroupJsonView: typeof removeGroupJsonView;
|
|
89
99
|
setBridgeInfo: typeof setBridgeInfo;
|
|
90
100
|
getBridgeInfo: import("./types").GetBridgeInfoFunc;
|
|
101
|
+
registerUIManifest: typeof registerUIManifest;
|
|
102
|
+
getUIManifest: typeof getUIManifest;
|
|
103
|
+
scope: typeof scope;
|
|
104
|
+
getCurrentPageId: typeof getCurrentPageId;
|
|
105
|
+
createPanelView: typeof createPanelView;
|
|
106
|
+
addPanelView: typeof addPanelView;
|
|
107
|
+
updatePanelView: typeof updatePanelView;
|
|
108
|
+
removePanelView: typeof removePanelView;
|
|
109
|
+
createOverlay: typeof createOverlay;
|
|
110
|
+
showOverlay: typeof showOverlay;
|
|
111
|
+
hideOverlay: typeof hideOverlay;
|
|
112
|
+
closeOverlay: typeof closeOverlay;
|
|
113
|
+
getPageOverlays: typeof getPageOverlays;
|
|
114
|
+
releasePageOverlays: typeof releasePageOverlays;
|
|
91
115
|
version: string;
|
|
92
116
|
};
|
|
93
117
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
32
|
+
exports.removeGroupRule = exports.getRuleByGroup = exports.addRuleByGroup = exports.getGroupsAllKeys = exports.removeApiView = exports.updateApiView = exports.addApiView = exports.getApiView = exports.createApiView = exports.removeNetworkView = exports.updateNetworkView = exports.addNetworkView = exports.getNetworkView = exports.createNetworkView = exports.removeTableView = exports.updateTableView = exports.addTableView = exports.getTableView = exports.createTableView = exports.removeJsonView = exports.updateJsonView = exports.addJsonView = exports.getJsonView = exports.createJsonView = exports.removeFormRule = exports.addFormRule = exports.getFormRule = exports.createFormRule = exports.LAUNCHER_DOT_UPDATE = exports.readLauncherDotGroup = exports.getLauncherDotGroups = exports.hideLauncherDot = exports.showLauncherDot = exports.hasLauncherDot = exports.removeBadge = exports.addBadge = exports.getBadge = exports.createBadge = exports.textEncoder = exports.util = exports.store = exports.event = exports.createCache = exports.init = exports.use = exports.isSilent = exports.silent = exports.getEnv = exports.DEFAULT_GROUP = exports.ENV_TYPE = void 0;
|
|
33
|
+
exports.version = exports.releasePageOverlays = exports.getPageOverlays = exports.closeOverlay = exports.hideOverlay = exports.showOverlay = exports.createOverlay = exports.removePanelView = exports.updatePanelView = exports.addPanelView = exports.createPanelView = exports.getCurrentPageId = exports.scope = exports.getUIManifest = exports.registerUIManifest = exports.getBridgeInfo = exports.setBridgeInfo = exports.removeGroupJsonView = exports.getJsonViewByGroup = exports.addJsonViewByGroup = void 0;
|
|
33
34
|
var index_1 = __importDefault(require("./store/index"));
|
|
34
35
|
exports.store = index_1.default;
|
|
35
36
|
var util = __importStar(require("./utils/simple-type-function"));
|
|
@@ -48,6 +49,13 @@ Object.defineProperty(exports, "createBadge", { enumerable: true, get: function
|
|
|
48
49
|
Object.defineProperty(exports, "getBadge", { enumerable: true, get: function () { return badge_1.getBadge; } });
|
|
49
50
|
Object.defineProperty(exports, "addBadge", { enumerable: true, get: function () { return badge_1.addBadge; } });
|
|
50
51
|
Object.defineProperty(exports, "removeBadge", { enumerable: true, get: function () { return badge_1.removeBadge; } });
|
|
52
|
+
var launcher_1 = require("./api/launcher");
|
|
53
|
+
Object.defineProperty(exports, "hasLauncherDot", { enumerable: true, get: function () { return launcher_1.hasLauncherDot; } });
|
|
54
|
+
Object.defineProperty(exports, "showLauncherDot", { enumerable: true, get: function () { return launcher_1.showLauncherDot; } });
|
|
55
|
+
Object.defineProperty(exports, "hideLauncherDot", { enumerable: true, get: function () { return launcher_1.hideLauncherDot; } });
|
|
56
|
+
Object.defineProperty(exports, "getLauncherDotGroups", { enumerable: true, get: function () { return launcher_1.getLauncherDotGroups; } });
|
|
57
|
+
Object.defineProperty(exports, "readLauncherDotGroup", { enumerable: true, get: function () { return launcher_1.readLauncherDotGroup; } });
|
|
58
|
+
Object.defineProperty(exports, "LAUNCHER_DOT_UPDATE", { enumerable: true, get: function () { return launcher_1.LAUNCHER_DOT_UPDATE; } });
|
|
51
59
|
var rule_1 = require("./api/rule");
|
|
52
60
|
Object.defineProperty(exports, "createFormRule", { enumerable: true, get: function () { return rule_1.createFormRule; } });
|
|
53
61
|
Object.defineProperty(exports, "getFormRule", { enumerable: true, get: function () { return rule_1.getFormRule; } });
|
|
@@ -98,6 +106,22 @@ var group_2 = require("./config/group");
|
|
|
98
106
|
Object.defineProperty(exports, "DEFAULT_GROUP", { enumerable: true, get: function () { return group_2.DEFAULT_GROUP; } });
|
|
99
107
|
var version_1 = require("./version");
|
|
100
108
|
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_1.version; } });
|
|
109
|
+
var ui_1 = require("./api/ui");
|
|
110
|
+
Object.defineProperty(exports, "registerUIManifest", { enumerable: true, get: function () { return ui_1.registerUIManifest; } });
|
|
111
|
+
Object.defineProperty(exports, "getUIManifest", { enumerable: true, get: function () { return ui_1.getUIManifest; } });
|
|
112
|
+
Object.defineProperty(exports, "scope", { enumerable: true, get: function () { return ui_1.scope; } });
|
|
113
|
+
Object.defineProperty(exports, "getCurrentPageId", { enumerable: true, get: function () { return ui_1.getCurrentPageId; } });
|
|
114
|
+
Object.defineProperty(exports, "addPanelView", { enumerable: true, get: function () { return ui_1.addPanelView; } });
|
|
115
|
+
Object.defineProperty(exports, "updatePanelView", { enumerable: true, get: function () { return ui_1.updatePanelView; } });
|
|
116
|
+
Object.defineProperty(exports, "removePanelView", { enumerable: true, get: function () { return ui_1.removePanelView; } });
|
|
117
|
+
Object.defineProperty(exports, "showOverlay", { enumerable: true, get: function () { return ui_1.showOverlay; } });
|
|
118
|
+
Object.defineProperty(exports, "hideOverlay", { enumerable: true, get: function () { return ui_1.hideOverlay; } });
|
|
119
|
+
Object.defineProperty(exports, "closeOverlay", { enumerable: true, get: function () { return ui_1.closeOverlay; } });
|
|
120
|
+
Object.defineProperty(exports, "getPageOverlays", { enumerable: true, get: function () { return ui_1.getPageOverlays; } });
|
|
121
|
+
Object.defineProperty(exports, "releasePageOverlays", { enumerable: true, get: function () { return ui_1.releasePageOverlays; } });
|
|
122
|
+
var index_2 = require("./model/index");
|
|
123
|
+
Object.defineProperty(exports, "createPanelView", { enumerable: true, get: function () { return index_2.createPanelView; } });
|
|
124
|
+
Object.defineProperty(exports, "createOverlay", { enumerable: true, get: function () { return index_2.createOverlay; } });
|
|
101
125
|
var event = index_1.default.event;
|
|
102
126
|
exports.event = event;
|
|
103
127
|
__exportStar(require("./types"), exports);
|
|
@@ -118,6 +142,12 @@ exports.default = {
|
|
|
118
142
|
getBadge: badge_1.getBadge,
|
|
119
143
|
addBadge: badge_1.addBadge,
|
|
120
144
|
removeBadge: badge_1.removeBadge,
|
|
145
|
+
hasLauncherDot: launcher_1.hasLauncherDot,
|
|
146
|
+
showLauncherDot: launcher_1.showLauncherDot,
|
|
147
|
+
hideLauncherDot: launcher_1.hideLauncherDot,
|
|
148
|
+
getLauncherDotGroups: launcher_1.getLauncherDotGroups,
|
|
149
|
+
readLauncherDotGroup: launcher_1.readLauncherDotGroup,
|
|
150
|
+
LAUNCHER_DOT_UPDATE: launcher_1.LAUNCHER_DOT_UPDATE,
|
|
121
151
|
createFormRule: rule_1.createFormRule,
|
|
122
152
|
getFormRule: rule_1.getFormRule,
|
|
123
153
|
addFormRule: rule_1.addFormRule,
|
|
@@ -151,5 +181,19 @@ exports.default = {
|
|
|
151
181
|
removeGroupJsonView: group_1.removeGroupJsonView,
|
|
152
182
|
setBridgeInfo: bridge_1.setBridgeInfo,
|
|
153
183
|
getBridgeInfo: bridge_1.getBridgeInfo,
|
|
184
|
+
registerUIManifest: ui_1.registerUIManifest,
|
|
185
|
+
getUIManifest: ui_1.getUIManifest,
|
|
186
|
+
scope: ui_1.scope,
|
|
187
|
+
getCurrentPageId: ui_1.getCurrentPageId,
|
|
188
|
+
createPanelView: index_2.createPanelView,
|
|
189
|
+
addPanelView: ui_1.addPanelView,
|
|
190
|
+
updatePanelView: ui_1.updatePanelView,
|
|
191
|
+
removePanelView: ui_1.removePanelView,
|
|
192
|
+
createOverlay: index_2.createOverlay,
|
|
193
|
+
showOverlay: ui_1.showOverlay,
|
|
194
|
+
hideOverlay: ui_1.hideOverlay,
|
|
195
|
+
closeOverlay: ui_1.closeOverlay,
|
|
196
|
+
getPageOverlays: ui_1.getPageOverlays,
|
|
197
|
+
releasePageOverlays: ui_1.releasePageOverlays,
|
|
154
198
|
version: version_1.version
|
|
155
199
|
};
|
package/dist/model/badge.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export declare class Badge extends BaseManage {
|
|
|
4
4
|
private key;
|
|
5
5
|
private value;
|
|
6
6
|
private color;
|
|
7
|
-
|
|
7
|
+
show: boolean | (() => boolean);
|
|
8
8
|
private draggable;
|
|
9
9
|
private position;
|
|
10
10
|
private styles;
|
|
11
11
|
private textOnly;
|
|
12
|
+
type: 'default' | 'launcher';
|
|
12
13
|
constructor(opt?: IBadgeManageConstructorOption);
|
|
13
14
|
get prefix(): string;
|
|
14
15
|
}
|
package/dist/model/badge.js
CHANGED
|
@@ -34,6 +34,7 @@ var Badge = (function (_super) {
|
|
|
34
34
|
_this.position = (opt === null || opt === void 0 ? void 0 : opt.position) || {};
|
|
35
35
|
_this.styles = (opt === null || opt === void 0 ? void 0 : opt.styles) || '';
|
|
36
36
|
_this.textOnly = (opt === null || opt === void 0 ? void 0 : opt.textOnly) || false;
|
|
37
|
+
_this.type = (opt === null || opt === void 0 ? void 0 : opt.type) || 'default';
|
|
37
38
|
return _this;
|
|
38
39
|
}
|
|
39
40
|
Object.defineProperty(Badge.prototype, "prefix", {
|
package/dist/model/index.d.ts
CHANGED
package/dist/model/index.js
CHANGED
|
@@ -20,3 +20,5 @@ __exportStar(require("./jsonview"), exports);
|
|
|
20
20
|
__exportStar(require("./tableview"), exports);
|
|
21
21
|
__exportStar(require("./networkview"), exports);
|
|
22
22
|
__exportStar(require("./apiview"), exports);
|
|
23
|
+
__exportStar(require("./panelview"), exports);
|
|
24
|
+
__exportStar(require("./overlay"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import BaseManage from './base';
|
|
2
|
+
import { IAnyObject, IOverlayConstructorOption } from '../types';
|
|
3
|
+
export declare class Overlay extends BaseManage {
|
|
4
|
+
key: string;
|
|
5
|
+
componentId: string;
|
|
6
|
+
props: IAnyObject;
|
|
7
|
+
constructor(opt: IOverlayConstructorOption);
|
|
8
|
+
get prefix(): string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createOverlay(opt: IOverlayConstructorOption): Overlay;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createOverlay = exports.Overlay = void 0;
|
|
22
|
+
var base_1 = __importDefault(require("./base"));
|
|
23
|
+
var Overlay = (function (_super) {
|
|
24
|
+
__extends(Overlay, _super);
|
|
25
|
+
function Overlay(opt) {
|
|
26
|
+
var _this = _super.call(this) || this;
|
|
27
|
+
_this.key = opt.key;
|
|
28
|
+
_this.componentId = opt.componentId;
|
|
29
|
+
_this.props = opt.props || {};
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(Overlay.prototype, "prefix", {
|
|
33
|
+
get: function () {
|
|
34
|
+
return 'debug:overlay-' + this.id;
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
return Overlay;
|
|
40
|
+
}(base_1.default));
|
|
41
|
+
exports.Overlay = Overlay;
|
|
42
|
+
function createOverlay(opt) {
|
|
43
|
+
return new Overlay(opt);
|
|
44
|
+
}
|
|
45
|
+
exports.createOverlay = createOverlay;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseManage from './base';
|
|
2
|
+
import { IAnyObject, IPanelViewConstructorOption } from '../types';
|
|
3
|
+
export declare class PanelView extends BaseManage {
|
|
4
|
+
readonly isPanelView: boolean;
|
|
5
|
+
key: string;
|
|
6
|
+
componentId: string;
|
|
7
|
+
title: string;
|
|
8
|
+
props: IAnyObject;
|
|
9
|
+
group: string;
|
|
10
|
+
constructor(opt: IPanelViewConstructorOption);
|
|
11
|
+
get prefix(): string;
|
|
12
|
+
}
|
|
13
|
+
export declare function createPanelView(opt: IPanelViewConstructorOption): PanelView;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createPanelView = exports.PanelView = void 0;
|
|
22
|
+
var base_1 = __importDefault(require("./base"));
|
|
23
|
+
var PanelView = (function (_super) {
|
|
24
|
+
__extends(PanelView, _super);
|
|
25
|
+
function PanelView(opt) {
|
|
26
|
+
var _this = _super.call(this) || this;
|
|
27
|
+
_this.isPanelView = true;
|
|
28
|
+
_this.group = '';
|
|
29
|
+
_this.key = opt.key;
|
|
30
|
+
_this.componentId = opt.componentId;
|
|
31
|
+
_this.title = opt.title;
|
|
32
|
+
_this.props = opt.props || {};
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(PanelView.prototype, "prefix", {
|
|
36
|
+
get: function () {
|
|
37
|
+
return 'debug:panelview-' + this.id;
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
return PanelView;
|
|
43
|
+
}(base_1.default));
|
|
44
|
+
exports.PanelView = PanelView;
|
|
45
|
+
function createPanelView(opt) {
|
|
46
|
+
return new PanelView(opt);
|
|
47
|
+
}
|
|
48
|
+
exports.createPanelView = createPanelView;
|
package/dist/store/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MySet } from '../base/set';
|
|
|
2
2
|
import { Store } from '../base/store';
|
|
3
3
|
import { Event } from '../base/event';
|
|
4
4
|
import { Group } from './group';
|
|
5
|
-
import { Badge, FormRule, JsonView, TableView, NetworkView, ApiView } from '../model/index';
|
|
5
|
+
import { Badge, FormRule, JsonView, TableView, NetworkView, ApiView, PanelView } from '../model/index';
|
|
6
6
|
declare const _default: {
|
|
7
7
|
sys: {
|
|
8
8
|
get: () => WechatMiniprogram.SystemInfo;
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
tableviews: MySet<TableView>;
|
|
16
16
|
networkviews: MySet<NetworkView>;
|
|
17
17
|
apiviews: MySet<ApiView>;
|
|
18
|
+
panelviews: MySet<PanelView>;
|
|
18
19
|
group: Group;
|
|
19
20
|
bridge: Store;
|
|
20
21
|
};
|
package/dist/store/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface IBadgeManageConstructorOption extends IBaseManageConstructorOpt
|
|
|
42
42
|
position?: IPosition;
|
|
43
43
|
styles?: string;
|
|
44
44
|
textOnly?: boolean;
|
|
45
|
+
type?: 'default' | 'launcher';
|
|
46
|
+
}
|
|
47
|
+
export interface ILauncherDotOption {
|
|
48
|
+
group?: string;
|
|
45
49
|
}
|
|
46
50
|
export type FormRuleType = 'button' | 'arrow' | 'switch';
|
|
47
51
|
export interface IFormRuleManageConstructorOption extends IBaseManageConstructorOption {
|
|
@@ -129,3 +133,49 @@ export interface IWedebugInitOption {
|
|
|
129
133
|
export interface IPluginInstance<T extends IAnyObject = IAnyObject> {
|
|
130
134
|
install(weDebug: T, ...args: any[]): void;
|
|
131
135
|
}
|
|
136
|
+
export interface IUIManifest {
|
|
137
|
+
npmDirname: string;
|
|
138
|
+
packages: {
|
|
139
|
+
[pkg: string]: {
|
|
140
|
+
components: {
|
|
141
|
+
[name: string]: string;
|
|
142
|
+
};
|
|
143
|
+
pages: string[];
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export interface IPanelViewConstructorOption {
|
|
148
|
+
key: string;
|
|
149
|
+
componentId: string;
|
|
150
|
+
title: string;
|
|
151
|
+
props?: IAnyObject;
|
|
152
|
+
}
|
|
153
|
+
export interface IAddPanelViewOption {
|
|
154
|
+
group?: IGroupOption;
|
|
155
|
+
}
|
|
156
|
+
export interface IUpdatePanelViewOption {
|
|
157
|
+
title?: string;
|
|
158
|
+
props?: IAnyObject;
|
|
159
|
+
}
|
|
160
|
+
export interface IOverlayConstructorOption {
|
|
161
|
+
key: string;
|
|
162
|
+
componentId: string;
|
|
163
|
+
props?: IAnyObject;
|
|
164
|
+
}
|
|
165
|
+
export interface IScopePanelOption {
|
|
166
|
+
component: string;
|
|
167
|
+
title: string;
|
|
168
|
+
props?: IAnyObject;
|
|
169
|
+
}
|
|
170
|
+
export interface IScopeOverlayOption {
|
|
171
|
+
component: string;
|
|
172
|
+
props?: IAnyObject;
|
|
173
|
+
}
|
|
174
|
+
export interface IScopeNavigateOption {
|
|
175
|
+
events?: IAnyObject;
|
|
176
|
+
}
|
|
177
|
+
export interface IPageOverlay {
|
|
178
|
+
overlayId: number;
|
|
179
|
+
componentId: string;
|
|
180
|
+
props: IAnyObject;
|
|
181
|
+
}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@we-debug/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "a useful debug tool for weapp",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "dlhandsome"
|
|
@@ -20,18 +20,24 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"preset": "ts-jest",
|
|
23
|
-
"testEnvironment": "node"
|
|
23
|
+
"testEnvironment": "node",
|
|
24
|
+
"moduleNameMapper": {
|
|
25
|
+
"^@we-debug/core$": "<rootDir>/src/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"globals": {
|
|
28
|
+
"__VERSION__": "test"
|
|
29
|
+
}
|
|
24
30
|
},
|
|
25
31
|
"license": "MIT",
|
|
26
32
|
"dependencies": {
|
|
27
|
-
"@we-debug/plugin-api": "0.
|
|
28
|
-
"@we-debug/plugin-appdata": "0.
|
|
29
|
-
"@we-debug/plugin-error": "0.
|
|
30
|
-
"@we-debug/plugin-launcher": "0.
|
|
31
|
-
"@we-debug/plugin-network": "0.
|
|
32
|
-
"@we-debug/plugin-router": "0.
|
|
33
|
-
"@we-debug/plugin-storage": "0.
|
|
34
|
-
"@we-debug/plugin-ui-check": "0.
|
|
33
|
+
"@we-debug/plugin-api": "0.51.0",
|
|
34
|
+
"@we-debug/plugin-appdata": "0.51.0",
|
|
35
|
+
"@we-debug/plugin-error": "0.51.0",
|
|
36
|
+
"@we-debug/plugin-launcher": "0.51.0",
|
|
37
|
+
"@we-debug/plugin-network": "0.51.0",
|
|
38
|
+
"@we-debug/plugin-router": "0.51.0",
|
|
39
|
+
"@we-debug/plugin-storage": "0.51.0",
|
|
40
|
+
"@we-debug/plugin-ui-check": "0.51.0",
|
|
35
41
|
"deepmerge": "^4.2.2"
|
|
36
42
|
},
|
|
37
43
|
"readme": "ERROR: No README data found!",
|
|
@@ -41,5 +47,5 @@
|
|
|
41
47
|
"@types/jest": "^29.5.11",
|
|
42
48
|
"ts-jest": "^29.1.1"
|
|
43
49
|
},
|
|
44
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "22641ac4972a154619c6dc8f44b1bfdcbb92c8eb"
|
|
45
51
|
}
|
package/test/ui.test.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import './wx';
|
|
2
|
+
import Debug from '../src/index';
|
|
3
|
+
|
|
4
|
+
const manifest = {
|
|
5
|
+
npmDirname: 'miniprogram_npm',
|
|
6
|
+
packages: {
|
|
7
|
+
'demo-plugin': {
|
|
8
|
+
components: { panel: 'c0', cashier: 'c1' },
|
|
9
|
+
pages: ['pages/feedback/index']
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let currentPageId = 'pageId:1';
|
|
15
|
+
(global as any).getCurrentPages = () => [{ getPageId: () => currentPageId }];
|
|
16
|
+
|
|
17
|
+
test('warns once when manifest is missing', () => {
|
|
18
|
+
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
19
|
+
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
20
|
+
const ui = Debug.scope('demo-plugin');
|
|
21
|
+
ui.createPanel({ component: 'panel', title: 'A' });
|
|
22
|
+
ui.createOverlay({ component: 'cashier' });
|
|
23
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
24
|
+
expect(error).not.toHaveBeenCalled();
|
|
25
|
+
warn.mockRestore();
|
|
26
|
+
error.mockRestore();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('with manifest', () => {
|
|
30
|
+
let ui: ReturnType<typeof Debug.scope>;
|
|
31
|
+
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
Debug.registerUIManifest(manifest);
|
|
34
|
+
ui = Debug.scope('demo-plugin');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('unknown component logs declared components and is not added', () => {
|
|
38
|
+
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
39
|
+
const panel = ui.createPanel({ component: 'missing', title: 'X' });
|
|
40
|
+
expect(panel.componentId).toBe('');
|
|
41
|
+
expect(error.mock.calls[0][0]).toContain('panel, cashier');
|
|
42
|
+
ui.addPanel(panel);
|
|
43
|
+
expect(Debug.store.panelviews.get()).not.toContain(panel);
|
|
44
|
+
error.mockRestore();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('panel add, update and remove within its group', () => {
|
|
48
|
+
const updates = jest.fn();
|
|
49
|
+
Debug.event.on('panelview:update', updates);
|
|
50
|
+
const panel = ui.createPanel({ component: 'panel', title: 'Mock', props: { n: 1 } });
|
|
51
|
+
expect(panel.key).toBe('demo-plugin/panel');
|
|
52
|
+
expect(panel.componentId).toBe('c0');
|
|
53
|
+
ui.addPanel(panel);
|
|
54
|
+
expect(Debug.store.group.get('Mock').get()).toContain(panel);
|
|
55
|
+
ui.updatePanel(panel, { props: { n: 2 } });
|
|
56
|
+
expect(panel.props).toEqual({ n: 2 });
|
|
57
|
+
ui.removePanel(panel);
|
|
58
|
+
expect(Debug.store.group.get('Mock').get()).not.toContain(panel);
|
|
59
|
+
expect(updates).toHaveBeenCalledTimes(3);
|
|
60
|
+
Debug.event.off('panelview:update', updates);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('adding the same panel twice does not leave a duplicate', () => {
|
|
64
|
+
const panel = ui.createPanel({ component: 'panel', title: 'Duplicate' });
|
|
65
|
+
ui.addPanel(panel);
|
|
66
|
+
ui.addPanel(panel);
|
|
67
|
+
ui.removePanel(panel);
|
|
68
|
+
expect(Debug.store.panelviews.get()).not.toContain(panel);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('moving a panel between groups removes it from the old group', () => {
|
|
72
|
+
const panel = ui.createPanel({ component: 'panel', title: 'Movable' });
|
|
73
|
+
ui.addPanel(panel, { group: { name: 'A' } });
|
|
74
|
+
ui.addPanel(panel, { group: { name: 'B' } });
|
|
75
|
+
ui.removePanel(panel);
|
|
76
|
+
expect(Debug.store.group.get('A').get()).not.toContain(panel);
|
|
77
|
+
expect(Debug.store.group.get('B').get()).not.toContain(panel);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('overlay is scoped to the page and resolves with close result', async () => {
|
|
81
|
+
currentPageId = 'pageId:1';
|
|
82
|
+
const overlay = ui.createOverlay({ component: 'cashier' });
|
|
83
|
+
const promise = ui.showOverlay(overlay, { amount: 1 });
|
|
84
|
+
expect(Debug.getPageOverlays('pageId:1')).toEqual([{ overlayId: overlay.id, componentId: 'c1', props: { amount: 1 } }]);
|
|
85
|
+
expect(Debug.getPageOverlays('pageId:2')).toEqual([]);
|
|
86
|
+
expect(ui.showOverlay(overlay, { amount: 2 })).toBe(promise);
|
|
87
|
+
expect(Debug.getPageOverlays('pageId:1')[0].props).toEqual({ amount: 2 });
|
|
88
|
+
Debug.closeOverlay('pageId:1', 'c1', { paid: true });
|
|
89
|
+
await expect(promise).resolves.toEqual({ paid: true });
|
|
90
|
+
expect(Debug.getPageOverlays('pageId:1')).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('hide, replace and page release resolve undefined', async () => {
|
|
94
|
+
currentPageId = 'pageId:3';
|
|
95
|
+
const a = ui.createOverlay({ component: 'cashier' });
|
|
96
|
+
const b = ui.createOverlay({ component: 'cashier' });
|
|
97
|
+
const pa = ui.showOverlay(a);
|
|
98
|
+
const pb = ui.showOverlay(b);
|
|
99
|
+
await expect(pa).resolves.toBeUndefined();
|
|
100
|
+
ui.hideOverlay(b);
|
|
101
|
+
await expect(pb).resolves.toBeUndefined();
|
|
102
|
+
const pc = ui.showOverlay(a);
|
|
103
|
+
const updates = jest.fn();
|
|
104
|
+
Debug.event.on('overlay:update', updates);
|
|
105
|
+
Debug.releasePageOverlays('pageId:3');
|
|
106
|
+
await expect(pc).resolves.toBeUndefined();
|
|
107
|
+
expect(Debug.getPageOverlays('pageId:3')).toEqual([]);
|
|
108
|
+
expect(updates).toHaveBeenCalledTimes(1);
|
|
109
|
+
Debug.event.off('overlay:update', updates);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('the same overlay can be shown independently on another page', () => {
|
|
113
|
+
currentPageId = 'pageId:A';
|
|
114
|
+
const overlay = ui.createOverlay({ component: 'cashier' });
|
|
115
|
+
const first = ui.showOverlay(overlay);
|
|
116
|
+
currentPageId = 'pageId:B';
|
|
117
|
+
const second = ui.showOverlay(overlay);
|
|
118
|
+
expect(second).not.toBe(first);
|
|
119
|
+
expect(Debug.getPageOverlays('pageId:B')).toEqual([
|
|
120
|
+
{ overlayId: overlay.id, componentId: 'c1', props: {} }
|
|
121
|
+
]);
|
|
122
|
+
Debug.releasePageOverlays('pageId:A');
|
|
123
|
+
Debug.releasePageOverlays('pageId:B');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('navigateTo builds the npm page url and rejects undeclared pages', async () => {
|
|
127
|
+
const navigateTo = jest.fn((opt: any) => opt.success({}));
|
|
128
|
+
(global as any).wx.navigateTo = navigateTo;
|
|
129
|
+
await ui.navigateTo('pages/feedback/index', { from: 'panel', omitted: undefined, n: 1 });
|
|
130
|
+
expect(navigateTo.mock.calls[0][0].url).toBe('/miniprogram_npm/demo-plugin/pages/feedback/index?from=panel&n=1');
|
|
131
|
+
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
132
|
+
await expect(ui.navigateTo('pages/none/index')).resolves.toBeUndefined();
|
|
133
|
+
expect(navigateTo).toHaveBeenCalledTimes(1);
|
|
134
|
+
error.mockRestore();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('navigateTo resolves undefined when wx.navigateTo throws', async () => {
|
|
138
|
+
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
139
|
+
(global as any).wx.navigateTo = () => {
|
|
140
|
+
throw new Error('navigate failed');
|
|
141
|
+
};
|
|
142
|
+
await expect(ui.navigateTo('pages/feedback/index')).resolves.toBeUndefined();
|
|
143
|
+
expect(error).toHaveBeenCalled();
|
|
144
|
+
error.mockRestore();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('createCache prefixes the package name', () => {
|
|
148
|
+
const cache: any = ui.createCache('config');
|
|
149
|
+
expect(cache.key).toBe('demo-plugin:config');
|
|
150
|
+
});
|
|
151
|
+
});
|