chore(plugin-flip): Ported to v3
This commit is contained in:
parent
e5d5ead92d
commit
6f8cc6e753
5 changed files with 21 additions and 19 deletions
|
@ -14,7 +14,7 @@ const banner = `/**
|
|||
const options = {
|
||||
banner: { js: banner },
|
||||
bundle: true,
|
||||
entryPoints: ['src/index.js'],
|
||||
entryPoints: ['src/index.mjs'],
|
||||
format: 'esm',
|
||||
outfile: 'dist/index.mjs',
|
||||
external: ["@freesewing"],
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs",
|
||||
"lab": "cd ../../sites/lab && yarn start",
|
||||
"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",
|
||||
"cibuild_step1": "node --experimental-json-modules build.mjs"
|
||||
},
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import pkg from '../package.json'
|
||||
import { name, version } from '../package.json' assert { type: 'json' }
|
||||
|
||||
export default {
|
||||
name: pkg.name,
|
||||
version: pkg.version,
|
||||
hooks: {
|
||||
preRender: (svg) => svg.attributes.setIfUnset('freesewing:plugin-flip', pkg.version),
|
||||
},
|
||||
export const plugin = {
|
||||
name,
|
||||
version,
|
||||
macros: {
|
||||
flip: function (so) {
|
||||
const axis = so?.axis === 'y' ? 'y' : 'x'
|
||||
|
@ -49,3 +46,9 @@ export default {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
// More specifically named exports
|
||||
export const flipPlugin = plugin
|
||||
export const pluginFlip = plugin
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
import chai from 'chai'
|
||||
import freesewing from '@freesewing/core'
|
||||
import plugin from '../dist/index.mjs'
|
||||
import { Pattern } from '@freesewing/core'
|
||||
import { plugin } from './dist/index.mjs'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Flip Plugin Tests', () => {
|
||||
const pattern = new freesewing.Pattern().use(plugin);
|
||||
const pattern = new Pattern().use(plugin);
|
||||
pattern.parts.test = new pattern.Part()
|
||||
pattern.parts.test.points.from = new pattern.Point(10, 20)
|
||||
pattern.parts.test.points.to = new pattern.Point(30, 40)
|
||||
|
@ -44,7 +44,7 @@ describe('Flip Plugin Tests', () => {
|
|||
})
|
||||
|
||||
it('Should flip points in a part on their vertical axis', () => {
|
||||
let pattern = new freesewing.Pattern()
|
||||
let pattern = new Pattern()
|
||||
pattern.use(plugin)
|
||||
pattern.parts.test = new pattern.Part()
|
||||
pattern.parts.test.points.from = new pattern.Point(10,20)
|
||||
|
@ -58,7 +58,7 @@ describe('Flip Plugin Tests', () => {
|
|||
})
|
||||
|
||||
it('Should flip points in a path on their vertical axis', () => {
|
||||
let pattern = new freesewing.Pattern()
|
||||
let pattern = new Pattern()
|
||||
pattern.use(plugin)
|
||||
pattern.parts.test = new pattern.Part()
|
||||
pattern.parts.test.points.from = new pattern.Point(10,20)
|
||||
|
@ -82,7 +82,7 @@ describe('Flip Plugin Tests', () => {
|
|||
})
|
||||
|
||||
it('Should flip points in snippets on their vertical axis', () => {
|
||||
let pattern = new freesewing.Pattern()
|
||||
let pattern = new Pattern()
|
||||
pattern.use(plugin)
|
||||
pattern.parts.test = new pattern.Part()
|
||||
let anchorPoint = new pattern.Point(40,0)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// This file is auto-generated.
|
||||
// Changes you make will be overwritten.
|
||||
import plugin from './dist/index.mjs'
|
||||
// This file is auto-generated | Any changes you make will be overwritten.
|
||||
import { plugin } from './dist/index.mjs'
|
||||
import { sharedPluginTests } from '../../../tests/plugins/shared.mjs'
|
||||
|
||||
|
||||
// Run shared tests
|
||||
sharedPluginTests(plugin)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue