typebox 1.0.51 → 1.0.53
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.
|
@@ -156,8 +156,7 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
156
156
|
Action,
|
|
157
157
|
Parameters
|
|
158
158
|
] extends ['Uppercase', [infer Type extends TSchema]] ? TUppercaseInstantiate<Context, State, Type> : TDeferred<Action, Parameters>);
|
|
159
|
-
export type TInstantiateType<Context extends TProperties, State extends TState, Input extends TSchema,
|
|
160
|
-
Immutable extends boolean = Cloned extends TImmutable ? true : false, Modifiers extends [TSchema, ModifierAction, ModifierAction] = TModifierActions<Cloned, Cloned extends TReadonly<Cloned> ? 'add' : 'none', Cloned extends TOptional<Cloned> ? 'add' : 'none'>, Type extends TSchema = Modifiers[0], Instantiated extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TInstantiateType<Context, State, Type>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithImmutable extends TSchema = Immutable extends true ? TImmutable<Instantiated> : Instantiated, WithModifiers extends TSchema = TApplyReadonly<Modifiers[1], TApplyOptional<Modifiers[2], WithImmutable>>> = WithModifiers;
|
|
159
|
+
export type TInstantiateType<Context extends TProperties, State extends TState, Input extends TSchema, Immutable extends boolean = Input extends TImmutable ? true : false, Modifiers extends [TSchema, ModifierAction, ModifierAction] = TModifierActions<Input, Input extends TReadonly<Input> ? 'add' : 'none', Input extends TOptional<Input> ? 'add' : 'none'>, Type extends TSchema = Modifiers[0], Instantiated extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TInstantiateType<Context, State, Type>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithImmutable extends TSchema = Immutable extends true ? TImmutable<Instantiated> : Instantiated, WithModifiers extends TSchema = TApplyReadonly<Modifiers[1], TApplyOptional<Modifiers[2], WithImmutable>>> = WithModifiers;
|
|
161
160
|
export declare function InstantiateType<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, input: Type): TInstantiateType<Context, State, Type>;
|
|
162
161
|
/** Instantiates computed schematics using the given context and type. */
|
|
163
162
|
export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, {
|
|
@@ -143,10 +143,9 @@ function InstantiateDeferred(context, state, action, parameters, options) {
|
|
|
143
143
|
Deferred(action, parameters, options));
|
|
144
144
|
}
|
|
145
145
|
export function InstantiateType(context, state, input) {
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const type = modifiers[0];
|
|
146
|
+
const immutable = IsImmutable(input);
|
|
147
|
+
const modifiers = ModifierActions(input, IsReadonly(input) ? 'add' : 'none', IsOptional(input) ? 'add' : 'none');
|
|
148
|
+
const type = IsBase(modifiers[0]) ? modifiers[0].Clone() : modifiers[0];
|
|
150
149
|
const instantiated = (IsRef(type) ? RefInstantiate(context, state, type.$ref) :
|
|
151
150
|
IsArray(type) ? Array(InstantiateType(context, state, type.items), ArrayOptions(type)) :
|
|
152
151
|
IsAsyncIterator(type) ? AsyncIterator(InstantiateType(context, state, type.iteratorItems), AsyncIteratorOptions(type)) :
|
|
@@ -61,12 +61,14 @@ export declare const NonZero: TNonZero;
|
|
|
61
61
|
export declare const Digit: TDigit;
|
|
62
62
|
export declare const WhiteSpace = " ";
|
|
63
63
|
export declare const NewLine = "\n";
|
|
64
|
+
export declare const TabSpace = "\t";
|
|
64
65
|
export declare const UnderScore = "_";
|
|
65
66
|
export declare const Dot = ".";
|
|
66
67
|
export declare const DollarSign = "$";
|
|
67
68
|
export declare const Hyphen = "-";
|
|
68
69
|
export type TWhiteSpace = typeof WhiteSpace;
|
|
69
70
|
export type TNewLine = typeof NewLine;
|
|
71
|
+
export type TTabSpace = typeof TabSpace;
|
|
70
72
|
export type TUnderScore = typeof UnderScore;
|
|
71
73
|
export type TDot = typeof Dot;
|
|
72
74
|
export type TDollarSign = typeof DollarSign;
|
|
@@ -18,6 +18,7 @@ export const Digit = [Zero, ...NonZero];
|
|
|
18
18
|
// ------------------------------------------------------------------
|
|
19
19
|
export const WhiteSpace = ' ';
|
|
20
20
|
export const NewLine = '\n';
|
|
21
|
+
export const TabSpace = '\t';
|
|
21
22
|
export const UnderScore = '_';
|
|
22
23
|
export const Dot = '.';
|
|
23
24
|
export const DollarSign = '$';
|
|
@@ -14,6 +14,6 @@ type W1 = `${W0}${W0}`;
|
|
|
14
14
|
type W0 = ` `;
|
|
15
15
|
export type TTrimWhitespace<Input extends string> = (Input extends `${OpenComment}${infer Rest extends string}` ? TTrimWhitespace<TDiscardMultiLineComment<Rest>> : Input extends `${LineComment}${infer Rest extends string}` ? TTrimWhitespace<TDiscardLineComment<Rest>> : Input extends `${W4}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W3}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W1}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W0}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input);
|
|
16
16
|
export declare function TrimWhitespace<Input extends string>(input: Input): TTrimWhitespace<Input>;
|
|
17
|
-
export type TTrim<Input extends string> = (Input extends `${OpenComment}${infer Rest extends string}` ? TTrim<TDiscardMultiLineComment<Rest>> : Input extends `${LineComment}${infer Rest extends string}` ? TTrim<TDiscardLineComment<Rest>> : Input extends `${Char.TNewLine}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W4}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W3}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W1}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W0}${infer Rest extends string}` ? TTrim<Rest> : Input);
|
|
17
|
+
export type TTrim<Input extends string> = (Input extends `${OpenComment}${infer Rest extends string}` ? TTrim<TDiscardMultiLineComment<Rest>> : Input extends `${LineComment}${infer Rest extends string}` ? TTrim<TDiscardLineComment<Rest>> : Input extends `${Char.TNewLine}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${Char.TTabSpace}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W4}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W3}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W1}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W0}${infer Rest extends string}` ? TTrim<Rest> : Input);
|
|
18
18
|
export declare function Trim<Input extends string>(input: Input): TTrim<Input>;
|
|
19
19
|
export {};
|