@omnia/velcron 6.100.8-dev
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/README.md +6 -0
- package/actions/ActionResults.d.ts +4 -0
- package/actions/ActionResults.js +14 -0
- package/actions/Alert.d.ts +2 -0
- package/actions/Alert.js +12 -0
- package/actions/Array.d.ts +3 -0
- package/actions/Array.js +22 -0
- package/actions/Debounce.d.ts +2 -0
- package/actions/Debounce.js +43 -0
- package/actions/Delay.d.ts +2 -0
- package/actions/Delay.js +14 -0
- package/actions/Emit.d.ts +2 -0
- package/actions/Emit.js +25 -0
- package/actions/Http.d.ts +2 -0
- package/actions/Http.js +32 -0
- package/actions/IActionHandler.d.ts +5 -0
- package/actions/IActionHandler.js +2 -0
- package/actions/Log.d.ts +2 -0
- package/actions/Log.js +10 -0
- package/actions/MsGraph.d.ts +2 -0
- package/actions/MsGraph.js +16 -0
- package/actions/MsSharePoint.d.ts +2 -0
- package/actions/MsSharePoint.js +17 -0
- package/actions/index.d.ts +11 -0
- package/actions/index.js +14 -0
- package/index.d.ts +6 -0
- package/index.js +9 -0
- package/internal-do-not-import-from-here/shared/models/Bring.d.ts +23 -0
- package/internal-do-not-import-from-here/shared/models/Bring.js +2 -0
- package/internal-do-not-import-from-here/shared/models/Broadcasting.d.ts +25 -0
- package/internal-do-not-import-from-here/shared/models/Broadcasting.js +12 -0
- package/internal-do-not-import-from-here/shared/models/Future.d.ts +44 -0
- package/internal-do-not-import-from-here/shared/models/Future.js +122 -0
- package/internal-do-not-import-from-here/shared/models/Guid.d.ts +17 -0
- package/internal-do-not-import-from-here/shared/models/Guid.js +51 -0
- package/internal-do-not-import-from-here/shared/models/OmniaSharedBootstrapData.d.ts +32 -0
- package/internal-do-not-import-from-here/shared/models/OmniaSharedBootstrapData.js +2 -0
- package/internal-do-not-import-from-here/shared/models/Realtime.d.ts +40 -0
- package/internal-do-not-import-from-here/shared/models/Realtime.js +40 -0
- package/internal-do-not-import-from-here/shared/models/SharedConstants.d.ts +5 -0
- package/internal-do-not-import-from-here/shared/models/SharedConstants.js +9 -0
- package/internal-do-not-import-from-here/shared/models/StringExtensions.d.ts +6 -0
- package/internal-do-not-import-from-here/shared/models/StringExtensions.js +3 -0
- package/internal-do-not-import-from-here/shared/models/Tenant.d.ts +4 -0
- package/internal-do-not-import-from-here/shared/models/Tenant.js +2 -0
- package/internal-do-not-import-from-here/shared/models/Tokens.d.ts +14 -0
- package/internal-do-not-import-from-here/shared/models/Tokens.js +2 -0
- package/internal-do-not-import-from-here/shared/models/Topic.d.ts +10 -0
- package/internal-do-not-import-from-here/shared/models/Topic.js +2 -0
- package/internal-do-not-import-from-here/shared/models/WorkerProxyFuncs.d.ts +8 -0
- package/internal-do-not-import-from-here/shared/models/WorkerProxyFuncs.js +14 -0
- package/internal-do-not-import-from-here/shared/models/Workers.d.ts +29 -0
- package/internal-do-not-import-from-here/shared/models/Workers.js +8 -0
- package/internal-do-not-import-from-here/shared/models/index.d.ts +14 -0
- package/internal-do-not-import-from-here/shared/models/index.js +18 -0
- package/internal-do-not-import-from-here/shared/models/theming/BlueprintDefinition.d.ts +27 -0
- package/internal-do-not-import-from-here/shared/models/theming/BlueprintDefinition.js +2 -0
- package/internal-do-not-import-from-here/shared/models/theming/OmniaThemes.d.ts +5 -0
- package/internal-do-not-import-from-here/shared/models/theming/OmniaThemes.js +18 -0
- package/internal-do-not-import-from-here/shared/models/theming/ThemeDefinitionV2.d.ts +61 -0
- package/internal-do-not-import-from-here/shared/models/theming/ThemeDefinitionV2.js +24 -0
- package/internal-do-not-import-from-here/shared/models/theming/ThemeMethods.d.ts +11 -0
- package/internal-do-not-import-from-here/shared/models/theming/ThemeMethods.js +143 -0
- package/internal-do-not-import-from-here/shared/models/theming/TypographyDefinition.d.ts +29 -0
- package/internal-do-not-import-from-here/shared/models/theming/TypographyDefinition.js +11 -0
- package/internal-do-not-import-from-here/shared/models/theming/index.d.ts +4 -0
- package/internal-do-not-import-from-here/shared/models/theming/index.js +7 -0
- package/models/ActionHooks.d.ts +12 -0
- package/models/ActionHooks.js +2 -0
- package/models/Enums.d.ts +53 -0
- package/models/Enums.js +65 -0
- package/models/VelcronDefinitions.d.ts +265 -0
- package/models/VelcronDefinitions.js +8 -0
- package/models/VelcronDescriptors.d.ts +35 -0
- package/models/VelcronDescriptors.js +2 -0
- package/models/VelcronEvents.d.ts +16 -0
- package/models/VelcronEvents.js +2 -0
- package/models/VelcronTypes.d.ts +10 -0
- package/models/VelcronTypes.js +2 -0
- package/models/VelcronUnitProvider.d.ts +5 -0
- package/models/VelcronUnitProvider.js +2 -0
- package/models/ViewModelAndContext.d.ts +4 -0
- package/models/ViewModelAndContext.js +2 -0
- package/models/index.d.ts +8 -0
- package/models/index.js +11 -0
- package/package.json +27 -0
- package/parser/TextValue.d.ts +4 -0
- package/parser/TextValue.js +9 -0
- package/parser/VelcronActions.d.ts +42 -0
- package/parser/VelcronActions.js +460 -0
- package/parser/VelcronConstants.d.ts +30 -0
- package/parser/VelcronConstants.js +33 -0
- package/parser/VelcronData.d.ts +39 -0
- package/parser/VelcronData.js +634 -0
- package/parser/VelcronLogger.d.ts +6 -0
- package/parser/VelcronLogger.js +18 -0
- package/parser/VelcronRenderers.d.ts +41 -0
- package/parser/VelcronRenderers.js +125 -0
- package/parser/VelcronStyles.d.ts +12 -0
- package/parser/VelcronStyles.js +159 -0
- package/parser/index.d.ts +7 -0
- package/parser/index.js +10 -0
- package/stores/ReactivitySystem.d.ts +5 -0
- package/stores/ReactivitySystem.js +12 -0
- package/stores/VelcronStore.d.ts +12 -0
- package/stores/VelcronStore.js +23 -0
- package/stores/VelcronTheming.d.ts +19 -0
- package/stores/VelcronTheming.js +49 -0
- package/stores/index.d.ts +3 -0
- package/stores/index.js +6 -0
- package/utilities/ColorUtility.d.ts +1 -0
- package/utilities/ColorUtility.js +45 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipSetValue = exports.CancelProcedingActions = void 0;
|
|
4
|
+
//When this class is returned as the value of action promise
|
|
5
|
+
//we will stop executing actions after.
|
|
6
|
+
class CancelProcedingActions {
|
|
7
|
+
}
|
|
8
|
+
exports.CancelProcedingActions = CancelProcedingActions;
|
|
9
|
+
//Actions can set this as the promise response
|
|
10
|
+
//to indicate that they have controled the set operation
|
|
11
|
+
//in the action. e.g @arrayAppend sets the values
|
|
12
|
+
class SkipSetValue {
|
|
13
|
+
}
|
|
14
|
+
exports.SkipSetValue = SkipSetValue;
|
package/actions/Alert.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alerter = void 0;
|
|
4
|
+
exports.alerter = {
|
|
5
|
+
name: "@alert",
|
|
6
|
+
action: (action, value, nisse) => {
|
|
7
|
+
//value = VelcronData.dataBind(action, value)
|
|
8
|
+
//alert(value + nisse ? nisse : 'nullsiu');
|
|
9
|
+
alert(`${value}`);
|
|
10
|
+
return Promise.resolve(null);
|
|
11
|
+
}
|
|
12
|
+
};
|
package/actions/Array.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayTake = exports.arrayAppend = void 0;
|
|
4
|
+
const VelcronData_1 = require("../parser/VelcronData");
|
|
5
|
+
const ActionResults_1 = require("./ActionResults");
|
|
6
|
+
exports.arrayAppend = {
|
|
7
|
+
name: "@array.append",
|
|
8
|
+
action: (action, arrayToAppend) => {
|
|
9
|
+
const existingArray = VelcronData_1.VelcronData.getOrSetObjectByPathUsingRenderContext(action, action.path);
|
|
10
|
+
existingArray.push(...arrayToAppend);
|
|
11
|
+
return Promise.resolve(new ActionResults_1.SkipSetValue());
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.arrayTake = {
|
|
15
|
+
name: "@array.take",
|
|
16
|
+
action: (action, arr, takeTemplate) => {
|
|
17
|
+
takeTemplate = VelcronData_1.VelcronData.dataBind(action, takeTemplate);
|
|
18
|
+
const take = parseInt(takeTemplate);
|
|
19
|
+
arr = arr.slice(0, take);
|
|
20
|
+
return Promise.resolve(arr);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.debounce = void 0;
|
|
4
|
+
const VelcronData_1 = require("../parser/VelcronData");
|
|
5
|
+
const ActionResults_1 = require("./ActionResults");
|
|
6
|
+
const debounces = {};
|
|
7
|
+
exports.debounce = {
|
|
8
|
+
name: "@debounce",
|
|
9
|
+
action: (action, value) => {
|
|
10
|
+
//TODO Try catch
|
|
11
|
+
value = VelcronData_1.VelcronData.dataBind(action, value);
|
|
12
|
+
const bounceDelayTime = parseInt(value);
|
|
13
|
+
if (!debounces[action.id]) {
|
|
14
|
+
debounces[action.id] = debounceInternal(() => { Promise.resolve(); }, bounceDelayTime);
|
|
15
|
+
}
|
|
16
|
+
return debounces[action.id]();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function debounceInternal(inner, ms = 0) {
|
|
20
|
+
let timer;
|
|
21
|
+
let resolves = [];
|
|
22
|
+
return function (...args) {
|
|
23
|
+
// Run the function after a certain amount of time
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
timer = setTimeout(() => {
|
|
26
|
+
// Get the result of the inner function, then apply it to the resolve function of
|
|
27
|
+
// each promise that has been created since the last time the inner function was run
|
|
28
|
+
const result = inner(...args);
|
|
29
|
+
let count = 1;
|
|
30
|
+
resolves.forEach((resolvable) => {
|
|
31
|
+
if (count === resolves.length) {
|
|
32
|
+
resolvable.resolve(null);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
resolvable.resolve(new ActionResults_1.CancelProcedingActions());
|
|
36
|
+
}
|
|
37
|
+
count++;
|
|
38
|
+
});
|
|
39
|
+
resolves = [];
|
|
40
|
+
}, ms);
|
|
41
|
+
return new Promise((resolve, reject) => resolves.push({ resolve: resolve, reject: reject }));
|
|
42
|
+
};
|
|
43
|
+
}
|
package/actions/Delay.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delay = void 0;
|
|
4
|
+
const VelcronData_1 = require("../parser/VelcronData");
|
|
5
|
+
exports.delay = {
|
|
6
|
+
name: "@delay",
|
|
7
|
+
action: (action, value) => {
|
|
8
|
+
value = VelcronData_1.VelcronData.dataBind(action, value);
|
|
9
|
+
const delayTime = parseInt(value);
|
|
10
|
+
return new Promise(function (resolve) {
|
|
11
|
+
setTimeout(resolve.bind(null, null), delayTime);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
package/actions/Emit.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emit = void 0;
|
|
4
|
+
const parser_1 = require("../parser");
|
|
5
|
+
exports.emit = {
|
|
6
|
+
name: "@emit",
|
|
7
|
+
action: (action, value, ...args) => {
|
|
8
|
+
if (action.eventHandlers?.receiving) {
|
|
9
|
+
let found = false;
|
|
10
|
+
Object.keys(action.eventHandlers?.receiving).forEach((key) => {
|
|
11
|
+
if (value.toLowerCase() == key.toLowerCase()) {
|
|
12
|
+
action.eventHandlers?.receiving[key](...args);
|
|
13
|
+
found = true;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (!found) {
|
|
17
|
+
parser_1.VelcronLogger.logActionError(`Could not find incoming event handler for ${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
parser_1.VelcronLogger.logActionError("There is no incoming event handlers registered");
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve(null);
|
|
24
|
+
}
|
|
25
|
+
};
|
package/actions/Http.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpGet = void 0;
|
|
4
|
+
const parser_1 = require("../parser");
|
|
5
|
+
exports.httpGet = {
|
|
6
|
+
name: "@http.get",
|
|
7
|
+
action: (action, incomingUrl) => {
|
|
8
|
+
return new Promise(function (resolve) {
|
|
9
|
+
incomingUrl = parser_1.VelcronData.dataBind(action, incomingUrl);
|
|
10
|
+
let requestInitLocal = { "method": "GET" };
|
|
11
|
+
const hookResult = parser_1.VelcronActions.tryTriggerBeforeActionHook("http.get", { url: incomingUrl, requestInit: requestInitLocal });
|
|
12
|
+
incomingUrl = hookResult?.url ?? incomingUrl;
|
|
13
|
+
requestInitLocal = hookResult?.requestInit ?? requestInitLocal;
|
|
14
|
+
fetch(incomingUrl, requestInitLocal)
|
|
15
|
+
.then(async (response) => {
|
|
16
|
+
const res = parser_1.VelcronActions.tryTriggerAfterActionHook("http.get", {
|
|
17
|
+
json: await response.json(),
|
|
18
|
+
response: response
|
|
19
|
+
});
|
|
20
|
+
return res.json;
|
|
21
|
+
})
|
|
22
|
+
.then((json) => {
|
|
23
|
+
resolve(json);
|
|
24
|
+
})
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
//How do we handle errors?
|
|
27
|
+
console.error("Velcron @http.get error occurred:", error);
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
package/actions/Log.d.ts
ADDED
package/actions/Log.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.msGraphGet = void 0;
|
|
4
|
+
const VelcronData_1 = require("../parser/VelcronData");
|
|
5
|
+
exports.msGraphGet = {
|
|
6
|
+
name: "@msgraph.get",
|
|
7
|
+
action: (action, value) => {
|
|
8
|
+
return new Promise(async function (resolve) {
|
|
9
|
+
//TODO Make it typed!
|
|
10
|
+
const client = await window.omniaScriptApi.m365.graphClient;
|
|
11
|
+
value = VelcronData_1.VelcronData.dataBind(action, value);
|
|
12
|
+
const res = await client.get(value);
|
|
13
|
+
resolve(res.data);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.msSp = void 0;
|
|
4
|
+
const VelcronData_1 = require("../parser/VelcronData");
|
|
5
|
+
//TODO This should be pluggable from sharepoint package
|
|
6
|
+
exports.msSp = {
|
|
7
|
+
name: "@mssp.get",
|
|
8
|
+
action: (action, value) => {
|
|
9
|
+
return new Promise(async function (resolve) {
|
|
10
|
+
//TODO Make it typed!
|
|
11
|
+
const client = await window.omniaScriptApi.spfx.sharepointClient;
|
|
12
|
+
value = VelcronData_1.VelcronData.dataBind(action, value);
|
|
13
|
+
const res = await client.get(value);
|
|
14
|
+
resolve(res.data);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./IActionHandler";
|
|
2
|
+
export * from "./Delay";
|
|
3
|
+
export * from "./Http";
|
|
4
|
+
export * from "./Debounce";
|
|
5
|
+
export * from "./ActionResults";
|
|
6
|
+
export * from "./Array";
|
|
7
|
+
export * from "./Alert";
|
|
8
|
+
export * from "./Log";
|
|
9
|
+
export * from "./MsGraph";
|
|
10
|
+
export * from "./MsSharePoint";
|
|
11
|
+
export * from "./Emit";
|
package/actions/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./IActionHandler"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./Delay"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./Http"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./Debounce"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./ActionResults"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./Array"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./Alert"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./Log"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./MsGraph"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./MsSharePoint"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./Emit"), exports);
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./models"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./parser"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./actions"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./stores"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("@omnia/velcron/internal-do-not-import-from-here/shared/models"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./utilities"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type BringMethods = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
2
|
+
export type BringCacheOptions = "no-cache" | "reload" | "force-cache" | "only-if-cached";
|
|
3
|
+
export type BringCredentials = "include" | "omit" | "same-origin";
|
|
4
|
+
export interface BringInterceptOptions {
|
|
5
|
+
beforeRequest?: (request: BringConfig) => BringConfig;
|
|
6
|
+
afterRequest?: <T>(response: BringResponse<T>, request: BringConfig) => BringResponse<T>;
|
|
7
|
+
}
|
|
8
|
+
export interface BringConfig {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
headers?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
cache?: BringCacheOptions;
|
|
14
|
+
interceptors?: BringInterceptOptions;
|
|
15
|
+
abortable?: boolean;
|
|
16
|
+
credentials?: BringCredentials;
|
|
17
|
+
}
|
|
18
|
+
export interface BringResponse<TData> {
|
|
19
|
+
data?: TData;
|
|
20
|
+
status: Number;
|
|
21
|
+
statusText: String;
|
|
22
|
+
ok: Boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Topic } from "./Topic";
|
|
2
|
+
export declare enum BroadcastTopicScopes {
|
|
3
|
+
localUi = "localUi",
|
|
4
|
+
localWorker = "localWorker",
|
|
5
|
+
localAll = "localAll",
|
|
6
|
+
globalUi = "globalUi",
|
|
7
|
+
globalWorker = "globalWorker",
|
|
8
|
+
globalAll = "globalAll"
|
|
9
|
+
}
|
|
10
|
+
export interface BroadcastTopic<TMessage> extends Topic<TMessage> {
|
|
11
|
+
scope: BroadcastTopicScopes;
|
|
12
|
+
}
|
|
13
|
+
export interface BroadcastInvokeTopic<TMessage, TReturnValue> extends Topic<TMessage> {
|
|
14
|
+
scope: BroadcastTopicScopes;
|
|
15
|
+
}
|
|
16
|
+
export interface BroadcastMessage<TMessage> extends BroadcastTopic<TMessage> {
|
|
17
|
+
message: TMessage;
|
|
18
|
+
}
|
|
19
|
+
export interface BroadcastInvokeMessage<TMessage, TReturnValue> extends BroadcastInvokeTopic<TMessage, TReturnValue> {
|
|
20
|
+
messageId: string;
|
|
21
|
+
message: TMessage;
|
|
22
|
+
type: "request" | "response";
|
|
23
|
+
error?: string;
|
|
24
|
+
response?: TReturnValue;
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BroadcastTopicScopes = void 0;
|
|
4
|
+
var BroadcastTopicScopes;
|
|
5
|
+
(function (BroadcastTopicScopes) {
|
|
6
|
+
BroadcastTopicScopes["localUi"] = "localUi";
|
|
7
|
+
BroadcastTopicScopes["localWorker"] = "localWorker";
|
|
8
|
+
BroadcastTopicScopes["localAll"] = "localAll";
|
|
9
|
+
BroadcastTopicScopes["globalUi"] = "globalUi";
|
|
10
|
+
BroadcastTopicScopes["globalWorker"] = "globalWorker";
|
|
11
|
+
BroadcastTopicScopes["globalAll"] = "globalAll";
|
|
12
|
+
})(BroadcastTopicScopes = exports.BroadcastTopicScopes || (exports.BroadcastTopicScopes = {}));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare class Future<T> extends Promise<T> {
|
|
2
|
+
resolve: (value: T) => void;
|
|
3
|
+
reject: (reason: any) => void;
|
|
4
|
+
resolving: boolean;
|
|
5
|
+
private _resolved;
|
|
6
|
+
private _rejected;
|
|
7
|
+
private onAborted;
|
|
8
|
+
constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void, onAborted: (cb: (reason?: any) => void) => void) => void);
|
|
9
|
+
/**
|
|
10
|
+
* Handles success / rejection from Promise and returns the result as an object.
|
|
11
|
+
* If the promise is rejected, the error will be in the error property.
|
|
12
|
+
* No need to try/catch the promise when using this method.
|
|
13
|
+
*
|
|
14
|
+
* @return {*} {Future<{ success?: T, error?: Error; }>}
|
|
15
|
+
* @memberof Future
|
|
16
|
+
*/
|
|
17
|
+
tryCatch(): Future<[success: T, error: Error]>;
|
|
18
|
+
/**
|
|
19
|
+
* Aborts the request
|
|
20
|
+
*
|
|
21
|
+
* @param {*} [reason]
|
|
22
|
+
* @memberof Future
|
|
23
|
+
*/
|
|
24
|
+
abort(reason?: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
27
|
+
* resolve, or rejected when any Promise is rejected.
|
|
28
|
+
* @param values An array of Promises.
|
|
29
|
+
* @returns A new Promise.
|
|
30
|
+
*/
|
|
31
|
+
static all<T extends readonly unknown[] | []>(values: T): Promise<{
|
|
32
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
33
|
+
}>;
|
|
34
|
+
get resolved(): boolean;
|
|
35
|
+
get rejected(): boolean;
|
|
36
|
+
static get [Symbol.species](): PromiseConstructor;
|
|
37
|
+
get [Symbol.toStringTag](): string;
|
|
38
|
+
static new<TReturnValue>(): Future<TReturnValue>;
|
|
39
|
+
}
|
|
40
|
+
export declare class ResponsePromise<T> extends Promise<T> {
|
|
41
|
+
cancelCb: (() => void);
|
|
42
|
+
constructor(executor: any);
|
|
43
|
+
cancel(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponsePromise = exports.Future = void 0;
|
|
4
|
+
class Future extends Promise {
|
|
5
|
+
constructor(executor) {
|
|
6
|
+
let resolveLocal;
|
|
7
|
+
let rejectLocal;
|
|
8
|
+
const onAborted = (cb) => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
this.onAborted = cb;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const exec = (resolve, reject) => {
|
|
14
|
+
// assign to local to prevent error assignbefore call super;
|
|
15
|
+
resolveLocal = resolve;
|
|
16
|
+
rejectLocal = reject;
|
|
17
|
+
};
|
|
18
|
+
super(exec);
|
|
19
|
+
this.resolving = false;
|
|
20
|
+
this._resolved = false;
|
|
21
|
+
this._rejected = false;
|
|
22
|
+
this.resolve = (value) => {
|
|
23
|
+
this.resolving = false;
|
|
24
|
+
this._resolved = true;
|
|
25
|
+
resolveLocal(value);
|
|
26
|
+
};
|
|
27
|
+
this.reject = (reason) => {
|
|
28
|
+
this.resolving = false;
|
|
29
|
+
this._rejected = true;
|
|
30
|
+
rejectLocal(reason);
|
|
31
|
+
};
|
|
32
|
+
if (executor) {
|
|
33
|
+
executor(this.resolve, this.reject, onAborted);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Handles success / rejection from Promise and returns the result as an object.
|
|
38
|
+
* If the promise is rejected, the error will be in the error property.
|
|
39
|
+
* No need to try/catch the promise when using this method.
|
|
40
|
+
*
|
|
41
|
+
* @return {*} {Future<{ success?: T, error?: Error; }>}
|
|
42
|
+
* @memberof Future
|
|
43
|
+
*/
|
|
44
|
+
//tryCatch(): Future<{ success?: T, error?: Error; }> {
|
|
45
|
+
tryCatch() {
|
|
46
|
+
return new Future(async (resolve) => {
|
|
47
|
+
try {
|
|
48
|
+
const data = await this;
|
|
49
|
+
resolve([data, undefined]);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
resolve([undefined, err]);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Aborts the request
|
|
58
|
+
*
|
|
59
|
+
* @param {*} [reason]
|
|
60
|
+
* @memberof Future
|
|
61
|
+
*/
|
|
62
|
+
abort(reason) {
|
|
63
|
+
if (this.onAborted) {
|
|
64
|
+
this.onAborted(reason);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw "Failed calling abort() => The future has no onAborted callback or you tried to call abort immediately after the future was created.";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
72
|
+
* resolve, or rejected when any Promise is rejected.
|
|
73
|
+
* @param values An array of Promises.
|
|
74
|
+
* @returns A new Promise.
|
|
75
|
+
*/
|
|
76
|
+
static all(values) {
|
|
77
|
+
// have issue with Promise.all not working when promises is mixin Future and promise
|
|
78
|
+
// so implement Future.all to make a wrapper promise to Future to resolve that issue.
|
|
79
|
+
const promises = values.map(p => p instanceof Future ? new Promise((resolve, reject) => p.then(resolve, reject)) : p);
|
|
80
|
+
return Promise.all(promises);
|
|
81
|
+
}
|
|
82
|
+
get resolved() {
|
|
83
|
+
return this._resolved;
|
|
84
|
+
}
|
|
85
|
+
get rejected() {
|
|
86
|
+
return this._rejected;
|
|
87
|
+
}
|
|
88
|
+
static get [Symbol.species]() {
|
|
89
|
+
return Promise;
|
|
90
|
+
}
|
|
91
|
+
get [Symbol.toStringTag]() {
|
|
92
|
+
// return Object value to make vue can build get/set reactive.
|
|
93
|
+
return "Object";
|
|
94
|
+
}
|
|
95
|
+
static new() {
|
|
96
|
+
return new Future(() => { });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.Future = Future;
|
|
100
|
+
class ResponsePromise extends Promise {
|
|
101
|
+
constructor(executor) {
|
|
102
|
+
const onCancel = (cb) => {
|
|
103
|
+
//using nextTick because we cant use "this" before super()
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
this.cancelCb = cb;
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const oExecutor = (resolve, reject) => {
|
|
109
|
+
executor(resolve, reject, onCancel);
|
|
110
|
+
};
|
|
111
|
+
super(oExecutor);
|
|
112
|
+
}
|
|
113
|
+
cancel() {
|
|
114
|
+
if (this.cancelCb) {
|
|
115
|
+
this.cancelCb();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.warn("onCancel not provided");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.ResponsePromise = ResponsePromise;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface GuidValue {
|
|
2
|
+
toString: () => string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Class to create a guid
|
|
6
|
+
*/
|
|
7
|
+
export declare class Guid implements GuidValue {
|
|
8
|
+
private static _empty;
|
|
9
|
+
static newGuid(): GuidValue;
|
|
10
|
+
static get empty(): GuidValue;
|
|
11
|
+
static isValid(guid: string | GuidValue): boolean;
|
|
12
|
+
private value;
|
|
13
|
+
constructor(guid: string);
|
|
14
|
+
toString(): string;
|
|
15
|
+
toJSON: () => string;
|
|
16
|
+
valueOf(): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//export interface GuidValue {
|
|
3
|
+
// :string;
|
|
4
|
+
//}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Guid = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Class to create a guid
|
|
9
|
+
*/
|
|
10
|
+
class Guid {
|
|
11
|
+
static newGuid() {
|
|
12
|
+
return new Guid("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
|
|
13
|
+
const r = Math.random() * 16 | 0;
|
|
14
|
+
const v = (c == "x") ? r : (r & 0x3 | 0x8);
|
|
15
|
+
return v.toString(16);
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
static get empty() {
|
|
19
|
+
return this._empty;
|
|
20
|
+
}
|
|
21
|
+
static isValid(guid) {
|
|
22
|
+
if (guid === undefined || guid === null) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const validRegex = /^[{]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[}]?$/;
|
|
26
|
+
return validRegex.test(guid.toString());
|
|
27
|
+
}
|
|
28
|
+
constructor(guid) {
|
|
29
|
+
this.value = Guid._empty;
|
|
30
|
+
//We serialize as string value
|
|
31
|
+
this.toJSON = () => {
|
|
32
|
+
return this.value.toLowerCase();
|
|
33
|
+
};
|
|
34
|
+
if (guid) {
|
|
35
|
+
if (Guid.isValid(guid)) {
|
|
36
|
+
this.value = guid;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw `The string '${guid}' is not a valid Guid`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
toString() {
|
|
44
|
+
return this.value.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
valueOf() {
|
|
47
|
+
return this.value.toLowerCase();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Guid = Guid;
|
|
51
|
+
Guid._empty = "00000000-0000-0000-0000-000000000000";
|