@tstdl/base 0.90.69 → 0.90.71
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/dom/file-select-dialog.d.ts +7 -0
- package/dom/file-select-dialog.js +19 -0
- package/dom/index.d.ts +1 -0
- package/dom/index.js +1 -0
- package/object-storage/object-storage.d.ts +1 -0
- package/object-storage/s3/s3.object-storage.js +2 -2
- package/package.json +4 -3
- package/signals/index.d.ts +1 -2
- package/signals/index.js +1 -2
- package/signals/operators/combine.d.ts +9 -0
- package/signals/operators/combine.js +9 -0
- package/signals/{defer.d.ts → operators/defer.d.ts} +1 -1
- package/signals/{defer.js → operators/defer.js} +1 -1
- package/signals/operators/index.d.ts +3 -0
- package/signals/operators/index.js +3 -0
- package/signals/operators/map.d.ts +2 -0
- package/signals/operators/map.js +4 -0
- package/signals/{switch-map.d.ts → operators/switch-map.d.ts} +1 -1
- package/signals/{switch-map.js → operators/switch-map.js} +1 -1
- package/signals/untracked-operator.d.ts +2 -2
- package/signals/untracked-operator.js +1 -1
- package/text/dynamic-text.model.d.ts +2 -2
- package/text/dynamic-text.model.js +5 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OneOrMany } from '../types.js';
|
|
2
|
+
export type FileSelectDialogOptions = {
|
|
3
|
+
accept?: OneOrMany<string>;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
capture?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function openFileSelectDialog({ accept, multiple, capture }?: FileSelectDialogOptions): Promise<File[] | null>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isDefined, isString } from '../utils/type-guards.js';
|
|
2
|
+
export async function openFileSelectDialog({ accept, multiple, capture } = {}) {
|
|
3
|
+
const fileInput = document.createElement('input');
|
|
4
|
+
fileInput.type = 'file';
|
|
5
|
+
if (isDefined(accept)) {
|
|
6
|
+
fileInput.accept = isString(accept) ? accept : accept.join(',');
|
|
7
|
+
}
|
|
8
|
+
if (isDefined(multiple)) {
|
|
9
|
+
fileInput.multiple = multiple;
|
|
10
|
+
}
|
|
11
|
+
if (isDefined(capture)) {
|
|
12
|
+
fileInput.capture = capture;
|
|
13
|
+
}
|
|
14
|
+
fileInput.click();
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
fileInput.addEventListener('change', () => resolve(Array.from(fileInput.files ?? [])));
|
|
17
|
+
fileInput.addEventListener('cancel', () => resolve(null));
|
|
18
|
+
});
|
|
19
|
+
}
|
package/dom/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './file-select-dialog.js';
|
package/dom/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './file-select-dialog.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveArgumentType, type Resolvable } from '../injector/interfaces.js';
|
|
2
2
|
import type { ObjectMetadata, ObjectStorageObject } from './object.js';
|
|
3
3
|
export type UploadObjectOptions = {
|
|
4
|
+
contentLength?: number;
|
|
4
5
|
metadata?: ObjectMetadata;
|
|
5
6
|
};
|
|
6
7
|
export type ObjectStorageArgument = string;
|
|
@@ -55,13 +55,13 @@ let S3ObjectStorage = class S3ObjectStorage extends ObjectStorage {
|
|
|
55
55
|
async uploadObject(key, content, options) {
|
|
56
56
|
const bucketKey = this.getBucketKey(key);
|
|
57
57
|
if (isUint8Array(content)) {
|
|
58
|
-
await this.client.putObject(this.bucket, bucketKey, Buffer.from(content), options?.metadata);
|
|
58
|
+
await this.client.putObject(this.bucket, bucketKey, Buffer.from(content), options?.contentLength, options?.metadata);
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
const readable = Readable.fromWeb(content);
|
|
62
62
|
const errorPromise = new Promise((_, reject) => readable.on('error', reject));
|
|
63
63
|
await Promise.race([
|
|
64
|
-
this.client.putObject(this.bucket, bucketKey, readable, options?.metadata),
|
|
64
|
+
this.client.putObject(this.bucket, bucketKey, readable, options?.contentLength, options?.metadata),
|
|
65
65
|
errorPromise
|
|
66
66
|
]);
|
|
67
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.71",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"./decorators": "./decorators/index.js",
|
|
42
42
|
"./disposable": "./disposable/index.js",
|
|
43
43
|
"./distributed-loop": "./distributed-loop/index.js",
|
|
44
|
+
"./dom": "./dom/index.js",
|
|
44
45
|
"./enumerable": "./enumerable/index.js",
|
|
45
46
|
"./errors": "./errors/index.js",
|
|
46
47
|
"./file": "./file/index.js",
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"luxon": "^3.4",
|
|
111
112
|
"reflect-metadata": "^0.2",
|
|
112
113
|
"rxjs": "^7.8",
|
|
113
|
-
"type-fest": "4.
|
|
114
|
+
"type-fest": "4.17"
|
|
114
115
|
},
|
|
115
116
|
"devDependencies": {
|
|
116
117
|
"@mxssfd/typedoc-theme": "1.1",
|
|
@@ -151,7 +152,7 @@
|
|
|
151
152
|
"playwright": "^1.43",
|
|
152
153
|
"preact": "^10.20",
|
|
153
154
|
"preact-render-to-string": "^6.4",
|
|
154
|
-
"undici": "^6.
|
|
155
|
+
"undici": "^6.14",
|
|
155
156
|
"urlpattern-polyfill": "^10.0"
|
|
156
157
|
},
|
|
157
158
|
"peerDependenciesMeta": {
|
package/signals/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './api.js';
|
|
2
2
|
export * from './computed-with-dependencies.js';
|
|
3
|
-
export * from './defer.js';
|
|
4
3
|
export * from './effect-with-dependencies.js';
|
|
4
|
+
export * from './operators/index.js';
|
|
5
5
|
export * from './pipe.js';
|
|
6
|
-
export * from './switch-map.js';
|
|
7
6
|
export * from './to-lazy-signal.js';
|
|
8
7
|
export * from './types.js';
|
|
9
8
|
export * from './untracked-operator.js';
|
package/signals/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './api.js';
|
|
2
2
|
export * from './computed-with-dependencies.js';
|
|
3
|
-
export * from './defer.js';
|
|
4
3
|
export * from './effect-with-dependencies.js';
|
|
4
|
+
export * from './operators/index.js';
|
|
5
5
|
export * from './pipe.js';
|
|
6
|
-
export * from './switch-map.js';
|
|
7
6
|
export * from './to-lazy-signal.js';
|
|
8
7
|
export * from './types.js';
|
|
9
8
|
export * from './untracked-operator.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Signal } from '../api.js';
|
|
2
|
+
import type { UnwrappedSignal } from '../types.js';
|
|
3
|
+
export type CombineInput = Signal<any>[];
|
|
4
|
+
export declare function combine<const T extends Signal<any>[]>(sources: T): Signal<{
|
|
5
|
+
[I in keyof T]: UnwrappedSignal<T[I]>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function combine<const T extends Record<any, Signal<any>>>(sources: T): Signal<{
|
|
8
|
+
[P in keyof T]: UnwrappedSignal<T[P]>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { mapObjectValues } from '../../utils/object/object.js';
|
|
2
|
+
import { isArray } from '../../utils/type-guards.js';
|
|
3
|
+
import { computed } from '../api.js';
|
|
4
|
+
export function combine(sources) {
|
|
5
|
+
const computation = isArray(sources)
|
|
6
|
+
? () => sources.map((source) => source())
|
|
7
|
+
: () => mapObjectValues(sources, (source) => source());
|
|
8
|
+
return computed(computation);
|
|
9
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Signal } from '
|
|
1
|
+
import { type Signal } from '../api.js';
|
|
2
2
|
export declare function defer<T>(signalFactory: () => Signal<T>): Signal<T>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Signal } from '../api.js';
|
|
2
2
|
export declare function switchMap<T>(source: () => Signal<T>): Signal<T>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
/**
|
|
1
|
+
import { type MonoTypeOperatorFunction } from 'rxjs';
|
|
2
|
+
/** Wraps observer in {@link untracked} */
|
|
3
3
|
export declare function runInUntracked<T>(): MonoTypeOperatorFunction<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { untracked } from './api.js';
|
|
3
|
-
/**
|
|
3
|
+
/** Wraps observer in {@link untracked} */
|
|
4
4
|
export function runInUntracked() {
|
|
5
5
|
return function runInUntracked(source) {
|
|
6
6
|
return new Observable((subscriber) => source.subscribe({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type Observable } from 'rxjs';
|
|
2
|
+
import { type Signal } from '../signals/api.js';
|
|
3
3
|
import type { PickBy, ReactiveValue, ReplaceKey } from '../types.js';
|
|
4
4
|
import type { LocalizableText } from './localizable-text.model.js';
|
|
5
5
|
import { LocalizationService } from './localization.service.js';
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { isObservable } from 'rxjs';
|
|
2
2
|
import { inject } from '../injector/inject.js';
|
|
3
3
|
import { computed, isSignal, toObservable, toSignal, untracked } from '../signals/api.js';
|
|
4
|
-
import { switchMap } from '../signals/switch-map.js';
|
|
4
|
+
import { switchMap } from '../signals/operators/switch-map.js';
|
|
5
5
|
import { runInUntracked } from '../signals/untracked-operator.js';
|
|
6
6
|
import { isString } from '../utils/type-guards.js';
|
|
7
7
|
import { LocalizationService } from './localization.service.js';
|
|
8
8
|
export const missingLocalizationKeyText = '[MISSING LOCALIZATION KEY]';
|
|
9
9
|
export function resolveDynamicText(text, localizationService = inject(LocalizationService)) {
|
|
10
|
-
const localizableTextSignal = isSignal(text)
|
|
11
|
-
|
|
10
|
+
const localizableTextSignal = isSignal(text)
|
|
11
|
+
? text
|
|
12
|
+
: isObservable(text)
|
|
13
|
+
? untracked(() => toSignal(text.pipe(runInUntracked()), { initialValue: missingLocalizationKeyText }))
|
|
12
14
|
: computed(() => text);
|
|
13
15
|
return switchMap(() => {
|
|
14
16
|
const localizableText = localizableTextSignal();
|