Style.js 12 KB

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