Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-meta

Package Overview
Dependencies
Maintainers
3
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-meta - npm Package Compare versions

Comparing version 3.0.0-alpha.4 to 3.0.0-alpha.5

ssr/index.js

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

## [3.0.0-alpha.5](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2021-05-03)
### Bug Fixes
* apply diff on nested computed objects ([29b294c](https://github.com/nuxt/vue-meta/commit/29b294c2be1bdbb57d6341871df72848c9d0b034))
* dont include ssr support in main dist ([5699bf4](https://github.com/nuxt/vue-meta/commit/5699bf4ff202a731830621583183dd8ae97a2c7c))
## [3.0.0-alpha.4](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2021-04-11)

@@ -7,0 +15,0 @@

41

dist/vue-meta.cjs.js
/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -15,14 +15,2 @@ * - Pim (@pimlie)

function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
n[k] = e[k];
});
}
n['default'] = e;
return Object.freeze(n);
}
const resolveOption = (predicament, initialValue) => (options, contexts) => {

@@ -334,3 +322,3 @@ let resolvedIndex = -1;

const success = Reflect.set(target, key, value);
// console.warn(success, 'PROXY SET\nkey:', key, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
// console.warn(success, 'PROXY SET\nkey:', key, '\nvalue:', value, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
if (success) {

@@ -666,5 +654,4 @@ const isArrayItem = isArray(target);

}
// We dont care about nested objects here , these changes
// should already have been tracked by the MergeProxy
if (isObject(target[key])) {
applyDifference(target[key], newSource[key], oldSource[key]);
continue;

@@ -702,3 +689,2 @@ }

vue.watch(source, (newSource, oldSource) => {
// We only care about first level props, second+ level will already be changed by the merge proxy
applyDifference(metaProxy.meta, newSource, oldSource);

@@ -870,22 +856,2 @@ });

async function renderToStringWithMeta(app) {
const { renderToString } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@vue/server-renderer')); });
const ctx = {};
const html = await renderToString(app, ctx);
// TODO: better way of determining whether meta was rendered with the component or not
if (!ctx.teleports || !ctx.teleports.head) {
const teleports = app.config.globalProperties.$metaManager.render();
await Promise.all(teleports.map((teleport) => renderToString(teleport, ctx)));
}
const { teleports } = ctx;
for (const target in teleports) {
if (target.endsWith('Attrs')) {
const str = teleports[target];
// match from first space to first >, these should be all rendered attributes
teleports[target] = str.slice(str.indexOf(' ') + 1, str.indexOf('>'));
}
}
return [html, ctx];
}
exports.createMetaManager = createMetaManager;

@@ -895,5 +861,4 @@ exports.deepestResolver = defaultResolver;

exports.getCurrentManager = getCurrentManager;
exports.renderToStringWithMeta = renderToStringWithMeta;
exports.resolveOption = resolveOption;
exports.useActiveMeta = useActiveMeta;
exports.useMeta = useMeta;
/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -15,14 +15,2 @@ * - Pim (@pimlie)

function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
n[k] = e[k];
});
}
n['default'] = e;
return Object.freeze(n);
}
const resolveOption = (predicament, initialValue) => (options, contexts) => {

@@ -331,3 +319,3 @@ let resolvedIndex = -1;

const success = Reflect.set(target, key, value);
// console.warn(success, 'PROXY SET\nkey:', key, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
// console.warn(success, 'PROXY SET\nkey:', key, '\nvalue:', value, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
if (success) {

@@ -659,5 +647,4 @@ const isArrayItem = isArray(target);

}
// We dont care about nested objects here , these changes
// should already have been tracked by the MergeProxy
if (isObject(target[key])) {
applyDifference(target[key], newSource[key], oldSource[key]);
continue;

@@ -695,3 +682,2 @@ }

vue.watch(source, (newSource, oldSource) => {
// We only care about first level props, second+ level will already be changed by the merge proxy
applyDifference(metaProxy.meta, newSource, oldSource);

@@ -863,22 +849,2 @@ });

async function renderToStringWithMeta(app) {
const { renderToString } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@vue/server-renderer')); });
const ctx = {};
const html = await renderToString(app, ctx);
// TODO: better way of determining whether meta was rendered with the component or not
if (!ctx.teleports || !ctx.teleports.head) {
const teleports = app.config.globalProperties.$metaManager.render();
await Promise.all(teleports.map((teleport) => renderToString(teleport, ctx)));
}
const { teleports } = ctx;
for (const target in teleports) {
if (target.endsWith('Attrs')) {
const str = teleports[target];
// match from first space to first >, these should be all rendered attributes
teleports[target] = str.slice(str.indexOf(' ') + 1, str.indexOf('>'));
}
}
return [html, ctx];
}
exports.createMetaManager = createMetaManager;

@@ -888,5 +854,4 @@ exports.deepestResolver = defaultResolver;

exports.getCurrentManager = getCurrentManager;
exports.renderToStringWithMeta = renderToStringWithMeta;
exports.resolveOption = resolveOption;
exports.useActiveMeta = useActiveMeta;
exports.useMeta = useMeta;
import { App, ComponentInternalInstance, Slots, VNode } from 'vue';
import { SSRContext } from '@vue/server-renderer';

@@ -207,4 +206,2 @@ declare const IS_PROXY: unique symbol;

declare function renderToStringWithMeta(app: App): Promise<[string, SSRContext]>;
declare function getCurrentManager(vm?: ComponentInternalInstance): MetaManager | undefined;

@@ -214,2 +211,2 @@ declare function useMeta(source: MetaSource, manager?: MetaManager): MetaProxy;

export { MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, renderToStringWithMeta, resolveOption, useActiveMeta, useMeta };
export { MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -317,3 +317,3 @@ * - Pim (@pimlie)

const success = Reflect.set(target, key, value);
// console.warn(success, 'PROXY SET\nkey:', key, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
// console.warn(success, 'PROXY SET\nkey:', key, '\nvalue:', value, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
if (success) {

@@ -670,5 +670,4 @@ const isArrayItem = isArray(target);

}
// We dont care about nested objects here , these changes
// should already have been tracked by the MergeProxy
if (isObject(target[key])) {
applyDifference(target[key], newSource[key], oldSource[key]);
continue;

@@ -706,3 +705,2 @@ }

watch(source, (newSource, oldSource) => {
// We only care about first level props, second+ level will already be changed by the merge proxy
applyDifference(metaProxy.meta, newSource, oldSource);

@@ -709,0 +707,0 @@ });

/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -8,2 +8,2 @@ * - Pim (@pimlie)

*/
import{markRaw as t,h as e,getCurrentInstance as o,isProxy as r,watch as n,inject as s,defineComponent as i,reactive as c,onUnmounted as a,Teleport as u,Comment as l}from"vue";const f=(t,e)=>(o,r)=>{let n=-1;if(r.reduce(((e,o,r)=>{const s=t(e,o);return s!==e?(n=r,s):e}),e),n>-1)return o[n]};const d=f(((t,e)=>{const{depth:o}=e;return!t||o>t?o:t}));var p=Object.freeze({__proto__:null,setup:function(t){let e=0;if(t.vm){let{vm:o}=t;do{o.parent&&(e++,o=o.parent)}while(o&&o.parent&&o!==o.root)}t.depth=e},resolve:d});const m={body:{tag:"script",to:"body"},base:{valueAttribute:"href"},charset:{tag:"meta",nameless:!0,valueAttribute:"charset"},description:{tag:"meta"},og:{group:!0,namespacedAttribute:!0,tag:"meta",keyAttribute:"property"},twitter:{group:!0,namespacedAttribute:!0,tag:"meta"},htmlAttrs:{attributesFor:"html"},headAttrs:{attributesFor:"head"},bodyAttrs:{attributesFor:"body"}},b={title:{attributes:!1},base:{contentAsAttribute:!0,attributes:["href","target"]},meta:{contentAsAttribute:!0,keyAttribute:"name",attributes:["content","name","http-equiv","charset"]},link:{contentAsAttribute:!0,attributes:["href","crossorigin","rel","media","integrity","hreflang","type","referrerpolicy","sizes","imagesrcset","imagesizes","as","color"]},style:{attributes:["media"]},script:{attributes:["src","type","nomodule","async","defer","crossorigin","integrity","referrerpolicy"]},noscript:{attributes:!1}};Object.freeze({}),Object.freeze([]);const h=Array.isArray,y=t=>"function"==typeof t,g=t=>"string"==typeof t,v=t=>null!==t&&"object"==typeof t,A=Object.prototype.toString,S=t=>"[object Object]"===A.call(t),k=Symbol("kIsProxy"),w=Symbol("kProxySources"),j=Symbol("kProxyTarget"),N=Symbol("kResolveContext");function O(t){if(h(t))return t.map(O);if(v(t)){const e={};for(const o in t)e[o]="context"===o?t[o]:O(t[o]);return e}return t}const x=(t,e,o)=>{const r=[];for(const n of t)e in n&&(r.push(n[e]),o&&o(n));return r},$=(t,e,o,r=[])=>{if(r.length||(o||(o=t.active),e||(e=t.sources)),!o||!e)return;const n=((t,...e)=>{const o=t?Object.keys(t):[];if(e)for(const t of e)if(t&&v(t))for(const e in t)o.includes(e)||o.push(e);return o})(...e),s=Object.keys(o);for(const t of s)n.includes(t)||delete o[t];for(const s of n){if(S(e[0][s])){o[s]||(o[s]={});const n=[];for(const t of e)s in t&&n.push(t[s]);$(t,n,o[s],[...r,s]);continue}!o[s]&&h(e[0][s])&&(o[s]=[]);const n=[],i=x(e,s,(t=>n.push(t[N])));let c=t.resolve(i,n,o[s],s,r);S(c)&&(c=O(c)),o[s]=c}},P=(e,o,r,n=[])=>{const s=C(e,r,n),i=t(new Proxy(o,s));return!n.length&&e.sources&&e.sources.push(i),i},C=(t,e,o=[])=>({get:(r,n,s)=>{if(n===k)return!0;if(n===w)return t.sources;if(n===j)return r;if(n===N)return e;let i=Reflect.get(r,n,s);if(!v(i))return i;if(!i[k]){const s=[...o,n];i=P(t,i,e,s),Reflect.set(r,n,i)}return i},set:(e,r,n)=>{const s=Reflect.set(e,r,n);if(s){const n=h(e);let i,c=!1,{sources:a,active:u}=t,l=0;for(const t of o){if(a=x(a,t),n&&l===o.length-1){i=t;break}h(u)&&(c=!0),u=u[t],l++}if(c)return $(t),s;let f,d=[];n?(f=a,d=a.map((t=>t[N]))):f=x(a,r,(t=>d.push(t[N])));let p=t.resolve(f,d,u,r,o);S(p)&&(p=O(p)),n&&i?u[i]=p:u[r]=p}return s},deleteProperty:(e,r)=>{const n=Reflect.deleteProperty(e,r);if(n){const n=h(e);let s,i=t.sources,c=t.active,a=0;for(const t of o){if(i=i.map((e=>e[t])),n&&a===o.length-1){s=t;break}c=c[t],a++}if(i.some((t=>r in t))){let e,a=[];n?(e=i,a=i.map((t=>t[N]))):e=x(i,r,(t=>a.push(t[N])));let u=t.resolve(e,a,c,r,o);S(u)&&(u=O(u)),n&&s?c[s]=u:c[r]=u}else delete c[r]}return n}}),M={};function F(t,e,o,r){return"attributesFor"in r?function(t,e,o,r){const{attributesFor:n}=r;if(!n)return;if(!M[n]){const[t,e]=Array.from(document.querySelectorAll(n));if(!t)return void console.error("Could not find element for selector",n,", won't render attributes");e&&console.warn("Found multiple elements for selector",n),M[n]={el:t,attrs:[]}}const{el:s,attrs:i}=M[n];for(const r in o){const n=U(t,`${e}(${r})`,o[r],o);s.setAttribute(r,n||""),i.includes(r)||i.push(r)}const c=i.filter((t=>!o[t]));for(const t of c)s.removeAttribute(t)}(t,e,o,r):"group"in r?function(t,e,o,r){if(h(o))return console.warn("Specifying an array for group properties isnt supported"),[];return Object.keys(o).map((n=>{const s={group:e,data:o};if(r.namespaced)s.tagNamespace=!0===r.namespaced?e:r.namespaced;else if(r.namespacedAttribute){const t=!0===r.namespacedAttribute?e:r.namespacedAttribute;s.fullName=`${t}:${n}`,s.slotName=`${t}(${n})`}return R(t,e,o[n],r,s)})).flat()}(t,e,o,r):R(t,e,o,r)}function R(t,o,r,n={},s){const i=["content","json","rawContent"],c=t=>function(t,e){for(const o of t){const t=b[o];if(o&&t)return t[e]}}([a,n.tag],t);if(h(r))return r.map((e=>R(t,o,e,n,s))).flat();const{tag:a=n.tag||o}=r;let u="",l=!1,f=!1;if(g(r))u=r;else if(r.children&&h(r.children))l=!0,u=r.children.map((e=>{const r=R(t,o,e,n,s);return h(r)?r.map((({vnode:t})=>t)):r.vnode}));else{let t=0;for(const e of i){if(!u&&r[e]){u=1===t?JSON.stringify(r[e]):r[e],f=t>1;break}t++}}const d=s&&s.fullName||o,p=s&&s.slotName||o;let{attrs:m}=r;if(m||"object"!=typeof r)m||(m={});else{m={...r},delete m.tag,delete m.children,delete m.to;for(const t of i)delete m[t]}if(l)u=U(t,p,u,r);else{const e=!!c("contentAsAttribute");let{valueAttribute:o}=n;if(!o&&e){const[t]=c("attributes");o=g(e)?e:t}if(o){const{nameless:e,keyAttribute:r}=n;e||r&&(m[r]=d),m[o]=U(t,p,m[o]||u,s),u=""}else u=U(t,p,u,r)}const y=s&&s.tagNamespace?`${s.tagNamespace}:${a}`:a;f&&u&&(m.innerHTML=u);const v=e(y,m,u||void 0);return{to:r.to,vnode:v}}function U({metainfo:t,slots:e},o,r,n){const s=e&&e[o];if(!s||!y(s))return r;const i={content:r,metainfo:t};if(n&&n.group){const{group:t,data:e}=n;i[t]=e}const c=s(i);if(c&&c.length){const{children:t}=c[0];return t?t.toString():""}return r}const z="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,E=(t=>z?Symbol("[vue-meta]: "+t):"[vue-meta]: "+t)("meta_active");function _(t){if(t||(t=o()||void 0),t)return t.appContext.config.globalProperties.$metaManager}function L(t,e){const s=o()||void 0;if(!e&&s&&(e=_(s)),!e)throw new Error("No manager or current instance");r(t)&&(n(t,((t,e)=>{!function(t,e,o){for(const r in e)r in o?v(t[r])||e[r]!==o[r]&&(t[r]=e[r]):t[r]=e[r];for(const r in o)r in e||delete t[r]}(i.meta,t,e)})),t=t.value);const i=e.addMeta(t,s);return i}function q(){return s(E)}const T=i({name:"Metainfo",inheritAttrs:!1,setup:(t,{slots:e})=>()=>{const t=_();if(t)return t.render({slots:e})}}),I=c({});function D(t,e,o){const r=h(o)?o:[o];r.forEach(((t,e)=>{t.type===l&&r.splice(e,1)})),t[e]||(t[e]=[]),t[e].push(...r)}const H=(t,e)=>J.create(t||m,e||p);class J{constructor(t,e,o){this.ssrCleanedUp=!1,this.config=t,this.target=e,o&&"setup"in o&&y(o.setup)&&(this.resolver=o)}install(t){t.component("Metainfo",T),t.config.globalProperties.$metaManager=this,t.provide(E,I)}addMeta(t,e){e||(e=o()||void 0);const r={removed:[]},n={vm:e};this.resolver&&this.resolver.setup(n);const s=this.target.addSource(t,n,!0),i=t=>this.unmount(!!t,s,r,e);return e&&a(i),{meta:s,onRemoved:t=>r.removed.push(t),unmount:i}}unmount(t,e,o,r){if(r){const{$el:n}=r.proxy;if(n&&n.offsetParent){let r=new MutationObserver((s=>{for(const{removedNodes:i}of s)i&&i.forEach((s=>{s===n&&r&&(r.disconnect(),r=void 0,this.reallyUnmount(t,e,o))}))}));return void r.observe(n.parentNode,{childList:!0})}}this.reallyUnmount(t,e,o)}async reallyUnmount(t,e,o){this.target.delSource(e),!t&&o&&await Promise.all(o.removed.map((t=>t())))}render({slots:t}={}){this.ssrCleanedUp||(this.ssrCleanedUp=!0,window.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll("[data-vm-ssr]");t&&t.length&&Array.from(t).forEach((t=>t.parentNode&&t.parentNode.removeChild(t)))})));const o={};for(const e in I){const r=this.config[e]||{};let n=F({metainfo:I,slots:t},e,I[e],r);if(!n)continue;h(n)||(n=[n]);let s="base"!==e&&I[e].to;!s&&"to"in r&&(s=r.to),!s&&"attributesFor"in r&&(s=e);for(const{to:t,vnode:e}of n)D(o,t||s||"head",e)}if(t)for(const e in t){const r="default"===e?"head":e;if("head"!==r&&"body"!==r)continue;const n=t[e];y(n)&&D(o,r,n({metainfo:I}))}return Object.keys(o).map((t=>e(u,{to:t},o[t])))}}J.create=(t,e)=>{const o=((t,e)=>{const o=[],r={active:e,resolve:t,sources:o},n=()=>$(r);return{context:r,compute:n,addSource:(t,e,o=!1)=>{const s=P(r,t,e||{});return o&&n(),s},delSource:(t,e=!0)=>{const r=o.findIndex((e=>e===t||e[j]===t));return r>-1&&(o.splice(r,1),e&&n(),!0)}}})(((t,o,r,n,s)=>y(e)?e(t,o,r,n,s):e.resolve(t,o,r,n,s)),I);return new J(t,o,e)};export{H as createMetaManager,p as deepestResolver,m as defaultConfig,_ as getCurrentManager,f as resolveOption,q as useActiveMeta,L as useMeta};
import{markRaw as t,h as e,getCurrentInstance as o,isProxy as r,watch as n,inject as s,defineComponent as i,reactive as c,onUnmounted as a,Teleport as u,Comment as l}from"vue";const f=(t,e)=>(o,r)=>{let n=-1;if(r.reduce(((e,o,r)=>{const s=t(e,o);return s!==e?(n=r,s):e}),e),n>-1)return o[n]};const d=f(((t,e)=>{const{depth:o}=e;return!t||o>t?o:t}));var p=Object.freeze({__proto__:null,setup:function(t){let e=0;if(t.vm){let{vm:o}=t;do{o.parent&&(e++,o=o.parent)}while(o&&o.parent&&o!==o.root)}t.depth=e},resolve:d});const m={body:{tag:"script",to:"body"},base:{valueAttribute:"href"},charset:{tag:"meta",nameless:!0,valueAttribute:"charset"},description:{tag:"meta"},og:{group:!0,namespacedAttribute:!0,tag:"meta",keyAttribute:"property"},twitter:{group:!0,namespacedAttribute:!0,tag:"meta"},htmlAttrs:{attributesFor:"html"},headAttrs:{attributesFor:"head"},bodyAttrs:{attributesFor:"body"}},b={title:{attributes:!1},base:{contentAsAttribute:!0,attributes:["href","target"]},meta:{contentAsAttribute:!0,keyAttribute:"name",attributes:["content","name","http-equiv","charset"]},link:{contentAsAttribute:!0,attributes:["href","crossorigin","rel","media","integrity","hreflang","type","referrerpolicy","sizes","imagesrcset","imagesizes","as","color"]},style:{attributes:["media"]},script:{attributes:["src","type","nomodule","async","defer","crossorigin","integrity","referrerpolicy"]},noscript:{attributes:!1}};Object.freeze({}),Object.freeze([]);const h=Array.isArray,y=t=>"function"==typeof t,g=t=>"string"==typeof t,v=t=>null!==t&&"object"==typeof t,A=Object.prototype.toString,S=t=>"[object Object]"===A.call(t),k=Symbol("kIsProxy"),w=Symbol("kProxySources"),j=Symbol("kProxyTarget"),N=Symbol("kResolveContext");function O(t){if(h(t))return t.map(O);if(v(t)){const e={};for(const o in t)e[o]="context"===o?t[o]:O(t[o]);return e}return t}const x=(t,e,o)=>{const r=[];for(const n of t)e in n&&(r.push(n[e]),o&&o(n));return r},$=(t,e,o,r=[])=>{if(r.length||(o||(o=t.active),e||(e=t.sources)),!o||!e)return;const n=((t,...e)=>{const o=t?Object.keys(t):[];if(e)for(const t of e)if(t&&v(t))for(const e in t)o.includes(e)||o.push(e);return o})(...e),s=Object.keys(o);for(const t of s)n.includes(t)||delete o[t];for(const s of n){if(S(e[0][s])){o[s]||(o[s]={});const n=[];for(const t of e)s in t&&n.push(t[s]);$(t,n,o[s],[...r,s]);continue}!o[s]&&h(e[0][s])&&(o[s]=[]);const n=[],i=x(e,s,(t=>n.push(t[N])));let c=t.resolve(i,n,o[s],s,r);S(c)&&(c=O(c)),o[s]=c}},P=(e,o,r,n=[])=>{const s=C(e,r,n),i=t(new Proxy(o,s));return!n.length&&e.sources&&e.sources.push(i),i},C=(t,e,o=[])=>({get:(r,n,s)=>{if(n===k)return!0;if(n===w)return t.sources;if(n===j)return r;if(n===N)return e;let i=Reflect.get(r,n,s);if(!v(i))return i;if(!i[k]){const s=[...o,n];i=P(t,i,e,s),Reflect.set(r,n,i)}return i},set:(e,r,n)=>{const s=Reflect.set(e,r,n);if(s){const n=h(e);let i,c=!1,{sources:a,active:u}=t,l=0;for(const t of o){if(a=x(a,t),n&&l===o.length-1){i=t;break}h(u)&&(c=!0),u=u[t],l++}if(c)return $(t),s;let f,d=[];n?(f=a,d=a.map((t=>t[N]))):f=x(a,r,(t=>d.push(t[N])));let p=t.resolve(f,d,u,r,o);S(p)&&(p=O(p)),n&&i?u[i]=p:u[r]=p}return s},deleteProperty:(e,r)=>{const n=Reflect.deleteProperty(e,r);if(n){const n=h(e);let s,i=t.sources,c=t.active,a=0;for(const t of o){if(i=i.map((e=>e[t])),n&&a===o.length-1){s=t;break}c=c[t],a++}if(i.some((t=>r in t))){let e,a=[];n?(e=i,a=i.map((t=>t[N]))):e=x(i,r,(t=>a.push(t[N])));let u=t.resolve(e,a,c,r,o);S(u)&&(u=O(u)),n&&s?c[s]=u:c[r]=u}else delete c[r]}return n}}),M={};function F(t,e,o,r){return"attributesFor"in r?function(t,e,o,r){const{attributesFor:n}=r;if(!n)return;if(!M[n]){const[t,e]=Array.from(document.querySelectorAll(n));if(!t)return void console.error("Could not find element for selector",n,", won't render attributes");e&&console.warn("Found multiple elements for selector",n),M[n]={el:t,attrs:[]}}const{el:s,attrs:i}=M[n];for(const r in o){const n=U(t,`${e}(${r})`,o[r],o);s.setAttribute(r,n||""),i.includes(r)||i.push(r)}const c=i.filter((t=>!o[t]));for(const t of c)s.removeAttribute(t)}(t,e,o,r):"group"in r?function(t,e,o,r){if(h(o))return console.warn("Specifying an array for group properties isnt supported"),[];return Object.keys(o).map((n=>{const s={group:e,data:o};if(r.namespaced)s.tagNamespace=!0===r.namespaced?e:r.namespaced;else if(r.namespacedAttribute){const t=!0===r.namespacedAttribute?e:r.namespacedAttribute;s.fullName=`${t}:${n}`,s.slotName=`${t}(${n})`}return R(t,e,o[n],r,s)})).flat()}(t,e,o,r):R(t,e,o,r)}function R(t,o,r,n={},s){const i=["content","json","rawContent"],c=t=>function(t,e){for(const o of t){const t=b[o];if(o&&t)return t[e]}}([a,n.tag],t);if(h(r))return r.map((e=>R(t,o,e,n,s))).flat();const{tag:a=n.tag||o}=r;let u="",l=!1,f=!1;if(g(r))u=r;else if(r.children&&h(r.children))l=!0,u=r.children.map((e=>{const r=R(t,o,e,n,s);return h(r)?r.map((({vnode:t})=>t)):r.vnode}));else{let t=0;for(const e of i){if(!u&&r[e]){u=1===t?JSON.stringify(r[e]):r[e],f=t>1;break}t++}}const d=s&&s.fullName||o,p=s&&s.slotName||o;let{attrs:m}=r;if(m||"object"!=typeof r)m||(m={});else{m={...r},delete m.tag,delete m.children,delete m.to;for(const t of i)delete m[t]}if(l)u=U(t,p,u,r);else{const e=!!c("contentAsAttribute");let{valueAttribute:o}=n;if(!o&&e){const[t]=c("attributes");o=g(e)?e:t}if(o){const{nameless:e,keyAttribute:r}=n;e||r&&(m[r]=d),m[o]=U(t,p,m[o]||u,s),u=""}else u=U(t,p,u,r)}const y=s&&s.tagNamespace?`${s.tagNamespace}:${a}`:a;f&&u&&(m.innerHTML=u);const v=e(y,m,u||void 0);return{to:r.to,vnode:v}}function U({metainfo:t,slots:e},o,r,n){const s=e&&e[o];if(!s||!y(s))return r;const i={content:r,metainfo:t};if(n&&n.group){const{group:t,data:e}=n;i[t]=e}const c=s(i);if(c&&c.length){const{children:t}=c[0];return t?t.toString():""}return r}const z="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,E=(t=>z?Symbol("[vue-meta]: "+t):"[vue-meta]: "+t)("meta_active");function _(t,e,o){for(const r in e)r in o?v(t[r])?_(t[r],e[r],o[r]):e[r]!==o[r]&&(t[r]=e[r]):t[r]=e[r];for(const r in o)r in e||delete t[r]}function L(t){if(t||(t=o()||void 0),t)return t.appContext.config.globalProperties.$metaManager}function q(t,e){const s=o()||void 0;if(!e&&s&&(e=L(s)),!e)throw new Error("No manager or current instance");r(t)&&(n(t,((t,e)=>{_(i.meta,t,e)})),t=t.value);const i=e.addMeta(t,s);return i}function T(){return s(E)}const I=i({name:"Metainfo",inheritAttrs:!1,setup:(t,{slots:e})=>()=>{const t=L();if(t)return t.render({slots:e})}}),D=c({});function H(t,e,o){const r=h(o)?o:[o];r.forEach(((t,e)=>{t.type===l&&r.splice(e,1)})),t[e]||(t[e]=[]),t[e].push(...r)}const J=(t,e)=>B.create(t||m,e||p);class B{constructor(t,e,o){this.ssrCleanedUp=!1,this.config=t,this.target=e,o&&"setup"in o&&y(o.setup)&&(this.resolver=o)}install(t){t.component("Metainfo",I),t.config.globalProperties.$metaManager=this,t.provide(E,D)}addMeta(t,e){e||(e=o()||void 0);const r={removed:[]},n={vm:e};this.resolver&&this.resolver.setup(n);const s=this.target.addSource(t,n,!0),i=t=>this.unmount(!!t,s,r,e);return e&&a(i),{meta:s,onRemoved:t=>r.removed.push(t),unmount:i}}unmount(t,e,o,r){if(r){const{$el:n}=r.proxy;if(n&&n.offsetParent){let r=new MutationObserver((s=>{for(const{removedNodes:i}of s)i&&i.forEach((s=>{s===n&&r&&(r.disconnect(),r=void 0,this.reallyUnmount(t,e,o))}))}));return void r.observe(n.parentNode,{childList:!0})}}this.reallyUnmount(t,e,o)}async reallyUnmount(t,e,o){this.target.delSource(e),!t&&o&&await Promise.all(o.removed.map((t=>t())))}render({slots:t}={}){this.ssrCleanedUp||(this.ssrCleanedUp=!0,window.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll("[data-vm-ssr]");t&&t.length&&Array.from(t).forEach((t=>t.parentNode&&t.parentNode.removeChild(t)))})));const o={};for(const e in D){const r=this.config[e]||{};let n=F({metainfo:D,slots:t},e,D[e],r);if(!n)continue;h(n)||(n=[n]);let s="base"!==e&&D[e].to;!s&&"to"in r&&(s=r.to),!s&&"attributesFor"in r&&(s=e);for(const{to:t,vnode:e}of n)H(o,t||s||"head",e)}if(t)for(const e in t){const r="default"===e?"head":e;if("head"!==r&&"body"!==r)continue;const n=t[e];y(n)&&H(o,r,n({metainfo:D}))}return Object.keys(o).map((t=>e(u,{to:t},o[t])))}}B.create=(t,e)=>{const o=((t,e)=>{const o=[],r={active:e,resolve:t,sources:o},n=()=>$(r);return{context:r,compute:n,addSource:(t,e,o=!1)=>{const s=P(r,t,e||{});return o&&n(),s},delSource:(t,e=!0)=>{const r=o.findIndex((e=>e===t||e[j]===t));return r>-1&&(o.splice(r,1),e&&n(),!0)}}})(((t,o,r,n,s)=>y(e)?e(t,o,r,n,s):e.resolve(t,o,r,n,s)),D);return new B(t,o,e)};export{J as createMetaManager,p as deepestResolver,m as defaultConfig,L as getCurrentManager,f as resolveOption,T as useActiveMeta,q as useMeta};
/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -317,3 +317,3 @@ * - Pim (@pimlie)

const success = Reflect.set(target, key, value);
// console.warn(success, 'PROXY SET\nkey:', key, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
// console.warn(success, 'PROXY SET\nkey:', key, '\nvalue:', value, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
if (success) {

@@ -649,5 +649,4 @@ const isArrayItem = isArray(target);

}
// We dont care about nested objects here , these changes
// should already have been tracked by the MergeProxy
if (isObject(target[key])) {
applyDifference(target[key], newSource[key], oldSource[key]);
continue;

@@ -685,3 +684,2 @@ }

watch(source, (newSource, oldSource) => {
// We only care about first level props, second+ level will already be changed by the merge proxy
applyDifference(metaProxy.meta, newSource, oldSource);

@@ -853,22 +851,2 @@ });

async function renderToStringWithMeta(app) {
const { renderToString } = await import('@vue/server-renderer');
const ctx = {};
const html = await renderToString(app, ctx);
// TODO: better way of determining whether meta was rendered with the component or not
if (!ctx.teleports || !ctx.teleports.head) {
const teleports = app.config.globalProperties.$metaManager.render();
await Promise.all(teleports.map((teleport) => renderToString(teleport, ctx)));
}
const { teleports } = ctx;
for (const target in teleports) {
if (target.endsWith('Attrs')) {
const str = teleports[target];
// match from first space to first >, these should be all rendered attributes
teleports[target] = str.slice(str.indexOf(' ') + 1, str.indexOf('>'));
}
}
return [html, ctx];
}
export { createMetaManager, defaultResolver as deepestResolver, defaultConfig, getCurrentManager, renderToStringWithMeta, resolveOption, useActiveMeta, useMeta };
export { createMetaManager, defaultResolver as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -318,3 +318,3 @@ * - Pim (@pimlie)

const success = Reflect.set(target, key, value);
// console.warn(success, 'PROXY SET\nkey:', key, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
// console.warn(success, 'PROXY SET\nkey:', key, '\nvalue:', value, '\npath:', pathSegments, '\ntarget:', isArray(target), target, '\ncontext:\n', context)
if (success) {

@@ -671,5 +671,4 @@ const isArrayItem = isArray(target);

}
// We dont care about nested objects here , these changes
// should already have been tracked by the MergeProxy
if (isObject(target[key])) {
applyDifference(target[key], newSource[key], oldSource[key]);
continue;

@@ -707,3 +706,2 @@ }

vue.watch(source, (newSource, oldSource) => {
// We only care about first level props, second+ level will already be changed by the merge proxy
applyDifference(metaProxy.meta, newSource, oldSource);

@@ -710,0 +708,0 @@ });

/**
* vue-meta v3.0.0-alpha.4
* vue-meta v3.0.0-alpha.5
* (c) 2021

@@ -8,2 +8,2 @@ * - Pim (@pimlie)

*/
var VueMeta=function(t,e){"use strict";const r=(t,e)=>(r,n)=>{let o=-1;if(n.reduce(((e,r,n)=>{const s=t(e,r);return s!==e?(o=n,s):e}),e),o>-1)return r[o]};const n=r(((t,e)=>{const{depth:r}=e;return!t||r>t?r:t}));var o=Object.freeze({__proto__:null,setup:function(t){let e=0;if(t.vm){let{vm:r}=t;do{r.parent&&(e++,r=r.parent)}while(r&&r.parent&&r!==r.root)}t.depth=e},resolve:n});const s={body:{tag:"script",to:"body"},base:{valueAttribute:"href"},charset:{tag:"meta",nameless:!0,valueAttribute:"charset"},description:{tag:"meta"},og:{group:!0,namespacedAttribute:!0,tag:"meta",keyAttribute:"property"},twitter:{group:!0,namespacedAttribute:!0,tag:"meta"},htmlAttrs:{attributesFor:"html"},headAttrs:{attributesFor:"head"},bodyAttrs:{attributesFor:"body"}},i={title:{attributes:!1},base:{contentAsAttribute:!0,attributes:["href","target"]},meta:{contentAsAttribute:!0,keyAttribute:"name",attributes:["content","name","http-equiv","charset"]},link:{contentAsAttribute:!0,attributes:["href","crossorigin","rel","media","integrity","hreflang","type","referrerpolicy","sizes","imagesrcset","imagesizes","as","color"]},style:{attributes:["media"]},script:{attributes:["src","type","nomodule","async","defer","crossorigin","integrity","referrerpolicy"]},noscript:{attributes:!1}};Object.freeze({}),Object.freeze([]);const c=Array.isArray,a=t=>"function"==typeof t,u=t=>"string"==typeof t,l=t=>null!==t&&"object"==typeof t,f=Object.prototype.toString,d=t=>"[object Object]"===f.call(t),p=Symbol("kIsProxy"),m=Symbol("kProxySources"),b=Symbol("kProxyTarget"),h=Symbol("kResolveContext");function g(t){if(c(t))return t.map(g);if(l(t)){const e={};for(const r in t)e[r]="context"===r?t[r]:g(t[r]);return e}return t}const y=(t,e,r)=>{const n=[];for(const o of t)e in o&&(n.push(o[e]),r&&r(o));return n},v=(t,e,r,n=[])=>{if(n.length||(r||(r=t.active),e||(e=t.sources)),!r||!e)return;const o=((t,...e)=>{const r=t?Object.keys(t):[];if(e)for(const t of e)if(t&&l(t))for(const e in t)r.includes(e)||r.push(e);return r})(...e),s=Object.keys(r);for(const t of s)o.includes(t)||delete r[t];for(const s of o){if(d(e[0][s])){r[s]||(r[s]={});const o=[];for(const t of e)s in t&&o.push(t[s]);v(t,o,r[s],[...n,s]);continue}!r[s]&&c(e[0][s])&&(r[s]=[]);const o=[],i=y(e,s,(t=>o.push(t[h])));let a=t.resolve(i,o,r[s],s,n);d(a)&&(a=g(a)),r[s]=a}},A=(t,r,n,o=[])=>{const s=S(t,n,o),i=e.markRaw(new Proxy(r,s));return!o.length&&t.sources&&t.sources.push(i),i},S=(t,e,r=[])=>({get:(n,o,s)=>{if(o===p)return!0;if(o===m)return t.sources;if(o===b)return n;if(o===h)return e;let i=Reflect.get(n,o,s);if(!l(i))return i;if(!i[p]){const s=[...r,o];i=A(t,i,e,s),Reflect.set(n,o,i)}return i},set:(e,n,o)=>{const s=Reflect.set(e,n,o);if(s){const o=c(e);let i,a=!1,{sources:u,active:l}=t,f=0;for(const t of r){if(u=y(u,t),o&&f===r.length-1){i=t;break}c(l)&&(a=!0),l=l[t],f++}if(a)return v(t),s;let p,m=[];o?(p=u,m=u.map((t=>t[h]))):p=y(u,n,(t=>m.push(t[h])));let b=t.resolve(p,m,l,n,r);d(b)&&(b=g(b)),o&&i?l[i]=b:l[n]=b}return s},deleteProperty:(e,n)=>{const o=Reflect.deleteProperty(e,n);if(o){const o=c(e);let s,i=t.sources,a=t.active,u=0;for(const t of r){if(i=i.map((e=>e[t])),o&&u===r.length-1){s=t;break}a=a[t],u++}if(i.some((t=>n in t))){let e,c=[];o?(e=i,c=i.map((t=>t[h]))):e=y(i,n,(t=>c.push(t[h])));let u=t.resolve(e,c,a,n,r);d(u)&&(u=g(u)),o&&s?a[s]=u:a[n]=u}else delete a[n]}return o}}),k={};function w(t,e,r,n){return"attributesFor"in n?function(t,e,r,n){const{attributesFor:o}=n;if(!o)return;if(!k[o]){const[t,e]=Array.from(document.querySelectorAll(o));if(!t)return void console.error("Could not find element for selector",o,", won't render attributes");e&&console.warn("Found multiple elements for selector",o),k[o]={el:t,attrs:[]}}const{el:s,attrs:i}=k[o];for(const n in r){const o=M(t,`${e}(${n})`,r[n],r);s.setAttribute(n,o||""),i.includes(n)||i.push(n)}const c=i.filter((t=>!r[t]));for(const t of c)s.removeAttribute(t)}(t,e,r,n):"group"in n?function(t,e,r,n){if(c(r))return console.warn("Specifying an array for group properties isnt supported"),[];return Object.keys(r).map((o=>{const s={group:e,data:r};if(n.namespaced)s.tagNamespace=!0===n.namespaced?e:n.namespaced;else if(n.namespacedAttribute){const t=!0===n.namespacedAttribute?e:n.namespacedAttribute;s.fullName=`${t}:${o}`,s.slotName=`${t}(${o})`}return C(t,e,r[o],n,s)})).flat()}(t,e,r,n):C(t,e,r,n)}function C(t,r,n,o={},s){const a=["content","json","rawContent"],l=t=>function(t,e){for(const r of t){const t=i[r];if(r&&t)return t[e]}}([f,o.tag],t);if(c(n))return n.map((e=>C(t,r,e,o,s))).flat();const{tag:f=o.tag||r}=n;let d="",p=!1,m=!1;if(u(n))d=n;else if(n.children&&c(n.children))p=!0,d=n.children.map((e=>{const n=C(t,r,e,o,s);return c(n)?n.map((({vnode:t})=>t)):n.vnode}));else{let t=0;for(const e of a){if(!d&&n[e]){d=1===t?JSON.stringify(n[e]):n[e],m=t>1;break}t++}}const b=s&&s.fullName||r,h=s&&s.slotName||r;let{attrs:g}=n;if(g||"object"!=typeof n)g||(g={});else{g={...n},delete g.tag,delete g.children,delete g.to;for(const t of a)delete g[t]}if(p)d=M(t,h,d,n);else{const e=!!l("contentAsAttribute");let{valueAttribute:r}=o;if(!r&&e){const[t]=l("attributes");r=u(e)?e:t}if(r){const{nameless:e,keyAttribute:n}=o;e||n&&(g[n]=b),g[r]=M(t,h,g[r]||d,s),d=""}else d=M(t,h,d,n)}const y=s&&s.tagNamespace?`${s.tagNamespace}:${f}`:f;m&&d&&(g.innerHTML=d);const v=e.h(y,g,d||void 0);return{to:n.to,vnode:v}}function M({metainfo:t,slots:e},r,n,o){const s=e&&e[r];if(!s||!a(s))return n;const i={content:n,metainfo:t};if(o&&o.group){const{group:t,data:e}=o;i[t]=e}const c=s(i);if(c&&c.length){const{children:t}=c[0];return t?t.toString():""}return n}const j="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,O=(t=>j?Symbol("[vue-meta]: "+t):"[vue-meta]: "+t)("meta_active");function N(t){if(t||(t=e.getCurrentInstance()||void 0),t)return t.appContext.config.globalProperties.$metaManager}const P=e.defineComponent({name:"Metainfo",inheritAttrs:!1,setup:(t,{slots:e})=>()=>{const t=N();if(t)return t.render({slots:e})}}),x=e.reactive({});function $(t,r,n){const o=c(n)?n:[n];o.forEach(((t,r)=>{t.type===e.Comment&&o.splice(r,1)})),t[r]||(t[r]=[]),t[r].push(...o)}class R{constructor(t,e,r){this.ssrCleanedUp=!1,this.config=t,this.target=e,r&&"setup"in r&&a(r.setup)&&(this.resolver=r)}install(t){t.component("Metainfo",P),t.config.globalProperties.$metaManager=this,t.provide(O,x)}addMeta(t,r){r||(r=e.getCurrentInstance()||void 0);const n={removed:[]},o={vm:r};this.resolver&&this.resolver.setup(o);const s=this.target.addSource(t,o,!0),i=t=>this.unmount(!!t,s,n,r);return r&&e.onUnmounted(i),{meta:s,onRemoved:t=>n.removed.push(t),unmount:i}}unmount(t,e,r,n){if(n){const{$el:o}=n.proxy;if(o&&o.offsetParent){let n=new MutationObserver((s=>{for(const{removedNodes:i}of s)i&&i.forEach((s=>{s===o&&n&&(n.disconnect(),n=void 0,this.reallyUnmount(t,e,r))}))}));return void n.observe(o.parentNode,{childList:!0})}}this.reallyUnmount(t,e,r)}async reallyUnmount(t,e,r){this.target.delSource(e),!t&&r&&await Promise.all(r.removed.map((t=>t())))}render({slots:t}={}){this.ssrCleanedUp||(this.ssrCleanedUp=!0,window.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll("[data-vm-ssr]");t&&t.length&&Array.from(t).forEach((t=>t.parentNode&&t.parentNode.removeChild(t)))})));const r={};for(const e in x){const n=this.config[e]||{};let o=w({metainfo:x,slots:t},e,x[e],n);if(!o)continue;c(o)||(o=[o]);let s="base"!==e&&x[e].to;!s&&"to"in n&&(s=n.to),!s&&"attributesFor"in n&&(s=e);for(const{to:t,vnode:e}of o)$(r,t||s||"head",e)}if(t)for(const e in t){const n="default"===e?"head":e;if("head"!==n&&"body"!==n)continue;const o=t[e];a(o)&&$(r,n,o({metainfo:x}))}return Object.keys(r).map((t=>e.h(e.Teleport,{to:t},r[t])))}}return R.create=(t,e)=>{const r=((t,e)=>{const r=[],n={active:e,resolve:t,sources:r},o=()=>v(n);return{context:n,compute:o,addSource:(t,e,r=!1)=>{const s=A(n,t,e||{});return r&&o(),s},delSource:(t,e=!0)=>{const n=r.findIndex((e=>e===t||e[b]===t));return n>-1&&(r.splice(n,1),e&&o(),!0)}}})(((t,r,n,o,s)=>a(e)?e(t,r,n,o,s):e.resolve(t,r,n,o,s)),x);return new R(t,r,e)},t.createMetaManager=(t,e)=>R.create(t||s,e||o),t.deepestResolver=o,t.defaultConfig=s,t.getCurrentManager=N,t.resolveOption=r,t.useActiveMeta=function(){return e.inject(O)},t.useMeta=function(t,r){const n=e.getCurrentInstance()||void 0;if(!r&&n&&(r=N(n)),!r)throw new Error("No manager or current instance");e.isProxy(t)&&(e.watch(t,((t,e)=>{!function(t,e,r){for(const n in e)n in r?l(t[n])||e[n]!==r[n]&&(t[n]=e[n]):t[n]=e[n];for(const n in r)n in e||delete t[n]}(o.meta,t,e)})),t=t.value);const o=r.addMeta(t,n);return o},Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue);
var VueMeta=function(t,e){"use strict";const r=(t,e)=>(r,n)=>{let o=-1;if(n.reduce(((e,r,n)=>{const s=t(e,r);return s!==e?(o=n,s):e}),e),o>-1)return r[o]};const n=r(((t,e)=>{const{depth:r}=e;return!t||r>t?r:t}));var o=Object.freeze({__proto__:null,setup:function(t){let e=0;if(t.vm){let{vm:r}=t;do{r.parent&&(e++,r=r.parent)}while(r&&r.parent&&r!==r.root)}t.depth=e},resolve:n});const s={body:{tag:"script",to:"body"},base:{valueAttribute:"href"},charset:{tag:"meta",nameless:!0,valueAttribute:"charset"},description:{tag:"meta"},og:{group:!0,namespacedAttribute:!0,tag:"meta",keyAttribute:"property"},twitter:{group:!0,namespacedAttribute:!0,tag:"meta"},htmlAttrs:{attributesFor:"html"},headAttrs:{attributesFor:"head"},bodyAttrs:{attributesFor:"body"}},i={title:{attributes:!1},base:{contentAsAttribute:!0,attributes:["href","target"]},meta:{contentAsAttribute:!0,keyAttribute:"name",attributes:["content","name","http-equiv","charset"]},link:{contentAsAttribute:!0,attributes:["href","crossorigin","rel","media","integrity","hreflang","type","referrerpolicy","sizes","imagesrcset","imagesizes","as","color"]},style:{attributes:["media"]},script:{attributes:["src","type","nomodule","async","defer","crossorigin","integrity","referrerpolicy"]},noscript:{attributes:!1}};Object.freeze({}),Object.freeze([]);const c=Array.isArray,a=t=>"function"==typeof t,u=t=>"string"==typeof t,l=t=>null!==t&&"object"==typeof t,f=Object.prototype.toString,d=t=>"[object Object]"===f.call(t),p=Symbol("kIsProxy"),m=Symbol("kProxySources"),b=Symbol("kProxyTarget"),h=Symbol("kResolveContext");function g(t){if(c(t))return t.map(g);if(l(t)){const e={};for(const r in t)e[r]="context"===r?t[r]:g(t[r]);return e}return t}const y=(t,e,r)=>{const n=[];for(const o of t)e in o&&(n.push(o[e]),r&&r(o));return n},v=(t,e,r,n=[])=>{if(n.length||(r||(r=t.active),e||(e=t.sources)),!r||!e)return;const o=((t,...e)=>{const r=t?Object.keys(t):[];if(e)for(const t of e)if(t&&l(t))for(const e in t)r.includes(e)||r.push(e);return r})(...e),s=Object.keys(r);for(const t of s)o.includes(t)||delete r[t];for(const s of o){if(d(e[0][s])){r[s]||(r[s]={});const o=[];for(const t of e)s in t&&o.push(t[s]);v(t,o,r[s],[...n,s]);continue}!r[s]&&c(e[0][s])&&(r[s]=[]);const o=[],i=y(e,s,(t=>o.push(t[h])));let a=t.resolve(i,o,r[s],s,n);d(a)&&(a=g(a)),r[s]=a}},A=(t,r,n,o=[])=>{const s=S(t,n,o),i=e.markRaw(new Proxy(r,s));return!o.length&&t.sources&&t.sources.push(i),i},S=(t,e,r=[])=>({get:(n,o,s)=>{if(o===p)return!0;if(o===m)return t.sources;if(o===b)return n;if(o===h)return e;let i=Reflect.get(n,o,s);if(!l(i))return i;if(!i[p]){const s=[...r,o];i=A(t,i,e,s),Reflect.set(n,o,i)}return i},set:(e,n,o)=>{const s=Reflect.set(e,n,o);if(s){const o=c(e);let i,a=!1,{sources:u,active:l}=t,f=0;for(const t of r){if(u=y(u,t),o&&f===r.length-1){i=t;break}c(l)&&(a=!0),l=l[t],f++}if(a)return v(t),s;let p,m=[];o?(p=u,m=u.map((t=>t[h]))):p=y(u,n,(t=>m.push(t[h])));let b=t.resolve(p,m,l,n,r);d(b)&&(b=g(b)),o&&i?l[i]=b:l[n]=b}return s},deleteProperty:(e,n)=>{const o=Reflect.deleteProperty(e,n);if(o){const o=c(e);let s,i=t.sources,a=t.active,u=0;for(const t of r){if(i=i.map((e=>e[t])),o&&u===r.length-1){s=t;break}a=a[t],u++}if(i.some((t=>n in t))){let e,c=[];o?(e=i,c=i.map((t=>t[h]))):e=y(i,n,(t=>c.push(t[h])));let u=t.resolve(e,c,a,n,r);d(u)&&(u=g(u)),o&&s?a[s]=u:a[n]=u}else delete a[n]}return o}}),k={};function w(t,e,r,n){return"attributesFor"in n?function(t,e,r,n){const{attributesFor:o}=n;if(!o)return;if(!k[o]){const[t,e]=Array.from(document.querySelectorAll(o));if(!t)return void console.error("Could not find element for selector",o,", won't render attributes");e&&console.warn("Found multiple elements for selector",o),k[o]={el:t,attrs:[]}}const{el:s,attrs:i}=k[o];for(const n in r){const o=M(t,`${e}(${n})`,r[n],r);s.setAttribute(n,o||""),i.includes(n)||i.push(n)}const c=i.filter((t=>!r[t]));for(const t of c)s.removeAttribute(t)}(t,e,r,n):"group"in n?function(t,e,r,n){if(c(r))return console.warn("Specifying an array for group properties isnt supported"),[];return Object.keys(r).map((o=>{const s={group:e,data:r};if(n.namespaced)s.tagNamespace=!0===n.namespaced?e:n.namespaced;else if(n.namespacedAttribute){const t=!0===n.namespacedAttribute?e:n.namespacedAttribute;s.fullName=`${t}:${o}`,s.slotName=`${t}(${o})`}return C(t,e,r[o],n,s)})).flat()}(t,e,r,n):C(t,e,r,n)}function C(t,r,n,o={},s){const a=["content","json","rawContent"],l=t=>function(t,e){for(const r of t){const t=i[r];if(r&&t)return t[e]}}([f,o.tag],t);if(c(n))return n.map((e=>C(t,r,e,o,s))).flat();const{tag:f=o.tag||r}=n;let d="",p=!1,m=!1;if(u(n))d=n;else if(n.children&&c(n.children))p=!0,d=n.children.map((e=>{const n=C(t,r,e,o,s);return c(n)?n.map((({vnode:t})=>t)):n.vnode}));else{let t=0;for(const e of a){if(!d&&n[e]){d=1===t?JSON.stringify(n[e]):n[e],m=t>1;break}t++}}const b=s&&s.fullName||r,h=s&&s.slotName||r;let{attrs:g}=n;if(g||"object"!=typeof n)g||(g={});else{g={...n},delete g.tag,delete g.children,delete g.to;for(const t of a)delete g[t]}if(p)d=M(t,h,d,n);else{const e=!!l("contentAsAttribute");let{valueAttribute:r}=o;if(!r&&e){const[t]=l("attributes");r=u(e)?e:t}if(r){const{nameless:e,keyAttribute:n}=o;e||n&&(g[n]=b),g[r]=M(t,h,g[r]||d,s),d=""}else d=M(t,h,d,n)}const y=s&&s.tagNamespace?`${s.tagNamespace}:${f}`:f;m&&d&&(g.innerHTML=d);const v=e.h(y,g,d||void 0);return{to:n.to,vnode:v}}function M({metainfo:t,slots:e},r,n,o){const s=e&&e[r];if(!s||!a(s))return n;const i={content:n,metainfo:t};if(o&&o.group){const{group:t,data:e}=o;i[t]=e}const c=s(i);if(c&&c.length){const{children:t}=c[0];return t?t.toString():""}return n}const j="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,O=(t=>j?Symbol("[vue-meta]: "+t):"[vue-meta]: "+t)("meta_active");function N(t,e,r){for(const n in e)n in r?l(t[n])?N(t[n],e[n],r[n]):e[n]!==r[n]&&(t[n]=e[n]):t[n]=e[n];for(const n in r)n in e||delete t[n]}function P(t){if(t||(t=e.getCurrentInstance()||void 0),t)return t.appContext.config.globalProperties.$metaManager}const x=e.defineComponent({name:"Metainfo",inheritAttrs:!1,setup:(t,{slots:e})=>()=>{const t=P();if(t)return t.render({slots:e})}}),$=e.reactive({});function R(t,r,n){const o=c(n)?n:[n];o.forEach(((t,r)=>{t.type===e.Comment&&o.splice(r,1)})),t[r]||(t[r]=[]),t[r].push(...o)}class F{constructor(t,e,r){this.ssrCleanedUp=!1,this.config=t,this.target=e,r&&"setup"in r&&a(r.setup)&&(this.resolver=r)}install(t){t.component("Metainfo",x),t.config.globalProperties.$metaManager=this,t.provide(O,$)}addMeta(t,r){r||(r=e.getCurrentInstance()||void 0);const n={removed:[]},o={vm:r};this.resolver&&this.resolver.setup(o);const s=this.target.addSource(t,o,!0),i=t=>this.unmount(!!t,s,n,r);return r&&e.onUnmounted(i),{meta:s,onRemoved:t=>n.removed.push(t),unmount:i}}unmount(t,e,r,n){if(n){const{$el:o}=n.proxy;if(o&&o.offsetParent){let n=new MutationObserver((s=>{for(const{removedNodes:i}of s)i&&i.forEach((s=>{s===o&&n&&(n.disconnect(),n=void 0,this.reallyUnmount(t,e,r))}))}));return void n.observe(o.parentNode,{childList:!0})}}this.reallyUnmount(t,e,r)}async reallyUnmount(t,e,r){this.target.delSource(e),!t&&r&&await Promise.all(r.removed.map((t=>t())))}render({slots:t}={}){this.ssrCleanedUp||(this.ssrCleanedUp=!0,window.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll("[data-vm-ssr]");t&&t.length&&Array.from(t).forEach((t=>t.parentNode&&t.parentNode.removeChild(t)))})));const r={};for(const e in $){const n=this.config[e]||{};let o=w({metainfo:$,slots:t},e,$[e],n);if(!o)continue;c(o)||(o=[o]);let s="base"!==e&&$[e].to;!s&&"to"in n&&(s=n.to),!s&&"attributesFor"in n&&(s=e);for(const{to:t,vnode:e}of o)R(r,t||s||"head",e)}if(t)for(const e in t){const n="default"===e?"head":e;if("head"!==n&&"body"!==n)continue;const o=t[e];a(o)&&R(r,n,o({metainfo:$}))}return Object.keys(r).map((t=>e.h(e.Teleport,{to:t},r[t])))}}return F.create=(t,e)=>{const r=((t,e)=>{const r=[],n={active:e,resolve:t,sources:r},o=()=>v(n);return{context:n,compute:o,addSource:(t,e,r=!1)=>{const s=A(n,t,e||{});return r&&o(),s},delSource:(t,e=!0)=>{const n=r.findIndex((e=>e===t||e[b]===t));return n>-1&&(r.splice(n,1),e&&o(),!0)}}})(((t,r,n,o,s)=>a(e)?e(t,r,n,o,s):e.resolve(t,r,n,o,s)),$);return new F(t,r,e)},t.createMetaManager=(t,e)=>F.create(t||s,e||o),t.deepestResolver=o,t.defaultConfig=s,t.getCurrentManager=P,t.resolveOption=r,t.useActiveMeta=function(){return e.inject(O)},t.useMeta=function(t,r){const n=e.getCurrentInstance()||void 0;if(!r&&n&&(r=P(n)),!r)throw new Error("No manager or current instance");e.isProxy(t)&&(e.watch(t,((t,e)=>{N(o.meta,t,e)})),t=t.value);const o=r.addMeta(t,n);return o},Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue);
{
"name": "vue-meta",
"version": "3.0.0-alpha.4",
"version": "3.0.0-alpha.5",
"description": "Manage HTML metadata in Vue.js components with SSR support",

@@ -15,2 +15,3 @@ "main": "dist/vue-meta.cjs.js",

"dist/vue-meta.d.ts",
"ssr/*.js",
"README.md"

@@ -73,4 +74,3 @@ ],

"@vue/server-renderer": "^3.0.6",
"@vue/server-test-utils": "^1.1.3",
"@vue/test-utils": "^1.1.3",
"@vue/test-utils": "next",
"@wishy-gift/html-include-chunks-webpack-plugin": "^0.1.5",

@@ -111,4 +111,4 @@ "babel-jest": "^26.6.3",

"vite": "^2.0.4",
"vue": "^3.0.5",
"vue-jest": "^3.0.7",
"vue": "^3.0.6",
"vue-jest": "next",
"vue-loader": "^16.0.0",

@@ -115,0 +115,0 @@ "vue-router": "next",

@@ -147,3 +147,3 @@ > :warning: This is the readme for the next branch of vue-meta with Vue3 support

import { createSSRApp } from 'vue'
import { renderToStringWithMeta } from 'vue-meta'
import { renderToStringWithMeta } from 'vue-meta/ssr'
import { App, metaManager } from './App'

@@ -150,0 +150,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc