unhead 1.9.6 → 1.9.7
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 +8 -4
- package/dist/index.mjs +8 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -526,16 +526,20 @@ function useScript(_input, _options) {
|
|
|
526
526
|
return stub;
|
|
527
527
|
if (fn === "$script")
|
|
528
528
|
return $script;
|
|
529
|
-
const attempt = (args) => {
|
|
529
|
+
const attempt = (api, args) => {
|
|
530
530
|
if (head.ssr)
|
|
531
531
|
return;
|
|
532
|
-
|
|
532
|
+
api = api || options.use?.();
|
|
533
533
|
const exists = !!(api && fn in api);
|
|
534
534
|
const hookCtx2 = { script, fn, args, exists };
|
|
535
535
|
head.hooks.callHook("script:instance-fn", hookCtx2);
|
|
536
|
-
|
|
536
|
+
if (exists) {
|
|
537
|
+
if (typeof api[fn] === "function")
|
|
538
|
+
return api[fn](...args || []);
|
|
539
|
+
return api[fn];
|
|
540
|
+
}
|
|
537
541
|
};
|
|
538
|
-
return attempt() || ((...args) => loadPromise.then(() => attempt(args)
|
|
542
|
+
return attempt() || ((...args) => loadPromise.then((api) => attempt(api, args)));
|
|
539
543
|
}
|
|
540
544
|
});
|
|
541
545
|
head._scripts = Object.assign(
|
package/dist/index.mjs
CHANGED
|
@@ -525,16 +525,20 @@ function useScript(_input, _options) {
|
|
|
525
525
|
return stub;
|
|
526
526
|
if (fn === "$script")
|
|
527
527
|
return $script;
|
|
528
|
-
const attempt = (args) => {
|
|
528
|
+
const attempt = (api, args) => {
|
|
529
529
|
if (head.ssr)
|
|
530
530
|
return;
|
|
531
|
-
|
|
531
|
+
api = api || options.use?.();
|
|
532
532
|
const exists = !!(api && fn in api);
|
|
533
533
|
const hookCtx2 = { script, fn, args, exists };
|
|
534
534
|
head.hooks.callHook("script:instance-fn", hookCtx2);
|
|
535
|
-
|
|
535
|
+
if (exists) {
|
|
536
|
+
if (typeof api[fn] === "function")
|
|
537
|
+
return api[fn](...args || []);
|
|
538
|
+
return api[fn];
|
|
539
|
+
}
|
|
536
540
|
};
|
|
537
|
-
return attempt() || ((...args) => loadPromise.then(() => attempt(args)
|
|
541
|
+
return attempt() || ((...args) => loadPromise.then((api) => attempt(api, args)));
|
|
538
542
|
}
|
|
539
543
|
});
|
|
540
544
|
head._scripts = Object.assign(
|
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.7",
|
|
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/shared": "1.9.
|
|
37
|
+
"@unhead/schema": "1.9.7",
|
|
38
|
+
"@unhead/dom": "1.9.7",
|
|
39
|
+
"@unhead/shared": "1.9.7"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild .",
|