@k8slens/extensions 5.3.1-git.f61563c99f.0 → 5.3.1-git.f6193718ff.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.
- package/dist/src/common/cluster-types.d.ts +5 -1
- package/dist/src/extensions/extension-api.js +3 -3
- package/dist/src/extensions/extension-compatibility.d.ts +3 -1
- package/dist/src/main/cluster-manager.d.ts +1 -1
- package/dist/src/main/lens-proxy.d.ts +8 -1
- package/dist/src/main/menu.d.ts +6 -1
- package/dist/src/main/window-manager.d.ts +3 -0
- package/dist/src/renderer/components/+network-policies/network-policy-details.d.ts +5 -2
- package/dist/src/renderer/components/layout/__tests__/topbar-win-linux.test.d.ts +21 -0
- package/package.json +1 -1
|
@@ -76,7 +76,11 @@ export interface ClusterPreferences extends ClusterPrometheusPreferences {
|
|
|
76
76
|
terminalCWD?: string;
|
|
77
77
|
clusterName?: string;
|
|
78
78
|
iconOrder?: number;
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The <img> src for the cluster. If set to `null` that means that it was
|
|
81
|
+
* cleared by preferences.
|
|
82
|
+
*/
|
|
83
|
+
icon?: string | null;
|
|
80
84
|
httpsProxy?: string;
|
|
81
85
|
hiddenMetrics?: string[];
|
|
82
86
|
nodeShellImage?: string;
|
|
@@ -40944,7 +40944,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
|
40944
40944
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
40945
40945
|
|
|
40946
40946
|
"use strict";
|
|
40947
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"isLongRunningRequest\", function() { return isLongRunningRequest; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"LensProxy\", function() { return LensProxy; });\n/* harmony import */ var spdy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! spdy */ \"./node_modules/spdy/lib/spdy.js\");\n/* harmony import */ var spdy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(spdy__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var http_proxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! http-proxy */ \"./node_modules/http-proxy/index.js\");\n/* harmony import */ var http_proxy__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(http_proxy__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _common_vars__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/vars */ \"./src/common/vars.ts\");\n/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger */ \"./src/main/logger.ts\");\n/* harmony import */ var _common_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/utils */ \"./src/common/utils/index.ts\");\n/* harmony import */ var _common_event_bus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/event-bus */ \"./src/common/event-bus.ts\");\n/* harmony import */ var _utils_parse_query__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils/parse-query */ \"./src/main/utils/parse-query.ts\");\n/**\n * Copyright (c) 2021 OpenLens Authors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n\n\n\n\n\n\nconst watchParam = \"watch\";\nconst followParam = \"follow\";\nfunction isLongRunningRequest(reqUrl) {\n const url = new URL(reqUrl, \"http://localhost\");\n return Object(_utils_parse_query__WEBPACK_IMPORTED_MODULE_6__[\"getBoolean\"])(url.searchParams, watchParam) || Object(_utils_parse_query__WEBPACK_IMPORTED_MODULE_6__[\"getBoolean\"])(url.searchParams, followParam);\n}\nclass LensProxy extends _common_utils__WEBPACK_IMPORTED_MODULE_4__[\"Singleton\"] {\n constructor(router, { shellApiRequest, kubeApiRequest, getClusterForRequest }) {\n super();\n Object.defineProperty(this, \"router\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: router\n });\n Object.defineProperty(this, \"origin\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"proxyServer\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"closed\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"retryCounters\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: new Map()\n });\n Object.defineProperty(this, \"proxy\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: this.createProxy()\n });\n Object.defineProperty(this, \"getClusterForRequest\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"port\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.getClusterForRequest = getClusterForRequest;\n this.proxyServer = spdy__WEBPACK_IMPORTED_MODULE_0___default.a.createServer({\n spdy: {\n plain: true,\n protocols: [\"http/1.1\", \"spdy/3.1\"],\n },\n }, (req, res) => {\n this.handleRequest(req, res);\n });\n this.proxyServer\n .on(\"upgrade\", (req, socket, head) => {\n const isInternal = req.url.startsWith(`${_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiPrefix\"]}?`);\n const cluster = getClusterForRequest(req);\n if (!cluster) {\n return void _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: Could not find cluster for upgrade request from url=${req.url}`);\n }\n const reqHandler = isInternal ? shellApiRequest : kubeApiRequest;\n (async () => reqHandler({ req, socket, head, cluster }))()\n .catch(error => _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(\"[LENS-PROXY]: failed to handle proxy upgrade\", error));\n });\n }\n /**\n * Starts the lens proxy.\n * @resolves After the server is listening\n * @rejects if there is an error before that happens\n */\n listen() {\n return new Promise((resolve, reject) => {\n this.proxyServer.listen(0, \"127.0.0.1\");\n this.proxyServer\n .once(\"listening\", () => {\n this.proxyServer.removeAllListeners(\"error\"); // don't reject the promise\n const { address, port } = this.proxyServer.address();\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Proxy server has started at ${address}:${port}`);\n this.proxyServer.on(\"error\", (error) => {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Subsequent error: ${error}`);\n });\n this.port = port;\n _common_event_bus__WEBPACK_IMPORTED_MODULE_5__[\"appEventBus\"].emit({ name: \"lens-proxy\", action: \"listen\", params: { port } });\n resolve();\n })\n .once(\"error\", (error) => {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Proxy server failed to start: ${error}`);\n reject(error);\n });\n });\n }\n close() {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(\"Closing proxy server\");\n this.proxyServer.close();\n this.closed = true;\n }\n createProxy() {\n const proxy = http_proxy__WEBPACK_IMPORTED_MODULE_1___default.a.createProxyServer();\n proxy.on(\"proxyRes\", (proxyRes, req, res) => {\n const retryCounterId = this.getRequestId(req);\n if (this.retryCounters.has(retryCounterId)) {\n this.retryCounters.delete(retryCounterId);\n }\n if (!res.headersSent && req.url) {\n const url = new URL(req.url, \"http://localhost\");\n if (url.searchParams.has(\"watch\")) {\n res.statusCode = proxyRes.statusCode;\n res.flushHeaders();\n }\n }\n proxyRes.on(\"aborted\", () => {\n res.end();\n });\n });\n proxy.on(\"error\", (error, req, res, target) => {\n if (this.closed) {\n return;\n }\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: http proxy errored for cluster: ${error}`, { url: req.url });\n if (target) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].debug(`Failed proxy to target: ${JSON.stringify(target, null, 2)}`);\n if (req.method === \"GET\" && (!res.statusCode || res.statusCode >= 500)) {\n const reqId = this.getRequestId(req);\n const retryCount = this.retryCounters.get(reqId) || 0;\n const timeoutMs = retryCount * 250;\n if (retryCount < 20) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].debug(`Retrying proxy request to url: ${reqId}`);\n setTimeout(() => {\n this.retryCounters.set(reqId, retryCount + 1);\n this.handleRequest(req, res)\n .catch(error => _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: failed to handle request on proxy error: ${error}`));\n }, timeoutMs);\n }\n }\n }\n try {\n res.writeHead(500).end(`Oops, something went wrong.\\n${error}`);\n }\n catch (e) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: Failed to write headers: `, e);\n }\n });\n return proxy;\n }\n async getProxyTarget(req, contextHandler) {\n if (req.url.startsWith(_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiKubePrefix\"])) {\n delete req.headers.authorization;\n req.url = req.url.replace(_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiKubePrefix\"], \"\");\n return contextHandler.getApiTarget(isLongRunningRequest(req.url));\n }\n }\n getRequestId(req) {\n return req.headers.host + req.url;\n }\n async handleRequest(req, res) {\n const cluster = this.getClusterForRequest(req);\n if (cluster) {\n const proxyTarget = await this.getProxyTarget(req, cluster.contextHandler);\n if (proxyTarget) {\n return this.proxy.web(req, res, proxyTarget);\n }\n }\n this.router.route(cluster, req, res);\n }\n}\n\n\n//# sourceURL=webpack:///./src/main/lens-proxy.ts?");
|
|
40947
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"isLongRunningRequest\", function() { return isLongRunningRequest; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"LensProxy\", function() { return LensProxy; });\n/* harmony import */ var spdy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! spdy */ \"./node_modules/spdy/lib/spdy.js\");\n/* harmony import */ var spdy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(spdy__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var http_proxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! http-proxy */ \"./node_modules/http-proxy/index.js\");\n/* harmony import */ var http_proxy__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(http_proxy__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _common_vars__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/vars */ \"./src/common/vars.ts\");\n/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger */ \"./src/main/logger.ts\");\n/* harmony import */ var _common_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/utils */ \"./src/common/utils/index.ts\");\n/* harmony import */ var _common_event_bus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/event-bus */ \"./src/common/event-bus.ts\");\n/* harmony import */ var _utils_parse_query__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils/parse-query */ \"./src/main/utils/parse-query.ts\");\n/**\n * Copyright (c) 2021 OpenLens Authors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n\n\n\n\n\n\nconst watchParam = \"watch\";\nconst followParam = \"follow\";\nfunction isLongRunningRequest(reqUrl) {\n const url = new URL(reqUrl, \"http://localhost\");\n return Object(_utils_parse_query__WEBPACK_IMPORTED_MODULE_6__[\"getBoolean\"])(url.searchParams, watchParam) || Object(_utils_parse_query__WEBPACK_IMPORTED_MODULE_6__[\"getBoolean\"])(url.searchParams, followParam);\n}\n/**\n * This is the list of ports that chrome considers unsafe to allow HTTP\n * conntections to. Because they are the standard ports for processes that are\n * too forgiving in the connection types they accept.\n *\n * If we get one of these ports, the easiest thing to do is to just try again.\n *\n * Source: https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc\n */\nconst disallowedPorts = new Set([\n 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 69, 77, 79,\n 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 137,\n 139, 143, 161, 179, 389, 427, 465, 512, 513, 514, 515, 526, 530, 531, 532,\n 540, 548, 554, 556, 563, 587, 601, 636, 989, 990, 993, 995, 1719, 1720, 1723,\n 2049, 3659, 4045, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669, 6697,\n 10080,\n]);\nclass LensProxy extends _common_utils__WEBPACK_IMPORTED_MODULE_4__[\"Singleton\"] {\n constructor(router, { shellApiRequest, kubeApiRequest, getClusterForRequest }) {\n super();\n Object.defineProperty(this, \"router\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: router\n });\n Object.defineProperty(this, \"origin\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"proxyServer\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"closed\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"retryCounters\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: new Map()\n });\n Object.defineProperty(this, \"proxy\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: this.createProxy()\n });\n Object.defineProperty(this, \"getClusterForRequest\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"port\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.getClusterForRequest = getClusterForRequest;\n this.proxyServer = spdy__WEBPACK_IMPORTED_MODULE_0___default.a.createServer({\n spdy: {\n plain: true,\n protocols: [\"http/1.1\", \"spdy/3.1\"],\n },\n }, (req, res) => {\n this.handleRequest(req, res);\n });\n this.proxyServer\n .on(\"upgrade\", (req, socket, head) => {\n const isInternal = req.url.startsWith(`${_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiPrefix\"]}?`);\n const cluster = getClusterForRequest(req);\n if (!cluster) {\n return void _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: Could not find cluster for upgrade request from url=${req.url}`);\n }\n const reqHandler = isInternal ? shellApiRequest : kubeApiRequest;\n (async () => reqHandler({ req, socket, head, cluster }))()\n .catch(error => _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(\"[LENS-PROXY]: failed to handle proxy upgrade\", error));\n });\n }\n /**\n * Starts to listen on an OS provided port. Will reject if the server throws\n * an error.\n *\n * Resolves with the port number that was picked\n */\n attemptToListen() {\n return new Promise((resolve, reject) => {\n this.proxyServer.listen(0, \"127.0.0.1\");\n this.proxyServer\n .once(\"listening\", () => {\n this.proxyServer.removeAllListeners(\"error\"); // don't reject the promise\n const { address, port } = this.proxyServer.address();\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Proxy server has started at ${address}:${port}`);\n this.proxyServer.on(\"error\", (error) => {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Subsequent error: ${error}`);\n });\n this.port = port;\n _common_event_bus__WEBPACK_IMPORTED_MODULE_5__[\"appEventBus\"].emit({ name: \"lens-proxy\", action: \"listen\", params: { port } });\n resolve(port);\n })\n .once(\"error\", (error) => {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(`[LENS-PROXY]: Proxy server failed to start: ${error}`);\n reject(error);\n });\n });\n }\n /**\n * Starts the lens proxy.\n * @resolves After the server is listening on a good port\n * @rejects if there is an error before that happens\n */\n async listen() {\n var _a;\n const seenPorts = new Set();\n while (true) {\n (_a = this.proxyServer) === null || _a === void 0 ? void 0 : _a.close();\n const port = await this.attemptToListen();\n if (!disallowedPorts.has(port)) {\n // We didn't get a port that would result in an ERR_UNSAFE_PORT error, use it\n return;\n }\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].warn(`[LENS-PROXY]: Proxy server has with port known to be considered unsafe to connect to by chrome, restarting...`);\n if (seenPorts.has(port)) {\n /**\n * Assume that if we have seen the port before, then the OS has looped\n * through all the ports possible and we will not be able to get a safe\n * port.\n */\n throw new Error(\"Failed to start LensProxy due to seeing too many unsafe ports. Please restart Lens.\");\n }\n else {\n seenPorts.add(port);\n }\n }\n }\n close() {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].info(\"[LENS-PROXY]: Closing server\");\n this.proxyServer.close();\n this.closed = true;\n }\n createProxy() {\n const proxy = http_proxy__WEBPACK_IMPORTED_MODULE_1___default.a.createProxyServer();\n proxy.on(\"proxyRes\", (proxyRes, req, res) => {\n const retryCounterId = this.getRequestId(req);\n if (this.retryCounters.has(retryCounterId)) {\n this.retryCounters.delete(retryCounterId);\n }\n if (!res.headersSent && req.url) {\n const url = new URL(req.url, \"http://localhost\");\n if (url.searchParams.has(\"watch\")) {\n res.statusCode = proxyRes.statusCode;\n res.flushHeaders();\n }\n }\n proxyRes.on(\"aborted\", () => {\n res.end();\n });\n });\n proxy.on(\"error\", (error, req, res, target) => {\n if (this.closed) {\n return;\n }\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: http proxy errored for cluster: ${error}`, { url: req.url });\n if (target) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].debug(`Failed proxy to target: ${JSON.stringify(target, null, 2)}`);\n if (req.method === \"GET\" && (!res.statusCode || res.statusCode >= 500)) {\n const reqId = this.getRequestId(req);\n const retryCount = this.retryCounters.get(reqId) || 0;\n const timeoutMs = retryCount * 250;\n if (retryCount < 20) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].debug(`Retrying proxy request to url: ${reqId}`);\n setTimeout(() => {\n this.retryCounters.set(reqId, retryCount + 1);\n this.handleRequest(req, res)\n .catch(error => _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: failed to handle request on proxy error: ${error}`));\n }, timeoutMs);\n }\n }\n }\n try {\n res.writeHead(500).end(`Oops, something went wrong.\\n${error}`);\n }\n catch (e) {\n _logger__WEBPACK_IMPORTED_MODULE_3__[\"default\"].error(`[LENS-PROXY]: Failed to write headers: `, e);\n }\n });\n return proxy;\n }\n async getProxyTarget(req, contextHandler) {\n if (req.url.startsWith(_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiKubePrefix\"])) {\n delete req.headers.authorization;\n req.url = req.url.replace(_common_vars__WEBPACK_IMPORTED_MODULE_2__[\"apiKubePrefix\"], \"\");\n return contextHandler.getApiTarget(isLongRunningRequest(req.url));\n }\n }\n getRequestId(req) {\n return req.headers.host + req.url;\n }\n async handleRequest(req, res) {\n const cluster = this.getClusterForRequest(req);\n if (cluster) {\n const proxyTarget = await this.getProxyTarget(req, cluster.contextHandler);\n if (proxyTarget) {\n return this.proxy.web(req, res, proxyTarget);\n }\n }\n this.router.route(cluster, req, res);\n }\n}\n\n\n//# sourceURL=webpack:///./src/main/lens-proxy.ts?");
|
|
40948
40948
|
|
|
40949
40949
|
/***/ }),
|
|
40950
40950
|
|
|
@@ -41012,11 +41012,11 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
|
41012
41012
|
/*!************************************!*\
|
|
41013
41013
|
!*** ./src/main/window-manager.ts ***!
|
|
41014
41014
|
\************************************/
|
|
41015
|
-
/*! exports provided: WindowManager */
|
|
41015
|
+
/*! exports provided: IpcMainWindowEvents, WindowManager */
|
|
41016
41016
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
41017
41017
|
|
|
41018
41018
|
"use strict";
|
|
41019
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"WindowManager\", function() { return WindowManager; });\n/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mobx */ \"./node_modules/mobx/dist/mobx.esm.js\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! electron */ \"electron\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var electron_window_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! electron-window-state */ \"./node_modules/electron-window-state/index.js\");\n/* harmony import */ var electron_window_state__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(electron_window_state__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _common_event_bus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/event-bus */ \"./src/common/event-bus.ts\");\n/* harmony import */ var _common_ipc__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/ipc */ \"./src/common/ipc/index.ts\");\n/* harmony import */ var _common_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/utils */ \"./src/common/utils/index.ts\");\n/* harmony import */ var _common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/cluster-frames */ \"./src/common/cluster-frames.ts\");\n/* harmony import */ var _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../renderer/navigation/events */ \"./src/renderer/navigation/events.ts\");\n/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./logger */ \"./src/main/logger.ts\");\n/* harmony import */ var _common_vars__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../common/vars */ \"./src/common/vars.ts\");\n/* harmony import */ var _lens_proxy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lens-proxy */ \"./src/main/lens-proxy.ts\");\n/**\n * Copyright (c) 2021 OpenLens Authors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\n\n\n\n\n\n\n\n\n\n\n\nfunction isHideable(window) {\n return Boolean(window && !window.isDestroyed());\n}\nclass WindowManager extends _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"Singleton\"] {\n constructor() {\n super();\n Object.defineProperty(this, \"mainWindow\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"splashWindow\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"windowState\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"disposers\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: {}\n });\n Object.defineProperty(this, \"activeClusterId\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object(mobx__WEBPACK_IMPORTED_MODULE_0__[\"makeObservable\"])(this);\n this.bindEvents();\n }\n get mainUrl() {\n return `http://localhost:${_lens_proxy__WEBPACK_IMPORTED_MODULE_10__[\"LensProxy\"].getInstance().port}`;\n }\n async initMainWindow(showSplash) {\n var _a;\n // Manage main window size and position with state persistence\n if (!this.windowState) {\n this.windowState = electron_window_state__WEBPACK_IMPORTED_MODULE_2___default()({\n defaultHeight: 900,\n defaultWidth: 1440,\n });\n }\n if (!this.mainWindow) {\n // show icon in dock (mac-os only)\n (_a = electron__WEBPACK_IMPORTED_MODULE_1__[\"app\"].dock) === null || _a === void 0 ? void 0 : _a.show();\n const { width, height, x, y } = this.windowState;\n this.mainWindow = new electron__WEBPACK_IMPORTED_MODULE_1__[\"BrowserWindow\"]({\n x, y, width, height,\n title: _common_vars__WEBPACK_IMPORTED_MODULE_9__[\"productName\"],\n show: false,\n minWidth: 700,\n minHeight: 500,\n titleBarStyle: \"hiddenInset\",\n backgroundColor: \"#1e2124\",\n webPreferences: {\n nodeIntegration: true,\n nodeIntegrationInSubFrames: true,\n enableRemoteModule: true,\n webviewTag: true,\n contextIsolation: false,\n },\n });\n this.windowState.manage(this.mainWindow);\n // open external links in default browser (target=_blank, window.open)\n this.mainWindow\n .on(\"focus\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"focus\" });\n })\n .on(\"blur\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"blur\" });\n })\n .on(\"closed\", () => {\n var _a;\n // clean up\n this.windowState.unmanage();\n this.mainWindow = null;\n this.splashWindow = null;\n (_a = electron__WEBPACK_IMPORTED_MODULE_1__[\"app\"].dock) === null || _a === void 0 ? void 0 : _a.hide(); // hide icon in dock (mac-os)\n })\n .webContents\n .on(\"dom-ready\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"dom-ready\" });\n })\n .on(\"did-fail-load\", (_event, code, desc) => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(`[WINDOW-MANAGER]: Failed to load Main window`, { code, desc });\n })\n .on(\"did-finish-load\", () => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(\"[WINDOW-MANAGER]: Main window loaded\");\n })\n .on(\"will-attach-webview\", (event, webPreferences, params) => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].debug(\"[WINDOW-MANAGER]: Attaching webview\");\n // Following is security recommendations because we allow webview tag (webviewTag: true)\n // suggested by https://www.electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation\n // and https://www.electronjs.org/docs/tutorial/security#10-do-not-use-allowpopups\n if (webPreferences.preload) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: Strip away preload scripts of webview\");\n delete webPreferences.preload;\n }\n // @ts-expect-error some electron version uses webPreferences.preloadURL/webPreferences.preload\n if (webPreferences.preloadURL) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: Strip away preload scripts of webview\");\n delete webPreferences.preload;\n }\n if (params.allowpopups) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: We do not allow allowpopups props, stop webview from renderer\");\n // event.preventDefault() will destroy the guest page.\n event.preventDefault();\n return;\n }\n // Always disable Node.js integration for all webviews\n webPreferences.nodeIntegration = false;\n }).setWindowOpenHandler((details) => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"shell\"].openExternal(details.url);\n return { action: \"deny\" };\n });\n }\n try {\n if (showSplash)\n await this.showSplash();\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(`[WINDOW-MANAGER]: Loading Main window from url: ${this.mainUrl} ...`);\n await this.mainWindow.loadURL(this.mainUrl);\n }\n catch (error) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(\"Loading main window failed\", { error });\n electron__WEBPACK_IMPORTED_MODULE_1__[\"dialog\"].showErrorBox(\"ERROR!\", error.toString());\n }\n }\n bindEvents() {\n // track visible cluster from ui\n Object(_common_ipc__WEBPACK_IMPORTED_MODULE_4__[\"ipcMainOn\"])(_renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].CLUSTER_VIEW_CURRENT_ID, (event, clusterId) => {\n this.activeClusterId = clusterId;\n });\n }\n async ensureMainWindow(showSplash = true) {\n var _a;\n // This needs to be ready to hear the IPC message before the window is loaded\n let viewHasLoaded = Promise.resolve();\n if (!this.mainWindow) {\n viewHasLoaded = new Promise(resolve => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"ipcMain\"].once(_renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].LOADED, () => resolve());\n });\n await this.initMainWindow(showSplash);\n }\n try {\n await viewHasLoaded;\n await Object(_common_utils__WEBPACK_IMPORTED_MODULE_5__[\"delay\"])(50); // wait just a bit longer to let the first round of rendering happen\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(\"[WINDOW-MANAGER]: Main window has reported that it has loaded\");\n this.mainWindow.show();\n (_a = this.splashWindow) === null || _a === void 0 ? void 0 : _a.close();\n this.splashWindow = undefined;\n setTimeout(() => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"start\" });\n }, 1000);\n }\n catch (error) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(`Showing main window failed: ${error.stack || error}`);\n electron__WEBPACK_IMPORTED_MODULE_1__[\"dialog\"].showErrorBox(\"ERROR!\", error.toString());\n }\n return this.mainWindow;\n }\n sendToView({ channel, frameInfo, data = [] }) {\n if (frameInfo) {\n this.mainWindow.webContents.sendToFrame([frameInfo.processId, frameInfo.frameId], channel, ...data);\n }\n else {\n this.mainWindow.webContents.send(channel, ...data);\n }\n }\n async navigateExtension(extId, pageId, params, frameId) {\n await this.ensureMainWindow();\n const frameInfo = _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"iter\"].find(_common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].values(), frameInfo => frameInfo.frameId === frameId);\n this.sendToView({\n channel: \"extension:navigate\",\n frameInfo,\n data: [extId, pageId, params],\n });\n }\n async navigate(url, frameId) {\n await this.ensureMainWindow();\n const frameInfo = _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"iter\"].find(_common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].values(), frameInfo => frameInfo.frameId === frameId);\n const channel = frameInfo\n ? _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].NAVIGATE_IN_CLUSTER\n : _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].NAVIGATE_IN_APP;\n this.sendToView({\n channel,\n frameInfo,\n data: [url],\n });\n }\n reload() {\n const frameInfo = _common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].get(this.activeClusterId);\n if (frameInfo) {\n this.sendToView({ channel: _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].RELOAD_PAGE, frameInfo });\n }\n else {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"webContents\"].getAllWebContents().filter(wc => wc.getType() === \"window\").forEach(wc => {\n wc.reload();\n wc.clearHistory();\n });\n }\n }\n async showSplash() {\n if (!this.splashWindow) {\n this.splashWindow = new electron__WEBPACK_IMPORTED_MODULE_1__[\"BrowserWindow\"]({\n width: 500,\n height: 300,\n backgroundColor: \"#1e2124\",\n center: true,\n frame: false,\n resizable: false,\n show: false,\n webPreferences: {\n nodeIntegration: true,\n enableRemoteModule: true,\n contextIsolation: false,\n nodeIntegrationInSubFrames: true,\n },\n });\n await this.splashWindow.loadURL(\"static://splash.html\");\n }\n this.splashWindow.show();\n }\n hide() {\n if (isHideable(this.mainWindow)) {\n this.mainWindow.hide();\n }\n if (isHideable(this.splashWindow)) {\n this.splashWindow.hide();\n }\n }\n destroy() {\n this.mainWindow.destroy();\n this.splashWindow.destroy();\n this.mainWindow = null;\n this.splashWindow = null;\n Object.entries(this.disposers).forEach(([name, dispose]) => {\n dispose();\n delete this.disposers[name];\n });\n }\n}\n__decorate([\n mobx__WEBPACK_IMPORTED_MODULE_0__[\"observable\"],\n __metadata(\"design:type\", String)\n], WindowManager.prototype, \"activeClusterId\", void 0);\n\n\n//# sourceURL=webpack:///./src/main/window-manager.ts?");
|
|
41019
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"IpcMainWindowEvents\", function() { return IpcMainWindowEvents; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"WindowManager\", function() { return WindowManager; });\n/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mobx */ \"./node_modules/mobx/dist/mobx.esm.js\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! electron */ \"electron\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var electron_window_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! electron-window-state */ \"./node_modules/electron-window-state/index.js\");\n/* harmony import */ var electron_window_state__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(electron_window_state__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _common_event_bus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/event-bus */ \"./src/common/event-bus.ts\");\n/* harmony import */ var _common_ipc__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/ipc */ \"./src/common/ipc/index.ts\");\n/* harmony import */ var _common_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/utils */ \"./src/common/utils/index.ts\");\n/* harmony import */ var _common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/cluster-frames */ \"./src/common/cluster-frames.ts\");\n/* harmony import */ var _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../renderer/navigation/events */ \"./src/renderer/navigation/events.ts\");\n/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./logger */ \"./src/main/logger.ts\");\n/* harmony import */ var _common_vars__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../common/vars */ \"./src/common/vars.ts\");\n/* harmony import */ var _lens_proxy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lens-proxy */ \"./src/main/lens-proxy.ts\");\n/**\n * Copyright (c) 2021 OpenLens Authors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\n\n\n\n\n\n\n\n\n\n\n\nvar IpcMainWindowEvents;\n(function (IpcMainWindowEvents) {\n IpcMainWindowEvents[\"OPEN_CONTEXT_MENU\"] = \"window:open-context-menu\";\n})(IpcMainWindowEvents || (IpcMainWindowEvents = {}));\nfunction isHideable(window) {\n return Boolean(window && !window.isDestroyed());\n}\nclass WindowManager extends _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"Singleton\"] {\n constructor() {\n super();\n Object.defineProperty(this, \"mainWindow\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"splashWindow\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"windowState\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"disposers\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: {}\n });\n Object.defineProperty(this, \"activeClusterId\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object(mobx__WEBPACK_IMPORTED_MODULE_0__[\"makeObservable\"])(this);\n this.bindEvents();\n }\n get mainUrl() {\n return `http://localhost:${_lens_proxy__WEBPACK_IMPORTED_MODULE_10__[\"LensProxy\"].getInstance().port}`;\n }\n async initMainWindow(showSplash) {\n var _a;\n // Manage main window size and position with state persistence\n if (!this.windowState) {\n this.windowState = electron_window_state__WEBPACK_IMPORTED_MODULE_2___default()({\n defaultHeight: 900,\n defaultWidth: 1440,\n });\n }\n if (!this.mainWindow) {\n // show icon in dock (mac-os only)\n (_a = electron__WEBPACK_IMPORTED_MODULE_1__[\"app\"].dock) === null || _a === void 0 ? void 0 : _a.show();\n const { width, height, x, y } = this.windowState;\n this.mainWindow = new electron__WEBPACK_IMPORTED_MODULE_1__[\"BrowserWindow\"]({\n x, y, width, height,\n title: _common_vars__WEBPACK_IMPORTED_MODULE_9__[\"productName\"],\n show: false,\n minWidth: 700,\n minHeight: 500,\n titleBarStyle: _common_vars__WEBPACK_IMPORTED_MODULE_9__[\"isMac\"] ? \"hiddenInset\" : \"hidden\",\n frame: _common_vars__WEBPACK_IMPORTED_MODULE_9__[\"isMac\"],\n backgroundColor: \"#1e2124\",\n webPreferences: {\n nodeIntegration: true,\n nodeIntegrationInSubFrames: true,\n enableRemoteModule: true,\n webviewTag: true,\n contextIsolation: false,\n },\n });\n this.windowState.manage(this.mainWindow);\n // open external links in default browser (target=_blank, window.open)\n this.mainWindow\n .on(\"focus\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"focus\" });\n })\n .on(\"blur\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"blur\" });\n })\n .on(\"closed\", () => {\n var _a;\n // clean up\n this.windowState.unmanage();\n this.mainWindow = null;\n this.splashWindow = null;\n (_a = electron__WEBPACK_IMPORTED_MODULE_1__[\"app\"].dock) === null || _a === void 0 ? void 0 : _a.hide(); // hide icon in dock (mac-os)\n })\n .webContents\n .on(\"dom-ready\", () => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"dom-ready\" });\n })\n .on(\"did-fail-load\", (_event, code, desc) => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(`[WINDOW-MANAGER]: Failed to load Main window`, { code, desc });\n })\n .on(\"did-finish-load\", () => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(\"[WINDOW-MANAGER]: Main window loaded\");\n })\n .on(\"will-attach-webview\", (event, webPreferences, params) => {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].debug(\"[WINDOW-MANAGER]: Attaching webview\");\n // Following is security recommendations because we allow webview tag (webviewTag: true)\n // suggested by https://www.electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation\n // and https://www.electronjs.org/docs/tutorial/security#10-do-not-use-allowpopups\n if (webPreferences.preload) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: Strip away preload scripts of webview\");\n delete webPreferences.preload;\n }\n // @ts-expect-error some electron version uses webPreferences.preloadURL/webPreferences.preload\n if (webPreferences.preloadURL) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: Strip away preload scripts of webview\");\n delete webPreferences.preload;\n }\n if (params.allowpopups) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].warn(\"[WINDOW-MANAGER]: We do not allow allowpopups props, stop webview from renderer\");\n // event.preventDefault() will destroy the guest page.\n event.preventDefault();\n return;\n }\n // Always disable Node.js integration for all webviews\n webPreferences.nodeIntegration = false;\n }).setWindowOpenHandler((details) => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"shell\"].openExternal(details.url);\n return { action: \"deny\" };\n });\n }\n try {\n if (showSplash)\n await this.showSplash();\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(`[WINDOW-MANAGER]: Loading Main window from url: ${this.mainUrl} ...`);\n await this.mainWindow.loadURL(this.mainUrl);\n }\n catch (error) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(\"Loading main window failed\", { error });\n electron__WEBPACK_IMPORTED_MODULE_1__[\"dialog\"].showErrorBox(\"ERROR!\", error.toString());\n }\n }\n bindEvents() {\n // track visible cluster from ui\n Object(_common_ipc__WEBPACK_IMPORTED_MODULE_4__[\"ipcMainOn\"])(_renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].CLUSTER_VIEW_CURRENT_ID, (event, clusterId) => {\n this.activeClusterId = clusterId;\n });\n }\n async ensureMainWindow(showSplash = true) {\n var _a;\n // This needs to be ready to hear the IPC message before the window is loaded\n let viewHasLoaded = Promise.resolve();\n if (!this.mainWindow) {\n viewHasLoaded = new Promise(resolve => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"ipcMain\"].once(_renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].LOADED, () => resolve());\n });\n await this.initMainWindow(showSplash);\n }\n try {\n await viewHasLoaded;\n await Object(_common_utils__WEBPACK_IMPORTED_MODULE_5__[\"delay\"])(50); // wait just a bit longer to let the first round of rendering happen\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].info(\"[WINDOW-MANAGER]: Main window has reported that it has loaded\");\n this.mainWindow.show();\n (_a = this.splashWindow) === null || _a === void 0 ? void 0 : _a.close();\n this.splashWindow = undefined;\n setTimeout(() => {\n _common_event_bus__WEBPACK_IMPORTED_MODULE_3__[\"appEventBus\"].emit({ name: \"app\", action: \"start\" });\n }, 1000);\n }\n catch (error) {\n _logger__WEBPACK_IMPORTED_MODULE_8__[\"default\"].error(`Showing main window failed: ${error.stack || error}`);\n electron__WEBPACK_IMPORTED_MODULE_1__[\"dialog\"].showErrorBox(\"ERROR!\", error.toString());\n }\n return this.mainWindow;\n }\n sendToView({ channel, frameInfo, data = [] }) {\n if (frameInfo) {\n this.mainWindow.webContents.sendToFrame([frameInfo.processId, frameInfo.frameId], channel, ...data);\n }\n else {\n this.mainWindow.webContents.send(channel, ...data);\n }\n }\n async navigateExtension(extId, pageId, params, frameId) {\n await this.ensureMainWindow();\n const frameInfo = _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"iter\"].find(_common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].values(), frameInfo => frameInfo.frameId === frameId);\n this.sendToView({\n channel: \"extension:navigate\",\n frameInfo,\n data: [extId, pageId, params],\n });\n }\n async navigate(url, frameId) {\n await this.ensureMainWindow();\n const frameInfo = _common_utils__WEBPACK_IMPORTED_MODULE_5__[\"iter\"].find(_common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].values(), frameInfo => frameInfo.frameId === frameId);\n const channel = frameInfo\n ? _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].NAVIGATE_IN_CLUSTER\n : _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].NAVIGATE_IN_APP;\n this.sendToView({\n channel,\n frameInfo,\n data: [url],\n });\n }\n reload() {\n const frameInfo = _common_cluster_frames__WEBPACK_IMPORTED_MODULE_6__[\"clusterFrameMap\"].get(this.activeClusterId);\n if (frameInfo) {\n this.sendToView({ channel: _renderer_navigation_events__WEBPACK_IMPORTED_MODULE_7__[\"IpcRendererNavigationEvents\"].RELOAD_PAGE, frameInfo });\n }\n else {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"webContents\"].getAllWebContents().filter(wc => wc.getType() === \"window\").forEach(wc => {\n wc.reload();\n wc.clearHistory();\n });\n }\n }\n async showSplash() {\n if (!this.splashWindow) {\n this.splashWindow = new electron__WEBPACK_IMPORTED_MODULE_1__[\"BrowserWindow\"]({\n width: 500,\n height: 300,\n backgroundColor: \"#1e2124\",\n center: true,\n frame: false,\n resizable: false,\n show: false,\n webPreferences: {\n nodeIntegration: true,\n enableRemoteModule: true,\n contextIsolation: false,\n nodeIntegrationInSubFrames: true,\n },\n });\n await this.splashWindow.loadURL(\"static://splash.html\");\n }\n this.splashWindow.show();\n }\n hide() {\n if (isHideable(this.mainWindow)) {\n this.mainWindow.hide();\n }\n if (isHideable(this.splashWindow)) {\n this.splashWindow.hide();\n }\n }\n destroy() {\n this.mainWindow.destroy();\n this.splashWindow.destroy();\n this.mainWindow = null;\n this.splashWindow = null;\n Object.entries(this.disposers).forEach(([name, dispose]) => {\n dispose();\n delete this.disposers[name];\n });\n }\n}\n__decorate([\n mobx__WEBPACK_IMPORTED_MODULE_0__[\"observable\"],\n __metadata(\"design:type\", String)\n], WindowManager.prototype, \"activeClusterId\", void 0);\n\n\n//# sourceURL=webpack:///./src/main/window-manager.ts?");
|
|
41020
41020
|
|
|
41021
41021
|
/***/ }),
|
|
41022
41022
|
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
*/
|
|
21
|
+
import { SemVer } from "semver";
|
|
21
22
|
import type { LensExtensionManifest } from "./lens-extension";
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function rawIsCompatibleExtension(version: SemVer): (manifest: LensExtensionManifest) => boolean;
|
|
24
|
+
export declare const isCompatibleExtension: (manifest: LensExtensionManifest) => boolean;
|
|
23
25
|
export declare function isCompatibleBundledExtension(manifest: LensExtensionManifest): boolean;
|
|
@@ -34,7 +34,7 @@ export declare class ClusterManager extends Singleton {
|
|
|
34
34
|
protected updateCatalog(clusters: Cluster[]): void;
|
|
35
35
|
protected updateEntityFromCluster(cluster: Cluster): void;
|
|
36
36
|
protected updateEntityStatus(entity: KubernetesCluster, cluster?: Cluster): void;
|
|
37
|
-
syncClustersFromCatalog(entities: KubernetesCluster[]): void;
|
|
37
|
+
protected syncClustersFromCatalog(entities: KubernetesCluster[]): void;
|
|
38
38
|
protected onNetworkOffline: () => void;
|
|
39
39
|
protected onNetworkOnline: () => void;
|
|
40
40
|
stop(): void;
|
|
@@ -43,9 +43,16 @@ export declare class LensProxy extends Singleton {
|
|
|
43
43
|
protected getClusterForRequest: GetClusterForRequest;
|
|
44
44
|
port: number;
|
|
45
45
|
constructor(router: Router, { shellApiRequest, kubeApiRequest, getClusterForRequest }: LensProxyFunctions);
|
|
46
|
+
/**
|
|
47
|
+
* Starts to listen on an OS provided port. Will reject if the server throws
|
|
48
|
+
* an error.
|
|
49
|
+
*
|
|
50
|
+
* Resolves with the port number that was picked
|
|
51
|
+
*/
|
|
52
|
+
private attemptToListen;
|
|
46
53
|
/**
|
|
47
54
|
* Starts the lens proxy.
|
|
48
|
-
* @resolves After the server is listening
|
|
55
|
+
* @resolves After the server is listening on a good port
|
|
49
56
|
* @rejects if there is an error before that happens
|
|
50
57
|
*/
|
|
51
58
|
listen(): Promise<void>;
|
package/dist/src/main/menu.d.ts
CHANGED
|
@@ -18,9 +18,14 @@
|
|
|
18
18
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
*/
|
|
21
|
-
import { BrowserWindow } from "electron";
|
|
21
|
+
import { BrowserWindow, MenuItemConstructorOptions } from "electron";
|
|
22
22
|
import type { WindowManager } from "./window-manager";
|
|
23
23
|
export declare type MenuTopId = "mac" | "file" | "edit" | "view" | "help";
|
|
24
|
+
interface MenuItemsOpts extends MenuItemConstructorOptions {
|
|
25
|
+
submenu?: MenuItemConstructorOptions[];
|
|
26
|
+
}
|
|
24
27
|
export declare function initMenu(windowManager: WindowManager): import("mobx").IReactionDisposer;
|
|
25
28
|
export declare function showAbout(browserWindow: BrowserWindow): void;
|
|
29
|
+
export declare function getAppMenu(windowManager: WindowManager): MenuItemsOpts[];
|
|
26
30
|
export declare function buildMenu(windowManager: WindowManager): void;
|
|
31
|
+
export {};
|
|
@@ -23,6 +23,9 @@ import { BrowserWindow } from "electron";
|
|
|
23
23
|
import windowStateKeeper from "electron-window-state";
|
|
24
24
|
import { Singleton } from "../common/utils";
|
|
25
25
|
import { ClusterFrameInfo } from "../common/cluster-frames";
|
|
26
|
+
export declare const enum IpcMainWindowEvents {
|
|
27
|
+
OPEN_CONTEXT_MENU = "window:open-context-menu"
|
|
28
|
+
}
|
|
26
29
|
export interface SendToViewArgs {
|
|
27
30
|
channel: string;
|
|
28
31
|
frameInfo?: ClusterFrameInfo;
|
|
@@ -19,13 +19,16 @@
|
|
|
19
19
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
*/
|
|
21
21
|
import React from "react";
|
|
22
|
-
import { IPolicyIpBlock,
|
|
22
|
+
import { IPolicyIpBlock, NetworkPolicy, NetworkPolicyPeer, NetworkPolicyPort } from "../../../common/k8s-api/endpoints/network-policy.api";
|
|
23
23
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
|
24
|
+
import type { LabelMatchExpression, LabelSelector } from "../../../common/k8s-api/kube-object";
|
|
24
25
|
interface Props extends KubeObjectDetailsProps<NetworkPolicy> {
|
|
25
26
|
}
|
|
26
27
|
export declare class NetworkPolicyDetails extends React.Component<Props> {
|
|
27
28
|
renderIPolicyIpBlock(ipBlock: IPolicyIpBlock | undefined): JSX.Element;
|
|
28
|
-
|
|
29
|
+
renderMatchLabels(matchLabels: Record<string, string | undefined> | undefined): JSX.Element[];
|
|
30
|
+
renderMatchExpressions(matchExpressions: LabelMatchExpression[] | undefined): JSX.Element[];
|
|
31
|
+
renderIPolicySelector(name: string, selector: LabelSelector | undefined): JSX.Element;
|
|
29
32
|
renderNetworkPolicyPeers(name: string, peers: NetworkPolicyPeer[] | undefined): JSX.Element;
|
|
30
33
|
renderNetworkPolicyPorts(ports: NetworkPolicyPort[] | undefined): JSX.Element;
|
|
31
34
|
render(): JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 OpenLens Authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
* the Software without restriction, including without limitation the rights to
|
|
7
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
* subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
import "@testing-library/jest-dom/extend-expect";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@k8slens/extensions",
|
|
3
3
|
"productName": "OpenLens extensions",
|
|
4
4
|
"description": "OpenLens - Open Source Kubernetes IDE: extensions",
|
|
5
|
-
"version": "5.3.1-git.
|
|
5
|
+
"version": "5.3.1-git.f6193718ff.0",
|
|
6
6
|
"copyright": "© 2021 OpenLens Authors",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/src/extensions/extension-api.js",
|