@gi-tcg/gts-runtime 0.4.6 → 0.6.0
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/dist/index.d.ts +25 -17
- package/dist/index.js +17 -1
- package/package.json +1 -1
- package/src/attribute_return.ts +21 -3
- package/src/index.ts +3 -1
- package/src/simple_view_model.ts +20 -6
- package/src/symbols.ts +0 -3
- package/src/view_model.ts +65 -24
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
//#region src/attribute_return.d.ts
|
|
2
|
+
type Computed<T, Constraint = any> = T extends Constraint ? { [K in keyof T]: T[K] } : never;
|
|
3
|
+
interface AttributePositionalReturnBase {
|
|
4
|
+
key?: string;
|
|
5
|
+
rewriteMeta?: any;
|
|
6
|
+
namedDefinition: AttributeBlockDefinition;
|
|
7
|
+
}
|
|
2
8
|
declare namespace AttributeReturn {
|
|
3
9
|
type This<TMeta> = {
|
|
4
10
|
"~meta": TMeta;
|
|
@@ -18,8 +24,8 @@ declare namespace AttributeReturn {
|
|
|
18
24
|
};
|
|
19
25
|
rewriteMeta: NewMeta;
|
|
20
26
|
};
|
|
21
|
-
type WithRewriteMeta<VM extends IViewModel<any, any, any>,
|
|
22
|
-
namedDefinition: VM["~namedDefinition"]
|
|
27
|
+
type WithRewriteMeta<NewMeta, VM extends IViewModel<any, any, any>, TMeta = VM["~namedDefinition"]["~meta"]> = {
|
|
28
|
+
namedDefinition: BlockDefinitionRewriteMeta<VM["~namedDefinition"], TMeta>;
|
|
23
29
|
rewriteMeta: NewMeta;
|
|
24
30
|
};
|
|
25
31
|
}
|
|
@@ -28,7 +34,6 @@ declare namespace AttributeReturn {
|
|
|
28
34
|
type Meta = "~meta";
|
|
29
35
|
type Action = "~action";
|
|
30
36
|
type NamedDefinition = "~namedDefinition";
|
|
31
|
-
type Prelude = "~prelude";
|
|
32
37
|
//#endregion
|
|
33
38
|
//#region src/view.d.ts
|
|
34
39
|
type AttributeName = string | symbol;
|
|
@@ -59,13 +64,11 @@ declare function createBinding(rootVM: IViewModel<any, any, any>, node: SingleAt
|
|
|
59
64
|
//#endregion
|
|
60
65
|
//#region src/view_model.d.ts
|
|
61
66
|
interface AttributeBlockDefinition {
|
|
62
|
-
"~action"?: AttributeDefinition | undefined;
|
|
63
67
|
"~meta": any;
|
|
64
68
|
}
|
|
65
|
-
type Computed<T> = T extends infer U extends { [K in keyof T]: unknown } ? U : never;
|
|
66
69
|
type BlockDefinitionRewriteMeta<BlockDef extends AttributeBlockDefinition, NewMeta> = Computed<Omit<BlockDef, Meta> & {
|
|
67
70
|
"~meta": NewMeta;
|
|
68
|
-
}
|
|
71
|
+
}, AttributeBlockDefinition>;
|
|
69
72
|
interface IViewModel<ModelT, BlockDef extends AttributeBlockDefinition, CtorArgs extends any[]> {
|
|
70
73
|
parse(view: View<BlockDefinitionRewriteMeta<BlockDef, unknown>>, ...args: CtorArgs): ModelT;
|
|
71
74
|
/**
|
|
@@ -76,8 +79,11 @@ interface IViewModel<ModelT, BlockDef extends AttributeBlockDefinition, CtorArgs
|
|
|
76
79
|
* This is useful for creating binding ViewModels directly that forwards
|
|
77
80
|
* the binding logic to inner ViewModels.
|
|
78
81
|
*/
|
|
79
|
-
bind<NewMeta = BlockDef[Meta]>():
|
|
80
|
-
bind<NewMeta = BlockDef[Meta]>(...args: CtorArgs):
|
|
82
|
+
bind<NewMeta = BlockDef[Meta]>(): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, CtorArgs>;
|
|
83
|
+
bind<NewMeta = BlockDef[Meta]>(...args: CtorArgs): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, []>;
|
|
84
|
+
extend<ChildT extends ModelT, const ChildBlockDef extends Partial<Record<string | Action, AttributeDefinition>>, ChildCtorArgs extends any[] = []>(Ctor: new (...args: ChildCtorArgs) => ChildT, modelDefFn: (helper: AttributeDefHelper<ChildT>) => ChildBlockDef): IViewModel<ChildT, Computed<Omit<BlockDef, keyof ChildBlockDef> & ChildBlockDef & {
|
|
85
|
+
"~meta": BlockDef[Meta];
|
|
86
|
+
}>, ChildCtorArgs>;
|
|
81
87
|
"~namedDefinition": BlockDef;
|
|
82
88
|
}
|
|
83
89
|
type LazyAttributeActionOrBinder<ModelT> = (model: ModelT, positionals: () => unknown[], named: View<any>) => unknown;
|
|
@@ -87,8 +93,11 @@ declare class ViewModel<ModelT, BlockDef extends AttributeBlockDefinition, CtorA
|
|
|
87
93
|
constructor(Ctor: new (...args: CtorArgs) => ModelT);
|
|
88
94
|
"~setActionOrBinder"(context: "action" | "binder", name: PropertyKey, action: LazyAttributeActionOrBinder<ModelT>): void;
|
|
89
95
|
parse(view: View<BlockDefinitionRewriteMeta<BlockDef, unknown>>, ...args: CtorArgs): ModelT;
|
|
90
|
-
bind<NewMeta = BlockDef[Meta]>():
|
|
91
|
-
bind<NewMeta = BlockDef[Meta]>(...args: CtorArgs):
|
|
96
|
+
bind<NewMeta = BlockDef[Meta]>(): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, CtorArgs>;
|
|
97
|
+
bind<NewMeta = BlockDef[Meta]>(...args: CtorArgs): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, []>;
|
|
98
|
+
extend<ChildT extends ModelT, const ChildBlockDef extends Partial<Record<string | Action, AttributeDefinition>>, ChildCtorArgs extends any[] = []>(Ctor: new (...args: ChildCtorArgs) => ChildT, modelDefFn: (helper: AttributeDefHelper<ChildT>) => ChildBlockDef): IViewModel<ChildT, Computed<Omit<BlockDef, keyof ChildBlockDef> & ChildBlockDef & {
|
|
99
|
+
"~meta": BlockDef[Meta];
|
|
100
|
+
}>, ChildCtorArgs>;
|
|
92
101
|
}
|
|
93
102
|
interface SimpleAttributeOptions {
|
|
94
103
|
required?: true;
|
|
@@ -134,10 +143,7 @@ interface AttributeDefinition {
|
|
|
134
143
|
as?(): any;
|
|
135
144
|
required?(): boolean;
|
|
136
145
|
uniqueKey?(): string;
|
|
137
|
-
|
|
138
|
-
interface AttributePositionalReturnBase {
|
|
139
|
-
rewriteMeta?: any;
|
|
140
|
-
namedDefinition: AttributeBlockDefinition;
|
|
146
|
+
mergeMeta?(meta: any, subMeta: any): any;
|
|
141
147
|
}
|
|
142
148
|
type OverloadedParameters<T extends (...args: any[]) => any> = T extends {
|
|
143
149
|
(...args: infer A1): any;
|
|
@@ -256,12 +262,14 @@ type SimpleViewModelAttribute<ValueT, Options extends SimpleViewModelOptions> =
|
|
|
256
262
|
} : Options["booleanSwitch"] extends true ? [true] extends [ValueT] ? {
|
|
257
263
|
(): AttributeReturn.Done;
|
|
258
264
|
} : {} : {} : {});
|
|
259
|
-
|
|
265
|
+
interface SimpleViewModel<T, Options extends SimpleViewModelOptions = {}> extends IViewModel<T, { [K in keyof T]-?: SimpleViewModelAttribute<T[K], Options> & {
|
|
260
266
|
uniqueKey(): K;
|
|
261
267
|
required(): {} extends Pick<T, K> ? false : true;
|
|
262
268
|
} } & {
|
|
263
269
|
"~meta": undefined;
|
|
264
|
-
}, []
|
|
270
|
+
}, []> {
|
|
271
|
+
Model: new () => T;
|
|
272
|
+
}
|
|
265
273
|
declare function defineSimpleViewModel<const T extends StandardJSONSchemaV1, const Options extends SimpleViewModelOptions = {}>(schema: T, options?: Options): SimpleViewModel<StandardJSONSchemaV1.InferInput<T>, Options>;
|
|
266
274
|
//#endregion
|
|
267
|
-
export { type AttributeReturn as AR, type AttributeReturn, type Action, type AttributeDefinition, type IViewModel, type Meta, type NamedAttributesNode, type NamedDefinition, type
|
|
275
|
+
export { type AttributeReturn as AR, type AttributeReturn, type Action, type AttributeBlockDefinition, type AttributeDefinition, type IViewModel, type Meta, type NamedAttributesNode, type NamedDefinition, type SimpleAttributeOptions, type SimpleViewModel, type SimpleViewModelOptions, type SingleAttributeNode, type View, createBinding, createDefine, defineSimpleViewModel, defineViewModel };
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,15 @@ var ViewModel = class ViewModel {
|
|
|
74
74
|
};
|
|
75
75
|
return newModel;
|
|
76
76
|
}
|
|
77
|
+
extend(Ctor, modelDefFn) {
|
|
78
|
+
const newVM = new ViewModel(Ctor);
|
|
79
|
+
for (const [name, action] of this.#registeredActions) newVM["~setActionOrBinder"]("action", name, action);
|
|
80
|
+
for (const [name, binder] of this.#registeredBinders) newVM["~setActionOrBinder"]("binder", name, binder);
|
|
81
|
+
const helper = new AttributeDefHelper(newVM);
|
|
82
|
+
const defResult = modelDefFn(helper);
|
|
83
|
+
helper["~assignActions"](defResult);
|
|
84
|
+
return newVM;
|
|
85
|
+
}
|
|
77
86
|
};
|
|
78
87
|
var AttributeDefHelper = class AttributeDefHelper {
|
|
79
88
|
#viewModel;
|
|
@@ -150,7 +159,8 @@ function extractObjectSchema(propSchema) {
|
|
|
150
159
|
return null;
|
|
151
160
|
}
|
|
152
161
|
function createSimpleViewModelFromJsonSchema(jsonSchema, options) {
|
|
153
|
-
const
|
|
162
|
+
const Ctor = class SimpleViewModel {};
|
|
163
|
+
const vm = new ViewModel(Ctor);
|
|
154
164
|
const helper = new AttributeDefHelper(vm);
|
|
155
165
|
const defResult = {};
|
|
156
166
|
for (const key of Object.keys(jsonSchema.properties ?? {})) {
|
|
@@ -159,6 +169,12 @@ function createSimpleViewModelFromJsonSchema(jsonSchema, options) {
|
|
|
159
169
|
defResult[key] = registerAttribute(helper, key, propSchema, options);
|
|
160
170
|
}
|
|
161
171
|
helper["~assignActions"](defResult);
|
|
172
|
+
Object.defineProperty(vm, "Model", {
|
|
173
|
+
value: Ctor,
|
|
174
|
+
writable: false,
|
|
175
|
+
enumerable: true,
|
|
176
|
+
configurable: true
|
|
177
|
+
});
|
|
162
178
|
return vm;
|
|
163
179
|
}
|
|
164
180
|
function registerAttribute(helper, key, propSchema, options) {
|
package/package.json
CHANGED
package/src/attribute_return.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AttributeBlockDefinition,
|
|
3
|
+
BlockDefinitionRewriteMeta,
|
|
4
|
+
IViewModel,
|
|
5
|
+
} from "./view_model.ts";
|
|
6
|
+
|
|
7
|
+
export type Computed<T, Constraint = any> = T extends Constraint
|
|
8
|
+
? { [K in keyof T]: T[K] }
|
|
9
|
+
: never;
|
|
10
|
+
|
|
11
|
+
export interface AttributePositionalReturnBase {
|
|
12
|
+
key?: string;
|
|
13
|
+
rewriteMeta?: any;
|
|
14
|
+
namedDefinition: AttributeBlockDefinition;
|
|
15
|
+
}
|
|
2
16
|
|
|
3
17
|
export namespace AttributeReturn {
|
|
4
18
|
export type This<TMeta> = {
|
|
@@ -25,8 +39,12 @@ export namespace AttributeReturn {
|
|
|
25
39
|
rewriteMeta: NewMeta;
|
|
26
40
|
};
|
|
27
41
|
|
|
28
|
-
export type WithRewriteMeta<
|
|
29
|
-
|
|
42
|
+
export type WithRewriteMeta<
|
|
43
|
+
NewMeta,
|
|
44
|
+
VM extends IViewModel<any, any, any>,
|
|
45
|
+
TMeta = VM["~namedDefinition"]["~meta"],
|
|
46
|
+
> = {
|
|
47
|
+
namedDefinition: BlockDefinitionRewriteMeta<VM["~namedDefinition"], TMeta>;
|
|
30
48
|
rewriteMeta: NewMeta;
|
|
31
49
|
};
|
|
32
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export {
|
|
|
2
2
|
defineViewModel,
|
|
3
3
|
type AttributeDefinition,
|
|
4
4
|
type IViewModel,
|
|
5
|
+
type SimpleAttributeOptions,
|
|
6
|
+
type AttributeBlockDefinition,
|
|
5
7
|
} from "./view_model.ts";
|
|
6
8
|
export {
|
|
7
9
|
defineSimpleViewModel,
|
|
@@ -9,7 +11,7 @@ export {
|
|
|
9
11
|
type SimpleViewModelOptions,
|
|
10
12
|
} from "./simple_view_model.ts";
|
|
11
13
|
export type { AttributeReturn, AR } from "./attribute_return.ts";
|
|
12
|
-
export type { Action,
|
|
14
|
+
export type { Action, Meta, NamedDefinition } from "./symbols.ts";
|
|
13
15
|
|
|
14
16
|
export {
|
|
15
17
|
createBinding,
|
package/src/simple_view_model.ts
CHANGED
|
@@ -44,10 +44,10 @@ type SimpleViewModelAttribute<
|
|
|
44
44
|
: {}
|
|
45
45
|
: {});
|
|
46
46
|
|
|
47
|
-
export
|
|
47
|
+
export interface SimpleViewModel<
|
|
48
48
|
T,
|
|
49
49
|
Options extends SimpleViewModelOptions = {},
|
|
50
|
-
>
|
|
50
|
+
> extends IViewModel<
|
|
51
51
|
T,
|
|
52
52
|
{
|
|
53
53
|
[K in keyof T]-?: SimpleViewModelAttribute<T[K], Options> & {
|
|
@@ -58,7 +58,9 @@ export type SimpleViewModel<
|
|
|
58
58
|
"~meta": undefined;
|
|
59
59
|
},
|
|
60
60
|
[]
|
|
61
|
-
|
|
61
|
+
> {
|
|
62
|
+
Model: new () => T;
|
|
63
|
+
}
|
|
62
64
|
|
|
63
65
|
const ajv = new Ajv2020({ strict: false });
|
|
64
66
|
|
|
@@ -91,7 +93,7 @@ function extractObjectSchema(
|
|
|
91
93
|
function createSimpleViewModelFromJsonSchema(
|
|
92
94
|
jsonSchema: Record<string, unknown>,
|
|
93
95
|
options: SimpleViewModelOptions,
|
|
94
|
-
):
|
|
96
|
+
): SimpleViewModel<any, any> {
|
|
95
97
|
const Ctor = class SimpleViewModel {};
|
|
96
98
|
const vm = new ViewModel<any, any, []>(Ctor);
|
|
97
99
|
const helper = new AttributeDefHelper(vm);
|
|
@@ -109,6 +111,12 @@ function createSimpleViewModelFromJsonSchema(
|
|
|
109
111
|
);
|
|
110
112
|
}
|
|
111
113
|
helper["~assignActions"](defResult);
|
|
114
|
+
Object.defineProperty(vm, "Model", {
|
|
115
|
+
value: Ctor,
|
|
116
|
+
writable: false,
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
});
|
|
112
120
|
return vm as any;
|
|
113
121
|
}
|
|
114
122
|
|
|
@@ -120,7 +128,10 @@ function registerAttribute(
|
|
|
120
128
|
): unknown {
|
|
121
129
|
let objectSchema: Record<string, unknown> | null = null;
|
|
122
130
|
if (options.recursive && (objectSchema = extractObjectSchema(propSchema))) {
|
|
123
|
-
const subVM = createSimpleViewModelFromJsonSchema(
|
|
131
|
+
const subVM: IViewModel<any, any, []> = createSimpleViewModelFromJsonSchema(
|
|
132
|
+
objectSchema,
|
|
133
|
+
options,
|
|
134
|
+
);
|
|
124
135
|
return helper.attribute((model, positionals, named) => {
|
|
125
136
|
if (positionals.length > 0) {
|
|
126
137
|
model[key] = positionals[0];
|
|
@@ -156,5 +167,8 @@ export function defineSimpleViewModel<
|
|
|
156
167
|
const jsonSchema = schema["~standard"].jsonSchema.input({
|
|
157
168
|
target: "draft-2020-12",
|
|
158
169
|
});
|
|
159
|
-
return createSimpleViewModelFromJsonSchema(
|
|
170
|
+
return createSimpleViewModelFromJsonSchema(
|
|
171
|
+
jsonSchema,
|
|
172
|
+
resolvedOptions,
|
|
173
|
+
) as SimpleViewModel<StandardJSONSchemaV1.InferInput<T>, Options>;
|
|
160
174
|
}
|
package/src/symbols.ts
CHANGED
package/src/view_model.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AttributePositionalReturnBase,
|
|
3
|
+
AttributeReturn,
|
|
4
|
+
Computed,
|
|
5
|
+
} from "./attribute_return.ts";
|
|
6
|
+
import type { Action, Meta } from "./symbols.ts";
|
|
3
7
|
import { View } from "./view.ts";
|
|
4
8
|
|
|
5
9
|
export interface AttributeBlockDefinition {
|
|
6
|
-
"~action"?: AttributeDefinition | undefined;
|
|
7
10
|
"~meta": any;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
type Computed<T> = T extends infer U extends { [K in keyof T]: unknown }
|
|
11
|
-
? U
|
|
12
|
-
: never;
|
|
13
|
-
|
|
14
13
|
export type BlockDefinitionRewriteMeta<
|
|
15
14
|
BlockDef extends AttributeBlockDefinition,
|
|
16
15
|
NewMeta,
|
|
17
|
-
> =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: never;
|
|
16
|
+
> = Computed<
|
|
17
|
+
Omit<BlockDef, Meta> & { "~meta": NewMeta },
|
|
18
|
+
AttributeBlockDefinition
|
|
19
|
+
>;
|
|
22
20
|
|
|
23
21
|
export interface IViewModel<
|
|
24
22
|
ModelT,
|
|
@@ -37,14 +35,31 @@ export interface IViewModel<
|
|
|
37
35
|
* This is useful for creating binding ViewModels directly that forwards
|
|
38
36
|
* the binding logic to inner ViewModels.
|
|
39
37
|
*/
|
|
40
|
-
bind<NewMeta = BlockDef[Meta]>():
|
|
38
|
+
bind<NewMeta = BlockDef[Meta]>(): IViewModel<
|
|
41
39
|
ModelT,
|
|
42
40
|
BlockDefinitionRewriteMeta<BlockDef, NewMeta>,
|
|
43
41
|
CtorArgs
|
|
44
42
|
>;
|
|
45
43
|
bind<NewMeta = BlockDef[Meta]>(
|
|
46
44
|
...args: CtorArgs
|
|
47
|
-
):
|
|
45
|
+
): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, []>;
|
|
46
|
+
extend<
|
|
47
|
+
ChildT extends ModelT,
|
|
48
|
+
const ChildBlockDef extends Partial<
|
|
49
|
+
Record<string | Action, AttributeDefinition>
|
|
50
|
+
>,
|
|
51
|
+
ChildCtorArgs extends any[] = [],
|
|
52
|
+
>(
|
|
53
|
+
Ctor: new (...args: ChildCtorArgs) => ChildT,
|
|
54
|
+
modelDefFn: (helper: AttributeDefHelper<ChildT>) => ChildBlockDef,
|
|
55
|
+
): IViewModel<
|
|
56
|
+
ChildT,
|
|
57
|
+
Computed<
|
|
58
|
+
Omit<BlockDef, keyof ChildBlockDef> &
|
|
59
|
+
ChildBlockDef & { "~meta": BlockDef[Meta] }
|
|
60
|
+
>,
|
|
61
|
+
ChildCtorArgs
|
|
62
|
+
>;
|
|
48
63
|
"~namedDefinition": BlockDef;
|
|
49
64
|
}
|
|
50
65
|
|
|
@@ -118,17 +133,17 @@ export class ViewModel<
|
|
|
118
133
|
return newVM;
|
|
119
134
|
}
|
|
120
135
|
|
|
121
|
-
bind<NewMeta = BlockDef[Meta]>():
|
|
136
|
+
bind<NewMeta = BlockDef[Meta]>(): IViewModel<
|
|
122
137
|
ModelT,
|
|
123
138
|
BlockDefinitionRewriteMeta<BlockDef, NewMeta>,
|
|
124
139
|
CtorArgs
|
|
125
140
|
>;
|
|
126
141
|
bind<NewMeta = BlockDef[Meta]>(
|
|
127
142
|
...args: CtorArgs
|
|
128
|
-
):
|
|
143
|
+
): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, []>;
|
|
129
144
|
bind<NewMeta = BlockDef[Meta]>(
|
|
130
145
|
...args: any[]
|
|
131
|
-
):
|
|
146
|
+
): IViewModel<ModelT, BlockDefinitionRewriteMeta<BlockDef, NewMeta>, any> {
|
|
132
147
|
if (args.length === 0) {
|
|
133
148
|
return this as any;
|
|
134
149
|
}
|
|
@@ -138,11 +153,41 @@ export class ViewModel<
|
|
|
138
153
|
super(...args);
|
|
139
154
|
}
|
|
140
155
|
};
|
|
141
|
-
return newModel
|
|
156
|
+
return newModel as IViewModel<any, any, any>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
extend<
|
|
160
|
+
ChildT extends ModelT,
|
|
161
|
+
const ChildBlockDef extends Partial<
|
|
162
|
+
Record<string | Action, AttributeDefinition>
|
|
163
|
+
>,
|
|
164
|
+
ChildCtorArgs extends any[] = [],
|
|
165
|
+
>(
|
|
166
|
+
Ctor: new (...args: ChildCtorArgs) => ChildT,
|
|
167
|
+
modelDefFn: (helper: AttributeDefHelper<ChildT>) => ChildBlockDef,
|
|
168
|
+
): IViewModel<
|
|
169
|
+
ChildT,
|
|
170
|
+
Computed<
|
|
171
|
+
Omit<BlockDef, keyof ChildBlockDef> &
|
|
172
|
+
ChildBlockDef & { "~meta": BlockDef[Meta] }
|
|
173
|
+
>,
|
|
174
|
+
ChildCtorArgs
|
|
175
|
+
> {
|
|
176
|
+
const newVM = new ViewModel<ChildT, any, ChildCtorArgs>(Ctor);
|
|
177
|
+
for (const [name, action] of this.#registeredActions) {
|
|
178
|
+
newVM["~setActionOrBinder"]("action", name, action as any);
|
|
179
|
+
}
|
|
180
|
+
for (const [name, binder] of this.#registeredBinders) {
|
|
181
|
+
newVM["~setActionOrBinder"]("binder", name, binder as any);
|
|
182
|
+
}
|
|
183
|
+
const helper = new AttributeDefHelper(newVM);
|
|
184
|
+
const defResult = modelDefFn(helper);
|
|
185
|
+
helper["~assignActions"](defResult);
|
|
186
|
+
return newVM as any;
|
|
142
187
|
}
|
|
143
188
|
}
|
|
144
189
|
|
|
145
|
-
interface SimpleAttributeOptions {
|
|
190
|
+
export interface SimpleAttributeOptions {
|
|
146
191
|
required?: true;
|
|
147
192
|
uniqueKey?: string;
|
|
148
193
|
}
|
|
@@ -300,11 +345,7 @@ export interface AttributeDefinition {
|
|
|
300
345
|
as?(): any;
|
|
301
346
|
required?(): boolean;
|
|
302
347
|
uniqueKey?(): string;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
interface AttributePositionalReturnBase {
|
|
306
|
-
rewriteMeta?: any;
|
|
307
|
-
namedDefinition: AttributeBlockDefinition;
|
|
348
|
+
mergeMeta?(meta: any, subMeta: any): any;
|
|
308
349
|
}
|
|
309
350
|
|
|
310
351
|
type OverloadedParameters<T extends (...args: any[]) => any> = T extends {
|