@rws-framework/client 2.21.4 → 2.21.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.21.4",
4
+ "version": "2.21.5",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -13,6 +13,7 @@ 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';
16
17
 
17
18
  type ComposeMethodType<
18
19
  T extends FoundationElementDefinition,
@@ -262,47 +263,71 @@ abstract class RWSViewComponent extends FoundationElement implements IRWSViewCom
262
263
 
263
264
  let adoptedSheets: CSSStyleSheet[] = [];
264
265
 
266
+ let doneAdded = false;
267
+
265
268
  for (const styleLink of styleLinks) {
266
- if (mode === 'legacy' || mode === 'both') {
267
- const link = document.createElement('link');
268
- link.rel = 'stylesheet';
269
- link.href = styleLink;
270
- this.getShadowRoot().appendChild(link);
271
- }
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
+ }
272
284
 
273
- if (mode === 'adopted' || mode === 'both') {
274
- const entry = await this.indexedDBService.getFromDB(db, storeName, styleLink);
285
+ if (mode === 'adopted' || mode === 'both') {
286
+ const entry = await this.indexedDBService.getFromDB(db, storeName, styleLink);
275
287
 
276
- let cssText: string | null = null;
288
+ let cssText: string | null = null;
277
289
 
278
- if (entry && typeof entry === 'object' && 'css' in entry && 'timestamp' in entry) {
279
- const expired = Date.now() - entry.timestamp > maxAgeDays;
280
- if (!expired) {
281
- cssText = entry.css;
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
+ }
282
295
  }
283
- }
284
296
 
285
- if (!cssText) {
286
- cssText = await fetch(styleLink).then(res => res.text());
287
- await this.indexedDBService.saveToDB(db, storeName, styleLink, {
288
- css: cssText,
289
- timestamp: Date.now()
290
- });
291
- console.log(`System saved stylesheet: ${styleLink} to IndexedDB`)
292
- }
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
+ }
293
305
 
294
- const sheet = new CSSStyleSheet();
295
- await sheet.replace(cssText);
306
+ const sheet = new CSSStyleSheet();
307
+ await sheet.replace(cssText);
296
308
 
297
- adoptedSheets.push(sheet);
298
- }
309
+ adoptedSheets.push(sheet);
310
+
311
+ if(mode === 'adopted' || mode === 'both'){
312
+ resolve();
313
+ }
314
+ }
315
+ });
316
+
317
+ await loadPromise;
299
318
  }
300
319
 
301
- if(adoptedSheets.length){
302
- this.getShadowRoot().adoptedStyleSheets = [
320
+ if (adoptedSheets.length) {
321
+ this.getShadowRoot().adoptedStyleSheets = [
303
322
  ...adoptedSheets,
304
323
  ...this.getShadowRoot().adoptedStyleSheets,
305
324
  ];
325
+
326
+ doneAdded = true;
327
+ }
328
+
329
+ if (doneAdded) {
330
+ this.$emit(domEvents.loadedLinkedStyles);
306
331
  }
307
332
  }
308
333
  }
package/src/events.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const domEvents = {
2
+ loadedLinkedStyles: 'loaded:linked'
3
+ }
package/src/index.ts CHANGED
@@ -24,12 +24,12 @@ import type { IRWSPlugin, IStaticRWSPlugin, IPluginSpawnOption } from './types/I
24
24
  import type IRWSUser from './types/IRWSUser';
25
25
  import type { IAssetShowOptions, IRWSViewComponent } from './components/_component';
26
26
  import type { RWSDecoratorOptions } from './components/_decorator';
27
- import type { IKDBTypeInfo, IKDBTypesResponse } from './types/IBackendCore';
28
27
  import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
29
28
  import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
30
29
  import type IRWSConfig from './types/IRWSConfig';
31
30
  import type RWSNotify from './types/RWSNotify';
32
31
  import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
32
+ import * as RWSEvents from './events';
33
33
 
34
34
  export default RWSClient;
35
35
 
@@ -70,11 +70,12 @@ export {
70
70
  RWSService,
71
71
  RWSViewComponent,
72
72
 
73
- RWSContainer
73
+ RWSContainer,
74
+
75
+ RWSEvents
74
76
  };
75
77
 
76
- export type {
77
- IKDBTypeInfo, IKDBTypesResponse,
78
+ export type {
78
79
  NotifyUiType,
79
80
  NotifyLogType,
80
81
  IBackendRoute as IRWSBackendRoute,
@@ -1,4 +1,4 @@
1
- import { IKDBTypesResponse } from '../types/IBackendCore';
1
+ import { IKDBTypesResponse } from '../../../components/src/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});
86
+ const sanitized = DOMPurify.sanitize(output, { USE_PROFILES: { html: true }, ...sanitizeOptions}) as string;
87
87
  return sanitized;
88
88
  }
89
89
  }
@@ -1,12 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- export interface IRWSResourceQuery {
2
- fieldName: string,
3
- type: String,
4
- boundModel: string
5
- }
@@ -1,5 +0,0 @@
1
- export interface IReFormerField {
2
- name: string,
3
- defaultValue?: any,
4
- setForm: (field: string, value: any) => Promise<void>
5
- }