unhead 1.8.18 → 1.8.19

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
@@ -457,62 +457,6 @@ function useServerSeoMeta(input, options) {
457
457
  });
458
458
  }
459
459
 
460
- function isPlainObject(value) {
461
- if (value === null || typeof value !== "object") {
462
- return false;
463
- }
464
- const prototype = Object.getPrototypeOf(value);
465
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
466
- return false;
467
- }
468
- if (Symbol.iterator in value) {
469
- return false;
470
- }
471
- if (Symbol.toStringTag in value) {
472
- return Object.prototype.toString.call(value) === "[object Module]";
473
- }
474
- return true;
475
- }
476
-
477
- function _defu(baseObject, defaults, namespace = ".", merger) {
478
- if (!isPlainObject(defaults)) {
479
- return _defu(baseObject, {}, namespace, merger);
480
- }
481
- const object = Object.assign({}, defaults);
482
- for (const key in baseObject) {
483
- if (key === "__proto__" || key === "constructor") {
484
- continue;
485
- }
486
- const value = baseObject[key];
487
- if (value === null || value === void 0) {
488
- continue;
489
- }
490
- if (merger && merger(object, key, value, namespace)) {
491
- continue;
492
- }
493
- if (Array.isArray(value) && Array.isArray(object[key])) {
494
- object[key] = [...value, ...object[key]];
495
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
496
- object[key] = _defu(
497
- value,
498
- object[key],
499
- (namespace ? `${namespace}.` : "") + key.toString(),
500
- merger
501
- );
502
- } else {
503
- object[key] = value;
504
- }
505
- }
506
- return object;
507
- }
508
- function createDefu(merger) {
509
- return (...arguments_) => (
510
- // eslint-disable-next-line unicorn/no-array-reduce
511
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
512
- );
513
- }
514
- const defu = createDefu();
515
-
516
460
  const UseScriptDefaults = {
517
461
  defer: true,
518
462
  fetchpriority: "low"
@@ -572,7 +516,7 @@ function useScript(_input, _options) {
572
516
  waitForLoad() {
573
517
  return new Promise((resolve) => {
574
518
  if (script.status === "loaded")
575
- resolve(options.use());
519
+ resolve(options.use?.());
576
520
  function watchForScriptLoaded({ script: script2 }) {
577
521
  if (script2.id === id && script2.status === "loaded") {
578
522
  script2.loaded = true;
@@ -599,9 +543,6 @@ function useScript(_input, _options) {
599
543
  transform,
600
544
  head
601
545
  });
602
- head._scripts = defu(head._scripts, {
603
- [id]: script
604
- });
605
546
  return script.waitForLoad();
606
547
  }
607
548
  };
@@ -612,9 +553,6 @@ function useScript(_input, _options) {
612
553
  script.status = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
613
554
  head.hooks.callHook(`script:updated`, hookCtx);
614
555
  _fn && _fn(e);
615
- head._scripts = defu(head._scripts, {
616
- [id]: script
617
- });
618
556
  };
619
557
  });
620
558
  let trigger = options.trigger;
package/dist/index.mjs CHANGED
@@ -456,62 +456,6 @@ function useServerSeoMeta(input, options) {
456
456
  });
457
457
  }
458
458
 
459
- function isPlainObject(value) {
460
- if (value === null || typeof value !== "object") {
461
- return false;
462
- }
463
- const prototype = Object.getPrototypeOf(value);
464
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
465
- return false;
466
- }
467
- if (Symbol.iterator in value) {
468
- return false;
469
- }
470
- if (Symbol.toStringTag in value) {
471
- return Object.prototype.toString.call(value) === "[object Module]";
472
- }
473
- return true;
474
- }
475
-
476
- function _defu(baseObject, defaults, namespace = ".", merger) {
477
- if (!isPlainObject(defaults)) {
478
- return _defu(baseObject, {}, namespace, merger);
479
- }
480
- const object = Object.assign({}, defaults);
481
- for (const key in baseObject) {
482
- if (key === "__proto__" || key === "constructor") {
483
- continue;
484
- }
485
- const value = baseObject[key];
486
- if (value === null || value === void 0) {
487
- continue;
488
- }
489
- if (merger && merger(object, key, value, namespace)) {
490
- continue;
491
- }
492
- if (Array.isArray(value) && Array.isArray(object[key])) {
493
- object[key] = [...value, ...object[key]];
494
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
495
- object[key] = _defu(
496
- value,
497
- object[key],
498
- (namespace ? `${namespace}.` : "") + key.toString(),
499
- merger
500
- );
501
- } else {
502
- object[key] = value;
503
- }
504
- }
505
- return object;
506
- }
507
- function createDefu(merger) {
508
- return (...arguments_) => (
509
- // eslint-disable-next-line unicorn/no-array-reduce
510
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
511
- );
512
- }
513
- const defu = createDefu();
514
-
515
459
  const UseScriptDefaults = {
516
460
  defer: true,
517
461
  fetchpriority: "low"
@@ -571,7 +515,7 @@ function useScript(_input, _options) {
571
515
  waitForLoad() {
572
516
  return new Promise((resolve) => {
573
517
  if (script.status === "loaded")
574
- resolve(options.use());
518
+ resolve(options.use?.());
575
519
  function watchForScriptLoaded({ script: script2 }) {
576
520
  if (script2.id === id && script2.status === "loaded") {
577
521
  script2.loaded = true;
@@ -598,9 +542,6 @@ function useScript(_input, _options) {
598
542
  transform,
599
543
  head
600
544
  });
601
- head._scripts = defu(head._scripts, {
602
- [id]: script
603
- });
604
545
  return script.waitForLoad();
605
546
  }
606
547
  };
@@ -611,9 +552,6 @@ function useScript(_input, _options) {
611
552
  script.status = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
612
553
  head.hooks.callHook(`script:updated`, hookCtx);
613
554
  _fn && _fn(e);
614
- head._scripts = defu(head._scripts, {
615
- [id]: script
616
- });
617
555
  };
618
556
  });
619
557
  let trigger = options.trigger;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.8.18",
4
+ "version": "1.8.19",
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/schema": "1.8.18",
38
- "@unhead/dom": "1.8.18",
39
- "@unhead/shared": "1.8.18"
37
+ "@unhead/dom": "1.8.19",
38
+ "@unhead/schema": "1.8.19",
39
+ "@unhead/shared": "1.8.19"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild .",