@axi-engine/fields 0.2.1 → 0.2.3
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.mts +66 -99
- package/dist/index.d.ts +66 -99
- package/dist/index.js +41 -47
- package/dist/index.mjs +39 -46
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _axi_engine_utils from '@axi-engine/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { Constructor, Subscribable, Emitter, PathType } from '@axi-engine/utils';
|
|
3
3
|
|
|
4
4
|
interface Policy<T> {
|
|
5
5
|
readonly id: string;
|
|
@@ -75,6 +75,31 @@ declare class Policies<T> {
|
|
|
75
75
|
apply(val: T): T;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* extract field type
|
|
80
|
+
*/
|
|
81
|
+
type GetValueType<TField extends Field<any>> = TField extends Field<infer U> ? U : any;
|
|
82
|
+
/**
|
|
83
|
+
* A mapped type that creates the method signatures for a typed mixin.
|
|
84
|
+
* e.g., createBoolean, upsetBoolean, getBoolean
|
|
85
|
+
*/
|
|
86
|
+
type TypedMethods<TCtor extends Constructor<Field<any>>, TBaseName extends string> = {
|
|
87
|
+
[K in `create${TBaseName}`]: (name: string, initialValue: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
88
|
+
} & {
|
|
89
|
+
[K in `upset${TBaseName}`]: (name: string, value: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
90
|
+
} & {
|
|
91
|
+
[K in `get${TBaseName}`]: (name: string) => InstanceType<TCtor>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A higher-order function that generates a mixin for a specific Field type.
|
|
95
|
+
* This factory removes the need to write boilerplate mixin code for every new field type.
|
|
96
|
+
*
|
|
97
|
+
* @param typeName The `typeName` of the Field to create (e.g., 'boolean', 'my-signal-field').
|
|
98
|
+
* @param baseMethodName The base name for the generated methods (e.g., 'Boolean', 'MySignal').
|
|
99
|
+
* @returns A fully functional, typed mixin.
|
|
100
|
+
*/
|
|
101
|
+
declare function createTypedMethodsMixin<TCtor extends Constructor<Field<any>>, TBaseName extends string>(typeName: string, baseMethodName: TBaseName): <TBase extends Constructor<Fields>>(Base: TBase) => Constructor<InstanceType<TBase> & TypedMethods<TCtor, TBaseName>>;
|
|
102
|
+
|
|
78
103
|
interface FieldOptions<T> {
|
|
79
104
|
policies?: Policy<T>[];
|
|
80
105
|
}
|
|
@@ -333,106 +358,48 @@ declare class Fields {
|
|
|
333
358
|
destroy(): void;
|
|
334
359
|
}
|
|
335
360
|
|
|
336
|
-
declare const DefaultFields_base: {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
+
declare const DefaultFields_base: _axi_engine_utils.Constructor<{
|
|
362
|
+
createGeneric<T>(name: string, initialValue: T, options?: FieldOptions<T> | undefined): DefaultField<T>;
|
|
363
|
+
upsetGeneric<T>(name: string, value: T, options?: FieldOptions<T> | undefined): DefaultField<T>;
|
|
364
|
+
getGeneric<T>(name: string): DefaultField<T>;
|
|
365
|
+
readonly typeName: "fields";
|
|
366
|
+
readonly _fields: Map<string, Field<any>>;
|
|
367
|
+
readonly _fieldRegistry: FieldRegistry;
|
|
368
|
+
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
369
|
+
name: string;
|
|
370
|
+
field: Field<any>;
|
|
371
|
+
}]>;
|
|
372
|
+
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
373
|
+
names: string[];
|
|
374
|
+
}]>;
|
|
375
|
+
get fields(): Map<string, Field<any>>;
|
|
376
|
+
has(name: string): boolean;
|
|
377
|
+
add<T extends Field<any>>(field: Field<any>): T;
|
|
378
|
+
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
379
|
+
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
380
|
+
get<T extends Field<any>>(name: string): T;
|
|
381
|
+
remove(names: string | string[]): void;
|
|
382
|
+
clear(): void;
|
|
383
|
+
destroy(): void;
|
|
384
|
+
} & Fields & {
|
|
385
|
+
createNumeric: (name: string, initialValue: number, options?: DefaultNumericFieldOptions | undefined) => DefaultNumericField;
|
|
361
386
|
} & {
|
|
362
|
-
|
|
363
|
-
createString(name: string, initialValue: string, options?: DefaultStringFieldOptions): DefaultStringField;
|
|
364
|
-
upsetString(name: string, value: string, options?: DefaultStringFieldOptions): DefaultStringField;
|
|
365
|
-
getString(name: string): DefaultStringField;
|
|
366
|
-
readonly typeName: "fields";
|
|
367
|
-
readonly _fields: Map<string, Field<any>>;
|
|
368
|
-
readonly _fieldRegistry: FieldRegistry;
|
|
369
|
-
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
370
|
-
name: string;
|
|
371
|
-
field: Field<any>;
|
|
372
|
-
}]>;
|
|
373
|
-
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
374
|
-
names: string[];
|
|
375
|
-
}]>;
|
|
376
|
-
get fields(): Map<string, Field<any>>;
|
|
377
|
-
has(name: string): boolean;
|
|
378
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
379
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
380
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
381
|
-
get<T extends Field<any>>(name: string): T;
|
|
382
|
-
remove(names: string | string[]): void;
|
|
383
|
-
clear(): void;
|
|
384
|
-
destroy(): void;
|
|
385
|
-
};
|
|
387
|
+
upsetNumeric: (name: string, value: number, options?: DefaultNumericFieldOptions | undefined) => DefaultNumericField;
|
|
386
388
|
} & {
|
|
387
|
-
|
|
388
|
-
createNumeric(name: string, initialValue: number, options?: DefaultNumericFieldOptions): DefaultNumericField;
|
|
389
|
-
upsetNumeric(name: string, value: number, options?: DefaultNumericFieldOptions): DefaultNumericField;
|
|
390
|
-
getNumeric(name: string): DefaultNumericField;
|
|
391
|
-
readonly typeName: "fields";
|
|
392
|
-
readonly _fields: Map<string, Field<any>>;
|
|
393
|
-
readonly _fieldRegistry: FieldRegistry;
|
|
394
|
-
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
395
|
-
name: string;
|
|
396
|
-
field: Field<any>;
|
|
397
|
-
}]>;
|
|
398
|
-
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
399
|
-
names: string[];
|
|
400
|
-
}]>;
|
|
401
|
-
get fields(): Map<string, Field<any>>;
|
|
402
|
-
has(name: string): boolean;
|
|
403
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
404
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
405
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
406
|
-
get<T extends Field<any>>(name: string): T;
|
|
407
|
-
remove(names: string | string[]): void;
|
|
408
|
-
clear(): void;
|
|
409
|
-
destroy(): void;
|
|
410
|
-
};
|
|
389
|
+
getNumeric: (name: string) => DefaultNumericField;
|
|
411
390
|
} & {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}]>;
|
|
425
|
-
get fields(): Map<string, Field<any>>;
|
|
426
|
-
has(name: string): boolean;
|
|
427
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
428
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
429
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
430
|
-
get<T extends Field<any>>(name: string): T;
|
|
431
|
-
remove(names: string | string[]): void;
|
|
432
|
-
clear(): void;
|
|
433
|
-
destroy(): void;
|
|
434
|
-
};
|
|
435
|
-
} & typeof Fields;
|
|
391
|
+
createString: (name: string, initialValue: string, options?: DefaultStringFieldOptions | undefined) => DefaultStringField;
|
|
392
|
+
} & {
|
|
393
|
+
upsetString: (name: string, value: string, options?: DefaultStringFieldOptions | undefined) => DefaultStringField;
|
|
394
|
+
} & {
|
|
395
|
+
getString: (name: string) => DefaultStringField;
|
|
396
|
+
} & {
|
|
397
|
+
createBoolean: (name: string, initialValue: boolean, options?: DefaultBooleanFieldOptions | undefined) => DefaultBooleanField;
|
|
398
|
+
} & {
|
|
399
|
+
upsetBoolean: (name: string, value: boolean, options?: DefaultBooleanFieldOptions | undefined) => DefaultBooleanField;
|
|
400
|
+
} & {
|
|
401
|
+
getBoolean: (name: string) => DefaultBooleanField;
|
|
402
|
+
}>;
|
|
436
403
|
declare class DefaultFields extends DefaultFields_base {
|
|
437
404
|
}
|
|
438
405
|
|
|
@@ -838,4 +805,4 @@ declare class FieldTreeSerializer<TFields extends Fields> {
|
|
|
838
805
|
hydrate(snapshot: FieldTreeSnapshot): FieldTree<TFields>;
|
|
839
806
|
}
|
|
840
807
|
|
|
841
|
-
export { type BooleanField, ClampMaxPolicy, ClampMaxPolicySerializerHandler, ClampMinPolicy, ClampMinPolicySerializerHandler, ClampPolicy, ClampPolicySerializerHandler, DefaultBooleanField, type DefaultBooleanFieldOptions, DefaultField, DefaultFields, DefaultFieldsFactory, DefaultNumericField, type DefaultNumericFieldOptions, DefaultStringField, type DefaultStringFieldOptions, DefaultTreeNodeFactory, type Field, type FieldOptions, FieldRegistry, FieldSerializer, type FieldSnapshot, FieldTree, FieldTreeSerializer, type FieldTreeSnapshot, Fields, type FieldsFactory, FieldsSerializer, type FieldsSnapshot, type NumericField, Policies, type Policy, PolicySerializer, type PolicySerializerHandler, type StringField, type TreeNode, type TreeNodeFactory, clampMaxPolicy, clampMinPolicy, clampPolicy };
|
|
808
|
+
export { type BooleanField, ClampMaxPolicy, ClampMaxPolicySerializerHandler, ClampMinPolicy, ClampMinPolicySerializerHandler, ClampPolicy, ClampPolicySerializerHandler, DefaultBooleanField, type DefaultBooleanFieldOptions, DefaultField, DefaultFields, DefaultFieldsFactory, DefaultNumericField, type DefaultNumericFieldOptions, DefaultStringField, type DefaultStringFieldOptions, DefaultTreeNodeFactory, type Field, type FieldOptions, FieldRegistry, FieldSerializer, type FieldSnapshot, FieldTree, FieldTreeSerializer, type FieldTreeSnapshot, Fields, type FieldsFactory, FieldsSerializer, type FieldsSnapshot, type NumericField, Policies, type Policy, PolicySerializer, type PolicySerializerHandler, type StringField, type TreeNode, type TreeNodeFactory, clampMaxPolicy, clampMinPolicy, clampPolicy, createTypedMethodsMixin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _axi_engine_utils from '@axi-engine/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { Constructor, Subscribable, Emitter, PathType } from '@axi-engine/utils';
|
|
3
3
|
|
|
4
4
|
interface Policy<T> {
|
|
5
5
|
readonly id: string;
|
|
@@ -75,6 +75,31 @@ declare class Policies<T> {
|
|
|
75
75
|
apply(val: T): T;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* extract field type
|
|
80
|
+
*/
|
|
81
|
+
type GetValueType<TField extends Field<any>> = TField extends Field<infer U> ? U : any;
|
|
82
|
+
/**
|
|
83
|
+
* A mapped type that creates the method signatures for a typed mixin.
|
|
84
|
+
* e.g., createBoolean, upsetBoolean, getBoolean
|
|
85
|
+
*/
|
|
86
|
+
type TypedMethods<TCtor extends Constructor<Field<any>>, TBaseName extends string> = {
|
|
87
|
+
[K in `create${TBaseName}`]: (name: string, initialValue: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
88
|
+
} & {
|
|
89
|
+
[K in `upset${TBaseName}`]: (name: string, value: GetValueType<InstanceType<TCtor>>, options?: ConstructorParameters<TCtor>[2]) => InstanceType<TCtor>;
|
|
90
|
+
} & {
|
|
91
|
+
[K in `get${TBaseName}`]: (name: string) => InstanceType<TCtor>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A higher-order function that generates a mixin for a specific Field type.
|
|
95
|
+
* This factory removes the need to write boilerplate mixin code for every new field type.
|
|
96
|
+
*
|
|
97
|
+
* @param typeName The `typeName` of the Field to create (e.g., 'boolean', 'my-signal-field').
|
|
98
|
+
* @param baseMethodName The base name for the generated methods (e.g., 'Boolean', 'MySignal').
|
|
99
|
+
* @returns A fully functional, typed mixin.
|
|
100
|
+
*/
|
|
101
|
+
declare function createTypedMethodsMixin<TCtor extends Constructor<Field<any>>, TBaseName extends string>(typeName: string, baseMethodName: TBaseName): <TBase extends Constructor<Fields>>(Base: TBase) => Constructor<InstanceType<TBase> & TypedMethods<TCtor, TBaseName>>;
|
|
102
|
+
|
|
78
103
|
interface FieldOptions<T> {
|
|
79
104
|
policies?: Policy<T>[];
|
|
80
105
|
}
|
|
@@ -333,106 +358,48 @@ declare class Fields {
|
|
|
333
358
|
destroy(): void;
|
|
334
359
|
}
|
|
335
360
|
|
|
336
|
-
declare const DefaultFields_base: {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
+
declare const DefaultFields_base: _axi_engine_utils.Constructor<{
|
|
362
|
+
createGeneric<T>(name: string, initialValue: T, options?: FieldOptions<T> | undefined): DefaultField<T>;
|
|
363
|
+
upsetGeneric<T>(name: string, value: T, options?: FieldOptions<T> | undefined): DefaultField<T>;
|
|
364
|
+
getGeneric<T>(name: string): DefaultField<T>;
|
|
365
|
+
readonly typeName: "fields";
|
|
366
|
+
readonly _fields: Map<string, Field<any>>;
|
|
367
|
+
readonly _fieldRegistry: FieldRegistry;
|
|
368
|
+
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
369
|
+
name: string;
|
|
370
|
+
field: Field<any>;
|
|
371
|
+
}]>;
|
|
372
|
+
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
373
|
+
names: string[];
|
|
374
|
+
}]>;
|
|
375
|
+
get fields(): Map<string, Field<any>>;
|
|
376
|
+
has(name: string): boolean;
|
|
377
|
+
add<T extends Field<any>>(field: Field<any>): T;
|
|
378
|
+
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
379
|
+
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
380
|
+
get<T extends Field<any>>(name: string): T;
|
|
381
|
+
remove(names: string | string[]): void;
|
|
382
|
+
clear(): void;
|
|
383
|
+
destroy(): void;
|
|
384
|
+
} & Fields & {
|
|
385
|
+
createNumeric: (name: string, initialValue: number, options?: DefaultNumericFieldOptions | undefined) => DefaultNumericField;
|
|
361
386
|
} & {
|
|
362
|
-
|
|
363
|
-
createString(name: string, initialValue: string, options?: DefaultStringFieldOptions): DefaultStringField;
|
|
364
|
-
upsetString(name: string, value: string, options?: DefaultStringFieldOptions): DefaultStringField;
|
|
365
|
-
getString(name: string): DefaultStringField;
|
|
366
|
-
readonly typeName: "fields";
|
|
367
|
-
readonly _fields: Map<string, Field<any>>;
|
|
368
|
-
readonly _fieldRegistry: FieldRegistry;
|
|
369
|
-
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
370
|
-
name: string;
|
|
371
|
-
field: Field<any>;
|
|
372
|
-
}]>;
|
|
373
|
-
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
374
|
-
names: string[];
|
|
375
|
-
}]>;
|
|
376
|
-
get fields(): Map<string, Field<any>>;
|
|
377
|
-
has(name: string): boolean;
|
|
378
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
379
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
380
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
381
|
-
get<T extends Field<any>>(name: string): T;
|
|
382
|
-
remove(names: string | string[]): void;
|
|
383
|
-
clear(): void;
|
|
384
|
-
destroy(): void;
|
|
385
|
-
};
|
|
387
|
+
upsetNumeric: (name: string, value: number, options?: DefaultNumericFieldOptions | undefined) => DefaultNumericField;
|
|
386
388
|
} & {
|
|
387
|
-
|
|
388
|
-
createNumeric(name: string, initialValue: number, options?: DefaultNumericFieldOptions): DefaultNumericField;
|
|
389
|
-
upsetNumeric(name: string, value: number, options?: DefaultNumericFieldOptions): DefaultNumericField;
|
|
390
|
-
getNumeric(name: string): DefaultNumericField;
|
|
391
|
-
readonly typeName: "fields";
|
|
392
|
-
readonly _fields: Map<string, Field<any>>;
|
|
393
|
-
readonly _fieldRegistry: FieldRegistry;
|
|
394
|
-
onAdd: _axi_engine_utils.Emitter<[event: {
|
|
395
|
-
name: string;
|
|
396
|
-
field: Field<any>;
|
|
397
|
-
}]>;
|
|
398
|
-
onRemove: _axi_engine_utils.Emitter<[event: {
|
|
399
|
-
names: string[];
|
|
400
|
-
}]>;
|
|
401
|
-
get fields(): Map<string, Field<any>>;
|
|
402
|
-
has(name: string): boolean;
|
|
403
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
404
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
405
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
406
|
-
get<T extends Field<any>>(name: string): T;
|
|
407
|
-
remove(names: string | string[]): void;
|
|
408
|
-
clear(): void;
|
|
409
|
-
destroy(): void;
|
|
410
|
-
};
|
|
389
|
+
getNumeric: (name: string) => DefaultNumericField;
|
|
411
390
|
} & {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}]>;
|
|
425
|
-
get fields(): Map<string, Field<any>>;
|
|
426
|
-
has(name: string): boolean;
|
|
427
|
-
add<T extends Field<any>>(field: Field<any>): T;
|
|
428
|
-
create<T extends Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
429
|
-
upset<T extends Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
430
|
-
get<T extends Field<any>>(name: string): T;
|
|
431
|
-
remove(names: string | string[]): void;
|
|
432
|
-
clear(): void;
|
|
433
|
-
destroy(): void;
|
|
434
|
-
};
|
|
435
|
-
} & typeof Fields;
|
|
391
|
+
createString: (name: string, initialValue: string, options?: DefaultStringFieldOptions | undefined) => DefaultStringField;
|
|
392
|
+
} & {
|
|
393
|
+
upsetString: (name: string, value: string, options?: DefaultStringFieldOptions | undefined) => DefaultStringField;
|
|
394
|
+
} & {
|
|
395
|
+
getString: (name: string) => DefaultStringField;
|
|
396
|
+
} & {
|
|
397
|
+
createBoolean: (name: string, initialValue: boolean, options?: DefaultBooleanFieldOptions | undefined) => DefaultBooleanField;
|
|
398
|
+
} & {
|
|
399
|
+
upsetBoolean: (name: string, value: boolean, options?: DefaultBooleanFieldOptions | undefined) => DefaultBooleanField;
|
|
400
|
+
} & {
|
|
401
|
+
getBoolean: (name: string) => DefaultBooleanField;
|
|
402
|
+
}>;
|
|
436
403
|
declare class DefaultFields extends DefaultFields_base {
|
|
437
404
|
}
|
|
438
405
|
|
|
@@ -838,4 +805,4 @@ declare class FieldTreeSerializer<TFields extends Fields> {
|
|
|
838
805
|
hydrate(snapshot: FieldTreeSnapshot): FieldTree<TFields>;
|
|
839
806
|
}
|
|
840
807
|
|
|
841
|
-
export { type BooleanField, ClampMaxPolicy, ClampMaxPolicySerializerHandler, ClampMinPolicy, ClampMinPolicySerializerHandler, ClampPolicy, ClampPolicySerializerHandler, DefaultBooleanField, type DefaultBooleanFieldOptions, DefaultField, DefaultFields, DefaultFieldsFactory, DefaultNumericField, type DefaultNumericFieldOptions, DefaultStringField, type DefaultStringFieldOptions, DefaultTreeNodeFactory, type Field, type FieldOptions, FieldRegistry, FieldSerializer, type FieldSnapshot, FieldTree, FieldTreeSerializer, type FieldTreeSnapshot, Fields, type FieldsFactory, FieldsSerializer, type FieldsSnapshot, type NumericField, Policies, type Policy, PolicySerializer, type PolicySerializerHandler, type StringField, type TreeNode, type TreeNodeFactory, clampMaxPolicy, clampMinPolicy, clampPolicy };
|
|
808
|
+
export { type BooleanField, ClampMaxPolicy, ClampMaxPolicySerializerHandler, ClampMinPolicy, ClampMinPolicySerializerHandler, ClampPolicy, ClampPolicySerializerHandler, DefaultBooleanField, type DefaultBooleanFieldOptions, DefaultField, DefaultFields, DefaultFieldsFactory, DefaultNumericField, type DefaultNumericFieldOptions, DefaultStringField, type DefaultStringFieldOptions, DefaultTreeNodeFactory, type Field, type FieldOptions, FieldRegistry, FieldSerializer, type FieldSnapshot, FieldTree, FieldTreeSerializer, type FieldTreeSnapshot, Fields, type FieldsFactory, FieldsSerializer, type FieldsSnapshot, type NumericField, Policies, type Policy, PolicySerializer, type PolicySerializerHandler, type StringField, type TreeNode, type TreeNodeFactory, clampMaxPolicy, clampMinPolicy, clampPolicy, createTypedMethodsMixin };
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
PolicySerializer: () => PolicySerializer,
|
|
44
44
|
clampMaxPolicy: () => clampMaxPolicy,
|
|
45
45
|
clampMinPolicy: () => clampMinPolicy,
|
|
46
|
-
clampPolicy: () => clampPolicy
|
|
46
|
+
clampPolicy: () => clampPolicy,
|
|
47
|
+
createTypedMethodsMixin: () => createTypedMethodsMixin
|
|
47
48
|
});
|
|
48
49
|
module.exports = __toCommonJS(index_exports);
|
|
49
50
|
|
|
@@ -166,6 +167,31 @@ var Policies = class {
|
|
|
166
167
|
}
|
|
167
168
|
};
|
|
168
169
|
|
|
170
|
+
// src/mixins/mixin-factory.ts
|
|
171
|
+
function createTypedMethodsMixin(typeName, baseMethodName) {
|
|
172
|
+
const methodNames = {
|
|
173
|
+
create: `create${baseMethodName}`,
|
|
174
|
+
upset: `upset${baseMethodName}`,
|
|
175
|
+
get: `get${baseMethodName}`
|
|
176
|
+
};
|
|
177
|
+
return function(Base) {
|
|
178
|
+
return class FieldsWith extends Base {
|
|
179
|
+
// createBoolean, createMySignal, etc.
|
|
180
|
+
[methodNames.create](name, initialValue, options) {
|
|
181
|
+
return this.create(typeName, name, initialValue, options);
|
|
182
|
+
}
|
|
183
|
+
// upsetBoolean, upsetMySignal, etc.
|
|
184
|
+
[methodNames.upset](name, value, options) {
|
|
185
|
+
return this.upset(typeName, name, value, options);
|
|
186
|
+
}
|
|
187
|
+
// getBoolean, getMySignal, etc.
|
|
188
|
+
[methodNames.get](name) {
|
|
189
|
+
return this.get(name);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
// src/field-definitions/default-field.ts
|
|
170
196
|
var import_utils = require("@axi-engine/utils");
|
|
171
197
|
var import_dequal = require("dequal");
|
|
@@ -500,64 +526,31 @@ var Fields = class _Fields {
|
|
|
500
526
|
};
|
|
501
527
|
|
|
502
528
|
// src/mixins/with-boolean-fields.mixin.ts
|
|
503
|
-
|
|
504
|
-
return class FieldsWithBoolean extends Base {
|
|
505
|
-
createBoolean(name, initialValue, options) {
|
|
506
|
-
return this.create(DefaultBooleanField.typeName, name, initialValue, options);
|
|
507
|
-
}
|
|
508
|
-
upsetBoolean(name, value, options) {
|
|
509
|
-
return this.upset(DefaultBooleanField.typeName, name, value, options);
|
|
510
|
-
}
|
|
511
|
-
getBoolean(name) {
|
|
512
|
-
return this.get(name);
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
}
|
|
529
|
+
var WithBooleanFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "Boolean");
|
|
516
530
|
|
|
517
531
|
// src/mixins/with-string-fields.mixin.ts
|
|
518
|
-
|
|
519
|
-
return class FieldsWithString extends Base {
|
|
520
|
-
createString(name, initialValue, options) {
|
|
521
|
-
return this.create(DefaultStringField.typeName, name, initialValue, options);
|
|
522
|
-
}
|
|
523
|
-
upsetString(name, value, options) {
|
|
524
|
-
return this.upset(DefaultStringField.typeName, name, value, options);
|
|
525
|
-
}
|
|
526
|
-
getString(name) {
|
|
527
|
-
return this.get(name);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
}
|
|
532
|
+
var WithStringFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "String");
|
|
531
533
|
|
|
532
534
|
// src/mixins/with-numeric-fields.mixin.ts
|
|
533
|
-
|
|
534
|
-
return class FieldsWithNumeric extends Base {
|
|
535
|
-
createNumeric(name, initialValue, options) {
|
|
536
|
-
return this.create(DefaultNumericField.typeName, name, initialValue, options);
|
|
537
|
-
}
|
|
538
|
-
upsetNumeric(name, value, options) {
|
|
539
|
-
return this.upset(DefaultNumericField.typeName, name, value, options);
|
|
540
|
-
}
|
|
541
|
-
getNumeric(name) {
|
|
542
|
-
return this.get(name);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
}
|
|
535
|
+
var WithNumericFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "Numeric");
|
|
546
536
|
|
|
547
|
-
// src/mixins/with-default-fields.mixin.ts
|
|
548
|
-
function
|
|
549
|
-
return class
|
|
550
|
-
|
|
537
|
+
// src/mixins/with-default-generic-fields.mixin.ts
|
|
538
|
+
function WithDefaultGenericFields(Base) {
|
|
539
|
+
return class FieldsWithDefaultGeneric extends Base {
|
|
540
|
+
createGeneric(name, initialValue, options) {
|
|
551
541
|
return this.create(DefaultField.typeName, name, initialValue, options);
|
|
552
542
|
}
|
|
553
|
-
|
|
543
|
+
upsetGeneric(name, value, options) {
|
|
554
544
|
return this.upset(DefaultField.typeName, name, value, options);
|
|
555
545
|
}
|
|
546
|
+
getGeneric(name) {
|
|
547
|
+
return this.get(name);
|
|
548
|
+
}
|
|
556
549
|
};
|
|
557
550
|
}
|
|
558
551
|
|
|
559
552
|
// src/default-fields.ts
|
|
560
|
-
var DefaultFields = class extends WithBooleanFields(WithStringFields(WithNumericFields(
|
|
553
|
+
var DefaultFields = class extends WithBooleanFields(WithStringFields(WithNumericFields(WithDefaultGenericFields(Fields)))) {
|
|
561
554
|
};
|
|
562
555
|
|
|
563
556
|
// src/field-tree.ts
|
|
@@ -1050,5 +1043,6 @@ var FieldTreeSerializer = class {
|
|
|
1050
1043
|
PolicySerializer,
|
|
1051
1044
|
clampMaxPolicy,
|
|
1052
1045
|
clampMinPolicy,
|
|
1053
|
-
clampPolicy
|
|
1046
|
+
clampPolicy,
|
|
1047
|
+
createTypedMethodsMixin
|
|
1054
1048
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -117,6 +117,31 @@ var Policies = class {
|
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
+
// src/mixins/mixin-factory.ts
|
|
121
|
+
function createTypedMethodsMixin(typeName, baseMethodName) {
|
|
122
|
+
const methodNames = {
|
|
123
|
+
create: `create${baseMethodName}`,
|
|
124
|
+
upset: `upset${baseMethodName}`,
|
|
125
|
+
get: `get${baseMethodName}`
|
|
126
|
+
};
|
|
127
|
+
return function(Base) {
|
|
128
|
+
return class FieldsWith extends Base {
|
|
129
|
+
// createBoolean, createMySignal, etc.
|
|
130
|
+
[methodNames.create](name, initialValue, options) {
|
|
131
|
+
return this.create(typeName, name, initialValue, options);
|
|
132
|
+
}
|
|
133
|
+
// upsetBoolean, upsetMySignal, etc.
|
|
134
|
+
[methodNames.upset](name, value, options) {
|
|
135
|
+
return this.upset(typeName, name, value, options);
|
|
136
|
+
}
|
|
137
|
+
// getBoolean, getMySignal, etc.
|
|
138
|
+
[methodNames.get](name) {
|
|
139
|
+
return this.get(name);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
120
145
|
// src/field-definitions/default-field.ts
|
|
121
146
|
import { Emitter } from "@axi-engine/utils";
|
|
122
147
|
import { dequal } from "dequal";
|
|
@@ -451,64 +476,31 @@ var Fields = class _Fields {
|
|
|
451
476
|
};
|
|
452
477
|
|
|
453
478
|
// src/mixins/with-boolean-fields.mixin.ts
|
|
454
|
-
|
|
455
|
-
return class FieldsWithBoolean extends Base {
|
|
456
|
-
createBoolean(name, initialValue, options) {
|
|
457
|
-
return this.create(DefaultBooleanField.typeName, name, initialValue, options);
|
|
458
|
-
}
|
|
459
|
-
upsetBoolean(name, value, options) {
|
|
460
|
-
return this.upset(DefaultBooleanField.typeName, name, value, options);
|
|
461
|
-
}
|
|
462
|
-
getBoolean(name) {
|
|
463
|
-
return this.get(name);
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
}
|
|
479
|
+
var WithBooleanFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "Boolean");
|
|
467
480
|
|
|
468
481
|
// src/mixins/with-string-fields.mixin.ts
|
|
469
|
-
|
|
470
|
-
return class FieldsWithString extends Base {
|
|
471
|
-
createString(name, initialValue, options) {
|
|
472
|
-
return this.create(DefaultStringField.typeName, name, initialValue, options);
|
|
473
|
-
}
|
|
474
|
-
upsetString(name, value, options) {
|
|
475
|
-
return this.upset(DefaultStringField.typeName, name, value, options);
|
|
476
|
-
}
|
|
477
|
-
getString(name) {
|
|
478
|
-
return this.get(name);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
+
var WithStringFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "String");
|
|
482
483
|
|
|
483
484
|
// src/mixins/with-numeric-fields.mixin.ts
|
|
484
|
-
|
|
485
|
-
return class FieldsWithNumeric extends Base {
|
|
486
|
-
createNumeric(name, initialValue, options) {
|
|
487
|
-
return this.create(DefaultNumericField.typeName, name, initialValue, options);
|
|
488
|
-
}
|
|
489
|
-
upsetNumeric(name, value, options) {
|
|
490
|
-
return this.upset(DefaultNumericField.typeName, name, value, options);
|
|
491
|
-
}
|
|
492
|
-
getNumeric(name) {
|
|
493
|
-
return this.get(name);
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
}
|
|
485
|
+
var WithNumericFields = createTypedMethodsMixin(DefaultBooleanField.typeName, "Numeric");
|
|
497
486
|
|
|
498
|
-
// src/mixins/with-default-fields.mixin.ts
|
|
499
|
-
function
|
|
500
|
-
return class
|
|
501
|
-
|
|
487
|
+
// src/mixins/with-default-generic-fields.mixin.ts
|
|
488
|
+
function WithDefaultGenericFields(Base) {
|
|
489
|
+
return class FieldsWithDefaultGeneric extends Base {
|
|
490
|
+
createGeneric(name, initialValue, options) {
|
|
502
491
|
return this.create(DefaultField.typeName, name, initialValue, options);
|
|
503
492
|
}
|
|
504
|
-
|
|
493
|
+
upsetGeneric(name, value, options) {
|
|
505
494
|
return this.upset(DefaultField.typeName, name, value, options);
|
|
506
495
|
}
|
|
496
|
+
getGeneric(name) {
|
|
497
|
+
return this.get(name);
|
|
498
|
+
}
|
|
507
499
|
};
|
|
508
500
|
}
|
|
509
501
|
|
|
510
502
|
// src/default-fields.ts
|
|
511
|
-
var DefaultFields = class extends WithBooleanFields(WithStringFields(WithNumericFields(
|
|
503
|
+
var DefaultFields = class extends WithBooleanFields(WithStringFields(WithNumericFields(WithDefaultGenericFields(Fields)))) {
|
|
512
504
|
};
|
|
513
505
|
|
|
514
506
|
// src/field-tree.ts
|
|
@@ -1000,5 +992,6 @@ export {
|
|
|
1000
992
|
PolicySerializer,
|
|
1001
993
|
clampMaxPolicy,
|
|
1002
994
|
clampMinPolicy,
|
|
1003
|
-
clampPolicy
|
|
995
|
+
clampPolicy,
|
|
996
|
+
createTypedMethodsMixin
|
|
1004
997
|
};
|