wendang 0.1.1 โ†’ 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.
@@ -1 +1 @@
1
- "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||e(r,t,o)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./schema.js"),exports),t(require("./shared/node-catalog.js"),exports),t(require("./shared/doc-text.js"),exports);
1
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),r=this&&this.__exportStar||function(r,t){for(var o in r)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||e(t,r,o)};Object.defineProperty(exports,"__esModule",{value:!0}),r(require("./schema.js"),exports),r(require("./shared/node-catalog.js"),exports),r(require("./shared/doc-text.js"),exports),r(require("./shared/headings.js"),exports);
@@ -1 +1 @@
1
- "use strict";function validCalloutAttrs(o){if(!o||"object"!=typeof o||Array.isArray(o))return!1;const t=o,valid=(o,r)=>void 0===t[o]||null===t[o]||"string"==typeof t[o]&&r.includes(t[o]);return valid("tone",exports.CALLOUT_TONES)&&valid("icon",["",...exports.CALLOUT_ICONS])&&valid("textColor",exports.CALLOUT_COLORS)&&valid("borderColor",["none",...exports.CALLOUT_COLORS])&&valid("backgroundColor",["none",...exports.CALLOUT_FILLS])}function effectiveCallout(o={}){const t=exports.CALLOUT_TONES.includes(o.tone)?o.tone:"info",r={info:"blue",success:"green",warning:"orange",danger:"red"}[t];return{tone:t,icon:null===o.icon||void 0===o.icon?{info:"๐Ÿ’ก",success:"โœ…",warning:"โš ๏ธ",danger:"โ—"}[t]:["",...exports.CALLOUT_ICONS].includes(o.icon)?o.icon:"๐Ÿ’ก",textColor:exports.CALLOUT_COLORS.includes(o.textColor)?o.textColor:null,borderColor:["none",...exports.CALLOUT_COLORS].includes(o.borderColor)?o.borderColor:r,backgroundColor:["none",...exports.CALLOUT_FILLS].includes(o.backgroundColor)?o.backgroundColor:r}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.CALLOUT_FILLS=exports.CALLOUT_COLORS=exports.CALLOUT_ICONS=exports.CALLOUT_TONES=void 0,exports.validCalloutAttrs=validCalloutAttrs,exports.effectiveCallout=effectiveCallout,exports.calloutDOMAttributes=function calloutDOMAttributes(o={}){const t=effectiveCallout(o);return{"data-callout":"true","data-tone":t.tone,"data-callout-icon":o.icon??"default",...Object.fromEntries(["textColor","borderColor","backgroundColor"].filter(t=>null!=o[t]).map(t=>[`data-callout-${t.toLowerCase()}`,String(o[t])])),...""===t.icon?{"data-icon-hidden":"true"}:{},style:["--callout-border:"+("none"===t.borderColor?"transparent":`var(--callout-border-${t.borderColor})`),"--callout-fill:"+("none"===t.backgroundColor?"transparent":`var(--doc-highlight-${"gray"===t.backgroundColor?"gray-soft":t.backgroundColor})`),"--callout-text:"+(t.textColor?`var(--doc-text-${t.textColor})`:"var(--content-text-color, var(--color-text))")].join(";")}},exports.calloutMetadata=function calloutMetadata(o){if(!validCalloutAttrs(o))return"";const t=Object.fromEntries(["icon","textColor","borderColor","backgroundColor"].filter(t=>void 0!==o[t]&&null!==o[t]).map(t=>[t,o[t]]));return Object.keys(t).length?` \x3c!--ywiki-callout:${encodeURIComponent(JSON.stringify(t))}--\x3e`:""},exports.readCalloutMetadata=function readCalloutMetadata(o){const t=/^\s*<!--ywiki-callout:([^\s<>]{1,4096})-->\s*/.exec(o);if(!t)return null;try{const o=JSON.parse(decodeURIComponent(t[1]));return!validCalloutAttrs(o)||Object.keys(o).some(o=>!["icon","textColor","borderColor","backgroundColor"].includes(o))?null:{attrs:o,length:t[0].length}}catch{return null}},exports.CALLOUT_TONES=["info","success","warning","danger"],exports.CALLOUT_ICONS=["๐Ÿ’ก","โ„น๏ธ","โœ…","โš ๏ธ","โ—","๐Ÿ“Œ","๐ŸŽฏ","๐Ÿ’ฌ","๐Ÿ“–","๐Ÿ“","๐Ÿš€","๐Ÿ””","๐Ÿ”Ž","โญ","๐ŸŒ…","๐Ÿ› ๏ธ","๐Ÿ“…","๐Ÿ”’","โค๏ธ","๐ŸŽ‰","โ“","๐Ÿ“Ž","๐Ÿ","๐Ÿ”ฅ"],exports.CALLOUT_COLORS=["gray","red","orange","yellow","green","blue","purple"],exports.CALLOUT_FILLS=[...exports.CALLOUT_COLORS,...exports.CALLOUT_COLORS.map(o=>`${o}-strong`)];
1
+ "use strict";function calloutColorToken(o,r){return"textColor"===o?`--doc-text-${r}`:"borderColor"===o?`--callout-border-${r}`:`--doc-highlight-${"gray"===r?"gray-soft":r}`}function validCalloutAttrs(o){if(!o||"object"!=typeof o||Array.isArray(o))return!1;const r=o,valid=(o,e)=>void 0===r[o]||null===r[o]||"string"==typeof r[o]&&e.includes(r[o]);return valid("tone",exports.CALLOUT_TONES)&&valid("icon",["",...exports.CALLOUT_ICONS])&&valid("textColor",exports.CALLOUT_COLORS)&&valid("borderColor",["none",...exports.CALLOUT_COLORS])&&valid("backgroundColor",["none",...exports.CALLOUT_FILLS])}function effectiveCallout(o={}){const r=exports.CALLOUT_TONES.includes(o.tone)?o.tone:"info",e={info:"blue",success:"green",warning:"orange",danger:"red"}[r];return{tone:r,icon:null===o.icon||void 0===o.icon?{info:"๐Ÿ’ก",success:"โœ…",warning:"โš ๏ธ",danger:"โ—"}[r]:["",...exports.CALLOUT_ICONS].includes(o.icon)?o.icon:"๐Ÿ’ก",textColor:exports.CALLOUT_COLORS.includes(o.textColor)?o.textColor:null,borderColor:["none",...exports.CALLOUT_COLORS].includes(o.borderColor)?o.borderColor:e,backgroundColor:["none",...exports.CALLOUT_FILLS].includes(o.backgroundColor)?o.backgroundColor:e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.CALLOUT_SWATCH_FALLBACKS=exports.CALLOUT_FILLS=exports.CALLOUT_COLORS=exports.CALLOUT_ICONS=exports.CALLOUT_TONES=void 0,exports.calloutColorToken=calloutColorToken,exports.calloutSwatchStyle=function calloutSwatchStyle(o,r){if(null===r||"none"===r)return{};const e=exports.CALLOUT_SWATCH_FALLBACKS[o][r],t=e?`var(${calloutColorToken(o,r)}, ${e})`:`var(${calloutColorToken(o,r)})`;return"textColor"===o?{color:t}:{backgroundColor:t}},exports.validCalloutAttrs=validCalloutAttrs,exports.effectiveCallout=effectiveCallout,exports.calloutDOMAttributes=function calloutDOMAttributes(o={}){const r=effectiveCallout(o),token=(o,r)=>`var(${o}, ${r})`,e="none"===r.borderColor?"transparent":token(calloutColorToken("borderColor",r.borderColor),exports.CALLOUT_SWATCH_FALLBACKS.borderColor[r.borderColor]??"#9ac5ef"),t="none"===r.backgroundColor?"transparent":token(calloutColorToken("backgroundColor",r.backgroundColor),exports.CALLOUT_SWATCH_FALLBACKS.backgroundColor[r.backgroundColor]??"#d0ebff"),l=r.textColor?token(calloutColorToken("textColor",r.textColor),exports.CALLOUT_SWATCH_FALLBACKS.textColor[r.textColor]??"#1f2937"):"var(--content-text-color, var(--color-text))";return{"data-callout":"true","data-tone":r.tone,"data-callout-icon":o.icon??"default",...Object.fromEntries(["textColor","borderColor","backgroundColor"].filter(r=>null!=o[r]).map(r=>[`data-callout-${r.toLowerCase()}`,String(o[r])])),...""===r.icon?{"data-icon-hidden":"true"}:{},style:[`--callout-border:${e}`,`--callout-fill:${t}`,`--callout-text:${l}`].join(";")}},exports.calloutMetadata=function calloutMetadata(o){if(!validCalloutAttrs(o))return"";const r=Object.fromEntries(["icon","textColor","borderColor","backgroundColor"].filter(r=>void 0!==o[r]&&null!==o[r]).map(r=>[r,o[r]]));return Object.keys(r).length?` \x3c!--ywiki-callout:${encodeURIComponent(JSON.stringify(r))}--\x3e`:""},exports.readCalloutMetadata=function readCalloutMetadata(o){const r=/^\s*<!--ywiki-callout:([^\s<>]{1,4096})-->\s*/.exec(o);if(!r)return null;try{const o=JSON.parse(decodeURIComponent(r[1]));return!validCalloutAttrs(o)||Object.keys(o).some(o=>!["icon","textColor","borderColor","backgroundColor"].includes(o))?null:{attrs:o,length:r[0].length}}catch{return null}},exports.CALLOUT_TONES=["info","success","warning","danger"],exports.CALLOUT_ICONS=["๐Ÿ’ก","โ„น๏ธ","โœ…","โš ๏ธ","โ—","๐Ÿ“Œ","๐ŸŽฏ","๐Ÿ’ฌ","๐Ÿ“–","๐Ÿ“","๐Ÿš€","๐Ÿ””","๐Ÿ”Ž","โญ","๐ŸŒ…","๐Ÿ› ๏ธ","๐Ÿ“…","๐Ÿ”’","โค๏ธ","๐ŸŽ‰","โ“","๐Ÿ“Ž","๐Ÿ","๐Ÿ”ฅ"],exports.CALLOUT_COLORS=["gray","red","orange","yellow","green","blue","purple"],exports.CALLOUT_FILLS=[...exports.CALLOUT_COLORS,...exports.CALLOUT_COLORS.map(o=>`${o}-strong`)],exports.CALLOUT_SWATCH_FALLBACKS={textColor:{gray:"#646a73",red:"#d92c2c",orange:"#b95d0b",yellow:"#8a6c0a",green:"#237b35",blue:"#1971c2",purple:"#7048e8"},borderColor:{gray:"#c7cbd1",red:"#f0a2a2",orange:"#ffc078",yellow:"#e3ca71",green:"#91d4a0",blue:"#9ac5ef",purple:"#c0a4ed"},backgroundColor:{gray:"#f1f3f5",red:"#ffe3e3",orange:"#fff0db",yellow:"#fff3bf",green:"#d3f9d8",blue:"#d0ebff",purple:"#e5dbff","gray-strong":"#ced4da","red-strong":"#ffc9c9","orange-strong":"#ffd8a8","yellow-strong":"#ffec99","green-strong":"#b2f2bb","blue-strong":"#a5d8ff","purple-strong":"#d0bfff"}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.extractHeadings=function extractHeadings(e){const n=[];if(!e||!Array.isArray(e.content))return n;const walk=e=>{if("codeBlock"!==e.type){if("heading"===e.type){const r=Number(e.attrs?.level??1),o=plainTextOf(e).trim();return void(o&&n.push({level:t.has(r)?r:1,text:o,order:n.length}))}for(const t of e.content??[])walk(t)}};for(const t of e.content)walk(t);return n};const t=new Set([1,2,3,4,5,6]);function plainTextOf(t){if("string"==typeof t.text&&t.text)return t.text;let e="";for(const n of t.content??[])e+=plainTextOf(n);return e}
@@ -1 +1 @@
1
- "use strict";function normalizeVideoEmbed(e){if(!e||"object"!=typeof e)return null;const r=e,t="youtube"===r.provider?"string"==typeof r.videoId&&/^[\w-]{11}$/.test(r.videoId):"bilibili"===r.provider&&"string"==typeof r.videoId&&/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15})$/.test(r.videoId),i=r.page??1,o=r.startSeconds??0;return!t||!Number.isInteger(i)||Number(i)<1||Number(i)>1e3||!Number.isInteger(o)||Number(o)<0||Number(o)>604800?null:{provider:r.provider,videoId:r.videoId,page:"youtube"===r.provider?1:Number(i),startSeconds:Number(o)}}function seconds(e){if(!e)return 0;if(/^\d+$/.test(e))return Number(e);const r=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);return r&&r[0]?3600*Number(r[1]??0)+60*Number(r[2]??0)+Number(r[3]??0):NaN}Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeVideoEmbed=normalizeVideoEmbed,exports.parseVideoUrl=function parseVideoUrl(e){let r;try{r=new URL(e.trim())}catch{return null}if(!["https:","http:"].includes(r.protocol)||r.username||r.password||r.port)return null;const t=r.hostname.toLowerCase(),i=r.pathname.split("/").filter(Boolean);let o,s;if("youtu.be"===t)o="youtube",s=1===i.length?i[0]:null;else if(["youtube.com","www.youtube.com","m.youtube.com","www.youtube-nocookie.com"].includes(t))o="youtube",s="/watch"===r.pathname?r.searchParams.get("v"):["embed","shorts","live"].includes(i[0])&&2===i.length?i[1]:null;else if(["bilibili.com","www.bilibili.com","m.bilibili.com"].includes(t))o="bilibili",s="video"===i[0]&&2===i.length?i[1]:null;else{if("player.bilibili.com"!==t||"/player.html"!==r.pathname)return null;o="bilibili",s=r.searchParams.get("bvid")??(r.searchParams.get("aid")?`av${r.searchParams.get("aid")}`:null)}const a=/^#t=(.*)$/.exec(r.hash)?.[1]??null;return normalizeVideoEmbed({provider:o,videoId:s,page:Number(r.searchParams.get("p")??1),startSeconds:seconds(r.searchParams.get("start")??r.searchParams.get("t")??a)})},exports.videoSourceUrl=function videoSourceUrl(e){const r=normalizeVideoEmbed(e);if(!r)return"";const t=new URL("youtube"===r.provider?`https://www.youtube.com/watch?v=${r.videoId}`:`https://www.bilibili.com/video/${r.videoId}`);return"bilibili"===r.provider&&r.page>1&&t.searchParams.set("p",String(r.page)),r.startSeconds&&t.searchParams.set("t",String(r.startSeconds)),t.href},exports.videoPlayerUrl=function videoPlayerUrl(e){const r=normalizeVideoEmbed(e);if(!r)return"";const t=new URL("youtube"===r.provider?`https://www.youtube.com/embed/${r.videoId}`:"https://player.bilibili.com/player.html");return t.searchParams.set("autoplay","0"),"youtube"===r.provider?(t.searchParams.set("playsinline","1"),r.startSeconds&&t.searchParams.set("start",String(r.startSeconds))):(t.searchParams.set(r.videoId.startsWith("BV")?"bvid":"aid",r.videoId.startsWith("BV")?r.videoId:r.videoId.slice(2)),t.searchParams.set("p",String(r.page)),t.searchParams.set("t",String(r.startSeconds)),t.searchParams.set("danmaku","0")),t.href};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VIDEO_PROVIDER_LABELS=void 0,exports.normalizeVideoEmbed=normalizeVideoEmbed,exports.inspectVideoUrl=inspectVideoUrl,exports.parseVideoUrl=function parseVideoUrl(e){return inspectVideoUrl(e).data},exports.videoSourceUrl=function videoSourceUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const{provider:r,videoId:i}=t,s=new URL("youtube"===r?`https://www.youtube.com/watch?v=${i}`:"bilibili"===r?i.startsWith("ep")||i.startsWith("ss")?`https://www.bilibili.com/bangumi/play/${i}`:`https://www.bilibili.com/video/${i}`:"vimeo"===r?`https://vimeo.com/${i}`:"youku"===r?`https://v.youku.com/v_show/id_${i}.html`:"tencent"===r?`https://v.qq.com/x/page/${i}.html`:`https://www.acfun.cn/v/${i}`);return"bilibili"===r&&t.page>1&&s.searchParams.set("p",String(t.page)),t.startSeconds&&"vimeo"!==r&&s.searchParams.set("t",String(t.startSeconds)),s.href},exports.videoPlayerUrl=function videoPlayerUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const{provider:r,videoId:i}=t;if("youtube"===r){const e=new URL(`https://www.youtube.com/embed/${i}`);return e.searchParams.set("autoplay","0"),e.searchParams.set("playsinline","1"),t.startSeconds&&e.searchParams.set("start",String(t.startSeconds)),e.href}if("vimeo"===r){const e=new URL(`https://player.vimeo.com/video/${i}`);return e.searchParams.set("autoplay","0"),e.href}if("youku"===r){const e=new URL(`https://player.youku.com/embed/${i}`);return e.searchParams.set("autoplay","0"),e.href}if("tencent"===r){const e=new URL("https://v.qq.com/txp/iframe/player.html");return e.searchParams.set("vid",i),e.searchParams.set("autoplay","false"),e.href}if("acfun"===r)return`https://www.acfun.cn/player/${i}`;const s=new URL("https://player.bilibili.com/player.html");return s.searchParams.set("autoplay","0"),i.startsWith("ep")||i.startsWith("ss")?s.searchParams.set(i.startsWith("ep")?"episodeId":"seasonId",i.slice(2)):(s.searchParams.set(i.startsWith("BV")?"bvid":"aid",i.startsWith("BV")?i:i.slice(2)),s.searchParams.set("p",String(t.page)),s.searchParams.set("t",String(t.startSeconds)),s.searchParams.set("danmaku","0")),s.href},exports.VIDEO_PROVIDER_LABELS={youtube:"YouTube",bilibili:"bilibili",vimeo:"Vimeo",youku:"ไผ˜้…ท",tencent:"่…พ่ฎฏ่ง†้ข‘",acfun:"AcFun"};const e={youtube:/^[\w-]{11}$/,bilibili:/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15}|ep\d{1,12}|ss\d{1,12})$/,vimeo:/^[1-9]\d{0,11}$/,youku:/^[A-Za-z0-9=_+-]{6,44}$/,tencent:/^[A-Za-z0-9]{8,24}$/,acfun:/^ac\d{1,12}$/};function normalizeVideoEmbed(t){if(!t||"object"!=typeof t)return null;const r=t,i=function isProvider(t){return"string"==typeof t&&Object.hasOwn(e,t)}(r.provider)&&"string"==typeof r.videoId&&e[r.provider].test(r.videoId),s=r.page??1,a=r.startSeconds??0;return!i||!Number.isInteger(s)||Number(s)<1||Number(s)>1e3||!Number.isInteger(a)||Number(a)<0||Number(a)>604800?null:{provider:r.provider,videoId:r.videoId,page:"bilibili"===r.provider?Number(s):1,startSeconds:Number(a)}}const t=["bilibili.com","www.bilibili.com","m.bilibili.com","bangumi.bilibili.com"],r=/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15}|ep\d{1,12}|ss\d{1,12})$/,i=["youtube.com","www.youtube.com","m.youtube.com","www.youtube-nocookie.com","youtube-nocookie.com"];function seconds(e){if(!e)return 0;if(/^\d+$/.test(e))return Number(e);const t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);return t&&t[0]?3600*Number(t[1]??0)+60*Number(t[2]??0)+Number(t[3]??0):NaN}function inspectVideoUrl(e){const s=e.trim();if(!s)return{data:null,issue:"empty"};let a;try{a=new URL(s)}catch{return{data:null,issue:"invalid"}}if(!["https:","http:"].includes(a.protocol)||a.username||a.password||a.port)return{data:null,issue:"invalid"};const o=a.hostname.toLowerCase(),n=a.pathname.split("/").filter(Boolean);let u,c;if("youtu.be"===o||i.includes(o))u="youtube",c=function parseYouTube(e,t,r){return"youtu.be"===e?1===r.length?r[0]:null:"/watch"===t.pathname?t.searchParams.get("v"):["embed","shorts","live","v"].includes(r[0])&&2===r.length?r[1]:null}(o,a,n);else if(t.includes(o)||"player.bilibili.com"===o)u="bilibili",c=function parseBilibili(e,t,i){return"player.bilibili.com"===e?"/player.html"!==t.pathname?null:t.searchParams.get("bvid")??(t.searchParams.get("aid")?`av${t.searchParams.get("aid")}`:null):i.find(e=>r.test(e))??null}(o,a,n);else{if("b23.tv"===o)return{data:null,issue:"short-link"};if("vimeo.com"===o||"www.vimeo.com"===o||"player.vimeo.com"===o)u="vimeo",c=function parseVimeo(e,t){if("player.vimeo.com"===e)return"video"===t[0]?t[1]??null:null;const r=t.at(-1)??"";return/^\d+$/.test(r)?r:null}(o,n);else if("v.youku.com"===o||"m.youku.com"===o||"player.youku.com"===o)u="youku",c=function parseYouku(e,t,r){if("player.youku.com"===e)return"embed"===r[0]?r[1]:null;const i=r.find(e=>/^id_.+\.html$/.test(e));return i?i.slice(3,-5):t.searchParams.get("vid")}(o,a,n);else if(["v.qq.com","m.v.qq.com","www.v.qq.com"].includes(o))u="tencent",c=function parseTencent(e,t,r){const i=t.searchParams.get("vid")??t.searchParams.get("video_id");if(i)return i;const s=(r.at(-1)??"").replace(/\.html?$/,"");return/^[A-Za-z0-9]{8,24}$/.test(s)?s:null}(0,a,n);else{if("acfun.cn"!==o&&"www.acfun.cn"!==o&&"m.acfun.cn"!==o)return{data:null,issue:"unsupported"};u="acfun",c=function parseAcfun(e,t){const r=e.find(e=>/^ac\d{1,12}$/.test(e));if(r)return r;const i=t.searchParams.get("ac");if(i&&/^\d{1,12}$/.test(i))return`ac${i}`;const s=e.join("/").match(/(^|[/_])ac(\d{1,12})/)?.[2];return s?`ac${s}`:null}(n,a)}}if(!c)return{data:null,issue:"missing-id"};const l=/^#t=(.*)$/.exec(a.hash)?.[1]??null,m=normalizeVideoEmbed({provider:u,videoId:c,page:Number(a.searchParams.get("p")??1),startSeconds:seconds(a.searchParams.get("start")??a.searchParams.get("t")??l)});return{data:m,issue:m?null:"invalid"}}
@@ -1 +1 @@
1
- export*from"./schema.js";export*from"./shared/node-catalog.js";export*from"./shared/doc-text.js";
1
+ export*from"./schema.js";export*from"./shared/node-catalog.js";export*from"./shared/doc-text.js";export*from"./shared/headings.js";
@@ -1 +1 @@
1
- export const CALLOUT_TONES=["info","success","warning","danger"];export const CALLOUT_ICONS=["๐Ÿ’ก","โ„น๏ธ","โœ…","โš ๏ธ","โ—","๐Ÿ“Œ","๐ŸŽฏ","๐Ÿ’ฌ","๐Ÿ“–","๐Ÿ“","๐Ÿš€","๐Ÿ””","๐Ÿ”Ž","โญ","๐ŸŒ…","๐Ÿ› ๏ธ","๐Ÿ“…","๐Ÿ”’","โค๏ธ","๐ŸŽ‰","โ“","๐Ÿ“Ž","๐Ÿ","๐Ÿ”ฅ"];export const CALLOUT_COLORS=["gray","red","orange","yellow","green","blue","purple"];export const CALLOUT_FILLS=[...CALLOUT_COLORS,...CALLOUT_COLORS.map(o=>`${o}-strong`)];export function validCalloutAttrs(o){if(!o||"object"!=typeof o||Array.isArray(o))return!1;const r=o,valid=(o,t)=>void 0===r[o]||null===r[o]||"string"==typeof r[o]&&t.includes(r[o]);return valid("tone",CALLOUT_TONES)&&valid("icon",["",...CALLOUT_ICONS])&&valid("textColor",CALLOUT_COLORS)&&valid("borderColor",["none",...CALLOUT_COLORS])&&valid("backgroundColor",["none",...CALLOUT_FILLS])}export function effectiveCallout(o={}){const r=CALLOUT_TONES.includes(o.tone)?o.tone:"info",t={info:"blue",success:"green",warning:"orange",danger:"red"}[r];return{tone:r,icon:null===o.icon||void 0===o.icon?{info:"๐Ÿ’ก",success:"โœ…",warning:"โš ๏ธ",danger:"โ—"}[r]:["",...CALLOUT_ICONS].includes(o.icon)?o.icon:"๐Ÿ’ก",textColor:CALLOUT_COLORS.includes(o.textColor)?o.textColor:null,borderColor:["none",...CALLOUT_COLORS].includes(o.borderColor)?o.borderColor:t,backgroundColor:["none",...CALLOUT_FILLS].includes(o.backgroundColor)?o.backgroundColor:t}}export function calloutDOMAttributes(o={}){const r=effectiveCallout(o);return{"data-callout":"true","data-tone":r.tone,"data-callout-icon":o.icon??"default",...Object.fromEntries(["textColor","borderColor","backgroundColor"].filter(r=>null!=o[r]).map(r=>[`data-callout-${r.toLowerCase()}`,String(o[r])])),...""===r.icon?{"data-icon-hidden":"true"}:{},style:["--callout-border:"+("none"===r.borderColor?"transparent":`var(--callout-border-${r.borderColor})`),"--callout-fill:"+("none"===r.backgroundColor?"transparent":`var(--doc-highlight-${"gray"===r.backgroundColor?"gray-soft":r.backgroundColor})`),"--callout-text:"+(r.textColor?`var(--doc-text-${r.textColor})`:"var(--content-text-color, var(--color-text))")].join(";")}}export function calloutMetadata(o){if(!validCalloutAttrs(o))return"";const r=Object.fromEntries(["icon","textColor","borderColor","backgroundColor"].filter(r=>void 0!==o[r]&&null!==o[r]).map(r=>[r,o[r]]));return Object.keys(r).length?` \x3c!--ywiki-callout:${encodeURIComponent(JSON.stringify(r))}--\x3e`:""}export function readCalloutMetadata(o){const r=/^\s*<!--ywiki-callout:([^\s<>]{1,4096})-->\s*/.exec(o);if(!r)return null;try{const o=JSON.parse(decodeURIComponent(r[1]));return!validCalloutAttrs(o)||Object.keys(o).some(o=>!["icon","textColor","borderColor","backgroundColor"].includes(o))?null:{attrs:o,length:r[0].length}}catch{return null}}
1
+ export const CALLOUT_TONES=["info","success","warning","danger"];export const CALLOUT_ICONS=["๐Ÿ’ก","โ„น๏ธ","โœ…","โš ๏ธ","โ—","๐Ÿ“Œ","๐ŸŽฏ","๐Ÿ’ฌ","๐Ÿ“–","๐Ÿ“","๐Ÿš€","๐Ÿ””","๐Ÿ”Ž","โญ","๐ŸŒ…","๐Ÿ› ๏ธ","๐Ÿ“…","๐Ÿ”’","โค๏ธ","๐ŸŽ‰","โ“","๐Ÿ“Ž","๐Ÿ","๐Ÿ”ฅ"];export const CALLOUT_COLORS=["gray","red","orange","yellow","green","blue","purple"];export const CALLOUT_FILLS=[...CALLOUT_COLORS,...CALLOUT_COLORS.map(o=>`${o}-strong`)];export const CALLOUT_SWATCH_FALLBACKS={textColor:{gray:"#646a73",red:"#d92c2c",orange:"#b95d0b",yellow:"#8a6c0a",green:"#237b35",blue:"#1971c2",purple:"#7048e8"},borderColor:{gray:"#c7cbd1",red:"#f0a2a2",orange:"#ffc078",yellow:"#e3ca71",green:"#91d4a0",blue:"#9ac5ef",purple:"#c0a4ed"},backgroundColor:{gray:"#f1f3f5",red:"#ffe3e3",orange:"#fff0db",yellow:"#fff3bf",green:"#d3f9d8",blue:"#d0ebff",purple:"#e5dbff","gray-strong":"#ced4da","red-strong":"#ffc9c9","orange-strong":"#ffd8a8","yellow-strong":"#ffec99","green-strong":"#b2f2bb","blue-strong":"#a5d8ff","purple-strong":"#d0bfff"}};export function calloutColorToken(o,r){return"textColor"===o?`--doc-text-${r}`:"borderColor"===o?`--callout-border-${r}`:`--doc-highlight-${"gray"===r?"gray-soft":r}`}export function calloutSwatchStyle(o,r){if(null===r||"none"===r)return{};const e=CALLOUT_SWATCH_FALLBACKS[o][r],t=e?`var(${calloutColorToken(o,r)}, ${e})`:`var(${calloutColorToken(o,r)})`;return"textColor"===o?{color:t}:{backgroundColor:t}}export function validCalloutAttrs(o){if(!o||"object"!=typeof o||Array.isArray(o))return!1;const r=o,valid=(o,e)=>void 0===r[o]||null===r[o]||"string"==typeof r[o]&&e.includes(r[o]);return valid("tone",CALLOUT_TONES)&&valid("icon",["",...CALLOUT_ICONS])&&valid("textColor",CALLOUT_COLORS)&&valid("borderColor",["none",...CALLOUT_COLORS])&&valid("backgroundColor",["none",...CALLOUT_FILLS])}export function effectiveCallout(o={}){const r=CALLOUT_TONES.includes(o.tone)?o.tone:"info",e={info:"blue",success:"green",warning:"orange",danger:"red"}[r];return{tone:r,icon:null===o.icon||void 0===o.icon?{info:"๐Ÿ’ก",success:"โœ…",warning:"โš ๏ธ",danger:"โ—"}[r]:["",...CALLOUT_ICONS].includes(o.icon)?o.icon:"๐Ÿ’ก",textColor:CALLOUT_COLORS.includes(o.textColor)?o.textColor:null,borderColor:["none",...CALLOUT_COLORS].includes(o.borderColor)?o.borderColor:e,backgroundColor:["none",...CALLOUT_FILLS].includes(o.backgroundColor)?o.backgroundColor:e}}export function calloutDOMAttributes(o={}){const r=effectiveCallout(o),token=(o,r)=>`var(${o}, ${r})`,e="none"===r.borderColor?"transparent":token(calloutColorToken("borderColor",r.borderColor),CALLOUT_SWATCH_FALLBACKS.borderColor[r.borderColor]??"#9ac5ef"),t="none"===r.backgroundColor?"transparent":token(calloutColorToken("backgroundColor",r.backgroundColor),CALLOUT_SWATCH_FALLBACKS.backgroundColor[r.backgroundColor]??"#d0ebff"),l=r.textColor?token(calloutColorToken("textColor",r.textColor),CALLOUT_SWATCH_FALLBACKS.textColor[r.textColor]??"#1f2937"):"var(--content-text-color, var(--color-text))";return{"data-callout":"true","data-tone":r.tone,"data-callout-icon":o.icon??"default",...Object.fromEntries(["textColor","borderColor","backgroundColor"].filter(r=>null!=o[r]).map(r=>[`data-callout-${r.toLowerCase()}`,String(o[r])])),...""===r.icon?{"data-icon-hidden":"true"}:{},style:[`--callout-border:${e}`,`--callout-fill:${t}`,`--callout-text:${l}`].join(";")}}export function calloutMetadata(o){if(!validCalloutAttrs(o))return"";const r=Object.fromEntries(["icon","textColor","borderColor","backgroundColor"].filter(r=>void 0!==o[r]&&null!==o[r]).map(r=>[r,o[r]]));return Object.keys(r).length?` \x3c!--ywiki-callout:${encodeURIComponent(JSON.stringify(r))}--\x3e`:""}export function readCalloutMetadata(o){const r=/^\s*<!--ywiki-callout:([^\s<>]{1,4096})-->\s*/.exec(o);if(!r)return null;try{const o=JSON.parse(decodeURIComponent(r[1]));return!validCalloutAttrs(o)||Object.keys(o).some(o=>!["icon","textColor","borderColor","backgroundColor"].includes(o))?null:{attrs:o,length:r[0].length}}catch{return null}}
@@ -0,0 +1 @@
1
+ const t=new Set([1,2,3,4,5,6]);export function extractHeadings(e){const n=[];if(!e||!Array.isArray(e.content))return n;const walk=e=>{if("codeBlock"!==e.type){if("heading"===e.type){const o=Number(e.attrs?.level??1),r=plainTextOf(e).trim();return void(r&&n.push({level:t.has(o)?o:1,text:r,order:n.length}))}for(const t of e.content??[])walk(t)}};for(const t of e.content)walk(t);return n}function plainTextOf(t){if("string"==typeof t.text&&t.text)return t.text;let e="";for(const n of t.content??[])e+=plainTextOf(n);return e}
@@ -1 +1 @@
1
- export function normalizeVideoEmbed(e){if(!e||"object"!=typeof e)return null;const t=e,r="youtube"===t.provider?"string"==typeof t.videoId&&/^[\w-]{11}$/.test(t.videoId):"bilibili"===t.provider&&"string"==typeof t.videoId&&/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15})$/.test(t.videoId),i=t.page??1,o=t.startSeconds??0;return!r||!Number.isInteger(i)||Number(i)<1||Number(i)>1e3||!Number.isInteger(o)||Number(o)<0||Number(o)>604800?null:{provider:t.provider,videoId:t.videoId,page:"youtube"===t.provider?1:Number(i),startSeconds:Number(o)}}function seconds(e){if(!e)return 0;if(/^\d+$/.test(e))return Number(e);const t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);return t&&t[0]?3600*Number(t[1]??0)+60*Number(t[2]??0)+Number(t[3]??0):NaN}export function parseVideoUrl(e){let t;try{t=new URL(e.trim())}catch{return null}if(!["https:","http:"].includes(t.protocol)||t.username||t.password||t.port)return null;const r=t.hostname.toLowerCase(),i=t.pathname.split("/").filter(Boolean);let o,s;if("youtu.be"===r)o="youtube",s=1===i.length?i[0]:null;else if(["youtube.com","www.youtube.com","m.youtube.com","www.youtube-nocookie.com"].includes(r))o="youtube",s="/watch"===t.pathname?t.searchParams.get("v"):["embed","shorts","live"].includes(i[0])&&2===i.length?i[1]:null;else if(["bilibili.com","www.bilibili.com","m.bilibili.com"].includes(r))o="bilibili",s="video"===i[0]&&2===i.length?i[1]:null;else{if("player.bilibili.com"!==r||"/player.html"!==t.pathname)return null;o="bilibili",s=t.searchParams.get("bvid")??(t.searchParams.get("aid")?`av${t.searchParams.get("aid")}`:null)}const a=/^#t=(.*)$/.exec(t.hash)?.[1]??null;return normalizeVideoEmbed({provider:o,videoId:s,page:Number(t.searchParams.get("p")??1),startSeconds:seconds(t.searchParams.get("start")??t.searchParams.get("t")??a)})}export function videoSourceUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const r=new URL("youtube"===t.provider?`https://www.youtube.com/watch?v=${t.videoId}`:`https://www.bilibili.com/video/${t.videoId}`);return"bilibili"===t.provider&&t.page>1&&r.searchParams.set("p",String(t.page)),t.startSeconds&&r.searchParams.set("t",String(t.startSeconds)),r.href}export function videoPlayerUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const r=new URL("youtube"===t.provider?`https://www.youtube.com/embed/${t.videoId}`:"https://player.bilibili.com/player.html");return r.searchParams.set("autoplay","0"),"youtube"===t.provider?(r.searchParams.set("playsinline","1"),t.startSeconds&&r.searchParams.set("start",String(t.startSeconds))):(r.searchParams.set(t.videoId.startsWith("BV")?"bvid":"aid",t.videoId.startsWith("BV")?t.videoId:t.videoId.slice(2)),r.searchParams.set("p",String(t.page)),r.searchParams.set("t",String(t.startSeconds)),r.searchParams.set("danmaku","0")),r.href}
1
+ export const VIDEO_PROVIDER_LABELS={youtube:"YouTube",bilibili:"bilibili",vimeo:"Vimeo",youku:"ไผ˜้…ท",tencent:"่…พ่ฎฏ่ง†้ข‘",acfun:"AcFun"};const e={youtube:/^[\w-]{11}$/,bilibili:/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15}|ep\d{1,12}|ss\d{1,12})$/,vimeo:/^[1-9]\d{0,11}$/,youku:/^[A-Za-z0-9=_+-]{6,44}$/,tencent:/^[A-Za-z0-9]{8,24}$/,acfun:/^ac\d{1,12}$/};export function normalizeVideoEmbed(t){if(!t||"object"!=typeof t)return null;const r=t,i=function isProvider(t){return"string"==typeof t&&Object.hasOwn(e,t)}(r.provider)&&"string"==typeof r.videoId&&e[r.provider].test(r.videoId),s=r.page??1,a=r.startSeconds??0;return!i||!Number.isInteger(s)||Number(s)<1||Number(s)>1e3||!Number.isInteger(a)||Number(a)<0||Number(a)>604800?null:{provider:r.provider,videoId:r.videoId,page:"bilibili"===r.provider?Number(s):1,startSeconds:Number(a)}}const t=["bilibili.com","www.bilibili.com","m.bilibili.com","bangumi.bilibili.com"],r=/^(BV[A-Za-z0-9]{10}|av[1-9]\d{0,15}|ep\d{1,12}|ss\d{1,12})$/,i=["youtube.com","www.youtube.com","m.youtube.com","www.youtube-nocookie.com","youtube-nocookie.com"];function seconds(e){if(!e)return 0;if(/^\d+$/.test(e))return Number(e);const t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);return t&&t[0]?3600*Number(t[1]??0)+60*Number(t[2]??0)+Number(t[3]??0):NaN}export function inspectVideoUrl(e){const s=e.trim();if(!s)return{data:null,issue:"empty"};let a;try{a=new URL(s)}catch{return{data:null,issue:"invalid"}}if(!["https:","http:"].includes(a.protocol)||a.username||a.password||a.port)return{data:null,issue:"invalid"};const n=a.hostname.toLowerCase(),o=a.pathname.split("/").filter(Boolean);let u,c;if("youtu.be"===n||i.includes(n))u="youtube",c=function parseYouTube(e,t,r){return"youtu.be"===e?1===r.length?r[0]:null:"/watch"===t.pathname?t.searchParams.get("v"):["embed","shorts","live","v"].includes(r[0])&&2===r.length?r[1]:null}(n,a,o);else if(t.includes(n)||"player.bilibili.com"===n)u="bilibili",c=function parseBilibili(e,t,i){return"player.bilibili.com"===e?"/player.html"!==t.pathname?null:t.searchParams.get("bvid")??(t.searchParams.get("aid")?`av${t.searchParams.get("aid")}`:null):i.find(e=>r.test(e))??null}(n,a,o);else{if("b23.tv"===n)return{data:null,issue:"short-link"};if("vimeo.com"===n||"www.vimeo.com"===n||"player.vimeo.com"===n)u="vimeo",c=function parseVimeo(e,t){if("player.vimeo.com"===e)return"video"===t[0]?t[1]??null:null;const r=t.at(-1)??"";return/^\d+$/.test(r)?r:null}(n,o);else if("v.youku.com"===n||"m.youku.com"===n||"player.youku.com"===n)u="youku",c=function parseYouku(e,t,r){if("player.youku.com"===e)return"embed"===r[0]?r[1]:null;const i=r.find(e=>/^id_.+\.html$/.test(e));return i?i.slice(3,-5):t.searchParams.get("vid")}(n,a,o);else if(["v.qq.com","m.v.qq.com","www.v.qq.com"].includes(n))u="tencent",c=function parseTencent(e,t,r){const i=t.searchParams.get("vid")??t.searchParams.get("video_id");if(i)return i;const s=(r.at(-1)??"").replace(/\.html?$/,"");return/^[A-Za-z0-9]{8,24}$/.test(s)?s:null}(0,a,o);else{if("acfun.cn"!==n&&"www.acfun.cn"!==n&&"m.acfun.cn"!==n)return{data:null,issue:"unsupported"};u="acfun",c=function parseAcfun(e,t){const r=e.find(e=>/^ac\d{1,12}$/.test(e));if(r)return r;const i=t.searchParams.get("ac");if(i&&/^\d{1,12}$/.test(i))return`ac${i}`;const s=e.join("/").match(/(^|[/_])ac(\d{1,12})/)?.[2];return s?`ac${s}`:null}(o,a)}}if(!c)return{data:null,issue:"missing-id"};const l=/^#t=(.*)$/.exec(a.hash)?.[1]??null,m=normalizeVideoEmbed({provider:u,videoId:c,page:Number(a.searchParams.get("p")??1),startSeconds:seconds(a.searchParams.get("start")??a.searchParams.get("t")??l)});return{data:m,issue:m?null:"invalid"}}export function parseVideoUrl(e){return inspectVideoUrl(e).data}export function videoSourceUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const{provider:r,videoId:i}=t,s=new URL("youtube"===r?`https://www.youtube.com/watch?v=${i}`:"bilibili"===r?i.startsWith("ep")||i.startsWith("ss")?`https://www.bilibili.com/bangumi/play/${i}`:`https://www.bilibili.com/video/${i}`:"vimeo"===r?`https://vimeo.com/${i}`:"youku"===r?`https://v.youku.com/v_show/id_${i}.html`:"tencent"===r?`https://v.qq.com/x/page/${i}.html`:`https://www.acfun.cn/v/${i}`);return"bilibili"===r&&t.page>1&&s.searchParams.set("p",String(t.page)),t.startSeconds&&"vimeo"!==r&&s.searchParams.set("t",String(t.startSeconds)),s.href}export function videoPlayerUrl(e){const t=normalizeVideoEmbed(e);if(!t)return"";const{provider:r,videoId:i}=t;if("youtube"===r){const e=new URL(`https://www.youtube.com/embed/${i}`);return e.searchParams.set("autoplay","0"),e.searchParams.set("playsinline","1"),t.startSeconds&&e.searchParams.set("start",String(t.startSeconds)),e.href}if("vimeo"===r){const e=new URL(`https://player.vimeo.com/video/${i}`);return e.searchParams.set("autoplay","0"),e.href}if("youku"===r){const e=new URL(`https://player.youku.com/embed/${i}`);return e.searchParams.set("autoplay","0"),e.href}if("tencent"===r){const e=new URL("https://v.qq.com/txp/iframe/player.html");return e.searchParams.set("vid",i),e.searchParams.set("autoplay","false"),e.href}if("acfun"===r)return`https://www.acfun.cn/player/${i}`;const s=new URL("https://player.bilibili.com/player.html");return s.searchParams.set("autoplay","0"),i.startsWith("ep")||i.startsWith("ss")?s.searchParams.set(i.startsWith("ep")?"episodeId":"seasonId",i.slice(2)):(s.searchParams.set(i.startsWith("BV")?"bvid":"aid",i.startsWith("BV")?i:i.slice(2)),s.searchParams.set("p",String(t.page)),s.searchParams.set("t",String(t.startSeconds)),s.searchParams.set("danmaku","0")),s.href}
@@ -2,3 +2,4 @@ export type { ProseMirrorNode, ProseMirrorDoc } from './shared/types.js';
2
2
  export * from './schema.js';
3
3
  export * from './shared/node-catalog.js';
4
4
  export * from './shared/doc-text.js';
5
+ export * from './shared/headings.js';
@@ -2,6 +2,45 @@ export declare const CALLOUT_TONES: readonly ["info", "success", "warning", "dan
2
2
  export declare const CALLOUT_ICONS: readonly ["๐Ÿ’ก", "โ„น๏ธ", "โœ…", "โš ๏ธ", "โ—", "๐Ÿ“Œ", "๐ŸŽฏ", "๐Ÿ’ฌ", "๐Ÿ“–", "๐Ÿ“", "๐Ÿš€", "๐Ÿ””", "๐Ÿ”Ž", "โญ", "๐ŸŒ…", "๐Ÿ› ๏ธ", "๐Ÿ“…", "๐Ÿ”’", "โค๏ธ", "๐ŸŽ‰", "โ“", "๐Ÿ“Ž", "๐Ÿ", "๐Ÿ”ฅ"];
3
3
  export declare const CALLOUT_COLORS: readonly ["gray", "red", "orange", "yellow", "green", "blue", "purple"];
4
4
  export declare const CALLOUT_FILLS: readonly ["gray", "red", "orange", "yellow", "green", "blue", "purple", ...string[]];
5
+ export declare const CALLOUT_SWATCH_FALLBACKS: {
6
+ readonly textColor: {
7
+ readonly gray: "#646a73";
8
+ readonly red: "#d92c2c";
9
+ readonly orange: "#b95d0b";
10
+ readonly yellow: "#8a6c0a";
11
+ readonly green: "#237b35";
12
+ readonly blue: "#1971c2";
13
+ readonly purple: "#7048e8";
14
+ };
15
+ readonly borderColor: {
16
+ readonly gray: "#c7cbd1";
17
+ readonly red: "#f0a2a2";
18
+ readonly orange: "#ffc078";
19
+ readonly yellow: "#e3ca71";
20
+ readonly green: "#91d4a0";
21
+ readonly blue: "#9ac5ef";
22
+ readonly purple: "#c0a4ed";
23
+ };
24
+ readonly backgroundColor: {
25
+ readonly gray: "#f1f3f5";
26
+ readonly red: "#ffe3e3";
27
+ readonly orange: "#fff0db";
28
+ readonly yellow: "#fff3bf";
29
+ readonly green: "#d3f9d8";
30
+ readonly blue: "#d0ebff";
31
+ readonly purple: "#e5dbff";
32
+ readonly 'gray-strong': "#ced4da";
33
+ readonly 'red-strong': "#ffc9c9";
34
+ readonly 'orange-strong': "#ffd8a8";
35
+ readonly 'yellow-strong': "#ffec99";
36
+ readonly 'green-strong': "#b2f2bb";
37
+ readonly 'blue-strong': "#a5d8ff";
38
+ readonly 'purple-strong': "#d0bfff";
39
+ };
40
+ };
41
+ export type CalloutSwatchKey = keyof typeof CALLOUT_SWATCH_FALLBACKS;
42
+ export declare function calloutColorToken(key: CalloutSwatchKey, value: string): string;
43
+ export declare function calloutSwatchStyle(key: CalloutSwatchKey, value: string | null): Record<string, string>;
5
44
  export interface CalloutAttrs {
6
45
  tone?: string | null;
7
46
  icon?: string | null;
@@ -0,0 +1,7 @@
1
+ import type { ProseMirrorNode } from './types.js';
2
+ export interface DocumentHeading {
3
+ level: number;
4
+ text: string;
5
+ order: number;
6
+ }
7
+ export declare function extractHeadings(doc: ProseMirrorNode | null | undefined): DocumentHeading[];
@@ -1,10 +1,18 @@
1
+ export type VideoProvider = 'youtube' | 'bilibili' | 'vimeo' | 'youku' | 'tencent' | 'acfun';
1
2
  export interface VideoEmbedData {
2
- provider: 'youtube' | 'bilibili';
3
+ provider: VideoProvider;
3
4
  videoId: string;
4
5
  page: number;
5
6
  startSeconds: number;
6
7
  }
8
+ export declare const VIDEO_PROVIDER_LABELS: Record<VideoProvider, string>;
7
9
  export declare function normalizeVideoEmbed(raw: unknown): VideoEmbedData | null;
10
+ export type VideoUrlIssue = 'empty' | 'invalid' | 'unsupported' | 'short-link' | 'missing-id';
11
+ export interface VideoUrlInspection {
12
+ data: VideoEmbedData | null;
13
+ issue: VideoUrlIssue | null;
14
+ }
15
+ export declare function inspectVideoUrl(value: string): VideoUrlInspection;
8
16
  export declare function parseVideoUrl(value: string): VideoEmbedData | null;
9
17
  export declare function videoSourceUrl(data: VideoEmbedData): string;
10
18
  export declare function videoPlayerUrl(data: VideoEmbedData): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wendang",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "ๆ–‡ๆกฃใ€ๅทฅไฝœ่กจๅ’Œๆ€็ปดๅฏผๅ›พ็š„ๅ†…ๅฎนๅ่ฎฎไธŽๆ ก้ชŒๆ ธๅฟƒใ€‚",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -74,6 +74,11 @@
74
74
  "engines": {
75
75
  "node": ">=20.19"
76
76
  },
77
+ "scripts": {
78
+ "build": "node ../../scripts/build-core.mjs",
79
+ "dev": "node ../../scripts/build-core.mjs --watch",
80
+ "typecheck": "tsc --noEmit"
81
+ },
77
82
  "publishConfig": {
78
83
  "access": "public",
79
84
  "registry": "https://registry.npmjs.org/"
@@ -87,10 +92,5 @@
87
92
  "homepage": "https://doc.yjmf.com",
88
93
  "bugs": {
89
94
  "url": "https://gitee.com/ztes/wendang/issues"
90
- },
91
- "scripts": {
92
- "build": "node ../../scripts/build-core.mjs",
93
- "dev": "node ../../scripts/build-core.mjs --watch",
94
- "typecheck": "tsc --noEmit"
95
95
  }
96
- }
96
+ }