electrobun 0.0.10 → 0.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 CHANGED
@@ -61,9 +61,6 @@ Ways to get involved at this early stage:
61
61
 
62
62
  run `bun run install-zig` to install the right version of zig to vendors/zig
63
63
 
64
- `bun dev:example` and `bun dev:example:canary` will compile everything in electrobun in either dev or release modes and then compile the example app in either dev or canary modes and run it.
64
+ `bun dev:example` and `bun dev:example:canary` will compile everything in electrobun in either dev mode and then compile the example app in either dev or canary modes and run it.
65
65
 
66
- Note: For now `bun build:release` will build all the electrobun components in release mode and copy them to the /dist folder.
67
- Setting up a more complex release process is a todo, since those binaries should ideally stay in sync with the bun and browser typescript apis.
68
-
69
- More work is needed to separate out "build everything in release mode for testing with the example app" vs. "build everything in release mode and prepare for distribution"
66
+ Note: use `lldb <path-to-bundle>/Contents/MacOS/launcher` and then `run` to debug release builds
@@ -1,8 +1,8 @@
1
- // src/browser/node_modules/rpc-anywhere/dist/esm/rpc.js
2
- var missingTransportMethodError = function(methods, action) {
1
+ // node_modules/rpc-anywhere/dist/esm/rpc.js
2
+ function missingTransportMethodError(methods, action) {
3
3
  const methodsString = methods.map((method) => `"${method}"`).join(", ");
4
4
  return new Error(`This RPC instance cannot ${action} because the transport did not provide one or more of these methods: ${methodsString}`);
5
- };
5
+ }
6
6
  function _createRPC(options = {}) {
7
7
  let debugHooks = {};
8
8
  function _setDebugHooks(newDebugHooks) {
@@ -188,7 +188,7 @@ function _createRPC(options = {}) {
188
188
  var MAX_ID = 10000000000;
189
189
  var DEFAULT_MAX_REQUEST_TIME = 1000;
190
190
 
191
- // src/browser/node_modules/rpc-anywhere/dist/esm/create-rpc.js
191
+ // node_modules/rpc-anywhere/dist/esm/create-rpc.js
192
192
  function createRPC(options) {
193
193
  return _createRPC(options);
194
194
  }
@@ -259,7 +259,7 @@ var ConfigureWebviewTags = (enableWebviewTags, zigRpc, syncRpc) => {
259
259
  }
260
260
  });
261
261
  this.webviewId = webviewId;
262
- this.id = `electrobun-webview-${this.webviewId}`;
262
+ this.id = `electrobun-webview-${webviewId}`;
263
263
  this.setAttribute("id", this.id);
264
264
  }
265
265
  asyncResolvers = {};
@@ -347,7 +347,7 @@ var ConfigureWebviewTags = (enableWebviewTags, zigRpc, syncRpc) => {
347
347
  this.dispatchEvent(new CustomEvent(event, { detail }));
348
348
  }
349
349
  syncDimensions(force = false) {
350
- if (!force && this.hidden) {
350
+ if (!this.webviewId || !force && this.hidden) {
351
351
  return;
352
352
  }
353
353
  const rect = this.getBoundingClientRect();
@@ -501,7 +501,7 @@ var ConfigureWebviewTags = (enableWebviewTags, zigRpc, syncRpc) => {
501
501
  }
502
502
  };
503
503
  }
504
- DEFAULT_FRAME_RATE = Math.round(33.333333333333336);
504
+ DEFAULT_FRAME_RATE = Math.round(1000 / 30);
505
505
  streamScreenInterval;
506
506
  startMirroringToDom(frameRate = this.DEFAULT_FRAME_RATE) {
507
507
  if (this.streamScreenInterval) {
@@ -805,10 +805,10 @@ class Electroview {
805
805
  }
806
806
  }
807
807
  };
808
- const rpc2 = createRPC(rpcOptions);
808
+ const rpc = createRPC(rpcOptions);
809
809
  const messageHandlers = config.handlers.messages;
810
810
  if (messageHandlers) {
811
- rpc2.addMessageListener("*", (messageName, payload) => {
811
+ rpc.addMessageListener("*", (messageName, payload) => {
812
812
  const globalHandler = messageHandlers["*"];
813
813
  if (globalHandler) {
814
814
  globalHandler(messageName, payload);
@@ -819,7 +819,7 @@ class Electroview {
819
819
  }
820
820
  });
821
821
  }
822
- return rpc2;
822
+ return rpc;
823
823
  }
824
824
  }
825
825
  var Electrobun = {
@@ -832,4 +832,4 @@ export {
832
832
  Electroview
833
833
  };
834
834
 
835
- //# debugId=5A7994858FFC99B964756e2164756e21
835
+ //# debugId=4AEF499E7763490A64756E2164756E21
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/browser/node_modules/rpc-anywhere/dist/esm/rpc.js", "../../../src/browser/node_modules/rpc-anywhere/dist/esm/create-rpc.js", "../../../src/browser/webviewtag.ts", "../../../src/browser/stylesAndElements.ts", "../../../src/browser/index.ts", "../../../src/browser/index.ts"],
3
+ "sources": ["../../../node_modules/rpc-anywhere/dist/esm/rpc.js", "../../../node_modules/rpc-anywhere/dist/esm/create-rpc.js", "../../../src/browser/webviewtag.ts", "../../../src/browser/stylesAndElements.ts", "../../../src/browser/index.ts"],
4
4
  "sourcesContent": [
5
5
  "const MAX_ID = 1e10;\nconst DEFAULT_MAX_REQUEST_TIME = 1000;\nfunction missingTransportMethodError(methods, action) {\n const methodsString = methods.map((method) => `\"${method}\"`).join(\", \");\n return new Error(`This RPC instance cannot ${action} because the transport did not provide one or more of these methods: ${methodsString}`);\n}\nexport function _createRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions = {}) {\n // setters\n // -------\n let debugHooks = {};\n /**\n * Sets the debug hooks that will be used to debug the RPC instance.\n */\n function _setDebugHooks(newDebugHooks) {\n debugHooks = newDebugHooks;\n }\n let transport = {};\n /**\n * Sets the transport that will be used to send and receive requests,\n * responses and messages.\n */\n function setTransport(newTransport) {\n if (transport.unregisterHandler)\n transport.unregisterHandler();\n transport = newTransport;\n transport.registerHandler?.(handler);\n }\n let requestHandler = undefined;\n /**\n * Sets the function that will be used to handle requests from the\n * remote RPC instance.\n */\n function setRequestHandler(\n /**\n * The function that will be set as the \"request handler\" function.\n */\n handler) {\n if (typeof handler === \"function\") {\n requestHandler = handler;\n return;\n }\n requestHandler = (method, params) => {\n const handlerFn = handler[method];\n if (handlerFn)\n return handlerFn(params);\n const fallbackHandler = handler._;\n if (!fallbackHandler)\n throw new Error(`The requested method has no handler: ${method}`);\n return fallbackHandler(method, params);\n };\n }\n // options\n // -------\n const { maxRequestTime = DEFAULT_MAX_REQUEST_TIME } = options;\n if (options.transport)\n setTransport(options.transport);\n if (options.requestHandler)\n setRequestHandler(options.requestHandler);\n if (options._debugHooks)\n _setDebugHooks(options._debugHooks);\n // requests\n // --------\n let lastRequestId = 0;\n function getRequestId() {\n if (lastRequestId <= MAX_ID)\n return ++lastRequestId;\n return (lastRequestId = 0);\n }\n const requestListeners = new Map();\n const requestTimeouts = new Map();\n /**\n * Sends a request to the remote RPC endpoint and returns a promise\n * with the response.\n */\n function requestFn(method, ...args) {\n const params = args[0];\n return new Promise((resolve, reject) => {\n if (!transport.send)\n throw missingTransportMethodError([\"send\"], \"make requests\");\n const requestId = getRequestId();\n const request = {\n type: \"request\",\n id: requestId,\n method,\n params,\n };\n requestListeners.set(requestId, { resolve, reject });\n if (maxRequestTime !== Infinity)\n requestTimeouts.set(requestId, setTimeout(() => {\n requestTimeouts.delete(requestId);\n reject(new Error(\"RPC request timed out.\"));\n }, maxRequestTime));\n debugHooks.onSend?.(request);\n transport.send(request);\n });\n }\n /**\n * Sends a request to the remote RPC endpoint and returns a promise\n * with the response.\n *\n * It can also be used as a proxy to send requests by using the request\n * name as a property name.\n *\n * @example\n *\n * ```js\n * await rpc.request(\"methodName\", { param: \"value\" });\n * // or\n * await rpc.request.methodName({ param: \"value\" });\n * ```\n */\n const request = new Proxy(requestFn, {\n get: (target, prop, receiver) => {\n if (prop in target)\n return Reflect.get(target, prop, receiver);\n // @ts-expect-error Not very important.\n return (params) => requestFn(prop, params);\n },\n });\n const requestProxy = request;\n // messages\n // --------\n function sendFn(\n /**\n * The name of the message to send.\n */\n message, ...args) {\n const payload = args[0];\n if (!transport.send)\n throw missingTransportMethodError([\"send\"], \"send messages\");\n const rpcMessage = {\n type: \"message\",\n id: message,\n payload,\n };\n debugHooks.onSend?.(rpcMessage);\n transport.send(rpcMessage);\n }\n /**\n * Sends a message to the remote RPC endpoint.\n *\n * It can also be used as a proxy to send messages by using the message\n * name as a property name.\n *\n * @example\n *\n * ```js\n * rpc.send(\"messageName\", { content: \"value\" });\n * // or\n * rpc.send.messageName({ content: \"value\" });\n * ```\n */\n const send = new Proxy(sendFn, {\n get: (target, prop, receiver) => {\n if (prop in target)\n return Reflect.get(target, prop, receiver);\n // @ts-expect-error Not very important.\n return (payload) => sendFn(prop, payload);\n },\n });\n const sendProxy = send;\n const messageListeners = new Map();\n const wildcardMessageListeners = new Set();\n /**\n * Adds a listener for a message (or all if \"*\" is used) from the\n * remote RPC endpoint.\n */\n function addMessageListener(\n /**\n * The name of the message to listen to. Use \"*\" to listen to all\n * messages.\n */\n message, \n /**\n * The function that will be called when a message is received.\n */\n listener) {\n if (!transport.registerHandler)\n throw missingTransportMethodError([\"registerHandler\"], \"register message listeners\");\n if (message === \"*\") {\n wildcardMessageListeners.add(listener);\n return;\n }\n if (!messageListeners.has(message))\n messageListeners.set(message, new Set());\n messageListeners.get(message)?.add(listener);\n }\n /**\n * Removes a listener for a message (or all if \"*\" is used) from the\n * remote RPC endpoint.\n */\n function removeMessageListener(\n /**\n * The name of the message to remove the listener for. Use \"*\" to\n * remove a listener for all messages.\n */\n message, \n /**\n * The listener function that will be removed.\n */\n listener) {\n if (message === \"*\") {\n wildcardMessageListeners.delete(listener);\n return;\n }\n messageListeners.get(message)?.delete(listener);\n if (messageListeners.get(message)?.size === 0)\n messageListeners.delete(message);\n }\n // message handling\n // ----------------\n async function handler(message) {\n debugHooks.onReceive?.(message);\n if (!(\"type\" in message))\n throw new Error(\"Message does not contain a type.\");\n if (message.type === \"request\") {\n if (!transport.send || !requestHandler)\n throw missingTransportMethodError([\"send\", \"requestHandler\"], \"handle requests\");\n const { id, method, params } = message;\n let response;\n try {\n response = {\n type: \"response\",\n id,\n success: true,\n payload: await requestHandler(method, params),\n };\n }\n catch (error) {\n if (!(error instanceof Error))\n throw error;\n response = {\n type: \"response\",\n id,\n success: false,\n error: error.message,\n };\n }\n debugHooks.onSend?.(response);\n transport.send(response);\n return;\n }\n if (message.type === \"response\") {\n const timeout = requestTimeouts.get(message.id);\n if (timeout != null)\n clearTimeout(timeout);\n const { resolve, reject } = requestListeners.get(message.id) ?? {};\n if (!message.success)\n reject?.(new Error(message.error));\n else\n resolve?.(message.payload);\n return;\n }\n if (message.type === \"message\") {\n for (const listener of wildcardMessageListeners)\n listener(message.id, message.payload);\n const listeners = messageListeners.get(message.id);\n if (!listeners)\n return;\n for (const listener of listeners)\n listener(message.payload);\n return;\n }\n throw new Error(`Unexpected RPC message type: ${message.type}`);\n }\n // proxy\n // -----\n /**\n * A proxy object that can be used to send requests and messages.\n */\n const proxy = { send: sendProxy, request: requestProxy };\n return {\n setTransport,\n setRequestHandler,\n request,\n requestProxy,\n send,\n sendProxy,\n addMessageListener,\n removeMessageListener,\n proxy,\n _setDebugHooks,\n };\n}\n",
6
- "import { _createRPC } from \"./rpc.js\";\n/**\n * Creates an RPC instance that can send and receive requests, responses\n * and messages.\n */\nexport function createRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n/**\n * Creates an RPC instance as a client. The passed schema represents\n * the remote RPC's (server) schema.\n */\nexport function createClientRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n/**\n * Creates an RPC instance as a server. The passed schema represents\n * this RPC's (server) schema.\n */\nexport function createServerRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n",
7
- "type WebviewEventTypes =\n | \"did-navigate\"\n | \"did-navigate-in-page\"\n | \"did-commit-navigation\"\n | \"dom-ready\";\n\ntype Rect = { x: number; y: number; width: number; height: number };\n\nconst ConfigureWebviewTags = (\n enableWebviewTags: boolean,\n zigRpc: (params: any) => any,\n syncRpc: (params: any) => any\n) => {\n if (!enableWebviewTags) {\n return;\n }\n\n // todo: provide global types for <electrobun-webview> tag elements (like querySelector results etc.)\n\n class WebviewTag extends HTMLElement {\n // todo (yoav): come up with a better mechanism to eliminate collisions with bun created\n // webviews\n webviewId?: number; // = nextWebviewId++;\n\n // rpc\n zigRpc: any;\n syncRpc: any;\n\n // querySelectors for elements that you want to appear\n // in front of the webview.\n maskSelectors: Set<string> = new Set();\n\n // observers\n resizeObserver?: ResizeObserver;\n // intersectionObserver?: IntersectionObserver;\n // mutationObserver?: MutationObserver;\n\n positionCheckLoop?: Timer;\n positionCheckLoopReset?: Timer;\n\n lastRect = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n\n lastMasksJSON: string = \"\";\n lastMasks: Rect[] = [];\n\n transparent: boolean = false;\n passthroughEnabled: boolean = false;\n hidden: boolean = false;\n delegateMode: boolean = false;\n hiddenMirrorMode: boolean = false;\n wasZeroRect: boolean = false;\n isMirroring: boolean = false;\n\n partition: string | null = null;\n\n constructor() {\n super();\n this.zigRpc = zigRpc;\n this.syncRpc = syncRpc;\n\n // Give it a frame to be added to the dom and render before measuring\n requestAnimationFrame(() => {\n this.initWebview();\n });\n }\n\n addMaskSelector(selector: string) {\n this.maskSelectors.add(selector);\n this.syncDimensions();\n }\n\n removeMaskSelector(selector: string) {\n this.maskSelectors.delete(selector);\n this.syncDimensions();\n }\n\n initWebview() {\n const rect = this.getBoundingClientRect();\n this.lastRect = rect;\n\n const webviewId = this.syncRpc({\n method: \"webviewTagInit\",\n params: {\n hostWebviewId: window.__electrobunWebviewId,\n windowId: window.__electrobunWindowId,\n url: this.src || this.getAttribute(\"src\") || null,\n html: this.html || this.getAttribute(\"html\") || null,\n preload: this.preload || this.getAttribute(\"preload\") || null,\n partition: this.partition || this.getAttribute(\"partition\") || null,\n frame: {\n width: rect.width,\n height: rect.height,\n x: rect.x,\n y: rect.y,\n },\n },\n });\n\n this.webviewId = webviewId;\n this.id = `electrobun-webview-${this.webviewId}`;\n // todo: replace zig -> webviewtag communication with a global instead of\n // queryselector based on id\n this.setAttribute(\"id\", this.id);\n }\n\n asyncResolvers: {\n [id: string]: { resolve: (arg: any) => void; reject: (arg: any) => void };\n } = {};\n\n callAsyncJavaScript({ script }: { script: string }) {\n return new Promise((resolve, reject) => {\n const messageId = \"\" + Date.now() + Math.random();\n this.asyncResolvers[messageId] = {\n resolve,\n reject,\n };\n\n this.zigRpc.request.webviewTagCallAsyncJavaScript({\n messageId,\n webviewId: this.webviewId,\n hostWebviewId: window.__electrobunWebviewId,\n script,\n });\n });\n }\n\n setCallAsyncJavaScriptResponse(messageId: string, response: any) {\n const resolvers = this.asyncResolvers[messageId];\n delete this.asyncResolvers[messageId];\n try {\n response = JSON.parse(response);\n\n if (response.result) {\n resolvers.resolve(response.result);\n } else {\n resolvers.reject(response.error);\n }\n } catch (e: any) {\n resolvers.reject(e.message);\n }\n }\n\n async canGoBack() {\n const {\n payload: { webviewTagCanGoBackResponse },\n } = await this.zigRpc.request.webviewTagCanGoBack({ id: this.webviewId });\n return webviewTagCanGoBackResponse;\n }\n\n async canGoForward() {\n const {\n payload: { webviewTagCanGoForwardResponse },\n } = await this.zigRpc.request.webviewTagCanGoForward({\n id: this.webviewId,\n });\n return webviewTagCanGoForwardResponse;\n }\n\n // propertie setters/getters. keeps them in sync with dom attributes\n updateAttr(name: string, value: string | null) {\n if (value) {\n this.setAttribute(name, value);\n } else {\n this.removeAttribute(name);\n }\n }\n\n get src() {\n return this.getAttribute(\"src\");\n }\n\n set src(value) {\n this.updateAttr(\"src\", value);\n }\n\n get html() {\n return this.getAttribute(\"html\");\n }\n\n set html(value) {\n this.updateAttr(\"html\", value);\n }\n\n get preload() {\n return this.getAttribute(\"preload\");\n }\n\n set preload(value) {\n this.updateAttr(\"preload\", value);\n }\n\n // Note: since <electrobun-webview> is an anchor for a native webview\n // on osx even if we hide it, enable mouse passthrough etc. There\n // are still events like drag events which are natively handled deep in the window manager\n // and will be handled incorrectly. To get around this for now we need to\n // move the webview off screen during delegate mode.\n adjustDimensionsForHiddenMirrorMode(rect: DOMRect) {\n if (this.hiddenMirrorMode) {\n rect.x = 0 - rect.width;\n }\n\n return rect;\n }\n\n // Note: in the brwoser-context we can ride on the dom element's uilt in event emitter for managing custom events\n on(event: WebviewEventTypes, listener: () => {}) {\n this.addEventListener(event, listener);\n }\n\n off(event: WebviewEventTypes, listener: () => {}) {\n this.removeEventListener(event, listener);\n }\n\n // This is typically called by injected js from zig\n emit(event: WebviewEventTypes, detail: any) {\n this.dispatchEvent(new CustomEvent(event, { detail }));\n }\n\n // Call this via document.querySelector('electrobun-webview').syncDimensions();\n // That way the host can trigger an alignment with the nested webview when they\n // know that they're chaning something in order to eliminate the lag that the\n // catch all loop will catch\n syncDimensions(force: boolean = false) {\n if (!force && this.hidden) {\n return;\n }\n\n const rect = this.getBoundingClientRect();\n const { x, y, width, height } =\n this.adjustDimensionsForHiddenMirrorMode(rect);\n const lastRect = this.lastRect;\n\n if (width === 0 && height === 0) {\n if (this.wasZeroRect === false) {\n this.wasZeroRect = true;\n this.toggleHidden(true, true);\n }\n return;\n }\n\n const masks: Rect[] = [];\n this.maskSelectors.forEach((selector) => {\n const els = document.querySelectorAll(selector);\n\n for (let i = 0; i < els.length; i++) {\n const el = els[i];\n\n if (el) {\n const maskRect = el.getBoundingClientRect();\n\n masks.push({\n // reposition the bounding rect to be relative to the webview rect\n // so objc can apply the mask correctly and handle the actual overlap\n x: maskRect.x - x,\n y: maskRect.y - y,\n width: maskRect.width,\n height: maskRect.height,\n });\n }\n }\n });\n\n // store jsonStringified last masks value to compare\n const masksJson = masks.length ? JSON.stringify(masks) : \"\";\n\n if (\n force ||\n lastRect.x !== x ||\n lastRect.y !== y ||\n lastRect.width !== width ||\n lastRect.height !== height ||\n this.lastMasksJSON !== masksJson\n ) {\n // let it know we're still accelerating\n this.setPositionCheckLoop(true);\n\n this.lastRect = rect;\n this.lastMasks = masks;\n this.lastMasksJSON = masksJson;\n\n this.zigRpc.send.webviewTagResize({\n id: this.webviewId,\n frame: {\n width: width,\n height: height,\n x: x,\n y: y,\n },\n masks: masksJson,\n });\n }\n\n if (this.wasZeroRect) {\n this.wasZeroRect = false;\n this.toggleHidden(false, true);\n }\n }\n\n boundSyncDimensions = () => this.syncDimensions();\n boundForceSyncDimensions = () => this.syncDimensions(true);\n\n setPositionCheckLoop(accelerate = false) {\n if (this.positionCheckLoop) {\n clearInterval(this.positionCheckLoop);\n this.positionCheckLoop = undefined;\n }\n\n if (this.positionCheckLoopReset) {\n clearTimeout(this.positionCheckLoopReset);\n this.positionCheckLoopReset = undefined;\n }\n\n const delay = accelerate ? 0 : 300;\n\n if (accelerate) {\n this.positionCheckLoopReset = setTimeout(() => {\n this.setPositionCheckLoop(false);\n }, 2000);\n }\n // Note: Since there's not catch all way to listen for x/y changes\n // we have a 400ms interval to check\n // on m1 max this 400ms interval for one nested webview\n // only uses around 0.1% cpu\n\n // Note: We also listen for resize events and changes to\n // certain properties to get reactive repositioning for\n // many cases.\n\n // todo: consider having an option to disable this and let user\n // trigger position sync for high performance cases (like\n // a browser with a hundred tabs)\n this.positionCheckLoop = setInterval(() => this.syncDimensions(), delay);\n }\n\n connectedCallback() {\n this.setPositionCheckLoop();\n\n this.resizeObserver = new ResizeObserver(() => {\n this.syncDimensions();\n });\n // Note: In objc the webview is positioned in the window from the bottom-left corner\n // the html anchor is positioned in the webview from the top-left corner\n // In those cases the getBoundingClientRect() will return the same value, but\n // we still need to send it to objc to calculate from its bottom left position\n // otherwise it'll move around unexpectedly.\n window.addEventListener(\"resize\", this.boundForceSyncDimensions);\n window.addEventListener(\"scroll\", this.boundSyncDimensions);\n\n // todo: For chromium webviews (windows native or chromium bundled)\n // should be able to use performanceObservers on layout-shift to\n // call syncDimensions more reactively\n }\n\n disconnectedCallback() {\n // removed from the dom\n clearInterval(this.positionCheckLoop);\n\n this.resizeObserver?.disconnect();\n // this.intersectionObserver?.disconnect();\n // this.mutationObserver?.disconnect();\n window.removeEventListener(\"resize\", this.boundForceSyncDimensions);\n window.removeEventListener(\"scroll\", this.boundSyncDimensions);\n this.zigRpc.send.webviewTagRemove({ id: this.webviewId });\n }\n\n static get observedAttributes() {\n // TODO: support html, preload, and other stuff here\n return [\"src\", \"html\", \"preload\", \"class\", \"style\"];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === \"src\" && oldValue !== newValue) {\n this.updateIFrameSrc(newValue);\n } else if (name === \"html\" && oldValue !== newValue) {\n this.updateIFrameHtml(newValue);\n } else if (name === \"preload\" && oldValue !== newValue) {\n this.updateIFramePreload(newValue);\n } else {\n this.syncDimensions();\n }\n }\n\n updateIFrameSrc(src: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdateSrc({\n id: this.webviewId,\n url: src,\n });\n }\n\n updateIFrameHtml(html: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdateHtml({\n id: this.webviewId,\n html,\n });\n }\n\n updateIFramePreload(preload: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdatePreload({\n id: this.webviewId,\n preload,\n });\n }\n\n goBack() {\n this.zigRpc.send.webviewTagGoBack({ id: this.webviewId });\n }\n\n goForward() {\n this.zigRpc.send.webviewTagGoForward({ id: this.webviewId });\n }\n\n reload() {\n this.zigRpc.send.webviewTagReload({ id: this.webviewId });\n }\n loadURL(url: string) {\n this.setAttribute(\"src\", url);\n this.zigRpc.send.webviewTagUpdateSrc({\n id: this.webviewId,\n url,\n });\n }\n // Note: you can set an interval and do this 60 times a second and it's pretty smooth\n // but it uses quite a bit of cpu\n // todo: change this to \"mirror to dom\" or something\n syncScreenshot(callback?: () => void) {\n const cacheBustString = `?${Date.now()}`;\n const url = `views://screenshot/${this.webviewId}${cacheBustString}`;\n const img = new Image();\n img.src = url;\n img.onload = () => {\n this.style.backgroundImage = `url(${url})`;\n if (callback) {\n // We've preloaded the image, but we still want to give it a chance to render\n // after setting the background style. give it quite a bit longer than a rafr\n setTimeout(callback, 100);\n }\n };\n }\n\n DEFAULT_FRAME_RATE = Math.round(1000 / 30); // 30fps\n streamScreenInterval?: Timer;\n\n // NOTE: This is very cpu intensive, Prefer startMirroring where possible\n startMirroringToDom(frameRate: number = this.DEFAULT_FRAME_RATE) {\n if (this.streamScreenInterval) {\n clearInterval(this.streamScreenInterval);\n }\n\n this.streamScreenInterval = setInterval(() => {\n this.syncScreenshot();\n }, frameRate);\n }\n\n stopMirroringToDom() {\n if (this.streamScreenInterval) {\n clearInterval(this.streamScreenInterval);\n this.streamScreenInterval = undefined;\n }\n }\n\n startMirroring() {\n // TEMP: mirroring now happens automatically in objc\n // when the mouse moves. I'm leaving this here for now\n // because I suspect there may still be use cases to\n // toggle it from the dom outside of the mouse moving.\n return;\n if (this.isMirroring === false) {\n this.isMirroring = true;\n this.zigRpc.send.webviewTagToggleMirroring({\n id: this.webviewId,\n enable: true,\n });\n }\n }\n\n stopMirroring() {\n return;\n if (this.isMirroring === true) {\n this.isMirroring = false;\n this.zigRpc.send.webviewTagToggleMirroring({\n id: this.webviewId,\n enable: false,\n });\n }\n }\n\n clearScreenImage() {\n this.style.backgroundImage = \"\";\n }\n\n tryClearScreenImage() {\n if (\n !this.transparent &&\n !this.hiddenMirrorMode &&\n !this.delegateMode &&\n !this.hidden\n ) {\n this.clearScreenImage();\n }\n }\n // This sets the native webview hovering over the dom to be transparent\n toggleTransparent(transparent?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof transparent === \"undefined\") {\n this.transparent = !this.transparent;\n } else {\n this.transparent = transparent;\n }\n }\n\n if (!this.transparent && !transparent) {\n this.tryClearScreenImage();\n }\n\n this.zigRpc.send.webviewTagSetTransparent({\n id: this.webviewId,\n transparent: this.transparent || Boolean(transparent),\n });\n }\n togglePassthrough(enablePassthrough?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof enablePassthrough === \"undefined\") {\n this.passthroughEnabled = !this.passthroughEnabled;\n } else {\n this.passthroughEnabled = enablePassthrough;\n }\n }\n\n this.zigRpc.send.webviewTagSetPassthrough({\n id: this.webviewId,\n enablePassthrough:\n this.passthroughEnabled || Boolean(enablePassthrough),\n });\n }\n\n toggleHidden(hidden?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof hidden === \"undefined\") {\n this.hidden = !this.hidden;\n } else {\n this.hidden = hidden;\n }\n }\n\n this.zigRpc.send.webviewTagSetHidden({\n id: this.webviewId,\n hidden: this.hidden || Boolean(hidden),\n });\n }\n\n // note: delegateMode and hiddenMirrorMode are experimental\n // ideally delegate mode would move the webview off screen\n // and delegate mouse and keyboard events to the webview while\n // streaming the screen so it can be fully layered in the dom\n // and fully interactive.\n toggleDelegateMode(delegateMode?: boolean) {\n const _newDelegateMode =\n typeof delegateMode === \"undefined\" ? !this.delegateMode : delegateMode;\n\n if (_newDelegateMode) {\n this.syncScreenshot(() => {\n this.delegateMode = true;\n this.toggleTransparent(true, true);\n this.startMirroringToDom();\n });\n } else {\n this.delegateMode = false;\n this.stopMirroringToDom();\n this.toggleTransparent(this.transparent);\n this.tryClearScreenImage();\n }\n }\n\n // While hiddenMirroMode would be similar to delegate mode but non-interactive\n // This is used while scrolling or resizing the <electrobun-webviewtag> to\n // make it smoother (scrolls with the dom) but disables interaction so that\n // during the scroll we don't need to worry about the webview being misaligned\n // with the mirror and accidentlly clicking on the wrong thing.\n toggleHiddenMirrorMode(force: boolean) {\n const enable =\n typeof force === \"undefined\" ? !this.hiddenMirrorMode : force;\n\n if (enable === true) {\n this.syncScreenshot(() => {\n this.hiddenMirrorMode = true;\n this.toggleHidden(true, true);\n this.togglePassthrough(true, true);\n this.startMirroringToDom();\n });\n } else {\n this.stopMirroringToDom();\n this.toggleHidden(this.hidden);\n this.togglePassthrough(this.passthroughEnabled);\n this.tryClearScreenImage();\n this.hiddenMirrorMode = false;\n }\n }\n }\n\n customElements.define(\"electrobun-webview\", WebviewTag);\n\n insertWebviewTagNormalizationStyles();\n};\n\n// Give <electrobun-webview>s some default styles that can\n// be easily overridden in the host document\nconst insertWebviewTagNormalizationStyles = () => {\n var style = document.createElement(\"style\");\n style.type = \"text/css\";\n\n var css = `\nelectrobun-webview {\n display: block;\n width: 800px;\n height: 300px;\n background: #fff;\n background-repeat: no-repeat!important; \n overflow: hidden; \n}\n`;\n\n style.appendChild(document.createTextNode(css));\n\n var head = document.getElementsByTagName(\"head\")[0];\n if (!head) {\n return;\n }\n\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n};\n\nexport { ConfigureWebviewTags };\n",
8
- "export const isAppRegionDrag = (e: MouseEvent) => {\n return e.target?.classList.contains(\"electrobun-webkit-app-region-drag\");\n};\n",
9
- "import {\n type RPCSchema,\n type RPCRequestHandler,\n type RPCOptions,\n type RPCMessageHandlerFn,\n type WildcardRPCMessageHandlerFn,\n type RPCTransport,\n createRPC,\n} from \"rpc-anywhere\";\nimport { ConfigureWebviewTags } from \"./webviewtag\";\n// todo: should this just be injected as a preload script?\nimport { isAppRegionDrag } from \"./stylesAndElements\";\nimport type { BuiltinBunToWebviewSchema } from \"./builtinrpcSchema\";\n\ninterface ElectrobunWebviewRPCSChema {\n bun: RPCSchema;\n webview: RPCSchema;\n}\n\nconst WEBVIEW_ID = window.__electrobunWebviewId;\n\n// todo (yoav): move this stuff to browser/rpc/webview.ts\ntype ZigWebviewHandlers = RPCSchema<{\n requests: {\n webviewTagCallAsyncJavaScript: {\n params: {\n messageId: string;\n webviewId: number;\n hostWebviewId: number;\n script: string;\n };\n response: void;\n };\n };\n}>;\n\ntype WebviewTagHandlers = RPCSchema<{\n requests: {};\n messages: {\n webviewTagResize: {\n id: number;\n frame: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n masks: string;\n };\n webviewTagUpdateSrc: {\n id: number;\n url: string;\n };\n webviewTagGoBack: {\n id: number;\n };\n webviewTagGoForward: {\n id: number;\n };\n webviewTagReload: {\n id: number;\n };\n webviewTagRemove: {\n id: number;\n };\n startWindowMove: {\n id: number;\n };\n stopWindowMove: {\n id: number;\n };\n moveWindowBy: {\n id: number;\n x: number;\n y: number;\n };\n webviewTagSetTransparent: {\n id: number;\n transparent: boolean;\n };\n webviewTagToggleMirroring: {\n id: number;\n enable: boolean;\n };\n webviewTagSetPassthrough: {\n id: number;\n enablePassthrough: boolean;\n };\n webviewTagSetHidden: {\n id: number;\n hidden: boolean;\n };\n };\n}>;\n\nclass Electroview<T> {\n // user's custom rpc browser <-> bun\n rpc?: T;\n rpcHandler?: (msg: any) => void;\n // electrobun rpc browser <-> zig\n zigRpc?: any;\n zigRpcHandler?: (msg: any) => void;\n // give it a default function\n syncRpc: (params: any) => any = () => {\n console.log(\"syncRpc not initialized\");\n };\n\n constructor(config: { rpc: T }) {\n this.rpc = config.rpc;\n this.init();\n }\n\n init() {\n // todo (yoav): should init webviewTag by default when src is local\n // and have a setting that forces it enabled or disabled\n this.initZigRpc();\n // Note:\n // syncRPC messages doesn't need to be defined since there's no need for sync 1-way message\n // just use non-blocking async rpc for that, we just need sync requests\n // We don't need request ids either since we're not receiving the response on a different pipe\n if (true) {\n // TODO: define sync requests on schema (separate from async reqeusts and messages)\n this.syncRpc = (msg: { method: string; params: any }) => {\n try {\n const messageString = JSON.stringify(msg);\n return this.bunBridgeSync(messageString);\n } catch (error) {\n console.error(\n \"bun: failed to serialize message to webview syncRpc\",\n error\n );\n }\n };\n }\n ConfigureWebviewTags(true, this.zigRpc, this.syncRpc);\n\n this.initElectrobunListeners();\n\n window.__electrobun = {\n receiveMessageFromBun: this.receiveMessageFromBun.bind(this),\n receiveMessageFromZig: this.receiveMessageFromZig.bind(this),\n };\n\n if (this.rpc) {\n this.rpc.setTransport(this.createTransport());\n }\n }\n\n initZigRpc() {\n this.zigRpc = createRPC<WebviewTagHandlers, ZigWebviewHandlers>({\n transport: this.createZigTransport(),\n // requestHandler: {\n\n // },\n maxRequestTime: 1000,\n });\n }\n\n // This will be attached to the global object, zig can rpc reply by executingJavascript\n // of that global reference to the function\n receiveMessageFromZig(msg: any) {\n if (this.zigRpcHandler) {\n this.zigRpcHandler(msg);\n }\n }\n\n // TODO: implement proper rpc-anywhere style rpc here\n // todo: this is duplicated in webviewtag.ts and should be DRYed up\n sendToZig(message: {}) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n }\n\n initElectrobunListeners() {\n document.addEventListener(\"mousedown\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.startWindowMove({ id: WEBVIEW_ID });\n }\n });\n\n document.addEventListener(\"mouseup\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.stopWindowMove({ id: WEBVIEW_ID });\n }\n });\n }\n\n createTransport() {\n const that = this;\n return {\n send(message) {\n try {\n const messageString = JSON.stringify(message);\n that.bunBridge(messageString);\n } catch (error) {\n console.error(\"bun: failed to serialize message to webview\", error);\n }\n },\n registerHandler(handler) {\n that.rpcHandler = handler;\n },\n };\n }\n\n createZigTransport(): RPCTransport {\n const that = this;\n return {\n send(message) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n },\n registerHandler(handler) {\n that.zigRpcHandler = handler;\n // webview tag doesn't handle any messages from zig just yet\n },\n };\n }\n\n // call any of your bun syncrpc methods in a way that appears synchronous from the browser context\n bunBridgeSync(msg: string) {\n var xhr = new XMLHttpRequest();\n // Note: setting false here makes the xhr request blocking. This completely\n // blocks the main thread which is terrible. You can use this safely from a webworker.\n // There are also cases where exposing bun sync apis (eg: existsSync) is useful especially\n // on a first pass when migrating from Electron to Electrobun.\n // This mechanism is designed to make any rpc call over the bridge into a sync blocking call\n // from the browser context while bun asynchronously replies. Use it sparingly from the main thread.\n xhr.open(\"POST\", \"views://syncrpc\", false); // Synchronous call\n xhr.send(msg);\n if (!xhr.responseText) {\n return xhr.responseText;\n }\n\n try {\n return JSON.parse(xhr.responseText);\n } catch {\n return xhr.responseText;\n }\n }\n\n bunBridge(msg: string) {\n // Note: messageHandlers seem to freeze when sending large messages\n // but xhr to views://rpc can run into CORS issues on non views://\n // loaded content (eg: when writing extensions/preload scripts for\n // remote content).\n\n // Since most messages--especially those on remote content, are small\n // we can solve most use cases by having a fallback to xhr for\n // large messages\n\n // TEMP: disable the fallback for now. for some reason suddenly can't\n // repro now that other places are chunking messages and laptop restart\n if (true || msg.length < 8 * 1024) {\n window.webkit.messageHandlers.bunBridge.postMessage(msg);\n } else {\n var xhr = new XMLHttpRequest();\n\n // Note: we're only using synchronouse http on this async\n // call to get around CORS for now\n // Note: DO NOT use postMessage handlers since it\n // freezes the process when sending lots of large messages\n\n xhr.open(\"POST\", \"views://rpc\", false); // sychronous call\n xhr.send(msg);\n }\n }\n\n receiveMessageFromBun(msg) {\n // NOTE: in the webview messages are passed by executing ElectrobunView.receiveMessageFromBun(object)\n // so they're already parsed into an object here\n if (this.rpcHandler) {\n this.rpcHandler(msg);\n }\n }\n // todo (yoav): This is mostly just the reverse of the one in BrowserView.ts on the bun side. Should DRY this up.\n static defineRPC<\n Schema extends ElectrobunWebviewRPCSChema,\n BunSchema extends RPCSchema = Schema[\"bun\"],\n WebviewSchema extends RPCSchema = Schema[\"webview\"]\n >(config: {\n maxRequestTime?: number;\n handlers: {\n requests?: RPCRequestHandler<WebviewSchema[\"requests\"]>;\n messages?: {\n [key in keyof WebviewSchema[\"messages\"]]: RPCMessageHandlerFn<\n WebviewSchema[\"messages\"],\n key\n >;\n } & {\n \"*\"?: WildcardRPCMessageHandlerFn<WebviewSchema[\"messages\"]>;\n };\n };\n }) {\n // Note: RPC Anywhere requires defining the requests that a schema handles and the messages that a schema sends.\n // eg: BunSchema {\n // requests: // ... requests bun handles, sent by webview\n // messages: // ... messages bun sends, handled by webview\n // }\n // In some generlized contexts that makes sense,\n // In the Electrobun context it can feel a bit counter-intuitive so we swap this around a bit. In Electrobun, the\n // webview and bun are known endpoints so we simplify schema definitions by combining them.\n // Schema {\n // bun: BunSchema {\n // requests: // ... requests bun sends, handled by webview,\n // messages: // ... messages bun sends, handled by webview\n // },\n // webview: WebviewSchema {\n // requests: // ... requests webview sends, handled by bun,\n // messages: // ... messages webview sends, handled by bun\n // },\n // }\n // electrobun also treats messages as \"requests that we don't wait for to complete\", and normalizes specifying the\n // handlers for them alongside request handlers.\n\n const builtinHandlers: {\n requests: RPCRequestHandler<BuiltinBunToWebviewSchema[\"requests\"]>;\n } = {\n requests: {\n evaluateJavascriptWithResponse: ({ script }) => {\n return new Promise((resolve) => {\n try {\n const resultFunction = new Function(script);\n const result = resultFunction();\n\n if (result instanceof Promise) {\n result\n .then((resolvedResult) => {\n resolve(resolvedResult);\n })\n .catch((error) => {\n console.error(\"bun: async script execution failed\", error);\n resolve(String(error));\n });\n } else {\n resolve(result);\n }\n } catch (error) {\n console.error(\"bun: failed to eval script\", error);\n resolve(String(error));\n }\n });\n },\n },\n };\n\n type mixedWebviewSchema = {\n requests: BunSchema[\"requests\"];\n messages: WebviewSchema[\"messages\"];\n };\n\n type mixedBunSchema = {\n requests: WebviewSchema[\"requests\"] &\n BuiltinBunToWebviewSchema[\"requests\"];\n messages: BunSchema[\"messages\"];\n };\n\n const rpcOptions = {\n maxRequestTime: config.maxRequestTime,\n requestHandler: {\n ...config.handlers.requests,\n ...builtinHandlers.requests,\n },\n transport: {\n // Note: RPC Anywhere will throw if you try add a message listener if transport.registerHandler is falsey\n registerHandler: () => {},\n },\n } as RPCOptions<mixedBunSchema, mixedWebviewSchema>;\n\n const rpc = createRPC<mixedBunSchema, mixedWebviewSchema>(rpcOptions);\n\n const messageHandlers = config.handlers.messages;\n if (messageHandlers) {\n // note: this can only be done once there is a transport\n // @ts-ignore - this is due to all the schema mixing we're doing, fine to ignore\n // while types in here are borked, they resolve correctly/bubble up to the defineRPC call site.\n rpc.addMessageListener(\n \"*\",\n (messageName: keyof WebviewSchema[\"messages\"], payload) => {\n const globalHandler = messageHandlers[\"*\"];\n if (globalHandler) {\n globalHandler(messageName, payload);\n }\n\n const messageHandler = messageHandlers[messageName];\n if (messageHandler) {\n messageHandler(payload);\n }\n }\n );\n }\n\n return rpc;\n }\n}\n\nexport { type RPCSchema, createRPC, Electroview };\n\nconst Electrobun = {\n Electroview,\n};\n\nexport default Electrobun;\n",
10
- "import {\n type RPCSchema,\n type RPCRequestHandler,\n type RPCOptions,\n type RPCMessageHandlerFn,\n type WildcardRPCMessageHandlerFn,\n type RPCTransport,\n createRPC,\n} from \"rpc-anywhere\";\nimport { ConfigureWebviewTags } from \"./webviewtag\";\n// todo: should this just be injected as a preload script?\nimport { isAppRegionDrag } from \"./stylesAndElements\";\nimport type { BuiltinBunToWebviewSchema } from \"./builtinrpcSchema\";\n\ninterface ElectrobunWebviewRPCSChema {\n bun: RPCSchema;\n webview: RPCSchema;\n}\n\nconst WEBVIEW_ID = window.__electrobunWebviewId;\n\n// todo (yoav): move this stuff to browser/rpc/webview.ts\ntype ZigWebviewHandlers = RPCSchema<{\n requests: {\n webviewTagCallAsyncJavaScript: {\n params: {\n messageId: string;\n webviewId: number;\n hostWebviewId: number;\n script: string;\n };\n response: void;\n };\n };\n}>;\n\ntype WebviewTagHandlers = RPCSchema<{\n requests: {};\n messages: {\n webviewTagResize: {\n id: number;\n frame: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n masks: string;\n };\n webviewTagUpdateSrc: {\n id: number;\n url: string;\n };\n webviewTagGoBack: {\n id: number;\n };\n webviewTagGoForward: {\n id: number;\n };\n webviewTagReload: {\n id: number;\n };\n webviewTagRemove: {\n id: number;\n };\n startWindowMove: {\n id: number;\n };\n stopWindowMove: {\n id: number;\n };\n moveWindowBy: {\n id: number;\n x: number;\n y: number;\n };\n webviewTagSetTransparent: {\n id: number;\n transparent: boolean;\n };\n webviewTagToggleMirroring: {\n id: number;\n enable: boolean;\n };\n webviewTagSetPassthrough: {\n id: number;\n enablePassthrough: boolean;\n };\n webviewTagSetHidden: {\n id: number;\n hidden: boolean;\n };\n };\n}>;\n\nclass Electroview<T> {\n // user's custom rpc browser <-> bun\n rpc?: T;\n rpcHandler?: (msg: any) => void;\n // electrobun rpc browser <-> zig\n zigRpc?: any;\n zigRpcHandler?: (msg: any) => void;\n // give it a default function\n syncRpc: (params: any) => any = () => {\n console.log(\"syncRpc not initialized\");\n };\n\n constructor(config: { rpc: T }) {\n this.rpc = config.rpc;\n this.init();\n }\n\n init() {\n // todo (yoav): should init webviewTag by default when src is local\n // and have a setting that forces it enabled or disabled\n this.initZigRpc();\n // Note:\n // syncRPC messages doesn't need to be defined since there's no need for sync 1-way message\n // just use non-blocking async rpc for that, we just need sync requests\n // We don't need request ids either since we're not receiving the response on a different pipe\n if (true) {\n // TODO: define sync requests on schema (separate from async reqeusts and messages)\n this.syncRpc = (msg: { method: string; params: any }) => {\n try {\n const messageString = JSON.stringify(msg);\n return this.bunBridgeSync(messageString);\n } catch (error) {\n console.error(\n \"bun: failed to serialize message to webview syncRpc\",\n error\n );\n }\n };\n }\n ConfigureWebviewTags(true, this.zigRpc, this.syncRpc);\n\n this.initElectrobunListeners();\n\n window.__electrobun = {\n receiveMessageFromBun: this.receiveMessageFromBun.bind(this),\n receiveMessageFromZig: this.receiveMessageFromZig.bind(this),\n };\n\n if (this.rpc) {\n this.rpc.setTransport(this.createTransport());\n }\n }\n\n initZigRpc() {\n this.zigRpc = createRPC<WebviewTagHandlers, ZigWebviewHandlers>({\n transport: this.createZigTransport(),\n // requestHandler: {\n\n // },\n maxRequestTime: 1000,\n });\n }\n\n // This will be attached to the global object, zig can rpc reply by executingJavascript\n // of that global reference to the function\n receiveMessageFromZig(msg: any) {\n if (this.zigRpcHandler) {\n this.zigRpcHandler(msg);\n }\n }\n\n // TODO: implement proper rpc-anywhere style rpc here\n // todo: this is duplicated in webviewtag.ts and should be DRYed up\n sendToZig(message: {}) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n }\n\n initElectrobunListeners() {\n document.addEventListener(\"mousedown\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.startWindowMove({ id: WEBVIEW_ID });\n }\n });\n\n document.addEventListener(\"mouseup\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.stopWindowMove({ id: WEBVIEW_ID });\n }\n });\n }\n\n createTransport() {\n const that = this;\n return {\n send(message) {\n try {\n const messageString = JSON.stringify(message);\n that.bunBridge(messageString);\n } catch (error) {\n console.error(\"bun: failed to serialize message to webview\", error);\n }\n },\n registerHandler(handler) {\n that.rpcHandler = handler;\n },\n };\n }\n\n createZigTransport(): RPCTransport {\n const that = this;\n return {\n send(message) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n },\n registerHandler(handler) {\n that.zigRpcHandler = handler;\n // webview tag doesn't handle any messages from zig just yet\n },\n };\n }\n\n // call any of your bun syncrpc methods in a way that appears synchronous from the browser context\n bunBridgeSync(msg: string) {\n var xhr = new XMLHttpRequest();\n // Note: setting false here makes the xhr request blocking. This completely\n // blocks the main thread which is terrible. You can use this safely from a webworker.\n // There are also cases where exposing bun sync apis (eg: existsSync) is useful especially\n // on a first pass when migrating from Electron to Electrobun.\n // This mechanism is designed to make any rpc call over the bridge into a sync blocking call\n // from the browser context while bun asynchronously replies. Use it sparingly from the main thread.\n xhr.open(\"POST\", \"views://syncrpc\", false); // Synchronous call\n xhr.send(msg);\n if (!xhr.responseText) {\n return xhr.responseText;\n }\n\n try {\n return JSON.parse(xhr.responseText);\n } catch {\n return xhr.responseText;\n }\n }\n\n bunBridge(msg: string) {\n // Note: messageHandlers seem to freeze when sending large messages\n // but xhr to views://rpc can run into CORS issues on non views://\n // loaded content (eg: when writing extensions/preload scripts for\n // remote content).\n\n // Since most messages--especially those on remote content, are small\n // we can solve most use cases by having a fallback to xhr for\n // large messages\n\n // TEMP: disable the fallback for now. for some reason suddenly can't\n // repro now that other places are chunking messages and laptop restart\n if (true || msg.length < 8 * 1024) {\n window.webkit.messageHandlers.bunBridge.postMessage(msg);\n } else {\n var xhr = new XMLHttpRequest();\n\n // Note: we're only using synchronouse http on this async\n // call to get around CORS for now\n // Note: DO NOT use postMessage handlers since it\n // freezes the process when sending lots of large messages\n\n xhr.open(\"POST\", \"views://rpc\", false); // sychronous call\n xhr.send(msg);\n }\n }\n\n receiveMessageFromBun(msg) {\n // NOTE: in the webview messages are passed by executing ElectrobunView.receiveMessageFromBun(object)\n // so they're already parsed into an object here\n if (this.rpcHandler) {\n this.rpcHandler(msg);\n }\n }\n // todo (yoav): This is mostly just the reverse of the one in BrowserView.ts on the bun side. Should DRY this up.\n static defineRPC<\n Schema extends ElectrobunWebviewRPCSChema,\n BunSchema extends RPCSchema = Schema[\"bun\"],\n WebviewSchema extends RPCSchema = Schema[\"webview\"]\n >(config: {\n maxRequestTime?: number;\n handlers: {\n requests?: RPCRequestHandler<WebviewSchema[\"requests\"]>;\n messages?: {\n [key in keyof WebviewSchema[\"messages\"]]: RPCMessageHandlerFn<\n WebviewSchema[\"messages\"],\n key\n >;\n } & {\n \"*\"?: WildcardRPCMessageHandlerFn<WebviewSchema[\"messages\"]>;\n };\n };\n }) {\n // Note: RPC Anywhere requires defining the requests that a schema handles and the messages that a schema sends.\n // eg: BunSchema {\n // requests: // ... requests bun handles, sent by webview\n // messages: // ... messages bun sends, handled by webview\n // }\n // In some generlized contexts that makes sense,\n // In the Electrobun context it can feel a bit counter-intuitive so we swap this around a bit. In Electrobun, the\n // webview and bun are known endpoints so we simplify schema definitions by combining them.\n // Schema {\n // bun: BunSchema {\n // requests: // ... requests bun sends, handled by webview,\n // messages: // ... messages bun sends, handled by webview\n // },\n // webview: WebviewSchema {\n // requests: // ... requests webview sends, handled by bun,\n // messages: // ... messages webview sends, handled by bun\n // },\n // }\n // electrobun also treats messages as \"requests that we don't wait for to complete\", and normalizes specifying the\n // handlers for them alongside request handlers.\n\n const builtinHandlers: {\n requests: RPCRequestHandler<BuiltinBunToWebviewSchema[\"requests\"]>;\n } = {\n requests: {\n evaluateJavascriptWithResponse: ({ script }) => {\n return new Promise((resolve) => {\n try {\n const resultFunction = new Function(script);\n const result = resultFunction();\n\n if (result instanceof Promise) {\n result\n .then((resolvedResult) => {\n resolve(resolvedResult);\n })\n .catch((error) => {\n console.error(\"bun: async script execution failed\", error);\n resolve(String(error));\n });\n } else {\n resolve(result);\n }\n } catch (error) {\n console.error(\"bun: failed to eval script\", error);\n resolve(String(error));\n }\n });\n },\n },\n };\n\n type mixedWebviewSchema = {\n requests: BunSchema[\"requests\"];\n messages: WebviewSchema[\"messages\"];\n };\n\n type mixedBunSchema = {\n requests: WebviewSchema[\"requests\"] &\n BuiltinBunToWebviewSchema[\"requests\"];\n messages: BunSchema[\"messages\"];\n };\n\n const rpcOptions = {\n maxRequestTime: config.maxRequestTime,\n requestHandler: {\n ...config.handlers.requests,\n ...builtinHandlers.requests,\n },\n transport: {\n // Note: RPC Anywhere will throw if you try add a message listener if transport.registerHandler is falsey\n registerHandler: () => {},\n },\n } as RPCOptions<mixedBunSchema, mixedWebviewSchema>;\n\n const rpc = createRPC<mixedBunSchema, mixedWebviewSchema>(rpcOptions);\n\n const messageHandlers = config.handlers.messages;\n if (messageHandlers) {\n // note: this can only be done once there is a transport\n // @ts-ignore - this is due to all the schema mixing we're doing, fine to ignore\n // while types in here are borked, they resolve correctly/bubble up to the defineRPC call site.\n rpc.addMessageListener(\n \"*\",\n (messageName: keyof WebviewSchema[\"messages\"], payload) => {\n const globalHandler = messageHandlers[\"*\"];\n if (globalHandler) {\n globalHandler(messageName, payload);\n }\n\n const messageHandler = messageHandlers[messageName];\n if (messageHandler) {\n messageHandler(payload);\n }\n }\n );\n }\n\n return rpc;\n }\n}\n\nexport { type RPCSchema, createRPC, Electroview };\n\nconst Electrobun = {\n Electroview,\n};\n\nexport default Electrobun;\n"
6
+ "import { _createRPC } from \"./rpc.js\";\n/**\n * Creates an RPC instance that can send and receive requests, responses\n * and messages.\n */\nexport function createRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n/**\n * Creates an RPC instance as a client. The passed schema represents\n * the remote RPC's (server) schema.\n */\nexport function createClientRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n/**\n * Creates an RPC instance as a server. The passed schema represents\n * this RPC's (server) schema.\n */\nexport function createServerRPC(\n/**\n * The options that will be used to configure the RPC instance.\n */\noptions) {\n return _createRPC(options);\n}\n",
7
+ "type WebviewEventTypes =\n | \"did-navigate\"\n | \"did-navigate-in-page\"\n | \"did-commit-navigation\"\n | \"dom-ready\";\n\ntype Rect = { x: number; y: number; width: number; height: number };\n\nconst ConfigureWebviewTags = (\n enableWebviewTags: boolean,\n zigRpc: (params: any) => any,\n syncRpc: (params: any) => any\n) => {\n if (!enableWebviewTags) {\n return;\n }\n\n // todo: provide global types for <electrobun-webview> tag elements (like querySelector results etc.)\n\n class WebviewTag extends HTMLElement {\n // todo (yoav): come up with a better mechanism to eliminate collisions with bun created\n // webviews\n webviewId?: number; // = nextWebviewId++;\n\n // rpc\n zigRpc: any;\n syncRpc: any;\n\n // querySelectors for elements that you want to appear\n // in front of the webview.\n maskSelectors: Set<string> = new Set();\n\n // observers\n resizeObserver?: ResizeObserver;\n // intersectionObserver?: IntersectionObserver;\n // mutationObserver?: MutationObserver;\n\n positionCheckLoop?: Timer;\n positionCheckLoopReset?: Timer;\n\n lastRect = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n\n lastMasksJSON: string = \"\";\n lastMasks: Rect[] = [];\n\n transparent: boolean = false;\n passthroughEnabled: boolean = false;\n hidden: boolean = false;\n delegateMode: boolean = false;\n hiddenMirrorMode: boolean = false;\n wasZeroRect: boolean = false;\n isMirroring: boolean = false;\n\n partition: string | null = null;\n\n constructor() {\n super();\n this.zigRpc = zigRpc;\n this.syncRpc = syncRpc;\n\n // Give it a frame to be added to the dom and render before measuring\n requestAnimationFrame(() => {\n this.initWebview();\n });\n }\n\n addMaskSelector(selector: string) {\n this.maskSelectors.add(selector);\n this.syncDimensions();\n }\n\n removeMaskSelector(selector: string) {\n this.maskSelectors.delete(selector);\n this.syncDimensions();\n }\n\n initWebview() {\n const rect = this.getBoundingClientRect();\n this.lastRect = rect;\n\n const webviewId = this.syncRpc({\n method: \"webviewTagInit\",\n params: {\n hostWebviewId: window.__electrobunWebviewId,\n windowId: window.__electrobunWindowId,\n url: this.src || this.getAttribute(\"src\") || null,\n html: this.html || this.getAttribute(\"html\") || null,\n preload: this.preload || this.getAttribute(\"preload\") || null,\n partition: this.partition || this.getAttribute(\"partition\") || null,\n frame: {\n width: rect.width,\n height: rect.height,\n x: rect.x,\n y: rect.y,\n },\n },\n });\n\n this.webviewId = webviewId;\n this.id = `electrobun-webview-${webviewId}`;\n // todo: replace zig -> webviewtag communication with a global instead of\n // queryselector based on id\n this.setAttribute(\"id\", this.id);\n }\n\n asyncResolvers: {\n [id: string]: { resolve: (arg: any) => void; reject: (arg: any) => void };\n } = {};\n\n callAsyncJavaScript({ script }: { script: string }) {\n return new Promise((resolve, reject) => {\n const messageId = \"\" + Date.now() + Math.random();\n this.asyncResolvers[messageId] = {\n resolve,\n reject,\n };\n\n this.zigRpc.request.webviewTagCallAsyncJavaScript({\n messageId,\n webviewId: this.webviewId,\n hostWebviewId: window.__electrobunWebviewId,\n script,\n });\n });\n }\n\n setCallAsyncJavaScriptResponse(messageId: string, response: any) {\n const resolvers = this.asyncResolvers[messageId];\n delete this.asyncResolvers[messageId];\n try {\n response = JSON.parse(response);\n\n if (response.result) {\n resolvers.resolve(response.result);\n } else {\n resolvers.reject(response.error);\n }\n } catch (e: any) {\n resolvers.reject(e.message);\n }\n }\n\n async canGoBack() {\n const {\n payload: { webviewTagCanGoBackResponse },\n } = await this.zigRpc.request.webviewTagCanGoBack({ id: this.webviewId });\n return webviewTagCanGoBackResponse;\n }\n\n async canGoForward() {\n const {\n payload: { webviewTagCanGoForwardResponse },\n } = await this.zigRpc.request.webviewTagCanGoForward({\n id: this.webviewId,\n });\n return webviewTagCanGoForwardResponse;\n }\n\n // propertie setters/getters. keeps them in sync with dom attributes\n updateAttr(name: string, value: string | null) {\n if (value) {\n this.setAttribute(name, value);\n } else {\n this.removeAttribute(name);\n }\n }\n\n get src() {\n return this.getAttribute(\"src\");\n }\n\n set src(value) {\n this.updateAttr(\"src\", value);\n }\n\n get html() {\n return this.getAttribute(\"html\");\n }\n\n set html(value) {\n this.updateAttr(\"html\", value);\n }\n\n get preload() {\n return this.getAttribute(\"preload\");\n }\n\n set preload(value) {\n this.updateAttr(\"preload\", value);\n }\n\n // Note: since <electrobun-webview> is an anchor for a native webview\n // on osx even if we hide it, enable mouse passthrough etc. There\n // are still events like drag events which are natively handled deep in the window manager\n // and will be handled incorrectly. To get around this for now we need to\n // move the webview off screen during delegate mode.\n adjustDimensionsForHiddenMirrorMode(rect: DOMRect) {\n if (this.hiddenMirrorMode) {\n rect.x = 0 - rect.width;\n }\n\n return rect;\n }\n\n // Note: in the brwoser-context we can ride on the dom element's uilt in event emitter for managing custom events\n on(event: WebviewEventTypes, listener: () => {}) {\n this.addEventListener(event, listener);\n }\n\n off(event: WebviewEventTypes, listener: () => {}) {\n this.removeEventListener(event, listener);\n }\n\n // This is typically called by injected js from zig\n emit(event: WebviewEventTypes, detail: any) {\n this.dispatchEvent(new CustomEvent(event, { detail }));\n }\n\n // Call this via document.querySelector('electrobun-webview').syncDimensions();\n // That way the host can trigger an alignment with the nested webview when they\n // know that they're chaning something in order to eliminate the lag that the\n // catch all loop will catch\n syncDimensions(force: boolean = false) {\n if (!this.webviewId || (!force && this.hidden)) {\n return;\n }\n\n const rect = this.getBoundingClientRect();\n const { x, y, width, height } =\n this.adjustDimensionsForHiddenMirrorMode(rect);\n const lastRect = this.lastRect;\n\n if (width === 0 && height === 0) {\n if (this.wasZeroRect === false) {\n this.wasZeroRect = true;\n this.toggleHidden(true, true);\n }\n return;\n }\n\n const masks: Rect[] = [];\n this.maskSelectors.forEach((selector) => {\n const els = document.querySelectorAll(selector);\n\n for (let i = 0; i < els.length; i++) {\n const el = els[i];\n\n if (el) {\n const maskRect = el.getBoundingClientRect();\n\n masks.push({\n // reposition the bounding rect to be relative to the webview rect\n // so objc can apply the mask correctly and handle the actual overlap\n x: maskRect.x - x,\n y: maskRect.y - y,\n width: maskRect.width,\n height: maskRect.height,\n });\n }\n }\n });\n\n // store jsonStringified last masks value to compare\n const masksJson = masks.length ? JSON.stringify(masks) : \"\";\n\n if (\n force ||\n lastRect.x !== x ||\n lastRect.y !== y ||\n lastRect.width !== width ||\n lastRect.height !== height ||\n this.lastMasksJSON !== masksJson\n ) {\n // let it know we're still accelerating\n this.setPositionCheckLoop(true);\n\n this.lastRect = rect;\n this.lastMasks = masks;\n this.lastMasksJSON = masksJson;\n\n this.zigRpc.send.webviewTagResize({\n id: this.webviewId,\n frame: {\n width: width,\n height: height,\n x: x,\n y: y,\n },\n masks: masksJson,\n });\n }\n\n if (this.wasZeroRect) {\n this.wasZeroRect = false;\n this.toggleHidden(false, true);\n }\n }\n\n boundSyncDimensions = () => this.syncDimensions();\n boundForceSyncDimensions = () => this.syncDimensions(true);\n\n setPositionCheckLoop(accelerate = false) {\n if (this.positionCheckLoop) {\n clearInterval(this.positionCheckLoop);\n this.positionCheckLoop = undefined;\n }\n\n if (this.positionCheckLoopReset) {\n clearTimeout(this.positionCheckLoopReset);\n this.positionCheckLoopReset = undefined;\n }\n\n const delay = accelerate ? 0 : 300;\n\n if (accelerate) {\n this.positionCheckLoopReset = setTimeout(() => {\n this.setPositionCheckLoop(false);\n }, 2000);\n }\n // Note: Since there's not catch all way to listen for x/y changes\n // we have a 400ms interval to check\n // on m1 max this 400ms interval for one nested webview\n // only uses around 0.1% cpu\n\n // Note: We also listen for resize events and changes to\n // certain properties to get reactive repositioning for\n // many cases.\n\n // todo: consider having an option to disable this and let user\n // trigger position sync for high performance cases (like\n // a browser with a hundred tabs)\n this.positionCheckLoop = setInterval(() => this.syncDimensions(), delay);\n }\n\n connectedCallback() {\n this.setPositionCheckLoop();\n\n this.resizeObserver = new ResizeObserver(() => {\n this.syncDimensions();\n });\n // Note: In objc the webview is positioned in the window from the bottom-left corner\n // the html anchor is positioned in the webview from the top-left corner\n // In those cases the getBoundingClientRect() will return the same value, but\n // we still need to send it to objc to calculate from its bottom left position\n // otherwise it'll move around unexpectedly.\n window.addEventListener(\"resize\", this.boundForceSyncDimensions);\n window.addEventListener(\"scroll\", this.boundSyncDimensions);\n\n // todo: For chromium webviews (windows native or chromium bundled)\n // should be able to use performanceObservers on layout-shift to\n // call syncDimensions more reactively\n }\n\n disconnectedCallback() {\n // removed from the dom\n clearInterval(this.positionCheckLoop);\n\n this.resizeObserver?.disconnect();\n // this.intersectionObserver?.disconnect();\n // this.mutationObserver?.disconnect();\n window.removeEventListener(\"resize\", this.boundForceSyncDimensions);\n window.removeEventListener(\"scroll\", this.boundSyncDimensions);\n this.zigRpc.send.webviewTagRemove({ id: this.webviewId });\n }\n\n static get observedAttributes() {\n // TODO: support html, preload, and other stuff here\n return [\"src\", \"html\", \"preload\", \"class\", \"style\"];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === \"src\" && oldValue !== newValue) {\n this.updateIFrameSrc(newValue);\n } else if (name === \"html\" && oldValue !== newValue) {\n this.updateIFrameHtml(newValue);\n } else if (name === \"preload\" && oldValue !== newValue) {\n this.updateIFramePreload(newValue);\n } else {\n this.syncDimensions();\n }\n }\n\n updateIFrameSrc(src: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdateSrc({\n id: this.webviewId,\n url: src,\n });\n }\n\n updateIFrameHtml(html: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdateHtml({\n id: this.webviewId,\n html,\n });\n }\n\n updateIFramePreload(preload: string) {\n if (!this.webviewId) {\n return;\n }\n this.zigRpc.send.webviewTagUpdatePreload({\n id: this.webviewId,\n preload,\n });\n }\n\n goBack() {\n this.zigRpc.send.webviewTagGoBack({ id: this.webviewId });\n }\n\n goForward() {\n this.zigRpc.send.webviewTagGoForward({ id: this.webviewId });\n }\n\n reload() {\n this.zigRpc.send.webviewTagReload({ id: this.webviewId });\n }\n loadURL(url: string) {\n this.setAttribute(\"src\", url);\n this.zigRpc.send.webviewTagUpdateSrc({\n id: this.webviewId,\n url,\n });\n }\n // Note: you can set an interval and do this 60 times a second and it's pretty smooth\n // but it uses quite a bit of cpu\n // todo: change this to \"mirror to dom\" or something\n syncScreenshot(callback?: () => void) {\n const cacheBustString = `?${Date.now()}`;\n const url = `views://screenshot/${this.webviewId}${cacheBustString}`;\n const img = new Image();\n img.src = url;\n img.onload = () => {\n this.style.backgroundImage = `url(${url})`;\n if (callback) {\n // We've preloaded the image, but we still want to give it a chance to render\n // after setting the background style. give it quite a bit longer than a rafr\n setTimeout(callback, 100);\n }\n };\n }\n\n DEFAULT_FRAME_RATE = Math.round(1000 / 30); // 30fps\n streamScreenInterval?: Timer;\n\n // NOTE: This is very cpu intensive, Prefer startMirroring where possible\n startMirroringToDom(frameRate: number = this.DEFAULT_FRAME_RATE) {\n if (this.streamScreenInterval) {\n clearInterval(this.streamScreenInterval);\n }\n\n this.streamScreenInterval = setInterval(() => {\n this.syncScreenshot();\n }, frameRate);\n }\n\n stopMirroringToDom() {\n if (this.streamScreenInterval) {\n clearInterval(this.streamScreenInterval);\n this.streamScreenInterval = undefined;\n }\n }\n\n startMirroring() {\n // TEMP: mirroring now happens automatically in objc\n // when the mouse moves. I'm leaving this here for now\n // because I suspect there may still be use cases to\n // toggle it from the dom outside of the mouse moving.\n return;\n if (this.isMirroring === false) {\n this.isMirroring = true;\n this.zigRpc.send.webviewTagToggleMirroring({\n id: this.webviewId,\n enable: true,\n });\n }\n }\n\n stopMirroring() {\n return;\n if (this.isMirroring === true) {\n this.isMirroring = false;\n this.zigRpc.send.webviewTagToggleMirroring({\n id: this.webviewId,\n enable: false,\n });\n }\n }\n\n clearScreenImage() {\n this.style.backgroundImage = \"\";\n }\n\n tryClearScreenImage() {\n if (\n !this.transparent &&\n !this.hiddenMirrorMode &&\n !this.delegateMode &&\n !this.hidden\n ) {\n this.clearScreenImage();\n }\n }\n // This sets the native webview hovering over the dom to be transparent\n toggleTransparent(transparent?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof transparent === \"undefined\") {\n this.transparent = !this.transparent;\n } else {\n this.transparent = transparent;\n }\n }\n\n if (!this.transparent && !transparent) {\n this.tryClearScreenImage();\n }\n\n this.zigRpc.send.webviewTagSetTransparent({\n id: this.webviewId,\n transparent: this.transparent || Boolean(transparent),\n });\n }\n togglePassthrough(enablePassthrough?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof enablePassthrough === \"undefined\") {\n this.passthroughEnabled = !this.passthroughEnabled;\n } else {\n this.passthroughEnabled = enablePassthrough;\n }\n }\n\n this.zigRpc.send.webviewTagSetPassthrough({\n id: this.webviewId,\n enablePassthrough:\n this.passthroughEnabled || Boolean(enablePassthrough),\n });\n }\n\n toggleHidden(hidden?: boolean, bypassState?: boolean) {\n if (!bypassState) {\n if (typeof hidden === \"undefined\") {\n this.hidden = !this.hidden;\n } else {\n this.hidden = hidden;\n }\n }\n\n this.zigRpc.send.webviewTagSetHidden({\n id: this.webviewId,\n hidden: this.hidden || Boolean(hidden),\n });\n }\n\n // note: delegateMode and hiddenMirrorMode are experimental\n // ideally delegate mode would move the webview off screen\n // and delegate mouse and keyboard events to the webview while\n // streaming the screen so it can be fully layered in the dom\n // and fully interactive.\n toggleDelegateMode(delegateMode?: boolean) {\n const _newDelegateMode =\n typeof delegateMode === \"undefined\" ? !this.delegateMode : delegateMode;\n\n if (_newDelegateMode) {\n this.syncScreenshot(() => {\n this.delegateMode = true;\n this.toggleTransparent(true, true);\n this.startMirroringToDom();\n });\n } else {\n this.delegateMode = false;\n this.stopMirroringToDom();\n this.toggleTransparent(this.transparent);\n this.tryClearScreenImage();\n }\n }\n\n // While hiddenMirroMode would be similar to delegate mode but non-interactive\n // This is used while scrolling or resizing the <electrobun-webviewtag> to\n // make it smoother (scrolls with the dom) but disables interaction so that\n // during the scroll we don't need to worry about the webview being misaligned\n // with the mirror and accidentlly clicking on the wrong thing.\n toggleHiddenMirrorMode(force: boolean) {\n const enable =\n typeof force === \"undefined\" ? !this.hiddenMirrorMode : force;\n\n if (enable === true) {\n this.syncScreenshot(() => {\n this.hiddenMirrorMode = true;\n this.toggleHidden(true, true);\n this.togglePassthrough(true, true);\n this.startMirroringToDom();\n });\n } else {\n this.stopMirroringToDom();\n this.toggleHidden(this.hidden);\n this.togglePassthrough(this.passthroughEnabled);\n this.tryClearScreenImage();\n this.hiddenMirrorMode = false;\n }\n }\n }\n\n customElements.define(\"electrobun-webview\", WebviewTag);\n\n insertWebviewTagNormalizationStyles();\n};\n\n// Give <electrobun-webview>s some default styles that can\n// be easily overridden in the host document\nconst insertWebviewTagNormalizationStyles = () => {\n var style = document.createElement(\"style\");\n style.type = \"text/css\";\n\n var css = `\nelectrobun-webview {\n display: block;\n width: 800px;\n height: 300px;\n background: #fff;\n background-repeat: no-repeat!important; \n overflow: hidden; \n}\n`;\n\n style.appendChild(document.createTextNode(css));\n\n var head = document.getElementsByTagName(\"head\")[0];\n if (!head) {\n return;\n }\n\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n};\n\nexport { ConfigureWebviewTags };\n",
8
+ "export const isAppRegionDrag = (e: MouseEvent) => {\n return e.target?.classList.contains(\"electrobun-webkit-app-region-drag\");\n};\n",
9
+ "import {\n type RPCSchema,\n type RPCRequestHandler,\n type RPCOptions,\n type RPCMessageHandlerFn,\n type WildcardRPCMessageHandlerFn,\n type RPCTransport,\n createRPC,\n} from \"rpc-anywhere\";\nimport { ConfigureWebviewTags } from \"./webviewtag\";\n// todo: should this just be injected as a preload script?\nimport { isAppRegionDrag } from \"./stylesAndElements\";\nimport type { BuiltinBunToWebviewSchema } from \"./builtinrpcSchema\";\n\ninterface ElectrobunWebviewRPCSChema {\n bun: RPCSchema;\n webview: RPCSchema;\n}\n\nconst WEBVIEW_ID = window.__electrobunWebviewId;\n\n// todo (yoav): move this stuff to browser/rpc/webview.ts\ntype ZigWebviewHandlers = RPCSchema<{\n requests: {\n webviewTagCallAsyncJavaScript: {\n params: {\n messageId: string;\n webviewId: number;\n hostWebviewId: number;\n script: string;\n };\n response: void;\n };\n };\n}>;\n\ntype WebviewTagHandlers = RPCSchema<{\n requests: {};\n messages: {\n webviewTagResize: {\n id: number;\n frame: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n masks: string;\n };\n webviewTagUpdateSrc: {\n id: number;\n url: string;\n };\n webviewTagGoBack: {\n id: number;\n };\n webviewTagGoForward: {\n id: number;\n };\n webviewTagReload: {\n id: number;\n };\n webviewTagRemove: {\n id: number;\n };\n startWindowMove: {\n id: number;\n };\n stopWindowMove: {\n id: number;\n };\n moveWindowBy: {\n id: number;\n x: number;\n y: number;\n };\n webviewTagSetTransparent: {\n id: number;\n transparent: boolean;\n };\n webviewTagToggleMirroring: {\n id: number;\n enable: boolean;\n };\n webviewTagSetPassthrough: {\n id: number;\n enablePassthrough: boolean;\n };\n webviewTagSetHidden: {\n id: number;\n hidden: boolean;\n };\n };\n}>;\n\nclass Electroview<T> {\n // user's custom rpc browser <-> bun\n rpc?: T;\n rpcHandler?: (msg: any) => void;\n // electrobun rpc browser <-> zig\n zigRpc?: any;\n zigRpcHandler?: (msg: any) => void;\n // give it a default function\n syncRpc: (params: any) => any = () => {\n console.log(\"syncRpc not initialized\");\n };\n\n constructor(config: { rpc: T }) {\n this.rpc = config.rpc;\n this.init();\n }\n\n init() {\n // todo (yoav): should init webviewTag by default when src is local\n // and have a setting that forces it enabled or disabled\n this.initZigRpc();\n // Note:\n // syncRPC messages doesn't need to be defined since there's no need for sync 1-way message\n // just use non-blocking async rpc for that, we just need sync requests\n // We don't need request ids either since we're not receiving the response on a different pipe\n if (true) {\n // TODO: define sync requests on schema (separate from async reqeusts and messages)\n this.syncRpc = (msg: { method: string; params: any }) => {\n try {\n const messageString = JSON.stringify(msg);\n return this.bunBridgeSync(messageString);\n } catch (error) {\n console.error(\n \"bun: failed to serialize message to webview syncRpc\",\n error\n );\n }\n };\n }\n ConfigureWebviewTags(true, this.zigRpc, this.syncRpc);\n\n this.initElectrobunListeners();\n\n window.__electrobun = {\n receiveMessageFromBun: this.receiveMessageFromBun.bind(this),\n receiveMessageFromZig: this.receiveMessageFromZig.bind(this),\n };\n\n if (this.rpc) {\n this.rpc.setTransport(this.createTransport());\n }\n }\n\n initZigRpc() {\n this.zigRpc = createRPC<WebviewTagHandlers, ZigWebviewHandlers>({\n transport: this.createZigTransport(),\n // requestHandler: {\n\n // },\n maxRequestTime: 1000,\n });\n }\n\n // This will be attached to the global object, zig can rpc reply by executingJavascript\n // of that global reference to the function\n receiveMessageFromZig(msg: any) {\n if (this.zigRpcHandler) {\n this.zigRpcHandler(msg);\n }\n }\n\n // TODO: implement proper rpc-anywhere style rpc here\n // todo: this is duplicated in webviewtag.ts and should be DRYed up\n sendToZig(message: {}) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n }\n\n initElectrobunListeners() {\n document.addEventListener(\"mousedown\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.startWindowMove({ id: WEBVIEW_ID });\n }\n });\n\n document.addEventListener(\"mouseup\", (e) => {\n if (isAppRegionDrag(e)) {\n this.zigRpc?.send.stopWindowMove({ id: WEBVIEW_ID });\n }\n });\n }\n\n createTransport() {\n const that = this;\n return {\n send(message) {\n try {\n const messageString = JSON.stringify(message);\n that.bunBridge(messageString);\n } catch (error) {\n console.error(\"bun: failed to serialize message to webview\", error);\n }\n },\n registerHandler(handler) {\n that.rpcHandler = handler;\n },\n };\n }\n\n createZigTransport(): RPCTransport {\n const that = this;\n return {\n send(message) {\n window.webkit.messageHandlers.webviewTagBridge.postMessage(\n JSON.stringify(message)\n );\n },\n registerHandler(handler) {\n that.zigRpcHandler = handler;\n // webview tag doesn't handle any messages from zig just yet\n },\n };\n }\n\n // call any of your bun syncrpc methods in a way that appears synchronous from the browser context\n bunBridgeSync(msg: string) {\n var xhr = new XMLHttpRequest();\n // Note: setting false here makes the xhr request blocking. This completely\n // blocks the main thread which is terrible. You can use this safely from a webworker.\n // There are also cases where exposing bun sync apis (eg: existsSync) is useful especially\n // on a first pass when migrating from Electron to Electrobun.\n // This mechanism is designed to make any rpc call over the bridge into a sync blocking call\n // from the browser context while bun asynchronously replies. Use it sparingly from the main thread.\n xhr.open(\"POST\", \"views://syncrpc\", false); // Synchronous call\n xhr.send(msg);\n if (!xhr.responseText) {\n return xhr.responseText;\n }\n\n try {\n return JSON.parse(xhr.responseText);\n } catch {\n return xhr.responseText;\n }\n }\n\n bunBridge(msg: string) {\n // Note: messageHandlers seem to freeze when sending large messages\n // but xhr to views://rpc can run into CORS issues on non views://\n // loaded content (eg: when writing extensions/preload scripts for\n // remote content).\n\n // Since most messages--especially those on remote content, are small\n // we can solve most use cases by having a fallback to xhr for\n // large messages\n\n // TEMP: disable the fallback for now. for some reason suddenly can't\n // repro now that other places are chunking messages and laptop restart\n if (true || msg.length < 8 * 1024) {\n window.webkit.messageHandlers.bunBridge.postMessage(msg);\n } else {\n var xhr = new XMLHttpRequest();\n\n // Note: we're only using synchronouse http on this async\n // call to get around CORS for now\n // Note: DO NOT use postMessage handlers since it\n // freezes the process when sending lots of large messages\n\n xhr.open(\"POST\", \"views://rpc\", false); // sychronous call\n xhr.send(msg);\n }\n }\n\n receiveMessageFromBun(msg) {\n // NOTE: in the webview messages are passed by executing ElectrobunView.receiveMessageFromBun(object)\n // so they're already parsed into an object here\n if (this.rpcHandler) {\n this.rpcHandler(msg);\n }\n }\n // todo (yoav): This is mostly just the reverse of the one in BrowserView.ts on the bun side. Should DRY this up.\n static defineRPC<\n Schema extends ElectrobunWebviewRPCSChema,\n BunSchema extends RPCSchema = Schema[\"bun\"],\n WebviewSchema extends RPCSchema = Schema[\"webview\"]\n >(config: {\n maxRequestTime?: number;\n handlers: {\n requests?: RPCRequestHandler<WebviewSchema[\"requests\"]>;\n messages?: {\n [key in keyof WebviewSchema[\"messages\"]]: RPCMessageHandlerFn<\n WebviewSchema[\"messages\"],\n key\n >;\n } & {\n \"*\"?: WildcardRPCMessageHandlerFn<WebviewSchema[\"messages\"]>;\n };\n };\n }) {\n // Note: RPC Anywhere requires defining the requests that a schema handles and the messages that a schema sends.\n // eg: BunSchema {\n // requests: // ... requests bun handles, sent by webview\n // messages: // ... messages bun sends, handled by webview\n // }\n // In some generlized contexts that makes sense,\n // In the Electrobun context it can feel a bit counter-intuitive so we swap this around a bit. In Electrobun, the\n // webview and bun are known endpoints so we simplify schema definitions by combining them.\n // Schema {\n // bun: BunSchema {\n // requests: // ... requests bun sends, handled by webview,\n // messages: // ... messages bun sends, handled by webview\n // },\n // webview: WebviewSchema {\n // requests: // ... requests webview sends, handled by bun,\n // messages: // ... messages webview sends, handled by bun\n // },\n // }\n // electrobun also treats messages as \"requests that we don't wait for to complete\", and normalizes specifying the\n // handlers for them alongside request handlers.\n\n const builtinHandlers: {\n requests: RPCRequestHandler<BuiltinBunToWebviewSchema[\"requests\"]>;\n } = {\n requests: {\n evaluateJavascriptWithResponse: ({ script }) => {\n return new Promise((resolve) => {\n try {\n const resultFunction = new Function(script);\n const result = resultFunction();\n\n if (result instanceof Promise) {\n result\n .then((resolvedResult) => {\n resolve(resolvedResult);\n })\n .catch((error) => {\n console.error(\"bun: async script execution failed\", error);\n resolve(String(error));\n });\n } else {\n resolve(result);\n }\n } catch (error) {\n console.error(\"bun: failed to eval script\", error);\n resolve(String(error));\n }\n });\n },\n },\n };\n\n type mixedWebviewSchema = {\n requests: BunSchema[\"requests\"];\n messages: WebviewSchema[\"messages\"];\n };\n\n type mixedBunSchema = {\n requests: WebviewSchema[\"requests\"] &\n BuiltinBunToWebviewSchema[\"requests\"];\n messages: BunSchema[\"messages\"];\n };\n\n const rpcOptions = {\n maxRequestTime: config.maxRequestTime,\n requestHandler: {\n ...config.handlers.requests,\n ...builtinHandlers.requests,\n },\n transport: {\n // Note: RPC Anywhere will throw if you try add a message listener if transport.registerHandler is falsey\n registerHandler: () => {},\n },\n } as RPCOptions<mixedBunSchema, mixedWebviewSchema>;\n\n const rpc = createRPC<mixedBunSchema, mixedWebviewSchema>(rpcOptions);\n\n const messageHandlers = config.handlers.messages;\n if (messageHandlers) {\n // note: this can only be done once there is a transport\n // @ts-ignore - this is due to all the schema mixing we're doing, fine to ignore\n // while types in here are borked, they resolve correctly/bubble up to the defineRPC call site.\n rpc.addMessageListener(\n \"*\",\n (messageName: keyof WebviewSchema[\"messages\"], payload) => {\n const globalHandler = messageHandlers[\"*\"];\n if (globalHandler) {\n globalHandler(messageName, payload);\n }\n\n const messageHandler = messageHandlers[messageName];\n if (messageHandler) {\n messageHandler(payload);\n }\n }\n );\n }\n\n return rpc;\n }\n}\n\nexport { type RPCSchema, createRPC, Electroview };\n\nconst Electrobun = {\n Electroview,\n};\n\nexport default Electrobun;\n"
11
10
  ],
12
- "mappings": ";AAEA,IAAS,sCAA2B,CAAC,SAAS,QAAQ;AAClD,QAAM,gBAAgB,QAAQ,IAAI,CAAC,WAAW,IAAI,SAAS,EAAE,KAAK,IAAI;AACtE,SAAO,IAAI,MAAM,4BAA4B,8EAA8E,eAAe;AAAA;AAEvI,SAAS,UAAU,CAI1B,UAAU,CAAC,GAAG;AAGV,MAAI,aAAa,CAAC;AAIlB,WAAS,cAAc,CAAC,eAAe;AACnC,iBAAa;AAAA;AAEjB,MAAI,YAAY,CAAC;AAKjB,WAAS,YAAY,CAAC,cAAc;AAChC,QAAI,UAAU;AACV,gBAAU,kBAAkB;AAChC,gBAAY;AACZ,cAAU,kBAAkB,OAAO;AAAA;AAEvC,MAAI,iBAAiB;AAKrB,WAAS,iBAAiB,CAI1B,UAAS;AACL,eAAW,aAAY,YAAY;AAC/B,uBAAiB;AACjB;AAAA,IACJ;AACA,qBAAiB,CAAC,QAAQ,WAAW;AACjC,YAAM,YAAY,SAAQ;AAC1B,UAAI;AACA,eAAO,UAAU,MAAM;AAC3B,YAAM,kBAAkB,SAAQ;AAChC,WAAK;AACD,cAAM,IAAI,MAAM,wCAAwC,QAAQ;AACpE,aAAO,gBAAgB,QAAQ,MAAM;AAAA;AAAA;AAK7C,UAAQ,iBAAiB,6BAA6B;AACtD,MAAI,QAAQ;AACR,iBAAa,QAAQ,SAAS;AAClC,MAAI,QAAQ;AACR,sBAAkB,QAAQ,cAAc;AAC5C,MAAI,QAAQ;AACR,mBAAe,QAAQ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