@resoc/core
Advanced tools
Comparing version 0.8.5 to 0.9.0
@@ -1,4 +0,7 @@ | ||
export { DefaultManifestName, renderTemplateToHtml, demoParamValues, paramLabel, validateParamValue, stringToParamValue, paramValueToString, FacebookOpenGraph, TwitterCard } from "./template"; | ||
export { FacebookOpenGraph, TwitterCard } from './resolution'; | ||
export type { ImageResolution } from "./resolution"; | ||
export { DefaultManifestName, renderTemplateToHtml, demoParamValues, paramLabel, validateParamValue, stringToParamValue, paramValueToString, getImageSpecs, ParamType } from "./template"; | ||
export { loadRemoteTemplate, isAbsoluteUrl } from "./remote"; | ||
export type { ImageTemplate, ParamValue, ParamValues, TemplateParam, ImageResolution } from "./template"; | ||
export { ParamType } from "./template"; | ||
export type { ImageTemplate, ParamValue, ParamValues, TemplateParam, } from "./template"; | ||
export type { ImageSpecs } from './image-specs'; | ||
export { getImageSpecsByDestination, fillImageSpecsViaDestination, getImageMaxRatio, getImageMinRatio, getImageRatio, getImageMaxWidth, getImageMinWidth, getImageWidth, getImageMaxHeight, getImageMinHeight, getImageHeight, getImageDemoResolution, ImageDestination, TwitterBannerDestination, WebPageSocialImageDestination } from './image-specs'; |
import Mustache from 'mustache'; | ||
import fetch from 'isomorphic-fetch'; | ||
var FacebookOpenGraph = { | ||
width: 1200, | ||
height: 630 | ||
}; | ||
var TwitterCard = { | ||
width: 1500, | ||
height: 750 | ||
}; | ||
var ImageDestination; | ||
(function (ImageDestination) { | ||
ImageDestination["WebPageSocialImage"] = "WebPageSocialImage"; | ||
ImageDestination["TwitterBanner"] = "TwitterBanner"; | ||
})(ImageDestination || (ImageDestination = {})); | ||
var WebPageSocialImageDestination = { | ||
destination: ImageDestination.WebPageSocialImage, | ||
minRatio: 1.91, | ||
maxRatio: 2.0, | ||
minWidth: 1200, | ||
minHeight: 630 | ||
}; | ||
var TwitterBannerDestination = { | ||
destination: ImageDestination.TwitterBanner, | ||
ratio: 3.0, | ||
minWidth: 600, | ||
minHeight: 200 | ||
}; | ||
var getImageSpecsByDestination = function (destination) { | ||
if (destination === ImageDestination.WebPageSocialImage) { | ||
return WebPageSocialImageDestination; | ||
} | ||
return TwitterBannerDestination; | ||
}; | ||
var fillImageSpecsViaDestination = function (specs) { return (Object.assign({}, specs.destination ? getImageSpecsByDestination(specs.destination) : {}, specs)); }; | ||
var getImageMaxRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxRatio || s.ratio; | ||
}; | ||
var getImageMinRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minRatio || s.ratio; | ||
}; | ||
var getImageRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.ratio; | ||
}; | ||
var getImageMaxWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxWidth || s.width; | ||
}; | ||
var getImageMinWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minWidth || s.width; | ||
}; | ||
var getImageWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.width; | ||
}; | ||
var getImageMaxHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxHeight || s.height; | ||
}; | ||
var getImageMinHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minHeight || s.height; | ||
}; | ||
var getImageHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.height; | ||
}; | ||
var getImageDemoResolution = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
if (s.destination === ImageDestination.TwitterBanner) { | ||
var height = 600; | ||
return { width: height * (getImageRatio(s) || 3.0), height: height }; | ||
} | ||
return FacebookOpenGraph; | ||
}; | ||
var DefaultManifestName = 'resoc.manifest.json'; | ||
@@ -16,10 +95,3 @@ var PartialContent = 'content'; | ||
})(ParamType || (ParamType = {})); | ||
var FacebookOpenGraph = { | ||
width: 1200, | ||
height: 630 | ||
}; | ||
var TwitterCard = { | ||
width: 1500, | ||
height: 750 | ||
}; | ||
var getImageSpecs = function (template) { return (template.imageSpecs || WebPageSocialImageDestination); }; | ||
var demoParamValues = function (params) { | ||
@@ -221,6 +293,3 @@ var values = {}; | ||
}); | ||
return [2 /*return*/, { | ||
partials: partials, | ||
parameters: parameters | ||
}]; | ||
return [2 /*return*/, Object.assign(manifest, { partials: partials, parameters: parameters })]; | ||
} | ||
@@ -230,3 +299,3 @@ }); | ||
export { DefaultManifestName, FacebookOpenGraph, ParamType, TwitterCard, demoParamValues, isAbsoluteUrl, loadRemoteTemplate, paramLabel, paramValueToString, renderTemplateToHtml, stringToParamValue, validateParamValue }; | ||
export { DefaultManifestName, FacebookOpenGraph, ImageDestination, ParamType, TwitterBannerDestination, TwitterCard, WebPageSocialImageDestination, demoParamValues, fillImageSpecsViaDestination, getImageDemoResolution, getImageHeight, getImageMaxHeight, getImageMaxRatio, getImageMaxWidth, getImageMinHeight, getImageMinRatio, getImageMinWidth, getImageRatio, getImageSpecs, getImageSpecsByDestination, getImageWidth, isAbsoluteUrl, loadRemoteTemplate, paramLabel, paramValueToString, renderTemplateToHtml, stringToParamValue, validateParamValue }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -13,2 +13,81 @@ 'use strict'; | ||
var FacebookOpenGraph = { | ||
width: 1200, | ||
height: 630 | ||
}; | ||
var TwitterCard = { | ||
width: 1500, | ||
height: 750 | ||
}; | ||
exports.ImageDestination = void 0; | ||
(function (ImageDestination) { | ||
ImageDestination["WebPageSocialImage"] = "WebPageSocialImage"; | ||
ImageDestination["TwitterBanner"] = "TwitterBanner"; | ||
})(exports.ImageDestination || (exports.ImageDestination = {})); | ||
var WebPageSocialImageDestination = { | ||
destination: exports.ImageDestination.WebPageSocialImage, | ||
minRatio: 1.91, | ||
maxRatio: 2.0, | ||
minWidth: 1200, | ||
minHeight: 630 | ||
}; | ||
var TwitterBannerDestination = { | ||
destination: exports.ImageDestination.TwitterBanner, | ||
ratio: 3.0, | ||
minWidth: 600, | ||
minHeight: 200 | ||
}; | ||
var getImageSpecsByDestination = function (destination) { | ||
if (destination === exports.ImageDestination.WebPageSocialImage) { | ||
return WebPageSocialImageDestination; | ||
} | ||
return TwitterBannerDestination; | ||
}; | ||
var fillImageSpecsViaDestination = function (specs) { return (Object.assign({}, specs.destination ? getImageSpecsByDestination(specs.destination) : {}, specs)); }; | ||
var getImageMaxRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxRatio || s.ratio; | ||
}; | ||
var getImageMinRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minRatio || s.ratio; | ||
}; | ||
var getImageRatio = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.ratio; | ||
}; | ||
var getImageMaxWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxWidth || s.width; | ||
}; | ||
var getImageMinWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minWidth || s.width; | ||
}; | ||
var getImageWidth = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.width; | ||
}; | ||
var getImageMaxHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.maxHeight || s.height; | ||
}; | ||
var getImageMinHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.minHeight || s.height; | ||
}; | ||
var getImageHeight = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
return s.height; | ||
}; | ||
var getImageDemoResolution = function (specs) { | ||
var s = fillImageSpecsViaDestination(specs); | ||
if (s.destination === exports.ImageDestination.TwitterBanner) { | ||
var height = 600; | ||
return { width: height * (getImageRatio(s) || 3.0), height: height }; | ||
} | ||
return FacebookOpenGraph; | ||
}; | ||
var DefaultManifestName = 'resoc.manifest.json'; | ||
@@ -26,10 +105,3 @@ var PartialContent = 'content'; | ||
})(exports.ParamType || (exports.ParamType = {})); | ||
var FacebookOpenGraph = { | ||
width: 1200, | ||
height: 630 | ||
}; | ||
var TwitterCard = { | ||
width: 1500, | ||
height: 750 | ||
}; | ||
var getImageSpecs = function (template) { return (template.imageSpecs || WebPageSocialImageDestination); }; | ||
var demoParamValues = function (params) { | ||
@@ -231,6 +303,3 @@ var values = {}; | ||
}); | ||
return [2 /*return*/, { | ||
partials: partials, | ||
parameters: parameters | ||
}]; | ||
return [2 /*return*/, Object.assign(manifest, { partials: partials, parameters: parameters })]; | ||
} | ||
@@ -242,4 +311,19 @@ }); | ||
exports.FacebookOpenGraph = FacebookOpenGraph; | ||
exports.TwitterBannerDestination = TwitterBannerDestination; | ||
exports.TwitterCard = TwitterCard; | ||
exports.WebPageSocialImageDestination = WebPageSocialImageDestination; | ||
exports.demoParamValues = demoParamValues; | ||
exports.fillImageSpecsViaDestination = fillImageSpecsViaDestination; | ||
exports.getImageDemoResolution = getImageDemoResolution; | ||
exports.getImageHeight = getImageHeight; | ||
exports.getImageMaxHeight = getImageMaxHeight; | ||
exports.getImageMaxRatio = getImageMaxRatio; | ||
exports.getImageMaxWidth = getImageMaxWidth; | ||
exports.getImageMinHeight = getImageMinHeight; | ||
exports.getImageMinRatio = getImageMinRatio; | ||
exports.getImageMinWidth = getImageMinWidth; | ||
exports.getImageRatio = getImageRatio; | ||
exports.getImageSpecs = getImageSpecs; | ||
exports.getImageSpecsByDestination = getImageSpecsByDestination; | ||
exports.getImageWidth = getImageWidth; | ||
exports.isAbsoluteUrl = isAbsoluteUrl; | ||
@@ -246,0 +330,0 @@ exports.loadRemoteTemplate = loadRemoteTemplate; |
@@ -0,1 +1,3 @@ | ||
import { ImageResolution } from './resolution'; | ||
import { ImageSpecs } from './image-specs'; | ||
export declare const DefaultManifestName = "resoc.manifest.json"; | ||
@@ -28,12 +30,8 @@ export declare const HtmlTemplate: string; | ||
parameters: TemplateParam[]; | ||
imageSpecs?: ImageSpecs; | ||
} | ||
export declare const getImageSpecs: (template: ImageTemplate) => ImageSpecs; | ||
export declare type ParamValues = { | ||
[name: string]: ParamValue; | ||
}; | ||
export declare type ImageResolution = { | ||
width: number; | ||
height: number; | ||
}; | ||
export declare const FacebookOpenGraph: ImageResolution; | ||
export declare const TwitterCard: ImageResolution; | ||
export declare const demoParamValues: (params: TemplateParam[]) => ParamValues; | ||
@@ -40,0 +38,0 @@ export declare const assignResolutionToParamerters: (values: ParamValues, resolution: ImageResolution, baseUrl?: string | undefined) => ParamValues & { |
{ | ||
"name": "@resoc/core", | ||
"version": "0.8.5", | ||
"version": "0.9.0", | ||
"description": "Resoc core utils", | ||
@@ -61,3 +61,3 @@ "main": "build/index.js", | ||
}, | ||
"gitHead": "82a13ba759469665c7f9d8f0f2c2f7277c0320e2" | ||
"gitHead": "f3d0204c6b795181db438aed86e162cd96402484" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38738
14
713