@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,66 +0,0 @@
1
- import Renderer from "./renderer";
2
-
3
- class DrawingLayer {
4
- constructor(options = {}) {
5
- this.options = {
6
- ...DrawingLayer.defaultOptions,
7
- ...options,
8
- };
9
- if (this.options.canvas) {
10
- this.ctx = this.options.canvas.getContext('2d', { alpha: this.options.alpha });
11
- }
12
-
13
- if (this.options.renderer) {
14
- this.renderer = this.options.renderer;
15
- this.render = this.renderer.render;
16
- } else {
17
- console.warn('No renderer specified for drawing layer.');
18
- this.renderer = new Renderer();
19
- }
20
-
21
- if (this.renderer.clearCache) {
22
- this.clearCache = this.renderer.clearCache;
23
- }
24
- if (this.renderer.preWarmCache) {
25
- this.preWarmCache = this.renderer.preWarmCache;
26
- }
27
-
28
- this.clear = this.clear.bind(this);
29
- }
30
-
31
- set isScrolling(isScrolling) {
32
- this._isScrolling = isScrolling;
33
- this.renderer.isScrolling = isScrolling;
34
- }
35
-
36
- get isScrolling() {
37
- return this._isScrolling;
38
- }
39
-
40
- clearCache() {
41
-
42
- }
43
-
44
- preWarmCache() {
45
-
46
- }
47
-
48
- clear () {
49
- this.ctx.clearRect(0, 0, this.options.canvas.width, this.options.canvas.height);
50
- }
51
-
52
- render(value = '', x = 0, y = 0, width = 0, height = 0, isUpdated = false, isValueUpdated = false, forcedDraw = false, diff = 0) {
53
-
54
- }
55
- }
56
-
57
- DrawingLayer.defaultOptions = {
58
- /** @param {HTMLElement} */
59
- host: null,
60
- /** @param {HTMLCanvasElement} */
61
- canvas: null,
62
- alpha: true,
63
- renderer: null,
64
- };
65
-
66
- export default DrawingLayer;
@@ -1,57 +0,0 @@
1
- import Collection from "./collection";
2
-
3
- /**
4
- * @typedef Attributes
5
- * @property {String} [key]
6
- **/
7
-
8
-
9
- /**
10
- * @type {{cache: Collection, invalidateCache(*=): void, createElement(Renderer, Attributes, Array<Renderer>): HTMLCanvasElement}}
11
- */
12
- const JSX = {
13
- cache: new Collection(),
14
- invalidateCache(matcher) {
15
- JSX.cache.clear(matcher);
16
- },
17
- bufferNode: document.createElement('canvas'),
18
- /**
19
- * @param {Renderer} renderer
20
- * @param {Attributes} attrs
21
- * @param {Array<Renderer>} children
22
- * */
23
- createElement(renderer, attrs, children) {
24
- const canvas = renderer.render(attrs);
25
-
26
- if (attrs && attrs.key !== undefined) {
27
- const buffer = JSX.bufferNode.cloneNode();
28
- const key = attrs.key;
29
- const cached = JSX.cache.get(key);
30
- if (cached && cached.renderer === renderer) return cached.buffer;
31
-
32
- if (canvas.width > 0 && canvas.height > 0) {
33
- buffer.width = canvas.width;
34
- buffer.height = canvas.height;
35
- const ctx = buffer.getContext('2d');
36
- ctx.drawImage(canvas, 0, 0);
37
- JSX.cache.set(key, { renderer, buffer, cached: Date.now() });
38
- // TODO: automatic invalidation?
39
- // setTimeout(( )=> {
40
- // JSX.cache.delete(key);
41
- // }, 5000)
42
- }
43
- }
44
-
45
- // TODO: child element rendering
46
- // if (Array.isArray(children)) {
47
- // children.forEach(child => {
48
- // const result = JSX.createElement();
49
- // ctx.drawImage(canvas, 0, 0);
50
- // })
51
- // }
52
-
53
- return canvas;
54
- }
55
- };
56
-
57
- export default JSX;
@@ -1,58 +0,0 @@
1
- import Renderer from "./renderer";
2
-
3
- class Loading extends Renderer {
4
- constructor(options) {
5
- super(options);
6
-
7
- this.ctx = this.options.ctx;
8
-
9
- this.offCanvas = document.createElement('canvas');
10
- this.offCanvas.width = 250;
11
- this.offCanvas.height = 250;
12
- this.offCtx = this.offCanvas.getContext('2d');
13
- this.offCtx.lineWidth = 0.5;
14
- this.offCtx.strokeStyle = 'rgba(255, 255, 255, 0.75)';
15
- this.rotation = 270 * (Math.PI / 180);
16
- this.speed = 6;
17
- this.count = 75;
18
-
19
- this.updateLoader = this.updateLoader.bind(this);
20
- this.renderLoader = this.renderLoader.bind(this);
21
- this.render = this.render.bind(this);
22
- }
23
-
24
- updateLoader() {
25
- this.rotation += this.speed / 100;
26
- }
27
-
28
- renderLoader() {
29
- this.offCtx.save();
30
- this.offCtx.globalCompositeOperation = 'source-over';
31
- this.offCtx.translate(125, 125);
32
- this.offCtx.rotate(this.rotation);
33
- let i = this.count;
34
- while (i--) {
35
- this.offCtx.beginPath();
36
- this.offCtx.arc(0, 0, i + (Math.random() * 35), Math.random(), Math.PI / 3 + (Math.random() / 12), false);
37
- this.offCtx.stroke();
38
- }
39
- this.offCtx.restore();
40
- }
41
-
42
- render() {
43
- this.offCtx.globalCompositeOperation = "destination-out";
44
- this.offCtx.fillStyle = "rgba(255, 255, 255, 0.03)";
45
- this.offCtx.fillRect(0, 0, 250, 250);
46
- this.updateLoader();
47
- this.renderLoader();
48
-
49
- const x = Math.round((this.ctx.canvas.width - this.offCanvas.width) / 2);
50
- const y = Math.round((this.ctx.canvas.height - this.offCanvas.height) / 2);
51
- this.ctx.clearRect(x, y, 250, 250);
52
- this.ctx.drawImage(this.offCanvas, x, y);
53
-
54
- return this.offCanvas;
55
- }
56
- }
57
-
58
- export default Loading;
@@ -1,45 +0,0 @@
1
- class Renderer {
2
- constructor(options = {}) {
3
- this._actualOptions = {
4
- ...this.constructor.defaultOptions,
5
- ...options,
6
- };
7
- this._options = {};
8
- Object.keys(this._actualOptions).forEach(key => {
9
- Object.defineProperty(this._options, key, {
10
- get: () => this._actualOptions[key],
11
- set: v => {
12
- const prevOptions = { ...this._actualOptions };
13
- this._actualOptions[key] = v;
14
- this.optionsUpdated(prevOptions);
15
- }
16
- })
17
- });
18
-
19
- this.optionsUpdated = this.optionsUpdated.bind(this);
20
- }
21
-
22
- set options(options) {
23
- Object.keys(options).forEach(key => {
24
- this._options[key] = options[key];
25
- });
26
- }
27
-
28
- get options() {
29
- return this._options;
30
- }
31
-
32
- optionsUpdated() {}
33
-
34
- clearCache() {}
35
-
36
- preWarmCache() {}
37
-
38
- render(value = '', x = 0, y = 0, width = 0, height = 0, isUpdated = false, isValueUpdated = false, forcedDraw = false, diff = 0) {
39
-
40
- }
41
- }
42
-
43
- Renderer.defaultOptions = {};
44
-
45
- export default Renderer;
@@ -1,13 +0,0 @@
1
- export const getColumn = (row, key) => row.columns.get(key);
2
-
3
- export const getNow = () => new Date().valueOf();
4
-
5
-
6
- export const generateColumn = (value, key, updatedAt, displayedValue) => ({
7
- column: key,
8
- value: value,
9
- displayedValue: displayedValue,
10
- updatedAt: updatedAt ? updatedAt : null,
11
- });
12
-
13
- export const getRowId = (row, index) => row.id;