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.js CHANGED
@@ -1853,6 +1853,7 @@ ${importMapJSON}
1853
1853
  );
1854
1854
  }
1855
1855
  }
1856
+ html = injectIntoHead(html, `<script>${HISTORY_GUARD_SCRIPT}</script>`);
1856
1857
  return { html, usesESM: true };
1857
1858
  }
1858
1859
  function generateHTMLShell(files, config) {
@@ -2121,12 +2122,13 @@ function applyTailwindRuntime(html, project, config, tailwind) {
2121
2122
  /<style>([\s\S]*?)<\/style>/g,
2122
2123
  (match, css) => hasTailwindDirectives(css) ? `<style type="text/tailwindcss">${css}</style>` : match
2123
2124
  );
2124
- let injection = `<script src="${TAILWIND_CDN_URL}"></script>`;
2125
+ let injection = "";
2125
2126
  const configObject = extractTailwindConfig(project.files);
2126
2127
  if (configObject) {
2127
- injection += `
2128
- <script>tailwind.config = ${configObject};</script>`;
2128
+ injection += `<script>window.tailwind = { config: ${configObject} };</script>
2129
+ `;
2129
2130
  }
2131
+ injection += `<script src="${TAILWIND_CDN_URL}" defer></script>`;
2130
2132
  return injectIntoHead(html, injection);
2131
2133
  }
2132
2134
  function extractTailwindConfig(files) {
@@ -2197,6 +2199,7 @@ function extractBalancedObject(source) {
2197
2199
  function isSafeConfigObject(object) {
2198
2200
  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));
2199
2201
  }
2202
+ 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){}";
2200
2203
  function injectImportMetaEnv(files) {
2201
2204
  const shim = `if(!import.meta.env){Object.defineProperty(import.meta,'env',{value:{MODE:'production',BASE_URL:'/',PROD:true,DEV:false,SSR:false}});}`;
2202
2205
  for (const [path, content] of files) {