@bemoje/composition 2.1.2 → 2.1.5
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/README.md +19 -35
- package/lib/index.cjs +823 -101
- package/lib/index.d.cts +2429 -16
- package/lib/index.d.ts +2429 -16
- package/lib/index.js +809 -14
- package/package.json +23 -209
- package/lib/IView.cjs +0 -2
- package/lib/IView.d.cts +0 -12
- package/lib/IView.d.ts +0 -12
- package/lib/IView.js +0 -1
- package/lib/OptionsConfigurator.cjs +0 -166
- package/lib/OptionsConfigurator.d.cts +0 -2229
- package/lib/OptionsConfigurator.d.ts +0 -2229
- package/lib/OptionsConfigurator.js +0 -163
- package/lib/View.cjs +0 -22
- package/lib/View.d.cts +0 -14
- package/lib/View.d.ts +0 -14
- package/lib/View.js +0 -20
- package/lib/inheritProxifiedPrototype.cjs +0 -19
- package/lib/inheritProxifiedPrototype.d.cts +0 -11
- package/lib/inheritProxifiedPrototype.d.ts +0 -11
- package/lib/inheritProxifiedPrototype.js +0 -16
- package/lib/inheritProxifiedPrototypeProperty.cjs +0 -45
- package/lib/inheritProxifiedPrototypeProperty.d.cts +0 -9
- package/lib/inheritProxifiedPrototypeProperty.d.ts +0 -9
- package/lib/inheritProxifiedPrototypeProperty.js +0 -43
- package/lib/inspector/Inspector.cjs +0 -227
- package/lib/inspector/Inspector.d.cts +0 -4
- package/lib/inspector/Inspector.d.ts +0 -4
- package/lib/inspector/Inspector.js +0 -220
- package/lib/inspector/defaults/ignoreValuesDefaults.cjs +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.d.cts +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.d.ts +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.js +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.cjs +0 -23
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.js +0 -21
- package/lib/inspector/defaults/inspectDefaults.cjs +0 -17
- package/lib/inspector/defaults/inspectDefaults.d.cts +0 -8
- package/lib/inspector/defaults/inspectDefaults.d.ts +0 -8
- package/lib/inspector/defaults/inspectDefaults.js +0 -16
- package/lib/inspector/defaults/inspectorDefaults.cjs +0 -15
- package/lib/inspector/defaults/inspectorDefaults.d.cts +0 -11
- package/lib/inspector/defaults/inspectorDefaults.d.ts +0 -11
- package/lib/inspector/defaults/inspectorDefaults.js +0 -14
- package/lib/inspector/types.cjs +0 -2
- package/lib/inspector/types.d.cts +0 -4
- package/lib/inspector/types.d.ts +0 -4
- package/lib/inspector/types.js +0 -1
- package/lib/parenting/ParentRelationTypes.cjs +0 -130
- package/lib/parenting/ParentRelationTypes.d.cts +0 -4
- package/lib/parenting/ParentRelationTypes.d.ts +0 -4
- package/lib/parenting/ParentRelationTypes.js +0 -123
- package/lib/parenting/Parenting.cjs +0 -88
- package/lib/parenting/Parenting.d.cts +0 -4
- package/lib/parenting/Parenting.d.ts +0 -4
- package/lib/parenting/Parenting.js +0 -85
- package/lib/parenting/types.cjs +0 -2
- package/lib/parenting/types.d.cts +0 -4
- package/lib/parenting/types.d.ts +0 -4
- package/lib/parenting/types.js +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/composition",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Class composition utilities for views, proxy-based inheritance, object inspection, and parent-child relationships.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@sinclair/typebox": "^0.34.48",
|
|
12
|
+
"ansi-colors": "^4.1.3",
|
|
13
|
+
"es-toolkit": "^1.45.1",
|
|
14
|
+
"mnemonist": "^0.40.3"
|
|
15
|
+
},
|
|
5
16
|
"keywords": [
|
|
6
17
|
"composition",
|
|
7
18
|
"class",
|
|
@@ -13,20 +24,15 @@
|
|
|
13
24
|
"utilities",
|
|
14
25
|
"typescript"
|
|
15
26
|
],
|
|
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
27
|
"main": "./lib/index.cjs",
|
|
28
28
|
"module": "./lib/index.js",
|
|
29
29
|
"types": "./lib/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"./lib/index.js",
|
|
32
|
+
"./lib/index.d.ts",
|
|
33
|
+
"./lib/index.cjs",
|
|
34
|
+
"./lib/index.d.cts"
|
|
35
|
+
],
|
|
30
36
|
"exports": {
|
|
31
37
|
".": {
|
|
32
38
|
"import": {
|
|
@@ -38,209 +44,17 @@
|
|
|
38
44
|
"default": "./lib/index.cjs"
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
|
-
"
|
|
47
|
+
"./*": {
|
|
42
48
|
"import": {
|
|
43
|
-
"types": "./lib/
|
|
44
|
-
"default": "./lib/
|
|
45
|
-
},
|
|
46
|
-
"require": {
|
|
47
|
-
"types": "./lib/IView.d.cts",
|
|
48
|
-
"default": "./lib/IView.cjs"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"./OptionsConfigurator": {
|
|
52
|
-
"import": {
|
|
53
|
-
"types": "./lib/OptionsConfigurator.d.ts",
|
|
54
|
-
"default": "./lib/OptionsConfigurator.js"
|
|
55
|
-
},
|
|
56
|
-
"require": {
|
|
57
|
-
"types": "./lib/OptionsConfigurator.d.cts",
|
|
58
|
-
"default": "./lib/OptionsConfigurator.cjs"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"./View": {
|
|
62
|
-
"import": {
|
|
63
|
-
"types": "./lib/View.d.ts",
|
|
64
|
-
"default": "./lib/View.js"
|
|
65
|
-
},
|
|
66
|
-
"require": {
|
|
67
|
-
"types": "./lib/View.d.cts",
|
|
68
|
-
"default": "./lib/View.cjs"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"./inheritProxifiedPrototype": {
|
|
72
|
-
"import": {
|
|
73
|
-
"types": "./lib/inheritProxifiedPrototype.d.ts",
|
|
74
|
-
"default": "./lib/inheritProxifiedPrototype.js"
|
|
75
|
-
},
|
|
76
|
-
"require": {
|
|
77
|
-
"types": "./lib/inheritProxifiedPrototype.d.cts",
|
|
78
|
-
"default": "./lib/inheritProxifiedPrototype.cjs"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"./inheritProxifiedPrototypeProperty": {
|
|
82
|
-
"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"
|
|
95
|
-
},
|
|
96
|
-
"require": {
|
|
97
|
-
"types": "./lib/inspector/Inspector.d.cts",
|
|
98
|
-
"default": "./lib/inspector/Inspector.cjs"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"./inspector/defaults/ignoreValuesDefaults": {
|
|
102
|
-
"import": {
|
|
103
|
-
"types": "./lib/inspector/defaults/ignoreValuesDefaults.d.ts",
|
|
104
|
-
"default": "./lib/inspector/defaults/ignoreValuesDefaults.js"
|
|
105
|
-
},
|
|
106
|
-
"require": {
|
|
107
|
-
"types": "./lib/inspector/defaults/ignoreValuesDefaults.d.cts",
|
|
108
|
-
"default": "./lib/inspector/defaults/ignoreValuesDefaults.cjs"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"./inspector/defaults/ignoreValuesFilterDefaults": {
|
|
112
|
-
"import": {
|
|
113
|
-
"types": "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts",
|
|
114
|
-
"default": "./lib/inspector/defaults/ignoreValuesFilterDefaults.js"
|
|
115
|
-
},
|
|
116
|
-
"require": {
|
|
117
|
-
"types": "./lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts",
|
|
118
|
-
"default": "./lib/inspector/defaults/ignoreValuesFilterDefaults.cjs"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"./inspector/defaults/inspectDefaults": {
|
|
122
|
-
"import": {
|
|
123
|
-
"types": "./lib/inspector/defaults/inspectDefaults.d.ts",
|
|
124
|
-
"default": "./lib/inspector/defaults/inspectDefaults.js"
|
|
125
|
-
},
|
|
126
|
-
"require": {
|
|
127
|
-
"types": "./lib/inspector/defaults/inspectDefaults.d.cts",
|
|
128
|
-
"default": "./lib/inspector/defaults/inspectDefaults.cjs"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
"./inspector/defaults/inspectorDefaults": {
|
|
132
|
-
"import": {
|
|
133
|
-
"types": "./lib/inspector/defaults/inspectorDefaults.d.ts",
|
|
134
|
-
"default": "./lib/inspector/defaults/inspectorDefaults.js"
|
|
135
|
-
},
|
|
136
|
-
"require": {
|
|
137
|
-
"types": "./lib/inspector/defaults/inspectorDefaults.d.cts",
|
|
138
|
-
"default": "./lib/inspector/defaults/inspectorDefaults.cjs"
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"./inspector/types": {
|
|
142
|
-
"import": {
|
|
143
|
-
"types": "./lib/inspector/types.d.ts",
|
|
144
|
-
"default": "./lib/inspector/types.js"
|
|
145
|
-
},
|
|
146
|
-
"require": {
|
|
147
|
-
"types": "./lib/inspector/types.d.cts",
|
|
148
|
-
"default": "./lib/inspector/types.cjs"
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
"./parenting/ParentRelationTypes": {
|
|
152
|
-
"import": {
|
|
153
|
-
"types": "./lib/parenting/ParentRelationTypes.d.ts",
|
|
154
|
-
"default": "./lib/parenting/ParentRelationTypes.js"
|
|
155
|
-
},
|
|
156
|
-
"require": {
|
|
157
|
-
"types": "./lib/parenting/ParentRelationTypes.d.cts",
|
|
158
|
-
"default": "./lib/parenting/ParentRelationTypes.cjs"
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
"./parenting/Parenting": {
|
|
162
|
-
"import": {
|
|
163
|
-
"types": "./lib/parenting/Parenting.d.ts",
|
|
164
|
-
"default": "./lib/parenting/Parenting.js"
|
|
165
|
-
},
|
|
166
|
-
"require": {
|
|
167
|
-
"types": "./lib/parenting/Parenting.d.cts",
|
|
168
|
-
"default": "./lib/parenting/Parenting.cjs"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"./parenting/types": {
|
|
172
|
-
"import": {
|
|
173
|
-
"types": "./lib/parenting/types.d.ts",
|
|
174
|
-
"default": "./lib/parenting/types.js"
|
|
49
|
+
"types": "./lib/index.d.ts",
|
|
50
|
+
"default": "./lib/index.js"
|
|
175
51
|
},
|
|
176
52
|
"require": {
|
|
177
|
-
"types": "./lib/
|
|
178
|
-
"default": "./lib/
|
|
53
|
+
"types": "./lib/index.d.cts",
|
|
54
|
+
"default": "./lib/index.cjs"
|
|
179
55
|
}
|
|
180
56
|
}
|
|
181
57
|
},
|
|
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
58
|
"repository": {
|
|
245
59
|
"type": "git",
|
|
246
60
|
"url": "git+https://github.com/bemoje/mono.git",
|
package/lib/IView.cjs
DELETED
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;
|