dotvvm-types 5.0.0-preview02-final → 5.0.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 +229 -226
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,75 +1,4 @@
|
|
|
1
1
|
/// <reference types="knockout" />
|
|
2
|
-
declare module "shared-classes" {
|
|
3
|
-
export class DotvvmPostbackError {
|
|
4
|
-
reason: DotvvmPostbackErrorReason;
|
|
5
|
-
constructor(reason: DotvvmPostbackErrorReason);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
export class CoerceError extends Error implements CoerceErrorType {
|
|
9
|
-
path: string;
|
|
10
|
-
isError: true;
|
|
11
|
-
wasCoerced: false;
|
|
12
|
-
get value(): never;
|
|
13
|
-
constructor(message: string, path?: string);
|
|
14
|
-
static generic(value: any, type: TypeDefinition): CoerceError;
|
|
15
|
-
prependPathFragment(fragment: string): void;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
declare module "utils/logging" {
|
|
19
|
-
type LogLevel = "normal" | "verbose";
|
|
20
|
-
export const level: LogLevel;
|
|
21
|
-
type ConsoleLogLevel = "warn" | "log" | "error" | "trace";
|
|
22
|
-
let logger: (level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Instead of calling console.log, console.warn or console.error, DotVVM will call this function instead.
|
|
25
|
-
* Please keep in mind that the exact wording of log messages is not DotVVM public API and may change without notice.
|
|
26
|
-
* @example
|
|
27
|
-
* dotvvm.log.setLogger((next, level, area, ...args) => {
|
|
28
|
-
* if (area == "validation" && /^This message should be an error$/.test(args[0])) {
|
|
29
|
-
* level = "error"
|
|
30
|
-
* }
|
|
31
|
-
* previous(level, area, ...args) // call the default logger
|
|
32
|
-
* })
|
|
33
|
-
*/
|
|
34
|
-
export function setLogger(newLogger: (next: typeof logger, level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void): void;
|
|
35
|
-
export type DotvvmLoggingArea = ("debug" | "configuration" | "postback" | "spa" | "static-command" | "binding-handler" | "resource-loader" | "coercer" | "state-manager" | "validation" | "events" | "rest-api");
|
|
36
|
-
export function logInfoVerbose(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
37
|
-
export function logInfo(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
38
|
-
export function logWarning(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
39
|
-
export function logError(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
40
|
-
export function logPostBackScriptError(err: any): void;
|
|
41
|
-
/** puts the string in quotes, escaping weird characters if it is more complex than just letters */
|
|
42
|
-
export function debugQuoteString(s: string): string;
|
|
43
|
-
}
|
|
44
|
-
declare module "serialization/date" {
|
|
45
|
-
export function parseDate(value: string | null | undefined, convertFromUtc?: boolean): Date | null;
|
|
46
|
-
export function parseDateOnly(value: string | null | undefined): Date | null;
|
|
47
|
-
export function parseTimeOnly(value: string | null | undefined): Date | null;
|
|
48
|
-
export function parseTimeSpan(value: string | null | undefined): number | null;
|
|
49
|
-
export function parseDateTimeOffset(value: string | null | undefined): Date | null;
|
|
50
|
-
export function serializeDate(date: string | Date | null, convertToUtc?: boolean): string | null;
|
|
51
|
-
export function serializeDateOnly(date: Date): string;
|
|
52
|
-
export function serializeTimeOnly(date: Date): string;
|
|
53
|
-
export function serializeTimeSpan(ticks: number): string;
|
|
54
|
-
}
|
|
55
|
-
declare module "utils/dom" {
|
|
56
|
-
export const getElementByDotvvmId: (id: string) => HTMLElement;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated Use addEventListener directly
|
|
59
|
-
*/
|
|
60
|
-
export function attachEvent(target: any, name: string, callback: (ev: PointerEvent) => any, useCapture?: boolean): void;
|
|
61
|
-
export const isElementDisabled: (element: HTMLElement | null | undefined) => boolean | null | undefined;
|
|
62
|
-
export function setIdFragment(idFragment: string | null | undefined): void;
|
|
63
|
-
}
|
|
64
|
-
declare module "utils/knockout" {
|
|
65
|
-
export function wrapObservable<T>(obj: T): KnockoutObservable<T>;
|
|
66
|
-
export function wrapObservableObjectOrArray<T>(obj: T): KnockoutObservable<T> | KnockoutObservableArray<T>;
|
|
67
|
-
export function isObservableArray(target: any): boolean;
|
|
68
|
-
/** If ko.options.deferUpdates is on,
|
|
69
|
-
* obs.notifySubscribers() will not invoke them if the value didn't change, because the equalityComparer is checked again when the notification runs.
|
|
70
|
-
* This function removes the equalityComparer, waits for all tasks and returns it */
|
|
71
|
-
export function hackInvokeNotifySubscribers(obs: KnockoutObservable<any>): void;
|
|
72
|
-
}
|
|
73
2
|
declare module "utils/objects" {
|
|
74
3
|
export function isPrimitive(viewModel: any): boolean;
|
|
75
4
|
export const createArray: {
|
|
@@ -92,6 +21,7 @@ declare module "metadata/typeMap" {
|
|
|
92
21
|
[prop: string]: PropertyMetadata;
|
|
93
22
|
};
|
|
94
23
|
export function getKnownTypes(): string[];
|
|
24
|
+
export function getCurrentTypeMap(): TypeMap;
|
|
95
25
|
export function updateTypeInfo(newTypes: TypeMap | undefined): void;
|
|
96
26
|
export function replaceTypeInfo(newTypes: TypeMap | undefined): void;
|
|
97
27
|
export function areObjectTypesEqual(currentValue: any, newVal: any): boolean;
|
|
@@ -126,6 +56,26 @@ declare module "events" {
|
|
|
126
56
|
export const staticCommandMethodFailed: DotvvmEvent<DotvvmStaticCommandMethodFailedEventArgs>;
|
|
127
57
|
export const newState: DotvvmEvent<RootViewModel>;
|
|
128
58
|
}
|
|
59
|
+
declare module "utils/knockout" {
|
|
60
|
+
export function wrapObservable<T>(obj: T): KnockoutObservable<T>;
|
|
61
|
+
export function wrapObservableObjectOrArray<T>(obj: T): KnockoutObservable<T> | KnockoutObservableArray<T>;
|
|
62
|
+
export function isObservableArray(target: any): boolean;
|
|
63
|
+
/** If ko.options.deferUpdates is on,
|
|
64
|
+
* obs.notifySubscribers() will not invoke them if the value didn't change, because the equalityComparer is checked again when the notification runs.
|
|
65
|
+
* This function removes the equalityComparer, waits for all tasks and returns it */
|
|
66
|
+
export function hackInvokeNotifySubscribers(obs: KnockoutObservable<any>): void;
|
|
67
|
+
}
|
|
68
|
+
declare module "serialization/deserialize" {
|
|
69
|
+
export function deserialize(viewModel: any, target?: any, deserializeAll?: boolean): any;
|
|
70
|
+
export function deserializePrimitive(viewModel: any, target?: any): any;
|
|
71
|
+
export function deserializeDate(viewModel: any, target?: any): any;
|
|
72
|
+
export function deserializeArray(viewModel: any, target?: any, deserializeAll?: boolean): any;
|
|
73
|
+
export function deserializeObject(viewModel: any, target: any, deserializeAll: boolean): any;
|
|
74
|
+
export function extendToObservableArrayIfRequired(observable: any): any;
|
|
75
|
+
/** Clones only updatable properties from the object.
|
|
76
|
+
* Used after postback, to avoid updating properties which were sent to server, but weren't sent back. */
|
|
77
|
+
export function mapUpdatableProperties(viewModel: any, type?: TypeDefinition | undefined): any;
|
|
78
|
+
}
|
|
129
79
|
declare module "utils/isNumber" {
|
|
130
80
|
export function isNumber(value: any): boolean;
|
|
131
81
|
}
|
|
@@ -151,17 +101,23 @@ declare module "metadata/coercer" {
|
|
|
151
101
|
export function tryCoerce(value: any, type: TypeDefinition | null | undefined, originalValue?: any): CoerceResult;
|
|
152
102
|
export function coerce(value: any, type: TypeDefinition, originalValue?: any): any;
|
|
153
103
|
}
|
|
154
|
-
declare module "utils/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
104
|
+
declare module "utils/dom" {
|
|
105
|
+
export const getElementByDotvvmId: (id: string) => HTMLElement;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use addEventListener directly
|
|
108
|
+
*/
|
|
109
|
+
export function attachEvent(target: any, name: string, callback: (ev: PointerEvent) => any, useCapture?: boolean): void;
|
|
110
|
+
export const isElementDisabled: (element: HTMLElement | null | undefined) => boolean | null | undefined;
|
|
111
|
+
export function setIdFragment(idFragment: string | null | undefined): void;
|
|
158
112
|
}
|
|
159
|
-
declare module "postback/
|
|
160
|
-
export
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
export function
|
|
164
|
-
export
|
|
113
|
+
declare module "postback/resourceLoader" {
|
|
114
|
+
export type RenderedResourceList = {
|
|
115
|
+
[name: string]: string;
|
|
116
|
+
};
|
|
117
|
+
export function registerResources(rs: string[] | null | undefined): void;
|
|
118
|
+
export const getRenderedResources: () => string[];
|
|
119
|
+
export function loadResourceList(resources: RenderedResourceList | undefined): Promise<void>;
|
|
120
|
+
export function notifyModuleLoaded(id: number): void;
|
|
165
121
|
}
|
|
166
122
|
declare module "validation/common" {
|
|
167
123
|
export type DotvvmValidationContext = {
|
|
@@ -182,146 +138,10 @@ declare module "validation/common" {
|
|
|
182
138
|
export function isEmpty(value: any): boolean;
|
|
183
139
|
export function getValidationMetadata(property: KnockoutObservable<any>): DotvvmValidationObservableMetadata;
|
|
184
140
|
}
|
|
185
|
-
declare module "utils/
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* @example "" or null - returns context
|
|
190
|
-
* @example /exampleProp/A - returns prop A located withing property exampleProp located at provided context
|
|
191
|
-
* @example /exampleProp/B/1 - returns second item from collection B located within property exampleProp located at provided context
|
|
192
|
-
* @returns found property as unwrapped object
|
|
193
|
-
*/
|
|
194
|
-
export function traverseContext(context: any, path: string): any;
|
|
195
|
-
export function findPathToChildObservable(vm: any, child: any, path: string): string | null;
|
|
196
|
-
export function getDataSourceItems(viewModel: any): Array<KnockoutObservable<any>>;
|
|
197
|
-
export function wrapObservable(func: () => any, isArray?: boolean): KnockoutComputed<any>;
|
|
198
|
-
export function proxyObservableArrayMethods(wrapper: KnockoutObservable<any>, getObservableArray: () => any): void;
|
|
199
|
-
export const unwrapComputedProperty: (obs: any) => any;
|
|
200
|
-
}
|
|
201
|
-
declare module "validation/error" {
|
|
202
|
-
export const allErrors: ValidationError[];
|
|
203
|
-
export function detachAllErrors(): void;
|
|
204
|
-
export function getErrors<T>(o: KnockoutObservable<T> | null): ValidationError[];
|
|
205
|
-
export class ValidationError {
|
|
206
|
-
errorMessage: string;
|
|
207
|
-
propertyPath: string;
|
|
208
|
-
validatedObservable: KnockoutObservable<any>;
|
|
209
|
-
private constructor();
|
|
210
|
-
static attach(errorMessage: string, propertyPath: string, observable: KnockoutObservable<any>): ValidationError;
|
|
211
|
-
detach(): void;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
declare module "state-manager" {
|
|
215
|
-
import { DotvvmEvent } from "events";
|
|
216
|
-
import { ValidationError } from "validation/error";
|
|
217
|
-
import { errorsSymbol } from "validation/common";
|
|
218
|
-
export const currentStateSymbol: unique symbol;
|
|
219
|
-
export const notifySymbol: unique symbol;
|
|
220
|
-
export const lastSetErrorSymbol: unique symbol;
|
|
221
|
-
export const internalPropCache: unique symbol;
|
|
222
|
-
export const updateSymbol: unique symbol;
|
|
223
|
-
export const updatePropertySymbol: unique symbol;
|
|
224
|
-
export function getIsViewModelUpdating(): boolean;
|
|
225
|
-
export type UpdatableObjectExtensions<T> = {
|
|
226
|
-
[notifySymbol]: (newValue: T) => void;
|
|
227
|
-
[currentStateSymbol]: T;
|
|
228
|
-
[updateSymbol]?: UpdateDispatcher<T>;
|
|
229
|
-
};
|
|
230
|
-
/** Manages the consistency of DotVVM immutable ViewModel state object with the knockout observables.
|
|
231
|
-
* Knockout observables are by-default updated asynchronously after a state change, but the synchronization can be forced by calling `doUpdateNow`.
|
|
232
|
-
* The newState event is also called asynchronously right before the knockout observables are updated.
|
|
233
|
-
* Changes from observables to state are immediate.
|
|
234
|
-
*/
|
|
235
|
-
export class StateManager<TViewModel extends {
|
|
236
|
-
$type?: TypeDefinition;
|
|
237
|
-
}> implements DotvvmStateContainer<TViewModel> {
|
|
238
|
-
stateUpdateEvent?: DotvvmEvent<DeepReadonly<TViewModel>> | undefined;
|
|
239
|
-
/** The knockout observable containing the root objects, equivalent to `dotvvm.viewModels.root.viewModel` */
|
|
240
|
-
readonly stateObservable: DeepKnockoutObservable<TViewModel>;
|
|
241
|
-
private _state;
|
|
242
|
-
/** Returns the current */
|
|
243
|
-
get state(): DeepReadonly<TViewModel>;
|
|
244
|
-
private _isDirty;
|
|
245
|
-
/** Indicates whether there is a pending update of the knockout observables. */
|
|
246
|
-
get isDirty(): boolean;
|
|
247
|
-
private _currentFrameNumber;
|
|
248
|
-
constructor(initialState: DeepReadonly<TViewModel>, stateUpdateEvent?: DotvvmEvent<DeepReadonly<TViewModel>> | undefined);
|
|
249
|
-
private dispatchUpdate;
|
|
250
|
-
/** Performs a synchronous update of knockout observables with the data currently stored in `state`.
|
|
251
|
-
* Consequently, if ko.options.deferUpdates is false (default), the UI will be updated immediately.
|
|
252
|
-
* If ko.options.deferUpdates is true, the UI can be manually updated by also calling the `ko.tasks.runEarly()` function. */
|
|
253
|
-
doUpdateNow(): void;
|
|
254
|
-
private rerender;
|
|
255
|
-
/** Sets a new view model state, after checking its type compatibility and possibly performing implicit conversions.
|
|
256
|
-
* Only the changed objects are re-checked and updated in the knockout observables.
|
|
257
|
-
* It is therefore recommended to clone only the changed parts of the view model using the `{... x, ChangedProp: 1 }` syntax.
|
|
258
|
-
* In the rarely occuring complex cases where this is difficult, you can use `structuredClone` to obtain a writable clone of some part of the viewmodel.
|
|
259
|
-
*
|
|
260
|
-
* @throws CoerceError if the new state has incompatible type.
|
|
261
|
-
* @returns The type-coerced version of the new state. */
|
|
262
|
-
setState(newState: DeepReadonly<TViewModel>): DeepReadonly<TViewModel>;
|
|
263
|
-
/** Applies a patch to the current view model state.
|
|
264
|
-
* @throws CoerceError if the new state has incompatible type.
|
|
265
|
-
* @returns The type-coerced version of the new state. */
|
|
266
|
-
patchState(patch: DeepReadonly<DeepPartial<TViewModel>>): DeepReadonly<TViewModel>;
|
|
267
|
-
/** Updates the view model state using the provided `State => State` function.
|
|
268
|
-
* @throws CoerceError if the new state has incompatible type.
|
|
269
|
-
* @returns The type-coerced version of the new state. */
|
|
270
|
-
updateState(updater: StateUpdate<TViewModel>): DeepReadonly<TViewModel>;
|
|
271
|
-
/** @deprecated Use updateState method instead */
|
|
272
|
-
update: UpdateDispatcher<TViewModel>;
|
|
273
|
-
}
|
|
274
|
-
class FakeObservableObject<T extends object> implements UpdatableObjectExtensions<T> {
|
|
275
|
-
[currentStateSymbol]: T;
|
|
276
|
-
[errorsSymbol]: Array<ValidationError>;
|
|
277
|
-
[updateSymbol]: UpdateDispatcher<T>;
|
|
278
|
-
[notifySymbol](newValue: T): void;
|
|
279
|
-
[internalPropCache]: {
|
|
280
|
-
[name: string]: (KnockoutObservable<any> & UpdatableObjectExtensions<any>) | null;
|
|
281
|
-
};
|
|
282
|
-
[updatePropertySymbol](propName: keyof DeepReadonly<T>, valUpdate: StateUpdate<any>): void;
|
|
283
|
-
constructor(initialValue: T, getter: () => DeepReadonly<T> | undefined, updater: UpdateDispatcher<T>, typeId: TypeDefinition, typeInfo: ObjectTypeMetadata | DynamicTypeMetadata | undefined, additionalProperties: string[]);
|
|
284
|
-
}
|
|
285
|
-
export function isDotvvmObservable(obj: any): obj is DotvvmObservable<any>;
|
|
286
|
-
export function isFakeObservableObject(obj: any): obj is FakeObservableObject<any>;
|
|
287
|
-
/**
|
|
288
|
-
* Recursively unwraps knockout observables from the object / array hierarchy. When nothing needs to be unwrapped, the original object is returned.
|
|
289
|
-
* @param allowStateUnwrap Allows accessing [currentStateSymbol], which makes it faster, but doesn't register in the knockout dependency tracker
|
|
290
|
-
* @param preferStateAccess Also allows accessing observable.state, which also doesn't register in the knockout dependency tracker, but returns an realtime updated value directly from dotvvm.state
|
|
291
|
-
*/
|
|
292
|
-
export function unmapKnockoutObservables(viewModel: any, allowStateUnwrap?: boolean, preferStateAccess?: boolean): any;
|
|
293
|
-
}
|
|
294
|
-
declare module "serialization/deserialize" {
|
|
295
|
-
export function deserialize(viewModel: any, target?: any, deserializeAll?: boolean): any;
|
|
296
|
-
export function deserializePrimitive(viewModel: any, target?: any): any;
|
|
297
|
-
export function deserializeDate(viewModel: any, target?: any): any;
|
|
298
|
-
export function deserializeArray(viewModel: any, target?: any, deserializeAll?: boolean): any;
|
|
299
|
-
export function deserializeObject(viewModel: any, target: any, deserializeAll: boolean): any;
|
|
300
|
-
export function extendToObservableArrayIfRequired(observable: any): any;
|
|
301
|
-
/** Clones only updatable properties from the object.
|
|
302
|
-
* Used after postback, to avoid updating properties which were sent to server, but weren't sent back. */
|
|
303
|
-
export function mapUpdatableProperties(viewModel: any, type?: TypeDefinition | undefined): any;
|
|
304
|
-
}
|
|
305
|
-
declare module "serialization/serialize" {
|
|
306
|
-
interface ISerializationOptions {
|
|
307
|
-
serializeAll?: boolean;
|
|
308
|
-
ignoreSpecialProperties?: boolean;
|
|
309
|
-
pathMatcher?: (vm: any) => boolean;
|
|
310
|
-
path?: string[];
|
|
311
|
-
pathOnly?: boolean;
|
|
312
|
-
restApiTarget?: boolean;
|
|
313
|
-
}
|
|
314
|
-
export function serialize(viewModel: any, opt?: ISerializationOptions): any;
|
|
315
|
-
export function serializeCore(viewModel: any, opt?: ISerializationOptions): any;
|
|
316
|
-
}
|
|
317
|
-
declare module "postback/resourceLoader" {
|
|
318
|
-
export type RenderedResourceList = {
|
|
319
|
-
[name: string]: string;
|
|
320
|
-
};
|
|
321
|
-
export function registerResources(rs: string[] | null | undefined): void;
|
|
322
|
-
export const getRenderedResources: () => string[];
|
|
323
|
-
export function loadResourceList(resources: RenderedResourceList | undefined): Promise<void>;
|
|
324
|
-
export function notifyModuleLoaded(id: number): void;
|
|
141
|
+
declare module "utils/promise" {
|
|
142
|
+
/** Runs the callback in the next event loop cycle */
|
|
143
|
+
export const defer: <T>(callback: () => T) => Promise<T>;
|
|
144
|
+
export const delay: (ms: number) => Promise<unknown>;
|
|
325
145
|
}
|
|
326
146
|
declare module "binding-handlers/textbox-text" {
|
|
327
147
|
const _default: {
|
|
@@ -360,6 +180,22 @@ declare module "binding-handlers/SSR-foreach" {
|
|
|
360
180
|
};
|
|
361
181
|
export default _default_2;
|
|
362
182
|
}
|
|
183
|
+
declare module "utils/evaluator" {
|
|
184
|
+
/**
|
|
185
|
+
* Traverses provided context according to given path.
|
|
186
|
+
* @example / - returns context
|
|
187
|
+
* @example "" or null - returns context
|
|
188
|
+
* @example /exampleProp/A - returns prop A located withing property exampleProp located at provided context
|
|
189
|
+
* @example /exampleProp/B/1 - returns second item from collection B located within property exampleProp located at provided context
|
|
190
|
+
* @returns found property as unwrapped object
|
|
191
|
+
*/
|
|
192
|
+
export function traverseContext(context: any, path: string): any;
|
|
193
|
+
export function findPathToChildObservable(vm: any, child: any, path: string): string | null;
|
|
194
|
+
export function getDataSourceItems(viewModel: any): Array<KnockoutObservable<any>>;
|
|
195
|
+
export function wrapObservable(func: () => any, isArray?: boolean): KnockoutComputed<any>;
|
|
196
|
+
export function proxyObservableArrayMethods(wrapper: KnockoutObservable<any>, getObservableArray: () => any): void;
|
|
197
|
+
export const unwrapComputedProperty: (obs: any) => any;
|
|
198
|
+
}
|
|
363
199
|
declare module "viewModules/viewModuleManager" {
|
|
364
200
|
type ModuleCommand = (...args: any) => Promise<unknown>;
|
|
365
201
|
export const viewModulesSymbol: unique symbol;
|
|
@@ -566,6 +402,11 @@ declare module "spa/events" {
|
|
|
566
402
|
export const spaNavigated: DotvvmEvent<DotvvmSpaNavigatedEventArgs>;
|
|
567
403
|
export const spaNavigationFailed: DotvvmEvent<DotvvmSpaNavigationFailedEventArgs>;
|
|
568
404
|
}
|
|
405
|
+
declare module "metadata/metadataHelper" {
|
|
406
|
+
export function getTypeId(viewModel: object): string | undefined;
|
|
407
|
+
export function getTypeMetadata(typeId: string | object): TypeMetadata;
|
|
408
|
+
export function getEnumMetadata(enumMetadataId: string): EnumTypeMetadata;
|
|
409
|
+
}
|
|
569
410
|
declare module "dotvvm-base" {
|
|
570
411
|
import { StateManager } from "state-manager";
|
|
571
412
|
export const options: {
|
|
@@ -581,11 +422,178 @@ declare module "dotvvm-base" {
|
|
|
581
422
|
export function getState(): Readonly<RootViewModel>;
|
|
582
423
|
export function updateViewModelCache(viewModelCacheId: string, viewModelCache: any): void;
|
|
583
424
|
export function clearViewModelCache(): void;
|
|
425
|
+
export function updateInitialUrl(url: string): void;
|
|
584
426
|
export function getCulture(): string;
|
|
585
427
|
export function getStateManager(): StateManager<RootViewModel>;
|
|
586
428
|
export function initCore(culture: string): void;
|
|
587
429
|
export function initBindings(): void;
|
|
588
430
|
}
|
|
431
|
+
declare module "postback/updater" {
|
|
432
|
+
export function cleanUpdatedControls(resultObject: any, updatedControls?: any): any;
|
|
433
|
+
export function restoreUpdatedControls(resultObject: any, updatedControls: any): void;
|
|
434
|
+
export function updateViewModelAndControls(resultObject: any, updateTypeInfo: (t: TypeMap) => void): void;
|
|
435
|
+
export function patchViewModel(source: any, patch: any): any;
|
|
436
|
+
export function diffViewModel(source: any, modified: any): any;
|
|
437
|
+
}
|
|
438
|
+
declare module "validation/error" {
|
|
439
|
+
export const allErrors: ValidationError[];
|
|
440
|
+
export function detachAllErrors(): void;
|
|
441
|
+
export function getErrors<T>(o: KnockoutObservable<T> | null): ValidationError[];
|
|
442
|
+
export class ValidationError {
|
|
443
|
+
errorMessage: string;
|
|
444
|
+
propertyPath: string;
|
|
445
|
+
validatedObservable: KnockoutObservable<any>;
|
|
446
|
+
private constructor();
|
|
447
|
+
static attach(errorMessage: string, propertyPath: string, observable: KnockoutObservable<any>): ValidationError;
|
|
448
|
+
detach(): void;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
declare module "state-manager" {
|
|
452
|
+
import { DotvvmEvent } from "events";
|
|
453
|
+
import { ValidationError } from "validation/error";
|
|
454
|
+
import { errorsSymbol } from "validation/common";
|
|
455
|
+
export const currentStateSymbol: unique symbol;
|
|
456
|
+
export const notifySymbol: unique symbol;
|
|
457
|
+
export const lastSetErrorSymbol: unique symbol;
|
|
458
|
+
export const internalPropCache: unique symbol;
|
|
459
|
+
export const updateSymbol: unique symbol;
|
|
460
|
+
export const updatePropertySymbol: unique symbol;
|
|
461
|
+
export function getIsViewModelUpdating(): boolean;
|
|
462
|
+
export type UpdatableObjectExtensions<T> = {
|
|
463
|
+
[notifySymbol]: (newValue: T) => void;
|
|
464
|
+
[currentStateSymbol]: T;
|
|
465
|
+
[updateSymbol]?: UpdateDispatcher<T>;
|
|
466
|
+
};
|
|
467
|
+
/** Manages the consistency of DotVVM immutable ViewModel state object with the knockout observables.
|
|
468
|
+
* Knockout observables are by-default updated asynchronously after a state change, but the synchronization can be forced by calling `doUpdateNow`.
|
|
469
|
+
* The newState event is also called asynchronously right before the knockout observables are updated.
|
|
470
|
+
* Changes from observables to state are immediate.
|
|
471
|
+
*/
|
|
472
|
+
export class StateManager<TViewModel extends {
|
|
473
|
+
$type?: TypeDefinition;
|
|
474
|
+
}> implements DotvvmStateContainer<TViewModel> {
|
|
475
|
+
stateUpdateEvent?: DotvvmEvent<DeepReadonly<TViewModel>> | undefined;
|
|
476
|
+
/** The knockout observable containing the root objects, equivalent to `dotvvm.viewModels.root.viewModel` */
|
|
477
|
+
readonly stateObservable: DeepKnockoutObservable<TViewModel>;
|
|
478
|
+
private _state;
|
|
479
|
+
/** Returns the current */
|
|
480
|
+
get state(): DeepReadonly<TViewModel>;
|
|
481
|
+
private _isDirty;
|
|
482
|
+
/** Indicates whether there is a pending update of the knockout observables. */
|
|
483
|
+
get isDirty(): boolean;
|
|
484
|
+
private _currentFrameNumber;
|
|
485
|
+
constructor(initialState: DeepReadonly<TViewModel>, stateUpdateEvent?: DotvvmEvent<DeepReadonly<TViewModel>> | undefined);
|
|
486
|
+
private dispatchUpdate;
|
|
487
|
+
/** Performs a synchronous update of knockout observables with the data currently stored in `state`.
|
|
488
|
+
* Consequently, if ko.options.deferUpdates is false (default), the UI will be updated immediately.
|
|
489
|
+
* If ko.options.deferUpdates is true, the UI can be manually updated by also calling the `ko.tasks.runEarly()` function. */
|
|
490
|
+
doUpdateNow(): void;
|
|
491
|
+
private rerender;
|
|
492
|
+
/** Sets a new view model state, after checking its type compatibility and possibly performing implicit conversions.
|
|
493
|
+
* Only the changed objects are re-checked and updated in the knockout observables.
|
|
494
|
+
* It is therefore recommended to clone only the changed parts of the view model using the `{... x, ChangedProp: 1 }` syntax.
|
|
495
|
+
* In the rarely occuring complex cases where this is difficult, you can use `structuredClone` to obtain a writable clone of some part of the viewmodel.
|
|
496
|
+
*
|
|
497
|
+
* @throws CoerceError if the new state has incompatible type.
|
|
498
|
+
* @returns The type-coerced version of the new state. */
|
|
499
|
+
setState(newState: DeepReadonly<TViewModel>): DeepReadonly<TViewModel>;
|
|
500
|
+
/** Applies a patch to the current view model state.
|
|
501
|
+
* @throws CoerceError if the new state has incompatible type.
|
|
502
|
+
* @returns The type-coerced version of the new state. */
|
|
503
|
+
patchState(patch: DeepReadonly<DeepPartial<TViewModel>>): DeepReadonly<TViewModel>;
|
|
504
|
+
/** Updates the view model state using the provided `State => State` function.
|
|
505
|
+
* @throws CoerceError if the new state has incompatible type.
|
|
506
|
+
* @returns The type-coerced version of the new state. */
|
|
507
|
+
updateState(updater: StateUpdate<TViewModel>): DeepReadonly<TViewModel>;
|
|
508
|
+
/** @deprecated Use updateState method instead */
|
|
509
|
+
update: UpdateDispatcher<TViewModel>;
|
|
510
|
+
}
|
|
511
|
+
class FakeObservableObject<T extends object> implements UpdatableObjectExtensions<T> {
|
|
512
|
+
[currentStateSymbol]: T;
|
|
513
|
+
[errorsSymbol]: Array<ValidationError>;
|
|
514
|
+
[updateSymbol]: UpdateDispatcher<T>;
|
|
515
|
+
[notifySymbol](newValue: T): void;
|
|
516
|
+
[internalPropCache]: {
|
|
517
|
+
[name: string]: (KnockoutObservable<any> & UpdatableObjectExtensions<any>) | null;
|
|
518
|
+
};
|
|
519
|
+
[updatePropertySymbol](propName: keyof DeepReadonly<T>, valUpdate: StateUpdate<any>): void;
|
|
520
|
+
constructor(initialValue: T, getter: () => DeepReadonly<T> | undefined, updater: UpdateDispatcher<T>, typeId: TypeDefinition, typeInfo: ObjectTypeMetadata | DynamicTypeMetadata | undefined, additionalProperties: string[]);
|
|
521
|
+
}
|
|
522
|
+
export function isDotvvmObservable(obj: any): obj is DotvvmObservable<any>;
|
|
523
|
+
export function isFakeObservableObject(obj: any): obj is FakeObservableObject<any>;
|
|
524
|
+
/**
|
|
525
|
+
* Recursively unwraps knockout observables from the object / array hierarchy. When nothing needs to be unwrapped, the original object is returned.
|
|
526
|
+
* @param allowStateUnwrap Allows accessing [currentStateSymbol], which makes it faster, but doesn't register in the knockout dependency tracker
|
|
527
|
+
* @param preferStateAccess Also allows accessing observable.state, which also doesn't register in the knockout dependency tracker, but returns an realtime updated value directly from dotvvm.state
|
|
528
|
+
*/
|
|
529
|
+
export function unmapKnockoutObservables(viewModel: any, allowStateUnwrap?: boolean, preferStateAccess?: boolean): any;
|
|
530
|
+
}
|
|
531
|
+
declare module "serialization/serialize" {
|
|
532
|
+
interface ISerializationOptions {
|
|
533
|
+
serializeAll?: boolean;
|
|
534
|
+
ignoreSpecialProperties?: boolean;
|
|
535
|
+
pathMatcher?: (vm: any) => boolean;
|
|
536
|
+
path?: string[];
|
|
537
|
+
pathOnly?: boolean;
|
|
538
|
+
restApiTarget?: boolean;
|
|
539
|
+
}
|
|
540
|
+
export function serialize(viewModel: any, opt?: ISerializationOptions): any;
|
|
541
|
+
export function serializeCore(viewModel: any, opt?: ISerializationOptions): any;
|
|
542
|
+
export function jsonStringify(value: any, indent?: string | undefined): string;
|
|
543
|
+
}
|
|
544
|
+
declare module "shared-classes" {
|
|
545
|
+
export class DotvvmPostbackError {
|
|
546
|
+
reason: DotvvmPostbackErrorReason;
|
|
547
|
+
constructor(reason: DotvvmPostbackErrorReason);
|
|
548
|
+
toString(): string;
|
|
549
|
+
}
|
|
550
|
+
export class CoerceError extends Error implements CoerceErrorType {
|
|
551
|
+
path: string;
|
|
552
|
+
isError: true;
|
|
553
|
+
wasCoerced: false;
|
|
554
|
+
get value(): never;
|
|
555
|
+
constructor(message: string, path?: string);
|
|
556
|
+
static generic(value: any, type: TypeDefinition): CoerceError;
|
|
557
|
+
prependPathFragment(fragment: string): void;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
declare module "utils/logging" {
|
|
561
|
+
type LogLevel = "normal" | "verbose";
|
|
562
|
+
export const level: LogLevel;
|
|
563
|
+
type ConsoleLogLevel = "warn" | "log" | "error" | "trace";
|
|
564
|
+
let logger: (level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void;
|
|
565
|
+
/**
|
|
566
|
+
* Instead of calling console.log, console.warn or console.error, DotVVM will call this function instead.
|
|
567
|
+
* Please keep in mind that the exact wording of log messages is not DotVVM public API and may change without notice.
|
|
568
|
+
* @example
|
|
569
|
+
* dotvvm.log.setLogger((next, level, area, ...args) => {
|
|
570
|
+
* if (area == "validation" && /^This message should be an error$/.test(args[0])) {
|
|
571
|
+
* level = "error"
|
|
572
|
+
* }
|
|
573
|
+
* previous(level, area, ...args) // call the default logger
|
|
574
|
+
* })
|
|
575
|
+
*/
|
|
576
|
+
export function setLogger(newLogger: (next: typeof logger, level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void): void;
|
|
577
|
+
export type DotvvmLoggingArea = ("debug" | "configuration" | "postback" | "spa" | "static-command" | "binding-handler" | "resource-loader" | "coercer" | "state-manager" | "validation" | "events" | "rest-api");
|
|
578
|
+
export function logInfoVerbose(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
579
|
+
export function logInfo(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
580
|
+
export function logWarning(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
581
|
+
export function logError(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
582
|
+
export function logPostBackScriptError(err: any): void;
|
|
583
|
+
/** puts the string in quotes, escaping weird characters if it is more complex than just letters */
|
|
584
|
+
export function debugQuoteString(s: string): string;
|
|
585
|
+
}
|
|
586
|
+
declare module "serialization/date" {
|
|
587
|
+
export function parseDate(value: string | null | undefined, convertFromUtc?: boolean): Date | null;
|
|
588
|
+
export function parseDateOnly(value: string | null | undefined): Date | null;
|
|
589
|
+
export function parseTimeOnly(value: string | null | undefined): Date | null;
|
|
590
|
+
export function parseTimeSpan(value: string | null | undefined): number | null;
|
|
591
|
+
export function parseDateTimeOffset(value: string | null | undefined): Date | null;
|
|
592
|
+
export function serializeDate(date: string | Date | null, convertToUtc?: boolean): string | null;
|
|
593
|
+
export function serializeDateOnly(date: Date): string;
|
|
594
|
+
export function serializeTimeOnly(date: Date): string;
|
|
595
|
+
export function serializeTimeSpan(ticks: number): string;
|
|
596
|
+
}
|
|
589
597
|
declare module "DotVVM.Globalize" {
|
|
590
598
|
import { parseDate as serializationParseDate } from "serialization/date";
|
|
591
599
|
export function format(format: string, ...values: any[]): string;
|
|
@@ -806,11 +814,6 @@ declare module "controls/fileUpload" {
|
|
|
806
814
|
export function showUploadDialog(sender: HTMLElement): void;
|
|
807
815
|
export function reportProgress(inputControl: HTMLInputElement, isBusy: boolean, progress: number, result: DotvvmStaticCommandResponse<DotvvmFileUploadData[]> | string): void;
|
|
808
816
|
}
|
|
809
|
-
declare module "metadata/metadataHelper" {
|
|
810
|
-
export function getTypeId(viewModel: object): string | undefined;
|
|
811
|
-
export function getTypeMetadata(typeId: string | object): TypeMetadata;
|
|
812
|
-
export function getEnumMetadata(enumMetadataId: string): EnumTypeMetadata;
|
|
813
|
-
}
|
|
814
817
|
declare module "translations/sortingHelper" {
|
|
815
818
|
type ElementType = string | number | boolean;
|
|
816
819
|
export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string | null) => T[];
|