mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-22 19:00:35 +03:00
chore(release): 3.0.0-alpha.3
This commit is contained in:
@@ -2,6 +2,23 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [3.0.0-alpha.3](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.2...v3.0.0-alpha.3) (2021-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add fully static / client-only example ([c6c3b47](https://github.com/nuxt/vue-meta/commit/c6c3b4758664b0b7ea2487ed785128416d0905b5))
|
||||||
|
* make createMetaManager util args optional (use defaults) ([89d7f58](https://github.com/nuxt/vue-meta/commit/89d7f584910da78a6af6bc700dde61a8a1625658))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* dont call clean before starting dev server ([683ea9c](https://github.com/nuxt/vue-meta/commit/683ea9c0765dea40b98093d6946cabc0369d79c2))
|
||||||
|
* fix/improve resolver types ([fcb47a9](https://github.com/nuxt/vue-meta/commit/fcb47a9d5f106704f1e187154b5691939130f630))
|
||||||
|
* only match vue-meta in jiti alias ([2b8c5e8](https://github.com/nuxt/vue-meta/commit/2b8c5e8866e54d9fd784a6f1bb3733d572aaa8af))
|
||||||
|
* replace node-env in rollup config ([ed6ba9f](https://github.com/nuxt/vue-meta/commit/ed6ba9fa942869e9c10dbd1df251381451117e74))
|
||||||
|
* use dynamic import for vue server-renderer ([8e2fed1](https://github.com/nuxt/vue-meta/commit/8e2fed1525f1c8594ab4bf4360ffb4af11ea8ddb))
|
||||||
|
|
||||||
## [3.0.0-alpha.2](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2021-02-28)
|
## [3.0.0-alpha.2](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2021-02-28)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+33
-21
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v3.0.0-alpha.2
|
* vue-meta v3.0.0-alpha.3
|
||||||
* (c) 2021
|
* (c) 2021
|
||||||
* - Pim (@pimlie)
|
* - Pim (@pimlie)
|
||||||
* - All the amazing contributors
|
* - All the amazing contributors
|
||||||
@@ -12,7 +12,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|||||||
|
|
||||||
var vue = require('vue');
|
var vue = require('vue');
|
||||||
|
|
||||||
const resolveOption = predicament => (options, contexts) => {
|
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) => {
|
||||||
let resolvedIndex = -1;
|
let resolvedIndex = -1;
|
||||||
contexts.reduce((acc, context, index) => {
|
contexts.reduce((acc, context, index) => {
|
||||||
const retval = predicament(acc, context);
|
const retval = predicament(acc, context);
|
||||||
@@ -21,7 +33,7 @@ const resolveOption = predicament => (options, contexts) => {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, undefined);
|
}, initialValue);
|
||||||
if (resolvedIndex > -1) {
|
if (resolvedIndex > -1) {
|
||||||
return options[resolvedIndex];
|
return options[resolvedIndex];
|
||||||
}
|
}
|
||||||
@@ -40,14 +52,15 @@ function setup(context) {
|
|||||||
}
|
}
|
||||||
context.depth = depth;
|
context.depth = depth;
|
||||||
}
|
}
|
||||||
const resolve = resolveOption((acc, context) => {
|
const resolve = resolveOption((currentValue, context) => {
|
||||||
const { depth } = context;
|
const { depth } = context;
|
||||||
if (!acc || depth > acc) {
|
if (!currentValue || depth > currentValue) {
|
||||||
return acc;
|
return depth;
|
||||||
}
|
}
|
||||||
|
return currentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
var deepest = /*#__PURE__*/Object.freeze({
|
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
setup: setup,
|
setup: setup,
|
||||||
resolve: resolve
|
resolve: resolve
|
||||||
@@ -161,10 +174,9 @@ function getTagConfigItem(tagOrName, key) {
|
|||||||
* \/\*#\_\_PURE\_\_\*\/
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
* So that rollup can tree-shake them if necessary.
|
* So that rollup can tree-shake them if necessary.
|
||||||
*/
|
*/
|
||||||
(process.env.NODE_ENV !== 'production')
|
Object.freeze({})
|
||||||
? Object.freeze({})
|
;
|
||||||
: {};
|
Object.freeze([]) ;
|
||||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
|
||||||
const isArray = Array.isArray;
|
const isArray = Array.isArray;
|
||||||
const isFunction = (val) => typeof val === 'function';
|
const isFunction = (val) => typeof val === 'function';
|
||||||
const isString = (val) => typeof val === 'string';
|
const isString = (val) => typeof val === 'string';
|
||||||
@@ -252,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
// This assumes consistent types usages for keys across sources
|
// This assumes consistent types usages for keys across sources
|
||||||
|
// @ts-ignore
|
||||||
if (isPlainObject(sources[0][key])) {
|
if (isPlainObject(sources[0][key])) {
|
||||||
if (!target[key]) {
|
if (!target[key]) {
|
||||||
target[key] = {};
|
target[key] = {};
|
||||||
@@ -259,6 +272,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
const keySources = [];
|
const keySources = [];
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (key in source) {
|
if (key in source) {
|
||||||
|
// @ts-ignore
|
||||||
keySources.push(source[key]);
|
keySources.push(source[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,6 +280,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Ensure the target is an array if source is an array and target is empty
|
// Ensure the target is an array if source is an array and target is empty
|
||||||
|
// @ts-ignore
|
||||||
if (!target[key] && isArray(sources[0][key])) {
|
if (!target[key] && isArray(sources[0][key])) {
|
||||||
target[key] = [];
|
target[key] = [];
|
||||||
}
|
}
|
||||||
@@ -309,7 +324,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
if (!value[IS_PROXY]) {
|
if (!value[IS_PROXY]) {
|
||||||
const keyPath = [...pathSegments, key];
|
const keyPath = [...pathSegments, key];
|
||||||
value = createProxy(context, value, resolveContext, keyPath);
|
value = createProxy(context, value, resolveContext, keyPath);
|
||||||
target[key] = value;
|
Reflect.set(target, key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
@@ -381,6 +396,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
let active = context.active;
|
let active = context.active;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
|
// @ts-ignore
|
||||||
proxies = proxies.map(proxy => proxy[segment]);
|
proxies = proxies.map(proxy => proxy[segment]);
|
||||||
if (isArrayItem && index === pathSegments.length - 1) {
|
if (isArrayItem && index === pathSegments.length - 1) {
|
||||||
activeSegmentKey = segment;
|
activeSegmentKey = segment;
|
||||||
@@ -421,11 +437,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMergedObject = (resolve, active = {}) => {
|
const createMergedObject = (resolve, active) => {
|
||||||
const sources = [];
|
const sources = [];
|
||||||
if (!active) {
|
|
||||||
active = {};
|
|
||||||
}
|
|
||||||
const context = {
|
const context = {
|
||||||
active,
|
active,
|
||||||
resolve,
|
resolve,
|
||||||
@@ -443,7 +456,7 @@ const createMergedObject = (resolve, active = {}) => {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
delSource: (sourceOrProxy, recompute = true) => {
|
delSource: (sourceOrProxy, recompute = true) => {
|
||||||
const index = sources.findIndex(src => src === sourceOrProxy || src[PROXY_TARGET] === sourceOrProxy);
|
const index = sources.findIndex(source => source === sourceOrProxy || source[PROXY_TARGET] === sourceOrProxy);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
if (recompute) {
|
if (recompute) {
|
||||||
@@ -727,7 +740,7 @@ function addVnode(teleports, to, vnodes) {
|
|||||||
}
|
}
|
||||||
teleports[to].push(...nodes);
|
teleports[to].push(...nodes);
|
||||||
}
|
}
|
||||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||||
class MetaManager {
|
class MetaManager {
|
||||||
constructor(config, target, resolver) {
|
constructor(config, target, resolver) {
|
||||||
this.ssrCleanedUp = false;
|
this.ssrCleanedUp = false;
|
||||||
@@ -850,9 +863,8 @@ MetaManager.create = (config, resolver) => {
|
|||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
// rollup doesnt like an import as it cant find the export so use require
|
|
||||||
const { renderToString } = require('@vue/server-renderer');
|
|
||||||
async function renderToStringWithMeta(app) {
|
async function renderToStringWithMeta(app) {
|
||||||
|
const { renderToString } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@vue/server-renderer')); });
|
||||||
const ctx = {};
|
const ctx = {};
|
||||||
const html = await renderToString(app, ctx);
|
const html = await renderToString(app, ctx);
|
||||||
// TODO: better way of determining whether meta was rendered with the component or not
|
// TODO: better way of determining whether meta was rendered with the component or not
|
||||||
@@ -872,7 +884,7 @@ async function renderToStringWithMeta(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.createMetaManager = createMetaManager;
|
exports.createMetaManager = createMetaManager;
|
||||||
exports.deepestResolver = deepest;
|
exports.deepestResolver = defaultResolver;
|
||||||
exports.defaultConfig = defaultConfig;
|
exports.defaultConfig = defaultConfig;
|
||||||
exports.getCurrentManager = getCurrentManager;
|
exports.getCurrentManager = getCurrentManager;
|
||||||
exports.renderToStringWithMeta = renderToStringWithMeta;
|
exports.renderToStringWithMeta = renderToStringWithMeta;
|
||||||
|
|||||||
Vendored
+30
-21
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v3.0.0-alpha.2
|
* vue-meta v3.0.0-alpha.3
|
||||||
* (c) 2021
|
* (c) 2021
|
||||||
* - Pim (@pimlie)
|
* - Pim (@pimlie)
|
||||||
* - All the amazing contributors
|
* - All the amazing contributors
|
||||||
@@ -12,7 +12,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|||||||
|
|
||||||
var vue = require('vue');
|
var vue = require('vue');
|
||||||
|
|
||||||
const resolveOption = predicament => (options, contexts) => {
|
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) => {
|
||||||
let resolvedIndex = -1;
|
let resolvedIndex = -1;
|
||||||
contexts.reduce((acc, context, index) => {
|
contexts.reduce((acc, context, index) => {
|
||||||
const retval = predicament(acc, context);
|
const retval = predicament(acc, context);
|
||||||
@@ -21,7 +33,7 @@ const resolveOption = predicament => (options, contexts) => {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, undefined);
|
}, initialValue);
|
||||||
if (resolvedIndex > -1) {
|
if (resolvedIndex > -1) {
|
||||||
return options[resolvedIndex];
|
return options[resolvedIndex];
|
||||||
}
|
}
|
||||||
@@ -40,14 +52,15 @@ function setup(context) {
|
|||||||
}
|
}
|
||||||
context.depth = depth;
|
context.depth = depth;
|
||||||
}
|
}
|
||||||
const resolve = resolveOption((acc, context) => {
|
const resolve = resolveOption((currentValue, context) => {
|
||||||
const { depth } = context;
|
const { depth } = context;
|
||||||
if (!acc || depth > acc) {
|
if (!currentValue || depth > currentValue) {
|
||||||
return acc;
|
return depth;
|
||||||
}
|
}
|
||||||
|
return currentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
var deepest = /*#__PURE__*/Object.freeze({
|
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
setup: setup,
|
setup: setup,
|
||||||
resolve: resolve
|
resolve: resolve
|
||||||
@@ -161,10 +174,6 @@ function getTagConfigItem(tagOrName, key) {
|
|||||||
* \/\*#\_\_PURE\_\_\*\/
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
* So that rollup can tree-shake them if necessary.
|
* So that rollup can tree-shake them if necessary.
|
||||||
*/
|
*/
|
||||||
(process.env.NODE_ENV !== 'production')
|
|
||||||
? Object.freeze({})
|
|
||||||
: {};
|
|
||||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
|
||||||
const isArray = Array.isArray;
|
const isArray = Array.isArray;
|
||||||
const isFunction = (val) => typeof val === 'function';
|
const isFunction = (val) => typeof val === 'function';
|
||||||
const isString = (val) => typeof val === 'string';
|
const isString = (val) => typeof val === 'string';
|
||||||
@@ -252,6 +261,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
// This assumes consistent types usages for keys across sources
|
// This assumes consistent types usages for keys across sources
|
||||||
|
// @ts-ignore
|
||||||
if (isPlainObject(sources[0][key])) {
|
if (isPlainObject(sources[0][key])) {
|
||||||
if (!target[key]) {
|
if (!target[key]) {
|
||||||
target[key] = {};
|
target[key] = {};
|
||||||
@@ -259,6 +269,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
const keySources = [];
|
const keySources = [];
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (key in source) {
|
if (key in source) {
|
||||||
|
// @ts-ignore
|
||||||
keySources.push(source[key]);
|
keySources.push(source[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,6 +277,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Ensure the target is an array if source is an array and target is empty
|
// Ensure the target is an array if source is an array and target is empty
|
||||||
|
// @ts-ignore
|
||||||
if (!target[key] && isArray(sources[0][key])) {
|
if (!target[key] && isArray(sources[0][key])) {
|
||||||
target[key] = [];
|
target[key] = [];
|
||||||
}
|
}
|
||||||
@@ -309,7 +321,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
if (!value[IS_PROXY]) {
|
if (!value[IS_PROXY]) {
|
||||||
const keyPath = [...pathSegments, key];
|
const keyPath = [...pathSegments, key];
|
||||||
value = createProxy(context, value, resolveContext, keyPath);
|
value = createProxy(context, value, resolveContext, keyPath);
|
||||||
target[key] = value;
|
Reflect.set(target, key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
@@ -381,6 +393,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
let active = context.active;
|
let active = context.active;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
|
// @ts-ignore
|
||||||
proxies = proxies.map(proxy => proxy[segment]);
|
proxies = proxies.map(proxy => proxy[segment]);
|
||||||
if (isArrayItem && index === pathSegments.length - 1) {
|
if (isArrayItem && index === pathSegments.length - 1) {
|
||||||
activeSegmentKey = segment;
|
activeSegmentKey = segment;
|
||||||
@@ -421,11 +434,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMergedObject = (resolve, active = {}) => {
|
const createMergedObject = (resolve, active) => {
|
||||||
const sources = [];
|
const sources = [];
|
||||||
if (!active) {
|
|
||||||
active = {};
|
|
||||||
}
|
|
||||||
const context = {
|
const context = {
|
||||||
active,
|
active,
|
||||||
resolve,
|
resolve,
|
||||||
@@ -443,7 +453,7 @@ const createMergedObject = (resolve, active = {}) => {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
delSource: (sourceOrProxy, recompute = true) => {
|
delSource: (sourceOrProxy, recompute = true) => {
|
||||||
const index = sources.findIndex(src => src === sourceOrProxy || src[PROXY_TARGET] === sourceOrProxy);
|
const index = sources.findIndex(source => source === sourceOrProxy || source[PROXY_TARGET] === sourceOrProxy);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
if (recompute) {
|
if (recompute) {
|
||||||
@@ -723,7 +733,7 @@ function addVnode(teleports, to, vnodes) {
|
|||||||
}
|
}
|
||||||
teleports[to].push(...nodes);
|
teleports[to].push(...nodes);
|
||||||
}
|
}
|
||||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||||
class MetaManager {
|
class MetaManager {
|
||||||
constructor(config, target, resolver) {
|
constructor(config, target, resolver) {
|
||||||
this.ssrCleanedUp = false;
|
this.ssrCleanedUp = false;
|
||||||
@@ -846,9 +856,8 @@ MetaManager.create = (config, resolver) => {
|
|||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
// rollup doesnt like an import as it cant find the export so use require
|
|
||||||
const { renderToString } = require('@vue/server-renderer');
|
|
||||||
async function renderToStringWithMeta(app) {
|
async function renderToStringWithMeta(app) {
|
||||||
|
const { renderToString } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@vue/server-renderer')); });
|
||||||
const ctx = {};
|
const ctx = {};
|
||||||
const html = await renderToString(app, ctx);
|
const html = await renderToString(app, ctx);
|
||||||
// TODO: better way of determining whether meta was rendered with the component or not
|
// TODO: better way of determining whether meta was rendered with the component or not
|
||||||
@@ -868,7 +877,7 @@ async function renderToStringWithMeta(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.createMetaManager = createMetaManager;
|
exports.createMetaManager = createMetaManager;
|
||||||
exports.deepestResolver = deepest;
|
exports.deepestResolver = defaultResolver;
|
||||||
exports.defaultConfig = defaultConfig;
|
exports.defaultConfig = defaultConfig;
|
||||||
exports.getCurrentManager = getCurrentManager;
|
exports.getCurrentManager = getCurrentManager;
|
||||||
exports.renderToStringWithMeta = renderToStringWithMeta;
|
exports.renderToStringWithMeta = renderToStringWithMeta;
|
||||||
|
|||||||
Vendored
+31
-16
@@ -1,36 +1,49 @@
|
|||||||
import { App, ComponentInternalInstance, Slots, VNode } from 'vue';
|
import { App, ComponentInternalInstance, Slots, VNode } from 'vue';
|
||||||
import { SSRContext } from '@vue/server-renderer';
|
import { SSRContext } from '@vue/server-renderer';
|
||||||
|
|
||||||
declare type MergeSource = {
|
declare const IS_PROXY: unique symbol;
|
||||||
[key: string]: any;
|
declare const PROXY_SOURCES: unique symbol;
|
||||||
|
declare const PROXY_TARGET: unique symbol;
|
||||||
|
declare const RESOLVE_CONTEXT: unique symbol;
|
||||||
|
|
||||||
|
interface ResolveContext {
|
||||||
|
}
|
||||||
|
declare type MergeSource<T extends Object> = {
|
||||||
|
[K in keyof T]: T[K];
|
||||||
|
} & {
|
||||||
|
[IS_PROXY]: boolean;
|
||||||
|
[PROXY_SOURCES]: MergeSource<T>[];
|
||||||
|
[PROXY_TARGET]: MergeSource<T>;
|
||||||
|
[RESOLVE_CONTEXT]: ResolveContext;
|
||||||
};
|
};
|
||||||
declare type MergedObjectValue = boolean | number | string | MergedObject | any;
|
declare type MergedObjectValue = boolean | number | string | MergedObject | any;
|
||||||
declare type MergedObject = {
|
declare type MergedObject = {
|
||||||
[key: string]: MergedObjectValue;
|
[key: string]: MergedObjectValue;
|
||||||
};
|
};
|
||||||
declare type PathSegments = Array<string>;
|
declare type PathSegments = Array<string>;
|
||||||
declare type ResolveContext = {};
|
interface ResolveMethod<T = any, U = ResolveContext> {
|
||||||
declare type ResolveMethod = (options: Array<any>, contexts: Array<ResolveContext>, active: MergedObjectValue, key: string | number | symbol, pathSegments: PathSegments) => MergedObjectValue;
|
(options: Array<T>, contexts: Array<U>, active: MergedObjectValue, key: string | number | symbol, pathSegments: PathSegments): MergedObjectValue;
|
||||||
declare type MergeContext = {
|
}
|
||||||
|
declare type MergeContext<T> = {
|
||||||
resolve: ResolveMethod;
|
resolve: ResolveMethod;
|
||||||
active: MergedObject;
|
active: MergedObject;
|
||||||
sources: Array<MergeSource>;
|
sources: MergeSource<T>[];
|
||||||
};
|
};
|
||||||
declare type MergedObjectBuilder = {
|
declare type MergedObjectBuilder<T> = {
|
||||||
context: MergeContext;
|
context: MergeContext<T>;
|
||||||
compute: () => void;
|
compute: () => void;
|
||||||
addSource: (source: MergeSource, resolveContext: ResolveContext | undefined, recompute?: Boolean) => any;
|
addSource: (source: T, resolveContext?: ResolveContext, recompute?: Boolean) => any;
|
||||||
delSource: (sourceOrProxy: MergeSource, recompute?: boolean) => boolean;
|
delSource: (sourceOrProxy: T | MergeSource<T>, recompute?: boolean) => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type createMetaManagerMethod = (config: MetaConfig, resolver: MetaResolver | ResolveMethod) => MetaManager;
|
declare type createMetaManagerMethod = (config: MetaConfig, resolver: MetaResolver | ResolveMethod) => MetaManager;
|
||||||
declare const createMetaManager: createMetaManagerMethod;
|
declare const createMetaManager: (config?: MetaConfig | undefined, resolver?: MetaResolver | undefined) => MetaManager;
|
||||||
declare class MetaManager {
|
declare class MetaManager {
|
||||||
config: MetaConfig;
|
config: MetaConfig;
|
||||||
target: MergedObjectBuilder;
|
target: MergedObjectBuilder<MetaSource>;
|
||||||
resolver?: MetaResolverSetup;
|
resolver?: MetaResolverSetup;
|
||||||
ssrCleanedUp: boolean;
|
ssrCleanedUp: boolean;
|
||||||
constructor(config: MetaConfig, target: MergedObjectBuilder, resolver: MetaResolver | ResolveMethod);
|
constructor(config: MetaConfig, target: MergedObjectBuilder<MetaSource>, resolver: MetaResolver | ResolveMethod);
|
||||||
static create: createMetaManagerMethod;
|
static create: createMetaManagerMethod;
|
||||||
install(app: App): void;
|
install(app: App): void;
|
||||||
addMeta(metadata: MetaSource, vm?: ComponentInternalInstance): MetaProxy;
|
addMeta(metadata: MetaSource, vm?: ComponentInternalInstance): MetaProxy;
|
||||||
@@ -173,7 +186,7 @@ declare type MergeResolveContextDeepest = MetaResolveContext & {
|
|||||||
depth: number;
|
depth: number;
|
||||||
};
|
};
|
||||||
declare function setup(context: MergeResolveContextDeepest): void;
|
declare function setup(context: MergeResolveContextDeepest): void;
|
||||||
declare const resolve: ResolveMethod;
|
declare const resolve: ResolveMethod<any, MergeResolveContextDeepest>;
|
||||||
|
|
||||||
declare const deepest_d_setup: typeof setup;
|
declare const deepest_d_setup: typeof setup;
|
||||||
declare const deepest_d_resolve: typeof resolve;
|
declare const deepest_d_resolve: typeof resolve;
|
||||||
@@ -186,8 +199,10 @@ declare namespace deepest_d {
|
|||||||
|
|
||||||
declare const defaultConfig: MetaConfig;
|
declare const defaultConfig: MetaConfig;
|
||||||
|
|
||||||
declare type ResolveOptionReducer = (accumulator: any, context: ResolveContext) => ResolveMethod;
|
interface ResolveOptionPredicament<T, U> {
|
||||||
declare const resolveOption: (predicament: ResolveOptionReducer) => ResolveMethod;
|
(currentValue: T | undefined, context: U): T;
|
||||||
|
}
|
||||||
|
declare const resolveOption: <T, U = ResolveContext>(predicament: ResolveOptionPredicament<T, U>, initialValue?: T | undefined) => ResolveMethod<any, U>;
|
||||||
|
|
||||||
declare function renderToStringWithMeta(app: App): Promise<[string, SSRContext]>;
|
declare function renderToStringWithMeta(app: App): Promise<[string, SSRContext]>;
|
||||||
|
|
||||||
|
|||||||
Vendored
+20
-19
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v3.0.0-alpha.2
|
* vue-meta v3.0.0-alpha.3
|
||||||
* (c) 2021
|
* (c) 2021
|
||||||
* - Pim (@pimlie)
|
* - Pim (@pimlie)
|
||||||
* - All the amazing contributors
|
* - All the amazing contributors
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport, Comment } from 'vue';
|
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport, Comment } from 'vue';
|
||||||
|
|
||||||
const resolveOption = predicament => (options, contexts) => {
|
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||||
let resolvedIndex = -1;
|
let resolvedIndex = -1;
|
||||||
contexts.reduce((acc, context, index) => {
|
contexts.reduce((acc, context, index) => {
|
||||||
const retval = predicament(acc, context);
|
const retval = predicament(acc, context);
|
||||||
@@ -17,7 +17,7 @@ const resolveOption = predicament => (options, contexts) => {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, undefined);
|
}, initialValue);
|
||||||
if (resolvedIndex > -1) {
|
if (resolvedIndex > -1) {
|
||||||
return options[resolvedIndex];
|
return options[resolvedIndex];
|
||||||
}
|
}
|
||||||
@@ -36,14 +36,15 @@ function setup(context) {
|
|||||||
}
|
}
|
||||||
context.depth = depth;
|
context.depth = depth;
|
||||||
}
|
}
|
||||||
const resolve = resolveOption((acc, context) => {
|
const resolve = resolveOption((currentValue, context) => {
|
||||||
const { depth } = context;
|
const { depth } = context;
|
||||||
if (!acc || depth > acc) {
|
if (!currentValue || depth > currentValue) {
|
||||||
return acc;
|
return depth;
|
||||||
}
|
}
|
||||||
|
return currentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
var deepest = /*#__PURE__*/Object.freeze({
|
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
setup: setup,
|
setup: setup,
|
||||||
resolve: resolve
|
resolve: resolve
|
||||||
@@ -157,10 +158,9 @@ function getTagConfigItem(tagOrName, key) {
|
|||||||
* \/\*#\_\_PURE\_\_\*\/
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
* So that rollup can tree-shake them if necessary.
|
* So that rollup can tree-shake them if necessary.
|
||||||
*/
|
*/
|
||||||
(process.env.NODE_ENV !== 'production')
|
Object.freeze({})
|
||||||
? Object.freeze({})
|
;
|
||||||
: {};
|
Object.freeze([]) ;
|
||||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
|
||||||
const isArray = Array.isArray;
|
const isArray = Array.isArray;
|
||||||
const isFunction = (val) => typeof val === 'function';
|
const isFunction = (val) => typeof val === 'function';
|
||||||
const isString = (val) => typeof val === 'string';
|
const isString = (val) => typeof val === 'string';
|
||||||
@@ -248,6 +248,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
// This assumes consistent types usages for keys across sources
|
// This assumes consistent types usages for keys across sources
|
||||||
|
// @ts-ignore
|
||||||
if (isPlainObject(sources[0][key])) {
|
if (isPlainObject(sources[0][key])) {
|
||||||
if (!target[key]) {
|
if (!target[key]) {
|
||||||
target[key] = {};
|
target[key] = {};
|
||||||
@@ -255,6 +256,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
const keySources = [];
|
const keySources = [];
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (key in source) {
|
if (key in source) {
|
||||||
|
// @ts-ignore
|
||||||
keySources.push(source[key]);
|
keySources.push(source[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Ensure the target is an array if source is an array and target is empty
|
// Ensure the target is an array if source is an array and target is empty
|
||||||
|
// @ts-ignore
|
||||||
if (!target[key] && isArray(sources[0][key])) {
|
if (!target[key] && isArray(sources[0][key])) {
|
||||||
target[key] = [];
|
target[key] = [];
|
||||||
}
|
}
|
||||||
@@ -305,7 +308,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
if (!value[IS_PROXY]) {
|
if (!value[IS_PROXY]) {
|
||||||
const keyPath = [...pathSegments, key];
|
const keyPath = [...pathSegments, key];
|
||||||
value = createProxy(context, value, resolveContext, keyPath);
|
value = createProxy(context, value, resolveContext, keyPath);
|
||||||
target[key] = value;
|
Reflect.set(target, key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
@@ -377,6 +380,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
let active = context.active;
|
let active = context.active;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
|
// @ts-ignore
|
||||||
proxies = proxies.map(proxy => proxy[segment]);
|
proxies = proxies.map(proxy => proxy[segment]);
|
||||||
if (isArrayItem && index === pathSegments.length - 1) {
|
if (isArrayItem && index === pathSegments.length - 1) {
|
||||||
activeSegmentKey = segment;
|
activeSegmentKey = segment;
|
||||||
@@ -417,11 +421,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMergedObject = (resolve, active = {}) => {
|
const createMergedObject = (resolve, active) => {
|
||||||
const sources = [];
|
const sources = [];
|
||||||
if (!active) {
|
|
||||||
active = {};
|
|
||||||
}
|
|
||||||
const context = {
|
const context = {
|
||||||
active,
|
active,
|
||||||
resolve,
|
resolve,
|
||||||
@@ -439,7 +440,7 @@ const createMergedObject = (resolve, active = {}) => {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
delSource: (sourceOrProxy, recompute = true) => {
|
delSource: (sourceOrProxy, recompute = true) => {
|
||||||
const index = sources.findIndex(src => src === sourceOrProxy || src[PROXY_TARGET] === sourceOrProxy);
|
const index = sources.findIndex(source => source === sourceOrProxy || source[PROXY_TARGET] === sourceOrProxy);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
if (recompute) {
|
if (recompute) {
|
||||||
@@ -745,7 +746,7 @@ function addVnode(teleports, to, vnodes) {
|
|||||||
}
|
}
|
||||||
teleports[to].push(...nodes);
|
teleports[to].push(...nodes);
|
||||||
}
|
}
|
||||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||||
class MetaManager {
|
class MetaManager {
|
||||||
constructor(config, target, resolver) {
|
constructor(config, target, resolver) {
|
||||||
this.ssrCleanedUp = false;
|
this.ssrCleanedUp = false;
|
||||||
@@ -882,4 +883,4 @@ MetaManager.create = (config, resolver) => {
|
|||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { createMetaManager, deepest as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
|
export { createMetaManager, defaultResolver as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+25
-25
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v3.0.0-alpha.2
|
* vue-meta v3.0.0-alpha.3
|
||||||
* (c) 2021
|
* (c) 2021
|
||||||
* - Pim (@pimlie)
|
* - Pim (@pimlie)
|
||||||
* - All the amazing contributors
|
* - All the amazing contributors
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport } from 'vue';
|
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport } from 'vue';
|
||||||
|
|
||||||
const resolveOption = predicament => (options, contexts) => {
|
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||||
let resolvedIndex = -1;
|
let resolvedIndex = -1;
|
||||||
contexts.reduce((acc, context, index) => {
|
contexts.reduce((acc, context, index) => {
|
||||||
const retval = predicament(acc, context);
|
const retval = predicament(acc, context);
|
||||||
@@ -17,7 +17,7 @@ const resolveOption = predicament => (options, contexts) => {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, undefined);
|
}, initialValue);
|
||||||
if (resolvedIndex > -1) {
|
if (resolvedIndex > -1) {
|
||||||
return options[resolvedIndex];
|
return options[resolvedIndex];
|
||||||
}
|
}
|
||||||
@@ -36,14 +36,15 @@ function setup(context) {
|
|||||||
}
|
}
|
||||||
context.depth = depth;
|
context.depth = depth;
|
||||||
}
|
}
|
||||||
const resolve = resolveOption((acc, context) => {
|
const resolve = resolveOption((currentValue, context) => {
|
||||||
const { depth } = context;
|
const { depth } = context;
|
||||||
if (!acc || depth > acc) {
|
if (!currentValue || depth > currentValue) {
|
||||||
return acc;
|
return depth;
|
||||||
}
|
}
|
||||||
|
return currentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
var deepest = /*#__PURE__*/Object.freeze({
|
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
setup: setup,
|
setup: setup,
|
||||||
resolve: resolve
|
resolve: resolve
|
||||||
@@ -157,10 +158,9 @@ function getTagConfigItem(tagOrName, key) {
|
|||||||
* \/\*#\_\_PURE\_\_\*\/
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
* So that rollup can tree-shake them if necessary.
|
* So that rollup can tree-shake them if necessary.
|
||||||
*/
|
*/
|
||||||
(process.env.NODE_ENV !== 'production')
|
Object.freeze({})
|
||||||
? Object.freeze({})
|
;
|
||||||
: {};
|
Object.freeze([]) ;
|
||||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
|
||||||
const isArray = Array.isArray;
|
const isArray = Array.isArray;
|
||||||
const isFunction = (val) => typeof val === 'function';
|
const isFunction = (val) => typeof val === 'function';
|
||||||
const isString = (val) => typeof val === 'string';
|
const isString = (val) => typeof val === 'string';
|
||||||
@@ -248,6 +248,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
// This assumes consistent types usages for keys across sources
|
// This assumes consistent types usages for keys across sources
|
||||||
|
// @ts-ignore
|
||||||
if (isPlainObject(sources[0][key])) {
|
if (isPlainObject(sources[0][key])) {
|
||||||
if (!target[key]) {
|
if (!target[key]) {
|
||||||
target[key] = {};
|
target[key] = {};
|
||||||
@@ -255,6 +256,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
const keySources = [];
|
const keySources = [];
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (key in source) {
|
if (key in source) {
|
||||||
|
// @ts-ignore
|
||||||
keySources.push(source[key]);
|
keySources.push(source[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Ensure the target is an array if source is an array and target is empty
|
// Ensure the target is an array if source is an array and target is empty
|
||||||
|
// @ts-ignore
|
||||||
if (!target[key] && isArray(sources[0][key])) {
|
if (!target[key] && isArray(sources[0][key])) {
|
||||||
target[key] = [];
|
target[key] = [];
|
||||||
}
|
}
|
||||||
@@ -305,7 +308,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
if (!value[IS_PROXY]) {
|
if (!value[IS_PROXY]) {
|
||||||
const keyPath = [...pathSegments, key];
|
const keyPath = [...pathSegments, key];
|
||||||
value = createProxy(context, value, resolveContext, keyPath);
|
value = createProxy(context, value, resolveContext, keyPath);
|
||||||
target[key] = value;
|
Reflect.set(target, key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
@@ -377,6 +380,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
let active = context.active;
|
let active = context.active;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
|
// @ts-ignore
|
||||||
proxies = proxies.map(proxy => proxy[segment]);
|
proxies = proxies.map(proxy => proxy[segment]);
|
||||||
if (isArrayItem && index === pathSegments.length - 1) {
|
if (isArrayItem && index === pathSegments.length - 1) {
|
||||||
activeSegmentKey = segment;
|
activeSegmentKey = segment;
|
||||||
@@ -417,11 +421,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMergedObject = (resolve, active = {}) => {
|
const createMergedObject = (resolve, active) => {
|
||||||
const sources = [];
|
const sources = [];
|
||||||
if (!active) {
|
|
||||||
active = {};
|
|
||||||
}
|
|
||||||
const context = {
|
const context = {
|
||||||
active,
|
active,
|
||||||
resolve,
|
resolve,
|
||||||
@@ -439,7 +440,7 @@ const createMergedObject = (resolve, active = {}) => {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
delSource: (sourceOrProxy, recompute = true) => {
|
delSource: (sourceOrProxy, recompute = true) => {
|
||||||
const index = sources.findIndex(src => src === sourceOrProxy || src[PROXY_TARGET] === sourceOrProxy);
|
const index = sources.findIndex(source => source === sourceOrProxy || source[PROXY_TARGET] === sourceOrProxy);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
if (recompute) {
|
if (recompute) {
|
||||||
@@ -465,7 +466,7 @@ function renderMeta(context, key, data, config) {
|
|||||||
function renderGroup(context, key, data, config) {
|
function renderGroup(context, key, data, config) {
|
||||||
// console.info('renderGroup', key, data, config)
|
// console.info('renderGroup', key, data, config)
|
||||||
if (isArray(data)) {
|
if (isArray(data)) {
|
||||||
if ((process.env.NODE_ENV !== 'production')) {
|
if (("development" !== 'production')) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.warn('Specifying an array for group properties isnt supported');
|
console.warn('Specifying an array for group properties isnt supported');
|
||||||
}
|
}
|
||||||
@@ -631,9 +632,9 @@ const hasSymbol = typeof Symbol === 'function' && typeof Symbol.toStringTag ===
|
|||||||
const PolySymbol = (name) =>
|
const PolySymbol = (name) =>
|
||||||
// vm = vue meta
|
// vm = vue meta
|
||||||
hasSymbol
|
hasSymbol
|
||||||
? Symbol((process.env.NODE_ENV !== 'production') ? '[vue-meta]: ' + name : name)
|
? Symbol(("development" !== 'production') ? '[vue-meta]: ' + name : name)
|
||||||
: ((process.env.NODE_ENV !== 'production') ? '[vue-meta]: ' : '_vm_') + name;
|
: (("development" !== 'production') ? '[vue-meta]: ' : '_vm_') + name;
|
||||||
const metaActiveKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'meta_active' : 'ma');
|
const metaActiveKey = /*#__PURE__*/ PolySymbol(("development" !== 'production') ? 'meta_active' : 'ma');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the differences between newSource & oldSource to target
|
* Apply the differences between newSource & oldSource to target
|
||||||
@@ -723,7 +724,7 @@ function addVnode(teleports, to, vnodes) {
|
|||||||
}
|
}
|
||||||
teleports[to].push(...nodes);
|
teleports[to].push(...nodes);
|
||||||
}
|
}
|
||||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||||
class MetaManager {
|
class MetaManager {
|
||||||
constructor(config, target, resolver) {
|
constructor(config, target, resolver) {
|
||||||
this.ssrCleanedUp = false;
|
this.ssrCleanedUp = false;
|
||||||
@@ -846,9 +847,8 @@ MetaManager.create = (config, resolver) => {
|
|||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
// rollup doesnt like an import as it cant find the export so use require
|
|
||||||
const { renderToString } = require('@vue/server-renderer');
|
|
||||||
async function renderToStringWithMeta(app) {
|
async function renderToStringWithMeta(app) {
|
||||||
|
const { renderToString } = await import('@vue/server-renderer');
|
||||||
const ctx = {};
|
const ctx = {};
|
||||||
const html = await renderToString(app, ctx);
|
const html = await renderToString(app, ctx);
|
||||||
// TODO: better way of determining whether meta was rendered with the component or not
|
// TODO: better way of determining whether meta was rendered with the component or not
|
||||||
@@ -867,4 +867,4 @@ async function renderToStringWithMeta(app) {
|
|||||||
return [html, ctx];
|
return [html, ctx];
|
||||||
}
|
}
|
||||||
|
|
||||||
export { createMetaManager, deepest as deepestResolver, defaultConfig, getCurrentManager, renderToStringWithMeta, resolveOption, useActiveMeta, useMeta };
|
export { createMetaManager, defaultResolver as deepestResolver, defaultConfig, getCurrentManager, renderToStringWithMeta, resolveOption, useActiveMeta, useMeta };
|
||||||
|
|||||||
Vendored
+20
-19
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v3.0.0-alpha.2
|
* vue-meta v3.0.0-alpha.3
|
||||||
* (c) 2021
|
* (c) 2021
|
||||||
* - Pim (@pimlie)
|
* - Pim (@pimlie)
|
||||||
* - All the amazing contributors
|
* - All the amazing contributors
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
var VueMeta = (function (exports, vue) {
|
var VueMeta = (function (exports, vue) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const resolveOption = predicament => (options, contexts) => {
|
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||||
let resolvedIndex = -1;
|
let resolvedIndex = -1;
|
||||||
contexts.reduce((acc, context, index) => {
|
contexts.reduce((acc, context, index) => {
|
||||||
const retval = predicament(acc, context);
|
const retval = predicament(acc, context);
|
||||||
@@ -18,7 +18,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, undefined);
|
}, initialValue);
|
||||||
if (resolvedIndex > -1) {
|
if (resolvedIndex > -1) {
|
||||||
return options[resolvedIndex];
|
return options[resolvedIndex];
|
||||||
}
|
}
|
||||||
@@ -37,14 +37,15 @@ var VueMeta = (function (exports, vue) {
|
|||||||
}
|
}
|
||||||
context.depth = depth;
|
context.depth = depth;
|
||||||
}
|
}
|
||||||
const resolve = resolveOption((acc, context) => {
|
const resolve = resolveOption((currentValue, context) => {
|
||||||
const { depth } = context;
|
const { depth } = context;
|
||||||
if (!acc || depth > acc) {
|
if (!currentValue || depth > currentValue) {
|
||||||
return acc;
|
return depth;
|
||||||
}
|
}
|
||||||
|
return currentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
var deepest = /*#__PURE__*/Object.freeze({
|
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
setup: setup,
|
setup: setup,
|
||||||
resolve: resolve
|
resolve: resolve
|
||||||
@@ -158,10 +159,9 @@ var VueMeta = (function (exports, vue) {
|
|||||||
* \/\*#\_\_PURE\_\_\*\/
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
* So that rollup can tree-shake them if necessary.
|
* So that rollup can tree-shake them if necessary.
|
||||||
*/
|
*/
|
||||||
(process.env.NODE_ENV !== 'production')
|
Object.freeze({})
|
||||||
? Object.freeze({})
|
;
|
||||||
: {};
|
Object.freeze([]) ;
|
||||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
|
||||||
const isArray = Array.isArray;
|
const isArray = Array.isArray;
|
||||||
const isFunction = (val) => typeof val === 'function';
|
const isFunction = (val) => typeof val === 'function';
|
||||||
const isString = (val) => typeof val === 'string';
|
const isString = (val) => typeof val === 'string';
|
||||||
@@ -249,6 +249,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
// This assumes consistent types usages for keys across sources
|
// This assumes consistent types usages for keys across sources
|
||||||
|
// @ts-ignore
|
||||||
if (isPlainObject(sources[0][key])) {
|
if (isPlainObject(sources[0][key])) {
|
||||||
if (!target[key]) {
|
if (!target[key]) {
|
||||||
target[key] = {};
|
target[key] = {};
|
||||||
@@ -256,6 +257,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
const keySources = [];
|
const keySources = [];
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (key in source) {
|
if (key in source) {
|
||||||
|
// @ts-ignore
|
||||||
keySources.push(source[key]);
|
keySources.push(source[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,6 +265,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Ensure the target is an array if source is an array and target is empty
|
// Ensure the target is an array if source is an array and target is empty
|
||||||
|
// @ts-ignore
|
||||||
if (!target[key] && isArray(sources[0][key])) {
|
if (!target[key] && isArray(sources[0][key])) {
|
||||||
target[key] = [];
|
target[key] = [];
|
||||||
}
|
}
|
||||||
@@ -306,7 +309,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
if (!value[IS_PROXY]) {
|
if (!value[IS_PROXY]) {
|
||||||
const keyPath = [...pathSegments, key];
|
const keyPath = [...pathSegments, key];
|
||||||
value = createProxy(context, value, resolveContext, keyPath);
|
value = createProxy(context, value, resolveContext, keyPath);
|
||||||
target[key] = value;
|
Reflect.set(target, key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
@@ -378,6 +381,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
let active = context.active;
|
let active = context.active;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
|
// @ts-ignore
|
||||||
proxies = proxies.map(proxy => proxy[segment]);
|
proxies = proxies.map(proxy => proxy[segment]);
|
||||||
if (isArrayItem && index === pathSegments.length - 1) {
|
if (isArrayItem && index === pathSegments.length - 1) {
|
||||||
activeSegmentKey = segment;
|
activeSegmentKey = segment;
|
||||||
@@ -418,11 +422,8 @@ var VueMeta = (function (exports, vue) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMergedObject = (resolve, active = {}) => {
|
const createMergedObject = (resolve, active) => {
|
||||||
const sources = [];
|
const sources = [];
|
||||||
if (!active) {
|
|
||||||
active = {};
|
|
||||||
}
|
|
||||||
const context = {
|
const context = {
|
||||||
active,
|
active,
|
||||||
resolve,
|
resolve,
|
||||||
@@ -440,7 +441,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
delSource: (sourceOrProxy, recompute = true) => {
|
delSource: (sourceOrProxy, recompute = true) => {
|
||||||
const index = sources.findIndex(src => src === sourceOrProxy || src[PROXY_TARGET] === sourceOrProxy);
|
const index = sources.findIndex(source => source === sourceOrProxy || source[PROXY_TARGET] === sourceOrProxy);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
if (recompute) {
|
if (recompute) {
|
||||||
@@ -746,7 +747,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
}
|
}
|
||||||
teleports[to].push(...nodes);
|
teleports[to].push(...nodes);
|
||||||
}
|
}
|
||||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||||
class MetaManager {
|
class MetaManager {
|
||||||
constructor(config, target, resolver) {
|
constructor(config, target, resolver) {
|
||||||
this.ssrCleanedUp = false;
|
this.ssrCleanedUp = false;
|
||||||
@@ -884,7 +885,7 @@ var VueMeta = (function (exports, vue) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.createMetaManager = createMetaManager;
|
exports.createMetaManager = createMetaManager;
|
||||||
exports.deepestResolver = deepest;
|
exports.deepestResolver = defaultResolver;
|
||||||
exports.defaultConfig = defaultConfig;
|
exports.defaultConfig = defaultConfig;
|
||||||
exports.getCurrentManager = getCurrentManager;
|
exports.getCurrentManager = getCurrentManager;
|
||||||
exports.resolveOption = resolveOption;
|
exports.resolveOption = resolveOption;
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-meta",
|
"name": "vue-meta",
|
||||||
"version": "3.0.0-alpha.2",
|
"version": "3.0.0-alpha.3",
|
||||||
"description": "Manage HTML metadata in Vue.js components with SSR support",
|
"description": "Manage HTML metadata in Vue.js components with SSR support",
|
||||||
"main": "dist/vue-meta.cjs.js",
|
"main": "dist/vue-meta.cjs.js",
|
||||||
"unpkg": "dist/vue-meta.global.js",
|
"unpkg": "dist/vue-meta.global.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user