@puth/core 0.0.0 → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Copyright (c) 2020-2024 Sebastian Uehlin
2
+
3
+ All rights reserved.
package/dist/index.cjs ADDED
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var ContextStatus = /* @__PURE__ */ ((ContextStatus2) => {
4
+ ContextStatus2["SUCCESSFUL"] = "successful";
5
+ ContextStatus2["FAILED"] = "failed";
6
+ ContextStatus2["PENDING"] = "pending";
7
+ return ContextStatus2;
8
+ })(ContextStatus || {});
9
+ var SnapshotMode = /* @__PURE__ */ ((SnapshotMode2) => {
10
+ SnapshotMode2["FRAME"] = "frame";
11
+ SnapshotMode2["DOM"] = "dom";
12
+ return SnapshotMode2;
13
+ })(SnapshotMode || {});
14
+ var SnapshotState = /* @__PURE__ */ ((SnapshotState2) => {
15
+ SnapshotState2["BEFORE"] = "before";
16
+ SnapshotState2["AFTER"] = "after";
17
+ SnapshotState2["REPLAY"] = "replay";
18
+ return SnapshotState2;
19
+ })(SnapshotState || {});
20
+
21
+ const Constructors = {
22
+ Page: "CdpPage",
23
+ Frame: "CdpFrame",
24
+ Browser: "CdpBrowser",
25
+ BrowserContext: "CdpBrowserContext",
26
+ JSHandle: "CdpJSHandle",
27
+ ElementHandle: "CdpElementHandle",
28
+ Session: "CdpSession",
29
+ // SessionImpl: 'CdpSessionImpl',
30
+ ConnectionAdapter: "CdpConnectionAdapter",
31
+ ClientAdapter: "CdpClientAdapter",
32
+ Mouse: "CdpMouse",
33
+ Keyboard: "CdpKeyboard",
34
+ Touchscreen: "CdpTouchscreen",
35
+ Target: "CdpTarget",
36
+ Context: "Context"
37
+ };
38
+ const ConstructorValues = Object.values(Constructors);
39
+
40
+ exports.ConstructorValues = ConstructorValues;
41
+ exports.Constructors = Constructors;
42
+ exports.ContextStatus = ContextStatus;
43
+ exports.SnapshotMode = SnapshotMode;
44
+ exports.SnapshotState = SnapshotState;
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
- export type IPacket = {
1
+ type IPacket = {
3
2
  id: string;
4
3
  type: string;
5
4
  context: IContext;
6
5
  timestamp: number;
7
6
  };
8
- export type IViewport = {
7
+ type IViewport = {
9
8
  width: number;
10
9
  height: number;
11
10
  deviceScaleFactor?: number;
@@ -13,7 +12,7 @@ export type IViewport = {
13
12
  isLandscape?: boolean;
14
13
  hasTouch?: boolean;
15
14
  };
16
- export type ICommand = IPacket & {
15
+ type ICommand = IPacket & {
17
16
  type: 'command';
18
17
  snapshots: {
19
18
  before: ISnapshot | undefined;
@@ -33,22 +32,22 @@ export type ICommand = IPacket & {
33
32
  finished: number;
34
33
  };
35
34
  };
36
- export declare enum ContextStatus {
35
+ declare enum ContextStatus {
37
36
  SUCCESSFUL = "successful",
38
37
  FAILED = "failed",
39
38
  PENDING = "pending"
40
39
  }
41
- export type CommandProps = {
40
+ type CommandProps = {
42
41
  index: number | undefined;
43
42
  command: ICommand;
44
43
  showTimings: boolean;
45
44
  };
46
- export type IBlobHandle = {
45
+ type IBlobHandle = {
47
46
  blob: Blob;
48
47
  url?: string;
49
48
  options?: BlobPropertyBag;
50
49
  };
51
- export type IContext = {
50
+ type IContext = {
52
51
  id: string;
53
52
  type: string;
54
53
  represents: string;
@@ -58,14 +57,14 @@ export type IContext = {
58
57
  };
59
58
  group: string | undefined;
60
59
  };
61
- export type IPageInclude = {
60
+ type IPageInclude = {
62
61
  url: string;
63
62
  method: string;
64
63
  resourceType: string;
65
64
  content: Buffer;
66
65
  headers: Record<string, string>;
67
66
  };
68
- export type ISnapshot = {
67
+ type ISnapshot = {
69
68
  type: 'snapshot';
70
69
  data?: any;
71
70
  version: number;
@@ -74,16 +73,16 @@ export type ISnapshot = {
74
73
  isJavascriptEnabled: boolean;
75
74
  includes?: IPageInclude[];
76
75
  };
77
- export declare enum SnapshotMode {
76
+ declare enum SnapshotMode {
78
77
  FRAME = "frame",
79
78
  DOM = "dom"
80
79
  }
81
- export declare enum SnapshotState {
80
+ declare enum SnapshotState {
82
81
  BEFORE = "before",
83
82
  AFTER = "after",
84
83
  REPLAY = "replay"
85
84
  }
86
- export type IResponse = IPacket & {
85
+ type IResponse = IPacket & {
87
86
  type: 'response';
88
87
  time: number;
89
88
  isNavigationRequest: boolean;
@@ -95,13 +94,13 @@ export type IResponse = IPacket & {
95
94
  };
96
95
  content: Uint8Array;
97
96
  };
98
- export type ILogLocation = {
97
+ type ILogLocation = {
99
98
  url?: string;
100
99
  lineNumber?: number;
101
100
  columnNumber?: number;
102
101
  };
103
- export type IConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
104
- export type ILog = {
102
+ type IConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
103
+ type ILog = {
105
104
  type: 'log';
106
105
  context: {};
107
106
  time: number;
@@ -111,17 +110,38 @@ export type ILog = {
111
110
  text: string;
112
111
  stackTrace: ILogLocation[];
113
112
  };
114
- export type ICommandError = {
113
+ type ICommandError = {
115
114
  type: string;
116
115
  specific?: string;
117
116
  error?: Error;
118
117
  expectation?: IExpectation;
119
118
  time: number;
120
119
  };
121
- export type IExpectation = {
120
+ type IExpectation = {
122
121
  test: (value: any) => boolean;
123
122
  message: string;
124
123
  };
125
- export type IExpects = {
124
+ type IExpects = {
126
125
  [key: string]: IExpectation;
127
126
  };
127
+
128
+ declare const Constructors: {
129
+ Page: string;
130
+ Frame: string;
131
+ Browser: string;
132
+ BrowserContext: string;
133
+ JSHandle: string;
134
+ ElementHandle: string;
135
+ Session: string;
136
+ ConnectionAdapter: string;
137
+ ClientAdapter: string;
138
+ Mouse: string;
139
+ Keyboard: string;
140
+ Touchscreen: string;
141
+ Target: string;
142
+ Context: string;
143
+ };
144
+ declare const ConstructorValues: string[];
145
+
146
+ export { ConstructorValues, Constructors, ContextStatus, SnapshotMode, SnapshotState };
147
+ export type { CommandProps, IBlobHandle, ICommand, ICommandError, IConsoleMessageType, IContext, IExpectation, IExpects, ILog, ILogLocation, IPacket, IPageInclude, IResponse, ISnapshot, IViewport };
@@ -0,0 +1,147 @@
1
+ type IPacket = {
2
+ id: string;
3
+ type: string;
4
+ context: IContext;
5
+ timestamp: number;
6
+ };
7
+ type IViewport = {
8
+ width: number;
9
+ height: number;
10
+ deviceScaleFactor?: number;
11
+ isMobile?: boolean;
12
+ isLandscape?: boolean;
13
+ hasTouch?: boolean;
14
+ };
15
+ type ICommand = IPacket & {
16
+ type: 'command';
17
+ snapshots: {
18
+ before: ISnapshot | undefined;
19
+ after: ISnapshot | undefined;
20
+ };
21
+ errors: ICommandError[];
22
+ func: string;
23
+ args: string[];
24
+ on: {
25
+ type: string;
26
+ path: [[string, number][] | string][];
27
+ };
28
+ time: {
29
+ started: number;
30
+ elapsed: number;
31
+ took?: number;
32
+ finished: number;
33
+ };
34
+ };
35
+ declare enum ContextStatus {
36
+ SUCCESSFUL = "successful",
37
+ FAILED = "failed",
38
+ PENDING = "pending"
39
+ }
40
+ type CommandProps = {
41
+ index: number | undefined;
42
+ command: ICommand;
43
+ showTimings: boolean;
44
+ };
45
+ type IBlobHandle = {
46
+ blob: Blob;
47
+ url?: string;
48
+ options?: BlobPropertyBag;
49
+ };
50
+ type IContext = {
51
+ id: string;
52
+ type: string;
53
+ represents: string;
54
+ test: {
55
+ name: string;
56
+ status: ContextStatus.FAILED | ContextStatus.SUCCESSFUL | ContextStatus.PENDING;
57
+ };
58
+ group: string | undefined;
59
+ };
60
+ type IPageInclude = {
61
+ url: string;
62
+ method: string;
63
+ resourceType: string;
64
+ content: Buffer;
65
+ headers: Record<string, string>;
66
+ };
67
+ type ISnapshot = {
68
+ type: 'snapshot';
69
+ data?: any;
70
+ version: number;
71
+ url: any;
72
+ viewport: IViewport | null;
73
+ isJavascriptEnabled: boolean;
74
+ includes?: IPageInclude[];
75
+ };
76
+ declare enum SnapshotMode {
77
+ FRAME = "frame",
78
+ DOM = "dom"
79
+ }
80
+ declare enum SnapshotState {
81
+ BEFORE = "before",
82
+ AFTER = "after",
83
+ REPLAY = "replay"
84
+ }
85
+ type IResponse = IPacket & {
86
+ type: 'response';
87
+ time: number;
88
+ isNavigationRequest: boolean;
89
+ url: string;
90
+ resourceType: string;
91
+ method: string;
92
+ headers: {
93
+ [key: string]: string;
94
+ };
95
+ content: Uint8Array;
96
+ };
97
+ type ILogLocation = {
98
+ url?: string;
99
+ lineNumber?: number;
100
+ columnNumber?: number;
101
+ };
102
+ type IConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
103
+ type ILog = {
104
+ type: 'log';
105
+ context: {};
106
+ time: number;
107
+ messageType: IConsoleMessageType;
108
+ args: any[];
109
+ location: ILogLocation;
110
+ text: string;
111
+ stackTrace: ILogLocation[];
112
+ };
113
+ type ICommandError = {
114
+ type: string;
115
+ specific?: string;
116
+ error?: Error;
117
+ expectation?: IExpectation;
118
+ time: number;
119
+ };
120
+ type IExpectation = {
121
+ test: (value: any) => boolean;
122
+ message: string;
123
+ };
124
+ type IExpects = {
125
+ [key: string]: IExpectation;
126
+ };
127
+
128
+ declare const Constructors: {
129
+ Page: string;
130
+ Frame: string;
131
+ Browser: string;
132
+ BrowserContext: string;
133
+ JSHandle: string;
134
+ ElementHandle: string;
135
+ Session: string;
136
+ ConnectionAdapter: string;
137
+ ClientAdapter: string;
138
+ Mouse: string;
139
+ Keyboard: string;
140
+ Touchscreen: string;
141
+ Target: string;
142
+ Context: string;
143
+ };
144
+ declare const ConstructorValues: string[];
145
+
146
+ export { ConstructorValues, Constructors, ContextStatus, SnapshotMode, SnapshotState };
147
+ export type { CommandProps, IBlobHandle, ICommand, ICommandError, IConsoleMessageType, IContext, IExpectation, IExpects, ILog, ILogLocation, IPacket, IPageInclude, IResponse, ISnapshot, IViewport };
package/dist/index.mjs ADDED
@@ -0,0 +1,38 @@
1
+ var ContextStatus = /* @__PURE__ */ ((ContextStatus2) => {
2
+ ContextStatus2["SUCCESSFUL"] = "successful";
3
+ ContextStatus2["FAILED"] = "failed";
4
+ ContextStatus2["PENDING"] = "pending";
5
+ return ContextStatus2;
6
+ })(ContextStatus || {});
7
+ var SnapshotMode = /* @__PURE__ */ ((SnapshotMode2) => {
8
+ SnapshotMode2["FRAME"] = "frame";
9
+ SnapshotMode2["DOM"] = "dom";
10
+ return SnapshotMode2;
11
+ })(SnapshotMode || {});
12
+ var SnapshotState = /* @__PURE__ */ ((SnapshotState2) => {
13
+ SnapshotState2["BEFORE"] = "before";
14
+ SnapshotState2["AFTER"] = "after";
15
+ SnapshotState2["REPLAY"] = "replay";
16
+ return SnapshotState2;
17
+ })(SnapshotState || {});
18
+
19
+ const Constructors = {
20
+ Page: "CdpPage",
21
+ Frame: "CdpFrame",
22
+ Browser: "CdpBrowser",
23
+ BrowserContext: "CdpBrowserContext",
24
+ JSHandle: "CdpJSHandle",
25
+ ElementHandle: "CdpElementHandle",
26
+ Session: "CdpSession",
27
+ // SessionImpl: 'CdpSessionImpl',
28
+ ConnectionAdapter: "CdpConnectionAdapter",
29
+ ClientAdapter: "CdpClientAdapter",
30
+ Mouse: "CdpMouse",
31
+ Keyboard: "CdpKeyboard",
32
+ Touchscreen: "CdpTouchscreen",
33
+ Target: "CdpTarget",
34
+ Context: "Context"
35
+ };
36
+ const ConstructorValues = Object.values(Constructors);
37
+
38
+ export { ConstructorValues, Constructors, ContextStatus, SnapshotMode, SnapshotState };
package/package.json CHANGED
@@ -1,12 +1,29 @@
1
1
  {
2
2
  "name": "@puth/core",
3
- "main": "./lib/index.js",
4
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
+ "author": {
5
+ "name": "Sebastian Uehlin",
6
+ "email": "s.uehlin@proton.me"
7
+ },
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.cts",
11
+ "exports": {
12
+ "require": {
13
+ "types": "./dist/index.d.cts",
14
+ "default": "./dist/index.cjs"
15
+ },
16
+ "import": {
17
+ "types": "./dist/index.d.mts",
18
+ "default": "./dist/index.mjs"
19
+ }
20
+ },
5
21
  "scripts": {
6
- "build": "tsc --build",
22
+ "build": "pkgroll --clean-dist",
7
23
  "prepublishOnly": "npm run build"
8
24
  },
9
25
  "files": [
10
- "lib/"
26
+ "dist/",
27
+ "LICENCE"
11
28
  ]
12
29
  }
package/lib/Types.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SnapshotState = exports.SnapshotMode = exports.ContextStatus = void 0;
4
- var ContextStatus;
5
- (function (ContextStatus) {
6
- ContextStatus["SUCCESSFUL"] = "successful";
7
- ContextStatus["FAILED"] = "failed";
8
- ContextStatus["PENDING"] = "pending";
9
- })(ContextStatus = exports.ContextStatus || (exports.ContextStatus = {}));
10
- var SnapshotMode;
11
- (function (SnapshotMode) {
12
- SnapshotMode["FRAME"] = "frame";
13
- SnapshotMode["DOM"] = "dom";
14
- })(SnapshotMode = exports.SnapshotMode || (exports.SnapshotMode = {}));
15
- var SnapshotState;
16
- (function (SnapshotState) {
17
- SnapshotState["BEFORE"] = "before";
18
- SnapshotState["AFTER"] = "after";
19
- SnapshotState["REPLAY"] = "replay";
20
- })(SnapshotState = exports.SnapshotState || (exports.SnapshotState = {}));
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './Types';
package/lib/index.js DELETED
@@ -1,17 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Types"), exports);