1
0
Fork 0

🚧 Question time

This commit is contained in:
joostdecock 2018-07-11 12:45:02 +00:00
parent 38ccf65789
commit 20eafd4a99
17 changed files with 123 additions and 44 deletions

2
dist/index.d.ts vendored
View file

@ -1,8 +1,10 @@
import pattern from './lib/pattern';
import point from './lib/point';
import bezier from 'bezier-js';
declare var Freesewing: {
version: string;
pattern: typeof pattern;
point: typeof point;
bezier: typeof bezier;
};
export default Freesewing;

2
dist/index.js vendored
View file

@ -4,10 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
var pattern_1 = __importDefault(require("./lib/pattern"));
var point_1 = __importDefault(require("./lib/point"));
var bezier_js_1 = __importDefault(require("bezier-js"));
var Freesewing = {
version: '0.0.1',
pattern: pattern_1.default,
point: point_1.default,
bezier: bezier_js_1.default
};
exports.default = Freesewing;

21
dist/lib/model.d.ts vendored
View file

@ -1,7 +1,16 @@
import { PatternOption } from './types';
export default class Model {
id: string;
config: PatternOption;
val: number;
constructor(config: PatternOption);
import { PatternConfig } from './types';
import Part from './part';
import Option from './option';
export default class Pattern {
config: PatternConfig;
parts: {
[propName: string]: Part;
};
options: {
[propName: string]: Option;
};
constructor(config: PatternConfig);
draft(config: object): void;
getOption(id: string | number): any;
o(id: string | number): any;
}

34
dist/lib/model.js vendored
View file

@ -1,12 +1,34 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var Model = /** @class */ (function () {
function Model(config) {
this.id = config.id;
var part_1 = __importDefault(require("./part"));
var option_1 = __importDefault(require("./option"));
var Pattern = /** @class */ (function () {
function Pattern(config) {
this.config = config;
this.val = config.val;
this.parts = {};
for (var _i = 0, _a = config.parts; _i < _a.length; _i++) {
var id = _a[_i];
this.parts[id] = new part_1.default(id);
}
this.options = {};
for (var _b = 0, _c = config.options; _b < _c.length; _b++) {
var conf = _c[_b];
this.options[conf.id] = new option_1.default(conf);
}
return this;
}
return Model;
Pattern.prototype.draft = function (config) {
throw Error('You have to implement the draft() method in your Pattern instance.');
};
Pattern.prototype.getOption = function (id) {
return this.options[id].val;
};
Pattern.prototype.o = function (id) {
return this.getOption(id);
};
return Pattern;
}());
exports.default = Model;
exports.default = Pattern;

10
dist/lib/part.d.ts vendored
View file

@ -1,4 +1,10 @@
import Point from './point';
export default class Part {
id: string;
constructor(id: string);
id: string | number;
points: {
[index: string]: Point;
};
[propName: string]: any;
constructor(id: string | number);
newPoint(id: string | number, x: number, y: number): void;
}

8
dist/lib/part.js vendored
View file

@ -1,10 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var point_1 = __importDefault(require("./point"));
var Part = /** @class */ (function () {
function Part(id) {
this.id = id;
this.points = {};
return this;
}
Part.prototype.newPoint = function (id, x, y) {
this.points[id] = new point_1.default(x, y);
};
return Part;
}());
exports.default = Part;

View file

@ -11,4 +11,6 @@ export default class Pattern {
};
constructor(config: PatternConfig);
draft(config: object): void;
getOption(id: string | number): any;
o(id: string | number): any;
}

6
dist/lib/pattern.js vendored
View file

@ -23,6 +23,12 @@ var Pattern = /** @class */ (function () {
Pattern.prototype.draft = function (config) {
throw Error('You have to implement the draft() method in your Pattern instance.');
};
Pattern.prototype.getOption = function (id) {
return this.options[id].val;
};
Pattern.prototype.o = function (id) {
return this.getOption(id);
};
return Pattern;
}());
exports.default = Pattern;

5
dist/lib/point.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
export default class Point {
x: number;
y: number;
constructor(x: number, y: number);
}

12
dist/lib/point.js vendored Normal file
View file

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PRECISION = 2;
var Point = /** @class */ (function () {
function Point(x, y) {
this.x = +x.toFixed(PRECISION);
this.y = +y.toFixed(PRECISION);
return this;
}
return Point;
}());
exports.default = Point;

5
dist/lib/types.d.ts vendored
View file

@ -19,11 +19,6 @@ export interface PatternConfig {
options: PatternOption[];
[propName: string]: any;
}
export declare type Pattern = {
parts: string[];
measurements: string[];
config: PatternConfig;
};
export declare type DraftMode = "sample" | "compare" | "draft";
export declare type CompareGroup = "men" | "women";
export declare type Units = "metric" | "imperial";

View file

@ -1,9 +1,11 @@
import pattern from './lib/pattern'
import point from './lib/point'
import bezier from 'bezier-js'
var Freesewing = {
version: '0.0.1',
pattern,
point,
bezier
}

View file

@ -1,14 +0,0 @@
import { PatternOption } from './types'
export default class Model {
id: string;
config: PatternOption;
val: number;
constructor(config: PatternOption) {
this.id = config.id;
this.config = config;
this.val = config.val;
return this;
}
}

View file

@ -1,11 +1,20 @@
import { PatternOption } from './types'
import Point from './point'
export default class Part {
id: string;
id: string | number;
points: {
[index: string]: Point;
}
[propName: string]: any;
constructor(id: string) {
constructor(id: string | number) {
this.id = id;
this.points = {};
return this;
}
newPoint(id: string | number, x: number, y: number) {
this.points[id] = new Point(x, y);
}
}

View file

@ -26,4 +26,12 @@ export default class Pattern {
draft(config: object): void {
throw Error('You have to implement the draft() method in your Pattern instance.');
}
getOption(id: string | number): any {
return this.options[id].val;
}
o(id: string | number): any {
return this.getOption(id);
}
}

13
lib/point.ts Normal file
View file

@ -0,0 +1,13 @@
const PRECISION = 2;
export default class Point {
x: number;
y: number;
constructor(x: number, y: number) {
this.x = +x.toFixed(PRECISION);
this.y = +y.toFixed(PRECISION);
return this;
}
}

View file

@ -22,12 +22,6 @@ export interface PatternConfig {
[propName: string]: any;
}
export type Pattern = {
parts: string[];
measurements: string[];
config: PatternConfig;
}
export type DraftMode = "sample" | "compare" | "draft";
export type CompareGroup = "men" | "women";
export type Units = "metric" | "imperial";
@ -43,5 +37,3 @@ export interface DraftConfig {
scope?: string[];
theme?: string;
}