@hhfenpm/micro-app 1.0.6 → 1.0.7

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/dist/index.esm.js CHANGED
@@ -426,6 +426,22 @@ function baseSyncPlugin({
426
426
  }
427
427
  }
428
428
 
429
- var index = { initBridge, baseSyncPlugin };
429
+ function syncState(watch = {}) {
430
+ return function SYNC_STATE(state, payload) {
431
+ if (!payload || typeof payload !== 'object') return
432
+
433
+ Object.keys(watch).forEach(key => {
434
+ if (state[key] !== payload[key] && typeof watch[key] === 'function')
435
+ watch[key]({
436
+ store: this,
437
+ value: payload[key],
438
+ valueOld: state[key],
439
+ });
440
+ });
441
+ Object.keys(payload).forEach(key => {
442
+ if (state[key] !== payload[key]) state[key] = payload[key];
443
+ });
444
+ }
445
+ }
430
446
 
431
- export { baseSyncPlugin, createMicroAppCore, createRegisterHandlers, index as default, initBridge };
447
+ export { baseSyncPlugin, createMicroAppCore, createRegisterHandlers, initBridge, syncState };
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var uiHandler = vm => ({
6
4
  $message: (...args) => vm.$message(...args),
7
5
  $success: msg => vm.$message.success(msg),
@@ -430,10 +428,26 @@ function baseSyncPlugin({
430
428
  }
431
429
  }
432
430
 
433
- var index = { initBridge, baseSyncPlugin };
431
+ function syncState(watch = {}) {
432
+ return function SYNC_STATE(state, payload) {
433
+ if (!payload || typeof payload !== 'object') return
434
+
435
+ Object.keys(watch).forEach(key => {
436
+ if (state[key] !== payload[key] && typeof watch[key] === 'function')
437
+ watch[key]({
438
+ store: this,
439
+ value: payload[key],
440
+ valueOld: state[key],
441
+ });
442
+ });
443
+ Object.keys(payload).forEach(key => {
444
+ if (state[key] !== payload[key]) state[key] = payload[key];
445
+ });
446
+ }
447
+ }
434
448
 
435
449
  exports.baseSyncPlugin = baseSyncPlugin;
436
450
  exports.createMicroAppCore = createMicroAppCore;
437
451
  exports.createRegisterHandlers = createRegisterHandlers;
438
- exports.default = index;
439
452
  exports.initBridge = initBridge;
453
+ exports.syncState = syncState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hhfenpm/micro-app",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "微前端通信桥接和状态同步工具,支持父子应用通信、状态同步、生命周期管理",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",