@getv.design/embed 0.1.4 → 0.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.
- package/README.md +56 -17
- package/THIRD_PARTY_NOTICES.txt +1 -1
- package/dist/auto.d.ts +24 -0
- package/dist/auto.js +2 -0
- package/dist/chunks/chunk-62FKKJ5M.js +4 -0
- package/dist/chunks/{chunk-E3UBMQLG.js → chunk-BESL4IJP.js} +1 -1
- package/dist/chunks/chunk-DSFLLPRE.js +6 -0
- package/dist/chunks/chunk-OMODSFXU.js +10 -0
- package/dist/chunks/chunk-R6OULTHF.js +3 -0
- package/dist/chunks/chunk-T6H6KLK6.js +2 -0
- package/dist/chunks/fonts.js +4 -4
- package/dist/cli.js +29 -0
- package/dist/edit.js +33 -27
- package/dist/index.js +2 -2
- package/dist/markdown-it.d.ts +16 -0
- package/dist/markdown-it.js +2 -0
- package/dist/markdown.d.ts +19 -0
- package/dist/markdown.js +2 -0
- package/dist/marked.d.ts +14 -0
- package/dist/marked.js +2 -0
- package/dist/rehype.d.ts +19 -0
- package/dist/rehype.js +2 -0
- package/dist/static.d.ts +29 -2
- package/dist/static.js +2 -2
- package/dist/types.d.ts +127 -0
- package/dist/view.js +2 -2
- package/fonts.css +127 -0
- package/markdown.css +72 -0
- package/package.json +30 -2
- package/dist/chunks/chunk-5NSMF3ZC.js +0 -8
- package/dist/chunks/chunk-QFKGWML4.js +0 -2
- package/dist/chunks/chunk-WT7EGVYI.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{a as y}from"./chunks/chunk-
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as y}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.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};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MarkdownItOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, MarkdownItOptions, Problem, Renderer, } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
/**
|
|
5
|
+
* The slice of markdown-it this plugin touches, typed loosely on purpose: any
|
|
6
|
+
* markdown-it instance, whatever its version and whichever `@types` describe
|
|
7
|
+
* it, is accepted by `md.use(vdesignMarkdownIt)`.
|
|
8
|
+
*/
|
|
9
|
+
interface MarkdownItLike {
|
|
10
|
+
renderer: {
|
|
11
|
+
rules: object;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** `md.use(vdesignMarkdownIt, options)`. */
|
|
15
|
+
export declare function vdesignMarkdownIt(md: MarkdownItLike, options?: MarkdownItOptions): void;
|
|
16
|
+
export default vdesignMarkdownIt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as f,b as p,d as u}from"./chunks/chunk-62FKKJ5M.js";import{e as F}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function I(l,t={}){let o=l.renderer.rules,s=o.fence,i=new WeakMap;o.fence=(n,c,k,d,g)=>{let e=n[c];if(!e||!p(e.info))return s?s(n,c,k,d,g):"";let r=t.idPrefix;r||(r=i.get(n)??f(),i.set(n,r));let{resolveSrc:a,...w}=t;return u(e.content,e.info,{...w,idPrefix:r,...e.attrs?{attributes:e.attrs}:{},...a?{resolveSrc:m=>a(m,d)}:{}})}}var b=I;export{F as createRenderer,b as default,I as vdesignMarkdownIt};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FenceOptions, FenceRenderOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, Renderer } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
/** Ids for one page of HTML: each fence on it gets its own prefix. */
|
|
5
|
+
export declare function createFenceIds(prefix?: string): () => string;
|
|
6
|
+
/** The language a fence must name. `vdesign` is accepted too, for hosts that know `vd` as something else. */
|
|
7
|
+
export declare function isVdFence(info: string | undefined | null): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The attributes after the language: `key=value`, `key="quoted value"`, or a
|
|
10
|
+
* bare `key` for a flag. Unknown keys are ignored, so adding one later breaks
|
|
11
|
+
* no fence written today.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseInfo(info: string): FenceOptions;
|
|
14
|
+
/**
|
|
15
|
+
* A fence to HTML. `info` is the whole info string (`vd page=1`) or options
|
|
16
|
+
* already parsed. Never throws: a fence that cannot be drawn comes back as
|
|
17
|
+
* its code block, with what was wrong.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderFence(body: string, info: string | FenceOptions, options?: FenceRenderOptions): string;
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as b,b as c,c as d,d as e}from"./chunks/chunk-62FKKJ5M.js";import{e as a}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";export{b as createFenceIds,a as createRenderer,c as isVdFence,d as parseInfo,e as renderFence};
|
package/dist/marked.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FenceRenderOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, Renderer } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
interface CodeToken {
|
|
5
|
+
text: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A marked extension. Returning `false` hands the block back to marked's own renderer. */
|
|
9
|
+
export declare function vdesignMarked(options?: FenceRenderOptions): {
|
|
10
|
+
renderer: {
|
|
11
|
+
code(this: unknown, token: CodeToken | string, info?: string): string | false;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default vdesignMarked;
|
package/dist/marked.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as t,b as i,d as o}from"./chunks/chunk-62FKKJ5M.js";import{e as f}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function p(r={}){let s=r.idPrefix??t();return{renderer:{code(e,d){let c=typeof e=="string"?e:e.text,n=typeof e=="string"?d:e.lang;return i(n)?o(c,n??"vd",{...r,idPrefix:s}):!1}}}}var a=p;export{f as createRenderer,a as default,p as vdesignMarked};
|
package/dist/rehype.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RehypeOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, RehypeOptions, Renderer, } from './types.js';
|
|
3
|
+
interface HastNode {
|
|
4
|
+
type: string;
|
|
5
|
+
tagName?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
properties?: Record<string, unknown>;
|
|
8
|
+
data?: {
|
|
9
|
+
meta?: unknown;
|
|
10
|
+
};
|
|
11
|
+
children?: HastNode[];
|
|
12
|
+
}
|
|
13
|
+
interface VFileLike {
|
|
14
|
+
path?: string;
|
|
15
|
+
history?: string[];
|
|
16
|
+
}
|
|
17
|
+
/** `.use(rehypeVdesign, options)`. */
|
|
18
|
+
export declare function rehypeVdesign(options?: RehypeOptions): (tree: HastNode, file?: VFileLike) => Promise<void>;
|
|
19
|
+
export default rehypeVdesign;
|
package/dist/rehype.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as h,d as m}from"./chunks/chunk-62FKKJ5M.js";import{e as g}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function x(e={}){let n,i=()=>e.renderer?Promise.resolve(e.renderer):n??=g({fonts:e.fonts??"exact",...e.fontBase===void 0?{}:{fontBase:e.fontBase}});return async(t,r)=>{let s=r?.path??r?.history?.at(-1);if(e.include&&!e.include(s))return;let o=[];if(v(t,(d,l,a)=>{if(d.type!=="element"||d.tagName!=="pre"||!l)return;let c=d.children?.find(p=>p.type==="element");c?.tagName!=="code"||!F(c)||o.push({parent:l,index:a,code:c})}),o.length===0)return;let u=await i(),f={...e};for(let d of["resolveSrc","fonts","fontBase","include"])delete f[d];let N=e.idPrefix??h(),R=e.resolveSrc??k;for(let{parent:d,index:l,code:a}of o){let c=typeof a.data?.meta=="string"?a.data.meta:"",p=m(y(a),`vd ${c}`,{...f,renderer:u,idPrefix:N,resolveSrc:H=>R(H,s)});d.children[l]={type:"raw",value:p}}}}var B=x;function F(e){let n=e.properties?.className;return(Array.isArray(n)?n:typeof n=="string"?n.split(/\s+/):[]).some(t=>t==="language-vd"||t==="language-vdesign")}function y(e){return e.type==="text"?e.value??"":(e.children??[]).map(y).join("")}function v(e,n,i,t=0){n(e,i,t),e.children?.forEach((r,s)=>v(r,n,e,s))}function k(e,n){let i=globalThis,t=i.process?.getBuiltinModule?.("node:fs"),r=i.process?.getBuiltinModule?.("node:path"),s=i.process?.cwd?.();if(!t||!r||s===void 0||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.includes("\\")||!/\.vd(\.svg)?$/i.test(e))return;let o=n===void 0?s:r.dirname(r.resolve(s,n));try{let u=t.realpathSync(r.resolve(o,e)),f=t.realpathSync(s);return u.startsWith(f+r.sep)?t.readFileSync(u,"utf8"):void 0}catch{return}}export{B as default,x as rehypeVdesign};
|
package/dist/static.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import type { ParseResult, RenderSvgOptions, Source } from './types.js';
|
|
2
|
-
export type { ParseResult, Problem, RenderSvgOptions, Source, VdDocument } from './types.js';
|
|
1
|
+
import type { Outline, ParseResult, Renderer, RendererOptions, RenderSvgOptions, Source } from './types.js';
|
|
2
|
+
export type { Outline, OutlinePage, ParseResult, Problem, Renderer, RendererOptions, RendererRenderOptions, RenderSvgOptions, Source, VdDocument, } from './types.js';
|
|
3
3
|
export { version } from './version.js';
|
|
4
4
|
/** Read `.vd` text. Never throws: what is wrong comes back as `problems`. */
|
|
5
5
|
export declare function parse(text: string): ParseResult;
|
|
6
6
|
/** Draw a document, or one of its pages, as a standalone SVG. */
|
|
7
7
|
export declare function renderSvg(source: Source, options?: RenderSvgOptions): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The `.vd` text in `text`: itself for a `.vd`, the design it carries for a
|
|
10
|
+
* `.vd.svg`, `undefined` for an SVG that carries none. For copying a design
|
|
11
|
+
* out of an SVG as text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function designOf(text: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* A document's title and pages, each with the line its `frame` is written on:
|
|
16
|
+
* what an editor needs for an outline, breadcrumbs, and keeping a preview on
|
|
17
|
+
* the page the cursor is in. Never throws.
|
|
18
|
+
*
|
|
19
|
+
* The line is found by reading the text for the page's top-level `frame`
|
|
20
|
+
* line, never by evaluating anything, so it is as cheap as parsing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function outline(text: string): Outline;
|
|
23
|
+
/**
|
|
24
|
+
* A renderer that draws synchronously once it exists. Exact fonts are fetched
|
|
25
|
+
* here, all of them, because which ones a later document needs is not known
|
|
26
|
+
* yet and the render cannot wait to find out.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createRenderer(options?: RendererOptions): Promise<Renderer>;
|
|
29
|
+
/**
|
|
30
|
+
* The renderer with no font files, made synchronously: what the Markdown
|
|
31
|
+
* adapters use when a host does not hand them one, because a markdown-it
|
|
32
|
+
* plugin is installed in a synchronous call.
|
|
33
|
+
*/
|
|
34
|
+
export declare function approximateRenderer(): Renderer;
|
package/dist/static.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{a as
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import{a}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";export{g as approximateRenderer,f as createRenderer,d as designOf,e as outline,b as parse,c as renderSvg,a as version};
|
package/dist/types.d.ts
CHANGED
|
@@ -59,6 +59,57 @@ export interface RenderSvgOptions {
|
|
|
59
59
|
* load. Empty when nothing is.
|
|
60
60
|
*/
|
|
61
61
|
onProblems?: (problems: Problem[]) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Put in front of every id the SVG defines for itself (clips, shadows,
|
|
64
|
+
* gradients) and of every reference to one. Two SVGs inline in one page
|
|
65
|
+
* otherwise share those names, and the second one's shapes clip to the
|
|
66
|
+
* first one's rectangles. The `/markdown` entries give each fence its own.
|
|
67
|
+
*/
|
|
68
|
+
idPrefix?: string;
|
|
69
|
+
}
|
|
70
|
+
/** A page in `outline()`: what `view()` calls a page, and where it starts in the text. */
|
|
71
|
+
export interface OutlinePage {
|
|
72
|
+
id: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The 1-based line of the page's `frame` line in the text given, which for
|
|
76
|
+
* a `.vd.svg` counts the SVG's own lines. Undefined only if the frame could
|
|
77
|
+
* not be found, which a document `parse` accepted does not do.
|
|
78
|
+
*/
|
|
79
|
+
line?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface Outline {
|
|
82
|
+
title?: string;
|
|
83
|
+
/** In play order: top-level frames that are not hidden. */
|
|
84
|
+
pages: OutlinePage[];
|
|
85
|
+
problems: Problem[];
|
|
86
|
+
}
|
|
87
|
+
export interface RendererOptions {
|
|
88
|
+
/**
|
|
89
|
+
* `'approximate'` (the default) needs no font files. `'exact'` fetches every
|
|
90
|
+
* bundled face once, before `createRenderer` resolves, so each later render
|
|
91
|
+
* can lay text out from them without waiting. That is all 18 faces, about
|
|
92
|
+
* 2.6 MB: meant for a build step or an editor's preview, not a web page.
|
|
93
|
+
*/
|
|
94
|
+
fonts?: 'exact' | 'approximate';
|
|
95
|
+
/** As for `renderSvg`. */
|
|
96
|
+
fontBase?: string | URL;
|
|
97
|
+
}
|
|
98
|
+
export interface RendererRenderOptions {
|
|
99
|
+
page?: string | number;
|
|
100
|
+
idPrefix?: string;
|
|
101
|
+
onProblems?: (problems: Problem[]) => void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Renders synchronously, for a caller that cannot wait: a markdown-it rule
|
|
105
|
+
* returns a string. Under `fonts: 'exact'` a document that needs a face that
|
|
106
|
+
* did not load draws approximately and `onProblems` hears `fonts-unavailable`.
|
|
107
|
+
*/
|
|
108
|
+
export interface Renderer {
|
|
109
|
+
/** `.vd` or `.vd.svg` text, or a parsed document, to an SVG string. Throws a `RangeError` for a missing page. */
|
|
110
|
+
renderSvg(source: string | VdDocument, options?: RendererRenderOptions): string;
|
|
111
|
+
/** What `createRenderer` was asked for, and what it got: `'approximate'` if the faces would not load. */
|
|
112
|
+
readonly fonts: 'exact' | 'approximate';
|
|
62
113
|
}
|
|
63
114
|
export interface ViewOptions {
|
|
64
115
|
/**
|
|
@@ -220,4 +271,80 @@ export type MountMode = 'view' | 'edit' | 'play';
|
|
|
220
271
|
export type MountOptions = {
|
|
221
272
|
mode: MountMode;
|
|
222
273
|
} & EditOptions;
|
|
274
|
+
/** What a fence's info string asks for: ` ```vd page=pricing mode=view source `. */
|
|
275
|
+
export interface FenceOptions {
|
|
276
|
+
/** One page, by id or 0-based index (a number written as digits). Default: the whole document. */
|
|
277
|
+
page?: string | number;
|
|
278
|
+
/** A file to draw instead of the body, resolved by `resolveSrc`. */
|
|
279
|
+
src?: string;
|
|
280
|
+
/** The live view's height in CSS pixels. Default: the drawing's own aspect ratio. */
|
|
281
|
+
height?: number;
|
|
282
|
+
/** `'view'` hydrates into a live view; `'static'` stays an SVG. Default: the adapter's `mode`. */
|
|
283
|
+
mode?: 'static' | 'view';
|
|
284
|
+
/** Also show the `.vd` text, folded, under the drawing. */
|
|
285
|
+
source?: boolean;
|
|
286
|
+
/** The drawing's accessible name. Default: the document's title. */
|
|
287
|
+
alt?: string;
|
|
288
|
+
}
|
|
289
|
+
export interface FenceRenderOptions {
|
|
290
|
+
/** Default: a renderer with no font files (`approximateRenderer()`). `createRenderer` makes an exact one. */
|
|
291
|
+
renderer?: Renderer;
|
|
292
|
+
/** Read a fence's `src=`. Without it, or when it returns `undefined`, the fence shows a problem. */
|
|
293
|
+
resolveSrc?: (src: string) => string | undefined;
|
|
294
|
+
/** For fences that do not say. Default `'static'`. */
|
|
295
|
+
mode?: 'static' | 'view';
|
|
296
|
+
/**
|
|
297
|
+
* `'inline'` (the default) puts the SVG in the page: its text can be selected
|
|
298
|
+
* and searched. `'img'` wraps it in `<img src="data:…">`: isolated from the
|
|
299
|
+
* page's CSS, and what a mail client or a CMS that strips `<svg>` accepts.
|
|
300
|
+
*/
|
|
301
|
+
output?: 'inline' | 'img';
|
|
302
|
+
/**
|
|
303
|
+
* `false` for a page whose content security policy refuses `style=""`. A
|
|
304
|
+
* drawing that needs one (a blend mode) is then wrapped as an `<img>`,
|
|
305
|
+
* which the policy does not reach into. Default `true`.
|
|
306
|
+
*/
|
|
307
|
+
inlineStyles?: boolean;
|
|
308
|
+
/** The most text and nodes one fence may hold. Past either it stays a code block. */
|
|
309
|
+
limits?: {
|
|
310
|
+
bytes?: number;
|
|
311
|
+
nodes?: number;
|
|
312
|
+
};
|
|
313
|
+
/** A fresh prefix for each drawing's ids. Default: `vd1-`, `vd2-`, … per call of `createFenceIds`. */
|
|
314
|
+
idPrefix?: () => string;
|
|
315
|
+
/**
|
|
316
|
+
* Extra attributes for the `<figure>`, as the host's own code block would
|
|
317
|
+
* have carried them: VS Code's preview marks blocks `class="code-line"
|
|
318
|
+
* data-line="12"` to keep its scroll in step with the editor.
|
|
319
|
+
*/
|
|
320
|
+
attributes?: readonly (readonly [string, string])[];
|
|
321
|
+
}
|
|
322
|
+
export interface MarkdownItOptions extends Omit<FenceRenderOptions, 'resolveSrc'> {
|
|
323
|
+
/** Read a fence's `src=`. `env` is what the host passed to `md.render(text, env)`. */
|
|
324
|
+
resolveSrc?: (src: string, env: unknown) => string | undefined;
|
|
325
|
+
}
|
|
326
|
+
export interface RehypeOptions extends Omit<FenceRenderOptions, 'resolveSrc' | 'renderer'> {
|
|
327
|
+
/** Default `'exact'`. Ignored when `renderer` is given. */
|
|
328
|
+
fonts?: RendererOptions['fonts'];
|
|
329
|
+
fontBase?: RendererOptions['fontBase'];
|
|
330
|
+
renderer?: Renderer;
|
|
331
|
+
/**
|
|
332
|
+
* Read a fence's `src=`. `path` is the Markdown file's own path when the
|
|
333
|
+
* pipeline knows it. Default, in Node: the file, relative to the Markdown.
|
|
334
|
+
*/
|
|
335
|
+
resolveSrc?: (src: string, path: string | undefined) => string | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* Which Markdown files to draw fences in, by path. Default: all of them. For
|
|
338
|
+
* a site whose reference pages quote DSL to teach it, where the reader came
|
|
339
|
+
* for the code, not the picture.
|
|
340
|
+
*/
|
|
341
|
+
include?: (path: string | undefined) => boolean;
|
|
342
|
+
}
|
|
343
|
+
export interface HydrateOptions {
|
|
344
|
+
/** Passed to each view. Default `'exact'`, from `fontBase`. */
|
|
345
|
+
fonts?: ViewOptions['fonts'];
|
|
346
|
+
fontBase?: ViewOptions['fontBase'];
|
|
347
|
+
surface?: ViewOptions['surface'];
|
|
348
|
+
onLink?: ViewOptions['onLink'];
|
|
349
|
+
}
|
|
223
350
|
export {};
|
package/dist/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{c as ut,e as ze,f as ce,g as Ee,h as pt,i as Le}from"./chunks/chunk-DSFLLPRE.js";import{A as lt,a as Xe,b as Je,c as Te,d as Fe,e as Qe,f as et,g as tt,h as nt,j as rt,l as it,p as Ie,q as _e,r as ot,s as Ne,v as st,w as at,x as ct,y as dt,z as ft}from"./chunks/chunk-OMODSFXU.js";import{a as qt,b as qe}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";var Xt=.8,Jt=.2;function Ve(e,t){let i=e.createElement("canvas").getContext("2d"),n=ot(),u=new Map,s=new Map,m=new Set;function f(l){return`${l.italic?"italic ":""}${l.weight} ${l.size}px ${l.family}`}function g(){u.clear(),s.clear()}return{advance(l,p){if(!i)return n.advance(l,p);let M=f(p),S=`${M}\0${p.letterSpacing}\0${l}`,O=u.get(S);if(O!==void 0)return O;i.font=M;let w=i.measureText(l).width+p.letterSpacing*[...l].length;return u.set(S,w),w},metrics(l){if(!i)return n.metrics(l);let p=f(l),M=s.get(p);if(M)return M;i.font=p;let S=i.measureText("Hxg"),O=S.fontBoundingBoxAscent??l.size*Xt,w=S.fontBoundingBoxDescent??l.size*Jt,N={ascent:O,descent:w,lineGap:0};return s.set(p,N),N},load(l,p){let M=e.fonts;if(!M||typeof FontFace!="function")return!1;let S=!1;for(let O of Object.values(l.fonts))for(let w of Qt(O)){let N=`${O.family}\0${w.src}\0${w.weight??400}\0${w.style??"normal"}`;if(m.has(N))continue;m.add(N);let _=w.src.startsWith("data:")?void 0:p?.(w.src),x={weight:String(w.weight??400),style:w.style??"normal"},R=X=>{let z=new FontFace(O.family,typeof X=="string"?`url(${X})`:en(X),x);M.add(z),z.load().then(()=>{g(),t?.()},()=>{M.delete(z)})};_===void 0?R(w.src):(S=!0,_.then(R,()=>{}))}return S},invalidate:g,destroy(){g(),m.clear()}}}function Qt(e){return e.faces??[]}function en(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var Pe={x:0,y:0,zoom:1},ht=.02,mt=64;function Se(e){return Number.isFinite(e)?Math.min(Math.max(e,ht),mt):1}function Ce(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function Re(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function De(e,t,r){let i=Se(e.zoom*r),n=Ce(e,t);return{zoom:i,x:t.x-n.x*i,y:t.y-n.y*i}}function ke(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 de(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 Pe;let n=Se(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",gt="vd-viewer-styles",yt=`
|
|
3
3
|
.vd-viewer {
|
|
4
4
|
position: relative;
|
|
5
5
|
overflow: hidden;
|
package/fonts.css
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* Inter, for the drawings the Markdown entries write. SIL Open Font License: fonts/OFL.txt. */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: Inter;
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 900;
|
|
6
|
+
font-display: swap;
|
|
7
|
+
src: url('fonts/Inter-Black.woff2') format('woff2');
|
|
8
|
+
}
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: Inter;
|
|
11
|
+
font-style: italic;
|
|
12
|
+
font-weight: 900;
|
|
13
|
+
font-display: swap;
|
|
14
|
+
src: url('fonts/Inter-BlackItalic.woff2') format('woff2');
|
|
15
|
+
}
|
|
16
|
+
@font-face {
|
|
17
|
+
font-family: Inter;
|
|
18
|
+
font-style: normal;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
font-display: swap;
|
|
21
|
+
src: url('fonts/Inter-Bold.woff2') format('woff2');
|
|
22
|
+
}
|
|
23
|
+
@font-face {
|
|
24
|
+
font-family: Inter;
|
|
25
|
+
font-style: italic;
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
font-display: swap;
|
|
28
|
+
src: url('fonts/Inter-BoldItalic.woff2') format('woff2');
|
|
29
|
+
}
|
|
30
|
+
@font-face {
|
|
31
|
+
font-family: Inter;
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: 800;
|
|
34
|
+
font-display: swap;
|
|
35
|
+
src: url('fonts/Inter-ExtraBold.woff2') format('woff2');
|
|
36
|
+
}
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: Inter;
|
|
39
|
+
font-style: italic;
|
|
40
|
+
font-weight: 800;
|
|
41
|
+
font-display: swap;
|
|
42
|
+
src: url('fonts/Inter-ExtraBoldItalic.woff2') format('woff2');
|
|
43
|
+
}
|
|
44
|
+
@font-face {
|
|
45
|
+
font-family: Inter;
|
|
46
|
+
font-style: normal;
|
|
47
|
+
font-weight: 200;
|
|
48
|
+
font-display: swap;
|
|
49
|
+
src: url('fonts/Inter-ExtraLight.woff2') format('woff2');
|
|
50
|
+
}
|
|
51
|
+
@font-face {
|
|
52
|
+
font-family: Inter;
|
|
53
|
+
font-style: italic;
|
|
54
|
+
font-weight: 200;
|
|
55
|
+
font-display: swap;
|
|
56
|
+
src: url('fonts/Inter-ExtraLightItalic.woff2') format('woff2');
|
|
57
|
+
}
|
|
58
|
+
@font-face {
|
|
59
|
+
font-family: Inter;
|
|
60
|
+
font-style: italic;
|
|
61
|
+
font-weight: 400;
|
|
62
|
+
font-display: swap;
|
|
63
|
+
src: url('fonts/Inter-Italic.woff2') format('woff2');
|
|
64
|
+
}
|
|
65
|
+
@font-face {
|
|
66
|
+
font-family: Inter;
|
|
67
|
+
font-style: normal;
|
|
68
|
+
font-weight: 300;
|
|
69
|
+
font-display: swap;
|
|
70
|
+
src: url('fonts/Inter-Light.woff2') format('woff2');
|
|
71
|
+
}
|
|
72
|
+
@font-face {
|
|
73
|
+
font-family: Inter;
|
|
74
|
+
font-style: italic;
|
|
75
|
+
font-weight: 300;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
src: url('fonts/Inter-LightItalic.woff2') format('woff2');
|
|
78
|
+
}
|
|
79
|
+
@font-face {
|
|
80
|
+
font-family: Inter;
|
|
81
|
+
font-style: normal;
|
|
82
|
+
font-weight: 500;
|
|
83
|
+
font-display: swap;
|
|
84
|
+
src: url('fonts/Inter-Medium.woff2') format('woff2');
|
|
85
|
+
}
|
|
86
|
+
@font-face {
|
|
87
|
+
font-family: Inter;
|
|
88
|
+
font-style: italic;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
font-display: swap;
|
|
91
|
+
src: url('fonts/Inter-MediumItalic.woff2') format('woff2');
|
|
92
|
+
}
|
|
93
|
+
@font-face {
|
|
94
|
+
font-family: Inter;
|
|
95
|
+
font-style: normal;
|
|
96
|
+
font-weight: 400;
|
|
97
|
+
font-display: swap;
|
|
98
|
+
src: url('fonts/Inter-Regular.woff2') format('woff2');
|
|
99
|
+
}
|
|
100
|
+
@font-face {
|
|
101
|
+
font-family: Inter;
|
|
102
|
+
font-style: normal;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
font-display: swap;
|
|
105
|
+
src: url('fonts/Inter-SemiBold.woff2') format('woff2');
|
|
106
|
+
}
|
|
107
|
+
@font-face {
|
|
108
|
+
font-family: Inter;
|
|
109
|
+
font-style: italic;
|
|
110
|
+
font-weight: 600;
|
|
111
|
+
font-display: swap;
|
|
112
|
+
src: url('fonts/Inter-SemiBoldItalic.woff2') format('woff2');
|
|
113
|
+
}
|
|
114
|
+
@font-face {
|
|
115
|
+
font-family: Inter;
|
|
116
|
+
font-style: normal;
|
|
117
|
+
font-weight: 100;
|
|
118
|
+
font-display: swap;
|
|
119
|
+
src: url('fonts/Inter-Thin.woff2') format('woff2');
|
|
120
|
+
}
|
|
121
|
+
@font-face {
|
|
122
|
+
font-family: Inter;
|
|
123
|
+
font-style: italic;
|
|
124
|
+
font-weight: 100;
|
|
125
|
+
font-display: swap;
|
|
126
|
+
src: url('fonts/Inter-ThinItalic.woff2') format('woff2');
|
|
127
|
+
}
|
package/markdown.css
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The figures the Markdown entries write (/markdown, /markdown-it, /rehype,
|
|
3
|
+
* /marked). Classes only: no element selector reaches outside .vd-figure, and
|
|
4
|
+
* nothing needs a style="" attribute, so a page with a strict content security
|
|
5
|
+
* policy can link this file as it is. Text in the drawings names the family
|
|
6
|
+
* "Inter"; link fonts.css too if the page does not already have it.
|
|
7
|
+
*/
|
|
8
|
+
.vd-figure {
|
|
9
|
+
margin: 1.5em 0;
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
}
|
|
12
|
+
.vd-figure-art {
|
|
13
|
+
display: block;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
line-height: 0;
|
|
16
|
+
}
|
|
17
|
+
.vd-figure-art svg,
|
|
18
|
+
img.vd-figure-art {
|
|
19
|
+
display: block;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
height: auto;
|
|
22
|
+
}
|
|
23
|
+
.vd-figure-art[hidden] {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
.vd-figure-live {
|
|
27
|
+
width: 100%;
|
|
28
|
+
border-radius: var(--vd-figure-radius, 8px);
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
.vd-figure-source {
|
|
32
|
+
margin-top: 0.75em;
|
|
33
|
+
}
|
|
34
|
+
.vd-figure-source > summary {
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
font-size: 0.875em;
|
|
37
|
+
opacity: 0.75;
|
|
38
|
+
}
|
|
39
|
+
.vd-problems {
|
|
40
|
+
margin: 0.5em 0 0;
|
|
41
|
+
padding: 0.5em 0.75em 0.5em 2em;
|
|
42
|
+
border-left: 3px solid var(--vd-problem, #d64545);
|
|
43
|
+
font-size: 0.875em;
|
|
44
|
+
}
|
|
45
|
+
.vd-problems > li[data-severity='warning'] {
|
|
46
|
+
opacity: 0.8;
|
|
47
|
+
}
|
|
48
|
+
.vd-figure-pager {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: 0.5em;
|
|
52
|
+
margin-top: 0.5em;
|
|
53
|
+
font-size: 0.875em;
|
|
54
|
+
}
|
|
55
|
+
.vd-figure-pager__label {
|
|
56
|
+
min-width: 8em;
|
|
57
|
+
text-align: center;
|
|
58
|
+
opacity: 0.8;
|
|
59
|
+
}
|
|
60
|
+
.vd-figure-pager__button {
|
|
61
|
+
font: inherit;
|
|
62
|
+
color: inherit;
|
|
63
|
+
background: transparent;
|
|
64
|
+
border: 1px solid currentColor;
|
|
65
|
+
border-radius: 6px;
|
|
66
|
+
padding: 0.15em 0.75em;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
opacity: 0.85;
|
|
69
|
+
}
|
|
70
|
+
.vd-figure-pager__button:hover {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getv.design/embed",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"prepublishOnly": "node ./scripts/gate.mjs"
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": [
|
|
17
|
-
"*.css"
|
|
17
|
+
"*.css",
|
|
18
|
+
"./dist/chunks/*.js"
|
|
18
19
|
],
|
|
19
20
|
"exports": {
|
|
20
21
|
".": {
|
|
@@ -33,15 +34,42 @@
|
|
|
33
34
|
"types": "./dist/edit.d.ts",
|
|
34
35
|
"default": "./dist/edit.js"
|
|
35
36
|
},
|
|
37
|
+
"./markdown": {
|
|
38
|
+
"types": "./dist/markdown.d.ts",
|
|
39
|
+
"default": "./dist/markdown.js"
|
|
40
|
+
},
|
|
41
|
+
"./markdown-it": {
|
|
42
|
+
"types": "./dist/markdown-it.d.ts",
|
|
43
|
+
"default": "./dist/markdown-it.js"
|
|
44
|
+
},
|
|
45
|
+
"./rehype": {
|
|
46
|
+
"types": "./dist/rehype.d.ts",
|
|
47
|
+
"default": "./dist/rehype.js"
|
|
48
|
+
},
|
|
49
|
+
"./marked": {
|
|
50
|
+
"types": "./dist/marked.d.ts",
|
|
51
|
+
"default": "./dist/marked.js"
|
|
52
|
+
},
|
|
53
|
+
"./auto": {
|
|
54
|
+
"types": "./dist/auto.d.ts",
|
|
55
|
+
"default": "./dist/auto.js"
|
|
56
|
+
},
|
|
36
57
|
"./view.css": "./view.css",
|
|
37
58
|
"./edit.css": "./edit.css",
|
|
59
|
+
"./markdown.css": "./markdown.css",
|
|
60
|
+
"./fonts.css": "./fonts.css",
|
|
38
61
|
"./fonts/*": "./fonts/*"
|
|
39
62
|
},
|
|
63
|
+
"bin": {
|
|
64
|
+
"vd-render": "./dist/cli.js"
|
|
65
|
+
},
|
|
40
66
|
"files": [
|
|
41
67
|
"dist/**/*.js",
|
|
42
68
|
"dist/**/*.d.ts",
|
|
43
69
|
"view.css",
|
|
44
70
|
"edit.css",
|
|
71
|
+
"markdown.css",
|
|
72
|
+
"fonts.css",
|
|
45
73
|
"fonts/Inter-*.woff2",
|
|
46
74
|
"fonts/OFL.txt",
|
|
47
75
|
"THIRD_PARTY_NOTICES.txt",
|