dotvvm-types 4.3.0-preview03-final → 4.3.0-preview04-final
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/package.json +1 -1
- package/types/index.d.ts +39 -14
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -19,6 +19,20 @@ declare module "shared-classes" {
|
|
|
19
19
|
declare module "utils/logging" {
|
|
20
20
|
type LogLevel = "normal" | "verbose";
|
|
21
21
|
export const level: LogLevel;
|
|
22
|
+
type ConsoleLogLevel = "warn" | "log" | "error" | "trace";
|
|
23
|
+
let logger: (level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Instead of calling console.log, console.warn or console.error, DotVVM will call this function instead.
|
|
26
|
+
* Please keep in mind that the exact wording of log messages is not DotVVM public API and may change without notice.
|
|
27
|
+
* @example
|
|
28
|
+
* dotvvm.log.setLogger((next, level, area, ...args) => {
|
|
29
|
+
* if (area == "validation" && /^This message should be an error$/.test(args[0])) {
|
|
30
|
+
* level = "error"
|
|
31
|
+
* }
|
|
32
|
+
* previous(level, area, ...args) // call the default logger
|
|
33
|
+
* })
|
|
34
|
+
*/
|
|
35
|
+
export function setLogger(newLogger: (next: typeof logger, level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void): void;
|
|
22
36
|
export type DotvvmLoggingArea = ("debug" | "configuration" | "postback" | "spa" | "static-command" | "binding-handler" | "resource-loader" | "coercer" | "state-manager" | "validation" | "events" | "rest-api");
|
|
23
37
|
export function logInfoVerbose(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
24
38
|
export function logInfo(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
@@ -117,7 +131,7 @@ declare module "utils/isNumber" {
|
|
|
117
131
|
export function isNumber(value: any): boolean;
|
|
118
132
|
}
|
|
119
133
|
declare module "metadata/enums" {
|
|
120
|
-
export function enumStringToInt(value: number | string, type: EnumTypeMetadata): number | null;
|
|
134
|
+
export function enumStringToInt(value: number | string | null | undefined, type: EnumTypeMetadata): number | null;
|
|
121
135
|
export function enumIntToString(value: number, type: EnumTypeMetadata): string | null;
|
|
122
136
|
export function tryCoerceEnum(value: any, type: EnumTypeMetadata): CoerceResult;
|
|
123
137
|
}
|
|
@@ -313,6 +327,7 @@ declare module "viewModules/viewModuleManager" {
|
|
|
313
327
|
export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement, properties?: object): ModuleContext;
|
|
314
328
|
export function callViewModuleCommand(viewIdOrElement: string | HTMLElement, commandName: string, args: any[], allowAsync?: boolean): any;
|
|
315
329
|
export function findComponent(viewIdOrElement: null | string | HTMLElement, name: string): [ModuleContext | null, DotvvmJsComponentFactory];
|
|
330
|
+
/** Registers a component to be used in any JsComponent, independent of view modules */
|
|
316
331
|
export function registerGlobalComponent(name: string, c: DotvvmJsComponentFactory): void;
|
|
317
332
|
export function registerNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string, command: ModuleCommand, rootElement: HTMLElement): void;
|
|
318
333
|
export function unregisterNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string): void;
|
|
@@ -647,6 +662,7 @@ declare module "validation/validation" {
|
|
|
647
662
|
* `dotvvm.validation.removeErrors("/Detail")` removes all errors from the object in property root.Detail */
|
|
648
663
|
removeErrors: typeof removeErrors;
|
|
649
664
|
};
|
|
665
|
+
export const runClientSideValidation: (validationTarget: any, options: PostbackOptions) => void;
|
|
650
666
|
export function init(): void;
|
|
651
667
|
export type ValidationErrorDescriptor = {
|
|
652
668
|
/** Error to be displayed to the user */
|
|
@@ -726,24 +742,22 @@ declare module "metadata/metadataHelper" {
|
|
|
726
742
|
}
|
|
727
743
|
declare module "translations/sortingHelper" {
|
|
728
744
|
type ElementType = string | number | boolean;
|
|
729
|
-
export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
|
|
730
|
-
export const orderByDesc: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
|
|
745
|
+
export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string | null) => T[];
|
|
746
|
+
export const orderByDesc: <T>(array: T[], selector: (item: T) => ElementType, typeId: string | null) => T[];
|
|
731
747
|
}
|
|
732
748
|
declare module "translations/arrayHelper" {
|
|
733
749
|
import { orderBy, orderByDesc } from "translations/sortingHelper";
|
|
734
|
-
export { add, addOrUpdate, addRange, clear, distinct, contains,
|
|
750
|
+
export { add, addOrUpdate, addRange, clear, distinct, contains, insert, insertRange, max, min, orderBy, orderByDesc, removeAll, removeAt, removeFirst, removeLast, removeRange, reverse, setItem };
|
|
735
751
|
function add<T>(observable: any, element: T): void;
|
|
736
752
|
function addOrUpdate<T>(observable: any, element: T, matcher: (e: T) => boolean, updater: (e: T) => T): void;
|
|
737
753
|
function addRange<T>(observable: any, elements: T[]): void;
|
|
738
754
|
function clear(observable: any): void;
|
|
739
755
|
function distinct<T>(array: T[]): T[];
|
|
740
756
|
function contains<T>(array: T[], value: T): boolean;
|
|
741
|
-
function firstOrDefault<T>(array: T[], predicate: (s: T) => boolean): T | null;
|
|
742
757
|
function insert<T>(observable: any, index: number, element: T): void;
|
|
743
758
|
function insertRange<T>(observable: any, index: number, elements: T[]): void;
|
|
744
|
-
function
|
|
745
|
-
function
|
|
746
|
-
function min<T>(array: T[], selector: (item: T) => number, throwIfEmpty: boolean): number | null;
|
|
759
|
+
function max<T>(array: T[], selector: (item: T) => number): number | null;
|
|
760
|
+
function min<T>(array: T[], selector: (item: T) => number): number | null;
|
|
747
761
|
function removeAt<T>(observable: any, index: number): void;
|
|
748
762
|
function removeAll<T>(observable: any, predicate: (s: T) => boolean): void;
|
|
749
763
|
function removeRange<T>(observable: any, index: number, length: number): void;
|
|
@@ -759,7 +773,7 @@ declare module "translations/dictionaryHelper" {
|
|
|
759
773
|
}[];
|
|
760
774
|
export function clear(observable: any): void;
|
|
761
775
|
export function containsKey<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key): boolean;
|
|
762
|
-
export function getItem<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key, defaultValue?: Value): Value;
|
|
776
|
+
export function getItem<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key, defaultValue?: Value): Value | undefined;
|
|
763
777
|
export function remove<Key, Value>(observable: any, identifier: Key): boolean;
|
|
764
778
|
export function setItem<Key, Value>(observable: any, identifier: Key, value: Value): void;
|
|
765
779
|
}
|
|
@@ -816,7 +830,7 @@ declare module "dotvvm-root" {
|
|
|
816
830
|
import * as eventHub from "api/eventHub";
|
|
817
831
|
import * as viewModuleManager from "viewModules/viewModuleManager";
|
|
818
832
|
import { notifyModuleLoaded } from "postback/resourceLoader";
|
|
819
|
-
import { logError, logWarning, logInfo, logInfoVerbose, logPostBackScriptError } from "utils/logging";
|
|
833
|
+
import { logError, logWarning, logInfo, logInfoVerbose, logPostBackScriptError, setLogger } from "utils/logging";
|
|
820
834
|
import * as metadataHelper from "metadata/metadataHelper";
|
|
821
835
|
import { StateManager } from "state-manager";
|
|
822
836
|
function init(culture: string): void;
|
|
@@ -903,6 +917,7 @@ declare module "dotvvm-root" {
|
|
|
903
917
|
logInfoVerbose: typeof logInfoVerbose;
|
|
904
918
|
logPostBackScriptError: typeof logPostBackScriptError;
|
|
905
919
|
level: "normal" | "verbose";
|
|
920
|
+
setLogger: typeof setLogger;
|
|
906
921
|
};
|
|
907
922
|
options: {
|
|
908
923
|
compressPOST: boolean;
|
|
@@ -1207,20 +1222,30 @@ type DotvvmFileSize = {
|
|
|
1207
1222
|
FormattedText: KnockoutObservable<string>;
|
|
1208
1223
|
};
|
|
1209
1224
|
type DotvvmJsComponent = {
|
|
1210
|
-
|
|
1225
|
+
/** Called after each update of dotvvm.state which changes any of the bound properties. Only the changed properties are listed in the `updatedProps` argument. */
|
|
1226
|
+
updateProps(updatedProps: {
|
|
1211
1227
|
[key: string]: any;
|
|
1212
1228
|
}): void;
|
|
1213
|
-
|
|
1229
|
+
/** Called after the HTMLElement is removed from DOM.
|
|
1230
|
+
* The component does not need to remove any child elements, but should clean any external data, such as subscription to dotvvm events */
|
|
1231
|
+
dispose?(): void;
|
|
1214
1232
|
};
|
|
1215
1233
|
type DotvvmJsComponentFactory = {
|
|
1234
|
+
/** Initializes the component on the specified HTMLElement.
|
|
1235
|
+
* @param element The root HTMLElement of this component
|
|
1236
|
+
* @param props An object listing all constants and `value` bindings from the `dot:JsComponent` instance
|
|
1237
|
+
* @param commands An object listing all `command` and `staticCommand` bindings from the `dot:JsComponent` instance
|
|
1238
|
+
* @param templates An object listing all content properties of the `dot:JsComponent`. The template is identified using its HTML id attribute, it can be rendered using ko.renderTemplate, KnockoutTemplateReactComponent or KnockoutTemplateSvelteComponent
|
|
1239
|
+
* @param setProps A function which will attempt to write a value back into the bound property. Only certain `value` bindings can be updated, an exception is thown if it isn't possible
|
|
1240
|
+
* @returns An object which will be notified about subsequent changes to the bound properties and when the component
|
|
1241
|
+
*/
|
|
1216
1242
|
create(element: HTMLElement, props: {
|
|
1217
1243
|
[key: string]: any;
|
|
1218
1244
|
}, commands: {
|
|
1219
1245
|
[key: string]: (args: any[]) => Promise<any>;
|
|
1220
1246
|
}, templates: {
|
|
1221
1247
|
[key: string]: string;
|
|
1222
|
-
},
|
|
1223
|
-
setProps: (p: {
|
|
1248
|
+
}, setProps: (p: {
|
|
1224
1249
|
[key: string]: any;
|
|
1225
1250
|
}) => void): DotvvmJsComponent;
|
|
1226
1251
|
};
|