unhead 1.9.9 → 1.9.11
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 +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -455,7 +455,6 @@ function useScript(_input, _options) {
|
|
|
455
455
|
const id = input.key || shared.hashCode(input.src || (typeof input.innerHTML === "string" ? input.innerHTML : ""));
|
|
456
456
|
if (head._scripts?.[id])
|
|
457
457
|
return head._scripts[id];
|
|
458
|
-
options.beforeInit?.();
|
|
459
458
|
const syncStatus = (s) => {
|
|
460
459
|
script.status = s;
|
|
461
460
|
head.hooks.callHook(`script:updated`, hookCtx);
|
|
@@ -473,8 +472,12 @@ function useScript(_input, _options) {
|
|
|
473
472
|
const _ = head.hooks.hook("script:updated", ({ script: script2 }) => {
|
|
474
473
|
if (script2.id === id && (script2.status === "loaded" || script2.status === "error")) {
|
|
475
474
|
if (script2.status === "loaded") {
|
|
476
|
-
|
|
477
|
-
|
|
475
|
+
if (typeof options.use === "function") {
|
|
476
|
+
const api = options.use();
|
|
477
|
+
api && resolve(api);
|
|
478
|
+
} else {
|
|
479
|
+
resolve({});
|
|
480
|
+
}
|
|
478
481
|
} else if (script2.status === "error") {
|
|
479
482
|
reject(new Error(`Failed to load script: ${input.src}`));
|
|
480
483
|
}
|
|
@@ -505,6 +508,7 @@ function useScript(_input, _options) {
|
|
|
505
508
|
defaults.crossorigin = "anonymous";
|
|
506
509
|
defaults.referrerpolicy = "no-referrer";
|
|
507
510
|
}
|
|
511
|
+
options.beforeInit?.();
|
|
508
512
|
script.entry = head.push({
|
|
509
513
|
script: [{ ...defaults, ...input, key: `script.${id}` }]
|
|
510
514
|
}, options);
|
package/dist/index.mjs
CHANGED
|
@@ -454,7 +454,6 @@ function useScript(_input, _options) {
|
|
|
454
454
|
const id = input.key || hashCode(input.src || (typeof input.innerHTML === "string" ? input.innerHTML : ""));
|
|
455
455
|
if (head._scripts?.[id])
|
|
456
456
|
return head._scripts[id];
|
|
457
|
-
options.beforeInit?.();
|
|
458
457
|
const syncStatus = (s) => {
|
|
459
458
|
script.status = s;
|
|
460
459
|
head.hooks.callHook(`script:updated`, hookCtx);
|
|
@@ -472,8 +471,12 @@ function useScript(_input, _options) {
|
|
|
472
471
|
const _ = head.hooks.hook("script:updated", ({ script: script2 }) => {
|
|
473
472
|
if (script2.id === id && (script2.status === "loaded" || script2.status === "error")) {
|
|
474
473
|
if (script2.status === "loaded") {
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
if (typeof options.use === "function") {
|
|
475
|
+
const api = options.use();
|
|
476
|
+
api && resolve(api);
|
|
477
|
+
} else {
|
|
478
|
+
resolve({});
|
|
479
|
+
}
|
|
477
480
|
} else if (script2.status === "error") {
|
|
478
481
|
reject(new Error(`Failed to load script: ${input.src}`));
|
|
479
482
|
}
|
|
@@ -504,6 +507,7 @@ function useScript(_input, _options) {
|
|
|
504
507
|
defaults.crossorigin = "anonymous";
|
|
505
508
|
defaults.referrerpolicy = "no-referrer";
|
|
506
509
|
}
|
|
510
|
+
options.beforeInit?.();
|
|
507
511
|
script.entry = head.push({
|
|
508
512
|
script: [{ ...defaults, ...input, key: `script.${id}` }]
|
|
509
513
|
}, options);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unhead",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.11",
|
|
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/
|
|
38
|
-
"@unhead/
|
|
39
|
-
"@unhead/
|
|
37
|
+
"@unhead/dom": "1.9.11",
|
|
38
|
+
"@unhead/shared": "1.9.11",
|
|
39
|
+
"@unhead/schema": "1.9.11"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild .",
|