vue-act-master 2.0.3 → 2.1.0

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,10 +1,10 @@
1
- var P = Object.defineProperty;
2
- var D = (e, t, s) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var w = (e, t, s) => (D(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- var v = Object.defineProperty, $ = (e, t, s) => t in e ? v(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => ($(e, typeof t != "symbol" ? t + "" : t, s), s);
5
- class b {
1
+ var y = Object.defineProperty;
2
+ var $ = (r, t, s) => t in r ? y(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s;
3
+ var P = (r, t, s) => ($(r, typeof t != "symbol" ? t + "" : t, s), s);
4
+ var M = Object.defineProperty, x = (r, t, s) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s, a = (r, t, s) => (x(r, typeof t != "symbol" ? t + "" : t, s), s);
5
+ class _ {
6
6
  constructor(t, s) {
7
- if (c(this, "reason", ""), c(this, "data"), typeof t == "string") {
7
+ if (a(this, "reason", ""), a(this, "data"), typeof t == "string") {
8
8
  this.reason = t, this.data = s;
9
9
  return;
10
10
  }
@@ -18,10 +18,10 @@ class b {
18
18
  return "__CancelledAct__";
19
19
  }
20
20
  get _name() {
21
- return b._name;
21
+ return _._name;
22
22
  }
23
23
  static is(t) {
24
- return !t || typeof t != "object" ? !1 : t._name === b._name;
24
+ return !t || typeof t != "object" ? !1 : t._name === _._name;
25
25
  }
26
26
  valueOf() {
27
27
  return null;
@@ -30,7 +30,7 @@ class b {
30
30
  return this.reason;
31
31
  }
32
32
  }
33
- class y extends Error {
33
+ class m extends Error {
34
34
  constructor(t) {
35
35
  super(`Can't find "${t}" action`), this.eventName = t;
36
36
  }
@@ -40,184 +40,188 @@ class C extends Error {
40
40
  super(`Action "${t}" already existing`), this.eventName = t;
41
41
  }
42
42
  }
43
- class M extends Error {
43
+ class O extends Error {
44
44
  constructor(t) {
45
45
  super(`"${t}" already exists in DI`), this.key = t;
46
46
  }
47
47
  }
48
- class N extends Error {
48
+ class R extends Error {
49
49
  constructor() {
50
50
  super(`"di" can't be array`);
51
51
  }
52
52
  }
53
- const O = "2.0.1";
54
- function S(e) {
53
+ const S = "2.1.0";
54
+ function j(r) {
55
55
  return function(t, s) {
56
- t._DI_MAP_ || (t._DI_MAP_ = {}), t._DI_MAP_[s] = e;
56
+ t._DI_MAP_ || (t._DI_MAP_ = {}), t._DI_MAP_[s] = r;
57
57
  };
58
58
  }
59
- function j() {
60
- return (e, t) => {
61
- Object.defineProperty(e, "useEmit", {
59
+ function T() {
60
+ return (r, t) => {
61
+ Object.defineProperty(r, "useEmit", {
62
62
  value: function(s) {
63
63
  this[t] = s;
64
64
  }
65
65
  });
66
66
  };
67
67
  }
68
- const _ = class {
69
- constructor(e = {}) {
70
- if (c(this, "version", O), c(this, "_actions", /* @__PURE__ */ new Map()), c(this, "_watchers", /* @__PURE__ */ new Map()), c(this, "_listeners", /* @__PURE__ */ new Map()), c(this, "_inProgressWatchers", /* @__PURE__ */ new Map()), c(this, "_subsMap", /* @__PURE__ */ new Map()), c(this, "_lastUnsubscribe", () => !1), c(this, "_DIContainer", {}), c(this, "_singlePromisesStore", /* @__PURE__ */ new Map()), c(this, "config", {
68
+ const w = class b {
69
+ constructor(t = {}) {
70
+ if (a(this, "version", S), a(this, "_actions", /* @__PURE__ */ new Map()), a(this, "_watchers", /* @__PURE__ */ new Map()), a(this, "_listeners", /* @__PURE__ */ new Map()), a(this, "_inProgressWatchers", /* @__PURE__ */ new Map()), a(this, "_subsMap", /* @__PURE__ */ new Map()), a(this, "_lastUnsubscribe", () => !1), a(this, "_DIContainer", {}), a(this, "_singlePromisesStore", /* @__PURE__ */ new Map()), a(this, "config", {
71
71
  errorOnReplaceDI: !1,
72
72
  autoUnsubscribeCallback: void 0,
73
73
  errorHandlerEventName: void 0
74
- }), c(this, "exec", async (i, ...l) => {
75
- if (this.setProgress(i, !0), this._singlePromisesStore.has(i)) {
76
- const h = this._singlePromisesStore.get(i);
77
- if (h)
78
- return h;
74
+ }), a(this, "exec", async (n, ...h) => {
75
+ if (this.setProgress(n, !0), this._singlePromisesStore.has(n)) {
76
+ const p = this._singlePromisesStore.get(n);
77
+ if (p)
78
+ return p;
79
79
  }
80
- const u = this.emit(i, ...l).then((h) => (this.setProgress(i, !1), h)).then((h) => (this._singlePromisesStore.has(i) && this._singlePromisesStore.delete(i), h)).catch((h) => {
81
- if (this.setProgress(i, !1), h instanceof y)
82
- throw h;
83
- const m = this.getActionOrNull(i);
84
- if (m != null && m.errorHandlerEventName && m.errorHandlerEventName !== i)
85
- return this.emit(m.errorHandlerEventName, h), new b(h);
86
- if (this.config.errorHandlerEventName && this.config.errorHandlerEventName !== i)
87
- return this.emit(this.config.errorHandlerEventName, h), Promise.resolve(null);
88
- throw h;
89
- }), f = this.getActionOrNull(i);
90
- return f && f.isSingleExec && this._singlePromisesStore.set(i, u), u;
91
- }), c(this, "subscribe", (i, l, u) => {
92
- this._listeners.set(i, [
93
- ...this._listeners.get(i) || [],
94
- l
80
+ const u = this.emit(n, ...h).catch((p) => {
81
+ debugger;
82
+ return this.catchEmitException(p, n);
83
+ }).finally(() => {
84
+ this._singlePromisesStore.has(n) && this._singlePromisesStore.delete(n), this.setProgress(n, !1);
85
+ }), f = this.getActionOrNull(n);
86
+ return f && f.isSingleExec && this._singlePromisesStore.set(n, u), u;
87
+ }), a(this, "subscribe", (n, h, u) => {
88
+ this._listeners.set(n, [
89
+ ...this._listeners.get(n) || [],
90
+ h
95
91
  ]);
96
- const f = () => this.unsubscribe(i, l);
92
+ const f = () => this.unsubscribe(n, h);
97
93
  return this._lastUnsubscribe = f, this.config.autoUnsubscribeCallback && this.config.autoUnsubscribeCallback({
98
94
  context: u,
99
- listener: l,
100
- eventName: i
95
+ listener: h,
96
+ eventName: n
101
97
  }), u && this.subsList.add(u), f;
102
- }), c(this, "once", (i, l) => {
103
- const u = this.subscribe(i, (...f) => {
104
- u(), l(...f);
98
+ }), a(this, "once", (n, h) => {
99
+ const u = this.subscribe(n, (...f) => {
100
+ u(), h(...f);
105
101
  });
106
102
  return u;
107
- }), c(this, "on", (i, l, u) => this.subscribe(i, l, u)), _.instance)
108
- return _.instance;
103
+ }), a(this, "on", (n, h, u) => this.subscribe(n, h, u)), b.instance)
104
+ return b.instance;
109
105
  const {
110
- actions: t,
111
- di: s,
112
- errorOnReplaceDI: r,
113
- autoUnsubscribeCallback: n,
114
- errorHandlerEventName: o
115
- } = e;
116
- if (t && this.addActions(t), typeof n == "function" && (this.config.autoUnsubscribeCallback = n), typeof s == "object" && s) {
117
- if (Array.isArray(s))
118
- throw new N();
119
- for (const i in s)
120
- Object.prototype.hasOwnProperty.call(s, i) && this.setDI(i, s[i]);
106
+ actions: s,
107
+ di: e,
108
+ errorOnReplaceDI: i,
109
+ autoUnsubscribeCallback: c,
110
+ errorHandlerEventName: l
111
+ } = t;
112
+ if (s && this.addActions(s), typeof c == "function" && (this.config.autoUnsubscribeCallback = c), typeof e == "object" && e) {
113
+ if (Array.isArray(e))
114
+ throw new R();
115
+ for (const n in e)
116
+ Object.prototype.hasOwnProperty.call(e, n) && this.setDI(n, e[n]);
121
117
  }
122
- typeof r == "boolean" && (this.config.errorOnReplaceDI = r), typeof o == "string" && (this.config.errorHandlerEventName = o), _.instance = this;
118
+ typeof i == "boolean" && (this.config.errorOnReplaceDI = i), typeof l == "string" && (this.config.errorHandlerEventName = l), b.instance = this;
123
119
  }
124
120
  static getInstance() {
125
- if (!_.instance)
121
+ if (!b.instance)
126
122
  throw new Error("ActMaster not initialized");
127
- return _.instance;
123
+ return b.instance;
128
124
  }
129
125
  //#region [ Actions ]
130
- addActions(e) {
131
- Array.isArray(e) && e.forEach((t) => {
132
- this.addAction(t);
126
+ addActions(t) {
127
+ Array.isArray(t) && t.forEach((s) => {
128
+ this.addAction(s);
133
129
  });
134
130
  }
135
- addAction(e) {
136
- const t = e.name;
137
- if (this._actions.has(t))
138
- throw new C(t);
139
- if (e.useEmit) {
140
- const s = (r, ...n) => this.emit(r, ...n);
141
- e.useEmit(s);
131
+ addAction(t) {
132
+ const s = t.name;
133
+ if (this._actions.has(s))
134
+ throw new C(s);
135
+ if (t.useEmit) {
136
+ const e = (i, ...c) => this.exec(i, ...c);
137
+ t.useEmit(e);
142
138
  }
143
- return this._actions.set(t, e), this.emitDIProps(e), e.watch && e.watch.forEach((s) => {
144
- const r = this._watchers.get(s) || [];
145
- r.push(t), this._watchers.set(s, r);
139
+ return this._actions.set(s, t), this.emitDIProps(t), t.watch && t.watch.forEach((e) => {
140
+ const i = this._watchers.get(e) || [];
141
+ i.push(s), this._watchers.set(e, i);
146
142
  }), this;
147
143
  }
148
- removeAction(e) {
149
- if (!this._actions.has(e))
150
- throw new y(e);
151
- this._actions.delete(e);
144
+ removeAction(t) {
145
+ if (!this._actions.has(t))
146
+ throw new m(t);
147
+ this._actions.delete(t);
152
148
  }
153
149
  clearActions() {
154
150
  this._actions.clear();
155
151
  }
156
152
  clearListeners() {
157
- for (const e in this._listeners)
158
- this._listeners.has(e) && this._listeners.delete(e);
159
- }
160
- async emit(e, ...t) {
161
- const s = this.getActionOrNull(e);
162
- if (s === null)
163
- throw new y(e);
164
- if (s.validateInput) {
165
- const n = await s.validateInput(...t);
166
- if (n !== !0)
167
- return this.config.errorHandlerEventName && this.emit(this.config.errorHandlerEventName, n), n;
153
+ for (const t in this._listeners)
154
+ this._listeners.has(t) && this._listeners.delete(t);
155
+ }
156
+ async emit(t, ...s) {
157
+ const e = this.getActionOrNull(t);
158
+ if (e === null)
159
+ throw new m(t);
160
+ if (e.validateInput) {
161
+ const i = await e.validateInput(...s);
162
+ if (i !== !0)
163
+ return this.config.errorHandlerEventName && this.emit(this.config.errorHandlerEventName, i), e.errorHandlerEventName && this.emit(e.errorHandlerEventName, i), i;
168
164
  }
169
- const r = await s.exec(...t);
170
- if (r instanceof b || b.is(r))
171
- return r;
172
- if (this.notifyListeners(e, r), this._watchers.has(e))
173
- for (const n of this._watchers.get(e) || [])
174
- this.emit(n, r);
175
- return r;
176
- }
177
- notifyListeners(e, t) {
178
- const s = this._listeners.get(e);
179
- s && s.forEach((r) => {
180
- r(t);
165
+ try {
166
+ const i = await e.exec(...s);
167
+ return i instanceof _ || _.is(i) || this.notifyListeners(t, i), i;
168
+ } catch (i) {
169
+ return this.catchEmitException(i, t);
170
+ }
171
+ }
172
+ catchEmitException(t, s) {
173
+ if (t instanceof m)
174
+ throw t;
175
+ const e = this.getActionOrNull(s);
176
+ return e != null && e.errorHandlerEventName && e.errorHandlerEventName !== s ? (this.emit(e.errorHandlerEventName, t), Promise.resolve(null)) : this.config.errorHandlerEventName && this.config.errorHandlerEventName !== s ? (this.emit(this.config.errorHandlerEventName, t), Promise.resolve(null)) : Promise.reject(t);
177
+ }
178
+ notifyListeners(t, s) {
179
+ const e = this._listeners.get(t);
180
+ if (this._watchers.has(t))
181
+ for (const i of this._watchers.get(t) || [])
182
+ this.exec(i, s);
183
+ e && e.forEach((i) => {
184
+ i(s);
181
185
  });
182
186
  }
183
- unsubscribe(e, t) {
184
- const s = this._listeners.get(e);
185
- if (!s)
186
- return this._subsMap.set(e, []), !1;
187
- const r = s.indexOf(t);
188
- return r > -1 && s.splice(r, 1), this._listeners.set(e, s), r > -1;
187
+ unsubscribe(t, s) {
188
+ const e = this._listeners.get(t);
189
+ if (!e)
190
+ return this._subsMap.set(t, []), !1;
191
+ const i = e.indexOf(s);
192
+ return i > -1 && e.splice(i, 1), this._listeners.set(t, e), i > -1;
189
193
  }
190
- off(e, t) {
191
- return this.unsubscribe(e, t);
194
+ off(t, s) {
195
+ return this.unsubscribe(t, s);
192
196
  }
193
197
  //#endregion
194
198
  //#region [ extends functions ]
195
- inProgress(e, t) {
196
- if (Array.isArray(e)) {
197
- e.forEach((n) => this._inProgressWatchers.set(n, t));
198
- const r = () => {
199
- e.forEach((n) => {
200
- this._inProgressWatchers.delete(n);
199
+ inProgress(t, s) {
200
+ if (Array.isArray(t)) {
201
+ t.forEach((c) => this._inProgressWatchers.set(c, s));
202
+ const i = () => {
203
+ t.forEach((c) => {
204
+ this._inProgressWatchers.delete(c);
201
205
  });
202
206
  };
203
- return this._lastUnsubscribe = r, r;
207
+ return this._lastUnsubscribe = i, i;
204
208
  }
205
- this._inProgressWatchers.set(e, t);
206
- const s = () => this._inProgressWatchers.delete(e);
207
- return this._lastUnsubscribe = s, s;
209
+ this._inProgressWatchers.set(t, s);
210
+ const e = () => this._inProgressWatchers.delete(t);
211
+ return this._lastUnsubscribe = e, e;
208
212
  }
209
- setProgress(e, t) {
210
- this._inProgressWatchers.has(e) && this._inProgressWatchers.get(e)(t);
213
+ setProgress(t, s) {
214
+ this._inProgressWatchers.has(t) && this._inProgressWatchers.get(t)(s);
211
215
  }
212
216
  get subsList() {
213
217
  return {
214
- add: (e, ...t) => {
215
- t.length || t.push(this._lastUnsubscribe);
216
- const s = this._subsMap.get(e) || [];
217
- s.push(...t), this._subsMap.set(e, s);
218
+ add: (t, ...s) => {
219
+ s.length || s.push(this._lastUnsubscribe);
220
+ const e = this._subsMap.get(t) || [];
221
+ e.push(...s), this._subsMap.set(t, e);
218
222
  },
219
- clear: (e) => {
220
- (this._subsMap.get(e) || []).forEach((t) => t()), this._subsMap.delete(e);
223
+ clear: (t) => {
224
+ (this._subsMap.get(t) || []).forEach((e) => e()), this._subsMap.delete(t);
221
225
  }
222
226
  };
223
227
  }
@@ -226,205 +230,205 @@ const _ = class {
226
230
  clearDI() {
227
231
  this._DIContainer = {};
228
232
  }
229
- setDI(e, t) {
230
- if (this.config.errorOnReplaceDI && this._DIContainer[e])
231
- throw new M(e);
232
- return this._DIContainer[e] = t, this.freshEmitDI(), this;
233
+ setDI(t, s) {
234
+ if (this.config.errorOnReplaceDI && this._DIContainer[t])
235
+ throw new O(t);
236
+ return this._DIContainer[t] = s, this.freshEmitDI(), this;
233
237
  }
234
238
  freshEmitDI() {
235
- let e;
236
- Object.keys(this._actions).forEach((t) => {
237
- e = this._actions.get(t), e && this.emitDIProps(e);
239
+ let t;
240
+ Object.keys(this._actions).forEach((s) => {
241
+ t = this._actions.get(s), t && this.emitDIProps(t);
238
242
  });
239
243
  }
240
- emitDIProps(e) {
241
- e._DI_CONTAINER_ || Object.defineProperty(e, "_DI_CONTAINER_", {
244
+ emitDIProps(t) {
245
+ t._DI_CONTAINER_ || Object.defineProperty(t, "_DI_CONTAINER_", {
242
246
  get: () => this._DIContainer,
243
247
  enumerable: !1
244
248
  // Uncomment for DEBUG
245
- }), e._DI_MAP_ && Object.keys(e._DI_MAP_).forEach((t) => {
246
- var s;
247
- if (e[t])
249
+ }), t._DI_MAP_ && Object.keys(t._DI_MAP_).forEach((s) => {
250
+ var e;
251
+ if (t[s])
248
252
  return;
249
- const r = (s = e._DI_MAP_) == null ? void 0 : s[t];
250
- r && Object.defineProperty(e, t, {
253
+ const i = (e = t._DI_MAP_) == null ? void 0 : e[s];
254
+ i && Object.defineProperty(t, s, {
251
255
  get() {
252
- return this._DI_CONTAINER_[r];
256
+ return this._DI_CONTAINER_[i];
253
257
  },
254
258
  enumerable: !0
255
259
  });
256
- }), e.useDI && e.useDI(this._DIContainer);
260
+ }), t.useDI && t.useDI(this._DIContainer);
257
261
  }
258
262
  //#endregion
259
263
  //#region [ helpers ]
260
- getActionOrNull(e) {
261
- return this._actions.get(e) || null;
264
+ getActionOrNull(t) {
265
+ return this._actions.get(t) || null;
262
266
  }
263
267
  //#endregion
264
268
  };
265
- let g = _;
266
- c(g, "instance");
267
- const a = class {
269
+ a(w, "instance");
270
+ let d = w;
271
+ const A = class o {
268
272
  constructor() {
269
273
  }
270
- static getInstance(e = {}) {
271
- return a.resetAll(), a.removeSingleton(), a.$act = new g(e), a.$act;
274
+ static getInstance(t = {}) {
275
+ return o.resetAll(), o.removeSingleton(), o.$act = new d(t), o.$act;
272
276
  }
273
277
  static resetAll() {
274
- a.$act && (a.$act.clearActions(), a.$act.clearListeners(), a.$act.clearDI()), a._lastResult = void 0;
278
+ o.$act && (o.$act.clearActions(), o.$act.clearListeners(), o.$act.clearDI()), o._lastResult = void 0;
275
279
  }
276
280
  static removeSingleton() {
277
- g.instance = void 0, a._lastResult = void 0;
281
+ d.instance = void 0, o._lastResult = void 0;
278
282
  }
279
- static addActions(e) {
280
- a.$act.addActions(e);
283
+ static addActions(t) {
284
+ o.$act.addActions(t);
281
285
  }
282
- static exec(e, ...t) {
283
- return a.$act.exec(e, ...t).then((s) => (a._lastResult = s, s)).catch((s) => {
284
- throw a._lastResult = s, s;
286
+ static exec(t, ...s) {
287
+ return o.$act.exec(t, ...s).then((e) => (o._lastResult = e, e)).catch((e) => {
288
+ throw o._lastResult = e, e;
285
289
  });
286
290
  }
287
- static subscribe(e, t, s) {
288
- return a.$act.subscribe(e, t, s);
291
+ static subscribe(t, s, e) {
292
+ return o.$act.subscribe(t, s, e);
289
293
  }
290
- static entityCount(e) {
291
- if (e === "di")
292
- return Object.keys(a.$act._DIContainer).length;
293
- if (e === "actions")
294
- return a.$act._actions.size;
295
- const t = {
294
+ static entityCount(t) {
295
+ if (t === "di")
296
+ return Object.keys(o.$act._DIContainer).length;
297
+ if (t === "actions")
298
+ return o.$act._actions.size;
299
+ const e = {
296
300
  watchers: "_watchers",
297
301
  listeners: "_listeners"
298
- }[e];
299
- let s = 0;
300
- return a.$act[t].forEach((r) => {
301
- s += r.length;
302
- }), s;
302
+ }[t];
303
+ let i = 0;
304
+ return o.$act[e].forEach((c) => {
305
+ i += c.length;
306
+ }), i;
303
307
  }
304
308
  static getLastResult() {
305
- return a._lastResult;
309
+ return o._lastResult;
306
310
  }
307
- static makeActionStub(e) {
311
+ static makeActionStub(t) {
308
312
  return {
309
313
  name: `Act_${Math.random()}`,
310
314
  exec: () => null,
311
- ...e
315
+ ...t
312
316
  };
313
317
  }
314
318
  };
315
- let A = a;
316
- c(A, "$act"), c(A, "_lastResult");
317
- d.init = (e) => new g(e);
318
- const U = (e, t, s) => {
319
- const r = d().subscribe(e, t);
320
- return s && (typeof s == "function" ? s(r) : d().subsList.add(s, r)), r;
321
- }, x = (e) => d().subsList.clear(e);
322
- d.subListClear = x;
323
- function d() {
324
- const e = g.getInstance();
325
- if (!e)
319
+ a(A, "$act");
320
+ a(A, "_lastResult");
321
+ let W = A;
322
+ function g() {
323
+ const r = d.getInstance();
324
+ if (!r)
326
325
  throw new Error(
327
326
  'Instance call before initialization. Make a "new ActMaster()" first'
328
327
  );
329
- return e;
328
+ return r;
330
329
  }
331
- const k = (e) => {
332
- if (typeof e != "function" || !e.name)
333
- throw new Error(`Pass not valid function: "${e}"`);
330
+ g.init = (r) => new d(r);
331
+ const z = (r, t, s) => {
332
+ const e = g().subscribe(r, t);
333
+ return s && (typeof s == "function" ? s(e) : g().subsList.add(s, e)), e;
334
+ }, v = (r) => g().subsList.clear(r);
335
+ g.subListClear = v;
336
+ const H = (r) => {
337
+ if (typeof r != "function" || !r.name)
338
+ throw new Error(`Pass not valid function: "${r}"`);
334
339
  return {
335
- name: e.name,
336
- exec: e
340
+ name: r.name,
341
+ exec: r
337
342
  };
338
- }, L = k;
339
- function E(e) {
340
- return (t, s, r) => {
341
- const n = typeof t == "function" ? t : t.constructor;
342
- n.__decorators__ || (n.__decorators__ = []), typeof r != "number" && (r = void 0), n.__decorators__.push((o) => e(o, s, r));
343
+ }, N = H;
344
+ function D(r) {
345
+ return (t, s, e) => {
346
+ const i = typeof t == "function" ? t : t.constructor;
347
+ i.__decorators__ || (i.__decorators__ = []), typeof e != "number" && (e = void 0), i.__decorators__.push((c) => r(c, s, e));
343
348
  };
344
349
  }
345
- function W(e, t, s = null) {
346
- return E((r, n) => {
347
- const o = {
350
+ function F(r, t, s = null) {
351
+ return D((e, i) => {
352
+ const c = {
348
353
  created() {
349
354
  this.$act.subscribe(
350
- e,
351
- (i) => {
352
- const l = R(i, t, s);
353
- typeof this[n] == "function" ? this[n](l) : this[n] = l;
355
+ r,
356
+ (l) => {
357
+ const n = U(l, t, s);
358
+ typeof this[i] == "function" ? this[i](n) : this[i] = n;
354
359
  },
355
360
  this
356
361
  );
357
362
  }
358
363
  };
359
- r.mixins ? r.mixins = [...r.mixins, o] : r.mixins = [o];
364
+ e.mixins ? e.mixins = [...e.mixins, c] : e.mixins = [c];
360
365
  });
361
366
  }
362
- function R(e, t, s) {
363
- if (e === void 0)
367
+ function U(r, t, s) {
368
+ if (r === void 0)
364
369
  return s;
365
370
  if (typeof t == "function")
366
- return t(e);
367
- let r = e;
371
+ return t(r);
372
+ let e = r;
368
373
  if (t) {
369
- const n = (t || "").split(".");
370
- let o, i = 0;
371
- for (i = 0; i < n.length && r; i++)
372
- o = n[i], r = r[o];
374
+ const i = (t || "").split(".");
375
+ let c, l = 0;
376
+ for (l = 0; l < i.length && e; l++)
377
+ c = i[l], e = e[c];
373
378
  }
374
- return r === void 0 ? s : r;
379
+ return e === void 0 ? s : e;
375
380
  }
376
- function T(e) {
377
- return E((t, s) => {
378
- const r = {
381
+ function q(r) {
382
+ return D((t, s) => {
383
+ const e = {
379
384
  created() {
380
- const n = this.$act.inProgress(e, (o) => {
381
- this[s] = o;
385
+ const i = this.$act.inProgress(r, (c) => {
386
+ this[s] = c;
382
387
  });
383
388
  this.$once("hook:beforeDestroy", () => {
384
- n(e);
389
+ i(r);
385
390
  });
386
391
  }
387
392
  };
388
- t.mixins ? t.mixins = [...t.mixins, r] : t.mixins = [r];
393
+ t.mixins ? t.mixins = [...t.mixins, e] : t.mixins = [e];
389
394
  });
390
395
  }
391
- const p = class {
396
+ const E = class {
392
397
  static install(t, s) {
393
- var n;
394
- const r = new g({
395
- autoUnsubscribeCallback({ context: o, eventName: i, listener: l }) {
396
- o && typeof o == "function" ? o(function() {
397
- r.unsubscribe(i, l);
398
- }) : o && typeof o.$once == "function" && o.$once("hook:beforeDestroy", () => {
399
- r.unsubscribe(i, l);
398
+ var i;
399
+ const e = new d({
400
+ autoUnsubscribeCallback({ context: c, eventName: l, listener: n }) {
401
+ c && typeof c == "function" ? c(function() {
402
+ e.unsubscribe(l, n);
403
+ }) : c && typeof c.$once == "function" && c.$once("hook:beforeDestroy", () => {
404
+ e.unsubscribe(l, n);
400
405
  });
401
406
  },
402
407
  ...s
403
408
  });
404
- p.instance = r, (n = t.config) != null && n.globalProperties && !t.config.globalProperties.$act ? (t.config.globalProperties.$act = r, t.provide("$act", r)) : Object.prototype.hasOwnProperty.call(t, "$act") || (t.act = r, t.prototype.$act = r);
409
+ E.instance = e, (i = t.config) != null && i.globalProperties && !t.config.globalProperties.$act ? (t.config.globalProperties.$act = e, t.provide("$act", e)) : Object.prototype.hasOwnProperty.call(t, "$act") || (t.act = e, t.prototype.$act = e);
405
410
  }
406
411
  install(t, s) {
407
- p.install(t, s);
412
+ E.install(t, s);
408
413
  }
409
414
  };
410
- let I = p;
411
- w(I, "instance", null);
415
+ let I = E;
416
+ P(I, "instance", null);
412
417
  export {
413
- T as ActInProgress,
414
- g as ActMaster,
415
- W as ActSubscribe,
416
- A as ActTest,
418
+ q as ActInProgress,
419
+ d as ActMaster,
420
+ F as ActSubscribe,
421
+ W as ActTest,
417
422
  C as ActinonAlreadyExistingError,
418
- b as CancelledAct,
419
- j as Emit,
420
- N as InvalidDITypeError,
421
- M as KeyAlreadyExistsInDIError,
422
- y as NotFoundActionError,
423
- S as UseDI,
423
+ _ as CancelledAct,
424
+ T as Emit,
425
+ R as InvalidDITypeError,
426
+ O as KeyAlreadyExistsInDIError,
427
+ m as NotFoundActionError,
428
+ j as UseDI,
424
429
  I as VueActMaster,
425
- d as act,
426
- U as actSubscribe,
427
- L as fn2act,
428
- k as functionToAction,
429
- x as subListClear
430
+ g as act,
431
+ z as actSubscribe,
432
+ N as fn2act,
433
+ H as functionToAction
430
434
  };
@@ -1 +1 @@
1
- (function(c,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis<"u"?globalThis:c||self,u(c["vue-act-master"]={}))})(this,function(c){"use strict";var W=Object.defineProperty;var x=(c,u,b)=>u in c?W(c,u,{enumerable:!0,configurable:!0,writable:!0,value:b}):c[u]=b;var O=(c,u,b)=>(x(c,typeof u!="symbol"?u+"":u,b),b);var u=Object.defineProperty,b=(e,t,s)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,o=(e,t,s)=>(b(e,typeof t!="symbol"?t+"":t,s),s);class d{constructor(t,s){if(o(this,"reason",""),o(this,"data"),typeof t=="string"){this.reason=t,this.data=s;return}if(t&&typeof t=="object")return Object.assign(t,{_name:this._name,reason:t.message||""})}static get _name(){return"__CancelledAct__"}get _name(){return d._name}static is(t){return!t||typeof t!="object"?!1:t._name===d._name}valueOf(){return null}toString(){return this.reason}}class A extends Error{constructor(t){super(`Can't find "${t}" action`),this.eventName=t}}class D extends Error{constructor(t){super(`Action "${t}" already existing`),this.eventName=t}}class v extends Error{constructor(t){super(`"${t}" already exists in DI`),this.key=t}}class $ extends Error{constructor(){super(`"di" can't be array`)}}const S="2.0.1";function k(e){return function(t,s){t._DI_MAP_||(t._DI_MAP_={}),t._DI_MAP_[s]=e}}function j(){return(e,t)=>{Object.defineProperty(e,"useEmit",{value:function(s){this[t]=s}})}}const y=class{constructor(e={}){if(o(this,"version",S),o(this,"_actions",new Map),o(this,"_watchers",new Map),o(this,"_listeners",new Map),o(this,"_inProgressWatchers",new Map),o(this,"_subsMap",new Map),o(this,"_lastUnsubscribe",()=>!1),o(this,"_DIContainer",{}),o(this,"_singlePromisesStore",new Map),o(this,"config",{errorOnReplaceDI:!1,autoUnsubscribeCallback:void 0,errorHandlerEventName:void 0}),o(this,"exec",async(i,...h)=>{if(this.setProgress(i,!0),this._singlePromisesStore.has(i)){const f=this._singlePromisesStore.get(i);if(f)return f}const _=this.emit(i,...h).then(f=>(this.setProgress(i,!1),f)).then(f=>(this._singlePromisesStore.has(i)&&this._singlePromisesStore.delete(i),f)).catch(f=>{if(this.setProgress(i,!1),f instanceof A)throw f;const P=this.getActionOrNull(i);if(P!=null&&P.errorHandlerEventName&&P.errorHandlerEventName!==i)return this.emit(P.errorHandlerEventName,f),new d(f);if(this.config.errorHandlerEventName&&this.config.errorHandlerEventName!==i)return this.emit(this.config.errorHandlerEventName,f),Promise.resolve(null);throw f}),m=this.getActionOrNull(i);return m&&m.isSingleExec&&this._singlePromisesStore.set(i,_),_}),o(this,"subscribe",(i,h,_)=>{this._listeners.set(i,[...this._listeners.get(i)||[],h]);const m=()=>this.unsubscribe(i,h);return this._lastUnsubscribe=m,this.config.autoUnsubscribeCallback&&this.config.autoUnsubscribeCallback({context:_,listener:h,eventName:i}),_&&this.subsList.add(_),m}),o(this,"once",(i,h)=>{const _=this.subscribe(i,(...m)=>{_(),h(...m)});return _}),o(this,"on",(i,h,_)=>this.subscribe(i,h,_)),y.instance)return y.instance;const{actions:t,di:s,errorOnReplaceDI:r,autoUnsubscribeCallback:n,errorHandlerEventName:l}=e;if(t&&this.addActions(t),typeof n=="function"&&(this.config.autoUnsubscribeCallback=n),typeof s=="object"&&s){if(Array.isArray(s))throw new $;for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&this.setDI(i,s[i])}typeof r=="boolean"&&(this.config.errorOnReplaceDI=r),typeof l=="string"&&(this.config.errorHandlerEventName=l),y.instance=this}static getInstance(){if(!y.instance)throw new Error("ActMaster not initialized");return y.instance}addActions(e){Array.isArray(e)&&e.forEach(t=>{this.addAction(t)})}addAction(e){const t=e.name;if(this._actions.has(t))throw new D(t);if(e.useEmit){const s=(r,...n)=>this.emit(r,...n);e.useEmit(s)}return this._actions.set(t,e),this.emitDIProps(e),e.watch&&e.watch.forEach(s=>{const r=this._watchers.get(s)||[];r.push(t),this._watchers.set(s,r)}),this}removeAction(e){if(!this._actions.has(e))throw new A(e);this._actions.delete(e)}clearActions(){this._actions.clear()}clearListeners(){for(const e in this._listeners)this._listeners.has(e)&&this._listeners.delete(e)}async emit(e,...t){const s=this.getActionOrNull(e);if(s===null)throw new A(e);if(s.validateInput){const n=await s.validateInput(...t);if(n!==!0)return this.config.errorHandlerEventName&&this.emit(this.config.errorHandlerEventName,n),n}const r=await s.exec(...t);if(r instanceof d||d.is(r))return r;if(this.notifyListeners(e,r),this._watchers.has(e))for(const n of this._watchers.get(e)||[])this.emit(n,r);return r}notifyListeners(e,t){const s=this._listeners.get(e);s&&s.forEach(r=>{r(t)})}unsubscribe(e,t){const s=this._listeners.get(e);if(!s)return this._subsMap.set(e,[]),!1;const r=s.indexOf(t);return r>-1&&s.splice(r,1),this._listeners.set(e,s),r>-1}off(e,t){return this.unsubscribe(e,t)}inProgress(e,t){if(Array.isArray(e)){e.forEach(n=>this._inProgressWatchers.set(n,t));const r=()=>{e.forEach(n=>{this._inProgressWatchers.delete(n)})};return this._lastUnsubscribe=r,r}this._inProgressWatchers.set(e,t);const s=()=>this._inProgressWatchers.delete(e);return this._lastUnsubscribe=s,s}setProgress(e,t){this._inProgressWatchers.has(e)&&this._inProgressWatchers.get(e)(t)}get subsList(){return{add:(e,...t)=>{t.length||t.push(this._lastUnsubscribe);const s=this._subsMap.get(e)||[];s.push(...t),this._subsMap.set(e,s)},clear:e=>{(this._subsMap.get(e)||[]).forEach(t=>t()),this._subsMap.delete(e)}}}clearDI(){this._DIContainer={}}setDI(e,t){if(this.config.errorOnReplaceDI&&this._DIContainer[e])throw new v(e);return this._DIContainer[e]=t,this.freshEmitDI(),this}freshEmitDI(){let e;Object.keys(this._actions).forEach(t=>{e=this._actions.get(t),e&&this.emitDIProps(e)})}emitDIProps(e){e._DI_CONTAINER_||Object.defineProperty(e,"_DI_CONTAINER_",{get:()=>this._DIContainer,enumerable:!1}),e._DI_MAP_&&Object.keys(e._DI_MAP_).forEach(t=>{var s;if(e[t])return;const r=(s=e._DI_MAP_)==null?void 0:s[t];r&&Object.defineProperty(e,t,{get(){return this._DI_CONTAINER_[r]},enumerable:!0})}),e.useDI&&e.useDI(this._DIContainer)}getActionOrNull(e){return this._actions.get(e)||null}};let g=y;o(g,"instance");const a=class{constructor(){}static getInstance(e={}){return a.resetAll(),a.removeSingleton(),a.$act=new g(e),a.$act}static resetAll(){a.$act&&(a.$act.clearActions(),a.$act.clearListeners(),a.$act.clearDI()),a._lastResult=void 0}static removeSingleton(){g.instance=void 0,a._lastResult=void 0}static addActions(e){a.$act.addActions(e)}static exec(e,...t){return a.$act.exec(e,...t).then(s=>(a._lastResult=s,s)).catch(s=>{throw a._lastResult=s,s})}static subscribe(e,t,s){return a.$act.subscribe(e,t,s)}static entityCount(e){if(e==="di")return Object.keys(a.$act._DIContainer).length;if(e==="actions")return a.$act._actions.size;const t={watchers:"_watchers",listeners:"_listeners"}[e];let s=0;return a.$act[t].forEach(r=>{s+=r.length}),s}static getLastResult(){return a._lastResult}static makeActionStub(e){return{name:`Act_${Math.random()}`,exec:()=>null,...e}}};let p=a;o(p,"$act"),o(p,"_lastResult"),I.init=e=>new g(e);const R=(e,t,s)=>{const r=I().subscribe(e,t);return s&&(typeof s=="function"?s(r):I().subsList.add(s,r)),r},M=e=>I().subsList.clear(e);I.subListClear=M;function I(){const e=g.getInstance();if(!e)throw new Error('Instance call before initialization. Make a "new ActMaster()" first');return e}const C=e=>{if(typeof e!="function"||!e.name)throw new Error(`Pass not valid function: "${e}"`);return{name:e.name,exec:e}},H=C;function N(e){return(t,s,r)=>{const n=typeof t=="function"?t:t.constructor;n.__decorators__||(n.__decorators__=[]),typeof r!="number"&&(r=void 0),n.__decorators__.push(l=>e(l,s,r))}}function U(e,t,s=null){return N((r,n)=>{const l={created(){this.$act.subscribe(e,i=>{const h=L(i,t,s);typeof this[n]=="function"?this[n](h):this[n]=h},this)}};r.mixins?r.mixins=[...r.mixins,l]:r.mixins=[l]})}function L(e,t,s){if(e===void 0)return s;if(typeof t=="function")return t(e);let r=e;if(t){const n=(t||"").split(".");let l,i=0;for(i=0;i<n.length&&r;i++)l=n[i],r=r[l]}return r===void 0?s:r}function T(e){return N((t,s)=>{const r={created(){const n=this.$act.inProgress(e,l=>{this[s]=l});this.$once("hook:beforeDestroy",()=>{n(e)})}};t.mixins?t.mixins=[...t.mixins,r]:t.mixins=[r]})}const E=class{static install(t,s){var n;const r=new g({autoUnsubscribeCallback({context:l,eventName:i,listener:h}){l&&typeof l=="function"?l(function(){r.unsubscribe(i,h)}):l&&typeof l.$once=="function"&&l.$once("hook:beforeDestroy",()=>{r.unsubscribe(i,h)})},...s});E.instance=r,(n=t.config)!=null&&n.globalProperties&&!t.config.globalProperties.$act?(t.config.globalProperties.$act=r,t.provide("$act",r)):Object.prototype.hasOwnProperty.call(t,"$act")||(t.act=r,t.prototype.$act=r)}install(t,s){E.install(t,s)}};let w=E;O(w,"instance",null),c.ActInProgress=T,c.ActMaster=g,c.ActSubscribe=U,c.ActTest=p,c.ActinonAlreadyExistingError=D,c.CancelledAct=d,c.Emit=j,c.InvalidDITypeError=$,c.KeyAlreadyExistsInDIError=v,c.NotFoundActionError=A,c.UseDI=k,c.VueActMaster=w,c.act=I,c.actSubscribe=R,c.fn2act=H,c.functionToAction=C,c.subListClear=M,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis<"u"?globalThis:c||self,u(c["vue-act-master"]={}))})(this,function(c){"use strict";var F=Object.defineProperty;var q=(c,u,_)=>u in c?F(c,u,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[u]=_;var v=(c,u,_)=>(q(c,typeof u!="symbol"?u+"":u,_),_);var u=Object.defineProperty,_=(r,t,e)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,l=(r,t,e)=>(_(r,typeof t!="symbol"?t+"":t,e),e);class g{constructor(t,e){if(l(this,"reason",""),l(this,"data"),typeof t=="string"){this.reason=t,this.data=e;return}if(t&&typeof t=="object")return Object.assign(t,{_name:this._name,reason:t.message||""})}static get _name(){return"__CancelledAct__"}get _name(){return g._name}static is(t){return!t||typeof t!="object"?!1:t._name===g._name}valueOf(){return null}toString(){return this.reason}}class m extends Error{constructor(t){super(`Can't find "${t}" action`),this.eventName=t}}class y extends Error{constructor(t){super(`Action "${t}" already existing`),this.eventName=t}}class $ extends Error{constructor(t){super(`"${t}" already exists in DI`),this.key=t}}class M extends Error{constructor(){super(`"di" can't be array`)}}const R="2.1.0";function T(r){return function(t,e){t._DI_MAP_||(t._DI_MAP_={}),t._DI_MAP_[e]=r}}function U(){return(r,t)=>{Object.defineProperty(r,"useEmit",{value:function(e){this[t]=e}})}}const C=class p{constructor(t={}){if(l(this,"version",R),l(this,"_actions",new Map),l(this,"_watchers",new Map),l(this,"_listeners",new Map),l(this,"_inProgressWatchers",new Map),l(this,"_subsMap",new Map),l(this,"_lastUnsubscribe",()=>!1),l(this,"_DIContainer",{}),l(this,"_singlePromisesStore",new Map),l(this,"config",{errorOnReplaceDI:!1,autoUnsubscribeCallback:void 0,errorHandlerEventName:void 0}),l(this,"exec",async(n,...b)=>{if(this.setProgress(n,!0),this._singlePromisesStore.has(n)){const w=this._singlePromisesStore.get(n);if(w)return w}const f=this.emit(n,...b).catch(w=>{debugger;return this.catchEmitException(w,n)}).finally(()=>{this._singlePromisesStore.has(n)&&this._singlePromisesStore.delete(n),this.setProgress(n,!1)}),d=this.getActionOrNull(n);return d&&d.isSingleExec&&this._singlePromisesStore.set(n,f),f}),l(this,"subscribe",(n,b,f)=>{this._listeners.set(n,[...this._listeners.get(n)||[],b]);const d=()=>this.unsubscribe(n,b);return this._lastUnsubscribe=d,this.config.autoUnsubscribeCallback&&this.config.autoUnsubscribeCallback({context:f,listener:b,eventName:n}),f&&this.subsList.add(f),d}),l(this,"once",(n,b)=>{const f=this.subscribe(n,(...d)=>{f(),b(...d)});return f}),l(this,"on",(n,b,f)=>this.subscribe(n,b,f)),p.instance)return p.instance;const{actions:e,di:s,errorOnReplaceDI:i,autoUnsubscribeCallback:o,errorHandlerEventName:h}=t;if(e&&this.addActions(e),typeof o=="function"&&(this.config.autoUnsubscribeCallback=o),typeof s=="object"&&s){if(Array.isArray(s))throw new M;for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&this.setDI(n,s[n])}typeof i=="boolean"&&(this.config.errorOnReplaceDI=i),typeof h=="string"&&(this.config.errorHandlerEventName=h),p.instance=this}static getInstance(){if(!p.instance)throw new Error("ActMaster not initialized");return p.instance}addActions(t){Array.isArray(t)&&t.forEach(e=>{this.addAction(e)})}addAction(t){const e=t.name;if(this._actions.has(e))throw new y(e);if(t.useEmit){const s=(i,...o)=>this.exec(i,...o);t.useEmit(s)}return this._actions.set(e,t),this.emitDIProps(t),t.watch&&t.watch.forEach(s=>{const i=this._watchers.get(s)||[];i.push(e),this._watchers.set(s,i)}),this}removeAction(t){if(!this._actions.has(t))throw new m(t);this._actions.delete(t)}clearActions(){this._actions.clear()}clearListeners(){for(const t in this._listeners)this._listeners.has(t)&&this._listeners.delete(t)}async emit(t,...e){const s=this.getActionOrNull(t);if(s===null)throw new m(t);if(s.validateInput){const i=await s.validateInput(...e);if(i!==!0)return this.config.errorHandlerEventName&&this.emit(this.config.errorHandlerEventName,i),s.errorHandlerEventName&&this.emit(s.errorHandlerEventName,i),i}try{const i=await s.exec(...e);return i instanceof g||g.is(i)||this.notifyListeners(t,i),i}catch(i){return this.catchEmitException(i,t)}}catchEmitException(t,e){if(t instanceof m)throw t;const s=this.getActionOrNull(e);return s!=null&&s.errorHandlerEventName&&s.errorHandlerEventName!==e?(this.emit(s.errorHandlerEventName,t),Promise.resolve(null)):this.config.errorHandlerEventName&&this.config.errorHandlerEventName!==e?(this.emit(this.config.errorHandlerEventName,t),Promise.resolve(null)):Promise.reject(t)}notifyListeners(t,e){const s=this._listeners.get(t);if(this._watchers.has(t))for(const i of this._watchers.get(t)||[])this.exec(i,e);s&&s.forEach(i=>{i(e)})}unsubscribe(t,e){const s=this._listeners.get(t);if(!s)return this._subsMap.set(t,[]),!1;const i=s.indexOf(e);return i>-1&&s.splice(i,1),this._listeners.set(t,s),i>-1}off(t,e){return this.unsubscribe(t,e)}inProgress(t,e){if(Array.isArray(t)){t.forEach(o=>this._inProgressWatchers.set(o,e));const i=()=>{t.forEach(o=>{this._inProgressWatchers.delete(o)})};return this._lastUnsubscribe=i,i}this._inProgressWatchers.set(t,e);const s=()=>this._inProgressWatchers.delete(t);return this._lastUnsubscribe=s,s}setProgress(t,e){this._inProgressWatchers.has(t)&&this._inProgressWatchers.get(t)(e)}get subsList(){return{add:(t,...e)=>{e.length||e.push(this._lastUnsubscribe);const s=this._subsMap.get(t)||[];s.push(...e),this._subsMap.set(t,s)},clear:t=>{(this._subsMap.get(t)||[]).forEach(s=>s()),this._subsMap.delete(t)}}}clearDI(){this._DIContainer={}}setDI(t,e){if(this.config.errorOnReplaceDI&&this._DIContainer[t])throw new $(t);return this._DIContainer[t]=e,this.freshEmitDI(),this}freshEmitDI(){let t;Object.keys(this._actions).forEach(e=>{t=this._actions.get(e),t&&this.emitDIProps(t)})}emitDIProps(t){t._DI_CONTAINER_||Object.defineProperty(t,"_DI_CONTAINER_",{get:()=>this._DIContainer,enumerable:!1}),t._DI_MAP_&&Object.keys(t._DI_MAP_).forEach(e=>{var s;if(t[e])return;const i=(s=t._DI_MAP_)==null?void 0:s[e];i&&Object.defineProperty(t,e,{get(){return this._DI_CONTAINER_[i]},enumerable:!0})}),t.useDI&&t.useDI(this._DIContainer)}getActionOrNull(t){return this._actions.get(t)||null}};l(C,"instance");let E=C;const D=class a{constructor(){}static getInstance(t={}){return a.resetAll(),a.removeSingleton(),a.$act=new E(t),a.$act}static resetAll(){a.$act&&(a.$act.clearActions(),a.$act.clearListeners(),a.$act.clearDI()),a._lastResult=void 0}static removeSingleton(){E.instance=void 0,a._lastResult=void 0}static addActions(t){a.$act.addActions(t)}static exec(t,...e){return a.$act.exec(t,...e).then(s=>(a._lastResult=s,s)).catch(s=>{throw a._lastResult=s,s})}static subscribe(t,e,s){return a.$act.subscribe(t,e,s)}static entityCount(t){if(t==="di")return Object.keys(a.$act._DIContainer).length;if(t==="actions")return a.$act._actions.size;const s={watchers:"_watchers",listeners:"_listeners"}[t];let i=0;return a.$act[s].forEach(o=>{i+=o.length}),i}static getLastResult(){return a._lastResult}static makeActionStub(t){return{name:`Act_${Math.random()}`,exec:()=>null,...t}}};l(D,"$act"),l(D,"_lastResult");let H=D;function A(){const r=E.getInstance();if(!r)throw new Error('Instance call before initialization. Make a "new ActMaster()" first');return r}A.init=r=>new E(r);const j=(r,t,e)=>{const s=A().subscribe(r,t);return e&&(typeof e=="function"?e(s):A().subsList.add(e,s)),s},L=r=>A().subsList.clear(r);A.subListClear=L;const O=r=>{if(typeof r!="function"||!r.name)throw new Error(`Pass not valid function: "${r}"`);return{name:r.name,exec:r}},x=O;function S(r){return(t,e,s)=>{const i=typeof t=="function"?t:t.constructor;i.__decorators__||(i.__decorators__=[]),typeof s!="number"&&(s=void 0),i.__decorators__.push(o=>r(o,e,s))}}function W(r,t,e=null){return S((s,i)=>{const o={created(){this.$act.subscribe(r,h=>{const n=N(h,t,e);typeof this[i]=="function"?this[i](n):this[i]=n},this)}};s.mixins?s.mixins=[...s.mixins,o]:s.mixins=[o]})}function N(r,t,e){if(r===void 0)return e;if(typeof t=="function")return t(r);let s=r;if(t){const i=(t||"").split(".");let o,h=0;for(h=0;h<i.length&&s;h++)o=i[h],s=s[o]}return s===void 0?e:s}function z(r){return S((t,e)=>{const s={created(){const i=this.$act.inProgress(r,o=>{this[e]=o});this.$once("hook:beforeDestroy",()=>{i(r)})}};t.mixins?t.mixins=[...t.mixins,s]:t.mixins=[s]})}const P=class{static install(t,e){var i;const s=new E({autoUnsubscribeCallback({context:o,eventName:h,listener:n}){o&&typeof o=="function"?o(function(){s.unsubscribe(h,n)}):o&&typeof o.$once=="function"&&o.$once("hook:beforeDestroy",()=>{s.unsubscribe(h,n)})},...e});P.instance=s,(i=t.config)!=null&&i.globalProperties&&!t.config.globalProperties.$act?(t.config.globalProperties.$act=s,t.provide("$act",s)):Object.prototype.hasOwnProperty.call(t,"$act")||(t.act=s,t.prototype.$act=s)}install(t,e){P.install(t,e)}};let I=P;v(I,"instance",null),c.ActInProgress=z,c.ActMaster=E,c.ActSubscribe=W,c.ActTest=H,c.ActinonAlreadyExistingError=y,c.CancelledAct=g,c.Emit=U,c.InvalidDITypeError=M,c.KeyAlreadyExistsInDIError=$,c.NotFoundActionError=m,c.UseDI=T,c.VueActMaster=I,c.act=A,c.actSubscribe=j,c.fn2act=x,c.functionToAction=O,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-act-master",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "author": "avil13",
6
6
  "main": "dist/vue-act-master.umd.cjs",
@@ -52,10 +52,10 @@
52
52
  },
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "act-master": "^2.0.1"
55
+ "act-master": "^2.1.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "act-master": "^2.0.1"
58
+ "act-master": "^2.1.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@babel/types": "^7.22.5",