dotvvm-types 4.1.0 → 4.2.0-preview02-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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +35 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotvvm-types",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-preview02-final",
4
4
  "description": "MVVM framework for ASP.NET",
5
5
  "types": "./types/index.d.ts",
6
6
  "repository": {
package/types/index.d.ts CHANGED
@@ -68,8 +68,11 @@ declare module "utils/objects" {
68
68
  };
69
69
  }
70
70
  declare module "metadata/typeMap" {
71
- export function getTypeInfo(typeId: string): TypeMetadata;
72
- export function getObjectTypeInfo(typeId: string): ObjectTypeMetadata;
71
+ export function getTypeInfo(typeId: string | object): TypeMetadata;
72
+ export function getObjectTypeInfo(typeId: string): ObjectTypeMetadata | DynamicTypeMetadata;
73
+ export function getTypeProperties(typeId: string | object | null | undefined): {
74
+ [prop: string]: PropertyMetadata;
75
+ };
73
76
  export function getKnownTypes(): string[];
74
77
  export function updateTypeInfo(newTypes: TypeMap | undefined): void;
75
78
  export function replaceTypeInfo(newTypes: TypeMap | undefined): void;
@@ -126,13 +129,13 @@ declare module "metadata/coercer" {
126
129
  * @param type Expected type of type value.
127
130
  * @param originalValue Value that is known to be valid instance of type. It is used to perform incremental validation.
128
131
  */
129
- export function tryCoerce(value: any, type: TypeDefinition, originalValue?: any): CoerceResult;
132
+ export function tryCoerce(value: any, type: TypeDefinition | null | undefined, originalValue?: any): CoerceResult;
130
133
  export function coerce(value: any, type: TypeDefinition, originalValue?: any): any;
131
134
  }
132
135
  declare module "postback/updater" {
133
136
  export function cleanUpdatedControls(resultObject: any, updatedControls?: any): any;
134
137
  export function restoreUpdatedControls(resultObject: any, updatedControls: any): void;
135
- export function updateViewModelAndControls(resultObject: any): void;
138
+ export function updateViewModelAndControls(resultObject: any, updateTypeInfo: (t: TypeMap) => void): void;
136
139
  export function patchViewModel(source: any, patch: any): any;
137
140
  export function diffViewModel(source: any, modified: any): any;
138
141
  }
@@ -295,19 +298,21 @@ declare module "viewModules/viewModuleManager" {
295
298
  export function registerViewModules(modules: {
296
299
  [name: string]: any;
297
300
  }): void;
298
- export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement): ModuleContext;
301
+ export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement, properties?: object): ModuleContext;
299
302
  export function callViewModuleCommand(viewIdOrElement: string | HTMLElement, commandName: string, args: any[], allowAsync?: boolean): any;
300
303
  export function findComponent(viewIdOrElement: null | string | HTMLElement, name: string): [ModuleContext | null, DotvvmJsComponentFactory];
301
304
  export function registerGlobalComponent(name: string, c: DotvvmJsComponentFactory): void;
302
305
  export function registerNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string, command: ModuleCommand, rootElement: HTMLElement): void;
303
306
  export function unregisterNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string): void;
304
- export class ModuleContext {
307
+ export class ModuleContext implements DotvvmModuleContext {
305
308
  readonly moduleName: string;
306
309
  readonly elements: HTMLElement[];
307
310
  readonly properties: {
308
311
  [name: string]: any;
309
312
  };
310
- private readonly namedCommands;
313
+ readonly namedCommands: {
314
+ [name: string]: (...args: any[]) => Promise<any>;
315
+ };
311
316
  module: any;
312
317
  constructor(moduleName: string, elements: HTMLElement[], properties: {
313
318
  [name: string]: any;
@@ -526,7 +531,6 @@ declare module "validation/validators" {
526
531
  };
527
532
  export const required: DotvvmValidator;
528
533
  export const regex: DotvvmValidator;
529
- export const intRange: DotvvmValidator;
530
534
  export const enforceClientFormat: DotvvmValidator;
531
535
  export const range: DotvvmValidator;
532
536
  export const notNull: DotvvmValidator;
@@ -653,6 +657,7 @@ declare module "api/api" {
653
657
  type ApiComputed<T> = KnockoutComputed<T | null> & {
654
658
  refreshValue: () => PromiseLike<any>;
655
659
  };
660
+ export const isLoading: KnockoutObservable<boolean>;
656
661
  export function invoke<T>(target: any, methodName: string, argsProvider: () => any[], refreshTriggers: (args: any[]) => Array<KnockoutObservable<any> | string>, notifyTriggers: (args: any[]) => string[], cacheElement: HTMLElement, sharingKeyProvider: (args: any[]) => string[], lifetimeElement: HTMLElement): ApiComputed<T>;
657
662
  export function refreshOn<T>(value: ApiComputed<T>, watch: KnockoutObservable<any>): ApiComputed<T>;
658
663
  export function clearApiCachedValues(): void;
@@ -684,7 +689,7 @@ declare module "controls/fileUpload" {
684
689
  }
685
690
  declare module "metadata/metadataHelper" {
686
691
  export function getTypeId(viewModel: object): string | undefined;
687
- export function getTypeMetadata(typeId: string): TypeMetadata;
692
+ export function getTypeMetadata(typeId: string | object): TypeMetadata;
688
693
  export function getEnumMetadata(enumMetadataId: string): EnumTypeMetadata;
689
694
  }
690
695
  declare module "translations/sortingHelper" {
@@ -794,6 +799,7 @@ declare module "dotvvm-root" {
794
799
  showUploadDialog: typeof fileUpload.showUploadDialog;
795
800
  };
796
801
  api: {
802
+ isLoading: KnockoutObservable<boolean>;
797
803
  invoke: typeof api.invoke;
798
804
  refreshOn: typeof api.refreshOn;
799
805
  };
@@ -1091,6 +1097,9 @@ declare type RootViewModel = {
1091
1097
  declare type TypeMap = {
1092
1098
  [typeId: string]: TypeMetadata;
1093
1099
  };
1100
+ declare type DynamicTypeMetadata = {
1101
+ type: "dynamic";
1102
+ };
1094
1103
  declare type ObjectTypeMetadata = {
1095
1104
  type: "object";
1096
1105
  properties: {
@@ -1104,7 +1113,7 @@ declare type EnumTypeMetadata = {
1104
1113
  };
1105
1114
  isFlags?: boolean;
1106
1115
  };
1107
- declare type TypeMetadata = ObjectTypeMetadata | EnumTypeMetadata;
1116
+ declare type TypeMetadata = ObjectTypeMetadata | EnumTypeMetadata | DynamicTypeMetadata;
1108
1117
  declare type PropertyMetadata = {
1109
1118
  type: TypeDefinition;
1110
1119
  post?: "always" | "pathOnly" | "no";
@@ -1179,3 +1188,19 @@ declare type DotvvmViewModule = {
1179
1188
  $dispose?: (context: any) => void;
1180
1189
  [commandName: DotvvmViewModuleCommandName]: (...args: any[]) => Promise<any> | any;
1181
1190
  };
1191
+ declare type DotvvmModuleContext = {
1192
+ /** Name of the resource defining the view module */
1193
+ moduleName: string;
1194
+ /** Instance of the view module */
1195
+ module: any;
1196
+ /** List of element where this module is mounted. It will be `document.body` for pages and the wrapper tag for markup controls. Most likely, only one element is in the collection. */
1197
+ elements: HTMLElement[];
1198
+ /** Properties of the markup control which were sent to the client */
1199
+ properties: {
1200
+ [name: string]: any;
1201
+ };
1202
+ /** <dot:NamedCommand /> declared in the dothtml/dotcontrol view. */
1203
+ namedCommands: {
1204
+ [name: string]: (...args: any[]) => Promise<any>;
1205
+ };
1206
+ };