This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Hello World!</title> | |
| </head> | |
| <body> | |
| <!-- All of the Node.js APIs are available in this renderer process. --> | |
| <pre> | |
| <b>Node.js :</b> <script>document.write(process.versions.node)</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function waitSingleWidgetInVirtualTree( | |
| options: MacroApiOptions, | |
| scope: ScopeItem[] = [], | |
| callback: ( | |
| (error: Error | null, virtualTreeNode: VirtualTreeNode | null) => void | |
| ) | |
| ) { | |
| let unsubscribeFromStore: (() => void) | null = null; | |
| function stopWaitingSingleWidgetInVirtualTree() { | |
| if (unsubscribeFromStore) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // In Renderer | |
| export function makeHttpRequest(url: string; method: string) { | |
| return createIpcSender<{ url: string; method: string }, void>( | |
| 'http-request', | |
| { url, method }, | |
| ); | |
| } | |
| // ... in browser window code ... | |
| makeHttpRequest('https://httpbin.org', 'GET').subscribe({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function replaceVars( | |
| content: string, | |
| variables: { [key: string]: string } | |
| ) { | |
| const varRegex = /\$([a-z0-9_]*)/gi; | |
| let match: RegExpExecArray; | |
| while ((match = varRegex.exec(content)!)) { | |
| let [wholeVar, varName] = match; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const urlHasProtocol = (url: string) => { | |
| return url.match(/^([a-z]*:\/\/)/i) !== null; | |
| }; | |
| const isRelativePath = (arg: unknown) => | |
| typeof arg === "string" && !urlHasProtocol(arg); | |
| const isHttpMethod = (arg: unknown) => | |
| typeof arg === "string" && | |
| ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"].includes(arg); | |
| /** |
OlderNewer