Trying to get modules to work

This commit is contained in:
Ian Gulliver
2021-05-08 13:00:59 -07:00
parent 3e4769b3ef
commit c3b890199d
12 changed files with 78 additions and 17 deletions

View File

@@ -1,2 +1,2 @@
all: tsconfig.json $(wildcard src/*.ts)
all: tsconfig.json $(wildcard ts/*.ts)
tsc

View File

@@ -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

View File

@@ -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"}
{"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"}

View File

@@ -1,3 +1,28 @@
export class TowerMap {
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

View File

@@ -1 +1 @@
{"version":3,"file":"tower_map.js","sourceRoot":"","sources":["../src/tower_map.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;CACpB"}
{"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"}

View File

@@ -1,5 +0,0 @@
import { TowerMap } from 'tower_map.js';
export function main() {
const map = new TowerMap();
};

View File

@@ -1,2 +0,0 @@
export class TowerMap {
}

View File

@@ -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);

View File

@@ -6,5 +6,5 @@
</head>
<body>
<script src="js/tower.js"></script>
<script type="module" src="js/tower.js"></script>
</body>

14
ts/tower.ts Normal file
View File

@@ -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();
};

14
ts/tower_map.ts Normal file
View File

@@ -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)';
}
}

View File

@@ -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"
]
}