@getv.design/embed 0.1.1 → 0.1.3

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.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.1.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
- import{a as y}from"./chunks/chunk-BBJ6N4ZS.js";import"./chunks/chunk-Q6QQ2HGJ.js";var d=["view","edit","play"];async function l(a,i,e){let o=e?.mode;if(!d.includes(o))throw new TypeError(`mount: mode must be one of ${d.join(", ")}; got ${String(o)}.`);if(o==="edit"){let{edit:t}=await import("./edit.js");return t(a,i,e)}let{view:s}=await import("./view.js"),n=await s(a,i,e);if(o==="view")return n;let r;try{r=await n.play(e.page===void 0?{}:{page:e.page})}catch(t){throw n.destroy(),t}return{goTo:t=>r.goTo(t),destroy(){r.destroy(),n.destroy()}}}export{l as mount,y as version};
1
+ /*! @getv.design/embed v0.1.3. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ import{a as y}from"./chunks/chunk-ETXF3NVH.js";import"./chunks/chunk-FGXZYG3Y.js";var d=["view","edit","play"];async function l(a,i,e){let o=e?.mode;if(!d.includes(o))throw new TypeError(`mount: mode must be one of ${d.join(", ")}; got ${String(o)}.`);if(o==="edit"){let{edit:t}=await import("./edit.js");return t(a,i,e)}let{view:s}=await import("./view.js"),n=await s(a,i,e);if(o==="view")return n;let r;try{r=await n.play(e.page===void 0?{}:{page:e.page})}catch(t){throw n.destroy(),t}return{goTo:t=>r.goTo(t),destroy(){r.destroy(),n.destroy()}}}export{l as mount,y as version};
package/dist/static.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.1.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
- import{a as g,c as h,e as b,f as v,g as f}from"./chunks/chunk-2H24PH2F.js";import{a as P,b as l}from"./chunks/chunk-BBJ6N4ZS.js";import{j as d,x as m}from"./chunks/chunk-QFL2QGB3.js";import"./chunks/chunk-Q6QQ2HGJ.js";function A(e){return g(e)}async function F(e,t={}){let o=t.fonts??"approximate";if(!S.includes(o))throw new TypeError(`renderSvg: fonts must be one of ${S.join(", ")}; got ${String(o)}.`);let n=o==="exact"?v(t.fontBase,w()):void 0,{document:c,blocks:x,problems:y}=await h(e),u=t.page===void 0?c:O(c,t.page),p=s=>{let r=x.get(s.hash);return r===void 0?void 0:d(s.type,r)},i=[...y],a;if(o==="exact")if(n===void 0)i.push(f([],"no fontBase was given and this build has no default"));else{let{exactSvg:s}=await import("./chunks/fonts.js"),r=await s(u,{base:n,resolveAsset:p});"svg"in r?a=r.svg:i.push(f(r.failures))}return a??=m(u,{ids:!1,resolveAsset:p}),t.onProblems?.(i),a}var S=["approximate","exact"];function w(){let e=import.meta.url,o=typeof globalThis.process?.getBuiltinModule=="function";return e.startsWith("file:")&&o?new URL("../fonts/",e).href:l}function O(e,t){let o=b(e,t);return{...e,root:{...e.root,children:e.root.children.map(n=>n===o?n:{...n,hidden:!0})}}}export{A as parse,F as renderSvg,P as version};
1
+ /*! @getv.design/embed v0.1.3. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ import{a as g,c as h,e as b,f as v,g as f}from"./chunks/chunk-3XUNDFDN.js";import{a as P,b as l}from"./chunks/chunk-ETXF3NVH.js";import{j as d,x as m}from"./chunks/chunk-KODHLOJV.js";import"./chunks/chunk-FGXZYG3Y.js";function A(e){return g(e)}async function F(e,t={}){let o=t.fonts??"approximate";if(!S.includes(o))throw new TypeError(`renderSvg: fonts must be one of ${S.join(", ")}; got ${String(o)}.`);let n=o==="exact"?v(t.fontBase,w()):void 0,{document:c,blocks:x,problems:y}=await h(e),u=t.page===void 0?c:O(c,t.page),p=s=>{let r=x.get(s.hash);return r===void 0?void 0:d(s.type,r)},i=[...y],a;if(o==="exact")if(n===void 0)i.push(f([],"no fontBase was given and this build has no default"));else{let{exactSvg:s}=await import("./chunks/fonts.js"),r=await s(u,{base:n,resolveAsset:p});"svg"in r?a=r.svg:i.push(f(r.failures))}return a??=m(u,{ids:!1,resolveAsset:p}),t.onProblems?.(i),a}var S=["approximate","exact"];function w(){let e=import.meta.url,o=typeof globalThis.process?.getBuiltinModule=="function";return e.startsWith("file:")&&o?new URL("../fonts/",e).href:l}function O(e,t){let o=b(e,t);return{...e,root:{...e.root,children:e.root.children.map(n=>n===o?n:{...n,hidden:!0})}}}export{A as parse,F as renderSvg,P as version};
package/dist/view.js CHANGED
@@ -1,5 +1,5 @@
1
- /*! @getv.design/embed v0.1.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
- import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-2H24PH2F.js";import{a as Ft,b as Re}from"./chunks/chunk-BBJ6N4ZS.js";import{a as Ve,b as $e,c as ge,d as Se,e as He,f as Be,g as je,h as Ue,j as We,k as Ke,m as Ee,n as me,o as Ge,p as ke,s as Ye,t as Ze,u as qe,v as Xe,w as Je}from"./chunks/chunk-QFL2QGB3.js";import"./chunks/chunk-Q6QQ2HGJ.js";var It=.8,Nt=.2;function Oe(e,t){let i=e.createElement("canvas").getContext("2d"),n=Ge(),l=new Map,c=new Map,m=new Set;function u(f){return`${f.italic?"italic ":""}${f.weight} ${f.size}px ${f.family}`}function y(){l.clear(),c.clear()}return{advance(f,p){if(!i)return n.advance(f,p);let A=u(p),S=`${A}\0${p.letterSpacing}\0${f}`,E=l.get(S);if(E!==void 0)return E;i.font=A;let x=i.measureText(f).width+p.letterSpacing*[...f].length;return l.set(S,x),x},metrics(f){if(!i)return n.metrics(f);let p=u(f),A=c.get(p);if(A)return A;i.font=p;let S=i.measureText("Hxg"),E=S.fontBoundingBoxAscent??f.size*It,x=S.fontBoundingBoxDescent??f.size*Nt,C={ascent:E,descent:x,lineGap:0};return c.set(p,C),C},load(f,p){let A=e.fonts;if(!A||typeof FontFace!="function")return!1;let S=!1;for(let E of Object.values(f.fonts))for(let x of zt(E)){let C=`${E.family}\0${x.src}\0${x.weight??400}\0${x.style??"normal"}`;if(m.has(C))continue;m.add(C);let O=x.src.startsWith("data:")?void 0:p?.(x.src),_={weight:String(x.weight??400),style:x.style??"normal"},N=$=>{let P=new FontFace(E.family,typeof $=="string"?`url(${$})`:Rt($),_);A.add(P),P.load().then(()=>{y(),t?.()},()=>{A.delete(P)})};O===void 0?N(x.src):(S=!0,O.then(N,()=>{}))}return S},invalidate:y,destroy(){y(),m.clear()}}}function zt(e){return e.faces??[]}function Rt(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var we={x:0,y:0,zoom:1},tt=.02,nt=64;function Me(e){return Number.isFinite(e)?Math.min(Math.max(e,tt),nt):1}function ve(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function Te(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function xe(e,t,r){let i=Me(e.zoom*r),n=ve(e,t);return{zoom:i,x:t.x-n.x*i,y:t.y-n.y*i}}function fe(e,t,r){return{...e,x:e.x+t,y:e.y+r}}function _e(e){return`translate(${e.x} ${e.y}) scale(${e.zoom})`}function oe(e,t,r){let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)};if(e.width<=0||e.height<=0)return we;let n=Me(Math.min(i.width/e.width,i.height/e.height));return{zoom:n,x:(t.width-e.width*n)/2-(e.x??0)*n,y:(t.height-e.height*n)/2-(e.y??0)*n}}var j="http://www.w3.org/2000/svg",rt="vd-viewer-styles",it=`
1
+ /*! @getv.design/embed v0.1.3. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-3XUNDFDN.js";import{a as Ft,b as Re}from"./chunks/chunk-ETXF3NVH.js";import{a as Ve,b as $e,c as ge,d as Se,e as He,f as Be,g as je,h as Ue,j as We,k as Ke,m as Ee,n as me,o as Ge,p as ke,s as Ye,t as Ze,u as qe,v as Xe,w as Je}from"./chunks/chunk-KODHLOJV.js";import"./chunks/chunk-FGXZYG3Y.js";var It=.8,Nt=.2;function Oe(e,t){let i=e.createElement("canvas").getContext("2d"),n=Ge(),l=new Map,c=new Map,m=new Set;function u(f){return`${f.italic?"italic ":""}${f.weight} ${f.size}px ${f.family}`}function y(){l.clear(),c.clear()}return{advance(f,p){if(!i)return n.advance(f,p);let A=u(p),S=`${A}\0${p.letterSpacing}\0${f}`,E=l.get(S);if(E!==void 0)return E;i.font=A;let x=i.measureText(f).width+p.letterSpacing*[...f].length;return l.set(S,x),x},metrics(f){if(!i)return n.metrics(f);let p=u(f),A=c.get(p);if(A)return A;i.font=p;let S=i.measureText("Hxg"),E=S.fontBoundingBoxAscent??f.size*It,x=S.fontBoundingBoxDescent??f.size*Nt,C={ascent:E,descent:x,lineGap:0};return c.set(p,C),C},load(f,p){let A=e.fonts;if(!A||typeof FontFace!="function")return!1;let S=!1;for(let E of Object.values(f.fonts))for(let x of zt(E)){let C=`${E.family}\0${x.src}\0${x.weight??400}\0${x.style??"normal"}`;if(m.has(C))continue;m.add(C);let O=x.src.startsWith("data:")?void 0:p?.(x.src),_={weight:String(x.weight??400),style:x.style??"normal"},N=$=>{let P=new FontFace(E.family,typeof $=="string"?`url(${$})`:Rt($),_);A.add(P),P.load().then(()=>{y(),t?.()},()=>{A.delete(P)})};O===void 0?N(x.src):(S=!0,O.then(N,()=>{}))}return S},invalidate:y,destroy(){y(),m.clear()}}}function zt(e){return e.faces??[]}function Rt(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var we={x:0,y:0,zoom:1},tt=.02,nt=64;function Me(e){return Number.isFinite(e)?Math.min(Math.max(e,tt),nt):1}function ve(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function Te(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function xe(e,t,r){let i=Me(e.zoom*r),n=ve(e,t);return{zoom:i,x:t.x-n.x*i,y:t.y-n.y*i}}function fe(e,t,r){return{...e,x:e.x+t,y:e.y+r}}function _e(e){return`translate(${e.x} ${e.y}) scale(${e.zoom})`}function oe(e,t,r){let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)};if(e.width<=0||e.height<=0)return we;let n=Me(Math.min(i.width/e.width,i.height/e.height));return{zoom:n,x:(t.width-e.width*n)/2-(e.x??0)*n,y:(t.height-e.height*n)/2-(e.y??0)*n}}var j="http://www.w3.org/2000/svg",rt="vd-viewer-styles",it=`
3
3
  .vd-viewer {
4
4
  position: relative;
5
5
  overflow: hidden;
package/edit.css CHANGED
@@ -617,6 +617,256 @@
617
617
  }
618
618
  }
619
619
 
620
+ /* --- thumbnail strip ------------------------------------------------------ */
621
+
622
+ /*
623
+ * One row under the canvas (strip.ts). The height is STRIP_HEIGHT in
624
+ * strip-model.ts — 12 above, a 64 tile, 6, a 14 caption, 8 below — and the
625
+ * host shifts the camera by half of it, so change both or neither.
626
+ */
627
+ .vd-strip {
628
+ box-sizing: border-box;
629
+ /* The drop line and the context menu are placed against it. */
630
+ position: relative;
631
+ display: flex;
632
+ flex: 0 0 104px;
633
+ height: 104px;
634
+ min-width: 0;
635
+ border-top: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
636
+ background: var(--vd-strip-bg, #ffffff);
637
+ color: var(--vd-ink, #1a1a1f);
638
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
639
+ }
640
+
641
+ .vd-strip__list {
642
+ display: flex;
643
+ align-items: flex-start;
644
+ gap: 12px;
645
+ flex: 1 1 auto;
646
+ min-width: 0;
647
+ padding: 11px 16px 0;
648
+ overflow-x: auto;
649
+ overflow-y: hidden;
650
+ outline: none;
651
+ scrollbar-width: thin;
652
+ /* A tile scrolled into view lands clear of the edge, outline and all. */
653
+ scroll-padding-inline: 16px;
654
+ }
655
+
656
+ .vd-strip__list[hidden],
657
+ .vd-strip__blank[hidden],
658
+ .vd-strip__drop[hidden] {
659
+ display: none;
660
+ }
661
+
662
+ /* No frames: what the strip is for, and the way to start one. */
663
+ .vd-strip__blank {
664
+ display: flex;
665
+ flex: 1 1 auto;
666
+ align-items: center;
667
+ justify-content: center;
668
+ gap: 12px;
669
+ min-width: 0;
670
+ padding: 0 16px;
671
+ }
672
+
673
+ .vd-strip__empty {
674
+ min-width: 0;
675
+ margin: 0;
676
+ font-size: 12px;
677
+ line-height: 1.5;
678
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
679
+ }
680
+
681
+ .vd-strip__add {
682
+ flex: 0 0 auto;
683
+ height: 28px;
684
+ padding: 0 12px;
685
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
686
+ border-radius: 6px;
687
+ background: none;
688
+ color: var(--vd-ink, #1a1a1f);
689
+ font: inherit;
690
+ font-size: 12px;
691
+ cursor: default;
692
+ }
693
+
694
+ .vd-strip__add:hover {
695
+ background: var(--vd-row-hover, rgb(0 0 0 / 0.06));
696
+ }
697
+
698
+ .vd-strip__add:focus-visible {
699
+ outline: 2px solid var(--vd-focus, var(--vd-accent, #3b82f6));
700
+ outline-offset: 2px;
701
+ }
702
+
703
+ /* Where a dragged tile lands: a line in the gap, the tile's height, level
704
+ with the pictures (the list's 11 px top padding). */
705
+ .vd-strip__drop {
706
+ position: absolute;
707
+ top: 11px;
708
+ width: 2px;
709
+ height: 64px;
710
+ border-radius: 1px;
711
+ background: var(--vd-chosen, var(--vd-accent, #3b82f6));
712
+ pointer-events: none;
713
+ }
714
+
715
+ /* The tiles being dragged stay in place, faded, until the drop moves them. */
716
+ .vd-strip__tile[data-dragging='true'] {
717
+ opacity: 0.35;
718
+ }
719
+
720
+ .vd-strip--dragging,
721
+ .vd-strip--dragging * {
722
+ cursor: grabbing;
723
+ }
724
+
725
+ /* The picture under the pointer while dragging, with a count for several. */
726
+ .vd-strip__ghost {
727
+ position: fixed;
728
+ top: 0;
729
+ left: 0;
730
+ z-index: 10;
731
+ pointer-events: none;
732
+ opacity: 0.9;
733
+ }
734
+
735
+ .vd-strip__ghost .vd-strip__thumb {
736
+ outline: 2px solid var(--vd-chosen, var(--vd-accent, #3b82f6));
737
+ outline-offset: 1px;
738
+ }
739
+
740
+ .vd-strip__count {
741
+ position: absolute;
742
+ top: -8px;
743
+ right: -8px;
744
+ min-width: 18px;
745
+ height: 18px;
746
+ padding: 0 5px;
747
+ box-sizing: border-box;
748
+ border-radius: 9px;
749
+ background: var(--vd-chosen, var(--vd-accent, #3b82f6));
750
+ color: var(--vd-on-chosen, #ffffff);
751
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
752
+ font-size: 11px;
753
+ line-height: 18px;
754
+ text-align: center;
755
+ }
756
+
757
+ /* Read by a screen reader, never seen. */
758
+ .vd-strip__status {
759
+ position: absolute;
760
+ width: 1px;
761
+ height: 1px;
762
+ overflow: hidden;
763
+ clip-path: inset(50%);
764
+ white-space: nowrap;
765
+ }
766
+
767
+ /* The menu opens up over the canvas, so it sits above the canvas's chrome. */
768
+ .vd-strip > .vd-menu {
769
+ z-index: 10;
770
+ }
771
+
772
+ .vd-strip__tile {
773
+ display: flex;
774
+ flex: 0 0 auto;
775
+ flex-direction: column;
776
+ gap: 6px;
777
+ cursor: default;
778
+ user-select: none;
779
+ }
780
+
781
+ .vd-strip__well {
782
+ display: flex;
783
+ align-items: center;
784
+ /* Left, so a narrow picture lines up with its number under it. */
785
+ justify-content: flex-start;
786
+ height: 64px;
787
+ }
788
+
789
+ .vd-strip__thumb {
790
+ flex: 0 0 auto;
791
+ box-sizing: border-box;
792
+ overflow: hidden;
793
+ border-radius: 4px;
794
+ /* Its own variable, not the strip's rule: a dark slide on a dark strip
795
+ needs a stronger edge than a panel's hairline to be told apart. */
796
+ outline: 1px solid var(--vd-thumb-rule, var(--vd-rule, rgb(0 0 0 / 0.12)));
797
+ outline-offset: -1px;
798
+ background: var(--vd-thumb-bg, #f2f2f2);
799
+ }
800
+
801
+ .vd-strip__thumb svg {
802
+ display: block;
803
+ width: 100%;
804
+ height: 100%;
805
+ /* As on the canvas: text was measured against real faces, and drawn with
806
+ every space it was measured with. */
807
+ font-synthesis: none;
808
+ }
809
+
810
+ .vd-strip__thumb text {
811
+ white-space: pre;
812
+ }
813
+
814
+ .vd-strip__tile:hover .vd-strip__thumb {
815
+ outline-color: var(--vd-muted, rgb(0 0 0 / 0.55));
816
+ }
817
+
818
+ /* Current: Ink in light, lime in dark, as a chosen card is. */
819
+ .vd-strip__tile[aria-selected='true'] .vd-strip__thumb {
820
+ outline: 2px solid var(--vd-chosen, var(--vd-accent, #3b82f6));
821
+ outline-offset: 1px;
822
+ }
823
+
824
+ /* The keyboard's tile: a ring outside the current outline, so the two read
825
+ apart when they are on different tiles and stack when they are on one. */
826
+ .vd-strip__list:focus-visible .vd-strip__tile[data-active='true'] .vd-strip__thumb {
827
+ box-shadow:
828
+ 0 0 0 5px var(--vd-strip-bg, #ffffff),
829
+ 0 0 0 7px var(--vd-focus, var(--vd-accent, #3b82f6));
830
+ }
831
+
832
+ .vd-strip__tile[data-state='hidden'] .vd-strip__thumb {
833
+ opacity: 0.4;
834
+ }
835
+
836
+ .vd-strip__caption {
837
+ display: flex;
838
+ align-items: center;
839
+ height: 14px;
840
+ overflow: hidden;
841
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
842
+ font-size: 11px;
843
+ line-height: 14px;
844
+ white-space: nowrap;
845
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
846
+ }
847
+
848
+ .vd-strip__tile[aria-selected='true'] .vd-strip__caption {
849
+ color: var(--vd-ink, #1a1a1f);
850
+ }
851
+
852
+ .vd-strip__tag {
853
+ padding: 0 4px;
854
+ border: 1px solid currentColor;
855
+ border-radius: 4px;
856
+ font-size: 10px;
857
+ line-height: 12px;
858
+ }
859
+
860
+ .vd-strip__icon {
861
+ display: grid;
862
+ place-items: center;
863
+ }
864
+
865
+ .vd-strip__icon svg {
866
+ width: 12px;
867
+ height: 12px;
868
+ }
869
+
620
870
  /* --- inspector ------------------------------------------------------------ */
621
871
 
622
872
  .vd-inspector {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getv.design/embed",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Render, present and edit vDesign (.vd) documents in any web page. Free to use.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
@@ -1,2 +0,0 @@
1
- /*! @getv.design/embed v0.1.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
- var _="0.1.1",e="https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.1/fonts/";export{_ as a,e as b};