adaptive-extender 0.9.10 → 0.9.11
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/CHANGELOG.md +1 -1
- package/README.md +347 -68
- package/package.json +1 -1
- package/dist/core/archivable.d.ts +0 -19
- package/dist/core/archivable.js +0 -3
- package/dist/core/archivable.js.map +0 -1
- package/dist/core/debug_types.d.ts +0 -1
- package/dist/core/debug_types.js +0 -65
- package/dist/core/debug_types.js.map +0 -1
- package/dist/core/repro_issue.d.ts +0 -1
- package/dist/core/repro_issue.js +0 -55
- package/dist/core/repro_issue.js.map +0 -1
- package/dist/node/environment.d.ts +0 -20
- package/dist/node/environment.js +0 -37
- package/dist/node/environment.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## 0.9.
|
|
1
|
+
## 0.9.11 (17.03.2026)
|
|
2
2
|
- Moved `environment` module from [node](./src/node/environment.ts) to [core](./src/core/environment.ts).
|
|
3
3
|
- Added `EnvironmentProvider` class for resolving environment variables.
|
|
4
4
|
- Added `RecordOf` and `MapOf` adapters for portable maps in [portable](./src/core/portable.ts) module.
|
package/README.md
CHANGED
|
@@ -1,130 +1,409 @@
|
|
|
1
1
|
# Adaptive Extender
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/adaptive-extender)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://bundlephobia.com/package/adaptive-extender)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
**Adaptive Extender** enables strict portability, structured time management, and LINQ-like collections by extending native prototypes. It provides a robust standard library layer for enterprise-grade architecture.
|
|
8
|
+
Extends native prototypes and provides missing standard utilities — with a focus on strict typing, safety, and code readability.
|
|
8
9
|
|
|
9
10
|
[Change log](./CHANGELOG.md)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
##
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install adaptive-extender
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Packages
|
|
21
|
+
|
|
22
|
+
| Package | Environment |
|
|
23
|
+
| :----------------------- | :---------------------- |
|
|
24
|
+
| `adaptive-extender/core` | Browser, Node.js, Deno |
|
|
25
|
+
| `adaptive-extender/node` | Node.js (includes core) |
|
|
26
|
+
| `adaptive-extender/web` | Browser (includes core) |
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// Import once — extensions are active everywhere
|
|
30
|
+
import "adaptive-extender/core";
|
|
31
|
+
import "adaptive-extender/web"; // Browser only
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Native Extensions
|
|
37
|
+
|
|
38
|
+
### Number
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
```typescript
|
|
41
|
+
volume = volume.clamp(0, 1);
|
|
42
|
+
|
|
43
|
+
// Normalize into [0, 1] or remap between ranges
|
|
44
|
+
const normalized = currentValue.lerp(sourceMin, sourceMax);
|
|
45
|
+
const pixelX = angle.lerp(0, 360, 0, canvasWidth);
|
|
46
|
+
|
|
47
|
+
// True mathematical modulo — works correctly with negative numbers
|
|
48
|
+
const wrappedIndex = (-1).mod(items.length); // → items.length - 1
|
|
49
|
+
|
|
50
|
+
// Chainable fallback for invalid values
|
|
51
|
+
const ratio = (numerator / denominator).insteadNaN(0).insteadInfinity(1);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### String
|
|
17
55
|
|
|
18
56
|
```typescript
|
|
19
|
-
|
|
57
|
+
if (String.isWhitespace(userInput)) return;
|
|
58
|
+
|
|
59
|
+
const displayName = username.insteadEmpty("Anonymous");
|
|
60
|
+
|
|
61
|
+
"hello world".toTitleCase(); // → "Hello World"
|
|
62
|
+
"île-de-france".toLocalTitleCase("fr"); // → "Île-De-France"
|
|
63
|
+
```
|
|
20
64
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
65
|
+
### Array
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
for (const index of Array.range(0, 10)) { ... }
|
|
69
|
+
|
|
70
|
+
for (const [user, role] of Array.zip(users, roles)) {
|
|
71
|
+
console.log(`${user.name}: ${role}`);
|
|
24
72
|
}
|
|
25
73
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
74
|
+
// Collect an async iterable into an array
|
|
75
|
+
const packets = await Array.fromAsync(readableStream);
|
|
76
|
+
|
|
77
|
+
items.swap(0, items.length - 1);
|
|
78
|
+
items.resize(10, null);
|
|
79
|
+
const wasRemoved = items.remove(targetItem);
|
|
30
80
|
```
|
|
31
81
|
|
|
32
|
-
###
|
|
33
|
-
|
|
82
|
+
### Math
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const [integer, fractional] = Math.split(3.75); // → [3, 0.75]
|
|
86
|
+
Math.sqpw(sideLength); // sideLength²
|
|
87
|
+
Math.toRadians(90); // → Math.PI / 2
|
|
88
|
+
Math.toDegrees(Math.PI); // → 180
|
|
89
|
+
|
|
90
|
+
Math.meanArithmetic(1, 2, 3, 4); // → 2.5
|
|
91
|
+
Math.meanGeometric(4, 16);
|
|
92
|
+
Math.meanHarmonic(1, 2, 4);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Set / Map / Date
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Like classList.toggle
|
|
99
|
+
selected.toggle(item); // add if absent, remove if present
|
|
100
|
+
selected.toggle(item, true); // force add
|
|
101
|
+
selected.toggle(item, false); // force remove
|
|
102
|
+
|
|
103
|
+
// Add only if key is not already present
|
|
104
|
+
cache.add(requestKey, response); // → false if key exists
|
|
105
|
+
|
|
106
|
+
// Detect and replace invalid dates
|
|
107
|
+
const safeDate = new Date("invalid").insteadInvalid(new Date());
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Promise
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const request = fetch("/api/data");
|
|
114
|
+
|
|
115
|
+
if (await request.isSettled) { ... }
|
|
116
|
+
if (await request.isResolved) { ... }
|
|
117
|
+
if (await request.isRejected) { ... }
|
|
118
|
+
|
|
119
|
+
const responseData = await request.value; // throws if rejected
|
|
120
|
+
const rejectReason = await request.reason; // throws if resolved
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Error / Global
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// Wrap anything into an Error (string, undefined, object)
|
|
127
|
+
const error = Error.from(thrown);
|
|
128
|
+
|
|
129
|
+
// Assert non-null — throws ReferenceError with a message
|
|
130
|
+
const appRoot = ReferenceError.suppress(document.getElementById("app"));
|
|
131
|
+
|
|
132
|
+
throw new ImplementationError(); // sealed, cannot be subclassed
|
|
133
|
+
|
|
134
|
+
// Get type name without typeof / manual checks
|
|
135
|
+
typename(value); // → "String", "Null", "User", ...
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Classes
|
|
141
|
+
|
|
142
|
+
### Timespan
|
|
143
|
+
|
|
144
|
+
Value object for time intervals. Eliminates raw millisecond arithmetic.
|
|
34
145
|
|
|
35
146
|
```typescript
|
|
36
147
|
import { Timespan } from "adaptive-extender/core";
|
|
37
148
|
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
149
|
+
const sessionDuration = Timespan.fromComponents(0, 30, 0); // 30 minutes
|
|
150
|
+
const uptime = Timespan.fromValue(process.uptime() * 1000);
|
|
151
|
+
const parsed = Timespan.parse("1.02:30:00.500"); // 1d 2h 30m 0.5s
|
|
152
|
+
|
|
153
|
+
console.log(uptime.toString()); // "0.00:12:45.123"
|
|
41
154
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
155
|
+
uptime.minutes = 0; // other components recalculate automatically
|
|
156
|
+
|
|
157
|
+
if (uptime.valueOf() > sessionDuration.valueOf()) {
|
|
158
|
+
console.log("Session expired");
|
|
45
159
|
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Color
|
|
163
|
+
|
|
164
|
+
Full color object with RGB, HSL, HEX support and alpha channel. Changing a component in one color space automatically recalculates the other.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { Color, ColorFormats } from "adaptive-extender/core";
|
|
168
|
+
|
|
169
|
+
const orange = Color.fromRGB(255, 128, 0);
|
|
170
|
+
const parsed = Color.parse("#ff8800");
|
|
171
|
+
|
|
172
|
+
orange.hue = 200; // RGB recalculates automatically
|
|
173
|
+
orange.alpha = 0.8;
|
|
46
174
|
|
|
47
|
-
|
|
48
|
-
|
|
175
|
+
console.log(orange.toString({ format: ColorFormats.hsl, deep: true }));
|
|
176
|
+
// → "hsla(200, 100%, 50%, 0.8)"
|
|
49
177
|
```
|
|
50
178
|
|
|
51
|
-
###
|
|
52
|
-
Native prototypes (`Array`, `String`, `Math`) are augmented with missing standard utility methods. These extensions are non-enumerable and designed to be conflict-free.
|
|
179
|
+
### Random
|
|
53
180
|
|
|
54
181
|
```typescript
|
|
55
|
-
|
|
56
|
-
|
|
182
|
+
import { Random } from "adaptive-extender/core";
|
|
183
|
+
|
|
184
|
+
const rng = Random.global;
|
|
185
|
+
|
|
186
|
+
rng.boolean(0.9); // true with 90% probability
|
|
187
|
+
rng.number(0, 1); // float [0, 1)
|
|
188
|
+
rng.integer(1, 6); // int [1, 6]
|
|
189
|
+
rng.item(options); // random element from array
|
|
190
|
+
rng.subarray(items, 3); // 3 random elements
|
|
191
|
+
rng.shuffle(array); // shuffle in place
|
|
192
|
+
|
|
193
|
+
// Weighted selection
|
|
194
|
+
const loot = rng.case(new Map([
|
|
195
|
+
["common", 70],
|
|
196
|
+
["rare", 25],
|
|
197
|
+
["legendary", 5],
|
|
198
|
+
]));
|
|
199
|
+
```
|
|
57
200
|
|
|
58
|
-
|
|
59
|
-
for (const [user, role] of Array.zip(users, roles)) { ... }
|
|
201
|
+
### Vector
|
|
60
202
|
|
|
61
|
-
|
|
62
|
-
|
|
203
|
+
Mathematical vectors with a LINQ-style iteration API.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { Vector, Vector2D, Vector3D } from "adaptive-extender/core";
|
|
207
|
+
|
|
208
|
+
const position = new Vector2D(3, 4);
|
|
209
|
+
const direction = Vector3D.fromScalar(1); // (1, 1, 1)
|
|
210
|
+
|
|
211
|
+
// LINQ-like methods over components
|
|
212
|
+
const normalized = Vector3D.fromVector(
|
|
213
|
+
direction.map(component => component / Math.sqrt(3))
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
Vector.isFinite(position);
|
|
217
|
+
const safePosition = position.insteadNaN(Vector2D.newZero);
|
|
218
|
+
const point = Vector2D.parse("(10, 20)"); // → Vector2D { x: 10, y: 20 }
|
|
63
219
|
```
|
|
64
220
|
|
|
65
|
-
###
|
|
66
|
-
|
|
221
|
+
### Controller
|
|
222
|
+
|
|
223
|
+
Abstract base class for async tasks with centralized error handling.
|
|
67
224
|
|
|
68
225
|
```typescript
|
|
69
226
|
import { Controller } from "adaptive-extender/core";
|
|
70
227
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
228
|
+
class InitTask extends Controller {
|
|
229
|
+
async run(): Promise<void> {
|
|
230
|
+
const response = await fetch("/api/init");
|
|
231
|
+
// ...
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async catch(error: Error): Promise<void> {
|
|
235
|
+
console.error("Init failed:", error.message);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Creates an instance and runs it — errors are routed to catch()
|
|
240
|
+
await InitTask.launch();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### EnvironmentProvider
|
|
244
|
+
|
|
245
|
+
Deserializes environment variables into a strictly typed model. JSON values are parsed automatically.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { EnvironmentProvider, Model, Field, Optional } from "adaptive-extender/core";
|
|
249
|
+
|
|
250
|
+
class AppConfig extends Model {
|
|
251
|
+
@Field(String) DB_HOST: string = "localhost";
|
|
252
|
+
@Field(Number) DB_PORT: number = 5432;
|
|
253
|
+
@Field(Optional(String)) LOG_LEVEL?: string;
|
|
75
254
|
}
|
|
255
|
+
|
|
256
|
+
const config = EnvironmentProvider.resolve(process.env, AppConfig);
|
|
257
|
+
// config.DB_PORT is a number, not a string
|
|
258
|
+
// Throws TypeError if a required variable is missing or has the wrong type
|
|
76
259
|
```
|
|
77
260
|
|
|
78
261
|
---
|
|
79
262
|
|
|
80
|
-
##
|
|
263
|
+
## Portable Data System
|
|
264
|
+
|
|
265
|
+
Binds classes to their schema via decorators. Importing from JSON validates types automatically and returns a real class instance.
|
|
81
266
|
|
|
82
|
-
|
|
267
|
+
### Basic Usage
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { Model, Field, ArrayOf, Optional, Nullable } from "adaptive-extender/core";
|
|
271
|
+
|
|
272
|
+
class Tag extends Model {
|
|
273
|
+
@Field(String) name: string = "";
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
class Article extends Model {
|
|
277
|
+
@Field(String) title: string = "";
|
|
278
|
+
@Field(Number) views: number = 0;
|
|
279
|
+
@Field(ArrayOf(Tag)) tags: Tag[] = [];
|
|
280
|
+
@Field(Optional(String)) subtitle?: string;
|
|
281
|
+
@Field(Nullable(String)) draft: string | null = null;
|
|
282
|
+
}
|
|
83
283
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
284
|
+
const article = Article.import(json, "api.article");
|
|
285
|
+
// article instanceof Article → true
|
|
286
|
+
// TypeError with exact path on failure: "api.article.tags[2].name"
|
|
287
|
+
|
|
288
|
+
const raw = Article.export(article); // → plain object, ready for JSON.stringify
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Polymorphism
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { Model, Field, Descendant, DiscriminatorKey } from "adaptive-extender/core";
|
|
295
|
+
|
|
296
|
+
class Dog extends Model { @Field(String) breed: string = ""; }
|
|
297
|
+
class Cat extends Model { @Field(Boolean) indoor: boolean = true; }
|
|
298
|
+
|
|
299
|
+
@DiscriminatorKey("kind")
|
|
300
|
+
@Descendant(Dog, "dog")
|
|
301
|
+
@Descendant(Cat, "cat")
|
|
302
|
+
abstract class Animal extends Model {}
|
|
303
|
+
|
|
304
|
+
// { kind: "dog", breed: "Husky" } → Dog instance
|
|
305
|
+
// { kind: "cat", indoor: true } → Cat instance
|
|
306
|
+
const animal = Animal.import(json, "api.animal");
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Adapters
|
|
310
|
+
|
|
311
|
+
| Adapter | Type |
|
|
312
|
+
| :------------- | :------------------------------------- |
|
|
313
|
+
| `ArrayOf(T)` | `T[]` |
|
|
314
|
+
| `SetOf(T)` | `Set<T>` ↔ `T[]` |
|
|
315
|
+
| `RecordOf(T)` | `Map<string, T>` ↔ `Record<string, T>` |
|
|
316
|
+
| `MapOf(K, V)` | `Map<K, V>` ↔ `[K, V][]` |
|
|
317
|
+
| `Optional(T)` | `T \| undefined` |
|
|
318
|
+
| `Nullable(T)` | `T \| null` |
|
|
319
|
+
| `Deferred(fn)` | Circular references |
|
|
94
320
|
|
|
95
321
|
---
|
|
96
322
|
|
|
97
|
-
##
|
|
323
|
+
## Web
|
|
98
324
|
|
|
99
|
-
|
|
100
|
-
Universal utilities. Works in Browser, Node, Deno.
|
|
101
|
-
*(Math, arrays, promises, portable system, time)*
|
|
325
|
+
### DOM Queries
|
|
102
326
|
|
|
103
|
-
-
|
|
104
|
-
Backend-specific tools.
|
|
105
|
-
*(Enhanced `fs` operations, strict environment variable parsing)*
|
|
327
|
+
Type-safe wrappers over `querySelector` — throw instead of returning `null`.
|
|
106
328
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*(DOM element wrappers, parent-node extensions)*
|
|
329
|
+
```typescript
|
|
330
|
+
import "adaptive-extender/web";
|
|
110
331
|
|
|
111
|
-
|
|
332
|
+
const loginForm = document.getElement(HTMLFormElement, "#login-form");
|
|
333
|
+
const requiredInputs = loginForm.getElements(HTMLInputElement, "input[required]");
|
|
334
|
+
const container = loginForm.getClosest(HTMLDivElement, ".wrapper");
|
|
112
335
|
|
|
113
|
-
|
|
114
|
-
|
|
336
|
+
// Async variants — useful with Shadow DOM
|
|
337
|
+
const canvas = await document.getElementAsync(HTMLCanvasElement, "#scene");
|
|
115
338
|
```
|
|
116
339
|
|
|
117
|
-
|
|
340
|
+
### Game Engines
|
|
341
|
+
|
|
342
|
+
Three update-loop engines for UI animation or game logic:
|
|
118
343
|
|
|
119
344
|
```typescript
|
|
120
|
-
import "adaptive-extender/
|
|
345
|
+
import { FastEngine, StaticEngine } from "adaptive-extender/web";
|
|
346
|
+
|
|
347
|
+
// Fast — requestAnimationFrame based
|
|
348
|
+
const engine = new FastEngine({ launch: true });
|
|
349
|
+
engine.limit = 60;
|
|
350
|
+
|
|
351
|
+
engine.addEventListener("trigger", () => {
|
|
352
|
+
const deltaTime = engine.delta; // seconds since last frame
|
|
353
|
+
// update scene...
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// Static — fixed fps via setTimeout
|
|
357
|
+
const fixedEngine = new StaticEngine({ launch: true });
|
|
358
|
+
fixedEngine.limit = 30;
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Archive (localStorage)
|
|
362
|
+
|
|
363
|
+
Type-safe localStorage with buffered access and auto-save.
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { ArchiveRepository, Model, Field } from "adaptive-extender/web";
|
|
121
367
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
368
|
+
class Settings extends Model {
|
|
369
|
+
@Field(Boolean) darkMode: boolean = false;
|
|
370
|
+
@Field(Number) volume: number = 1;
|
|
125
371
|
}
|
|
372
|
+
|
|
373
|
+
const repository = new ArchiveRepository("settings", Settings, new Settings());
|
|
374
|
+
|
|
375
|
+
const settings = repository.content;
|
|
376
|
+
settings.volume = 0.5;
|
|
377
|
+
|
|
378
|
+
repository.save(); // persist immediately
|
|
379
|
+
repository.save(3000); // debounced — persist after 3 seconds
|
|
380
|
+
repository.reset(); // revert to initial state
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Promise Utilities
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
await Promise.asTimeout(1000);
|
|
387
|
+
|
|
388
|
+
// AbortController is created and aborted automatically on completion
|
|
389
|
+
const result = await Promise.withSignal((signal, resolve, reject) => {
|
|
390
|
+
fetch("/api/data", { signal }).then(resolve).catch(reject);
|
|
391
|
+
});
|
|
126
392
|
```
|
|
127
393
|
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Reflect Utilities
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
// Apply a function only if the value is not null / undefined
|
|
400
|
+
const upper = Reflect.mapNull(maybeNull, text => text.toUpperCase());
|
|
401
|
+
const trimmed = Reflect.mapUndefined(maybeUndefined, text => text.trim());
|
|
402
|
+
const parsed = Reflect.mapNullable(maybeNullable, text => parseInt(text));
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
128
407
|
## License
|
|
129
408
|
|
|
130
409
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the interface for an archivable object's prototype.
|
|
3
|
-
* @template S The type of the notation returned by the export method.
|
|
4
|
-
*/
|
|
5
|
-
export interface ArchivablePrototype<S = any> {
|
|
6
|
-
/**
|
|
7
|
-
* Creates a new instance of the archivable object.
|
|
8
|
-
*/
|
|
9
|
-
new (...args: any): any;
|
|
10
|
-
/**
|
|
11
|
-
* Imports data from a source and returns a new instance.
|
|
12
|
-
* @throws {TypeError} If unable to import the source.
|
|
13
|
-
*/
|
|
14
|
-
import(source: any, name: string): InstanceType<this>;
|
|
15
|
-
/**
|
|
16
|
-
* Exports the state of an instance to a notation.
|
|
17
|
-
*/
|
|
18
|
-
export(source: InstanceType<this>): S;
|
|
19
|
-
}
|
package/dist/core/archivable.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archivable.js","sourceRoot":"","sources":["../../src/core/archivable.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/core/debug_types.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
-
var _, done = false;
|
|
7
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
-
var context = {};
|
|
9
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
-
if (kind === "accessor") {
|
|
14
|
-
if (result === void 0) continue;
|
|
15
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
-
}
|
|
20
|
-
else if (_ = accept(result)) {
|
|
21
|
-
if (kind === "field") initializers.unshift(_);
|
|
22
|
-
else descriptor[key] = _;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
-
done = true;
|
|
27
|
-
};
|
|
28
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
-
var useValue = arguments.length > 2;
|
|
30
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
-
}
|
|
33
|
-
return useValue ? value : void 0;
|
|
34
|
-
};
|
|
35
|
-
import { Model, Field } from "./portable";
|
|
36
|
-
// Mock types
|
|
37
|
-
class MyModel extends Model {
|
|
38
|
-
}
|
|
39
|
-
let TestClass = (() => {
|
|
40
|
-
let _classSuper = Model;
|
|
41
|
-
let _prop_decorators;
|
|
42
|
-
let _prop_initializers = [];
|
|
43
|
-
let _prop_extraInitializers = [];
|
|
44
|
-
let _date_decorators;
|
|
45
|
-
let _date_initializers = [];
|
|
46
|
-
let _date_extraInitializers = [];
|
|
47
|
-
return class TestClass extends _classSuper {
|
|
48
|
-
static {
|
|
49
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
50
|
-
_prop_decorators = [Field(MyType)];
|
|
51
|
-
_date_decorators = [Field(Date)];
|
|
52
|
-
__esDecorate(null, null, _prop_decorators, { kind: "field", name: "prop", static: false, private: false, access: { has: obj => "prop" in obj, get: obj => obj.prop, set: (obj, value) => { obj.prop = value; } }, metadata: _metadata }, _prop_initializers, _prop_extraInitializers);
|
|
53
|
-
__esDecorate(null, null, _date_decorators, { kind: "field", name: "date", static: false, private: false, access: { has: obj => "date" in obj, get: obj => obj.date, set: (obj, value) => { obj.date = value; } }, metadata: _metadata }, _date_initializers, _date_extraInitializers);
|
|
54
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
55
|
-
}
|
|
56
|
-
// Check if compilation fails or inference is weird
|
|
57
|
-
prop = __runInitializers(this, _prop_initializers, void 0);
|
|
58
|
-
date = (__runInitializers(this, _prop_extraInitializers), __runInitializers(this, _date_initializers, void 0));
|
|
59
|
-
constructor() {
|
|
60
|
-
super(...arguments);
|
|
61
|
-
__runInitializers(this, _date_extraInitializers);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
})();
|
|
65
|
-
//# sourceMappingURL=debug_types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug_types.js","sourceRoot":"","sources":["../../src/core/debug_types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAA4B,MAAM,YAAY,CAAC;AAEpE,aAAa;AACb,MAAM,OAAQ,SAAQ,KAAK;CAAG;IAIxB,SAAS;sBAAS,KAAK;;;;;;;iBAAvB,SAAU,SAAQ,WAAK;;;gCAExB,KAAK,CAAC,MAAM,CAAC;gCAGb,KAAK,CAAC,IAAI,CAAC;YAFZ,8JAAA,IAAI,6BAAJ,IAAI,mFAAW;YAGf,8JAAA,IAAI,6BAAJ,IAAI,mFAAQ;;;QALZ,mDAAmD;QAEnD,IAAI,uDAAW;QAGf,IAAI,2GAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/core/repro_issue.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
-
var _, done = false;
|
|
7
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
-
var context = {};
|
|
9
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
-
if (kind === "accessor") {
|
|
14
|
-
if (result === void 0) continue;
|
|
15
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
-
}
|
|
20
|
-
else if (_ = accept(result)) {
|
|
21
|
-
if (kind === "field") initializers.unshift(_);
|
|
22
|
-
else descriptor[key] = _;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
-
done = true;
|
|
27
|
-
};
|
|
28
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
-
var useValue = arguments.length > 2;
|
|
30
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
-
}
|
|
33
|
-
return useValue ? value : void 0;
|
|
34
|
-
};
|
|
35
|
-
import { Model, Field } from "./portable";
|
|
36
|
-
let TestDate = (() => {
|
|
37
|
-
let _classSuper = Model;
|
|
38
|
-
let _dateField_decorators;
|
|
39
|
-
let _dateField_initializers = [];
|
|
40
|
-
let _dateField_extraInitializers = [];
|
|
41
|
-
return class TestDate extends _classSuper {
|
|
42
|
-
static {
|
|
43
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
44
|
-
_dateField_decorators = [Field(Date)];
|
|
45
|
-
__esDecorate(null, null, _dateField_decorators, { kind: "field", name: "dateField", static: false, private: false, access: { has: obj => "dateField" in obj, get: obj => obj.dateField, set: (obj, value) => { obj.dateField = value; } }, metadata: _metadata }, _dateField_initializers, _dateField_extraInitializers);
|
|
46
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
47
|
-
}
|
|
48
|
-
dateField = __runInitializers(this, _dateField_initializers, void 0);
|
|
49
|
-
constructor() {
|
|
50
|
-
super(...arguments);
|
|
51
|
-
__runInitializers(this, _dateField_extraInitializers);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
})();
|
|
55
|
-
//# sourceMappingURL=repro_issue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repro_issue.js","sourceRoot":"","sources":["../../src/core/repro_issue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;IAEpC,QAAQ;sBAAS,KAAK;;;;iBAAtB,QAAS,SAAQ,WAAK;;;qCACvB,KAAK,CAAC,IAAI,CAAC;YACZ,6KAAA,SAAS,6BAAT,SAAS,6FAAQ;;;QAAjB,SAAS,4DAAQ"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "../core/index.js";
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
/**
|
|
4
|
-
* Represents the system environment and provides utility methods to access environment variables.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Environment {
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves a new instance of the Environment class.
|
|
9
|
-
*/
|
|
10
|
-
static get env(): Environment;
|
|
11
|
-
/**
|
|
12
|
-
* Checks if a specific key exists within the environment variables.
|
|
13
|
-
*/
|
|
14
|
-
hasValue(key: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Reads and parses the value of a specific environment variable.
|
|
17
|
-
* @throws {ReferenceError} if the key is missing.
|
|
18
|
-
*/
|
|
19
|
-
readValue(key: string): any;
|
|
20
|
-
}
|
package/dist/node/environment.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import "../core/index.js";
|
|
3
|
-
import "dotenv/config";
|
|
4
|
-
//#region Environment
|
|
5
|
-
/**
|
|
6
|
-
* Represents the system environment and provides utility methods to access environment variables.
|
|
7
|
-
*/
|
|
8
|
-
export class Environment {
|
|
9
|
-
/**
|
|
10
|
-
* Retrieves a new instance of the Environment class.
|
|
11
|
-
*/
|
|
12
|
-
static get env() {
|
|
13
|
-
return new Environment();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Checks if a specific key exists within the environment variables.
|
|
17
|
-
*/
|
|
18
|
-
hasValue(key) {
|
|
19
|
-
const { env } = process;
|
|
20
|
-
return (env[key] !== undefined);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Reads and parses the value of a specific environment variable.
|
|
24
|
-
* @throws {ReferenceError} if the key is missing.
|
|
25
|
-
*/
|
|
26
|
-
readValue(key) {
|
|
27
|
-
const { env } = process;
|
|
28
|
-
const text = ReferenceError.suppress(env[key], `Key '${key}' at environment not registered`);
|
|
29
|
-
try {
|
|
30
|
-
return JSON.parse(text);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return text;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=environment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/node/environment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,kBAAkB,CAAC;AAC1B,OAAO,eAAe,CAAC;AAEvB,qBAAqB;AACrB;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;OAEG;IACH,MAAM,KAAK,GAAG;QACb,OAAO,IAAI,WAAW,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,GAAW;QACnB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,GAAW;QACpB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACxB,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,iCAAiC,CAAC,CAAC;QAC7F,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;CACD"}
|