@rws-framework/client 2.21.5 → 2.22.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.21.5",
4
+ "version": "2.22.0",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -13,7 +13,6 @@ import TheRWSService from '../services/_service';
13
13
  import { handleExternalChange } from './_attrs/_external_handler';
14
14
  import { IFastDefinition, isDefined, defineComponent, getDefinition } from './_definitions';
15
15
  import { on, $emitDown, observe, sendEventToOutside } from './_event_handling';
16
- import { domEvents } from '../events';
17
16
 
18
17
  type ComposeMethodType<
19
18
  T extends FoundationElementDefinition,
@@ -22,8 +21,6 @@ type ComposeMethodType<
22
21
 
23
22
  type CSSInjectMode = 'adopted' | 'legacy' | 'both';
24
23
 
25
- const _DEFAULT_INJECT_CSS_CACHE_LIMIT_DAYS = 1;
26
-
27
24
  export interface IWithCompose<T extends RWSViewComponent> {
28
25
  [key: string]: any
29
26
  new(...args: any[]): T;
@@ -253,81 +250,55 @@ abstract class RWSViewComponent extends FoundationElement implements IRWSViewCom
253
250
  return RWSViewComponent.instances;
254
251
  }
255
252
 
256
- protected async injectStyles(styleLinks: string[], mode: CSSInjectMode = 'adopted', maxDaysExp?: number) {
253
+ protected async injectStyles(styleLinks: string[], mode: CSSInjectMode = 'adopted') {
257
254
  const dbName = 'css-cache';
258
255
  const storeName = 'styles';
259
256
  const db = await this.indexedDBService.openDB(dbName, storeName);
260
- const maxAgeMs = 1000 * 60 * 60 * 24; // 24h
261
- const maxDaysAge = maxDaysExp ? maxDaysExp : _DEFAULT_INJECT_CSS_CACHE_LIMIT_DAYS;
262
- const maxAgeDays = maxAgeMs * maxDaysAge;
263
257
 
264
258
  let adoptedSheets: CSSStyleSheet[] = [];
265
259
 
266
- let doneAdded = false;
267
-
268
260
  for (const styleLink of styleLinks) {
269
- const loadPromise = new Promise<void>(async (resolve, reject) => {
270
- if (mode === 'legacy' || mode === 'both') {
271
- const link = document.createElement('link');
272
- link.rel = 'stylesheet';
273
- link.href = styleLink;
274
- this.getShadowRoot().appendChild(link);
275
-
276
- link.onload = () => {
277
- doneAdded = true;
278
-
279
- if(mode === 'legacy'){
280
- resolve();
281
- }
282
- };
283
- }
261
+ if (mode === 'legacy' || mode === 'both') {
262
+ const link = document.createElement('link');
263
+ link.rel = 'stylesheet';
264
+ link.href = styleLink;
265
+ this.getShadowRoot().appendChild(link);
266
+ }
284
267
 
285
- if (mode === 'adopted' || mode === 'both') {
286
- const entry = await this.indexedDBService.getFromDB(db, storeName, styleLink);
268
+ if (mode === 'adopted' || mode === 'both') {
269
+ const entry = await this.indexedDBService.getFromDB(db, storeName, styleLink);
270
+ const maxAgeMs = 1000 * 60 * 60 * 24; // 24h
287
271
 
288
- let cssText: string | null = null;
272
+ let cssText: string | null = null;
289
273
 
290
- if (entry && typeof entry === 'object' && 'css' in entry && 'timestamp' in entry) {
291
- const expired = Date.now() - entry.timestamp > maxAgeDays;
292
- if (!expired) {
293
- cssText = entry.css;
294
- }
274
+ if (entry && typeof entry === 'object' && 'css' in entry && 'timestamp' in entry) {
275
+ const expired = Date.now() - entry.timestamp > maxAgeMs;
276
+ if (!expired) {
277
+ cssText = entry.css;
295
278
  }
279
+ }
296
280
 
297
- if (!cssText) {
298
- cssText = await fetch(styleLink).then(res => res.text());
299
- await this.indexedDBService.saveToDB(db, storeName, styleLink, {
300
- css: cssText,
301
- timestamp: Date.now()
302
- });
303
- console.log(`System saved stylesheet: ${styleLink} to IndexedDB`)
304
- }
305
-
306
- const sheet = new CSSStyleSheet();
307
- await sheet.replace(cssText);
308
-
309
- adoptedSheets.push(sheet);
310
-
311
- if(mode === 'adopted' || mode === 'both'){
312
- resolve();
313
- }
281
+ if (!cssText) {
282
+ cssText = await fetch(styleLink).then(res => res.text());
283
+ await this.indexedDBService.saveToDB(db, storeName, styleLink, {
284
+ css: cssText,
285
+ timestamp: Date.now()
286
+ });
287
+ console.log(`System saved stylesheet: ${styleLink} to IndexedDB`)
314
288
  }
315
- });
316
289
 
317
- await loadPromise;
290
+ const sheet = new CSSStyleSheet();
291
+ await sheet.replace(cssText);
292
+
293
+ adoptedSheets.push(sheet);
294
+ }
318
295
  }
319
296
 
320
- if (adoptedSheets.length) {
321
- this.getShadowRoot().adoptedStyleSheets = [
297
+ if(adoptedSheets.length){
298
+ this.getShadowRoot().adoptedStyleSheets = [
322
299
  ...adoptedSheets,
323
300
  ...this.getShadowRoot().adoptedStyleSheets,
324
301
  ];
325
-
326
- doneAdded = true;
327
- }
328
-
329
- if (doneAdded) {
330
- this.$emit(domEvents.loadedLinkedStyles);
331
302
  }
332
303
  }
333
304
  }
package/src/index.ts CHANGED
@@ -22,14 +22,14 @@ import { RWSIgnore, RWSInject, RWSView } from './components/_decorator';
22
22
  import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
23
23
  import type { IRWSPlugin, IStaticRWSPlugin, IPluginSpawnOption } from './types/IRWSPlugin';
24
24
  import type IRWSUser from './types/IRWSUser';
25
- import type { IAssetShowOptions, IRWSViewComponent } from './components/_component';
25
+ import type { IAssetShowOptions } from './components/_component';
26
26
  import type { RWSDecoratorOptions } from './components/_decorator';
27
+ import type { IKDBTypeInfo, IKDBTypesResponse } from './types/IBackendCore';
27
28
  import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
28
29
  import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
29
30
  import type IRWSConfig from './types/IRWSConfig';
30
31
  import type RWSNotify from './types/RWSNotify';
31
32
  import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
32
- import * as RWSEvents from './events';
33
33
 
34
34
  export default RWSClient;
35
35
 
@@ -70,12 +70,11 @@ export {
70
70
  RWSService,
71
71
  RWSViewComponent,
72
72
 
73
- RWSContainer,
74
-
75
- RWSEvents
73
+ RWSContainer
76
74
  };
77
75
 
78
- export type {
76
+ export type {
77
+ IKDBTypeInfo, IKDBTypesResponse,
79
78
  NotifyUiType,
80
79
  NotifyLogType,
81
80
  IBackendRoute as IRWSBackendRoute,
@@ -85,6 +84,5 @@ export type {
85
84
  IAssetShowOptions as IRWSAssetShowOptions,
86
85
  IRWSConfig,
87
86
  IRWSUser,
88
- TagsProcessorType,
89
- IRWSViewComponent
87
+ TagsProcessorType
90
88
  }
@@ -1,4 +1,4 @@
1
- import { IKDBTypesResponse } from '../../../components/src/types/IBackendCore';
1
+ import { IKDBTypesResponse } from '../types/IBackendCore';
2
2
  import TheService from './_service';
3
3
 
4
4
  //@4DI
@@ -83,7 +83,7 @@ class DOMService extends RWSService {
83
83
  sanitizeOptions: DOMPurify.Config = { })
84
84
  {
85
85
  const output: string = line.trim();
86
- const sanitized = DOMPurify.sanitize(output, { USE_PROFILES: { html: true }, ...sanitizeOptions}) as string;
86
+ const sanitized = DOMPurify.sanitize(output, { USE_PROFILES: { html: true }, ...sanitizeOptions});
87
87
  return sanitized;
88
88
  }
89
89
  }
@@ -0,0 +1,12 @@
1
+ export interface IKDBTypeInfo {
2
+ fieldName: string;
3
+ type: string;
4
+ boundModel?: string
5
+ }
6
+
7
+ export interface IKDBTypesResponse {
8
+ success: boolean;
9
+ data: {
10
+ types: IKDBTypeInfo[];
11
+ };
12
+ }
@@ -0,0 +1,5 @@
1
+ export interface IRWSResourceQuery {
2
+ fieldName: string,
3
+ type: String,
4
+ boundModel: string
5
+ }
@@ -1,9 +1,9 @@
1
- import { FASTElement, ViewTemplate } from '@microsoft/fast-element';
1
+ import { ViewTemplate } from '@microsoft/fast-element';
2
2
  import { DOMOutputType } from '../services/DOMService';
3
3
 
4
4
  type IAssetShowOptions = Record<string, any>;
5
5
 
6
- interface IRWSViewComponent extends FASTElement {
6
+ interface IRWSViewComponent extends Node {
7
7
  __isLoading: boolean;
8
8
  routeParams: Record<string, string>;
9
9
  trashIterator: number;
@@ -0,0 +1,5 @@
1
+ export interface IReFormerField {
2
+ name: string,
3
+ defaultValue?: any,
4
+ setForm: (field: string, value: any) => Promise<void>
5
+ }
package/src/events.ts DELETED
@@ -1,3 +0,0 @@
1
- export const domEvents = {
2
- loadedLinkedStyles: 'loaded:linked'
3
- }