Skip to content

Commit

Permalink
enable typechecking, expose types to users
Browse files Browse the repository at this point in the history
  • Loading branch information
mildsunrise authored and murillo128 committed Oct 31, 2023
1 parent 5037640 commit 92628ee
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from "./build/types/RTMPServer";

export type { default as Server } from "./build/types/Server";
export type { default as Application } from "./build/types/Application";
export type { default as Client } from "./build/types/Client";
export type { default as Stream, AMFData, Command } from "./build/types/Stream";
export type { default as IncomingStreamBridge, StreamStats } from "./build/types/IncomingStreamBridge";

export type {
default as IncomingStreamTrackBridge,
ActiveEncodingInfo, ActiveLayersInfo,
EncodingStats, LayerStats, MediaStats, PacketWaitTime, TrackStats,
} from "./build/types/IncomingStreamTrackBridge";
5 changes: 2 additions & 3 deletions lib/RTMPServer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const Native = require("./Native.js");
const Server = require("./Server.js");
const Application = require("./Application.js");
const Status = require("./Status.js");
const IncomingStreamBridge = require("./IncomingStreamBridge");

/** @typedef {import("./Status").Status} Status */

/** @namespace */
const RTMPServer = {};
RTMPServer.NetStream = Status.NetStream;
RTMPServer.NetConnection = Status.NetConnection;
RTMPServer.NetStream = require("./Status.js").NetStream;
RTMPServer.NetConnection = require("./Status.js").NetConnection;

//INitialize Stuff
Native.RTMPServerModule.Initialize();
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"description": "RTMP Server by Medooze",
"main": "index.js",
"scripts": {
"prepare": "tsc --checkJs false",
"check": "tsc --noEmit --emitDeclarationOnly false",
"configure": "node-gyp configure",
"swig": "swig -javascript -node -c++ src/rtmp-server.i",
"build": "node-gyp build --jobs=max",
"install": "test -f build/Release/medooze-rtmp-server.node || (node-gyp configure && node-gyp rebuild --jobs=max)",
"package": "tar cvzf build/medooze-rtmp-server.tgz `([ \"$(uname)\" = 'Darwin' ] && echo \"-s |^|medooze-rtmp-server/|\") || echo \" --transform=flags=r;s|^|medooze-rtmp-server/|\"` media-server/src/* media-server/include/* media-server/ext/libdatachannels/src/* media-server/ext/crc32c/* lib/* package.json index.js binding.gyp README.md src",
"dist": "node-gyp configure && node-gyp build --jobs=max && mkdir -p dist && tar cvzf dist/medooze-rtmp-server-`node -e 'console.log(require(\"./package.json\").version)'`.tgz `([ \"$(uname)\" = 'Darwin' ] && echo \"-s |^|medooze-rtmp-server/|\") || echo \" --transform=flags=r;s|^|medooze-rtmp-server/|\"` package.json index.js README.md lib/* build/Release/medooze-rtmp-server.node",
"package": "npm run prepare && tar cvzf build/medooze-rtmp-server.tgz `([ \"$(uname)\" = 'Darwin' ] && echo \"-s |^|medooze-rtmp-server/|\") || echo \" --transform=flags=r;s|^|medooze-rtmp-server/|\"` media-server/src/* media-server/include/* media-server/ext/libdatachannels/src/* media-server/ext/crc32c/* lib/* package.json index.js index.d.ts build/types binding.gyp README.md src",
"dist": "npm run configure && npm run build && npm run prepare && mkdir -p dist && tar cvzf dist/medooze-rtmp-server-`node -e 'console.log(require(\"./package.json\").version)'`.tgz `([ \"$(uname)\" = 'Darwin' ] && echo \"-s |^|medooze-rtmp-server/|\") || echo \" --transform=flags=r;s|^|medooze-rtmp-server/|\"` package.json index.js index.d.ts build/types README.md lib/* build/Release/medooze-rtmp-server.node",
"test": "tap tests/*.js --cov --no-check-coverage"
},
"repository": {
Expand All @@ -33,5 +35,10 @@
"nan": "^2.12.1",
"tap": "^16.3.2",
"uuid": "^3.3.2"
},
"devDependencies": {
"@types/node": "^20.8.6",
"@types/uuid": "^9.0.5",
"typescript": "^5.2.2"
}
}
17 changes: 17 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"include": ["lib/**/*"],
"compilerOptions": {
"lib": ["ES2018"],
"target": "ES2018",
"module": "CommonJS",
"moduleResolution": "Node",
"allowJs": true,
"checkJs": true,
"strict": true,
"noImplicitAny": true,
"outDir": "build/types",
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true
}
}

0 comments on commit 92628ee

Please sign in to comment.