arcane-os 0.47.0 → 0.49.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.
@@ -1,5 +1,13 @@
1
1
  import Is from 'strong-type';
2
- import {arcaneLightThemeTokens} from '../entities/Theme.js';
2
+
3
+ // Components import this module independently of their rendering. Await only
4
+ // the required print stylesheet here so every registered view is ready for the
5
+ // synchronous native beforeprint event, with no stylesheet fetch during print.
6
+ const printResponse=await fetch(new URL('../css/print.css',import.meta.url));
7
+ if(!printResponse.ok){
8
+ throw new Error(`Unable to load shared print styles: HTTP ${printResponse.status}.`);
9
+ }
10
+ const printStyles=await printResponse.text();
3
11
 
4
12
  const is=new Is(false);
5
13
  const registries=new WeakMap();
@@ -401,38 +409,13 @@ function capture(registry,session){
401
409
  const heading=document.createElement('h1');
402
410
  heading.textContent=session.title;
403
411
  const rendered=copyRendered(session.content,state,true);
404
- // Screen layout and fonts describe the rendered content; screen-theme paint
405
- // does not describe a readable paper surface. Keep this palette in the
406
- // snapshot, including its pseudo-elements, without recoloring SVG artwork.
407
- styles.textContent=`
408
- :host{color-scheme:light!important;color:${arcaneLightThemeTokens.text}!important;background:${arcaneLightThemeTokens.surface}!important;font:12pt/1.5 serif}
409
- :host>h1{margin:0 0 .75em;font-size:1.5em;line-height:1.2}
410
- [data-arcane-print-node]:not(svg,svg *,img,video,audio),
411
- [data-arcane-print-node]:not(svg,svg *,img,video,audio)::before,
412
- [data-arcane-print-node]:not(svg,svg *,img,video,audio)::after{
413
- color:${arcaneLightThemeTokens.text}!important;background-color:transparent!important;
414
- border-color:${arcaneLightThemeTokens.border}!important;color-scheme:light!important;
415
- -webkit-text-fill-color:currentColor!important;-webkit-text-stroke:0!important;
416
- text-decoration-color:currentColor!important;text-shadow:none!important;box-shadow:none!important
417
- }
418
- a[data-arcane-print-node]:not(svg *){text-decoration:underline!important}
419
- table[data-arcane-print-node]:not(svg *){border-collapse:collapse!important}
420
- th[data-arcane-print-node]:not(svg *),td[data-arcane-print-node]:not(svg *){border:1px solid ${arcaneLightThemeTokens.border}!important;padding:.35em .5em!important}
421
- ${state.rules.join('\n')}
422
- `;
412
+ // Only captured pseudo-element declarations are generated here. Authored
413
+ // print palette, page margins, and expansion rules share the CSS owner.
414
+ styles.textContent=printStyles+'\n'+state.rules.join('\n');
423
415
  root.append(styles,heading,rendered);
424
416
  const sheet=document.createElement('style');
425
417
  session.sheet=sheet;
426
- sheet.textContent=`
427
- [data-arcane-print-stage]{display:none!important}
428
- @media print{
429
- @page{margin:15mm}
430
- html:root,html:root>body{display:block!important;height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;contain:none!important;margin:0!important;padding:0!important;border:0!important;background:${arcaneLightThemeTokens.surface}!important;color:${arcaneLightThemeTokens.text}!important;color-scheme:light!important}
431
- html:root>body>*:not([data-arcane-print-stage]){display:none!important}
432
- html:root>body::before,html:root>body::after{display:none!important}
433
- html:root>body>[data-arcane-print-stage]{display:block!important;position:static!important;width:auto!important;height:auto!important;overflow:visible!important;margin:0!important;padding:0!important;border:0!important}
434
- }
435
- `;
418
+ sheet.textContent=printStyles;
436
419
  document.head.append(sheet);
437
420
  document.body.append(stage);
438
421
  session.originalTitle=document.title;
@@ -523,36 +506,17 @@ function copyRendered(source,state,root=false){
523
506
  clone.selected=source.selected;
524
507
  }
525
508
  if(!['img','svg','video','audio','input','canvas'].includes(name)){
526
- for(const [property,value] of [
527
- ['height','auto'],['min-height','0'],['max-height','none'],
528
- ['width','auto'],['min-width','0'],['max-width','100%'],['overflow','visible'],
529
- ['contain','none'],['content-visibility','visible'],['grid-template-rows','none'],
530
- ['break-inside','auto']
531
- ]){
532
- clone.style.setProperty(property,value);
533
- }
534
- }else if(name==='img'||name==='canvas'){
535
- clone.style.setProperty('max-width','100%');
536
- clone.style.setProperty('height','auto');
509
+ clone.setAttribute('data-arcane-print-expand','');
537
510
  }
538
511
  if(['absolute','fixed','sticky'].includes(appearance.position)){
539
- clone.style.setProperty('position','static');
512
+ clone.setAttribute('data-arcane-print-static','');
540
513
  }
541
514
  if(root||name==='iframe'){
542
515
  clone.hidden=false;
543
- clone.style.setProperty('display',appearance.display==='none'?'block':appearance.display);
544
- clone.style.setProperty('visibility','visible');
545
- }
546
- if(name==='pre'){
547
- clone.style.setProperty('white-space','pre-wrap');
548
- clone.style.setProperty('overflow-wrap','anywhere');
549
- }
550
- if(name==='table'){
551
- clone.style.setProperty('table-layout','auto');
552
- }
553
- if(name==='td'||name==='th'){
554
- clone.style.setProperty('overflow-wrap','anywhere');
555
- clone.style.setProperty('white-space','normal');
516
+ clone.setAttribute('data-arcane-print-root','');
517
+ if(appearance.display==='none'){
518
+ clone.setAttribute('data-arcane-print-block','');
519
+ }
556
520
  }
557
521
  if(name==='iframe'){
558
522
  const embedded=frameDocument(source);