@vaadin/hilla-models 24.6.4 → 24.7.0-alpha10
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.js +2 -2
- package/index.js.map +1 -1
- package/model.d.ts.map +1 -1
- package/model.js.map +2 -2
- package/package.json +7 -33
package/index.js
CHANGED
|
@@ -118,8 +118,8 @@ const m = {
|
|
|
118
118
|
return value === nothing ? model[$defaultValue] : value;
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
|
-
var
|
|
121
|
+
var index_default = m;
|
|
122
122
|
export {
|
|
123
|
-
|
|
123
|
+
index_default as default
|
|
124
124
|
};
|
|
125
125
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { EmptyObject } from 'type-fest';\nimport { CoreModelBuilder, ObjectModelBuilder } from './builders.js';\nimport { ArrayModel, EnumModel, ObjectModel, type UnionModel } from './core.js';\nimport {\n $defaultValue,\n $enum,\n $itemModel,\n $key,\n $members,\n $name,\n $optional,\n $owner,\n type AnyObject,\n type Target,\n type Enum,\n type Extensions,\n Model,\n nothing,\n type References,\n type Value,\n} from './model.js';\n\nexport * from './model.js';\nexport * from './core.js';\nexport type * from './builders.js';\n\nconst { defineProperty } = Object;\n\nconst arrayItemModels = new WeakMap<ArrayModel, Model[]>();\n\nfunction getRawValue<T>(model: Model<T>): T | typeof nothing {\n if (model[$owner] instanceof Model) {\n // If the current model is a property of another model, the owner is\n // definitely an object. So we just return the part of the value of\n // the owner.\n const parentValue = getRawValue(model[$owner] as Model<Record<keyof any, T>>);\n return parentValue === nothing ? nothing : parentValue[model[$key]];\n }\n\n // Otherwise, the owner is a Target, so we can return the full value.\n return (model[$owner] as Target<T>).value;\n}\n\n/**\n * The utility object that provides methods to create and manipulate models.\n */\nconst m = {\n /**\n * Attaches the given model to the target.\n *\n * @param model - The model to attach.\n * @param target - The target to attach the model to. It could be a Binder\n * instance, a Signal, or another object. However, it could never be another\n * model.\n */\n attach<M extends Model>(model: M, target: Target<Value<M>>): M {\n const _model = new CoreModelBuilder<Value<M>, Extensions<M>, { named: false; selfRefKeys: References<M> }>(model)\n .name(`@${model[$name]}`)\n .build();\n defineProperty(_model, $owner, { value: target });\n defineProperty(target, 'model', { enumerable: true, configurable: true, value: model });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return _model as any;\n },\n\n /**\n * Creates a new model that extends the given base model.\n *\n * @param base - The base model to extend.\n */\n extend<M extends Model<AnyObject>>(\n base: M,\n ): ObjectModelBuilder<Value<M>, Value<M>, Extensions<M>, { named: false; selfRefKeys: References<M> }> {\n return new ObjectModelBuilder(base);\n },\n\n /**\n * Creates a new model that represents an optional value.\n *\n * @param base - The base model to extend.\n */\n optional<M extends Model>(base: M): M {\n return new CoreModelBuilder<Value<M>, Extensions<M>, { named: true; selfRefKeys: References<M> }>(base)\n .define($optional, { value: true })\n .build() as M;\n },\n\n /**\n * Creates a new model that represents an array of items.\n *\n * @param itemModel - The model of the items in the array.\n */\n array<M extends Model>(itemModel: M): ArrayModel<M> {\n return new CoreModelBuilder<Array<Value<M>>>(ArrayModel)\n .name(`Array<${itemModel[$name]}>`)\n .define($itemModel, { value: itemModel })\n .build();\n },\n\n /**\n * Creates a new model that represents an object.\n *\n * @param name - The name of the object.\n */\n object<T extends AnyObject>(\n name: string,\n ): ObjectModelBuilder<T, EmptyObject, EmptyObject, { named: true; selfRefKeys: never }> {\n return new ObjectModelBuilder(ObjectModel).name(name) as any;\n },\n\n /**\n * Creates a new model that represents an enum.\n *\n * @param obj - The enum object to represent.\n * @param name - The name of the model.\n */\n enum<T extends typeof Enum>(obj: T, name: string): EnumModel<T> {\n return new CoreModelBuilder<T[keyof T]>(EnumModel).define($enum, { value: obj }).name(name).build();\n },\n\n /**\n * Creates a new model that represents a union of the values of the given\n * models.\n *\n * @param members - The models to create the union from.\n */\n union<MM extends Model[]>(...members: MM): UnionModel<MM> {\n return new CoreModelBuilder(Model, () => members[0][$defaultValue] as Value<MM[number]>)\n .name(members.map((model) => model[$name]).join(' | '))\n .define($members, { value: members })\n .build();\n },\n\n /**\n * Iterates over the given array model yielding an item model for each item\n * the model value has.\n *\n * @param model - The array model to iterate over.\n */\n *items<V extends Model>(model: ArrayModel<V>): Generator<V, undefined, void> {\n const list = arrayItemModels.get(model) ?? [];\n arrayItemModels.set(model, list);\n const value = m.value(model);\n\n list.length = value.length;\n\n for (let i = 0; i < value.length; i++) {\n if (!list[i]) {\n list[i] = new CoreModelBuilder(model[$itemModel], () => value[i])\n .name(`${model[$itemModel][$name]}[${i}]`)\n .define($key, { value: i })\n .define($owner, { value: model })\n .build();\n }\n\n yield list[i] as V;\n }\n },\n\n /**\n * Provides the value the given model represents. For attached models it will\n * be the owner value or its part, for detached models it will be the default\n * value of the model.\n *\n * @param model - The model to get the value from.\n */\n value<T>(model: Model<T>): T {\n const value = getRawValue(model);\n\n // If the value is `nothing`, we return the default value of the model.\n return value === nothing ? model[$defaultValue] : value;\n },\n};\n\nexport default m;\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,kBAAkB,0BAA0B;AACrD,SAAS,YAAY,WAAW,mBAAoC;AACpE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAKA;AAAA,EACA;AAAA,OAGK;AAEP,cAAc;AACd,cAAc;AAGd,MAAM,EAAE,eAAe,IAAI;AAE3B,MAAM,kBAAkB,oBAAI,QAA6B;AAEzD,SAAS,YAAe,OAAqC;AAC3D,MAAI,MAAM,MAAM,aAAa,OAAO;AAIlC,UAAM,cAAc,YAAY,MAAM,MAAM,CAAgC;AAC5E,WAAO,gBAAgB,UAAU,UAAU,YAAY,MAAM,IAAI,CAAC;AAAA,EACpE;AAGA,SAAQ,MAAM,MAAM,EAAgB;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SAAS,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE,GAClG,QAAQ,CAAC;KACN,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1B,CAAC,GACF,QAAQ,CAAC;IACP;;OAEG;IACH,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC;IAElB;;;OAGG;IACH,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC;IAExB;;;OAGG;IACH,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,QAAQ,IAAI,MAAM,CAAC;CACpB,CAAC,CAAC;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,EAAE,SAAS,SAAS,GAAG,WAAW,EAAE,CAAC,SAAS,MAAM,GAAG,GAAG,KAAK,IAAI,CACrG,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KACnB,CAAC,CAAC;AAEP,eAAO,MAAM,KAAK,EAAE,KA+BlB,CAAC"}
|
package/model.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/model.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EmptyObject } from 'type-fest';\n\nexport interface JvmTypeRef {\n jvmType: string;\n genericArguments?: JvmTypeRef[];\n}\n\nexport type AnnotationValue = AnnotationValue[] | JvmTypeRef | boolean | number | string | undefined;\n\nexport interface Annotation {\n jvmType: string;\n arguments: Record<string, AnnotationValue>;\n}\n\n/**\n * The metadata of a model.\n */\nexport interface ModelMetadata {\n jvmType?: string;\n annotations?: Annotation[];\n}\n\n/**\n * The target to which a model is attached. It could be a Binder instance, a\n * Signal or another object. However, it could never be another model.\n */\nexport type Target<T = unknown> = Readonly<{\n model?: Model<T>;\n value: T;\n}>;\n\nexport const nothing = Symbol('nothing');\n\nconst detachedTarget: Target = Object.create(\n {\n toString: () => ':detached:',\n },\n {\n model: { value: undefined },\n value: { value: nothing },\n },\n);\n\nexport declare enum Enum {}\n\nexport type AnyObject = Readonly<Record<never, never>>; // {}\n\n/* eslint-disable tsdoc/syntax */\n/**\n * The symbol that represents the {@link Model[$key]} property.\n */\nexport const $key = Symbol('key');\n\n/**\n * The symbol that represents the {@link Model[$name]} property.\n */\nexport const $name = Symbol('name');\n\n/**\n * The symbol that represents the {@link Model[$owner]} property.\n */\nexport const $owner = Symbol('owner');\n\n/**\n * The symbol that represents the {@link Model[$meta]} property.\n */\nexport const $meta = Symbol('meta');\n\n/**\n * The symbol that represents the {@link Model[$optional]} property.\n */\nexport const $optional = Symbol('optional');\n\n/**\n * The symbol that represents the {@link Model[$value]} property.\n */\nexport const $defaultValue = Symbol('value');\n\n/**\n * The symbol that represents the {@link EnumModel[$enumerate]} property.\n */\nexport const $enum = Symbol('enumerate');\n\n/**\n * The symbol that represents the {@link UnionModel[$members]} property.\n */\nexport const $members = Symbol('members');\n\n/**\n * The symbol that represents the {@link ArrayModel[$itemModel]} property.\n */\nexport const $itemModel = Symbol('itemModel');\n\n/* eslint-enable tsdoc/syntax */\n\n/**\n * Extracts the value type the model represents.\n */\nexport type Value<M extends Model> = M extends Model<infer T> ? T : never;\n\n/**\n * Extracts the list of extra properties of the model.\n */\nexport type Extensions<M extends Model> = M extends Model<unknown, infer EX> ? EX : EmptyObject;\n\n/**\n * Extracts the list of self-referencing properties of the model.\n */\nexport type References<M extends Model> = M extends Model<unknown, AnyObject, infer R> ? R : never;\n\n/**\n * A model that represents a specific type of data.\n *\n * @typeParam V - The type of the data described by the model.\n * @typeParam EX - The extra properties of the model. It could be either a model\n * that represents a property of the object the current model describe, or a\n * model-specific metadata. It's recommended to use a symbol as a key for the\n * metadata property to avoid the potential naming conflicts with the described\n * object properties.\n * @typeParam R - The keys of the self-referencing properties of the model.\n *\n * @remarks\n * Since we know the full model definition only on this step, the `R` type\n * parameter is essential to describe a model with self-reference properties.\n */\nexport type Model<V = unknown, EX extends AnyObject = EmptyObject, R extends keyof any = never> = EX &\n Readonly<{\n [P in R]: Model<V, EX, R>;\n }> &\n Readonly<{\n /**\n * The key of the model in the owner model.\n */\n [$key]: keyof any;\n\n /**\n * The name of the model. For attached models, the name will be prefixed\n * with the `@` symbol.\n */\n [$name]: string;\n\n /**\n * The owner model of the model. For detached models, the owner will always\n * be a specific global object `detachedTarget`.\n */\n [$owner]: Model | Target;\n\n /**\n * The metadata of the model.\n */\n [$meta]?: ModelMetadata;\n\n /**\n * Whether the model is optional. It describes if the data described by\n * this model is nullable.\n */\n [$optional]: boolean;\n\n /**\n * The default value of the model.\n */\n [$defaultValue]: V;\n [Symbol.toStringTag]: string;\n [Symbol.hasInstance](value: any): value is Model<V, EX, R>;\n toString(): string;\n }>;\n\n/**\n * A function that provides a default value for a model.\n *\n * @typeParam V - The type of the data described by the model.\n * @typeParam EX - The extra properties of the model.\n * @typeParam R - The keys of the self-referencing properties of the model.\n */\nexport type DefaultValueProvider<V, EX extends AnyObject = EmptyObject, R extends keyof any = never> = (\n model: Model<V, EX, R>,\n) => V;\n\nexport const Model: Model = Object.create(null, {\n [$key]: {\n value: 'model',\n },\n [$name]: {\n value: 'Model',\n },\n [$owner]: {\n value: detachedTarget,\n },\n [$meta]: {},\n [$optional]: {\n value: false,\n },\n [$defaultValue]: {},\n [Symbol.toStringTag]: {\n get(this: Model) {\n return this[$name];\n },\n },\n [Symbol.hasInstance]: {\n value(this: Model, o: unknown) {\n return typeof o === 'object' && o != null && (this === o || Object.prototype.isPrototypeOf.call(this, o));\n },\n },\n toString: {\n value(this: Model) {\n return `[${String(this[$owner])} / ${String(this[$key])}${this[$optional] ? '?' : ''}] ${this[$name]}`;\n },\n },\n});\n"],
|
|
5
|
-
"mappings": "AA+BO,MAAM,UAAU,OAAO,SAAS;AAEvC,MAAM,iBAAyB,OAAO;AAAA,EACpC;AAAA,IACE,UAAU,MAAM;AAAA,EAClB;AAAA,EACA;AAAA,IACE,OAAO,EAAE,OAAO,OAAU;AAAA,IAC1B,OAAO,EAAE,OAAO,QAAQ;AAAA,EAC1B;AACF;AAUO,MAAM,OAAO,OAAO,KAAK;AAKzB,MAAM,QAAQ,OAAO,MAAM;AAK3B,MAAM,SAAS,OAAO,OAAO;AAK7B,MAAM,QAAQ,OAAO,MAAM;AAK3B,MAAM,YAAY,OAAO,UAAU;AAKnC,MAAM,gBAAgB,OAAO,OAAO;AAKpC,MAAM,QAAQ,OAAO,WAAW;AAKhC,MAAM,WAAW,OAAO,SAAS;AAKjC,MAAM,aAAa,OAAO,WAAW;AAuFrC,MAAM,QAAe,OAAO,OAAO,MAAM;AAAA,EAC9C,CAAC,IAAI,GAAG;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA,CAAC,KAAK,GAAG;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,CAAC,MAAM,GAAG;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,CAAC,KAAK,GAAG,CAAC;AAAA,EACV,CAAC,SAAS,GAAG;AAAA,IACX,OAAO;AAAA,EACT;AAAA,EACA,CAAC,aAAa,GAAG,CAAC;AAAA,EAClB,CAAC,OAAO,WAAW,GAAG;AAAA,IACpB,MAAiB;AACf,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AAAA,EACA,CAAC,OAAO,WAAW,GAAG;AAAA,IACpB,MAAmB,GAAY;AAC7B,aAAO,OAAO,MAAM,YAAY,KAAK,SAAS,SAAS,KAAK,OAAO,UAAU,cAAc,KAAK,MAAM,CAAC;AAAA,IACzG;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR,QAAmB;
|
|
4
|
+
"sourcesContent": ["import type { EmptyObject } from 'type-fest';\n\nexport interface JvmTypeRef {\n jvmType: string;\n genericArguments?: JvmTypeRef[];\n}\n\nexport type AnnotationValue = AnnotationValue[] | JvmTypeRef | boolean | number | string | undefined;\n\nexport interface Annotation {\n jvmType: string;\n arguments: Record<string, AnnotationValue>;\n}\n\n/**\n * The metadata of a model.\n */\nexport interface ModelMetadata {\n jvmType?: string;\n annotations?: Annotation[];\n}\n\n/**\n * The target to which a model is attached. It could be a Binder instance, a\n * Signal or another object. However, it could never be another model.\n */\nexport type Target<T = unknown> = Readonly<{\n model?: Model<T>;\n value: T;\n}>;\n\nexport const nothing = Symbol('nothing');\n\nconst detachedTarget: Target = Object.create(\n {\n toString: () => ':detached:',\n },\n {\n model: { value: undefined },\n value: { value: nothing },\n },\n);\n\nexport declare enum Enum {}\n\nexport type AnyObject = Readonly<Record<never, never>>; // {}\n\n/* eslint-disable tsdoc/syntax */\n/**\n * The symbol that represents the {@link Model[$key]} property.\n */\nexport const $key = Symbol('key');\n\n/**\n * The symbol that represents the {@link Model[$name]} property.\n */\nexport const $name = Symbol('name');\n\n/**\n * The symbol that represents the {@link Model[$owner]} property.\n */\nexport const $owner = Symbol('owner');\n\n/**\n * The symbol that represents the {@link Model[$meta]} property.\n */\nexport const $meta = Symbol('meta');\n\n/**\n * The symbol that represents the {@link Model[$optional]} property.\n */\nexport const $optional = Symbol('optional');\n\n/**\n * The symbol that represents the {@link Model[$value]} property.\n */\nexport const $defaultValue = Symbol('value');\n\n/**\n * The symbol that represents the {@link EnumModel[$enumerate]} property.\n */\nexport const $enum = Symbol('enumerate');\n\n/**\n * The symbol that represents the {@link UnionModel[$members]} property.\n */\nexport const $members = Symbol('members');\n\n/**\n * The symbol that represents the {@link ArrayModel[$itemModel]} property.\n */\nexport const $itemModel = Symbol('itemModel');\n\n/* eslint-enable tsdoc/syntax */\n\n/**\n * Extracts the value type the model represents.\n */\nexport type Value<M extends Model> = M extends Model<infer T> ? T : never;\n\n/**\n * Extracts the list of extra properties of the model.\n */\nexport type Extensions<M extends Model> = M extends Model<unknown, infer EX> ? EX : EmptyObject;\n\n/**\n * Extracts the list of self-referencing properties of the model.\n */\nexport type References<M extends Model> = M extends Model<unknown, AnyObject, infer R> ? R : never;\n\n/**\n * A model that represents a specific type of data.\n *\n * @typeParam V - The type of the data described by the model.\n * @typeParam EX - The extra properties of the model. It could be either a model\n * that represents a property of the object the current model describe, or a\n * model-specific metadata. It's recommended to use a symbol as a key for the\n * metadata property to avoid the potential naming conflicts with the described\n * object properties.\n * @typeParam R - The keys of the self-referencing properties of the model.\n *\n * @remarks\n * Since we know the full model definition only on this step, the `R` type\n * parameter is essential to describe a model with self-reference properties.\n */\nexport type Model<V = unknown, EX extends AnyObject = EmptyObject, R extends keyof any = never> = EX &\n Readonly<{\n [P in R]: Model<V, EX, R>;\n }> &\n Readonly<{\n /**\n * The key of the model in the owner model.\n */\n [$key]: keyof any;\n\n /**\n * The name of the model. For attached models, the name will be prefixed\n * with the `@` symbol.\n */\n [$name]: string;\n\n /**\n * The owner model of the model. For detached models, the owner will always\n * be a specific global object `detachedTarget`.\n */\n [$owner]: Model | Target;\n\n /**\n * The metadata of the model.\n */\n [$meta]?: ModelMetadata;\n\n /**\n * Whether the model is optional. It describes if the data described by\n * this model is nullable.\n */\n [$optional]: boolean;\n\n /**\n * The default value of the model.\n */\n [$defaultValue]: V;\n [Symbol.toStringTag]: string;\n [Symbol.hasInstance](value: any): value is Model<V, EX, R>;\n toString(): string;\n }>;\n\n/**\n * A function that provides a default value for a model.\n *\n * @typeParam V - The type of the data described by the model.\n * @typeParam EX - The extra properties of the model.\n * @typeParam R - The keys of the self-referencing properties of the model.\n */\nexport type DefaultValueProvider<V, EX extends AnyObject = EmptyObject, R extends keyof any = never> = (\n model: Model<V, EX, R>,\n) => V;\n\nexport const Model: Model = Object.create(null, {\n [$key]: {\n value: 'model',\n },\n [$name]: {\n value: 'Model',\n },\n [$owner]: {\n value: detachedTarget,\n },\n [$meta]: {},\n [$optional]: {\n value: false,\n },\n [$defaultValue]: {},\n [Symbol.toStringTag]: {\n get(this: Model) {\n return this[$name];\n },\n },\n [Symbol.hasInstance]: {\n value(this: Model, o: unknown) {\n return typeof o === 'object' && o != null && (this === o || Object.prototype.isPrototypeOf.call(this, o));\n },\n },\n toString: {\n value(this: Model) {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return `[${String(this[$owner])} / ${String(this[$key])}${this[$optional] ? '?' : ''}] ${this[$name]}`;\n },\n },\n});\n"],
|
|
5
|
+
"mappings": "AA+BO,MAAM,UAAU,OAAO,SAAS;AAEvC,MAAM,iBAAyB,OAAO;AAAA,EACpC;AAAA,IACE,UAAU,MAAM;AAAA,EAClB;AAAA,EACA;AAAA,IACE,OAAO,EAAE,OAAO,OAAU;AAAA,IAC1B,OAAO,EAAE,OAAO,QAAQ;AAAA,EAC1B;AACF;AAUO,MAAM,OAAO,OAAO,KAAK;AAKzB,MAAM,QAAQ,OAAO,MAAM;AAK3B,MAAM,SAAS,OAAO,OAAO;AAK7B,MAAM,QAAQ,OAAO,MAAM;AAK3B,MAAM,YAAY,OAAO,UAAU;AAKnC,MAAM,gBAAgB,OAAO,OAAO;AAKpC,MAAM,QAAQ,OAAO,WAAW;AAKhC,MAAM,WAAW,OAAO,SAAS;AAKjC,MAAM,aAAa,OAAO,WAAW;AAuFrC,MAAM,QAAe,OAAO,OAAO,MAAM;AAAA,EAC9C,CAAC,IAAI,GAAG;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA,CAAC,KAAK,GAAG;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,CAAC,MAAM,GAAG;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,CAAC,KAAK,GAAG,CAAC;AAAA,EACV,CAAC,SAAS,GAAG;AAAA,IACX,OAAO;AAAA,EACT;AAAA,EACA,CAAC,aAAa,GAAG,CAAC;AAAA,EAClB,CAAC,OAAO,WAAW,GAAG;AAAA,IACpB,MAAiB;AACf,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AAAA,EACA,CAAC,OAAO,WAAW,GAAG;AAAA,IACpB,MAAmB,GAAY;AAC7B,aAAO,OAAO,MAAM,YAAY,KAAK,SAAS,SAAS,KAAK,OAAO,UAAU,cAAc,KAAK,MAAM,CAAC;AAAA,IACzG;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR,QAAmB;AAEjB,aAAO,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,EAAE,KAAK,KAAK,KAAK,CAAC;AAAA,IACtG;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-models",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha10",
|
|
4
4
|
"description": "Generative form models for Hilla",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"build:copy": "cd src && copyfiles **/*.d.ts ..",
|
|
24
24
|
"lint": "eslint src test",
|
|
25
25
|
"lint:fix": "eslint src test --fix",
|
|
26
|
-
"test": "
|
|
27
|
-
"test:coverage": "
|
|
28
|
-
"test:watch": "
|
|
26
|
+
"test": "vitest --run",
|
|
27
|
+
"test:coverage": "vitest --run --coverage",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
@@ -46,36 +46,10 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vaadin/hilla-lit-form": "24.
|
|
49
|
+
"@vaadin/hilla-lit-form": "24.7.0-alpha10"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@testing-library/react": "^16.1.0",
|
|
57
|
-
"@testing-library/user-event": "^14.5.2",
|
|
58
|
-
"@types/chai": "^4.3.6",
|
|
59
|
-
"@types/chai-as-promised": "^7.1.8",
|
|
60
|
-
"@types/chai-dom": "^1.11.1",
|
|
61
|
-
"@types/chai-like": "^1.1.3",
|
|
62
|
-
"@types/mocha": "^10.0.2",
|
|
63
|
-
"@types/node": "^20.14.2",
|
|
64
|
-
"@types/react": "^18.3.17",
|
|
65
|
-
"@types/react-dom": "^18",
|
|
66
|
-
"@types/sinon": "^10.0.20",
|
|
67
|
-
"@types/sinon-chai": "^3.2.12",
|
|
68
|
-
"@types/validator": "^13.12.2",
|
|
69
|
-
"c8": "^10.1.3",
|
|
70
|
-
"chai": "^5.1.2",
|
|
71
|
-
"chai-as-promised": "^7.1.2",
|
|
72
|
-
"chai-dom": "^1.12.0",
|
|
73
|
-
"chai-like": "^1.1.3",
|
|
74
|
-
"glob": "^10.4.5",
|
|
75
|
-
"mocha": "^10.8.2",
|
|
76
|
-
"monocart-coverage-reports": "^2.11.4",
|
|
77
|
-
"sinon": "^16.1.3",
|
|
78
|
-
"sinon-chai": "^3.7.0",
|
|
79
|
-
"typescript": "5.7.2"
|
|
52
|
+
"react": "18 || 19",
|
|
53
|
+
"react-dom": "18 || 19"
|
|
80
54
|
}
|
|
81
55
|
}
|