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