mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-06 07:02:24 +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.
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
Vendored
+33
-21
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.2
|
||||
* vue-meta v3.0.0-alpha.3
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -12,7 +12,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
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;
|
||||
contexts.reduce((acc, context, index) => {
|
||||
const retval = predicament(acc, context);
|
||||
@@ -21,7 +33,7 @@ const resolveOption = predicament => (options, contexts) => {
|
||||
return retval;
|
||||
}
|
||||
return acc;
|
||||
}, undefined);
|
||||
}, initialValue);
|
||||
if (resolvedIndex > -1) {
|
||||
return options[resolvedIndex];
|
||||
}
|
||||
@@ -40,14 +52,15 @@ function setup(context) {
|
||||
}
|
||||
context.depth = depth;
|
||||
}
|
||||
const resolve = resolveOption((acc, context) => {
|
||||
const resolve = resolveOption((currentValue, context) => {
|
||||
const { depth } = context;
|
||||
if (!acc || depth > acc) {
|
||||
return acc;
|
||||
if (!currentValue || depth > currentValue) {
|
||||
return depth;
|
||||
}
|
||||
return currentValue;
|
||||
});
|
||||
|
||||
var deepest = /*#__PURE__*/Object.freeze({
|
||||
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
setup: setup,
|
||||
resolve: resolve
|
||||
@@ -161,10 +174,9 @@ function getTagConfigItem(tagOrName, key) {
|
||||
* \/\*#\_\_PURE\_\_\*\/
|
||||
* So that rollup can tree-shake them if necessary.
|
||||
*/
|
||||
(process.env.NODE_ENV !== 'production')
|
||||
? Object.freeze({})
|
||||
: {};
|
||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
||||
Object.freeze({})
|
||||
;
|
||||
Object.freeze([]) ;
|
||||
const isArray = Array.isArray;
|
||||
const isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
@@ -252,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
}
|
||||
for (const key of keys) {
|
||||
// This assumes consistent types usages for keys across sources
|
||||
// @ts-ignore
|
||||
if (isPlainObject(sources[0][key])) {
|
||||
if (!target[key]) {
|
||||
target[key] = {};
|
||||
@@ -259,6 +272,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
const keySources = [];
|
||||
for (const source of sources) {
|
||||
if (key in source) {
|
||||
// @ts-ignore
|
||||
keySources.push(source[key]);
|
||||
}
|
||||
}
|
||||
@@ -266,6 +280,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
continue;
|
||||
}
|
||||
// Ensure the target is an array if source is an array and target is empty
|
||||
// @ts-ignore
|
||||
if (!target[key] && isArray(sources[0][key])) {
|
||||
target[key] = [];
|
||||
}
|
||||
@@ -309,7 +324,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
if (!value[IS_PROXY]) {
|
||||
const keyPath = [...pathSegments, key];
|
||||
value = createProxy(context, value, resolveContext, keyPath);
|
||||
target[key] = value;
|
||||
Reflect.set(target, key, value);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -381,6 +396,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
let active = context.active;
|
||||
let index = 0;
|
||||
for (const segment of pathSegments) {
|
||||
// @ts-ignore
|
||||
proxies = proxies.map(proxy => proxy[segment]);
|
||||
if (isArrayItem && index === pathSegments.length - 1) {
|
||||
activeSegmentKey = segment;
|
||||
@@ -421,11 +437,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
}
|
||||
});
|
||||
|
||||
const createMergedObject = (resolve, active = {}) => {
|
||||
const createMergedObject = (resolve, active) => {
|
||||
const sources = [];
|
||||
if (!active) {
|
||||
active = {};
|
||||
}
|
||||
const context = {
|
||||
active,
|
||||
resolve,
|
||||
@@ -443,7 +456,7 @@ const createMergedObject = (resolve, active = {}) => {
|
||||
return proxy;
|
||||
},
|
||||
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) {
|
||||
sources.splice(index, 1);
|
||||
if (recompute) {
|
||||
@@ -727,7 +740,7 @@ function addVnode(teleports, to, vnodes) {
|
||||
}
|
||||
teleports[to].push(...nodes);
|
||||
}
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||
class MetaManager {
|
||||
constructor(config, target, resolver) {
|
||||
this.ssrCleanedUp = false;
|
||||
@@ -850,9 +863,8 @@ MetaManager.create = (config, resolver) => {
|
||||
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) {
|
||||
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
|
||||
@@ -872,7 +884,7 @@ async function renderToStringWithMeta(app) {
|
||||
}
|
||||
|
||||
exports.createMetaManager = createMetaManager;
|
||||
exports.deepestResolver = deepest;
|
||||
exports.deepestResolver = defaultResolver;
|
||||
exports.defaultConfig = defaultConfig;
|
||||
exports.getCurrentManager = getCurrentManager;
|
||||
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
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -12,7 +12,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
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;
|
||||
contexts.reduce((acc, context, index) => {
|
||||
const retval = predicament(acc, context);
|
||||
@@ -21,7 +33,7 @@ const resolveOption = predicament => (options, contexts) => {
|
||||
return retval;
|
||||
}
|
||||
return acc;
|
||||
}, undefined);
|
||||
}, initialValue);
|
||||
if (resolvedIndex > -1) {
|
||||
return options[resolvedIndex];
|
||||
}
|
||||
@@ -40,14 +52,15 @@ function setup(context) {
|
||||
}
|
||||
context.depth = depth;
|
||||
}
|
||||
const resolve = resolveOption((acc, context) => {
|
||||
const resolve = resolveOption((currentValue, context) => {
|
||||
const { depth } = context;
|
||||
if (!acc || depth > acc) {
|
||||
return acc;
|
||||
if (!currentValue || depth > currentValue) {
|
||||
return depth;
|
||||
}
|
||||
return currentValue;
|
||||
});
|
||||
|
||||
var deepest = /*#__PURE__*/Object.freeze({
|
||||
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
setup: setup,
|
||||
resolve: resolve
|
||||
@@ -161,10 +174,6 @@ function getTagConfigItem(tagOrName, key) {
|
||||
* \/\*#\_\_PURE\_\_\*\/
|
||||
* 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 isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
@@ -252,6 +261,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
}
|
||||
for (const key of keys) {
|
||||
// This assumes consistent types usages for keys across sources
|
||||
// @ts-ignore
|
||||
if (isPlainObject(sources[0][key])) {
|
||||
if (!target[key]) {
|
||||
target[key] = {};
|
||||
@@ -259,6 +269,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
const keySources = [];
|
||||
for (const source of sources) {
|
||||
if (key in source) {
|
||||
// @ts-ignore
|
||||
keySources.push(source[key]);
|
||||
}
|
||||
}
|
||||
@@ -266,6 +277,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
continue;
|
||||
}
|
||||
// Ensure the target is an array if source is an array and target is empty
|
||||
// @ts-ignore
|
||||
if (!target[key] && isArray(sources[0][key])) {
|
||||
target[key] = [];
|
||||
}
|
||||
@@ -309,7 +321,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
if (!value[IS_PROXY]) {
|
||||
const keyPath = [...pathSegments, key];
|
||||
value = createProxy(context, value, resolveContext, keyPath);
|
||||
target[key] = value;
|
||||
Reflect.set(target, key, value);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -381,6 +393,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
let active = context.active;
|
||||
let index = 0;
|
||||
for (const segment of pathSegments) {
|
||||
// @ts-ignore
|
||||
proxies = proxies.map(proxy => proxy[segment]);
|
||||
if (isArrayItem && index === pathSegments.length - 1) {
|
||||
activeSegmentKey = segment;
|
||||
@@ -421,11 +434,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
}
|
||||
});
|
||||
|
||||
const createMergedObject = (resolve, active = {}) => {
|
||||
const createMergedObject = (resolve, active) => {
|
||||
const sources = [];
|
||||
if (!active) {
|
||||
active = {};
|
||||
}
|
||||
const context = {
|
||||
active,
|
||||
resolve,
|
||||
@@ -443,7 +453,7 @@ const createMergedObject = (resolve, active = {}) => {
|
||||
return proxy;
|
||||
},
|
||||
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) {
|
||||
sources.splice(index, 1);
|
||||
if (recompute) {
|
||||
@@ -723,7 +733,7 @@ function addVnode(teleports, to, vnodes) {
|
||||
}
|
||||
teleports[to].push(...nodes);
|
||||
}
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||
class MetaManager {
|
||||
constructor(config, target, resolver) {
|
||||
this.ssrCleanedUp = false;
|
||||
@@ -846,9 +856,8 @@ MetaManager.create = (config, resolver) => {
|
||||
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) {
|
||||
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
|
||||
@@ -868,7 +877,7 @@ async function renderToStringWithMeta(app) {
|
||||
}
|
||||
|
||||
exports.createMetaManager = createMetaManager;
|
||||
exports.deepestResolver = deepest;
|
||||
exports.deepestResolver = defaultResolver;
|
||||
exports.defaultConfig = defaultConfig;
|
||||
exports.getCurrentManager = getCurrentManager;
|
||||
exports.renderToStringWithMeta = renderToStringWithMeta;
|
||||
|
||||
Vendored
+31
-16
@@ -1,36 +1,49 @@
|
||||
import { App, ComponentInternalInstance, Slots, VNode } from 'vue';
|
||||
import { SSRContext } from '@vue/server-renderer';
|
||||
|
||||
declare type MergeSource = {
|
||||
[key: string]: any;
|
||||
declare const IS_PROXY: unique symbol;
|
||||
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 MergedObject = {
|
||||
[key: string]: MergedObjectValue;
|
||||
};
|
||||
declare type PathSegments = Array<string>;
|
||||
declare type ResolveContext = {};
|
||||
declare type ResolveMethod = (options: Array<any>, contexts: Array<ResolveContext>, active: MergedObjectValue, key: string | number | symbol, pathSegments: PathSegments) => MergedObjectValue;
|
||||
declare type MergeContext = {
|
||||
interface ResolveMethod<T = any, U = ResolveContext> {
|
||||
(options: Array<T>, contexts: Array<U>, active: MergedObjectValue, key: string | number | symbol, pathSegments: PathSegments): MergedObjectValue;
|
||||
}
|
||||
declare type MergeContext<T> = {
|
||||
resolve: ResolveMethod;
|
||||
active: MergedObject;
|
||||
sources: Array<MergeSource>;
|
||||
sources: MergeSource<T>[];
|
||||
};
|
||||
declare type MergedObjectBuilder = {
|
||||
context: MergeContext;
|
||||
declare type MergedObjectBuilder<T> = {
|
||||
context: MergeContext<T>;
|
||||
compute: () => void;
|
||||
addSource: (source: MergeSource, resolveContext: ResolveContext | undefined, recompute?: Boolean) => any;
|
||||
delSource: (sourceOrProxy: MergeSource, recompute?: boolean) => boolean;
|
||||
addSource: (source: T, resolveContext?: ResolveContext, recompute?: Boolean) => any;
|
||||
delSource: (sourceOrProxy: T | MergeSource<T>, recompute?: boolean) => boolean;
|
||||
};
|
||||
|
||||
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 {
|
||||
config: MetaConfig;
|
||||
target: MergedObjectBuilder;
|
||||
target: MergedObjectBuilder<MetaSource>;
|
||||
resolver?: MetaResolverSetup;
|
||||
ssrCleanedUp: boolean;
|
||||
constructor(config: MetaConfig, target: MergedObjectBuilder, resolver: MetaResolver | ResolveMethod);
|
||||
constructor(config: MetaConfig, target: MergedObjectBuilder<MetaSource>, resolver: MetaResolver | ResolveMethod);
|
||||
static create: createMetaManagerMethod;
|
||||
install(app: App): void;
|
||||
addMeta(metadata: MetaSource, vm?: ComponentInternalInstance): MetaProxy;
|
||||
@@ -173,7 +186,7 @@ declare type MergeResolveContextDeepest = MetaResolveContext & {
|
||||
depth: number;
|
||||
};
|
||||
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_resolve: typeof resolve;
|
||||
@@ -186,8 +199,10 @@ declare namespace deepest_d {
|
||||
|
||||
declare const defaultConfig: MetaConfig;
|
||||
|
||||
declare type ResolveOptionReducer = (accumulator: any, context: ResolveContext) => ResolveMethod;
|
||||
declare const resolveOption: (predicament: ResolveOptionReducer) => ResolveMethod;
|
||||
interface ResolveOptionPredicament<T, U> {
|
||||
(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]>;
|
||||
|
||||
|
||||
Vendored
+20
-19
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vue-meta v3.0.0-alpha.2
|
||||
* vue-meta v3.0.0-alpha.3
|
||||
* (c) 2021
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
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;
|
||||
contexts.reduce((acc, context, index) => {
|
||||
const retval = predicament(acc, context);
|
||||
@@ -17,7 +17,7 @@ const resolveOption = predicament => (options, contexts) => {
|
||||
return retval;
|
||||
}
|
||||
return acc;
|
||||
}, undefined);
|
||||
}, initialValue);
|
||||
if (resolvedIndex > -1) {
|
||||
return options[resolvedIndex];
|
||||
}
|
||||
@@ -36,14 +36,15 @@ function setup(context) {
|
||||
}
|
||||
context.depth = depth;
|
||||
}
|
||||
const resolve = resolveOption((acc, context) => {
|
||||
const resolve = resolveOption((currentValue, context) => {
|
||||
const { depth } = context;
|
||||
if (!acc || depth > acc) {
|
||||
return acc;
|
||||
if (!currentValue || depth > currentValue) {
|
||||
return depth;
|
||||
}
|
||||
return currentValue;
|
||||
});
|
||||
|
||||
var deepest = /*#__PURE__*/Object.freeze({
|
||||
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
setup: setup,
|
||||
resolve: resolve
|
||||
@@ -157,10 +158,9 @@ function getTagConfigItem(tagOrName, key) {
|
||||
* \/\*#\_\_PURE\_\_\*\/
|
||||
* So that rollup can tree-shake them if necessary.
|
||||
*/
|
||||
(process.env.NODE_ENV !== 'production')
|
||||
? Object.freeze({})
|
||||
: {};
|
||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
||||
Object.freeze({})
|
||||
;
|
||||
Object.freeze([]) ;
|
||||
const isArray = Array.isArray;
|
||||
const isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
@@ -248,6 +248,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
}
|
||||
for (const key of keys) {
|
||||
// This assumes consistent types usages for keys across sources
|
||||
// @ts-ignore
|
||||
if (isPlainObject(sources[0][key])) {
|
||||
if (!target[key]) {
|
||||
target[key] = {};
|
||||
@@ -255,6 +256,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
const keySources = [];
|
||||
for (const source of sources) {
|
||||
if (key in source) {
|
||||
// @ts-ignore
|
||||
keySources.push(source[key]);
|
||||
}
|
||||
}
|
||||
@@ -262,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
continue;
|
||||
}
|
||||
// Ensure the target is an array if source is an array and target is empty
|
||||
// @ts-ignore
|
||||
if (!target[key] && isArray(sources[0][key])) {
|
||||
target[key] = [];
|
||||
}
|
||||
@@ -305,7 +308,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
if (!value[IS_PROXY]) {
|
||||
const keyPath = [...pathSegments, key];
|
||||
value = createProxy(context, value, resolveContext, keyPath);
|
||||
target[key] = value;
|
||||
Reflect.set(target, key, value);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -377,6 +380,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
let active = context.active;
|
||||
let index = 0;
|
||||
for (const segment of pathSegments) {
|
||||
// @ts-ignore
|
||||
proxies = proxies.map(proxy => proxy[segment]);
|
||||
if (isArrayItem && index === pathSegments.length - 1) {
|
||||
activeSegmentKey = segment;
|
||||
@@ -417,11 +421,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
}
|
||||
});
|
||||
|
||||
const createMergedObject = (resolve, active = {}) => {
|
||||
const createMergedObject = (resolve, active) => {
|
||||
const sources = [];
|
||||
if (!active) {
|
||||
active = {};
|
||||
}
|
||||
const context = {
|
||||
active,
|
||||
resolve,
|
||||
@@ -439,7 +440,7 @@ const createMergedObject = (resolve, active = {}) => {
|
||||
return proxy;
|
||||
},
|
||||
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) {
|
||||
sources.splice(index, 1);
|
||||
if (recompute) {
|
||||
@@ -745,7 +746,7 @@ function addVnode(teleports, to, vnodes) {
|
||||
}
|
||||
teleports[to].push(...nodes);
|
||||
}
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||
class MetaManager {
|
||||
constructor(config, target, resolver) {
|
||||
this.ssrCleanedUp = false;
|
||||
@@ -882,4 +883,4 @@ MetaManager.create = (config, resolver) => {
|
||||
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
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
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;
|
||||
contexts.reduce((acc, context, index) => {
|
||||
const retval = predicament(acc, context);
|
||||
@@ -17,7 +17,7 @@ const resolveOption = predicament => (options, contexts) => {
|
||||
return retval;
|
||||
}
|
||||
return acc;
|
||||
}, undefined);
|
||||
}, initialValue);
|
||||
if (resolvedIndex > -1) {
|
||||
return options[resolvedIndex];
|
||||
}
|
||||
@@ -36,14 +36,15 @@ function setup(context) {
|
||||
}
|
||||
context.depth = depth;
|
||||
}
|
||||
const resolve = resolveOption((acc, context) => {
|
||||
const resolve = resolveOption((currentValue, context) => {
|
||||
const { depth } = context;
|
||||
if (!acc || depth > acc) {
|
||||
return acc;
|
||||
if (!currentValue || depth > currentValue) {
|
||||
return depth;
|
||||
}
|
||||
return currentValue;
|
||||
});
|
||||
|
||||
var deepest = /*#__PURE__*/Object.freeze({
|
||||
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
setup: setup,
|
||||
resolve: resolve
|
||||
@@ -157,10 +158,9 @@ function getTagConfigItem(tagOrName, key) {
|
||||
* \/\*#\_\_PURE\_\_\*\/
|
||||
* So that rollup can tree-shake them if necessary.
|
||||
*/
|
||||
(process.env.NODE_ENV !== 'production')
|
||||
? Object.freeze({})
|
||||
: {};
|
||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
||||
Object.freeze({})
|
||||
;
|
||||
Object.freeze([]) ;
|
||||
const isArray = Array.isArray;
|
||||
const isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
@@ -248,6 +248,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
}
|
||||
for (const key of keys) {
|
||||
// This assumes consistent types usages for keys across sources
|
||||
// @ts-ignore
|
||||
if (isPlainObject(sources[0][key])) {
|
||||
if (!target[key]) {
|
||||
target[key] = {};
|
||||
@@ -255,6 +256,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
const keySources = [];
|
||||
for (const source of sources) {
|
||||
if (key in source) {
|
||||
// @ts-ignore
|
||||
keySources.push(source[key]);
|
||||
}
|
||||
}
|
||||
@@ -262,6 +264,7 @@ const recompute = (context, sources, target, path = []) => {
|
||||
continue;
|
||||
}
|
||||
// Ensure the target is an array if source is an array and target is empty
|
||||
// @ts-ignore
|
||||
if (!target[key] && isArray(sources[0][key])) {
|
||||
target[key] = [];
|
||||
}
|
||||
@@ -305,7 +308,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
if (!value[IS_PROXY]) {
|
||||
const keyPath = [...pathSegments, key];
|
||||
value = createProxy(context, value, resolveContext, keyPath);
|
||||
target[key] = value;
|
||||
Reflect.set(target, key, value);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -377,6 +380,7 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
let active = context.active;
|
||||
let index = 0;
|
||||
for (const segment of pathSegments) {
|
||||
// @ts-ignore
|
||||
proxies = proxies.map(proxy => proxy[segment]);
|
||||
if (isArrayItem && index === pathSegments.length - 1) {
|
||||
activeSegmentKey = segment;
|
||||
@@ -417,11 +421,8 @@ const createHandler = (context, resolveContext, pathSegments = []) => ({
|
||||
}
|
||||
});
|
||||
|
||||
const createMergedObject = (resolve, active = {}) => {
|
||||
const createMergedObject = (resolve, active) => {
|
||||
const sources = [];
|
||||
if (!active) {
|
||||
active = {};
|
||||
}
|
||||
const context = {
|
||||
active,
|
||||
resolve,
|
||||
@@ -439,7 +440,7 @@ const createMergedObject = (resolve, active = {}) => {
|
||||
return proxy;
|
||||
},
|
||||
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) {
|
||||
sources.splice(index, 1);
|
||||
if (recompute) {
|
||||
@@ -465,7 +466,7 @@ function renderMeta(context, key, data, config) {
|
||||
function renderGroup(context, key, data, config) {
|
||||
// console.info('renderGroup', key, data, config)
|
||||
if (isArray(data)) {
|
||||
if ((process.env.NODE_ENV !== 'production')) {
|
||||
if (("development" !== 'production')) {
|
||||
// eslint-disable-next-line no-console
|
||||
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) =>
|
||||
// vm = vue meta
|
||||
hasSymbol
|
||||
? Symbol((process.env.NODE_ENV !== 'production') ? '[vue-meta]: ' + name : name)
|
||||
: ((process.env.NODE_ENV !== 'production') ? '[vue-meta]: ' : '_vm_') + name;
|
||||
const metaActiveKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'meta_active' : 'ma');
|
||||
? Symbol(("development" !== 'production') ? '[vue-meta]: ' + name : name)
|
||||
: (("development" !== 'production') ? '[vue-meta]: ' : '_vm_') + name;
|
||||
const metaActiveKey = /*#__PURE__*/ PolySymbol(("development" !== 'production') ? 'meta_active' : 'ma');
|
||||
|
||||
/**
|
||||
* Apply the differences between newSource & oldSource to target
|
||||
@@ -723,7 +724,7 @@ function addVnode(teleports, to, vnodes) {
|
||||
}
|
||||
teleports[to].push(...nodes);
|
||||
}
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||
class MetaManager {
|
||||
constructor(config, target, resolver) {
|
||||
this.ssrCleanedUp = false;
|
||||
@@ -846,9 +847,8 @@ MetaManager.create = (config, resolver) => {
|
||||
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) {
|
||||
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
|
||||
@@ -867,4 +867,4 @@ async function renderToStringWithMeta(app) {
|
||||
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
|
||||
* - Pim (@pimlie)
|
||||
* - All the amazing contributors
|
||||
@@ -9,7 +9,7 @@
|
||||
var VueMeta = (function (exports, vue) {
|
||||
'use strict';
|
||||
|
||||
const resolveOption = predicament => (options, contexts) => {
|
||||
const resolveOption = (predicament, initialValue) => (options, contexts) => {
|
||||
let resolvedIndex = -1;
|
||||
contexts.reduce((acc, context, index) => {
|
||||
const retval = predicament(acc, context);
|
||||
@@ -18,7 +18,7 @@ var VueMeta = (function (exports, vue) {
|
||||
return retval;
|
||||
}
|
||||
return acc;
|
||||
}, undefined);
|
||||
}, initialValue);
|
||||
if (resolvedIndex > -1) {
|
||||
return options[resolvedIndex];
|
||||
}
|
||||
@@ -37,14 +37,15 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
context.depth = depth;
|
||||
}
|
||||
const resolve = resolveOption((acc, context) => {
|
||||
const resolve = resolveOption((currentValue, context) => {
|
||||
const { depth } = context;
|
||||
if (!acc || depth > acc) {
|
||||
return acc;
|
||||
if (!currentValue || depth > currentValue) {
|
||||
return depth;
|
||||
}
|
||||
return currentValue;
|
||||
});
|
||||
|
||||
var deepest = /*#__PURE__*/Object.freeze({
|
||||
var defaultResolver = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
setup: setup,
|
||||
resolve: resolve
|
||||
@@ -158,10 +159,9 @@ var VueMeta = (function (exports, vue) {
|
||||
* \/\*#\_\_PURE\_\_\*\/
|
||||
* So that rollup can tree-shake them if necessary.
|
||||
*/
|
||||
(process.env.NODE_ENV !== 'production')
|
||||
? Object.freeze({})
|
||||
: {};
|
||||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
|
||||
Object.freeze({})
|
||||
;
|
||||
Object.freeze([]) ;
|
||||
const isArray = Array.isArray;
|
||||
const isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
@@ -249,6 +249,7 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
for (const key of keys) {
|
||||
// This assumes consistent types usages for keys across sources
|
||||
// @ts-ignore
|
||||
if (isPlainObject(sources[0][key])) {
|
||||
if (!target[key]) {
|
||||
target[key] = {};
|
||||
@@ -256,6 +257,7 @@ var VueMeta = (function (exports, vue) {
|
||||
const keySources = [];
|
||||
for (const source of sources) {
|
||||
if (key in source) {
|
||||
// @ts-ignore
|
||||
keySources.push(source[key]);
|
||||
}
|
||||
}
|
||||
@@ -263,6 +265,7 @@ var VueMeta = (function (exports, vue) {
|
||||
continue;
|
||||
}
|
||||
// Ensure the target is an array if source is an array and target is empty
|
||||
// @ts-ignore
|
||||
if (!target[key] && isArray(sources[0][key])) {
|
||||
target[key] = [];
|
||||
}
|
||||
@@ -306,7 +309,7 @@ var VueMeta = (function (exports, vue) {
|
||||
if (!value[IS_PROXY]) {
|
||||
const keyPath = [...pathSegments, key];
|
||||
value = createProxy(context, value, resolveContext, keyPath);
|
||||
target[key] = value;
|
||||
Reflect.set(target, key, value);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -378,6 +381,7 @@ var VueMeta = (function (exports, vue) {
|
||||
let active = context.active;
|
||||
let index = 0;
|
||||
for (const segment of pathSegments) {
|
||||
// @ts-ignore
|
||||
proxies = proxies.map(proxy => proxy[segment]);
|
||||
if (isArrayItem && index === pathSegments.length - 1) {
|
||||
activeSegmentKey = segment;
|
||||
@@ -418,11 +422,8 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
});
|
||||
|
||||
const createMergedObject = (resolve, active = {}) => {
|
||||
const createMergedObject = (resolve, active) => {
|
||||
const sources = [];
|
||||
if (!active) {
|
||||
active = {};
|
||||
}
|
||||
const context = {
|
||||
active,
|
||||
resolve,
|
||||
@@ -440,7 +441,7 @@ var VueMeta = (function (exports, vue) {
|
||||
return proxy;
|
||||
},
|
||||
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) {
|
||||
sources.splice(index, 1);
|
||||
if (recompute) {
|
||||
@@ -746,7 +747,7 @@ var VueMeta = (function (exports, vue) {
|
||||
}
|
||||
teleports[to].push(...nodes);
|
||||
}
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config, resolver);
|
||||
const createMetaManager = (config, resolver) => MetaManager.create(config || defaultConfig, resolver || defaultResolver);
|
||||
class MetaManager {
|
||||
constructor(config, target, resolver) {
|
||||
this.ssrCleanedUp = false;
|
||||
@@ -884,7 +885,7 @@ var VueMeta = (function (exports, vue) {
|
||||
};
|
||||
|
||||
exports.createMetaManager = createMetaManager;
|
||||
exports.deepestResolver = deepest;
|
||||
exports.deepestResolver = defaultResolver;
|
||||
exports.defaultConfig = defaultConfig;
|
||||
exports.getCurrentManager = getCurrentManager;
|
||||
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",
|
||||
"version": "3.0.0-alpha.2",
|
||||
"version": "3.0.0-alpha.3",
|
||||
"description": "Manage HTML metadata in Vue.js components with SSR support",
|
||||
"main": "dist/vue-meta.cjs.js",
|
||||
"unpkg": "dist/vue-meta.global.js",
|
||||
|
||||
Reference in New Issue
Block a user