mvvm-mobx 1.0.2 → 1.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.
- package/dist/commands/RelayCommand.js +61 -24
- package/dist/core/CounterFlag.d.ts +1 -1
- package/dist/core/CounterFlag.js +108 -54
- package/dist/interaction/CommonInteractionResponses.d.ts +5 -5
- package/dist/interaction/CommonInteractionResponses.js +5 -5
- package/dist/interaction/InteractionResponse.d.ts +2 -2
- package/dist/interaction/InteractionResponse.js +85 -16
- package/dist/interaction/SingleConcurrentInteractionManager.d.ts +1 -1
- package/dist/interaction/SingleConcurrentInteractionManager.js +86 -32
- package/package.json +1 -1
|
@@ -1,31 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
7
35
|
};
|
|
8
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
37
|
exports.RelayCommand = void 0;
|
|
10
38
|
const mobx_1 = require("mobx");
|
|
11
39
|
const CounterFlag_1 = require("../core/CounterFlag");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
let RelayCommand = (() => {
|
|
41
|
+
var _a;
|
|
42
|
+
let _instanceExtraInitializers = [];
|
|
43
|
+
let _execute_decorators;
|
|
44
|
+
return _a = class RelayCommand {
|
|
45
|
+
constructor(executeFunc, canExecuteFunc) {
|
|
46
|
+
this.executeFunc = (__runInitializers(this, _instanceExtraInitializers), executeFunc);
|
|
47
|
+
this.canExecuteFunc = canExecuteFunc;
|
|
48
|
+
this.workingFlag = new CounterFlag_1.CounterFlag();
|
|
49
|
+
(0, mobx_1.makeObservable)(this);
|
|
50
|
+
}
|
|
51
|
+
canExecute(parameter) {
|
|
52
|
+
return this.canExecuteFunc?.(parameter) ?? true;
|
|
53
|
+
}
|
|
54
|
+
async execute(parameter) {
|
|
55
|
+
await this.workingFlag.using(async () => {
|
|
56
|
+
await this.executeFunc(parameter);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
(() => {
|
|
61
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
62
|
+
_execute_decorators = [mobx_1.action];
|
|
63
|
+
__esDecorate(_a, null, _execute_decorators, { kind: "method", name: "execute", static: false, private: false, access: { has: obj => "execute" in obj, get: obj => obj.execute }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
64
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
65
|
+
})(),
|
|
66
|
+
_a;
|
|
67
|
+
})();
|
|
28
68
|
exports.RelayCommand = RelayCommand;
|
|
29
|
-
__decorate([
|
|
30
|
-
mobx_1.action
|
|
31
|
-
], RelayCommand.prototype, "execute", null);
|
package/dist/core/CounterFlag.js
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
7
35
|
};
|
|
8
36
|
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
9
37
|
if (value !== null && value !== void 0) {
|
|
@@ -57,56 +85,82 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
57
85
|
var e = new Error(message);
|
|
58
86
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
87
|
});
|
|
88
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
89
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
90
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
91
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
92
|
+
};
|
|
93
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
94
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
95
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
96
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
97
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
98
|
+
};
|
|
60
99
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
100
|
exports.CounterFlag = void 0;
|
|
62
101
|
const mobx_1 = require("mobx");
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
let CounterFlag = (() => {
|
|
103
|
+
var _a, _CounterFlag_counter_accessor_storage;
|
|
104
|
+
let _instanceExtraInitializers = [];
|
|
105
|
+
let _counter_decorators;
|
|
106
|
+
let _counter_initializers = [];
|
|
107
|
+
let _counter_extraInitializers = [];
|
|
108
|
+
let _using_decorators;
|
|
109
|
+
let _increment_decorators;
|
|
110
|
+
let _get_isActive_decorators;
|
|
111
|
+
return _a = class CounterFlag {
|
|
112
|
+
get counter() { return __classPrivateFieldGet(this, _CounterFlag_counter_accessor_storage, "f"); }
|
|
113
|
+
set counter(value) { __classPrivateFieldSet(this, _CounterFlag_counter_accessor_storage, value, "f"); }
|
|
114
|
+
constructor() {
|
|
115
|
+
_CounterFlag_counter_accessor_storage.set(this, (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _counter_initializers, 0)));
|
|
116
|
+
__runInitializers(this, _counter_extraInitializers);
|
|
117
|
+
(0, mobx_1.makeObservable)(this);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Activates the flag while executing the provided function.
|
|
121
|
+
* @param fn The function to execute while the flag is active.
|
|
122
|
+
*/
|
|
123
|
+
async using(fn) {
|
|
124
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
125
|
+
try {
|
|
126
|
+
const _ = __addDisposableResource(env_1, this.increment(), false);
|
|
127
|
+
await fn();
|
|
128
|
+
}
|
|
129
|
+
catch (e_1) {
|
|
130
|
+
env_1.error = e_1;
|
|
131
|
+
env_1.hasError = true;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
__disposeResources(env_1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Increments the counter and returns a disposable object that decreases the counter when disposed.
|
|
139
|
+
* @returns A disposable object that decreases the counter when disposed.
|
|
140
|
+
*/
|
|
141
|
+
increment() {
|
|
142
|
+
this.counter++;
|
|
143
|
+
return {
|
|
144
|
+
[Symbol.dispose]: () => (0, mobx_1.runInAction)(() => this.counter--),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
get isActive() {
|
|
148
|
+
return this.counter > 0;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
_CounterFlag_counter_accessor_storage = new WeakMap(),
|
|
152
|
+
(() => {
|
|
153
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
154
|
+
_counter_decorators = [mobx_1.observable];
|
|
155
|
+
_using_decorators = [mobx_1.action];
|
|
156
|
+
_increment_decorators = [mobx_1.action];
|
|
157
|
+
_get_isActive_decorators = [mobx_1.computed];
|
|
158
|
+
__esDecorate(_a, null, _counter_decorators, { kind: "accessor", name: "counter", static: false, private: false, access: { has: obj => "counter" in obj, get: obj => obj.counter, set: (obj, value) => { obj.counter = value; } }, metadata: _metadata }, _counter_initializers, _counter_extraInitializers);
|
|
159
|
+
__esDecorate(_a, null, _using_decorators, { kind: "method", name: "using", static: false, private: false, access: { has: obj => "using" in obj, get: obj => obj.using }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
160
|
+
__esDecorate(_a, null, _increment_decorators, { kind: "method", name: "increment", static: false, private: false, access: { has: obj => "increment" in obj, get: obj => obj.increment }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
161
|
+
__esDecorate(_a, null, _get_isActive_decorators, { kind: "getter", name: "isActive", static: false, private: false, access: { has: obj => "isActive" in obj, get: obj => obj.isActive }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
162
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
163
|
+
})(),
|
|
164
|
+
_a;
|
|
165
|
+
})();
|
|
100
166
|
exports.CounterFlag = CounterFlag;
|
|
101
|
-
__decorate([
|
|
102
|
-
mobx_1.observable
|
|
103
|
-
], CounterFlag.prototype, "counter", void 0);
|
|
104
|
-
__decorate([
|
|
105
|
-
mobx_1.action
|
|
106
|
-
], CounterFlag.prototype, "using", null);
|
|
107
|
-
__decorate([
|
|
108
|
-
mobx_1.action
|
|
109
|
-
], CounterFlag.prototype, "increment", null);
|
|
110
|
-
__decorate([
|
|
111
|
-
mobx_1.computed
|
|
112
|
-
], CounterFlag.prototype, "isActive", null);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { InteractionResponse } from "./InteractionResponse";
|
|
2
2
|
/** Contains predefined common responses and their ID. */
|
|
3
3
|
export declare class CommonInteractionResponses {
|
|
4
|
-
static
|
|
4
|
+
static readonly ok: {
|
|
5
5
|
id: string;
|
|
6
6
|
action: InteractionResponse;
|
|
7
7
|
};
|
|
8
|
-
static
|
|
8
|
+
static readonly cancel: {
|
|
9
9
|
id: string;
|
|
10
10
|
action: InteractionResponse;
|
|
11
11
|
};
|
|
12
|
-
static
|
|
12
|
+
static readonly close: {
|
|
13
13
|
id: string;
|
|
14
14
|
action: InteractionResponse;
|
|
15
15
|
};
|
|
16
|
-
static
|
|
16
|
+
static readonly yes: {
|
|
17
17
|
id: string;
|
|
18
18
|
action: InteractionResponse;
|
|
19
19
|
};
|
|
20
|
-
static
|
|
20
|
+
static readonly no: {
|
|
21
21
|
id: string;
|
|
22
22
|
action: InteractionResponse;
|
|
23
23
|
};
|
|
@@ -4,10 +4,10 @@ exports.CommonInteractionResponses = void 0;
|
|
|
4
4
|
const InteractionResponse_1 = require("./InteractionResponse");
|
|
5
5
|
/** Contains predefined common responses and their ID. */
|
|
6
6
|
class CommonInteractionResponses {
|
|
7
|
-
static get ok() { return { id: 'ok', action: new InteractionResponse_1.InteractionResponse('ok', 'OK') }; }
|
|
8
|
-
static get cancel() { return { id: 'cancel', action: new InteractionResponse_1.InteractionResponse('cancel', 'Cancel') }; }
|
|
9
|
-
static get close() { return { id: 'close', action: new InteractionResponse_1.InteractionResponse('close', 'Close') }; }
|
|
10
|
-
static get yes() { return { id: 'yes', action: new InteractionResponse_1.InteractionResponse('yes', 'Yes') }; }
|
|
11
|
-
static get no() { return { id: 'no', action: new InteractionResponse_1.InteractionResponse('no', 'No') }; }
|
|
12
7
|
}
|
|
13
8
|
exports.CommonInteractionResponses = CommonInteractionResponses;
|
|
9
|
+
CommonInteractionResponses.ok = { id: 'ok', action: new InteractionResponse_1.InteractionResponse('ok', 'OK') };
|
|
10
|
+
CommonInteractionResponses.cancel = { id: 'cancel', action: new InteractionResponse_1.InteractionResponse('cancel', 'Cancel') };
|
|
11
|
+
CommonInteractionResponses.close = { id: 'close', action: new InteractionResponse_1.InteractionResponse('close', 'Close') };
|
|
12
|
+
CommonInteractionResponses.yes = { id: 'yes', action: new InteractionResponse_1.InteractionResponse('yes', 'Yes') };
|
|
13
|
+
CommonInteractionResponses.no = { id: 'no', action: new InteractionResponse_1.InteractionResponse('no', 'No') };
|
|
@@ -3,12 +3,12 @@ import { RelayCommand } from "../commands/RelayCommand";
|
|
|
3
3
|
export declare class InteractionResponse {
|
|
4
4
|
/** The ID of the response. */
|
|
5
5
|
readonly id: string;
|
|
6
|
-
/** The title of the response. */
|
|
7
|
-
readonly title: string;
|
|
8
6
|
/** An optional command to invoke as the user responds. */
|
|
9
7
|
readonly command?: RelayCommand<void> | undefined;
|
|
10
8
|
/** An optional icon. */
|
|
11
9
|
readonly icon?: string | undefined;
|
|
10
|
+
/** The title of the response. */
|
|
11
|
+
accessor title: string;
|
|
12
12
|
constructor(
|
|
13
13
|
/** The ID of the response. */
|
|
14
14
|
id: string,
|
|
@@ -1,21 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
39
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
40
|
+
};
|
|
41
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
42
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
43
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
44
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
45
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
46
|
+
};
|
|
2
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
48
|
exports.InteractionResponse = void 0;
|
|
49
|
+
const mobx_1 = require("mobx");
|
|
4
50
|
/** Represents an action for the user to respond on an interaction request. */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
51
|
+
let InteractionResponse = (() => {
|
|
52
|
+
var _a, _InteractionResponse_title_accessor_storage;
|
|
53
|
+
let _title_decorators;
|
|
54
|
+
let _title_initializers = [];
|
|
55
|
+
let _title_extraInitializers = [];
|
|
56
|
+
return _a = class InteractionResponse {
|
|
57
|
+
/** The title of the response. */
|
|
58
|
+
get title() { return __classPrivateFieldGet(this, _InteractionResponse_title_accessor_storage, "f"); }
|
|
59
|
+
set title(value) { __classPrivateFieldSet(this, _InteractionResponse_title_accessor_storage, value, "f"); }
|
|
60
|
+
constructor(
|
|
61
|
+
/** The ID of the response. */
|
|
62
|
+
id,
|
|
63
|
+
/** The title of the response. */
|
|
64
|
+
title,
|
|
65
|
+
/** An optional command to invoke as the user responds. */
|
|
66
|
+
command,
|
|
67
|
+
/** An optional icon. */
|
|
68
|
+
icon) {
|
|
69
|
+
this.id = id;
|
|
70
|
+
this.command = command;
|
|
71
|
+
this.icon = icon;
|
|
72
|
+
_InteractionResponse_title_accessor_storage.set(this, __runInitializers(this, _title_initializers, ''));
|
|
73
|
+
__runInitializers(this, _title_extraInitializers);
|
|
74
|
+
this.id = id;
|
|
75
|
+
this.command = command;
|
|
76
|
+
this.icon = icon;
|
|
77
|
+
this.title = title;
|
|
78
|
+
(0, mobx_1.makeObservable)(this);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
_InteractionResponse_title_accessor_storage = new WeakMap(),
|
|
82
|
+
(() => {
|
|
83
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
84
|
+
_title_decorators = [mobx_1.observable];
|
|
85
|
+
__esDecorate(_a, null, _title_decorators, { kind: "accessor", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
|
|
86
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
87
|
+
})(),
|
|
88
|
+
_a;
|
|
89
|
+
})();
|
|
21
90
|
exports.InteractionResponse = InteractionResponse;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InteractionManager } from "./InteractionManager";
|
|
2
2
|
import { InteractionRequest } from "./InteractionRequest";
|
|
3
3
|
export declare class SingleConcurrentInteractionManager implements InteractionManager {
|
|
4
|
-
interactionRequest: InteractionRequest | null;
|
|
4
|
+
accessor interactionRequest: InteractionRequest | null;
|
|
5
5
|
private resolveFunc?;
|
|
6
6
|
constructor();
|
|
7
7
|
requestInteraction(interactionRequest: InteractionRequest): Promise<string | void>;
|
|
@@ -1,38 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
39
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
40
|
+
};
|
|
41
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
42
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
43
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
44
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
45
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
46
|
};
|
|
8
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
48
|
exports.SingleConcurrentInteractionManager = void 0;
|
|
10
49
|
const mobx_1 = require("mobx");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
let SingleConcurrentInteractionManager = (() => {
|
|
51
|
+
var _a, _SingleConcurrentInteractionManager_interactionRequest_accessor_storage;
|
|
52
|
+
let _instanceExtraInitializers = [];
|
|
53
|
+
let _interactionRequest_decorators;
|
|
54
|
+
let _interactionRequest_initializers = [];
|
|
55
|
+
let _interactionRequest_extraInitializers = [];
|
|
56
|
+
let _requestInteraction_decorators;
|
|
57
|
+
let _respond_decorators;
|
|
58
|
+
return _a = class SingleConcurrentInteractionManager {
|
|
59
|
+
get interactionRequest() { return __classPrivateFieldGet(this, _SingleConcurrentInteractionManager_interactionRequest_accessor_storage, "f"); }
|
|
60
|
+
set interactionRequest(value) { __classPrivateFieldSet(this, _SingleConcurrentInteractionManager_interactionRequest_accessor_storage, value, "f"); }
|
|
61
|
+
constructor() {
|
|
62
|
+
_SingleConcurrentInteractionManager_interactionRequest_accessor_storage.set(this, (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _interactionRequest_initializers, { title: '', content: '' })));
|
|
63
|
+
this.resolveFunc = __runInitializers(this, _interactionRequest_extraInitializers);
|
|
64
|
+
(0, mobx_1.makeObservable)(this);
|
|
65
|
+
this.interactionRequest = null;
|
|
66
|
+
}
|
|
67
|
+
requestInteraction(interactionRequest) {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
this.interactionRequest = interactionRequest;
|
|
70
|
+
this.resolveFunc = resolve;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
respond(interactionResponse) {
|
|
74
|
+
this.interactionRequest = null;
|
|
75
|
+
this.resolveFunc(interactionResponse);
|
|
76
|
+
this.resolveFunc = undefined;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
_SingleConcurrentInteractionManager_interactionRequest_accessor_storage = new WeakMap(),
|
|
80
|
+
(() => {
|
|
81
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
82
|
+
_interactionRequest_decorators = [mobx_1.observable];
|
|
83
|
+
_requestInteraction_decorators = [mobx_1.action];
|
|
84
|
+
_respond_decorators = [mobx_1.action];
|
|
85
|
+
__esDecorate(_a, null, _interactionRequest_decorators, { kind: "accessor", name: "interactionRequest", static: false, private: false, access: { has: obj => "interactionRequest" in obj, get: obj => obj.interactionRequest, set: (obj, value) => { obj.interactionRequest = value; } }, metadata: _metadata }, _interactionRequest_initializers, _interactionRequest_extraInitializers);
|
|
86
|
+
__esDecorate(_a, null, _requestInteraction_decorators, { kind: "method", name: "requestInteraction", static: false, private: false, access: { has: obj => "requestInteraction" in obj, get: obj => obj.requestInteraction }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
87
|
+
__esDecorate(_a, null, _respond_decorators, { kind: "method", name: "respond", static: false, private: false, access: { has: obj => "respond" in obj, get: obj => obj.respond }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
88
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
89
|
+
})(),
|
|
90
|
+
_a;
|
|
91
|
+
})();
|
|
29
92
|
exports.SingleConcurrentInteractionManager = SingleConcurrentInteractionManager;
|
|
30
|
-
__decorate([
|
|
31
|
-
mobx_1.observable
|
|
32
|
-
], SingleConcurrentInteractionManager.prototype, "interactionRequest", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
mobx_1.action
|
|
35
|
-
], SingleConcurrentInteractionManager.prototype, "requestInteraction", null);
|
|
36
|
-
__decorate([
|
|
37
|
-
mobx_1.action
|
|
38
|
-
], SingleConcurrentInteractionManager.prototype, "respond", null);
|