Реверснутый zcode с своими фишками и плагинами · VibeGit
Реверснутый zcode с своими фишками и плагинами Реверснутая ade zcode без z ai, с массовой загрузкой ключей, умным апи роутингом, плагином для командной разработки
reversnutyy-zcode-s-svoimi-fishkami-i-plaginami / tools / shots-team-launcher-stand.mjs 125 строк · изменён 13 нояб., 21:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import path from 'node:path' ;
import fs from 'node:fs' ;
import http from 'node:http' ;
import { execSync } from 'node:child_process' ;
import { createRequire } from 'node:module' ;
const require = createRequire ( import . meta . url ) ;
const ROOT = path. resolve ( 'extracted/out/renderer' ) ;
path
pw path
css fs path f
page
server http
url req
url
res
res page
file path url
file fs file
res
res
res file
fs file res
server r
exe fs p
browser pw exe
results
check n ok x
results ok
p browser
errors
p errors e
p m errors m
p
p
card p
card
desc card
desc desc
p path
card
p
p path
card
p
p path
p
geo p
h
s
r h
h h r s r s r s
geo geo geo
geo
p path
p
p
follow p
s
r
r s r s
follow
frame p
frame
p
p
card
p
p
p
p
p
errors errors
browser
server
failed results x
process failed
const
OUT
=
.
resolve
(
'shots'
)
;
const
=
require
(
.
join
(
execSync
(
'npm root -g'
)
.
toString
(
)
.
trim
(
)
,
'@playwright/cli/node_modules/playwright-core'
)
)
;
const
icon
=
(
d
)
=>
` <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="size-6 text-foreground-subtle" aria-hidden="true"> ${ d} </svg> `
;
const
item
=
(
id, label, desc, svg
)
=>
`
<button type="button" data-side-pane-open-tab-item=" ${ id} " class="flex w-full min-w-0 items-center gap-3 rounded-xl px-2 py-2.5 text-left transition-colors hover:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-input-border-focused">
<span class="flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface"> ${ icon ( svg) } </span>
<span class="min-w-0 flex-1"><span class="block truncate text-ui-base font-semibold text-foreground"> ${ label} </span><span class="mt-0.5 flex min-w-0 items-center gap-1.5 text-ui-sm text-foreground-subtle"><span class="truncate" title=" ${ desc} "> ${ desc} </span></span></span>
<span aria-hidden="true" class="inline-flex items-center justify-center gap-1.5 whitespace-nowrap font-medium bg-secondary text-secondary-foreground hover:bg-secondary/80 h-7 px-3 text-ui-sm shrink-0 rounded-full">Open</span>
</button> `
;
const
=
.
readdirSync
(
.
join
(
ROOT
,
'assets'
)
)
.
filter
(
(
f
)
=>
/ ^ styles-. * \. css$ /
.
test
(
)
)
.
map
(
(
f
)
=>
` <link rel="stylesheet" href="/assets/ ${ f} "> `
)
.
join
(
''
)
;
const
=
` <!doctype html><html class="dark theme-zai-dark platform-windows-desktop"><head><meta charset="utf-8"> ${ css}
<style>html,body{height:100%;margin:0}body{background:var(--color-background);font-family:var(--font-sans)}
.app{display:flex;height:100%}.chat{flex:1;border-right:1px solid var(--color-border)}.pane{width:var(--pane-w,520px);display:flex;flex-direction:column}
.bar{height:48px;border-bottom:1px solid var(--color-border);display:flex;align-items:center;padding:0 12px;color:var(--color-foreground);font-size:13px}</style></head>
<body><div id="root" class="app"><div class="chat"></div><div class="pane"><div class="bar">New tab</div>
<div class="side-pane-open-tab-shell @container/launcher flex h-full min-h-0 flex-col bg-background"><div class="min-h-0 flex-1 overflow-y-auto px-7 py-6"><div class="mx-auto flex w-full max-w-3xl flex-col gap-6">
<h2 class="pl-2 text-ui-xl font-semibold text-foreground">New tab</h2>
<div class="grid min-w-0 grid-cols-1 gap-x-8 gap-y-1 @min-[36rem]/launcher:grid-cols-2">
${ item ( 'files' , 'Files' , 'Select a file from the navigation' , '<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>' ) }
${ item ( 'browser' , 'Browser' , 'Browse websites and preview apps.' , '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>' ) }
${ item ( 'terminal' , 'Terminal' , 'Run commands and view output.' , '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="m7 11 2-2-2-2"/><path d="M11 13h4"/>' ) }
${ item ( 'review' , 'Review' , 'Review code changes and diffs.' , '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 15h6"/><path d="M12 18v-6"/>' ) }
</div></div></div></div></div></div>
<script type="module" src="/assets/zteam-panel.js"></script></body></html> `
;
const
=
.
createServer
(
(
req, res
)
=>
{
const
=
new
URL
(
.
url
,
'http://x'
)
;
if
(
.
pathname
===
'/'
)
{
.
writeHead
(
200
,
{
'content-type'
:
'text/html; charset=utf-8'
}
)
;
return
.
end
(
)
;
}
const
=
.
join
(
ROOT
,
.
pathname
)
;
if
(
!
.
startsWith
(
ROOT
)
||
!
.
existsSync
(
)
)
{
.
writeHead
(
404
)
;
return
.
end
(
)
;
}
.
writeHead
(
200
,
{
'content-type'
:
.
endsWith
(
'.css'
)
?
'text/css'
:
'text/javascript'
}
)
;
.
createReadStream
(
)
.
pipe
(
)
;
}
)
;
await
new
Promise
(
(
r
)
=>
.
listen
(
8799
,
'127.0.0.1'
,
)
)
;
const
=
[
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
,
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'
]
.
find
(
(
p
)
=>
.
existsSync
(
)
)
;
const
=
await
.
chromium
.
launch
(
{
executablePath
:
}
)
;
const
=
[
]
;
const
=
(
,
,
=
''
)
=>
{
.
push
(
)
;
console
.
log
(
` ${ ok ? 'PASS' : 'FAIL' } ${ n} ${ x ? ' — ' + x : '' } `
)
;
}
;
try
{
const
=
await
.
newPage
(
{
viewport
:
{
width
:
1240
,
height
:
860
}
}
)
;
const
=
[
]
;
.
on
(
'pageerror'
,
(
e
)
=>
.
push
(
String
(
)
)
)
;
.
on
(
'console'
,
(
m
)
=>
.
type
(
)
===
'error'
&&
.
push
(
.
text
(
)
)
)
;
await
.
goto
(
'http://127.0.0.1:8799/'
)
;
await
.
waitForTimeout
(
1500
)
;
const
=
.
locator
(
'[data-side-pane-open-tab-item="aura-team"]'
)
;
check
(
'карточка «Команда» появилась в New tab'
,
(
await
.
count
(
)
)
===
1
)
;
const
=
await
.
textContent
(
)
;
check
(
'подпись и описание'
,
/ Team| Команда /
.
test
(
??
''
)
,
?.
trim
(
)
.
replace
(
/ \s + / g
,
' '
)
)
;
await
.
screenshot
(
{
path
:
.
join
(
OUT
,
'team-stand-launcher.png'
)
}
)
;
await
.
hover
(
)
;
await
.
waitForTimeout
(
200
)
;
await
.
screenshot
(
{
path
:
.
join
(
OUT
,
'team-stand-hover.png'
)
,
clip
:
{
x
:
720
,
y
:
60
,
width
:
520
,
height
:
330
}
}
)
;
await
.
click
(
)
;
await
.
waitForTimeout
(
110
)
;
await
.
screenshot
(
{
path
:
.
join
(
OUT
,
'team-stand-opening.png'
)
}
)
;
await
.
waitForTimeout
(
1500
)
;
const
=
await
.
evaluate
(
(
)
=>
{
const
=
document
.
getElementById
(
'zteam-host'
)
;
const
=
document
.
querySelector
(
'.side-pane-open-tab-shell'
)
.
getBoundingClientRect
(
)
;
const
=
.
getBoundingClientRect
(
)
;
return
{
open
:
.
dataset
.
open
,
ready
:
.
dataset
.
ready
,
same
:
Math
.
abs
(
.
x
-
.
x
)
<
1
&&
Math
.
abs
(
.
width
-
.
width
)
<
1
&&
Math
.
abs
(
.
height
-
.
height
)
<
1
}
;
}
)
;
check
(
'панель открылась ровно поверх вкладки'
,
.
open
===
'true'
&&
.
same
,
JSON
.
stringify
(
)
)
;
check
(
'iframe панели загрузился'
,
.
ready
===
'true'
)
;
await
.
screenshot
(
{
path
:
.
join
(
OUT
,
'team-stand-open.png'
)
}
)
;
await
.
evaluate
(
(
)
=>
document
.
documentElement
.
style
.
setProperty
(
'--pane-w'
,
'700px'
)
)
;
await
.
waitForTimeout
(
300
)
;
const
=
await
.
evaluate
(
(
)
=>
{
const
=
document
.
querySelector
(
'.side-pane-open-tab-shell'
)
.
getBoundingClientRect
(
)
;
const
=
document
.
getElementById
(
'zteam-host'
)
.
getBoundingClientRect
(
)
;
return
Math
.
abs
(
.
width
-
.
width
)
<
1
&&
Math
.
abs
(
.
x
-
.
x
)
<
1
;
}
)
;
check
(
'панель следует за шириной правой панели'
,
)
;
const
=
.
frameLocator
(
'#zteam-host iframe'
)
;
await
.
locator
(
'[aria-label="Закрыть панель"]'
)
.
click
(
)
;
await
.
waitForTimeout
(
400
)
;
check
(
'× в панели закрывает её'
,
(
await
.
evaluate
(
(
)
=>
document
.
getElementById
(
'zteam-host'
)
.
dataset
.
open
)
)
===
'false'
)
;
await
.
click
(
)
;
await
.
waitForTimeout
(
350
)
;
check
(
'повторное открытие без перезагрузки iframe'
,
(
await
.
evaluate
(
(
)
=>
document
.
getElementById
(
'zteam-host'
)
.
dataset
.
open
)
)
===
'true'
)
;
await
.
evaluate
(
(
)
=>
document
.
querySelector
(
'.side-pane-open-tab-shell'
)
.
remove
(
)
)
;
await
.
waitForTimeout
(
300
)
;
check
(
'закрытие вкладки прячет панель'
,
(
await
.
evaluate
(
(
)
=>
document
.
getElementById
(
'zteam-host'
)
.
dataset
.
open
)
)
===
'false'
)
;
check
(
'ошибок в консоли нет'
,
.
length
===
0
,
.
slice
(
0
,
3
)
.
join
(
' | '
)
)
;
}
finally
{
await
.
close
(
)
;
.
close
(
)
;
}
const
=
.
filter
(
(
x
)
=>
!
)
.
length
;
console
.
log
(
` \n ${ results. length - failed} / ${ results. length } passed `
)
;
.
exit
(
?
1
:
0
)
;