Skip to content

Commit b33fa05

Browse files
authored
Merge pull request #6 from BossSloth/improvements
Small type improvements and fixed the webkit package not building right again
2 parents 086cbe3 + 2dfc360 commit b33fa05

File tree

10 files changed

+60
-41
lines changed

10 files changed

+60
-41
lines changed

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.base.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"outDir": "build",
43
"module": "ESNext",
54
"target": "ES2021",
65
"jsx": "react",

typescript-packages/browser/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { constSysfsExpr } from "./shared/constSysfsExpr";
2+
13
declare global {
24
interface Window {
35
Millennium: Millennium;
@@ -7,7 +9,7 @@ declare global {
79
/** Returnable IPC types */
810
type IPC_types = string | number | boolean | void;
911
/*
10-
Global Millennium API for developers.
12+
Global Millennium API for developers.
1113
*/
1214
type Millennium = {
1315
/**
@@ -40,4 +42,5 @@ declare global {
4042
declare const BindPluginSettings: () => any;
4143

4244
const Millennium: Millennium = window.Millennium;
43-
export { Millennium, callable, BindPluginSettings };
45+
export { BindPluginSettings, callable, constSysfsExpr, Millennium };
46+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../shared

typescript-packages/browser/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"rootDir": "src"
4+
"outDir": "build",
5+
"rootDir": "src",
56
},
67
"include": ["**/*"],
78
"exclude": ["build"]

typescript-packages/client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@rollup/plugin-terser": "^0.4.4",
3838
"@rollup/plugin-typescript": "^11.1.6",
3939
"chalk": "^4.1.0",
40+
"devtools-protocol": "^0.0.1485358",
4041
"fs": "0.0.1-security",
4142
"path": "^0.12.7",
4243
"rollup": "^4.17.2",

typescript-packages/client/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
export * from './class-mapper';
2+
export * from './components';
13
export * from './custom-components';
24
export * from './custom-hooks';
3-
export * from './components';
45
export * from './deck-hooks';
5-
export * from './modules';
66
export * from './globals';
7-
export * from './webpack';
8-
export * from './utils';
9-
export * from './class-mapper';
107
export * from './millennium-api';
8+
export * from './modules';
9+
export * from './shared/constSysfsExpr';
10+
export * from './utils';
11+
export * from './webpack';
1112

1213
import ErrorBoundaryHook from './hooks/error-boundary-hook';
1314
import RouterHook from './hooks/router/router-hook';

typescript-packages/client/src/millennium-api.ts

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import ProtocolMapping from 'devtools-protocol/types/protocol-mapping';
2+
13
/** Returnable IPC types */
24
type IPC_types = string | number | boolean;
35

46
/*
5-
Global Millennium API for developers.
7+
Global Millennium API for developers.
68
*/
79
type Millennium = {
810
/**
@@ -55,34 +57,6 @@ declare global {
5557

5658
declare const BindPluginSettings: () => any;
5759

58-
interface FileInfo {
59-
content: string;
60-
filePath: string;
61-
fileName: string;
62-
}
63-
64-
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex';
65-
66-
interface SingleFileExprProps {
67-
basePath?: string;
68-
encoding?: BufferEncoding;
69-
}
70-
71-
interface MultiFileExprProps {
72-
basePath?: string;
73-
include?: string; // A regex pattern to include files
74-
encoding?: BufferEncoding;
75-
}
76-
77-
/**
78-
* Create a compile time filesystem expression.
79-
* This function will evaluate a file path at compile time, and embed a files content statically into the bundle.
80-
*/
81-
declare const constSysfsExpr: {
82-
(fileName: string, props: SingleFileExprProps): FileInfo;
83-
(props: MultiFileExprProps): FileInfo[];
84-
};
85-
8660
interface CDPMessage {
8761
id?: number;
8862
method: string;
@@ -130,7 +104,7 @@ class MillenniumChromeDevToolsProtocol {
130104
}
131105
}
132106

133-
send(method: string, params: any = {}, sessionId?: string) {
107+
send<T extends keyof ProtocolMapping.Commands>(method: T, params: ProtocolMapping.Commands[T]['paramsType'][0] = {}, sessionId?: string): Promise<ProtocolMapping.Commands[T]['returnType']> {
134108
return new Promise((resolve, reject) => {
135109
const id = this.currentId++;
136110

@@ -165,7 +139,7 @@ class MillenniumChromeDevToolsProtocol {
165139
}
166140

167141
// Helper method to send without waiting for response (fire and forget)
168-
sendNoResponse(method: string, params = {}) {
142+
sendNoResponse<T extends keyof ProtocolMapping.Commands>(method: T, params: ProtocolMapping.Commands[T]['paramsType'][0] = {}) {
169143
const message: CDPMessage = {
170144
id: this.currentId++,
171145
method: method,
@@ -181,4 +155,5 @@ class MillenniumChromeDevToolsProtocol {
181155

182156
const ChromeDevToolsProtocol: MillenniumChromeDevToolsProtocol = new MillenniumChromeDevToolsProtocol();
183157
const Millennium: Millennium = window.Millennium;
184-
export { ChromeDevToolsProtocol, Millennium, callable, BindPluginSettings, constSysfsExpr };
158+
export { BindPluginSettings, callable, ChromeDevToolsProtocol, Millennium };
159+

typescript-packages/client/src/shared

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../shared
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
interface FileInfo {
2+
content: string;
3+
filePath: string;
4+
fileName: string;
5+
}
6+
7+
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex';
8+
9+
interface SingleFileExprProps {
10+
basePath?: string;
11+
encoding?: BufferEncoding;
12+
}
13+
14+
interface MultiFileExprProps {
15+
basePath?: string;
16+
include?: string; // A regex pattern to include files
17+
encoding?: BufferEncoding;
18+
}
19+
20+
/**
21+
* Create a compile time filesystem expression.
22+
* This function will evaluate a file path at compile time, and embed a files content statically into the bundle.
23+
*/
24+
declare const constSysfsExpr: {
25+
(fileName: string, props: SingleFileExprProps): FileInfo;
26+
(props: MultiFileExprProps): FileInfo[];
27+
};
28+
29+
export { constSysfsExpr };

0 commit comments

Comments
 (0)