@nookuio/iframe 0.9.1 → 0.9.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.
@@ -36,7 +36,9 @@ function createClient(localCtx, options) {
36
36
  key: request.key,
37
37
  result: void 0
38
38
  };
39
- const result = typeof value === "function" ? await value(...deserialize(request.args)) : value;
39
+ let args = request.args ? deserialize(request.args) : [];
40
+ if (!Array.isArray(args)) args = [args];
41
+ const result = typeof value === "function" ? await value(...args) : value;
40
42
  return {
41
43
  type: "response",
42
44
  id: request.id,
@@ -47,7 +49,9 @@ function createClient(localCtx, options) {
47
49
  handleEvent(request => {
48
50
  const currentEventListeners = listenersCollection.get(request.eventName);
49
51
  if (!currentEventListeners?.length) return;
50
- currentEventListeners.forEach(listener => listener(...deserialize(request.args || [])));
52
+ let args = request.args ? deserialize(request.args) : [];
53
+ if (!Array.isArray(args)) args = [args];
54
+ currentEventListeners.forEach(listener => listener(...args));
51
55
  });
52
56
  const proxyCache = /* @__PURE__ */new Map();
53
57
  function createProxyForPath(path) {
@@ -109,10 +113,9 @@ function createClient(localCtx, options) {
109
113
  }
110
114
  if (prop === "emit") {
111
115
  const emitHandler = (eventName, ...args) => {
112
- args = args.map(arg => serialize(arg));
113
116
  emit({
114
117
  eventName,
115
- args
118
+ args: serialize(args)
116
119
  });
117
120
  };
118
121
  return emitHandler;
@@ -24,7 +24,9 @@ export function createClient(localCtx, options) {
24
24
  key: request.key,
25
25
  result: void 0
26
26
  };
27
- const result = typeof value === "function" ? await value(...deserialize(request.args)) : value;
27
+ let args = request.args ? deserialize(request.args) : [];
28
+ if (!Array.isArray(args)) args = [args];
29
+ const result = typeof value === "function" ? await value(...args) : value;
28
30
  return {
29
31
  type: "response",
30
32
  id: request.id,
@@ -35,7 +37,9 @@ export function createClient(localCtx, options) {
35
37
  handleEvent((request) => {
36
38
  const currentEventListeners = listenersCollection.get(request.eventName);
37
39
  if (!currentEventListeners?.length) return;
38
- currentEventListeners.forEach((listener) => listener(...deserialize(request.args || [])));
40
+ let args = request.args ? deserialize(request.args) : [];
41
+ if (!Array.isArray(args)) args = [args];
42
+ currentEventListeners.forEach((listener) => listener(...args));
39
43
  });
40
44
  const proxyCache = /* @__PURE__ */ new Map();
41
45
  function createProxyForPath(path) {
@@ -99,8 +103,7 @@ export function createClient(localCtx, options) {
99
103
  }
100
104
  if (prop === "emit") {
101
105
  const emitHandler = (eventName, ...args) => {
102
- args = args.map((arg) => serialize(arg));
103
- emit({ eventName, args });
106
+ emit({ eventName, args: serialize(args) });
104
107
  };
105
108
  return emitHandler;
106
109
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nookuio/iframe",
3
3
  "description": "",
4
- "version": "0.9.1",
4
+ "version": "0.9.2",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {