@venizia/ardor-kernel 0.4.8-1 → 0.4.8-10

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 (38) hide show
  1. package/README.md +10 -6
  2. package/dist/base/applications/abstract.d.ts +17 -1
  3. package/dist/base/applications/abstract.js +7 -0
  4. package/dist/base/providers/base.d.ts +2 -0
  5. package/dist/base/providers/base.js +1 -0
  6. package/dist/base/services/auth.d.ts +23 -2
  7. package/dist/base/services/auth.js +48 -13
  8. package/dist/base/services/base.d.ts +1 -0
  9. package/dist/base/services/base.js +1 -0
  10. package/dist/base/services/network-request.d.ts +63 -6
  11. package/dist/base/services/network-request.js +121 -17
  12. package/dist/common/constants.d.ts +47 -0
  13. package/dist/common/constants.js +47 -0
  14. package/dist/common/keys.d.ts +37 -1
  15. package/dist/common/keys.js +41 -1
  16. package/dist/common/types.d.ts +99 -8
  17. package/dist/helpers/auth-token-store.d.ts +6 -2
  18. package/dist/helpers/auth-token-store.js +5 -4
  19. package/dist/helpers/networks/auth-recovery.d.ts +1 -0
  20. package/dist/helpers/networks/request-body-encoder.d.ts +1 -0
  21. package/dist/helpers/networks/request-body-encoder.js +1 -0
  22. package/dist/helpers/networks/response-reader.d.ts +8 -0
  23. package/dist/helpers/networks/response-reader.js +8 -0
  24. package/dist/testing.d.ts +137 -0
  25. package/dist/testing.js +367 -0
  26. package/dist/utilities/browser-storage.d.ts +15 -3
  27. package/dist/utilities/browser-storage.js +26 -7
  28. package/dist/utilities/browser.d.ts +2 -0
  29. package/dist/utilities/browser.js +2 -0
  30. package/dist/utilities/file.d.ts +1 -0
  31. package/dist/utilities/file.js +1 -0
  32. package/dist/utilities/runtime-config.d.ts +4 -0
  33. package/dist/utilities/runtime-config.js +1 -0
  34. package/dist/utilities/storage-codecs.d.ts +1 -0
  35. package/dist/utilities/storage-codecs.js +1 -0
  36. package/dist/utilities/value.d.ts +3 -0
  37. package/dist/utilities/value.js +3 -0
  38. package/package.json +23 -14
@@ -0,0 +1,367 @@
1
+ /**
2
+ * Fakes of the browser APIs ARDOR's hooks and helpers use, for a test host that has none of them or
3
+ * whose own do nothing, such as happy-dom. Each fake puts itself on the global with `install`,
4
+ * which returns the function that puts the previous value back.
5
+ */
6
+ /**
7
+ * Defines `name` on the global and, where `window` is another object (happy-dom), on `window` too, so
8
+ * code that reads `window.matchMedia` or `window.localStorage` meets the fake. `at` names a member of
9
+ * them instead (`navigator`). Answers the function that puts the previous properties back.
10
+ */
11
+ const swap = (opts) => {
12
+ const { name, value, at } = opts;
13
+ const roots = [globalThis, Reflect.get(globalThis, 'window')];
14
+ const targets = new Set();
15
+ for (const root of roots) {
16
+ const target = at && root ? Reflect.get(Object(root), at) : root;
17
+ if (typeof target === 'object' && target !== null) {
18
+ targets.add(target);
19
+ }
20
+ }
21
+ const restores = [...targets].map((target) => {
22
+ const previous = Object.getOwnPropertyDescriptor(target, name);
23
+ Object.defineProperty(target, name, { value, configurable: true, writable: true });
24
+ return () => {
25
+ if (previous) {
26
+ Object.defineProperty(target, name, previous);
27
+ }
28
+ else {
29
+ Reflect.deleteProperty(target, name);
30
+ }
31
+ };
32
+ });
33
+ return () => {
34
+ for (const restore of restores) {
35
+ restore();
36
+ }
37
+ };
38
+ };
39
+ /** Removes the first `item` from `list`. */
40
+ const drop = (opts) => {
41
+ const index = opts.list.indexOf(opts.item);
42
+ if (index >= 0) {
43
+ opts.list.splice(index, 1);
44
+ }
45
+ };
46
+ /**
47
+ * A `ResizeObserver` whose `observe()` records the element. `flush` delivers a size to the observers
48
+ * of an element; a callback runs at once, so code that waits for an animation frame still needs the
49
+ * test's own frame control.
50
+ */
51
+ export class FakeResizeObserver {
52
+ /** The observers created since the last `install`, in creation order. */
53
+ static { this.all = []; }
54
+ constructor(callback) {
55
+ this.callback = callback;
56
+ /** The elements observed now. */
57
+ this.targets = [];
58
+ /** The options of each `observe` call, in order. */
59
+ this.options = [];
60
+ /** Every element passed to `unobserve`, in order. */
61
+ this.unobserved = [];
62
+ this.isDisconnected = false;
63
+ FakeResizeObserver.all.push(this);
64
+ }
65
+ /** Replaces `globalThis.ResizeObserver` with the fake and forgets the earlier observers. */
66
+ static install() {
67
+ FakeResizeObserver.all = [];
68
+ return swap({ name: 'ResizeObserver', value: FakeResizeObserver });
69
+ }
70
+ /** Calls every observer of `element` with one entry of that size, for the content and the border box alike. */
71
+ static flush(opts) {
72
+ const { element, width, height } = opts;
73
+ const box = { x: 0, y: 0, width, height, top: 0, left: 0, right: width, bottom: height };
74
+ const size = [{ inlineSize: width, blockSize: height }];
75
+ const entry = {
76
+ target: element,
77
+ contentRect: { ...box, toJSON: () => box },
78
+ contentBoxSize: size,
79
+ borderBoxSize: size,
80
+ devicePixelContentBoxSize: [],
81
+ };
82
+ for (const observer of FakeResizeObserver.all) {
83
+ if (observer.targets.includes(element)) {
84
+ observer.callback([entry], observer);
85
+ }
86
+ }
87
+ }
88
+ observe(target, options) {
89
+ if (!this.targets.includes(target)) {
90
+ this.targets.push(target);
91
+ this.options.push(options);
92
+ }
93
+ }
94
+ unobserve(target) {
95
+ this.unobserved.push(target);
96
+ drop({ list: this.targets, item: target });
97
+ }
98
+ disconnect() {
99
+ this.isDisconnected = true;
100
+ this.targets.length = 0;
101
+ }
102
+ }
103
+ const intersectionEntryOf = (opts) => {
104
+ const box = { x: 0, y: 0, width: 10, height: 10, top: 0, left: 0, right: 10, bottom: 10 };
105
+ const rect = { ...box, toJSON: () => box };
106
+ return {
107
+ target: opts.element,
108
+ isIntersecting: opts.isIntersecting,
109
+ intersectionRatio: opts.ratio,
110
+ boundingClientRect: rect,
111
+ intersectionRect: rect,
112
+ rootBounds: null,
113
+ time: 0,
114
+ };
115
+ };
116
+ /**
117
+ * An `IntersectionObserver` whose `observe()` records the element and reports nothing by itself: `settle`
118
+ * delivers the first report of a browser, `flush` delivers an entry to the observers of an element.
119
+ */
120
+ export class FakeIntersectionObserver {
121
+ /** The observers created since the last `install`, in creation order. */
122
+ static { this.all = []; }
123
+ /** How many observers were created since the last `install`. */
124
+ static get created() {
125
+ return FakeIntersectionObserver.all.length;
126
+ }
127
+ /** The observers created since the last `install` that are not disconnected. */
128
+ static live() {
129
+ return FakeIntersectionObserver.all.filter((observer) => !observer.isDisconnected);
130
+ }
131
+ /** The targets this observer has reported on: a browser reports each newly observed target once, at first. */
132
+ #reported;
133
+ constructor(callback, options) {
134
+ this.callback = callback;
135
+ this.options = options;
136
+ /** The targets this observer has reported on: a browser reports each newly observed target once, at first. */
137
+ this.#reported = new Set();
138
+ this.root = null;
139
+ this.rootMargin = '';
140
+ this.scrollMargin = '';
141
+ this.thresholds = [];
142
+ /** The elements observed now. */
143
+ this.targets = [];
144
+ this.isDisconnected = false;
145
+ FakeIntersectionObserver.all.push(this);
146
+ }
147
+ /** Replaces `globalThis.IntersectionObserver` with the fake and forgets the earlier observers. */
148
+ static install() {
149
+ FakeIntersectionObserver.all = [];
150
+ return swap({ name: 'IntersectionObserver', value: FakeIntersectionObserver });
151
+ }
152
+ /** Calls every observer of `element` with one entry. `ratio` is 1 when the element intersects and 0 when not, unless given. */
153
+ static flush(opts) {
154
+ const { element, isIntersecting, ratio = isIntersecting ? 1 : 0 } = opts;
155
+ const entry = intersectionEntryOf({ element, isIntersecting, ratio });
156
+ for (const observer of FakeIntersectionObserver.all) {
157
+ if (observer.targets.includes(element)) {
158
+ observer.#reported.add(element);
159
+ observer.callback([entry], observer);
160
+ }
161
+ }
162
+ }
163
+ /**
164
+ * The first report of a browser: every live observer is called, once per target it has not reported
165
+ * on yet, with the entry for `isIntersecting` (not intersecting by default). A target already
166
+ * reported on, by `settle` or `flush`, is skipped.
167
+ */
168
+ static settle(opts = {}) {
169
+ const { isIntersecting = false, ratio = isIntersecting ? 1 : 0 } = opts;
170
+ for (const observer of FakeIntersectionObserver.live()) {
171
+ const entries = observer.targets
172
+ .filter((element) => !observer.#reported.has(element))
173
+ .map((element) => {
174
+ observer.#reported.add(element);
175
+ return intersectionEntryOf({ element, isIntersecting, ratio });
176
+ });
177
+ if (entries.length > 0) {
178
+ observer.callback(entries, observer);
179
+ }
180
+ }
181
+ }
182
+ observe(target) {
183
+ if (!this.targets.includes(target)) {
184
+ this.targets.push(target);
185
+ }
186
+ }
187
+ unobserve(target) {
188
+ this.#reported.delete(target);
189
+ drop({ list: this.targets, item: target });
190
+ }
191
+ disconnect() {
192
+ this.isDisconnected = true;
193
+ this.targets.length = 0;
194
+ }
195
+ takeRecords() {
196
+ return [];
197
+ }
198
+ }
199
+ /** The `MediaQueryList` that `matchMedia` answers under `FakeMatchMedia.install`: one per query, `false` until `set`. */
200
+ export class FakeMatchMedia extends EventTarget {
201
+ /** The queries asked since the last `install`, with the list each one got. */
202
+ static { this.queries = new Map(); }
203
+ #listeners = new Set();
204
+ constructor(media, matches = false) {
205
+ super();
206
+ this.media = media;
207
+ this.matches = matches;
208
+ }
209
+ /** How many distinct `change` listeners are subscribed now, to assert a subscribe and an unsubscribe. */
210
+ get listenerCount() {
211
+ return this.#listeners.size;
212
+ }
213
+ addEventListener(type, listener, options) {
214
+ if (type === 'change' && listener) {
215
+ this.#listeners.add(listener);
216
+ }
217
+ super.addEventListener(type, listener, options);
218
+ }
219
+ removeEventListener(type, listener, options) {
220
+ if (type === 'change' && listener) {
221
+ this.#listeners.delete(listener);
222
+ }
223
+ super.removeEventListener(type, listener, options);
224
+ }
225
+ /** Replaces `window.matchMedia` with a function that answers the list of the query. */
226
+ static install() {
227
+ FakeMatchMedia.queries.clear();
228
+ return swap({
229
+ name: 'matchMedia',
230
+ value: (query) => FakeMatchMedia.of(query),
231
+ });
232
+ }
233
+ /** The list of `query`, made on the first ask. */
234
+ static of(query) {
235
+ const list = FakeMatchMedia.queries.get(query) ?? new FakeMatchMedia(query);
236
+ FakeMatchMedia.queries.set(query, list);
237
+ return list;
238
+ }
239
+ /** Sets whether `query` matches and tells its listeners with a `change` event. */
240
+ static set(opts) {
241
+ const list = FakeMatchMedia.of(opts.query);
242
+ list.matches = opts.matches;
243
+ list.dispatchEvent(new Event('change'));
244
+ }
245
+ }
246
+ /**
247
+ * A `Storage` that behaves like the real one: stored keys are own properties, so `Object.keys` lists
248
+ * them. Each way to fail has its own switch, and each can change at any time: `failReads` makes
249
+ * `getItem` throw `SecurityError`, `failListing` makes `key` and `length` throw it, `failWrites` makes
250
+ * `setItem` and `clear` throw `QuotaExceededError` and `removeItem` throw `SecurityError`. A key named like a member of the fake (`getItem`,
251
+ * `length`, `writes`, `failWrites` and the rest) would shadow it, so `setItem` throws a `TypeError`
252
+ * for it, where the real `Storage` accepts it.
253
+ */
254
+ export class FakeStorage {
255
+ #failReads = false;
256
+ #failListing = false;
257
+ #failWrites = false;
258
+ #writes = [];
259
+ get failReads() {
260
+ return this.#failReads;
261
+ }
262
+ set failReads(value) {
263
+ this.#failReads = value;
264
+ }
265
+ get failListing() {
266
+ return this.#failListing;
267
+ }
268
+ set failListing(value) {
269
+ this.#failListing = value;
270
+ }
271
+ get failWrites() {
272
+ return this.#failWrites;
273
+ }
274
+ set failWrites(value) {
275
+ this.#failWrites = value;
276
+ }
277
+ /** The values passed to `setItem` that the storage accepted, in order. */
278
+ get writes() {
279
+ return this.#writes;
280
+ }
281
+ get length() {
282
+ this.#assertListable();
283
+ return Object.keys(this).length;
284
+ }
285
+ /** Makes this the `localStorage` (the default) or the `sessionStorage` of the global. */
286
+ install(area = 'local') {
287
+ const name = area === 'session' ? 'sessionStorage' : 'localStorage';
288
+ return swap({ name, value: this });
289
+ }
290
+ getItem(key) {
291
+ this.#assertReadable();
292
+ const value = Object.getOwnPropertyDescriptor(this, key)?.value;
293
+ return typeof value === 'string' ? value : null;
294
+ }
295
+ setItem(key, value) {
296
+ this.#assertWritable('The quota has been exceeded', 'QuotaExceededError');
297
+ if (Object.hasOwn(FakeStorage.prototype, key)) {
298
+ throw new TypeError(`FakeStorage cannot store the key "${key}": it is a member of the fake`);
299
+ }
300
+ const text = String(value);
301
+ Object.defineProperty(this, key, {
302
+ value: text,
303
+ enumerable: true,
304
+ configurable: true,
305
+ writable: true,
306
+ });
307
+ this.#writes.push(text);
308
+ }
309
+ removeItem(key) {
310
+ this.#assertWritable('Access is denied', 'SecurityError');
311
+ Reflect.deleteProperty(this, key);
312
+ }
313
+ clear() {
314
+ this.#assertWritable('The quota has been exceeded', 'QuotaExceededError');
315
+ for (const key of Object.keys(this)) {
316
+ Reflect.deleteProperty(this, key);
317
+ }
318
+ }
319
+ key(index) {
320
+ this.#assertListable();
321
+ return Object.keys(this)[index] ?? null;
322
+ }
323
+ #assertListable() {
324
+ if (this.#failListing) {
325
+ throw new DOMException('Access is denied', 'SecurityError');
326
+ }
327
+ }
328
+ #assertReadable() {
329
+ if (this.#failReads) {
330
+ throw new DOMException('Access is denied', 'SecurityError');
331
+ }
332
+ }
333
+ #assertWritable(message, name) {
334
+ if (this.#failWrites) {
335
+ throw new DOMException(message, name);
336
+ }
337
+ }
338
+ }
339
+ /** A `navigator.clipboard` that keeps the text in memory; `isDenied` makes both methods reject as a refused permission does. */
340
+ export class FakeClipboard {
341
+ constructor() {
342
+ /** The text of every `writeText`, in order. */
343
+ this.written = [];
344
+ /** What `readText` answers; `writeText` replaces it. */
345
+ this.text = '';
346
+ this.isDenied = false;
347
+ }
348
+ /** Makes this the `navigator.clipboard`. */
349
+ install() {
350
+ return swap({ at: 'navigator', name: 'clipboard', value: this });
351
+ }
352
+ writeText(text) {
353
+ if (this.isDenied) {
354
+ return Promise.reject(new DOMException('Write permission denied', 'NotAllowedError'));
355
+ }
356
+ this.written.push(text);
357
+ this.text = text;
358
+ return Promise.resolve();
359
+ }
360
+ readText() {
361
+ if (this.isDenied) {
362
+ return Promise.reject(new DOMException('Read permission denied', 'NotAllowedError'));
363
+ }
364
+ return Promise.resolve(this.text);
365
+ }
366
+ }
367
+ //# sourceMappingURL=testing.js.map
@@ -1,4 +1,9 @@
1
1
  import { type IStorageCodec, type TStorageArea } from '../common/index.js';
2
+ /** What `BrowserStorage.subscribe` tells its listener about a change. */
3
+ export interface IStorageChange {
4
+ /** `true` when another tab or window changed the storage (a `storage` event); `false` for a write or removal through `BrowserStorage` in this one. */
5
+ isExternal: boolean;
6
+ }
2
7
  /**
3
8
  * `localStorage` and `sessionStorage` that never throw: a missing area, a blocked accessor, a quota
4
9
  * error or text the codec cannot read gives the fallback or `false`. Nothing touches `window` at
@@ -35,6 +40,7 @@ export declare class BrowserStorage {
35
40
  storage?: TStorageArea;
36
41
  codec?: IStorageCodec<TValue>;
37
42
  }): boolean;
43
+ /** Removes the key; `false` when it is under `LocalStorageKeys.PREFIX_AUTH`, when there is no such area, or when storage throws. */
38
44
  static remove(opts: {
39
45
  key: string;
40
46
  storage?: TStorageArea;
@@ -42,22 +48,28 @@ export declare class BrowserStorage {
42
48
  /** The keys of the area, only those that start with `prefix` when it is given. Lists the session keys too. */
43
49
  static keys(opts?: {
44
50
  storage?: TStorageArea;
51
+ /** @default '' */
45
52
  prefix?: string;
46
53
  }): Array<string>;
47
54
  /**
48
55
  * Removes every key that starts with `prefix` and answers how many it removed. An empty `prefix`
49
- * removes nothing, and a session key is never removed, as in `remove`. A key another tab removed
56
+ * removes nothing, and a session key is never removed, as in `remove`. Every subscriber of a key under the
57
+ * prefix is told, whether or not the key was stored. A key another tab removed
50
58
  * after the listing still counts: `removeItem` of a missing key does not throw.
51
59
  */
52
60
  static removeWhere(opts: {
53
61
  storage?: TStorageArea;
54
62
  prefix: string;
55
63
  }): number;
56
- /** `listener` runs after a write through `BrowserStorage` and after another tab changes the key. */
64
+ /**
65
+ * `listener` runs after a write through `BrowserStorage` and after another tab changes the key, and says which
66
+ * of the two it was in `change.isExternal`: a listener that writes back can skip the change of another tab, and one that
67
+ * shows "changed in another tab" can skip its own. A listener that takes no argument is called the same way.
68
+ */
57
69
  static subscribe(opts: {
58
70
  key: string;
59
71
  storage?: TStorageArea;
60
- listener: () => void;
72
+ listener: (change: IStorageChange) => void;
61
73
  }): () => void;
62
74
  private static listen;
63
75
  private static write;
@@ -53,6 +53,7 @@ export class BrowserStorage {
53
53
  },
54
54
  });
55
55
  }
56
+ /** Removes the key; `false` when it is under `LocalStorageKeys.PREFIX_AUTH`, when there is no such area, or when storage throws. */
56
57
  static remove(opts) {
57
58
  return BrowserStorage.write({ ...opts, run: (area) => area.removeItem(opts.key) });
58
59
  }
@@ -73,15 +74,30 @@ export class BrowserStorage {
73
74
  }
74
75
  /**
75
76
  * Removes every key that starts with `prefix` and answers how many it removed. An empty `prefix`
76
- * removes nothing, and a session key is never removed, as in `remove`. A key another tab removed
77
+ * removes nothing, and a session key is never removed, as in `remove`. Every subscriber of a key under the
78
+ * prefix is told, whether or not the key was stored. A key another tab removed
77
79
  * after the listing still counts: `removeItem` of a missing key does not throw.
78
80
  */
79
81
  static removeWhere(opts) {
80
82
  const { storage, prefix } = opts;
81
83
  const keys = prefix ? BrowserStorage.keys({ storage, prefix }) : [];
82
- return keys.filter((key) => BrowserStorage.remove({ key, storage })).length;
84
+ const removed = keys.filter((key) => BrowserStorage.remove({ key, storage })).length;
85
+ // A key not stored yet, with a write waiting for it, is under the prefix too: tell its subscribers.
86
+ if (prefix) {
87
+ BrowserStorage.notify({
88
+ key: undefined,
89
+ area: BrowserStorage.area({ storage }),
90
+ prefix,
91
+ isExternal: false,
92
+ });
93
+ }
94
+ return removed;
83
95
  }
84
- /** `listener` runs after a write through `BrowserStorage` and after another tab changes the key. */
96
+ /**
97
+ * `listener` runs after a write through `BrowserStorage` and after another tab changes the key, and says which
98
+ * of the two it was in `change.isExternal`: a listener that writes back can skip the change of another tab, and one that
99
+ * shows "changed in another tab" can skip its own. A listener that takes no argument is called the same way.
100
+ */
85
101
  static subscribe(opts) {
86
102
  const subscription = { ...opts };
87
103
  if (BrowserStorage.subs.size === 0) {
@@ -108,7 +124,7 @@ export class BrowserStorage {
108
124
  return BrowserStorage.safe({
109
125
  run: () => {
110
126
  opts.run(area);
111
- BrowserStorage.notify({ key: opts.key, area });
127
+ BrowserStorage.notify({ key: opts.key, area, isExternal: false });
112
128
  return true;
113
129
  },
114
130
  fallback: false,
@@ -116,15 +132,18 @@ export class BrowserStorage {
116
132
  }
117
133
  static notify(opts) {
118
134
  for (const { key, storage, listener } of BrowserStorage.subs) {
119
- if ((opts.key === null || opts.key === key) &&
135
+ if ((opts.key === null || opts.key === key || (!!opts.prefix && key.startsWith(opts.prefix))) &&
120
136
  opts.area === BrowserStorage.area({ storage })) {
121
- BrowserStorage.safe({ run: listener, fallback: undefined });
137
+ BrowserStorage.safe({
138
+ run: () => listener({ isExternal: opts.isExternal }),
139
+ fallback: undefined,
140
+ });
122
141
  }
123
142
  }
124
143
  }
125
144
  static { this.onEvent = (event) => {
126
145
  if ('key' in event && 'storageArea' in event) {
127
- BrowserStorage.notify({ key: event.key, area: event.storageArea });
146
+ BrowserStorage.notify({ key: event.key, area: event.storageArea, isExternal: true });
128
147
  }
129
148
  }; }
130
149
  }
@@ -1,4 +1,6 @@
1
+ /** Checks of the runtime. */
1
2
  export declare class BrowserUtility {
3
+ /** Whether a global `window` exists. */
2
4
  static isBrowser(): boolean;
3
5
  }
4
6
  //# sourceMappingURL=browser.d.ts.map
@@ -1,4 +1,6 @@
1
+ /** Checks of the runtime. */
1
2
  export class BrowserUtility {
3
+ /** Whether a global `window` exists. */
2
4
  static isBrowser() {
3
5
  return typeof window !== 'undefined';
4
6
  }
@@ -1,3 +1,4 @@
1
+ /** Helpers over `Blob` and file data. */
1
2
  export declare class FileUtility {
2
3
  /** The blob as a `data:` URL. */
3
4
  static toDataUrl(opts: {
@@ -1,3 +1,4 @@
1
+ /** Helpers over `Blob` and file data. */
1
2
  export class FileUtility {
2
3
  /** The blob as a `data:` URL. */
3
4
  static toDataUrl(opts) {
@@ -6,10 +6,14 @@ export declare const RUNTIME_CONFIG_GLOBAL = "__APP_CONFIG__";
6
6
  /** The `normalized.code` of the error `RuntimeConfig.get` throws for a required value that is not set; the key is in its `extra.key`. */
7
7
  export declare const RUNTIME_CONFIG_REQUIRED_CODE = "ardor.runtime_config.required";
8
8
  interface IRuntimeConfigOptions {
9
+ /** The name looked up in `window.__APP_CONFIG__` and in `buildTimeEnv`. */
9
10
  key: string;
11
+ /** The build-time source, normally `import.meta.env`. */
10
12
  buildTimeEnv?: Record<string, unknown>;
13
+ /** Used when neither source has a non-empty string for `key`. */
11
14
  defaultValue?: string;
12
15
  }
16
+ /** Reads configuration a deployment can change without a rebuild. */
13
17
  export declare class RuntimeConfig {
14
18
  /**
15
19
  * One config value: the runtime one (`window.__APP_CONFIG__`), else the build-time one
@@ -18,6 +18,7 @@ const readString = (opts) => {
18
18
  const value = Reflect.get(source, key);
19
19
  return typeof value === 'string' && value !== '' ? value : undefined;
20
20
  };
21
+ /** Reads configuration a deployment can change without a rebuild. */
21
22
  export class RuntimeConfig {
22
23
  static get(opts) {
23
24
  const { key, buildTimeEnv, defaultValue, required } = opts;
@@ -1,4 +1,5 @@
1
1
  import type { IStorageCodec } from '../common/index.js';
2
+ /** The codecs `BrowserStorage` takes, in place of its JSON default. */
2
3
  export declare class StorageCodecs {
3
4
  /** A bare string, not JSON. Create once; outside `allowed`, decode and encode throw. */
4
5
  static text<TText extends string = string>(opts?: {
@@ -1,4 +1,5 @@
1
1
  import { getError } from '@venizia/ignis-inversion';
2
+ /** The codecs `BrowserStorage` takes, in place of its JSON default. */
2
3
  export class StorageCodecs {
3
4
  /** A bare string, not JSON. Create once; outside `allowed`, decode and encode throw. */
4
5
  static text(opts = {}) {
@@ -1,3 +1,4 @@
1
+ /** Checks of a value's kind. */
1
2
  export declare class ValueUtility {
2
3
  /** Positional on purpose: a type predicate narrows its own parameter. */
3
4
  static isDefined<TValue>(value: TValue | null | undefined): value is TValue;
@@ -7,9 +8,11 @@ export declare class ValueUtility {
7
8
  static isNumber(opts: {
8
9
  value: unknown;
9
10
  }): boolean;
11
+ /** A non-null object that is not an array. */
10
12
  static isObject(opts: {
11
13
  value: unknown;
12
14
  }): boolean;
15
+ /** Whether `new Date(value)` is a valid date; takes a string, a number or a `Date`. */
13
16
  static isValidDate(opts: {
14
17
  value: string | number | Date;
15
18
  }): boolean;
@@ -1,3 +1,4 @@
1
+ /** Checks of a value's kind. */
1
2
  export class ValueUtility {
2
3
  /** Positional on purpose: a type predicate narrows its own parameter. */
3
4
  static isDefined(value) {
@@ -15,10 +16,12 @@ export class ValueUtility {
15
16
  }
16
17
  return !Number.isNaN(Number.parseFloat(String(value))) && Number.isFinite(Number(value));
17
18
  }
19
+ /** A non-null object that is not an array. */
18
20
  static isObject(opts) {
19
21
  const { value } = opts;
20
22
  return typeof value === 'object' && value !== null && !Array.isArray(value);
21
23
  }
24
+ /** Whether `new Date(value)` is a valid date; takes a string, a number or a `Date`. */
22
25
  static isValidDate(opts) {
23
26
  const date = new Date(opts.value);
24
27
  return !Number.isNaN(date.valueOf());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ardor-kernel",
3
- "version": "0.4.8-1",
3
+ "version": "0.4.8-10",
4
4
  "description": "ARDOR kernel - the isomorphic core of the ARDOR frontend framework: application base on IGNIS inversion, service and provider bases, request/auth constants, binding keys, the network request service, runtime config and the HTTP repository (from IGNIS). No React and no react-admin.",
5
5
  "keywords": [
6
6
  "ardor",
@@ -56,24 +56,28 @@
56
56
  "import": "./dist/base/repositories/index.js",
57
57
  "default": "./dist/base/repositories/index.js"
58
58
  },
59
+ "./testing": {
60
+ "types": "./dist/testing.d.ts",
61
+ "import": "./dist/testing.js",
62
+ "default": "./dist/testing.js"
63
+ },
59
64
  "./package.json": "./package.json"
60
65
  },
61
66
  "publishConfig": {
62
67
  "access": "public"
63
68
  },
64
69
  "scripts": {
65
- "force-update": "sh ../../scripts/build/force-update.sh",
66
70
  "prepublishOnly": "make rebuild"
67
71
  },
68
72
  "devDependencies": {
69
73
  "@size-limit/preset-small-lib": "^14.2.0",
70
74
  "@types/bun": "^1.4.3",
71
- "@venizia/dev-configs": "^0.4.8-0",
72
- "@venizia/ignis-connectors": "^0.4.8-0",
73
- "@venizia/ignis-filter": "^0.4.7-0",
74
- "@venizia/ignis-helpers": "^0.4.8-0",
75
- "@venizia/ignis-inversion": "^0.4.7-0",
76
- "@venizia/ignis-kernel": "^0.4.8-0",
75
+ "@venizia/dev-configs": "^0.4.8-5",
76
+ "@venizia/ignis-connectors": "^0.4.8-9",
77
+ "@venizia/ignis-filter": "^0.4.7-4",
78
+ "@venizia/ignis-helpers": "^0.4.8-8",
79
+ "@venizia/ignis-inversion": "^0.4.7-3",
80
+ "@venizia/ignis-kernel": "^0.4.8-9",
77
81
  "eslint": "^10.13.0",
78
82
  "oxlint": "1.89.0",
79
83
  "oxlint-tsgolint": "7.0.2004",
@@ -83,11 +87,11 @@
83
87
  "typescript": "^6.0.3"
84
88
  },
85
89
  "peerDependencies": {
86
- "@venizia/ignis-connectors": "^0.4.8-0",
87
- "@venizia/ignis-filter": "^0.4.7-0",
88
- "@venizia/ignis-helpers": "^0.4.8-0",
89
- "@venizia/ignis-inversion": "^0.4.7-0",
90
- "@venizia/ignis-kernel": "^0.4.8-0",
90
+ "@venizia/ignis-connectors": "^0.4.8-9",
91
+ "@venizia/ignis-filter": "^0.4.7-4",
92
+ "@venizia/ignis-helpers": "^0.4.8-8",
93
+ "@venizia/ignis-inversion": "^0.4.7-3",
94
+ "@venizia/ignis-kernel": "^0.4.8-9",
91
95
  "reflect-metadata": ">=0.2.2"
92
96
  },
93
97
  "peerDependenciesMeta": {
@@ -104,7 +108,12 @@
104
108
  "@venizia/ignis-inversion",
105
109
  "reflect-metadata"
106
110
  ],
107
- "limit": "7660 B"
111
+ "limit": "8440 B"
112
+ },
113
+ {
114
+ "path": "dist/testing.js",
115
+ "import": "*",
116
+ "limit": "1640 B"
108
117
  }
109
118
  ],
110
119
  "engines": {