MCPcopy Create free account
hub / github.com/deta/surf / createView

Method createView

app/src/main/viewManager.ts:501–586  ·  view source on GitHub ↗
(opts: WebContentsViewCreateOptions)

Source from the content-addressed store, hash-verified

499 }
500
501 async createView(opts: WebContentsViewCreateOptions) {
502 try {
503 const { navigationHistory, ...logOptions } = opts
504
505 const currentEntry =
506 opts.navigationHistory &&
507 opts.navigationHistoryIndex !== undefined &&
508 opts.navigationHistory.length > 0 &&
509 opts.navigationHistoryIndex >= 0
510 ? opts.navigationHistory[opts.navigationHistoryIndex]
511 : null
512
513 const url = currentEntry?.url ?? opts.url
514
515 const newIsSurfUrl = url ? checkIfSurfProtocolUrl(url) : false
516
517 log.log('[main] webcontentsview-create: creating new view with options', logOptions, {
518 url,
519 newIsSurfUrl
520 })
521
522 const view = new WCView(
523 {
524 ...opts,
525 additionalArguments: [
526 ...(opts.additionalArguments || []),
527 `--userDataPath=${app.getPath('userData')}`,
528 `--appPath=${app.getAppPath()}${isDev ? '' : '.unpacked'}`,
529 `--pdf-viewer-entry-point=${PDFViewerEntryPoint}`,
530 ...(process.env.ENABLE_DEBUG_PROXY ? ['--enable-debug-proxy'] : []),
531 ...(process.env.DISABLE_TAB_SWITCHING_SHORTCUTS
532 ? ['--disable-tab-switching-shortcuts']
533 : [])
534 ],
535 sandbox: false,
536 preload: newIsSurfUrl
537 ? path.resolve(__dirname, '../preload/resource.js')
538 : path.resolve(__dirname, '../preload/webcontents.js')
539 },
540 this
541 )
542
543 log.log('[main] webcontentsview-create: registering id', view.id)
544 this.views.set(view.id, view)
545
546 if (opts.activate) {
547 if (opts.isOverlay) {
548 this.activeOverlayViewId = view.id
549
550 this.hideAllViews()
551 } else {
552 this.activeViewId = view.id
553 }
554
555 this.addChildView(view)
556 } else if (opts.permanentlyActive) {
557 this.addChildView(view)
558 }

Callers 1

attachIPCEventsMethod · 0.95

Calls 8

hideAllViewsMethod · 0.95
addChildViewMethod · 0.95
attachViewIPCEventsMethod · 0.95
loadURLMethod · 0.95
positionOverlaysMethod · 0.95
checkIfSurfProtocolUrlFunction · 0.90
logMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected