From c3b890199d4a3701445a37624abd613d57238496 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 8 May 2021 13:00:59 -0700 Subject: [PATCH] Trying to get modules to work --- Makefile | 2 +- js/tower.js | 9 ++++++++- js/tower.js.map | 2 +- js/tower_map.js | 25 +++++++++++++++++++++++++ js/tower_map.js.map | 2 +- src/tower.ts | 5 ----- src/tower_map.ts | 2 -- test.html | 1 - tower.html | 2 +- ts/tower.ts | 14 ++++++++++++++ ts/tower_map.ts | 14 ++++++++++++++ tsconfig.json | 17 +++++++++++++---- 12 files changed, 78 insertions(+), 17 deletions(-) delete mode 100644 src/tower.ts delete mode 100644 src/tower_map.ts create mode 100644 ts/tower.ts create mode 100644 ts/tower_map.ts diff --git a/Makefile b/Makefile index 3a9b5e5..d98ceee 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ -all: tsconfig.json $(wildcard src/*.ts) +all: tsconfig.json $(wildcard ts/*.ts) tsc diff --git a/js/tower.js b/js/tower.js index dedf8b3..cc273e2 100644 --- a/js/tower.js +++ b/js/tower.js @@ -1,6 +1,13 @@ import { TowerMap } from 'tower_map.js'; export function main() { - const map = new TowerMap(); + document.body.style.margin = '0'; + document.body.style.backgroundColor = 'black'; + const container = document.createElement('div'); + document.body.appendChild(container); + container.style.width = '100vmin'; + container.style.height = '100vmin'; + const map = new TowerMap(container); + map.draw(); } ; //# sourceMappingURL=tower.js.map \ No newline at end of file diff --git a/js/tower.js.map b/js/tower.js.map index 05a69a2..3a3b235 100644 --- a/js/tower.js.map +++ b/js/tower.js.map @@ -1 +1 @@ -{"version":3,"file":"tower.js","sourceRoot":"","sources":["../src/tower.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,UAAU,IAAI;IAClB,MAAM,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAAA,CAAC"} \ No newline at end of file +{"version":3,"file":"tower.js","sourceRoot":"","sources":["../ts/tower.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,UAAU,IAAI;IAClB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC;IAE9C,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAEnC,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,GAAG,CAAC,IAAI,EAAE,CAAC;AACb,CAAC;AAAA,CAAC"} \ No newline at end of file diff --git a/js/tower_map.js b/js/tower_map.js index 2aa9d12..28b1397 100644 --- a/js/tower_map.js +++ b/js/tower_map.js @@ -1,3 +1,28 @@ +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + privateMap.set(receiver, value); + return value; +}; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + return privateMap.get(receiver); +}; +var _prnt; export class TowerMap { + constructor(prnt) { + _prnt.set(this, void 0); + __classPrivateFieldSet(this, _prnt, prnt); + __classPrivateFieldGet(this, _prnt).style.display = 'grid'; + } + draw() { + __classPrivateFieldGet(this, _prnt).style.backgroundImage = 'url("images/land1.svg")'; + __classPrivateFieldGet(this, _prnt).style.gridTemplateColumns = 'repeat(20, 1ft)'; + __classPrivateFieldGet(this, _prnt).style.gridTemplateRows = 'repeat(20, 1ft)'; + } } +_prnt = new WeakMap(); //# sourceMappingURL=tower_map.js.map \ No newline at end of file diff --git a/js/tower_map.js.map b/js/tower_map.js.map index d4db089..945d0eb 100644 --- a/js/tower_map.js.map +++ b/js/tower_map.js.map @@ -1 +1 @@ -{"version":3,"file":"tower_map.js","sourceRoot":"","sources":["../src/tower_map.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;CACpB"} \ No newline at end of file +{"version":3,"file":"tower_map.js","sourceRoot":"","sources":["../ts/tower_map.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,MAAM,OAAO,QAAQ;IAGnB,YAAY,IAAiB;QAF7B,wBAAM;QAGJ,uBAAA,IAAI,SAAS,IAAI,EAAC;QAClB,oCAAW,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACpC,CAAC;IAED,IAAI;QACF,oCAAW,KAAK,CAAC,eAAe,GAAG,yBAAyB,CAAC;QAC7D,oCAAW,KAAK,CAAC,mBAAmB,GAAG,iBAAiB,CAAC;QACzD,oCAAW,KAAK,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;IACxD,CAAC;CACF"} \ No newline at end of file diff --git a/src/tower.ts b/src/tower.ts deleted file mode 100644 index 7b0063f..0000000 --- a/src/tower.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TowerMap } from 'tower_map.js'; - -export function main() { - const map = new TowerMap(); -}; diff --git a/src/tower_map.ts b/src/tower_map.ts deleted file mode 100644 index b91ba0a..0000000 --- a/src/tower_map.ts +++ /dev/null @@ -1,2 +0,0 @@ -export class TowerMap { -} diff --git a/test.html b/test.html index f0b0ad2..48d986b 100644 --- a/test.html +++ b/test.html @@ -26,7 +26,6 @@ div { width: var(--map-width); height: var(--map-height); background-image: url('images/land1.svg'); - background-size: 100% 100%; display: grid; grid-template-columns: repeat(var(--map-width-tiles), 1fr); grid-template-rows: repeat(var(--map-height-tiles), 1fr); diff --git a/tower.html b/tower.html index 8a75430..b738ce4 100644 --- a/tower.html +++ b/tower.html @@ -6,5 +6,5 @@ - + diff --git a/ts/tower.ts b/ts/tower.ts new file mode 100644 index 0000000..a91f1d0 --- /dev/null +++ b/ts/tower.ts @@ -0,0 +1,14 @@ +import { TowerMap } from 'tower_map.js'; + +export function main() { + document.body.style.margin = '0'; + document.body.style.backgroundColor = 'black'; + + const container = document.createElement('div'); + document.body.appendChild(container); + container.style.width = '100vmin'; + container.style.height = '100vmin'; + + const map = new TowerMap(container); + map.draw(); +}; diff --git a/ts/tower_map.ts b/ts/tower_map.ts new file mode 100644 index 0000000..39e18d1 --- /dev/null +++ b/ts/tower_map.ts @@ -0,0 +1,14 @@ +export class TowerMap { + #prnt; + + constructor(prnt: HTMLElement) { + this.#prnt = prnt; + this.#prnt.style.display = 'grid'; + } + + draw() { + this.#prnt.style.backgroundImage = 'url("images/land1.svg")'; + this.#prnt.style.gridTemplateColumns = 'repeat(20, 1ft)'; + this.#prnt.style.gridTemplateRows = 'repeat(20, 1ft)'; + } +} diff --git a/tsconfig.json b/tsconfig.json index dcf8d10..0631246 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,21 @@ "compilerOptions": { "target": "ES2020", "module": "ES2020", - "noImplicitAny": true, + "outDir": "js", "sourceMap": true, - "outDir": "js" + + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "strictPropertyInitialization": true }, "files": [ - "src/tower.ts", - "src/tower_map.ts" + "ts/tower.ts", + "ts/tower_map.ts" ] }