@symbo.ls/mermaid 3.14.711 → 3.14.712
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/esm/src/render.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import E from"./utils/logger.js";import
|
|
1
|
+
import E from"./utils/logger.js";import yt from"./utils/vartranformer.js";import{getBundleScript as bt,getSmblsIife as St,getSmblsRuntimeVersion as $t}from"./bundle.js";import{deepDestringifyFunctions as Tt,isStringTag as z,markRevived as Et}from"./utils/deepDestringify.js";import{transpile as U}from"./utils/funcql-transpile.js";import{normalizeRoute as It,resolvePageRoute as Ot}from"./route.js";import{generateMetaTags as vt,getPageMetadata as Rt,getImportMapScript as Nt}from"@symbo.ls/utils";import{getTapStyles as _t,getTapRuntimeSnippet as Dt}from"@symbo.ls/tap";import{resolveDeployIdentity as xt,deployIdentityScript as wt}from"./deployIdentity.js";const Pt=(t,o)=>{const e=parseInt(t,16);if(Number.isNaN(e))return t;const s=m=>m>255?255:m<0?0:m,n=s((e>>16)+o),i=s((e>>8&255)+o);return((s((e&255)+o)|i<<8|n<<16)+16777216).toString(16).slice(1)},K=(t,o)=>{if(typeof t!="string")return;if(o&&typeof o[t]=="string")return o[t];if(/^(#|rgb|hsl|var\(|[a-z]+$)/i.test(t))return t;const e=t.match(/^([a-z][a-z0-9]*)(?:\.(\d+))?([+-]\d+)?$/i);if(e&&(e[2]||e[3])){const s=o&&o[e[1]],n=typeof s=="string"&&s.match(/^#?([0-9a-f]{6})$/i);if(n){let i=n[1];if(e[3]&&(i=Pt(i,parseInt(e[3],10))),e[2]){const f=parseFloat("0."+e[2]),m=parseInt(i,16);return`rgba(${m>>16&255},${m>>8&255},${m&255},${f})`}return"#"+i}}},Lt=process.env.BRENDER!=="false";let M=null,V=null,W=null;if(Lt)try{const t=await import("@symbo.ls/brender");M=t.renderRoute,V=t.generateSitemap,W=t.prefetchPageData}catch(t){E.debug(`[MERMAID] Brender not available: ${t.message}`)}const Bt=`<!doctype html>
|
|
2
2
|
<html'\${{{ ROOT_ATTRS }}}'>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
'\${{{ HEAD_BOOT }}}'
|
|
6
6
|
'\${{{ META }}}'
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
-
<style id="smbls-tap-styles">${
|
|
9
|
-
<script>${
|
|
8
|
+
<style id="smbls-tap-styles">${_t()}</style>
|
|
9
|
+
<script>${Dt()}<\/script>
|
|
10
10
|
'\${{{ IMPORTMAP }}}'
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
@@ -23,20 +23,20 @@ import E from"./utils/logger.js";import ut from"./utils/vartranformer.js";import
|
|
|
23
23
|
<\/script>
|
|
24
24
|
'\${{{ EDITOR }}}'
|
|
25
25
|
</body>
|
|
26
|
-
</html>`;function j(t,
|
|
26
|
+
</html>`;function j(t,o=Array.isArray(t)?[]:{}){for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const s=t[e];if(typeof s=="string"){const n=s.trim();if(n.startsWith("(")&&n.includes("=>")||n.startsWith("function")||n.startsWith("async ")){const f=U(s);o[e]=f?f.schema:null}else o[e]=s}else z(s)?o[e]=s.value:Array.isArray(s)?o[e]=s.map(n=>{if(typeof n=="string"){const i=n.trim();if(i.startsWith("(")&&i.includes("=>")||i.startsWith("function")||i.startsWith("async ")){const m=U(n);return m?m.schema:null}}return z(n)?n.value:n&&typeof n=="object"?j(n):n}):s&&typeof s=="object"&&!Array.isArray(s)?o[e]=j(s):o[e]=s}return Et(o)}async function Wt(t,o={}){const{appkey:e,pathname:s="/",channel:n="production",userEnv:i=n,isProd:f=!1,req:m,query:Mt,userId:k,smblsIife:q,editorBundle:A,analyzedScript:G="",indexHtml:Q,ssrCache:a,ProjectDataService:X,deployChannel:Z,apiBaseUrl:tt}=o;if(!t)return{html:"",status:404,contentType:"text/html"};if(typeof e=="string"&&e.includes("/")){const[c,g]=e.split("/");t.key||(t.key=g),t.owner||(t.owner=c)}const N=It(s),$=Ot(t.pages,s),_=i==="production"||i==="staging";let I="",D="",r=null,O=null,x="";if(a&&_){I=a.html||"";const c=[];a.fontLinks&&c.push(a.fontLinks);const g=[a.globalCSS||"",a.resetCss||""].filter(Boolean).join(`
|
|
27
27
|
`);g&&c.push(`<style>${g}</style>`),a.css&&c.push(`<style data-emotion="smbls">${a.css}</style>`),D=c.join(`
|
|
28
28
|
`);const u=[];if(a.ssrTranslations){const p=(t.config||t.settings||{}).polyglot||t.polyglot,l=p?.storagePrefix||"",d=p?.storageLangKey||"",h=[];for(const y in a.ssrTranslations){const b=a.ssrTranslations[y];b&&typeof b=="object"&&h.push(`localStorage.setItem(${JSON.stringify(l+y)},${JSON.stringify(JSON.stringify(b))})`)}if(d){const y=p?.defaultLang||"en";h.push(`if(!localStorage.getItem(${JSON.stringify(d)}))localStorage.setItem(${JSON.stringify(d)},${JSON.stringify(y)})`)}h.length&&u.push(`<script>try{${h.join(";")}}catch(e){}<\/script>`)}u.push("<script>window.__BRENDER__=true<\/script>"),x=u.join(`
|
|
29
|
-
`),
|
|
30
|
-
`);p&&u.push(`<style>${p}</style>`),
|
|
31
|
-
`);const l=[];if(
|
|
32
|
-
`),E.debug(`[MERMAID] Brender completed: body=${I.length}b, registry=${Object.keys(
|
|
33
|
-
`:`<!-- symbols | ${e} | ${i} | ${
|
|
34
|
-
`,L=t.useDocumentTheme!==!1,T=t.globalTheme&&t.globalTheme!=="auto"?String(t.globalTheme):null,H=t.themeStorageKey?String(t.themeStorageKey):"",
|
|
35
|
-
<meta name="color-scheme" content="light dark">`:"";let Y="";if(L){const c=t.designSystem||t.config&&t.config.designSystem||{},g=c.color||{},u=c.theme&&c.theme.document||{},S=l=>{const d=u["@"+l];if(!d)return null;const h=
|
|
29
|
+
`),r={metadata:a.metadata,prefetchedState:a.prefetchedState,activeLang:a.activeLang}}else if(M&&_)try{const c=$?$.route:N;E.debug(`[MERMAID] Running brender for route: ${c}`);let g=!1;try{(0,eval)("1"),g=!0}catch{}if(O=g?Tt(t):j(t),r=await M(O,{route:c,pathname:N}),r){I=r.html||"";const u=[];r.fontLinks&&u.push(r.fontLinks);const S=r.globalCSS||{},p=[S.rootRule||"",r.resetCss||"",S.keyframeRules||""].filter(Boolean).join(`
|
|
30
|
+
`);p&&u.push(`<style>${p}</style>`),r.css&&u.push(`<style data-emotion="smbls">${r.css}</style>`),D=u.join(`
|
|
31
|
+
`);const l=[];if(r.ssrTranslations){const h=(O?.config||{}).polyglot||O?.polyglot,y=h?.storagePrefix||"",b=h?.storageLangKey||"",v=[];for(const R in r.ssrTranslations){const B=r.ssrTranslations[R];B&&typeof B=="object"&&v.push(`localStorage.setItem(${JSON.stringify(y+R)},${JSON.stringify(JSON.stringify(B))})`)}if(b){const R=h?.defaultLang||"en";v.push(`if(!localStorage.getItem(${JSON.stringify(b)}))localStorage.setItem(${JSON.stringify(b)},${JSON.stringify(R)})`)}v.length&&l.push(`<script>try{${v.join(";")}}catch(e){}<\/script>`)}g&&r.brRegistry&&Object.keys(r.brRegistry).length&&l.push(`<script>window.__BR_REGISTRY__=${JSON.stringify(r.brRegistry)}<\/script>`),l.push("<script>window.__BRENDER__=true<\/script>"),x=l.join(`
|
|
32
|
+
`),E.debug(`[MERMAID] Brender completed: body=${I.length}b, registry=${Object.keys(r.brRegistry||{}).length}`)}}catch(c){E.warn(`[MERMAID] Brender failed, falling back to client render: ${c.message}`)}const et=bt(e,t,m,{ProjectDataService:X}),F=$t(),st=Nt(t,t?.settings?.cdnProvider||"symbols",{pin:F?{smbls:F}:void 0}),nt=t?.files&&t.files["index.html"],C=Q||nt?.code||Bt,ot=xt({deployChannel:Z,channel:n,userEnv:i,apiBaseUrl:tt}),J=wt(ot),rt=/\$\{\{\{\s*DEPLOY_IDENTITY\s*\}\}\}/.test(C),it=k?`<script>window.__SYMBOLS_AUTH__=${JSON.stringify({userId:k})}<\/script>`:"",w=r?.prefetchedState,ct=(t.config||t.settings||{}).polyglot||t.polyglot,lt=r?.activeLang||ct?.defaultLang||"en",at=w&&Object.keys(w).length?{state:w,lang:lt,actualPathname:s}:{actualPathname:s},pt=r?.metadata&&Object.keys(r.metadata).length?r.metadata:Rt(t,$?$.route:N,at,{isProduction:f,channel:n}),ft=vt(pt,f),P=q||St();if(!P)return E.error("[MERMAID] smbls IIFE bundle not available"),{html:"Internal Server Error: smbls bundle not found",status:500,contentType:"text/plain"};const mt=A&&!f?`<script defer type="text/javascript">${A}<\/script>`:"",dt=f?`<!-- built with symbols.app -->
|
|
33
|
+
`:`<!-- symbols | ${e} | ${i} | ${_?"ssr":"csr"} | noindex -->
|
|
34
|
+
`,L=t.useDocumentTheme!==!1,T=t.globalTheme&&t.globalTheme!=="auto"?String(t.globalTheme):null,H=t.themeStorageKey?String(t.themeStorageKey):"",gt=L&&T?' data-theme="'+T+'"':"",ht=L?"<script>(function(){try{var t=null;try{t=new URLSearchParams(location.search).get('globalTheme')}catch(e){}"+(H?"if(!t){try{t=localStorage.getItem("+JSON.stringify(H)+")}catch(e){}}":"")+"if(!t||t==='auto'){"+(T?"t="+JSON.stringify(T)+";":"try{t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}catch(e){}")+`}if(t&&t!=='auto')document.documentElement.setAttribute('data-theme',t);}catch(e){}})();<\/script>
|
|
35
|
+
<meta name="color-scheme" content="light dark">`:"";let Y="";if(L){const c=t.designSystem||t.config&&t.config.designSystem||{},g=c.color||{},u=c.theme&&c.theme.document||{},S=l=>{const d=u["@"+l];if(!d)return null;const h=K(d.background,g),y=K(d.color,g);return[h&&`background:${h}`,y&&`color:${y}`].filter(Boolean).join(";")||null},p=[];if(T){const l=S(T);l&&p.push(`html{${l}}`)}else{const l=S("dark"),d=S("light");l&&(p.push(`@media (prefers-color-scheme:dark){:root:not([data-theme]) html{${l}}}`),p.push(`[data-theme="dark"] html{${l}}`)),d&&(p.push(`@media (prefers-color-scheme:light){:root:not([data-theme]) html{${d}}}`),p.push(`[data-theme="light"] html{${d}}`))}p.length&&(Y=`<style>${p.join("")}</style>`)}const ut=typeof t.__criticalCss=="string"&&t.__criticalCss.trim()?`<style>${t.__criticalCss}</style>`:"";return{html:yt(dt+C,{ROOT_ATTRS:gt,HEAD_BOOT:ht+(ut||Y),META:ft+`
|
|
36
36
|
`+D+`
|
|
37
37
|
`+x+`
|
|
38
|
-
`+
|
|
39
|
-
`+P,DEPLOY_IDENTITY:J,NODE_ENV:"'production'",IMPORTMAP:
|
|
38
|
+
`+it,BUNDLE:et,BODY:I,SMBLS_IIFE:rt?P:J+`
|
|
39
|
+
`+P,DEPLOY_IDENTITY:J,NODE_ENV:"'production'",IMPORTMAP:st,EDITOR:mt+G},{allowScript:!0}),status:$&&$.notFound?404:200,contentType:"text/html"}}function qt(t,o="production",e=null){const s=o!=="production"?` (${o})`:"",n=e==="not_public",i=n?"Site Not Yet Public":"Not Published",f=n?`This site isn't public yet${s}`:`This project hasn't been published yet${s}`;return`<!doctype html>
|
|
40
40
|
<html>
|
|
41
41
|
<head>
|
|
42
42
|
<meta charset="UTF-8">
|
|
@@ -62,4 +62,4 @@ import E from"./utils/logger.js";import ut from"./utils/vartranformer.js";import
|
|
|
62
62
|
<span class="env">${t}${s}</span>
|
|
63
63
|
</div>
|
|
64
64
|
</body>
|
|
65
|
-
</html>`}export{
|
|
65
|
+
</html>`}export{Bt as DEFAULT_TEMPLATE_HTML,V as generateSitemap,W as prefetchPageData,qt as renderNotPublishedHtml,Wt as renderProjectHtml,j as transpileFunctionStrings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(s){if(!s)return!1;const n=s.trim().replace(/\n\s*/g," ").trim();if(n===""||n==="{}"||n==="[]")return!1;const r=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/].some(h=>h.test(n)),e=n.startsWith("{")&&!n.includes("=>"),o=n.startsWith("["),a=/^["[{]/.test(n)&&!n.includes("=>");return r&&!e&&!o&&!a}const c=s=>typeof s=="string",t=Array.isArray,u=s=>s!==null&&typeof s=="object"&&!t(s),l=s=>{if(!u(s)||s.__type!=="String"||!c(s.value))return!1;const n=Object.keys(s);return n.length===2&&n.includes("value")},A=Symbol.for("smbls.revived"),d=s=>{if(s&&typeof s=="object")try{s[A]=!0}catch{}return s};function _(s,n=Array.isArray(s)?[]:{}){return d(p(s,n))}function p(s,n=Array.isArray(s)?[]:{}){for(const i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;const r=s[i];if(c(r)){if(f(r))try{const e=Function("return ("+r+")")();n[i]=e}catch{n[i]=r}else n[i]=r;continue}if(t(r)){n[i]=[],r.forEach(e=>{if(c(e))if(f(e))try{const o=Function("return ("+e+")")();n[i].push(o)}catch{n[i].push(e)}else n[i].push(e);else l(e)?n[i].push(e.value):u(e)||t(e)?n[i].push(p(e)):n[i].push(e)});continue}if(l(r)){n[i]=r.value;continue}if(u(r)){n[i]=p(r);continue}n[i]=r}return n}function y(s,n=Array.isArray(s)?[]:{}){for(const i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;const r=s[i];c(r)?n[i]=f(r)?null:r:l(r)?n[i]=r.value:t(r)?n[i]=r.map(e=>c(e)&&f(e)?null:l(e)?e.value:u(e)||t(e)?y(e):e):u(r)?n[i]=y(r):n[i]=r}return n}var O=_;export{_ as deepDestringifyFunctions,O as default,l as isStringTag,d as markRevived,y as stripFunctionStrings};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/mermaid",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.712",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "CC-BY-NC-4.0",
|
|
6
6
|
"description": "Self-sustaining server runner for Symbols projects from JSON. Renders DOMQL projects to HTML with optional brender SSR.",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@symbo.ls/channels": "^3.14.676",
|
|
65
65
|
"@symbo.ls/tap": "^3.14.612",
|
|
66
|
-
"@symbo.ls/utils": "^3.14.
|
|
66
|
+
"@symbo.ls/utils": "^3.14.782",
|
|
67
67
|
"cors": "^2.8.6",
|
|
68
68
|
"express": "^4.22.2"
|
|
69
69
|
},
|