@fugood/bricks-cli 2.25.0-beta.63 → 2.25.0-beta.65
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/lib/1010.js +1 -0
- package/lib/1178.js +1 -0
- package/lib/1215.js +1 -0
- package/lib/{708.js → 1708.js} +7 -7
- package/lib/1759.js +1 -0
- package/lib/1936.js +1 -0
- package/lib/2151.js +1 -0
- package/lib/{209.js → 2209.js} +3 -3
- package/lib/2247.js +1 -0
- package/lib/2486.js +1 -0
- package/lib/2557.js +1 -0
- package/lib/{223.js → 3223.js} +1 -1
- package/lib/3332.js +13 -0
- package/lib/3690.js +1 -0
- package/lib/3774.js +44 -0
- package/lib/3976.js +14 -0
- package/lib/4305.js +1 -0
- package/lib/4456.js +3 -0
- package/lib/{192.js → 4479.js} +4 -4
- package/lib/4530.js +22 -0
- package/lib/4642.js +9 -0
- package/lib/4685.js +1202 -0
- package/lib/5212.js +1 -0
- package/lib/{658.js → 5658.js} +1 -1
- package/lib/5785.js +1 -0
- package/lib/6194.js +3 -0
- package/lib/6370.js +1 -0
- package/lib/6645.js +1 -0
- package/lib/6818.js +1 -0
- package/lib/7111.js +2 -0
- package/lib/7456.js +1 -0
- package/lib/7511.js +1 -0
- package/lib/7574.js +1 -0
- package/lib/7648.js +1 -0
- package/lib/8026.js +1 -0
- package/lib/{117.js → 8117.js} +6 -6
- package/lib/8166.js +1 -0
- package/lib/853.js +1 -0
- package/lib/915.js +3 -3
- package/lib/9320.js +3 -0
- package/lib/{387.js → 9387.js} +1 -1
- package/lib/9405.js +1 -0
- package/lib/9430.js +1 -0
- package/lib/{583.js → 9583.js} +1 -1
- package/lib/9663.js +1 -0
- package/lib/{866.js → 9866.js} +1 -1
- package/lib/9940.js +19 -0
- package/lib/index.js +17 -17
- package/lib/simulator-main.mjs +5 -3
- package/package.json +5 -5
- package/lib/10.js +0 -1
- package/lib/111.js +0 -2
- package/lib/166.js +0 -1
- package/lib/178.js +0 -1
- package/lib/212.js +0 -1
- package/lib/215.js +0 -1
- package/lib/247.js +0 -1
- package/lib/274.js +0 -55
- package/lib/305.js +0 -1
- package/lib/306.js +0 -1
- package/lib/320.js +0 -3
- package/lib/332.js +0 -13
- package/lib/358.js +0 -1
- package/lib/370.js +0 -1
- package/lib/405.js +0 -1
- package/lib/430.js +0 -1
- package/lib/456.js +0 -3
- package/lib/479.js +0 -1231
- package/lib/486.js +0 -1
- package/lib/511.js +0 -1
- package/lib/557.js +0 -1
- package/lib/574.js +0 -1
- package/lib/645.js +0 -1
- package/lib/648.js +0 -1
- package/lib/663.js +0 -1
- package/lib/690.js +0 -1
- package/lib/75.js +0 -1
- package/lib/759.js +0 -1
- package/lib/785.js +0 -1
- package/lib/818.js +0 -1
- package/lib/917.js +0 -1
- package/lib/936.js +0 -1
- package/lib/940.js +0 -19
package/lib/simulator-main.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s,readdir as r,readFile as n,rm as a,writeFile as i}from"fs/promises";import{watchFile as l}from"fs";import{createServer as c}from"http";import p from"node:path";import{fileURLToPath as d}from"node:url";import{parseArgs as u}from"util";import*as w from"@toon-format/toon";import h from"./simulator-host-bridge.cjs";let{resolveAutomationScreenshotPath:m,normalizeAutomationScreenshotEncoding:
|
|
1
|
+
import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s,readdir as r,readFile as n,rm as a,writeFile as i}from"fs/promises";import{watchFile as l}from"fs";import{createServer as c}from"http";import p from"node:path";import{fileURLToPath as d}from"node:url";import{parseArgs as u}from"util";import*as w from"@toon-format/toon";import h from"./simulator-host-bridge.cjs";let{resolveAutomationScreenshotPath:m,normalizeAutomationScreenshotEncoding:g}=h;for(let e of[process.stdout,process.stderr])e.on("error",e=>{if("EPIPE"!==e.code)throw e});let{values:f}=u({args:process.argv,options:{"clear-cache":{type:"boolean"},"take-screenshot":{type:"string"},"show-menu":{type:"boolean"},"test-id":{type:"string"},"test-title-like":{type:"string"},"test-timeout":{type:"string"},"no-keep-open":{type:"boolean"},"cdp-port":{type:"string"}},strict:!0,allowPositionals:!0}),y=process.cwd(),S=p.dirname(d(import.meta.url)),b=Object.freeze({allowedInsecureHosts:[]}),v=(e={})=>{let t=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return{allowedInsecureHosts:(Array.isArray(t.allowedInsecureHosts)?t.allowedInsecureHosts:b.allowedInsecureHosts).filter(e=>"string"==typeof e).map(e=>e.trim().toLowerCase()).filter(Boolean)}},C=e=>{try{let t=new URL(String(e||""));if("http:"!==t.protocol&&"ws:"!==t.protocol)return null;return t.host.toLowerCase()}catch{return null}},k=async()=>{try{return v(JSON.parse(await n(`${y}/simulator.json`,"utf8")))}catch{return v()}},I=null;try{f["take-screenshot"]&&((I=JSON.parse(f["take-screenshot"])).path||(I.path=`${y}/screenshot.jpg`),I.width||(I.width=1280),I.height||(I.height=768),I.delay||(I.delay=1e3))}catch(e){console.error("Invalid take-screenshot config",e),process.exit(1)}let J=JSON.parse(await n(`${y}/.bricks/build/application-config.json`)),O=await k(),T=e=>{console.error(e),process.exit(1)},$=Object.values(J.automation_map||{}).flatMap(e=>Object.entries(e.map||{})),j=e=>{let t=e.toLowerCase();return $.find(([,e])=>e.title?.toLowerCase().includes(t))?.[0]??null},N=()=>$.map(([e,t])=>`- ${e} (${t.title||"untitled"})`).join("\n")||"(none — the compiled automation map is empty)",L=f["test-id"]||null;if(L&&!$.some(([e])=>e===L)){let e=f["test-title-like"]?j(f["test-title-like"]):null;e||T(`No automation test with id: ${f["test-id"]}. Available tests:
|
|
2
|
+
${N()}`),L=e}!L&&f["test-title-like"]&&((L=j(f["test-title-like"]))||T(`No automation found matching title: ${f["test-title-like"]}. Available tests:
|
|
3
|
+
${N()}`));let R=f["no-keep-open"]??!1,H=parseInt(f["test-timeout"]||"",10)||9e4,P=process.env.BRICKS_STAGE||"production",E={production:"https://control.bricks.tools/applicationPreview.html",beta:"https://control-beta.bricks.tools/applicationPreview.html",development:"http://localhost:3006/dev-applicationPreview.html"}[P];E||T(`Invalid BRICKS_STAGE: ${P}`),O=v({...O,allowedInsecureHosts:[...O.allowedInsecureHosts,C(E)].filter(Boolean)});let B=async(e,t)=>{let{WebSocketServer:o}=await import("ws"),s=new Set;e.webContents.on("console-message",(e,...t)=>{let o="object"==typeof t[0]?t[0].message:t[1];if(o?.startsWith("[CDP]"))try{let e=JSON.parse(o.slice(5)),t="cdp-response"===e.type?{id:e.id,result:e.result,error:e.error}:{method:e.method,params:e.params};e.sessionId&&(t.sessionId=e.sessionId);let r=JSON.stringify(t);for(let e of s)1===e.readyState&&e.send(r)}catch{}});let r=e=>new Promise(o=>{let s=c();s.once("error",()=>{e<t+100?o(r(e+1)):o(null)}),s.listen(e,()=>s.close(()=>o(e)))}),n=await r(t);if(!n)return void console.warn(`CDP server: no available port in range ${t}-${t+99}`);let a=c((e,t)=>{if("/json/list"===e.url||"/json"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify([{description:"BRICKS Simulator",id:"bricks-simulator",title:"BRICKS Simulator",type:"page",url:E,webSocketDebuggerUrl:`ws://localhost:${n}/ws`}]));return}if("/json/version"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({Browser:"BRICKS Simulator","Protocol-Version":"1.3"}));return}if("/devtools/info"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({name:"BRICKS Simulator",port:n,protocols:["cdp"],hasPasscode:!1}));return}t.writeHead(404),t.end()});new o({server:a,path:"/ws"}).on("connection",t=>{s.add(t),e.webContents.executeJavaScript(`
|
|
2
4
|
if (!window.__cdpRelayInstalled) {
|
|
3
5
|
window.__cdpRelayInstalled = true
|
|
4
6
|
window.addEventListener('message', (evt) => {
|
|
@@ -9,7 +11,7 @@ import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s
|
|
|
9
11
|
} catch {}
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
|
-
`),t.on("message",t=>{try{let o=JSON.parse(t.toString()),s=JSON.stringify({type:"cdp-request",id:o.id,method:o.method,params:o.params||{},sessionId:o.sessionId});e.webContents.executeJavaScript(`window.postMessage(${JSON.stringify(s)})`)}catch{}}),t.on("close",()=>s.delete(t))}),a.listen(n,()=>{console.log(`CDP server: ws://localhost:${n}/ws`),console.log(`Inspect: devtools://devtools/bundled/inspector.html?ws=localhost:${n}/ws`)})};e.on("ready",()=>{o.handle("bricks-automation-screenshots:exists",async(e,t)=>{try{return await n(((e="")=>m(y,e))(t)),!0}catch{return!1}}),o.handle("bricks-automation-screenshots:readdir",async(e,t)=>{try{return await r(((e="")=>m(y,e))(t))}catch{return[]}}),o.handle("bricks-automation-screenshots:mkdir",async(e,t)=>{await s(((e="")=>m(y,e))(t),{recursive:!0})}),o.handle("bricks-automation-screenshots:unlink",async(e,t)=>{await a(((e="")=>m(y,e))(t),{recursive:!0,force:!0})}),o.handle("bricks-automation-screenshots:read-file",async(e,t,o)=>n(((e="")=>m(y,e))(t),
|
|
14
|
+
`),t.on("message",t=>{try{let o=JSON.parse(t.toString()),s=JSON.stringify({type:"cdp-request",id:o.id,method:o.method,params:o.params||{},sessionId:o.sessionId});e.webContents.executeJavaScript(`window.postMessage(${JSON.stringify(s)})`)}catch{}}),t.on("close",()=>s.delete(t))}),a.listen(n,()=>{console.log(`CDP server: ws://localhost:${n}/ws`),console.log(`Inspect: devtools://devtools/bundled/inspector.html?ws=localhost:${n}/ws`)})};e.on("ready",()=>{o.handle("bricks-automation-screenshots:exists",async(e,t)=>{try{return await n(((e="")=>m(y,e))(t)),!0}catch{return!1}}),o.handle("bricks-automation-screenshots:readdir",async(e,t)=>{try{return await r(((e="")=>m(y,e))(t))}catch{return[]}}),o.handle("bricks-automation-screenshots:mkdir",async(e,t)=>{await s(((e="")=>m(y,e))(t),{recursive:!0})}),o.handle("bricks-automation-screenshots:unlink",async(e,t)=>{await a(((e="")=>m(y,e))(t),{recursive:!0,force:!0})}),o.handle("bricks-automation-screenshots:read-file",async(e,t,o)=>n(((e="")=>m(y,e))(t),g(o))),o.handle("bricks-automation-screenshots:write-file",async(e,t,o,r)=>{let n=((e="")=>m(y,e))(t);await s(p.dirname(n),{recursive:!0}),await i(n,o,g(r))});let c=!0;I&&!I.noHeadless&&(c=!1);let d=new t({width:I?.width||1280,height:I?.height||768,frame:!I,show:c,webPreferences:{preload:p.join(S,"simulator-preload.cjs"),contextIsolation:!0,nodeIntegration:!1}});d.setBackgroundColor("#333"),d.webContents.session.webRequest.onBeforeRequest({urls:["http://*/*","ws://*/*"]},(e,t)=>{t({cancel:((e,t={})=>{let o=v(t);try{let t=new URL(String(e||""));if("http:"!==t.protocol&&"ws:"!==t.protocol)return!1;let s=t.host.toLowerCase(),r=t.hostname.toLowerCase().replace(/^\[|\]$/g,"");return!o.allowedInsecureHosts.some(e=>{let o=(e=>{let t=String(e||"").trim().toLowerCase();if(!t)return null;if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(t))return{host:t,protocol:null};try{let e=new URL(t);return{host:e.host.toLowerCase(),protocol:e.protocol}}catch{return null}})(e);return!!o&&(!o.protocol||o.protocol===t.protocol)&&(o.host===s||o.host===r)})}catch{return!1}})(e.url,O)})}),d.loadURL(E);let u=()=>{let t={type:"config",configFile:{_originTitle:"Test",...J,title:Math.random().toString()},workspace:{billing:{lock:{},plan:"free"}},showMenu:f["show-menu"]||!1,testId:L};if(d.webContents.executeJavaScript(`window.postMessage(JSON.stringify(${JSON.stringify(t)}))`),I){let{delay:t,width:o,height:s,path:r}=I;setTimeout(async()=>{let t=!1;console.log("Taking screenshot");try{let e=await d.webContents.capturePage();console.log("Writing screenshot to",r),await i(r,e.resize({width:o,height:s}).toJPEG(75))}catch(e){t=!0,console.error("Screenshot capture/write failed",e)}finally{R&&(console.log("Closing app"),t?e.exit(1):e.quit())}},t)}},h=null;d.webContents.once("dom-ready",()=>{u(),L&&(R||I)&&(h=setTimeout(()=>{console.error(`Automation test ${L} did not report a result within ${H}ms — check that its waits can resolve and the expected canvas/data changes actually happen.`),e.exit(1)},H)),L&&d.webContents.executeJavaScript(`
|
|
13
15
|
window.addEventListener('message', (evt) => {
|
|
14
16
|
try {
|
|
15
17
|
const data = JSON.parse(evt.data)
|
|
@@ -18,4 +20,4 @@ import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s
|
|
|
18
20
|
}
|
|
19
21
|
} catch (e) {}
|
|
20
22
|
})
|
|
21
|
-
`);let
|
|
23
|
+
`);let t=f["cdp-port"]?parseInt(f["cdp-port"],10):null;t&&B(d,t)}),L&&d.webContents.on("console-message",(t,...o)=>{let s="object"==typeof o[0]?o[0].message:o[1];if(s?.startsWith("[TEST_RESULT]")){h&&clearTimeout(h);let t=JSON.parse(s.replace("[TEST_RESULT]",""));console.log(`[TEST_RESULT_TOON]${w.encode(t.result)}`),!I&&R&&e.quit()}}),f["clear-cache"]&&(console.log("Clearing cache"),d.webContents.session.clearCache()),d.on("close",()=>e.quit()),l(`${y}/.bricks/build/application-config.json`,{bigint:!1,persistent:!0,interval:1e3},async()=>{console.log("Detected config changed"),J=JSON.parse(await n(`${y}/.bricks/build/application-config.json`));let e=await k();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(E)].filter(Boolean)}),u()}),l(`${y}/simulator.json`,{bigint:!1,persistent:!0,interval:1e3},async()=>{console.log("Detected simulator settings changed");let e=await k();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(E)].filter(Boolean)})})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-cli",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.65",
|
|
4
4
|
"description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bricks",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"@babel/parser": "7.28.5",
|
|
57
57
|
"@babel/traverse": "7.28.5",
|
|
58
58
|
"@babel/types": "7.28.5",
|
|
59
|
-
"@fugood/bricks-config-core": "^2.25.0-beta.
|
|
60
|
-
"@fugood/bricks-core-generated": "^2.25.0-beta.
|
|
59
|
+
"@fugood/bricks-config-core": "^2.25.0-beta.65",
|
|
60
|
+
"@fugood/bricks-core-generated": "^2.25.0-beta.65",
|
|
61
61
|
"@fugood/bricks-system-properties-definition": "^2.24.0",
|
|
62
|
-
"@fugood/property-bank-calc-generated": "^2.25.0-beta.
|
|
62
|
+
"@fugood/property-bank-calc-generated": "^2.25.0-beta.65",
|
|
63
63
|
"@huggingface/gguf": "^0.3.2",
|
|
64
64
|
"@iarna/toml": "^3.0.0",
|
|
65
65
|
"@inquirer/prompts": "^7.0.0",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=18.0.0"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "1b94fe3266aea26a9d3b16273d1853a40bbff2ae"
|
|
94
94
|
}
|