wacom 20.3.3 → 20.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,16 +68,21 @@ You can reference these variables in your global styles to keep the design consi
68
68
  | Name | Description |
69
69
  | ------------------------------------------------------------------ | :-----------------------------------------------------------------: |
70
70
  | [**`Core`**](https://www.npmjs.com/package/wacom#core-service) | Common supportive function which can be used in any service |
71
+ | [**`Base`**](https://www.npmjs.com/package/wacom#base-service) | Tracks timestamps and can refresh to the current time |
71
72
  | [**`Http`**](https://www.npmjs.com/package/wacom#http-service) | Http layer for HttpClient |
72
- | [**`Store`**](https://www.npmjs.com/package/wacom#store-service) | Service will is responsible for keeping information on the device |
73
+ | [**`Store`**](https://www.npmjs.com/package/wacom#store-service) | Service responsible for keeping information on the device |
73
74
  | [**`Meta`**](https://www.npmjs.com/package/wacom#meta-service) | Website meta tags management within router |
74
- | [**`UI`**](https://www.npmjs.com/package/wacom#ui-service) | Supportive UI/UX service |
75
75
  | [**`Crud`**](https://www.npmjs.com/package/wacom#crud-service) | Provides basic CRUD operations for managing data with HTTP services |
76
76
  | [**`File`**](https://www.npmjs.com/package/wacom#file-service) | Handles file uploads, image processing, and file management tasks |
77
77
  | [**`Socket`**](https://www.npmjs.com/package/wacom#socket-service) | Manages WebSocket connections and real-time data communication |
78
78
  | [**`Time`**](https://www.npmjs.com/package/wacom#time-service) | Provides utilities for date and time manipulation and formatting |
79
79
  | [**`Dom`**](https://www.npmjs.com/package/wacom#dom-service) | Facilitates DOM manipulation and dynamic component loading |
80
- | [**`Network`**](https://www.npmjs.com/package/wacom#network-service) | Monitors network connectivity and latency |
80
+ | [**`Network`**](https://www.npmjs.com/package/wacom#network-service) | Monitors network connectivity and latency |
81
+ | [**`Alert`**](https://www.npmjs.com/package/wacom#alert-service) | Displays configurable alert messages |
82
+ | [**`Loader`**](https://www.npmjs.com/package/wacom#loader-service) | Shows and manages loading indicators |
83
+ | [**`Modal`**](https://www.npmjs.com/package/wacom#modal-service) | Creates and controls modal dialogs |
84
+ | [**`RTC`**](https://www.npmjs.com/package/wacom#rtc-service) | Wraps WebRTC peer connections and local media streams |
85
+ | [**`Util`**](https://www.npmjs.com/package/wacom#util-service) | Utility methods for forms, validation, and CSS variables |
81
86
 
82
87
  ## [Core Service](#core-service)
83
88
 
@@ -630,6 +635,32 @@ In this example:
630
635
 
631
636
  This ensures controlled access to the resource, preventing race conditions and ensuring data integrity.
632
637
 
638
+ ## [Base Service](#base-service)
639
+
640
+ The `BaseService` provides a minimal utility for tracking the current timestamp.
641
+
642
+ ### Properties
643
+
644
+ - `now` (`number`): Stores the current timestamp in milliseconds.
645
+
646
+ ### Methods
647
+
648
+ #### `refreshNow(): void`
649
+
650
+ Updates the `now` property to the current timestamp.
651
+
652
+ **Example**:
653
+
654
+ ```Typescript
655
+ import { BaseService } from 'wacom';
656
+
657
+ constructor(private baseService: BaseService) {}
658
+
659
+ refresh() {
660
+ this.baseService.refreshNow();
661
+ }
662
+ ```
663
+
633
664
  ## [Http Service](#http-service)
634
665
 
635
666
  The `HttpService` provides an HTTP layer for `HttpClient` in Angular, supporting both callbacks and observables for various HTTP operations.
@@ -1059,128 +1090,6 @@ Applies the configured prefix to a storage key.
1059
1090
  const prefixedKey = storeService.applyPrefix('key');
1060
1091
  ```
1061
1092
 
1062
- ## [Hash Service](#hash-service)
1063
-
1064
- The `HashService` manages the URL hash in an Angular application. It can parse, set, get, and clear hash values, providing a simple API for manipulating the URL hash.
1065
-
1066
- ### Properties
1067
-
1068
- #### `hash: { [key: string]: string }`
1069
-
1070
- The object containing the parsed hash values.
1071
-
1072
- ### Methods
1073
-
1074
- #### `initialize(): void`
1075
-
1076
- Initializes the hash service by loading the current hash from the URL.
1077
- **Example**:
1078
-
1079
- ```Typescript
1080
- hashService.initialize();
1081
- ```
1082
-
1083
- #### `load(): void`
1084
-
1085
- Loads the current hash from the URL into the hash object.
1086
-
1087
- **Example**:
1088
-
1089
- ```Typescript
1090
- hashService.load();
1091
- ```
1092
-
1093
- #### `applyReplacements(str: string | undefined): string`
1094
-
1095
- Applies replacements to a given string based on the replacements array.
1096
-
1097
- **Parameters**:
1098
-
1099
- - `str` (string | undefined): The string to apply replacements to.
1100
-
1101
- **Returns**:
1102
-
1103
- - `string`: The string with replacements applied.
1104
-
1105
- **Example**:
1106
-
1107
- ```Typescript
1108
- const result = hashService.applyReplacements('hello%20world');
1109
- ```
1110
-
1111
- #### `on(field: string, cb: (value: string) => void): void`
1112
-
1113
- Executes a callback with the value of a specific hash field once the hash is loaded.
1114
-
1115
- **Parameters**:
1116
-
1117
- - `field` (string): The hash field to get the value for.
1118
- - `cb` (function): The callback to execute with the value.
1119
-
1120
- **Example**:
1121
-
1122
- ```Typescript
1123
- hashService.on('key', value => console.log(value));
1124
- ```
1125
-
1126
- #### `save(): void`
1127
-
1128
- Saves the current hash object to the URL.
1129
-
1130
- **Example**:
1131
-
1132
- ```Typescript
1133
- hashService.save();
1134
- ```
1135
-
1136
- #### `set(field: string, value: string): void`
1137
-
1138
- Sets a value for a specific hash field and updates the URL.
1139
-
1140
- **Parameters**:
1141
-
1142
- - `field` (string): The hash field to set the value for.
1143
- - `value` (string): The value to set.
1144
-
1145
- **Example**:
1146
-
1147
- ```Typescript
1148
- hashService.set('key', 'value');
1149
- ```
1150
-
1151
- #### `get(field: string): string | undefined`
1152
-
1153
- Gets the value of a specific hash field.
1154
-
1155
- **Parameters**:
1156
-
1157
- - `field` (string): The hash field to get the value for.
1158
-
1159
- **Returns**:
1160
-
1161
- - `string | undefined`: The value of the hash field.
1162
-
1163
- **Example**:
1164
-
1165
- ```Typescript
1166
- const value = hashService.get('key');
1167
- ```
1168
-
1169
- #### `clear(field?: string): void`
1170
-
1171
- Clears a specific hash field or all hash fields and updates the URL.
1172
-
1173
- **Parameters**:
1174
-
1175
- - `field` (string | undefined): The hash field to clear. If not provided, clears all hash fields.
1176
-
1177
- **Example**:
1178
-
1179
- ```Typescript
1180
- hashService.clear('key');
1181
- hashService.clear();
1182
- ```
1183
-
1184
1093
  ## [Meta Service](#meta-service)
1185
1094
 
1186
1095
  The `MetaService` manages meta tags and titles in an Angular application. It allows setting defaults, updating meta tags, and configuring titles dynamically.
@@ -1297,9 +1206,9 @@ Warns about missing meta guards in routes.
1297
1206
  metaService._warnMissingGuard();
1298
1207
  ```
1299
1208
 
1300
- ## [UI Service](#ui-service)
1209
+ ## [Util Service](#util-service)
1301
1210
 
1302
- The `UiService` manages various UI-related tasks in an Angular application, including CSS management, form validation, and generating sample data for UI components.
1211
+ The `UtilService` manages various UI-related tasks in an Angular application, including CSS management, form validation, and generating sample data for UI components.
1303
1212
 
1304
1213
  ### Methods
1305
1214
 
@@ -1318,7 +1227,7 @@ Manages form states.
1318
1227
  **Example**:
1319
1228
 
1320
1229
  ```Typescript
1321
- const formState = uiService.form('contactForm');
1230
+ const formState = utilService.form('contactForm');
1322
1231
  ```
1323
1232
 
1324
1233
  #### `valid(value: any, kind = 'email', extra = 0): boolean`
@@ -1338,7 +1247,7 @@ Validates input values based on the specified type.
1338
1247
  **Example**:
1339
1248
 
1340
1249
  ```Typescript
1341
- const isValidEmail = uiService.valid('test@example.com', 'email');
1250
+ const isValidEmail = utilService.valid('test@example.com', 'email');
1342
1251
  ```
1343
1252
 
1344
1253
  #### `level(value = ''): number`
@@ -1356,7 +1265,7 @@ Determines the strength of a password.
1356
1265
  **Example**:
1357
1266
 
1358
1267
  ```Typescript
1359
- const passwordLevel = uiService.level('Password123!');
1268
+ const passwordLevel = utilService.level('Password123!');
1360
1269
  ```
1361
1270
 
1362
1271
  #### `set(variables: { [key: string]: string }, opts: any = {}): void`
@@ -1371,7 +1280,7 @@ Sets multiple CSS variables.
1371
1280
  **Example**:
1372
1281
 
1373
1282
  ```Typescript
1374
- uiService.set({ '--primary-color': '#ff0000' }, 'local');
1283
+ utilService.set({ '--primary-color': '#ff0000' }, 'local');
1375
1284
  ```
1376
1285
 
1377
1286
  #### `get(): { [key: string]: string }`
@@ -1385,7 +1294,7 @@ Retrieves the stored CSS variables.
1385
1294
  **Example**:
1386
1295
 
1387
1296
  ```Typescript
1388
- const cssVariables = uiService.get();
1297
+ const cssVariables = utilService.get();
1389
1298
  ```
1390
1299
 
1391
1300
  #### `remove(keys: string | string[]): void`
@@ -1399,7 +1308,7 @@ Removes specified CSS variables.
1399
1308
  **Example**:
1400
1309
 
1401
1310
  ```Typescript
1402
- uiService.remove('primary-color secondary-color');
1311
+ utilService.remove('primary-color secondary-color');
1403
1312
  ```
1404
1313
 
1405
1314
  #### `arr(arrLen = 10, type: string = 'number'): any[]`
@@ -1418,7 +1327,7 @@ Generates an array of sample data.
1418
1327
  **Example**:
1419
1328
 
1420
1329
  ```Typescript
1421
- const sampleArray = uiService.arr(5, 'text');
1330
+ const sampleArray = utilService.arr(5, 'text');
1422
1331
  ```
1423
1332
 
1424
1333
  #### `text(length = 10): string`
@@ -1436,7 +1345,7 @@ Generates a random text string.
1436
1345
  **Example**:
1437
1346
 
1438
1347
  ```Typescript
1439
- const randomText = uiService.text(15);
1348
+ const randomText = utilService.text(15);
1440
1349
  ```
1441
1350
 
1442
1351
  ## [Crud Service](#crud-service)
@@ -2532,3 +2441,130 @@ Performs an immediate connectivity check and updates all signals.
2532
2441
  await networkService.recheckNow();
2533
2442
  ```
2534
2443
 
2444
+ ## [Alert Service](#alert-service)
2445
+
2446
+ The `AlertService` displays configurable alert messages such as information, success, warning, error or question prompts.
2447
+
2448
+ ### Methods
2449
+
2450
+ #### `show(opts: Alert | string): Alert`
2451
+ Displays a customizable alert. Passing a string uses it as the alert text.
2452
+
2453
+ #### `info(opts: Alert): void`
2454
+ Shows an informational alert.
2455
+
2456
+ #### `success(opts: Alert): void`
2457
+ Shows a success alert.
2458
+
2459
+ #### `warning(opts: Alert): void`
2460
+ Shows a warning alert.
2461
+
2462
+ #### `error(opts: Alert): void`
2463
+ Shows an error alert.
2464
+
2465
+ #### `question(opts: Alert): void`
2466
+ Shows a question alert.
2467
+
2468
+ #### `destroy(): void`
2469
+ Removes all alerts.
2470
+
2471
+ **Example**:
2472
+
2473
+ ```Typescript
2474
+ import { AlertService } from 'wacom';
2475
+
2476
+ constructor(private alertService: AlertService) {}
2477
+
2478
+ notify() {
2479
+ this.alertService.success({ text: 'Saved!' });
2480
+ }
2481
+ ```
2482
+
2483
+ ## [Loader Service](#loader-service)
2484
+
2485
+ The `LoaderService` provides global loading indicators.
2486
+
2487
+ ### Methods
2488
+
2489
+ #### `show(opts: Loader | string = 'Loading...'): Loader`
2490
+ Displays a loader with optional text or configuration.
2491
+
2492
+ #### `destroy(): void`
2493
+ Removes all active loaders.
2494
+
2495
+ **Example**:
2496
+
2497
+ ```Typescript
2498
+ import { LoaderService } from 'wacom';
2499
+
2500
+ constructor(private loader: LoaderService) {}
2501
+
2502
+ load() {
2503
+ const l = this.loader.show();
2504
+ // ...do work...
2505
+ l.close?.();
2506
+ }
2507
+ ```
2508
+
2509
+ ## [Modal Service](#modal-service)
2510
+
2511
+ The `ModalService` manages modal dialogs and projects components into them.
2512
+
2513
+ ### Methods
2514
+
2515
+ #### `show(opts: Modal | Type<unknown>): Modal`
2516
+ Opens a modal with the given configuration or component type.
2517
+
2518
+ #### `small(opts: Modal): void`
2519
+ #### `mid(opts: Modal): void`
2520
+ #### `big(opts: Modal): void`
2521
+ #### `full(opts: Modal): void`
2522
+ Convenience helpers to open modals of different sizes.
2523
+
2524
+ #### `destroy(): void`
2525
+ Closes all open modals.
2526
+
2527
+ **Example**:
2528
+
2529
+ ```Typescript
2530
+ import { ModalService } from 'wacom';
2531
+ import { MyComponent } from './my.component';
2532
+
2533
+ constructor(private modal: ModalService) {}
2534
+
2535
+ open() {
2536
+ this.modal.show({ component: MyComponent, size: 'mid' });
2537
+ }
2538
+ ```
2539
+
2540
+ ## [RTC Service](#rtc-service)
2541
+
2542
+ The `RtcService` wraps WebRTC peer connections and local media streams.
2543
+
2544
+ ### Methods
2545
+
2546
+ - `initLocalStream(): Promise<MediaStream>` – initializes and returns the local media stream.
2547
+ - `createPeer(id: string): Promise<RTCPeerConnection>` – creates a peer connection and attaches local tracks.
2548
+ - `createOffer(id: string): Promise<RTCSessionDescriptionInit>` – creates an SDP offer.
2549
+ - `createAnswer(id: string, offer: RTCSessionDescriptionInit): Promise<RTCSessionDescriptionInit>` – responds to an offer.
2550
+ - `setRemoteAnswer(id: string, answer: RTCSessionDescriptionInit): Promise<void>` – applies a remote answer.
2551
+ - `addIceCandidate(id: string, candidate: RTCIceCandidateInit): void` – adds an ICE candidate.
2552
+ - `getLocalStream(): MediaStream | null` – returns the initialized local stream.
2553
+ - `closePeer(id: string): void` – closes a peer connection.
2554
+ - `closeAll(): void` – closes all peers and stops the local stream.
2555
+
2556
+ **Example**:
2557
+
2558
+ ```Typescript
2559
+ import { RtcService } from 'wacom';
2560
+
2561
+ constructor(private rtc: RtcService) {}
2562
+
2563
+ async connect(id: string) {
2564
+ await this.rtc.initLocalStream();
2565
+ await this.rtc.createPeer(id);
2566
+ const offer = await this.rtc.createOffer(id);
2567
+ // send offer to remote peer...
2568
+ }
2569
+ ```
2570
+