Merge branch 'master' of github.com:freesewing/plugin-designer
This commit is contained in:
parent
9fb8745d7c
commit
15b6d2f752
6 changed files with 6438 additions and 1141 deletions
10
packages/plugin-designer/.babelrc
Normal file
10
packages/plugin-designer/.babelrc
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"useBuiltIns": "entry"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
9
packages/plugin-designer/.travis.yml
Normal file
9
packages/plugin-designer/.travis.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "node"
|
||||
install:
|
||||
- npm install
|
||||
- npm run build
|
||||
script:
|
||||
- npm run test
|
||||
- npm run coverage
|
|
@ -68,29 +68,6 @@ var pattern = freesewing.patterns.brian
|
|||
</script>
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
Below is a screenshot of a part of the pattern and the browser console.
|
||||
|
||||
You can see the extra markers on the pattern, and the info in the console.
|
||||
|
||||

|
||||
|
||||
### Parameters
|
||||
|
||||
- `to`: A point object at the start of the cut-on-fold indicator
|
||||
- `from`: A point object at the end of the cut-on-fold indicator
|
||||
|
||||
As all freesewing macros, bundle these parameters into a single object.
|
||||
|
||||
## Build
|
||||
|
||||
To build this plugin, run:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
## License: MIT
|
||||
|
||||
See [the license file](https://github.com/freesewing/plugin-designer/blob/master/LICENSE)
|
||||
|
|
7443
packages/plugin-designer/package-lock.json
generated
7443
packages/plugin-designer/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -25,13 +25,15 @@
|
|||
"minor": "npm version minor -m ':bookmark: v%s' && npm run build",
|
||||
"major": "npm version major -m ':bookmark: v%s' && npm run build",
|
||||
"precommit": "npm run pretty && lint-staged",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"test": "nyc mocha --require @babel/register tests/*.test.js",
|
||||
"report": "nyc report --reporter=html mocha --require @babel/register tests/*.test.js",
|
||||
"coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && ./node_modules/.bin/codecov",
|
||||
"clean": "rimraf dist",
|
||||
"pretty": "npx prettier --write \"src/*.js\"",
|
||||
"lint": "eslint --fix \"src/*.js\"",
|
||||
"browserbuild": "rollup -c rollup.js --file dist/browser.js --format iife --name freesewing.plugins.designer",
|
||||
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs",
|
||||
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es",
|
||||
"browserbuild": "rollup -c rollup.js --file dist/browser.js --format iife -m true --name freesewing.plugins.designer",
|
||||
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs -m true",
|
||||
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es -m true",
|
||||
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
|
||||
},
|
||||
"husky": {
|
||||
|
@ -46,16 +48,24 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"@babel/core": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"chai-string": "1.4.0",
|
||||
"codecov": "^3.1.0",
|
||||
"eslint": "^5.2.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"freesewing": "^0.18.3",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.2.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "12.0.2",
|
||||
"prettier": "^1.13.7",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup-plugin-babel": "^3.0.7",
|
||||
"rollup": "^0.66.2",
|
||||
"rollup-plugin-babel": "^4.0.3",
|
||||
"rollup-plugin-commonjs": "^9.1.3",
|
||||
"rollup-plugin-filesize": "^4.0.1",
|
||||
"rollup-plugin-json": "^3.0.0",
|
||||
|
|
70
packages/plugin-designer/tests/designer.test.js
Normal file
70
packages/plugin-designer/tests/designer.test.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
import script from "../src/lib/script.js";
|
||||
import defs from "../src/lib/snippets.js";
|
||||
import freesewing from "freesewing";
|
||||
import { version } from "../package.json";
|
||||
|
||||
let expect = require("chai").expect;
|
||||
let designerPlugin = require("../dist/index.js");
|
||||
|
||||
let pattern = new freesewing.Pattern().with(designerPlugin);
|
||||
pattern.render();
|
||||
|
||||
it("Should load script", () => {
|
||||
expect(pattern.svg.script).to.equal(script);
|
||||
});
|
||||
|
||||
it("Should set load defs", () => {
|
||||
expect(pattern.svg.defs).to.equal(defs);
|
||||
});
|
||||
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
expect(pattern.svg.attributes.get('freesewing:plugin-designer')).to.equal(version);
|
||||
});
|
||||
|
||||
it("Should decorate a point", () => {
|
||||
pattern.parts.testPart = new pattern.Part();
|
||||
pattern.parts.testPart.points.testPoint = new freesewing.Point(10,20);
|
||||
let a = pattern.parts.testPart.points.testPoint.attributes;
|
||||
pattern.render();
|
||||
expect(a.get('id')).to.equal('1');
|
||||
expect(a.get('data-point')).to.equal('testPoint');
|
||||
expect(a.get('data-part')).to.equal('testPart');
|
||||
let snippet = pattern.parts.testPart.snippets['snippet-testPoint'];
|
||||
expect(snippet.def).to.equal('point');
|
||||
expect(snippet.anchor).to.equal(pattern.parts.testPart.points.testPoint);
|
||||
let b = snippet.attributes;
|
||||
expect(b.get('onmouseover')).to.equal('pointHover(evt)');
|
||||
expect(b.get('id')).to.equal('snippet-testPoint');
|
||||
expect(b.get('data-point')).to.equal('testPoint');
|
||||
expect(b.get('data-part')).to.equal('testPart');
|
||||
});
|
||||
|
||||
it("Should decorate a hidden point", () => {
|
||||
pattern.parts.testPart.points._hidden = new freesewing.Point(30,40);
|
||||
let a = pattern.parts.testPart.points._hidden.attributes;
|
||||
pattern.render();
|
||||
expect(a.get('id')).to.equal('2');
|
||||
expect(a.get('data-point')).to.equal('_hidden');
|
||||
expect(a.get('data-part')).to.equal('testPart');
|
||||
});
|
||||
|
||||
it("Should decorate a path point", () => {
|
||||
pattern.parts.testPart.points.from = new freesewing.Point(5,60);
|
||||
pattern.parts.testPart.points.cp1 = new freesewing.Point(50,60);
|
||||
pattern.parts.testPart.points.cp2 = new freesewing.Point(90,10);
|
||||
pattern.parts.testPart.points.to = new freesewing.Point(10,10);
|
||||
pattern.parts.testPart.paths.testPath = new freesewing.Path()
|
||||
.move(pattern.parts.testPart.points.from)
|
||||
.line(pattern.parts.testPart.points.testPoint)
|
||||
.curve(pattern.parts.testPart.points.cp1,
|
||||
pattern.parts.testPart.points.cp2,
|
||||
pattern.parts.testPart.points.to);
|
||||
pattern.render();
|
||||
let snippet = pattern.parts.testPart.snippets[7];
|
||||
expect(snippet.def).to.equal('path-move-point');
|
||||
expect(snippet.anchor).to.equal(pattern.parts.testPart.points.from);
|
||||
let b = snippet.attributes;
|
||||
expect(b.get('data-path')).to.equal('testPath');
|
||||
expect(b.get('data-part')).to.equal('testPart');
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue