diff --git a/lib/part.ts b/lib/part.ts index 65f261f5acf..933afcea62e 100644 --- a/lib/part.ts +++ b/lib/part.ts @@ -4,10 +4,27 @@ import { Snippet } from './snippet' import { Attributes } from './attributes' import { PointList } from './pointlist' +var pointProxy: any = { + id: 'test', + get: function(points, key: string, proxy: ProxyHandler>): Point { + console.log(`getting ${key}`); + return points.get(key); + }, + set: function(points: Map, key: string, point: Point, proxy: ProxyHandler>) { + console.log(arguments); + console.log(`Args above. Setting ${key} to`, point); + point.attributes.add('data-key', key); + point.attributes.add('data-part', this.id); + points.set(key, point); + return true; + } +}; + + export class Part { id: string; render: boolean; - points: PointList = new PointList(); + points = new Proxy(new Map(), pointProxy); paths: { [index: string]: Path; } = {}; snippets: { [index: string]: Snippet; } = {}; attributes = new Attributes(); @@ -16,6 +33,7 @@ export class Part { constructor(id: string) { this.id = id; this.render = (id.substr(0,1) === '_') ? false : true; + this.points = new Proxy(new Map(), pointProxy); this.points.origin = new Point(0,0); return this; diff --git a/lib/themes/designer.ts b/lib/themes/designer.ts index 642add790f0..f3e52aac882 100644 --- a/lib/themes/designer.ts +++ b/lib/themes/designer.ts @@ -1,6 +1,7 @@ import { Pattern } from '../pattern' import { Svg } from '../svg' import { Path } from '../path' +import { Part } from '../part' import { Snippet } from '../snippet' import { Theme } from './theme'; @@ -88,7 +89,7 @@ export class Designer extends Theme { decoratePoint(pointId: string, part: Part, svg: Svg): void { let point = part.points[pointId]; point.attributes.add('id', svg.getUid()); - point.attributes.add('data-point', id); + point.attributes.add('data-point', pointId); } /** Decorares paths with extra info */ @@ -107,22 +108,23 @@ export class Designer extends Theme { decoratePath(pathId: string, part: Part, svg: Svg): void { let path = part.paths[pathId]; if (!path.render) return false; + let id: string; for (let op of path.ops) { switch(op.type) { case 'move': - let id = svg.getUid(); + id = svg.getUid(); part.snippets[id] = new Snippet(op.to, 'path-start-point', `Startpoint of path ${pathId}`); part.snippets[id].attributes.add('onmouseover', 'pointHover(evt)'); part.snippets[id].attributes.add('id', svg.getUid()); break; case 'line': - let id = svg.getUid(); + id = svg.getUid(); part.snippets[id] = new Snippet(op.to, 'path-point', `Line endpoint of path ${pathId}`); part.snippets[id].attributes.add('onmouseover', 'pointHover(evt)'); part.snippets[id].attributes.add('id', svg.getUid()); break; case 'curve': - let id = svg.getUid(); + id = svg.getUid(); part.snippets[id] = new Snippet(op.to, 'path-point', `Curve endpoint of path ${pathId}`); part.snippets[id].attributes.add('onmouseover', 'pointHover(evt)'); part.snippets[id].attributes.add('id', svg.getUid()); diff --git a/package.json b/package.json index c5f839c2e0a..3ea4cbc66fc 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,7 @@ "scripts": { "test": "mocha -r ts-node/register tests/*.test.js", "build": "tsc", - "build-watch": "tsc -w", - "run": "nodemon node dist/index.js", - "run-watch": "nodemon node dist/index.js" + "watch": "tsc -w" }, "repository": { "type": "git", diff --git a/tsconfig.json b/tsconfig.json index 328bdc686e4..8d6e9fc4c4e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es6", "module": "commonjs", "declaration": true, "outDir": "./dist",