@omnia/velcron 7.1.552-dev → 7.5.1-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/actions/Http.js +22 -6
- package/internal-do-not-import-from-here/shared/models/OmniaSharedBootstrapData.d.ts +2 -0
- package/internal-do-not-import-from-here/shared/models/Tokens.d.ts +2 -1
- package/models/ActionHooks.d.ts +12 -0
- package/models/ActionHooks.js +2 -0
- package/models/VelcronDefinitions.d.ts +16 -25
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/package.json +1 -1
- package/parser/VelcronActions.d.ts +7 -1
- package/parser/VelcronActions.js +17 -0
- package/parser/VelcronConstants.d.ts +0 -1
- package/parser/VelcronConstants.js +1 -2
- package/parser/VelcronRenderers.d.ts +5 -5
- package/parser/VelcronStyles.js +1 -1
package/actions/Http.js
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.httpGet = void 0;
|
|
4
|
-
const
|
|
4
|
+
const parser_1 = require("../parser");
|
|
5
5
|
exports.httpGet = {
|
|
6
6
|
name: "@http.get",
|
|
7
|
-
action: (action,
|
|
7
|
+
action: (action, incomingUrl) => {
|
|
8
8
|
return new Promise(function (resolve) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
return parser_1.VelcronActions.tryTriggerAfterActionHook("http.get", {
|
|
17
|
+
json: await response.json(),
|
|
18
|
+
response: response
|
|
19
|
+
});
|
|
20
|
+
})
|
|
21
|
+
.then((json) => {
|
|
22
|
+
resolve(json);
|
|
23
|
+
})
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
//How do we handle errors?
|
|
26
|
+
console.error("Velcron @http.get error occurred:", error);
|
|
27
|
+
throw error;
|
|
28
|
+
});
|
|
13
29
|
});
|
|
14
30
|
}
|
|
15
31
|
};
|
|
@@ -13,12 +13,14 @@ export interface OmniaSharedBootstrapData {
|
|
|
13
13
|
*/
|
|
14
14
|
tokenKey?: OmniaToken;
|
|
15
15
|
tokenRef: GuidValue;
|
|
16
|
+
identity: string;
|
|
16
17
|
licenses: Array<Guid>;
|
|
17
18
|
hubDev?: boolean;
|
|
18
19
|
realtimeDevPort?: string;
|
|
19
20
|
tenant: TenantIdentifier;
|
|
20
21
|
servingMode?: boolean;
|
|
21
22
|
serviceDnsMapping: OmniaServiceToDnsMapping;
|
|
23
|
+
authDisabled?: boolean;
|
|
22
24
|
}
|
|
23
25
|
export interface OmniaServiceToDnsMapping {
|
|
24
26
|
[serviceId: string]: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface VelcronActionHooks<TBefore = any, TAfter = any> {
|
|
2
|
+
beforeHandler?: (args: TBefore) => TBefore;
|
|
3
|
+
afterHandler?: (args: TBefore) => TAfter;
|
|
4
|
+
}
|
|
5
|
+
export interface HttpGetBeforeActionHookArgs {
|
|
6
|
+
url: string;
|
|
7
|
+
requestInit: RequestInit;
|
|
8
|
+
}
|
|
9
|
+
export interface HttpGetAfterActionHookArgs {
|
|
10
|
+
json: string;
|
|
11
|
+
response: Response;
|
|
12
|
+
}
|
|
@@ -19,7 +19,6 @@ export interface BuiltInComponentRenderers {
|
|
|
19
19
|
"WebView": unknown;
|
|
20
20
|
"CustomComponent": unknown;
|
|
21
21
|
"Dialog": unknown;
|
|
22
|
-
"FlexView": unknown;
|
|
23
22
|
"Icon": unknown;
|
|
24
23
|
"Chip": unknown;
|
|
25
24
|
}
|
|
@@ -27,19 +26,15 @@ export interface ColorSchemaReference {
|
|
|
27
26
|
name: string;
|
|
28
27
|
schema: string;
|
|
29
28
|
}
|
|
30
|
-
export
|
|
31
|
-
colorSchemas?: {
|
|
32
|
-
[key: string]: ColorSchemaReference;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
29
|
+
export type DynamicState = object;
|
|
35
30
|
export interface OnItemRenderedHookResult {
|
|
36
31
|
cssClass: string;
|
|
37
32
|
containerRenderer?: VelcronContainerRenderer;
|
|
38
33
|
}
|
|
39
34
|
export interface VelcronRenderContext {
|
|
40
35
|
id?: string;
|
|
41
|
-
rootContext:
|
|
42
|
-
currentContext:
|
|
36
|
+
rootContext: DynamicState;
|
|
37
|
+
currentContext: DynamicState;
|
|
43
38
|
theming?: ReturnType<typeof useVelcronThemingStore>;
|
|
44
39
|
colorSchemaType?: string;
|
|
45
40
|
colorSchema?: ColorSchema;
|
|
@@ -147,15 +142,15 @@ export interface VelcronIcon {
|
|
|
147
142
|
type: VelcronIconTypes;
|
|
148
143
|
name: string;
|
|
149
144
|
}
|
|
150
|
-
export interface VelcronAppDefinition extends VelcronDefinitionBase {
|
|
151
|
-
type: "
|
|
145
|
+
export interface VelcronAppDefinition<TState extends DynamicState = DynamicState> extends VelcronDefinitionBase {
|
|
146
|
+
type: "Velcron";
|
|
152
147
|
body?: Array<VelcronDefinition>;
|
|
153
148
|
events?: VelcronOnLoadEvent & VelcronOnPressEvent;
|
|
154
149
|
actions?: {
|
|
155
150
|
[name: string]: [];
|
|
156
151
|
};
|
|
157
152
|
components?: Array<VelcronCustomComponentDefinition>;
|
|
158
|
-
state?:
|
|
153
|
+
state?: TState;
|
|
159
154
|
computed?: {
|
|
160
155
|
[name: string]: [];
|
|
161
156
|
};
|
|
@@ -165,10 +160,18 @@ export interface VelcronComponentDefinition extends VelcronDefinition {
|
|
|
165
160
|
events: VelcronOnPressEvent;
|
|
166
161
|
}
|
|
167
162
|
/*** Built-in Components *********************************************************************/
|
|
168
|
-
export interface VelcronViewDefinition extends VelcronDefinition {
|
|
163
|
+
export interface VelcronViewDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
|
|
169
164
|
type: "View";
|
|
170
|
-
style?: VelcronStyling;
|
|
171
165
|
events?: VelcronOnPressEvent;
|
|
166
|
+
column?: boolean;
|
|
167
|
+
body: Array<VelcronDefinition>;
|
|
168
|
+
columnStyle?: object;
|
|
169
|
+
horizontalAlignment?: VelcronHorizontalAlignments;
|
|
170
|
+
verticalAlignment?: VerticalAlignments;
|
|
171
|
+
grow?: number;
|
|
172
|
+
border?: VelcronBorder;
|
|
173
|
+
borderRadius?: VelcronDimensions;
|
|
174
|
+
width: string;
|
|
172
175
|
}
|
|
173
176
|
export interface VelcronCardDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
|
|
174
177
|
type: "Card";
|
|
@@ -232,18 +235,6 @@ export interface VelcronIconDefinition extends VelcronDefinition, VelcronCustomT
|
|
|
232
235
|
size?: number;
|
|
233
236
|
events?: VelcronOnPressEvent;
|
|
234
237
|
}
|
|
235
|
-
export interface VelcronFlexViewDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
|
|
236
|
-
type: "FlexView";
|
|
237
|
-
column?: boolean;
|
|
238
|
-
body: Array<VelcronDefinition>;
|
|
239
|
-
columnStyle?: object;
|
|
240
|
-
horizontalAlignment?: VelcronHorizontalAlignments;
|
|
241
|
-
verticalAlignment?: VerticalAlignments;
|
|
242
|
-
grow?: number;
|
|
243
|
-
border?: VelcronBorder;
|
|
244
|
-
borderRadius?: VelcronDimensions;
|
|
245
|
-
width: string;
|
|
246
|
-
}
|
|
247
238
|
export interface VelcronDimensions {
|
|
248
239
|
top: number;
|
|
249
240
|
right: number;
|
package/models/index.d.ts
CHANGED
package/models/index.js
CHANGED
|
@@ -8,3 +8,4 @@ tslib_1.__exportStar(require("./VelcronEvents"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./VelcronTypes"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./Enums"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./VelcronUnitProvider"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./ActionHooks"), exports);
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, DeferredPromise } from "../models";
|
|
1
|
+
import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, DeferredPromise, VelcronActionHooks } from "../models";
|
|
2
2
|
import { IActionHandler } from "../actions";
|
|
3
3
|
export declare class VelcronActions {
|
|
4
4
|
static _actionHandlers: {
|
|
5
5
|
[name: string]: IActionHandler;
|
|
6
6
|
} | null;
|
|
7
|
+
static actionHooks: {
|
|
8
|
+
[name: string]: VelcronActionHooks;
|
|
9
|
+
};
|
|
7
10
|
static registerAction(name: string, handler: IActionHandler): void;
|
|
8
11
|
static parseAndExecuteActions(templates: Array<string>, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): void;
|
|
9
12
|
static parseFunction(target: {
|
|
@@ -15,6 +18,9 @@ export declare class VelcronActions {
|
|
|
15
18
|
static executeAction(awAction: VelcronActionWithAutoAwait, callback: (continueExecution: boolean) => void): void;
|
|
16
19
|
static dataBindComputed(renderContext: VelcronRenderContext, template: string): string;
|
|
17
20
|
static parseAndExecuteComputed(renderContext: VelcronRenderContext, template: string): string;
|
|
21
|
+
static registerActionHook<TBefore, TAfter>(actionName: string, handler: VelcronActionHooks<TBefore, TAfter>): void;
|
|
22
|
+
static tryTriggerBeforeActionHook<T>(actionName: string, args: T): T;
|
|
23
|
+
static tryTriggerAfterActionHook<T>(actionName: string, args: T): T;
|
|
18
24
|
private static extractParameterValues;
|
|
19
25
|
}
|
|
20
26
|
interface VelcronActionParameterValue {
|
package/parser/VelcronActions.js
CHANGED
|
@@ -348,6 +348,22 @@ class VelcronActions {
|
|
|
348
348
|
});
|
|
349
349
|
return template;
|
|
350
350
|
}
|
|
351
|
+
static registerActionHook(actionName, handler) {
|
|
352
|
+
VelcronActions.actionHooks ?? (VelcronActions.actionHooks = {});
|
|
353
|
+
VelcronActions.actionHooks[actionName] = handler;
|
|
354
|
+
}
|
|
355
|
+
static tryTriggerBeforeActionHook(actionName, args) {
|
|
356
|
+
if (VelcronActions.actionHooks && VelcronActions.actionHooks[actionName] && VelcronActions.actionHooks[actionName].beforeHandler) {
|
|
357
|
+
return VelcronActions.actionHooks[actionName].beforeHandler(args);
|
|
358
|
+
}
|
|
359
|
+
return args;
|
|
360
|
+
}
|
|
361
|
+
static tryTriggerAfterActionHook(actionName, args) {
|
|
362
|
+
if (VelcronActions.actionHooks && VelcronActions.actionHooks[actionName] && VelcronActions.actionHooks[actionName].afterHandler) {
|
|
363
|
+
return VelcronActions.actionHooks[actionName].afterHandler(args);
|
|
364
|
+
}
|
|
365
|
+
return args;
|
|
366
|
+
}
|
|
351
367
|
static extractParameterValues(template, action) {
|
|
352
368
|
const params = [];
|
|
353
369
|
let hasMoreParams = true;
|
|
@@ -434,6 +450,7 @@ class VelcronActions {
|
|
|
434
450
|
}
|
|
435
451
|
exports.VelcronActions = VelcronActions;
|
|
436
452
|
VelcronActions._actionHandlers = null;
|
|
453
|
+
VelcronActions.actionHooks = {};
|
|
437
454
|
var VelcronActionParameterDataType;
|
|
438
455
|
(function (VelcronActionParameterDataType) {
|
|
439
456
|
VelcronActionParameterDataType[VelcronActionParameterDataType["text"] = 0] = "text";
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VelcronConstants = void 0;
|
|
4
4
|
exports.VelcronConstants = {
|
|
5
5
|
components: {
|
|
6
|
-
app: "
|
|
6
|
+
app: "Velcron",
|
|
7
7
|
view: "View",
|
|
8
8
|
card: "Card",
|
|
9
9
|
text: "Text",
|
|
@@ -13,7 +13,6 @@ exports.VelcronConstants = {
|
|
|
13
13
|
progressCircle: "ProgressCircle",
|
|
14
14
|
webView: "WebView",
|
|
15
15
|
dialog: "Dialog",
|
|
16
|
-
flexView: "FlexView",
|
|
17
16
|
icon: "Icon",
|
|
18
17
|
chip: "Chip"
|
|
19
18
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuiltInComponentRenderers,
|
|
1
|
+
import { BuiltInComponentRenderers, DynamicState, ResolvedComponentRenderer, VelcronCustomComponentDefinition, VelcronDefinition, VelcronRenderContext } from "../models";
|
|
2
2
|
export declare class VelcronRenderers {
|
|
3
3
|
private static components;
|
|
4
4
|
static registerComponent(type: string, component: any): void;
|
|
@@ -7,8 +7,8 @@ export declare class VelcronRenderers {
|
|
|
7
7
|
static registerComponents(components: BuiltInComponentRenderers): void;
|
|
8
8
|
static getComponent(definition: VelcronDefinition, renderContext: VelcronRenderContext): ResolvedComponentRenderer;
|
|
9
9
|
static definitionContainsCustomColorSchema(definition: VelcronDefinition): boolean;
|
|
10
|
-
static createNewRendererContext(currentRenderCtx: VelcronRenderContext, definition: VelcronDefinition, newViewModel?:
|
|
11
|
-
rootContext:
|
|
10
|
+
static createNewRendererContext(currentRenderCtx: VelcronRenderContext, definition: VelcronDefinition, newViewModel?: DynamicState): {
|
|
11
|
+
rootContext: object;
|
|
12
12
|
theming: {
|
|
13
13
|
state: {
|
|
14
14
|
currentTheme: import("@omnia/fx-models").ThemeDefinitionV2;
|
|
@@ -27,7 +27,7 @@ export declare class VelcronRenderers {
|
|
|
27
27
|
setTheme(newTheme: import("@omnia/fx-models").ThemeDefinitionV2): void;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
currentContext:
|
|
30
|
+
currentContext: object;
|
|
31
31
|
actions: {
|
|
32
32
|
[name: string]: [];
|
|
33
33
|
};
|
|
@@ -37,5 +37,5 @@ export declare class VelcronRenderers {
|
|
|
37
37
|
[name: string]: [];
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?:
|
|
40
|
+
static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?: DynamicState): VelcronRenderContext;
|
|
41
41
|
}
|
package/parser/VelcronStyles.js
CHANGED
|
@@ -98,7 +98,7 @@ class VelcronStyles {
|
|
|
98
98
|
styleBase["color"] = renderCtx.colorSchema.onBase.color;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
else if (definition.type === VelcronConstants_1.VelcronConstants.components.
|
|
101
|
+
else if (definition.type === VelcronConstants_1.VelcronConstants.components.view) {
|
|
102
102
|
const flexViewDefinition = definition;
|
|
103
103
|
const flexGrow = flexViewDefinition.grow || flexViewDefinition.grow === 0 ? flexViewDefinition.grow : 1;
|
|
104
104
|
styleBase["flex"] = flexGrow;
|