@ssgoi/angular 6.2.0 → 6.4.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/README.md +9 -10
- package/package.json +2 -2
- package/src/lib/index.ts +1 -0
- package/src/lib/ssgoi-transition.directive.ts +4 -0
- package/src/lib/ssgoi.directive.ts +36 -12
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ yarn add @ssgoi/angular
|
|
|
15
15
|
## What You Get
|
|
16
16
|
|
|
17
17
|
- `Ssgoi` directive (selector: `[ssgoi]`) that bootstraps the core transition context on the client and gracefully no-ops during SSR.
|
|
18
|
-
- `
|
|
18
|
+
- `data-ssgoi-transition` route markers discovered automatically inside `[ssgoi]`.
|
|
19
|
+
- Deprecated `SsgoiTransition` directive (selector: `[ssgoiTransition]`) kept for backward compatibility.
|
|
19
20
|
- `injectSsgoi()` helper and `SSGOI_CONTEXT` injection token for retrieving the transition context anywhere in your component tree.
|
|
20
21
|
- Re-exported transition factories under `@ssgoi/angular/view-transitions`.
|
|
21
22
|
|
|
@@ -50,18 +51,16 @@ export class AppComponent {
|
|
|
50
51
|
}
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
### 2. Mark each routed view
|
|
54
|
+
### 2. Mark each routed view
|
|
54
55
|
|
|
55
56
|
```typescript
|
|
56
57
|
import { Component } from "@angular/core";
|
|
57
|
-
import { SsgoiTransition } from "@ssgoi/angular";
|
|
58
58
|
|
|
59
59
|
@Component({
|
|
60
60
|
selector: "app-home",
|
|
61
61
|
standalone: true,
|
|
62
|
-
imports: [SsgoiTransition],
|
|
63
62
|
template: `
|
|
64
|
-
<section
|
|
63
|
+
<section data-ssgoi-transition="/home">
|
|
65
64
|
<h1>Home Page</h1>
|
|
66
65
|
</section>
|
|
67
66
|
`,
|
|
@@ -69,12 +68,12 @@ import { SsgoiTransition } from "@ssgoi/angular";
|
|
|
69
68
|
export class HomeComponent {}
|
|
70
69
|
```
|
|
71
70
|
|
|
72
|
-
The
|
|
71
|
+
The `data-ssgoi-transition` value should uniquely identify the view (commonly the route path).
|
|
73
72
|
|
|
74
73
|
## How It Works
|
|
75
74
|
|
|
76
|
-
- `Ssgoi` wraps `createSggoiTransitionContext` from `@ssgoi/core
|
|
77
|
-
- `SsgoiTransition`
|
|
75
|
+
- `Ssgoi` wraps `createSggoiTransitionContext` from `@ssgoi/core`, injects it via `SSGOI_CONTEXT`, and observes `data-ssgoi-transition` elements under the host. The directive guards against the server platform so SSR renders stay deterministic.
|
|
76
|
+
- The deprecated `SsgoiTransition` directive still sets `data-ssgoi-transition` and registers the host directly for backward compatibility.
|
|
78
77
|
|
|
79
78
|
Because everything is driven by signals, Angular change detection stays minimal and the bundle remains fully tree-shakeable.
|
|
80
79
|
|
|
@@ -83,8 +82,8 @@ Because everything is driven by signals, Angular change detection stays minimal
|
|
|
83
82
|
- `Ssgoi`
|
|
84
83
|
- `config: SsgoiConfig` (input, optional) – global transition configuration. Uses `{}` as default.
|
|
85
84
|
- `host: HostAnimation | undefined` (input, optional) – external playback host for debug tooling.
|
|
86
|
-
- `
|
|
87
|
-
|
|
85
|
+
- `data-ssgoi-transition` – identifier for the target view/container.
|
|
86
|
+
- `SsgoiTransition` is deprecated; use `data-ssgoi-transition` directly.
|
|
88
87
|
- `injectSsgoi(): SsgoiContext` – returns the adapter context. During SSR it falls back to a no-op implementation so you can call it unconditionally.
|
|
89
88
|
|
|
90
89
|
## Available Transitions
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/angular",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "Angular bindings for SSGOI - Native app-like page transitions for Angular applications",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@ssgoi/core": "^6.
|
|
9
|
+
"@ssgoi/core": "^6.4.0"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@angular/common": "^20.0.0",
|
package/src/lib/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Ssgoi } from "./ssgoi.directive";
|
|
2
|
+
/** @deprecated Set `data-ssgoi-transition` directly on an element inside `[ssgoi]` instead. */
|
|
2
3
|
export { SsgoiTransition } from "./ssgoi-transition.directive";
|
|
3
4
|
export { injectSsgoi, SSGOI_CONTEXT } from "./context";
|
|
4
5
|
export * from "./types";
|
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
import { isPlatformBrowser } from "@angular/common";
|
|
11
11
|
import { injectSsgoi } from "./context";
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Set `data-ssgoi-transition` directly on the page boundary
|
|
15
|
+
* element inside `[ssgoi]` instead.
|
|
16
|
+
*/
|
|
13
17
|
@Directive({
|
|
14
18
|
selector: "[ssgoiTransition]",
|
|
15
19
|
standalone: true,
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AfterViewInit,
|
|
2
3
|
Directive,
|
|
4
|
+
ElementRef,
|
|
5
|
+
OnDestroy,
|
|
3
6
|
input,
|
|
4
7
|
forwardRef,
|
|
5
8
|
PLATFORM_ID,
|
|
6
9
|
inject,
|
|
7
10
|
} from "@angular/core";
|
|
8
11
|
import { isPlatformBrowser } from "@angular/common";
|
|
9
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createSggoiTransitionContext,
|
|
14
|
+
observeSsgoiTransitions,
|
|
15
|
+
} from "@ssgoi/core/internal";
|
|
10
16
|
import type { HostAnimation } from "@ssgoi/core/internal";
|
|
11
17
|
import type { SsgoiConfig, SsgoiContext } from "@ssgoi/core/types";
|
|
12
18
|
import { SSGOI_CONTEXT } from "./context";
|
|
13
19
|
|
|
14
20
|
function createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Only create context in browser environment
|
|
18
|
-
if (!isPlatformBrowser(platformId)) {
|
|
19
|
-
// Return a no-op context for SSR
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
return createSggoiTransitionContext(component.config(), {
|
|
23
|
-
host: component.host(),
|
|
24
|
-
});
|
|
21
|
+
return component.getContext();
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
@Directive({
|
|
@@ -35,7 +32,34 @@ function createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {
|
|
|
35
32
|
},
|
|
36
33
|
],
|
|
37
34
|
})
|
|
38
|
-
export class Ssgoi {
|
|
35
|
+
export class Ssgoi implements AfterViewInit, OnDestroy {
|
|
39
36
|
readonly config = input<SsgoiConfig>({});
|
|
40
37
|
readonly host = input<HostAnimation | undefined>(undefined);
|
|
38
|
+
|
|
39
|
+
private readonly el = inject(ElementRef<HTMLElement>);
|
|
40
|
+
private readonly platformId = inject(PLATFORM_ID);
|
|
41
|
+
private contextValue?: SsgoiContext;
|
|
42
|
+
private stopObserving?: () => void;
|
|
43
|
+
|
|
44
|
+
getContext(): SsgoiContext | undefined {
|
|
45
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.contextValue ??= createSggoiTransitionContext(this.config(), {
|
|
50
|
+
host: this.host(),
|
|
51
|
+
});
|
|
52
|
+
return this.contextValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ngAfterViewInit(): void {
|
|
56
|
+
const ssgoi = this.getContext();
|
|
57
|
+
if (!ssgoi) return;
|
|
58
|
+
|
|
59
|
+
this.stopObserving = observeSsgoiTransitions(this.el.nativeElement, ssgoi);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
ngOnDestroy(): void {
|
|
63
|
+
this.stopObserving?.();
|
|
64
|
+
}
|
|
41
65
|
}
|