ewvjs 1.0.10 → 1.0.12
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/README.md +69 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/window.d.ts +1 -1
- package/dist/window.d.ts.map +1 -1
- package/dist/window.js +4 -1
- package/native/WebView.dll +0 -0
- package/package.json +6 -4
- package/native/Microsoft.Web.WebView2.Wpf.dll +0 -0
package/README.md
CHANGED
|
@@ -143,10 +143,42 @@ Once a window is created, you can control it using the returned `Window` instanc
|
|
|
143
143
|
* **Interaction**:
|
|
144
144
|
* `setTitle(title)`
|
|
145
145
|
* `showTitlebar()`, `hideTitlebar()`
|
|
146
|
-
* `evaluate(script)`: Execute JavaScript in the WebView.
|
|
146
|
+
* `evaluate(script, [frame])`: Execute JavaScript in the WebView or target a specific subframe/iframe context.
|
|
147
147
|
* `setIcon(path)`
|
|
148
148
|
* **Cookies**: `getCookies()`, `setCookie(name, value, domain, path)`, `clearCookies()`
|
|
149
149
|
|
|
150
|
+
### Executing JavaScript inside IFrames (Cross-Origin Bypass)
|
|
151
|
+
|
|
152
|
+
The `evaluate` method supports executing and injecting JavaScript directly inside any subframe/iframe context, completely bypassing standard browser Same-Origin Policy (SOP) limitations. This enables the native Node.js layer to inspect and mutate the DOM of cross-origin or same-origin subframes natively.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
async evaluate(script: string, frame?: string | number): Promise<any>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Parameters:
|
|
159
|
+
* `script`: The JavaScript code string to execute.
|
|
160
|
+
* `frame` *(optional)*: The target subframe selector. This can be:
|
|
161
|
+
* **String**: The iframe's `name` attribute value (case-insensitive) or a substring of the iframe's loaded `src` URL.
|
|
162
|
+
* **Number**: The internal unique frame registry identifier.
|
|
163
|
+
|
|
164
|
+
#### Example:
|
|
165
|
+
```javascript
|
|
166
|
+
// Execute on top-level main document
|
|
167
|
+
const title = await win.evaluate("document.title");
|
|
168
|
+
|
|
169
|
+
// Execute inside a cross-origin iframe using its frame name
|
|
170
|
+
const iframeText = await win.evaluate(
|
|
171
|
+
"document.querySelector('h1').innerText",
|
|
172
|
+
"my-frame-name"
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// Execute inside an iframe targeted by its loaded URL substring
|
|
176
|
+
await win.evaluate(
|
|
177
|
+
"document.body.style.background = '#8b5cf6'",
|
|
178
|
+
"example.com/payment"
|
|
179
|
+
);
|
|
180
|
+
```
|
|
181
|
+
|
|
150
182
|
### Custom Context Menus
|
|
151
183
|
|
|
152
184
|
Define native context menus using `on_context_menu`. It should return an array of `ContextMenuItem` objects.
|
|
@@ -196,25 +228,53 @@ Create a new ewvjs project with a sample application structure.
|
|
|
196
228
|
|
|
197
229
|
**Usage:**
|
|
198
230
|
```bash
|
|
199
|
-
npx ewvjs-cli init [name]
|
|
231
|
+
npx ewvjs-cli init [name] [options]
|
|
200
232
|
```
|
|
201
233
|
|
|
202
234
|
**Arguments:**
|
|
203
235
|
* `name` - Project name (default: `my-ewvjs-app`)
|
|
204
236
|
|
|
237
|
+
**Options:**
|
|
238
|
+
* `-t, --template <template>` - Template to initialize (`basic` | `react`) (default: `basic`)
|
|
239
|
+
* `-l, --list-templates` - List all available templates
|
|
240
|
+
|
|
205
241
|
**Example:**
|
|
206
242
|
```bash
|
|
207
|
-
npx ewvjs-cli init my-awesome-app
|
|
243
|
+
npx ewvjs-cli init my-awesome-app --template react
|
|
208
244
|
cd my-awesome-app
|
|
209
245
|
npm install
|
|
210
|
-
npm
|
|
246
|
+
npm run dev
|
|
211
247
|
```
|
|
212
248
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
249
|
+
### Project Templates
|
|
250
|
+
|
|
251
|
+
`ewvjs-cli` supports two official templates out of the box:
|
|
252
|
+
|
|
253
|
+
#### 1. Basic Template (`basic` - default)
|
|
254
|
+
A simple, lightweight setup using plain static assets:
|
|
255
|
+
- **`app.js`**: Main host controller containing standard Node.js exposure hooks.
|
|
256
|
+
- **`assets/`**: Pure HTML/CSS/JS frontend files loaded natively via `file://` resolution.
|
|
257
|
+
|
|
258
|
+
#### 2. React Template (`react`)
|
|
259
|
+
A premium, feature-rich React 19 + Vite 8 + TypeScript development environment:
|
|
260
|
+
- **Vite Bundler**: Ultra-fast build times and hot-reload configs.
|
|
261
|
+
- **Premium Styling**: Pre-configured global CSS resets, sleek glassmorphic themes, and linear gradients styled around the **Outfit** Google Font.
|
|
262
|
+
- **HMR Developer Runner**: Spawns a parallel Vite developer server and embeds it directly into the native ewvjs window, rendering real-time UI changes dynamically as you edit.
|
|
263
|
+
- **Type-Safe Host API**: Employs global typed window definitions for fully intelligent, warning-free React-to-Node API communications.
|
|
264
|
+
|
|
265
|
+
**React Workflow Commands:**
|
|
266
|
+
```bash
|
|
267
|
+
# Initialize a new React project
|
|
268
|
+
npx ewvjs-cli init my-react-app --template react
|
|
269
|
+
cd my-react-app
|
|
270
|
+
npm install
|
|
271
|
+
|
|
272
|
+
# Run the HMR interactive developer window
|
|
273
|
+
npm run dev
|
|
274
|
+
|
|
275
|
+
# Compile React static outputs and build a standalone packaged exe
|
|
276
|
+
npm run package
|
|
277
|
+
```
|
|
218
278
|
|
|
219
279
|
---
|
|
220
280
|
|
|
@@ -240,7 +300,6 @@ npx ewvjs-cli package <entry> [options]
|
|
|
240
300
|
| `--assets <dir>` | `-a` | Assets directory to include in package | `./assets` |
|
|
241
301
|
| `--target <target>` | `-t` | Target platform | `node18-win-x64` |
|
|
242
302
|
| `--modules <modules>` | `-m` | Additional node modules to bundle (comma-separated) | None |
|
|
243
|
-
| `--no-native` | | Skip bundling native DLLs (if already included) | Includes by default |
|
|
244
303
|
|
|
245
304
|
**Examples:**
|
|
246
305
|
|
|
@@ -257,7 +316,6 @@ npx ewvjs-cli package app.js \
|
|
|
257
316
|
--icon icon.ico \
|
|
258
317
|
--assets ./public \
|
|
259
318
|
--modules axios,lodash \
|
|
260
|
-
--compress
|
|
261
319
|
```
|
|
262
320
|
|
|
263
321
|
Package with custom target:
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+BA,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,QAAA,MAAM,KAAK,SAAgB,CAAC;AAC5B,eAAe,KAAK,CAAC;AAGrB,eAAO,MAAM,aAAa,8HAAkC,CAAC;AAC7D,eAAO,MAAM,KAAK,qBAA0B,CAAC;AAC7C,eAAO,MAAM,MAAM,wCAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,13 @@ if (isPkg) {
|
|
|
15
15
|
// Since pkg locks Module properties, we need to intercept requires at a higher level
|
|
16
16
|
// Add the node_modules path to require.resolve paths by modifying module.paths
|
|
17
17
|
// This needs to be done for every module, so we'll hook into the module creation
|
|
18
|
-
|
|
19
|
-
require.main.paths
|
|
18
|
+
try {
|
|
19
|
+
if (typeof require !== 'undefined' && require.main !== 'undefined' && require.main.paths) {
|
|
20
|
+
require.main.paths.unshift(nodeModulesPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
// Ignore ReferenceError in pure ES module environments
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
}
|
package/dist/window.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Window {
|
|
|
17
17
|
get is_closed(): boolean;
|
|
18
18
|
run(): Promise<any>;
|
|
19
19
|
private _call;
|
|
20
|
-
evaluate(script: string): Promise<any>;
|
|
20
|
+
evaluate(script: string, frame?: string | number): Promise<any>;
|
|
21
21
|
close(): Promise<any>;
|
|
22
22
|
destroy(): Promise<any>;
|
|
23
23
|
maximize(): Promise<any>;
|
package/dist/window.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D,qBAAa,MAAM;IAClB,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IAEvB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,oBAAoB,CAAuB;IAEnD,eAAe,EAAE,CAChB,KAAK,EAAE,GAAG,EAAE,KACR,eAAe,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,CAC3D;gBAGL,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE;IAkB9C,IAAI,MAAM,kBAET;IAED,IAAI,SAAS,YAEZ;IAEK,GAAG;YAmBK,KAAK;IAoCb,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D,qBAAa,MAAM;IAClB,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,aA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,UAAU;IAGV,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAW,EACnB,IAAI,GAAE,MAAY;IAIb,YAAY;YAIJ,WAAW;IAkEzB,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,gBAAgB;YAOV,kBAAkB;YAYlB,sBAAsB;YAmBtB,oBAAoB;YAUpB,kBAAkB;IAUhC,OAAO,CAAC,YAAY;CAkBpB"}
|
package/dist/window.js
CHANGED
|
@@ -77,7 +77,10 @@ export class Window {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
// Core methods
|
|
80
|
-
async evaluate(script) {
|
|
80
|
+
async evaluate(script, frame) {
|
|
81
|
+
if (frame !== undefined) {
|
|
82
|
+
return this._call("evaluate", { script, frame });
|
|
83
|
+
}
|
|
81
84
|
return this._call("evaluate", script);
|
|
82
85
|
}
|
|
83
86
|
async close() {
|
package/native/WebView.dll
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ewvjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Embedded WebView for JavaScript - Edge WebView2 bindings for Node.js",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"packages/*"
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"import": "./dist/index.js"
|
|
15
|
-
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
18
20
|
"dist/**/*",
|
|
@@ -53,4 +55,4 @@
|
|
|
53
55
|
"mime-types": "^3.0.2",
|
|
54
56
|
"node-api-dotnet": "^0.9.19"
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|
|
Binary file
|