@publier/shell 4.7.0 → 4.7.1
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.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,t as n}from"./integration-
|
|
1
|
+
import{a as e,i as t,t as n}from"./integration-BTmCC0U-.mjs";export{t as HASHED_ASSET_RE,n as docsShell,e as publierCacheControl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{remarkAsides as e,remarkDirectivesRestoration as t}from"./plugins/remark-asides.mjs";import n from"./plugins/remark-snippets.mjs";import r from"./plugins/remark-vars.mjs";import{CODE_GROUP_SYNC_SCRIPT as i}from"./runtime/code-group-sync.mjs";import{TABS_SYNC_SCRIPT as a}from"./runtime/tabs-sync.mjs";import{publierCssPlugin as o,publierThemeCssPlugin as s}from"./tailwind/css-plugin.mjs";import{createRequire as c}from"node:module";import{configResolveShellConfig as l,contentGenerateLlmsTxt as u,generateAnalyticsScripts as d,shellAnnouncementBannerScript as f,shellBuildHeaders as p,shellBuildLicenseErrorMessage as ee,shellCacheControl as m,shellCollectTailwindClassTokens as h,shellComposeTailwindEntry as g,shellLazyUpgradeScript as _,shellOpenInAiScript as
|
|
2
|
-
`)}]);let i=e.properties.dataLanguage;typeof i==`string`&&(t.properties.className=[`language-${i}`])}}for(let i of e.children)i.type===`element`&&K(i,t,n,r)}function be(e,t){let n=structuredClone(e.tree);G(n);let r=z(n,e=>e.tagName===`main`)??z(n,e=>e.tagName===`article`);if(!r)return;let i
|
|
1
|
+
import{remarkAsides as e,remarkDirectivesRestoration as t}from"./plugins/remark-asides.mjs";import n from"./plugins/remark-snippets.mjs";import r from"./plugins/remark-vars.mjs";import{CODE_GROUP_SYNC_SCRIPT as i}from"./runtime/code-group-sync.mjs";import{TABS_SYNC_SCRIPT as a}from"./runtime/tabs-sync.mjs";import{publierCssPlugin as o,publierThemeCssPlugin as s}from"./tailwind/css-plugin.mjs";import{createRequire as c}from"node:module";import{configResolveShellConfig as l,contentGenerateLlmsTxt as u,generateAnalyticsScripts as d,shellAnnouncementBannerScript as f,shellBuildHeaders as p,shellBuildLicenseErrorMessage as ee,shellCacheControl as m,shellCollectTailwindClassTokens as h,shellComposeTailwindEntry as g,shellLazyUpgradeScript as _,shellOpenInAiScript as te,shellPlanDefaultRoutes as ne,shellPlanRehypePlugins as re,shellPlanRemarkPlugins as ie,shellResolvePrefetch as ae,shellResolveSnippetsConfig as oe,shellRewriteHead as v,shellRewriteModulepreload as y,shellSearchButtonScript as b,shellSearchDialogScript as x,shellTableOfContentsScript as S,verifyLicense as se}from"@publier/native";import{existsSync as C,lstatSync as w,mkdirSync as T,readFileSync as E,readdirSync as ce,writeFileSync as D}from"node:fs";import{writeFile as O}from"node:fs/promises";import k from"node:path";import{fileURLToPath as le}from"node:url";import{fontProviders as A}from"astro/config";import{fromHtml as ue}from"hast-util-from-html";import{toMdast as j}from"hast-util-to-mdast";import{gfmToMarkdown as M}from"mdast-util-gfm";import{toMarkdown as N}from"mdast-util-to-markdown";import P from"rehype-autolink-headings";import F from"rehype-external-links";import de from"remark-directive";const fe=/^\/(?:_astro|assets|build)\//;function I(){return p()}function L(e){return m(e)}function R(e,t){let n=t.map(e=>e.pathname),r=v(e,n);return{stylesheetsCount:r.stylesheetsCount,modulesCount:r.modulesCount,pagesRewritten:r.pagesRewritten,stylesheets:r.stylesheets,modules:r.modules}}function z(e,t){for(let n of e.children){if(n.type!==`element`)continue;if(t(n))return n;let e=z(n,t);if(e)return e}}function B(e){return e.children.map(e=>e.type===`text`?e.value:e.type===`element`?B(e):``).join(``)}function V(e){let t=e.replace(/^\//,``).replace(/\/$/,``);if(!t)return`/`;for(let e of t.split(`/`)){let t;try{t=decodeURIComponent(e)}catch{return}if(!t||t===`.`||t===`..`||/[\\/?#]/.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127))return}return`/${t}`}function H(e){try{return w(e),!0}catch(e){if(e.code===`ENOENT`)return!1;throw e}}function U(e,t){let n=k.resolve(e),r=k.resolve(n,t);if(!r.startsWith(`${n}${k.sep}`))throw Error(`Unsafe export path: ${t}`);let i=n;for(let e of k.relative(n,r).split(k.sep))if(i=k.join(i,e),H(i)&&w(i).isSymbolicLink())throw Error(`Symlink in export path: ${t}`);return r}function pe(e){return!!z(e,e=>e.tagName===`meta`&&String(e.properties.name).toLowerCase()===`robots`&&/(?:^|[\s,])(noindex|none)(?:$|[\s,])/i.test(String(e.properties.content)))}function W(e,t){let n=[],r=new Set;for(let{pathname:i}of t){let t=V(i);if(!t||r.has(t)||t===`/404`||t===`/500`)continue;let a=`${t}${t!==`/`&&i.endsWith(`/`)?`/`:``}`,o=t.slice(1),s=(o?[`${o}/index.html`,`${o}.html`]:[`index.html`]).find(t=>H(U(e,t)));if(!s)continue;let c=U(e,s);if(!w(c).isFile())continue;let l=ue(E(c,`utf-8`));if(pe(l)||z(l,e=>e.tagName===`meta`&&String(e.properties.httpEquiv).toLowerCase()===`refresh`))continue;let u=z(l,e=>e.tagName===`title`),d=u&&B(u).replace(/\s+/g,` `).trim();if(!d)continue;let f=z(l,e=>e.tagName===`meta`&&String(e.properties.name).toLowerCase()===`description`),p=String(f?.properties.content??``).replace(/\s+/g,` `).trim()||void 0;r.add(t),n.push({url:a,title:d,description:p,collection:o.split(`/`)[0]||void 0,tree:l,directory:s===`index.html`||s.endsWith(`/index.html`)})}return n.sort((e,t)=>e.url.localeCompare(t.url))}function me(e,t){return W(e,t).map(({url:e,title:t,description:n,collection:r})=>({url:e,title:t,description:n,collection:r}))}function he(e,t,n){let r=U(e,`llms.txt`);if(H(r))return{written:!1,pageCount:0,skipped:`existing-file`};let i=me(e,t);if(i.length===0)return{written:!1,pageCount:0,skipped:`no-pages`};let a=u(JSON.stringify({siteName:n.siteName,siteDescription:n.siteDescription,pages:i,collections:n.collections}));return D(r,a,{encoding:`utf-8`,flag:`wx`}),{written:!0,pageCount:i.length}}function ge(e,t){let n=t.map(e=>e.pathname),r=y(e,n);return{jsCount:r.jsCount,fontsCount:r.fontsCount,pagesRewritten:r.pagesRewritten}}const _e=new Set([`nav`,`footer`,`script`,`style`,`noscript`,`template`,`button`,`input`,`select`,`textarea`,`form`,`svg`]),ve=new Set([`navigation`,`search`,`tablist`,`tab`,`button`,`menu`,`toolbar`]);function ye(e){return _e.has(e.tagName)||ve.has(String(e.properties.role))||`dataPagefindIgnore`in e.properties||`dataPublierMarkdownExclude`in e.properties||String(e.properties.dataMdast)===`ignore`}function G(e){e.children=e.children.filter(e=>e.type!==`comment`&&(e.type!==`element`||!ye(e)));for(let t of e.children)t.type===`element`&&G(t)}function K(e,t,n,r){delete e.properties.hidden,delete e.properties.ariaHidden,delete e.properties.style;for(let i of[`href`,`src`,`poster`]){let a=e.properties[i];if(typeof a!=`string`||!a)continue;let o=new URL(a,t);e.properties[i]=n||o.origin!==r?o.href:`${o.pathname}${o.search}${o.hash}`}if(e.tagName===`pre`){let t=z(e,e=>e.tagName===`code`);if(t){let n=[],r=e=>{for(let t of e.children)t.type===`element`&&(Array.isArray(t.properties.className)&&t.properties.className.includes(`ec-line`)?n.push(t):r(t))};r(t),n.length&&(t.children=[{type:`text`,value:n.map(e=>B(z(e,e=>Array.isArray(e.properties.className)&&e.properties.className.includes(`code`))??e)).join(`
|
|
2
|
+
`)}]);let i=e.properties.dataLanguage;typeof i==`string`&&(t.properties.className=[`language-${i}`])}}for(let i of e.children)i.type===`element`&&K(i,t,n,r)}function be(e,t){let n=structuredClone(e.tree);G(n);let r=z(n,e=>e.tagName===`main`)??z(n,e=>e.tagName===`article`);if(!r)return;let i=e.url===`/`?`/`:e.url.replace(/\/$/,``),a=`${i}${e.directory&&i!==`/`?`/`:``}`,o=new URL(a,t||`https:`),s=o,c=z(e.tree,e=>e.tagName===`base`&&`href`in e.properties)?.properties.href;if(typeof c==`string`)try{let e=new URL(c,o);(e.protocol===`https:`||e.protocol===`http:`)&&(s=e)}catch{}K(r,s,!!t,o.origin);let l=N(j({type:`root`,children:[r]}),{fences:!0,extensions:[M()]});return l.trim()?l:void 0}function xe(e,t,n){let r=W(e,t).filter(e=>n.collections.length===0||n.collections.includes(e.collection??`pages`)).flatMap(e=>{let t=be(e,n.siteUrl);return t?[{page:e,markdown:t,relative:`${e.url===`/`?`index`:e.url.slice(1).replace(/\/$/,``)}.md`}]:[]}),i=U(e,`llms-full.txt`),a=new Set,o=t=>{if(H(t)&&!w(t).isFile())throw Error(`Markdown export collision: ${k.relative(e,t)}`)};r.length&&(o(i),a.add(i));for(let t of r){let n=U(e,t.relative);if([...a].some(e=>n===e||n.startsWith(`${e}${k.sep}`)||e.startsWith(`${n}${k.sep}`)))throw Error(`Markdown export collision: ${t.relative}`);o(n),a.add(n)}let s={pageCount:r.length,written:0,existing:0,fullWritten:!1};for(let t of r){let n=U(e,t.relative);if(H(n)){s.existing++;continue}T(k.dirname(n),{recursive:!0}),D(n,t.markdown,{encoding:`utf-8`,flag:`wx`}),s.written++}if(r.length&&!H(i)){let e=N({type:`root`,children:[{type:`heading`,depth:1,children:[{type:`text`,value:n.siteName}]},...n.siteDescription?[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:n.siteDescription}]}]}]:[]]}),t=r.map(({page:e,markdown:t})=>{let r=n.siteUrl?new URL(e.url,n.siteUrl).href:e.url;return`${N({type:`root`,children:[{type:`heading`,depth:2,children:[{type:`link`,url:r,children:[{type:`text`,value:e.title}]}]}]})}\n${t}`}).join(`
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
`);D(i,`${e}\n${t}`,{encoding:`utf-8`,flag:`wx`}),s.fullWritten=!0}return s}const Se={enabled:!1,full:!1,collections:[]};function Ce(e){let t=l(e),{config:n,errors:r}=JSON.parse(t);if(r.length>0){let e=r.map(e=>` - [${e.code}] ${e.path}: ${e.message}`);throw Error(`Invalid publier.config.yaml:\n${e.join(`
|
|
@@ -50,8 +50,8 @@ if (import.meta.hot) {
|
|
|
50
50
|
}
|
|
51
51
|
customElements.define('publier-table-scroll', PublierTableScroll);
|
|
52
52
|
})();
|
|
53
|
-
`,f(),
|
|
54
|
-
`)}function Be(e,t){let n=[],r=[],i=[];for(let a of[`heading`,`body`,`mono`]){let o=e[a];if(!o?.family)continue;let s=`--publier-font-${a}`,c=a===`mono`?[`monospace`]:[`system-ui`,`sans-serif`],l=[o.weight??`400`],u=[o.style??`normal`];if(o.googleFontsUrl)n.push({name:o.family,cssVariable:s,provider:A.google(),fallbacks:c,weights:l,styles:u,subsets:[`latin`]}),r.push(a);else if(o.src){let e=k.isAbsolute(o.src)&&C(o.src)?o.src:k.join(t,`public`,o.src.replace(/^\/+/,``));n.push({name:o.family,cssVariable:s,provider:A.local(),fallbacks:c,weights:l,styles:u,subsets:[`latin`],options:{variants:[{weight:l[0],style:u[0],src:[e]}]}}),r.push(a)}else i.push(`${s}:"${o.family}",${c.join(`,`)};`)}return{entries:n,familyOnlyCss:i.length?`:root{${i.join(``)}}`:``,slots:r}}const Ve=[{pkg:`astro-expressive-code`,aliases:[`astro-expressive-code`]},{pkg:`@astrojs/mdx`,aliases:[`@astrojs/mdx`]},{pkg:`@astrojs/sitemap`,aliases:[`@astrojs/sitemap`]},{pkg:`astro-pagefind`,aliases:[`astro-pagefind`,`pagefind`]},{pkg:`@qwik.dev/astro`,aliases:[`@qwik.dev/astro`]}];function $(e,t){let n=k.join(e,`src`,`content`,t);if(!C(n))return!1;try{return ce(n,{recursive:!0}).some(e=>typeof e==`string`&&/\.mdx?$/.test(e))}catch{return!1}}function He(e={}){let t=null;return{name:`@publier/shell`,hooks:{"astro:config:setup":async({config:n,updateConfig:r,injectScript:i,injectRoute:a,logger:l})=>{let u=n.root?le(n.root):process.cwd();try{se()}catch(e){let t=e instanceof Error?e.message:String(e),n=ee(t);throw n?Error(n):e}let f=c(k.join(u,`package.json`)),p=JSON.stringify(e),m=Ce(we(u)??``),h=m.site;t={llms:m.llms,siteName:h.name,siteUrl:h.url??void 0,siteDescription:h.description??void 0};let g=m.vars,_=m.fonts,
|
|
53
|
+
`,f(),te(),S()];return e.searchEnabled&&t.push(x(),b()),t.join(`
|
|
54
|
+
`)}function Be(e,t){let n=[],r=[],i=[];for(let a of[`heading`,`body`,`mono`]){let o=e[a];if(!o?.family)continue;let s=`--publier-font-${a}`,c=a===`mono`?[`monospace`]:[`system-ui`,`sans-serif`],l=[o.weight??`400`],u=[o.style??`normal`];if(o.googleFontsUrl)n.push({name:o.family,cssVariable:s,provider:A.google(),fallbacks:c,weights:l,styles:u,subsets:[`latin`]}),r.push(a);else if(o.src){let e=k.isAbsolute(o.src)&&C(o.src)?o.src:k.join(t,`public`,o.src.replace(/^\/+/,``));n.push({name:o.family,cssVariable:s,provider:A.local(),fallbacks:c,weights:l,styles:u,subsets:[`latin`],options:{variants:[{weight:l[0],style:u[0],src:[e]}]}}),r.push(a)}else i.push(`${s}:"${o.family}",${c.join(`,`)};`)}return{entries:n,familyOnlyCss:i.length?`:root{${i.join(``)}}`:``,slots:r}}const Ve=[{pkg:`astro-expressive-code`,aliases:[`astro-expressive-code`]},{pkg:`@astrojs/mdx`,aliases:[`@astrojs/mdx`]},{pkg:`@astrojs/sitemap`,aliases:[`@astrojs/sitemap`]},{pkg:`astro-pagefind`,aliases:[`astro-pagefind`,`pagefind`]},{pkg:`@qwik.dev/astro`,aliases:[`@qwik.dev/astro`]}];function $(e,t){let n=k.join(e,`src`,`content`,t);if(!C(n))return!1;try{return ce(n,{recursive:!0}).some(e=>typeof e==`string`&&/\.mdx?$/.test(e))}catch{return!1}}function He(e={}){let t=null;return{name:`@publier/shell`,hooks:{"astro:config:setup":async({config:n,updateConfig:r,injectScript:i,injectRoute:a,logger:l})=>{let u=n.root?le(n.root):process.cwd();try{se()}catch(e){let t=e instanceof Error?e.message:String(e),n=ee(t);throw n?Error(n):e}let f=c(k.join(u,`package.json`)),p=JSON.stringify(e),m=Ce(we(u)??``),h=m.site;t={llms:m.llms,siteName:h.name,siteUrl:h.url??void 0,siteDescription:h.description??void 0};let g=m.vars,_=m.fonts,te=m.nav,v=m.announcement,y=m.docs,b=typeof h.url==`string`&&h.url.length>0;b&&!n.site&&r({site:h.url});let x=new Set(n.integrations.map(e=>e.name)),S=Ve.filter(({aliases:e})=>!e.some(e=>x.has(e)));S.length>0&&l.warn(`[@publier/shell] Required framework integrations are not registered in
|
|
55
55
|
astro.config.ts. As of @publier/shell@2.0.0, docsShell() no longer
|
|
56
56
|
auto-wires these. Add the following to your integrations[] array
|
|
57
57
|
(import statements + entries shown). Order matters: docsShell() must
|
|
@@ -76,7 +76,7 @@ mdx.
|
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
Missing:\n ${S.map(e=>e.pkg).join(`
|
|
79
|
-
`)}\n`);let w=n.prefetch;
|
|
79
|
+
`)}\n`);let w=n.prefetch;ae(w===void 0?void 0:JSON.stringify(w),p)&&r({prefetch:{prefetchAll:!0,defaultStrategy:`viewport`}});let{entries:T,familyOnlyCss:E,slots:ce}=_?Be(_,u):{entries:[],familyOnlyCss:``,slots:[]},D=m.snippets??null,O=D==null?null:D===!1?`false`:JSON.stringify(D),ue=oe(p,O??void 0,C(k.join(u,`content/snippets`))),j=JSON.parse(ue),M={...e,snippets:j===null?void 0:j},N=JSON.stringify(M),P=e.math!==!1,F=P?Ee(f,l):null,de=ie(N,!!(g&&Object.keys(g).length>0),j!==null&&j!==!1,P&&F!==null),fe=re(p,P&&F!==null),I=Oe(de,g,F),L=ke(fe,F),R=De(f,l);await Ae(e,n.integrations,u,r);let z=Me({root:u,mathEnabled:P}),B=ze({searchEnabled:e.search!==!1}),V=JSON.stringify({docs:$(u,`docs`),blog:$(u,`blog`),changelog:$(u,`changelog`)}),H=JSON.parse(ne(p,b,V)),U=H.filter(e=>e.pattern.endsWith(`/rss.xml`)).map(e=>({title:e.pattern===`/blog/rss.xml`?`Blog feed`:e.pattern===`/changelog/rss.xml`?`Changelog feed`:e.pattern,href:e.pattern}));if(R){let e=n.markdown?.processor,t=e?.options?.hastPlugins;e?.name!==`unified`&&Array.isArray(t)&&t.length>0&&l.warn(`[@publier/shell] docsShell() is replacing the configured "${e?.name}" Markdown processor, discarding ${t.length} HAST plugin(s) another integration already registered on it — typically astro-expressive-code >=0.43, which registers into the processor it finds at its own setup. Code fences will silently lose ALL processing (plain <pre><code>, no syntax highlighting). Fix: move docsShell() BEFORE expressiveCode() (and any other Markdown-processor-touching integration) in astro.config.ts integrations[] so they register into docsShell's unified() processor instead.`)}r({markdown:R?{processor:R({remarkPlugins:I,rehypePlugins:L})}:{remarkPlugins:[...I],rehypePlugins:[...L]},vite:{ssr:{noExternal:[`@publier/shell`],external:[`@publier/native`]},build:{rollupOptions:{external:[`@publier/native`]}},optimizeDeps:{exclude:[`@publier/shell`,`@publier/native`]},plugins:[...Ne(f,l,n.vite?.plugins??[]),s({root:u}),o({root:u}),Q(`virtual:publier-nav-config`,`navConfig`,te),Pe({entryPath:z}),Ie(),Q(`virtual:publier-announcement`,`announcement`,v),Q(`virtual:publier-site`,`site`,h),Q(`virtual:publier-docs-config`,`docsConfig`,y),Q(`virtual:publier-appearance`,`appearance`,m.appearance),Q(`virtual:publier-feeds`,`feeds`,U),Q(`virtual:publier-fonts`,`fonts`,{slots:ce}),Le()]}}),r({fonts:[{name:`Inter Variable`,cssVariable:`--publier-font-builtin-sans`,provider:A.npm({remote:!1}),fallbacks:[`system-ui`,`sans-serif`],weights:[`100 900`],styles:[`normal`],subsets:[`latin`],options:{package:`@fontsource-variable/inter`}},{name:`JetBrains Mono Variable`,cssVariable:`--publier-font-builtin-mono`,provider:A.npm({remote:!1}),fallbacks:[`monospace`],weights:[`100 800`],styles:[`normal`],subsets:[`latin`],options:{package:`@fontsource-variable/jetbrains-mono`}},...T]}),i(`page-ssr`,[`import ${JSON.stringify(z)};`,`import 'virtual:publier-theme-css';`,`import 'virtual:publier-custom-css';`,`import '@publier/shell/styles/base.css';`].join(`
|
|
80
80
|
`)),i(`page`,B),i(`head-inline`,`(function(){
|
|
81
81
|
if (typeof window === 'undefined' || !window.sessionStorage || !window.fetch) return;
|
|
82
82
|
var store = window.sessionStorage;
|
package/dist/integration.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./integration-
|
|
1
|
+
import{n as e,r as t,t as n}from"./integration-BTmCC0U-.mjs";export{n as docsShell,e as hoistMediaOutOfUtilitiesLayer,t as publierCascadeHoistPlugin};
|