Skip to content

Commit 5fc5127

Browse files
committed
export typedefs for scramjet controller
1 parent fd34bc7 commit 5fc5127

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

lib/index.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
declare const scramjetPath: string;
22

3+
import * as controller from "../dist/types/controller/index.ts";
4+
import * as types from "../dist/types/types.ts";
5+
import * as frame from "../dist/types/controller/frame.ts";
6+
7+
declare global {
8+
const ScramjetController: typeof controller.ScramjetController;
9+
const ScramjetFrame: typeof frame.ScramjetFrame;
10+
11+
type ScramjetConfig = types.ScramjetConfig;
12+
type ScramjetInitConfig = types.ScramjetInitConfig;
13+
}
314
export { scramjetPath };

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
1515
"dev": "node server.js",
1616
"dev:debug": "DEBUG=1 node server.js",
17-
"prepack": "RELEASE=1 npm run rewriter:build && npm run build",
17+
"prepack": "RELEASE=1 npm run rewriter:build && tsc && npm run build",
1818
"pub": "npm publish --no-git-checks --access public",
1919
"format": "prettier --write .",
2020
"lint": "eslint ./src/",

src/types.d.ts renamed to src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ScramjetClient } from "./client/client";
2424
import { ScramjetFrame } from "./controller/frame";
2525
import { Rewriter } from "./shared/rewriters/wasm";
2626

27-
type ScramjetFlags = {
27+
export type ScramjetFlags = {
2828
serviceworkers: boolean;
2929
syncxhr: boolean;
3030
naiiveRewriter: boolean;
@@ -36,7 +36,7 @@ type ScramjetFlags = {
3636
sourcemaps: boolean;
3737
};
3838

39-
interface ScramjetConfig {
39+
export interface ScramjetConfig {
4040
prefix: string;
4141
globals: {
4242
wrapfn: string;
@@ -63,7 +63,7 @@ interface ScramjetConfig {
6363
};
6464
}
6565

66-
interface ScramjetInitConfig extends ScramjetConfig {
66+
export interface ScramjetInitConfig extends Omit<ScramjetConfig, "codec"> {
6767
codec: {
6868
encode: (url: string) => string;
6969
decode: (url: string) => string;

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"target": "ES2022",
66
"moduleResolution": "Bundler",
77
"module": "ES2022",
8-
"noEmit": true,
9-
"skipLibCheck": true
8+
"skipLibCheck": true,
9+
"declaration": true,
10+
"declarationDir": "./dist/types",
11+
"emitDeclarationOnly": true,
1012
},
1113
"include": [
1214
"src"

0 commit comments

Comments
 (0)