@sneat/app 0.24.0 → 0.25.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/esm2022/index.js +1 -3
- package/esm2022/index.js.map +1 -1
- package/esm2022/lib/app-specific-providers.js +1 -7
- package/esm2022/lib/app-specific-providers.js.map +1 -1
- package/esm2022/lib/base-app.component.js +8 -49
- package/esm2022/lib/base-app.component.js.map +1 -1
- package/esm2022/lib/get-standard-sneat-providers.js +17 -60
- package/esm2022/lib/get-standard-sneat-providers.js.map +1 -1
- package/esm2022/lib/init-firebase.js +1 -84
- package/esm2022/lib/init-firebase.js.map +1 -1
- package/index.d.ts +1 -3
- package/lib/app-specific-providers.d.ts +1 -2
- package/lib/base-app.component.d.ts +1 -6
- package/lib/get-standard-sneat-providers.d.ts +2 -0
- package/lib/init-firebase.d.ts +1 -4
- package/package.json +20 -2
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
- package/esm2022/lib/page-title.service.js +0 -42
- package/esm2022/lib/page-title.service.js.map +0 -1
- package/esm2022/lib/register-posthog.js +0 -11
- package/esm2022/lib/register-posthog.js.map +0 -1
- package/esm2022/lib/route-title.js +0 -24
- package/esm2022/lib/route-title.js.map +0 -1
- package/esm2022/lib/sneat-title.strategy.js +0 -28
- package/esm2022/lib/sneat-title.strategy.js.map +0 -1
- package/lib/page-title.service.d.ts +0 -10
- package/lib/register-posthog.d.ts +0 -2
- package/lib/route-title.d.ts +0 -2
- package/lib/sneat-title.strategy.d.ts +0 -8
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { inject, Injectable } from '@angular/core';
|
|
2
|
-
import { Title } from '@angular/platform-browser';
|
|
3
|
-
import { APP_INFO } from '@sneat/core';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
// Owns the browser/document title. A page can set it imperatively during its
|
|
6
|
-
// lifecycle, e.g. once a record loads:
|
|
7
|
-
// inject(PageTitleService).setPageTitle(space.title)
|
|
8
|
-
//
|
|
9
|
-
// Composes the "bare" page title with the app name (APP_INFO.appTitle, e.g.
|
|
10
|
-
// "Debtus.app") => "Debts @ Debtus.app", or just the app name when no page
|
|
11
|
-
// title is given. SneatTitleStrategy calls this on every navigation with the
|
|
12
|
-
// route's declarative data.title, so a value set by one page does not leak into
|
|
13
|
-
// the next.
|
|
14
|
-
//
|
|
15
|
-
// If the app forgot to register APP_INFO we fall back to the current host name
|
|
16
|
-
// (e.g. "debtus.app") and warn once, so the title is still sensible while
|
|
17
|
-
// surfacing the misconfiguration to the developer.
|
|
18
|
-
export class PageTitleService {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.title = inject(Title);
|
|
21
|
-
this.appInfo = inject(APP_INFO, { optional: true });
|
|
22
|
-
if (this.appInfo?.appTitle) {
|
|
23
|
-
this.appTitle = this.appInfo.appTitle;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
this.appTitle = location.host;
|
|
27
|
-
console.warn(`[PageTitleService] APP_INFO is not provided (or has no appTitle). ` +
|
|
28
|
-
`Falling back to host "${this.appTitle}" for the document title. ` +
|
|
29
|
-
`Register it via provideAppInfo({ appId, appTitle }).`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
setPageTitle(pageTitle) {
|
|
33
|
-
this.title.setTitle(pageTitle ? `${pageTitle} @ ${this.appTitle}` : this.appTitle);
|
|
34
|
-
}
|
|
35
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: PageTitleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
36
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: PageTitleService, providedIn: 'root' }); }
|
|
37
|
-
}
|
|
38
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: PageTitleService, decorators: [{
|
|
39
|
-
type: Injectable,
|
|
40
|
-
args: [{ providedIn: 'root' }]
|
|
41
|
-
}], ctorParameters: () => [] });
|
|
42
|
-
//# sourceMappingURL=page-title.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page-title.service.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/page-title.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAC;;AAEjD,6EAA6E;AAC7E,uCAAuC;AACvC,uDAAuD;AACvD,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,gFAAgF;AAChF,YAAY;AACZ,EAAE;AACF,+EAA+E;AAC/E,0EAA0E;AAC1E,mDAAmD;AAEnD,MAAM,OAAO,gBAAgB;IAK3B;QAJiB,UAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACtB,YAAO,GAAG,MAAM,CAAW,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAIxE,IAAI,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC9B,OAAO,CAAC,IAAI,CACV,oEAAoE;gBAClE,yBAAyB,IAAI,CAAC,QAAQ,4BAA4B;gBAClE,sDAAsD,CACzD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,YAAY,CAAC,SAA6B;QACxC,IAAI,CAAC,KAAK,CAAC,QAAQ,CACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAC9D,CAAC;IACJ,CAAC;8GAtBU,gBAAgB;kHAAhB,gBAAgB,cADH,MAAM;;2FACnB,gBAAgB;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { APP_INFO, IAppInfo } from '@sneat/core';\n\n// Owns the browser/document title. A page can set it imperatively during its\n// lifecycle, e.g. once a record loads:\n// inject(PageTitleService).setPageTitle(space.title)\n//\n// Composes the \"bare\" page title with the app name (APP_INFO.appTitle, e.g.\n// \"Debtus.app\") => \"Debts @ Debtus.app\", or just the app name when no page\n// title is given. SneatTitleStrategy calls this on every navigation with the\n// route's declarative data.title, so a value set by one page does not leak into\n// the next.\n//\n// If the app forgot to register APP_INFO we fall back to the current host name\n// (e.g. \"debtus.app\") and warn once, so the title is still sensible while\n// surfacing the misconfiguration to the developer.\n@Injectable({ providedIn: 'root' })\nexport class PageTitleService {\n private readonly title = inject(Title);\n private readonly appInfo = inject<IAppInfo>(APP_INFO, { optional: true });\n private readonly appTitle: string;\n\n constructor() {\n if (this.appInfo?.appTitle) {\n this.appTitle = this.appInfo.appTitle;\n } else {\n this.appTitle = location.host;\n console.warn(\n `[PageTitleService] APP_INFO is not provided (or has no appTitle). ` +\n `Falling back to host \"${this.appTitle}\" for the document title. ` +\n `Register it via provideAppInfo({ appId, appTitle }).`,\n );\n }\n }\n\n setPageTitle(pageTitle: string | undefined): void {\n this.title.setTitle(\n pageTitle ? `${pageTitle} @ ${this.appTitle}` : this.appTitle,\n );\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import posthog from 'posthog-js';
|
|
2
|
-
export function registerPosthog(settings) {
|
|
3
|
-
// Under NodeNext + ESM, TS can sometimes treat the import as a module namespace.
|
|
4
|
-
// Cast to the declared PostHog interface to access instance methods like init().
|
|
5
|
-
// (posthog as unknown as PostHog)
|
|
6
|
-
posthog.init(settings.token, {
|
|
7
|
-
...settings.config,
|
|
8
|
-
capture_pageview: false,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=register-posthog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register-posthog.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/register-posthog.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,MAAM,UAAU,eAAe,CAAC,QAA0B;IACxD,iFAAiF;IACjF,iFAAiF;IACjF,kCAAkC;IAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;QAC3B,GAAG,QAAQ,CAAC,MAAM;QAClB,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { IPosthogSettings } from '@sneat/core';\nimport posthog from 'posthog-js';\n\nexport function registerPosthog(settings: IPosthogSettings): void {\n // Under NodeNext + ESM, TS can sometimes treat the import as a module namespace.\n // Cast to the declared PostHog interface to access instance methods like init().\n // (posthog as unknown as PostHog)\n posthog.init(settings.token, {\n ...settings.config,\n capture_pageview: false,\n });\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Derives the page title from route config: walks to the deepest activated
|
|
2
|
-
// route, reads its `data['title']`, and (for space routes) prefixes the space
|
|
3
|
-
// type, e.g. data.title="Debts" on a family space => "Family Debts". This is
|
|
4
|
-
// the single source of the "bare" page title (without the app-name suffix),
|
|
5
|
-
// shared by SneatTitleStrategy (document.title) and BaseAppComponent (analytics)
|
|
6
|
-
// so both stay in sync.
|
|
7
|
-
export function getRouteTitle(snapshot) {
|
|
8
|
-
let route = snapshot.root;
|
|
9
|
-
while (route.firstChild) {
|
|
10
|
-
route = route.firstChild;
|
|
11
|
-
}
|
|
12
|
-
let title = route.data['title'];
|
|
13
|
-
if (title) {
|
|
14
|
-
const spaceType = route.paramMap.get('spaceType');
|
|
15
|
-
if (spaceType) {
|
|
16
|
-
title = `${capitalizeFirstLetter(spaceType)} ${title}`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return title;
|
|
20
|
-
}
|
|
21
|
-
function capitalizeFirstLetter(text) {
|
|
22
|
-
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=route-title.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-title.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/route-title.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,iFAAiF;AACjF,wBAAwB;AACxB,MAAM,UAAU,aAAa,CAAC,QAA6B;IACzD,IAAI,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC1B,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;QACxB,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAuB,CAAC;IACtD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,GAAG,GAAG,qBAAqB,CAAC,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { RouterStateSnapshot } from '@angular/router';\n\n// Derives the page title from route config: walks to the deepest activated\n// route, reads its `data['title']`, and (for space routes) prefixes the space\n// type, e.g. data.title=\"Debts\" on a family space => \"Family Debts\". This is\n// the single source of the \"bare\" page title (without the app-name suffix),\n// shared by SneatTitleStrategy (document.title) and BaseAppComponent (analytics)\n// so both stay in sync.\nexport function getRouteTitle(snapshot: RouterStateSnapshot): string | undefined {\n let route = snapshot.root;\n while (route.firstChild) {\n route = route.firstChild;\n }\n let title = route.data['title'] as string | undefined;\n if (title) {\n const spaceType = route.paramMap.get('spaceType');\n if (spaceType) {\n title = `${capitalizeFirstLetter(spaceType)} ${title}`;\n }\n }\n return title;\n}\n\nfunction capitalizeFirstLetter(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { inject, Injectable } from '@angular/core';
|
|
2
|
-
import { TitleStrategy } from '@angular/router';
|
|
3
|
-
import { PageTitleService } from './page-title.service';
|
|
4
|
-
import { getRouteTitle } from './route-title';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
// Single place that owns document.title for every Sneat-based app. On each
|
|
7
|
-
// navigation it reads the route's declarative `data['title']` (via getRouteTitle)
|
|
8
|
-
// and hands it to PageTitleService, which composes it with the app name.
|
|
9
|
-
//
|
|
10
|
-
// Pages can override the title imperatively during their lifecycle by calling
|
|
11
|
-
// PageTitleService.setPageTitle(...) directly; the next navigation resets it.
|
|
12
|
-
//
|
|
13
|
-
// Registered once in getStandardSneatProviders, so every app inherits it.
|
|
14
|
-
export class SneatTitleStrategy extends TitleStrategy {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.pageTitleService = inject(PageTitleService);
|
|
18
|
-
}
|
|
19
|
-
updateTitle(snapshot) {
|
|
20
|
-
this.pageTitleService.setPageTitle(getRouteTitle(snapshot));
|
|
21
|
-
}
|
|
22
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SneatTitleStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
23
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SneatTitleStrategy }); }
|
|
24
|
-
}
|
|
25
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SneatTitleStrategy, decorators: [{
|
|
26
|
-
type: Injectable
|
|
27
|
-
}] });
|
|
28
|
-
//# sourceMappingURL=sneat-title.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sneat-title.strategy.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/sneat-title.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAuB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;;AAE9C,2EAA2E;AAC3E,kFAAkF;AAClF,yEAAyE;AACzE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,EAAE;AACF,0EAA0E;AAE1E,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IADrD;;QAEmB,qBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;KAK9D;IAHU,WAAW,CAAC,QAA6B;QAChD,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9D,CAAC;8GALU,kBAAkB;kHAAlB,kBAAkB;;2FAAlB,kBAAkB;kBAD9B,UAAU","sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { RouterStateSnapshot, TitleStrategy } from '@angular/router';\nimport { PageTitleService } from './page-title.service';\nimport { getRouteTitle } from './route-title';\n\n// Single place that owns document.title for every Sneat-based app. On each\n// navigation it reads the route's declarative `data['title']` (via getRouteTitle)\n// and hands it to PageTitleService, which composes it with the app name.\n//\n// Pages can override the title imperatively during their lifecycle by calling\n// PageTitleService.setPageTitle(...) directly; the next navigation resets it.\n//\n// Registered once in getStandardSneatProviders, so every app inherits it.\n@Injectable()\nexport class SneatTitleStrategy extends TitleStrategy {\n private readonly pageTitleService = inject(PageTitleService);\n\n override updateTitle(snapshot: RouterStateSnapshot): void {\n this.pageTitleService.setPageTitle(getRouteTitle(snapshot));\n }\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class PageTitleService {
|
|
3
|
-
private readonly title;
|
|
4
|
-
private readonly appInfo;
|
|
5
|
-
private readonly appTitle;
|
|
6
|
-
constructor();
|
|
7
|
-
setPageTitle(pageTitle: string | undefined): void;
|
|
8
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<PageTitleService, never>;
|
|
9
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<PageTitleService>;
|
|
10
|
-
}
|
package/lib/route-title.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RouterStateSnapshot, TitleStrategy } from '@angular/router';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export declare class SneatTitleStrategy extends TitleStrategy {
|
|
4
|
-
private readonly pageTitleService;
|
|
5
|
-
updateTitle(snapshot: RouterStateSnapshot): void;
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SneatTitleStrategy, never>;
|
|
7
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<SneatTitleStrategy>;
|
|
8
|
-
}
|