defuddle-cli 0.1.4 → 0.3.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 (36) hide show
  1. package/dist/dom/document.d.ts +3 -0
  2. package/dist/dom/document.js +49 -0
  3. package/dist/dom/elements.d.ts +2 -0
  4. package/dist/dom/elements.js +478 -0
  5. package/dist/dom/interfaces/elements/base.d.ts +14 -0
  6. package/dist/dom/interfaces/elements/base.js +46 -0
  7. package/dist/dom/interfaces/elements/form.d.ts +2 -0
  8. package/dist/dom/interfaces/elements/form.js +123 -0
  9. package/dist/dom/interfaces/elements/index.d.ts +2 -0
  10. package/dist/dom/interfaces/elements/index.js +22 -0
  11. package/dist/dom/interfaces/elements/interactive.d.ts +2 -0
  12. package/dist/dom/interfaces/elements/interactive.js +83 -0
  13. package/dist/dom/interfaces/elements/media.d.ts +2 -0
  14. package/dist/dom/interfaces/elements/media.js +43 -0
  15. package/dist/dom/interfaces/elements/table.d.ts +2 -0
  16. package/dist/dom/interfaces/elements/table.js +155 -0
  17. package/dist/dom/interfaces/elements/text.d.ts +2 -0
  18. package/dist/dom/interfaces/elements/text.js +57 -0
  19. package/dist/dom/interfaces/elements.d.ts +2 -0
  20. package/dist/dom/interfaces/elements.js +478 -0
  21. package/dist/dom/interfaces/range.d.ts +1 -1
  22. package/dist/dom/range.d.ts +2 -0
  23. package/dist/dom/range.js +87 -0
  24. package/dist/dom/setup/document.d.ts +3 -0
  25. package/dist/dom/setup/document.js +49 -0
  26. package/dist/dom/setup.d.ts +12 -9
  27. package/dist/dom/setup.js +148 -533
  28. package/dist/dom/types/setup.d.ts +10 -0
  29. package/dist/dom/types/setup.js +1 -0
  30. package/dist/index.js +10 -684
  31. package/package.json +3 -5
  32. package/src/index.ts +10 -772
  33. package/src/dom/interfaces/document.ts +0 -53
  34. package/src/dom/interfaces/range.ts +0 -120
  35. package/src/dom/interfaces/setup.ts +0 -196
  36. package/src/markdown.ts +0 -592
package/dist/dom/setup.js CHANGED
@@ -1,37 +1,28 @@
1
- import { JSDOM, VirtualConsole } from 'jsdom';
2
- import { setupDOMInterfaces } from './interfaces/setup.js';
3
- import { setupRange } from './interfaces/range.js';
4
- import { setupDocumentMethods, setupWindowMethods } from './interfaces/document.js';
5
- // Create a virtual console
6
- const virtualConsole = new VirtualConsole();
7
- // Create a virtual DOM
8
- const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', {
9
- virtualConsole,
10
- runScripts: 'dangerously',
11
- resources: 'usable',
12
- pretendToBeVisual: true,
13
- beforeParse(window) {
14
- setupDOMInterfaces(window);
15
- setupRange(window);
16
- setupDocumentMethods(window);
17
- setupWindowMethods(window);
1
+ import { setupDocumentMethods, setupWindowMethods } from './document.js';
2
+ // Setup basic window properties
3
+ export const setupBasicWindow = (window) => {
4
+ if (!window.innerWidth) {
5
+ Object.defineProperty(window, 'innerWidth', { value: 1024 });
18
6
  }
19
- });
20
- // Get the window object
21
- const window = dom.window;
22
- // Add window to global scope
23
- globalThis.window = window;
24
- // Add document to global scope
25
- globalThis.document = window.document;
26
- // Add required DOM interfaces to global scope
27
- globalThis.Element = window.Element;
28
- globalThis.Node = window.Node;
29
- globalThis.NodeFilter = window.NodeFilter;
30
- globalThis.Range = window.Range;
31
- globalThis.DOMParser = window.DOMParser;
32
- globalThis.XMLSerializer = window.XMLSerializer;
33
- globalThis.navigator = window.navigator;
34
- globalThis.HTMLElement = window.HTMLElement;
7
+ if (!window.innerHeight) {
8
+ Object.defineProperty(window, 'innerHeight', { value: 768 });
9
+ }
10
+ if (!window.devicePixelRatio) {
11
+ Object.defineProperty(window, 'devicePixelRatio', { value: 1 });
12
+ }
13
+ };
14
+ // Setup CSS interfaces
15
+ export const setupCSSInterfaces = (window) => {
16
+ if (!window.CSSRule) {
17
+ window.CSSRule = globalThis.CSSRule;
18
+ }
19
+ if (!window.CSSMediaRule) {
20
+ window.CSSMediaRule = globalThis.CSSMediaRule;
21
+ }
22
+ if (!window.CSSStyleSheet) {
23
+ window.CSSStyleSheet = globalThis.CSSStyleSheet;
24
+ }
25
+ };
35
26
  // Define CSS interfaces globally first
36
27
  globalThis.CSSRule = class {
37
28
  constructor(type) {
@@ -125,536 +116,160 @@ globalThis.CSSStyleSheet = class {
125
116
  }
126
117
  deleteRule(index) { }
127
118
  };
128
- // Define SVGElement globally
129
- globalThis.SVGElement = class {
130
- constructor() {
131
- this.id = '';
132
- this.className = '';
133
- this.style = {
134
- cssText: '',
135
- length: 0,
136
- parentRule: null,
137
- getPropertyPriority: () => '',
138
- getPropertyValue: () => '',
139
- item: () => '',
140
- removeProperty: () => '',
141
- setProperty: () => '',
142
- [Symbol.iterator]: function* () { yield ''; return undefined; }
143
- };
144
- this.ownerSVGElement = null;
145
- this.viewportElement = null;
146
- this.tagName = '';
147
- this.namespaceURI = null;
148
- this.prefix = null;
149
- this.localName = '';
150
- this.baseURI = '';
151
- this.textContent = '';
152
- this.innerHTML = '';
153
- this.outerHTML = '';
154
- this.hidden = false;
155
- this.slot = '';
156
- this.attributes = {
157
- length: 0,
158
- getNamedItem: () => null,
159
- getNamedItemNS: () => null,
160
- item: () => null,
161
- removeNamedItem: () => null,
162
- removeNamedItemNS: () => null,
163
- setNamedItem: () => null,
164
- setNamedItemNS: () => null,
165
- [Symbol.iterator]: function* () { yield null; return undefined; }
166
- };
167
- this.childNodes = {
168
- length: 0,
169
- item: () => null,
170
- forEach: () => { },
171
- entries: function* () { yield [0, null]; return undefined; },
172
- keys: function* () { yield 0; return undefined; },
173
- values: function* () { yield null; return undefined; },
174
- [Symbol.iterator]: function* () { yield null; return undefined; }
175
- };
176
- this.firstChild = null;
177
- this.lastChild = null;
178
- this.nextSibling = null;
179
- this.previousSibling = null;
180
- this.parentNode = null;
181
- this.parentElement = null;
182
- this.childElementCount = 0;
183
- this.firstElementChild = null;
184
- this.lastElementChild = null;
185
- this.nextElementSibling = null;
186
- this.previousElementSibling = null;
187
- this.children = {
188
- length: 0,
189
- item: () => null,
190
- namedItem: () => null,
191
- [Symbol.iterator]: function* () { yield null; return undefined; }
192
- };
193
- // Initialize any required properties
194
- }
195
- getAttribute(name) {
196
- return null;
197
- }
198
- getAttributeNS(namespaceURI, localName) {
199
- return null;
200
- }
201
- setAttribute(name, value) { }
202
- setAttributeNS(namespaceURI, qualifiedName, value) { }
203
- removeAttributeNS(namespaceURI, localName) { }
204
- hasAttribute(name) {
205
- return false;
206
- }
207
- hasAttributeNS(namespaceURI, localName) {
208
- return false;
209
- }
210
- getBoundingClientRect() {
211
- return {
212
- top: 0,
213
- left: 0,
214
- bottom: 0,
215
- right: 0,
216
- width: 0,
217
- height: 0,
218
- x: 0,
219
- y: 0,
220
- toJSON: function () { return this; }
221
- };
222
- }
223
- getClientRects() {
224
- return {
225
- length: 0,
226
- item: function () { return null; },
227
- [Symbol.iterator]: function* () { }
228
- };
229
- }
230
- getElementsByClassName(classNames) {
231
- return {
232
- length: 0,
233
- item: () => null,
234
- namedItem: () => null,
235
- [Symbol.iterator]: function* () { yield null; return undefined; }
236
- };
237
- }
238
- getElementsByTagName(qualifiedName) {
239
- return {
240
- length: 0,
241
- item: () => null,
242
- namedItem: () => null,
243
- [Symbol.iterator]: function* () { yield null; return undefined; }
244
- };
245
- }
246
- getElementsByTagNameNS(namespaceURI, localName) {
247
- return {
248
- length: 0,
249
- item: () => null,
250
- namedItem: () => null,
251
- [Symbol.iterator]: function* () { yield null; return undefined; }
252
- };
253
- }
254
- querySelector(selectors) {
255
- return null;
256
- }
257
- querySelectorAll(selectors) {
258
- return {
259
- length: 0,
260
- item: () => null,
261
- forEach: () => { },
262
- entries: function* () { yield [0, null]; return undefined; },
263
- keys: function* () { yield 0; return undefined; },
264
- values: function* () { yield null; return undefined; },
265
- [Symbol.iterator]: function* () { yield null; return undefined; }
266
- };
267
- }
268
- matches(selectors) {
269
- return false;
270
- }
271
- closest(selectors) {
272
- return null;
119
+ // Setup HTML and SVG interfaces
120
+ export const setupHTMLAndSVG = (window) => {
121
+ if (!window.HTMLImageElement) {
122
+ window.HTMLImageElement = globalThis.HTMLImageElement;
273
123
  }
274
- contains(other) {
275
- return false;
276
- }
277
- append(...nodes) { }
278
- prepend(...nodes) { }
279
- after(...nodes) { }
280
- before(...nodes) { }
281
- replaceWith(...nodes) { }
282
- remove() { }
283
- insertAdjacentElement(where, element) {
284
- return null;
285
- }
286
- insertAdjacentText(where, data) { }
287
- insertAdjacentHTML(position, text) { }
288
- replaceChildren(...nodes) { }
289
- };
290
- // Define HTMLImageElement globally
291
- globalThis.HTMLImageElement = class {
292
- constructor() {
293
- this.alt = '';
294
- this.src = '';
295
- this.srcset = '';
296
- this.sizes = '';
297
- this.crossOrigin = null;
298
- this.useMap = '';
299
- this.isMap = false;
300
- this.width = 0;
301
- this.height = 0;
302
- this.naturalWidth = 0;
303
- this.naturalHeight = 0;
304
- this.complete = false;
305
- this.name = '';
306
- this.lowsrc = '';
307
- this.align = '';
308
- this.hspace = 0;
309
- this.vspace = 0;
310
- this.longDesc = '';
311
- this.border = '';
312
- this.x = 0;
313
- this.y = 0;
314
- this.currentSrc = '';
315
- this.decoding = 'auto';
316
- this.fetchPriority = 'auto';
317
- this.loading = 'eager';
318
- this.referrerPolicy = '';
319
- // Initialize any required properties
124
+ if (!window.SVGElement) {
125
+ window.SVGElement = globalThis.SVGElement;
320
126
  }
321
- decode() {
322
- return Promise.resolve();
127
+ if (!window.HTMLAnchorElement) {
128
+ window.HTMLAnchorElement = globalThis.HTMLAnchorElement;
323
129
  }
324
130
  };
325
- // Define DOMSettableTokenList
326
- globalThis.DOMSettableTokenList = class {
327
- constructor() {
328
- this.length = 0;
329
- this.value = '';
330
- }
331
- add(token) { }
332
- contains(token) { return false; }
333
- item(index) { return null; }
334
- remove(token) { }
335
- replace(oldToken, newToken) { return false; }
336
- supports(token) { return false; }
337
- toggle(token, force) { return false; }
338
- [Symbol.iterator]() {
339
- return function* () { yield ''; return undefined; }();
131
+ // Setup screen object
132
+ export const setupScreen = (window) => {
133
+ if (!window.screen) {
134
+ Object.defineProperty(window, 'screen', {
135
+ value: {
136
+ width: 1024,
137
+ height: 768,
138
+ availWidth: 1024,
139
+ availHeight: 768,
140
+ colorDepth: 24,
141
+ pixelDepth: 24,
142
+ orientation: {
143
+ type: 'landscape-primary',
144
+ angle: 0
145
+ }
146
+ }
147
+ });
340
148
  }
341
149
  };
342
- // Define HTML element types
343
- globalThis.HTMLIFrameElement = class extends globalThis.HTMLElement {
344
- constructor() {
345
- super();
346
- this.align = '';
347
- this.allow = '';
348
- this.allowFullscreen = false;
349
- this.contentDocument = null;
350
- this.contentWindow = null;
351
- this.frameBorder = '';
352
- this.height = '';
353
- this.longDesc = '';
354
- this.marginHeight = '';
355
- this.marginWidth = '';
356
- this.name = '';
357
- this.referrerPolicy = '';
358
- this.sandbox = {
150
+ // Setup storage objects
151
+ export const setupStorage = (window) => {
152
+ const createStorage = () => {
153
+ const storage = {
359
154
  length: 0,
360
- value: '',
361
- add: () => { },
362
- contains: () => false,
363
- item: () => null,
364
- remove: () => { },
365
- replace: () => false,
366
- supports: () => false,
367
- toggle: () => false,
368
- [Symbol.iterator]: function* () { yield ''; return undefined; }
155
+ getItem: () => null,
156
+ setItem: () => { },
157
+ removeItem: () => { },
158
+ clear: () => { },
159
+ key: () => null
369
160
  };
370
- this.scrolling = '';
371
- this.src = '';
372
- this.srcdoc = '';
373
- this.width = '';
374
- }
375
- };
376
- globalThis.HTMLOListElement = class extends globalThis.HTMLElement {
377
- constructor() {
378
- super();
379
- this.type = '';
380
- this.compact = false;
381
- this.reversed = false;
382
- this.start = 0;
161
+ // Make the storage object non-extensible
162
+ Object.preventExtensions(storage);
163
+ return storage;
164
+ };
165
+ try {
166
+ // Create storage objects
167
+ const localStorage = createStorage();
168
+ const sessionStorage = createStorage();
169
+ // Define properties with more permissive attributes
170
+ Object.defineProperties(window, {
171
+ localStorage: {
172
+ value: localStorage,
173
+ writable: true,
174
+ configurable: true
175
+ },
176
+ sessionStorage: {
177
+ value: sessionStorage,
178
+ writable: true,
179
+ configurable: true
180
+ }
181
+ });
383
182
  }
384
- };
385
- globalThis.HTMLUListElement = class extends globalThis.HTMLElement {
386
- constructor() {
387
- super();
388
- this.type = '';
389
- this.compact = false;
183
+ catch (error) {
184
+ // Log the error but don't throw
185
+ console.warn('Warning: Could not set up storage objects:', error instanceof Error ? error.message : 'Unknown error');
390
186
  }
391
187
  };
392
- globalThis.HTMLTableElement = class extends globalThis.HTMLElement {
393
- constructor() {
394
- super();
395
- this.caption = null;
396
- this.tHead = null;
397
- this.tFoot = null;
398
- this.tBodies = {
399
- length: 0,
400
- item: () => null,
401
- namedItem: () => null,
402
- [Symbol.iterator]: function* () { yield null; return undefined; }
188
+ // Setup animation frame methods
189
+ export const setupAnimationFrame = (window) => {
190
+ if (!window.requestAnimationFrame) {
191
+ window.requestAnimationFrame = (callback) => {
192
+ return setTimeout(callback, 0);
403
193
  };
404
- this.rows = {
405
- length: 0,
406
- item: () => null,
407
- namedItem: () => null,
408
- [Symbol.iterator]: function* () { yield null; return undefined; }
409
- };
410
- this.align = '';
411
- this.bgColor = '';
412
- this.border = '';
413
- this.cellPadding = '';
414
- this.cellSpacing = '';
415
- this.frame = '';
416
- this.rules = '';
417
- this.summary = '';
418
- this.width = '';
419
- }
420
- createCaption() {
421
- return new globalThis.HTMLTableCaptionElement();
422
- }
423
- deleteCaption() { }
424
- createTHead() {
425
- return new globalThis.HTMLTableSectionElement();
426
194
  }
427
- deleteTHead() { }
428
- createTFoot() {
429
- return new globalThis.HTMLTableSectionElement();
430
- }
431
- deleteTFoot() { }
432
- createTBody() {
433
- return new globalThis.HTMLTableSectionElement();
434
- }
435
- insertRow(index) {
436
- return new globalThis.HTMLTableRowElement();
437
- }
438
- deleteRow(index) { }
439
- };
440
- globalThis.HTMLTableRowElement = class extends globalThis.HTMLElement {
441
- constructor() {
442
- super();
443
- this.rowIndex = 0;
444
- this.sectionRowIndex = 0;
445
- this.cells = {
446
- length: 0,
447
- item: () => null,
448
- namedItem: () => null,
449
- [Symbol.iterator]: function* () { yield null; return undefined; }
195
+ if (!window.cancelAnimationFrame) {
196
+ window.cancelAnimationFrame = (handle) => {
197
+ clearTimeout(handle);
450
198
  };
451
- this.align = '';
452
- this.bgColor = '';
453
- this.ch = '';
454
- this.chOff = '';
455
- this.vAlign = '';
456
- }
457
- insertCell(index) {
458
- return new globalThis.HTMLTableCellElement();
459
199
  }
460
- deleteCell(index) { }
461
200
  };
462
- globalThis.HTMLTableCellElement = class extends globalThis.HTMLElement {
463
- constructor() {
464
- super();
465
- this.colSpan = 1;
466
- this.rowSpan = 1;
467
- this.headers = {
468
- length: 0,
469
- value: '',
470
- add: () => { },
471
- contains: () => false,
472
- item: () => null,
473
- remove: () => { },
474
- replace: () => false,
475
- supports: () => false,
476
- toggle: () => false,
477
- [Symbol.iterator]: function* () { yield ''; return undefined; }
201
+ // Setup DOM methods
202
+ export const setupDOMMethods = (window) => {
203
+ if (!window.Document.prototype.getElementsByClassName) {
204
+ window.Document.prototype.getElementsByClassName = function (classNames) {
205
+ const elements = this.querySelectorAll('.' + classNames);
206
+ const collection = new HTMLCollection();
207
+ elements.forEach((el, i) => {
208
+ collection[i] = el;
209
+ });
210
+ return collection;
478
211
  };
479
- this.cellIndex = 0;
480
- this.scope = '';
481
- this.abbr = '';
482
- this.align = '';
483
- this.axis = '';
484
- this.bgColor = '';
485
- this.ch = '';
486
- this.chOff = '';
487
- this.height = '';
488
- this.noWrap = false;
489
- this.vAlign = '';
490
- this.width = '';
491
212
  }
492
213
  };
493
- globalThis.HTMLTableSectionElement = class extends globalThis.HTMLElement {
494
- constructor() {
495
- super();
496
- this.rows = {
497
- length: 0,
498
- item: () => null,
499
- namedItem: () => null,
500
- [Symbol.iterator]: function* () { yield null; return undefined; }
214
+ // Setup Node methods
215
+ export const setupNodeMethods = (window) => {
216
+ if (!window.Node.prototype.contains) {
217
+ window.Node.prototype.contains = function (node) {
218
+ let current = node;
219
+ while (current) {
220
+ if (current === this)
221
+ return true;
222
+ current = current.parentNode;
223
+ }
224
+ return false;
501
225
  };
502
- this.align = '';
503
- this.ch = '';
504
- this.chOff = '';
505
- this.vAlign = '';
506
- }
507
- insertRow(index) {
508
- return new globalThis.HTMLTableRowElement();
509
- }
510
- deleteRow(index) { }
511
- };
512
- globalThis.HTMLTableCaptionElement = class extends globalThis.HTMLElement {
513
- constructor() {
514
- super();
515
- this.align = '';
516
226
  }
517
227
  };
518
- globalThis.HTMLButtonElement = class extends globalThis.HTMLElement {
519
- constructor() {
520
- super();
521
- this.disabled = false;
522
- this.form = null;
523
- this.formAction = '';
524
- this.formEnctype = '';
525
- this.formMethod = '';
526
- this.formNoValidate = false;
527
- this.formTarget = '';
528
- this.name = '';
529
- this.type = 'submit';
530
- this.value = '';
531
- this.menu = null;
532
- }
533
- };
534
- // Add HTMLSpanElement interface
535
- globalThis.HTMLSpanElement = class extends globalThis.HTMLElement {
536
- constructor() {
537
- super();
538
- }
539
- };
540
- // Add HTMLDivElement interface
541
- globalThis.HTMLDivElement = class extends globalThis.HTMLElement {
542
- constructor() {
543
- super();
544
- this.align = '';
545
- }
546
- };
547
- globalThis.HTMLAnchorElement = class extends globalThis.HTMLElement {
548
- constructor() {
549
- super();
550
- this.href = '';
551
- this.target = '';
552
- this.download = '';
553
- this.ping = '';
554
- this.rel = '';
555
- this.relList = {
556
- length: 0,
557
- value: '',
558
- add: () => { },
559
- contains: () => false,
560
- item: () => null,
561
- remove: () => { },
562
- replace: () => false,
563
- supports: () => false,
564
- toggle: () => false,
565
- [Symbol.iterator]: function* () { yield ''; return undefined; }
228
+ // Setup Element methods
229
+ export const setupElementMethods = (window) => {
230
+ if (!window.Element.prototype.getBoundingClientRect) {
231
+ window.Element.prototype.getBoundingClientRect = function () {
232
+ return {
233
+ top: 0,
234
+ left: 0,
235
+ bottom: 0,
236
+ right: 0,
237
+ width: 0,
238
+ height: 0,
239
+ x: 0,
240
+ y: 0,
241
+ toJSON: function () { return this; }
242
+ };
566
243
  };
567
- this.hreflang = '';
568
- this.type = '';
569
- this.text = '';
570
- this.referrerPolicy = '';
571
- this.origin = '';
572
- this.protocol = '';
573
- this.username = '';
574
- this.password = '';
575
- this.host = '';
576
- this.hostname = '';
577
- this.port = '';
578
- this.pathname = '';
579
- this.search = '';
580
- this.hash = '';
581
244
  }
582
245
  };
583
- /**
584
- * Creates a virtual DOM instance with the given HTML content
585
- */
586
- export function createVirtualDOM(html, url) {
587
- const dom = new JSDOM(html, {
588
- virtualConsole,
589
- runScripts: 'dangerously',
590
- resources: 'usable',
591
- pretendToBeVisual: true,
592
- url,
593
- beforeParse(window) {
246
+ // Main setup function that orchestrates all the individual setups
247
+ export const setupDOMInterfaces = (window) => {
248
+ const setupFunctions = [
249
+ ['basic window', setupBasicWindow],
250
+ ['CSS interfaces', setupCSSInterfaces],
251
+ ['HTML and SVG interfaces', setupHTMLAndSVG],
252
+ ['screen object', setupScreen],
253
+ ['storage objects', setupStorage],
254
+ ['animation frame methods', setupAnimationFrame],
255
+ ['DOM methods', setupDOMMethods],
256
+ ['Node methods', setupNodeMethods],
257
+ ['Element methods', setupElementMethods],
258
+ ['Document methods', setupDocumentMethods],
259
+ ['Window methods', setupWindowMethods]
260
+ ];
261
+ try {
262
+ for (const [name, setup] of setupFunctions) {
594
263
  try {
595
- setupDOMInterfaces(window);
264
+ setup(window);
596
265
  }
597
266
  catch (error) {
598
- console.error('Error setting up DOM interfaces:', error);
267
+ console.warn(`Warning: Could not set up ${name}:`, error instanceof Error ? error.message : 'Unknown error');
599
268
  }
600
269
  }
601
- });
602
- return dom;
603
- }
604
- /**
605
- * Sets up additional document properties
606
- */
607
- export function setupDocumentProperties(doc) {
608
- // Ensure document has required properties
609
- if (!doc.documentElement) {
610
- throw new Error('Document has no root element');
611
- }
612
- // Set up document properties
613
- try {
614
- doc.documentElement.style.cssText = '';
615
- doc.documentElement.className = '';
616
270
  }
617
271
  catch (error) {
618
- console.warn('Warning: Could not set document element properties:', error);
619
- }
620
- // Ensure body exists and is properly set up
621
- if (!doc.body) {
622
- const body = doc.createElement('body');
623
- doc.documentElement.appendChild(body);
624
- }
625
- try {
626
- doc.body.style.cssText = '';
627
- doc.body.className = '';
272
+ console.error('Error in setupDOMInterfaces:', error instanceof Error ? error.message : 'Unknown error');
273
+ // Don't throw the error, just log it
628
274
  }
629
- catch (error) {
630
- console.warn('Warning: Could not set body properties:', error);
631
- }
632
- // Set up viewport and ensure head exists
633
- if (!doc.head) {
634
- const head = doc.createElement('head');
635
- doc.documentElement.insertBefore(head, doc.body);
636
- }
637
- // Add viewport meta tag
638
- try {
639
- const viewport = doc.createElement('meta');
640
- viewport.setAttribute('name', 'viewport');
641
- viewport.setAttribute('content', 'width=device-width, initial-scale=1');
642
- doc.head.appendChild(viewport);
643
- }
644
- catch (error) {
645
- console.warn('Warning: Could not add viewport meta tag:', error);
646
- }
647
- // Add a base style element for mobile styles
648
- try {
649
- const style = doc.createElement('style');
650
- style.textContent = `
651
- @media (max-width: 768px) {
652
- body { width: 100%; }
653
- }
654
- `;
655
- doc.head.appendChild(style);
656
- }
657
- catch (error) {
658
- console.warn('Warning: Could not add style element:', error);
659
- }
660
- }
275
+ };