@skyvexsoftware/stratos-sdk 0.1.15 → 0.1.16

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.
@@ -30,12 +30,21 @@ export function cssInject() {
30
30
  const jsEntry = Object.values(bundle).find((chunk) => chunk.type === "chunk" && chunk.isEntry);
31
31
  if (!jsEntry || jsEntry.type !== "chunk")
32
32
  return;
33
- // Prepend CSS injection code to the JS entry
33
+ // Export the CSS as __STRATOS_PLUGIN_CSS__ so the shell's PluginHost
34
+ // can inject/remove it based on plugin lifecycle (mount/unmount).
35
+ //
36
+ // Also self-inject via IIFE for backwards compatibility with older shells
37
+ // that don't manage plugin CSS lifecycle. The IIFE tags its <style> with
38
+ // data-plugin-css-fallback so the new shell can remove it when it takes over.
34
39
  const escaped = cssContent
35
40
  .replace(/\\/g, "\\\\")
36
41
  .replace(/`/g, "\\`")
37
42
  .replace(/\$/g, "\\$");
38
- const injection = `(function(){try{var s=document.createElement("style");s.textContent=\`${escaped}\`;document.head.appendChild(s)}catch(e){}})();\n`;
43
+ const injection = [
44
+ `export const __STRATOS_PLUGIN_CSS__ = \`${escaped}\`;`,
45
+ `(function(){try{var s=document.createElement("style");s.textContent=\`${escaped}\`;s.setAttribute("data-plugin-css-fallback","");document.head.appendChild(s)}catch(e){}})();`,
46
+ "",
47
+ ].join("\n");
39
48
  jsEntry.code = injection + jsEntry.code;
40
49
  // Remove the separate CSS files
41
50
  for (const name of cssAssets) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software",