unhead 1.9.3 → 1.9.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.
package/dist/index.cjs CHANGED
@@ -460,7 +460,7 @@ function useScript(_input, _options) {
460
460
  script.status = s;
461
461
  head.hooks.callHook(`script:updated`, hookCtx);
462
462
  };
463
- const trigger = options.trigger;
463
+ const trigger = typeof options.trigger !== "undefined" ? options.trigger : "client";
464
464
  shared.ScriptNetworkEvents.forEach((fn) => {
465
465
  const _fn = typeof input[fn] === "function" ? input[fn].bind(options.eventContext) : null;
466
466
  input[fn] = (e) => {
@@ -503,14 +503,12 @@ function useScript(_input, _options) {
503
503
  }
504
504
  };
505
505
  const hookCtx = { script };
506
- if (trigger) {
507
- if (trigger instanceof Promise)
508
- trigger.then(script.load);
509
- else if (typeof trigger === "function")
510
- trigger(script.load);
511
- } else {
506
+ if (trigger === "client" && !head.ssr || trigger === "server" && head.ssr)
512
507
  script.load();
513
- }
508
+ else if (trigger instanceof Promise)
509
+ trigger.then(script.load);
510
+ else if (typeof trigger === "function")
511
+ trigger(script.load);
514
512
  const removeHook = head.hooks.hook("dom:renderTag", (ctx) => {
515
513
  if (ctx.tag.key !== key)
516
514
  return;
package/dist/index.mjs CHANGED
@@ -459,7 +459,7 @@ function useScript(_input, _options) {
459
459
  script.status = s;
460
460
  head.hooks.callHook(`script:updated`, hookCtx);
461
461
  };
462
- const trigger = options.trigger;
462
+ const trigger = typeof options.trigger !== "undefined" ? options.trigger : "client";
463
463
  ScriptNetworkEvents.forEach((fn) => {
464
464
  const _fn = typeof input[fn] === "function" ? input[fn].bind(options.eventContext) : null;
465
465
  input[fn] = (e) => {
@@ -502,14 +502,12 @@ function useScript(_input, _options) {
502
502
  }
503
503
  };
504
504
  const hookCtx = { script };
505
- if (trigger) {
506
- if (trigger instanceof Promise)
507
- trigger.then(script.load);
508
- else if (typeof trigger === "function")
509
- trigger(script.load);
510
- } else {
505
+ if (trigger === "client" && !head.ssr || trigger === "server" && head.ssr)
511
506
  script.load();
512
- }
507
+ else if (trigger instanceof Promise)
508
+ trigger.then(script.load);
509
+ else if (typeof trigger === "function")
510
+ trigger(script.load);
513
511
  const removeHook = head.hooks.hook("dom:renderTag", (ctx) => {
514
512
  if (ctx.tag.key !== key)
515
513
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.9.3",
4
+ "version": "1.9.4",
5
5
  "author": {
6
6
  "name": "Harlan Wilton",
7
7
  "email": "harlan@harlanzw.com",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "hookable": "^5.5.3",
37
- "@unhead/dom": "1.9.3",
38
- "@unhead/schema": "1.9.3",
39
- "@unhead/shared": "1.9.3"
37
+ "@unhead/dom": "1.9.4",
38
+ "@unhead/schema": "1.9.4",
39
+ "@unhead/shared": "1.9.4"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild .",