@lvce-editor/main-process 6.15.0 → 6.17.0

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.
@@ -3426,7 +3426,7 @@ const formatUtilityProcessName = name => {
3426
3426
  const state$6 = {
3427
3427
  all: Object.create(null)
3428
3428
  };
3429
- const add$1 = (pid, process, name) => {
3429
+ const add$2 = (pid, process, name) => {
3430
3430
  number(pid);
3431
3431
  object(process);
3432
3432
  string(name);
@@ -3461,7 +3461,7 @@ const trackUtilityProcess = (rawIpc, name) => {
3461
3461
  pid
3462
3462
  } = rawIpc;
3463
3463
  const formattedName = formatUtilityProcessName(name);
3464
- add$1(pid, rawIpc, formattedName);
3464
+ add$2(pid, rawIpc, formattedName);
3465
3465
  const cleanup = () => {
3466
3466
  remove$1(pid);
3467
3467
  rawIpc.off('exit', handleExit);
@@ -4067,6 +4067,7 @@ const DidNavigate = 'did-navigate';
4067
4067
  const PageTitleUpdated = 'page-title-updated';
4068
4068
  const Destroyed = 'destroyed';
4069
4069
  const BeforeInputEvent = 'before-input-event';
4070
+ const Login = 'login';
4070
4071
 
4071
4072
  const Deny = 'deny';
4072
4073
 
@@ -4087,7 +4088,7 @@ const state$3 = {
4087
4088
  fallThroughKeyBindings: [],
4088
4089
  views: Object.create(null)
4089
4090
  };
4090
- const add = (id, browserWindow, view) => {
4091
+ const add$1 = (id, browserWindow, view) => {
4091
4092
  // state
4092
4093
  state$3.views[id] = {
4093
4094
  browserWindow,
@@ -4515,8 +4516,14 @@ const formatMessage = ({
4515
4516
  message,
4516
4517
  sourceId
4517
4518
  }) => {
4518
- const source = sourceId ? ` (${sourceId}:${lineNumber})` : '';
4519
- return `${new Date().toISOString()} [${level}] [Window] ${message}${source}`;
4519
+ return JSON.stringify({
4520
+ category: 'Window',
4521
+ level,
4522
+ line: lineNumber,
4523
+ message,
4524
+ source: sourceId,
4525
+ timestamp: new Date().toISOString()
4526
+ });
4520
4527
  };
4521
4528
  const addListener = (webContents, logger = getOrCreateLogger()) => {
4522
4529
  webContents.on('console-message', event => {
@@ -6155,14 +6162,14 @@ const getKeyBindingIdentifier = input => {
6155
6162
  return identifier;
6156
6163
  };
6157
6164
 
6158
- const key$6 = 'before-input';
6159
- const attach$6 = (webContents, listener) => {
6165
+ const key$7 = 'before-input';
6166
+ const attach$7 = (webContents, listener) => {
6160
6167
  webContents.on(BeforeInputEvent, listener);
6161
6168
  };
6162
- const detach$6 = (webContents, listener) => {
6169
+ const detach$7 = (webContents, listener) => {
6163
6170
  webContents.off(BeforeInputEvent, listener);
6164
6171
  };
6165
- const handler$6 = (event, input) => {
6172
+ const handler$7 = (event, input) => {
6166
6173
  if (input.type !== KeyDown) {
6167
6174
  return {
6168
6175
  messages: [],
@@ -6187,6 +6194,28 @@ const handler$6 = (event, input) => {
6187
6194
  };
6188
6195
 
6189
6196
  const ElectronBrowserViewEventListenerBeforeInput = {
6197
+ __proto__: null,
6198
+ attach: attach$7,
6199
+ detach: detach$7,
6200
+ handler: handler$7,
6201
+ key: key$7
6202
+ };
6203
+
6204
+ const key$6 = 'context-menu';
6205
+ const attach$6 = (webContents, listener) => {
6206
+ webContents.on(ContextMenu, listener);
6207
+ };
6208
+ const detach$6 = (webContents, listener) => {
6209
+ webContents.off(ContextMenu, listener);
6210
+ };
6211
+ const handler$6 = (event, params) => {
6212
+ return {
6213
+ messages: [['handleContextMenu', params]],
6214
+ result: undefined
6215
+ };
6216
+ };
6217
+
6218
+ const ElectronBrowserViewEventListenerContextMenu = {
6190
6219
  __proto__: null,
6191
6220
  attach: attach$6,
6192
6221
  detach: detach$6,
@@ -6194,21 +6223,21 @@ const ElectronBrowserViewEventListenerBeforeInput = {
6194
6223
  key: key$6
6195
6224
  };
6196
6225
 
6197
- const key$5 = 'context-menu';
6226
+ const key$5 = 'destroyed';
6198
6227
  const attach$5 = (webContents, listener) => {
6199
- webContents.on(ContextMenu, listener);
6228
+ webContents.on(Destroyed, listener);
6200
6229
  };
6201
6230
  const detach$5 = (webContents, listener) => {
6202
- webContents.off(ContextMenu, listener);
6231
+ webContents.off(Destroyed, listener);
6203
6232
  };
6204
- const handler$5 = (event, params) => {
6233
+ const handler$5 = () => {
6205
6234
  return {
6206
- messages: [['handleContextMenu', params]],
6235
+ messages: [['handleBrowserViewDestroyed']],
6207
6236
  result: undefined
6208
6237
  };
6209
6238
  };
6210
6239
 
6211
- const ElectronBrowserViewEventListenerContextMenu = {
6240
+ const ElectronBrowserViewEventListenerDestroyed = {
6212
6241
  __proto__: null,
6213
6242
  attach: attach$5,
6214
6243
  detach: detach$5,
@@ -6216,21 +6245,21 @@ const ElectronBrowserViewEventListenerContextMenu = {
6216
6245
  key: key$5
6217
6246
  };
6218
6247
 
6219
- const key$4 = 'destroyed';
6248
+ const key$4 = 'did-navigate';
6220
6249
  const attach$4 = (webContents, listener) => {
6221
- webContents.on(Destroyed, listener);
6250
+ webContents.on(DidNavigate, listener);
6222
6251
  };
6223
6252
  const detach$4 = (webContents, listener) => {
6224
- webContents.off(Destroyed, listener);
6253
+ webContents.off(DidNavigate, listener);
6225
6254
  };
6226
- const handler$4 = () => {
6255
+ const handler$4 = (event, url) => {
6227
6256
  return {
6228
- messages: [['handleBrowserViewDestroyed']],
6257
+ messages: [['handleDidNavigate', url]],
6229
6258
  result: undefined
6230
6259
  };
6231
6260
  };
6232
6261
 
6233
- const ElectronBrowserViewEventListenerDestroyed = {
6262
+ const ElectronBrowserViewEventListenerDidNavigate = {
6234
6263
  __proto__: null,
6235
6264
  attach: attach$4,
6236
6265
  detach: detach$4,
@@ -6238,21 +6267,64 @@ const ElectronBrowserViewEventListenerDestroyed = {
6238
6267
  key: key$4
6239
6268
  };
6240
6269
 
6241
- const key$3 = 'did-navigate';
6270
+ const pendingLogins = new Map();
6271
+ let nextRequestId = 1;
6272
+ const add = (webContentsId, callback) => {
6273
+ const requestId = `${webContentsId}:${nextRequestId++}`;
6274
+ pendingLogins.set(requestId, {
6275
+ callback,
6276
+ webContentsId
6277
+ });
6278
+ return requestId;
6279
+ };
6280
+ const take = requestId => {
6281
+ const pendingLogin = pendingLogins.get(requestId);
6282
+ pendingLogins.delete(requestId);
6283
+ return pendingLogin;
6284
+ };
6285
+ const accept = (requestId, username, password) => {
6286
+ const pendingLogin = take(requestId);
6287
+ pendingLogin?.callback(username, password);
6288
+ };
6289
+ const cancel = requestId => {
6290
+ const pendingLogin = take(requestId);
6291
+ pendingLogin?.callback();
6292
+ };
6293
+ const cancelForWebContents = webContentsId => {
6294
+ for (const [requestId, pendingLogin] of pendingLogins) {
6295
+ if (pendingLogin.webContentsId !== webContentsId) {
6296
+ continue;
6297
+ }
6298
+ pendingLogins.delete(requestId);
6299
+ pendingLogin.callback();
6300
+ }
6301
+ };
6302
+
6303
+ const key$3 = Login;
6242
6304
  const attach$3 = (webContents, listener) => {
6243
- webContents.on(DidNavigate, listener);
6305
+ webContents.on(Login, listener);
6244
6306
  };
6245
6307
  const detach$3 = (webContents, listener) => {
6246
- webContents.off(DidNavigate, listener);
6308
+ webContents.off(Login, listener);
6247
6309
  };
6248
- const handler$3 = (event, url) => {
6310
+ const handler$3 = (event, authenticationResponseDetails, authInfo, callback, webContentsId) => {
6311
+ event.preventDefault();
6312
+ const requestId = add(webContentsId, callback);
6249
6313
  return {
6250
- messages: [['handleDidNavigate', url]],
6314
+ messages: [['handleLogin', {
6315
+ host: authInfo.host,
6316
+ isProxy: authInfo.isProxy,
6317
+ port: authInfo.port,
6318
+ realm: authInfo.realm,
6319
+ requestId,
6320
+ scheme: authInfo.scheme,
6321
+ url: String(authenticationResponseDetails.url)
6322
+ }]],
6251
6323
  result: undefined
6252
6324
  };
6253
6325
  };
6254
6326
 
6255
- const ElectronBrowserViewEventListenerDidNavigate = {
6327
+ const ElectronBrowserViewEventListenerLogin = {
6256
6328
  __proto__: null,
6257
6329
  attach: attach$3,
6258
6330
  detach: detach$3,
@@ -6339,6 +6411,7 @@ const ElectronBrowserViewEventListeners = {
6339
6411
  contextMenu: ElectronBrowserViewEventListenerContextMenu,
6340
6412
  destroyed: ElectronBrowserViewEventListenerDestroyed,
6341
6413
  didNavigate: ElectronBrowserViewEventListenerDidNavigate,
6414
+ login: ElectronBrowserViewEventListenerLogin,
6342
6415
  pageTitleUpdated: ElectronBrowserViewEventListenerPageTitleUpdated,
6343
6416
  willNavigate: ElectronBrowserViewEventListenerWillNavigate,
6344
6417
  windowOpen: ElectronBrowserViewEventListenerWindowOpen
@@ -6367,7 +6440,7 @@ const createWebContentsView = async () => {
6367
6440
  const {
6368
6441
  id
6369
6442
  } = webContents;
6370
- add(id, browserWindow, view);
6443
+ add$1(id, browserWindow, view);
6371
6444
  return id;
6372
6445
  };
6373
6446
  const attachEventListeners = webContentsId => {
@@ -6383,7 +6456,7 @@ const attachEventListeners = webContentsId => {
6383
6456
  const {
6384
6457
  messages,
6385
6458
  result
6386
- } = value.handler(...args);
6459
+ } = value.handler(...args, webContentsId);
6387
6460
  for (const message of messages) {
6388
6461
  const [key, ...rest] = message;
6389
6462
  send(`ElectronWebContents.${key}`, webContentsId, ...rest);
@@ -6397,6 +6470,7 @@ const attachEventListeners = webContentsId => {
6397
6470
  };
6398
6471
  const disposeWebContentsView = browserViewId => {
6399
6472
  console.log('[main process] dispose browser view', browserViewId);
6473
+ cancelForWebContents(browserViewId);
6400
6474
  const instance = get$3(browserViewId);
6401
6475
  if (!instance) {
6402
6476
  return;
@@ -6972,7 +7046,9 @@ const commandMap = {
6972
7046
  'ElectronWebContents.callFunction': callFunction,
6973
7047
  'ElectronWebContents.dispose': dispose$1,
6974
7048
  'ElectronWebContents.getStats': getStats$1,
7049
+ 'ElectronWebContentsView.acceptLogin': accept,
6975
7050
  'ElectronWebContentsView.attachEventListeners': attachEventListeners,
7051
+ 'ElectronWebContentsView.cancelLogin': cancel,
6976
7052
  'ElectronWebContentsView.createWebContentsView': createWebContentsView,
6977
7053
  'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
6978
7054
  'ElectronWebContentsViewFunctions.addToWindow': addToWindow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.15.0",
3
+ "version": "6.17.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"