@bemoje/composition 2.1.0 → 2.1.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.
Files changed (57) hide show
  1. package/package.json +83 -149
  2. package/lib/IView.cjs +0 -2
  3. package/lib/IView.d.cts +0 -12
  4. package/lib/IView.d.ts +0 -12
  5. package/lib/IView.js +0 -1
  6. package/lib/OptionsConfigurator.cjs +0 -166
  7. package/lib/OptionsConfigurator.d.cts +0 -2229
  8. package/lib/OptionsConfigurator.d.ts +0 -2229
  9. package/lib/OptionsConfigurator.js +0 -163
  10. package/lib/View.cjs +0 -22
  11. package/lib/View.d.cts +0 -14
  12. package/lib/View.d.ts +0 -14
  13. package/lib/View.js +0 -20
  14. package/lib/inheritProxifiedPrototype.cjs +0 -19
  15. package/lib/inheritProxifiedPrototype.d.cts +0 -11
  16. package/lib/inheritProxifiedPrototype.d.ts +0 -11
  17. package/lib/inheritProxifiedPrototype.js +0 -16
  18. package/lib/inheritProxifiedPrototypeProperty.cjs +0 -45
  19. package/lib/inheritProxifiedPrototypeProperty.d.cts +0 -9
  20. package/lib/inheritProxifiedPrototypeProperty.d.ts +0 -9
  21. package/lib/inheritProxifiedPrototypeProperty.js +0 -43
  22. package/lib/inspector/Inspector.cjs +0 -227
  23. package/lib/inspector/Inspector.d.cts +0 -4
  24. package/lib/inspector/Inspector.d.ts +0 -4
  25. package/lib/inspector/Inspector.js +0 -220
  26. package/lib/inspector/defaults/ignoreValuesDefaults.cjs +0 -11
  27. package/lib/inspector/defaults/ignoreValuesDefaults.d.cts +0 -11
  28. package/lib/inspector/defaults/ignoreValuesDefaults.d.ts +0 -11
  29. package/lib/inspector/defaults/ignoreValuesDefaults.js +0 -11
  30. package/lib/inspector/defaults/ignoreValuesFilterDefaults.cjs +0 -23
  31. package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts +0 -11
  32. package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts +0 -11
  33. package/lib/inspector/defaults/ignoreValuesFilterDefaults.js +0 -21
  34. package/lib/inspector/defaults/inspectDefaults.cjs +0 -17
  35. package/lib/inspector/defaults/inspectDefaults.d.cts +0 -8
  36. package/lib/inspector/defaults/inspectDefaults.d.ts +0 -8
  37. package/lib/inspector/defaults/inspectDefaults.js +0 -16
  38. package/lib/inspector/defaults/inspectorDefaults.cjs +0 -15
  39. package/lib/inspector/defaults/inspectorDefaults.d.cts +0 -11
  40. package/lib/inspector/defaults/inspectorDefaults.d.ts +0 -11
  41. package/lib/inspector/defaults/inspectorDefaults.js +0 -14
  42. package/lib/inspector/types.cjs +0 -2
  43. package/lib/inspector/types.d.cts +0 -4
  44. package/lib/inspector/types.d.ts +0 -4
  45. package/lib/inspector/types.js +0 -1
  46. package/lib/parenting/ParentRelationTypes.cjs +0 -130
  47. package/lib/parenting/ParentRelationTypes.d.cts +0 -4
  48. package/lib/parenting/ParentRelationTypes.d.ts +0 -4
  49. package/lib/parenting/ParentRelationTypes.js +0 -123
  50. package/lib/parenting/Parenting.cjs +0 -88
  51. package/lib/parenting/Parenting.d.cts +0 -4
  52. package/lib/parenting/Parenting.d.ts +0 -4
  53. package/lib/parenting/Parenting.js +0 -85
  54. package/lib/parenting/types.cjs +0 -2
  55. package/lib/parenting/types.d.cts +0 -4
  56. package/lib/parenting/types.d.ts +0 -4
  57. package/lib/parenting/types.js +0 -1
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@bemoje/composition",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "Class composition utilities for views, proxy-based inheritance, object inspection, and parent-child relationships.",
5
+ "type": "module",
6
+ "sideEffects": false,
5
7
  "keywords": [
6
8
  "composition",
7
9
  "class",
@@ -13,20 +15,15 @@
13
15
  "utilities",
14
16
  "typescript"
15
17
  ],
16
- "dependencies": {
17
- "@sinclair/typebox": "^0.34.48",
18
- "ansi-colors": "^4.1.3",
19
- "es-toolkit": "^1.45.1",
20
- "mnemonist": "^0.40.3"
21
- },
22
- "type": "module",
23
- "sideEffects": false,
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
18
  "main": "./lib/index.cjs",
28
19
  "module": "./lib/index.js",
29
20
  "types": "./lib/index.d.ts",
21
+ "files": [
22
+ "./lib/index.js",
23
+ "./lib/index.d.ts",
24
+ "./lib/index.cjs",
25
+ "./lib/index.d.cts"
26
+ ],
30
27
  "exports": {
31
28
  ".": {
32
29
  "import": {
@@ -40,216 +37,153 @@
40
37
  },
41
38
  "./IView": {
42
39
  "import": {
43
- "types": "./lib/IView.d.ts",
44
- "default": "./lib/IView.js"
40
+ "types": "./lib/index.d.ts",
41
+ "default": "./lib/index.js"
45
42
  },
46
43
  "require": {
47
- "types": "./lib/IView.d.cts",
48
- "default": "./lib/IView.cjs"
44
+ "types": "./lib/index.d.cts",
45
+ "default": "./lib/index.cjs"
49
46
  }
50
47
  },
51
48
  "./OptionsConfigurator": {
52
49
  "import": {
53
- "types": "./lib/OptionsConfigurator.d.ts",
54
- "default": "./lib/OptionsConfigurator.js"
50
+ "types": "./lib/index.d.ts",
51
+ "default": "./lib/index.js"
55
52
  },
56
53
  "require": {
57
- "types": "./lib/OptionsConfigurator.d.cts",
58
- "default": "./lib/OptionsConfigurator.cjs"
54
+ "types": "./lib/index.d.cts",
55
+ "default": "./lib/index.cjs"
59
56
  }
60
57
  },
61
58
  "./View": {
62
59
  "import": {
63
- "types": "./lib/View.d.ts",
64
- "default": "./lib/View.js"
60
+ "types": "./lib/index.d.ts",
61
+ "default": "./lib/index.js"
65
62
  },
66
63
  "require": {
67
- "types": "./lib/View.d.cts",
68
- "default": "./lib/View.cjs"
64
+ "types": "./lib/index.d.cts",
65
+ "default": "./lib/index.cjs"
69
66
  }
70
67
  },
71
68
  "./inheritProxifiedPrototype": {
72
69
  "import": {
73
- "types": "./lib/inheritProxifiedPrototype.d.ts",
74
- "default": "./lib/inheritProxifiedPrototype.js"
70
+ "types": "./lib/index.d.ts",
71
+ "default": "./lib/index.js"
75
72
  },
76
73
  "require": {
77
- "types": "./lib/inheritProxifiedPrototype.d.cts",
78
- "default": "./lib/inheritProxifiedPrototype.cjs"
74
+ "types": "./lib/index.d.cts",
75
+ "default": "./lib/index.cjs"
79
76
  }
80
77
  },
81
78
  "./inheritProxifiedPrototypeProperty": {
82
79
  "import": {
83
- "types": "./lib/inheritProxifiedPrototypeProperty.d.ts",
84
- "default": "./lib/inheritProxifiedPrototypeProperty.js"
85
- },
86
- "require": {
87
- "types": "./lib/inheritProxifiedPrototypeProperty.d.cts",
88
- "default": "./lib/inheritProxifiedPrototypeProperty.cjs"
89
- }
90
- },
91
- "./inspector/Inspector": {
92
- "import": {
93
- "types": "./lib/inspector/Inspector.d.ts",
94
- "default": "./lib/inspector/Inspector.js"
80
+ "types": "./lib/index.d.ts",
81
+ "default": "./lib/index.js"
95
82
  },
96
83
  "require": {
97
- "types": "./lib/inspector/Inspector.d.cts",
98
- "default": "./lib/inspector/Inspector.cjs"
84
+ "types": "./lib/index.d.cts",
85
+ "default": "./lib/index.cjs"
99
86
  }
100
87
  },
101
- "./inspector/defaults/ignoreValuesDefaults": {
88
+ "./Inspector": {
102
89
  "import": {
103
- "types": "./lib/inspector/defaults/ignoreValuesDefaults.d.ts",
104
- "default": "./lib/inspector/defaults/ignoreValuesDefaults.js"
90
+ "types": "./lib/index.d.ts",
91
+ "default": "./lib/index.js"
105
92
  },
106
93
  "require": {
107
- "types": "./lib/inspector/defaults/ignoreValuesDefaults.d.cts",
108
- "default": "./lib/inspector/defaults/ignoreValuesDefaults.cjs"
94
+ "types": "./lib/index.d.cts",
95
+ "default": "./lib/index.cjs"
109
96
  }
110
97
  },
111
- "./inspector/defaults/ignoreValuesFilterDefaults": {
98
+ "./ignoreValuesDefaults": {
112
99
  "import": {
113
- "types": "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts",
114
- "default": "./lib/inspector/defaults/ignoreValuesFilterDefaults.js"
100
+ "types": "./lib/index.d.ts",
101
+ "default": "./lib/index.js"
115
102
  },
116
103
  "require": {
117
- "types": "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts",
118
- "default": "./lib/inspector/defaults/ignoreValuesFilterDefaults.cjs"
104
+ "types": "./lib/index.d.cts",
105
+ "default": "./lib/index.cjs"
119
106
  }
120
107
  },
121
- "./inspector/defaults/inspectDefaults": {
108
+ "./ignoreValuesFilterDefaults": {
122
109
  "import": {
123
- "types": "./lib/inspector/defaults/inspectDefaults.d.ts",
124
- "default": "./lib/inspector/defaults/inspectDefaults.js"
110
+ "types": "./lib/index.d.ts",
111
+ "default": "./lib/index.js"
125
112
  },
126
113
  "require": {
127
- "types": "./lib/inspector/defaults/inspectDefaults.d.cts",
128
- "default": "./lib/inspector/defaults/inspectDefaults.cjs"
114
+ "types": "./lib/index.d.cts",
115
+ "default": "./lib/index.cjs"
129
116
  }
130
117
  },
131
- "./inspector/defaults/inspectorDefaults": {
118
+ "./inspectDefaults": {
132
119
  "import": {
133
- "types": "./lib/inspector/defaults/inspectorDefaults.d.ts",
134
- "default": "./lib/inspector/defaults/inspectorDefaults.js"
120
+ "types": "./lib/index.d.ts",
121
+ "default": "./lib/index.js"
135
122
  },
136
123
  "require": {
137
- "types": "./lib/inspector/defaults/inspectorDefaults.d.cts",
138
- "default": "./lib/inspector/defaults/inspectorDefaults.cjs"
124
+ "types": "./lib/index.d.cts",
125
+ "default": "./lib/index.cjs"
139
126
  }
140
127
  },
141
- "./inspector/types": {
128
+ "./inspectorDefaults": {
142
129
  "import": {
143
- "types": "./lib/inspector/types.d.ts",
144
- "default": "./lib/inspector/types.js"
130
+ "types": "./lib/index.d.ts",
131
+ "default": "./lib/index.js"
145
132
  },
146
133
  "require": {
147
- "types": "./lib/inspector/types.d.cts",
148
- "default": "./lib/inspector/types.cjs"
134
+ "types": "./lib/index.d.cts",
135
+ "default": "./lib/index.cjs"
149
136
  }
150
137
  },
151
- "./parenting/ParentRelationTypes": {
138
+ "./types": {
152
139
  "import": {
153
- "types": "./lib/parenting/ParentRelationTypes.d.ts",
154
- "default": "./lib/parenting/ParentRelationTypes.js"
140
+ "types": "./lib/index.d.ts",
141
+ "default": "./lib/index.js"
155
142
  },
156
143
  "require": {
157
- "types": "./lib/parenting/ParentRelationTypes.d.cts",
158
- "default": "./lib/parenting/ParentRelationTypes.cjs"
144
+ "types": "./lib/index.d.cts",
145
+ "default": "./lib/index.cjs"
159
146
  }
160
147
  },
161
- "./parenting/Parenting": {
148
+ "./ParentRelationTypes": {
162
149
  "import": {
163
- "types": "./lib/parenting/Parenting.d.ts",
164
- "default": "./lib/parenting/Parenting.js"
150
+ "types": "./lib/index.d.ts",
151
+ "default": "./lib/index.js"
165
152
  },
166
153
  "require": {
167
- "types": "./lib/parenting/Parenting.d.cts",
168
- "default": "./lib/parenting/Parenting.cjs"
154
+ "types": "./lib/index.d.cts",
155
+ "default": "./lib/index.cjs"
169
156
  }
170
157
  },
171
- "./parenting/types": {
158
+ "./Parenting": {
172
159
  "import": {
173
- "types": "./lib/parenting/types.d.ts",
174
- "default": "./lib/parenting/types.js"
160
+ "types": "./lib/index.d.ts",
161
+ "default": "./lib/index.js"
175
162
  },
176
163
  "require": {
177
- "types": "./lib/parenting/types.d.cts",
178
- "default": "./lib/parenting/types.cjs"
164
+ "types": "./lib/index.d.cts",
165
+ "default": "./lib/index.cjs"
179
166
  }
180
167
  }
181
168
  },
182
- "files": [
183
- "./lib/index.js",
184
- "./lib/index.d.ts",
185
- "./lib/index.cjs",
186
- "./lib/index.d.cts",
187
- "./lib/IView.js",
188
- "./lib/IView.d.ts",
189
- "./lib/IView.cjs",
190
- "./lib/IView.d.cts",
191
- "./lib/OptionsConfigurator.js",
192
- "./lib/OptionsConfigurator.d.ts",
193
- "./lib/OptionsConfigurator.cjs",
194
- "./lib/OptionsConfigurator.d.cts",
195
- "./lib/View.js",
196
- "./lib/View.d.ts",
197
- "./lib/View.cjs",
198
- "./lib/View.d.cts",
199
- "./lib/inheritProxifiedPrototype.js",
200
- "./lib/inheritProxifiedPrototype.d.ts",
201
- "./lib/inheritProxifiedPrototype.cjs",
202
- "./lib/inheritProxifiedPrototype.d.cts",
203
- "./lib/inheritProxifiedPrototypeProperty.js",
204
- "./lib/inheritProxifiedPrototypeProperty.d.ts",
205
- "./lib/inheritProxifiedPrototypeProperty.cjs",
206
- "./lib/inheritProxifiedPrototypeProperty.d.cts",
207
- "./lib/inspector/Inspector.js",
208
- "./lib/inspector/Inspector.d.ts",
209
- "./lib/inspector/Inspector.cjs",
210
- "./lib/inspector/Inspector.d.cts",
211
- "./lib/inspector/defaults/ignoreValuesDefaults.js",
212
- "./lib/inspector/defaults/ignoreValuesDefaults.d.ts",
213
- "./lib/inspector/defaults/ignoreValuesDefaults.cjs",
214
- "./lib/inspector/defaults/ignoreValuesDefaults.d.cts",
215
- "./lib/inspector/defaults/ignoreValuesFilterDefaults.js",
216
- "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts",
217
- "./lib/inspector/defaults/ignoreValuesFilterDefaults.cjs",
218
- "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts",
219
- "./lib/inspector/defaults/inspectDefaults.js",
220
- "./lib/inspector/defaults/inspectDefaults.d.ts",
221
- "./lib/inspector/defaults/inspectDefaults.cjs",
222
- "./lib/inspector/defaults/inspectDefaults.d.cts",
223
- "./lib/inspector/defaults/inspectorDefaults.js",
224
- "./lib/inspector/defaults/inspectorDefaults.d.ts",
225
- "./lib/inspector/defaults/inspectorDefaults.cjs",
226
- "./lib/inspector/defaults/inspectorDefaults.d.cts",
227
- "./lib/inspector/types.js",
228
- "./lib/inspector/types.d.ts",
229
- "./lib/inspector/types.cjs",
230
- "./lib/inspector/types.d.cts",
231
- "./lib/parenting/ParentRelationTypes.js",
232
- "./lib/parenting/ParentRelationTypes.d.ts",
233
- "./lib/parenting/ParentRelationTypes.cjs",
234
- "./lib/parenting/ParentRelationTypes.d.cts",
235
- "./lib/parenting/Parenting.js",
236
- "./lib/parenting/Parenting.d.ts",
237
- "./lib/parenting/Parenting.cjs",
238
- "./lib/parenting/Parenting.d.cts",
239
- "./lib/parenting/types.js",
240
- "./lib/parenting/types.d.ts",
241
- "./lib/parenting/types.cjs",
242
- "./lib/parenting/types.d.cts"
243
- ],
244
- "repository": {
245
- "type": "git",
246
- "url": "git+https://github.com/bemoje/mono.git",
247
- "directory": "libs/composition"
169
+ "dependencies": {
170
+ "@sinclair/typebox": "^0.34.48",
171
+ "ansi-colors": "^4.1.3",
172
+ "es-toolkit": "^1.45.1",
173
+ "mnemonist": "^0.40.3"
174
+ },
175
+ "publishConfig": {
176
+ "access": "public"
248
177
  },
178
+ "license": "MIT",
249
179
  "author": {
250
180
  "name": "Benjamin Møller Jensen",
251
181
  "email": "bemoje@bemoje.net",
252
182
  "url": "https://github.com/bemoje/"
253
183
  },
254
- "license": "MIT"
184
+ "repository": {
185
+ "type": "git",
186
+ "url": "git+https://github.com/bemoje/mono.git",
187
+ "directory": "libs/composition"
188
+ }
255
189
  }
package/lib/IView.cjs DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
package/lib/IView.d.cts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Interface for a View that wraps a target object.
3
- * View methods are redirected to the wrapped object which acts as
4
- * a surrogate 'this'.
5
- *
6
- * To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
7
- */
8
- interface IView<T extends object> {
9
- readonly target: T;
10
- }
11
-
12
- export type { IView };
package/lib/IView.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Interface for a View that wraps a target object.
3
- * View methods are redirected to the wrapped object which acts as
4
- * a surrogate 'this'.
5
- *
6
- * To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
7
- */
8
- interface IView<T extends object> {
9
- readonly target: T;
10
- }
11
-
12
- export type { IView };
package/lib/IView.js DELETED
@@ -1 +0,0 @@
1
-
@@ -1,166 +0,0 @@
1
- 'use strict';
2
-
3
- var typebox = require('@sinclair/typebox');
4
- var value = require('@sinclair/typebox/value');
5
- var tschema = require('@mono/tschema');
6
- var object = require('@mono/object');
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- function OptionsConfigurator(schemaOrProps, defaultKeys) {
11
- const props = typebox.KindGuard.IsObject(schemaOrProps) ? schemaOrProps.properties : schemaOrProps;
12
- const schema = typebox.KindGuard.IsObject(schemaOrProps) ? schemaOrProps : typebox.Type.Object(props);
13
- const defaults = object.entriesOf(props).reduce((acc, [key, prop]) => {
14
- if ("default" in prop) {
15
- Reflect.set(acc, key, typeof prop.default === "function" ? prop.default : () => {
16
- return prop.default;
17
- });
18
- }
19
- return acc;
20
- }, {});
21
- const requiredKeys = schema.required;
22
- const optionalKeys = object.keysOf(props).filter((k) => {
23
- return !requiredKeys.includes(k);
24
- });
25
- const create = createConfigurator({
26
- defaults,
27
- requiredKeys,
28
- optionalKeys
29
- });
30
- const build = /* @__PURE__ */ __name((callback) => {
31
- const builder = create();
32
- const options = callback(builder);
33
- return options;
34
- }, "build");
35
- build.getSchemaProps = () => {
36
- return props;
37
- };
38
- build.getSchema = () => {
39
- return schema;
40
- };
41
- build.getDefaults = () => {
42
- return defaults;
43
- };
44
- build.getDefaultKeys = () => {
45
- return defaultKeys;
46
- };
47
- build.cast = (v) => {
48
- return v;
49
- };
50
- build.getCreate = () => {
51
- return create;
52
- };
53
- build.getBuild = () => {
54
- return build;
55
- };
56
- build.createFunction = (func) => {
57
- function fn(arg0) {
58
- const options = typeof arg0 === "function" ? build(arg0) : value.Value.Default(schema, arg0);
59
- tschema.assertValidSchema(schema, options, "Invalid options");
60
- return func(options);
61
- }
62
- __name(fn, "fn");
63
- if (func.name) {
64
- Object.defineProperty(fn, "name", {
65
- value: func.name,
66
- configurable: true
67
- });
68
- }
69
- Object.defineProperty(fn, "OptionsConfigurator", {
70
- get() {
71
- return build;
72
- },
73
- enumerable: true
74
- });
75
- return fn;
76
- };
77
- build.createBaseClass = () => {
78
- return class Base {
79
- static {
80
- __name(this, "Base");
81
- }
82
- static get OptionsConfigurator() {
83
- return build;
84
- }
85
- options;
86
- constructor(arg0) {
87
- this.options = typeof arg0 === "function" ? build(arg0) : value.Value.Default(schema, arg0);
88
- this.initialize();
89
- }
90
- /**
91
- * Called by the constructor
92
- */
93
- initialize() {
94
- this.assertValidOptions();
95
- }
96
- isValidOptions() {
97
- return value.Value.Check(schema, this.options);
98
- }
99
- assertValidOptions() {
100
- tschema.assertValidSchema(schema, this.options, "Invalid options");
101
- }
102
- };
103
- };
104
- return build;
105
- }
106
- __name(OptionsConfigurator, "OptionsConfigurator");
107
- function createConfigurator(options) {
108
- let CFG = class CFG {
109
- static {
110
- __name(this, "CFG");
111
- }
112
- $data;
113
- constructor($data) {
114
- this.$data = $data;
115
- }
116
- /**
117
- * Applies defaults for missing values and then returns data.
118
- */
119
- done() {
120
- this.applyDefaults();
121
- return this.$data;
122
- }
123
- /**
124
- * Set default values for missing keys.
125
- */
126
- applyDefaults() {
127
- object.entriesOf(options.defaults).forEach(([key, dfValue]) => {
128
- if (this.$data[key] === void 0) {
129
- const df = dfValue?.();
130
- if (df !== void 0) {
131
- this.$data[key] = df;
132
- }
133
- }
134
- });
135
- return this;
136
- }
137
- };
138
- const keys = /* @__PURE__ */ new Set([
139
- ...options.requiredKeys,
140
- ...object.keysOf(options.defaults),
141
- ...options.optionalKeys
142
- ]);
143
- for (const key of keys) {
144
- Object.defineProperty(CFG.prototype, key, {
145
- value: /* @__PURE__ */ __name(function(value) {
146
- if (value === void 0) {
147
- if (key in options.defaults) {
148
- this.$data[key] = options.defaults[key]();
149
- } else {
150
- delete this.$data[key];
151
- }
152
- } else {
153
- this.$data[key] = value;
154
- }
155
- return new CFG(this.$data);
156
- }, "value")
157
- });
158
- }
159
- return /* @__PURE__ */ __name(function configurator() {
160
- const ins = new CFG({});
161
- return ins;
162
- }, "configurator");
163
- }
164
- __name(createConfigurator, "createConfigurator");
165
-
166
- exports.OptionsConfigurator = OptionsConfigurator;