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

@resoc/core

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@resoc/core - npm Package Compare versions

Comparing version 0.2.12 to 0.3.0

4

build/index.d.ts

@@ -1,4 +0,4 @@

export { DefaultManifestName, renderTemplateToHtml, demoParamValues, paramLabel, validateParamValue } from "./template";
export { DefaultManifestName, renderTemplateToHtml, demoParamValues, paramLabel, validateParamValue, FacebookOpenGraph, TwitterCard } from "./template";
export { loadRemoteTemplate } from "./remote";
export type { ImageTemplate, ParamValues, TemplateParam } from "./template";
export type { ImageTemplate, ParamValues, TemplateParam, ImageResolution } from "./template";
export { ParamType } from "./template";

@@ -15,2 +15,10 @@ import Mustache from 'mustache';

})(ParamType || (ParamType = {}));
var FacebookOpenGraph = {
width: 1200,
height: 630
};
var TwitterCard = {
width: 1500,
height: 750
};
var demoParamValues = function (params) {

@@ -23,6 +31,8 @@ var values = {};

};
var renderTemplate = function (mainTemplate, template, parameters) {
return Mustache.render(mainTemplate, parameters, template.partials);
};
var renderTemplateToHtml = function (template, parameters) { return (renderTemplate(HtmlTemplate, template, parameters)); };
var assignResolutionToParamerters = function (values, resolution) { return (Object.assign({}, values, {
resoc_imageWidth: resolution.width,
resoc_imageHeight: resolution.height
})); };
var renderRawTemplate = function (mainTemplate, template, parameters) { return (Mustache.render(mainTemplate, parameters, template.partials)); };
var renderTemplateToHtml = function (template, parameters, resolution) { return (renderRawTemplate(HtmlTemplate, template, assignResolutionToParamerters(parameters, resolution))); };
/**

@@ -204,3 +214,3 @@ * Throw an error when the value is not correct.

export { DefaultManifestName, ParamType, demoParamValues, loadRemoteTemplate, paramLabel, renderTemplateToHtml, validateParamValue };
export { DefaultManifestName, FacebookOpenGraph, ParamType, TwitterCard, demoParamValues, loadRemoteTemplate, paramLabel, renderTemplateToHtml, validateParamValue };
//# sourceMappingURL=index.es.js.map

@@ -24,2 +24,10 @@ 'use strict';

})(exports.ParamType || (exports.ParamType = {}));
var FacebookOpenGraph = {
width: 1200,
height: 630
};
var TwitterCard = {
width: 1500,
height: 750
};
var demoParamValues = function (params) {

@@ -32,6 +40,8 @@ var values = {};

};
var renderTemplate = function (mainTemplate, template, parameters) {
return Mustache__default['default'].render(mainTemplate, parameters, template.partials);
};
var renderTemplateToHtml = function (template, parameters) { return (renderTemplate(HtmlTemplate, template, parameters)); };
var assignResolutionToParamerters = function (values, resolution) { return (Object.assign({}, values, {
resoc_imageWidth: resolution.width,
resoc_imageHeight: resolution.height
})); };
var renderRawTemplate = function (mainTemplate, template, parameters) { return (Mustache__default['default'].render(mainTemplate, parameters, template.partials)); };
var renderTemplateToHtml = function (template, parameters, resolution) { return (renderRawTemplate(HtmlTemplate, template, assignResolutionToParamerters(parameters, resolution))); };
/**

@@ -214,2 +224,4 @@ * Throw an error when the value is not correct.

exports.DefaultManifestName = DefaultManifestName;
exports.FacebookOpenGraph = FacebookOpenGraph;
exports.TwitterCard = TwitterCard;
exports.demoParamValues = demoParamValues;

@@ -216,0 +228,0 @@ exports.loadRemoteTemplate = loadRemoteTemplate;

@@ -29,5 +29,15 @@ export declare const DefaultManifestName = "resoc.manifest.json";

};
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;
export declare const renderTemplate: (mainTemplate: string, template: ImageTemplate, parameters: ParamValues) => string;
export declare const renderTemplateToHtml: (template: ImageTemplate, parameters: ParamValues) => string;
export declare const assignResolutionToParamerters: (values: ParamValues, resolution: ImageResolution) => ParamValues & {
resoc_imageWidth: number;
resoc_imageHeight: number;
};
export declare const renderRawTemplate: (mainTemplate: string, template: ImageTemplate, parameters: ParamValues) => string;
export declare const renderTemplateToHtml: (template: ImageTemplate, parameters: ParamValues, resolution: ImageResolution) => string;
export declare const parseTemplateManifestParams: (manifest: any) => TemplateParam[];

@@ -34,0 +44,0 @@ /**

{
"name": "@resoc/core",
"version": "0.2.12",
"version": "0.3.0",
"description": "Resoc core utils",

@@ -57,3 +57,3 @@ "main": "build/index.js",

},
"gitHead": "9df8cd9a0b7135410d2c219742990f8bf77f8dad"
"gitHead": "e7a11a17f5baa8e9b99c40aa2d1bdb42ab9455d2"
}

@@ -1,4 +0,20 @@

export { DefaultManifestName, renderTemplateToHtml, demoParamValues, paramLabel, validateParamValue } from "./template";
export {
DefaultManifestName,
renderTemplateToHtml,
demoParamValues,
paramLabel,
validateParamValue,
FacebookOpenGraph,
TwitterCard
} from "./template";
export { loadRemoteTemplate } from "./remote";
export type { ImageTemplate, ParamValues, TemplateParam } from "./template";
export type {
ImageTemplate,
ParamValues,
TemplateParam,
ImageResolution
} from "./template";
export { ParamType } from "./template";

@@ -1,5 +0,10 @@

import { paramLabel, ParamType, parseTemplateManifestParams, renderTemplate, validateParamValue } from './template'
import { assignResolutionToParamerters, paramLabel, ParamType, parseTemplateManifestParams, renderRawTemplate, validateParamValue } from './template'
test('renderTemplate', () => {
expect(renderTemplate('# {{> content }} *', { partials: { content: 'Hello {{name}}' }, parameters: [] }, { name: 'world' }))
test('renderRawTemplate', () => {
expect(renderRawTemplate(
'# {{> content }} *',{
partials: { content: 'Hello {{name}}' }, parameters: []
}, {
name: 'world'
}))
.toEqual('# Hello world *');

@@ -54,1 +59,14 @@ });

});
test('assignResolutionToParamerters', () => {
expect(assignResolutionToParamerters({
title: 'Hello'
}, {
width: 123,
height: 456
})).toEqual({
title: 'Hello',
resoc_imageWidth: 123,
resoc_imageHeight: 456
});
});

@@ -72,2 +72,17 @@ import axios from 'axios';

export type ImageResolution = {
width: number;
height: number;
};
export const FacebookOpenGraph: ImageResolution = {
width: 1200,
height: 630
};
export const TwitterCard: ImageResolution = {
width: 1500,
height: 750
};
export const demoParamValues = (params: TemplateParam[]): ParamValues => {

@@ -81,12 +96,19 @@ const values: ParamValues = {};

export const renderTemplate = (
export const assignResolutionToParamerters = (values: ParamValues, resolution: ImageResolution) => (
Object.assign({}, values, {
resoc_imageWidth: resolution.width,
resoc_imageHeight: resolution.height
})
);
export const renderRawTemplate = (
mainTemplate: string,
template: ImageTemplate,
parameters: ParamValues,
) => {
return Mustache.render(mainTemplate, parameters, template.partials);
};
parameters: ParamValues
) => (
Mustache.render(mainTemplate, parameters, template.partials)
);
export const renderTemplateToHtml = (template: ImageTemplate, parameters: ParamValues) => (
renderTemplate(HtmlTemplate, template, parameters)
export const renderTemplateToHtml = (template: ImageTemplate, parameters: ParamValues, resolution: ImageResolution) => (
renderRawTemplate(HtmlTemplate, template, assignResolutionToParamerters(parameters, resolution))
);

@@ -93,0 +115,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc