xctc-utils 1.6.33 → 1.6.34

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,6 @@
1
1
  export declare const $iframe: (id: string) => any;
2
2
  export declare const initParentDataToIframe: (id: string, keys?: string) => void;
3
3
  export declare const updateIframeReceiveData: (cb: any) => void;
4
+ export declare const sendIframeParentData: (sendData: any, url: string) => void;
4
5
  export declare const updateWeiXinShareReady: () => void;
5
6
  export declare const sendParentMessage: (data: any, url: string) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendParentMessage = exports.updateWeiXinShareReady = exports.updateIframeReceiveData = exports.initParentDataToIframe = exports.$iframe = void 0;
3
+ exports.sendParentMessage = exports.updateWeiXinShareReady = exports.sendIframeParentData = exports.updateIframeReceiveData = exports.initParentDataToIframe = exports.$iframe = void 0;
4
4
  var is_1 = require("../is");
5
5
  var weixin_1 = require("../weixin");
6
6
  var utils_1 = require("../utils");
@@ -58,6 +58,19 @@ var updateIframeReceiveData = function (cb) {
58
58
  });
59
59
  };
60
60
  exports.updateIframeReceiveData = updateIframeReceiveData;
61
+ var sendIframeParentData = function (sendData, url) {
62
+ if (!url) {
63
+ console.error("必须传入父页面的地址!");
64
+ return;
65
+ }
66
+ if ((0, is_1.isObject)(sendData)) {
67
+ win.parent.postMessage(JSON.stringify(sendData), url);
68
+ }
69
+ else {
70
+ console.error("返回父页面的数据必须是对象!");
71
+ }
72
+ };
73
+ exports.sendIframeParentData = sendIframeParentData;
61
74
  var updateWeiXinShareReady = function () {
62
75
  win.addEventListener('message', function (event) {
63
76
  var data = event.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.33",
3
+ "version": "1.6.34",
4
4
  "description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",