1
0

Style.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. export class Style {
  2. static init() {
  3. if ( document.getElementById( 'profiler-styles' ) ) return;
  4. const css = `
  5. :root {
  6. --profiler-bg: #1e1e24;
  7. --profiler-header: #2a2a33;
  8. --profiler-border: #4a4a5a;
  9. --text-primary: #e0e0e0;
  10. --text-secondary: #9a9aab;
  11. --accent-color: #00aaff;
  12. --color-green: #4caf50;
  13. --color-yellow: #ffc107;
  14. --color-red: #f44336;
  15. --font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  16. --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
  17. }
  18. @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Fira+Code&display=swap');
  19. #profiler-panel * {
  20. text-transform: initial;
  21. line-height: normal;
  22. }
  23. #profiler-toggle {
  24. position: fixed;
  25. top: 15px;
  26. right: 15px;
  27. background-color: rgba(30, 30, 36, 0.85);
  28. border: 1px solid #4a4a5a54;
  29. border-radius: 6px 12px 12px 6px;
  30. color: var(--text-primary);
  31. cursor: pointer;
  32. z-index: 1001;
  33. transition: all 0.2s ease-in-out;
  34. font-size: 14px;
  35. backdrop-filter: blur(8px);
  36. box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  37. display: flex;
  38. align-items: stretch;
  39. padding: 0;
  40. overflow: hidden;
  41. font-family: var(--font-family);
  42. }
  43. #profiler-toggle:hover {
  44. border-color: var(--accent-color);
  45. }
  46. #profiler-toggle.hidden {
  47. opacity: 0;
  48. pointer-events: none;
  49. }
  50. #toggle-icon {
  51. display: flex;
  52. align-items: center;
  53. justify-content: center;
  54. width: 40px;
  55. font-size: 20px;
  56. transition: background-color 0.2s;
  57. }
  58. #profiler-toggle:hover #toggle-icon {
  59. background-color: rgba(255, 255, 255, 0.05);
  60. }
  61. .toggle-separator {
  62. width: 1px;
  63. background-color: var(--profiler-border);
  64. }
  65. #toggle-text {
  66. display: flex;
  67. align-items: baseline;
  68. padding: 8px 14px;
  69. min-width: 80px;
  70. justify-content: right;
  71. }
  72. #toggle-text .fps-label {
  73. font-size: 0.7em;
  74. margin-left: 10px;
  75. color: #999;
  76. }
  77. #profiler-panel {
  78. position: fixed;
  79. z-index: 1001 !important;
  80. bottom: 0;
  81. left: 0;
  82. right: 0;
  83. height: 350px;
  84. background-color: var(--profiler-bg);
  85. border-top: 2px solid var(--profiler-border);
  86. color: var(--text-primary);
  87. display: flex;
  88. flex-direction: column;
  89. z-index: 1000;
  90. /*box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);*/
  91. transform: translateY(100%);
  92. transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.3s ease-out;
  93. font-family: var(--font-mono);
  94. }
  95. #profiler-panel.resizing {
  96. transition: none;
  97. }
  98. #profiler-panel.visible {
  99. transform: translateY(0);
  100. }
  101. #profiler-panel.maximized {
  102. height: 100vh;
  103. }
  104. .panel-resizer {
  105. position: absolute;
  106. top: -2px;
  107. left: 0;
  108. width: 100%;
  109. height: 5px;
  110. cursor: ns-resize;
  111. z-index: 1001;
  112. }
  113. .profiler-header {
  114. display: flex;
  115. background-color: var(--profiler-header);
  116. border-bottom: 1px solid var(--profiler-border);
  117. flex-shrink: 0;
  118. justify-content: space-between;
  119. align-items: stretch;
  120. }
  121. .profiler-tabs {
  122. display: flex;
  123. }
  124. .tab-btn {
  125. background: transparent;
  126. border: none;
  127. /*border-right: 1px solid var(--profiler-border);*/
  128. color: var(--text-secondary);
  129. padding: 8px 18px;
  130. cursor: pointer;
  131. display: flex;
  132. align-items: center;
  133. font-family: var(--font-family);
  134. font-weight: 600;
  135. font-size: 14px;
  136. }
  137. .tab-btn.active {
  138. border-bottom: 2px solid var(--accent-color);
  139. color: white;
  140. }
  141. #maximize-btn,
  142. #hide-panel-btn {
  143. background: transparent;
  144. border: none;
  145. border-left: 1px solid var(--profiler-border);
  146. color: var(--text-secondary);
  147. width: 45px;
  148. cursor: pointer;
  149. transition: all 0.2s;
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. }
  154. #maximize-btn:hover,
  155. #hide-panel-btn:hover {
  156. background-color: rgba(255, 255, 255, 0.1);
  157. color: var(--text-primary);
  158. }
  159. .profiler-content-wrapper {
  160. flex-grow: 1;
  161. overflow: hidden;
  162. position: relative;
  163. }
  164. .profiler-content {
  165. position: absolute;
  166. top: 0;
  167. left: 0;
  168. width: 100%;
  169. height: 100%;
  170. overflow-y: auto;
  171. font-size: 13px;
  172. visibility: hidden;
  173. opacity: 0;
  174. transition: opacity 0.2s, visibility 0.2s;
  175. box-sizing: border-box;
  176. display: flex;
  177. flex-direction: column;
  178. }
  179. .profiler-content.active {
  180. visibility: visible;
  181. opacity: 1;
  182. }
  183. .profiler-content {
  184. overflow: auto; /* make sure scrollbars can appear */
  185. }
  186. .profiler-content::-webkit-scrollbar {
  187. width: 8px;
  188. height: 8px;
  189. }
  190. .profiler-content::-webkit-scrollbar-track {
  191. background: transparent;
  192. }
  193. .profiler-content::-webkit-scrollbar-thumb {
  194. background-color: rgba(0, 0, 0, 0.25);
  195. border-radius: 10px;
  196. transition: background 0.3s ease;
  197. }
  198. .profiler-content::-webkit-scrollbar-thumb:hover {
  199. background-color: rgba(0, 0, 0, 0.4);
  200. }
  201. .profiler-content::-webkit-scrollbar-corner {
  202. background: transparent;
  203. }
  204. .profiler-content {
  205. scrollbar-width: thin; /* "auto" | "thin" */
  206. scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
  207. }
  208. .list-item-row {
  209. display: grid;
  210. align-items: center;
  211. padding: 4px 8px;
  212. border-radius: 3px;
  213. transition: background-color 0.2s;
  214. gap: 10px;
  215. border-bottom: none;
  216. }
  217. .list-item-wrapper {
  218. margin-top: 2px;
  219. margin-bottom: 2px;
  220. }
  221. .list-item-wrapper:first-child {
  222. /*margin-top: 0;*/
  223. }
  224. .list-item-wrapper:not(.header-wrapper):nth-child(odd) > .list-item-row {
  225. background-color: rgba(0,0,0,0.1);
  226. }
  227. .list-item-wrapper.header-wrapper>.list-item-row {
  228. color: var(--accent-color);
  229. background-color: rgba(0, 170, 255, 0.1);
  230. }
  231. .list-item-wrapper.header-wrapper>.list-item-row>.list-item-cell:first-child {
  232. font-weight: 600;
  233. }
  234. .list-item-row.collapsible,
  235. .list-item-row.actionable {
  236. cursor: pointer;
  237. }
  238. .list-item-row.collapsible {
  239. background-color: rgba(0, 170, 255, 0.15) !important;
  240. }
  241. .list-item-row.collapsible.alert,
  242. .list-item-row.alert {
  243. background-color: rgba(244, 67, 54, 0.1) !important;
  244. }
  245. @media (hover: hover) {
  246. .list-item-row:hover:not(.collapsible):not(.no-hover),
  247. .list-item-row:hover:not(.no-hover),
  248. .list-item-row.actionable:hover,
  249. .list-item-row.collapsible.actionable:hover {
  250. background-color: rgba(255, 255, 255, 0.05) !important;
  251. }
  252. .list-item-row.collapsible:hover {
  253. background-color: rgba(0, 170, 255, 0.25) !important;
  254. }
  255. }
  256. .list-item-cell {
  257. white-space: pre;
  258. display: flex;
  259. align-items: center;
  260. }
  261. .list-item-cell:not(:first-child) {
  262. justify-content: flex-end;
  263. font-weight: 600;
  264. }
  265. .list-header {
  266. display: grid;
  267. align-items: center;
  268. padding: 4px 8px;
  269. font-weight: 600;
  270. color: var(--text-secondary);
  271. padding-bottom: 6px;
  272. border-bottom: 1px solid var(--profiler-border);
  273. margin-bottom: 5px;
  274. gap: 10px;
  275. }
  276. .list-item-wrapper.section-start {
  277. margin-top: 5px;
  278. margin-bottom: 5px;
  279. }
  280. .list-header .list-header-cell:not(:first-child) {
  281. text-align: right;
  282. }
  283. .list-children-container {
  284. padding-left: 1.5em;
  285. overflow: hidden;
  286. max-height: 1000px;
  287. transition: max-height 0.1s ease-out;
  288. margin-top: 2px;
  289. }
  290. .list-children-container.closed {
  291. max-height: 0;
  292. }
  293. .item-toggler {
  294. display: inline-block;
  295. margin-right: 0.8em;
  296. text-align: left;
  297. }
  298. .list-item-row.open .item-toggler::before {
  299. content: '-';
  300. }
  301. .list-item-row:not(.open) .item-toggler::before {
  302. content: '+';
  303. }
  304. .list-item-cell .value.good {
  305. color: var(--color-green);
  306. }
  307. .list-item-cell .value.warn {
  308. color: var(--color-yellow);
  309. }
  310. .list-item-cell .value.bad {
  311. color: var(--color-red);
  312. }
  313. .list-scroll-wrapper {
  314. overflow-x: auto;
  315. width: 100%;
  316. }
  317. .list-container.parameters .list-item-row:not(.collapsible) {
  318. height: 31px;
  319. }
  320. .graph-container {
  321. width: 100%;
  322. box-sizing: border-box;
  323. padding: 8px 0;
  324. position: relative;
  325. }
  326. .graph-svg {
  327. width: 100%;
  328. height: 80px;
  329. background-color: #2a2a33;
  330. border: 1px solid var(--profiler-border);
  331. border-radius: 4px;
  332. }
  333. .graph-path {
  334. stroke-width: 2;
  335. fill-opacity: 0.4;
  336. }
  337. .console-header {
  338. padding: 10px;
  339. border-bottom: 1px solid var(--profiler-border);
  340. display: flex;
  341. gap: 20px;
  342. flex-shrink: 0;
  343. align-items: center;
  344. justify-content: space-between;
  345. }
  346. .console-filters-group {
  347. display: flex;
  348. gap: 20px;
  349. }
  350. .console-filter-input {
  351. background-color: var(--profiler-bg);
  352. border: 1px solid var(--profiler-border);
  353. color: var(--text-primary);
  354. border-radius: 4px;
  355. padding: 4px 8px;
  356. font-family: var(--font-mono);
  357. flex-grow: 1;
  358. max-width: 300px;
  359. border-radius: 15px;
  360. }
  361. #console-log {
  362. display: flex;
  363. flex-direction: column;
  364. gap: 4px;
  365. padding: 10px;
  366. overflow-y: auto;
  367. flex-grow: 1;
  368. }
  369. .log-message {
  370. padding: 2px 5px;
  371. white-space: pre-wrap;
  372. word-break: break-all;
  373. border-radius: 3px;
  374. line-height: 1.5 !important;
  375. }
  376. .log-message.hidden {
  377. display: none;
  378. }
  379. .log-message.info {
  380. color: var(--text-primary);
  381. }
  382. .log-message.warn {
  383. color: var(--color-yellow);
  384. }
  385. .log-message.error {
  386. color: #f9dedc;
  387. background-color: rgba(244, 67, 54, 0.1);
  388. }
  389. .log-prefix {
  390. color: var(--text-secondary);
  391. margin-right: 8px;
  392. }
  393. .log-code {
  394. background-color: rgba(255, 255, 255, 0.1);
  395. border-radius: 3px;
  396. padding: 1px 4px;
  397. }
  398. .thumbnail-container {
  399. display: flex;
  400. align-items: center;
  401. }
  402. .thumbnail-svg {
  403. width: 40px;
  404. height: 22.5px;
  405. flex-shrink: 0;
  406. margin-right: 8px;
  407. }
  408. .param-control {
  409. display: flex;
  410. align-items: center;
  411. justify-content: flex-end;
  412. gap: 10px;
  413. width: 100%;
  414. }
  415. .param-control input,
  416. .param-control select,
  417. .param-control button {
  418. background-color: var(--profiler-bg);
  419. border: 1px solid var(--profiler-border);
  420. color: var(--text-primary);
  421. border-radius: 4px;
  422. padding: 4px 6px;
  423. padding-bottom: 2px;
  424. font-family: var(--font-mono);
  425. width: 100%;
  426. box-sizing: border-box;
  427. }
  428. .param-control select {
  429. padding-top: 3px;
  430. padding-bottom: 1px;
  431. }
  432. .param-control input[type="number"] {
  433. cursor: ns-resize;
  434. }
  435. .param-control input[type="color"] {
  436. padding: 2px;
  437. }
  438. .param-control button {
  439. cursor: pointer;
  440. transition: background-color 0.2s;
  441. }
  442. .param-control button:hover {
  443. background-color: var(--profiler-header);
  444. }
  445. .param-control-vector {
  446. display: flex;
  447. gap: 5px;
  448. }
  449. .custom-checkbox {
  450. display: inline-flex;
  451. align-items: center;
  452. cursor: pointer;
  453. gap: 8px;
  454. }
  455. .custom-checkbox input {
  456. display: none;
  457. }
  458. .custom-checkbox .checkmark {
  459. width: 14px;
  460. height: 14px;
  461. border: 1px solid var(--profiler-border);
  462. border-radius: 3px;
  463. display: inline-flex;
  464. justify-content: center;
  465. align-items: center;
  466. transition: background-color 0.2s, border-color 0.2s;
  467. }
  468. .custom-checkbox .checkmark::after {
  469. content: '';
  470. width: 8px;
  471. height: 8px;
  472. background-color: var(--accent-color);
  473. border-radius: 1px;
  474. display: block;
  475. transform: scale(0);
  476. transition: transform 0.2s;
  477. }
  478. .custom-checkbox input:checked+.checkmark {
  479. border-color: var(--accent-color);
  480. }
  481. .custom-checkbox input:checked+.checkmark::after {
  482. transform: scale(1);
  483. }
  484. .param-control input[type="range"] {
  485. -webkit-appearance: none;
  486. appearance: none;
  487. width: 100%;
  488. height: 16px;
  489. background: var(--profiler-header);
  490. border-radius: 5px;
  491. border: 1px solid var(--profiler-border);
  492. outline: none;
  493. padding: 0px;
  494. padding-top: 8px;
  495. }
  496. .param-control input[type="range"]::-webkit-slider-thumb {
  497. -webkit-appearance: none;
  498. appearance: none;
  499. width: 18px;
  500. height: 18px;
  501. background: var(--profiler-bg);
  502. border: 1px solid var(--accent-color);
  503. border-radius: 3px;
  504. cursor: pointer;
  505. margin-top: -8px;
  506. }
  507. .param-control input[type="range"]::-moz-range-thumb {
  508. width: 18px;
  509. height: 18px;
  510. background: var(--profiler-bg);
  511. border: 2px solid var(--accent-color);
  512. border-radius: 3px;
  513. cursor: pointer;
  514. }
  515. .param-control input[type="range"]::-moz-range-track {
  516. width: 100%;
  517. height: 16px;
  518. background: var(--profiler-header);
  519. border-radius: 5px;
  520. border: 1px solid var(--profiler-border);
  521. }
  522. @media screen and (max-width: 768px) and (orientation: portrait) {
  523. .console-filter-input {
  524. max-width: 100px;
  525. }
  526. }
  527. `;
  528. const styleElement = document.createElement( 'style' );
  529. styleElement.id = 'profiler-styles';
  530. styleElement.textContent = css;
  531. document.head.appendChild( styleElement );
  532. }
  533. }
粤ICP备19079148号