@design.estate/wcctools 6.0.0 → 6.2.0

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.
Files changed (202) hide show
  1. package/changelog.md +33 -0
  2. package/dist_shell/bundle.js +405 -368
  3. package/dist_shell/bundle.js.map +1 -1
  4. package/dist_shell/bundle.js.third-party-notices.json +52 -0
  5. package/dist_shell/bundle.js.third-party-notices.txt +107 -1
  6. package/dist_shell/index.html +1 -1
  7. package/dist_ts/00_commitinfo_data.js +1 -1
  8. package/dist_ts/classes.bundlestatus.d.ts +36 -0
  9. package/dist_ts/classes.bundlestatus.js +110 -0
  10. package/dist_ts/classes.devapi.d.ts +3 -0
  11. package/dist_ts/classes.devapi.js +8 -1
  12. package/dist_ts/classes.devserver.d.ts +45 -10
  13. package/dist_ts/classes.devserver.js +123 -49
  14. package/dist_ts/cli.js +12 -3
  15. package/dist_ts/index.d.ts +0 -2
  16. package/dist_ts/index.js +1 -3
  17. package/dist_ts/plugins.d.ts +7 -2
  18. package/dist_ts/plugins.js +9 -3
  19. package/dist_ts/standards/baselines.d.ts +27 -0
  20. package/dist_ts/standards/baselines.js +83 -0
  21. package/dist_ts/standards/checker.d.ts +21 -0
  22. package/dist_ts/standards/checker.js +88 -0
  23. package/dist_ts/standards/classes.gitrepo.d.ts +13 -0
  24. package/dist_ts/standards/classes.gitrepo.js +43 -0
  25. package/dist_ts/standards/classes.sourceedits.d.ts +15 -0
  26. package/dist_ts/standards/classes.sourceedits.js +54 -0
  27. package/dist_ts/standards/classes.standardfixer.d.ts +40 -0
  28. package/dist_ts/standards/classes.standardfixer.js +210 -0
  29. package/dist_ts/standards/classes.standardproject.d.ts +80 -0
  30. package/dist_ts/standards/classes.standardproject.js +195 -0
  31. package/dist_ts/standards/classes.standardtree.d.ts +56 -0
  32. package/dist_ts/standards/classes.standardtree.js +207 -0
  33. package/dist_ts/standards/cli.d.ts +7 -0
  34. package/dist_ts/standards/cli.js +89 -0
  35. package/dist_ts/standards/config.d.ts +33 -0
  36. package/dist_ts/standards/config.js +139 -0
  37. package/dist_ts/standards/errors.d.ts +9 -0
  38. package/dist_ts/standards/errors.js +17 -0
  39. package/dist_ts/standards/helpers.ast.d.ts +56 -0
  40. package/dist_ts/standards/helpers.ast.js +172 -0
  41. package/dist_ts/standards/helpers.paths.d.ts +36 -0
  42. package/dist_ts/standards/helpers.paths.js +86 -0
  43. package/dist_ts/standards/index.d.ts +14 -0
  44. package/dist_ts/standards/index.js +15 -0
  45. package/dist_ts/standards/output.d.ts +7 -0
  46. package/dist_ts/standards/output.js +57 -0
  47. package/dist_ts/standards/ratchet.d.ts +15 -0
  48. package/dist_ts/standards/ratchet.js +45 -0
  49. package/dist_ts/standards/rule.d.ts +50 -0
  50. package/dist_ts/standards/rule.js +9 -0
  51. package/dist_ts/standards/rules/barrel.element-index.d.ts +7 -0
  52. package/dist_ts/standards/rules/barrel.element-index.js +108 -0
  53. package/dist_ts/standards/rules/barrel.no-demo-export.d.ts +3 -0
  54. package/dist_ts/standards/rules/barrel.no-demo-export.js +29 -0
  55. package/dist_ts/standards/rules/demo.fixture-not-exported.d.ts +3 -0
  56. package/dist_ts/standards/rules/demo.fixture-not-exported.js +29 -0
  57. package/dist_ts/standards/rules/demo.groups.d.ts +6 -0
  58. package/dist_ts/standards/rules/demo.groups.js +72 -0
  59. package/dist_ts/standards/rules/demo.required.d.ts +3 -0
  60. package/dist_ts/standards/rules/demo.required.js +48 -0
  61. package/dist_ts/standards/rules/demo.separate-file.d.ts +3 -0
  62. package/dist_ts/standards/rules/demo.separate-file.js +38 -0
  63. package/dist_ts/standards/rules/demo.shape.d.ts +3 -0
  64. package/dist_ts/standards/rules/demo.shape.js +38 -0
  65. package/dist_ts/standards/rules/docs.component-index.d.ts +8 -0
  66. package/dist_ts/standards/rules/docs.component-index.js +84 -0
  67. package/dist_ts/standards/rules/element.exported.d.ts +3 -0
  68. package/dist_ts/standards/rules/element.exported.js +33 -0
  69. package/dist_ts/standards/rules/element.literal-tag.d.ts +3 -0
  70. package/dist_ts/standards/rules/element.literal-tag.js +30 -0
  71. package/dist_ts/standards/rules/element.reachable.d.ts +3 -0
  72. package/dist_ts/standards/rules/element.reachable.js +48 -0
  73. package/dist_ts/standards/rules/element.tag-map.d.ts +3 -0
  74. package/dist_ts/standards/rules/element.tag-map.js +83 -0
  75. package/dist_ts/standards/rules/i18n.literals.d.ts +3 -0
  76. package/dist_ts/standards/rules/i18n.literals.js +52 -0
  77. package/dist_ts/standards/rules/index.d.ts +12 -0
  78. package/dist_ts/standards/rules/index.js +83 -0
  79. package/dist_ts/standards/rules/layout.element-folder.d.ts +3 -0
  80. package/dist_ts/standards/rules/layout.element-folder.js +47 -0
  81. package/dist_ts/standards/rules/layout.entry-file-name.d.ts +3 -0
  82. package/dist_ts/standards/rules/layout.entry-file-name.js +71 -0
  83. package/dist_ts/standards/rules/layout.entry.d.ts +3 -0
  84. package/dist_ts/standards/rules/layout.entry.js +38 -0
  85. package/dist_ts/standards/rules/layout.group-folder.d.ts +3 -0
  86. package/dist_ts/standards/rules/layout.group-folder.js +22 -0
  87. package/dist_ts/standards/rules/layout.shared-00.d.ts +3 -0
  88. package/dist_ts/standards/rules/layout.shared-00.js +36 -0
  89. package/dist_ts/standards/rules/naming.class-matches-tag.d.ts +3 -0
  90. package/dist_ts/standards/rules/naming.class-matches-tag.js +26 -0
  91. package/dist_ts/standards/rules/naming.lowercase-files.d.ts +3 -0
  92. package/dist_ts/standards/rules/naming.lowercase-files.js +26 -0
  93. package/dist_ts/standards/rules/naming.tag-prefix.d.ts +3 -0
  94. package/dist_ts/standards/rules/naming.tag-prefix.js +23 -0
  95. package/dist_ts/standards/rules/props.accessor.d.ts +3 -0
  96. package/dist_ts/standards/rules/props.accessor.js +35 -0
  97. package/dist_ts/standards/rules/props.object-no-attribute.d.ts +3 -0
  98. package/dist_ts/standards/rules/props.object-no-attribute.js +42 -0
  99. package/dist_ts/standards/rules/props.reflect-primitive.d.ts +5 -0
  100. package/dist_ts/standards/rules/props.reflect-primitive.js +41 -0
  101. package/dist_ts/standards/rules/props.typed.d.ts +6 -0
  102. package/dist_ts/standards/rules/props.typed.js +64 -0
  103. package/dist_ts/standards/rules/shared.d.ts +38 -0
  104. package/dist_ts/standards/rules/shared.js +103 -0
  105. package/dist_ts/standards/rules/style.bdtheme.d.ts +5 -0
  106. package/dist_ts/standards/rules/style.bdtheme.js +28 -0
  107. package/dist_ts_interfaces/index.d.ts +1 -0
  108. package/dist_ts_interfaces/index.js +2 -1
  109. package/dist_ts_interfaces/requests.d.ts +35 -0
  110. package/dist_ts_interfaces/standard.d.ts +93 -0
  111. package/dist_ts_interfaces/standard.js +6 -0
  112. package/dist_ts_shell/bundlestatus.d.ts +15 -0
  113. package/dist_ts_shell/bundlestatus.js +64 -0
  114. package/dist_ts_shell/elements/wcc-contextmenu.d.ts +3 -0
  115. package/dist_ts_shell/elements/wcc-contextmenu.js +18 -3
  116. package/dist_ts_shell/elements/wcc-preview-frame.d.ts +6 -0
  117. package/dist_ts_shell/elements/wcc-preview-frame.js +50 -2
  118. package/dist_ts_shell/elements/wcc-shell.d.ts +15 -0
  119. package/dist_ts_shell/elements/wcc-shell.js +45 -3
  120. package/dist_ts_shell/plugins.d.ts +2 -1
  121. package/dist_ts_shell/plugins.js +3 -2
  122. package/dist_ts_web/00_commitinfo_data.js +1 -1
  123. package/package.json +8 -3
  124. package/readme.md +40 -3
  125. package/ts/00_commitinfo_data.ts +1 -1
  126. package/ts/classes.bundlestatus.ts +123 -0
  127. package/ts/classes.devapi.ts +9 -0
  128. package/ts/classes.devserver.ts +127 -47
  129. package/ts/cli.ts +12 -2
  130. package/ts/index.ts +0 -2
  131. package/ts/plugins.ts +10 -2
  132. package/ts/standards/baselines.ts +100 -0
  133. package/ts/standards/checker.ts +114 -0
  134. package/ts/standards/classes.gitrepo.ts +48 -0
  135. package/ts/standards/classes.sourceedits.ts +58 -0
  136. package/ts/standards/classes.standardfixer.ts +234 -0
  137. package/ts/standards/classes.standardproject.ts +250 -0
  138. package/ts/standards/classes.standardtree.ts +220 -0
  139. package/ts/standards/cli.ts +86 -0
  140. package/ts/standards/config.ts +160 -0
  141. package/ts/standards/errors.ts +18 -0
  142. package/ts/standards/helpers.ast.ts +208 -0
  143. package/ts/standards/helpers.paths.ts +119 -0
  144. package/ts/standards/index.ts +22 -0
  145. package/ts/standards/output.ts +65 -0
  146. package/ts/standards/ratchet.ts +63 -0
  147. package/ts/standards/rule.ts +58 -0
  148. package/ts/standards/rules/barrel.element-index.ts +112 -0
  149. package/ts/standards/rules/barrel.no-demo-export.ts +30 -0
  150. package/ts/standards/rules/demo.fixture-not-exported.ts +30 -0
  151. package/ts/standards/rules/demo.groups.ts +74 -0
  152. package/ts/standards/rules/demo.required.ts +49 -0
  153. package/ts/standards/rules/demo.separate-file.ts +40 -0
  154. package/ts/standards/rules/demo.shape.ts +42 -0
  155. package/ts/standards/rules/docs.component-index.ts +88 -0
  156. package/ts/standards/rules/element.exported.ts +35 -0
  157. package/ts/standards/rules/element.literal-tag.ts +30 -0
  158. package/ts/standards/rules/element.reachable.ts +49 -0
  159. package/ts/standards/rules/element.tag-map.ts +87 -0
  160. package/ts/standards/rules/i18n.literals.ts +58 -0
  161. package/ts/standards/rules/index.ts +87 -0
  162. package/ts/standards/rules/layout.element-folder.ts +49 -0
  163. package/ts/standards/rules/layout.entry-file-name.ts +73 -0
  164. package/ts/standards/rules/layout.entry.ts +40 -0
  165. package/ts/standards/rules/layout.group-folder.ts +23 -0
  166. package/ts/standards/rules/layout.shared-00.ts +37 -0
  167. package/ts/standards/rules/naming.class-matches-tag.ts +27 -0
  168. package/ts/standards/rules/naming.lowercase-files.ts +27 -0
  169. package/ts/standards/rules/naming.tag-prefix.ts +24 -0
  170. package/ts/standards/rules/props.accessor.ts +37 -0
  171. package/ts/standards/rules/props.object-no-attribute.ts +45 -0
  172. package/ts/standards/rules/props.reflect-primitive.ts +44 -0
  173. package/ts/standards/rules/props.typed.ts +70 -0
  174. package/ts/standards/rules/shared.ts +127 -0
  175. package/ts/standards/rules/style.bdtheme.ts +31 -0
  176. package/ts_interfaces/bridge.ts +95 -0
  177. package/ts_interfaces/catalog.ts +37 -0
  178. package/ts_interfaces/index.ts +4 -0
  179. package/ts_interfaces/plugins.ts +3 -0
  180. package/ts_interfaces/requests.ts +65 -0
  181. package/ts_interfaces/standard.ts +103 -0
  182. package/ts_shared/index.ts +1 -0
  183. package/ts_shared/plugins.ts +3 -0
  184. package/ts_shared/previewroute.ts +58 -0
  185. package/ts_shell/bundlestatus.ts +68 -0
  186. package/ts_shell/elements/wcc-contextmenu.ts +306 -0
  187. package/ts_shell/elements/wcc-preview-frame.ts +167 -0
  188. package/ts_shell/elements/wcc-properties.ts +998 -0
  189. package/ts_shell/elements/wcc-record-button.ts +108 -0
  190. package/ts_shell/elements/wcc-recording-panel.ts +1005 -0
  191. package/ts_shell/elements/wcc-shell.ts +485 -0
  192. package/ts_shell/elements/wcc-sidebar.ts +1419 -0
  193. package/ts_shell/index.html +21 -0
  194. package/ts_shell/index.ts +4 -0
  195. package/ts_shell/plugins.ts +12 -0
  196. package/ts_shell/previewconnection.ts +103 -0
  197. package/ts_shell/services/recorder.service.ts +451 -0
  198. package/ts_shell/types/dom-mediacapture-stub/index.d.ts +12 -0
  199. package/ts_shell/types/dom-mediacapture-stub/package.json +6 -0
  200. package/ts_shell/types/dom-webcodecs-stub/index.d.ts +2 -0
  201. package/ts_shell/types/dom-webcodecs-stub/package.json +6 -0
  202. package/ts_web/00_commitinfo_data.ts +1 -1
@@ -0,0 +1,1005 @@
1
+ import { DeesElement, customElement, html, css, property, state, type TemplateResult } from '@design.estate/dees-element';
2
+ import { RecorderService, type TOutputFormat } from '../services/recorder.service.js';
3
+
4
+ @customElement('wcc-recording-panel')
5
+ export class WccRecordingPanel extends DeesElement {
6
+ /** The element a viewport recording is cropped to: the shell's preview frame. */
7
+ @property({ attribute: false })
8
+ accessor captureTarget: HTMLElement | null = null;
9
+
10
+ // Panel state
11
+ @state()
12
+ accessor panelState: 'options' | 'recording' | 'preview' = 'options';
13
+
14
+ // Recording options
15
+ @state()
16
+ accessor recordingMode: 'viewport' | 'screen' = 'viewport';
17
+
18
+ @state()
19
+ accessor outputFormat: TOutputFormat = 'mp4';
20
+
21
+ @state()
22
+ accessor audioEnabled: boolean = false;
23
+
24
+ @state()
25
+ accessor selectedMicrophoneId: string = '';
26
+
27
+ @state()
28
+ accessor availableMicrophones: MediaDeviceInfo[] = [];
29
+
30
+ @state()
31
+ accessor audioLevel: number = 0;
32
+
33
+ // Recording state
34
+ @state()
35
+ accessor recordingDuration: number = 0;
36
+
37
+ // Preview/trim state
38
+ @state()
39
+ accessor previewVideoUrl: string = '';
40
+
41
+ @state()
42
+ accessor trimStart: number = 0;
43
+
44
+ @state()
45
+ accessor trimEnd: number = 0;
46
+
47
+ @state()
48
+ accessor videoDuration: number = 0;
49
+
50
+ @state()
51
+ accessor isDraggingTrim: 'start' | 'end' | null = null;
52
+
53
+ @state()
54
+ accessor isExporting: boolean = false;
55
+
56
+ // Service instance
57
+ private recorderService: RecorderService;
58
+
59
+ constructor() {
60
+ super();
61
+ this.recorderService = new RecorderService({
62
+ onDurationUpdate: (duration) => {
63
+ this.recordingDuration = duration;
64
+ this.dispatchEvent(new CustomEvent('duration-update', {
65
+ detail: { duration },
66
+ bubbles: true,
67
+ composed: true
68
+ }));
69
+ },
70
+ onRecordingComplete: (blob) => {
71
+ this.handleRecordingComplete(blob);
72
+ },
73
+ onAudioLevelUpdate: (level) => {
74
+ this.audioLevel = level;
75
+ },
76
+ onStreamEnded: () => {
77
+ this.stopRecording();
78
+ }
79
+ });
80
+ }
81
+
82
+ public static styles = [
83
+ css`
84
+ :host {
85
+ /* CSS Variables */
86
+ --background: #0a0a0a;
87
+ --foreground: #e5e5e5;
88
+ --input: #141414;
89
+ --primary: #3b82f6;
90
+ --border: rgba(255, 255, 255, 0.06);
91
+ --radius-sm: 2px;
92
+ --radius-md: 4px;
93
+ --radius-lg: 6px;
94
+ }
95
+
96
+ /* Recording Options Panel */
97
+ .recording-options-panel {
98
+ position: fixed;
99
+ right: 16px;
100
+ bottom: 116px;
101
+ width: 360px;
102
+ background: #0c0c0c;
103
+ border: 1px solid rgba(255, 255, 255, 0.1);
104
+ border-radius: var(--radius-md);
105
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
106
+ z-index: 1000;
107
+ overflow: hidden;
108
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
109
+ }
110
+
111
+ .recording-options-header {
112
+ padding: 0.75rem 1rem;
113
+ background: rgba(255, 255, 255, 0.02);
114
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
115
+ display: flex;
116
+ justify-content: space-between;
117
+ align-items: center;
118
+ }
119
+
120
+ .recording-options-title {
121
+ font-size: 0.8rem;
122
+ font-weight: 500;
123
+ color: #ccc;
124
+ }
125
+
126
+ .recording-options-close {
127
+ width: 24px;
128
+ height: 24px;
129
+ background: transparent;
130
+ border: none;
131
+ color: #666;
132
+ cursor: pointer;
133
+ display: flex;
134
+ align-items: center;
135
+ justify-content: center;
136
+ border-radius: var(--radius-sm);
137
+ transition: all 0.15s ease;
138
+ }
139
+
140
+ .recording-options-close:hover {
141
+ background: rgba(255, 255, 255, 0.05);
142
+ color: #999;
143
+ }
144
+
145
+ .recording-options-content {
146
+ padding: 1rem;
147
+ }
148
+
149
+ .recording-option-group {
150
+ margin-bottom: 1rem;
151
+ }
152
+
153
+ .recording-option-group:last-child {
154
+ margin-bottom: 0;
155
+ }
156
+
157
+ .recording-option-label {
158
+ font-size: 0.7rem;
159
+ font-weight: 500;
160
+ color: #888;
161
+ text-transform: uppercase;
162
+ letter-spacing: 0.05em;
163
+ margin-bottom: 0.5rem;
164
+ }
165
+
166
+ .recording-mode-buttons {
167
+ display: flex;
168
+ gap: 0.5rem;
169
+ }
170
+
171
+ .recording-mode-btn {
172
+ flex: 1;
173
+ padding: 0.6rem 0.75rem;
174
+ background: var(--input);
175
+ border: 1px solid transparent;
176
+ border-radius: var(--radius-sm);
177
+ color: #999;
178
+ font-size: 0.75rem;
179
+ cursor: pointer;
180
+ transition: all 0.15s ease;
181
+ text-align: center;
182
+ }
183
+
184
+ .recording-mode-btn:hover {
185
+ border-color: var(--primary);
186
+ color: #ccc;
187
+ }
188
+
189
+ .recording-mode-btn.selected {
190
+ background: rgba(59, 130, 246, 0.15);
191
+ border-color: var(--primary);
192
+ color: var(--primary);
193
+ }
194
+
195
+ .audio-toggle {
196
+ display: flex;
197
+ align-items: center;
198
+ gap: 0.5rem;
199
+ margin-bottom: 0.75rem;
200
+ }
201
+
202
+ .audio-toggle input[type="checkbox"] {
203
+ width: 1rem;
204
+ height: 1rem;
205
+ accent-color: var(--primary);
206
+ }
207
+
208
+ .audio-toggle label {
209
+ font-size: 0.75rem;
210
+ color: #999;
211
+ cursor: pointer;
212
+ }
213
+
214
+ .microphone-select {
215
+ width: 100%;
216
+ padding: 0.5rem 0.75rem;
217
+ background: var(--input);
218
+ border: 1px solid transparent;
219
+ border-radius: var(--radius-sm);
220
+ color: var(--foreground);
221
+ font-size: 0.75rem;
222
+ outline: none;
223
+ cursor: pointer;
224
+ transition: all 0.15s ease;
225
+ }
226
+
227
+ .microphone-select:focus {
228
+ border-color: var(--primary);
229
+ }
230
+
231
+ .microphone-select:disabled {
232
+ opacity: 0.5;
233
+ cursor: not-allowed;
234
+ }
235
+
236
+ .audio-level-container {
237
+ margin-top: 0.75rem;
238
+ padding: 0.5rem;
239
+ background: rgba(255, 255, 255, 0.02);
240
+ border-radius: var(--radius-sm);
241
+ }
242
+
243
+ .audio-level-label {
244
+ font-size: 0.65rem;
245
+ color: #666;
246
+ margin-bottom: 0.25rem;
247
+ }
248
+
249
+ .audio-level-bar {
250
+ height: 8px;
251
+ background: var(--input);
252
+ border-radius: 4px;
253
+ overflow: hidden;
254
+ }
255
+
256
+ .audio-level-fill {
257
+ height: 100%;
258
+ background: linear-gradient(90deg, #22c55e, #84cc16, #eab308);
259
+ border-radius: 4px;
260
+ transition: width 0.1s ease;
261
+ }
262
+
263
+ .start-recording-btn {
264
+ width: 100%;
265
+ padding: 0.75rem;
266
+ background: #dc2626;
267
+ border: none;
268
+ border-radius: var(--radius-sm);
269
+ color: white;
270
+ font-size: 0.8rem;
271
+ font-weight: 500;
272
+ cursor: pointer;
273
+ transition: all 0.15s ease;
274
+ margin-top: 1rem;
275
+ display: flex;
276
+ align-items: center;
277
+ justify-content: center;
278
+ gap: 0.5rem;
279
+ }
280
+
281
+ .start-recording-btn:hover {
282
+ background: #b91c1c;
283
+ }
284
+
285
+ .start-recording-btn .rec-dot {
286
+ width: 10px;
287
+ height: 10px;
288
+ background: white;
289
+ border-radius: 50%;
290
+ }
291
+
292
+ /* Preview Modal */
293
+ .preview-modal-overlay {
294
+ position: fixed;
295
+ top: 0;
296
+ left: 0;
297
+ right: 0;
298
+ bottom: 0;
299
+ background: rgba(0, 0, 0, 0.8);
300
+ display: flex;
301
+ align-items: center;
302
+ justify-content: center;
303
+ z-index: 1000;
304
+ backdrop-filter: blur(4px);
305
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
306
+ }
307
+
308
+ .preview-modal {
309
+ width: 90%;
310
+ max-width: 800px;
311
+ background: #0c0c0c;
312
+ border: 1px solid rgba(255, 255, 255, 0.1);
313
+ border-radius: var(--radius-lg);
314
+ overflow: hidden;
315
+ box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
316
+ }
317
+
318
+ .preview-modal-header {
319
+ padding: 1rem 1.25rem;
320
+ background: rgba(255, 255, 255, 0.02);
321
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
322
+ display: flex;
323
+ justify-content: space-between;
324
+ align-items: center;
325
+ }
326
+
327
+ .preview-modal-title {
328
+ font-size: 0.9rem;
329
+ font-weight: 500;
330
+ color: #ccc;
331
+ }
332
+
333
+ .preview-modal-close {
334
+ width: 28px;
335
+ height: 28px;
336
+ background: transparent;
337
+ border: none;
338
+ color: #666;
339
+ cursor: pointer;
340
+ display: flex;
341
+ align-items: center;
342
+ justify-content: center;
343
+ border-radius: var(--radius-sm);
344
+ font-size: 1.2rem;
345
+ transition: all 0.15s ease;
346
+ }
347
+
348
+ .preview-modal-close:hover {
349
+ background: rgba(255, 255, 255, 0.05);
350
+ color: #999;
351
+ }
352
+
353
+ .preview-modal-content {
354
+ padding: 1.25rem;
355
+ }
356
+
357
+ .preview-video-container {
358
+ background: #000;
359
+ border-radius: var(--radius-sm);
360
+ overflow: hidden;
361
+ aspect-ratio: 16 / 9;
362
+ }
363
+
364
+ .preview-video {
365
+ width: 100%;
366
+ height: 100%;
367
+ object-fit: contain;
368
+ }
369
+
370
+ .preview-modal-actions {
371
+ padding: 1rem 1.25rem;
372
+ border-top: 1px solid rgba(255, 255, 255, 0.05);
373
+ display: flex;
374
+ justify-content: flex-end;
375
+ gap: 0.75rem;
376
+ }
377
+
378
+ .preview-btn {
379
+ padding: 0.6rem 1.25rem;
380
+ border-radius: var(--radius-sm);
381
+ font-size: 0.8rem;
382
+ font-weight: 500;
383
+ cursor: pointer;
384
+ transition: all 0.15s ease;
385
+ display: inline-flex;
386
+ align-items: center;
387
+ gap: 0.5rem;
388
+ }
389
+
390
+ .preview-btn.secondary {
391
+ background: transparent;
392
+ border: 1px solid rgba(255, 255, 255, 0.1);
393
+ color: #999;
394
+ }
395
+
396
+ .preview-btn.secondary:hover {
397
+ border-color: rgba(255, 255, 255, 0.2);
398
+ color: #ccc;
399
+ }
400
+
401
+ .preview-btn.primary {
402
+ background: var(--primary);
403
+ border: none;
404
+ color: white;
405
+ }
406
+
407
+ .preview-btn.primary:hover {
408
+ background: #2563eb;
409
+ }
410
+
411
+ .preview-btn.primary:disabled {
412
+ background: #1e3a5f;
413
+ cursor: not-allowed;
414
+ opacity: 0.7;
415
+ }
416
+
417
+ /* Trim Timeline Styles */
418
+ .trim-section {
419
+ margin-top: 1.25rem;
420
+ padding-top: 1.25rem;
421
+ border-top: 1px solid rgba(255, 255, 255, 0.05);
422
+ }
423
+
424
+ .trim-section-header {
425
+ display: flex;
426
+ justify-content: space-between;
427
+ align-items: center;
428
+ margin-bottom: 0.75rem;
429
+ }
430
+
431
+ .trim-section-title {
432
+ font-size: 0.75rem;
433
+ font-weight: 500;
434
+ color: #888;
435
+ text-transform: uppercase;
436
+ letter-spacing: 0.05em;
437
+ }
438
+
439
+ .trim-duration-info {
440
+ font-size: 0.7rem;
441
+ color: #666;
442
+ font-family: 'Consolas', 'Monaco', monospace;
443
+ }
444
+
445
+ .trim-timeline {
446
+ position: relative;
447
+ height: 48px;
448
+ background: var(--input);
449
+ border-radius: var(--radius-sm);
450
+ margin-bottom: 0.75rem;
451
+ user-select: none;
452
+ }
453
+
454
+ .trim-track {
455
+ position: absolute;
456
+ top: 50%;
457
+ left: 12px;
458
+ right: 12px;
459
+ height: 6px;
460
+ background: #333;
461
+ transform: translateY(-50%);
462
+ border-radius: 3px;
463
+ }
464
+
465
+ .trim-selected {
466
+ position: absolute;
467
+ top: 50%;
468
+ height: 6px;
469
+ background: var(--primary);
470
+ transform: translateY(-50%);
471
+ border-radius: 3px;
472
+ pointer-events: none;
473
+ }
474
+
475
+ .trim-handle {
476
+ position: absolute;
477
+ top: 50%;
478
+ width: 16px;
479
+ height: 36px;
480
+ background: white;
481
+ border: 2px solid var(--primary);
482
+ border-radius: 4px;
483
+ transform: translate(-50%, -50%);
484
+ cursor: ew-resize;
485
+ z-index: 2;
486
+ display: flex;
487
+ align-items: center;
488
+ justify-content: center;
489
+ transition: background 0.15s ease, transform 0.1s ease;
490
+ }
491
+
492
+ .trim-handle:hover {
493
+ background: #e0e0e0;
494
+ }
495
+
496
+ .trim-handle:active {
497
+ background: var(--primary);
498
+ transform: translate(-50%, -50%) scale(1.05);
499
+ }
500
+
501
+ .trim-handle::before {
502
+ content: '';
503
+ width: 2px;
504
+ height: 16px;
505
+ background: #666;
506
+ border-radius: 1px;
507
+ }
508
+
509
+ .trim-handle:active::before {
510
+ background: white;
511
+ }
512
+
513
+ .trim-time-labels {
514
+ display: flex;
515
+ justify-content: space-between;
516
+ font-size: 0.65rem;
517
+ color: #666;
518
+ font-family: 'Consolas', 'Monaco', monospace;
519
+ padding: 0 12px;
520
+ }
521
+
522
+ .trim-actions {
523
+ display: flex;
524
+ gap: 0.5rem;
525
+ margin-top: 0.75rem;
526
+ }
527
+
528
+ .trim-action-btn {
529
+ flex: 1;
530
+ padding: 0.5rem 0.75rem;
531
+ background: var(--input);
532
+ border: 1px solid transparent;
533
+ border-radius: var(--radius-sm);
534
+ color: #999;
535
+ font-size: 0.75rem;
536
+ cursor: pointer;
537
+ transition: all 0.15s ease;
538
+ text-align: center;
539
+ }
540
+
541
+ .trim-action-btn:hover {
542
+ border-color: var(--primary);
543
+ color: #ccc;
544
+ }
545
+
546
+ .export-spinner {
547
+ display: inline-block;
548
+ width: 14px;
549
+ height: 14px;
550
+ border: 2px solid rgba(255, 255, 255, 0.3);
551
+ border-radius: 50%;
552
+ border-top-color: white;
553
+ animation: spin 0.8s linear infinite;
554
+ flex-shrink: 0;
555
+ }
556
+
557
+ @keyframes spin {
558
+ to { transform: rotate(360deg); }
559
+ }
560
+
561
+ `
562
+ ];
563
+
564
+ public render(): TemplateResult {
565
+ if (this.panelState === 'options') {
566
+ return this.renderOptionsPanel();
567
+ } else if (this.panelState === 'preview') {
568
+ return this.renderPreviewModal();
569
+ }
570
+ return html``;
571
+ }
572
+
573
+ private renderOptionsPanel(): TemplateResult {
574
+ return html`
575
+ <div class="recording-options-panel">
576
+ <div class="recording-options-header">
577
+ <span class="recording-options-title">Recording Settings</span>
578
+ <button class="recording-options-close" @click=${() => this.close()}>✕</button>
579
+ </div>
580
+ <div class="recording-options-content">
581
+ <div class="recording-option-group">
582
+ <div class="recording-option-label">Record Area</div>
583
+ <div class="recording-mode-buttons">
584
+ <button
585
+ class="recording-mode-btn ${this.recordingMode === 'viewport' ? 'selected' : ''}"
586
+ @click=${() => this.recordingMode = 'viewport'}
587
+ >
588
+ Viewport Only
589
+ </button>
590
+ <button
591
+ class="recording-mode-btn ${this.recordingMode === 'screen' ? 'selected' : ''}"
592
+ @click=${() => this.recordingMode = 'screen'}
593
+ >
594
+ Entire Screen
595
+ </button>
596
+ </div>
597
+ </div>
598
+
599
+ <div class="recording-option-group">
600
+ <div class="recording-option-label">Format</div>
601
+ <div class="recording-mode-buttons">
602
+ <button
603
+ class="recording-mode-btn ${this.outputFormat === 'mp4' ? 'selected' : ''}"
604
+ @click=${() => this.outputFormat = 'mp4'}
605
+ >
606
+ MP4 (H.264)
607
+ </button>
608
+ <button
609
+ class="recording-mode-btn ${this.outputFormat === 'webm' ? 'selected' : ''}"
610
+ @click=${() => this.outputFormat = 'webm'}
611
+ >
612
+ WebM (VP9)
613
+ </button>
614
+ </div>
615
+ </div>
616
+
617
+ <div class="recording-option-group">
618
+ <div class="recording-option-label">Audio</div>
619
+ <div class="audio-toggle">
620
+ <input
621
+ type="checkbox"
622
+ id="audioToggle"
623
+ ?checked=${this.audioEnabled}
624
+ @change=${(e: Event) => this.handleAudioToggle((e.target as HTMLInputElement).checked)}
625
+ />
626
+ <label for="audioToggle">Enable Microphone</label>
627
+ </div>
628
+
629
+ ${this.audioEnabled ? html`
630
+ <select
631
+ class="microphone-select"
632
+ .value=${this.selectedMicrophoneId}
633
+ @change=${(e: Event) => this.handleMicrophoneChange((e.target as HTMLSelectElement).value)}
634
+ >
635
+ <option value="">Select Microphone...</option>
636
+ ${this.availableMicrophones.map(mic => html`
637
+ <option value=${mic.deviceId}>${mic.label || `Microphone ${mic.deviceId.slice(0, 8)}`}</option>
638
+ `)}
639
+ </select>
640
+
641
+ ${this.selectedMicrophoneId ? html`
642
+ <div class="audio-level-container">
643
+ <div class="audio-level-label">Input Level</div>
644
+ <div class="audio-level-bar">
645
+ <div class="audio-level-fill" style="width: ${this.audioLevel}%"></div>
646
+ </div>
647
+ </div>
648
+ ` : null}
649
+ ` : null}
650
+ </div>
651
+
652
+ <button class="start-recording-btn" @click=${() => this.startRecording()}>
653
+ <div class="rec-dot"></div>
654
+ Start Recording
655
+ </button>
656
+ </div>
657
+ </div>
658
+ `;
659
+ }
660
+
661
+ private renderPreviewModal(): TemplateResult {
662
+ return html`
663
+ <div class="preview-modal-overlay" @click=${(e: Event) => {
664
+ if ((e.target as HTMLElement).classList.contains('preview-modal-overlay')) {
665
+ this.discardRecording();
666
+ }
667
+ }}>
668
+ <div class="preview-modal">
669
+ <div class="preview-modal-header">
670
+ <span class="preview-modal-title">Recording Preview</span>
671
+ <button class="preview-modal-close" @click=${() => this.discardRecording()}>✕</button>
672
+ </div>
673
+ <div class="preview-modal-content">
674
+ <div class="preview-video-container">
675
+ <video
676
+ class="preview-video"
677
+ src=${this.previewVideoUrl}
678
+ controls
679
+ @loadedmetadata=${(e: Event) => this.handleVideoLoaded(e.target as HTMLVideoElement)}
680
+ ></video>
681
+ </div>
682
+
683
+ <!-- Trim Section -->
684
+ <div class="trim-section">
685
+ <div class="trim-section-header">
686
+ <span class="trim-section-title">Trim Video</span>
687
+ <span class="trim-duration-info">
688
+ ${this.formatDuration(Math.floor(this.trimEnd - this.trimStart))}
689
+ ${this.trimStart > 0 || this.trimEnd < this.videoDuration
690
+ ? `(trimmed from ${this.formatDuration(Math.floor(this.videoDuration))})`
691
+ : ''}
692
+ </span>
693
+ </div>
694
+
695
+ <div
696
+ class="trim-timeline"
697
+ @mousedown=${(e: MouseEvent) => this.handleTimelineClick(e)}
698
+ @mousemove=${(e: MouseEvent) => this.handleTimelineDrag(e)}
699
+ @mouseup=${() => this.handleTimelineDragEnd()}
700
+ @mouseleave=${() => this.handleTimelineDragEnd()}
701
+ >
702
+ <div class="trim-track"></div>
703
+ <div
704
+ class="trim-selected"
705
+ style="left: ${this.getHandlePositionStyle(this.trimStart)}; right: ${this.getHandlePositionFromEndStyle(this.trimEnd)};"
706
+ ></div>
707
+ <div
708
+ class="trim-handle start-handle"
709
+ style="left: ${this.getHandlePositionStyle(this.trimStart)};"
710
+ @mousedown=${(e: MouseEvent) => { e.stopPropagation(); this.isDraggingTrim = 'start'; }}
711
+ ></div>
712
+ <div
713
+ class="trim-handle end-handle"
714
+ style="left: ${this.getHandlePositionStyle(this.trimEnd)};"
715
+ @mousedown=${(e: MouseEvent) => { e.stopPropagation(); this.isDraggingTrim = 'end'; }}
716
+ ></div>
717
+ </div>
718
+
719
+ <div class="trim-time-labels">
720
+ <span>${this.formatDuration(Math.floor(this.trimStart))}</span>
721
+ <span>${this.formatDuration(Math.floor(this.trimEnd))}</span>
722
+ </div>
723
+
724
+ <div class="trim-actions">
725
+ <button class="trim-action-btn" @click=${() => this.resetTrim()}>
726
+ Reset Trim
727
+ </button>
728
+ <button class="trim-action-btn" @click=${() => this.previewTrimmedSection()}>
729
+ Preview Selection
730
+ </button>
731
+ </div>
732
+ </div>
733
+
734
+ </div>
735
+ <div class="preview-modal-actions">
736
+ <button class="preview-btn secondary" @click=${() => this.discardRecording()}>Discard</button>
737
+ <button
738
+ class="preview-btn primary"
739
+ ?disabled=${this.isExporting}
740
+ @click=${() => this.downloadRecording()}
741
+ >
742
+ ${this.isExporting
743
+ ? html`<span class="export-spinner"></span>${this.outputFormat === 'mp4' ? 'Converting to MP4...' : 'Exporting...'}`
744
+ : `Download ${this.outputFormat === 'mp4' ? 'MP4' : 'WebM'}`}
745
+ </button>
746
+ </div>
747
+ </div>
748
+ </div>
749
+ `;
750
+ }
751
+
752
+ // ==================== Audio Methods ====================
753
+
754
+ private async handleAudioToggle(enabled: boolean): Promise<void> {
755
+ this.audioEnabled = enabled;
756
+ if (enabled) {
757
+ this.availableMicrophones = await this.recorderService.loadMicrophones(true);
758
+ if (this.availableMicrophones.length > 0 && !this.selectedMicrophoneId) {
759
+ this.selectedMicrophoneId = this.availableMicrophones[0].deviceId;
760
+ await this.recorderService.startAudioMonitoring(this.selectedMicrophoneId);
761
+ }
762
+ } else {
763
+ this.recorderService.stopAudioMonitoring();
764
+ this.selectedMicrophoneId = '';
765
+ this.audioLevel = 0;
766
+ }
767
+ }
768
+
769
+ private async handleMicrophoneChange(deviceId: string): Promise<void> {
770
+ this.selectedMicrophoneId = deviceId;
771
+ if (deviceId) {
772
+ await this.recorderService.startAudioMonitoring(deviceId);
773
+ } else {
774
+ this.recorderService.stopAudioMonitoring();
775
+ this.audioLevel = 0;
776
+ }
777
+ }
778
+
779
+ // ==================== Recording Methods ====================
780
+
781
+ private async startRecording(): Promise<void> {
782
+ try {
783
+ const viewportElement = this.recordingMode === 'viewport' ? this.captureTarget ?? undefined : undefined;
784
+
785
+ await this.recorderService.startRecording({
786
+ mode: this.recordingMode,
787
+ audioDeviceId: this.audioEnabled ? this.selectedMicrophoneId : undefined,
788
+ viewportElement,
789
+ });
790
+
791
+ this.panelState = 'recording';
792
+ this.dispatchEvent(new CustomEvent('recording-start', {
793
+ bubbles: true,
794
+ composed: true
795
+ }));
796
+ } catch (error) {
797
+ console.error('Failed to start recording:', error);
798
+ this.panelState = 'options';
799
+ }
800
+ }
801
+
802
+ public stopRecording(): void {
803
+ this.recorderService.stopRecording();
804
+ }
805
+
806
+ private handleRecordingComplete(blob: Blob): void {
807
+ if (this.previewVideoUrl) {
808
+ URL.revokeObjectURL(this.previewVideoUrl);
809
+ }
810
+ this.previewVideoUrl = URL.createObjectURL(blob);
811
+ this.panelState = 'preview';
812
+ this.dispatchEvent(new CustomEvent('recording-stop', {
813
+ bubbles: true,
814
+ composed: true
815
+ }));
816
+ }
817
+
818
+ private discardRecording(): void {
819
+ if (this.previewVideoUrl) {
820
+ URL.revokeObjectURL(this.previewVideoUrl);
821
+ this.previewVideoUrl = '';
822
+ }
823
+ this.recorderService.reset();
824
+ this.trimStart = 0;
825
+ this.trimEnd = 0;
826
+ this.videoDuration = 0;
827
+ this.isExporting = false;
828
+ this.recordingDuration = 0;
829
+ this.close();
830
+ }
831
+
832
+ private async downloadRecording(): Promise<void> {
833
+ const recordedBlob = this.recorderService.recordedBlob;
834
+ if (!recordedBlob) return;
835
+
836
+ this.isExporting = true;
837
+
838
+ try {
839
+ let blobToDownload: Blob;
840
+
841
+ // Handle trimming if needed — always produces WebM
842
+ const needsTrim = this.trimStart > 0.1 || this.trimEnd < this.videoDuration - 0.1;
843
+
844
+ if (needsTrim) {
845
+ const video = this.shadowRoot?.querySelector('.preview-video') as HTMLVideoElement;
846
+ if (video) {
847
+ blobToDownload = await this.recorderService.exportTrimmedVideo(video, this.trimStart, this.trimEnd);
848
+ } else {
849
+ blobToDownload = recordedBlob;
850
+ }
851
+ } else {
852
+ blobToDownload = recordedBlob;
853
+ }
854
+
855
+ // Convert WebM → MP4 if MP4 format selected
856
+ if (this.outputFormat === 'mp4') {
857
+ blobToDownload = await this.recorderService.convertToMp4(blobToDownload);
858
+ }
859
+
860
+ // Trigger download
861
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
862
+ const ext = this.outputFormat === 'mp4' ? 'mp4' : 'webm';
863
+ const filename = `wcctools-recording-${timestamp}.${ext}`;
864
+
865
+ const url = URL.createObjectURL(blobToDownload);
866
+ const a = document.createElement('a');
867
+ a.href = url;
868
+ a.download = filename;
869
+ document.body.appendChild(a);
870
+ a.click();
871
+ document.body.removeChild(a);
872
+ URL.revokeObjectURL(url);
873
+
874
+ this.discardRecording();
875
+ } catch (error) {
876
+ console.error('Error exporting video:', error);
877
+ this.isExporting = false;
878
+ }
879
+ }
880
+
881
+ // ==================== Trim Methods ====================
882
+
883
+ private handleVideoLoaded(video: HTMLVideoElement): void {
884
+ // WebM files from MediaRecorder may have Infinity/NaN duration
885
+ // Fall back to the tracked recording duration
886
+ const duration = Number.isFinite(video.duration) ? video.duration : this.recordingDuration;
887
+ this.videoDuration = duration;
888
+ this.trimStart = 0;
889
+ this.trimEnd = duration;
890
+ }
891
+
892
+ private formatDuration(seconds: number): string {
893
+ const mins = Math.floor(seconds / 60);
894
+ const secs = seconds % 60;
895
+ return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
896
+ }
897
+
898
+ private getHandlePositionStyle(time: number): string {
899
+ if (this.videoDuration === 0) return '12px';
900
+ const percentage = time / this.videoDuration;
901
+ // Formula: 12px padding + percentage of remaining width (total - 24px padding)
902
+ // At 0%: 12px (left edge of track)
903
+ // At 100%: calc(100% - 12px) (right edge of track)
904
+ return `calc(12px + ${(percentage * 100).toFixed(2)}% - ${(percentage * 24).toFixed(2)}px)`;
905
+ }
906
+
907
+ private getHandlePositionFromEndStyle(time: number): string {
908
+ if (this.videoDuration === 0) return '12px';
909
+ const percentage = time / this.videoDuration;
910
+ const remainingPercentage = 1 - percentage;
911
+ // For CSS 'right' property: distance from right edge
912
+ // At trimEnd = 100%: right = 12px (at right edge of track)
913
+ // At trimEnd = 0%: right = calc(100% - 12px) (at left edge of track)
914
+ return `calc(12px + ${(remainingPercentage * 100).toFixed(2)}% - ${(remainingPercentage * 24).toFixed(2)}px)`;
915
+ }
916
+
917
+ private handleTimelineClick(e: MouseEvent): void {
918
+ if (this.isDraggingTrim) return;
919
+
920
+ const timeline = e.currentTarget as HTMLElement;
921
+ const rect = timeline.getBoundingClientRect();
922
+ const x = e.clientX - rect.left;
923
+ const percentage = Math.max(0, Math.min(1, (x - 12) / (rect.width - 24)));
924
+ const time = percentage * this.videoDuration;
925
+
926
+ const video = this.shadowRoot?.querySelector('.preview-video') as HTMLVideoElement;
927
+ if (video) {
928
+ video.currentTime = time;
929
+ }
930
+ }
931
+
932
+ private handleTimelineDrag(e: MouseEvent): void {
933
+ if (!this.isDraggingTrim) return;
934
+
935
+ const timeline = e.currentTarget as HTMLElement;
936
+ const rect = timeline.getBoundingClientRect();
937
+ const x = e.clientX - rect.left;
938
+ const percentage = Math.max(0, Math.min(1, (x - 12) / (rect.width - 24)));
939
+ const time = percentage * this.videoDuration;
940
+
941
+ const minDuration = 1;
942
+
943
+ if (this.isDraggingTrim === 'start') {
944
+ this.trimStart = Math.min(time, this.trimEnd - minDuration);
945
+ this.trimStart = Math.max(0, this.trimStart);
946
+ } else if (this.isDraggingTrim === 'end') {
947
+ this.trimEnd = Math.max(time, this.trimStart + minDuration);
948
+ this.trimEnd = Math.min(this.videoDuration, this.trimEnd);
949
+ }
950
+
951
+ const video = this.shadowRoot?.querySelector('.preview-video') as HTMLVideoElement;
952
+ if (video) {
953
+ video.currentTime = this.isDraggingTrim === 'start' ? this.trimStart : this.trimEnd;
954
+ }
955
+ }
956
+
957
+ private handleTimelineDragEnd(): void {
958
+ this.isDraggingTrim = null;
959
+ }
960
+
961
+ private resetTrim(): void {
962
+ this.trimStart = 0;
963
+ this.trimEnd = this.videoDuration;
964
+
965
+ const video = this.shadowRoot?.querySelector('.preview-video') as HTMLVideoElement;
966
+ if (video) {
967
+ video.currentTime = 0;
968
+ }
969
+ }
970
+
971
+ private previewTrimmedSection(): void {
972
+ const video = this.shadowRoot?.querySelector('.preview-video') as HTMLVideoElement;
973
+ if (!video) return;
974
+
975
+ video.currentTime = this.trimStart;
976
+ video.play();
977
+
978
+ const checkTime = () => {
979
+ if (video.currentTime >= this.trimEnd) {
980
+ video.pause();
981
+ video.removeEventListener('timeupdate', checkTime);
982
+ }
983
+ };
984
+
985
+ video.addEventListener('timeupdate', checkTime);
986
+ }
987
+
988
+ // ==================== Lifecycle ====================
989
+
990
+ private close(): void {
991
+ this.recorderService.stopAudioMonitoring();
992
+ this.dispatchEvent(new CustomEvent('close', {
993
+ bubbles: true,
994
+ composed: true
995
+ }));
996
+ }
997
+
998
+ async disconnectedCallback(): Promise<void> {
999
+ await super.disconnectedCallback();
1000
+ this.recorderService.dispose();
1001
+ if (this.previewVideoUrl) {
1002
+ URL.revokeObjectURL(this.previewVideoUrl);
1003
+ }
1004
+ }
1005
+ }