n8n-nodes-nvk-browser 1.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.
Files changed (55) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +76 -0
  3. package/dist/nodes/PageInteraction/MoveAndClick/MoveAndClick.description.d.ts +2 -0
  4. package/dist/nodes/PageInteraction/MoveAndClick/MoveAndClick.description.js +132 -0
  5. package/dist/nodes/PageInteraction/MoveAndClick/MoveAndClick.node.d.ts +5 -0
  6. package/dist/nodes/PageInteraction/MoveAndClick/MoveAndClick.node.js +176 -0
  7. package/dist/nodes/PageInteraction/MoveAndClick/click.svg +5 -0
  8. package/dist/nodes/PageInteraction/MoveAndClick/code.svg +5 -0
  9. package/dist/nodes/PageInteraction/MoveAndClick/profile.svg +5 -0
  10. package/dist/nodes/PageInteraction/RunJavaScript/RunJavaScript.description.d.ts +2 -0
  11. package/dist/nodes/PageInteraction/RunJavaScript/RunJavaScript.description.js +62 -0
  12. package/dist/nodes/PageInteraction/RunJavaScript/RunJavaScript.node.d.ts +5 -0
  13. package/dist/nodes/PageInteraction/RunJavaScript/RunJavaScript.node.js +126 -0
  14. package/dist/nodes/PageInteraction/RunJavaScript/click.svg +5 -0
  15. package/dist/nodes/PageInteraction/RunJavaScript/code.svg +5 -0
  16. package/dist/nodes/PageInteraction/RunJavaScript/profile.svg +5 -0
  17. package/dist/nodes/ProfileManagement/CreateProfile/CreateProfile.description.d.ts +2 -0
  18. package/dist/nodes/ProfileManagement/CreateProfile/CreateProfile.description.js +61 -0
  19. package/dist/nodes/ProfileManagement/CreateProfile/CreateProfile.node.d.ts +5 -0
  20. package/dist/nodes/ProfileManagement/CreateProfile/CreateProfile.node.js +124 -0
  21. package/dist/nodes/ProfileManagement/CreateProfile/click.svg +5 -0
  22. package/dist/nodes/ProfileManagement/CreateProfile/code.svg +5 -0
  23. package/dist/nodes/ProfileManagement/CreateProfile/profile.svg +5 -0
  24. package/dist/nodes/ProfileManagement/DeleteProfile/DeleteProfile.description.d.ts +2 -0
  25. package/dist/nodes/ProfileManagement/DeleteProfile/DeleteProfile.description.js +19 -0
  26. package/dist/nodes/ProfileManagement/DeleteProfile/DeleteProfile.node.d.ts +5 -0
  27. package/dist/nodes/ProfileManagement/DeleteProfile/DeleteProfile.node.js +123 -0
  28. package/dist/nodes/ProfileManagement/DeleteProfile/click.svg +5 -0
  29. package/dist/nodes/ProfileManagement/DeleteProfile/code.svg +5 -0
  30. package/dist/nodes/ProfileManagement/DeleteProfile/profile.svg +5 -0
  31. package/dist/nodes/ProfileManagement/StartProfile/StartProfile.description.d.ts +2 -0
  32. package/dist/nodes/ProfileManagement/StartProfile/StartProfile.description.js +122 -0
  33. package/dist/nodes/ProfileManagement/StartProfile/StartProfile.node.d.ts +5 -0
  34. package/dist/nodes/ProfileManagement/StartProfile/StartProfile.node.js +140 -0
  35. package/dist/nodes/ProfileManagement/StartProfile/click.svg +5 -0
  36. package/dist/nodes/ProfileManagement/StartProfile/code.svg +5 -0
  37. package/dist/nodes/ProfileManagement/StartProfile/profile.svg +5 -0
  38. package/dist/nodes/ProfileManagement/StopProfile/StopProfile.description.d.ts +2 -0
  39. package/dist/nodes/ProfileManagement/StopProfile/StopProfile.description.js +19 -0
  40. package/dist/nodes/ProfileManagement/StopProfile/StopProfile.node.d.ts +5 -0
  41. package/dist/nodes/ProfileManagement/StopProfile/StopProfile.node.js +115 -0
  42. package/dist/nodes/ProfileManagement/StopProfile/click.svg +5 -0
  43. package/dist/nodes/ProfileManagement/StopProfile/code.svg +5 -0
  44. package/dist/nodes/ProfileManagement/StopProfile/profile.svg +5 -0
  45. package/dist/utils/BrowserManager.d.ts +18 -0
  46. package/dist/utils/BrowserManager.js +174 -0
  47. package/dist/utils/ExtensionHandler.d.ts +9 -0
  48. package/dist/utils/ExtensionHandler.js +86 -0
  49. package/dist/utils/ProfileManager.d.ts +14 -0
  50. package/dist/utils/ProfileManager.js +128 -0
  51. package/dist/utils/ProxyHandler.d.ts +5 -0
  52. package/dist/utils/ProxyHandler.js +50 -0
  53. package/dist/utils/types.d.ts +47 -0
  54. package/dist/utils/types.js +2 -0
  55. package/package.json +66 -0
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProfileFields = void 0;
4
+ exports.createProfileFields = [
5
+ {
6
+ displayName: 'Profile Name',
7
+ name: 'profileName',
8
+ type: 'string',
9
+ required: true,
10
+ default: '',
11
+ description: 'Name of the profile to create',
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['profile'],
15
+ operation: ['create'],
16
+ },
17
+ },
18
+ },
19
+ {
20
+ displayName: 'Proxy',
21
+ name: 'proxy',
22
+ type: 'string',
23
+ default: '',
24
+ description: 'Proxy format: http:127.0.0.1:8080:user:pass or socks5:127.0.0.1:1080:user:pass',
25
+ displayOptions: {
26
+ show: {
27
+ resource: ['profile'],
28
+ operation: ['create'],
29
+ },
30
+ },
31
+ },
32
+ {
33
+ displayName: 'Note',
34
+ name: 'note',
35
+ type: 'string',
36
+ default: '',
37
+ description: 'Optional note for this profile',
38
+ displayOptions: {
39
+ show: {
40
+ resource: ['profile'],
41
+ operation: ['create'],
42
+ },
43
+ },
44
+ },
45
+ {
46
+ displayName: 'Extensions',
47
+ name: 'extensions',
48
+ type: 'string',
49
+ typeOptions: {
50
+ rows: 4,
51
+ },
52
+ default: '',
53
+ description: 'Chrome Store extension IDs or local paths, one per line',
54
+ displayOptions: {
55
+ show: {
56
+ resource: ['profile'],
57
+ operation: ['create'],
58
+ },
59
+ },
60
+ },
61
+ ];
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class CreateProfile implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.CreateProfile = void 0;
27
+ const path = __importStar(require("path"));
28
+ const ProfileManager_1 = require("../../../utils/ProfileManager");
29
+ const ExtensionHandler_1 = require("../../../utils/ExtensionHandler");
30
+ const CreateProfile_description_1 = require("./CreateProfile.description");
31
+ class CreateProfile {
32
+ constructor() {
33
+ this.description = {
34
+ displayName: 'Create Profile',
35
+ name: 'createProfile',
36
+ icon: 'file:profile.svg',
37
+ group: ['transform'],
38
+ version: 1,
39
+ description: 'Create a new browser profile',
40
+ defaults: {
41
+ name: 'Create Profile',
42
+ },
43
+ inputs: ['main'],
44
+ outputs: ['main'],
45
+ properties: [
46
+ {
47
+ displayName: 'Resource',
48
+ name: 'resource',
49
+ type: 'options',
50
+ noDataExpression: true,
51
+ options: [
52
+ {
53
+ name: 'Profile',
54
+ value: 'profile',
55
+ },
56
+ ],
57
+ default: 'profile',
58
+ },
59
+ {
60
+ displayName: 'Operation',
61
+ name: 'operation',
62
+ type: 'options',
63
+ noDataExpression: true,
64
+ options: [
65
+ {
66
+ name: 'Create',
67
+ value: 'create',
68
+ description: 'Create a new profile',
69
+ action: 'Create a profile',
70
+ },
71
+ ],
72
+ default: 'create',
73
+ },
74
+ ...CreateProfile_description_1.createProfileFields,
75
+ ],
76
+ };
77
+ }
78
+ async execute() {
79
+ const items = this.getInputData();
80
+ const returnData = [];
81
+ // Lấy đường dẫn profiles từ environment hoặc default
82
+ const workspacePath = process.cwd();
83
+ const profilesDir = process.env.NVK_PROFILES_DIR || path.join(workspacePath, 'profiles');
84
+ const resolvedProfilesDir = path.isAbsolute(profilesDir)
85
+ ? profilesDir
86
+ : path.resolve(workspacePath, profilesDir);
87
+ const profileManager = new ProfileManager_1.ProfileManager(resolvedProfilesDir);
88
+ for (let i = 0; i < items.length; i++) {
89
+ try {
90
+ const profileName = this.getNodeParameter('profileName', i);
91
+ const proxy = this.getNodeParameter('proxy', i) || undefined;
92
+ const note = this.getNodeParameter('note', i) || undefined;
93
+ const extensionsInput = this.getNodeParameter('extensions', i) || '';
94
+ // Parse extensions
95
+ const extensions = ExtensionHandler_1.ExtensionHandler.parseExtensions(extensionsInput);
96
+ // Tạo profile
97
+ const profile = profileManager.createProfile(profileName, proxy, note, extensions);
98
+ returnData.push({
99
+ json: {
100
+ success: true,
101
+ profile: {
102
+ id: profile.id,
103
+ name: profile.name,
104
+ proxy: profile.proxy,
105
+ note: profile.note,
106
+ extensions: profile.extensions,
107
+ createdAt: profile.createdAt,
108
+ },
109
+ },
110
+ });
111
+ }
112
+ catch (error) {
113
+ returnData.push({
114
+ json: {
115
+ success: false,
116
+ error: error instanceof Error ? error.message : String(error),
117
+ },
118
+ });
119
+ }
120
+ }
121
+ return [returnData];
122
+ }
123
+ }
124
+ exports.CreateProfile = CreateProfile;
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M9 9l5 12 1.774-5.226L21 14 9 9z"></path>
3
+ <path d="M21 3l-3.5 3.5"></path>
4
+ </svg>
5
+
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <polyline points="16 18 22 12 16 6"></polyline>
3
+ <polyline points="8 6 2 12 8 18"></polyline>
4
+ </svg>
5
+
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
3
+ <circle cx="12" cy="7" r="4"></circle>
4
+ </svg>
5
+
@@ -0,0 +1,2 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const deleteProfileFields: INodeProperties[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProfileFields = void 0;
4
+ exports.deleteProfileFields = [
5
+ {
6
+ displayName: 'Profile ID',
7
+ name: 'profileId',
8
+ type: 'string',
9
+ required: true,
10
+ default: '',
11
+ description: 'ID of the profile to delete (e.g., 3c7d222d-2f17-4de8-bc3b-9d5cad5c0f1d)',
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['profile'],
15
+ operation: ['delete'],
16
+ },
17
+ },
18
+ },
19
+ ];
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class DeleteProfile implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.DeleteProfile = void 0;
27
+ const ProfileManager_1 = require("../../../utils/ProfileManager");
28
+ const BrowserManager_1 = require("../../../utils/BrowserManager");
29
+ const DeleteProfile_description_1 = require("./DeleteProfile.description");
30
+ const path = __importStar(require("path"));
31
+ class DeleteProfile {
32
+ constructor() {
33
+ this.description = {
34
+ displayName: 'Delete Profile',
35
+ name: 'deleteProfile',
36
+ icon: 'file:profile.svg',
37
+ group: ['transform'],
38
+ version: 1,
39
+ description: 'Delete a browser profile',
40
+ defaults: {
41
+ name: 'Delete Profile',
42
+ },
43
+ inputs: ['main'],
44
+ outputs: ['main'],
45
+ properties: [
46
+ {
47
+ displayName: 'Resource',
48
+ name: 'resource',
49
+ type: 'options',
50
+ noDataExpression: true,
51
+ options: [
52
+ {
53
+ name: 'Profile',
54
+ value: 'profile',
55
+ },
56
+ ],
57
+ default: 'profile',
58
+ },
59
+ {
60
+ displayName: 'Operation',
61
+ name: 'operation',
62
+ type: 'options',
63
+ noDataExpression: true,
64
+ options: [
65
+ {
66
+ name: 'Delete',
67
+ value: 'delete',
68
+ description: 'Delete a profile',
69
+ action: 'Delete a profile',
70
+ },
71
+ ],
72
+ default: 'delete',
73
+ },
74
+ ...DeleteProfile_description_1.deleteProfileFields,
75
+ ],
76
+ };
77
+ }
78
+ async execute() {
79
+ const items = this.getInputData();
80
+ const returnData = [];
81
+ const workspacePath = process.cwd();
82
+ const profilesDir = process.env.NVK_PROFILES_DIR || path.join(workspacePath, 'profiles');
83
+ const browserPath = process.env.NVK_BROWSER_PATH || path.join(workspacePath, 'browser-142', 'chrome.exe');
84
+ const resolvedBrowserPath = path.isAbsolute(browserPath)
85
+ ? browserPath
86
+ : path.resolve(workspacePath, browserPath);
87
+ const resolvedProfilesDir = path.isAbsolute(profilesDir)
88
+ ? profilesDir
89
+ : path.resolve(workspacePath, profilesDir);
90
+ const profileManager = new ProfileManager_1.ProfileManager(resolvedProfilesDir);
91
+ BrowserManager_1.BrowserManager.resetInstance(); // Reset để đảm bảo dùng đúng paths
92
+ const browserManager = BrowserManager_1.BrowserManager.getInstance(resolvedBrowserPath, resolvedProfilesDir);
93
+ for (let i = 0; i < items.length; i++) {
94
+ try {
95
+ const profileId = this.getNodeParameter('profileId', i);
96
+ // Dừng profile nếu đang chạy
97
+ const instance = browserManager.getInstance(profileId);
98
+ if (instance) {
99
+ await browserManager.stopProfile(profileId);
100
+ }
101
+ // Xóa profile
102
+ const deleted = profileManager.deleteProfile(profileId);
103
+ returnData.push({
104
+ json: {
105
+ success: deleted,
106
+ profileId,
107
+ message: deleted ? 'Profile deleted successfully' : 'Profile not found',
108
+ },
109
+ });
110
+ }
111
+ catch (error) {
112
+ returnData.push({
113
+ json: {
114
+ success: false,
115
+ error: error instanceof Error ? error.message : String(error),
116
+ },
117
+ });
118
+ }
119
+ }
120
+ return [returnData];
121
+ }
122
+ }
123
+ exports.DeleteProfile = DeleteProfile;
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M9 9l5 12 1.774-5.226L21 14 9 9z"></path>
3
+ <path d="M21 3l-3.5 3.5"></path>
4
+ </svg>
5
+
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <polyline points="16 18 22 12 16 6"></polyline>
3
+ <polyline points="8 6 2 12 8 18"></polyline>
4
+ </svg>
5
+
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
3
+ <circle cx="12" cy="7" r="4"></circle>
4
+ </svg>
5
+
@@ -0,0 +1,2 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const startProfileFields: INodeProperties[];
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startProfileFields = void 0;
4
+ exports.startProfileFields = [
5
+ {
6
+ displayName: 'Profile ID',
7
+ name: 'profileId',
8
+ type: 'string',
9
+ required: true,
10
+ default: '',
11
+ description: 'ID of the profile to start',
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['profile'],
15
+ operation: ['start'],
16
+ },
17
+ },
18
+ },
19
+ {
20
+ displayName: 'Window Scale',
21
+ name: 'winScale',
22
+ type: 'number',
23
+ typeOptions: {
24
+ minValue: 0.5,
25
+ maxValue: 3,
26
+ numberStepSize: 0.1,
27
+ },
28
+ default: 1,
29
+ description: 'Window scale factor',
30
+ displayOptions: {
31
+ show: {
32
+ resource: ['profile'],
33
+ operation: ['start'],
34
+ },
35
+ },
36
+ },
37
+ {
38
+ displayName: 'Window Position',
39
+ name: 'winPosition',
40
+ type: 'fixedCollection',
41
+ typeOptions: {
42
+ multipleValues: false,
43
+ },
44
+ default: {},
45
+ description: 'Window position on screen',
46
+ displayOptions: {
47
+ show: {
48
+ resource: ['profile'],
49
+ operation: ['start'],
50
+ },
51
+ },
52
+ options: [
53
+ {
54
+ name: 'position',
55
+ displayName: 'Position',
56
+ values: [
57
+ {
58
+ displayName: 'X',
59
+ name: 'x',
60
+ type: 'number',
61
+ default: 0,
62
+ },
63
+ {
64
+ displayName: 'Y',
65
+ name: 'y',
66
+ type: 'number',
67
+ default: 0,
68
+ },
69
+ ],
70
+ },
71
+ ],
72
+ },
73
+ {
74
+ displayName: 'Window Size',
75
+ name: 'winSize',
76
+ type: 'fixedCollection',
77
+ typeOptions: {
78
+ multipleValues: false,
79
+ },
80
+ default: {},
81
+ description: 'Window size',
82
+ displayOptions: {
83
+ show: {
84
+ resource: ['profile'],
85
+ operation: ['start'],
86
+ },
87
+ },
88
+ options: [
89
+ {
90
+ name: 'size',
91
+ displayName: 'Size',
92
+ values: [
93
+ {
94
+ displayName: 'Width',
95
+ name: 'width',
96
+ type: 'number',
97
+ default: 1280,
98
+ },
99
+ {
100
+ displayName: 'Height',
101
+ name: 'height',
102
+ type: 'number',
103
+ default: 720,
104
+ },
105
+ ],
106
+ },
107
+ ],
108
+ },
109
+ {
110
+ displayName: 'Headless Mode',
111
+ name: 'headless',
112
+ type: 'boolean',
113
+ default: false,
114
+ description: 'Run browser in headless mode',
115
+ displayOptions: {
116
+ show: {
117
+ resource: ['profile'],
118
+ operation: ['start'],
119
+ },
120
+ },
121
+ },
122
+ ];
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class StartProfile implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.StartProfile = void 0;
27
+ const BrowserManager_1 = require("../../../utils/BrowserManager");
28
+ const StartProfile_description_1 = require("./StartProfile.description");
29
+ const path = __importStar(require("path"));
30
+ class StartProfile {
31
+ constructor() {
32
+ this.description = {
33
+ displayName: 'Start Profile',
34
+ name: 'startProfile',
35
+ icon: 'file:profile.svg',
36
+ group: ['transform'],
37
+ version: 1,
38
+ description: 'Start a browser profile',
39
+ defaults: {
40
+ name: 'Start Profile',
41
+ },
42
+ inputs: ['main'],
43
+ outputs: ['main'],
44
+ properties: [
45
+ {
46
+ displayName: 'Resource',
47
+ name: 'resource',
48
+ type: 'options',
49
+ noDataExpression: true,
50
+ options: [
51
+ {
52
+ name: 'Profile',
53
+ value: 'profile',
54
+ },
55
+ ],
56
+ default: 'profile',
57
+ },
58
+ {
59
+ displayName: 'Operation',
60
+ name: 'operation',
61
+ type: 'options',
62
+ noDataExpression: true,
63
+ options: [
64
+ {
65
+ name: 'Start',
66
+ value: 'start',
67
+ description: 'Start a profile',
68
+ action: 'Start a profile',
69
+ },
70
+ ],
71
+ default: 'start',
72
+ },
73
+ ...StartProfile_description_1.startProfileFields,
74
+ ],
75
+ };
76
+ }
77
+ async execute() {
78
+ const items = this.getInputData();
79
+ const returnData = [];
80
+ const workspacePath = process.cwd();
81
+ const profilesDir = process.env.NVK_PROFILES_DIR || path.join(workspacePath, 'profiles');
82
+ const browserPath = process.env.NVK_BROWSER_PATH || path.join(workspacePath, 'browser-142', 'chrome.exe');
83
+ // Resolve absolute paths
84
+ const resolvedBrowserPath = path.isAbsolute(browserPath)
85
+ ? browserPath
86
+ : path.resolve(workspacePath, browserPath);
87
+ const resolvedProfilesDir = path.isAbsolute(profilesDir)
88
+ ? profilesDir
89
+ : path.resolve(workspacePath, profilesDir);
90
+ BrowserManager_1.BrowserManager.resetInstance(); // Reset để đảm bảo dùng đúng paths
91
+ const browserManager = BrowserManager_1.BrowserManager.getInstance(resolvedBrowserPath, resolvedProfilesDir);
92
+ for (let i = 0; i < items.length; i++) {
93
+ try {
94
+ const profileId = this.getNodeParameter('profileId', i);
95
+ const winScale = this.getNodeParameter('winScale', i);
96
+ const winPosition = this.getNodeParameter('winPosition', i);
97
+ const winSize = this.getNodeParameter('winSize', i);
98
+ const headless = this.getNodeParameter('headless', i);
99
+ const windowConfig = {};
100
+ if (winScale !== undefined) {
101
+ windowConfig.scale = winScale;
102
+ }
103
+ if (winPosition?.position) {
104
+ windowConfig.position = {
105
+ x: winPosition.position.x || 0,
106
+ y: winPosition.position.y || 0,
107
+ };
108
+ }
109
+ if (winSize?.size) {
110
+ windowConfig.size = {
111
+ width: winSize.size.width || 1280,
112
+ height: winSize.size.height || 720,
113
+ };
114
+ }
115
+ if (headless !== undefined) {
116
+ windowConfig.headless = headless;
117
+ }
118
+ const instance = await browserManager.startProfile(profileId, windowConfig);
119
+ returnData.push({
120
+ json: {
121
+ success: true,
122
+ profileId: instance.profileId,
123
+ debugPort: instance.debugPort,
124
+ message: 'Profile started successfully',
125
+ },
126
+ });
127
+ }
128
+ catch (error) {
129
+ returnData.push({
130
+ json: {
131
+ success: false,
132
+ error: error instanceof Error ? error.message : String(error),
133
+ },
134
+ });
135
+ }
136
+ }
137
+ return [returnData];
138
+ }
139
+ }
140
+ exports.StartProfile = StartProfile;
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M9 9l5 12 1.774-5.226L21 14 9 9z"></path>
3
+ <path d="M21 3l-3.5 3.5"></path>
4
+ </svg>
5
+