nuxt-jsonld
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,8 @@ | ||
# [1.3.0](https://github.com/ymmooot/nuxt-jsonld/compare/v1.2.0...v1.3.0) (2019-05-31) | ||
### Features | ||
* **typescript:** improve typescript support ([830957f](https://github.com/ymmooot/nuxt-jsonld/commit/830957f)), closes [#18](https://github.com/ymmooot/nuxt-jsonld/issues/18) | ||
# [1.2.0](https://github.com/ymmooot/nuxt-jsonld/compare/v1.1.0...v1.2.0) (2019-05-31) | ||
@@ -2,0 +9,0 @@ |
"use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
module.exports = function () { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var mergedOptions = _objectSpread({ | ||
space: 2 | ||
}, options); | ||
return { | ||
head: function head() { | ||
if (!this.$options || typeof this.$options.jsonld !== 'function') { | ||
return {}; | ||
} | ||
var stringifiedJson = JSON.stringify(this.$options.jsonld.call(this), null, mergedOptions.space); | ||
var innerHTML = mergedOptions.space === 0 ? stringifiedJson : "\n".concat(stringifiedJson, "\n"); | ||
var hid = "nuxt-jsonld-".concat(this._uid); | ||
return { | ||
script: [{ | ||
hid: hid, | ||
type: 'application/ld+json', | ||
innerHTML: innerHTML | ||
}], | ||
__dangerouslyDisableSanitizersByTagID: _defineProperty({}, hid, 'innerHTML') | ||
}; | ||
} | ||
}; | ||
}; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = (function (options) { | ||
if (options === void 0) { options = {}; } | ||
var mergedOptions = __assign({ space: 2 }, options); | ||
return { | ||
head: function () { | ||
var _a; | ||
if (!this.$options || typeof this.$options.jsonld !== 'function') { | ||
return {}; | ||
} | ||
var stringifiedJson = JSON.stringify(this.$options.jsonld.call(this), null, mergedOptions.space); | ||
var innerHTML = mergedOptions.space === 0 ? stringifiedJson : "\n" + stringifiedJson + "\n"; | ||
var hid = "nuxt-jsonld-" + this._uid; | ||
return { | ||
script: [ | ||
{ | ||
hid: hid, | ||
type: 'application/ld+json', | ||
innerHTML: innerHTML, | ||
}, | ||
], | ||
__dangerouslyDisableSanitizersByTagID: (_a = {}, | ||
_a[hid] = 'innerHTML', | ||
_a), | ||
}; | ||
}, | ||
}; | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = (function (component) { | ||
var options = component.options; | ||
if (!options.methods || !options.methods.jsonld || typeof options.methods.jsonld !== 'function') { | ||
return; | ||
} | ||
options.jsonld = options.methods.jsonld; | ||
delete options.methods.jsonld; | ||
}); | ||
exports.default = void 0; | ||
var _default = function _default(_ref) { | ||
var options = _ref.options; | ||
if (!options.methods || !options.methods.jsonld || typeof options.methods.jsonld !== 'function') { | ||
return; | ||
} | ||
options.jsonld = options.methods.jsonld; | ||
delete options.methods.jsonld; | ||
}; | ||
exports.default = _default; |
121
lib/index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.Jsonld = void 0; | ||
var _createMixin = _interopRequireDefault(require("./createMixin")); | ||
var _decorator = _interopRequireDefault(require("./decorator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var getValue = function getValue(val, context) { | ||
if (_typeof(val) === 'object') { | ||
return val; | ||
} | ||
if (typeof val === 'function') { | ||
return val.call(context); | ||
} | ||
return undefined; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var mergeStrategy = function mergeStrategy(toVal, fromVal) { | ||
if (!toVal) return fromVal; | ||
if (!fromVal) return toVal; | ||
return function head() { | ||
var res1 = getValue(fromVal, this); | ||
var res2 = getValue(toVal, this); | ||
if (res2.script) { | ||
var fromValScript = res1.script || []; | ||
var hasScript = fromValScript.some(function (s) { | ||
return s.hid === res2.script[0].hid; | ||
}); | ||
if (!hasScript) { | ||
res1.script = [].concat(_toConsumableArray(fromValScript), _toConsumableArray(res2.script)); | ||
} | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var createMixin_1 = __importDefault(require("./createMixin")); | ||
var decorator_1 = __importDefault(require("./decorator")); | ||
var getValue = function (val, context) { | ||
if (typeof val === 'object') { | ||
return val; | ||
} | ||
if (res2.__dangerouslyDisableSanitizersByTagID) { | ||
res1.__dangerouslyDisableSanitizersByTagID = _objectSpread({}, res1.__dangerouslyDisableSanitizersByTagID || {}, res2.__dangerouslyDisableSanitizersByTagID); | ||
if (typeof val === 'function') { | ||
return val.call(context); | ||
} | ||
return res1; | ||
}; | ||
return undefined; | ||
}; | ||
var Jsonld = _decorator.default; | ||
exports.Jsonld = Jsonld; | ||
var _default = { | ||
mergeStrategy: mergeStrategy, | ||
install: function install(Vue, options) { | ||
// eslint-disable-next-line no-param-reassign | ||
Vue.config.optionMergeStrategies.head = mergeStrategy; | ||
Vue.mixin((0, _createMixin.default)(options)); | ||
} | ||
var mergeStrategy = function (toVal, fromVal) { | ||
if (!toVal) | ||
return fromVal; | ||
if (!fromVal) | ||
return toVal; | ||
return function head() { | ||
var res1 = getValue(fromVal, this); | ||
var res2 = getValue(toVal, this); | ||
if (res2.script) { | ||
var fromValScript = res1.script || []; | ||
var hasScript = fromValScript.some(function (s) { return s.hid === res2.script[0].hid; }); | ||
if (!hasScript) { | ||
res1.script = fromValScript.concat(res2.script); | ||
} | ||
} | ||
if (res2.__dangerouslyDisableSanitizersByTagID) { | ||
res1.__dangerouslyDisableSanitizersByTagID = __assign({}, (res1.__dangerouslyDisableSanitizersByTagID || {}), res2.__dangerouslyDisableSanitizersByTagID); | ||
} | ||
return res1; | ||
}; | ||
}; | ||
exports.default = _default; | ||
exports.Jsonld = decorator_1.default; | ||
exports.default = { | ||
mergeStrategy: mergeStrategy, | ||
install: function (Vue, options) { | ||
// eslint-disable-next-line no-param-reassign | ||
Vue.config.optionMergeStrategies.head = mergeStrategy; | ||
Vue.mixin(createMixin_1.default(options)); | ||
}, | ||
}; |
{ | ||
"name": "nuxt-jsonld", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "manage jsonld in Vue component.", | ||
@@ -21,7 +21,7 @@ "main": "lib/index.js", | ||
"prebuild": "rimraf lib", | ||
"build": "babel src --out-dir lib", | ||
"build": "tsc -p .", | ||
"preversion": "npm run build", | ||
"release": "semantic-release", | ||
"lint": "eslint src", | ||
"lint:fix": "eslint --fix src" | ||
"lint": "eslint --ext .ts --ext .js src test", | ||
"lint:fix": "eslint --ext .ts --ext .js --fix src test" | ||
}, | ||
@@ -34,5 +34,2 @@ "files": [ | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.4", | ||
"@babel/preset-env": "^7.4.4", | ||
"@semantic-release/changelog": "^3.0.2", | ||
@@ -44,3 +41,5 @@ "@semantic-release/commit-analyzer": "^6.1.0", | ||
"@semantic-release/release-notes-generator": "^7.1.4", | ||
"babel-eslint": "^10.0.1", | ||
"@types/jest": "^24.0.13", | ||
"@typescript-eslint/eslint-plugin": "^1.9.0", | ||
"@typescript-eslint/parser": "^1.9.0", | ||
"cz-conventional-changelog": "2.1.0", | ||
@@ -50,3 +49,3 @@ "eslint": "^5.16.0", | ||
"eslint-config-prettier": "^4.2.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-jest": "^22.5.1", | ||
@@ -58,3 +57,6 @@ "eslint-plugin-prettier": "^3.0.1", | ||
"semantic-release": "^15.13.3", | ||
"vue": "^2.6.10" | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.5.1", | ||
"vue": "^2.6.10", | ||
"vue-class-component": "^7.1.0" | ||
}, | ||
@@ -61,0 +63,0 @@ "config": { |
@@ -8,1 +8,7 @@ import Vue, { ComponentOptions } from 'vue' | ||
} | ||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
_uid: number | ||
} | ||
} |
10
144
10876
24