@koeroesi86/canvas-grid 1.0.15 → 26.11.2

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.
Files changed (57) hide show
  1. package/README.md +27 -0
  2. package/build/types/cell-background/index.d.ts +25 -0
  3. package/build/types/cell-value/index.d.ts +21 -0
  4. package/build/types/character/index.d.ts +21 -0
  5. package/build/types/header/index.d.ts +25 -0
  6. package/build/types/rectangle/index.d.ts +12 -0
  7. package/build/types/text/index.d.ts +31 -0
  8. package/build/types/types.d.ts +87 -0
  9. package/build/types/utils/canvas.d.ts +1 -0
  10. package/build/types/utils/collection.d.ts +18 -0
  11. package/build/types/utils/column-store.d.ts +16 -0
  12. package/build/types/utils/data-store.d.ts +49 -0
  13. package/build/types/utils/jsx.d.ts +40 -0
  14. package/build/types/utils/layer.d.ts +26 -0
  15. package/build/types/utils/loading.d.ts +17 -0
  16. package/build/types/utils/lru-cache.d.ts +11 -0
  17. package/build/types/utils/renderer-registry.d.ts +13 -0
  18. package/build/types/utils/renderer.d.ts +26 -0
  19. package/build/types/utils/row-store.d.ts +37 -0
  20. package/build/types/utils/selectors.d.ts +3 -0
  21. package/build/types/web-component.d.ts +189 -0
  22. package/build/web-component.js +1 -732
  23. package/build/web-component.js.map +1 -1
  24. package/build/web-component.mjs +1226 -0
  25. package/build/web-component.mjs.map +1 -0
  26. package/package.json +32 -32
  27. package/.babelrc +0 -14
  28. package/.eslintrc +0 -7
  29. package/.github/CODEOWNERS +0 -1
  30. package/.github/SECURITY.md +0 -9
  31. package/.github/dependabot.yml +0 -11
  32. package/.github/workflows/ci.yml +0 -32
  33. package/.github/workflows/codeql.yml +0 -26
  34. package/.github/workflows/publish.yml +0 -51
  35. package/components/cellBackground/index.jsx +0 -86
  36. package/components/cellValue/index.jsx +0 -80
  37. package/components/character/index.jsx +0 -82
  38. package/components/component.scss +0 -45
  39. package/components/example.js +0 -56
  40. package/components/header/index.jsx +0 -100
  41. package/components/rectangle/index.jsx +0 -65
  42. package/components/text/index.jsx +0 -131
  43. package/components/utils/collection.js +0 -58
  44. package/components/utils/drawingLayer.js +0 -66
  45. package/components/utils/jsx.js +0 -57
  46. package/components/utils/loading.js +0 -58
  47. package/components/utils/renderer.js +0 -45
  48. package/components/utils/selectors.js +0 -13
  49. package/components/web-component.js +0 -582
  50. package/config/htmlGenerator.js +0 -36
  51. package/nodemon.json +0 -5
  52. package/public/index.html +0 -29
  53. package/scripts/build.js +0 -30
  54. package/scripts/dev.js +0 -64
  55. package/server/example.js +0 -59
  56. package/server/exampleServe.js +0 -3
  57. package/webpack.config.js +0 -151
@@ -1,582 +0,0 @@
1
- import throttle from 'lodash.throttle';
2
- import debounce from 'lodash.debounce';
3
- import classNames from 'classnames';
4
- import Collection from './utils/collection';
5
- import {
6
- getColumn,
7
- getNow,
8
- generateColumn,
9
- getRowId,
10
- } from './utils/selectors';
11
- import s from './component.scss';
12
- import Loading from "./utils/loading";
13
- import DrawingLayer from "./utils/drawingLayer";
14
- import CellBackground from "./cellBackground";
15
- import HeaderRenderer from "./header";
16
- import CellValueRenderer from "./cellValue";
17
-
18
- class CanvasGridComponent extends HTMLElement {
19
- setup() {
20
- this.fps = 30;
21
- this._font = '12px monospace';
22
- this._headerFont = '13px monospace';
23
- this.headerHeight = 30;
24
- this.cellHeight = 20;
25
- this.flashInDuration = 200;
26
- this.flashOutDuration = 500;
27
- this.cellPadding = {
28
- top: 3,
29
- right: 3,
30
- bottom: 3,
31
- left: 3,
32
- };
33
- this.showRowNumbers = true;
34
- this.showHeaders = true;
35
- this.rowNumbersWidth = 30;
36
- this.ellipsis = '…';
37
- this._backgroundColor = '#333';
38
- this._headerBackgroundColor = '#222';
39
- this.charactersToCache = `${Array(200).fill(1).map((a, index) => String.fromCharCode(index)).join('')} ${this.ellipsis}`;
40
- this.textColor = '#efefef';
41
- this._dataCollection = new Collection();
42
- this.prevValues = new Collection();
43
- this.getRowId = getRowId;
44
- this.headers = new Collection();
45
- this.animationFrame = null;
46
- this.scrollYOffset = 0;
47
- this.prevScrollYOffset = 0;
48
- this.scrollXOffset = 0;
49
- this.prevScrollXOffset = 0;
50
- this.backgroundCanvas = document.createElement('canvas');
51
- this.backgroundCanvas.className = classNames(s.drawingLayer, s.background);
52
- this.appendChild(this.backgroundCanvas);
53
- this.canvas = document.createElement('canvas');
54
- this.canvas.className = classNames(s.drawingLayer, s.content);
55
- this.appendChild(this.canvas);
56
- this.headerCanvas = document.createElement('canvas');
57
- this.headerCanvas.className = classNames(s.drawingLayer, s.header);
58
- this.appendChild(this.headerCanvas);
59
- this.scrollArea = document.createElement('div');
60
- this.scrollArea.className = s.scrollArea;
61
- this.scrollHelper = document.createElement('div');
62
- this.scrollArea.appendChild(this.scrollHelper);
63
- this.appendChild(this.scrollArea);
64
-
65
- this.cellBackgroundDrawingLayer = new DrawingLayer({
66
- canvas: this.backgroundCanvas,
67
- renderer: new CellBackground({
68
- canvas: this.backgroundCanvas,
69
- background: this._backgroundColor,
70
- alpha: false,
71
- enableFlashing: true,
72
- flashInDuration: 200,
73
- flashOutDuration: 400,
74
- flashRGB: '214, 144, 13',
75
- borderRightWidth: 1,
76
- borderRightColor: '#3f3f3f',
77
- borderBottomWidth: 1,
78
- borderBottomColor: '#3f3f3f',
79
- }),
80
- });
81
- this.cellValueDrawingLayer = new DrawingLayer({
82
- canvas: this.canvas,
83
- renderer: new CellValueRenderer({
84
- font: this._font,
85
- color: this.textColor,
86
- characters: this.charactersToCache,
87
- canvas: this.canvas,
88
- }),
89
- });
90
- this.headerDrawingLayer = new DrawingLayer({
91
- canvas: this.headerCanvas,
92
- renderer: new HeaderRenderer({
93
- canvas: this.headerCanvas,
94
- font: this._headerFont,
95
- color: this.textColor,
96
- characters: this.charactersToCache,
97
- background: '#222',
98
- borderRightWidth: 1,
99
- borderRightColor: '#2f2f2f',
100
- borderBottomWidth: 1,
101
- borderBottomColor: '#2f2f2f',
102
- }),
103
- });
104
- window.cellBackgroundDrawingLayer = this.cellBackgroundDrawingLayer;
105
- window.cellValueDrawingLayer = this.cellValueDrawingLayer;
106
- window.headerDrawingLayer = this.headerDrawingLayer;
107
- this.loadingIndicator = new Loading({ ctx: this.headerCanvas.getContext('2d') });
108
- this.pendingUpdates = new Collection();
109
- this.pendingRemoves = new Collection();
110
- this.throttleTransation = throttle(() => {
111
- const prevSize = this.totalHeight;
112
- if (this.pendingUpdates.length > 0) {
113
- this.updateValues();
114
- }
115
- if (this.pendingRemoves.length > 0) {
116
- this.removeValues();
117
- }
118
- if (prevSize !== this.totalHeight) {
119
- this.refreshScrollbar();
120
- }
121
- }, 50);
122
-
123
- this.resize = this.resize.bind(this);
124
- this.setValues = this.setValues.bind(this);
125
- this.setColumns = this.setColumns.bind(this);
126
- this.clearValues = this.clearValues.bind(this);
127
- this.updateLastRender = this.updateLastRender.bind(this);
128
- this.renderHeader = this.renderHeader.bind(this);
129
- this.renderCell = this.renderCell.bind(this);
130
- this.transaction = this.transaction.bind(this);
131
- this.queueUpdate = this.queueUpdate.bind(this);
132
-
133
- this.agApi = {
134
- setRowData: this.setValues,
135
- updateRowData: this.transaction,
136
- setColumnDefs: this.setColumns,
137
- };
138
- Object.defineProperty(this.agApi, 'getRowNodeId', {
139
- get: () => this.getRowId,
140
- set: getId => { if (typeof getId === 'function') this.getRowId = getId },
141
- })
142
- }
143
-
144
- set font(font) {
145
- if (this._font !== font) {
146
- this._font = font;
147
- this.cellValueDrawingLayer.renderer.font = font;
148
- }
149
- }
150
-
151
- get font() {
152
- return this._font;
153
- }
154
-
155
- set headerFont(font) {
156
- if (this._headerFont !== font) {
157
- this._headerFont = font;
158
- this.headerDrawingLayer.renderer.font = font;
159
- }
160
- }
161
-
162
- get headerFont() {
163
- return this._headerFont;
164
- }
165
-
166
- connectedCallback() {
167
- this.setup();
168
- this.updateLastRender();
169
- this.resize();
170
- this.setColumns(Array(50).fill(1).map((a, index) => index));
171
-
172
- document.addEventListener('visibilitychange', () => {
173
- switch (document.visibilityState) {
174
- case 'hidden':
175
- cancelAnimationFrame(this.animationFrame);
176
- break;
177
- case 'visible':
178
- default:
179
- this.resize();
180
- }
181
- });
182
-
183
- if (document && document.fonts) {
184
- document.fonts.onloadingdone = () => {
185
- this.cellValueDrawingLayer.clearCache();
186
- this.headerDrawingLayer.clearCache();
187
- this.cellValueDrawingLayer.preWarmCache();
188
- this.headerDrawingLayer.preWarmCache();
189
- this.resize();
190
- };
191
- } else {
192
- setTimeout(() => {
193
- this.cellValueDrawingLayer.clearCache();
194
- this.headerDrawingLayer.clearCache();
195
- this.cellValueDrawingLayer.preWarmCache();
196
- this.headerDrawingLayer.preWarmCache();
197
- this.resize();
198
- }, 2000);
199
- }
200
-
201
- const debounceAfterScroll = debounce(() => {
202
- this.cellValueDrawingLayer.isScrolling = false;
203
- this.cellBackgroundDrawingLayer.isScrolling = false;
204
- this.headerDrawingLayer.isScrolling = false;
205
- }, 200);
206
- const throttledUpdate = throttle((scrollYOffset, scrollXOffset) => {
207
- this.scrollXOffset = Math.round(scrollXOffset);
208
- this.scrollYOffset = Math.round(scrollYOffset);
209
- debounceAfterScroll();
210
- }, 10);
211
- this.scrollArea.addEventListener('scroll', e => {
212
- const { target: { scrollTop, scrollLeft } } = e;
213
- this.cellValueDrawingLayer.isScrolling = true;
214
- this.cellBackgroundDrawingLayer.isScrolling = true;
215
- this.headerDrawingLayer.isScrolling = true;
216
- throttledUpdate(scrollTop, scrollLeft);
217
- });
218
- }
219
-
220
- updateLastRender() {
221
- this.lastRender = new Date().valueOf();
222
- }
223
-
224
- render() {
225
- const delta = new Date().valueOf() - this.lastRender;
226
- if (delta >= (1000 / this.fps)) {
227
- if (this.canvas.width !== this.clientWidth || this.canvas.height !== this.clientHeight) {
228
- this.resize();
229
- }
230
-
231
- this.draw();
232
- this.updateLastRender();
233
- }
234
- this.animationFrame = requestAnimationFrame(() => this.render());
235
- }
236
-
237
- hasScrolled() {
238
- return this.hasXScrolled() || this.hasYScrolled();
239
- }
240
-
241
- hasYScrolled() {
242
- return this.prevScrollYOffset !== this.scrollYOffset;
243
- }
244
-
245
- hasXScrolled() {
246
- return this.prevScrollXOffset !== this.scrollXOffset;
247
- }
248
-
249
- isInViewport(x = 0, y = 0, width = 0, height = 0) {
250
- if (x > this.canvas.width) return false;
251
- if (y > this.canvas.height) return false;
252
- if (x + width < 0) return false;
253
- if (y + height < 0) return false;
254
-
255
- return true;
256
- }
257
-
258
- draw(forced) {
259
- const now = new Date().valueOf();
260
-
261
- if ((forced || this.hasXScrolled()) && this.showHeaders) {
262
- this.renderHeaders();
263
- }
264
-
265
- const fakeRows = 200;
266
- if (forced && this.showRowNumbers && this._dataCollection.length === 0) {
267
- for (let fakeRowIndex= 0; fakeRowIndex <= fakeRows; fakeRowIndex++) {
268
- this.renderRowNumber({ index: fakeRowIndex }, (fakeRowIndex * this.cellHeight) + (this.showHeaders ? this.headerHeight : 0) - this.scrollYOffset);
269
- }
270
- }
271
-
272
- if (this._dataCollection.length === 0) {
273
- this.loadingIndicator.render();
274
- for (let fakeRowIndex= 0; fakeRowIndex <= fakeRows; fakeRowIndex++) {
275
- this.headers.forEach(header => {
276
- header.cellRenderer(
277
- '',
278
- Math.round((header.index * header.width) + (this.showRowNumbers ? this.rowNumbersWidth : 0) - this.scrollXOffset),
279
- Math.round((fakeRowIndex * this.cellHeight) + (this.showHeaders ? this.headerHeight : 0) - this.scrollYOffset),
280
- header.width,
281
- this.cellHeight,
282
- true,
283
- false,
284
- true,
285
- 0
286
- );
287
- });
288
- }
289
- }
290
-
291
- let currentY = Math.round((this.showHeaders ? this.headerHeight : 0) - this.scrollYOffset);
292
- const updateUntil = now - (this.flashInDuration + this.flashOutDuration + 100);
293
- const xOffset = Math.round((this.showRowNumbers ? this.rowNumbersWidth : 0) - this.scrollXOffset);
294
- this._dataCollection.forEach((row, key) => {
295
- const { columns } = row;
296
- let currentX = xOffset;
297
-
298
- if ((forced || this.hasYScrolled()) && this.showRowNumbers) {
299
- this.renderRowNumber(row, currentY);
300
- }
301
-
302
- if (row.height + currentY > 0 && currentY < this.canvas.height) {
303
- if (!this.prevValues.get(key)) {
304
- this.prevValues.set(key, new Collection());
305
- }
306
- const prevRow = this.prevValues.get(key);
307
-
308
- columns.forEach((column, key) => {
309
- const { displayedValue, updatedAt } = column;
310
- const header = this.getColumnHeader(key);
311
- const shouldUpdate = updatedAt > updateUntil;
312
-
313
- if (header) {
314
- const isNotPrev = prevRow[key] !== displayedValue;
315
- if (this.isInViewport(currentX, currentY, header.width, row.height) && (forced || this.hasScrolled() || shouldUpdate)) {
316
- header.cellRenderer(
317
- displayedValue,
318
- currentX,
319
- currentY,
320
- header.width,
321
- row.height,
322
- shouldUpdate || this.hasScrolled() || forced,
323
- isNotPrev,
324
- forced || this.hasScrolled(),
325
- now - updatedAt
326
- );
327
- }
328
- if (isNotPrev) {
329
- prevRow[key] = displayedValue;
330
- }
331
- currentX += Math.round(header.width);
332
- }
333
- });
334
- }
335
- currentY += Math.round(row.height);
336
- });
337
- if (this.scrollYOffset > 0 || this.scrollXOffset > 0) {
338
- this.renderBrick();
339
- }
340
- this.prevScrollYOffset = this.scrollYOffset;
341
- this.prevScrollXOffset = this.scrollXOffset;
342
- }
343
-
344
- renderRowNumber(row, y) {
345
- if (!this.isInViewport(0, y, this.rowNumbersWidth, row.height)) return;
346
- this.headerDrawingLayer.render(
347
- `${row.index + 1}`,
348
- 0,
349
- Math.ceil(y),
350
- this.rowNumbersWidth,
351
- row.height,
352
- true,
353
- true
354
- );
355
- }
356
-
357
- forceDraw() {
358
- this.cellValueDrawingLayer.clear();
359
- this.cellBackgroundDrawingLayer.clear();
360
- this.headerDrawingLayer.clear();
361
- this.draw(true);
362
- }
363
-
364
- resize() {
365
- cancelAnimationFrame(this.animationFrame);
366
- this.canvas.width = this.clientWidth;
367
- this.canvas.height = this.clientHeight;
368
- this.headerCanvas.width = this.clientWidth;
369
- this.headerCanvas.height = this.clientHeight;
370
- this.backgroundCanvas.width = this.clientWidth;
371
- this.backgroundCanvas.height = this.clientHeight;
372
- this.forceDraw();
373
- this.render();
374
- }
375
-
376
- getRowData(rowId) {
377
- return this._dataCollection.get(rowId);
378
- }
379
-
380
- renderBrick() {
381
- if (this.showHeaders && this.showRowNumbers && this._headerBackgroundColor) {
382
- this.headerDrawingLayer.render(
383
- '',
384
- 0,
385
- 0,
386
- this.rowNumbersWidth,
387
- this.headerHeight,
388
- true,
389
- true
390
- );
391
- }
392
- }
393
-
394
- renderHeader(header, x) {
395
- this.headerDrawingLayer.render(
396
- header.displayName,
397
- x,
398
- 0,
399
- header.width,
400
- this.headerHeight,
401
- true,
402
- true
403
- );
404
- }
405
-
406
- renderHeaders() {
407
- let currentX = (this.showRowNumbers ? this.rowNumbersWidth : 0) - this.scrollXOffset;
408
-
409
- this.headers.forEach(header => {
410
- if (this.isInViewport(currentX, 0, header.width, this.headerHeight)) {
411
- header.headerRenderer(header, currentX);
412
- }
413
- currentX += header.width;
414
- });
415
-
416
- if (this.scrollXOffset + this.rowNumbersWidth > 0) {
417
- this.renderBrick();
418
- }
419
- }
420
-
421
- getColumnHeader(key) {
422
- return this.headers.get(key);
423
- }
424
-
425
- get totalHeight() {
426
- let totalHeight = 0;
427
- this._dataCollection.forEach(row => {
428
- totalHeight += row.height;
429
- });
430
- return totalHeight;
431
- }
432
-
433
- refreshScrollbar() {
434
- const height = this.totalHeight + this.headerHeight;
435
- this.scrollHelper.style.height = `${height}px`;
436
- let width = 0;
437
- this.headers.forEach(header => {
438
- width += Math.round(header.width);
439
- });
440
- this.scrollHelper.style.width = `${width}px`;
441
- }
442
-
443
- queueUpdate(row) {
444
- this.pendingUpdates.add(row);
445
- this.throttleTransation();
446
- }
447
-
448
- queueRemove(row) {
449
- this.pendingRemoves.add(row);
450
- this.throttleTransation();
451
- }
452
-
453
- transaction({ add = [], remove = [], update = [] }) {
454
- if (Array.isArray(add)) {
455
- add.forEach(row => this.queueUpdate(row));
456
- }
457
-
458
- if (Array.isArray(update)) {
459
- update.forEach(row => this.queueUpdate(row));
460
- }
461
-
462
- if (Array.isArray(remove)) {
463
- remove.forEach(row => this.queueRemove(row));
464
- }
465
- }
466
-
467
- clearValues() {
468
- this._dataCollection.clear();
469
- this.prevValues.clear();
470
- }
471
-
472
- setValues(data) {
473
- this.throttleTransation.cancel();
474
- this.pendingUpdates.clear();
475
- this.pendingRemoves.clear();
476
- this.clearValues();
477
- if (Array.isArray(data)) {
478
- data.forEach((row, index) => {
479
- const rowId = this.getRowId(row, index);
480
- const columns = new Collection();
481
- Object.keys(row).forEach(key => {
482
- const header = this.headers.get(key);
483
- columns.set(key, generateColumn(row[key], key, null, header.valueFormatter(row[key])));
484
- });
485
- this._dataCollection.set(rowId, { index, height: this.cellHeight, columns });
486
- });
487
- this.refreshScrollbar();
488
- this.forceDraw();
489
- }
490
- }
491
-
492
- removeValues() {
493
- this.pendingRemoves.forEach(row => {
494
- this._dataCollection.delete(this.getRowId(row));
495
- });
496
- this.pendingRemoves.clear();
497
- }
498
-
499
- updateValues() {
500
- const now = getNow();
501
- this.pendingUpdates.forEach(row => {
502
- const rowId = this.getRowId(row);
503
- const currentIndex = this._dataCollection.keys.indexOf(rowId);
504
- const rowData = this.getRowData(rowId);
505
- if (rowData) {
506
- Object.keys(row).forEach(columnKey => {
507
- const columnValue = row[columnKey];
508
- const columnData = getColumn(rowData, columnKey);
509
- const header = this.headers.get(columnKey);
510
- if (columnData) {
511
- if (columnData.value !== columnValue) {
512
- columnData.value = columnValue;
513
- columnData.displayedValue = header.valueFormatter(columnValue);
514
- columnData.updatedAt = now;
515
- }
516
- } else {
517
- rowData.columns.set(columnKey, generateColumn(columnValue, columnKey, null, header.valueFormatter(columnValue)));
518
- }
519
- });
520
- } else {
521
- const columns = new Collection();
522
- Object.keys(row).forEach(key => {
523
- const header = this.headers.get(key);
524
- columns.set(key, generateColumn(row[key], key, now, header.valueFormatter(row[key])));
525
- });
526
- this._dataCollection.set(rowId, { index: currentIndex !== -1 ? currentIndex : this._dataCollection.keys.length, columns: columns });
527
- }
528
- });
529
- this.pendingUpdates.clear();
530
- }
531
-
532
- renderCell(value, x, y, width, height, isUpdated, isValueUpdated, forcedDraw, diff) {
533
- this.cellBackgroundDrawingLayer.render('', x, y, width, height, isUpdated, isValueUpdated, forcedDraw, diff);
534
- this.cellValueDrawingLayer.render(value, x, y, width, height, isUpdated, isValueUpdated, forcedDraw, diff);
535
- }
536
-
537
- setColumns(columns) {
538
- if (Array.isArray(columns)) {
539
- this.headers.clear();
540
- const defaults = {
541
- width: 100,
542
- cellRenderer: this.renderCell,
543
- valueFormatter: v => v + '',
544
- headerRenderer: this.renderHeader,
545
- };
546
- columns.forEach((column, index) => {
547
- if (typeof column === 'string' || typeof column === 'number') {
548
- const columnId = column + '';
549
- this.headers.set(columnId, {
550
- ...defaults,
551
- index: index,
552
- id: column,
553
- displayName: columnId,
554
- });
555
- }
556
- if (typeof column === 'object') {
557
- this.headers.set(column.id + '', {
558
- ...defaults,
559
- index: index,
560
- ...column,
561
- });
562
- }
563
- this.refreshScrollbar();
564
- this.forceDraw();
565
- });
566
- }
567
- }
568
-
569
- disconnectedCallback() {
570
- cancelAnimationFrame(this.animationFrame);
571
- }
572
-
573
- attributeChangedCallback(attrName, oldVal, newVal) {
574
- console.log('attributeChangedCallback', attrName, oldVal, newVal)
575
- }
576
- }
577
-
578
- if (window && window.customElements) {
579
- customElements.define('canvas-grid', CanvasGridComponent);
580
- }
581
-
582
- export default CanvasGridComponent;
@@ -1,36 +0,0 @@
1
- const getHtml = (locals) => {
2
- return `
3
- <!DOCTYPE html>
4
- <html lang="en">
5
- <head>
6
- <meta charset="UTF-8">
7
- <title>Canvas example</title>
8
- <style>
9
- html, body {
10
- box-sizing: border-box;
11
- margin: 0;
12
- padding: 0;
13
- width: 100vw;
14
- height: 100vh;
15
- }
16
- canvas-grid {
17
- position: absolute;
18
- top: 0;
19
- left: 0;
20
- width: 100%;
21
- height: 100%;
22
- }
23
- </style>
24
- <link href="https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap" rel="stylesheet" />
25
- <link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
26
- <script type="application/javascript" src="${locals.assets.example}"></script>
27
- </head>
28
- <body>
29
- <canvas-grid></canvas-grid>
30
- </body>
31
- </html>`;
32
- };
33
-
34
- export default function htmlGenerator(locals) {
35
- return getHtml(locals);
36
- };
package/nodemon.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "watch": [
3
- "server/example.js"
4
- ]
5
- }
package/public/index.html DELETED
@@ -1,29 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Canvas example</title>
6
- <style>
7
- html, body {
8
- box-sizing: border-box;
9
- margin: 0;
10
- padding: 0;
11
- width: 100vw;
12
- height: 100vh;
13
- }
14
-
15
- canvas-grid {
16
- position: absolute;
17
- top: 0;
18
- left: 0;
19
- width: 100%;
20
- height: 100%;
21
- }
22
- </style>
23
- <link href="https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap" rel="stylesheet"/>
24
- <script type="application/javascript" src="../components/example.js"></script>
25
- </head>
26
- <body>
27
- <canvas-grid></canvas-grid>
28
- </body>
29
- </html>
package/scripts/build.js DELETED
@@ -1,30 +0,0 @@
1
- const { resolve } = require('path');
2
- const { existsSync } = require('fs');
3
- const { removeSync } = require('fs-extra');
4
- const webpack = require('webpack');
5
-
6
- process.env.BABEL_ENV = 'production';
7
- process.env.NODE_ENV = 'production';
8
-
9
- require('dotenv').config();
10
-
11
- const config = require('../webpack.config');
12
-
13
- if (existsSync(resolve(__dirname, '../build'))) {
14
- removeSync(resolve(__dirname, '../build'))
15
- }
16
-
17
- process.on('unhandledRejection', err => {
18
- throw err
19
- });
20
-
21
- const logger = (err, stats) => {
22
- console.log(stats.toString({
23
- colors: true,
24
- errors: true,
25
- errorDetails: true,
26
- warnings: true,
27
- }));
28
- };
29
-
30
- webpack(config, logger);