chore(plugin-scalebox): Ported to v3
This commit is contained in:
parent
3e59f830fd
commit
60c5533e0e
8 changed files with 30 additions and 29 deletions
|
@ -14,7 +14,7 @@ const banner = `/**
|
||||||
const options = {
|
const options = {
|
||||||
banner: { js: banner },
|
banner: { js: banner },
|
||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints: ['src/index.js'],
|
entryPoints: ['src/index.mjs'],
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: 'dist/index.mjs',
|
outfile: 'dist/index.mjs',
|
||||||
external: ["@freesewing"],
|
external: ["@freesewing"],
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs",
|
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs",
|
||||||
"lab": "cd ../../sites/lab && yarn start",
|
"lab": "cd ../../sites/lab && yarn start",
|
||||||
"tips": "node ../../scripts/help.mjs",
|
"tips": "node ../../scripts/help.mjs",
|
||||||
"prettier": "npx prettier --write 'src/*.js' 'tests/*.mjs'",
|
"prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'",
|
||||||
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
||||||
"cibuild_step1": "node --experimental-json-modules build.mjs"
|
"cibuild_step1": "node --experimental-json-modules build.mjs"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
import pkg from '../package.json'
|
|
||||||
import scalebox from './scalebox'
|
|
||||||
import miniscale from './miniscale'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: pkg.name,
|
|
||||||
version: pkg.version,
|
|
||||||
hooks: {
|
|
||||||
preRender: (svg) => svg.attributes.setIfUnset('freesewing:plugin-scalebox', pkg.version),
|
|
||||||
},
|
|
||||||
macros: { scalebox, miniscale },
|
|
||||||
}
|
|
14
plugins/plugin-scalebox/src/index.mjs
Normal file
14
plugins/plugin-scalebox/src/index.mjs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { name, version } from '../package.json'
|
||||||
|
import { scalebox } from './scalebox.mjs'
|
||||||
|
import { miniscale } from './miniscale.mjs'
|
||||||
|
|
||||||
|
export const plugin = {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
macros: { scalebox, miniscale },
|
||||||
|
}
|
||||||
|
|
||||||
|
// More specifically named exports
|
||||||
|
export const scaleboxPlugin = plugin
|
||||||
|
export const pluginScalebox = plugin
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default function (so) {
|
export function miniscale(so) {
|
||||||
// Passing `false` will remove the miniscale
|
// Passing `false` will remove the miniscale
|
||||||
if (so === false) {
|
if (so === false) {
|
||||||
for (let id of [
|
for (let id of [
|
|
@ -1,4 +1,4 @@
|
||||||
export default function (so) {
|
export function scalebox(so) {
|
||||||
// Passing `false` will remove the scalebox
|
// Passing `false` will remove the scalebox
|
||||||
if (so === false) {
|
if (so === false) {
|
||||||
for (let id of [
|
for (let id of [
|
||||||
|
@ -182,3 +182,4 @@ export default function (so) {
|
||||||
.attr('data-text', `${imperialDisplayHeight}`)
|
.attr('data-text', `${imperialDisplayHeight}`)
|
||||||
.attr('data-text-class', 'text-xs center ')
|
.attr('data-text-class', 'text-xs center ')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
import freesewing from '@freesewing/core'
|
import { Pattern, round } from '@freesewing/core'
|
||||||
import plugin from '../dist/index.mjs'
|
import { plugin } from '../dist/index.mjs'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
const round = freesewing.utils.round
|
|
||||||
|
|
||||||
describe('Scalebox Plugin Tests', () => {
|
describe('Scalebox Plugin Tests', () => {
|
||||||
it("Should run the default scalebox macro", () => {
|
it("Should run the default scalebox macro", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
const { macro } = pattern.parts.test.shorthand()
|
||||||
|
@ -74,7 +73,7 @@ describe('Scalebox Plugin Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should run the scalebox macro with rotation", () => {
|
it("Should run the scalebox macro with rotation", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
const { macro } = pattern.parts.test.shorthand()
|
||||||
|
@ -114,7 +113,7 @@ describe('Scalebox Plugin Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should run the scalebox macro with default text", () => {
|
it("Should run the scalebox macro with default text", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
const { macro } = pattern.parts.test.shorthand()
|
||||||
|
@ -134,7 +133,7 @@ describe('Scalebox Plugin Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should run the scalebox macro with custom text", () => {
|
it("Should run the scalebox macro with custom text", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
const { macro } = pattern.parts.test.shorthand()
|
||||||
|
@ -157,7 +156,7 @@ describe('Scalebox Plugin Tests', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should apply scale to the scalebox macro", () => {
|
it("Should apply scale to the scalebox macro", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.settings.scale = 0.5
|
pattern.settings.scale = 0.5
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
|
@ -189,7 +188,7 @@ describe('Scalebox Plugin Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should apply scale to the miniscale macro", () => {
|
it("Should apply scale to the miniscale macro", () => {
|
||||||
const pattern = new freesewing.Pattern().use(plugin)
|
const pattern = new Pattern().use(plugin)
|
||||||
pattern.settings.scale = 0.5
|
pattern.settings.scale = 0.5
|
||||||
pattern.parts.test = new pattern.Part();
|
pattern.parts.test = new pattern.Part();
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// This file is auto-generated.
|
// This file is auto-generated | Any changes you make will be overwritten.
|
||||||
// Changes you make will be overwritten.
|
import { plugin } from './dist/index.mjs'
|
||||||
import plugin from './dist/index.mjs'
|
|
||||||
import { sharedPluginTests } from '../../../tests/plugins/shared.mjs'
|
import { sharedPluginTests } from '../../../tests/plugins/shared.mjs'
|
||||||
|
|
||||||
|
|
||||||
// Run shared tests
|
// Run shared tests
|
||||||
sharedPluginTests(plugin)
|
sharedPluginTests(plugin)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue