squishjs 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/BaseNode.js CHANGED
@@ -1,9 +1,7 @@
1
- const listenable = require("./util/listenable");
2
1
  const InternalGameNode = require('./InternalGameNode');
3
2
 
4
3
  const gameNode = (color, onClick, coordinates2d, border, fill, text, asset, playerIds, effects, input, subtype, id) => {
5
- const node = new InternalGameNode(color, onClick, coordinates2d, border, fill, text, asset, playerIds, effects, input, subtype, id);
6
- return listenable(node, node.onStateChange.bind(node));
4
+ return new InternalGameNode(color, onClick, coordinates2d, border, fill, text, asset, playerIds, effects, input, subtype, id);
7
5
  };
8
6
 
9
7
  class BaseNode {
@@ -45,22 +43,30 @@ class BaseNode {
45
43
  }
46
44
  }
47
45
 
48
- addChild(child) {
46
+ addChild(child, notifyListeners = true) {
49
47
  this.node.addChild(child);
48
+ if (notifyListeners) {
49
+ this.node.onStateChange();
50
+ }
50
51
  }
51
52
 
52
53
  addChildren(...nodes) {
53
54
  for (let nodeIndex = 0; nodeIndex < nodes.length; nodeIndex++) {
54
- this.addChild(nodes[nodeIndex]);
55
+ this.addChild(nodes[nodeIndex], false);
55
56
  }
57
+
58
+ this.node.onStateChange();
56
59
  }
57
60
 
58
61
  getChildren() {
59
62
  return this.node.children;
60
63
  }
61
64
 
62
- removeChild(nodeId) {
65
+ removeChild(nodeId, notifyListeners = true) {
63
66
  this.node.removeChild(nodeId);
67
+ if (notifyListeners) {
68
+ this.node.onStateChange();
69
+ }
64
70
  }
65
71
 
66
72
  addListener(listener) {
@@ -89,14 +95,23 @@ class BaseNode {
89
95
 
90
96
  clearChildren(excludedNodeIds) {
91
97
  this.node.clearChildren(excludedNodeIds);
98
+ this.node.onStateChange();
92
99
  }
93
100
 
94
- clone() {
95
- throw new Error("Clone not implemented");
101
+ update( params = {} ) {
102
+ if (params) {
103
+ if (params.fill) {
104
+ this.node.fill = params.fill;
105
+ }
106
+ if (params.coordinates2d) {
107
+ this.node.coordinates2d = coordinates2d;
108
+ }
109
+ }
110
+ this.node.onStateChange();
96
111
  }
97
112
 
98
- free() {
99
- this.node.free();
113
+ clone() {
114
+ throw new Error("Clone not implemented");
100
115
  }
101
116
  }
102
117
 
@@ -21,7 +21,6 @@ class InternalGameNode {
21
21
 
22
22
  addChild(node) {
23
23
  this.children.push(node);
24
- this.onStateChange();
25
24
  }
26
25
 
27
26
  addChildren(...nodes) {
@@ -37,8 +36,6 @@ class InternalGameNode {
37
36
  clearInterval(this._animation);
38
37
  }
39
38
  this.children.splice(removeIndex, 1);
40
- // hack to invoke update listener
41
- this.id = this.id;
42
39
  }
43
40
  }
44
41
 
package/src/Squisher.js CHANGED
@@ -147,21 +147,6 @@ class Squisher {
147
147
  this.squishHelper(node.node.children[i], squishedNodes, scale, playerMap, pathFilter);
148
148
  }
149
149
 
150
- // debug
151
- for (let k in playerMap) {
152
- for (let squished in playerMap[k]) {
153
- const unsquished = unsquish(playerMap[k][squished]);
154
- if (unsquished.node.playerIds.length > 0 && unsquished.node.playerIds.findIndex(i => Number(i) === Number(k)) < 0) {
155
- console.log(unsquished.node.playerIds);
156
- console.log(k);
157
- console.log(unsquished.node.playerIds.indexOf(k));
158
- if (k != 254) {
159
- throw new Error('fuk');
160
- }
161
- }
162
- }
163
- }
164
-
165
150
  }
166
151
 
167
152
  getJson() {
@@ -39,10 +39,13 @@ test("squisher listener", () => {
39
39
  assert(timesInvoked === 0);
40
40
 
41
41
  root.node.color = COLORS.BLACK;
42
+ root.node.onStateChange();
42
43
 
43
44
  assert(timesInvoked === 1);
44
45
 
45
46
  root.node.color = COLORS.GREEN;
47
+ root.node.onStateChange();
48
+
46
49
  assert(timesInvoked === 2);
47
50
  });
48
51
 
package/test/main.test.js CHANGED
@@ -3,7 +3,7 @@ const { GameNode } = require('../src/GameNode');
3
3
  const { COLORS } = require("../src/Colors");
4
4
  const Shapes = require('../src/Shapes');
5
5
  const ShapeUtils = require('../src/util/shapes');
6
- const { verifyArrayEquality } = require('./utils');
6
+ const { verifyArrayEquality, rectNode, FakeGame } = require('./utils');
7
7
  const Squisher = require('../src/Squisher');
8
8
  const Game = require('../src/Game');
9
9
 
@@ -361,7 +361,7 @@ test("big big text", () => {
361
361
  test("allocate a bunch of nodes", () => {
362
362
  const initialMemUsage = process.memoryUsage();
363
363
 
364
- const nodeCount = Math.pow(10, 2);
364
+ const nodeCount = Math.pow(10, 3);
365
365
 
366
366
  const root = new GameNode.Text({
367
367
  textInfo: {
@@ -404,10 +404,47 @@ test("allocate a bunch of nodes", () => {
404
404
 
405
405
  root.addChild(gameNode);
406
406
  root.removeChild(gameNode.node.id);
407
- gameNode.free();
408
407
  }
409
408
 
410
409
  const postMemUsage = process.memoryUsage();
411
410
  assert(postMemUsage.heapTotal - initialMemUsage.heapTotal <= (.05 * initialMemUsage.heapTotal));
412
411
  });
413
412
 
413
+ test("Simple shape with updates", () => {
414
+ const base = rectNode({ x: 0, y: 0, width: 100, height: 100, fill: COLORS.RED });
415
+
416
+ const game = new FakeGame([
417
+ {
418
+ root: base
419
+ }
420
+ ]);
421
+
422
+ const squisher = new Squisher({ game });
423
+
424
+ let updateCount = 0;
425
+ // add listener so squisher cares about update
426
+ squisher.addListener(() => {
427
+ updateCount++;
428
+ });
429
+
430
+ const initialState = Array.from(squisher.state);
431
+ assert(initialState.length === 1);
432
+
433
+ verifyArrayEquality(unsquish(initialState[0]).node.fill, COLORS.RED);
434
+
435
+ base.update({
436
+ fill: COLORS.BLUE
437
+ });
438
+
439
+ const state2 = Array.from(squisher.state);
440
+ verifyArrayEquality(unsquish(state2[0]).node.fill, COLORS.BLUE);
441
+
442
+ base.update({
443
+ fill: COLORS.GREEN
444
+ });
445
+
446
+ const state3 = Array.from(squisher.state);
447
+ verifyArrayEquality(unsquish(state3[0]).node.fill, COLORS.GREEN);
448
+ });
449
+
450
+
@@ -1,16 +0,0 @@
1
- export interface pointDef {
2
- x: number;
3
- y: number;
4
- };
5
-
6
- export interface boardInfo {
7
- filled: boolean;
8
- north: boolean;
9
- south: boolean;
10
- east: boolean;
11
- west: boolean;
12
- wentSouth?: boolean;
13
- wentEast?: boolean;
14
- wentNorth?: boolean;
15
- wentWest?: boolean;
16
- };
@@ -1,156 +0,0 @@
1
- import { getRandomTerrain, getRandomStartPoint } from './terrainFunctions';
2
- import { pointDef, boardInfo } from './defs';
3
-
4
- interface dimensionDef {
5
- width: number;
6
- height: number;
7
- };
8
-
9
- export const terrainGenerator = (boardBounds: pointDef = { x: 100, y: 100 }, terrainBounds: pointDef = { x: 5, y: 5 }, numberOfTerrainElements = 5) => {
10
- const { width, height } = getBoardDimensions(boardBounds, terrainBounds);
11
- let board = initializeBoard(width, height);
12
- const keyPoint = {
13
- x: Math.floor(Math.random() * width),
14
- y: Math.floor(Math.random() * height)
15
- };
16
- board = generateTerrain(board, keyPoint, numberOfTerrainElements, width, height);
17
- return board;
18
- };
19
-
20
- const getBoardDimensions = (boardBounds: pointDef, terrainBounds: pointDef): dimensionDef => {
21
- const boardX = boardBounds.x;
22
- const boardY = boardBounds.y;
23
- const terrainX = terrainBounds.x;
24
- const terrainY = terrainBounds.y;
25
- return {
26
- width: Math.floor(boardX/terrainX),
27
- height: Math.floor(boardY/terrainY)
28
- };
29
- };
30
-
31
- const initializeBoard = (width: number, height: number): boardInfo[][] => {
32
- const board: boardInfo[][] = [];
33
-
34
- const defaultInfo: boardInfo = {
35
- filled: false,
36
- north: true,
37
- south: true,
38
- east: true,
39
- west: true
40
- };
41
-
42
- for(let i = 0; i < width; i++) {
43
- board[i] = [];
44
- for (let j = 0; j < height; j++) {
45
- const info = { ...defaultInfo };
46
- if (i === 0) {
47
- info.west = false;
48
- } else if (i === width - 1) {
49
- info.east = false;
50
- }
51
- if (j === 0) {
52
- info.north = false;
53
- } else if (j === height - 1) {
54
- info.south = false;
55
- }
56
- board[i].push(info);
57
- }
58
- }
59
- return board;
60
- };
61
-
62
- const deepClone = (toCopy: boardInfo[][]) => {
63
- const toReturn: boardInfo[][] = [];
64
- toCopy.forEach((row, rowNum) => {
65
- toReturn[rowNum] = [];
66
- row.forEach(elem => {
67
- toReturn[rowNum].push({ ...elem });
68
- });
69
- });
70
- return toReturn;
71
- };
72
-
73
- const cleanUpBoard = (board: boardInfo[][]) => {
74
- for (let i = 0; i < board.length; i++) {
75
- for (let j = 0; j < board[i].length; j++) {
76
- board[i][j] = {
77
- filled: board[i][j].filled,
78
- north: board[i][j].north,
79
- south: board[i][j].south,
80
- east: board[i][j].east,
81
- west: board[i][j].west
82
- };
83
- }
84
- }
85
- };
86
-
87
- const verifyKeyPoint = (board: boardInfo[][], keyPoint: pointDef, boardWidth: number, boardHeight: number) => {
88
- const pointsVerified = [];
89
- for (let x = 0; x < boardWidth; x++) {
90
- for (let y = 0; y < boardHeight; y++) {
91
- const pointsOnCurrentPath = [];
92
- const currentPoint = { x, y };
93
- while(true) {
94
- const boardPoint = board[currentPoint.x][currentPoint.y];
95
- if (
96
- (pointsVerified.findIndex(point => point.x === currentPoint.x && point.y === currentPoint.y) > -1) ||
97
- (currentPoint.x === keyPoint.x && currentPoint.y === keyPoint.y) ||
98
- (boardPoint.filled)
99
- ) {
100
- /*
101
- if we already know we can reach the keyPoint from our test point or
102
- if we are at the key point or
103
- if we are in a filled point, just skip the iteration, no need to test this point further
104
- */
105
- pointsVerified.push(...pointsOnCurrentPath);
106
- break;
107
- } else if(
108
- (!boardPoint.north || boardPoint.wentNorth) &&
109
- (!boardPoint.south || boardPoint.wentSouth) &&
110
- (!boardPoint.east || boardPoint.wentEast) &&
111
- (!boardPoint.west || boardPoint.wentWest)
112
- ) {
113
- /*
114
- if we have exhausted all possible movements for a point, and not reached the keypoint
115
- then this possibleBoard is not workable
116
- */
117
- return false;
118
- }
119
- pointsOnCurrentPath.push({ ...currentPoint });
120
- if (boardPoint.south && !boardPoint.wentSouth) {
121
- boardPoint.wentSouth = true;
122
- currentPoint.y = currentPoint.y + 1;
123
- } else if (boardPoint.east && !boardPoint.wentEast) {
124
- boardPoint.wentEast = true;
125
- currentPoint.x = currentPoint.x + 1;
126
- } else if (boardPoint.north && !boardPoint.wentNorth) {
127
- boardPoint.wentNorth = true;
128
- currentPoint.y = currentPoint.y - 1;
129
- } else if (boardPoint.west && !boardPoint.wentWest) {
130
- boardPoint.wentWest = true;
131
- currentPoint.x = currentPoint.x - 1;
132
- } else {
133
- return false;
134
- }
135
- }
136
- cleanUpBoard(board);
137
- }
138
- }
139
- return true;
140
- };
141
-
142
- const generateTerrain = (board: boardInfo[][], keyPoint: pointDef, toPlace: number, boardWidth: number, boardHeight: number, numberOfIterations = 0): boardInfo[][] => {
143
- if (toPlace === 0 || numberOfIterations === 3) {
144
- return board;
145
- }
146
- const possibleBoard = deepClone(board);
147
- const terrainFunction = getRandomTerrain();
148
- const terrainStartPoint = getRandomStartPoint(boardWidth, boardHeight, keyPoint);
149
- terrainFunction(possibleBoard, terrainStartPoint, boardWidth, boardHeight, keyPoint);
150
- const temp = verifyKeyPoint(possibleBoard, keyPoint, boardWidth, boardHeight);
151
- if (temp) {
152
- return generateTerrain(possibleBoard, keyPoint, toPlace - 1, boardWidth, boardHeight, 0);
153
- } else {
154
- return generateTerrain(board, keyPoint, toPlace, boardWidth, boardHeight, numberOfIterations + 1);
155
- }
156
- };
@@ -1,142 +0,0 @@
1
- import { pointDef, boardInfo } from './defs';
2
-
3
- const placeTerrain = (board: boardInfo[][], { x, y }: pointDef, boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
4
- if (x < 0 || x >= boardWidth) {
5
- return;
6
- } else if (y < 0 || y >= boardHeight) {
7
- return;
8
- } else if ( x === keyPoint.x && y === keyPoint.y) {
9
- return;
10
- }
11
-
12
- if (!board[x][y].filled) {
13
- if (board[x][y].north) {
14
- board[x][y - 1].south = false;
15
- }
16
- if (board[x][y].south) {
17
- board[x][y + 1].north = false;
18
- }
19
- if (board[x][y].east) {
20
- board[x + 1][y].west = false;
21
- }
22
- if (board[x][y].west) {
23
- board[x - 1][y].east = false;
24
- }
25
- board[x][y].filled = true;
26
- board[x][y].north = false;
27
- board[x][y].south = false;
28
- board[x][y].east = false;
29
- board[x][y].west = false;
30
- }
31
- }
32
-
33
- const square = (board: boardInfo[][], { x, y }: pointDef, boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
34
- const option = Math.floor(Math.random() * 4);
35
- placeTerrain(board, { x, y }, boardWidth, boardHeight, keyPoint);
36
- if (option === 0) { // start point is top left
37
- placeTerrain(board, { x: x + 1, y }, boardWidth, boardHeight, keyPoint);
38
- placeTerrain(board, { x, y: y + 1 }, boardWidth, boardHeight, keyPoint);
39
- placeTerrain(board, { x: x + 1, y: y + 1 }, boardWidth, boardHeight, keyPoint);
40
- } else if (option === 1) { // start point is top right
41
- placeTerrain(board, { x: x - 1, y }, boardWidth, boardHeight, keyPoint);
42
- placeTerrain(board, { x, y: y + 1 }, boardWidth, boardHeight, keyPoint);
43
- placeTerrain(board, { x: x - 1, y: y + 1 }, boardWidth, boardHeight, keyPoint);
44
- } else if (option === 2) { // start point is bottom left
45
- placeTerrain(board, { x, y: y - 1 }, boardWidth, boardHeight, keyPoint);
46
- placeTerrain(board, { x: x + 1, y }, boardWidth, boardHeight, keyPoint);
47
- placeTerrain(board, { x: x + 1, y: y - 1 }, boardWidth, boardHeight, keyPoint);
48
- } else { // start point is bottom right
49
- placeTerrain(board, { x, y: y - 1 }, boardWidth, boardHeight, keyPoint);
50
- placeTerrain(board, { x: x - 1, y }, boardWidth, boardHeight, keyPoint);
51
- placeTerrain(board, { x: x - 1, y: y - 1 }, boardWidth, boardHeight, keyPoint);
52
- }
53
- };
54
-
55
- const line = (board: boardInfo[][], { x, y }: pointDef, boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
56
- const option = Math.floor(Math.random() * 4);
57
- placeTerrain(board, { x, y }, boardWidth, boardHeight, keyPoint);
58
- if (option === 0) { // start point is top
59
- placeTerrain(board, { x, y: y + 1}, boardWidth, boardHeight, keyPoint);
60
- placeTerrain(board, { x, y: y + 2 }, boardWidth, boardHeight, keyPoint);
61
- placeTerrain(board, { x, y: y + 3 }, boardWidth, boardHeight, keyPoint);
62
- } else if (option === 1) { // start point is left
63
- placeTerrain(board, { x: x + 1, y }, boardWidth, boardHeight, keyPoint);
64
- placeTerrain(board, { x: x + 2, y }, boardWidth, boardHeight, keyPoint);
65
- placeTerrain(board, { x: x + 3, y }, boardWidth, boardHeight, keyPoint);
66
- } else if (option === 2) { // start point is right
67
- placeTerrain(board, { x: x - 1, y }, boardWidth, boardHeight, keyPoint);
68
- placeTerrain(board, { x: x - 2, y }, boardWidth, boardHeight, keyPoint);
69
- placeTerrain(board, { x: x - 3, y }, boardWidth, boardHeight, keyPoint);
70
- } else { // start point is bottom
71
- placeTerrain(board, { x, y: y - 1 }, boardWidth, boardHeight, keyPoint);
72
- placeTerrain(board, { x, y: y - 2 }, boardWidth, boardHeight, keyPoint);
73
- placeTerrain(board, { x, y: y - 3 }, boardWidth, boardHeight, keyPoint);
74
- }
75
- };
76
-
77
- const bentLine = (board: boardInfo[][], { x, y }: pointDef, boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
78
- const option = Math.floor(Math.random() * 4);
79
- placeTerrain(board, { x, y }, boardWidth, boardHeight, keyPoint);
80
- if (option === 0) { // start point is top
81
- placeTerrain(board, { x, y: y + 1 }, boardWidth, boardHeight, keyPoint);
82
- placeTerrain(board, { x, y: y + 2 }, boardWidth, boardHeight, keyPoint);
83
- placeTerrain(board, { x: x + 1, y: y + 2 }, boardWidth, boardHeight, keyPoint);
84
- } else if (option === 1) { // start point is left
85
- placeTerrain(board, { x: x + 1, y }, boardWidth, boardHeight, keyPoint);
86
- placeTerrain(board, { x: x + 2, y }, boardWidth, boardHeight, keyPoint);
87
- placeTerrain(board, { x: x + 2, y: y - 1 }, boardWidth, boardHeight, keyPoint);
88
- } else if (option === 2) { // start point is right
89
- placeTerrain(board, { x: x - 1, y }, boardWidth, boardHeight, keyPoint);
90
- placeTerrain(board, { x: x - 2, y }, boardWidth, boardHeight, keyPoint);
91
- placeTerrain(board, { x: x - 2, y: y + 1 }, boardWidth, boardHeight, keyPoint);
92
- } else { // start point is bottom
93
- placeTerrain(board, { x, y: y - 1 }, boardWidth, boardHeight, keyPoint);
94
- placeTerrain(board, { x, y: y - 2 }, boardWidth, boardHeight, keyPoint);
95
- placeTerrain(board, { x: x - 1, y: y - 2 }, boardWidth, boardHeight, keyPoint);
96
- }
97
- };
98
-
99
- const zShape = (board: boardInfo[][], { x, y }: pointDef, boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
100
- const option = Math.floor(Math.random() * 4);
101
- placeTerrain(board, { x, y }, boardWidth, boardHeight, keyPoint);
102
- if (option === 0) { // start point is top
103
- placeTerrain(board, { x, y: y + 1 }, boardWidth, boardHeight, keyPoint);
104
- placeTerrain(board, { x: x - 1, y: y + 1 }, boardWidth, boardHeight, keyPoint);
105
- placeTerrain(board, { x: x - 1, y: y + 2 }, boardWidth, boardHeight, keyPoint);
106
- } else if (option === 1) { // start point is left
107
- placeTerrain(board, { x: x + 1, y }, boardWidth, boardHeight, keyPoint);
108
- placeTerrain(board, { x: x + 1, y: y + 1 }, boardWidth, boardHeight, keyPoint);
109
- placeTerrain(board, { x: x + 2, y: y + 1 }, boardWidth, boardHeight, keyPoint);
110
- } else if (option === 2) { // start point is right
111
- placeTerrain(board, { x: x - 1, y }, boardWidth, boardHeight, keyPoint);
112
- placeTerrain(board, { x: x - 1, y: y + 1 }, boardWidth, boardHeight, keyPoint);
113
- placeTerrain(board, { x: x - 2, y: y + 1 }, boardWidth, boardHeight, keyPoint);
114
- } else { // start point is bottom
115
- placeTerrain(board, { x, y: y - 1 }, boardWidth, boardHeight, keyPoint);
116
- placeTerrain(board, { x: x - 1, y: y - 1 }, boardWidth, boardHeight, keyPoint);
117
- placeTerrain(board, { x: x - 1, y: y - 2 }, boardWidth, boardHeight, keyPoint);
118
- }
119
- };
120
-
121
- const terrainFunctions = [
122
- square,
123
- line,
124
- bentLine,
125
- zShape
126
- ];
127
-
128
- export const getRandomTerrain = () => {
129
- return terrainFunctions[Math.floor(Math.random() * terrainFunctions.length)];
130
- };
131
-
132
- export const getRandomStartPoint = (boardWidth: number, boardHeight: number, keyPoint: pointDef) => {
133
- const startPoint = {
134
- x: Math.floor(Math.random() * boardWidth),
135
- y: Math.floor(Math.random() * boardHeight)
136
- };
137
- while (startPoint.x === keyPoint.x && startPoint.y === keyPoint.y) {
138
- startPoint.x = Math.floor(Math.random() * boardWidth);
139
- startPoint.y = Math.floor(Math.random() * boardHeight);
140
- }
141
- return startPoint;
142
- };
package/src/util/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export const hypLength = (x: number, y: number) => Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
2
-
3
- // get the first 2 digits after the decimal
4
- export const getFractional = (number: number) => {
5
- return Math.round(100 * (number - Math.floor(number)));
6
- };
@@ -1,27 +0,0 @@
1
- const listenable = function(obj, onChange) {
2
- const handler = {
3
- get(target, property, receiver) {
4
- return Reflect.get(target, property, receiver);
5
- },
6
- defineProperty(target, property, descriptor) {
7
- const change = Reflect.defineProperty(target, property, descriptor);
8
- onChange && onChange();
9
- return change;
10
- },
11
- deleteProperty(target, property) {
12
- const change = Reflect.deleteProperty(target, property);
13
- onChange && onChange();
14
- return change;
15
- }
16
- };
17
-
18
- const revocable = Proxy.revocable(obj, handler);
19
-
20
- obj.free = () => {
21
- revocable.revoke();
22
- }
23
-
24
- return revocable.proxy;
25
- };
26
-
27
- module.exports = listenable;
@@ -1,20 +0,0 @@
1
- import { gameNodeDef, internalGameNodeDef } from '../sharedDefs';
2
- export default (obj: internalGameNodeDef, onChange: () => void) => {
3
- const handler = {
4
- get(target: Object, property: PropertyKey, receiver: any) {
5
- return Reflect.get(target, property, receiver);
6
- },
7
- defineProperty(target: Object, property: PropertyKey, descriptor: PropertyDescriptor) {
8
- const change = Reflect.defineProperty(target, property, descriptor);
9
- onChange && onChange();
10
- return change;
11
- },
12
- deleteProperty(target: Object, property: PropertyKey) {
13
- const change = Reflect.deleteProperty(target, property);
14
- onChange && onChange();
15
- return change;
16
- }
17
- };
18
-
19
- return new Proxy(obj, handler);
20
- };
@@ -1,18 +0,0 @@
1
- export const rectangle = (startX: number, startY: number, width: number, height: number) => {
2
- return [
3
- [startX, startY],
4
- [startX + width, startY],
5
- [startX + width, startY + height],
6
- [startX, startY + height],
7
- [startX, startY],
8
- ];
9
- };
10
-
11
- export const triangle = (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => {
12
- return [
13
- [x1, y1],
14
- [x2, y2],
15
- [x3, y3],
16
- [x1, y1]
17
- ];
18
- };
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["es2019"],
4
- "target": "es2015",
5
- "module": "commonjs",
6
- "declaration": true,
7
- "noEmitOnError": true,
8
- "noImplicitAny": true,
9
- "experimentalDecorators": true,
10
- "sourceMap": false,
11
- "inlineSourceMap": true,
12
- "outDir": "./dist"
13
- },
14
- "exclude": [
15
- "dist",
16
- "test",
17
- "node_modules"
18
- ],
19
- "include": [
20
- "src/**/*"
21
- ]
22
- }