@symbo.ls/mermaid 3.14.708 → 3.14.710
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/index.js +1 -1
- package/dist/esm/src/bundle.js +4 -4
- package/dist/esm/src/render.js +10 -10
- package/dist/esm/src/route.js +1 -1
- package/dist/esm/src/server.js +1 -1
- package/index.js +7 -1
- package/package.json +3 -11
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMermaidApp as t,loadJsonData as o}from"./src/server.js";import{renderProjectHtml as n,renderNotPublishedHtml as i,transpileFunctionStrings as p,generateSitemap as l,prefetchPageData as s}from"./src/render.js";import{getBundleScript as f,getSmblsIife as
|
|
1
|
+
import{createMermaidApp as t,loadJsonData as o}from"./src/server.js";import{renderProjectHtml as n,renderNotPublishedHtml as i,transpileFunctionStrings as p,generateSitemap as l,prefetchPageData as s}from"./src/render.js";import{getBundleScript as f,getSmblsIife as u}from"./src/bundle.js";import{normalizeRoute as d,resolvePageRoute as g,extractRouteParams as x,isNotFoundPage as S,STATIC_EXT as F}from"./src/route.js";import{deepDestringifyFunctions as b,stripFunctionStrings as D}from"./src/utils/deepDestringify.js";import{transpile as R}from"./src/utils/funcql-transpile.js";import{default as h}from"./src/utils/vartranformer.js";import{default as A}from"./src/utils/logger.js";export{F as STATIC_EXT,t as createMermaidApp,b as deepDestringifyFunctions,x as extractRouteParams,l as generateSitemap,f as getBundleScript,u as getSmblsIife,S as isNotFoundPage,o as loadJsonData,A as log,d as normalizeRoute,s as prefetchPageData,i as renderNotPublishedHtml,n as renderProjectHtml,h as replaceVariablesInFileSync,g as resolvePageRoute,D as stripFunctionStrings,R as transpileFuncql,p as transpileFunctionStrings};
|
package/dist/esm/src/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var context = Smbls.deepDestringifyFunctions(${
|
|
1
|
+
import o from"./utils/logger.js";import*as p from"smbls/iife-string";import{isWrappedLibrary as L}from"@symbo.ls/utils";const f=p.default,g=p.version||null;o.debug(`[BUNDLE] smbls IIFE loaded from smbls/iife-string (${f.length} bytes, v${g||"unknown"})`);const b=s=>s.replace(/</g,"\\u003c");function R(){return f}function N(){return g}function B(s,e,t,{ProjectDataService:a}={}){if(o.debug(`[BUNDLE] getBundleScript started for ${s}`),!e)return o.warn("[BUNDLE] No data provided, returning empty"),"";try{if(e.merged)Object.assign(e,e.merged),o.debug(`[BUNDLE] Applied precomputed merged data for project ${e.id}`);else if(a&&Array.isArray(e.sharedLibraries)&&e.sharedLibraries.length>0){const r=a.mergeSharedLibraries(e,e.sharedLibraries,e.projectType);Object.assign(e,r),o.debug(`[BUNDLE] Merged ${e.sharedLibraries.length} shared libraries`)}}catch(r){o.error(`[BUNDLE] Failed to ensure merged data: ${r.message}`)}try{if(e.dependencies&&Array.isArray(e.sharedLibraries))for(const r of e.sharedLibraries){const u=L(r)?r.library:r,m=u&&u.key;if(m)for(const D of["@symbo-ls","@symbo.ls"]){const i=`${D}/${m}`;e.dependencies[i]&&(delete e.dependencies[i],o.debug(`[BUNDLE] Dropped CDN dependency ${i} \u2014 already merged as shared library`))}}}catch(r){o.error(`[BUNDLE] Failed to strip shared-library dependencies: ${r.message}`)}const y=b(JSON.stringify(e)),S=t?.headers&&typeof t.headers.get=="function"&&t.headers.get("host")||t?.headers?.host||t?.host||t?.url&&(()=>{try{return new URL(t.url).host}catch{return""}})()||"",n=String(S).toLowerCase().split(":")[0],c=(()=>{if(t?.query)return t.query;try{return Object.fromEntries(new URL(t?.url||"","http://x").searchParams)}catch{return{}}})(),v=c.release||!1,w=c.version,l=n.endsWith(".symbo.ls")||n.endsWith(".preview.symbols.app")||n==="localhost"||n.endsWith(".localhost"),d=!!v||!!w||!l,x=e&&(e._id||e.projectId||e.id)||null,k=l?b(JSON.stringify({...e.settings,liveSync:!d,inspect:!0,verbose:!d,projectId:x})):"null",h=`
|
|
2
|
+
var context = Smbls.deepDestringifyFunctions(${y});
|
|
3
3
|
// Must name the SAME provider render.js used for the page's importmap
|
|
4
4
|
// (default 'symbols' \u2192 pkg.symbo.ls). This drives prepareDependencies'
|
|
5
5
|
// runtime loads; if the two disagree, a package arrives twice from two
|
|
@@ -20,7 +20,7 @@ import r from"./utils/logger.js";import*as m from"smbls/iife-string";const p=m.d
|
|
|
20
20
|
|
|
21
21
|
var app = context.app || {};
|
|
22
22
|
delete context.app;
|
|
23
|
-
var settings = ${
|
|
23
|
+
var settings = ${k};
|
|
24
24
|
if (settings) context.editor = settings;
|
|
25
25
|
|
|
26
26
|
// Theme initialization: set data-theme before app renders to avoid FOUC.
|
|
@@ -98,4 +98,4 @@ import r from"./utils/logger.js";import*as m from"smbls/iife-string";const p=m.d
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
Smbls.create(app, context);
|
|
101
|
-
`;return
|
|
101
|
+
`;return o.debug(`[BUNDLE] Script generated (${h.length} bytes)`),h}export{B as getBundleScript,R as getSmblsIife,N as getSmblsRuntimeVersion};
|
package/dist/esm/src/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import E 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){E.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" />
|
|
@@ -23,20 +23,20 @@ import T 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,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,
|
|
27
|
-
`);
|
|
28
|
-
`);const u=[];if(a.ssrTranslations){const p=(t.config||t.settings||{}).polyglot||t.polyglot,l=p?.storagePrefix||"",
|
|
29
|
-
`),o={metadata:a.metadata,prefetchedState:a.prefetchedState,activeLang:a.activeLang}}else if(M&&v)try{const c
|
|
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,g]=e.split("/");t.key||(t.key=g),t.owner||(t.owner=c)}const _=Tt(s),$=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 g=[a.globalCSS||"",a.resetCss||""].filter(Boolean).join(`
|
|
27
|
+
`);g&&c.push(`<style>${g}</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||"",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
|
+
`),o={metadata:a.metadata,prefetchedState:a.prefetchedState,activeLang:a.activeLang}}else if(M&&v)try{const c=$?$.route:_;E.debug(`[MERMAID] Running brender for route: ${c}`);let g=!1;try{(0,eval)("1"),g=!0}catch{}if(O=g?$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
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>`)}
|
|
32
|
-
`),
|
|
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>`)}g&&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
|
+
`),E.debug(`[MERMAID] Brender completed: body=${I.length}b, registry=${Object.keys(o.brRegistry||{}).length}`)}}catch(c){E.warn(`[MERMAID] Brender failed, falling back to client render: ${c.message}`)}const tt=yt(e,t,m,{ProjectDataService:Q}),F=St(),et=Rt(t,t?.settings?.cdnProvider||"symbols",{pin:F?{smbls:F}:void 0}),st=t?.files&&t.files["index.html"],C=G||st?.code||Pt,nt=vt({deployChannel:X,channel:n,userEnv:i,apiBaseUrl:Z}),J=Dt(nt),ot=/\$\{\{\{\s*DEPLOY_IDENTITY\s*\}\}\}/.test(C),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,$?$.route:_,lt,{isProduction:f,channel:n}),pt=It(at,f),P=W||bt();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 ft=k&&!f?`<script defer type="text/javascript">${k}<\/script>`:"",mt=f?`<!-- built with symbols.app -->
|
|
33
33
|
`:`<!-- symbols | ${e} | ${i} | ${v?"ssr":"csr"} | noindex -->
|
|
34
|
-
`,L=t.useDocumentTheme!==!1
|
|
35
|
-
<meta name="color-scheme" content="light dark">`:"";let Y="";if(L){const c=t.designSystem||t.config&&t.config.designSystem||{},
|
|
34
|
+
`,L=t.useDocumentTheme!==!1,T=t.globalTheme&&t.globalTheme!=="auto"?String(t.globalTheme):null,H=t.themeStorageKey?String(t.themeStorageKey):"",dt=L&&T?' data-theme="'+T+'"':"",gt=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=U(d.background,g),y=U(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 ht=typeof t.__criticalCss=="string"&&t.__criticalCss.trim()?`<style>${t.__criticalCss}</style>`:"";return{html:ut(mt+C,{ROOT_ATTRS:dt,HEAD_BOOT:gt+(ht||Y),META:pt+`
|
|
36
36
|
`+D+`
|
|
37
37
|
`+x+`
|
|
38
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>
|
|
39
|
+
`+P,DEPLOY_IDENTITY:J,NODE_ENV:"'production'",IMPORTMAP:et,EDITOR:ft+q},{allowScript:!0}),status:$&&$.notFound?404: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>
|
|
40
40
|
<html>
|
|
41
41
|
<head>
|
|
42
42
|
<meta charset="UTF-8">
|
package/dist/esm/src/route.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(t){let n=t||"/";return n.startsWith("/")||(n="/"+n),n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),n}function h(t,n){const o=t.split("/"),f=n.split("/"),s={};for(let r=0;r<o.length;r++)o[r].startsWith(":")&&(s[o[r].slice(1)]=f[r]);return s}function c(t){return!!t&&typeof t=="object"&&(t.notFound===!0||t.metadata?.notFound===!0)}function p(t,n){if(!t||!Object.keys(t).length)return null;const o=a(n),f=e=>c(t[e.route])?{...e,notFound:!0}:e;if(t[o])return f({route:o,fallback:!1});const s=o.split("/");for(const e of Object.keys(t)){if(!e.includes(":"))continue;const i=e.split("/");if(i.length!==s.length)continue;let l=!0;for(let u=0;u<i.length;u++)if(!i[u].startsWith(":")&&i[u]!==s[u]){l=!1;break}if(l)return f({route:e,fallback:!1,params:h(e,o)})}let r=null;for(const e of Object.keys(t)){if(!e.endsWith("/*"))continue;const i=e.slice(0,-2);i&&o!==i&&!o.startsWith(i+"/")||(!r||i.length>r.prefix.length)&&(r={prefix:i,route:e})}if(r)return f({route:r.route,fallback:!1});for(const e of Object.keys(t))if(c(t[e]))return{route:e,fallback:!1,notFound:!0};return o!=="/"&&t["/"]?{route:"/",fallback:!0}:null}const m=/\.(js|mjs|css|map|png|jpe?g|gif|svg|ico|webp|avif|woff2?|ttf|eot|otf|json|xml|txt|webmanifest|mp4|webm|mp3|ogg|wav|pdf)$/i;export{m as STATIC_EXT,h as extractRouteParams,c as isNotFoundPage,a as normalizeRoute,p as resolvePageRoute};
|
package/dist/esm/src/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import P from"path";import y from"fs";import b from"express";import D from"cors";import u from"./utils/logger.js";import{STATIC_EXT as I}from"./route.js";import{renderProjectHtml as $,renderNotPublishedHtml as w,generateSitemap as j}from"./render.js";function R(t){const e=P.resolve(t);let s=e;if(y.existsSync(e)&&y.statSync(e).isDirectory()&&(s=P.join(e,"app.json")),!y.existsSync(s))throw new Error(`JSON data file not found: ${s}`);const d=y.readFileSync(s,"utf8"),a=JSON.parse(d);return u.info(`[MERMAID] Loaded project data from ${s}`),a}function T(t,e){if(typeof t!="string")return t;if(t.includes("?")&&e){const[s,d]=t.split("?");t=s.replace(/\/$/,"");try{const a=new URLSearchParams(d);for(const[f,g]of a.entries())e.query[f]===void 0&&(e.query[f]=g)}catch(a){u.warn(`[MERMAID] Failed to parse nested query in renderUrl: ${a.message}`)}}return t.replace(/^https?:\/\//,"").split(":")[0].replace(/^www\./,"").replace(/\/$/,"")}function F(t={}){const{jsonPath:e,appkeyOverride:s,channel:d="production",getProjectData:a,cors:f=!0,editor:g}=t;let S=null;e&&(S=R(e));const c=b();return f&&c.use(D({origin:"*",methods:"GET, POST"})),c.use(b.json()),c.get("/health",(o,r)=>r.send({alive:!0,service:"mermaid",version:"3.14.0"})),c.get("*",async(o,r)=>{try{const
|
|
1
|
+
import P from"path";import y from"fs";import b from"express";import D from"cors";import u from"./utils/logger.js";import{STATIC_EXT as I}from"./route.js";import{renderProjectHtml as $,renderNotPublishedHtml as w,generateSitemap as j}from"./render.js";function R(t){const e=P.resolve(t);let s=e;if(y.existsSync(e)&&y.statSync(e).isDirectory()&&(s=P.join(e,"app.json")),!y.existsSync(s))throw new Error(`JSON data file not found: ${s}`);const d=y.readFileSync(s,"utf8"),a=JSON.parse(d);return u.info(`[MERMAID] Loaded project data from ${s}`),a}function T(t,e){if(typeof t!="string")return t;if(t.includes("?")&&e){const[s,d]=t.split("?");t=s.replace(/\/$/,"");try{const a=new URLSearchParams(d);for(const[f,g]of a.entries())e.query[f]===void 0&&(e.query[f]=g)}catch(a){u.warn(`[MERMAID] Failed to parse nested query in renderUrl: ${a.message}`)}}return t.replace(/^https?:\/\//,"").split(":")[0].replace(/^www\./,"").replace(/\/$/,"")}function F(t={}){const{jsonPath:e,appkeyOverride:s,channel:d="production",getProjectData:a,cors:f=!0,editor:g}=t;let S=null;e&&(S=R(e));const c=b();return f&&c.use(D({origin:"*",methods:"GET, POST"})),c.use(b.json()),c.get("/health",(o,r)=>r.send({alive:!0,service:"mermaid",version:"3.14.0"})),c.get("*",async(o,r)=>{try{const i=o.originalUrl.split("?")[0];if(I.test(i)&&i!=="/sitemap.xml")return i==="/favicon.ico"?r.status(204).end():r.status(404).send("Not Found");let m=s||o.query.renderUrl||o.headers.host;m=T(m,o);let l=null,p=m,v=d,M=!1;if(S)l=S,u.debug("[MERMAID] Using local JSON data");else if(a){const n=await a(o,{appkey:m});n&&(l=n.data,n.appkey&&(p=n.appkey),n.channel&&(v=n.channel),typeof n.isProd=="boolean"&&(M=n.isProd))}if(!p)return r.send("Hello, this is Mermaid (Symbols runner). Read developer documentation at https://symbols.app/developers");if(!l)return u.warn(`[MERMAID] Project not found for appkey: ${p}`),r.status(404).type("html").send(w(p,v));if(i==="/sitemap.xml"){if(j&&l.pages&&Object.keys(l.pages).length){const n=`https://${p}`,E=j(n,l.pages);return r.type("application/xml").send(E)}return r.status(404).send("No sitemap available")}const x=o.headers["x-user-id"]||"",h=await $(l,{appkey:p,pathname:i,channel:v,isProd:M,req:o,userId:x,editorBundle:g?.bundle});return r.status(h.status).set({host:"https://"+p+"/"}).type(h.contentType==="text/html"?"html":h.contentType).send(h.html)}catch(i){return u.error(`[MERMAID] Error in request: ${i}`),r.status(500).send("Internal Server Error")}}),c}export{F as createMermaidApp,R as loadJsonData};
|
package/index.js
CHANGED
|
@@ -14,7 +14,13 @@ export {
|
|
|
14
14
|
prefetchPageData,
|
|
15
15
|
} from './src/render.js';
|
|
16
16
|
export { getBundleScript, getSmblsIife } from './src/bundle.js';
|
|
17
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
normalizeRoute,
|
|
19
|
+
resolvePageRoute,
|
|
20
|
+
extractRouteParams,
|
|
21
|
+
isNotFoundPage,
|
|
22
|
+
STATIC_EXT,
|
|
23
|
+
} from './src/route.js';
|
|
18
24
|
export { deepDestringifyFunctions, stripFunctionStrings } from './src/utils/deepDestringify.js';
|
|
19
25
|
export { transpile as transpileFuncql } from './src/utils/funcql-transpile.js';
|
|
20
26
|
export { default as replaceVariablesInFileSync } from './src/utils/vartranformer.js';
|
package/package.json
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/mermaid",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.710",
|
|
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.",
|
|
7
|
+
"source": "index.js",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
|
-
"development": "./index.js",
|
|
10
10
|
"import": "./dist/esm/index.js",
|
|
11
11
|
"default": "./dist/esm/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./package.json": "./package.json",
|
|
14
14
|
"./server": {
|
|
15
|
-
"development": "./src/server.js",
|
|
16
15
|
"import": "./dist/esm/src/server.js",
|
|
17
16
|
"default": "./dist/esm/src/server.js"
|
|
18
17
|
},
|
|
19
18
|
"./render": {
|
|
20
|
-
"development": "./src/render.js",
|
|
21
19
|
"import": "./dist/esm/src/render.js",
|
|
22
20
|
"default": "./dist/esm/src/render.js"
|
|
23
21
|
},
|
|
24
22
|
"./bundle": {
|
|
25
|
-
"development": "./src/bundle.js",
|
|
26
23
|
"import": "./dist/esm/src/bundle.js",
|
|
27
24
|
"default": "./dist/esm/src/bundle.js"
|
|
28
25
|
},
|
|
29
26
|
"./route": {
|
|
30
|
-
"development": "./src/route.js",
|
|
31
27
|
"import": "./dist/esm/src/route.js",
|
|
32
28
|
"default": "./dist/esm/src/route.js"
|
|
33
29
|
},
|
|
34
30
|
"./utils/deepDestringify": {
|
|
35
|
-
"development": "./src/utils/deepDestringify.js",
|
|
36
31
|
"import": "./dist/esm/src/utils/deepDestringify.js",
|
|
37
32
|
"default": "./dist/esm/src/utils/deepDestringify.js"
|
|
38
33
|
},
|
|
39
34
|
"./utils/funcql-transpile": {
|
|
40
|
-
"development": "./src/utils/funcql-transpile.js",
|
|
41
35
|
"import": "./dist/esm/src/utils/funcql-transpile.js",
|
|
42
36
|
"default": "./dist/esm/src/utils/funcql-transpile.js"
|
|
43
37
|
},
|
|
44
38
|
"./utils/vartranformer": {
|
|
45
|
-
"development": "./src/utils/vartranformer.js",
|
|
46
39
|
"import": "./dist/esm/src/utils/vartranformer.js",
|
|
47
40
|
"default": "./dist/esm/src/utils/vartranformer.js"
|
|
48
41
|
},
|
|
49
42
|
"./utils/logger": {
|
|
50
|
-
"development": "./src/utils/logger.js",
|
|
51
43
|
"import": "./dist/esm/src/utils/logger.js",
|
|
52
44
|
"default": "./dist/esm/src/utils/logger.js"
|
|
53
45
|
}
|
|
@@ -79,7 +71,7 @@
|
|
|
79
71
|
"@symbo.ls/brender": "^3.14.599"
|
|
80
72
|
},
|
|
81
73
|
"publishConfig": {
|
|
82
|
-
"access": "
|
|
74
|
+
"access": "public"
|
|
83
75
|
},
|
|
84
76
|
"module": "./dist/esm/index.js"
|
|
85
77
|
}
|