@rws-framework/client 2.21.3 → 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 +1 -1
- package/src/components/_component.ts +53 -28
- package/src/events.ts +3 -0
- package/src/index.ts +8 -6
- package/src/services/ApiService.ts +1 -1
- package/src/services/DOMService.ts +1 -1
- package/src/types/IRWSViewComponent.ts +2 -2
- package/src/types/IBackendCore.ts +0 -12
- package/src/types/IRWSResource.ts +0 -5
- package/src/types/IReFormerField.ts +0 -5
package/package.json
CHANGED
|
@@ -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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
274
|
-
|
|
285
|
+
if (mode === 'adopted' || mode === 'both') {
|
|
286
|
+
const entry = await this.indexedDBService.getFromDB(db, storeName, styleLink);
|
|
275
287
|
|
|
276
|
-
|
|
288
|
+
let cssText: string | null = null;
|
|
277
289
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
295
|
-
|
|
306
|
+
const sheet = new CSSStyleSheet();
|
|
307
|
+
await sheet.replace(cssText);
|
|
296
308
|
|
|
297
|
-
|
|
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
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 } from './components/_component';
|
|
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,
|
|
@@ -84,5 +85,6 @@ export type {
|
|
|
84
85
|
IAssetShowOptions as IRWSAssetShowOptions,
|
|
85
86
|
IRWSConfig,
|
|
86
87
|
IRWSUser,
|
|
87
|
-
TagsProcessorType
|
|
88
|
+
TagsProcessorType,
|
|
89
|
+
IRWSViewComponent
|
|
88
90
|
}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
-
import { ViewTemplate } from '@microsoft/fast-element';
|
|
1
|
+
import { FASTElement, 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
|
|
6
|
+
interface IRWSViewComponent extends FASTElement {
|
|
7
7
|
__isLoading: boolean;
|
|
8
8
|
routeParams: Record<string, string>;
|
|
9
9
|
trashIterator: number;
|