Skip to content

Commit fe00eb4

Browse files
committed
Add new test-app with SSR support and tests for ssr and csr
1 parent 7bf36c4 commit fe00eb4

45 files changed

Lines changed: 5789 additions & 8632 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test-app/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

test-app/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
__screenshots__/
40+
41+
# System files
42+
.DS_Store
43+
Thumbs.db

test-app/.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}

test-app/.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

test-app/.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

test-app/README.md

Lines changed: 32 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,59 @@
1-
# ImageKit Angular SDK - Test Application
1+
# test-app
22

3-
This is a test/demo application showcasing the `@imagekit/angular` SDK.
3+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.13.
44

5-
## Setup
5+
## Development server
66

7-
1. **Install dependencies:**
8-
```bash
9-
npm install
10-
```
7+
To start a local development server, run:
118

12-
2. **Configure ImageKit (Optional):**
13-
Edit `src/app/app.config.ts` and replace the demo URL with your ImageKit endpoint:
14-
```typescript
15-
provideImageKit({
16-
urlEndpoint: 'https://ik.imagekit.io/your_imagekit_id'
17-
})
18-
```
19-
20-
3. **Run the application:**
21-
```bash
22-
npm start
23-
```
24-
25-
4. **Open browser:**
26-
Navigate to `http://localhost:4200`
27-
28-
## What's Included
29-
30-
- ✅ Basic image rendering with transformations
31-
- ✅ Advanced transformations (resize, quality, format, effects)
32-
- ✅ Responsive images with automatic srcSet
33-
- ✅ Video component with transformations
34-
- ✅ Image gallery example
35-
- ✅ Multiple use cases demonstrated
9+
```bash
10+
ng serve
11+
```
3612

37-
## Features Tested
13+
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
3814

39-
1. **IKImageComponent** - Standalone image component
40-
2. **IKVideoComponent** - Standalone video component
41-
3. **Transformations** - Width, height, crop, quality, format
42-
4. **Responsive** - Automatic srcSet generation
43-
5. **Lazy Loading** - Default lazy loading for images
44-
6. **SSR Support** - Platform-aware rendering
15+
## Code scaffolding
4516

46-
## File Structure
17+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
4718

19+
```bash
20+
ng generate component component-name
4821
```
49-
test-app/
50-
├── src/
51-
│ ├── app/
52-
│ │ ├── app.component.ts # Main component
53-
│ │ ├── app.component.html # Template with examples
54-
│ │ ├── app.component.css # Styles
55-
│ │ └── app.config.ts # ImageKit configuration
56-
│ ├── index.html
57-
│ ├── main.ts
58-
│ └── styles.css
59-
├── angular.json
60-
├── package.json
61-
└── tsconfig.json
62-
```
63-
64-
## Customization
6522

66-
### Change ImageKit Endpoint
23+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
6724

68-
Edit `src/app/app.config.ts`:
69-
```typescript
70-
provideImageKit({
71-
urlEndpoint: 'https://ik.imagekit.io/your_id',
72-
publicKey: 'your_public_key', // for uploads
73-
authenticationEndpoint: 'https://...' // for uploads
74-
})
25+
```bash
26+
ng generate --help
7527
```
7628

77-
### Add Your Images
29+
## Building
30+
31+
To build the project run:
7832

79-
Replace the image paths in `app.component.html`:
80-
```html
81-
<ik-image
82-
src="/your-image-path.jpg"
83-
[transformation]="[...]"
84-
></ik-image>
33+
```bash
34+
ng build
8535
```
8636

87-
### Test File Upload
37+
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
8838

89-
Add an upload component (see EXAMPLES.md in root for upload examples).
39+
## Running unit tests
9040

91-
## Commands
41+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
9242

9343
```bash
94-
# Install dependencies
95-
npm install
44+
ng test
45+
```
9646

97-
# Start dev server
98-
npm start
47+
## Running end-to-end tests
9948

100-
# Build for production
101-
npm run build
49+
For end-to-end (e2e) testing, run:
10250

103-
# Serve production build
104-
npx http-server dist/test-app
51+
```bash
52+
ng e2e
10553
```
10654

107-
## Notes
55+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
10856

109-
- The app uses the ImageKit demo endpoint by default
110-
- TypeScript path mapping points to the built library in `../dist/imagekit-angular`
57+
## Additional Resources
11158

59+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.

test-app/angular.json

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,95 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6-
"test-app": {
6+
"angularDx": {
77
"projectType": "application",
8+
"schematics": {},
89
"root": "",
910
"sourceRoot": "src",
1011
"prefix": "app",
1112
"architect": {
1213
"build": {
13-
"builder": "@angular-devkit/build-angular:application",
14+
"builder": "@angular/build:application",
1415
"options": {
15-
"outputPath": "dist/test-app",
16-
"index": "src/index.html",
1716
"browser": "src/main.ts",
1817
"polyfills": [
1918
"zone.js"
2019
],
2120
"tsConfig": "tsconfig.app.json",
2221
"assets": [
23-
"src/favicon.ico"
22+
{
23+
"glob": "**/*",
24+
"input": "public"
25+
}
2426
],
2527
"styles": [
2628
"src/styles.css"
2729
],
28-
"scripts": []
29-
}
30+
"server": "src/main.server.ts",
31+
"outputMode": "server",
32+
"ssr": {
33+
"entry": "src/server.ts"
34+
}
35+
},
36+
"configurations": {
37+
"production": {
38+
"budgets": [
39+
{
40+
"type": "initial",
41+
"maximumWarning": "500kB",
42+
"maximumError": "1MB"
43+
},
44+
{
45+
"type": "anyComponentStyle",
46+
"maximumWarning": "4kB",
47+
"maximumError": "8kB"
48+
}
49+
],
50+
"outputHashing": "all"
51+
},
52+
"development": {
53+
"optimization": false,
54+
"extractLicenses": false,
55+
"sourceMap": true
56+
}
57+
},
58+
"defaultConfiguration": "production"
3059
},
3160
"serve": {
32-
"builder": "@angular-devkit/build-angular:dev-server",
61+
"builder": "@angular/build:dev-server",
62+
"configurations": {
63+
"production": {
64+
"buildTarget": "angularDx:build:production"
65+
},
66+
"development": {
67+
"buildTarget": "angularDx:build:development"
68+
}
69+
},
70+
"defaultConfiguration": "development"
71+
},
72+
"extract-i18n": {
73+
"builder": "@angular/build:extract-i18n"
74+
},
75+
"test": {
76+
"builder": "@angular/build:karma",
3377
"options": {
34-
"buildTarget": "test-app:build"
78+
"polyfills": [
79+
"zone.js",
80+
"zone.js/testing"
81+
],
82+
"tsConfig": "tsconfig.spec.json",
83+
"assets": [
84+
{
85+
"glob": "**/*",
86+
"input": "public"
87+
}
88+
],
89+
"styles": [
90+
"src/styles.css"
91+
]
3592
}
3693
}
3794
}
3895
}
39-
},
40-
"cli": {
41-
"analytics": false
4296
}
4397
}
44-

0 commit comments

Comments
 (0)