@sevtech/kit 0.0.1
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 -0
- package/fesm2022/http.mjs +1292 -0
- package/fesm2022/http.mjs.map +1 -0
- package/fesm2022/localization.mjs +344 -0
- package/fesm2022/localization.mjs.map +1 -0
- package/fesm2022/misc.mjs +352 -0
- package/fesm2022/misc.mjs.map +1 -0
- package/fesm2022/ng-misc.mjs +132 -0
- package/fesm2022/ng-misc.mjs.map +1 -0
- package/fesm2022/ng-sw.mjs +269 -0
- package/fesm2022/ng-sw.mjs.map +1 -0
- package/fesm2022/sevtech-kit.mjs +6 -0
- package/fesm2022/sevtech-kit.mjs.map +1 -0
- package/fesm2022/sw-scripts.mjs +92 -0
- package/fesm2022/sw-scripts.mjs.map +1 -0
- package/fesm2022/sw-shared.mjs +32 -0
- package/fesm2022/sw-shared.mjs.map +1 -0
- package/fesm2022/ui-yoda.mjs +583 -0
- package/fesm2022/ui-yoda.mjs.map +1 -0
- package/fesm2022/ui.mjs +133 -0
- package/fesm2022/ui.mjs.map +1 -0
- package/http/index.d.ts +977 -0
- package/index.d.ts +2 -0
- package/localization/index.d.ts +89 -0
- package/misc/index.d.ts +509 -0
- package/ng-misc/index.d.ts +199 -0
- package/package.json +94 -0
- package/service-worker/index.d.ts +109 -0
- package/service-worker/scripts/index.d.ts +52 -0
- package/service-worker/shared/index.d.ts +40 -0
- package/ui/index.d.ts +46 -0
- package/ui/yoda/index.d.ts +186 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Observable, Subscriber } from 'rxjs';
|
|
2
|
+
import { Route } from '@angular/router';
|
|
3
|
+
import { ComponentRef, OutputRef, QueryList, InputSignalWithTransform, InjectionToken, ViewContainerRef } from '@angular/core';
|
|
4
|
+
import { FormArray, FormControl, FormGroup, FormRecord } from '@angular/forms';
|
|
5
|
+
import { NgComponentOutlet } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Создаёт Observable который эмитит при изменении размеров элемента
|
|
9
|
+
* @example
|
|
10
|
+
* resizeObservable(elementRef.nativeElement).subscribe(entries => {
|
|
11
|
+
* console.log(entries[0].contentRect.width);
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
declare function resizeObservable(element: HTMLElement): Observable<ResizeObserverEntry[]>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Transform-функция для булевых HTML-атрибутов.
|
|
18
|
+
* В отличие от `booleanAttribute`, возвращает `true | undefined` вместо `boolean`,
|
|
19
|
+
* что позволяет корректно использовать атрибут в шаблоне — атрибут либо присутствует, либо отсутствует.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* class MyComponent {
|
|
23
|
+
* disabled = input(undefined, { transform: htmlBooleanAttribute });
|
|
24
|
+
* // <my-component disabled /> → true
|
|
25
|
+
* // <my-component /> → undefined
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
declare function htmlBooleanAttribute(value: unknown): true | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Синхронное или асинхронное значение (Promise/Observable)
|
|
32
|
+
* @example
|
|
33
|
+
* async function fetchData(source: MaybeAsync<string>): Promise<Data> {
|
|
34
|
+
* if (source instanceof Observable) {
|
|
35
|
+
* return firstValueFrom(source.pipe(map(parseData)));
|
|
36
|
+
* }
|
|
37
|
+
* // ... обработка Promise и синхронного значения
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
type MaybeAsync<T> = T | Observable<T> | Promise<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Извлекает тип значения из асинхронных оберток (Observable, Promise)
|
|
43
|
+
* @example
|
|
44
|
+
* type T = ExtractAsync<Observable<string>>; // string
|
|
45
|
+
* type T = ExtractAsync<Promise<number>>; // number
|
|
46
|
+
*/
|
|
47
|
+
type ExtractAsync<T> = T extends Subscriber<infer U> ? U : T extends Observable<infer U> ? U : Awaited<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Извлекает тип значения из InjectionToken
|
|
50
|
+
* @example
|
|
51
|
+
* const TOKEN = new InjectionToken<AppConfig>('app.config');
|
|
52
|
+
* type T = ExtractToken<typeof TOKEN>; // AppConfig
|
|
53
|
+
*/
|
|
54
|
+
type ExtractTokenType<T> = T extends InjectionToken<infer U> ? U : never;
|
|
55
|
+
/**
|
|
56
|
+
* Извлекает тип компонента из ComponentRef
|
|
57
|
+
* @example
|
|
58
|
+
* const ref: ComponentRef<AppComponent>;
|
|
59
|
+
* type T = ExtractComponentRef<typeof ref>; // AppComponent
|
|
60
|
+
*/
|
|
61
|
+
type ExtractComponentRef<T> = T extends ComponentRef<infer U> ? U : never;
|
|
62
|
+
/**
|
|
63
|
+
* Извлекает тип значения FormControl
|
|
64
|
+
*/
|
|
65
|
+
type ExtractFormControl<T> = T extends FormControl<infer U> ? U : never;
|
|
66
|
+
/**
|
|
67
|
+
* Извлекает тип элементов FormArray
|
|
68
|
+
*/
|
|
69
|
+
type ExtractFormArray<T> = T extends FormArray<infer U> ? U : never;
|
|
70
|
+
/**
|
|
71
|
+
* Извлекает тип значения FormGroup
|
|
72
|
+
*/
|
|
73
|
+
type ExtractFormGroup<T> = T extends FormGroup<infer U> ? U : never;
|
|
74
|
+
/**
|
|
75
|
+
* Извлекает тип значения FormRecord
|
|
76
|
+
*/
|
|
77
|
+
type ExtractFormRecord<T> = T extends FormRecord<infer U> ? U : never;
|
|
78
|
+
/**
|
|
79
|
+
* Извлекает тип элементов QueryList
|
|
80
|
+
* @example
|
|
81
|
+
* const items!: QueryList<ItemComponent>;
|
|
82
|
+
* type ItemsType = ExtractQueryList<typeof this.items>; // ItemComponent
|
|
83
|
+
*/
|
|
84
|
+
type ExtractQueryList<T> = T extends QueryList<infer U> ? U : never;
|
|
85
|
+
type ExtractSignalInputKey<Component, Key extends keyof Component> = Component[Key] extends InputSignalWithTransform<infer _, infer TransformFn> ? Key : never;
|
|
86
|
+
type ExtractSignalInputType<Signal> = Signal extends InputSignalWithTransform<infer Data, infer _> ? Data : never;
|
|
87
|
+
/**
|
|
88
|
+
* Извлекает все input-свойства компонента с сигналами
|
|
89
|
+
* @template Component - Тип Angular компонента
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* class MyComponent {
|
|
93
|
+
* title = input.required<string>();
|
|
94
|
+
* active = input<boolean>(true);
|
|
95
|
+
* protected template = input<string>('');
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* type Inputs = ExtractSignalInputs<MyComponent>; // { title: string; active: boolean }
|
|
99
|
+
*/
|
|
100
|
+
type ExtractSignalInputs<Component> = {
|
|
101
|
+
[Key in keyof Component as ExtractSignalInputKey<Component, Key>]: ExtractSignalInputType<Component[Key]>;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Извлекает все output-свойства компонента
|
|
105
|
+
* @example
|
|
106
|
+
* class MyComponent {
|
|
107
|
+
* clicked = output<string>();
|
|
108
|
+
* }
|
|
109
|
+
*
|
|
110
|
+
* type Outputs = ExtractOutputs<MyComponent>; // { clicked: OutputRef<Event> }
|
|
111
|
+
*/
|
|
112
|
+
type ExtractOutputs<T> = {
|
|
113
|
+
[K in keyof T as T[K] extends OutputRef<infer _> ? K : never]: T[K];
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* @extends {Route}
|
|
117
|
+
*/
|
|
118
|
+
interface DataRoute<Data extends Record<string | symbol, unknown>> extends Route {
|
|
119
|
+
data: Data;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @extends {Routes}
|
|
123
|
+
*/
|
|
124
|
+
type DataRoutes<Data extends Record<string | symbol, unknown>> = (DataRoute<Data> | Route)[];
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Проверяет, является ли значение экземпляром FormControl
|
|
128
|
+
* @example
|
|
129
|
+
* const control = new FormControl<string>('');
|
|
130
|
+
* if (isFormControl<string>(control)) {
|
|
131
|
+
* // control is FormControl<string>
|
|
132
|
+
* }
|
|
133
|
+
*/
|
|
134
|
+
declare function isFormControl<T = unknown>(data: unknown): data is FormControl<T>;
|
|
135
|
+
/**
|
|
136
|
+
* Проверяет, является ли значение экземпляром FormGroup
|
|
137
|
+
* @example
|
|
138
|
+
* const group = new FormGroup({ name: new FormControl('') });
|
|
139
|
+
* if (isFormGroup(group)) {
|
|
140
|
+
* // group is FormGroup
|
|
141
|
+
* }
|
|
142
|
+
*/
|
|
143
|
+
declare function isFormGroup(data: unknown): data is FormGroup;
|
|
144
|
+
/**
|
|
145
|
+
* Проверяет, является ли значение экземпляром FormArray
|
|
146
|
+
* @example
|
|
147
|
+
* const array = new FormArray([new FormControl('')]);
|
|
148
|
+
* if (isFormArray(array)) {
|
|
149
|
+
* // array is FormArray
|
|
150
|
+
* }
|
|
151
|
+
*/
|
|
152
|
+
declare function isFormArray(data: unknown): data is FormArray;
|
|
153
|
+
/**
|
|
154
|
+
* Проверяет, является ли значение экземпляром FormRecord
|
|
155
|
+
* @example
|
|
156
|
+
* const record = new FormRecord({ field: new FormControl('') });
|
|
157
|
+
* if (isFormRecord(record)) {
|
|
158
|
+
* // record is FormRecord
|
|
159
|
+
* }
|
|
160
|
+
*/
|
|
161
|
+
declare function isFormRecord(data: unknown): data is FormRecord;
|
|
162
|
+
/**
|
|
163
|
+
* Проверяет, является ли значение экземпляром ViewContainerRef
|
|
164
|
+
* @example
|
|
165
|
+
* class MyComponent {
|
|
166
|
+
* constructor(public vcr: ViewContainerRef) {}
|
|
167
|
+
*
|
|
168
|
+
* checkType() {
|
|
169
|
+
* if (isViewContainer(this.vcr)) {
|
|
170
|
+
* // this.vcr is ViewContainerRef
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
*/
|
|
175
|
+
declare function isViewContainer(data: unknown): data is ViewContainerRef;
|
|
176
|
+
/**
|
|
177
|
+
* Проверяет, является ли значение экземпляром ComponentRef
|
|
178
|
+
* @example
|
|
179
|
+
* const componentRef = this.componentFactory.create(injector);
|
|
180
|
+
* if (isComponentRef<MyComponent>(componentRef)) {
|
|
181
|
+
* // componentRef is ComponentRef<MyComponent>
|
|
182
|
+
* }
|
|
183
|
+
*/
|
|
184
|
+
declare function isComponentRef<Instance>(data: unknown): data is ComponentRef<Instance>;
|
|
185
|
+
/**
|
|
186
|
+
* Проверяет, является ли значение экземпляром NgComponentOutlet
|
|
187
|
+
* @example
|
|
188
|
+
* class HostComponent {
|
|
189
|
+
* checkOutlet(outlet: unknown) {
|
|
190
|
+
* if (isComponentOutlet(outlet)) {
|
|
191
|
+
* // outlet is NgComponentOutlet
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
* }
|
|
195
|
+
*/
|
|
196
|
+
declare function isComponentOutlet(data: unknown): data is NgComponentOutlet;
|
|
197
|
+
|
|
198
|
+
export { htmlBooleanAttribute, isComponentOutlet, isComponentRef, isFormArray, isFormControl, isFormGroup, isFormRecord, isViewContainer, resizeObservable };
|
|
199
|
+
export type { DataRoute, DataRoutes, ExtractAsync, ExtractComponentRef, ExtractFormArray, ExtractFormControl, ExtractFormGroup, ExtractFormRecord, ExtractOutputs, ExtractQueryList, ExtractSignalInputs, ExtractTokenType, MaybeAsync };
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sevtech/kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@angular/common": "^20.0.0",
|
|
13
|
+
"@angular/core": "^20.0.0",
|
|
14
|
+
"@angular/forms": "^20.0.0",
|
|
15
|
+
"@angular/router": "^20.0.0",
|
|
16
|
+
"@ngx-translate/core": "^17.0.0",
|
|
17
|
+
"@ngx-translate/http-loader": "17.0.0",
|
|
18
|
+
"primeng": "^20.0.0",
|
|
19
|
+
"rxjs": "^7.8.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependenciesMeta": {
|
|
22
|
+
"@angular/common": {
|
|
23
|
+
"optional": true
|
|
24
|
+
},
|
|
25
|
+
"@angular/core": {
|
|
26
|
+
"optional": true
|
|
27
|
+
},
|
|
28
|
+
"@angular/forms": {
|
|
29
|
+
"optional": true
|
|
30
|
+
},
|
|
31
|
+
"@angular/router": {
|
|
32
|
+
"optional": true
|
|
33
|
+
},
|
|
34
|
+
"@ngx-translate/core": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"@ngx-translate/http-loader": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"primeng": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"rxjs": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"module": "fesm2022/sevtech-kit.mjs",
|
|
48
|
+
"typings": "index.d.ts",
|
|
49
|
+
"exports": {
|
|
50
|
+
"./package.json": {
|
|
51
|
+
"default": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
".": {
|
|
54
|
+
"types": "./index.d.ts",
|
|
55
|
+
"default": "./fesm2022/sevtech-kit.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./http": {
|
|
58
|
+
"types": "./http/index.d.ts",
|
|
59
|
+
"default": "./fesm2022/http.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./localization": {
|
|
62
|
+
"types": "./localization/index.d.ts",
|
|
63
|
+
"default": "./fesm2022/localization.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./misc": {
|
|
66
|
+
"types": "./misc/index.d.ts",
|
|
67
|
+
"default": "./fesm2022/misc.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./ng-misc": {
|
|
70
|
+
"types": "./ng-misc/index.d.ts",
|
|
71
|
+
"default": "./fesm2022/ng-misc.mjs"
|
|
72
|
+
},
|
|
73
|
+
"./service-worker": {
|
|
74
|
+
"types": "./service-worker/index.d.ts",
|
|
75
|
+
"default": "./fesm2022/ng-sw.mjs"
|
|
76
|
+
},
|
|
77
|
+
"./service-worker/scripts": {
|
|
78
|
+
"types": "./service-worker/scripts/index.d.ts",
|
|
79
|
+
"default": "./fesm2022/sw-scripts.mjs"
|
|
80
|
+
},
|
|
81
|
+
"./service-worker/shared": {
|
|
82
|
+
"types": "./service-worker/shared/index.d.ts",
|
|
83
|
+
"default": "./fesm2022/sw-shared.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./ui": {
|
|
86
|
+
"types": "./ui/index.d.ts",
|
|
87
|
+
"default": "./fesm2022/ui.mjs"
|
|
88
|
+
},
|
|
89
|
+
"./ui/yoda": {
|
|
90
|
+
"types": "./ui/yoda/index.d.ts",
|
|
91
|
+
"default": "./fesm2022/ui-yoda.mjs"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ReceiveVariants, ChannelMessage, PostVariants, PostParameters } from '@sevtech/kit/service-worker/shared';
|
|
3
|
+
export { PostMessage, PostVariants, ReceiveMessage, ReceiveVariants, isPostMessage, isReceiveMessage, isSameAction, isSameChannel } from '@sevtech/kit/service-worker/shared';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { Provider } from '@angular/core';
|
|
6
|
+
import { MaybeAsync } from '@sevtech/kit/ng-misc';
|
|
7
|
+
|
|
8
|
+
declare class ServiceWorkerService<Receive extends ReceiveVariants> {
|
|
9
|
+
private readonly config;
|
|
10
|
+
private readonly ping$;
|
|
11
|
+
private readonly worker$;
|
|
12
|
+
private readonly messageFilter;
|
|
13
|
+
private readonly receiveStream$;
|
|
14
|
+
private readonly messages$;
|
|
15
|
+
constructor();
|
|
16
|
+
listen<Channel extends string>(channel: Channel): Observable<ChannelMessage<Receive, Channel>>;
|
|
17
|
+
postMessage<Channel extends string>(channel: Channel, action: string, payload?: unknown): Promise<void>;
|
|
18
|
+
requestMessage<Channel extends string, Return = unknown>(channel: Channel, action: string, options?: {
|
|
19
|
+
payload?: unknown;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}): Promise<Return>;
|
|
22
|
+
private cleanupRequestMessage;
|
|
23
|
+
private getWorker;
|
|
24
|
+
private prepareMessage;
|
|
25
|
+
private pingWorker;
|
|
26
|
+
private canSendMessage;
|
|
27
|
+
private prepareSendData;
|
|
28
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ServiceWorkerService<any>, never>;
|
|
29
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ServiceWorkerService<any>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare abstract class CommonChannel<Send extends PostVariants, Receive extends ReceiveVariants, Channel extends string> {
|
|
33
|
+
protected abstract channel: Channel;
|
|
34
|
+
protected readonly serviceWorker: ServiceWorkerService<Receive>;
|
|
35
|
+
protected listen<const Action extends Receive['action']>(action: Action): Observable<ChannelMessage<Receive & {
|
|
36
|
+
action: Action;
|
|
37
|
+
}, Channel>>;
|
|
38
|
+
protected postMessage<const Action extends Send['action']>(...[action, payload]: PostParameters<Send, Action>): Promise<void>;
|
|
39
|
+
protected requestMessage<const Action extends Send['action']>(...[action, payload]: PostParameters<Send, Action>): Promise<Receive & {
|
|
40
|
+
action: Action;
|
|
41
|
+
}>;
|
|
42
|
+
private postErrorHandler;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare enum ErrorCodes {
|
|
46
|
+
ActivationTimeout = "ACTIVATION_TIMEOUT",
|
|
47
|
+
RequestTimeout = "REQUEST_TIMEOUT",
|
|
48
|
+
PostMessage = "POST_MESSAGE",
|
|
49
|
+
Unavailable = "UNAVAILABLE",
|
|
50
|
+
PortError = "PORT_ERROR",
|
|
51
|
+
Blocked = "BLOCKED",
|
|
52
|
+
Ping = "PING"
|
|
53
|
+
}
|
|
54
|
+
declare class ServiceWorkerError extends Error {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly payload: unknown;
|
|
57
|
+
readonly code: ErrorCodes;
|
|
58
|
+
constructor(code: ErrorCodes, payload?: unknown, cause?: unknown);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type MessageFilterFunction = (message: unknown) => MaybeAsync<boolean>;
|
|
62
|
+
interface Config {
|
|
63
|
+
/**
|
|
64
|
+
* Настройки получения активного сервис-воркера
|
|
65
|
+
*/
|
|
66
|
+
active: {
|
|
67
|
+
/**
|
|
68
|
+
* Таймаут ожидания активации сервис-воркера
|
|
69
|
+
* @description Если сервис-воркер не активируется за указанное время — выбрасывается ошибка и запускается повторная попытка
|
|
70
|
+
* @default 10_000
|
|
71
|
+
*/
|
|
72
|
+
timeout: number;
|
|
73
|
+
/**
|
|
74
|
+
* Количество повторных попыток при таймауте активации
|
|
75
|
+
* @default 3
|
|
76
|
+
*/
|
|
77
|
+
retryCount: number;
|
|
78
|
+
/**
|
|
79
|
+
* Задержка между повторными попытками в мс
|
|
80
|
+
* @default 2000
|
|
81
|
+
*/
|
|
82
|
+
retryDelay: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Таймаут ожидания ответа
|
|
86
|
+
* @description Если сервис-воркер не ответил за указанное время — промис реджектится с ошибкой RequestTimeout
|
|
87
|
+
* @default 8000
|
|
88
|
+
*/
|
|
89
|
+
requestTimeout: number;
|
|
90
|
+
/**
|
|
91
|
+
* Таймаут ожидания ответа на ping
|
|
92
|
+
* @description Если сервис-воркер не ответил на ping за указанное время — считается недоступным
|
|
93
|
+
* @default 5000
|
|
94
|
+
*/
|
|
95
|
+
pingTimeout: number;
|
|
96
|
+
}
|
|
97
|
+
type ServiceWorkerConfig = Partial<Omit<Config, 'active'>> & {
|
|
98
|
+
active?: Partial<Config['active']>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
declare function provideServiceWorkerPing(observable: Observable<unknown>): Provider;
|
|
102
|
+
declare function provideServiceWorkerPing(observableFunction: () => Observable<unknown>): Provider;
|
|
103
|
+
declare function provideServiceWorkerMessageFilter(filter: MessageFilterFunction): Provider;
|
|
104
|
+
declare function provideServiceWorkerMessageFilter(filter: () => MessageFilterFunction, inject: true): Provider;
|
|
105
|
+
declare function provideServiceWorkerConfig(config: ServiceWorkerConfig): Provider;
|
|
106
|
+
declare function provideServiceWorkerConfig(config: () => ServiceWorkerConfig): Provider;
|
|
107
|
+
|
|
108
|
+
export { CommonChannel as ServiceWorkerChannel, ServiceWorkerError, provideServiceWorkerConfig, provideServiceWorkerMessageFilter, provideServiceWorkerPing };
|
|
109
|
+
export type { ServiceWorkerConfig };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PostVariants, ReceiveMessage } from '@sevtech/kit/service-worker/shared';
|
|
2
|
+
export { PostMessage, PostParameters, isPostMessage, isReceiveMessage } from '@sevtech/kit/service-worker/shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Обрабатывает служебные сообщения библиотеки
|
|
6
|
+
*/
|
|
7
|
+
declare function defineSystemChannel(): void;
|
|
8
|
+
|
|
9
|
+
type ActionHandler<Payload = unknown> = (payload: Payload, event: ExtendableMessageEvent) => void | Promise<void>;
|
|
10
|
+
type ChannelHandlerMap<Send extends PostVariants> = {
|
|
11
|
+
[K in Send['action']]: ActionHandler<Extract<Send, {
|
|
12
|
+
action: K;
|
|
13
|
+
}> extends {
|
|
14
|
+
payload: infer P;
|
|
15
|
+
} ? P : undefined>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Создаёт обработчик канала для использования в handleChannels
|
|
19
|
+
* @param channel - имя канала (должно совпадать с channel на Angular стороне)
|
|
20
|
+
* @param handlers - карта обработчиков по action
|
|
21
|
+
*/
|
|
22
|
+
declare function defineChannel<Send extends PostVariants>(channel: string, handlers: ChannelHandlerMap<Send>): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Обрабатывает сообщения которые приходят из Angular service.
|
|
26
|
+
* Системный канал (PING) подключается автоматически.
|
|
27
|
+
|
|
28
|
+
* @example
|
|
29
|
+
* self.addEventListener('message', handleByChannels);
|
|
30
|
+
*/
|
|
31
|
+
declare function handleChannels(event: ExtendableMessageEvent): boolean;
|
|
32
|
+
|
|
33
|
+
interface NotifyOptions {
|
|
34
|
+
/** Отправить только этим клиентам (ID или массив ID) */
|
|
35
|
+
clients?: string | string[];
|
|
36
|
+
/** Исключить этих клиентов (ID или массив ID) */
|
|
37
|
+
exclude?: string | string[];
|
|
38
|
+
/** Тип клиентов. По умолчанию 'window' */
|
|
39
|
+
type?: ClientQueryOptions['type'];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Отправляет сообщение клиентам (вкладкам), контролируемым данным сервис-воркером.
|
|
43
|
+
*
|
|
44
|
+
* По умолчанию — всем window-клиентам.
|
|
45
|
+
* Через options.clients — только указанным.
|
|
46
|
+
* Через options.exclude — всем кроме указанных.
|
|
47
|
+
*/
|
|
48
|
+
declare function notifyClients<Action extends string, Message = never>(message: {
|
|
49
|
+
channel: string;
|
|
50
|
+
} & ReceiveMessage<Action, Message>, options?: NotifyOptions): Promise<void>;
|
|
51
|
+
|
|
52
|
+
export { defineChannel, defineSystemChannel, handleChannels, notifyClients };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type PostVariants = PostMessage<string> | PostMessage<string, never>;
|
|
2
|
+
type ReceiveVariants = ReceiveMessage<string> | ReceiveMessage<string, never>;
|
|
3
|
+
type ChannelMessage<Message, Channel extends string> = Message & {
|
|
4
|
+
channel: Channel;
|
|
5
|
+
};
|
|
6
|
+
type PostParameters<Config, Action> = Extract<Config, {
|
|
7
|
+
action: Action;
|
|
8
|
+
}> extends {
|
|
9
|
+
payload: infer P;
|
|
10
|
+
} ? [Action, P] : [Action];
|
|
11
|
+
type PostMessage<Action, Payload = unknown> = [Payload] extends [never] ? {
|
|
12
|
+
action: Action;
|
|
13
|
+
} : {
|
|
14
|
+
action: Action;
|
|
15
|
+
payload: Payload;
|
|
16
|
+
};
|
|
17
|
+
type ReceiveMessage<Action, Message = unknown> = [Message] extends [never] ? {
|
|
18
|
+
action: Action;
|
|
19
|
+
} : {
|
|
20
|
+
action: Action;
|
|
21
|
+
message: Message;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare const SYSTEM_CHANNEL: "SYSTEM_CHANNEL";
|
|
25
|
+
declare const SYSTEM_ACTIONS: {
|
|
26
|
+
/** Пинг сервис воркера */
|
|
27
|
+
readonly Ping: "PING";
|
|
28
|
+
/** Ответ на пинг от сервиса воркера */
|
|
29
|
+
readonly Pong: "PONG";
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare function isPostMessage<T extends PostVariants, Channel extends string>(message: unknown): message is ChannelMessage<T, Channel>;
|
|
33
|
+
declare function isReceiveMessage<Receive extends ReceiveVariants>(message: unknown): message is ChannelMessage<Receive, string>;
|
|
34
|
+
declare function isSameChannel<Channel extends string, Receive extends ReceiveVariants>(message: ChannelMessage<Receive, string>, channel: Channel): message is ChannelMessage<Receive, Channel>;
|
|
35
|
+
declare function isSameAction<Receive extends ReceiveVariants, Action>(message: Receive, action: Action): message is ChannelMessage<Receive & {
|
|
36
|
+
action: Action;
|
|
37
|
+
}, string>;
|
|
38
|
+
|
|
39
|
+
export { SYSTEM_ACTIONS, SYSTEM_CHANNEL, isPostMessage, isReceiveMessage, isSameAction, isSameChannel };
|
|
40
|
+
export type { ChannelMessage, PostMessage, PostParameters, PostVariants, ReceiveMessage, ReceiveVariants };
|
package/ui/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { PipeTransform, Type } from '@angular/core';
|
|
3
|
+
import { SafeAny, DeepKeys, PickKey } from '@sevtech/kit/misc';
|
|
4
|
+
import { SafeUrl, SafeHtml, SafeStyle, SafeScript, SafeResourceUrl } from '@angular/platform-browser';
|
|
5
|
+
|
|
6
|
+
declare class PickKeyPipe implements PipeTransform {
|
|
7
|
+
transform<const Object extends Record<string, SafeAny>, const Path extends DeepKeys<Object>, const Fallback extends unknown>(object: Object, path: Path, fallback?: Fallback): PickKey<Object, Path> extends Object ? Fallback : PickKey<Object, Path>;
|
|
8
|
+
transform<const Object extends Record<string, SafeAny>, const Path extends DeepKeys<Object, Separator>, const Separator extends string, const Fallback extends unknown>(object: Object, path: Path, fallback?: Fallback, separator?: Separator): PickKey<Object, Path> extends Object ? Fallback : PickKey<Object, Path>;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PickKeyPipe, never>;
|
|
10
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<PickKeyPipe, "pickKey", true>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class SafePipe implements PipeTransform {
|
|
14
|
+
private readonly sanitizer;
|
|
15
|
+
transform(value: string, context: 'url'): SafeUrl;
|
|
16
|
+
transform(value: string, context: 'html'): SafeHtml;
|
|
17
|
+
transform(value: string, context: 'style'): SafeStyle;
|
|
18
|
+
transform(value: string, context: 'script'): SafeScript;
|
|
19
|
+
transform(value: string, context: 'resourceUrl'): SafeResourceUrl;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SafePipe, never>;
|
|
21
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SafePipe, "safe", true>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class EllipsisDirective {
|
|
25
|
+
private readonly destroyRef;
|
|
26
|
+
private readonly element;
|
|
27
|
+
private readonly styles;
|
|
28
|
+
private readonly textContent$$;
|
|
29
|
+
readonly ellipsis: i0.InputSignalWithTransform<number | boolean, unknown>;
|
|
30
|
+
readonly showTitle: i0.InputSignalWithTransform<boolean, unknown>;
|
|
31
|
+
protected readonly ellipsisState$$: i0.Signal<{
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
clamp: number;
|
|
34
|
+
}>;
|
|
35
|
+
readonly content$$: i0.Signal<string | undefined>;
|
|
36
|
+
constructor();
|
|
37
|
+
private isShowTooltip;
|
|
38
|
+
private computeEllipsisState;
|
|
39
|
+
private computeContent;
|
|
40
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EllipsisDirective, never>;
|
|
41
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<EllipsisDirective, "[ellipsis]", ["ellipsis"], { "ellipsis": { "alias": "ellipsis"; "required": false; "isSignal": true; }; "showTitle": { "alias": "showTitle"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function withStylesDirective(component: Type<unknown>): undefined;
|
|
45
|
+
|
|
46
|
+
export { EllipsisDirective, PickKeyPipe, SafePipe, withStylesDirective };
|