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/react.cjs CHANGED
@@ -1841,6 +1841,7 @@ ${importMapJSON}
1841
1841
  );
1842
1842
  }
1843
1843
  }
1844
+ html = injectIntoHead(html, `<script>${HISTORY_GUARD_SCRIPT}</script>`);
1844
1845
  return { html, usesESM: true };
1845
1846
  }
1846
1847
  function generateHTMLShell(files, config) {
@@ -2109,12 +2110,13 @@ function applyTailwindRuntime(html, project, config, tailwind) {
2109
2110
  /<style>([\s\S]*?)<\/style>/g,
2110
2111
  (match, css) => hasTailwindDirectives(css) ? `<style type="text/tailwindcss">${css}</style>` : match
2111
2112
  );
2112
- let injection = `<script src="${TAILWIND_CDN_URL}"></script>`;
2113
+ let injection = "";
2113
2114
  const configObject = extractTailwindConfig(project.files);
2114
2115
  if (configObject) {
2115
- injection += `
2116
- <script>tailwind.config = ${configObject};</script>`;
2116
+ injection += `<script>window.tailwind = { config: ${configObject} };</script>
2117
+ `;
2117
2118
  }
2119
+ injection += `<script src="${TAILWIND_CDN_URL}" defer></script>`;
2118
2120
  return injectIntoHead(html, injection);
2119
2121
  }
2120
2122
  function extractTailwindConfig(files) {
@@ -2185,6 +2187,7 @@ function extractBalancedObject(source) {
2185
2187
  function isSafeConfigObject(object) {
2186
2188
  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));
2187
2189
  }
2190
+ 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){}";
2188
2191
  function injectImportMetaEnv(files) {
2189
2192
  const shim = `if(!import.meta.env){Object.defineProperty(import.meta,'env',{value:{MODE:'production',BASE_URL:'/',PROD:true,DEV:false,SSR:false}});}`;
2190
2193
  for (const [path, content] of files) {