diorama-js 0.2.0 → 0.2.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.cjs CHANGED
@@ -1855,6 +1855,7 @@ ${importMapJSON}
1855
1855
  );
1856
1856
  }
1857
1857
  }
1858
+ html = injectIntoHead(html, `<script>${HISTORY_GUARD_SCRIPT}</script>`);
1858
1859
  return { html, usesESM: true };
1859
1860
  }
1860
1861
  function generateHTMLShell(files, config) {
@@ -2123,12 +2124,13 @@ function applyTailwindRuntime(html, project, config, tailwind) {
2123
2124
  /<style>([\s\S]*?)<\/style>/g,
2124
2125
  (match, css) => hasTailwindDirectives(css) ? `<style type="text/tailwindcss">${css}</style>` : match
2125
2126
  );
2126
- let injection = `<script src="${TAILWIND_CDN_URL}"></script>`;
2127
+ let injection = "";
2127
2128
  const configObject = extractTailwindConfig(project.files);
2128
2129
  if (configObject) {
2129
- injection += `
2130
- <script>tailwind.config = ${configObject};</script>`;
2130
+ injection += `<script>window.tailwind = { config: ${configObject} };</script>
2131
+ `;
2131
2132
  }
2133
+ injection += `<script src="${TAILWIND_CDN_URL}" defer></script>`;
2132
2134
  return injectIntoHead(html, injection);
2133
2135
  }
2134
2136
  function extractTailwindConfig(files) {
@@ -2199,6 +2201,7 @@ function extractBalancedObject(source) {
2199
2201
  function isSafeConfigObject(object) {
2200
2202
  return !(/\brequire\s*\(/.test(object) || /\bimport\b/.test(object) || /=>/.test(object) || /\bfunction\b/.test(object) || /`/.test(object) || /\bprocess\b/.test(object) || /\b__dirname\b|\b__filename\b/.test(object));
2201
2203
  }
2204
+ var HISTORY_GUARD_SCRIPT = "try{for(const m of ['pushState','replaceState']){const orig=history[m].bind(history);history[m]=function(state,title,url){try{return orig(state,title,url);}catch(e){try{return orig(state,title);}catch(e2){}}};}}catch(e){}";
2202
2205
  function injectImportMetaEnv(files) {
2203
2206
  const shim = `if(!import.meta.env){Object.defineProperty(import.meta,'env',{value:{MODE:'production',BASE_URL:'/',PROD:true,DEV:false,SSR:false}});}`;
2204
2207
  for (const [path, content] of files) {