@omnia/velcron 7.0.36-preview

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.
Files changed (112) hide show
  1. package/README.md +6 -0
  2. package/actions/ActionResults.d.ts +4 -0
  3. package/actions/ActionResults.js +14 -0
  4. package/actions/Alert.d.ts +2 -0
  5. package/actions/Alert.js +12 -0
  6. package/actions/Array.d.ts +3 -0
  7. package/actions/Array.js +22 -0
  8. package/actions/Debounce.d.ts +2 -0
  9. package/actions/Debounce.js +43 -0
  10. package/actions/Delay.d.ts +2 -0
  11. package/actions/Delay.js +14 -0
  12. package/actions/Emit.d.ts +2 -0
  13. package/actions/Emit.js +25 -0
  14. package/actions/Http.d.ts +2 -0
  15. package/actions/Http.js +15 -0
  16. package/actions/IActionHandler.d.ts +5 -0
  17. package/actions/IActionHandler.js +2 -0
  18. package/actions/Log.d.ts +2 -0
  19. package/actions/Log.js +10 -0
  20. package/actions/MsGraph.d.ts +2 -0
  21. package/actions/MsGraph.js +16 -0
  22. package/actions/MsSharePoint.d.ts +2 -0
  23. package/actions/MsSharePoint.js +17 -0
  24. package/actions/index.d.ts +11 -0
  25. package/actions/index.js +14 -0
  26. package/index.d.ts +6 -0
  27. package/index.js +9 -0
  28. package/internal-do-not-import-from-here/shared/models/Bring.d.ts +23 -0
  29. package/internal-do-not-import-from-here/shared/models/Bring.js +2 -0
  30. package/internal-do-not-import-from-here/shared/models/Broadcasting.d.ts +25 -0
  31. package/internal-do-not-import-from-here/shared/models/Broadcasting.js +12 -0
  32. package/internal-do-not-import-from-here/shared/models/Future.d.ts +44 -0
  33. package/internal-do-not-import-from-here/shared/models/Future.js +122 -0
  34. package/internal-do-not-import-from-here/shared/models/Guid.d.ts +17 -0
  35. package/internal-do-not-import-from-here/shared/models/Guid.js +51 -0
  36. package/internal-do-not-import-from-here/shared/models/OmniaSharedBootstrapData.d.ts +25 -0
  37. package/internal-do-not-import-from-here/shared/models/OmniaSharedBootstrapData.js +2 -0
  38. package/internal-do-not-import-from-here/shared/models/Realtime.d.ts +40 -0
  39. package/internal-do-not-import-from-here/shared/models/Realtime.js +40 -0
  40. package/internal-do-not-import-from-here/shared/models/SharedConstants.d.ts +5 -0
  41. package/internal-do-not-import-from-here/shared/models/SharedConstants.js +9 -0
  42. package/internal-do-not-import-from-here/shared/models/StringExtensions.d.ts +6 -0
  43. package/internal-do-not-import-from-here/shared/models/StringExtensions.js +3 -0
  44. package/internal-do-not-import-from-here/shared/models/Tenant.d.ts +4 -0
  45. package/internal-do-not-import-from-here/shared/models/Tenant.js +2 -0
  46. package/internal-do-not-import-from-here/shared/models/Tokens.d.ts +13 -0
  47. package/internal-do-not-import-from-here/shared/models/Tokens.js +2 -0
  48. package/internal-do-not-import-from-here/shared/models/Topic.d.ts +10 -0
  49. package/internal-do-not-import-from-here/shared/models/Topic.js +2 -0
  50. package/internal-do-not-import-from-here/shared/models/WorkerProxyFuncs.d.ts +8 -0
  51. package/internal-do-not-import-from-here/shared/models/WorkerProxyFuncs.js +14 -0
  52. package/internal-do-not-import-from-here/shared/models/Workers.d.ts +29 -0
  53. package/internal-do-not-import-from-here/shared/models/Workers.js +8 -0
  54. package/internal-do-not-import-from-here/shared/models/index.d.ts +14 -0
  55. package/internal-do-not-import-from-here/shared/models/index.js +18 -0
  56. package/internal-do-not-import-from-here/shared/models/theming/BlueprintDefinition.d.ts +27 -0
  57. package/internal-do-not-import-from-here/shared/models/theming/BlueprintDefinition.js +2 -0
  58. package/internal-do-not-import-from-here/shared/models/theming/OmniaThemes.d.ts +5 -0
  59. package/internal-do-not-import-from-here/shared/models/theming/OmniaThemes.js +18 -0
  60. package/internal-do-not-import-from-here/shared/models/theming/ThemeDefinitionV2.d.ts +61 -0
  61. package/internal-do-not-import-from-here/shared/models/theming/ThemeDefinitionV2.js +24 -0
  62. package/internal-do-not-import-from-here/shared/models/theming/ThemeMethods.d.ts +11 -0
  63. package/internal-do-not-import-from-here/shared/models/theming/ThemeMethods.js +143 -0
  64. package/internal-do-not-import-from-here/shared/models/theming/TypographyDefinition.d.ts +29 -0
  65. package/internal-do-not-import-from-here/shared/models/theming/TypographyDefinition.js +11 -0
  66. package/internal-do-not-import-from-here/shared/models/theming/index.d.ts +4 -0
  67. package/internal-do-not-import-from-here/shared/models/theming/index.js +7 -0
  68. package/models/Enums.d.ts +53 -0
  69. package/models/Enums.js +65 -0
  70. package/models/VelcronDefinitions.d.ts +268 -0
  71. package/models/VelcronDefinitions.js +8 -0
  72. package/models/VelcronDescriptors.d.ts +35 -0
  73. package/models/VelcronDescriptors.js +2 -0
  74. package/models/VelcronEvents.d.ts +16 -0
  75. package/models/VelcronEvents.js +2 -0
  76. package/models/VelcronTypes.d.ts +10 -0
  77. package/models/VelcronTypes.js +2 -0
  78. package/models/VelcronUnitProvider.d.ts +5 -0
  79. package/models/VelcronUnitProvider.js +2 -0
  80. package/models/ViewModelAndContext.d.ts +4 -0
  81. package/models/ViewModelAndContext.js +2 -0
  82. package/models/index.d.ts +7 -0
  83. package/models/index.js +10 -0
  84. package/package.json +27 -0
  85. package/parser/TextValue.d.ts +4 -0
  86. package/parser/TextValue.js +9 -0
  87. package/parser/VelcronActions.d.ts +36 -0
  88. package/parser/VelcronActions.js +443 -0
  89. package/parser/VelcronConstants.d.ts +29 -0
  90. package/parser/VelcronConstants.js +32 -0
  91. package/parser/VelcronData.d.ts +39 -0
  92. package/parser/VelcronData.js +638 -0
  93. package/parser/VelcronLogger.d.ts +6 -0
  94. package/parser/VelcronLogger.js +18 -0
  95. package/parser/VelcronRenderers.d.ts +41 -0
  96. package/parser/VelcronRenderers.js +126 -0
  97. package/parser/VelcronStyles.d.ts +12 -0
  98. package/parser/VelcronStyles.js +159 -0
  99. package/parser/index.d.ts +7 -0
  100. package/parser/index.js +10 -0
  101. package/stores/ReactivitySystem.d.ts +5 -0
  102. package/stores/ReactivitySystem.js +12 -0
  103. package/stores/VelcronStore.d.ts +12 -0
  104. package/stores/VelcronStore.js +23 -0
  105. package/stores/VelcronTheming.d.ts +19 -0
  106. package/stores/VelcronTheming.js +49 -0
  107. package/stores/index.d.ts +3 -0
  108. package/stores/index.js +6 -0
  109. package/utilities/ColorUtility.d.ts +1 -0
  110. package/utilities/ColorUtility.js +45 -0
  111. package/utilities/index.d.ts +1 -0
  112. package/utilities/index.js +4 -0
@@ -0,0 +1,4 @@
1
+ import { VelcronAppDefinition } from "./VelcronDefinitions";
2
+ export interface AppJson {
3
+ app: VelcronAppDefinition;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export * from "./VelcronDefinitions";
2
+ export * from "./ViewModelAndContext";
3
+ export * from "./VelcronDescriptors";
4
+ export * from "./VelcronEvents";
5
+ export * from "./VelcronTypes";
6
+ export * from "./Enums";
7
+ export * from "./VelcronUnitProvider";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./VelcronDefinitions"), exports);
5
+ tslib_1.__exportStar(require("./ViewModelAndContext"), exports);
6
+ tslib_1.__exportStar(require("./VelcronDescriptors"), exports);
7
+ tslib_1.__exportStar(require("./VelcronEvents"), exports);
8
+ tslib_1.__exportStar(require("./VelcronTypes"), exports);
9
+ tslib_1.__exportStar(require("./Enums"), exports);
10
+ tslib_1.__exportStar(require("./VelcronUnitProvider"), exports);
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@omnia/velcron",
3
+ "license": "MIT",
4
+ "version": "7.0.36-preview",
5
+ "description": "Provide Omnia Velcron Stuffs.",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/preciofishbone/OmniaFx"
12
+ },
13
+ "keywords": [
14
+ "omnia",
15
+ "omniafx",
16
+ "extension",
17
+ "office365",
18
+ "sharepoint"
19
+ ],
20
+ "author": "Precio Fishbone",
21
+ "dependencies": {},
22
+ "typings": "./index.d.ts",
23
+ "bugs": {
24
+ "url": "https://github.com/preciofishbone/OmniaFx/issues"
25
+ },
26
+ "homepage": "https://github.com/preciofishbone/OmniaFx#readme"
27
+ }
@@ -0,0 +1,4 @@
1
+ export declare class TextValue {
2
+ value: string;
3
+ constructor(val: any);
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextValue = void 0;
4
+ class TextValue {
5
+ constructor(val) {
6
+ this.value = val;
7
+ }
8
+ }
9
+ exports.TextValue = TextValue;
@@ -0,0 +1,36 @@
1
+ import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, DeferredPromise } from "../models";
2
+ import { IActionHandler } from "../actions";
3
+ export declare class VelcronActions {
4
+ static _actionHandlers: {
5
+ [name: string]: IActionHandler;
6
+ } | null;
7
+ static registerAction(name: string, handler: IActionHandler): void;
8
+ static parseAndExecuteActions(templates: Array<string>, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): void;
9
+ static parseFunction(target: {
10
+ [name: string]: [];
11
+ }, template: string, renderContext: VelcronRenderContext, params: Array<VelcronActionParameterValue>, foundCb: (name: string, params: {}) => void): void;
12
+ static getActionFromTemplate(partialTemplate: string, eventId: string, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): VelcronAction;
13
+ static valueIsAction(value: string): boolean;
14
+ static executeActions(arr: any, x: any, customActionContext?: VelcronCustomActionExecutionContext): void;
15
+ static executeAction(awAction: VelcronActionWithAutoAwait, callback: (continueExecution: boolean) => void): void;
16
+ static dataBindComputed(renderContext: VelcronRenderContext, template: string): string;
17
+ static parseAndExecuteComputed(renderContext: VelcronRenderContext, template: string): string;
18
+ private static extractParameterValues;
19
+ }
20
+ interface VelcronActionParameterValue {
21
+ dataType: VelcronActionParameterDataType;
22
+ value: any;
23
+ }
24
+ export declare enum VelcronActionParameterDataType {
25
+ text = 0,
26
+ number = 1,
27
+ boolean = 2,
28
+ pointer = 3
29
+ }
30
+ interface VelcronCustomActionExecutionContext {
31
+ customAction: VelcronAction | null;
32
+ parentAction: VelcronAction | VelcronRenderContext;
33
+ variables: object;
34
+ returnValue: DeferredPromise<any>;
35
+ }
36
+ export {};
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VelcronActionParameterDataType = exports.VelcronActions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const models_1 = require("../models");
6
+ const VelcronConstants_1 = require("./VelcronConstants");
7
+ const VelcronData_1 = require("./VelcronData");
8
+ const builtInHandlers = tslib_1.__importStar(require("../actions"));
9
+ const ActionResults_1 = require("../actions/ActionResults");
10
+ const VelcronLogger_1 = require("./VelcronLogger");
11
+ class VelcronActions {
12
+ static registerAction(name, handler) {
13
+ name = name.toLowerCase();
14
+ if (this._actionHandlers && this._actionHandlers[name]) {
15
+ VelcronLogger_1.VelcronLogger.logActionError(`The action handler with name ${name} is already registered`);
16
+ }
17
+ else if (this._actionHandlers) {
18
+ this._actionHandlers[name] = handler;
19
+ }
20
+ }
21
+ static parseAndExecuteActions(templates, renderContext, customActionContext) {
22
+ if (!templates) {
23
+ VelcronLogger_1.VelcronLogger.logActionError("The event template is empty");
24
+ return;
25
+ }
26
+ const actions = [];
27
+ let template = "";
28
+ let count = 1;
29
+ templates.forEach((temp) => {
30
+ temp = temp.trim();
31
+ if (temp.startsWith("=>")) {
32
+ temp = temp.substring(2);
33
+ }
34
+ template = template + temp + (count === templates.length ? "" : " => ");
35
+ count++;
36
+ });
37
+ const evIdEnd = template.indexOf(VelcronConstants_1.VelcronConstants.events.idTokenEnd);
38
+ const evId = template.substring(VelcronConstants_1.VelcronConstants.events.idTokenStart.length, evIdEnd);
39
+ template = template.substring(evIdEnd + 1);
40
+ for (const partialTemplate of template.split("=>")) {
41
+ if (partialTemplate) {
42
+ const res = VelcronActions.getActionFromTemplate(partialTemplate, evId, renderContext, customActionContext);
43
+ if (res) {
44
+ actions.push(res);
45
+ }
46
+ }
47
+ }
48
+ if (actions.length > 0) {
49
+ if (customActionContext) {
50
+ customActionContext.customAction = renderContext;
51
+ if (customActionContext.variables) {
52
+ VelcronData_1.VelcronData.setVariables(evId, customActionContext.variables);
53
+ }
54
+ }
55
+ VelcronActions.executeActions(actions, 0, customActionContext);
56
+ //Clean up temp variables after execution
57
+ VelcronData_1.VelcronData.deleteVariables(evId);
58
+ }
59
+ }
60
+ static parseFunction(target, template, renderContext, params, foundCb) {
61
+ //Supports parsing Action or Computed functions
62
+ let actionExists = false;
63
+ //Support custom actions
64
+ if (target) {
65
+ Object.keys(target).forEach((acName) => {
66
+ const actionMustMatch = `${template}(`;
67
+ if (actionMustMatch === acName.substring(0, actionMustMatch.length)) {
68
+ actionExists = true;
69
+ let actionName = acName;
70
+ const funcParams = {};
71
+ if (actionName.indexOf("(")) {
72
+ //Action having params @myAction(text,isTrue)
73
+ actionName = acName.substring(0, actionName.indexOf("("));
74
+ const paramTemplate = acName.substring(actionName.length + 1).replace(")", "");
75
+ if (paramTemplate.indexOf(",")) {
76
+ const par = paramTemplate.split(",");
77
+ let index = 0;
78
+ par.forEach((parVal) => {
79
+ parVal = parVal.replace(" /g", "").replace("\"/g", "");
80
+ parVal = parVal.trim();
81
+ if (funcParams[parVal]) {
82
+ VelcronLogger_1.VelcronLogger.logActionError(`A parameter with name ${parVal} on action with name ${actionName} already exists. Parameters must be unique`);
83
+ }
84
+ funcParams[parVal] = params[index];
85
+ index++;
86
+ });
87
+ }
88
+ }
89
+ if (template.indexOf(actionName.substring(1)) > -1) {
90
+ foundCb(acName, funcParams);
91
+ }
92
+ }
93
+ });
94
+ }
95
+ if (!actionExists) {
96
+ VelcronLogger_1.VelcronLogger.logActionError(`Cant find a built-in action, custom action or computed matching name ${template}`);
97
+ }
98
+ }
99
+ static getActionFromTemplate(partialTemplate, eventId, renderContext, customActionContext) {
100
+ let path = "";
101
+ let val = "";
102
+ const result = {
103
+ id: eventId,
104
+ type: models_1.VelcronActionTypes.getOrSetValue,
105
+ ...renderContext
106
+ };
107
+ partialTemplate = partialTemplate.trim();
108
+ if (partialTemplate.trim() === "") {
109
+ throw "partialTemplate is empty";
110
+ }
111
+ //Handle conditional actions e.g unsplashCurrentPage === 1 ? $state.unsplash = res : $state.unsplash.results = @arrayAppend(res.results)
112
+ let pattern = /\?(?=([^']*'[^']*')*[^']*$)/;
113
+ let re = new RegExp(pattern);
114
+ let match = re.exec(partialTemplate);
115
+ //If we have ? its a conditional but if we have =? its not
116
+ if (match && partialTemplate.substring(match.index - 1, match.index) !== "=") {
117
+ result.type = models_1.VelcronActionTypes.condition;
118
+ result.condition = partialTemplate.substring(0, match.index);
119
+ //var res = false//VelcronData.evaluateBoolean(evalBoolean, renderContext);
120
+ const questionMarkIndex = match.index;
121
+ const subActions = partialTemplate.substring(questionMarkIndex + 1);
122
+ pattern = /\:(?=([^']*'[^']*')*[^']*$)/;
123
+ re = new RegExp(pattern);
124
+ match = re.exec(subActions);
125
+ if (match) {
126
+ //Take the second in the conditional match : othervalue = bla
127
+ result.trueAction =
128
+ VelcronActions.getActionFromTemplate(subActions.substring(1, match.index), eventId, renderContext);
129
+ result.falseAction =
130
+ VelcronActions.getActionFromTemplate(subActions.substring(match.index + 1), eventId, renderContext);
131
+ }
132
+ else {
133
+ result.trueAction =
134
+ VelcronActions.getActionFromTemplate(subActions, eventId, renderContext);
135
+ }
136
+ }
137
+ if (result.type !== models_1.VelcronActionTypes.condition) {
138
+ let operator = null;
139
+ if (!VelcronActions.valueIsAction(partialTemplate)) {
140
+ let assignOpIndex = -1;
141
+ let length = 2;
142
+ if (partialTemplate.indexOf(models_1.AssignOperators.plusEquals) > -1) {
143
+ assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.plusEquals);
144
+ }
145
+ else if (partialTemplate.indexOf(models_1.AssignOperators.equalsPlus) > -1) {
146
+ assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsPlus);
147
+ }
148
+ else if (partialTemplate.indexOf(models_1.AssignOperators.equalsQuestion) > -1) {
149
+ assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsQuestion);
150
+ }
151
+ else if (partialTemplate.indexOf(models_1.AssignOperators.equalsExclamation) > -1) {
152
+ assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsExclamation);
153
+ }
154
+ else if (partialTemplate.indexOf(models_1.AssignOperators.equals) > -1) {
155
+ length = 1;
156
+ assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equals);
157
+ }
158
+ else {
159
+ path = partialTemplate;
160
+ }
161
+ if (assignOpIndex > -1) {
162
+ //Direct assignment e.g ${loading} = true
163
+ path = partialTemplate.substring(0, assignOpIndex + length).trim();
164
+ val = partialTemplate.substring(assignOpIndex + length).trim();
165
+ operator = partialTemplate.substring(assignOpIndex, assignOpIndex + length);
166
+ }
167
+ else {
168
+ path = partialTemplate;
169
+ }
170
+ }
171
+ else {
172
+ //Not setting a var just calling an action like await @delay(5000)
173
+ val = partialTemplate;
174
+ }
175
+ if (VelcronActions.valueIsAction(val)) {
176
+ //Action e.g await @http.get('https://localhost:4455/api/weather')
177
+ //All actions is auto awaited by default which i think should be the normal case
178
+ //in a modern language :) you can use => nowait @http.get to not wait for the async
179
+ //operation to complete.
180
+ if (val.startsWith("nowait")) {
181
+ result.nowait = true;
182
+ val = val.substring(6);
183
+ }
184
+ result.type = models_1.VelcronActionTypes.promise;
185
+ result.path = path;
186
+ result.action = val;
187
+ result.assignOperator = operator;
188
+ }
189
+ else if (partialTemplate.startsWith("return")) {
190
+ result.type = models_1.VelcronActionTypes.returnsValue;
191
+ result.value = partialTemplate.substring(6).trim();
192
+ }
193
+ else {
194
+ result.type = models_1.VelcronActionTypes.getOrSetValue;
195
+ result.path = path;
196
+ result.value = val;
197
+ result.assignOperator = operator;
198
+ }
199
+ }
200
+ if (customActionContext?.parentAction) {
201
+ result.parent = customActionContext.parentAction;
202
+ }
203
+ return result;
204
+ }
205
+ static valueIsAction(value) {
206
+ return value.startsWith("@") || value.startsWith("await");
207
+ }
208
+ static executeActions(arr, x, customActionContext) {
209
+ //The Callback approach is to be able to wait for a promise to be finished
210
+ //before the loop continues = await support
211
+ VelcronActions.executeAction(arr[x], (continueExecution) => {
212
+ if (continueExecution) {
213
+ x++;
214
+ }
215
+ else {
216
+ x = arr.length;
217
+ }
218
+ if (x < arr.length) {
219
+ VelcronActions.executeActions(arr, x, customActionContext);
220
+ }
221
+ else {
222
+ //To support waiting for custom actions to finish before continueing
223
+ if (customActionContext && customActionContext.customAction) {
224
+ const returnVal = VelcronData_1.VelcronData.getVariable(VelcronConstants_1.VelcronConstants.events.returnValueVariableName, customActionContext.customAction);
225
+ if (returnVal.is) {
226
+ customActionContext.returnValue.resolve(returnVal.value);
227
+ }
228
+ else {
229
+ customActionContext.returnValue.resolve(null);
230
+ }
231
+ }
232
+ }
233
+ });
234
+ }
235
+ static executeAction(awAction, callback) {
236
+ //Handles actions and support async using callback of promise
237
+ if (awAction.type === models_1.VelcronActionTypes.condition) {
238
+ const awAc = awAction;
239
+ const res = VelcronData_1.VelcronData.evaluateBoolean(awAc.condition, awAc);
240
+ if (res) {
241
+ awAction = awAc.trueAction;
242
+ }
243
+ else {
244
+ awAction = awAc.falseAction;
245
+ }
246
+ }
247
+ if (awAction.action) {
248
+ if (!awAction.action.endsWith(")")) {
249
+ throw (`Velcron error parsing action: ${awAction.action} it must end with a close parenthesis)`);
250
+ }
251
+ if ((awAction.action.split("(").length - 1) + (awAction.action.split(")").length - 1) !== 2) {
252
+ throw ("Actions must not contain more then 2 parenthesis, e.g @delay(5000)");
253
+ }
254
+ const val = awAction.action.substring(awAction.action.indexOf("(") + 1).replace(")", "").trim();
255
+ const params = VelcronActions.extractParameterValues(val, awAction);
256
+ let promise = null;
257
+ const actionName = awAction.action.substring(0, awAction.action.indexOf("(")).trim().toLowerCase();
258
+ //promise = VelcronActions.runHandler(awAction, actionName, params);
259
+ if (!VelcronActions._actionHandlers) {
260
+ VelcronActions._actionHandlers = {};
261
+ Object.keys(builtInHandlers).forEach((key) => {
262
+ const handler = builtInHandlers[key];
263
+ if (handler && handler.name && VelcronActions._actionHandlers) {
264
+ VelcronActions._actionHandlers[handler.name] = handler;
265
+ }
266
+ });
267
+ }
268
+ const paramValues = [];
269
+ params.forEach(param => paramValues.push(param.value));
270
+ let hasCustomActionValue = false;
271
+ if (VelcronActions._actionHandlers[actionName]) {
272
+ //Built in handler
273
+ promise = VelcronActions._actionHandlers[actionName].action(awAction, ...paramValues);
274
+ }
275
+ else {
276
+ //Custom handler
277
+ VelcronActions.parseFunction(awAction.actions, actionName, awAction, paramValues, (acName, params) => {
278
+ if (!acName.startsWith("@")) {
279
+ throw "Custom action names must start with @";
280
+ }
281
+ const acArr = awAction.actions[acName];
282
+ acArr[0] = VelcronData_1.VelcronData.ensureEventId(acArr[0]);
283
+ const customActionContext = {
284
+ parentAction: awAction,
285
+ customAction: null,
286
+ variables: params,
287
+ returnValue: VelcronData_1.VelcronData.createDeferredPromise()
288
+ };
289
+ VelcronActions.parseAndExecuteActions(acArr, awAction, customActionContext);
290
+ promise = customActionContext.returnValue.promise;
291
+ hasCustomActionValue = true;
292
+ });
293
+ }
294
+ if (!awAction.nowait && promise || hasCustomActionValue && promise) {
295
+ promise.then((val) => {
296
+ let continueExecution = true;
297
+ //If action returns StopProcedingActions class in promise we will not continue executing actions
298
+ if (val && val instanceof ActionResults_1.CancelProcedingActions) {
299
+ continueExecution = false;
300
+ }
301
+ else if (val && val instanceof ActionResults_1.SkipSetValue) {
302
+ //Dont run evaluateSet, it has bee done inside the action
303
+ }
304
+ else {
305
+ if (val) {
306
+ VelcronData_1.VelcronData.evaluateSet(awAction.path, val, awAction);
307
+ }
308
+ }
309
+ callback(continueExecution);
310
+ });
311
+ }
312
+ else {
313
+ callback(true);
314
+ }
315
+ }
316
+ else if (awAction.type === models_1.VelcronActionTypes.returnsValue) {
317
+ VelcronData_1.VelcronData.evaluateSet(VelcronConstants_1.VelcronConstants.events.returnValueVariableName, awAction.value, awAction);
318
+ callback(true);
319
+ }
320
+ else {
321
+ VelcronData_1.VelcronData.evaluateSet(awAction.path, awAction.value, awAction);
322
+ callback(true);
323
+ }
324
+ }
325
+ static dataBindComputed(renderContext, template) {
326
+ if (typeof template === typeof undefined || template === null) {
327
+ return;
328
+ }
329
+ let text = VelcronActions.parseAndExecuteComputed(renderContext, template);
330
+ text = VelcronData_1.VelcronData.dataBind(renderContext, text);
331
+ return text;
332
+ }
333
+ static parseAndExecuteComputed(renderContext, template) {
334
+ VelcronData_1.VelcronData.getTokens(template).forEach(token => {
335
+ const paramValues = [];
336
+ VelcronActions.parseFunction(renderContext.computed, token, renderContext, paramValues, (acName, params) => {
337
+ const funcContent = renderContext.computed[acName];
338
+ Object.keys(params).forEach((key) => {
339
+ params[key] = "currentCtx";
340
+ });
341
+ const toReplace = VelcronConstants_1.VelcronConstants.properties.tokenStart + token + VelcronConstants_1.VelcronConstants.properties.tokenEnd;
342
+ funcContent.forEach((c) => {
343
+ //const toEval = `return ${c}`;
344
+ const result = VelcronData_1.VelcronData.evauluateJs(c, renderContext, params);
345
+ template = template.replace(toReplace, result);
346
+ });
347
+ });
348
+ });
349
+ return template;
350
+ }
351
+ static extractParameterValues(template, action) {
352
+ const params = [];
353
+ let hasMoreParams = true;
354
+ let badCodeDetection = 0;
355
+ if (!template) {
356
+ return params;
357
+ }
358
+ while (hasMoreParams) {
359
+ template = template.trim();
360
+ if (template.startsWith(",")) {
361
+ template = template.substring(1);
362
+ }
363
+ template = template.trim();
364
+ if (template.startsWith("'")) {
365
+ //String parameter
366
+ template = template.substring(1);
367
+ if (template.indexOf("'") > -1) {
368
+ const subVal = template.substring(0, template.indexOf("'"));
369
+ params.push({ dataType: 0, value: VelcronData_1.VelcronData.dataBind(action, subVal) });
370
+ template = template.substring(subVal.length + 2);
371
+ }
372
+ else {
373
+ VelcronLogger_1.VelcronLogger.logActionError(`Found an action parameter with a opening ' indicating string but did not find the ending ' on parameter: ${template}`);
374
+ }
375
+ }
376
+ else {
377
+ let subVal = template;
378
+ let castedValue;
379
+ if (subVal.indexOf("'") > -1 || subVal.indexOf(",") > -1) {
380
+ subVal = subVal.substring(0, subVal.indexOf(","));
381
+ }
382
+ let dataType;
383
+ subVal = subVal.trim();
384
+ if (VelcronData_1.VelcronData.isNumber(subVal)) {
385
+ dataType = VelcronActionParameterDataType.number;
386
+ castedValue = Number.parseInt(subVal);
387
+ }
388
+ else if (VelcronData_1.VelcronData.tryParseBoolean(subVal).is) {
389
+ dataType = VelcronActionParameterDataType.boolean;
390
+ castedValue = VelcronData_1.VelcronData.tryParseBoolean(subVal).value;
391
+ }
392
+ else {
393
+ //Variable or DataContext binding
394
+ dataType = VelcronActionParameterDataType.pointer;
395
+ castedValue = subVal;
396
+ let rootName = "";
397
+ let procedingPath = "";
398
+ if (castedValue.indexOf(".") > -1) {
399
+ rootName = castedValue.substring(0, castedValue.indexOf("."));
400
+ procedingPath = castedValue.substring(castedValue.indexOf(".") + 1);
401
+ }
402
+ else {
403
+ rootName = castedValue;
404
+ }
405
+ const isVar = VelcronData_1.VelcronData.getVariable(rootName, action);
406
+ if (isVar.is) {
407
+ //Its a variable
408
+ if (procedingPath) {
409
+ castedValue = VelcronData_1.VelcronData.getOrSetObjectByPath(isVar.value, procedingPath);
410
+ }
411
+ else {
412
+ castedValue = isVar.value;
413
+ }
414
+ }
415
+ else {
416
+ //Try get it from ViewModel
417
+ castedValue = VelcronData_1.VelcronData.getOrSetObjectByPathUsingRenderContext(action, castedValue);
418
+ }
419
+ }
420
+ params.push({ dataType: dataType, value: castedValue });
421
+ template = template.substring(subVal.length);
422
+ }
423
+ if (template.length < 2) {
424
+ hasMoreParams = false;
425
+ }
426
+ if (badCodeDetection > 50) {
427
+ hasMoreParams = false;
428
+ VelcronLogger_1.VelcronLogger.logActionError("Bad parameter code detected! If you see this error please contact Andii :)");
429
+ }
430
+ badCodeDetection++;
431
+ }
432
+ return params;
433
+ }
434
+ }
435
+ exports.VelcronActions = VelcronActions;
436
+ VelcronActions._actionHandlers = null;
437
+ var VelcronActionParameterDataType;
438
+ (function (VelcronActionParameterDataType) {
439
+ VelcronActionParameterDataType[VelcronActionParameterDataType["text"] = 0] = "text";
440
+ VelcronActionParameterDataType[VelcronActionParameterDataType["number"] = 1] = "number";
441
+ VelcronActionParameterDataType[VelcronActionParameterDataType["boolean"] = 2] = "boolean";
442
+ VelcronActionParameterDataType[VelcronActionParameterDataType["pointer"] = 3] = "pointer";
443
+ })(VelcronActionParameterDataType = exports.VelcronActionParameterDataType || (exports.VelcronActionParameterDataType = {}));
@@ -0,0 +1,29 @@
1
+ export declare const VelcronConstants: {
2
+ components: {
3
+ app: string;
4
+ view: string;
5
+ card: string;
6
+ text: string;
7
+ image: string;
8
+ button: string;
9
+ textInput: string;
10
+ progressCircle: string;
11
+ webView: string;
12
+ dialog: string;
13
+ flexView: string;
14
+ icon: string;
15
+ chip: string;
16
+ };
17
+ events: {
18
+ idTokenStart: string;
19
+ idTokenEnd: string;
20
+ returnValueVariableName: string;
21
+ };
22
+ state: {
23
+ stateRootToken: string;
24
+ };
25
+ properties: {
26
+ tokenStart: string;
27
+ tokenEnd: string;
28
+ };
29
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VelcronConstants = void 0;
4
+ exports.VelcronConstants = {
5
+ components: {
6
+ app: "App",
7
+ view: "View",
8
+ card: "Card",
9
+ text: "Text",
10
+ image: "Image",
11
+ button: "Button",
12
+ textInput: "TextInput",
13
+ progressCircle: "ProgressCircle",
14
+ webView: "WebView",
15
+ dialog: "Dialog",
16
+ flexView: "FlexView",
17
+ icon: "Icon",
18
+ chip: "Chip"
19
+ },
20
+ events: {
21
+ idTokenStart: "$ev{",
22
+ idTokenEnd: "}",
23
+ returnValueVariableName: "$returnValue"
24
+ },
25
+ state: {
26
+ stateRootToken: "$state"
27
+ },
28
+ properties: {
29
+ tokenStart: "${",
30
+ tokenEnd: "}"
31
+ }
32
+ };
@@ -0,0 +1,39 @@
1
+ import { VelcronAppDefinition, VelcronDefinition, VelcronRenderContext, DeferredPromise } from "../models";
2
+ export interface ParseResult<T> {
3
+ is: boolean;
4
+ value: T;
5
+ }
6
+ export declare class VelcronData {
7
+ static dataBind(renderContext: VelcronRenderContext, text: string): string;
8
+ static addCtxToVariableNames(template: string, skipIfNameStartsWith?: string, skipIfNameMatches?: Array<string>, overridePrefixWhenNameMatches?: {
9
+ [name: string]: string;
10
+ }): string;
11
+ static evauluateJs(template: string, renderContext: VelcronRenderContext, overrideNamesMatching?: {}): any;
12
+ private static variables;
13
+ static deleteVariables(id: string): void;
14
+ static getVariable<T>(name: string, renderContext: VelcronRenderContext): ParseResult<T>;
15
+ static setVariables(eventId: string, varsToSet: object): void;
16
+ static evaluateSet(path: string, value: any, renderContext: VelcronRenderContext): void;
17
+ static evaluateArray(template: string, renderContext: VelcronRenderContext): Array<any> | null;
18
+ static evaluateBoolean(template: string | Boolean, renderContext: VelcronRenderContext): boolean | null;
19
+ static tryParseBoolean(bool: any): ParseResult<boolean | null>;
20
+ static isString(text: any): boolean;
21
+ static isBoolean(value: any): boolean;
22
+ static isNumber(value: any): boolean;
23
+ static isUndefined(value: any): boolean;
24
+ static isArray(obj: any): obj is ExtendArray;
25
+ static isObject(value: any): boolean;
26
+ static extendObject(obj: any): any;
27
+ static getOrSetObjectByPath<T>(object: Object, path: string, value?: any): T | null;
28
+ static getOrSetObjectByPathUsingRenderContext<T>(renderContext: VelcronRenderContext, path: string, value?: any): T;
29
+ static getTokens(template: any): string[];
30
+ static ensureEventId(event: string): string;
31
+ static ensureKeys(ui: VelcronDefinition | VelcronAppDefinition, generateNewKeys?: boolean): void;
32
+ static removeKeys(ui: VelcronDefinition | VelcronAppDefinition): void;
33
+ static generateId(): string;
34
+ static createDeferredPromise<T>(): DeferredPromise<T>;
35
+ }
36
+ interface ExtendArray extends Array<any> {
37
+ take: (amount: number) => Array<any>;
38
+ }
39
+ export {};