@xuda.io/runtime-bundle 1.0.1441 → 1.0.1442

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.
@@ -17956,6 +17956,40 @@ const wait_for_runtime_asset_load = function (node) {
17956
17956
  });
17957
17957
  };
17958
17958
 
17959
+ const is_runtime_tailwind_script_src = function (src) {
17960
+ const normalized_src = `${src || ''}`.trim().toLowerCase();
17961
+ if (!normalized_src) {
17962
+ return false;
17963
+ }
17964
+
17965
+ return normalized_src.includes('cdn.tailwindcss.com') || /(?:^|\/)tailwind\.cdn\.js(?:[?#].*)?$/.test(normalized_src);
17966
+ };
17967
+
17968
+ const is_runtime_tailwind_config_script = function (content) {
17969
+ return /(?:^|[^\w.])tailwind\.config\s*=/.test(`${content || ''}`);
17970
+ };
17971
+
17972
+ const has_runtime_tailwind = function () {
17973
+ const win = func.runtime.platform.get_window?.();
17974
+ return !!win?.tailwind;
17975
+ };
17976
+
17977
+ const refresh_runtime_tailwind = async function () {
17978
+ const win = func.runtime.platform.get_window?.();
17979
+ const refresh = win?.tailwind?.refresh;
17980
+ if (typeof refresh !== 'function') {
17981
+ return false;
17982
+ }
17983
+
17984
+ try {
17985
+ await refresh();
17986
+ return true;
17987
+ } catch (error) {
17988
+ console.error(error);
17989
+ return false;
17990
+ }
17991
+ };
17992
+
17959
17993
  const remove_runtime_head_asset = function (node) {
17960
17994
  if (node?.parentNode?.removeChild) {
17961
17995
  node.parentNode.removeChild(node);
@@ -18126,10 +18160,16 @@ const render_runtime_html_asset = async function (options) {
18126
18160
  }
18127
18161
  case 'script': {
18128
18162
  const src = `${attributes.src || ''}`.trim();
18163
+ const is_tailwind_script = is_runtime_tailwind_script_src(src);
18164
+ const is_tailwind_config_script = is_runtime_tailwind_config_script(content);
18129
18165
  if (!src && !content.trim()) {
18130
18166
  return options.$container;
18131
18167
  }
18132
18168
  queue_runtime_html_script_task(async function () {
18169
+ if (src && is_tailwind_script && has_runtime_tailwind()) {
18170
+ return;
18171
+ }
18172
+
18133
18173
  await upsert_runtime_head_element({
18134
18174
  tag_name,
18135
18175
  attributes,
@@ -18144,6 +18184,10 @@ const render_runtime_html_asset = async function (options) {
18144
18184
  : null,
18145
18185
  await_load: !!src,
18146
18186
  });
18187
+
18188
+ if (is_tailwind_config_script) {
18189
+ await refresh_runtime_tailwind();
18190
+ }
18147
18191
  });
18148
18192
  return options.$container;
18149
18193
  }