@instant-messengers/vk-teams-bridge 2.3.6 → 2.3.8

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/cjs/index.js CHANGED
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
19
  var __async = (__this, __arguments, generator) => {
22
20
  return new Promise((resolve, reject) => {
23
21
  var fulfilled = (value) => {
@@ -57,9 +55,7 @@ var BRIDGE_ERROR_TYPE = "BRIDGE_ERROR_TYPE";
57
55
  var BridgeError = class extends Error {
58
56
  constructor(code, reason) {
59
57
  super(`${code}: ${reason}`);
60
- __publicField(this, "_error_type_", BRIDGE_ERROR_TYPE);
61
- __publicField(this, "code");
62
- __publicField(this, "reason");
58
+ this._error_type_ = BRIDGE_ERROR_TYPE;
63
59
  this.code = code;
64
60
  this.reason = reason;
65
61
  }
@@ -144,6 +140,7 @@ var TeamsSendAction = /* @__PURE__ */ ((TeamsSendAction2) => {
144
140
  TeamsSendAction2["GetPlatformVersion"] = "GetPlatformVersion";
145
141
  TeamsSendAction2["GetMiniappConfig"] = "GetMiniappConfig";
146
142
  TeamsSendAction2["EnableLog"] = "EnableLog";
143
+ TeamsSendAction2["GetMiniappsSettings"] = "GetMiniappsSettings";
147
144
  return TeamsSendAction2;
148
145
  })(TeamsSendAction || {});
149
146
  var TeamsBridgeErrorCode = /* @__PURE__ */ ((TeamsBridgeErrorCode2) => {
@@ -175,16 +172,17 @@ var TeamsSubscribeAction = /* @__PURE__ */ ((TeamsSubscribeAction2) => {
175
172
  TeamsSubscribeAction2["Language"] = "Language";
176
173
  TeamsSubscribeAction2["BackButtonPressed"] = "BackButtonPressed";
177
174
  TeamsSubscribeAction2["ButtonPressed"] = "ButtonPressed";
175
+ TeamsSubscribeAction2["SettingChanged"] = "SettingChanged";
178
176
  return TeamsSubscribeAction2;
179
177
  })(TeamsSubscribeAction || {});
180
178
 
181
179
  // src/Bridge.ts
182
180
  var Bridge = class {
183
181
  constructor() {
184
- __publicField(this, "subscriptions", {});
185
- __publicField(this, "promises", {});
186
- __publicField(this, "enableLog", true);
187
- __publicField(this, "callBackHandlers", {
182
+ this.subscriptions = {};
183
+ this.promises = {};
184
+ this.enableLog = true;
185
+ this.callBackHandlers = {
188
186
  newEvent: (subscriptionId, eventAttributes) => {
189
187
  const callback = this.subscriptions[subscriptionId];
190
188
  if (!callback) {
@@ -193,8 +191,8 @@ var Bridge = class {
193
191
  }
194
192
  callback(eventAttributes);
195
193
  }
196
- });
197
- __publicField(this, "callFunction", (name, ...args) => {
194
+ };
195
+ this.callFunction = (name, ...args) => {
198
196
  const reqId = getUniqueId();
199
197
  const message = {
200
198
  type: "functionCall",
@@ -208,13 +206,13 @@ var Bridge = class {
208
206
  return new Promise((resolve, reject) => {
209
207
  this.promises[reqId] = [resolve, reject];
210
208
  });
211
- });
209
+ };
212
210
  /** Отправить событие в супер-апп */
213
- __publicField(this, "send", (action, payload) => {
211
+ this.send = (action, payload) => {
214
212
  return this.callFunction("send", action, payload);
215
- });
213
+ };
216
214
  /** Подписаться на событие из супер-апп */
217
- __publicField(this, "subscribe", (action, callback, params = null) => __async(this, null, function* () {
215
+ this.subscribe = (action, callback, params = null) => __async(this, null, function* () {
218
216
  const { subscriptionId } = yield this.callFunction(
219
217
  "subscribe",
220
218
  action,
@@ -222,9 +220,9 @@ var Bridge = class {
222
220
  );
223
221
  this.subscriptions[subscriptionId] = callback;
224
222
  return { unsubscribe: this.getUnsubscribe(subscriptionId) };
225
- }));
223
+ });
226
224
  /** Переопределить методы console что бы они отправляли логи в супер-апп */
227
- __publicField(this, "setupConsoleProxy", () => {
225
+ this.setupConsoleProxy = () => {
228
226
  const consoleMethodsNames = ["log", "warn", "info", "error"];
229
227
  const sendLog = this.sendLog.bind(this);
230
228
  consoleMethodsNames.forEach((method) => {
@@ -238,9 +236,9 @@ var Bridge = class {
238
236
  }
239
237
  });
240
238
  });
241
- });
239
+ };
242
240
  /** Функция отправки логов в супер-апп */
243
- __publicField(this, "sendLog", ({ text, type }) => {
241
+ this.sendLog = ({ text, type }) => {
244
242
  if (this.enableLog) {
245
243
  const reqId = getUniqueId();
246
244
  const message = {
@@ -253,20 +251,20 @@ var Bridge = class {
253
251
  };
254
252
  window.parent.postMessage(message, "*");
255
253
  }
256
- });
254
+ };
257
255
  /** Изменяем включени/выключение отправки логов в супер-апп */
258
- __publicField(this, "changeEnableLog", (_0) => __async(this, [_0], function* ({ enabled }) {
256
+ this.changeEnableLog = (_0) => __async(this, [_0], function* ({ enabled }) {
259
257
  this.enableLog = enabled;
260
258
  yield this.send("EnableLog" /* EnableLog */, {
261
259
  active: enabled
262
260
  });
263
- }));
264
- __publicField(this, "getUnsubscribe", (subscriptionId) => () => {
261
+ });
262
+ this.getUnsubscribe = (subscriptionId) => () => {
265
263
  if (subscriptionId in this.subscriptions) {
266
264
  delete this.subscriptions[subscriptionId];
267
265
  }
268
- });
269
- __publicField(this, "handleMessage", (event) => {
266
+ };
267
+ this.handleMessage = (event) => {
270
268
  const eventData = event.data;
271
269
  if (typeof eventData !== "object") {
272
270
  return;
@@ -279,8 +277,8 @@ var Bridge = class {
279
277
  this.handleCallBack(event, eventData.data);
280
278
  break;
281
279
  }
282
- });
283
- __publicField(this, "handleFunctionCallReply", (data) => {
280
+ };
281
+ this.handleFunctionCallReply = (data) => {
284
282
  const promise = this.promises[data.reqId];
285
283
  if (promise) {
286
284
  delete this.promises[data.reqId];
@@ -294,8 +292,8 @@ var Bridge = class {
294
292
  } else {
295
293
  logger.warn(`got reply to unknown function call with id ${data.reqId}`);
296
294
  }
297
- });
298
- __publicField(this, "handleCallBack", (event, data) => {
295
+ };
296
+ this.handleCallBack = (event, data) => {
299
297
  const callBackReply = ({ ok, err }) => {
300
298
  var _a;
301
299
  if (ok === void 0 === (err === void 0)) {
@@ -339,7 +337,7 @@ var Bridge = class {
339
337
  };
340
338
  }
341
339
  callBackReply(result);
342
- });
340
+ };
343
341
  window.addEventListener("message", this.handleMessage);
344
342
  if (window.self !== window.parent) {
345
343
  this.setupConsoleProxy();
package/dist/esm/index.js CHANGED
@@ -1,17 +1,36 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
1
22
  // src/error.ts
2
23
  var BRIDGE_ERROR_TYPE = "BRIDGE_ERROR_TYPE";
3
24
  var BridgeError = class extends Error {
4
- _error_type_ = BRIDGE_ERROR_TYPE;
5
- code;
6
- reason;
7
25
  constructor(code, reason) {
8
26
  super(`${code}: ${reason}`);
27
+ this._error_type_ = BRIDGE_ERROR_TYPE;
9
28
  this.code = code;
10
29
  this.reason = reason;
11
30
  }
12
31
  };
13
32
  var isBridgeError = (err) => {
14
- return err?._error_type_ === BRIDGE_ERROR_TYPE;
33
+ return (err == null ? void 0 : err._error_type_) === BRIDGE_ERROR_TYPE;
15
34
  };
16
35
 
17
36
  // src/types.ts
@@ -90,6 +109,7 @@ var TeamsSendAction = /* @__PURE__ */ ((TeamsSendAction2) => {
90
109
  TeamsSendAction2["GetPlatformVersion"] = "GetPlatformVersion";
91
110
  TeamsSendAction2["GetMiniappConfig"] = "GetMiniappConfig";
92
111
  TeamsSendAction2["EnableLog"] = "EnableLog";
112
+ TeamsSendAction2["GetMiniappsSettings"] = "GetMiniappsSettings";
93
113
  return TeamsSendAction2;
94
114
  })(TeamsSendAction || {});
95
115
  var TeamsBridgeErrorCode = /* @__PURE__ */ ((TeamsBridgeErrorCode2) => {
@@ -121,175 +141,177 @@ var TeamsSubscribeAction = /* @__PURE__ */ ((TeamsSubscribeAction2) => {
121
141
  TeamsSubscribeAction2["Language"] = "Language";
122
142
  TeamsSubscribeAction2["BackButtonPressed"] = "BackButtonPressed";
123
143
  TeamsSubscribeAction2["ButtonPressed"] = "ButtonPressed";
144
+ TeamsSubscribeAction2["SettingChanged"] = "SettingChanged";
124
145
  return TeamsSubscribeAction2;
125
146
  })(TeamsSubscribeAction || {});
126
147
 
127
148
  // src/Bridge.ts
128
149
  var Bridge = class {
129
- subscriptions = {};
130
- promises = {};
131
- enableLog = true;
132
- callBackHandlers = {
133
- newEvent: (subscriptionId, eventAttributes) => {
134
- const callback = this.subscriptions[subscriptionId];
135
- if (!callback) {
136
- logger.warn(`no subscription found with id ${subscriptionId}`);
137
- return;
138
- }
139
- callback(eventAttributes);
140
- }
141
- };
142
150
  constructor() {
143
- window.addEventListener("message", this.handleMessage);
144
- if (window.self !== window.parent) {
145
- this.setupConsoleProxy();
146
- }
147
- }
148
- callFunction = (name, ...args) => {
149
- const reqId = getUniqueId();
150
- const message = {
151
- type: "functionCall",
152
- data: {
153
- reqId,
154
- name,
155
- args
151
+ this.subscriptions = {};
152
+ this.promises = {};
153
+ this.enableLog = true;
154
+ this.callBackHandlers = {
155
+ newEvent: (subscriptionId, eventAttributes) => {
156
+ const callback = this.subscriptions[subscriptionId];
157
+ if (!callback) {
158
+ logger.warn(`no subscription found with id ${subscriptionId}`);
159
+ return;
160
+ }
161
+ callback(eventAttributes);
156
162
  }
157
163
  };
158
- window.parent.postMessage(message, "*");
159
- return new Promise((resolve, reject) => {
160
- this.promises[reqId] = [resolve, reject];
161
- });
162
- };
163
- /** Отправить событие в супер-апп */
164
- send = (action, payload) => {
165
- return this.callFunction("send", action, payload);
166
- };
167
- /** Подписаться на событие из супер-апп */
168
- subscribe = async (action, callback, params = null) => {
169
- const { subscriptionId } = await this.callFunction(
170
- "subscribe",
171
- action,
172
- params
173
- );
174
- this.subscriptions[subscriptionId] = callback;
175
- return { unsubscribe: this.getUnsubscribe(subscriptionId) };
176
- };
177
- /** Переопределить методы console что бы они отправляли логи в супер-апп */
178
- setupConsoleProxy = () => {
179
- const consoleMethodsNames = ["log", "warn", "info", "error"];
180
- const sendLog = this.sendLog.bind(this);
181
- consoleMethodsNames.forEach((method) => {
182
- window.console[method] = new Proxy(console[method], {
183
- apply(target, ctx, args) {
184
- sendLog({
185
- type: method,
186
- text: getStringFromLogParams(args)
187
- });
188
- Reflect.apply(target, ctx, [...args]);
189
- }
190
- });
191
- });
192
- };
193
- /** Функция отправки логов в супер-апп */
194
- sendLog = ({ text, type }) => {
195
- if (this.enableLog) {
164
+ this.callFunction = (name, ...args) => {
196
165
  const reqId = getUniqueId();
197
166
  const message = {
198
- type: "sendLog",
167
+ type: "functionCall",
199
168
  data: {
200
169
  reqId,
201
- name: "sendLog",
202
- logData: { text, type }
170
+ name,
171
+ args
203
172
  }
204
173
  };
205
174
  window.parent.postMessage(message, "*");
206
- }
207
- };
208
- /** Изменяем включени/выключение отправки логов в супер-апп */
209
- changeEnableLog = async ({ enabled }) => {
210
- this.enableLog = enabled;
211
- await this.send("EnableLog" /* EnableLog */, {
212
- active: enabled
175
+ return new Promise((resolve, reject) => {
176
+ this.promises[reqId] = [resolve, reject];
177
+ });
178
+ };
179
+ /** Отправить событие в супер-апп */
180
+ this.send = (action, payload) => {
181
+ return this.callFunction("send", action, payload);
182
+ };
183
+ /** Подписаться на событие из супер-апп */
184
+ this.subscribe = (action, callback, params = null) => __async(this, null, function* () {
185
+ const { subscriptionId } = yield this.callFunction(
186
+ "subscribe",
187
+ action,
188
+ params
189
+ );
190
+ this.subscriptions[subscriptionId] = callback;
191
+ return { unsubscribe: this.getUnsubscribe(subscriptionId) };
213
192
  });
214
- };
215
- getUnsubscribe = (subscriptionId) => () => {
216
- if (subscriptionId in this.subscriptions) {
217
- delete this.subscriptions[subscriptionId];
218
- }
219
- };
220
- handleMessage = (event) => {
221
- const eventData = event.data;
222
- if (typeof eventData !== "object") {
223
- return;
224
- }
225
- switch (eventData.type) {
226
- case "functionCallReply":
227
- this.handleFunctionCallReply(eventData.data);
228
- break;
229
- case "callBack":
230
- this.handleCallBack(event, eventData.data);
231
- break;
232
- }
233
- };
234
- handleFunctionCallReply = (data) => {
235
- const promise = this.promises[data.reqId];
236
- if (promise) {
237
- delete this.promises[data.reqId];
238
- const [resolve, reject] = promise;
239
- if (data.ok !== void 0) {
240
- resolve(data.ok);
241
- } else {
242
- logger.warn(`rejecting req ${data.reqId} promise: ${JSON.stringify(data.err)}`);
243
- reject(data.err);
244
- }
245
- } else {
246
- logger.warn(`got reply to unknown function call with id ${data.reqId}`);
247
- }
248
- };
249
- handleCallBack = (event, data) => {
250
- const callBackReply = ({ ok, err }) => {
251
- if (ok === void 0 === (err === void 0)) {
252
- return callBackReply({
253
- reqId: data.reqId,
254
- err: {
255
- code: "INTERNAL_ERROR" /* INTERNAL_ERROR */,
256
- reason: "callBack handler protocol violation"
193
+ /** Переопределить методы console что бы они отправляли логи в супер-апп */
194
+ this.setupConsoleProxy = () => {
195
+ const consoleMethodsNames = ["log", "warn", "info", "error"];
196
+ const sendLog = this.sendLog.bind(this);
197
+ consoleMethodsNames.forEach((method) => {
198
+ window.console[method] = new Proxy(console[method], {
199
+ apply(target, ctx, args) {
200
+ sendLog({
201
+ type: method,
202
+ text: getStringFromLogParams(args)
203
+ });
204
+ Reflect.apply(target, ctx, [...args]);
257
205
  }
258
206
  });
207
+ });
208
+ };
209
+ /** Функция отправки логов в супер-апп */
210
+ this.sendLog = ({ text, type }) => {
211
+ if (this.enableLog) {
212
+ const reqId = getUniqueId();
213
+ const message = {
214
+ type: "sendLog",
215
+ data: {
216
+ reqId,
217
+ name: "sendLog",
218
+ logData: { text, type }
219
+ }
220
+ };
221
+ window.parent.postMessage(message, "*");
259
222
  }
260
- const message = {
261
- type: "callBackReply",
262
- data: {
263
- reqId: data.reqId,
264
- ok,
265
- err
266
- }
267
- };
268
- event.source?.postMessage(message, event.origin);
269
223
  };
270
- const result = {
271
- reqId: data.reqId
224
+ /** Изменяем включени/выключение отправки логов в супер-апп */
225
+ this.changeEnableLog = (_0) => __async(this, [_0], function* ({ enabled }) {
226
+ this.enableLog = enabled;
227
+ yield this.send("EnableLog" /* EnableLog */, {
228
+ active: enabled
229
+ });
230
+ });
231
+ this.getUnsubscribe = (subscriptionId) => () => {
232
+ if (subscriptionId in this.subscriptions) {
233
+ delete this.subscriptions[subscriptionId];
234
+ }
272
235
  };
273
- try {
274
- const callback = this.callBackHandlers[data.name];
275
- if (!callback) {
276
- const reason = `got callBack request with unknown name "${data.name}"`;
277
- logger.warn(reason);
278
- throw new BridgeError("BAD_REQUEST" /* BAD_REQUEST */, reason);
236
+ this.handleMessage = (event) => {
237
+ const eventData = event.data;
238
+ if (typeof eventData !== "object") {
239
+ return;
279
240
  }
280
- result.ok = callback(...data.args) || null;
281
- } catch (e) {
282
- let reason = isBridgeError(e) ? e.reason : "callBack handler raised an exception";
283
- if (e instanceof Error) {
284
- reason += ` "${e.name}": "${e.message}"`;
241
+ switch (eventData.type) {
242
+ case "functionCallReply":
243
+ this.handleFunctionCallReply(eventData.data);
244
+ break;
245
+ case "callBack":
246
+ this.handleCallBack(event, eventData.data);
247
+ break;
285
248
  }
286
- result.err = {
287
- code: isBridgeError(e) ? e.code : "INTERNAL_ERROR" /* INTERNAL_ERROR */,
288
- reason
249
+ };
250
+ this.handleFunctionCallReply = (data) => {
251
+ const promise = this.promises[data.reqId];
252
+ if (promise) {
253
+ delete this.promises[data.reqId];
254
+ const [resolve, reject] = promise;
255
+ if (data.ok !== void 0) {
256
+ resolve(data.ok);
257
+ } else {
258
+ logger.warn(`rejecting req ${data.reqId} promise: ${JSON.stringify(data.err)}`);
259
+ reject(data.err);
260
+ }
261
+ } else {
262
+ logger.warn(`got reply to unknown function call with id ${data.reqId}`);
263
+ }
264
+ };
265
+ this.handleCallBack = (event, data) => {
266
+ const callBackReply = ({ ok, err }) => {
267
+ var _a;
268
+ if (ok === void 0 === (err === void 0)) {
269
+ return callBackReply({
270
+ reqId: data.reqId,
271
+ err: {
272
+ code: "INTERNAL_ERROR" /* INTERNAL_ERROR */,
273
+ reason: "callBack handler protocol violation"
274
+ }
275
+ });
276
+ }
277
+ const message = {
278
+ type: "callBackReply",
279
+ data: {
280
+ reqId: data.reqId,
281
+ ok,
282
+ err
283
+ }
284
+ };
285
+ (_a = event.source) == null ? void 0 : _a.postMessage(message, event.origin);
286
+ };
287
+ const result = {
288
+ reqId: data.reqId
289
289
  };
290
+ try {
291
+ const callback = this.callBackHandlers[data.name];
292
+ if (!callback) {
293
+ const reason = `got callBack request with unknown name "${data.name}"`;
294
+ logger.warn(reason);
295
+ throw new BridgeError("BAD_REQUEST" /* BAD_REQUEST */, reason);
296
+ }
297
+ result.ok = callback(...data.args) || null;
298
+ } catch (e) {
299
+ let reason = isBridgeError(e) ? e.reason : "callBack handler raised an exception";
300
+ if (e instanceof Error) {
301
+ reason += ` "${e.name}": "${e.message}"`;
302
+ }
303
+ result.err = {
304
+ code: isBridgeError(e) ? e.code : "INTERNAL_ERROR" /* INTERNAL_ERROR */,
305
+ reason
306
+ };
307
+ }
308
+ callBackReply(result);
309
+ };
310
+ window.addEventListener("message", this.handleMessage);
311
+ if (window.self !== window.parent) {
312
+ this.setupConsoleProxy();
290
313
  }
291
- callBackReply(result);
292
- };
314
+ }
293
315
  };
294
316
  export {
295
317
  BaseBridgeErrorCode,
@@ -1 +1 @@
1
- "use strict";var VKTBridge=(function(){var I=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var it=function(t,e){for(var o in e)I(t,o,{get:e[o],enumerable:!0})},ut=function(t,e,o,a){if(e&&typeof e=="object"||typeof e=="function")for(var r=ot(e),n=0,i=r.length,c;n<i;n++)c=r[n],!at.call(t,c)&&c!==o&&I(t,c,{get:function(f){return e[f]}.bind(null,c),enumerable:!(a=nt(e,c))||a.enumerable});return t};var ct=function(t){return ut(I({},"__esModule",{value:!0}),t)};var _t={};it(_t,{instance:function(){return A},send:function(){return ft},subscribe:function(){return st}});function F(t,e,o,a,r,n,i){try{var c=t[n](i),f=c.value}catch(u){o(u);return}c.done?e(f):Promise.resolve(f).then(a,r)}function N(t){return function(){var e=this,o=arguments;return new Promise(function(a,r){var n=t.apply(e,o);function i(f){F(n,a,r,i,c,"next",f)}function c(f){F(n,a,r,i,c,"throw",f)}i(void 0)})}}function d(t,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):d(t,e)}function E(t,e){if(!d(t,e))throw new TypeError("Cannot call a class as a function")}function s(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function T(t){if(Array.isArray(t))return t}function M(t,e){var o=t==null?null:typeof Symbol!="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var a=[],r=!0,n=!1,i,c;try{for(o=o.call(t);!(r=(i=o.next()).done)&&(a.push(i.value),!(e&&a.length===e));r=!0);}catch(f){n=!0,c=f}finally{try{!r&&o.return!=null&&o.return()}finally{if(n)throw c}}return a}}function B(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,a=new Array(e);o<e;o++)a[o]=t[o];return a}function x(t,e){if(t){if(typeof t=="string")return w(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);if(o==="Object"&&t.constructor&&(o=t.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return w(t,e)}}function C(t,e){return T(t)||M(t,e)||x(t,e)||B()}function k(t){if(Array.isArray(t))return w(t)}function q(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function K(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t){return k(t)||q(t)||x(t)||K()}function m(t){"@swc/helpers - typeof";return t&&typeof Symbol!="undefined"&&t.constructor===Symbol?"symbol":typeof t}function S(t,e){var o={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},a,r,n,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(u){return function(_){return f([u,_])}}function f(u){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(a=1,r&&(n=u[0]&2?r.return:u[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,u[1])).done)return n;switch(r=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(n=o.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){o.label=u[1];break}if(u[0]===6&&o.label<n[1]){o.label=n[1],n=u;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(u);break}n[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(_){u=[6,_],r=0}finally{a=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},y(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!t})()}function V(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Y(t,e){return e&&(m(e)==="object"||typeof e=="function")?e:V(t)}function W(t,e,o){return e=y(e),Y(t,g()?Reflect.construct(e,o||[],y(t).constructor):e.apply(t,o))}function p(t,e){return p=Object.setPrototypeOf||function(a,r){return a.__proto__=r,a},p(t,e)}function H(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}function O(t,e,o){return g()?O=Reflect.construct:O=function(r,n,i){var c=[null];c.push.apply(c,n);var f=Function.bind.apply(r,c),u=new f;return i&&p(u,i.prototype),u},O.apply(null,arguments)}function Q(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function R(t){var e=typeof Map=="function"?new Map:void 0;return R=function(a){if(a===null||!Q(a))return a;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(a))return e.get(a);e.set(a,r)}function r(){return O(a,arguments,y(this).constructor)}return r.prototype=Object.create(a.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,a)},R(t)}var z="BRIDGE_ERROR_TYPE",J=function(t){"use strict";H(e,t);function e(o,a){E(this,e);var r;return r=W(this,e,["".concat(o,": ").concat(a)]),s(r,"_error_type_",z),s(r,"code",void 0),s(r,"reason",void 0),r.code=o,r.reason=a,r}return e}(R(Error)),L=function(t){return(t==null?void 0:t._error_type_)===z};var b;(function(t){t.BAD_REQUEST="BAD_REQUEST",t.NETWORK_ERROR="NETWORK_ERROR",t.INTERNAL_ERROR="INTERNAL_ERROR",t.UNKNOWN_SUBSCRIPTION_NAME="UNKNOWN_SUBSCRIPTION_NAME"})(b||(b={}));function j(){if("crypto"in window&&window.crypto.randomUUID)return window.crypto.randomUUID();for(var t=new Date().getTime(),e=97,o=122,a="",r=0;r<30;r++){var n=Math.floor(Math.random()*(o-e+1))+e,i=String.fromCharCode(n);a+=i}return"".concat(t).concat(a)}var X=function(t){return"[Bridge]: ".concat(t)},v={log:function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var r;(r=console).log.apply(r,[X(t)].concat(h(o)))},warn:function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var r;(r=console).warn.apply(r,[X(t)].concat(h(o)))}};var Z=function(t){return t.map(function(e){return(typeof e=="undefined"?"undefined":m(e))==="object"?JSON.stringify(e):String(e)}).join(" ")};var P;(function(t){t.LoadingCompleted="LoadingCompleted",t.OpenProfile="OpenProfile",t.OpenDialog="OpenDialog",t.OpenThread="OpenThread",t.ForwardTask="ForwardTask",t.SetTitle="SetTitle",t.SetBadge="SetBadge",t.OpenLink="OpenLink",t.ShowToast="ShowToast",t.GetThemeSettings="GetThemeSettings",t.GetMiniAppShareLink="GetMiniAppShareLink",t.GetLanguage="GetLanguage",t.OpenPopUp="OpenPopUp",t.StoragePut="StoragePut",t.StorageGet="StorageGet",t.StorageDelete="StorageDelete",t.StorageClear="StorageClear",t.StartAudioCall="StartAudioCall",t.StartVideoCall="StartVideoCall",t.OpenAuthModal="OpenAuthModal",t.SetCanGoBack="SetCanGoBack",t.SetCanNotGoBack="SetCanNotGoBack",t.OpenContactSelectionDialog="OpenContactSelectionDialog",t.SetButtonGroup="SetButtonGroup",t.GetSelfId="GetSelfId",t.DownloadFile="DownloadFile",t.CreateChat="CreateChat",t.ForwardSurvey="ForwardSurvey",t.GetAuth="GetAuth",t.GetPlatformVersion="GetPlatformVersion",t.GetMiniappConfig="GetMiniappConfig",t.EnableLog="EnableLog"})(P||(P={}));var $;(function(t){t.ALREADY_CALLED="ALREADY_CALLED",t.PROFILE_NOT_FOUND="PROFILE_NOT_FOUND",t.DIALOG_NOT_FOUND="DIALOG_NOT_FOUND",t.THREAD_NOT_FOUND="THREAD_NOT_FOUND",t.POPUP_CLOSED="POPUP_CLOSED",t.KEY_IS_TOO_LARGE="KEY_IS_TOO_LARGE",t.VALUE_IS_TOO_LARGE="VALUE_IS_TOO_LARGE",t.TOTAL_LIMIT_EXCEEDED="TOTAL_LIMIT_EXCEEDED",t.INVALID_KEY="INVALID_KEY",t.INVALID_VALUE="INVALID_VALUE",t.KEY_NOT_FOUND="KEY_NOT_FOUND",t.USER_NOT_FOUND="USER_NOT_FOUND",t.MODAL_CLOSED="MODAL_CLOSED",t.UNKNOWN_GROUP="UNKNOWN_GROUP",t.UNKNOWN_ICON="UNKNOWN_ICON",t.CALLBACK_DATA_TOO_LARGE="CALLBACK_DATA_TOO_LARGE",t.TOO_MANY_BUTTONS="TOO_MANY_BUTTONS",t.CREATE_FAILED="CREATE_FAILED",t.UNAUTHTORIZED="401",t.FORBIDDEN="403",t.SERVER_ERROR="500"})($||($={}));var tt;(function(t){t.ThemeSettings="ThemeSettings",t.Language="Language",t.BackButtonPressed="BackButtonPressed",t.ButtonPressed="ButtonPressed"})(tt||(tt={}));var et=function t(){"use strict";var e=this,o=this;E(this,t);var a=this;s(this,"subscriptions",{}),s(this,"promises",{}),s(this,"enableLog",!0),s(this,"callBackHandlers",{newEvent:function(r,n){var i=e.subscriptions[r];if(!i){v.warn("no subscription found with id ".concat(r));return}i(n)}}),s(this,"callFunction",function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),c=1;c<n;c++)i[c-1]=arguments[c];var f=j(),u={type:"functionCall",data:{reqId:f,name:r,args:i}};return window.parent.postMessage(u,"*"),new Promise(function(_,l){o.promises[f]=[_,l]})}),s(this,"send",function(r,n){return e.callFunction("send",r,n)}),s(this,"subscribe",function(){var r=N(function(n,i){var c,f,u=arguments;return S(this,function(_){switch(_.label){case 0:return c=u.length>2&&u[2]!==void 0?u[2]:null,[4,a.callFunction("subscribe",n,c)];case 1:return f=_.sent().subscriptionId,a.subscriptions[f]=i,[2,{unsubscribe:a.getUnsubscribe(f)}]}})});return function(n,i){return r.apply(this,arguments)}}()),s(this,"setupConsoleProxy",function(){var r=["log","warn","info","error"],n=e.sendLog.bind(e);r.forEach(function(i){window.console[i]=new Proxy(console[i],{apply:function(f,u,_){n({type:i,text:Z(_)}),Reflect.apply(f,u,h(_))}})})}),s(this,"sendLog",function(r){var n=r.text,i=r.type;if(e.enableLog){var c=j(),f={type:"sendLog",data:{reqId:c,name:"sendLog",logData:{text:n,type:i}}};window.parent.postMessage(f,"*")}}),s(this,"changeEnableLog",function(){var r=N(function(n){var i;return S(this,function(c){switch(c.label){case 0:return i=n.enabled,a.enableLog=i,[4,a.send(P.EnableLog,{active:i})];case 1:return c.sent(),[2]}})});return function(n){return r.apply(this,arguments)}}()),s(this,"getUnsubscribe",function(r){return function(){r in e.subscriptions&&delete e.subscriptions[r]}}),s(this,"handleMessage",function(r){var n=r.data;if((typeof n=="undefined"?"undefined":m(n))==="object")switch(n.type){case"functionCallReply":e.handleFunctionCallReply(n.data);break;case"callBack":e.handleCallBack(r,n.data);break}}),s(this,"handleFunctionCallReply",function(r){var n=e.promises[r.reqId];if(n){delete e.promises[r.reqId];var i=C(n,2),c=i[0],f=i[1];r.ok!==void 0?c(r.ok):(v.warn("rejecting req ".concat(r.reqId," promise: ").concat(JSON.stringify(r.err))),f(r.err))}else v.warn("got reply to unknown function call with id ".concat(r.reqId))}),s(this,"handleCallBack",function(r,n){var i=function(l){var U=l.ok,G=l.err,D;if(U===void 0==(G===void 0))return i({reqId:n.reqId,err:{code:b.INTERNAL_ERROR,reason:"callBack handler protocol violation"}});var rt={type:"callBackReply",data:{reqId:n.reqId,ok:U,err:G}};(D=r.source)===null||D===void 0||D.postMessage(rt,r.origin)},c={reqId:n.reqId};try{var f=e.callBackHandlers[n.name];if(!f){var u='got callBack request with unknown name "'.concat(n.name,'"');throw v.warn(u),new J(b.BAD_REQUEST,u)}c.ok=f.apply(void 0,h(n.args))||null}catch(l){var _=L(l)?l.reason:"callBack handler raised an exception";d(l,Error)&&(_+=' "'.concat(l.name,'": "').concat(l.message,'"')),c.err={code:L(l)?l.code:b.INTERNAL_ERROR,reason:_}}i(c)}),window.addEventListener("message",this.handleMessage),window.self!==window.parent&&this.setupConsoleProxy()};var A=new et,ft=A.send,st=A.subscribe;return ct(_t);})();
1
+ "use strict";var VKTBridge=(function(){var I=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var it=function(t,e){for(var o in e)I(t,o,{get:e[o],enumerable:!0})},ut=function(t,e,o,a){if(e&&typeof e=="object"||typeof e=="function")for(var r=ot(e),n=0,i=r.length,c;n<i;n++)c=r[n],!at.call(t,c)&&c!==o&&I(t,c,{get:function(f){return e[f]}.bind(null,c),enumerable:!(a=nt(e,c))||a.enumerable});return t};var ct=function(t){return ut(I({},"__esModule",{value:!0}),t)};var _t={};it(_t,{instance:function(){return A},send:function(){return ft},subscribe:function(){return st}});function F(t,e,o,a,r,n,i){try{var c=t[n](i),f=c.value}catch(u){o(u);return}c.done?e(f):Promise.resolve(f).then(a,r)}function N(t){return function(){var e=this,o=arguments;return new Promise(function(a,r){var n=t.apply(e,o);function i(f){F(n,a,r,i,c,"next",f)}function c(f){F(n,a,r,i,c,"throw",f)}i(void 0)})}}function d(t,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):d(t,e)}function E(t,e){if(!d(t,e))throw new TypeError("Cannot call a class as a function")}function s(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function T(t){if(Array.isArray(t))return t}function M(t,e){var o=t==null?null:typeof Symbol!="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var a=[],r=!0,n=!1,i,c;try{for(o=o.call(t);!(r=(i=o.next()).done)&&(a.push(i.value),!(e&&a.length===e));r=!0);}catch(f){n=!0,c=f}finally{try{!r&&o.return!=null&&o.return()}finally{if(n)throw c}}return a}}function B(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,a=new Array(e);o<e;o++)a[o]=t[o];return a}function x(t,e){if(t){if(typeof t=="string")return g(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);if(o==="Object"&&t.constructor&&(o=t.constructor.name),o==="Map"||o==="Set")return Array.from(o);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return g(t,e)}}function C(t,e){return T(t)||M(t,e)||x(t,e)||B()}function k(t){if(Array.isArray(t))return g(t)}function q(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function K(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t){return k(t)||q(t)||x(t)||K()}function m(t){"@swc/helpers - typeof";return t&&typeof Symbol!="undefined"&&t.constructor===Symbol?"symbol":typeof t}function S(t,e){var o={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},a,r,n,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(u){return function(_){return f([u,_])}}function f(u){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(a=1,r&&(n=u[0]&2?r.return:u[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,u[1])).done)return n;switch(r=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(n=o.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){o.label=u[1];break}if(u[0]===6&&o.label<n[1]){o.label=n[1],n=u;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(u);break}n[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(_){u=[6,_],r=0}finally{a=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},y(t)}function w(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!t})()}function V(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Y(t,e){return e&&(m(e)==="object"||typeof e=="function")?e:V(t)}function W(t,e,o){return e=y(e),Y(t,w()?Reflect.construct(e,o||[],y(t).constructor):e.apply(t,o))}function p(t,e){return p=Object.setPrototypeOf||function(a,r){return a.__proto__=r,a},p(t,e)}function H(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}function O(t,e,o){return w()?O=Reflect.construct:O=function(r,n,i){var c=[null];c.push.apply(c,n);var f=Function.bind.apply(r,c),u=new f;return i&&p(u,i.prototype),u},O.apply(null,arguments)}function Q(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function R(t){var e=typeof Map=="function"?new Map:void 0;return R=function(a){if(a===null||!Q(a))return a;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(a))return e.get(a);e.set(a,r)}function r(){return O(a,arguments,y(this).constructor)}return r.prototype=Object.create(a.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,a)},R(t)}var z="BRIDGE_ERROR_TYPE",J=function(t){"use strict";H(e,t);function e(o,a){E(this,e);var r;return r=W(this,e,["".concat(o,": ").concat(a)]),s(r,"_error_type_",z),s(r,"code",void 0),s(r,"reason",void 0),r.code=o,r.reason=a,r}return e}(R(Error)),L=function(t){return(t==null?void 0:t._error_type_)===z};var b;(function(t){t.BAD_REQUEST="BAD_REQUEST",t.NETWORK_ERROR="NETWORK_ERROR",t.INTERNAL_ERROR="INTERNAL_ERROR",t.UNKNOWN_SUBSCRIPTION_NAME="UNKNOWN_SUBSCRIPTION_NAME"})(b||(b={}));function j(){if("crypto"in window&&window.crypto.randomUUID)return window.crypto.randomUUID();for(var t=new Date().getTime(),e=97,o=122,a="",r=0;r<30;r++){var n=Math.floor(Math.random()*(o-e+1))+e,i=String.fromCharCode(n);a+=i}return"".concat(t).concat(a)}var X=function(t){return"[Bridge]: ".concat(t)},v={log:function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var r;(r=console).log.apply(r,[X(t)].concat(h(o)))},warn:function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var r;(r=console).warn.apply(r,[X(t)].concat(h(o)))}};var Z=function(t){return t.map(function(e){return(typeof e=="undefined"?"undefined":m(e))==="object"?JSON.stringify(e):String(e)}).join(" ")};var P;(function(t){t.LoadingCompleted="LoadingCompleted",t.OpenProfile="OpenProfile",t.OpenDialog="OpenDialog",t.OpenThread="OpenThread",t.ForwardTask="ForwardTask",t.SetTitle="SetTitle",t.SetBadge="SetBadge",t.OpenLink="OpenLink",t.ShowToast="ShowToast",t.GetThemeSettings="GetThemeSettings",t.GetMiniAppShareLink="GetMiniAppShareLink",t.GetLanguage="GetLanguage",t.OpenPopUp="OpenPopUp",t.StoragePut="StoragePut",t.StorageGet="StorageGet",t.StorageDelete="StorageDelete",t.StorageClear="StorageClear",t.StartAudioCall="StartAudioCall",t.StartVideoCall="StartVideoCall",t.OpenAuthModal="OpenAuthModal",t.SetCanGoBack="SetCanGoBack",t.SetCanNotGoBack="SetCanNotGoBack",t.OpenContactSelectionDialog="OpenContactSelectionDialog",t.SetButtonGroup="SetButtonGroup",t.GetSelfId="GetSelfId",t.DownloadFile="DownloadFile",t.CreateChat="CreateChat",t.ForwardSurvey="ForwardSurvey",t.GetAuth="GetAuth",t.GetPlatformVersion="GetPlatformVersion",t.GetMiniappConfig="GetMiniappConfig",t.EnableLog="EnableLog",t.GetMiniappsSettings="GetMiniappsSettings"})(P||(P={}));var $;(function(t){t.ALREADY_CALLED="ALREADY_CALLED",t.PROFILE_NOT_FOUND="PROFILE_NOT_FOUND",t.DIALOG_NOT_FOUND="DIALOG_NOT_FOUND",t.THREAD_NOT_FOUND="THREAD_NOT_FOUND",t.POPUP_CLOSED="POPUP_CLOSED",t.KEY_IS_TOO_LARGE="KEY_IS_TOO_LARGE",t.VALUE_IS_TOO_LARGE="VALUE_IS_TOO_LARGE",t.TOTAL_LIMIT_EXCEEDED="TOTAL_LIMIT_EXCEEDED",t.INVALID_KEY="INVALID_KEY",t.INVALID_VALUE="INVALID_VALUE",t.KEY_NOT_FOUND="KEY_NOT_FOUND",t.USER_NOT_FOUND="USER_NOT_FOUND",t.MODAL_CLOSED="MODAL_CLOSED",t.UNKNOWN_GROUP="UNKNOWN_GROUP",t.UNKNOWN_ICON="UNKNOWN_ICON",t.CALLBACK_DATA_TOO_LARGE="CALLBACK_DATA_TOO_LARGE",t.TOO_MANY_BUTTONS="TOO_MANY_BUTTONS",t.CREATE_FAILED="CREATE_FAILED",t.UNAUTHTORIZED="401",t.FORBIDDEN="403",t.SERVER_ERROR="500"})($||($={}));var tt;(function(t){t.ThemeSettings="ThemeSettings",t.Language="Language",t.BackButtonPressed="BackButtonPressed",t.ButtonPressed="ButtonPressed",t.SettingChanged="SettingChanged"})(tt||(tt={}));var et=function t(){"use strict";var e=this,o=this;E(this,t);var a=this;s(this,"subscriptions",{}),s(this,"promises",{}),s(this,"enableLog",!0),s(this,"callBackHandlers",{newEvent:function(r,n){var i=e.subscriptions[r];if(!i){v.warn("no subscription found with id ".concat(r));return}i(n)}}),s(this,"callFunction",function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),c=1;c<n;c++)i[c-1]=arguments[c];var f=j(),u={type:"functionCall",data:{reqId:f,name:r,args:i}};return window.parent.postMessage(u,"*"),new Promise(function(_,l){o.promises[f]=[_,l]})}),s(this,"send",function(r,n){return e.callFunction("send",r,n)}),s(this,"subscribe",function(){var r=N(function(n,i){var c,f,u=arguments;return S(this,function(_){switch(_.label){case 0:return c=u.length>2&&u[2]!==void 0?u[2]:null,[4,a.callFunction("subscribe",n,c)];case 1:return f=_.sent().subscriptionId,a.subscriptions[f]=i,[2,{unsubscribe:a.getUnsubscribe(f)}]}})});return function(n,i){return r.apply(this,arguments)}}()),s(this,"setupConsoleProxy",function(){var r=["log","warn","info","error"],n=e.sendLog.bind(e);r.forEach(function(i){window.console[i]=new Proxy(console[i],{apply:function(f,u,_){n({type:i,text:Z(_)}),Reflect.apply(f,u,h(_))}})})}),s(this,"sendLog",function(r){var n=r.text,i=r.type;if(e.enableLog){var c=j(),f={type:"sendLog",data:{reqId:c,name:"sendLog",logData:{text:n,type:i}}};window.parent.postMessage(f,"*")}}),s(this,"changeEnableLog",function(){var r=N(function(n){var i;return S(this,function(c){switch(c.label){case 0:return i=n.enabled,a.enableLog=i,[4,a.send(P.EnableLog,{active:i})];case 1:return c.sent(),[2]}})});return function(n){return r.apply(this,arguments)}}()),s(this,"getUnsubscribe",function(r){return function(){r in e.subscriptions&&delete e.subscriptions[r]}}),s(this,"handleMessage",function(r){var n=r.data;if((typeof n=="undefined"?"undefined":m(n))==="object")switch(n.type){case"functionCallReply":e.handleFunctionCallReply(n.data);break;case"callBack":e.handleCallBack(r,n.data);break}}),s(this,"handleFunctionCallReply",function(r){var n=e.promises[r.reqId];if(n){delete e.promises[r.reqId];var i=C(n,2),c=i[0],f=i[1];r.ok!==void 0?c(r.ok):(v.warn("rejecting req ".concat(r.reqId," promise: ").concat(JSON.stringify(r.err))),f(r.err))}else v.warn("got reply to unknown function call with id ".concat(r.reqId))}),s(this,"handleCallBack",function(r,n){var i=function(l){var U=l.ok,G=l.err,D;if(U===void 0==(G===void 0))return i({reqId:n.reqId,err:{code:b.INTERNAL_ERROR,reason:"callBack handler protocol violation"}});var rt={type:"callBackReply",data:{reqId:n.reqId,ok:U,err:G}};(D=r.source)===null||D===void 0||D.postMessage(rt,r.origin)},c={reqId:n.reqId};try{var f=e.callBackHandlers[n.name];if(!f){var u='got callBack request with unknown name "'.concat(n.name,'"');throw v.warn(u),new J(b.BAD_REQUEST,u)}c.ok=f.apply(void 0,h(n.args))||null}catch(l){var _=L(l)?l.reason:"callBack handler raised an exception";d(l,Error)&&(_+=' "'.concat(l.name,'": "').concat(l.message,'"')),c.err={code:L(l)?l.code:b.INTERNAL_ERROR,reason:_}}i(c)}),window.addEventListener("message",this.handleMessage),window.self!==window.parent&&this.setupConsoleProxy()};var A=new et,ft=A.send,st=A.subscribe;return ct(_t);})();
@@ -63,7 +63,9 @@ export declare enum TeamsSendAction {
63
63
  /** Возвращает конфиг миниаппа */
64
64
  GetMiniappConfig = "GetMiniappConfig",
65
65
  /** Включить запись логов миниаппа */
66
- EnableLog = "EnableLog"
66
+ EnableLog = "EnableLog",
67
+ /** Получает настройки миниаппа от супераппа */
68
+ GetMiniappsSettings = "GetMiniappsSettings"
67
69
  }
68
70
  /** Специфичные коды ошибок */
69
71
  export declare enum TeamsBridgeErrorCode {
@@ -275,6 +277,7 @@ export type TTeamsSendActionsDescriptor = {
275
277
  [TeamsSendAction.GetPlatformVersion]: TGetPlatformVersion;
276
278
  [TeamsSendAction.GetMiniappConfig]: TGetMiniappConfig;
277
279
  [TeamsSendAction.EnableLog]: TEnableLog;
280
+ [TeamsSendAction.GetMiniappsSettings]: any;
278
281
  };
279
282
  export declare enum TeamsSubscribeAction {
280
283
  /** Изменились настройки темы */
@@ -284,7 +287,9 @@ export declare enum TeamsSubscribeAction {
284
287
  /** Пользователь нажал кнопку "Назад". */
285
288
  BackButtonPressed = "BackButtonPressed",
286
289
  /** Пользователь нажал на одну из кнопок, установленных при помощи метода SetButtonGroup */
287
- ButtonPressed = "ButtonPressed"
290
+ ButtonPressed = "ButtonPressed",
291
+ /** Изменение настроек миниаппа */
292
+ SettingChanged = "SettingChanged"
288
293
  }
289
294
  export type TThemeSettings = TSubscribeActionDescriptor<TGetThemeSettings['output']>;
290
295
  export type TLanguage = TSubscribeActionDescriptor<TGetLanguage['output']>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instant-messengers/vk-teams-bridge",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "browser": "dist/iife/index.min.js",
6
6
  "module": "dist/esm/index.js",