@unhead/vue 1.9.1 → 1.9.3

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
@@ -101,23 +101,22 @@ function useScript(_input, _options) {
101
101
  options.head = head;
102
102
  options.eventContext = vue.getCurrentInstance();
103
103
  const status = vue.ref("awaitingLoad");
104
+ const stubOptions = options.stub;
104
105
  options.stub = ({ script, fn }) => {
105
- if (fn === "$script") {
106
- return Object.assign(script, {
107
- status
108
- });
109
- }
106
+ script.status = status;
107
+ if (fn === "$script")
108
+ return script;
109
+ return stubOptions?.({ script, fn });
110
110
  };
111
- const instance = unhead.useScript(input, options);
112
- function syncStatus({ script }) {
113
- if (script.id === instance.$script.id) {
111
+ let instance;
112
+ const rmHook = head.hooks.hook("script:updated", ({ script }) => {
113
+ if (instance && script.id === instance.$script.id) {
114
114
  status.value = script.status;
115
115
  if (script.status === "removed")
116
- head.hooks.removeHook("script:updated", syncStatus);
116
+ rmHook();
117
117
  }
118
- }
119
- head.hooks.hook("script:updated", syncStatus);
120
- return instance;
118
+ });
119
+ return instance = unhead.useScript(input, options);
121
120
  }
122
121
 
123
122
  exports.CapoPlugin = unhead.CapoPlugin;
package/dist/index.mjs CHANGED
@@ -101,23 +101,22 @@ function useScript(_input, _options) {
101
101
  options.head = head;
102
102
  options.eventContext = getCurrentInstance();
103
103
  const status = ref("awaitingLoad");
104
+ const stubOptions = options.stub;
104
105
  options.stub = ({ script, fn }) => {
105
- if (fn === "$script") {
106
- return Object.assign(script, {
107
- status
108
- });
109
- }
106
+ script.status = status;
107
+ if (fn === "$script")
108
+ return script;
109
+ return stubOptions?.({ script, fn });
110
110
  };
111
- const instance = useScript$1(input, options);
112
- function syncStatus({ script }) {
113
- if (script.id === instance.$script.id) {
111
+ let instance;
112
+ const rmHook = head.hooks.hook("script:updated", ({ script }) => {
113
+ if (instance && script.id === instance.$script.id) {
114
114
  status.value = script.status;
115
115
  if (script.status === "removed")
116
- head.hooks.removeHook("script:updated", syncStatus);
116
+ rmHook();
117
117
  }
118
- }
119
- head.hooks.hook("script:updated", syncStatus);
120
- return instance;
118
+ });
119
+ return instance = useScript$1(input, options);
121
120
  }
122
121
 
123
122
  export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "1.9.1",
4
+ "version": "1.9.3",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -61,9 +61,9 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "hookable": "^5.5.3",
64
- "unhead": "1.9.1",
65
- "@unhead/schema": "1.9.1",
66
- "@unhead/shared": "1.9.1"
64
+ "@unhead/shared": "1.9.3",
65
+ "@unhead/schema": "1.9.3",
66
+ "unhead": "1.9.3"
67
67
  },
68
68
  "devDependencies": {
69
69
  "vue": "^3.4.21"