@ssgoi/angular 2.5.2 → 3.0.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.
@@ -0,0 +1,75 @@
1
+ import tseslint from "@typescript-eslint/eslint-plugin";
2
+ import tsparser from "@typescript-eslint/parser";
3
+ import angular from "@angular-eslint/eslint-plugin";
4
+ import angularTemplate from "@angular-eslint/eslint-plugin-template";
5
+ import angularTemplateParser from "@angular-eslint/template-parser";
6
+
7
+ export default [
8
+ {
9
+ ignores: ["dist/**", "node_modules/**", "*.js", "*.mjs"],
10
+ },
11
+ // TypeScript files
12
+ {
13
+ files: ["**/*.ts"],
14
+ languageOptions: {
15
+ parser: tsparser,
16
+ parserOptions: {
17
+ project: ["./tsconfig.lib.json"],
18
+ tsconfigRootDir: import.meta.dirname,
19
+ ecmaVersion: 2022,
20
+ sourceType: "module",
21
+ },
22
+ },
23
+ plugins: {
24
+ "@typescript-eslint": tseslint,
25
+ "@angular-eslint": angular,
26
+ },
27
+ rules: {
28
+ // TypeScript recommended rules
29
+ "@typescript-eslint/no-explicit-any": "warn",
30
+ "@typescript-eslint/no-unused-vars": [
31
+ "error",
32
+ { argsIgnorePattern: "^_" },
33
+ ],
34
+ "@typescript-eslint/explicit-function-return-type": "off",
35
+ "@typescript-eslint/explicit-module-boundary-types": "off",
36
+
37
+ // Angular recommended rules
38
+ "@angular-eslint/directive-selector": [
39
+ "error",
40
+ {
41
+ type: "attribute",
42
+ prefix: ["ssgoi", "transition"],
43
+ style: "camelCase",
44
+ },
45
+ ],
46
+ "@angular-eslint/component-selector": [
47
+ "error",
48
+ {
49
+ type: "element",
50
+ prefix: "ssgoi",
51
+ style: "kebab-case",
52
+ },
53
+ ],
54
+ "@angular-eslint/no-input-rename": "error",
55
+ "@angular-eslint/no-output-rename": "error",
56
+ "@angular-eslint/use-lifecycle-interface": "error",
57
+ "@angular-eslint/use-pipe-transform-interface": "error",
58
+ },
59
+ },
60
+ // HTML template files
61
+ {
62
+ files: ["**/*.html"],
63
+ languageOptions: {
64
+ parser: angularTemplateParser,
65
+ },
66
+ plugins: {
67
+ "@angular-eslint/template": angularTemplate,
68
+ },
69
+ rules: {
70
+ "@angular-eslint/template/no-negated-async": "error",
71
+ "@angular-eslint/template/eqeqeq": "error",
72
+ "@angular-eslint/template/no-any": "warn",
73
+ },
74
+ },
75
+ ];
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "./dist",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": [
8
+ "@ssgoi/core"
9
+ ]
10
+ }
package/package.json CHANGED
@@ -1,18 +1,33 @@
1
1
  {
2
2
  "name": "@ssgoi/angular",
3
- "version": "2.5.2",
3
+ "version": "3.0.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": "^2.5.2",
10
- "tslib": "^2.3.0"
9
+ "@ssgoi/core": "3.0.0"
11
10
  },
12
11
  "peerDependencies": {
13
12
  "@angular/common": "^20.0.0",
14
13
  "@angular/core": "^20.0.0"
15
14
  },
15
+ "devDependencies": {
16
+ "@angular-eslint/builder": "^20.3.0",
17
+ "@angular-eslint/eslint-plugin": "^20.3.0",
18
+ "@angular-eslint/eslint-plugin-template": "^20.3.0",
19
+ "@angular-eslint/schematics": "^20.3.0",
20
+ "@angular-eslint/template-parser": "^20.3.0",
21
+ "@angular/common": "^20.3.4",
22
+ "@angular/compiler": "^20.3.4",
23
+ "@angular/compiler-cli": "^20.3.4",
24
+ "@angular/core": "^20.3.4",
25
+ "@typescript-eslint/eslint-plugin": "^8.46.0",
26
+ "@typescript-eslint/parser": "^8.46.0",
27
+ "eslint": "^9.37.0",
28
+ "ng-packagr": "^20.3.0",
29
+ "typescript": "~5.8.3"
30
+ },
16
31
  "keywords": [
17
32
  "angular",
18
33
  "page-transition",
@@ -43,23 +58,27 @@
43
58
  "default": "./package.json"
44
59
  },
45
60
  ".": {
46
- "types": "./index.d.ts",
47
- "default": "./fesm2022/ssgoi-angular.mjs"
61
+ "types": "./dist/index.d.ts",
62
+ "default": "./dist/fesm2022/ssgoi-angular.mjs"
48
63
  },
49
64
  "./presets": {
50
- "types": "./presets/index.d.ts",
51
- "default": "./fesm2022/ssgoi-angular-presets.mjs"
65
+ "types": "./dist/presets/index.d.ts",
66
+ "default": "./dist/fesm2022/ssgoi-angular-presets.mjs"
52
67
  },
53
68
  "./transitions": {
54
- "types": "./transitions/index.d.ts",
55
- "default": "./fesm2022/ssgoi-angular-transitions.mjs"
69
+ "types": "./dist/transitions/index.d.ts",
70
+ "default": "./dist/fesm2022/ssgoi-angular-transitions.mjs"
56
71
  },
57
72
  "./view-transitions": {
58
- "types": "./view-transitions/index.d.ts",
59
- "default": "./fesm2022/ssgoi-angular-view-transitions.mjs"
73
+ "types": "./dist/view-transitions/index.d.ts",
74
+ "default": "./dist/fesm2022/ssgoi-angular-view-transitions.mjs"
60
75
  }
61
76
  },
62
77
  "sideEffects": false,
63
- "module": "fesm2022/ssgoi-angular.mjs",
64
- "typings": "index.d.ts"
78
+ "scripts": {
79
+ "build": "ng-packagr -p ng-package.json",
80
+ "watch": "ng-packagr -p ng-package.json --watch",
81
+ "lint": "eslint .",
82
+ "lint:fix": "eslint . --fix"
83
+ }
65
84
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "../src/lib/presets/index.ts"
5
+ }
6
+ }
@@ -0,0 +1,22 @@
1
+ import { InjectionToken, inject } from "@angular/core";
2
+ import type { SsgoiContext } from "@ssgoi/core";
3
+
4
+ export const SSGOI_CONTEXT = new InjectionToken<SsgoiContext | undefined>(
5
+ "ssgoi-context",
6
+ );
7
+
8
+ export function injectSsgoi(): SsgoiContext {
9
+ const context = inject(SSGOI_CONTEXT, { optional: true });
10
+
11
+ if (!context) {
12
+ // During SSR or when not wrapped in <ssgoi>, return a no-op context
13
+ // This prevents errors during server-side rendering
14
+ return () => ({
15
+ key: "",
16
+ in: async () => ({}),
17
+ out: async () => ({}),
18
+ });
19
+ }
20
+
21
+ return context;
22
+ }
@@ -0,0 +1,9 @@
1
+ export { Ssgoi } from "./ssgoi.directive";
2
+ export { SsgoiTransition } from "./ssgoi-transition.directive";
3
+ export {
4
+ TransitionDirective,
5
+ TransitionDirectiveConfig,
6
+ } from "./transition.directive";
7
+ export { injectSsgoi, SSGOI_CONTEXT } from "./context";
8
+ export { transition } from "@ssgoi/core";
9
+ export * from "./types";
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core/presets";
@@ -0,0 +1,59 @@
1
+ import {
2
+ Directive,
3
+ input,
4
+ OnInit,
5
+ OnDestroy,
6
+ AfterViewInit,
7
+ ElementRef,
8
+ inject,
9
+ PLATFORM_ID,
10
+ } from "@angular/core";
11
+ import { isPlatformBrowser } from "@angular/common";
12
+ import { transition } from "@ssgoi/core";
13
+ import { injectSsgoi } from "./context";
14
+
15
+ @Directive({
16
+ selector: "[ssgoiTransition]",
17
+ standalone: true,
18
+ })
19
+ export class SsgoiTransition implements OnInit, OnDestroy, AfterViewInit {
20
+ // The directive attribute value becomes the transition ID
21
+ readonly ssgoiTransition = input.required<string>();
22
+
23
+ private readonly getTransition = injectSsgoi();
24
+ private readonly el = inject(ElementRef<HTMLElement>);
25
+ private readonly platformId = inject(PLATFORM_ID);
26
+ private cleanup?: () => void;
27
+
28
+ ngOnInit(): void {
29
+ if (!isPlatformBrowser(this.platformId)) {
30
+ return;
31
+ }
32
+
33
+ // Set data attribute on host element
34
+ this.el.nativeElement.setAttribute(
35
+ "data-ssgoi-transition",
36
+ this.ssgoiTransition(),
37
+ );
38
+ }
39
+
40
+ ngAfterViewInit(): void {
41
+ if (!isPlatformBrowser(this.platformId)) {
42
+ return;
43
+ }
44
+
45
+ // Use the host element itself as the transition target
46
+ const targetElement = this.el.nativeElement;
47
+
48
+ const transitionConfig = this.getTransition(this.ssgoiTransition());
49
+ const cleanupResult = transition(transitionConfig)(targetElement);
50
+
51
+ if (cleanupResult) {
52
+ this.cleanup = cleanupResult;
53
+ }
54
+ }
55
+
56
+ ngOnDestroy(): void {
57
+ this.cleanup?.();
58
+ }
59
+ }
@@ -0,0 +1,37 @@
1
+ import {
2
+ Directive,
3
+ input,
4
+ forwardRef,
5
+ PLATFORM_ID,
6
+ inject,
7
+ } from "@angular/core";
8
+ import { isPlatformBrowser } from "@angular/common";
9
+ import { createSggoiTransitionContext } from "@ssgoi/core";
10
+ import type { SsgoiConfig, SsgoiContext } from "@ssgoi/core";
11
+ import { SSGOI_CONTEXT } from "./context";
12
+
13
+ function createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {
14
+ const platformId = inject(PLATFORM_ID);
15
+
16
+ // Only create context in browser environment
17
+ if (!isPlatformBrowser(platformId)) {
18
+ // Return a no-op context for SSR
19
+ return undefined;
20
+ }
21
+ return createSggoiTransitionContext(component.config());
22
+ }
23
+
24
+ @Directive({
25
+ selector: "[ssgoi]",
26
+ standalone: true,
27
+ providers: [
28
+ {
29
+ provide: SSGOI_CONTEXT,
30
+ useFactory: createSsgoiContext,
31
+ deps: [forwardRef(() => Ssgoi)],
32
+ },
33
+ ],
34
+ })
35
+ export class Ssgoi {
36
+ readonly config = input<SsgoiConfig>({});
37
+ }
@@ -0,0 +1,52 @@
1
+ import {
2
+ Directive,
3
+ ElementRef,
4
+ input,
5
+ OnInit,
6
+ OnDestroy,
7
+ inject,
8
+ PLATFORM_ID,
9
+ } from "@angular/core";
10
+ import { isPlatformBrowser } from "@angular/common";
11
+ import { transition as coreTransition } from "@ssgoi/core";
12
+ import type {
13
+ Transition as CoreTransitionConfig,
14
+ TransitionKey as CoreTransitionKey,
15
+ } from "@ssgoi/core";
16
+
17
+ export type TransitionDirectiveConfig = CoreTransitionConfig & {
18
+ key?: CoreTransitionKey;
19
+ };
20
+
21
+ @Directive({
22
+ selector: "[transition]",
23
+ })
24
+ export class TransitionDirective implements OnInit, OnDestroy {
25
+ transition = input.required<TransitionDirectiveConfig>();
26
+
27
+ private readonly el = inject(ElementRef<HTMLElement>);
28
+ private readonly platformId = inject(PLATFORM_ID);
29
+ private cleanup?: () => void;
30
+
31
+ ngOnInit(): void {
32
+ if (!isPlatformBrowser(this.platformId)) {
33
+ return;
34
+ }
35
+
36
+ const config = this.transition();
37
+ const cleanupResult = coreTransition({
38
+ key: config.key,
39
+ in: config.in,
40
+ out: config.out,
41
+ ref: this.el.nativeElement,
42
+ })(this.el.nativeElement);
43
+
44
+ if (cleanupResult) {
45
+ this.cleanup = cleanupResult;
46
+ }
47
+ }
48
+
49
+ ngOnDestroy(): void {
50
+ this.cleanup?.();
51
+ }
52
+ }
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core/transitions";
@@ -0,0 +1 @@
1
+ export type * from "@ssgoi/core";
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core/view-transitions";
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Public API Surface of @ssgoi/angular
3
+ */
4
+
5
+ export * from "./lib/index";
6
+ export * from "./lib/types";
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "../src/lib/transitions/index.ts"
5
+ }
6
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "lib": ["ES2022", "DOM"],
6
+ "moduleResolution": "node",
7
+ "experimentalDecorators": true,
8
+ "emitDecoratorMetadata": true,
9
+ "skipLibCheck": true,
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "outDir": "./dist",
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "inlineSources": true,
17
+ "types": []
18
+ },
19
+ "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"],
20
+ "angularCompilerOptions": {
21
+ "skipTemplateCodegen": true,
22
+ "strictMetadataEmit": true,
23
+ "enableResourceInlining": true,
24
+ "compilationMode": "partial"
25
+ }
26
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "../src/lib/view-transitions/index.ts"
5
+ }
6
+ }
@@ -1,6 +0,0 @@
1
- export * from '@ssgoi/core/presets';
2
-
3
- /**
4
- * Generated bundle index. Do not edit.
5
- */
6
- //# sourceMappingURL=ssgoi-angular-presets.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssgoi-angular-presets.mjs","sources":["../../src/lib/presets/ssgoi-angular-presets.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
@@ -1,6 +0,0 @@
1
- export * from '@ssgoi/core/transitions';
2
-
3
- /**
4
- * Generated bundle index. Do not edit.
5
- */
6
- //# sourceMappingURL=ssgoi-angular-transitions.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssgoi-angular-transitions.mjs","sources":["../../src/lib/transitions/ssgoi-angular-transitions.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
@@ -1,6 +0,0 @@
1
- export * from '@ssgoi/core/view-transitions';
2
-
3
- /**
4
- * Generated bundle index. Do not edit.
5
- */
6
- //# sourceMappingURL=ssgoi-angular-view-transitions.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssgoi-angular-view-transitions.mjs","sources":["../../src/lib/view-transitions/ssgoi-angular-view-transitions.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
@@ -1,139 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, PLATFORM_ID, input, forwardRef, Directive, ElementRef } from '@angular/core';
3
- import { isPlatformBrowser } from '@angular/common';
4
- import { createSggoiTransitionContext, transition } from '@ssgoi/core';
5
- export { transition } from '@ssgoi/core';
6
-
7
- const SSGOI_CONTEXT = new InjectionToken("ssgoi-context");
8
- function injectSsgoi() {
9
- const context = inject(SSGOI_CONTEXT, { optional: true });
10
- if (!context) {
11
- // During SSR or when not wrapped in <ssgoi>, return a no-op context
12
- // This prevents errors during server-side rendering
13
- return () => ({
14
- key: "",
15
- in: async () => ({}),
16
- out: async () => ({}),
17
- });
18
- }
19
- return context;
20
- }
21
-
22
- function createSsgoiContext(component) {
23
- const platformId = inject(PLATFORM_ID);
24
- // Only create context in browser environment
25
- if (!isPlatformBrowser(platformId)) {
26
- // Return a no-op context for SSR
27
- return undefined;
28
- }
29
- return createSggoiTransitionContext(component.config());
30
- }
31
- class Ssgoi {
32
- config = input({}, ...(ngDevMode ? [{ debugName: "config" }] : []));
33
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Ssgoi, deps: [], target: i0.ɵɵFactoryTarget.Directive });
34
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: Ssgoi, isStandalone: true, selector: "[ssgoi]", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
35
- {
36
- provide: SSGOI_CONTEXT,
37
- useFactory: createSsgoiContext,
38
- deps: [forwardRef(() => Ssgoi)],
39
- },
40
- ], ngImport: i0 });
41
- }
42
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Ssgoi, decorators: [{
43
- type: Directive,
44
- args: [{
45
- selector: "[ssgoi]",
46
- standalone: true,
47
- providers: [
48
- {
49
- provide: SSGOI_CONTEXT,
50
- useFactory: createSsgoiContext,
51
- deps: [forwardRef(() => Ssgoi)],
52
- },
53
- ],
54
- }]
55
- }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }] } });
56
-
57
- class SsgoiTransition {
58
- // The directive attribute value becomes the transition ID
59
- ssgoiTransition = input.required(...(ngDevMode ? [{ debugName: "ssgoiTransition" }] : []));
60
- getTransition = injectSsgoi();
61
- el = inject((ElementRef));
62
- platformId = inject(PLATFORM_ID);
63
- cleanup;
64
- ngOnInit() {
65
- if (!isPlatformBrowser(this.platformId)) {
66
- return;
67
- }
68
- // Set data attribute on host element
69
- this.el.nativeElement.setAttribute("data-ssgoi-transition", this.ssgoiTransition());
70
- }
71
- ngAfterViewInit() {
72
- if (!isPlatformBrowser(this.platformId)) {
73
- return;
74
- }
75
- // Use the host element itself as the transition target
76
- const targetElement = this.el.nativeElement;
77
- const transitionConfig = this.getTransition(this.ssgoiTransition());
78
- const cleanupResult = transition(transitionConfig)(targetElement);
79
- if (cleanupResult) {
80
- this.cleanup = cleanupResult;
81
- }
82
- }
83
- ngOnDestroy() {
84
- this.cleanup?.();
85
- }
86
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SsgoiTransition, deps: [], target: i0.ɵɵFactoryTarget.Directive });
87
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: SsgoiTransition, isStandalone: true, selector: "[ssgoiTransition]", inputs: { ssgoiTransition: { classPropertyName: "ssgoiTransition", publicName: "ssgoiTransition", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
88
- }
89
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SsgoiTransition, decorators: [{
90
- type: Directive,
91
- args: [{
92
- selector: "[ssgoiTransition]",
93
- standalone: true,
94
- }]
95
- }], propDecorators: { ssgoiTransition: [{ type: i0.Input, args: [{ isSignal: true, alias: "ssgoiTransition", required: true }] }] } });
96
-
97
- class TransitionDirective {
98
- transition = input.required(...(ngDevMode ? [{ debugName: "transition" }] : []));
99
- el = inject((ElementRef));
100
- platformId = inject(PLATFORM_ID);
101
- cleanup;
102
- ngOnInit() {
103
- if (!isPlatformBrowser(this.platformId)) {
104
- return;
105
- }
106
- const config = this.transition();
107
- const cleanupResult = transition({
108
- key: config.key,
109
- in: config.in,
110
- out: config.out,
111
- ref: this.el.nativeElement,
112
- })(this.el.nativeElement);
113
- if (cleanupResult) {
114
- this.cleanup = cleanupResult;
115
- }
116
- }
117
- ngOnDestroy() {
118
- this.cleanup?.();
119
- }
120
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TransitionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
121
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: TransitionDirective, isStandalone: true, selector: "[transition]", inputs: { transition: { classPropertyName: "transition", publicName: "transition", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
122
- }
123
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TransitionDirective, decorators: [{
124
- type: Directive,
125
- args: [{
126
- selector: "[transition]",
127
- }]
128
- }], propDecorators: { transition: [{ type: i0.Input, args: [{ isSignal: true, alias: "transition", required: true }] }] } });
129
-
130
- /*
131
- * Public API Surface of @ssgoi/angular
132
- */
133
-
134
- /**
135
- * Generated bundle index. Do not edit.
136
- */
137
-
138
- export { SSGOI_CONTEXT, Ssgoi, SsgoiTransition, TransitionDirective, injectSsgoi };
139
- //# sourceMappingURL=ssgoi-angular.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssgoi-angular.mjs","sources":["../../src/lib/context.ts","../../src/lib/ssgoi.directive.ts","../../src/lib/ssgoi-transition.directive.ts","../../src/lib/transition.directive.ts","../../src/public-api.ts","../../src/ssgoi-angular.ts"],"sourcesContent":["import { InjectionToken, inject } from \"@angular/core\";\nimport type { SsgoiContext } from \"@ssgoi/core\";\n\nexport const SSGOI_CONTEXT = new InjectionToken<SsgoiContext | undefined>(\n \"ssgoi-context\",\n);\n\nexport function injectSsgoi(): SsgoiContext {\n const context = inject(SSGOI_CONTEXT, { optional: true });\n\n if (!context) {\n // During SSR or when not wrapped in <ssgoi>, return a no-op context\n // This prevents errors during server-side rendering\n return () => ({\n key: \"\",\n in: async () => ({}),\n out: async () => ({}),\n });\n }\n\n return context;\n}\n","import {\n Directive,\n input,\n forwardRef,\n PLATFORM_ID,\n inject,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { createSggoiTransitionContext } from \"@ssgoi/core\";\nimport type { SsgoiConfig, SsgoiContext } from \"@ssgoi/core\";\nimport { SSGOI_CONTEXT } from \"./context\";\n\nfunction createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {\n const platformId = inject(PLATFORM_ID);\n\n // Only create context in browser environment\n if (!isPlatformBrowser(platformId)) {\n // Return a no-op context for SSR\n return undefined;\n }\n return createSggoiTransitionContext(component.config());\n}\n\n@Directive({\n selector: \"[ssgoi]\",\n standalone: true,\n providers: [\n {\n provide: SSGOI_CONTEXT,\n useFactory: createSsgoiContext,\n deps: [forwardRef(() => Ssgoi)],\n },\n ],\n})\nexport class Ssgoi {\n readonly config = input<SsgoiConfig>({});\n}\n","import {\n Directive,\n input,\n OnInit,\n OnDestroy,\n AfterViewInit,\n ElementRef,\n inject,\n PLATFORM_ID,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { transition } from \"@ssgoi/core\";\nimport { injectSsgoi } from \"./context\";\n\n@Directive({\n selector: \"[ssgoiTransition]\",\n standalone: true,\n})\nexport class SsgoiTransition implements OnInit, OnDestroy, AfterViewInit {\n // The directive attribute value becomes the transition ID\n readonly ssgoiTransition = input.required<string>();\n\n private readonly getTransition = injectSsgoi();\n private readonly el = inject(ElementRef<HTMLElement>);\n private readonly platformId = inject(PLATFORM_ID);\n private cleanup?: () => void;\n\n ngOnInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n // Set data attribute on host element\n this.el.nativeElement.setAttribute(\n \"data-ssgoi-transition\",\n this.ssgoiTransition(),\n );\n }\n\n ngAfterViewInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n // Use the host element itself as the transition target\n const targetElement = this.el.nativeElement;\n\n const transitionConfig = this.getTransition(this.ssgoiTransition());\n const cleanupResult = transition(transitionConfig)(targetElement);\n\n if (cleanupResult) {\n this.cleanup = cleanupResult;\n }\n }\n\n ngOnDestroy(): void {\n this.cleanup?.();\n }\n}\n","import {\n Directive,\n ElementRef,\n input,\n OnInit,\n OnDestroy,\n inject,\n PLATFORM_ID,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { transition as coreTransition } from \"@ssgoi/core\";\nimport type {\n Transition as CoreTransitionConfig,\n TransitionKey as CoreTransitionKey,\n} from \"@ssgoi/core\";\n\nexport type TransitionDirectiveConfig = CoreTransitionConfig & {\n key?: CoreTransitionKey;\n};\n\n@Directive({\n selector: \"[transition]\",\n})\nexport class TransitionDirective implements OnInit, OnDestroy {\n transition = input.required<TransitionDirectiveConfig>();\n\n private readonly el = inject(ElementRef<HTMLElement>);\n private readonly platformId = inject(PLATFORM_ID);\n private cleanup?: () => void;\n\n ngOnInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n const config = this.transition();\n const cleanupResult = coreTransition({\n key: config.key,\n in: config.in,\n out: config.out,\n ref: this.el.nativeElement,\n })(this.el.nativeElement);\n\n if (cleanupResult) {\n this.cleanup = cleanupResult;\n }\n }\n\n ngOnDestroy(): void {\n this.cleanup?.();\n }\n}\n","/*\n * Public API Surface of @ssgoi/angular\n */\n\nexport * from \"./lib/index\";\nexport * from \"./lib/types\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["coreTransition"],"mappings":";;;;;;MAGa,aAAa,GAAG,I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AACjB,YAAA,IAAI,CAAC,OAAO,GAAG,aAAa;QAC9B;IACF;IAEA,WAAW,GAAA;AACT,QAAA,IAAI,CAAC,OAAO,IAAI;IAClB;uGA3BW,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAnB,mBAAmB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,UAAA,EAAA,EAAA,iBAAA,EAAA,YAAA,EAAA,UAAA,EAAA,YAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAH/B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACzB,iBAAA;;;ACtBD;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, AfterViewInit, InjectionToken } from '@angular/core';
3
- import { SsgoiConfig, Transition, TransitionKey, SsgoiContext } from '@ssgoi/core';
4
- export * from '@ssgoi/core';
5
- export { transition } from '@ssgoi/core';
6
-
7
- declare class Ssgoi {
8
- readonly config: i0.InputSignal<SsgoiConfig>;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<Ssgoi, never>;
10
- static ɵdir: i0.ɵɵDirectiveDeclaration<Ssgoi, "[ssgoi]", never, { "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
11
- }
12
-
13
- declare class SsgoiTransition implements OnInit, OnDestroy, AfterViewInit {
14
- readonly ssgoiTransition: i0.InputSignal<string>;
15
- private readonly getTransition;
16
- private readonly el;
17
- private readonly platformId;
18
- private cleanup?;
19
- ngOnInit(): void;
20
- ngAfterViewInit(): void;
21
- ngOnDestroy(): void;
22
- static ɵfac: i0.ɵɵFactoryDeclaration<SsgoiTransition, never>;
23
- static ɵdir: i0.ɵɵDirectiveDeclaration<SsgoiTransition, "[ssgoiTransition]", never, { "ssgoiTransition": { "alias": "ssgoiTransition"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
24
- }
25
-
26
- type TransitionDirectiveConfig = Transition & {
27
- key?: TransitionKey;
28
- };
29
- declare class TransitionDirective implements OnInit, OnDestroy {
30
- transition: i0.InputSignal<TransitionDirectiveConfig>;
31
- private readonly el;
32
- private readonly platformId;
33
- private cleanup?;
34
- ngOnInit(): void;
35
- ngOnDestroy(): void;
36
- static ɵfac: i0.ɵɵFactoryDeclaration<TransitionDirective, never>;
37
- static ɵdir: i0.ɵɵDirectiveDeclaration<TransitionDirective, "[transition]", never, { "transition": { "alias": "transition"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
38
- }
39
-
40
- declare const SSGOI_CONTEXT: InjectionToken<SsgoiContext>;
41
- declare function injectSsgoi(): SsgoiContext;
42
-
43
- export { SSGOI_CONTEXT, Ssgoi, SsgoiTransition, TransitionDirective, injectSsgoi };
44
- export type { TransitionDirectiveConfig };
@@ -1 +0,0 @@
1
- export * from '@ssgoi/core/presets';
@@ -1 +0,0 @@
1
- export * from '@ssgoi/core/transitions';
@@ -1 +0,0 @@
1
- export * from '@ssgoi/core/view-transitions';