@itrocks/framework 0.3.5 → 0.3.6

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.
@@ -1,9 +1,10 @@
1
1
  import { PropertyTypes } from '@itrocks/property-type';
2
2
  import { ReflectClass as RC } from '@itrocks/reflect';
3
+ import { ReflectProperty } from './reflect-property';
3
4
  export declare class ReflectClass<T extends object = object> extends RC<T> {
4
5
  inheritPropertyTypes(propertyTypes: PropertyTypes<T>): void;
5
- get parent(): any;
6
- get properties(): import("@itrocks/reflect").ReflectProperty<T, keyof T>[];
7
- get property(): { [K in keyof T]: import("@itrocks/reflect").ReflectProperty<T, K>; };
6
+ get parent(): ReflectClass | null;
7
+ get properties(): ReflectProperty<T, keyof T>[];
8
+ get property(): { [K in keyof T]: ReflectProperty<T, K>; };
8
9
  get uses(): import("@itrocks/class-type").Type[];
9
10
  }
@@ -12,24 +12,23 @@ class ReflectClass extends reflect_1.ReflectClass {
12
12
  }
13
13
  }
14
14
  get parent() {
15
- const parent = super.parent
16
- ? Object.defineProperties(Object.create(ReflectClass.prototype), Object.getOwnPropertyDescriptors(super.parent))
17
- : super.parent;
15
+ const parentType = Object.getPrototypeOf(this.type);
16
+ const parent = (parentType === Function.prototype) ? null : new ReflectClass(parentType);
18
17
  Object.defineProperty(this, 'parent', { configurable: true, enumerable: false, value: parent, writable: true });
19
18
  return parent;
20
19
  }
21
20
  get properties() {
22
- const properties = super.properties;
23
- for (const reflectProperty of properties) {
24
- Object.defineProperties(Object.create(reflect_property_1.ReflectProperty.prototype), Object.getOwnPropertyDescriptors(reflectProperty));
21
+ const properties = new Array;
22
+ for (const name of this.propertyNames) {
23
+ properties.push(new reflect_property_1.ReflectProperty(this, name));
25
24
  }
26
25
  Object.defineProperty(this, 'properties', { configurable: true, enumerable: false, value: properties, writable: true });
27
26
  return properties;
28
27
  }
29
28
  get property() {
30
- const properties = super.property;
31
- for (const entry of Object.entries(properties)) {
32
- properties[entry[0]] = Object.defineProperties(Object.create(reflect_property_1.ReflectProperty.prototype), Object.getOwnPropertyDescriptors(entry[1]));
29
+ const properties = {};
30
+ for (const property of this.properties) {
31
+ properties[property.name] = property;
33
32
  }
34
33
  Object.defineProperty(this, 'property', { configurable: true, enumerable: false, value: properties, writable: true });
35
34
  return properties;
@@ -1,7 +1,8 @@
1
1
  import { HtmlContainer } from '@itrocks/core-transformers';
2
2
  import { ReflectProperty as RP } from '@itrocks/reflect';
3
- export declare class ReflectProperty<T extends object> extends RP<T> {
4
- get class(): any;
3
+ import { ReflectClass } from './reflect-class';
4
+ export declare class ReflectProperty<T extends object, K extends keyof T = keyof T> extends RP<T, K> {
5
+ get class(): ReflectClass<T>;
5
6
  edit(format?: string): Promise<any>;
6
7
  output(format?: string, askFor?: HtmlContainer): Promise<any>;
7
8
  outputMandatoryContainer(format?: string): Promise<any>;
@@ -8,7 +8,9 @@ const transformer_2 = require("@itrocks/transformer");
8
8
  const reflect_class_1 = require("./reflect-class");
9
9
  class ReflectProperty extends reflect_1.ReflectProperty {
10
10
  get class() {
11
- return Object.setPrototypeOf(super.class, reflect_class_1.ReflectClass.prototype);
11
+ const value = super.class;
12
+ Object.defineProperty(this, 'class', { configurable: true, enumerable: false, value, writable: true });
13
+ return value ? new reflect_class_1.ReflectClass(value.object ?? value.type) : value;
12
14
  }
13
15
  async edit(format = transformer_2.HTML) {
14
16
  const object = this.object ?? this.class.type;
package/package.json CHANGED
@@ -96,5 +96,5 @@
96
96
  "build:front": "tsc -p src/front/tsconfig.json && sed -i 's#../../##g' *.js *.d.ts"
97
97
  },
98
98
  "types": "./cjs/framework.d.ts",
99
- "version": "0.3.5"
99
+ "version": "0.3.6"
100
100
  }