wacom 20.2.2 → 20.2.4

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.
@@ -6,7 +6,7 @@ import { DomSanitizer } from '@angular/platform-browser';
6
6
  import * as i1$1 from '@angular/common';
7
7
  import { CommonModule } from '@angular/common';
8
8
  import { Subject, firstValueFrom, Observable, ReplaySubject, EMPTY } from 'rxjs';
9
- import * as i2$1 from '@angular/common/http';
9
+ import * as i1$2 from '@angular/common/http';
10
10
  import { HttpHeaders, HttpErrorResponse, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11
11
  import { first, catchError } from 'rxjs/operators';
12
12
  import { FormsModule } from '@angular/forms';
@@ -18,7 +18,17 @@ const ALERT_TYPES = ['info', 'error', 'success', 'warning', 'question'];
18
18
  /**
19
19
  * Possible screen positions where alerts can be placed.
20
20
  */
21
- const ALERT_POSITIONS = ['topLeft', 'top', 'topRight', 'left', 'center', 'right', 'bottomLeft', 'bottom', 'bottomRight'];
21
+ const ALERT_POSITIONS = [
22
+ 'topLeft',
23
+ 'top',
24
+ 'topRight',
25
+ 'left',
26
+ 'center',
27
+ 'right',
28
+ 'bottomLeft',
29
+ 'bottom',
30
+ 'bottomRight',
31
+ ];
22
32
  /**
23
33
  * Default values applied when an alert is shown without specific options.
24
34
  */
@@ -1825,197 +1835,21 @@ const DEFAULT_HTTP_CONFIG = {
1825
1835
  url: '',
1826
1836
  };
1827
1837
 
1828
- class StoreService {
1829
- constructor(config) {
1830
- this._prefix = '';
1831
- this._config = {
1832
- ...DEFAULT_CONFIG,
1833
- ...(config?.store || {}),
1834
- };
1835
- }
1836
- /**
1837
- * Sets the prefix for storage keys.
1838
- *
1839
- * @param prefix - The prefix to set.
1840
- */
1841
- setPrefix(prefix) {
1842
- this._prefix = prefix;
1843
- }
1844
- /**
1845
- * Sets a value in storage asynchronously.
1846
- *
1847
- * @param key - The storage key.
1848
- * @param value - The value to store.
1849
- * @returns A promise that resolves to a boolean indicating success.
1850
- */
1851
- async set(key, value, callback = () => { }, errCallback = () => { }) {
1852
- key = this._applyPrefix(key);
1853
- try {
1854
- if (this._config.set) {
1855
- await this._config.set(key, value, callback, errCallback);
1856
- }
1857
- else {
1858
- localStorage.setItem(key, value);
1859
- callback();
1860
- }
1861
- return true;
1862
- }
1863
- catch (err) {
1864
- console.error(err);
1865
- errCallback(err);
1866
- return false;
1867
- }
1868
- }
1869
- /**
1870
- * Gets a value from storage asynchronously.
1871
- *
1872
- * @param key - The storage key.
1873
- * @returns A promise that resolves to the retrieved value or `null` if the key is missing.
1874
- */
1875
- async get(key, callback, errCallback = () => { }) {
1876
- key = this._applyPrefix(key);
1877
- try {
1878
- if (this._config.get) {
1879
- const value = await this._config.get(key, (val) => {
1880
- callback?.(val ?? null);
1881
- }, errCallback);
1882
- return value ?? null;
1883
- }
1884
- else {
1885
- const value = localStorage.getItem(key);
1886
- callback?.(value ?? null);
1887
- return value ?? null;
1888
- }
1889
- }
1890
- catch (err) {
1891
- console.error(err);
1892
- errCallback(err);
1893
- return null;
1894
- }
1895
- }
1896
- /**
1897
- * Sets a JSON value in storage asynchronously.
1898
- *
1899
- * @param key - The storage key.
1900
- * @param value - The value to store.
1901
- * @returns A promise that resolves to a boolean indicating success.
1902
- */
1903
- async setJson(key, value, callback = () => { }, errCallback = () => { }) {
1904
- return await this.set(key, JSON.stringify(value), callback, errCallback);
1905
- }
1906
- /**
1907
- * Gets a JSON value from storage asynchronously.
1908
- *
1909
- * @param key - The storage key.
1910
- * @returns A promise that resolves to the retrieved value.
1911
- */
1912
- async getJson(key, callback, errCallback = () => { }) {
1913
- const value = await this.get(key, callback, errCallback);
1914
- if (value === null) {
1915
- return null;
1916
- }
1917
- try {
1918
- return JSON.parse(value);
1919
- }
1920
- catch (err) {
1921
- console.error(err);
1922
- return null;
1923
- }
1924
- }
1925
- /**
1926
- * Removes a value from storage.
1927
- *
1928
- * @param key - The storage key.
1929
- * @param callback - The callback to execute on success.
1930
- * @param errCallback - The callback to execute on error.
1931
- * @returns A promise that resolves to a boolean indicating success.
1932
- */
1933
- async remove(key, callback = () => { }, errCallback = () => { }) {
1934
- key = this._applyPrefix(key);
1935
- try {
1936
- if (this._config.remove) {
1937
- return await this._config.remove(key, callback, errCallback);
1938
- }
1939
- else {
1940
- localStorage.removeItem(key);
1941
- callback();
1942
- return true;
1943
- }
1944
- }
1945
- catch (err) {
1946
- console.error(err);
1947
- errCallback(err);
1948
- return false;
1949
- }
1950
- }
1951
- /**
1952
- * Clears all values from storage.
1953
- *
1954
- * @param callback - The callback to execute on success.
1955
- * @param errCallback - The callback to execute on error.
1956
- * @returns A promise that resolves to a boolean indicating success.
1957
- */
1958
- async clear(callback, errCallback) {
1959
- try {
1960
- if (this._config.clear) {
1961
- await this._config.clear();
1962
- }
1963
- else {
1964
- localStorage.clear();
1965
- }
1966
- callback?.();
1967
- return true;
1968
- }
1969
- catch (err) {
1970
- console.error(err);
1971
- errCallback?.(err);
1972
- return false;
1973
- }
1974
- }
1975
- /**
1976
- * Applies the configured prefix to a storage key.
1977
- *
1978
- * @param key - The storage key.
1979
- * @returns The prefixed storage key.
1980
- */
1981
- _applyPrefix(key) {
1982
- if (this._config.prefix) {
1983
- key = this._config.prefix + key;
1984
- }
1985
- if (this._prefix) {
1986
- key = this._prefix + key;
1987
- }
1988
- return key;
1989
- }
1990
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, deps: [{ token: CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1991
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, providedIn: 'root' }); }
1992
- }
1993
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, decorators: [{
1994
- type: Injectable,
1995
- args: [{
1996
- providedIn: 'root',
1997
- }]
1998
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1999
- type: Inject,
2000
- args: [CONFIG_TOKEN]
2001
- }, {
2002
- type: Optional
2003
- }] }] });
2004
-
2005
1838
  class HttpService {
2006
- constructor(config, store, http) {
2007
- this.store = store;
2008
- this.http = http;
1839
+ constructor(config, _http) {
1840
+ this._http = _http;
2009
1841
  // An array of error handling callbacks
2010
1842
  this.errors = [];
2011
1843
  // Base URL for HTTP requests
2012
- this.url = '';
1844
+ this.url = localStorage.getItem('wacom-http.url') || '';
2013
1845
  // Flag to lock the service to prevent multiple requests
2014
1846
  this.locked = false;
2015
1847
  // Array to store setTimeout IDs for managing request locks
2016
1848
  this.awaitLocked = [];
2017
1849
  // Object to store HTTP headers
2018
- this._headers = {};
1850
+ this._headers = localStorage.getItem('wacom-http.headers')
1851
+ ? JSON.parse(localStorage.getItem('wacom-http.headers'))
1852
+ : {};
2019
1853
  // Instance of HttpHeaders with current headers
2020
1854
  this._http_headers = new HttpHeaders(this._headers);
2021
1855
  // Initialize HTTP configuration and headers from injected config
@@ -2029,32 +1863,21 @@ class HttpService {
2029
1863
  }
2030
1864
  this._http_headers = new HttpHeaders(this._headers);
2031
1865
  }
2032
- // Retrieve and set the base URL and headers from the store
2033
- this.store.get('http_url', (url) => {
2034
- this.url = url || this._config.url || '';
2035
- });
2036
- this.store.getJson('http_headers').then((headers) => {
2037
- headers ||= {};
2038
- for (const header in headers) {
2039
- this._headers[header] = headers[header];
2040
- }
2041
- this._http_headers = new HttpHeaders(this._headers);
2042
- });
2043
1866
  }
2044
1867
  // Set a new base URL and save it in the store
2045
1868
  setUrl(url) {
2046
1869
  this.url = url;
2047
- this.store.set('http_url', url);
1870
+ localStorage.setItem('wacom-http.url', url);
2048
1871
  }
2049
1872
  // Remove the base URL and revert to the default or stored one
2050
1873
  removeUrl() {
2051
1874
  this.url = this._config.url || '';
2052
- this.store.remove('http_url');
1875
+ localStorage.removeItem('wacom-http.url');
2053
1876
  }
2054
1877
  // Set a new HTTP header and update the stored headers
2055
1878
  set(key, value) {
2056
1879
  this._headers[key] = value;
2057
- this.store.setJson('http_headers', this._headers);
1880
+ localStorage.setItem('wacom-http.headers', JSON.stringify(this._headers));
2058
1881
  this._http_headers = new HttpHeaders(this._headers);
2059
1882
  }
2060
1883
  // Get the value of a specific HTTP header
@@ -2064,25 +1887,25 @@ class HttpService {
2064
1887
  // Remove a specific HTTP header and update the stored headers
2065
1888
  remove(key) {
2066
1889
  delete this._headers[key];
1890
+ localStorage.setItem('wacom-http.headers', JSON.stringify(this._headers));
2067
1891
  this._http_headers = new HttpHeaders(this._headers);
2068
- this.store.setJson('http_headers', this._headers);
2069
1892
  }
2070
1893
  // Internal method to make HTTP requests based on the method type
2071
1894
  _httpMethod(method, _url, doc, headers) {
2072
1895
  if (method === 'post') {
2073
- return this.http.post(_url, doc, headers);
1896
+ return this._http.post(_url, doc, headers);
2074
1897
  }
2075
1898
  else if (method === 'put') {
2076
- return this.http.put(_url, doc, headers);
1899
+ return this._http.put(_url, doc, headers);
2077
1900
  }
2078
1901
  else if (method === 'patch') {
2079
- return this.http.patch(_url, doc, headers);
1902
+ return this._http.patch(_url, doc, headers);
2080
1903
  }
2081
1904
  else if (method === 'delete') {
2082
- return this.http.delete(_url, headers);
1905
+ return this._http.delete(_url, headers);
2083
1906
  }
2084
1907
  else {
2085
- return this.http.get(_url, headers);
1908
+ return this._http.get(_url, headers);
2086
1909
  }
2087
1910
  }
2088
1911
  /**
@@ -2142,7 +1965,8 @@ class HttpService {
2142
1965
  }))
2143
1966
  .subscribe({
2144
1967
  next: (resp) => {
2145
- if (opts.acceptance && typeof opts.acceptance === 'function') {
1968
+ if (opts.acceptance &&
1969
+ typeof opts.acceptance === 'function') {
2146
1970
  if (!opts.acceptance(resp)) {
2147
1971
  const error = new HttpErrorResponse({
2148
1972
  error: 'Acceptance failed',
@@ -2329,7 +2153,7 @@ class HttpService {
2329
2153
  }
2330
2154
  return newDoc;
2331
2155
  }
2332
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: HttpService, deps: [{ token: CONFIG_TOKEN, optional: true }, { token: StoreService }, { token: i2$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
2156
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: HttpService, deps: [{ token: CONFIG_TOKEN, optional: true }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
2333
2157
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: HttpService, providedIn: 'root' }); }
2334
2158
  }
2335
2159
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: HttpService, decorators: [{
@@ -2342,7 +2166,184 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
2342
2166
  args: [CONFIG_TOKEN]
2343
2167
  }, {
2344
2168
  type: Optional
2345
- }] }, { type: StoreService }, { type: i2$1.HttpClient }] });
2169
+ }] }, { type: i1$2.HttpClient }] });
2170
+
2171
+ class StoreService {
2172
+ constructor(config) {
2173
+ this._prefix = '';
2174
+ this._config = {
2175
+ ...DEFAULT_CONFIG,
2176
+ ...(config?.store || {}),
2177
+ };
2178
+ }
2179
+ /**
2180
+ * Sets the prefix for storage keys.
2181
+ *
2182
+ * @param prefix - The prefix to set.
2183
+ */
2184
+ setPrefix(prefix) {
2185
+ this._prefix = prefix;
2186
+ }
2187
+ /**
2188
+ * Sets a value in storage asynchronously.
2189
+ *
2190
+ * @param key - The storage key.
2191
+ * @param value - The value to store.
2192
+ * @returns A promise that resolves to a boolean indicating success.
2193
+ */
2194
+ async set(key, value, callback = () => { }, errCallback = () => { }) {
2195
+ key = this._applyPrefix(key);
2196
+ try {
2197
+ if (this._config.set) {
2198
+ await this._config.set(key, value, callback, errCallback);
2199
+ }
2200
+ else {
2201
+ localStorage.setItem(key, value);
2202
+ callback();
2203
+ }
2204
+ return true;
2205
+ }
2206
+ catch (err) {
2207
+ console.error(err);
2208
+ errCallback(err);
2209
+ return false;
2210
+ }
2211
+ }
2212
+ /**
2213
+ * Gets a value from storage asynchronously.
2214
+ *
2215
+ * @param key - The storage key.
2216
+ * @returns A promise that resolves to the retrieved value or `null` if the key is missing.
2217
+ */
2218
+ async get(key, callback, errCallback = () => { }) {
2219
+ key = this._applyPrefix(key);
2220
+ try {
2221
+ if (this._config.get) {
2222
+ const value = await this._config.get(key, (val) => {
2223
+ callback?.(val ?? null);
2224
+ }, errCallback);
2225
+ return value ?? null;
2226
+ }
2227
+ else {
2228
+ const value = localStorage.getItem(key);
2229
+ callback?.(value ?? null);
2230
+ return value ?? null;
2231
+ }
2232
+ }
2233
+ catch (err) {
2234
+ console.error(err);
2235
+ errCallback(err);
2236
+ return null;
2237
+ }
2238
+ }
2239
+ /**
2240
+ * Sets a JSON value in storage asynchronously.
2241
+ *
2242
+ * @param key - The storage key.
2243
+ * @param value - The value to store.
2244
+ * @returns A promise that resolves to a boolean indicating success.
2245
+ */
2246
+ async setJson(key, value, callback = () => { }, errCallback = () => { }) {
2247
+ return await this.set(key, JSON.stringify(value), callback, errCallback);
2248
+ }
2249
+ /**
2250
+ * Gets a JSON value from storage asynchronously.
2251
+ *
2252
+ * @param key - The storage key.
2253
+ * @returns A promise that resolves to the retrieved value.
2254
+ */
2255
+ async getJson(key, callback, errCallback = () => { }) {
2256
+ const value = await this.get(key, callback, errCallback);
2257
+ if (value === null) {
2258
+ return null;
2259
+ }
2260
+ try {
2261
+ return JSON.parse(value);
2262
+ }
2263
+ catch (err) {
2264
+ console.error(err);
2265
+ return null;
2266
+ }
2267
+ }
2268
+ /**
2269
+ * Removes a value from storage.
2270
+ *
2271
+ * @param key - The storage key.
2272
+ * @param callback - The callback to execute on success.
2273
+ * @param errCallback - The callback to execute on error.
2274
+ * @returns A promise that resolves to a boolean indicating success.
2275
+ */
2276
+ async remove(key, callback = () => { }, errCallback = () => { }) {
2277
+ key = this._applyPrefix(key);
2278
+ try {
2279
+ if (this._config.remove) {
2280
+ return await this._config.remove(key, callback, errCallback);
2281
+ }
2282
+ else {
2283
+ localStorage.removeItem(key);
2284
+ callback();
2285
+ return true;
2286
+ }
2287
+ }
2288
+ catch (err) {
2289
+ console.error(err);
2290
+ errCallback(err);
2291
+ return false;
2292
+ }
2293
+ }
2294
+ /**
2295
+ * Clears all values from storage.
2296
+ *
2297
+ * @param callback - The callback to execute on success.
2298
+ * @param errCallback - The callback to execute on error.
2299
+ * @returns A promise that resolves to a boolean indicating success.
2300
+ */
2301
+ async clear(callback, errCallback) {
2302
+ try {
2303
+ if (this._config.clear) {
2304
+ await this._config.clear();
2305
+ }
2306
+ else {
2307
+ localStorage.clear();
2308
+ }
2309
+ callback?.();
2310
+ return true;
2311
+ }
2312
+ catch (err) {
2313
+ console.error(err);
2314
+ errCallback?.(err);
2315
+ return false;
2316
+ }
2317
+ }
2318
+ /**
2319
+ * Applies the configured prefix to a storage key.
2320
+ *
2321
+ * @param key - The storage key.
2322
+ * @returns The prefixed storage key.
2323
+ */
2324
+ _applyPrefix(key) {
2325
+ if (this._config.prefix) {
2326
+ key = this._config.prefix + key;
2327
+ }
2328
+ if (this._prefix) {
2329
+ key = this._prefix + key;
2330
+ }
2331
+ return key;
2332
+ }
2333
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, deps: [{ token: CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
2334
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, providedIn: 'root' }); }
2335
+ }
2336
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: StoreService, decorators: [{
2337
+ type: Injectable,
2338
+ args: [{
2339
+ providedIn: 'root',
2340
+ }]
2341
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2342
+ type: Inject,
2343
+ args: [CONFIG_TOKEN]
2344
+ }, {
2345
+ type: Optional
2346
+ }] }] });
2346
2347
 
2347
2348
  /**
2348
2349
  * Abstract class representing a CRUD (Create, Read, Update, Delete) service.