@tech4good/platform-ui 0.0.0-stage → 0.1.0-alpha.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/CHANGELOG.md +7 -0
- package/MIGRATION.md +46 -0
- package/README.md +119 -2
- package/fesm2022/tech4good-platform-ui.mjs +134 -0
- package/fesm2022/tech4good-platform-ui.mjs.map +1 -0
- package/package.json +26 -4
- package/types/tech4good-platform-ui.d.ts +51 -0
- package/types/tech4good-platform-ui.d.ts.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
- Extract the standalone redeployment warning and its polling service.
|
|
6
|
+
- Add configurable copy, CSS custom properties, accessible Material buttons and base-URL-aware polling.
|
|
7
|
+
- Package Angular partial compilation output with public API and rendered component tests.
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Adopt the shared redeployment warning
|
|
2
|
+
|
|
3
|
+
Use a development branch or disposable checkout in the consuming repository.
|
|
4
|
+
The existing MathPets and Mentor warning implementations have the same service API,
|
|
5
|
+
so their first migration can be limited to the app shell and copied warning files.
|
|
6
|
+
|
|
7
|
+
1. Build and pack the UI package with `npm run pack:ui` in angular-schematics.
|
|
8
|
+
2. Install the returned archive in the consumer:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install --no-save --package-lock=false /absolute/path/to/tech4good-platform-ui-0.1.0-alpha.0.tgz
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For a published version use `npm install --save-exact @tech4good/platform-ui@0.1.0-alpha.0`.
|
|
15
|
+
Angular 21, Angular Material, and RxJS are peers; keep their compatible versions
|
|
16
|
+
in the app. The local archive changes `node_modules` even with these flags.
|
|
17
|
+
3. Replace the app component's two local imports:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { DetectRedeploymentService, RedeploymentWarningComponent } from '@tech4good/platform-ui';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Keep the standalone `imports: [RedeploymentWarningComponent]` entry and the
|
|
24
|
+
existing `detectRedeployment.init()` call. No auth or data provider changes are needed.
|
|
25
|
+
4. Change `<app-redeployment-warning>` to `<t4g-redeployment-warning>` in the
|
|
26
|
+
app template and in its placement styles. Keep placement in the app shell.
|
|
27
|
+
5. Delete `src/app/shared/redeployment-warning` and its copied unit tests after
|
|
28
|
+
searching for any remaining imports. Keep any app-specific integration tests,
|
|
29
|
+
replacing their service injection token with the package export. You can disable
|
|
30
|
+
polling using `provideRedeploymentWarning({ enabled: false })` in test providers.
|
|
31
|
+
6. Run `npm run lint`, `npm run build`, `npm run test`, and `npm run test:rules`.
|
|
32
|
+
Exercise a production build with two different main hashes: a new shell should
|
|
33
|
+
display the warning; dismiss should hide it; Update Now should reload the app.
|
|
34
|
+
|
|
35
|
+
The former `images/close-x.svg` is no longer required by this component. Remove the
|
|
36
|
+
asset only if no other app component references it. No automatic migration of an
|
|
37
|
+
existing app is included: ng-add generates the package integration for new apps.
|
|
38
|
+
|
|
39
|
+
The banner uses accessible Material buttons, so its appearance is slightly different
|
|
40
|
+
from the original custom link/image controls. Use its string inputs and CSS variables
|
|
41
|
+
for app branding. Development builds without a hashed main script do not poll.
|
|
42
|
+
SSR does not poll; network or response parsing failures no longer stop future checks.
|
|
43
|
+
|
|
44
|
+
After library edits, rebuild/repack/reinstall the tarball and restart the consumer's
|
|
45
|
+
dev server. Do not copy the package source into the consumer. A later `npm ci`
|
|
46
|
+
restores dependencies from the consumer's lockfile after temporary tarball testing.
|
package/README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tech4good/platform-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared Angular UI utilities, starting with the redeployment warning. This package
|
|
4
|
+
has no dependency on app stores, routes, Firebase, platform-data, platform-logging,
|
|
5
|
+
or auth. It targets Angular 21 and uses Angular Material buttons and your app's
|
|
6
|
+
Material theme. RxJS and the Angular packages are peer dependencies.
|
|
7
|
+
|
|
8
|
+
## Use the warning
|
|
9
|
+
|
|
10
|
+
Import the standalone component and start its singleton service from your app shell:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { Component, inject, OnInit } from '@angular/core';
|
|
14
|
+
import { DetectRedeploymentService, RedeploymentWarningComponent } from '@tech4good/platform-ui';
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'app-root',
|
|
18
|
+
imports: [RedeploymentWarningComponent],
|
|
19
|
+
template: '<t4g-redeployment-warning />',
|
|
20
|
+
styles: 't4g-redeployment-warning { position: fixed; top: 15px; right: 15px; }',
|
|
21
|
+
})
|
|
22
|
+
export class AppComponent implements OnInit {
|
|
23
|
+
private readonly redeployment = inject(DetectRedeploymentService);
|
|
24
|
+
|
|
25
|
+
ngOnInit(): void {
|
|
26
|
+
this.redeployment.init();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The app owns placement; the package owns rendering and detection. You can also
|
|
32
|
+
use `DetectRedeploymentService.redeployed()` with an app-specific banner. Calling
|
|
33
|
+
`init()` repeatedly does not create extra pollers. `redeployed()` does not start
|
|
34
|
+
polling on its own. `refresh()` reloads the browser page.
|
|
35
|
+
|
|
36
|
+
## Configure
|
|
37
|
+
|
|
38
|
+
No providers are required for the defaults. To override them, add a provider to
|
|
39
|
+
`ApplicationConfig.providers` at the application root:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { provideRedeploymentWarning } from '@tech4good/platform-ui';
|
|
43
|
+
|
|
44
|
+
provideRedeploymentWarning({
|
|
45
|
+
enabled: true, // false disables polling, useful in tests
|
|
46
|
+
pollIntervalMs: 120_000, // a positive, finite number of milliseconds
|
|
47
|
+
indexUrl: 'index.html', // relative to document.baseURI
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The component accepts `message`, `updateLabel`, and `dismissLabel` string inputs.
|
|
52
|
+
The dismiss control has an accessible name and both actions are native buttons
|
|
53
|
+
with Material behavior. No copied SVG or icon font is required.
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<t4g-redeployment-warning
|
|
57
|
+
message="A new version is available"
|
|
58
|
+
updateLabel="Reload app"
|
|
59
|
+
dismissLabel="Remind me next deployment"
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
CSS custom properties can be set on the component host or inherited from the app:
|
|
64
|
+
|
|
65
|
+
| Property | Default |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `--t4g-redeployment-width` | `350px`, limited to viewport width minus 30px |
|
|
68
|
+
| `--t4g-redeployment-background` | Material surface, with `#fff` fallback |
|
|
69
|
+
| `--t4g-redeployment-color` | Material on-surface, with `#283262` fallback |
|
|
70
|
+
| `--t4g-redeployment-border-color` | Material outline, with `#999` fallback |
|
|
71
|
+
| `--t4g-redeployment-radius` | `5px` |
|
|
72
|
+
| `--t4g-redeployment-z-index` | `100` |
|
|
73
|
+
|
|
74
|
+
## Detection behavior
|
|
75
|
+
|
|
76
|
+
- Compares the loaded hashed `main-*.js` or `main.*.js` script against script tags
|
|
77
|
+
in the latest app shell. The first check runs immediately, then every two minutes.
|
|
78
|
+
- Resolves the app shell against `<base href>` so apps hosted under `/my-app/`
|
|
79
|
+
do not accidentally inspect the domain root. A custom URL retains its query parameters.
|
|
80
|
+
- Adds a timestamp and requests `cache: 'no-store'`. Deployment caching must still
|
|
81
|
+
serve a fresh shell. This is not a service-worker update protocol; apps using
|
|
82
|
+
Angular service workers should use their update lifecycle instead.
|
|
83
|
+
- No polling during SSR, with `enabled: false`, or without a loaded hashed main
|
|
84
|
+
script (including normal unhashed development builds).
|
|
85
|
+
- Shares one poller per root service, avoids overlapping requests, retries after
|
|
86
|
+
network/HTTP/body failures, and aborts stalled requests after 30 seconds.
|
|
87
|
+
- Dismissing hides the current warning. Another distinct deployment displays it
|
|
88
|
+
again. The last detection is replayed if a banner is mounted later.
|
|
89
|
+
- Injector destruction cancels polling and pending requests. Component destruction
|
|
90
|
+
unsubscribes its listener; the root poller continues while the application lives.
|
|
91
|
+
|
|
92
|
+
This detects a changed shell, not whether every deployment asset is available.
|
|
93
|
+
It assumes Angular's hashed main-bundle naming and does not handle nonstandard
|
|
94
|
+
entry names or deployments whose main filename remains unchanged. Reloading may
|
|
95
|
+
lose unsaved app state, so the package leaves that action to the user.
|
|
96
|
+
|
|
97
|
+
## Develop and package
|
|
98
|
+
|
|
99
|
+
From the repository root:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install --ignore-scripts
|
|
103
|
+
npm run build:ui
|
|
104
|
+
npm run test:ui
|
|
105
|
+
npm run pack:ui
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`ng-packagr` produces partially compiled Angular Package Format output in
|
|
109
|
+
`packages/ui/dist`. Tests import the built public API, check declaration types,
|
|
110
|
+
render the compiled component, and exercise polling and cleanup. Pack the **dist**
|
|
111
|
+
directory; the source workspace manifest is for development only and has a
|
|
112
|
+
publication guard. The resulting archive is
|
|
113
|
+
`tech4good-platform-ui-0.1.0-alpha.0.tgz`.
|
|
114
|
+
|
|
115
|
+
The package is independently versioned. New schematics reference its exact alpha
|
|
116
|
+
version. Before releasing those schematics, publish and verify the referenced UI
|
|
117
|
+
version; local build and pack commands do not publish it.
|
|
118
|
+
|
|
119
|
+
See [MIGRATION.md](MIGRATION.md) for existing repositories and
|
|
120
|
+
[the extraction decision](../../docs-plans/platform-ui-extraction.md) for scope.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, PLATFORM_ID, DestroyRef, NgZone, Injectable, input, signal, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import * as i1 from '@angular/material/button';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
7
|
+
import { ReplaySubject, timer, exhaustMap, Observable, catchError, EMPTY } from 'rxjs';
|
|
8
|
+
|
|
9
|
+
const REDEPLOYMENT_WARNING_OPTIONS = new InjectionToken('REDEPLOYMENT_WARNING_OPTIONS', { providedIn: 'root', factory: () => ({}) });
|
|
10
|
+
/** Configure once at the application root. Polling begins when init() is called. */
|
|
11
|
+
function provideRedeploymentWarning(options = {}) {
|
|
12
|
+
if (options.pollIntervalMs !== undefined &&
|
|
13
|
+
(!Number.isFinite(options.pollIntervalMs) || options.pollIntervalMs <= 0)) {
|
|
14
|
+
throw new Error('pollIntervalMs must be a positive finite number.');
|
|
15
|
+
}
|
|
16
|
+
return { provide: REDEPLOYMENT_WARNING_OPTIONS, useValue: { ...options } };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class DetectRedeploymentService {
|
|
20
|
+
document = inject(DOCUMENT);
|
|
21
|
+
platformId = inject(PLATFORM_ID);
|
|
22
|
+
destroyRef = inject(DestroyRef);
|
|
23
|
+
zone = inject(NgZone);
|
|
24
|
+
options = inject(REDEPLOYMENT_WARNING_OPTIONS);
|
|
25
|
+
changes = new ReplaySubject(1);
|
|
26
|
+
changes$ = this.changes.asObservable();
|
|
27
|
+
started = false;
|
|
28
|
+
constructor() {
|
|
29
|
+
this.destroyRef.onDestroy(() => this.changes.complete());
|
|
30
|
+
}
|
|
31
|
+
/** Start one shared poller. Repeated calls return the same event stream. */
|
|
32
|
+
init() {
|
|
33
|
+
if (this.started || this.destroyRef.destroyed)
|
|
34
|
+
return this.changes$;
|
|
35
|
+
this.started = true;
|
|
36
|
+
const view = this.document.defaultView;
|
|
37
|
+
if (this.options.enabled === false || !isPlatformBrowser(this.platformId) ||
|
|
38
|
+
!view || typeof view.fetch !== 'function')
|
|
39
|
+
return this.changes$;
|
|
40
|
+
let previousScript = this.mainScript(this.document);
|
|
41
|
+
// Without a hashed loaded bundle there is no reliable deployed version to compare.
|
|
42
|
+
if (!previousScript)
|
|
43
|
+
return this.changes$;
|
|
44
|
+
const indexUrl = new URL(this.options.indexUrl ?? 'index.html', this.document.baseURI);
|
|
45
|
+
this.zone.runOutsideAngular(() => {
|
|
46
|
+
timer(0, this.options.pollIntervalMs ?? 120_000).pipe(
|
|
47
|
+
// Keep only one request in flight; unsubscribe aborts it during teardown.
|
|
48
|
+
exhaustMap(() => new Observable(subscriber => {
|
|
49
|
+
const controller = new AbortController();
|
|
50
|
+
const url = new URL(indexUrl);
|
|
51
|
+
url.searchParams.set('t', String(Date.now()));
|
|
52
|
+
// A stalled request must not block all subsequent checks.
|
|
53
|
+
const timeout = setTimeout(() => controller.abort(), 30_000);
|
|
54
|
+
void (async () => {
|
|
55
|
+
try {
|
|
56
|
+
const response = await view.fetch(url.href, {
|
|
57
|
+
cache: 'no-store', signal: controller.signal,
|
|
58
|
+
});
|
|
59
|
+
if (response.ok)
|
|
60
|
+
subscriber.next(await response.text());
|
|
61
|
+
subscriber.complete();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
subscriber.error(error);
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
return () => { clearTimeout(timeout); controller.abort(); };
|
|
68
|
+
}).pipe(catchError(() => EMPTY))), takeUntilDestroyed(this.destroyRef)).subscribe(html => {
|
|
69
|
+
const parsed = this.document.implementation.createHTMLDocument();
|
|
70
|
+
parsed.documentElement.innerHTML = html;
|
|
71
|
+
const nextScript = this.mainScript(parsed);
|
|
72
|
+
if (nextScript && nextScript !== previousScript) {
|
|
73
|
+
previousScript = nextScript;
|
|
74
|
+
this.zone.run(() => this.changes.next());
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return this.changes$;
|
|
79
|
+
}
|
|
80
|
+
/** Also replays a detected deployment to a banner mounted after the check. */
|
|
81
|
+
redeployed() {
|
|
82
|
+
return this.changes$;
|
|
83
|
+
}
|
|
84
|
+
refresh() {
|
|
85
|
+
if (isPlatformBrowser(this.platformId))
|
|
86
|
+
this.document.defaultView?.location.reload();
|
|
87
|
+
}
|
|
88
|
+
mainScript(document) {
|
|
89
|
+
for (const script of Array.from(document.querySelectorAll('script[src]'))) {
|
|
90
|
+
const match = script.getAttribute('src')?.match(/(?:^|\/)main[-.][a-zA-Z0-9_-]+\.js(?:[?#].*)?$/);
|
|
91
|
+
if (match)
|
|
92
|
+
return match[0].replace(/^\//, '').split(/[?#]/)[0];
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: DetectRedeploymentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
97
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: DetectRedeploymentService, providedIn: 'root' });
|
|
98
|
+
}
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: DetectRedeploymentService, decorators: [{
|
|
100
|
+
type: Injectable,
|
|
101
|
+
args: [{ providedIn: 'root' }]
|
|
102
|
+
}], ctorParameters: () => [] });
|
|
103
|
+
|
|
104
|
+
class RedeploymentWarningComponent {
|
|
105
|
+
message = input('This version is out of date!', ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
106
|
+
updateLabel = input('Update Now', ...(ngDevMode ? [{ debugName: "updateLabel" }] : /* istanbul ignore next */ []));
|
|
107
|
+
dismissLabel = input('Dismiss update warning', ...(ngDevMode ? [{ debugName: "dismissLabel" }] : /* istanbul ignore next */ []));
|
|
108
|
+
showRedeploymentWarning = signal(false, ...(ngDevMode ? [{ debugName: "showRedeploymentWarning" }] : /* istanbul ignore next */ []));
|
|
109
|
+
detectRedeployment = inject(DetectRedeploymentService);
|
|
110
|
+
constructor() {
|
|
111
|
+
this.detectRedeployment.redeployed().pipe(takeUntilDestroyed()).subscribe(() => {
|
|
112
|
+
this.showRedeploymentWarning.set(true);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
update() {
|
|
116
|
+
this.detectRedeployment.refresh();
|
|
117
|
+
}
|
|
118
|
+
close() {
|
|
119
|
+
this.showRedeploymentWarning.set(false);
|
|
120
|
+
}
|
|
121
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: RedeploymentWarningComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
122
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", type: RedeploymentWarningComponent, isStandalone: true, selector: "t4g-redeployment-warning", inputs: { message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, updateLabel: { classPropertyName: "updateLabel", publicName: "updateLabel", isSignal: true, isRequired: false, transformFunction: null }, dismissLabel: { classPropertyName: "dismissLabel", publicName: "dismissLabel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (showRedeploymentWarning()) {\n <section class=\"warning-container\" [attr.aria-label]=\"message()\">\n <div class=\"header\">\n <span class=\"title\" role=\"status\">{{ message() }}</span>\n <button mat-icon-button type=\"button\" [attr.aria-label]=\"dismissLabel()\" (click)=\"close()\">\n <span aria-hidden=\"true\">\u00D7</span>\n </button>\n </div>\n <button mat-button type=\"button\" class=\"update\" (click)=\"update()\">{{ updateLabel() }}</button>\n </section>\n}\n", styles: [":host{display:block;z-index:var(--t4g-redeployment-z-index, 100)}.warning-container{box-sizing:border-box;width:min(var(--t4g-redeployment-width, 350px),100vw - 30px);padding:8px 12px;background:var(--t4g-redeployment-background, var(--mat-sys-surface, #fff));color:var(--t4g-redeployment-color, var(--mat-sys-on-surface, #283262));border:1px solid var(--t4g-redeployment-border-color, var(--mat-sys-outline, #999));border-radius:var(--t4g-redeployment-radius, 5px);box-shadow:0 1px 4px #0003}.header{display:flex;align-items:center;gap:8px}.title{flex:1;font-size:13px;font-weight:700;text-transform:uppercase}.update{margin-top:4px}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i1.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
123
|
+
}
|
|
124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: RedeploymentWarningComponent, decorators: [{
|
|
125
|
+
type: Component,
|
|
126
|
+
args: [{ selector: 't4g-redeployment-warning', imports: [MatButtonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (showRedeploymentWarning()) {\n <section class=\"warning-container\" [attr.aria-label]=\"message()\">\n <div class=\"header\">\n <span class=\"title\" role=\"status\">{{ message() }}</span>\n <button mat-icon-button type=\"button\" [attr.aria-label]=\"dismissLabel()\" (click)=\"close()\">\n <span aria-hidden=\"true\">\u00D7</span>\n </button>\n </div>\n <button mat-button type=\"button\" class=\"update\" (click)=\"update()\">{{ updateLabel() }}</button>\n </section>\n}\n", styles: [":host{display:block;z-index:var(--t4g-redeployment-z-index, 100)}.warning-container{box-sizing:border-box;width:min(var(--t4g-redeployment-width, 350px),100vw - 30px);padding:8px 12px;background:var(--t4g-redeployment-background, var(--mat-sys-surface, #fff));color:var(--t4g-redeployment-color, var(--mat-sys-on-surface, #283262));border:1px solid var(--t4g-redeployment-border-color, var(--mat-sys-outline, #999));border-radius:var(--t4g-redeployment-radius, 5px);box-shadow:0 1px 4px #0003}.header{display:flex;align-items:center;gap:8px}.title{flex:1;font-size:13px;font-weight:700;text-transform:uppercase}.update{margin-top:4px}\n"] }]
|
|
127
|
+
}], ctorParameters: () => [], propDecorators: { message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], updateLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "updateLabel", required: false }] }], dismissLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissLabel", required: false }] }] } });
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Generated bundle index. Do not edit.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
export { DetectRedeploymentService, RedeploymentWarningComponent, provideRedeploymentWarning };
|
|
134
|
+
//# sourceMappingURL=tech4good-platform-ui.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tech4good-platform-ui.mjs","sources":["../../src/redeployment-warning/redeployment-warning.options.ts","../../src/redeployment-warning/redeployment-warning.service.ts","../../src/redeployment-warning/redeployment-warning.component.ts","../../src/redeployment-warning/redeployment-warning.component.html","../../src/tech4good-platform-ui.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core';\n\nexport interface RedeploymentWarningOptions {\n /** Disable polling, for example in tests or a service-worker-managed app. */\n enabled?: boolean;\n /** Interval between checks in milliseconds. Defaults to two minutes. */\n pollIntervalMs?: number;\n /** Relative to the document base URL. Defaults to index.html. */\n indexUrl?: string;\n}\n\nexport const REDEPLOYMENT_WARNING_OPTIONS = new InjectionToken<RedeploymentWarningOptions>(\n 'REDEPLOYMENT_WARNING_OPTIONS', { providedIn: 'root', factory: () => ({}) },\n);\n\n/** Configure once at the application root. Polling begins when init() is called. */\nexport function provideRedeploymentWarning(options: RedeploymentWarningOptions = {}): Provider {\n if (options.pollIntervalMs !== undefined &&\n (!Number.isFinite(options.pollIntervalMs) || options.pollIntervalMs <= 0)) {\n throw new Error('pollIntervalMs must be a positive finite number.');\n }\n return { provide: REDEPLOYMENT_WARNING_OPTIONS, useValue: { ...options } };\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Injectable, NgZone, PLATFORM_ID, inject } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { EMPTY, Observable, ReplaySubject, catchError, exhaustMap, timer } from 'rxjs';\nimport { REDEPLOYMENT_WARNING_OPTIONS } from './redeployment-warning.options';\n\n@Injectable({ providedIn: 'root' })\nexport class DetectRedeploymentService {\n private readonly document = inject(DOCUMENT);\n private readonly platformId = inject(PLATFORM_ID);\n private readonly destroyRef = inject(DestroyRef);\n private readonly zone = inject(NgZone);\n private readonly options = inject(REDEPLOYMENT_WARNING_OPTIONS);\n private readonly changes = new ReplaySubject<void>(1);\n private readonly changes$ = this.changes.asObservable();\n private started = false;\n\n constructor() {\n this.destroyRef.onDestroy(() => this.changes.complete());\n }\n\n /** Start one shared poller. Repeated calls return the same event stream. */\n init(): Observable<void> {\n if (this.started || this.destroyRef.destroyed) return this.changes$;\n this.started = true;\n const view = this.document.defaultView;\n if (this.options.enabled === false || !isPlatformBrowser(this.platformId) ||\n !view || typeof view.fetch !== 'function') return this.changes$;\n\n let previousScript = this.mainScript(this.document);\n // Without a hashed loaded bundle there is no reliable deployed version to compare.\n if (!previousScript) return this.changes$;\n const indexUrl = new URL(this.options.indexUrl ?? 'index.html', this.document.baseURI);\n\n this.zone.runOutsideAngular(() => {\n timer(0, this.options.pollIntervalMs ?? 120_000).pipe(\n // Keep only one request in flight; unsubscribe aborts it during teardown.\n exhaustMap(() => new Observable<string>(subscriber => {\n const controller = new AbortController();\n const url = new URL(indexUrl);\n url.searchParams.set('t', String(Date.now()));\n // A stalled request must not block all subsequent checks.\n const timeout = setTimeout(() => controller.abort(), 30_000);\n void (async () => {\n try {\n const response = await view.fetch(url.href, {\n cache: 'no-store', signal: controller.signal,\n });\n if (response.ok) subscriber.next(await response.text());\n subscriber.complete();\n } catch (error) {\n subscriber.error(error);\n }\n })();\n return () => { clearTimeout(timeout); controller.abort(); };\n }).pipe(catchError(() => EMPTY))),\n takeUntilDestroyed(this.destroyRef),\n ).subscribe(html => {\n const parsed = this.document.implementation.createHTMLDocument();\n parsed.documentElement.innerHTML = html;\n const nextScript = this.mainScript(parsed);\n if (nextScript && nextScript !== previousScript) {\n previousScript = nextScript;\n this.zone.run(() => this.changes.next());\n }\n });\n });\n return this.changes$;\n }\n\n /** Also replays a detected deployment to a banner mounted after the check. */\n redeployed(): Observable<void> {\n return this.changes$;\n }\n\n refresh(): void {\n if (isPlatformBrowser(this.platformId)) this.document.defaultView?.location.reload();\n }\n\n private mainScript(document: Document): string | null {\n for (const script of Array.from(document.querySelectorAll('script[src]'))) {\n const match = script.getAttribute('src')?.match(/(?:^|\\/)main[-.][a-zA-Z0-9_-]+\\.js(?:[?#].*)?$/);\n if (match) return match[0].replace(/^\\//, '').split(/[?#]/)[0];\n }\n return null;\n }\n}\n","import { ChangeDetectionStrategy, Component, inject, input, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { MatButtonModule } from '@angular/material/button';\nimport { DetectRedeploymentService } from './redeployment-warning.service';\n\n@Component({\n selector: 't4g-redeployment-warning',\n imports: [MatButtonModule],\n templateUrl: './redeployment-warning.component.html',\n styleUrl: './redeployment-warning.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RedeploymentWarningComponent {\n readonly message = input('This version is out of date!');\n readonly updateLabel = input('Update Now');\n readonly dismissLabel = input('Dismiss update warning');\n readonly showRedeploymentWarning = signal(false);\n private readonly detectRedeployment = inject(DetectRedeploymentService);\n\n constructor() {\n this.detectRedeployment.redeployed().pipe(takeUntilDestroyed()).subscribe(() => {\n this.showRedeploymentWarning.set(true);\n });\n }\n\n update(): void {\n this.detectRedeployment.refresh();\n }\n\n close(): void {\n this.showRedeploymentWarning.set(false);\n }\n}\n","@if (showRedeploymentWarning()) {\n <section class=\"warning-container\" [attr.aria-label]=\"message()\">\n <div class=\"header\">\n <span class=\"title\" role=\"status\">{{ message() }}</span>\n <button mat-icon-button type=\"button\" [attr.aria-label]=\"dismissLabel()\" (click)=\"close()\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <button mat-button type=\"button\" class=\"update\" (click)=\"update()\">{{ updateLabel() }}</button>\n </section>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAWO,MAAM,4BAA4B,GAAG,IAAI,cAAc,CAC5D,8BAA8B,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAC5E;AAED;AACM,SAAU,0BAA0B,CAAC,OAAA,GAAsC,EAAE,EAAA;AACjF,IAAA,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;AACpC,SAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC,EAAE;AAC7E,QAAA,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC;IACrE;AACA,IAAA,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE;AAC5E;;MCfa,yBAAyB,CAAA;AACnB,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC3B,IAAA,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;AAChC,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,IAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;AACrB,IAAA,OAAO,GAAG,MAAM,CAAC,4BAA4B,CAAC;AAC9C,IAAA,OAAO,GAAG,IAAI,aAAa,CAAO,CAAC,CAAC;AACpC,IAAA,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;IAC/C,OAAO,GAAG,KAAK;AAEvB,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,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A,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDJY,eAAe,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,SAAA,EAAA,QAAA,EAAA,iOAAA,EAAA,MAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,CAAA,WAAA,EAAA,WAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,aAAA,EAAA,QAAA,EAAA,sFAAA,EAAA,QAAA,EAAA,CAAA,WAAA,EAAA,WAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAKd,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAPxC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,0BAA0B,WAC3B,CAAC,eAAe,CAAC,EAAA,eAAA,EAGT,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,kgBAAA,EAAA,MAAA,EAAA,CAAA,8nBAAA,CAAA,EAAA;;;AEVjD;;AAEG;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tech4good/platform-ui",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Shared Angular UI utilities for Tech4Good applications.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"typings": "types/tech4good-platform-ui.d.ts",
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@angular/common": "^21.0.0",
|
|
10
|
+
"@angular/core": "^21.0.0",
|
|
11
|
+
"@angular/material": "^21.0.0",
|
|
12
|
+
"rxjs": "^7.8.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"tslib": "^2.3.0"
|
|
16
|
+
},
|
|
17
|
+
"module": "fesm2022/tech4good-platform-ui.mjs",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": {
|
|
20
|
+
"default": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./types/tech4good-platform-ui.d.ts",
|
|
24
|
+
"default": "./fesm2022/tech4good-platform-ui.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"type": "module"
|
|
28
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Provider } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
declare class RedeploymentWarningComponent {
|
|
6
|
+
readonly message: _angular_core.InputSignal<string>;
|
|
7
|
+
readonly updateLabel: _angular_core.InputSignal<string>;
|
|
8
|
+
readonly dismissLabel: _angular_core.InputSignal<string>;
|
|
9
|
+
readonly showRedeploymentWarning: _angular_core.WritableSignal<boolean>;
|
|
10
|
+
private readonly detectRedeployment;
|
|
11
|
+
constructor();
|
|
12
|
+
update(): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<RedeploymentWarningComponent, never>;
|
|
15
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<RedeploymentWarningComponent, "t4g-redeployment-warning", never, { "message": { "alias": "message"; "required": false; "isSignal": true; }; "updateLabel": { "alias": "updateLabel"; "required": false; "isSignal": true; }; "dismissLabel": { "alias": "dismissLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class DetectRedeploymentService {
|
|
19
|
+
private readonly document;
|
|
20
|
+
private readonly platformId;
|
|
21
|
+
private readonly destroyRef;
|
|
22
|
+
private readonly zone;
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly changes;
|
|
25
|
+
private readonly changes$;
|
|
26
|
+
private started;
|
|
27
|
+
constructor();
|
|
28
|
+
/** Start one shared poller. Repeated calls return the same event stream. */
|
|
29
|
+
init(): Observable<void>;
|
|
30
|
+
/** Also replays a detected deployment to a banner mounted after the check. */
|
|
31
|
+
redeployed(): Observable<void>;
|
|
32
|
+
refresh(): void;
|
|
33
|
+
private mainScript;
|
|
34
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DetectRedeploymentService, never>;
|
|
35
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<DetectRedeploymentService>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface RedeploymentWarningOptions {
|
|
39
|
+
/** Disable polling, for example in tests or a service-worker-managed app. */
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
/** Interval between checks in milliseconds. Defaults to two minutes. */
|
|
42
|
+
pollIntervalMs?: number;
|
|
43
|
+
/** Relative to the document base URL. Defaults to index.html. */
|
|
44
|
+
indexUrl?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Configure once at the application root. Polling begins when init() is called. */
|
|
47
|
+
declare function provideRedeploymentWarning(options?: RedeploymentWarningOptions): Provider;
|
|
48
|
+
|
|
49
|
+
export { DetectRedeploymentService, RedeploymentWarningComponent, provideRedeploymentWarning };
|
|
50
|
+
export type { RedeploymentWarningOptions };
|
|
51
|
+
//# sourceMappingURL=tech4good-platform-ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tech4good-platform-ui.d.ts","sources":["../../src/redeployment-warning/redeployment-warning.component.ts","../../src/redeployment-warning/redeployment-warning.service.ts","../../src/redeployment-warning/redeployment-warning.options.ts"],"mappings":";;;;AAKA,cAOa,4BAA4B;sBACvB,aAAA,CAAA,WAAA;0BACI,aAAA,CAAA,WAAA;2BACC,aAAA,CAAA,WAAA;sCACW,aAAA,CAAA,cAAA;AAChC;;AAQA;AAIA;oDAjBW,4BAA4B;sDAA5B,4BAA4B;AAoBxC;;AC1BD,cACa,yBAAyB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAQA,YAAQ,UAAU;;AAiDlB,kBAAc,UAAU;AAIxB;AAIA;oDAxEW,yBAAyB;wDAAzB,yBAAyB;AA+ErC;;UCpFgB,0BAA0B;;;;;;;AAO1C;AAMD;AACA,iBAAgB,0BAA0B,WAAU,0BAA+B,GAAG,QAAQ;;","names":[]}
|