@we-debug/plugin-appdata 0.43.4 → 0.44.2

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 CHANGED
@@ -3,6 +3,28 @@
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.44.2](https://github.com/dlhandsome/we-debug/compare/v0.44.1...v0.44.2) (2025-03-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fixed plugin appdata ([f961f60](https://github.com/dlhandsome/we-debug/commit/f961f60570c9cabecd9290448cd3a9ed1aa76f98))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.44.0](https://github.com/dlhandsome/we-debug/compare/v0.43.5...v0.44.0) (2025-03-10)
18
+
19
+
20
+ ### Features
21
+
22
+ * support json view update ([12c0822](https://github.com/dlhandsome/we-debug/commit/12c0822fd4d1c87e893a0a61e087d8e5f2975a09))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.43.4](https://github.com/dlhandsome/we-debug/compare/v0.43.3...v0.43.4) (2025-03-10)
7
29
 
8
30
 
package/dist/index.js CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  var APP_DATA_VIEW_CONFIG = {
4
15
  group: {
@@ -12,32 +23,32 @@ function getCurrentPage() {
12
23
  var pages = getCurrentPages();
13
24
  return pages.length > 0 ? pages[pages.length - 1] : null;
14
25
  }
15
- var currentRule;
26
+ function getJsonView(weDebug, page, options) {
27
+ var _a, _b;
28
+ return weDebug.createJsonView({
29
+ data: (page === null || page === void 0 ? void 0 : page.data) || {},
30
+ editable: (_a = options.editable) !== null && _a !== void 0 ? _a : true,
31
+ expandLevel: (_b = options.expandLevel) !== null && _b !== void 0 ? _b : 1,
32
+ handler: {
33
+ bindChange: function (data) {
34
+ var changeData = {};
35
+ data.changes.forEach(function (change) {
36
+ changeData[change.field] = change.value;
37
+ });
38
+ page === null || page === void 0 ? void 0 : page.setData(changeData);
39
+ }
40
+ }
41
+ });
42
+ }
16
43
  AppDataPlugin.install = function (weDebug, options) {
44
+ var currentJsonView = getJsonView(weDebug, {}, options);
45
+ weDebug.addJsonView(currentJsonView, APP_DATA_VIEW_CONFIG);
17
46
  weDebug.event.on('debug:mask:show-modal', function () {
18
- var _a, _b;
19
47
  var page = getCurrentPage();
20
48
  if (!page)
21
49
  return;
22
- var data = page.data || {};
23
- if (currentRule) {
24
- weDebug.removeJsonView(currentRule, APP_DATA_VIEW_CONFIG);
25
- }
26
- currentRule = weDebug.createJsonView({
27
- data: data,
28
- editable: (_a = options.editable) !== null && _a !== void 0 ? _a : true,
29
- expandLevel: (_b = options.expandLevel) !== null && _b !== void 0 ? _b : 1,
30
- handler: {
31
- bindChange: function (data) {
32
- var changeData = {};
33
- data.changes.forEach(function (change) {
34
- changeData[change.field] = change.value;
35
- });
36
- page.setData(changeData);
37
- }
38
- }
39
- });
40
- weDebug.addJsonView(currentRule, APP_DATA_VIEW_CONFIG);
50
+ var newJsonView = getJsonView(weDebug, page, options);
51
+ weDebug.updateJsonView(__assign(__assign({}, newJsonView), { id: currentJsonView.id }), APP_DATA_VIEW_CONFIG);
41
52
  });
42
53
  };
43
54
  exports.default = AppDataPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@we-debug/plugin-appdata",
3
- "version": "0.43.4",
3
+ "version": "0.44.2",
4
4
  "description": "> TODO: description",
5
5
  "author": "Sail <505441575@qq.com>",
6
6
  "homepage": "https://github.com/dlhandsome/we-debug/tree/master/packages/runtime/plugin-appdata#readme",
@@ -20,5 +20,5 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/dlhandsome/we-debug/issues"
22
22
  },
23
- "gitHead": "96b56563c8743eaccf33e7089370d8fe009d5ce0"
23
+ "gitHead": "3a4399d3b313fcc56a5e77ab0631a5602b9341b6"
24
24
  }
package/src/index.ts CHANGED
@@ -20,35 +20,38 @@ function getCurrentPage(): WechatMiniprogram.Page.Instance<any, any> | null {
20
20
  return pages.length > 0 ? pages[pages.length - 1] : null;
21
21
  }
22
22
 
23
- // 存储当前规则列表
24
- let currentRule: any;
23
+ function getJsonView (weDebug: IAnyObject, page: WechatMiniprogram.Page.Instance<any, any> | null, options: IPluginInitOptions) {
24
+ return weDebug.createJsonView({
25
+ data: page?.data || {},
26
+ editable: options.editable ?? true,
27
+ expandLevel: options.expandLevel ?? 1,
28
+ handler: {
29
+ bindChange(data: { changes: { field: string, value: IAnyObject }[] }) {
30
+ const changeData: IAnyObject = {};
31
+ data.changes.forEach((change) => {
32
+ changeData[change.field] = change.value;
33
+ });
34
+ page?.setData(changeData);
35
+ }
36
+ }
37
+ })
38
+ }
39
+
40
+ AppDataPlugin.install = function (weDebug, options: IPluginInitOptions) {
41
+ // 调试面板弹出时,触发规则更新
42
+ const currentJsonView = getJsonView(weDebug, {}, options);
43
+ weDebug.addJsonView(currentJsonView, APP_DATA_VIEW_CONFIG);
25
44
 
26
- AppDataPlugin.install = function (weDebug, options:IPluginInitOptions) {
27
- // 调试面板弹出时,触发规则更新
28
- weDebug.event.on('debug:mask:show-modal', () => {
45
+ weDebug.event.on('debug:mask:show-modal', () => {
29
46
  const page = getCurrentPage();
30
47
  if (!page) return;
31
- const data = page.data || {};
32
-
33
- if (currentRule) {
34
- weDebug.removeJsonView(currentRule, APP_DATA_VIEW_CONFIG);
35
- }
36
- currentRule = weDebug.createJsonView({
37
- data,
38
- editable: options.editable ?? true,
39
- expandLevel: options.expandLevel ?? 1,
40
- handler: {
41
- bindChange(data: { changes: { field: string, value: IAnyObject }[] }) {
42
- const changeData: IAnyObject = {};
43
- data.changes.forEach((change) => {
44
- changeData[change.field] = change.value;
45
- });
46
- page.setData(changeData);
47
- }
48
- }
49
- });
50
48
 
51
- weDebug.addJsonView(currentRule, APP_DATA_VIEW_CONFIG);
49
+ const newJsonView = getJsonView(weDebug, page, options);
50
+
51
+ weDebug.updateJsonView({
52
+ ...newJsonView,
53
+ id: currentJsonView.id
54
+ }, APP_DATA_VIEW_CONFIG);
52
55
  });
53
56
  }
54
57
 
package/dist/utils.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const showToast: (options: WechatMiniprogram.ShowToastOption) => Promise<void>;
2
- export declare const showModal: (options: WechatMiniprogram.ShowModalOption) => Promise<WechatMiniprogram.ShowModalSuccessCallbackResult>;
3
- export declare const showActionSheet: (options: WechatMiniprogram.ShowActionSheetOption) => Promise<WechatMiniprogram.ShowActionSheetSuccessCallbackResult>;
4
- export declare const setClipboardData: (data: string) => Promise<void>;
package/dist/utils.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.setClipboardData = exports.showActionSheet = exports.showModal = exports.showToast = void 0;
15
- var showToast = function (options) {
16
- return new Promise(function (resolve, reject) {
17
- wx.showToast(__assign(__assign({}, options), { success: function () { return resolve(); }, fail: reject }));
18
- });
19
- };
20
- exports.showToast = showToast;
21
- var showModal = function (options) {
22
- return new Promise(function (resolve, reject) {
23
- wx.showModal(__assign(__assign({}, options), { success: resolve, fail: reject }));
24
- });
25
- };
26
- exports.showModal = showModal;
27
- var showActionSheet = function (options) {
28
- return new Promise(function (resolve, reject) {
29
- wx.showActionSheet(__assign(__assign({}, options), { success: resolve, fail: reject }));
30
- });
31
- };
32
- exports.showActionSheet = showActionSheet;
33
- var setClipboardData = function (data) {
34
- return new Promise(function (resolve, reject) {
35
- wx.setClipboardData({
36
- data: data,
37
- success: function () { return resolve(); },
38
- fail: reject,
39
- });
40
- });
41
- };
42
- exports.setClipboardData = setClipboardData;