screen-recorder-angular 0.0.1 → 0.0.2

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/.editorconfig CHANGED
@@ -10,6 +10,7 @@ trim_trailing_whitespace = true
10
10
 
11
11
  [*.ts]
12
12
  quote_type = single
13
+ ij_typescript_use_double_quotes = false
13
14
 
14
15
  [*.md]
15
16
  max_line_length = off
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ // For more information, visit: https://angular.dev/ai/mcp
3
+ "servers": {
4
+ "angular-cli": {
5
+ "command": "npx",
6
+ "args": ["-y", "@angular/cli", "mcp"]
7
+ }
8
+ }
9
+ }
@@ -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": "Changes detected"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation (complete|failed)"
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": "Changes detected"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation (complete|failed)"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
package/angular.json CHANGED
@@ -1,106 +1,74 @@
1
1
  {
2
2
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
3
  "version": 1,
4
+ "cli": {
5
+ "packageManager": "npm",
6
+ "analytics": "76b137ab-abca-4ae5-8093-7df70dd46711"
7
+ },
4
8
  "newProjectRoot": "projects",
5
9
  "projects": {
6
10
  "screen-recorder-angular": {
7
11
  "projectType": "application",
8
- "schematics": {
9
- "@schematics/angular:application": {
10
- "strict": true
11
- }
12
- },
12
+ "schematics": {},
13
13
  "root": "",
14
14
  "sourceRoot": "src",
15
15
  "prefix": "app",
16
16
  "architect": {
17
17
  "build": {
18
- "builder": "@angular-devkit/build-angular:browser",
18
+ "builder": "@angular/build:application",
19
19
  "options": {
20
- "outputPath": "dist/screen-recorder-angular",
21
- "index": "src/index.html",
22
- "main": "src/main.ts",
23
- "polyfills": "src/polyfills.ts",
20
+ "browser": "src/main.ts",
24
21
  "tsConfig": "tsconfig.app.json",
25
22
  "assets": [
26
- "src/favicon.ico",
27
- "src/assets"
23
+ {
24
+ "glob": "**/*",
25
+ "input": "public"
26
+ }
28
27
  ],
29
28
  "styles": [
30
29
  "src/styles.css"
31
- ],
32
- "scripts": []
30
+ ]
33
31
  },
34
32
  "configurations": {
35
33
  "production": {
36
34
  "budgets": [
37
35
  {
38
36
  "type": "initial",
39
- "maximumWarning": "500kb",
40
- "maximumError": "1mb"
37
+ "maximumWarning": "500kB",
38
+ "maximumError": "1MB"
41
39
  },
42
40
  {
43
41
  "type": "anyComponentStyle",
44
- "maximumWarning": "2kb",
45
- "maximumError": "4kb"
46
- }
47
- ],
48
- "fileReplacements": [
49
- {
50
- "replace": "src/environments/environment.ts",
51
- "with": "src/environments/environment.prod.ts"
42
+ "maximumWarning": "4kB",
43
+ "maximumError": "8kB"
52
44
  }
53
45
  ],
54
46
  "outputHashing": "all"
55
47
  },
56
48
  "development": {
57
- "buildOptimizer": false,
58
49
  "optimization": false,
59
- "vendorChunk": true,
60
50
  "extractLicenses": false,
61
- "sourceMap": true,
62
- "namedChunks": true
51
+ "sourceMap": true
63
52
  }
64
53
  },
65
54
  "defaultConfiguration": "production"
66
55
  },
67
56
  "serve": {
68
- "builder": "@angular-devkit/build-angular:dev-server",
57
+ "builder": "@angular/build:dev-server",
69
58
  "configurations": {
70
59
  "production": {
71
- "browserTarget": "screen-recorder-angular:build:production"
60
+ "buildTarget": "screen-recorder-angular:build:production"
72
61
  },
73
62
  "development": {
74
- "browserTarget": "screen-recorder-angular:build:development"
63
+ "buildTarget": "screen-recorder-angular:build:development"
75
64
  }
76
65
  },
77
66
  "defaultConfiguration": "development"
78
67
  },
79
- "extract-i18n": {
80
- "builder": "@angular-devkit/build-angular:extract-i18n",
81
- "options": {
82
- "browserTarget": "screen-recorder-angular:build"
83
- }
84
- },
85
68
  "test": {
86
- "builder": "@angular-devkit/build-angular:karma",
87
- "options": {
88
- "main": "src/test.ts",
89
- "polyfills": "src/polyfills.ts",
90
- "tsConfig": "tsconfig.spec.json",
91
- "karmaConfig": "karma.conf.js",
92
- "assets": [
93
- "src/favicon.ico",
94
- "src/assets"
95
- ],
96
- "styles": [
97
- "src/styles.css"
98
- ],
99
- "scripts": []
100
- }
69
+ "builder": "@angular/build:unit-test"
101
70
  }
102
71
  }
103
72
  }
104
- },
105
- "defaultProject": "screen-recorder-angular"
73
+ }
106
74
  }
package/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="screen-recorder-base/env.d.ts" />
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "screen-recorder-angular",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "scripts": {
5
+ "predev": "pnpm --filter screen-recorder-base build",
6
+ "prebuild": "pnpm --filter screen-recorder-base build",
5
7
  "ng": "ng",
6
8
  "dev": "ng serve",
7
- "start": "ng serve",
8
- "build": "ng build --output-path dist --base-href ./ --deploy-url ./",
9
+ "build": "ng build --output-path dist --base-href ./",
9
10
  "watch": "ng build --watch --configuration development",
10
11
  "test": "ng test"
11
12
  },
@@ -15,33 +16,36 @@
15
16
  "require": "./src/app/screen-recorder/screen-recorder.module.ts"
16
17
  }
17
18
  },
19
+ "prettier": {
20
+ "printWidth": 100,
21
+ "singleQuote": true,
22
+ "overrides": [
23
+ {
24
+ "files": "*.html",
25
+ "options": {
26
+ "parser": "angular"
27
+ }
28
+ }
29
+ ]
30
+ },
18
31
  "dependencies": {
19
- "@angular/animations": "~13.0.0",
20
- "@angular/common": "~13.0.0",
21
- "@angular/compiler": "~13.0.0",
22
- "@angular/core": "~13.0.0",
23
- "@angular/forms": "~13.0.0",
24
- "@angular/platform-browser": "~13.0.0",
25
- "@angular/platform-browser-dynamic": "~13.0.0",
26
- "@angular/router": "~13.0.0",
27
- "@w-xuefeng/bindkey": "^1.0.1",
28
- "rxjs": "~7.4.0",
29
- "screen-recorder-base": "^0.0.7",
30
- "tslib": "^2.3.0",
31
- "zone.js": "~0.11.4"
32
+ "@angular/common": "^21.1.0",
33
+ "@angular/compiler": "^21.1.0",
34
+ "@angular/core": "^21.1.0",
35
+ "@angular/forms": "^21.1.0",
36
+ "@angular/platform-browser": "^21.1.0",
37
+ "@angular/router": "^21.1.0",
38
+ "@w-xuefeng/bindkey": "^1.0.3",
39
+ "screen-recorder-base": "^0.0.8",
40
+ "rxjs": "~7.8.0",
41
+ "tslib": "^2.3.0"
32
42
  },
33
43
  "devDependencies": {
34
- "@angular-devkit/build-angular": "~13.0.1",
35
- "@angular/cli": "~13.0.1",
36
- "@angular/compiler-cli": "~13.0.0",
37
- "@types/jasmine": "~3.10.0",
38
- "@types/node": "^12.11.1",
39
- "jasmine-core": "~3.10.0",
40
- "karma": "~6.3.0",
41
- "karma-chrome-launcher": "~3.1.0",
42
- "karma-coverage": "~2.0.3",
43
- "karma-jasmine": "~4.0.0",
44
- "karma-jasmine-html-reporter": "~1.7.0",
45
- "typescript": "~4.4.3"
44
+ "@angular/build": "^21.1.1",
45
+ "@angular/cli": "^21.1.1",
46
+ "@angular/compiler-cli": "^21.1.0",
47
+ "jsdom": "^27.1.0",
48
+ "typescript": "~5.9.2",
49
+ "vitest": "^4.0.8"
46
50
  }
47
- }
51
+ }
Binary file
@@ -1,14 +1,30 @@
1
- import { Component } from '@angular/core';
1
+ import { CommonModule } from "@angular/common";
2
+ import { ChangeDetectionStrategy, Component } from "@angular/core";
3
+ import { ScreenRecorderComponent } from "./screen-recorder/screen-recorder.component";
4
+ import {
5
+ EndContentDirective,
6
+ PreviewContentDirective,
7
+ StartContentDirective
8
+ } from "./screen-recorder/screen-recorder.props";
2
9
 
3
10
  @Component({
4
- selector: 'app-root',
5
- templateUrl: './app.component.html',
6
- styleUrls: ['./app.component.css']
11
+ selector: "app-root",
12
+ standalone: true,
13
+ imports: [
14
+ CommonModule,
15
+ StartContentDirective,
16
+ EndContentDirective,
17
+ PreviewContentDirective,
18
+ ScreenRecorderComponent,
19
+ ],
20
+ templateUrl: "./app.component.html",
21
+ styleUrls: ["./app.component.css"],
22
+ changeDetection: ChangeDetectionStrategy.OnPush,
7
23
  })
8
24
  export class AppComponent {
9
- title = "screen-recorder-angular"
25
+ title = "screen-recorder-angular";
10
26
 
11
- recording = false
27
+ recording = false;
12
28
 
13
29
  videoOptions: MediaTrackConstraints = {
14
30
  width: 1920,
@@ -1,6 +1,6 @@
1
- import { Directive, ElementRef, OnInit, HostListener } from '@angular/core';
1
+ import { Directive, ElementRef, HostListener, OnInit } from '@angular/core';
2
2
 
3
- @Directive({ selector: '[draggable]' })
3
+ @Directive({ selector: '[draggable]', standalone: true })
4
4
  export default class DragDirective implements OnInit {
5
5
 
6
6
  constructor(public el: ElementRef) {
@@ -36,7 +36,22 @@ export default class DragDirective implements OnInit {
36
36
 
37
37
  ngOnInit() {
38
38
  this.el.nativeElement.style.position = 'fixed';
39
- this.totalOffsetX = parseFloat(getComputedStyle(this.el.nativeElement).left);
40
- this.totalOffsetY = parseFloat(getComputedStyle(this.el.nativeElement).top);
39
+ const computed = getComputedStyle(this.el.nativeElement);
40
+ const left = parseFloat(computed.left);
41
+ const top = parseFloat(computed.top);
42
+
43
+ if (Number.isNaN(left) || Number.isNaN(top)) {
44
+ const rect = this.el.nativeElement.getBoundingClientRect();
45
+ this.totalOffsetX = rect.left;
46
+ this.totalOffsetY = rect.top;
47
+ this.el.nativeElement.style.left = `${this.totalOffsetX}px`;
48
+ this.el.nativeElement.style.top = `${this.totalOffsetY}px`;
49
+ this.el.nativeElement.style.right = 'auto';
50
+ this.el.nativeElement.style.bottom = 'auto';
51
+ return;
52
+ }
53
+
54
+ this.totalOffsetX = left;
55
+ this.totalOffsetY = top;
41
56
  }
42
57
  }
@@ -1,29 +1,29 @@
1
- <button *ngIf="(!startContent || !startContent.templateRef) && !state.recording" (click)="start()"
2
- [style]="defaultBtnStyle + startBtnStyle">
1
+ <button *ngIf="(!startContent || !startContent.templateRef) && !recording()" (click)="start()"
2
+ [style]="defaultBtnStyle + (startBtnStyle ?? '')">
3
3
  {{ startBtnText }}
4
4
  </button>
5
5
 
6
- <div *ngIf="startContent && startContent.templateRef && !state.recording">
6
+ <div *ngIf="startContent && startContent.templateRef && !recording()">
7
7
  <ng-container [ngTemplateOutlet]="startContent.templateRef" [ngTemplateOutletContext]="startContext">
8
8
  </ng-container>
9
9
  </div>
10
10
 
11
- <button *ngIf="(!endContent || !endContent.templateRef)&& state.recording" (click)="end()"
12
- [style]="defaultBtnStyle + endBtnStyle">
11
+ <button *ngIf="(!endContent || !endContent.templateRef)&& recording()" (click)="end()"
12
+ [style]="defaultBtnStyle + (endBtnStyle ?? '')">
13
13
  {{ endBtnText }}
14
14
  </button>
15
15
 
16
- <div *ngIf="endContent && endContent.templateRef && state.recording">
16
+ <div *ngIf="endContent && endContent.templateRef && recording()">
17
17
  <ng-container [ngTemplateOutlet]="endContent.templateRef" [ngTemplateOutletContext]="endContext">
18
18
  </ng-container>
19
19
  </div>
20
20
 
21
- <video *ngIf="(!previewContent || !previewContent.templateRef) && preview && state.recording"
22
- [srcObject]="previewMediaStream" muted autoplay draggable [width]="previewDefaultWidth"
21
+ <video *ngIf="(!previewContent || !previewContent.templateRef) && preview && recording()"
22
+ [srcObject]="previewMediaStream()" muted autoplay draggable [width]="previewDefaultWidth"
23
23
  style="position: fixed; border: 1px solid #666; z-index: 9999; cursor: move; right: 5px; top: 5px;">
24
24
  </video>
25
25
 
26
- <div *ngIf="previewContent && previewContent.templateRef && preview && state.recording && state.screenRecorder">
27
- <ng-container [ngTemplateOutlet]="previewContent.templateRef" [ngTemplateOutletContext]="previewContext">
26
+ <div *ngIf="previewContent && previewContent.templateRef && preview && recording() && screenRecorder()">
27
+ <ng-container [ngTemplateOutlet]="previewContent.templateRef" [ngTemplateOutletContext]="previewContext()">
28
28
  </ng-container>
29
29
  </div>
@@ -1,14 +1,25 @@
1
- import { Component, OnInit } from '@angular/core';
2
- import { ScreenRecorder, IScreenRecorderOptions, RecordRTC } from 'screen-recorder-base';
3
- import bindkey from '@w-xuefeng/bindkey'
4
- import ScreenRecorderProps from './screen-recorder.props';
1
+ import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from "@angular/core";
2
+ import {
3
+ IScreenRecorderOptions,
4
+ RecordRTC,
5
+ ScreenRecorder,
6
+ } from "screen-recorder-base";
7
+ import { CommonModule } from "@angular/common";
8
+ import { bindkey } from "@w-xuefeng/bindkey";
9
+ import ScreenRecorderProps from "./screen-recorder.props";
10
+ import DragDirective from "./draggable-directive/draggable.directive";
5
11
 
6
12
  @Component({
7
- selector: 'app-screen-recorder',
8
- templateUrl: './screen-recorder.component.html',
9
- styleUrls: ['./screen-recorder.component.css']
13
+ selector: "app-screen-recorder",
14
+ standalone: true,
15
+ imports: [CommonModule, DragDirective],
16
+ templateUrl: "./screen-recorder.component.html",
17
+ styleUrls: ["./screen-recorder.component.css"],
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
19
  })
11
- export class ScreenRecorderComponent extends ScreenRecorderProps implements OnInit {
20
+ export class ScreenRecorderComponent extends ScreenRecorderProps
21
+ implements OnInit, OnDestroy {
22
+ private boundKeys: string[] = [];
12
23
 
13
24
  constructor() {
14
25
  super();
@@ -17,36 +28,44 @@ export class ScreenRecorderComponent extends ScreenRecorderProps implements OnIn
17
28
  ngOnInit(): void {
18
29
  const options: IScreenRecorderOptions & RecordRTC.Options = {
19
30
  onUnsupported: () => {
20
- this.state.unsupported = true;
21
- this.state.recording = false;
22
- this.state.error = false;
23
- this.onRecordingUnsupport.emit()
31
+ this.unsupported.set(true);
32
+ this.recording.set(false);
33
+ this.error.set(false);
34
+ this.onRecordingUnsupport.emit();
24
35
  },
25
36
  onRecordStart: (mediaStream: MediaStream) => {
26
- this.state.recording = true;
27
- this.state.error = false;
37
+ this.recording.set(true);
38
+ this.error.set(false);
28
39
  this.initPreview(mediaStream);
29
- this.onRecordingStart.emit({ mediaStream })
40
+ this.onRecordingStart.emit({ mediaStream });
30
41
  },
31
42
  onError: (err: unknown) => {
32
- this.state.error = true;
33
- this.state.recording = false;
34
- this.onRecordingError.emit({ err })
43
+ this.error.set(true);
44
+ this.recording.set(false);
45
+ this.onRecordingError.emit({ err });
35
46
  },
36
47
  onRecordEnd: (blobUrl: string, fixedBlob: Blob) => {
37
- this.state.recording = false;
38
- this.state.error = false;
39
- this.onRecordingEnd.emit({ url: blobUrl, blob: fixedBlob })
48
+ this.recording.set(false);
49
+ this.error.set(false);
50
+ this.onRecordingEnd.emit({ url: blobUrl, blob: fixedBlob });
40
51
  },
41
52
  timeSlice: 1000,
42
53
  videoOptions: this.videoOptions,
43
54
  };
44
55
 
45
- this.state.screenRecorder = ScreenRecorder.createSR(options);
56
+ this.screenRecorder.set(ScreenRecorder.createSR(options));
46
57
 
47
- if (this.shortKey && this.shortKey.toUpperCase() !== 'ESC') {
58
+ if (this.shortKey && this.shortKey.toUpperCase() !== "ESC") {
48
59
  bindkey.add(this.shortKey, this.start);
49
- bindkey.add('ESC', this.end);
60
+ bindkey.add("ESC", this.end);
61
+ this.boundKeys = [this.shortKey, "ESC"];
50
62
  }
51
63
  }
64
+
65
+ ngOnDestroy(): void {
66
+ for (const key of this.boundKeys) {
67
+ bindkey.remove(key);
68
+ }
69
+ this.boundKeys = [];
70
+ }
52
71
  }
@@ -1,26 +1,29 @@
1
- import { NgModule } from '@angular/core';
2
- import { BrowserModule } from '@angular/platform-browser';
3
- import DragDirective from './draggable-directive/draggable.directive';
4
- import { ScreenRecorderComponent } from './screen-recorder.component';
5
- import { StartContentDirective, EndContentDirective, PreviewContentDirective } from './screen-recorder.props';
1
+ import { CommonModule } from "@angular/common";
2
+ import { NgModule } from "@angular/core";
3
+ import DragDirective from "./draggable-directive/draggable.directive";
4
+ import { ScreenRecorderComponent } from "./screen-recorder.component";
5
+ import {
6
+ EndContentDirective,
7
+ PreviewContentDirective,
8
+ StartContentDirective,
9
+ } from "./screen-recorder.props";
6
10
 
7
11
  @NgModule({
8
- declarations: [
12
+ declarations: [],
13
+ imports: [
14
+ CommonModule,
9
15
  DragDirective,
10
16
  StartContentDirective,
11
17
  EndContentDirective,
12
18
  PreviewContentDirective,
13
- ScreenRecorderComponent
14
- ],
15
- imports: [
16
- BrowserModule
19
+ ScreenRecorderComponent,
17
20
  ],
18
21
  exports: [
19
22
  DragDirective,
20
23
  StartContentDirective,
21
24
  EndContentDirective,
22
25
  PreviewContentDirective,
23
- ScreenRecorderComponent
24
- ]
26
+ ScreenRecorderComponent,
27
+ ],
25
28
  })
26
- export class ScreenRecorderModule { }
29
+ export class ScreenRecorderModule {}
@@ -4,26 +4,31 @@ import {
4
4
  EventEmitter,
5
5
  Input,
6
6
  Output,
7
- TemplateRef
7
+ TemplateRef,
8
+ computed,
9
+ signal
8
10
  } from "@angular/core";
9
11
  import { ScreenRecorder } from 'screen-recorder-base';
10
12
 
11
13
  @Directive({
12
- selector: '[startContent]'
14
+ selector: '[startContent]',
15
+ standalone: true
13
16
  })
14
17
  export class StartContentDirective {
15
18
  constructor(public templateRef: TemplateRef<unknown>) { }
16
19
  }
17
20
 
18
21
  @Directive({
19
- selector: '[endContent]'
22
+ selector: '[endContent]',
23
+ standalone: true
20
24
  })
21
25
  export class EndContentDirective {
22
26
  constructor(public templateRef: TemplateRef<unknown>) { }
23
27
  }
24
28
 
25
29
  @Directive({
26
- selector: '[previewContent]'
30
+ selector: '[previewContent]',
31
+ standalone: true
27
32
  })
28
33
  export class PreviewContentDirective {
29
34
  constructor(public templateRef: TemplateRef<unknown>) { }
@@ -49,27 +54,24 @@ export default class ScreenRecorderProps {
49
54
  @ContentChild(EndContentDirective) endContent!: EndContentDirective;
50
55
  @ContentChild(PreviewContentDirective) previewContent!: PreviewContentDirective;
51
56
 
52
- state = {
53
- error: false,
54
- unsupported: false,
55
- recording: false,
56
- screenRecorder: null as ScreenRecorder | null,
57
- }
57
+ readonly error = signal(false);
58
+ readonly unsupported = signal(false);
59
+ readonly recording = signal(false);
60
+ readonly screenRecorder = signal<ScreenRecorder | null>(null);
58
61
 
59
62
  previewDefaultWidth = 300;
60
- previewMediaStream?: MediaStream
63
+ readonly previewMediaStream = signal<MediaStream | undefined>(undefined);
61
64
 
62
65
  initPreview = (mediaStream: MediaStream) => {
63
- this.previewMediaStream = mediaStream
64
- this.previewContext = { mediaStream }
66
+ this.previewMediaStream.set(mediaStream);
65
67
  }
66
68
 
67
69
  start = () => {
68
- this.state.screenRecorder?.startRecording();
70
+ this.screenRecorder()?.startRecording();
69
71
  };
70
72
 
71
73
  end = () => {
72
- this.state.screenRecorder?.stopRecording();
74
+ this.screenRecorder()?.stopRecording();
73
75
  };
74
76
 
75
77
  startContext = {
@@ -82,9 +84,9 @@ export default class ScreenRecorderProps {
82
84
  endEvent: this.end
83
85
  }
84
86
 
85
- previewContext = {
86
- mediaStream: this.state.screenRecorder?.mediaStream
87
- }
87
+ previewContext = computed(() => ({
88
+ mediaStream: this.previewMediaStream()
89
+ }));
88
90
 
89
91
  defaultBtnStyle = `
90
92
  margin: 0 16px;
package/src/index.html CHANGED
@@ -1,13 +1,13 @@
1
- <!doctype html>
1
+ <!DOCTYPE html>
2
2
  <html lang="zh">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>ScreenRecorderAngular</title>
6
- <base href="./">
7
- <meta name="viewport" content="width=device-width, initial-scale=1">
8
- <link rel="icon" type="image/x-icon" href="./favicon.ico">
9
- </head>
10
- <body>
11
- <app-root></app-root>
12
- </body>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>ScreenRecorderAngular</title>
6
+ <base href="./">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="icon" type="image/x-icon" href="./favicon.ico">
9
+ </head>
10
+ <body>
11
+ <app-root></app-root>
12
+ </body>
13
13
  </html>
package/src/main.ts CHANGED
@@ -1,12 +1,5 @@
1
- import { enableProdMode } from '@angular/core';
2
- import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1
+ import { bootstrapApplication } from "@angular/platform-browser";
2
+ import { AppComponent } from "./app/app.component";
3
3
 
4
- import { AppModule } from './app/app.module';
5
- import { environment } from './environments/environment';
6
-
7
- if (environment.production) {
8
- enableProdMode();
9
- }
10
-
11
- platformBrowserDynamic().bootstrapModule(AppModule)
12
- .catch(err => console.error(err));
4
+ bootstrapApplication(AppComponent)
5
+ .catch((err) => console.error(err));
package/tsconfig.app.json CHANGED
@@ -1,16 +1,19 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
1
  {
3
2
  "extends": "./tsconfig.json",
4
3
  "compilerOptions": {
4
+ "lib": [
5
+ "DOM",
6
+ "ESNext"
7
+ ],
5
8
  "outDir": "./out-tsc/app",
6
- "allowSyntheticDefaultImports": true,
7
- "types": []
9
+ "types": [
10
+ "screen-recorder-base/env.d.ts"
11
+ ]
8
12
  },
9
- "files": [
10
- "src/main.ts",
11
- "src/polyfills.ts"
12
- ],
13
13
  "include": [
14
- "src/**/*.d.ts"
14
+ "src/**/*.ts"
15
+ ],
16
+ "exclude": [
17
+ "src/**/*.spec.ts"
15
18
  ]
16
- }
19
+ }
package/tsconfig.json CHANGED
@@ -1,32 +1,31 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
1
  {
3
2
  "compileOnSave": false,
4
3
  "compilerOptions": {
5
- "baseUrl": "./",
6
- "outDir": "./dist/out-tsc",
7
- "forceConsistentCasingInFileNames": true,
8
4
  "strict": true,
9
5
  "noImplicitOverride": true,
10
6
  "noPropertyAccessFromIndexSignature": true,
11
7
  "noImplicitReturns": true,
12
8
  "noFallthroughCasesInSwitch": true,
13
- "sourceMap": true,
14
- "declaration": false,
15
- "downlevelIteration": true,
9
+ "skipLibCheck": true,
10
+ "isolatedModules": true,
16
11
  "experimentalDecorators": true,
17
- "moduleResolution": "node",
18
12
  "importHelpers": true,
19
- "target": "es2017",
20
- "module": "es2020",
21
- "lib": [
22
- "es2020",
23
- "dom"
24
- ]
13
+ "target": "ES2022",
14
+ "module": "preserve"
25
15
  },
26
16
  "angularCompilerOptions": {
27
17
  "enableI18nLegacyMessageIdFormat": false,
28
18
  "strictInjectionParameters": true,
29
19
  "strictInputAccessModifiers": true,
30
20
  "strictTemplates": true
31
- }
32
- }
21
+ },
22
+ "files": [],
23
+ "references": [
24
+ {
25
+ "path": "./tsconfig.app.json"
26
+ },
27
+ {
28
+ "path": "./tsconfig.spec.json"
29
+ }
30
+ ]
31
+ }
@@ -1,18 +1,13 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
1
  {
3
2
  "extends": "./tsconfig.json",
4
3
  "compilerOptions": {
5
4
  "outDir": "./out-tsc/spec",
6
5
  "types": [
7
- "jasmine"
6
+ "vitest/globals"
8
7
  ]
9
8
  },
10
- "files": [
11
- "src/test.ts",
12
- "src/polyfills.ts"
13
- ],
14
9
  "include": [
15
- "src/**/*.spec.ts",
16
- "src/**/*.d.ts"
10
+ "src/**/*.d.ts",
11
+ "src/**/*.spec.ts"
17
12
  ]
18
- }
13
+ }
package/.browserslistrc DELETED
@@ -1,16 +0,0 @@
1
- # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
- # For additional information regarding the format and rule options, please see:
3
- # https://github.com/browserslist/browserslist#queries
4
-
5
- # For the full list of supported browsers by the Angular framework, please see:
6
- # https://angular.io/guide/browser-support
7
-
8
- # You can see what browsers were selected by your queries by running:
9
- # npx browserslist
10
-
11
- last 1 Chrome version
12
- last 1 Firefox version
13
- last 2 Edge major versions
14
- last 2 Safari major versions
15
- last 2 iOS major versions
16
- Firefox ESR
package/karma.conf.js DELETED
@@ -1,44 +0,0 @@
1
- // Karma configuration file, see link for more information
2
- // https://karma-runner.github.io/1.0/config/configuration-file.html
3
-
4
- module.exports = function (config) {
5
- config.set({
6
- basePath: '',
7
- frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
- plugins: [
9
- require('karma-jasmine'),
10
- require('karma-chrome-launcher'),
11
- require('karma-jasmine-html-reporter'),
12
- require('karma-coverage'),
13
- require('@angular-devkit/build-angular/plugins/karma')
14
- ],
15
- client: {
16
- jasmine: {
17
- // you can add configuration options for Jasmine here
18
- // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
- // for example, you can disable the random execution with `random: false`
20
- // or set a specific seed with `seed: 4321`
21
- },
22
- clearContext: false // leave Jasmine Spec Runner output visible in browser
23
- },
24
- jasmineHtmlReporter: {
25
- suppressAll: true // removes the duplicated traces
26
- },
27
- coverageReporter: {
28
- dir: require('path').join(__dirname, './coverage/screen-recorder-angular'),
29
- subdir: '.',
30
- reporters: [
31
- { type: 'html' },
32
- { type: 'text-summary' }
33
- ]
34
- },
35
- reporters: ['progress', 'kjhtml'],
36
- port: 9876,
37
- colors: true,
38
- logLevel: config.LOG_INFO,
39
- autoWatch: true,
40
- browsers: ['Chrome'],
41
- singleRun: false,
42
- restartOnFileChange: true
43
- });
44
- };
@@ -1,31 +0,0 @@
1
- import { TestBed } from '@angular/core/testing';
2
- import { AppComponent } from './app.component';
3
-
4
- describe('AppComponent', () => {
5
- beforeEach(async () => {
6
- await TestBed.configureTestingModule({
7
- declarations: [
8
- AppComponent
9
- ],
10
- }).compileComponents();
11
- });
12
-
13
- it('should create the app', () => {
14
- const fixture = TestBed.createComponent(AppComponent);
15
- const app = fixture.componentInstance;
16
- expect(app).toBeTruthy();
17
- });
18
-
19
- it(`should have as title 'screen-recorder-angular'`, () => {
20
- const fixture = TestBed.createComponent(AppComponent);
21
- const app = fixture.componentInstance;
22
- expect(app.title).toEqual('screen-recorder-angular');
23
- });
24
-
25
- it('should render title', () => {
26
- const fixture = TestBed.createComponent(AppComponent);
27
- fixture.detectChanges();
28
- const compiled = fixture.nativeElement as HTMLElement;
29
- expect(compiled.querySelector('.content span')?.textContent).toContain('screen-recorder-angular app is running!');
30
- });
31
- });
@@ -1,18 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { BrowserModule } from '@angular/platform-browser';
3
-
4
- import { AppComponent } from './app.component';
5
- import { ScreenRecorderModule } from './screen-recorder/screen-recorder.module';
6
-
7
- @NgModule({
8
- declarations: [
9
- AppComponent
10
- ],
11
- imports: [
12
- BrowserModule,
13
- ScreenRecorderModule
14
- ],
15
- providers: [],
16
- bootstrap: [AppComponent]
17
- })
18
- export class AppModule { }
@@ -1,25 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ScreenRecorderComponent } from './screen-recorder.component';
4
-
5
- describe('ScreenRecorderComponent', () => {
6
- let component: ScreenRecorderComponent;
7
- let fixture: ComponentFixture<ScreenRecorderComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- declarations: [ ScreenRecorderComponent ]
12
- })
13
- .compileComponents();
14
- });
15
-
16
- beforeEach(() => {
17
- fixture = TestBed.createComponent(ScreenRecorderComponent);
18
- component = fixture.componentInstance;
19
- fixture.detectChanges();
20
- });
21
-
22
- it('should create', () => {
23
- expect(component).toBeTruthy();
24
- });
25
- });
File without changes
package/src/env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="screen-recorder-base/env" />
@@ -1,3 +0,0 @@
1
- export const environment = {
2
- production: true
3
- };
@@ -1,16 +0,0 @@
1
- // This file can be replaced during build by using the `fileReplacements` array.
2
- // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3
- // The list of file replacements can be found in `angular.json`.
4
-
5
- export const environment = {
6
- production: false
7
- };
8
-
9
- /*
10
- * For easier debugging in development mode, you can import the following file
11
- * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12
- *
13
- * This import should be commented out in production mode because it will have a negative impact
14
- * on performance if an error is thrown.
15
- */
16
- // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
package/src/favicon.ico DELETED
Binary file
package/src/polyfills.ts DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * This file includes polyfills needed by Angular and is loaded before the app.
3
- * You can add your own extra polyfills to this file.
4
- *
5
- * This file is divided into 2 sections:
6
- * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7
- * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8
- * file.
9
- *
10
- * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11
- * automatically update themselves. This includes recent versions of Safari, Chrome (including
12
- * Opera), Edge on the desktop, and iOS and Chrome on mobile.
13
- *
14
- * Learn more in https://angular.io/guide/browser-support
15
- */
16
-
17
- /***************************************************************************************************
18
- * BROWSER POLYFILLS
19
- */
20
-
21
- /**
22
- * By default, zone.js will patch all possible macroTask and DomEvents
23
- * user can disable parts of macroTask/DomEvents patch by setting following flags
24
- * because those flags need to be set before `zone.js` being loaded, and webpack
25
- * will put import in the top of bundle, so user need to create a separate file
26
- * in this directory (for example: zone-flags.ts), and put the following flags
27
- * into that file, and then add the following code before importing zone.js.
28
- * import './zone-flags';
29
- *
30
- * The flags allowed in zone-flags.ts are listed here.
31
- *
32
- * The following flags will work for all browsers.
33
- *
34
- * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35
- * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36
- * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37
- *
38
- * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39
- * with the following flag, it will bypass `zone.js` patch for IE/Edge
40
- *
41
- * (window as any).__Zone_enable_cross_context_check = true;
42
- *
43
- */
44
-
45
- /***************************************************************************************************
46
- * Zone JS is required by default for Angular itself.
47
- */
48
- import 'zone.js'; // Included with Angular CLI.
49
-
50
-
51
- /***************************************************************************************************
52
- * APPLICATION IMPORTS
53
- */
package/src/test.ts DELETED
@@ -1,26 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'zone.js/testing';
4
- import { getTestBed } from '@angular/core/testing';
5
- import {
6
- BrowserDynamicTestingModule,
7
- platformBrowserDynamicTesting
8
- } from '@angular/platform-browser-dynamic/testing';
9
-
10
- declare const require: {
11
- context(path: string, deep?: boolean, filter?: RegExp): {
12
- keys(): string[];
13
- <T>(id: string): T;
14
- };
15
- };
16
-
17
- // First, initialize the Angular testing environment.
18
- getTestBed().initTestEnvironment(
19
- BrowserDynamicTestingModule,
20
- platformBrowserDynamicTesting(),
21
- );
22
-
23
- // Then we find all the tests.
24
- const context = require.context('./', true, /\.spec\.ts$/);
25
- // And load the modules.
26
- context.keys().map(context);