Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kirjavascript committed Jan 18, 2023
1 parent fd75077 commit 8bcfc49
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 170 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## [unreleased]
## [1.2.0]
- Sprite Rotation
- Add zoom slider in sprites tab

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.4",
"version": "1.2.0",
"scripts": {
"start": "electron ./static --dev"
},
Expand Down
96 changes: 0 additions & 96 deletions scripts/Streets Of Rage 2.js

This file was deleted.

15 changes: 6 additions & 9 deletions static/remote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ configure your bundler appropriately to package the code of `@electron/remote`
in the preload script. Of course, [using `@electron/remote` makes the sandbox
much less effective][remote-considered-harmful].

**Note:** In `electron >= 14.0.0`, you must use the new `enable` API to enable the remote module for each desired `WebContents` separately: `require("@electron/remote/main").enable(webContents)`.

In `electron < 14.0.0`, `@electron/remote` respects the `enableRemoteModule` WebPreferences
**Note:** `@electron/remote` respects the `enableRemoteModule` WebPreferences
value. You must pass `{ webPreferences: { enableRemoteModule: true } }` to
the constructor of `BrowserWindow`s that should be granted permission to use
`@electron/remote`.


# API Reference

The `remote` module provides a simple way to do inter-process communication
Expand Down Expand Up @@ -86,9 +85,7 @@ of the remote module:
require('@electron/remote/main').initialize()
```

**Note:** In `electron >= 14.0.0` the remote module is disabled by default for any `WebContents` instance and is only enabled for specified `WebContents` after explicitly calling `require("@electron/remote/main").enable(webContents)`.

In `electron < 14.0.0` the remote module can be disabled for security reasons in the following contexts:
**Note:** The remote module can be disabled for security reasons in the following contexts:
- [`BrowserWindow`](browser-window.md) - by setting the `enableRemoteModule` option to `false`.
- [`<webview>`](webview-tag.md) - by setting the `enableremotemodule` attribute to `false`.

Expand Down Expand Up @@ -217,8 +214,8 @@ e.g.
```sh
project/
├── main
├── foo.js
└── index.js
   ├── foo.js
   └── index.js
├── package.json
└── renderer
└── index.js
Expand Down Expand Up @@ -342,4 +339,4 @@ Custom value can be returned by setting `event.returnValue`.

[rmi]: https://en.wikipedia.org/wiki/Java_remote_method_invocation
[enumerable-properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties
[remote-considered-harmful]: https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
[remote-considered-harmful]: https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
3 changes: 0 additions & 3 deletions static/remote/dist/src/common/module-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ exports.browserModuleNames = [
'powerMonitor',
'powerSaveBlocker',
'protocol',
'pushNotifications',
'safeStorage',
'screen',
'session',
'ShareMenu',
'systemPreferences',
'TopLevelWindow',
'TouchBar',
'Tray',
'utilityProcess',
'View',
'webContents',
'WebContentsView',
Expand Down
2 changes: 1 addition & 1 deletion static/remote/dist/src/main/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { initialize, enable } from "./server";
export { initialize } from './server';
3 changes: 1 addition & 2 deletions static/remote/dist/src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.enable = exports.initialize = void 0;
exports.initialize = void 0;
var server_1 = require("./server");
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return server_1.initialize; } });
Object.defineProperty(exports, "enable", { enumerable: true, get: function () { return server_1.enable; } });
3 changes: 1 addition & 2 deletions static/remote/dist/src/main/server.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { WebContents } from 'electron';
export declare const isRemoteModuleEnabled: (contents: WebContents) => boolean | undefined;
export declare function enable(contents: WebContents): void;
export declare const isRemoteModuleEnabled: (contents: WebContents) => any;
export declare function initialize(): void;
24 changes: 7 additions & 17 deletions static/remote/dist/src/main/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialize = exports.enable = exports.isRemoteModuleEnabled = void 0;
exports.initialize = exports.isRemoteModuleEnabled = void 0;
const events_1 = require("events");
const objects_registry_1 = __importDefault(require("./objects-registry"));
const type_utils_1 = require("../common/type-utils");
const electron_1 = require("electron");
const get_electron_binding_1 = require("../common/get-electron-binding");
const { Promise } = global;
const v8Util = get_electron_binding_1.getElectronBinding('v8_util');
const hasWebPrefsRemoteModuleAPI = (() => {
var _a, _b;
const electronVersion = Number((_b = (_a = process.versions.electron) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b[0]);
return Number.isNaN(electronVersion) || electronVersion < 14;
})();
// The internal properties of Function.
const FUNCTION_PROPERTIES = [
'length', 'name', 'arguments', 'caller', 'prototype'
Expand Down Expand Up @@ -299,23 +293,19 @@ const isRemoteModuleEnabledImpl = function (contents) {
};
const isRemoteModuleEnabledCache = new WeakMap();
const isRemoteModuleEnabled = function (contents) {
if (hasWebPrefsRemoteModuleAPI && !isRemoteModuleEnabledCache.has(contents)) {
if (!isRemoteModuleEnabledCache.has(contents)) {
isRemoteModuleEnabledCache.set(contents, isRemoteModuleEnabledImpl(contents));
}
return isRemoteModuleEnabledCache.get(contents);
};
exports.isRemoteModuleEnabled = isRemoteModuleEnabled;
function enable(contents) {
isRemoteModuleEnabledCache.set(contents, true);
}
exports.enable = enable;
const handleRemoteCommand = function (channel, handler) {
electron_1.ipcMain.on(channel, (event, contextId, ...args) => {
let returnValue;
if (!exports.isRemoteModuleEnabled(event.sender)) {
event.returnValue = {
type: 'exception',
value: valueToMeta(event.sender, contextId, new Error('@electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.'))
value: valueToMeta(event.sender, contextId, new Error('@electron/remote is disabled for this WebContents. Set {enableRemoteModule: true} in WebPreferences to enable it.'))
};
return;
}
Expand Down Expand Up @@ -348,6 +338,8 @@ let initialized = false;
function initialize() {
if (initialized)
throw new Error('@electron/remote has already been initialized');
if (Number(process.versions.electron.split('.')[0]) >= 14)
throw new Error('@electron/remote >= 2.x is required for Electron >= 14. See https://github.com/electron/remote/blob/main/docs/migration-2.md for migration instructions.');
initialized = true;
handleRemoteCommand("REMOTE_BROWSER_WRONG_CONTEXT_ERROR" /* BROWSER_WRONG_CONTEXT_ERROR */, function (event, contextId, passedContextId, id) {
const objectId = [passedContextId, id];
Expand Down Expand Up @@ -441,8 +433,7 @@ function initialize() {
return valueToMeta(event.sender, contextId, func(...args), true);
}
catch (error) {
const err = new Error(`Could not call remote function '${func.name || "anonymous"}'. Check that the function signature is correct. Underlying error: ${error}\n` +
(error instanceof Error ? `Underlying stack: ${error.stack}\n` : ""));
const err = new Error(`Could not call remote function '${func.name || 'anonymous'}'. Check that the function signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
err.cause = error;
throw err;
}
Expand All @@ -465,8 +456,7 @@ function initialize() {
return valueToMeta(event.sender, contextId, object[method](...args), true);
}
catch (error) {
const err = new Error(`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error}` +
(error instanceof Error ? `Underlying stack: ${error.stack}\n` : ""));
const err = new Error(`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
err.cause = error;
throw err;
}
Expand Down
1 change: 0 additions & 1 deletion static/remote/dist/src/renderer/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const type_utils_1 = require("../common/type-utils");
const electron_1 = require("electron");
const module_names_1 = require("../common/module-names");
const get_electron_binding_1 = require("../common/get-electron-binding");
const { Promise } = global;
const callbacksRegistry = new callbacks_registry_1.CallbacksRegistry();
const remoteObjectCache = new Map();
const finalizationRegistry = new FinalizationRegistry((id) => {
Expand Down
51 changes: 23 additions & 28 deletions static/remote/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
import * as Electron from 'electron';

export {
ClientRequest,
CommandLine,
Cookies,
Debugger,
Dock,
DownloadItem,
IncomingMessage,
MessagePortMain,
ServiceWorkers,
TouchBarButton,
TouchBarColorPicker,
TouchBarGroup,
TouchBarLabel,
TouchBarOtherItemsProxy,
TouchBarPopover,
TouchBarScrubber,
TouchBarSegmentedControl,
TouchBarSlider,
TouchBarSpacer,
WebRequest,
} from 'electron/main';

// Taken from `RemoteMainInterface`
export var app: Electron.App;
export var autoUpdater: Electron.AutoUpdater;
export var BrowserView: typeof Electron.BrowserView;
export var BrowserWindow: typeof Electron.BrowserWindow;
export var ClientRequest: typeof Electron.ClientRequest;
export var clipboard: Electron.Clipboard;
export var CommandLine: typeof Electron.CommandLine;
export var contentTracing: Electron.ContentTracing;
export var Cookies: typeof Electron.Cookies;
export var crashReporter: Electron.CrashReporter;
export var Debugger: typeof Electron.Debugger;
export var desktopCapturer: Electron.DesktopCapturer;
export var dialog: Electron.Dialog;
export var Dock: typeof Electron.Dock;
export var DownloadItem: typeof Electron.DownloadItem;
export var globalShortcut: Electron.GlobalShortcut;
export var inAppPurchase: Electron.InAppPurchase;
export var IncomingMessage: typeof Electron.IncomingMessage;
export var ipcMain: Electron.IpcMain;
export var Menu: typeof Electron.Menu;
export var MenuItem: typeof Electron.MenuItem;
export var MessageChannelMain: typeof Electron.MessageChannelMain;
export var nativeImage: typeof Electron.nativeImage;
export var MessagePortMain: typeof Electron.MessagePortMain;
export var nativeImage: typeof Electron.NativeImage;
export var nativeTheme: Electron.NativeTheme;
export var net: Electron.Net;
export var netLog: Electron.NetLog;
Expand All @@ -48,14 +33,24 @@ export var powerMonitor: Electron.PowerMonitor;
export var powerSaveBlocker: Electron.PowerSaveBlocker;
export var protocol: Electron.Protocol;
export var screen: Electron.Screen;
export var session: typeof Electron.session;
export var ShareMenu: typeof Electron.ShareMenu;
export var ServiceWorkers: typeof Electron.ServiceWorkers;
export var session: typeof Electron.Session;
export var shell: Electron.Shell;
export var systemPreferences: Electron.SystemPreferences;
export var TouchBar: typeof Electron.TouchBar;
export var TouchBarButton: typeof Electron.TouchBarButton;
export var TouchBarColorPicker: typeof Electron.TouchBarColorPicker;
export var TouchBarGroup: typeof Electron.TouchBarGroup;
export var TouchBarLabel: typeof Electron.TouchBarLabel;
export var TouchBarOtherItemsProxy: typeof Electron.TouchBarOtherItemsProxy;
export var TouchBarPopover: typeof Electron.TouchBarPopover;
export var TouchBarScrubber: typeof Electron.TouchBarScrubber;
export var TouchBarSegmentedControl: typeof Electron.TouchBarSegmentedControl;
export var TouchBarSlider: typeof Electron.TouchBarSlider;
export var TouchBarSpacer: typeof Electron.TouchBarSpacer;
export var Tray: typeof Electron.Tray;
export var webContents: typeof Electron.webContents;
export var webFrameMain: typeof Electron.webFrameMain;
export var webContents: typeof Electron.WebContents;
export var WebRequest: typeof Electron.WebRequest;

// Taken from `Remote`
export function getCurrentWebContents(): Electron.WebContents;
Expand Down
Loading

0 comments on commit 8bcfc49

Please sign in to comment.