@fluid-topics/ft-app-context 1.1.67 → 1.1.69
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/build/ft-app-context.d.ts +3 -1
- package/build/ft-app-context.js +18 -4
- package/build/ft-app-context.light.js +3 -3
- package/build/ft-app-context.min.js +15 -15
- package/build/ft-app-context.properties.d.ts +2 -0
- package/build/index.d.ts +1 -3
- package/build/index.js +1 -3
- package/build/redux-stores/FtAppInfoStore.d.ts +2 -0
- package/build/redux-stores/FtAppInfoStore.js +2 -0
- package/build/services/FtAppInfoStoreService.d.ts +10 -0
- package/build/services/FtAppInfoStoreService.js +10 -0
- package/build/services/HighlightHtmlService.d.ts +8 -0
- package/build/services/HighlightHtmlService.js +7 -0
- package/build/services/index.d.ts +7 -0
- package/build/services/index.js +7 -0
- package/build/services/webapp/AuthenticationService.d.ts +25 -0
- package/build/services/webapp/AuthenticationService.js +11 -0
- package/build/services/webapp/ExternalComponents.d.ts +12 -0
- package/build/services/webapp/ExternalComponents.js +3 -0
- package/build/services/webapp/NotificationService.d.ts +19 -0
- package/build/services/webapp/NotificationService.js +14 -0
- package/build/services/webapp/RouterService.d.ts +12 -0
- package/build/services/webapp/RouterService.js +5 -0
- package/build/services/webapp/index.d.ts +4 -0
- package/build/services/webapp/index.js +4 -0
- package/package.json +5 -4
|
@@ -15,9 +15,11 @@ export declare class FtAppContext extends FtLitElement implements FtAppContextPr
|
|
|
15
15
|
openExternalDocumentInNewTab: boolean;
|
|
16
16
|
noCustomComponent: boolean | string;
|
|
17
17
|
withManualResources: boolean;
|
|
18
|
+
navigatorOnline: boolean;
|
|
19
|
+
forcedOffline: boolean;
|
|
20
|
+
apiProvider: () => import("@fluid-topics/public-api").FluidTopicsApi | undefined;
|
|
18
21
|
messageContexts: FtMessageContext[];
|
|
19
22
|
session?: FtSession;
|
|
20
|
-
apiProvider: () => import("@fluid-topics/public-api").FluidTopicsApi | undefined;
|
|
21
23
|
private cache;
|
|
22
24
|
render(): import("lit").TemplateResult<1>;
|
|
23
25
|
update(props: PropertyValues<FtAppContext>): void;
|
package/build/ft-app-context.js
CHANGED
|
@@ -21,8 +21,10 @@ class FtAppContext extends FtLitElement {
|
|
|
21
21
|
this.openExternalDocumentInNewTab = false;
|
|
22
22
|
this.noCustomComponent = false;
|
|
23
23
|
this.withManualResources = false;
|
|
24
|
-
this.
|
|
24
|
+
this.navigatorOnline = false;
|
|
25
|
+
this.forcedOffline = false;
|
|
25
26
|
this.apiProvider = () => FluidTopicsApiProvider.get();
|
|
27
|
+
this.messageContexts = [];
|
|
26
28
|
this.cache = new CacheRegistry();
|
|
27
29
|
this.cleanSessionDebouncer = new Debouncer();
|
|
28
30
|
}
|
|
@@ -67,6 +69,12 @@ class FtAppContext extends FtLitElement {
|
|
|
67
69
|
if (props.has("openExternalDocumentInNewTab")) {
|
|
68
70
|
ftAppInfoStore.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab);
|
|
69
71
|
}
|
|
72
|
+
if (props.has("navigatorOnline")) {
|
|
73
|
+
ftAppInfoStore.actions.navigatorOnline(this.navigatorOnline);
|
|
74
|
+
}
|
|
75
|
+
if (props.has("forcedOffline")) {
|
|
76
|
+
ftAppInfoStore.actions.forcedOffline(this.forcedOffline);
|
|
77
|
+
}
|
|
70
78
|
setTimeout(() => this.updateIfNeeded());
|
|
71
79
|
}
|
|
72
80
|
async updateIfNeeded() {
|
|
@@ -139,13 +147,19 @@ __decorate([
|
|
|
139
147
|
__decorate([
|
|
140
148
|
property({ type: Boolean })
|
|
141
149
|
], FtAppContext.prototype, "withManualResources", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: Boolean })
|
|
152
|
+
], FtAppContext.prototype, "navigatorOnline", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Boolean })
|
|
155
|
+
], FtAppContext.prototype, "forcedOffline", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: Object })
|
|
158
|
+
], FtAppContext.prototype, "apiProvider", void 0);
|
|
142
159
|
__decorate([
|
|
143
160
|
jsonProperty([])
|
|
144
161
|
], FtAppContext.prototype, "messageContexts", void 0);
|
|
145
162
|
__decorate([
|
|
146
163
|
jsonProperty(undefined)
|
|
147
164
|
], FtAppContext.prototype, "session", void 0);
|
|
148
|
-
__decorate([
|
|
149
|
-
property({ type: Object })
|
|
150
|
-
], FtAppContext.prototype, "apiProvider", void 0);
|
|
151
165
|
export { FtAppContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,s,
|
|
2
|
-
`,
|
|
1
|
+
!function(t,i,s,e){const n=s.css`
|
|
2
|
+
`,o="ft-app-info",a=i.FtReduxStore.get({name:o,reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1}});class l{static get(t){const{baseUrl:i,apiIntegrationIdentifier:s}=a.getState(),e=null!=t?t:s;if(i&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(i,e,!0)}static await(t){return new Promise((i=>{let s=l.get(t);if(s)i(s);else{const e=a.subscribe((()=>{s=l.get(t),s&&(e(),i(s))}))}}))}}class h{constructor(t=!0,s){var e;this.overrideApi=s;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new i.CacheRegistry,this.cache=t?n.commonCache:new i.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:l.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:l.await()}clearCache(){this.cache.clearAll()}}var r;const c=Symbol("clearAfterUnitTest");class d extends h{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[r]=()=>{this.defaultMessages={},this.cache=new i.CacheRegistry,this.listeners={}},this.currentUiLocale=a.getState().uiLocale,a.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=a.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const i=t.name.toLowerCase();this.cache.setFinal(i,t),this.notify(i)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,s){var e;if(t=t.toLowerCase(),Object.keys(s).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...s};i.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,s,...e){var n,o,a;t=t.toLowerCase(),this.fetchContext(t);const l=null!==(o=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==o?o:{};return new i.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},l).resolve(s,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,i){var s;return t=t.toLowerCase(),this.listeners[t]=null!==(s=this.listeners[t])&&void 0!==s?s:new Set,this.listeners[t].add(i),()=>{var s;return null===(s=this.listeners[t])||void 0===s?void 0:s.delete(i)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>i.delay(0).then((()=>t())).catch((()=>null)))))}}r=c,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends d{constructor(){super((async(t,i)=>(await this.awaitApi).getFluidTopicsMessageContext(t,i)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends d{constructor(){super((async(t,i)=>(await this.awaitApi).getCustomMessageContext(t,i)))}});const u=window.FluidTopicsI18nService,v=window.FluidTopicsCustomI18nService;var w=function(t,i,s,e){for(var n,o=arguments.length,a=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,l=t.length-1;l>=0;l--)(n=t[l])&&(a=(o<3?n(a):o>3?n(i,s,a):n(i,s))||a);return o>3&&a&&Object.defineProperty(i,s,a),a};class m extends i.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.navigatorOnline=!1,this.forcedOffline=!1,this.apiProvider=()=>l.get(),this.messageContexts=[],this.cache=new i.CacheRegistry,this.cleanSessionDebouncer=new i.Debouncer}render(){return s.html`
|
|
3
3
|
<slot></slot>
|
|
4
|
-
`}update(t){super.update(t),t.has("baseUrl")&&(
|
|
4
|
+
`}update(t){super.update(t),t.has("baseUrl")&&(a.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&a.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&a.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&a.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&a.actions.noCustom(this.noCustom),t.has("editorMode")&&a.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&a.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&a.actions.session(this.session),t.has("availableUiLocales")&&a.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>u.addContext(t))),t.has("openExternalDocumentInNewTab")&&a.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),t.has("navigatorOnline")&&a.actions.navigatorOnline(this.navigatorOnline),t.has("forcedOffline")&&a.actions.forcedOffline(this.forcedOffline),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}m.elementDefinitions={},m.styles=n,w([e.property()],m.prototype,"baseUrl",void 0),w([e.property()],m.prototype,"apiIntegrationIdentifier",void 0),w([e.property()],m.prototype,"uiLocale",void 0),w([i.jsonProperty(null)],m.prototype,"availableUiLocales",void 0),w([i.jsonProperty(null)],m.prototype,"metadataConfiguration",void 0),w([e.property({type:Boolean})],m.prototype,"editorMode",void 0),w([e.property({type:Boolean})],m.prototype,"noCustom",void 0),w([e.property({type:Boolean})],m.prototype,"openExternalDocumentInNewTab",void 0),w([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],m.prototype,"noCustomComponent",void 0),w([e.property({type:Boolean})],m.prototype,"withManualResources",void 0),w([e.property({type:Boolean})],m.prototype,"navigatorOnline",void 0),w([e.property({type:Boolean})],m.prototype,"forcedOffline",void 0),w([e.property({type:Object})],m.prototype,"apiProvider",void 0),w([i.jsonProperty([])],m.prototype,"messageContexts",void 0),w([i.jsonProperty(void 0)],m.prototype,"session",void 0);class f extends h{async listMySearches(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class p extends h{async listMyBookmarks(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const y="ft-user-assets",C=i.FtReduxStore.get({name:y,initialState:{savedSearches:void 0,bookmarks:void 0}});const b=new class{constructor(){this.currentSession=a.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new p,this.savedSearchesService=new f,a.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:s}=a.getState();i.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==s?void 0:s.profile)||(this.currentSession=s,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),C.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),C.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();C.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const i=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;C.actions.bookmarks(i)}}};class g{addCommand(t,i=!1){a.commands.add(t,i)}consumeCommand(t){return a.commands.consume(t)}}window.FluidTopicsAppInfoStoreService=new g;class x{highlightHtml(t,s){i.highlightHtml(t,s)}}window.FluidTopicsHighlightHtmlService=new x,i.customElement("ft-app-context")(m),t.AppInfoStoreService=g,t.BookmarksService=p,t.FluidTopicsApiProvider=l,t.FtAppContext=m,t.FtAppContextCssVariables={},t.FtAppInfoStoreName=o,t.FtI18nServiceInternalClass=d,t.FtServiceWithCache=h,t.FtUserAssetsStoreName=y,t.HighlightHtmlService=x,t.SavedSearchesService=f,t.clearAfterUnitTest=c,t.ftAppInfoStore=a,t.ftCustomI18nService=v,t.ftI18nService=u,t.ftUserAssetsStore=C,t.styles=n,t.userAssetsActions=b}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
|