diff --git a/examples/html.js b/examples/html.js index cfd19e2..8d42f27 100644 --- a/examples/html.js +++ b/examples/html.js @@ -1,6 +1,6 @@ // const requireScript = require('node:module').createRequire(__filename); // const { Application } = requireScript('../index.js'); -const { Application } = require('../dist/index.js'); +const { Application } = require('../index.js'); const app = new Application(); diff --git a/examples/url.mjs b/examples/url.mjs index 87c9874..efc3632 100644 --- a/examples/url.mjs +++ b/examples/url.mjs @@ -1,4 +1,4 @@ -import { Application, Theme } from '../dist/index.js'; +import { Application, Theme } from '../index.js'; const app = new Application(); const window = app.createBrowserWindow({ diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..1ad8772 --- /dev/null +++ b/index.d.ts @@ -0,0 +1 @@ +export * from './binding'; diff --git a/index.js b/index.js new file mode 100644 index 0000000..40e25b6 --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +const { Application, BrowserWindow, ControlFlow, FullscreenType, ProgressBarState, Theme, getWebviewVersion } = require('./binding') + +module.exports = { + Application, + BrowserWindow, + ControlFlow, + FullscreenType, + ProgressBarState, + Theme, + getWebviewVersion +} \ No newline at end of file diff --git a/lib/index.ts b/lib/index.ts deleted file mode 100644 index 7760e95..0000000 --- a/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../binding.js'; diff --git a/package.json b/package.json index f7c1e31..7f2bf81 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "webviewjs": "./cli/index.mjs" }, "description": "Robust cross-platform webview library for Node.js written in Rust. It also works with deno and bun.", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", + "main": "./index.js", + "types": "./index.d.ts", "repository": "git@github.com:twlite/webview.git", "license": "MIT", "type": "commonjs", @@ -20,7 +20,8 @@ ], "files": [ "cli", - "dist", + "index.d.ts", + "index.js", "binding.d.ts", "binding.js" ], diff --git a/src/lib.rs b/src/lib.rs index fd2c331..785c41a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,9 @@ pub mod browser_window; #[napi(object)] pub struct HeaderData { + /// The key of the header. pub key: String, + /// The value of the header. pub value: Option, } @@ -109,6 +111,7 @@ impl Application { self.ipc_handler = handler; } + /// Handles the IPC message. fn handle_ipc_message(&self, req: Request, id: &u32) { let func = &self.ipc_handler.as_ref(); diff --git a/tsconfig.json b/tsconfig.json index 07b463e..5056788 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,14 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ESNext", "strict": true, "moduleResolution": "node", "module": "CommonJS", "noUnusedLocals": true, "noUnusedParameters": true, "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "declaration": true + "allowSyntheticDefaultImports": true }, - "include": ["./lib/**/*.ts"], + "include": ["."], "exclude": ["node_modules", "bench", "__test__"] }