🐛 Moved options into settings property as they should be
This commit is contained in:
parent
f76e28e7e6
commit
2563eb93a3
4 changed files with 40 additions and 278 deletions
231
package-lock.json
generated
231
package-lock.json
generated
|
@ -212,217 +212,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/aaron": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/aaron/-/aaron-0.4.0.tgz",
|
||||
"integrity": "sha512-Y/bGqdaA6lpKlumwxOsCKCR2PZhqk9l+MDiQHS294SDq2Naqx+qHS5qg1FcJRTBK2PX20MZ6ZVu2tqGp+jO01w==",
|
||||
"requires": {
|
||||
"@freesewing/brian": "^0.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"@freesewing/brian": {
|
||||
"version": "0.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/brian/-/brian-0.13.0.tgz",
|
||||
"integrity": "sha512-PC9QMqjB2mERfRXqEu9TgFfSJ6xgawTlgwBQQWtZjw98wwiqdpGBjgTch8gkwHjJcn9uOuk9p8YplaOAMgFVpw==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-bundle": "^0.3",
|
||||
"freesewing": "^0.18.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/brian": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/brian/-/brian-0.14.0.tgz",
|
||||
"integrity": "sha512-+Wt4t3EZQpSTNYfRBRDvP9fssH3gUHRlI+PFKqgY9pMSTW5r7fZ/C9pl+nFtGKtMxexywY2zTPxM2cqgcG63Qw==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-bundle": "^0.5",
|
||||
"freesewing": "^0.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"@freesewing/plugin-bundle": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-bundle/-/plugin-bundle-0.5.0.tgz",
|
||||
"integrity": "sha512-vmjaB/2VnrubfZulAP3naIHkDIjhMSsI/fI1Ca6prP3M8UQMACz2opfgj1uqB4kZ04hrft5fKAjmHmPnYR/3yA==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-cutonfold": "^0.10",
|
||||
"@freesewing/plugin-dimension": "0.7.1",
|
||||
"@freesewing/plugin-grainline": "^0.2",
|
||||
"@freesewing/plugin-logo": "^0.5",
|
||||
"@freesewing/plugin-scalebox": "^0.3",
|
||||
"@freesewing/plugin-title": "^0.9"
|
||||
}
|
||||
},
|
||||
"@freesewing/plugin-cutonfold": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-cutonfold/-/plugin-cutonfold-0.10.0.tgz",
|
||||
"integrity": "sha512-s0/JAyNw0YvkEPrtarJemUJ3vGcpNatxZWnxnJPbbEyOMf3Ry8fDd/EfFe7AZU1lj0Vp7prknzFQDXN7XxsOsQ=="
|
||||
},
|
||||
"@freesewing/plugin-dimension": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-dimension/-/plugin-dimension-0.7.1.tgz",
|
||||
"integrity": "sha512-O/IVkBXtvs8HOVEFS7GGAQnLlNPvuT8fGPAxEfSz1+pqwhX5oyEjBjoL1GCENPFWamizwcn2143di5OnQIR6cg=="
|
||||
},
|
||||
"@freesewing/plugin-grainline": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-grainline/-/plugin-grainline-0.2.0.tgz",
|
||||
"integrity": "sha512-hU0nF3sBxG6yvMlDx2BznGTs7NSQs74fb0+2YEjYs6iJ6rpOzg82N0oP8fAiXdAewHaSykOyouapZdxgG8CXEg=="
|
||||
},
|
||||
"@freesewing/plugin-logo": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-logo/-/plugin-logo-0.5.0.tgz",
|
||||
"integrity": "sha512-yv40lmFUeEziB3lRIitZAwS6cvcOioSm7C2kFW+I191pXvBK8oGRvuVhw7OUQihdYwtyhYtfHwgNAGQqImBsAg=="
|
||||
},
|
||||
"@freesewing/plugin-scalebox": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-scalebox/-/plugin-scalebox-0.3.0.tgz",
|
||||
"integrity": "sha512-6djCCOsAWQUyzCffLThsENusOcr8bOyE4rYcBC7bXOvUFoucZ0CthbMncreKLWmr456uvMMLYnBOJNG4fk0+Wg=="
|
||||
},
|
||||
"@freesewing/plugin-title": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-title/-/plugin-title-0.9.0.tgz",
|
||||
"integrity": "sha512-DH2qbABNZrRNBe4/DVPIJmlsRfq12+VtAfG4jlVHrPrL9ZDQ56YLdiLt9I3LuGndNDuW7/KhisHMJs5md5qu/w=="
|
||||
},
|
||||
"freesewing": {
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.19.0.tgz",
|
||||
"integrity": "sha512-/wSEhF/Z10Pd3IGl3Nq+v/txcOboK21VKdQ1sXuBGp17D6Kq5ah+wbDyBrQRGu0X5sbQo7DazEFZ1kgnxyk5tg==",
|
||||
"requires": {
|
||||
"bezier-js": "^2.2.15",
|
||||
"bin-pack": "1.0.2",
|
||||
"hooks-fixed": "2.0.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/bruce": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/bruce/-/bruce-0.3.0.tgz",
|
||||
"integrity": "sha512-kvtu/Y+wxpyPz1tlOhwJBXs09vo0mz0SEIz7ZhFpmjP3AAb5tPKCpvylL2VKkfMGG89/S3YapCaGQRTNYibMQQ==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-bundle": "^0.3",
|
||||
"freesewing": "^0.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"freesewing": {
|
||||
"version": "0.17.0",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.17.0.tgz",
|
||||
"integrity": "sha512-LanZsKfdAan5LQH7HvTlRwF6cFxr64G666OeCY9Ij7NnZ79/+AEuffT0lrLpRa1dNU3SY7BWPlnkA8SMeiB8+Q==",
|
||||
"requires": {
|
||||
"bezier-js": "^2.2.13",
|
||||
"bin-pack": "1.0.2",
|
||||
"hooks": "^0.3.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/cathrin": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/cathrin/-/cathrin-0.2.0.tgz",
|
||||
"integrity": "sha512-HuYLpWunrLrUnBiLc3B4NY2e4EcukIjzLIkPpC2xc2w/FUdDA2Q+FM4sdZLL+VmlkAF7iZjztgI0rh18x1ONBw==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-bundle": "^0.3",
|
||||
"freesewing": "^0.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"freesewing": {
|
||||
"version": "0.17.0",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.17.0.tgz",
|
||||
"integrity": "sha512-LanZsKfdAan5LQH7HvTlRwF6cFxr64G666OeCY9Ij7NnZ79/+AEuffT0lrLpRa1dNU3SY7BWPlnkA8SMeiB8+Q==",
|
||||
"requires": {
|
||||
"bezier-js": "^2.2.13",
|
||||
"bin-pack": "1.0.2",
|
||||
"hooks": "^0.3.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/hugo": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/hugo/-/hugo-0.1.0.tgz",
|
||||
"integrity": "sha512-6wx3UD31WQUlH5zGk7C0sIBgJSlTxSren5+oH4ZyYidoygca60dJ/IQDZw21u5bkNkcU2QN4Qd+kNXgl31Lk6Q==",
|
||||
"requires": {
|
||||
"@freesewing/brian": "^0.11",
|
||||
"@freesewing/plugin-bundle": "^0.3",
|
||||
"freesewing": "^0.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@freesewing/brian": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/brian/-/brian-0.11.1.tgz",
|
||||
"integrity": "sha512-+3xdcBEGKzlGLlmm1z+1C/x77WeByi7O1Q9hQa7Hb9O57mwKK6SmMwUcn6tBx5/fzxOlSpAUUq3WXUf5wK8yXg==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-bundle": "^0.3",
|
||||
"freesewing": "^0.17"
|
||||
}
|
||||
},
|
||||
"freesewing": {
|
||||
"version": "0.17.0",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.17.0.tgz",
|
||||
"integrity": "sha512-LanZsKfdAan5LQH7HvTlRwF6cFxr64G666OeCY9Ij7NnZ79/+AEuffT0lrLpRa1dNU3SY7BWPlnkA8SMeiB8+Q==",
|
||||
"requires": {
|
||||
"bezier-js": "^2.2.13",
|
||||
"bin-pack": "1.0.2",
|
||||
"hooks": "^0.3.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@freesewing/patterns": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/patterns/-/patterns-0.3.0.tgz",
|
||||
"integrity": "sha512-wZwbRKkdCApBVqevd+CHa1SNRqQ1qwAMCfFzvTRoavLOyqAdw1fJXyUS3Qlzu6+e8V+1UiaBGG26ShTFpJLm1A==",
|
||||
"requires": {
|
||||
"@freesewing/aaron": "^0.4",
|
||||
"@freesewing/brian": "^0.14",
|
||||
"@freesewing/bruce": "^0.3",
|
||||
"@freesewing/cathrin": "^0.2",
|
||||
"@freesewing/hugo": "^0.1"
|
||||
}
|
||||
},
|
||||
"@freesewing/plugin-bundle": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-bundle/-/plugin-bundle-0.3.0.tgz",
|
||||
"integrity": "sha512-FUZmGgbrqb3md872w3aXQY+3TReoTeV25ak006UfCBzEJ0lm15QrCanqC46k+0Z6Iv98ChkCo1XZl/kWV1FYFQ==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-cutonfold": "0.9.0",
|
||||
"@freesewing/plugin-dimension": "0.6.1",
|
||||
"@freesewing/plugin-grainline": "0.0.3",
|
||||
"@freesewing/plugin-logo": "0.3.3",
|
||||
"@freesewing/plugin-scalebox": "0.2.0",
|
||||
"@freesewing/plugin-title": "0.7.0"
|
||||
}
|
||||
},
|
||||
"@freesewing/plugin-cutonfold": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-cutonfold/-/plugin-cutonfold-0.9.0.tgz",
|
||||
"integrity": "sha512-FZC6bSaDMgXKDzIU5ynByHmiVIVDXKzB9rlxZyldv+q8c0T/xfJ/x15wcey2Bffj/pv37hzLI+CocwGLHjWH7g=="
|
||||
},
|
||||
"@freesewing/plugin-dimension": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-dimension/-/plugin-dimension-0.6.1.tgz",
|
||||
"integrity": "sha512-OUdF3JyLDIwjHHRyuL0DZnfhykZzozv00AekcVOK3TZ61p+UQO4EK1FbDVczCY5SJx5DpYyuastvZ/FEW3SQMw=="
|
||||
},
|
||||
"@freesewing/plugin-grainline": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-grainline/-/plugin-grainline-0.0.3.tgz",
|
||||
"integrity": "sha512-Oa+FvjsdDfWxIoXa8bATYwj1Neg6q+gNQWJyX7j1HlJnEflsQtJBB8fqwcGJzeK/QDJauvbAm3sBJP30gMwSTw=="
|
||||
},
|
||||
"@freesewing/plugin-logo": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-logo/-/plugin-logo-0.3.3.tgz",
|
||||
"integrity": "sha512-t9VBoZvFx0tR83bFQMpc4iH/oJaXVr41zX0N8AogTt+FEjnHnZSmCJGTfpYkPtp1mWJSc4ibS95Gyh9c4YNgGA=="
|
||||
},
|
||||
"@freesewing/plugin-scalebox": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-scalebox/-/plugin-scalebox-0.2.0.tgz",
|
||||
"integrity": "sha512-SskEtAyvYCpjmCHEgjNzuSsMqOyT/ExQVhEdfoS3vjW4I9/uAqhOcI4EYR+gP1N3Ga6yh99hf9gDtSpTJP78pg=="
|
||||
},
|
||||
"@freesewing/plugin-title": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-title/-/plugin-title-0.7.0.tgz",
|
||||
"integrity": "sha512-LVnokj+SIYPdxehiqoF+RPdLCaCd/MnTBzRebjPWRxGQnywzNyuwgHN8jmJEQGb6dJ/6J4zFEvAm9pS1ID6cug=="
|
||||
},
|
||||
"@samverschueren/stream-to-observable": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz",
|
||||
|
@ -2709,16 +2498,6 @@
|
|||
"map-cache": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"freesewing": {
|
||||
"version": "0.18.3",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.18.3.tgz",
|
||||
"integrity": "sha512-uXBnN1IRqsH6QhYoM9juNo76GbzO75rSXgWrbMFHZcqSLw4RsCxRLppl5LqOAJ1pEYAWh7W9disxS53j5Eum4Q==",
|
||||
"requires": {
|
||||
"bezier-js": "^2.2.15",
|
||||
"bin-pack": "1.0.2",
|
||||
"hooks": "^0.3.2"
|
||||
}
|
||||
},
|
||||
"fs-constants": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||
|
@ -3056,16 +2835,6 @@
|
|||
"os-tmpdir": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"hooks": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/hooks/-/hooks-0.3.2.tgz",
|
||||
"integrity": "sha1-ox8GDCAmzqbPHKPrF4Qw5xjhxKM="
|
||||
},
|
||||
"hooks-fixed": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.2.tgz",
|
||||
"integrity": "sha512-YurCM4gQSetcrhwEtpQHhQ4M7Zo7poNGqY4kQGeBS6eZtOcT3tnNs01ThFa0jYBByAiYt1MjMjP/YApG0EnAvQ=="
|
||||
},
|
||||
"hosted-git-info": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz",
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@freesewing/patterns": "0.3.0",
|
||||
"bezier-js": "^2.2.15",
|
||||
"bin-pack": "1.0.2"
|
||||
},
|
||||
|
|
|
@ -22,10 +22,6 @@ function Part() {
|
|||
this.Path = Path;
|
||||
this.Snippet = Snippet;
|
||||
|
||||
let self = this;
|
||||
|
||||
this.context = this.getContext();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -167,7 +163,7 @@ Part.prototype.shorthand = function() {
|
|||
return {
|
||||
sa,
|
||||
measurements: this.context.settings.measurements || {},
|
||||
options: this.context.options || {},
|
||||
options: this.context.settings.options || {},
|
||||
store: this.context.store,
|
||||
points: this.points || {},
|
||||
paths: this.paths || {},
|
||||
|
|
|
@ -9,74 +9,60 @@ import Store from "./store";
|
|||
import hooks from "./hooks";
|
||||
|
||||
export default function Pattern(config = false) {
|
||||
// width and height properties
|
||||
this.width = false;
|
||||
this.height = false;
|
||||
this.config = config; // Pattern configuration
|
||||
this.width = false; // Will be set after render
|
||||
this.height = false; // Will be set after render
|
||||
this.is = ""; // Will be set when drafting/sampling
|
||||
|
||||
// Hooks
|
||||
this.hooks = hooks;
|
||||
this.store = new Store(); // Store for sharing data across parts
|
||||
this.parts = {}; // Parts container
|
||||
this.hooks = hooks; // Hooks container
|
||||
|
||||
// Containers
|
||||
this.Part = Part; // Part constructor
|
||||
this.Point = Point; // Point constructor
|
||||
this.Path = Path; // Path constructor
|
||||
this.Snippet = Snippet; // Snippet constructor
|
||||
|
||||
// Default settings
|
||||
this.settings = {
|
||||
complete: true,
|
||||
idPrefix: "fs-",
|
||||
locale: "en",
|
||||
units: "metric",
|
||||
margin: 2
|
||||
};
|
||||
this.options = {};
|
||||
this.store = new Store();
|
||||
this.parts = {};
|
||||
|
||||
// Merge config with defaults (FIXME: set defaults)
|
||||
let defaults = {
|
||||
measurements: {},
|
||||
margin: 2,
|
||||
options: {}
|
||||
};
|
||||
this.config = { ...defaults, ...config };
|
||||
|
||||
// Convert options
|
||||
for (let i in config.options) {
|
||||
let option = config.options[i];
|
||||
if (typeof option === "object") {
|
||||
if (typeof option.pct !== "undefined") this.options[i] = option.pct / 100;
|
||||
else if (typeof option.mm !== "undefined") this.options[i] = option.mm;
|
||||
else if (typeof option.deg !== "undefined") this.options[i] = option.deg;
|
||||
if (typeof option.pct !== "undefined")
|
||||
this.settings.options[i] = option.pct / 100;
|
||||
else if (typeof option.mm !== "undefined")
|
||||
this.settings.options[i] = option.mm;
|
||||
else if (typeof option.deg !== "undefined")
|
||||
this.settings.options[i] = option.deg;
|
||||
else if (typeof option.count !== "undefined")
|
||||
this.options[i] = option.count;
|
||||
this.settings.options[i] = option.count;
|
||||
else if (typeof option.dflt !== "undefined")
|
||||
this.options[i] = option.dflt;
|
||||
this.settings.options[i] = option.dflt;
|
||||
else throw "Unknown option type";
|
||||
} else {
|
||||
this.options[i] = option;
|
||||
this.settings.options[i] = option;
|
||||
}
|
||||
}
|
||||
|
||||
// Context object to inject in part
|
||||
// Context object (will be added to parts by createPart() )
|
||||
this.context = {
|
||||
parts: this.parts,
|
||||
config: this.config,
|
||||
settings: this.settings,
|
||||
options: this.options,
|
||||
store: this.store
|
||||
};
|
||||
|
||||
// Constructors
|
||||
this.Part = Part;
|
||||
this.Point = Point;
|
||||
this.Path = Path;
|
||||
this.Snippet = Snippet;
|
||||
|
||||
let self = this;
|
||||
this.Part.prototype.getContext = function() {
|
||||
return self.context;
|
||||
};
|
||||
|
||||
this.Part.prototype.hooks = this.hooks;
|
||||
this.is = "";
|
||||
}
|
||||
|
||||
// FIXME: Still needed?
|
||||
// Creates a new part with the pattern context
|
||||
Pattern.prototype.createPart = function() {
|
||||
let part = new Part();
|
||||
part.context = this.context;
|
||||
|
@ -84,6 +70,18 @@ Pattern.prototype.createPart = function() {
|
|||
return part;
|
||||
};
|
||||
|
||||
// Merges settings object with this.settings
|
||||
Pattern.prototype.mergeSettings = function(settings) {
|
||||
for (let key of Object.keys(settings)) {
|
||||
if (typeof settings[key] === "object") {
|
||||
this.settings[key] = {
|
||||
...this.settings[key],
|
||||
...settings[key]
|
||||
};
|
||||
} else this.settings[key] = settings[key];
|
||||
}
|
||||
};
|
||||
|
||||
Pattern.prototype.runHooks = function(hookName, data = false) {
|
||||
if (data === false) data = this;
|
||||
let hooks = this.hooks[hookName];
|
||||
|
@ -203,7 +201,7 @@ Pattern.prototype.sampleOption = function(optionName) {
|
|||
val = option.min / factor;
|
||||
step = (option.max / factor - val) / 9;
|
||||
for (let run = 1; run < 11; run++) {
|
||||
this.options[optionName] = val;
|
||||
this.settings.options[optionName] = val;
|
||||
this.debug(
|
||||
"info",
|
||||
"🏃🏿♀️ Sample run",
|
||||
|
@ -225,7 +223,7 @@ Pattern.prototype.sampleListOption = function(optionName) {
|
|||
let run = 1;
|
||||
let runs = option.list.length;
|
||||
for (let val of option.list) {
|
||||
this.options[optionName] = val;
|
||||
this.settings.options[optionName] = val;
|
||||
this.debug(
|
||||
"info",
|
||||
"🏃🏿♀️ Sample run",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue