@unhead/vue 1.8.0-beta.8 → 1.8.0-beta.9

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
@@ -103,11 +103,8 @@ function useScript(_input, _options) {
103
103
  const status = vue.ref("awaitingLoad");
104
104
  shared.NetworkEvents.forEach((fn) => {
105
105
  const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
106
- if (_fn || fn === "onload" || fn === "onerror") {
107
- input[fn] = (e) => {
108
- status.value = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
109
- _fn && _fn(e);
110
- };
106
+ if (_fn) {
107
+ input[fn] = (e) => _fn(e);
111
108
  }
112
109
  });
113
110
  options.stub = ({ script, fn }) => {
@@ -119,7 +116,16 @@ function useScript(_input, _options) {
119
116
  };
120
117
  }
121
118
  };
122
- return unhead.useScript(input, options);
119
+ const instance = unhead.useScript(input, options);
120
+ function syncStatus({ script }) {
121
+ if (script.id === instance.$script.id) {
122
+ status.value = script.status;
123
+ if (script.status === "removed")
124
+ head.hooks.removeHook(`script:updated`, syncStatus);
125
+ }
126
+ }
127
+ head.hooks.hook(`script:updated`, syncStatus);
128
+ return instance;
123
129
  }
124
130
 
125
131
  exports.CapoPlugin = unhead.CapoPlugin;
package/dist/index.mjs CHANGED
@@ -103,11 +103,8 @@ function useScript(_input, _options) {
103
103
  const status = ref("awaitingLoad");
104
104
  NetworkEvents.forEach((fn) => {
105
105
  const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
106
- if (_fn || fn === "onload" || fn === "onerror") {
107
- input[fn] = (e) => {
108
- status.value = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
109
- _fn && _fn(e);
110
- };
106
+ if (_fn) {
107
+ input[fn] = (e) => _fn(e);
111
108
  }
112
109
  });
113
110
  options.stub = ({ script, fn }) => {
@@ -119,7 +116,16 @@ function useScript(_input, _options) {
119
116
  };
120
117
  }
121
118
  };
122
- return useScript$1(input, options);
119
+ const instance = useScript$1(input, options);
120
+ function syncStatus({ script }) {
121
+ if (script.id === instance.$script.id) {
122
+ status.value = script.status;
123
+ if (script.status === "removed")
124
+ head.hooks.removeHook(`script:updated`, syncStatus);
125
+ }
126
+ }
127
+ head.hooks.hook(`script:updated`, syncStatus);
128
+ return instance;
123
129
  }
124
130
 
125
131
  export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, resolveUnrefHeadInput, 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.8.0-beta.8",
4
+ "version": "1.8.0-beta.9",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -48,9 +48,9 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "hookable": "^5.5.3",
51
- "@unhead/schema": "1.8.0-beta.8",
52
- "@unhead/shared": "1.8.0-beta.8",
53
- "unhead": "1.8.0-beta.8"
51
+ "@unhead/schema": "1.8.0-beta.9",
52
+ "@unhead/shared": "1.8.0-beta.9",
53
+ "unhead": "1.8.0-beta.9"
54
54
  },
55
55
  "devDependencies": {
56
56
  "vue": "^3.3.4"