ewvjs 1.0.17 → 1.0.19

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/dist/js/api.js CHANGED
@@ -333,11 +333,11 @@ window.ewvjs = {
333
333
  }, 10);
334
334
  },
335
335
 
336
- _callWindowMethod: function (methodName) {
336
+ _callWindowMethod: function (methodName, args) {
337
337
  var __id = (Math.random() + "").substring(2);
338
338
  window.chrome.webview.postMessage([
339
339
  'window_' + methodName,
340
- '[]',
340
+ JSON.stringify(args || []),
341
341
  __id
342
342
  ]);
343
343
  },
@@ -367,38 +367,23 @@ window.ewvjs._hookDrag();
367
367
  window.ewvjs._hookResize();
368
368
 
369
369
  // Add window state methods directly to window object
370
- window.close = function () {
371
- window.ewvjs._callWindowMethod('close');
372
- };
373
-
374
- window.maximize = function () {
375
- window.ewvjs._callWindowMethod('maximize');
376
- };
377
-
378
- window.restore = function () {
379
- window.ewvjs._callWindowMethod('restore');
380
- };
381
-
382
- window.minimize = function () {
383
- window.ewvjs._callWindowMethod('minimize');
384
- };
385
-
386
- window.focus = function () {
387
- window.ewvjs._callWindowMethod('focus');
388
- };
389
-
390
- window.show = function () {
391
- window.ewvjs._callWindowMethod('show');
392
- };
393
-
394
- window.hide = function () {
395
- window.ewvjs._callWindowMethod('hide');
396
- };
397
-
398
- window.resize = function () {
399
- window.ewvjs._callWindowMethod('resize');
400
- };
370
+ function defineWindowMethod(name) {
371
+ var fn = function () {
372
+ var args = Array.prototype.slice.call(arguments);
373
+ window.ewvjs._callWindowMethod(name, args);
374
+ };
375
+ try {
376
+ Object.defineProperty(window, name, {
377
+ value: fn,
378
+ writable: true,
379
+ configurable: true
380
+ });
381
+ } catch (e) {
382
+ window[name] = fn;
383
+ }
384
+ }
401
385
 
402
- window.move = function () {
403
- window.ewvjs._callWindowMethod('move');
404
- };
386
+ var methods = ['close', 'maximize', 'restore', 'minimize', 'focus', 'show', 'hide', 'resize', 'move'];
387
+ for (var i = 0; i < methods.length; i++) {
388
+ defineWindowMethod(methods[i]);
389
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../../src/platforms/windows.ts"],"names":[],"mappings":"AAaA,qBAAa,eAAe;;IAKxB,YAAY,CAAC,OAAO,EAAE,GAAG;CA0G5B"}
1
+ {"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../../src/platforms/windows.ts"],"names":[],"mappings":"AAaA,qBAAa,eAAe;;IAKxB,YAAY,CAAC,OAAO,EAAE,GAAG;CA6G5B"}
@@ -63,7 +63,10 @@ export class WindowsPlatform {
63
63
  if (_cachedApiScript === null) {
64
64
  _cachedApiScript = fs.readFileSync(apiPath, 'utf8');
65
65
  }
66
- const apiScript = _cachedApiScript.replace('%(token)s', token);
66
+ let apiScript = _cachedApiScript.replace('%(token)s', token);
67
+ if (options.exposedFunctionsList && options.exposedFunctionsList.length > 0) {
68
+ apiScript += `\nwindow.ewvjs._createApi(${JSON.stringify(options.exposedFunctionsList)});`;
69
+ }
67
70
  options.initScript = apiScript;
68
71
  // Handle messages from WebView
69
72
  options.onMessage = (message, callback) => {
package/dist/window.js CHANGED
@@ -46,7 +46,7 @@ export class Window {
46
46
  return this.controller;
47
47
  }
48
48
  async _call(method, payload = null) {
49
- if (this._isClosed) {
49
+ if (this._isClosed && method !== "close") {
50
50
  console.warn(`Cannot call ${method}: Window is closed`);
51
51
  return null;
52
52
  }
@@ -194,7 +194,7 @@ export class Window {
194
194
  if (funcName.startsWith("window_")) {
195
195
  const method = funcName.substring(7); // Remove 'window_' prefix
196
196
  if (typeof this[method] === "function") {
197
- await this[method]();
197
+ await this[method](...params);
198
198
  }
199
199
  return null;
200
200
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ewvjs",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Embedded WebView for JavaScript - Edge WebView2 bindings for Node.js",
5
5
  "workspaces": [
6
6
  "packages/*"