@lensmcp/nx-plugin 1.25.7 → 1.25.8
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/lens-frontend.js +1 -1
- package/package.json +1 -1
package/lens-frontend.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var r=(e,n)=>h(e,"name",{value:n,configurable:!0});var m=Object.defineProperty,o=r((e,n)=>m(e,"name",{value:n,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.spawnLensFrontend=spawnLensFrontend,exports.locateBin=locateBin,exports.resolveFirstExisting=resolveFirstExisting,exports.globalNodeModules=globalNodeModules,exports.findMcpBundle=findMcpBundle,exports.findDashboardBundle=findDashboardBundle,exports.findCaptureRunner=findCaptureRunner,exports.findBridgeBundle=findBridgeBundle,exports.clusterPageHosts=clusterPageHosts,exports.withBridgeAllowedOrigins=withBridgeAllowedOrigins,exports.readClusterPageDecls=readClusterPageDecls,exports.standaloneBridgeOrigins=standaloneBridgeOrigins;const node_child_process_1=require("node:child_process"),node_fs_1=require("node:fs"),node_path_1=require("node:path");function spawnLensFrontend(e,n){const t=e.log??(u=>console.log(u)),{projectRoot:s,workspaceRoot:i,eventFile:c}=e,a=e.chrome!==!1,v=e.headless!==!1,p=e.viteBin??locateBin("vite",[s,i]);if(!p)throw new Error("[lens] Could not find the vite binary in node_modules/.bin.");const d=e.port??(a?5173:void 0),f=["--config",resolveFirstExisting(["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs","vite.config.cts","vite.config.cjs"],s)??(0,node_path_1.join)(s,"vite.config.ts"),s];d!==void 0&&f.push("--port",String(d),"--strictPort");const g={LENSMCP_EVENT_FILE:c,...e.viteEnv??{}},j=e.labelPrefix??"";t(`[lens] starting Vite for ${e.project??s}${d?` on :${d}`:""}`);const b=n(`${j}vite`,p,f,g),l=e.openUrl??(d?`http://localhost:${d}/`:void 0);if(a){const u=findCaptureRunner(i);u?l?(t(`[lens] starting browser capture \u2192 ${l}`),n(`${j}browser-capture`,process.execPath,[u],{...g,LENSMCP_DEV_URL:l,LENSMCP_TOKENS_FILE:(0,node_path_1.join)(i,"lensmcp.tokens.json"),LENSMCP_RULES_FILE:(0,node_path_1.join)(i,"lensmcp.rules.json"),LENSMCP_HEADLESS:v===!1?"false":"true"},!0,{delayMs:1e4,max:5})):t("[lens] no dev URL/port resolved \u2014 skipping live capture."):t("[lens] browser-capture runner not found \u2014 skipping live capture. Install the self-contained CLI: `npm i -D lensmcp` (it ships `bundled/capture-runner.js`).")}return{...d!==void 0?{devPort:d}:{},...l?{devUrl:l}:{},vite:b}}r(spawnLensFrontend,"spawnLensFrontend"),o(spawnLensFrontend,"spawnLensFrontend");function locateBin(e,n){for(const t of n){const s=(0,node_path_1.join)(t,"node_modules",".bin",e);if((0,node_fs_1.existsSync)(s))return s}}r(locateBin,"locateBin"),o(locateBin,"locateBin");function resolveFirstExisting(e,n){for(const t of e){const s=(0,node_path_1.join)(n,t);if((0,node_fs_1.existsSync)(s))return s}}r(resolveFirstExisting,"resolveFirstExisting"),o(resolveFirstExisting,"resolveFirstExisting");let cachedGlobalRoot;function globalNodeModules(){if(cachedGlobalRoot!==void 0)return cachedGlobalRoot??void 0;const e=(0,node_path_1.resolve)((0,node_path_1.dirname)(process.execPath),"..","lib","node_modules");if((0,node_fs_1.existsSync)(e))return cachedGlobalRoot=e,e;try{const n=(0,node_child_process_1.execSync)("npm root -g",{encoding:"utf8",timeout:5e3}).trim();cachedGlobalRoot=n&&(0,node_fs_1.existsSync)(n)?n:null}catch{cachedGlobalRoot=null}return cachedGlobalRoot??void 0}r(globalNodeModules,"globalNodeModules"),o(globalNodeModules,"globalNodeModules");function findMcpBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","main.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","main.js")]:[],(0,node_path_1.join)(e,"servers","lensmcp-mcp","dist","main.js")])}r(findMcpBundle,"findMcpBundle"),o(findMcpBundle,"findMcpBundle");function findDashboardBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","dashboard.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","dashboard.js")]:[],(0,node_path_1.join)(e,"servers","lensmcp-mcp","dist","dashboard.js")])}r(findDashboardBundle,"findDashboardBundle"),o(findDashboardBundle,"findDashboardBundle");function findCaptureRunner(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","capture-runner.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","capture-runner.js")]:[],(0,node_path_1.join)(e,"libs","browser-capture","dist","capture-runner.js")])}r(findCaptureRunner,"findCaptureRunner"),o(findCaptureRunner,"findCaptureRunner");function findBridgeBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","bridge.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","bridge.js")]:[],(0,node_path_1.join)(e,"libs","bridge","dist","main.js")])}r(findBridgeBundle,"findBridgeBundle"),o(findBridgeBundle,"findBridgeBundle");function firstExisting(e){for(const n of e)if((0,node_fs_1.existsSync)(n))return n}r(firstExisting,"firstExisting"),o(firstExisting,"firstExisting");function clusterPageHosts(e){const n=new Set;for(const t of e){if(t.service||typeof t.host!="string")continue;const s=t.host.trim().toLowerCase();s&&n.add(s.startsWith("*.")?s.slice(1):s)}return[...n]}r(clusterPageHosts,"clusterPageHosts"),o(clusterPageHosts,"clusterPageHosts");function withBridgeAllowedOrigins(e,n){const t=[...new Set([...(e??"").split(/[\s,]+/).filter(Boolean),...n])];return t.length>0?t.join(","):void 0}r(withBridgeAllowedOrigins,"withBridgeAllowedOrigins"),o(withBridgeAllowedOrigins,"withBridgeAllowedOrigins");function readClusterPageDecls(e,n){const t=[];for(const s of n)try{const i=JSON.parse((0,node_fs_1.readFileSync)((0,node_path_1.join)(e,s,"project.json"),"utf8")),c=i.cluster??i.davnx;c&&typeof c=="object"&&t.push(c)}catch{}return t}r(readClusterPageDecls,"readClusterPageDecls"),o(readClusterPageDecls,"readClusterPageDecls");function standaloneBridgeOrigins(e,n,t=process.env){const s=clusterPageHosts(readClusterPageDecls(e,n)),i=withBridgeAllowedOrigins(t.LENSMCP_BRIDGE_ALLOWED_ORIGINS,s);return i?{hosts:s,allowedOrigins:i}:{hosts:s}}r(standaloneBridgeOrigins,"standaloneBridgeOrigins"),o(standaloneBridgeOrigins,"standaloneBridgeOrigins");
|
|
1
|
+
"use strict";var h=Object.defineProperty;var r=(e,n)=>h(e,"name",{value:n,configurable:!0});var m=Object.defineProperty,o=r((e,n)=>m(e,"name",{value:n,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.spawnLensFrontend=spawnLensFrontend,exports.locateBin=locateBin,exports.resolveFirstExisting=resolveFirstExisting,exports.globalNodeModules=globalNodeModules,exports.findMcpBundle=findMcpBundle,exports.findDashboardBundle=findDashboardBundle,exports.findCaptureRunner=findCaptureRunner,exports.findBridgeBundle=findBridgeBundle,exports.clusterPageHosts=clusterPageHosts,exports.withBridgeAllowedOrigins=withBridgeAllowedOrigins,exports.readClusterPageDecls=readClusterPageDecls,exports.standaloneBridgeOrigins=standaloneBridgeOrigins;const node_child_process_1=require("node:child_process"),node_fs_1=require("node:fs"),node_path_1=require("node:path");function spawnLensFrontend(e,n){const t=e.log??(u=>console.log(u)),{projectRoot:s,workspaceRoot:i,eventFile:c}=e,a=e.chrome!==!1,v=e.headless!==!1,p=e.viteBin??locateBin("vite",[s,i]);if(!p)throw new Error("[lens] Could not find the vite binary in node_modules/.bin.");const d=e.port??(a?5173:void 0),f=["--config",resolveFirstExisting(["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs","vite.config.cts","vite.config.cjs"],s)??(0,node_path_1.join)(s,"vite.config.ts"),s];d!==void 0&&f.push("--port",String(d),"--strictPort");const g={LENSMCP_EVENT_FILE:c,...e.project?{LENSMCP_APP:e.project}:{},...e.viteEnv??{}},j=e.labelPrefix??"";t(`[lens] starting Vite for ${e.project??s}${d?` on :${d}`:""}`);const b=n(`${j}vite`,p,f,g),l=e.openUrl??(d?`http://localhost:${d}/`:void 0);if(a){const u=findCaptureRunner(i);u?l?(t(`[lens] starting browser capture \u2192 ${l}`),n(`${j}browser-capture`,process.execPath,[u],{...g,LENSMCP_DEV_URL:l,LENSMCP_TOKENS_FILE:(0,node_path_1.join)(i,"lensmcp.tokens.json"),LENSMCP_RULES_FILE:(0,node_path_1.join)(i,"lensmcp.rules.json"),LENSMCP_HEADLESS:v===!1?"false":"true"},!0,{delayMs:1e4,max:5})):t("[lens] no dev URL/port resolved \u2014 skipping live capture."):t("[lens] browser-capture runner not found \u2014 skipping live capture. Install the self-contained CLI: `npm i -D lensmcp` (it ships `bundled/capture-runner.js`).")}return{...d!==void 0?{devPort:d}:{},...l?{devUrl:l}:{},vite:b}}r(spawnLensFrontend,"spawnLensFrontend"),o(spawnLensFrontend,"spawnLensFrontend");function locateBin(e,n){for(const t of n){const s=(0,node_path_1.join)(t,"node_modules",".bin",e);if((0,node_fs_1.existsSync)(s))return s}}r(locateBin,"locateBin"),o(locateBin,"locateBin");function resolveFirstExisting(e,n){for(const t of e){const s=(0,node_path_1.join)(n,t);if((0,node_fs_1.existsSync)(s))return s}}r(resolveFirstExisting,"resolveFirstExisting"),o(resolveFirstExisting,"resolveFirstExisting");let cachedGlobalRoot;function globalNodeModules(){if(cachedGlobalRoot!==void 0)return cachedGlobalRoot??void 0;const e=(0,node_path_1.resolve)((0,node_path_1.dirname)(process.execPath),"..","lib","node_modules");if((0,node_fs_1.existsSync)(e))return cachedGlobalRoot=e,e;try{const n=(0,node_child_process_1.execSync)("npm root -g",{encoding:"utf8",timeout:5e3}).trim();cachedGlobalRoot=n&&(0,node_fs_1.existsSync)(n)?n:null}catch{cachedGlobalRoot=null}return cachedGlobalRoot??void 0}r(globalNodeModules,"globalNodeModules"),o(globalNodeModules,"globalNodeModules");function findMcpBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","main.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","main.js")]:[],(0,node_path_1.join)(e,"servers","lensmcp-mcp","dist","main.js")])}r(findMcpBundle,"findMcpBundle"),o(findMcpBundle,"findMcpBundle");function findDashboardBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","dashboard.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","dashboard.js")]:[],(0,node_path_1.join)(e,"servers","lensmcp-mcp","dist","dashboard.js")])}r(findDashboardBundle,"findDashboardBundle"),o(findDashboardBundle,"findDashboardBundle");function findCaptureRunner(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","capture-runner.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","capture-runner.js")]:[],(0,node_path_1.join)(e,"libs","browser-capture","dist","capture-runner.js")])}r(findCaptureRunner,"findCaptureRunner"),o(findCaptureRunner,"findCaptureRunner");function findBridgeBundle(e){const n=globalNodeModules();return firstExisting([(0,node_path_1.join)(e,"node_modules","lensmcp","bundled","bridge.js"),...n?[(0,node_path_1.join)(n,"lensmcp","bundled","bridge.js")]:[],(0,node_path_1.join)(e,"libs","bridge","dist","main.js")])}r(findBridgeBundle,"findBridgeBundle"),o(findBridgeBundle,"findBridgeBundle");function firstExisting(e){for(const n of e)if((0,node_fs_1.existsSync)(n))return n}r(firstExisting,"firstExisting"),o(firstExisting,"firstExisting");function clusterPageHosts(e){const n=new Set;for(const t of e){if(t.service||typeof t.host!="string")continue;const s=t.host.trim().toLowerCase();s&&n.add(s.startsWith("*.")?s.slice(1):s)}return[...n]}r(clusterPageHosts,"clusterPageHosts"),o(clusterPageHosts,"clusterPageHosts");function withBridgeAllowedOrigins(e,n){const t=[...new Set([...(e??"").split(/[\s,]+/).filter(Boolean),...n])];return t.length>0?t.join(","):void 0}r(withBridgeAllowedOrigins,"withBridgeAllowedOrigins"),o(withBridgeAllowedOrigins,"withBridgeAllowedOrigins");function readClusterPageDecls(e,n){const t=[];for(const s of n)try{const i=JSON.parse((0,node_fs_1.readFileSync)((0,node_path_1.join)(e,s,"project.json"),"utf8")),c=i.cluster??i.davnx;c&&typeof c=="object"&&t.push(c)}catch{}return t}r(readClusterPageDecls,"readClusterPageDecls"),o(readClusterPageDecls,"readClusterPageDecls");function standaloneBridgeOrigins(e,n,t=process.env){const s=clusterPageHosts(readClusterPageDecls(e,n)),i=withBridgeAllowedOrigins(t.LENSMCP_BRIDGE_ALLOWED_ORIGINS,s);return i?{hosts:s,allowedOrigins:i}:{hosts:s}}r(standaloneBridgeOrigins,"standaloneBridgeOrigins"),o(standaloneBridgeOrigins,"standaloneBridgeOrigins");
|