@symbo.ls/mermaid 3.14.707 → 3.14.708
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/deployIdentity.js +1 -0
- package/dist/esm/src/render.js +19 -17
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isKnownChannel as r,currentChannel as p,apiUrl as a,socketUrl as f}from"@symbo.ls/channels";const c="__SYMBOLS_CHANNEL__",_="__SYMBOLS_ENV__",i=n=>typeof process<"u"&&process.env&&process.env[n]||null,u=()=>{const n=typeof globalThis<"u"?globalThis[c]:null;if(r(n))return n;const e=i("SYMBOLS_CHANNEL");if(r(e))return e;const o=i("NODE_ENV");return r(o)?o:null},d=(n={})=>{const{deployChannel:e,channel:o,userEnv:t,apiBaseUrl:l}=n,s=r(e)?e:u()||(r(o)?o:p());return{channel:s,projectEnv:typeof t=="string"&&t?t:"production",apiUrl:typeof l=="string"&&l?l:a(s),socketUrl:f(s)}},h=n=>`window.${c} = ${JSON.stringify(n.channel)}; window.${_} = ${JSON.stringify(n)};`;export{c as CHANNEL_GLOBAL,_ as IDENTITY_GLOBAL,h as deployIdentityScript,u as explicitProcessChannel,d as resolveDeployIdentity};
|
package/dist/esm/src/render.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import T from"./utils/logger.js";import
|
|
1
|
+
import T from"./utils/logger.js";import ut from"./utils/vartranformer.js";import{getBundleScript as yt,getSmblsIife as bt,getSmblsRuntimeVersion as St}from"./bundle.js";import{deepDestringifyFunctions as $t}from"./utils/deepDestringify.js";import{transpile as z}from"./utils/funcql-transpile.js";import{normalizeRoute as Tt,resolvePageRoute as Et}from"./route.js";import{generateMetaTags as It,getPageMetadata as Ot,getImportMapScript as Rt}from"@symbo.ls/utils";import{getTapStyles as Nt,getTapRuntimeSnippet as _t}from"@symbo.ls/tap";import{resolveDeployIdentity as vt,deployIdentityScript as Dt}from"./deployIdentity.js";const xt=(t,r)=>{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)+r),i=s((e>>8&255)+r);return((s((e&255)+r)|i<<8|n<<16)+16777216).toString(16).slice(1)},U=(t,r)=>{if(typeof t!="string")return;if(r&&typeof r[t]=="string")return r[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=r&&r[e[1]],n=typeof s=="string"&&s.match(/^#?([0-9a-f]{6})$/i);if(n){let i=n[1];if(e[3]&&(i=xt(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}}},wt=process.env.BRENDER!=="false";let M=null,K=null,V=null;if(wt)try{const t=await import("@symbo.ls/brender");M=t.renderRoute,K=t.generateSitemap,V=t.prefetchPageData}catch(t){T.debug(`[MERMAID] Brender not available: ${t.message}`)}const Pt=`<!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">${Nt()}</style>
|
|
9
|
+
<script>${_t()}<\/script>
|
|
10
10
|
'\${{{ IMPORTMAP }}}'
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div data-ssr>'\${{{ BODY }}}'</div>
|
|
14
14
|
<script>
|
|
15
15
|
window.process = { env: { NODE_ENV: '\${{{ NODE_ENV }}}' } };
|
|
16
|
+
'\${{{ DEPLOY_IDENTITY }}}'
|
|
16
17
|
<\/script>
|
|
17
18
|
<script>
|
|
18
19
|
'\${{{ SMBLS_IIFE }}}';
|
|
@@ -22,19 +23,20 @@ import T from"./utils/logger.js";import ft from"./utils/vartranformer.js";import
|
|
|
22
23
|
<\/script>
|
|
23
24
|
'\${{{ EDITOR }}}'
|
|
24
25
|
</body>
|
|
25
|
-
</html>`;function
|
|
26
|
-
`);
|
|
27
|
-
`);const u=[];if(a.ssrTranslations){const p=(t.config||t.settings||{}).polyglot||t.polyglot,l=p?.storagePrefix||"",g=p?.storageLangKey||"",
|
|
28
|
-
`),o={metadata:a.metadata,prefetchedState:a.prefetchedState,activeLang:a.activeLang}}else if(
|
|
29
|
-
`);p&&u.push(`<style>${p}</style>`),o.css&&u.push(`<style data-emotion="smbls">${o.css}</style>`),
|
|
30
|
-
`);const l=[];if(o.ssrTranslations){const
|
|
31
|
-
`),T.debug(`[MERMAID] Brender completed: body=${
|
|
32
|
-
`:`<!-- symbols | ${e} | ${i} | ${
|
|
33
|
-
`,
|
|
34
|
-
<meta name="color-scheme" content="light dark">`:"";let
|
|
35
|
-
`+
|
|
36
|
-
`+
|
|
37
|
-
`+
|
|
26
|
+
</html>`;function j(t,r=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=z(s);r[e]=f?f.schema:null}else r[e]=s}else Array.isArray(s)?r[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=z(n);return m?m.schema:null}}return n&&typeof n=="object"?j(n):n}):s&&typeof s=="object"&&!Array.isArray(s)?r[e]=j(s):r[e]=s}return r}async function Kt(t,r={}){const{appkey:e,pathname:s="/",channel:n="production",userEnv:i=n,isProd:f=!1,req:m,query:Lt,userId:A,smblsIife:W,editorBundle:k,analyzedScript:q="",indexHtml:G,ssrCache:a,ProjectDataService:Q,deployChannel:X,apiBaseUrl:Z}=r;if(!t)return{html:"",status:404,contentType:"text/html"};if(typeof e=="string"&&e.includes("/")){const[c,d]=e.split("/");t.key||(t.key=d),t.owner||(t.owner=c)}const _=Tt(s),E=Et(t.pages,s),v=i==="production"||i==="staging";let I="",D="",o=null,O=null,x="";if(a&&v){I=a.html||"";const c=[];a.fontLinks&&c.push(a.fontLinks);const d=[a.globalCSS||"",a.resetCss||""].filter(Boolean).join(`
|
|
27
|
+
`);d&&c.push(`<style>${d}</style>`),a.css&&c.push(`<style data-emotion="smbls">${a.css}</style>`),D=c.join(`
|
|
28
|
+
`);const u=[];if(a.ssrTranslations){const p=(t.config||t.settings||{}).polyglot||t.polyglot,l=p?.storagePrefix||"",g=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(g){const y=p?.defaultLang||"en";h.push(`if(!localStorage.getItem(${JSON.stringify(g)}))localStorage.setItem(${JSON.stringify(g)},${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
|
+
`),o={metadata:a.metadata,prefetchedState:a.prefetchedState,activeLang:a.activeLang}}else if(M&&v)try{const c=E?E.route:_;T.debug(`[MERMAID] Running brender for route: ${c}`);let d=!1;try{(0,eval)("1"),d=!0}catch{}if(O=d?$t(t):j(t),o=await M(O,{route:c,pathname:_}),o){I=o.html||"";const u=[];o.fontLinks&&u.push(o.fontLinks);const S=o.globalCSS||{},p=[S.rootRule||"",o.resetCss||"",S.keyframeRules||""].filter(Boolean).join(`
|
|
30
|
+
`);p&&u.push(`<style>${p}</style>`),o.css&&u.push(`<style data-emotion="smbls">${o.css}</style>`),D=u.join(`
|
|
31
|
+
`);const l=[];if(o.ssrTranslations){const h=(O?.config||{}).polyglot||O?.polyglot,y=h?.storagePrefix||"",b=h?.storageLangKey||"",R=[];for(const N in o.ssrTranslations){const B=o.ssrTranslations[N];B&&typeof B=="object"&&R.push(`localStorage.setItem(${JSON.stringify(y+N)},${JSON.stringify(JSON.stringify(B))})`)}if(b){const N=h?.defaultLang||"en";R.push(`if(!localStorage.getItem(${JSON.stringify(b)}))localStorage.setItem(${JSON.stringify(b)},${JSON.stringify(N)})`)}R.length&&l.push(`<script>try{${R.join(";")}}catch(e){}<\/script>`)}d&&o.brRegistry&&Object.keys(o.brRegistry).length&&l.push(`<script>window.__BR_REGISTRY__=${JSON.stringify(o.brRegistry)}<\/script>`),l.push("<script>window.__BRENDER__=true<\/script>"),x=l.join(`
|
|
32
|
+
`),T.debug(`[MERMAID] Brender completed: body=${I.length}b, registry=${Object.keys(o.brRegistry||{}).length}`)}}catch(c){T.warn(`[MERMAID] Brender failed, falling back to client render: ${c.message}`)}const tt=yt(e,t,m,{ProjectDataService:Q}),C=St(),et=Rt(t,t?.settings?.cdnProvider||"symbols",{pin:C?{smbls:C}:void 0}),st=t?.files&&t.files["index.html"],F=G||st?.code||Pt,nt=vt({deployChannel:X,channel:n,userEnv:i,apiBaseUrl:Z}),J=Dt(nt),ot=/\$\{\{\{\s*DEPLOY_IDENTITY\s*\}\}\}/.test(F),rt=A?`<script>window.__SYMBOLS_AUTH__=${JSON.stringify({userId:A})}<\/script>`:"",w=o?.prefetchedState,it=(t.config||t.settings||{}).polyglot||t.polyglot,ct=o?.activeLang||it?.defaultLang||"en",lt=w&&Object.keys(w).length?{state:w,lang:ct,actualPathname:s}:{actualPathname:s},at=o?.metadata&&Object.keys(o.metadata).length?o.metadata:Ot(t,E?E.route:_,lt,{isProduction:f,channel:n}),pt=It(at,f),P=W||bt();if(!P)return T.error("[MERMAID] smbls IIFE bundle not available"),{html:"Internal Server Error: smbls bundle not found",status:500,contentType:"text/plain"};const ft=k&&!f?`<script defer type="text/javascript">${k}<\/script>`:"",mt=f?`<!-- built with symbols.app -->
|
|
33
|
+
`:`<!-- symbols | ${e} | ${i} | ${v?"ssr":"csr"} | noindex -->
|
|
34
|
+
`,L=t.useDocumentTheme!==!1,$=t.globalTheme&&t.globalTheme!=="auto"?String(t.globalTheme):null,H=t.themeStorageKey?String(t.themeStorageKey):"",gt=L&&$?' data-theme="'+$+'"':"",dt=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="+JSON.stringify($)+";":"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||{},d=c.color||{},u=c.theme&&c.theme.document||{},S=l=>{const g=u["@"+l];if(!g)return null;const h=U(g.background,d),y=U(g.color,d);return[h&&`background:${h}`,y&&`color:${y}`].filter(Boolean).join(";")||null},p=[];if($){const l=S($);l&&p.push(`html{${l}}`)}else{const l=S("dark"),g=S("light");l&&(p.push(`@media (prefers-color-scheme:dark){:root:not([data-theme]) html{${l}}}`),p.push(`[data-theme="dark"] html{${l}}`)),g&&(p.push(`@media (prefers-color-scheme:light){:root:not([data-theme]) html{${g}}}`),p.push(`[data-theme="light"] html{${g}}`))}p.length&&(Y=`<style>${p.join("")}</style>`)}const ht=typeof t.__criticalCss=="string"&&t.__criticalCss.trim()?`<style>${t.__criticalCss}</style>`:"";return{html:ut(mt+F,{ROOT_ATTRS:gt,HEAD_BOOT:dt+(ht||Y),META:pt+`
|
|
36
|
+
`+D+`
|
|
37
|
+
`+x+`
|
|
38
|
+
`+rt,BUNDLE:tt,BODY:I,SMBLS_IIFE:ot?P:J+`
|
|
39
|
+
`+P,DEPLOY_IDENTITY:J,NODE_ENV:"'production'",IMPORTMAP:et,EDITOR:ft+q},{allowScript:!0}),status:200,contentType:"text/html"}}function Vt(t,r="production",e=null){const s=r!=="production"?` (${r})`:"",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>
|
|
38
40
|
<html>
|
|
39
41
|
<head>
|
|
40
42
|
<meta charset="UTF-8">
|
|
@@ -60,4 +62,4 @@ import T from"./utils/logger.js";import ft from"./utils/vartranformer.js";import
|
|
|
60
62
|
<span class="env">${t}${s}</span>
|
|
61
63
|
</div>
|
|
62
64
|
</body>
|
|
63
|
-
</html>`}export{
|
|
65
|
+
</html>`}export{Pt as DEFAULT_TEMPLATE_HTML,K as generateSitemap,V as prefetchPageData,Vt as renderNotPublishedHtml,Kt as renderProjectHtml,j as transpileFunctionStrings};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/mermaid",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.708",
|
|
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.",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"mermaid": "./dist/esm/bin/start.js"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
+
"@symbo.ls/channels": "^3.14.676",
|
|
72
73
|
"@symbo.ls/tap": "^3.14.612",
|
|
73
74
|
"@symbo.ls/utils": "^3.14.707",
|
|
74
75
|
"cors": "^2.8.6",
|