@pure-ds/core 0.3.3 → 0.3.4

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.
@@ -5126,23 +5126,23 @@ export const ${name}CSS = \`${escapedCSS}\`;
5126
5126
  /**
5127
5127
  * Static method to apply styles to document
5128
5128
  * Creates a link element with BLOB URL
5129
- * @param {Generator} generator - The Generator instance with generated styles
5129
+ * @param {Generator} [generator] - Optional Generator instance (defaults to singleton)
5130
5130
  */
5131
5131
  static applyStyles(generator) {
5132
+ // Use provided generator or singleton instance
5133
+ const target = generator || Generator.instance;
5134
+
5132
5135
  // Validate parameter
5133
- if (!generator || typeof generator !== "object") {
5134
- generator?.options?.log?.(
5135
- "error",
5136
- "[Generator] applyStyles requires a generator object"
5137
- );
5136
+ if (!target || typeof target !== "object") {
5137
+ console.error("[Generator] applyStyles requires a generator object or active singleton");
5138
5138
  return;
5139
5139
  }
5140
5140
 
5141
5141
  // Preferred: apply layered CSS so tokens + primitives + components + utilities
5142
5142
  // are available in light DOM (ensures primitives like :where(button):active apply)
5143
- const cssText = generator.layeredCSS || generator.css || "";
5143
+ const cssText = target.layeredCSS || target.css || "";
5144
5144
  if (!cssText) {
5145
- generator?.options?.log?.(
5145
+ target.options?.log?.(
5146
5146
  "warn",
5147
5147
  "[Generator] No CSS available on designer to apply"
5148
5148
  );
package/src/js/pds.js CHANGED
@@ -1166,7 +1166,7 @@ async function live(config) {
1166
1166
 
1167
1167
  // Apply styles globally if requested (default behavior)
1168
1168
  if (applyGlobalStyles) {
1169
- await PDS.Generator.applyStyles(generator);
1169
+ await PDS.Generator.applyStyles();
1170
1170
 
1171
1171
  // Clean up critical styles after adoptedStyleSheets are applied
1172
1172
  if (typeof window !== "undefined") {
@@ -1477,10 +1477,10 @@ async function setTheme(theme, options = {}) {
1477
1477
  currentGenerator.configure(newConfig);
1478
1478
 
1479
1479
  // Reapply styles
1480
- await PDS.Generator.applyStyles(currentDesigner);
1480
+ await PDS.Generator.applyStyles();
1481
1481
  }
1482
1482
  } catch (error) {
1483
- currentDesigner?.options?.log?.("warn", "Failed to update styles for new theme:", error);
1483
+ console.warn("Failed to update styles for new theme:", error);
1484
1484
  }
1485
1485
  }
1486
1486