dotvvm-types 3.0.2 → 4.1.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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference path="../../Resources/Scripts/typings/globalize/globalize.d.ts" />
1
2
  declare module "shared-classes" {
2
3
  export class DotvvmPostbackError {
3
4
  reason: DotvvmPostbackErrorReason;
@@ -25,9 +26,9 @@ declare module "utils/logging" {
25
26
  export function logPostBackScriptError(err: any): void;
26
27
  }
27
28
  declare module "serialization/date" {
28
- export function parseDate(value: string): Date | null;
29
- export function parseTimeSpan(value: string): number | null;
30
- export function parseDateTimeOffset(value: string): Date | null;
29
+ export function parseDate(value: string | null, convertFromUtc?: boolean): Date | null;
30
+ export function parseTimeSpan(value: string | null): number | null;
31
+ export function parseDateTimeOffset(value: string | null): Date | null;
31
32
  export function serializeDate(date: string | Date | null, convertToUtc?: boolean): string | null;
32
33
  export function serializeTimeSpan(time: string | number | null): string | null;
33
34
  }
@@ -47,9 +48,13 @@ declare module "utils/knockout" {
47
48
  }
48
49
  declare module "utils/objects" {
49
50
  export function isPrimitive(viewModel: any): boolean;
50
- export const createArray: <T>(a: ArrayLike<T>) => T[];
51
+ export const createArray: {
52
+ <T>(arrayLike: ArrayLike<T>): T[];
53
+ <T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
54
+ <T_2>(iterable: Iterable<T_2> | ArrayLike<T_2>): T_2[];
55
+ <T_3, U_1>(iterable: Iterable<T_3> | ArrayLike<T_3>, mapfn: (v: T_3, k: number) => U_1, thisArg?: any): U_1[];
56
+ };
51
57
  export const hasOwnProperty: (obj: any, prop: string) => boolean;
52
- export const symbolOrDollar: (name: string) => symbol;
53
58
  export const keys: {
54
59
  (o: object): string[];
55
60
  (o: {}): string[];
@@ -62,14 +67,6 @@ declare module "metadata/typeMap" {
62
67
  export function updateTypeInfo(newTypes: TypeMap | undefined): void;
63
68
  export function replaceTypeInfo(newTypes: TypeMap | undefined): void;
64
69
  }
65
- declare module "serialization/deserialize" {
66
- export function deserialize(viewModel: any, target?: any, deserializeAll?: boolean): any;
67
- export function deserializePrimitive(viewModel: any, target?: any): any;
68
- export function deserializeDate(viewModel: any, target?: any): any;
69
- export function deserializeArray(viewModel: any, target?: any, deserializeAll?: boolean): any;
70
- export function deserializeObject(viewModel: any, target: any, deserializeAll: boolean): any;
71
- export function extendToObservableArrayIfRequired(observable: any): any;
72
- }
73
70
  declare module "events" {
74
71
  export class DotvvmEvent<T> {
75
72
  readonly name: string;
@@ -94,7 +91,7 @@ declare module "events" {
94
91
  export const postbackCommitInvoked: DotvvmEvent<DotvvmPostbackCommitInvokedEventArgs>;
95
92
  export const postbackViewModelUpdated: DotvvmEvent<DotvvmPostbackViewModelUpdatedEventArgs>;
96
93
  export const postbackRejected: DotvvmEvent<DotvvmPostbackRejectedEventArgs>;
97
- export const staticCommandMethodInvoking: DotvvmEvent<DotvvmStaticCommandMethodEventArgs>;
94
+ export const staticCommandMethodInvoking: DotvvmEvent<DotvvmStaticCommandMethodInvokingEventArgs>;
98
95
  export const staticCommandMethodInvoked: DotvvmEvent<DotvvmStaticCommandMethodInvokedEventArgs>;
99
96
  export const staticCommandMethodFailed: DotvvmEvent<DotvvmStaticCommandMethodFailedEventArgs>;
100
97
  export const newState: DotvvmEvent<RootViewModel>;
@@ -123,10 +120,57 @@ declare module "postback/updater" {
123
120
  export function patchViewModel(source: any, patch: any): any;
124
121
  export function diffViewModel(source: any, modified: any): any;
125
122
  }
123
+ declare module "validation/common" {
124
+ export type DotvvmValidationContext = {
125
+ readonly valueToValidate: any;
126
+ readonly parentViewModel: any;
127
+ readonly parameters: any[];
128
+ };
129
+ export type DotvvmValidationObservableMetadata = DotvvmValidationElementMetadata[];
130
+ export type DotvvmValidationElementMetadata = {
131
+ element: HTMLElement;
132
+ dataType: string;
133
+ format: string;
134
+ domNodeDisposal: boolean;
135
+ elementValidationState: boolean;
136
+ };
137
+ export const errorsSymbol: unique symbol;
138
+ /** Checks if the value is null, undefined or a whitespace only string */
139
+ export function isEmpty(value: any): boolean;
140
+ export function getValidationMetadata(property: KnockoutObservable<any>): DotvvmValidationObservableMetadata;
141
+ }
142
+ declare module "utils/evaluator" {
143
+ /**
144
+ * Traverses provided context according to given path.
145
+ * @example / - returns context
146
+ * @example "" or null - returns context
147
+ * @example /exampleProp/A - returns prop A located withing property exampleProp located at provided context
148
+ * @example /exampleProp/B/1 - returns second item from collection B located within property exampleProp located at provided context
149
+ * @returns found property as unwrapped object
150
+ */
151
+ export function traverseContext(context: any, path: string): any;
152
+ export function findPathToChildObject(vm: any, child: any, path: string): string | null;
153
+ export function getDataSourceItems(viewModel: any): Array<KnockoutObservable<any>>;
154
+ export function wrapObservable(func: () => any, isArray?: boolean): KnockoutComputed<any>;
155
+ export const unwrapComputedProperty: (obs: any) => any;
156
+ }
157
+ declare module "validation/error" {
158
+ export const allErrors: ValidationError[];
159
+ export function detachAllErrors(): void;
160
+ export function getErrors<T>(o: KnockoutObservable<T> | null): ValidationError[];
161
+ export class ValidationError {
162
+ errorMessage: string;
163
+ propertyPath: string;
164
+ validatedObservable: KnockoutObservable<any>;
165
+ private constructor();
166
+ static attach(errorMessage: string, propertyPath: string, observable: KnockoutObservable<any>): ValidationError;
167
+ detach(): void;
168
+ }
169
+ }
126
170
  declare module "state-manager" {
127
171
  import { DotvvmEvent } from "events";
128
172
  export const currentStateSymbol: unique symbol;
129
- const notifySymbol: unique symbol;
173
+ export const notifySymbol: unique symbol;
130
174
  export const lastSetErrorSymbol: unique symbol;
131
175
  const updateSymbol: unique symbol;
132
176
  export function getIsViewModelUpdating(): boolean;
@@ -148,7 +192,6 @@ declare module "state-manager" {
148
192
  constructor(initialState: DeepReadonly<TViewModel>, stateUpdateEvent: DotvvmEvent<DeepReadonly<TViewModel>>);
149
193
  dispatchUpdate(): void;
150
194
  doUpdateNow(): void;
151
- private startTime;
152
195
  private rerender;
153
196
  setState(newState: DeepReadonly<TViewModel>): DeepReadonly<TViewModel>;
154
197
  patchState(patch: Partial<TViewModel>): DeepReadonly<TViewModel>;
@@ -156,6 +199,14 @@ declare module "state-manager" {
156
199
  }
157
200
  export function unmapKnockoutObservables(viewModel: any): any;
158
201
  }
202
+ declare module "serialization/deserialize" {
203
+ export function deserialize(viewModel: any, target?: any, deserializeAll?: boolean): any;
204
+ export function deserializePrimitive(viewModel: any, target?: any): any;
205
+ export function deserializeDate(viewModel: any, target?: any): any;
206
+ export function deserializeArray(viewModel: any, target?: any, deserializeAll?: boolean): any;
207
+ export function deserializeObject(viewModel: any, target: any, deserializeAll: boolean): any;
208
+ export function extendToObservableArrayIfRequired(observable: any): any;
209
+ }
159
210
  declare module "serialization/serialize" {
160
211
  interface ISerializationOptions {
161
212
  serializeAll?: boolean;
@@ -177,25 +228,6 @@ declare module "postback/resourceLoader" {
177
228
  export function loadResourceList(resources: RenderedResourceList | undefined): Promise<void>;
178
229
  export function notifyModuleLoaded(id: number): void;
179
230
  }
180
- declare module "validation/common" {
181
- export type DotvvmValidationContext = {
182
- readonly valueToValidate: any;
183
- readonly parentViewModel: any;
184
- readonly parameters: any[];
185
- };
186
- export type DotvvmValidationObservableMetadata = DotvvmValidationElementMetadata[];
187
- export type DotvvmValidationElementMetadata = {
188
- element: HTMLElement;
189
- dataType: string;
190
- format: string;
191
- domNodeDisposal: boolean;
192
- elementValidationState: boolean;
193
- };
194
- export const ErrorsPropertyName = "validationErrors";
195
- /** Checks if the value is null, undefined or a whitespace only string */
196
- export function isEmpty(value: any): boolean;
197
- export function getValidationMetadata(property: KnockoutObservable<any>): DotvvmValidationObservableMetadata;
198
- }
199
231
  declare module "binding-handlers/textbox-text" {
200
232
  const _default: {
201
233
  "dotvvm-textbox-text": {
@@ -233,13 +265,47 @@ declare module "binding-handlers/SSR-foreach" {
233
265
  };
234
266
  export default _default_2;
235
267
  }
236
- declare module "binding-handlers/introduce-alias" {
268
+ declare module "viewModules/viewModuleManager" {
269
+ type ModuleCommand = (...args: any) => Promise<unknown>;
270
+ export const viewModulesSymbol: unique symbol;
271
+ export function registerViewModule(name: string, moduleObject: any): void;
272
+ export function registerViewModules(modules: {
273
+ [name: string]: any;
274
+ }): void;
275
+ export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement): ModuleContext;
276
+ export function callViewModuleCommand(viewIdOrElement: string | HTMLElement, commandName: string, args: any[], allowAsync?: boolean): any;
277
+ export function findComponent(viewIdOrElement: null | string | HTMLElement, name: string): [ModuleContext | null, DotvvmJsComponentFactory];
278
+ export function registerGlobalComponent(name: string, c: DotvvmJsComponentFactory): void;
279
+ export function registerNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string, command: ModuleCommand, rootElement: HTMLElement): void;
280
+ export function unregisterNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string): void;
281
+ export class ModuleContext {
282
+ readonly moduleName: string;
283
+ readonly elements: HTMLElement[];
284
+ readonly properties: {
285
+ [name: string]: any;
286
+ };
287
+ private readonly namedCommands;
288
+ module: any;
289
+ constructor(moduleName: string, elements: HTMLElement[], properties: {
290
+ [name: string]: any;
291
+ });
292
+ registerNamedCommand: (name: string, command: (...args: any[]) => Promise<any>) => void;
293
+ unregisterNamedCommand: (name: string) => void;
294
+ }
295
+ }
296
+ declare module "binding-handlers/markup-controls" {
297
+ export function wrapControlProperties(valueAccessor: () => any): any;
237
298
  const _default_3: {
238
299
  'dotvvm-with-control-properties': {
239
300
  init: (element: HTMLElement, valueAccessor: () => any, allBindings?: any, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => {
240
301
  controlsDescendantBindings: boolean;
241
302
  };
242
303
  };
304
+ 'dotvvm-with-view-modules': {
305
+ init: (element: HTMLElement, valueAccessor: () => any, allBindings?: any, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => {
306
+ controlsDescendantBindings: boolean;
307
+ } | undefined;
308
+ };
243
309
  };
244
310
  export default _default_3;
245
311
  }
@@ -265,11 +331,11 @@ declare module "binding-handlers/checkbox" {
265
331
  'dotvvm-checkbox-updateAfterPostback': {
266
332
  init(element: HTMLElement, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor | undefined): void;
267
333
  };
268
- 'dotvvm-checked-pointer': {
269
- init(): void;
270
- };
334
+ 'dotvvm-checked-pointer': {};
271
335
  "dotvvm-CheckState": {
272
- init(element: HTMLElement, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor | undefined, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined): void;
336
+ init: ((element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor | undefined, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => void | {
337
+ controlsDescendantBindings: boolean;
338
+ }) | undefined;
273
339
  update(element: any, valueAccessor: () => any): void;
274
340
  };
275
341
  "dotvvm-checkedItems": {
@@ -317,35 +383,9 @@ declare module "binding-handlers/gridviewdataset" {
317
383
  };
318
384
  export default _default_8;
319
385
  }
320
- declare module "viewModules/viewModuleManager" {
321
- type ModuleCommand = (...args: any) => Promise<unknown>;
322
- export const viewModulesSymbol: unique symbol;
323
- export function registerViewModule(name: string, moduleObject: any): void;
324
- export function registerViewModules(modules: {
325
- [name: string]: any;
326
- }): void;
327
- export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement): ModuleContext;
328
- export function callViewModuleCommand(viewIdOrElement: string | HTMLElement, commandName: string, args: any[]): any;
329
- export function registerNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string, command: ModuleCommand, rootElement: HTMLElement): void;
330
- export function unregisterNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string): void;
331
- export class ModuleContext {
332
- readonly moduleName: string;
333
- readonly elements: HTMLElement[];
334
- readonly properties: {
335
- [name: string]: any;
336
- };
337
- private readonly namedCommands;
338
- module: any;
339
- constructor(moduleName: string, elements: HTMLElement[], properties: {
340
- [name: string]: any;
341
- });
342
- registerNamedCommand: (name: string, command: (...args: any[]) => Promise<any>) => void;
343
- unregisterNamedCommand: (name: string) => void;
344
- }
345
- }
346
- declare module "binding-handlers/with-view-modules" {
386
+ declare module "binding-handlers/named-command" {
347
387
  const _default_9: {
348
- 'dotvvm-with-view-modules': {
388
+ 'dotvvm-named-command': {
349
389
  init: (element: HTMLElement, valueAccessor: () => any, allBindings?: any, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => {
350
390
  controlsDescendantBindings: boolean;
351
391
  };
@@ -353,16 +393,22 @@ declare module "binding-handlers/with-view-modules" {
353
393
  };
354
394
  export default _default_9;
355
395
  }
356
- declare module "binding-handlers/named-command" {
396
+ declare module "binding-handlers/file-upload" {
357
397
  const _default_10: {
358
- 'dotvvm-named-command': {
359
- init: (element: HTMLElement, valueAccessor: () => any, allBindings?: any, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => {
360
- controlsDescendantBindings: boolean;
361
- };
398
+ "dotvvm-FileUpload": {
399
+ init: (element: HTMLInputElement, valueAccessor: () => any, allBindings?: any, viewModel?: any, bindingContext?: KnockoutBindingContext | undefined) => void;
362
400
  };
363
401
  };
364
402
  export default _default_10;
365
403
  }
404
+ declare module "binding-handlers/js-component" {
405
+ const _default_11: {
406
+ "dotvvm-js-component": {
407
+ init(element: HTMLInputElement, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor | undefined): void;
408
+ };
409
+ };
410
+ export default _default_11;
411
+ }
366
412
  declare module "binding-handlers/all-handlers" {
367
413
  type KnockoutHandlerDictionary = {
368
414
  [name: string]: KnockoutBindingHandler;
@@ -394,23 +440,21 @@ declare module "dotvvm-base" {
394
440
  export function initBindings(): void;
395
441
  }
396
442
  declare module "DotVVM.Globalize" {
443
+ import { parseDate as serializationParseDate } from "serialization/date";
397
444
  export function format(format: string, ...values: any[]): string;
398
445
  type GlobalizeFormattable = null | undefined | string | Date | number;
399
446
  export function formatString(format: string | null | undefined, value: GlobalizeFormattable | KnockoutObservable<GlobalizeFormattable>): string;
400
447
  export function parseNumber(value: string): number;
401
448
  export function parseDate(value: string, format: string, previousValue?: Date): Date | null;
402
- export const parseDotvvmDate: typeof parseDate;
403
- export function bindingDateToString(value: KnockoutObservable<string | Date> | string | Date, format?: string): "" | KnockoutComputed<string>;
404
- export function bindingNumberToString(value: KnockoutObservable<string | number> | string | number, format?: string): "" | KnockoutComputed<string>;
405
- }
406
- declare module "DotVVM.Polyfills" {
407
- export default function (): void;
449
+ export const parseDotvvmDate: typeof serializationParseDate;
450
+ export function bindingDateToString(value: KnockoutObservable<string | Date> | string | Date | null | undefined, format?: string): KnockoutComputed<string>;
451
+ export function bindingNumberToString(value: KnockoutObservable<string | number> | string | number | null | undefined, format?: string): KnockoutComputed<string>;
408
452
  }
409
453
  declare var compileConstants: {
410
454
  /** If the compiled bundle is for SPA applications */
411
455
  isSpa: boolean;
412
- /** If the compiled bundle is for legacy browser that don't support modules (and other new EcmaScript features) */
413
- nomodules: boolean;
456
+ /** If the compiled bundle is unminified */
457
+ debug: boolean;
414
458
  };
415
459
  declare module "utils/uri" {
416
460
  export function removeVirtualDirectoryFromUrl(url: string): string;
@@ -423,14 +467,14 @@ declare module "postback/http" {
423
467
  readonly result: T;
424
468
  readonly response?: Response;
425
469
  };
426
- export function getJSON<T>(url: string, spaPlaceHolderUniqueId?: string, additionalHeaders?: {
470
+ export function getJSON<T>(url: string, spaPlaceHolderUniqueId?: string, signal?: AbortSignal, additionalHeaders?: {
427
471
  [key: string]: string;
428
472
  }): Promise<WrappedResponse<T>>;
429
- export function postJSON<T>(url: string, postData: any, additionalHeaders?: {
473
+ export function postJSON<T>(url: string, postData: any, signal: AbortSignal | undefined, additionalHeaders?: {
430
474
  [key: string]: string;
431
475
  }): Promise<WrappedResponse<T>>;
432
476
  export function fetchJson<T>(url: string, init: RequestInit): Promise<WrappedResponse<T>>;
433
- export function fetchCsrfToken(): Promise<string>;
477
+ export function fetchCsrfToken(signal: AbortSignal | undefined): Promise<string>;
434
478
  export function retryOnInvalidCsrfToken<TResult>(postbackFunction: () => Promise<TResult>, iteration?: number, customErrorHandler?: () => void): Promise<TResult>;
435
479
  }
436
480
  declare module "postback/counter" {
@@ -443,12 +487,6 @@ declare module "postback/redirect" {
443
487
  export function performRedirect(url: string, replace: boolean, allowSpa: boolean): Promise<any>;
444
488
  export function handleRedirect(options: PostbackOptions, resultObject: any, response: Response, replace?: boolean): Promise<DotvvmRedirectEventArgs>;
445
489
  }
446
- declare module "utils/evaluator" {
447
- export function evaluateOnViewModel(context: any, expression: string): any;
448
- export function getDataSourceItems(viewModel: any): Array<KnockoutObservable<any>>;
449
- export function wrapObservable(func: () => any, isArray?: boolean): KnockoutComputed<any>;
450
- export const unwrapComputedProperty: (obs: any) => any;
451
- }
452
490
  declare module "postback/gate" {
453
491
  export function isPostbackDisabled(postbackId: number): boolean;
454
492
  export function enablePostbacks(): void;
@@ -471,18 +509,6 @@ declare module "validation/validators" {
471
509
  };
472
510
  export const validators: DotvvmValidatorSet;
473
511
  }
474
- declare module "validation/error" {
475
- export const allErrors: ValidationError[];
476
- export function detachAllErrors(): void;
477
- export function getErrors<T>(o: KnockoutObservable<T> | null): ValidationError[];
478
- export class ValidationError {
479
- errorMessage: string;
480
- validatedObservable: KnockoutObservable<any>;
481
- private constructor();
482
- static attach(errorMessage: string, observable: KnockoutObservable<any>): ValidationError;
483
- detach(): void;
484
- }
485
- }
486
512
  declare module "postback/internal-handlers" {
487
513
  export const isPostbackRunning: KnockoutObservable<boolean>;
488
514
  export const suppressOnDisabledElementHandler: DotvvmPostbackHandler;
@@ -536,35 +562,59 @@ declare module "validation/actions" {
536
562
  declare module "validation/validation" {
537
563
  import { ValidationError } from "validation/error";
538
564
  import { DotvvmEvent } from "events";
539
- type DotvvmValidationErrorsChangedEventArgs = PostbackOptions & {
565
+ type DotvvmValidationErrorsChangedEventArgs = Partial<PostbackOptions> & {
540
566
  readonly allErrors: ValidationError[];
541
567
  };
542
568
  export const events: {
543
569
  validationErrorsChanged: DotvvmEvent<DotvvmValidationErrorsChangedEventArgs>;
544
570
  };
545
571
  export const globalValidationObject: {
572
+ /** Dictionary of client-side validation rules. Add new items to this object if you want to add support for new validation rules */
546
573
  rules: {
547
574
  [name: string]: import("validation/validators").DotvvmValidator;
548
575
  };
576
+ /** List of all currently active errors */
549
577
  errors: ValidationError[];
550
578
  events: {
551
579
  validationErrorsChanged: DotvvmEvent<DotvvmValidationErrorsChangedEventArgs>;
552
580
  };
581
+ /** Add the specified list of validation errors. `dotvvm.validation.addErrors([ { errorMessage: "test error", propertyPath: "/LoginForm/Name" } ])` */
582
+ addErrors: typeof addErrors;
583
+ /** Removes errors from the specified properties.
584
+ * The errors are removed recursively, so calling `dotvvm.validation.removeErrors("/")` removes all errors in the page,
585
+ * `dotvvm.validation.removeErrors("/Detail")` removes all errors from the object in property root.Detail */
586
+ removeErrors: typeof removeErrors;
553
587
  };
554
588
  export function init(): void;
589
+ export type ValidationErrorDescriptor = {
590
+ /** Error to be displayed to the user */
591
+ errorMessage: string;
592
+ /** Path in the view model to the annotated property, for example `/LoginPage/Name` */
593
+ propertyPath: string;
594
+ };
595
+ export type AddErrorsOptions = {
596
+ /** Root object from which are the property paths resolved. By default it's the root view model of the page */
597
+ root?: KnockoutObservable<any> | any;
598
+ /** When set to false, the validationErrorsChanged is not triggered. By default it's true -> the error is triggered.
599
+ * The validationErrorsChanged event controls the `Validator`s in the DotHTML page, so when it's not triggered, the change won't be visible. */
600
+ triggerErrorsChanged?: false;
601
+ };
602
+ export function removeErrors(...paths: string[]): void;
603
+ export function addErrors(errors: ValidationErrorDescriptor[], options?: AddErrorsOptions): void;
555
604
  /**
556
605
  * Adds validation errors from the server to the appropriate arrays
557
606
  */
558
- export function showValidationErrorsFromServer(dataContext: any, path: string, serverResponseObject: any, options: PostbackOptions): void;
607
+ export function showValidationErrorsFromServer(serverResponseObject: any, options: PostbackOptions): void;
559
608
  }
560
609
  declare module "postback/postbackCore" {
610
+ export function throwIfAborted(options: PostbackOptions): void;
561
611
  export function getLastStartedPostbackId(): number;
562
612
  export function postbackCore(options: PostbackOptions, path: string[], command: string, controlUniqueId: string, context: any, commandArgs?: any[]): Promise<PostbackCommitFunction>;
563
613
  }
564
614
  declare module "postback/postback" {
565
- export function postBack(sender: HTMLElement, path: string[], command: string, controlUniqueId: string, context?: any, handlers?: ClientFriendlyPostbackHandlerConfiguration[], commandArgs?: any[]): Promise<DotvvmAfterPostBackEventArgs>;
615
+ export function postBack(sender: HTMLElement, path: string[], command: string, controlUniqueId: string, context?: any, handlers?: ClientFriendlyPostbackHandlerConfiguration[], commandArgs?: any[], abortSignal?: AbortSignal): Promise<DotvvmAfterPostBackEventArgs>;
566
616
  type MaybePromise<T> = Promise<T> | T;
567
- export function applyPostbackHandlers(next: (options: PostbackOptions) => MaybePromise<PostbackCommitFunction | any>, sender: HTMLElement, handlerConfigurations?: ClientFriendlyPostbackHandlerConfiguration[], args?: any[], context?: any, viewModel?: any): Promise<DotvvmAfterPostBackEventArgs>;
617
+ export function applyPostbackHandlers(next: (options: PostbackOptions) => MaybePromise<PostbackCommitFunction | any>, sender: HTMLElement, handlerConfigurations?: ClientFriendlyPostbackHandlerConfiguration[], args?: any[], context?: any, abortSignal?: AbortSignal): Promise<DotvvmAfterPostBackEventArgs>;
568
618
  export function isPostbackHandler(obj: any): obj is DotvvmPostbackHandler;
569
619
  export function sortHandlers(handlers: DotvvmPostbackHandler[]): DotvvmPostbackHandler[];
570
620
  }
@@ -579,11 +629,11 @@ declare module "spa/spa" {
579
629
  export function handleSpaNavigationCore(url: string | null, sender?: HTMLElement, handlePageNavigating?: (url: string) => void): Promise<DotvvmNavigationEventArgs>;
580
630
  }
581
631
  declare module "binding-handlers/register" {
582
- const _default_11: () => void;
583
- export default _default_11;
632
+ const _default_12: () => void;
633
+ export default _default_12;
584
634
  }
585
635
  declare module "postback/staticCommand" {
586
- export function staticCommandPostback(sender: HTMLElement, command: string, args: any[], options: PostbackOptions): Promise<any>;
636
+ export function staticCommandPostback(command: string, args: any[], options: PostbackOptions): Promise<any>;
587
637
  }
588
638
  declare module "controls/routeLink" {
589
639
  export function buildRouteUrl(routePath: string, params: any): string;
@@ -591,20 +641,7 @@ declare module "controls/routeLink" {
591
641
  }
592
642
  declare module "controls/fileUpload" {
593
643
  export function showUploadDialog(sender: HTMLElement): void;
594
- export function createUploadId(sender: HTMLElement, iframe: HTMLElement): void;
595
- export function reportProgress(targetControlId: any, isBusy: boolean, progress: number, result: DotvvmStaticCommandResponse<DotvvmFileUploadData[]> | string): void;
596
- type DotvvmFileUploadData = {
597
- FileId: KnockoutObservable<string>;
598
- FileName: KnockoutObservable<string>;
599
- FileSize: KnockoutObservable<DotvvmFileSize>;
600
- IsFileTypeAllowed: KnockoutObservable<boolean>;
601
- IsMaxSizeExceeded: KnockoutObservable<boolean>;
602
- IsAllowed: KnockoutObservable<boolean>;
603
- };
604
- type DotvvmFileSize = {
605
- Bytes: KnockoutObservable<number>;
606
- FormattedText: KnockoutObservable<string>;
607
- };
644
+ export function reportProgress(inputControl: HTMLInputElement, isBusy: boolean, progress: number, result: DotvvmStaticCommandResponse<DotvvmFileUploadData[]> | string): void;
608
645
  }
609
646
  declare module "api/eventHub" {
610
647
  export function notify(id: string): void;
@@ -617,9 +654,69 @@ declare module "api/api" {
617
654
  export function invoke<T>(target: any, methodName: string, argsProvider: () => any[], refreshTriggers: (args: any[]) => Array<KnockoutObservable<any> | string>, notifyTriggers: (args: any[]) => string[], element: HTMLElement, sharingKeyProvider: (args: any[]) => string[]): ApiComputed<T>;
618
655
  export function refreshOn<T>(value: ApiComputed<T>, watch: KnockoutObservable<any>): ApiComputed<T>;
619
656
  }
657
+ declare module "metadata/metadataHelper" {
658
+ export function getTypeId(viewModel: object): string | undefined;
659
+ export function getTypeMetadata(typeId: string): TypeMetadata;
660
+ export function getEnumMetadata(enumMetadataId: string): EnumTypeMetadata;
661
+ export function getEnumValue(identifier: string | number, enumMetadataId: string): number | undefined;
662
+ }
663
+ declare module "collections/sortingHelper" {
664
+ type ElementType = string | number | boolean;
665
+ export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
666
+ export const orderByDesc: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
667
+ }
668
+ declare module "collections/arrayHelper" {
669
+ import { orderBy, orderByDesc } from "collections/sortingHelper";
670
+ export { add, addOrUpdate, addRange, clear, distinct, firstOrDefault, insert, insertRange, lastOrDefault, max, min, orderBy, orderByDesc, removeAll, removeAt, removeFirst, removeLast, removeRange, reverse, setItem };
671
+ function add<T>(observable: any, element: T): void;
672
+ function addOrUpdate<T>(observable: any, element: T, matcher: (e: T) => boolean, updater: (e: T) => T): void;
673
+ function addRange<T>(observable: any, elements: T[]): void;
674
+ function clear(observable: any): void;
675
+ function distinct<T>(array: T[]): T[];
676
+ function firstOrDefault<T>(array: T[], predicate: (s: T) => boolean): T | null;
677
+ function insert<T>(observable: any, index: number, element: T): void;
678
+ function insertRange<T>(observable: any, index: number, elements: T[]): void;
679
+ function lastOrDefault<T>(array: T[], predicate: (s: T) => boolean): T | null;
680
+ function max<T>(array: T[], selector: (item: T) => number, throwIfEmpty: boolean): number | null;
681
+ function min<T>(array: T[], selector: (item: T) => number, throwIfEmpty: boolean): number | null;
682
+ function removeAt<T>(observable: any, index: number): void;
683
+ function removeAll<T>(observable: any, predicate: (s: T) => boolean): void;
684
+ function removeRange<T>(observable: any, index: number, length: number): void;
685
+ function removeFirst<T>(observable: any, predicate: (s: T) => boolean): void;
686
+ function removeLast<T>(observable: any, predicate: (s: T) => boolean): void;
687
+ function reverse<T>(observable: any): void;
688
+ function setItem<T>(observable: any, index: number, value: T): void;
689
+ }
690
+ declare module "collections/dictionaryHelper" {
691
+ type Dictionary<Key, Value> = {
692
+ Key: Key;
693
+ Value: Value;
694
+ }[];
695
+ export function clear(observable: any): void;
696
+ export function containsKey<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key): boolean;
697
+ export function getItem<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key): Value;
698
+ export function remove<Key, Value>(observable: any, identifier: Key): boolean;
699
+ export function setItem<Key, Value>(observable: any, identifier: Key, value: Value): void;
700
+ }
701
+ declare module "utils/stringHelper" {
702
+ export function contains(haystack: string, needle: string, options: string): boolean;
703
+ export function endsWith(haystack: string, needle: string, options: string): boolean;
704
+ export function startsWith(haystack: string, needle: string, options: string): boolean;
705
+ export function indexOf(haystack: string, startIndex: number, needle: string, options: string): number;
706
+ export function lastIndexOf(haystack: string, startIndex: number, needle: string, options: string): number;
707
+ export function split(text: string, delimiter: string, options: string): string[];
708
+ export function join<T>(elements: T[], delimiter: string): string;
709
+ export function format(pattern: string, expressions: any[]): string;
710
+ export function trimStart(text: string, char: string): string;
711
+ export function trimEnd(text: string, char: string): string;
712
+ }
713
+ declare module "utils/dateTimeHelper" {
714
+ export function toBrowserLocalTime(value: KnockoutObservable<string | null>): KnockoutComputed<string | null>;
715
+ }
620
716
  declare module "dotvvm-root" {
621
717
  import { getCulture } from "dotvvm-base";
622
718
  import * as events from "events";
719
+ import * as validation from "validation/validation";
623
720
  import { postBack } from "postback/postback";
624
721
  import { serialize } from "serialization/serialize";
625
722
  import { serializeDate, parseDate } from "serialization/date";
@@ -638,6 +735,8 @@ declare module "dotvvm-root" {
638
735
  import * as viewModuleManager from "viewModules/viewModuleManager";
639
736
  import { notifyModuleLoaded } from "postback/resourceLoader";
640
737
  import { logError, logWarning, logInfo, logInfoVerbose, logPostBackScriptError } from "utils/logging";
738
+ import * as metadataHelper from "metadata/metadataHelper";
739
+ import { StateManager } from "state-manager";
641
740
  function init(culture: string): void;
642
741
  const dotvvmExports: {
643
742
  getCulture: typeof getCulture;
@@ -648,7 +747,6 @@ declare module "dotvvm-root" {
648
747
  fileUpload: {
649
748
  reportProgress: typeof fileUpload.reportProgress;
650
749
  showUploadDialog: typeof fileUpload.showUploadDialog;
651
- createUploadId: typeof fileUpload.createUploadId;
652
750
  };
653
751
  api: {
654
752
  invoke: typeof api.invoke;
@@ -671,13 +769,16 @@ declare module "dotvvm-root" {
671
769
  };
672
770
  errors: import("validation/error").ValidationError[];
673
771
  events: {
674
- validationErrorsChanged: events.DotvvmEvent<PostbackOptions & {
772
+ validationErrorsChanged: events.DotvvmEvent<Partial<PostbackOptions> & {
675
773
  readonly allErrors: import("validation/error").ValidationError[];
676
774
  }>;
677
775
  };
776
+ addErrors: typeof validation.addErrors;
777
+ removeErrors: typeof validation.removeErrors;
678
778
  };
679
779
  postBack: typeof postBack;
680
780
  init: typeof init;
781
+ registerGlobalComponent: typeof viewModuleManager.registerGlobalComponent;
681
782
  isPostbackRunning: KnockoutObservable<boolean>;
682
783
  events: Partial<typeof spaEvents> & typeof events;
683
784
  viewModels: {
@@ -696,6 +797,12 @@ declare module "dotvvm-root" {
696
797
  parseDate: typeof parseDate;
697
798
  deserialize: typeof deserialize;
698
799
  };
800
+ metadata: {
801
+ getTypeId: typeof metadataHelper.getTypeId;
802
+ getTypeMetadata: typeof metadataHelper.getTypeMetadata;
803
+ getEnumMetadata: typeof metadataHelper.getEnumMetadata;
804
+ getEnumValue: typeof metadataHelper.getEnumValue;
805
+ };
699
806
  viewModules: {
700
807
  registerOne: typeof viewModuleManager.registerViewModule;
701
808
  init: typeof viewModuleManager.initViewModule;
@@ -713,9 +820,13 @@ declare module "dotvvm-root" {
713
820
  logPostBackScriptError: typeof logPostBackScriptError;
714
821
  level: "normal" | "verbose";
715
822
  };
823
+ translations: any;
824
+ StateManager: typeof StateManager;
825
+ DotvvmEvent: typeof events.DotvvmEvent;
716
826
  };
717
827
  global {
718
828
  const dotvvm: typeof dotvvmExports & {
829
+ debug?: true;
719
830
  isSpaReady?: typeof isSpaReady;
720
831
  handleSpaNavigation?: typeof handleSpaNavigation;
721
832
  };
@@ -725,7 +836,7 @@ declare module "dotvvm-root" {
725
836
  }
726
837
  export default dotvvmExports;
727
838
  }
728
- declare type PostbackCommitFunction = (...args: any) => Promise<DotvvmAfterPostBackEventArgs>;
839
+ declare type PostbackCommitFunction = () => Promise<DotvvmAfterPostBackEventArgs>;
729
840
  declare type DotvvmPostbackHandler = {
730
841
  execute(next: () => Promise<PostbackCommitFunction>, options: PostbackOptions): Promise<PostbackCommitFunction>;
731
842
  name?: string;
@@ -735,7 +846,7 @@ declare type DotvvmPostbackHandler = {
735
846
  declare type DotvvmPostbackErrorLike = {
736
847
  readonly reason: DotvvmPostbackErrorReason;
737
848
  };
738
- declare type DotvvmPostbackErrorReason = {
849
+ declare type DotvvmPostbackErrorReason = ({
739
850
  type: 'handler';
740
851
  handlerName: string;
741
852
  message?: string;
@@ -760,7 +871,13 @@ declare type DotvvmPostbackErrorReason = {
760
871
  type: 'validation';
761
872
  responseObject: any;
762
873
  response?: Response;
763
- } & {
874
+ } | {
875
+ type: 'abort';
876
+ } | {
877
+ type: 'redirect';
878
+ responseObject: any;
879
+ response?: Response;
880
+ }) & {
764
881
  options?: PostbackOptions;
765
882
  };
766
883
  declare type PostbackCommandType = "postback" | "staticCommand" | "spaNavigation";
@@ -770,8 +887,10 @@ declare type PostbackOptions = {
770
887
  readonly args: any[];
771
888
  readonly sender?: HTMLElement;
772
889
  readonly viewModel?: any;
890
+ readonly knockoutContext?: any;
773
891
  serverResponseObject?: any;
774
892
  validationTargetPath?: string;
893
+ abortSignal?: AbortSignal;
775
894
  };
776
895
  declare type DotvvmErrorEventArgs = PostbackOptions & {
777
896
  readonly response?: Response;
@@ -920,6 +1039,7 @@ declare type DotvvmObservable<T> = DeepKnockoutObservable<T> & {
920
1039
  declare type RootViewModel = {
921
1040
  $type: string;
922
1041
  $csrfToken?: string;
1042
+ [name: string]: any;
923
1043
  };
924
1044
  declare type TypeMap = {
925
1045
  [typeId: string]: TypeMetadata;
@@ -935,6 +1055,7 @@ declare type EnumTypeMetadata = {
935
1055
  values: {
936
1056
  [name: string]: number;
937
1057
  };
1058
+ isFlags?: boolean;
938
1059
  };
939
1060
  declare type TypeMetadata = ObjectTypeMetadata | EnumTypeMetadata;
940
1061
  declare type PropertyMetadata = {
@@ -967,3 +1088,47 @@ declare type CoerceResult = CoerceErrorType | {
967
1088
  wasCoerced?: boolean;
968
1089
  isError?: false;
969
1090
  };
1091
+ declare type DotvvmFileUploadCollection = {
1092
+ Files: KnockoutObservableArray<KnockoutObservable<DotvvmFileUploadData>>;
1093
+ Progress: KnockoutObservable<number>;
1094
+ Error: KnockoutObservable<string>;
1095
+ IsBusy: KnockoutObservable<boolean>;
1096
+ };
1097
+ declare type DotvvmFileUploadData = {
1098
+ FileId: KnockoutObservable<string>;
1099
+ FileName: KnockoutObservable<string>;
1100
+ FileSize: KnockoutObservable<DotvvmFileSize>;
1101
+ IsFileTypeAllowed: KnockoutObservable<boolean>;
1102
+ IsMaxSizeExceeded: KnockoutObservable<boolean>;
1103
+ IsAllowed: KnockoutObservable<boolean>;
1104
+ };
1105
+ declare type DotvvmFileSize = {
1106
+ Bytes: KnockoutObservable<number>;
1107
+ FormattedText: KnockoutObservable<string>;
1108
+ };
1109
+ declare type DotvvmJsComponent = {
1110
+ updateProps(p: {
1111
+ [key: string]: any;
1112
+ }): void;
1113
+ dispose(): void;
1114
+ };
1115
+ declare type DotvvmJsComponentFactory = {
1116
+ create(element: HTMLElement, props: {
1117
+ [key: string]: any;
1118
+ }, commands: {
1119
+ [key: string]: (args: any[]) => Promise<any>;
1120
+ }, templates: {
1121
+ [key: string]: string;
1122
+ }, // TODO
1123
+ setProps: (p: {
1124
+ [key: string]: any;
1125
+ }) => void): DotvvmJsComponent;
1126
+ };
1127
+ declare type DotvvmViewModuleCommandName = `${'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'}${string}`;
1128
+ declare type DotvvmViewModule = {
1129
+ $controls?: {
1130
+ [name: string]: DotvvmJsComponentFactory;
1131
+ };
1132
+ $dispose?: (context: any) => void;
1133
+ [commandName: DotvvmViewModuleCommandName]: (...args: any[]) => Promise<any> | any;
1134
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotvvm-types",
3
- "version": "3.0.2",
3
+ "version": "4.1.0-preview04-final",
4
4
  "description": "MVVM framework for ASP.NET",
5
5
  "types": "index.d.ts",
6
6
  "repository": {
@@ -13,9 +13,6 @@
13
13
  "url": "https://github.com/riganti/dotvvm/issues"
14
14
  },
15
15
  "homepage": "https://github.com/riganti/dotvvm#readme",
16
- "devDependencies": {
17
- "typescript": "^4.0.3"
18
- },
19
16
  "dependencies": {
20
17
  "@types/knockout": "^3.4.69"
21
18
  }
Binary file