@bitbybit-dev/base 0.19.0-alpha.0

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/babel.config.cjs +14 -0
  4. package/babel.config.d.cts +5 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +4 -0
  7. package/lib/api/index.d.ts +1 -0
  8. package/lib/api/index.js +1 -0
  9. package/lib/api/inputs/base-inputs.d.ts +35 -0
  10. package/lib/api/inputs/base-inputs.js +1 -0
  11. package/lib/api/inputs/color-inputs.d.ts +122 -0
  12. package/lib/api/inputs/color-inputs.js +164 -0
  13. package/lib/api/inputs/index.d.ts +8 -0
  14. package/lib/api/inputs/index.js +8 -0
  15. package/lib/api/inputs/inputs.d.ts +10 -0
  16. package/lib/api/inputs/inputs.js +10 -0
  17. package/lib/api/inputs/lists-inputs.d.ts +478 -0
  18. package/lib/api/inputs/lists-inputs.js +576 -0
  19. package/lib/api/inputs/logic-inputs.d.ts +163 -0
  20. package/lib/api/inputs/logic-inputs.js +111 -0
  21. package/lib/api/inputs/math-inputs.d.ts +311 -0
  22. package/lib/api/inputs/math-inputs.js +391 -0
  23. package/lib/api/inputs/point-inputs.d.ts +446 -0
  24. package/lib/api/inputs/point-inputs.js +521 -0
  25. package/lib/api/inputs/text-inputs.d.ts +83 -0
  26. package/lib/api/inputs/text-inputs.js +120 -0
  27. package/lib/api/inputs/transforms-inputs.d.ts +136 -0
  28. package/lib/api/inputs/transforms-inputs.js +200 -0
  29. package/lib/api/inputs/vector-inputs.d.ts +300 -0
  30. package/lib/api/inputs/vector-inputs.js +304 -0
  31. package/lib/api/services/color.d.ts +114 -0
  32. package/lib/api/services/color.js +170 -0
  33. package/lib/api/services/geometry-helper.d.ts +15 -0
  34. package/lib/api/services/geometry-helper.js +151 -0
  35. package/lib/api/services/index.d.ts +9 -0
  36. package/lib/api/services/index.js +9 -0
  37. package/lib/api/services/lists.d.ts +287 -0
  38. package/lib/api/services/lists.js +682 -0
  39. package/lib/api/services/logic.d.ts +99 -0
  40. package/lib/api/services/logic.js +203 -0
  41. package/lib/api/services/math.d.ts +349 -0
  42. package/lib/api/services/math.js +621 -0
  43. package/lib/api/services/point.d.ts +223 -0
  44. package/lib/api/services/point.js +351 -0
  45. package/lib/api/services/text.d.ts +69 -0
  46. package/lib/api/services/text.js +84 -0
  47. package/lib/api/services/transforms.d.ts +122 -0
  48. package/lib/api/services/transforms.js +256 -0
  49. package/lib/api/services/vector.d.ts +320 -0
  50. package/lib/api/services/vector.js +468 -0
  51. package/lib/index.d.ts +1 -0
  52. package/lib/index.js +1 -0
  53. package/package.json +93 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Bit By Bit Developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ ## Bit By Bit Developers Base Algorithms for CAD library
2
+
3
+ <img src="https://app.bitbybit.dev/assets/git-cover.png" alt="Picture showing bitbybit.dev platform">
4
+
5
+ This genericc package contains base algorithms for our CAD platform. It has various helper functions for math, text, lists, vectors, matrix operations. It also contains some base types used accross bitbybit.dev platform on higher levels. This layer should be kept as lightweight as possible and ideally not contain any third-party dependencies as they just add to the weight and complexity.
6
+
7
+ This package is already used or will be used in these packages:
8
+
9
+ @bitbybit-dev/occt
10
+ @bitbybit-dev/occt-worker
11
+ @bitbybit-dev/jscad
12
+ @bitbybit-dev/jscad-worker
13
+ @bitbybit-dev/manifold
14
+ @bitbybit-dev/manifold-worker
15
+ @bitbybit-dev/core
16
+ @bitbybit-dev/babylonjs
17
+ @bitbybit-dev/threejs
18
+
19
+ This package should work in Node and browser based applications and should provide generic layer which could be helpful to all higher-level CAD algorithms and kernels. Algorithms of this base layer are also exposed on our bitbybit.dev Rete, Blockly & Monaco editors.
20
+
21
+ Visit https://bitbybit.dev to use our full cloud platform.
22
+
23
+ ## Github
24
+ https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/base
25
+ ## NPM
26
+ https://www.npmjs.com/package/@bitbybit-dev/base
27
+
28
+ ## THREEJS Example Applications
29
+ Vase
30
+ https://app-store.bitbybit.dev/vase
31
+ Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/threejs/vase
32
+
33
+ ## Other Example Applications
34
+ Laptop Holder
35
+ https://app-store.bitbybit.dev/laptop-holder
36
+ Github Source Code Angular - https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder
37
+ Github Source Code React - https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder
38
+
39
+ Cup Configurator
40
+ https://app-store.bitbybit.dev/cup
41
+ Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/cup
42
+
43
+ ## Closed Source Example Applications
44
+ https://app-store.bitbybit.dev/terrace-furniture
45
+
46
+ ## Build package
47
+ npm run build-p
48
+
49
+ ## Run unit tests and generate test coverage
50
+ npm run test-c
51
+
52
+ ## Run live unit tests and generate test coverage on save
53
+ npm run test-c-l
54
+
55
+ ## Unit test coverage report online
56
+ https://tests.bitbybit.dev/threejs
57
+
58
+ ## Media Channels
59
+ Discord: https://discord.gg/GSe3VMe
60
+ Youtube: https://www.youtube.com/@bitbybitdev?sub_confirmation=1
61
+ Instagram: https://www.instagram.com/bitbybit.dev
62
+ Twitter: https://twitter.com/bitbybit_dev
63
+ LinkedIn: https://lnkd.in/gQjEQA2
64
+ Facebook: https://www.facebook.com/bitbybitdev
65
+ Medium: https://bitbybit-dev.medium.com/
66
+
67
+ ## Principles
68
+ Bit By Bit Developers company will keep these core algorithms that you can find in this repository free and opensource for its users. These algorithms are based on other open-source projects, run and are deployed on the browser, thus there is no point of closing them down from public.
69
+
70
+ ## About Bit By Bit Developers platform
71
+ Bit By Bit Developers web platform allows creators to program geometry through simple visual programming language or choose monaco typescript editor with full intellisense of bitbybit API. This cloud platform can fulfil many practical, educational and artistic needs of its users. Through familiar programming interface used in tools such as Scratch and Blockly.Games we expose powerful 3D algorithms that make it easier to implement various parametric tasks. Our goal is to make it very simple for users to share their ideas and designs. We want to encourage everyone to engage in the future of this tool.
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ presets: [
3
+ [
4
+ '@babel/preset-env',
5
+ {
6
+ targets: {
7
+ node: 'current',
8
+ },
9
+ },
10
+ ],
11
+ '@babel/preset-typescript'
12
+ ],
13
+ };
14
+ export {};
@@ -0,0 +1,5 @@
1
+ export const presets: (string | (string | {
2
+ targets: {
3
+ node: string;
4
+ };
5
+ })[])[];
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./lib";
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Public API Surface of bitbybit-core
3
+ */
4
+ export * from "./lib";
@@ -0,0 +1 @@
1
+ export * from "./services";
@@ -0,0 +1 @@
1
+ export * from "./services";
@@ -0,0 +1,35 @@
1
+ export declare namespace Base {
2
+ type Color = string;
3
+ type ColorRGB = {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ };
8
+ type Material = any;
9
+ type Point2 = [number, number];
10
+ type Vector2 = [number, number];
11
+ type Point3 = [number, number, number];
12
+ type Vector3 = [number, number, number];
13
+ type Line2 = {
14
+ start: Base.Point2;
15
+ end: Base.Point2;
16
+ };
17
+ type Line3 = {
18
+ start: Base.Point3;
19
+ end: Base.Point3;
20
+ };
21
+ type Polyline3 = {
22
+ points: Base.Point3[];
23
+ isClosed?: boolean;
24
+ color?: number[];
25
+ };
26
+ type Polyline2 = {
27
+ points: Base.Point2[];
28
+ isClosed?: boolean;
29
+ color?: number[];
30
+ };
31
+ type TransformMatrix3x3 = [number, number, number, number, number, number, number, number, number];
32
+ type TransformMatrixes3x3 = TransformMatrix3x3[];
33
+ type TransformMatrix = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
34
+ type TransformMatrixes = TransformMatrix[];
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ import { Base } from "./base-inputs";
2
+ export declare namespace Color {
3
+ class HexDto {
4
+ constructor(color?: Base.Color);
5
+ /**
6
+ * Color hex
7
+ * @default #0000ff
8
+ */
9
+ color: Base.Color;
10
+ }
11
+ class InvertHexDto {
12
+ constructor(color?: Base.Color);
13
+ /**
14
+ * Color hex
15
+ * @default #0000ff
16
+ */
17
+ color: Base.Color;
18
+ /**
19
+ * Choose to invert the color to black and white (useful for text color)
20
+ */
21
+ blackAndWhite: boolean;
22
+ }
23
+ class HexDtoMapped {
24
+ constructor(color?: Base.Color, from?: number, to?: number);
25
+ /**
26
+ * Color hex
27
+ * @default #0000ff
28
+ */
29
+ color: Base.Color;
30
+ /**
31
+ * From min bound
32
+ * @default 0
33
+ * @minimum -Infinity
34
+ * @maximum Infinity
35
+ * @step 1
36
+ */
37
+ from: number;
38
+ /**
39
+ * To max bound
40
+ * @default 255
41
+ * @minimum -Infinity
42
+ * @maximum Infinity
43
+ * @step 1
44
+ */
45
+ to: number;
46
+ }
47
+ class RGBObjectMaxDto {
48
+ constructor(rgb?: Base.ColorRGB, max?: number);
49
+ /**
50
+ * Red value component
51
+ * @default undefined
52
+ */
53
+ rgb: Base.ColorRGB;
54
+ /**
55
+ * Min value of the range
56
+ * @default 0
57
+ * @minimum 0
58
+ * @maximum 255
59
+ * @step 0.1
60
+ */
61
+ min: number;
62
+ /**
63
+ * Max value, it would automatically be remapped to whatever is needed if lower comes in
64
+ * @default 255
65
+ * @minimum 0
66
+ * @maximum 255
67
+ * @step 0.1
68
+ */
69
+ max: number;
70
+ }
71
+ class RGBMinMaxDto {
72
+ constructor(r?: number, g?: number, b?: number, min?: number, max?: number);
73
+ /**
74
+ * Red value component
75
+ * @default 255
76
+ * @minimum 0
77
+ * @maximum 255
78
+ * @step 1
79
+ */
80
+ r: number;
81
+ /**
82
+ * Green value component
83
+ * @default 255
84
+ * @minimum 0
85
+ * @maximum 255
86
+ * @step 1
87
+ */
88
+ g: number;
89
+ /**
90
+ * Blue value component
91
+ * @default 255
92
+ * @minimum 0
93
+ * @maximum 255
94
+ * @step 1
95
+ */
96
+ b: number;
97
+ /**
98
+ * Min value of the range
99
+ * @default 0
100
+ * @minimum 0
101
+ * @maximum 255
102
+ * @step 0.1
103
+ */
104
+ min: number;
105
+ /**
106
+ * Max value of the range
107
+ * @default 255
108
+ * @minimum 0
109
+ * @maximum 255
110
+ * @step 0.1
111
+ */
112
+ max: number;
113
+ }
114
+ class RGBObjectDto {
115
+ constructor(rgb?: Base.ColorRGB);
116
+ /**
117
+ * Red value component
118
+ * @default undefined
119
+ */
120
+ rgb: Base.ColorRGB;
121
+ }
122
+ }
@@ -0,0 +1,164 @@
1
+ // tslint:disable-next-line: no-namespace
2
+ export var Color;
3
+ (function (Color) {
4
+ class HexDto {
5
+ constructor(color) {
6
+ /**
7
+ * Color hex
8
+ * @default #0000ff
9
+ */
10
+ this.color = "#0000ff";
11
+ if (color !== undefined) {
12
+ this.color = color;
13
+ }
14
+ }
15
+ }
16
+ Color.HexDto = HexDto;
17
+ class InvertHexDto {
18
+ constructor(color) {
19
+ /**
20
+ * Color hex
21
+ * @default #0000ff
22
+ */
23
+ this.color = "#0000ff";
24
+ /**
25
+ * Choose to invert the color to black and white (useful for text color)
26
+ */
27
+ this.blackAndWhite = false;
28
+ if (color !== undefined) {
29
+ this.color = color;
30
+ }
31
+ }
32
+ }
33
+ Color.InvertHexDto = InvertHexDto;
34
+ class HexDtoMapped {
35
+ constructor(color, from, to) {
36
+ /**
37
+ * Color hex
38
+ * @default #0000ff
39
+ */
40
+ this.color = "#0000ff";
41
+ /**
42
+ * From min bound
43
+ * @default 0
44
+ * @minimum -Infinity
45
+ * @maximum Infinity
46
+ * @step 1
47
+ */
48
+ this.from = 0;
49
+ /**
50
+ * To max bound
51
+ * @default 255
52
+ * @minimum -Infinity
53
+ * @maximum Infinity
54
+ * @step 1
55
+ */
56
+ this.to = 255;
57
+ if (color !== undefined) {
58
+ this.color = color;
59
+ }
60
+ if (from !== undefined) {
61
+ this.from = from;
62
+ }
63
+ if (to !== undefined) {
64
+ this.to = to;
65
+ }
66
+ }
67
+ }
68
+ Color.HexDtoMapped = HexDtoMapped;
69
+ class RGBObjectMaxDto {
70
+ constructor(rgb, max) {
71
+ /**
72
+ * Min value of the range
73
+ * @default 0
74
+ * @minimum 0
75
+ * @maximum 255
76
+ * @step 0.1
77
+ */
78
+ this.min = 0;
79
+ /**
80
+ * Max value, it would automatically be remapped to whatever is needed if lower comes in
81
+ * @default 255
82
+ * @minimum 0
83
+ * @maximum 255
84
+ * @step 0.1
85
+ */
86
+ this.max = 255;
87
+ if (rgb !== undefined) {
88
+ this.rgb = rgb;
89
+ }
90
+ if (max !== undefined) {
91
+ this.max = max;
92
+ }
93
+ }
94
+ }
95
+ Color.RGBObjectMaxDto = RGBObjectMaxDto;
96
+ class RGBMinMaxDto {
97
+ constructor(r, g, b, min, max) {
98
+ /**
99
+ * Red value component
100
+ * @default 255
101
+ * @minimum 0
102
+ * @maximum 255
103
+ * @step 1
104
+ */
105
+ this.r = 255;
106
+ /**
107
+ * Green value component
108
+ * @default 255
109
+ * @minimum 0
110
+ * @maximum 255
111
+ * @step 1
112
+ */
113
+ this.g = 255;
114
+ /**
115
+ * Blue value component
116
+ * @default 255
117
+ * @minimum 0
118
+ * @maximum 255
119
+ * @step 1
120
+ */
121
+ this.b = 255;
122
+ /**
123
+ * Min value of the range
124
+ * @default 0
125
+ * @minimum 0
126
+ * @maximum 255
127
+ * @step 0.1
128
+ */
129
+ this.min = 0;
130
+ /**
131
+ * Max value of the range
132
+ * @default 255
133
+ * @minimum 0
134
+ * @maximum 255
135
+ * @step 0.1
136
+ */
137
+ this.max = 255;
138
+ if (r !== undefined) {
139
+ this.r = r;
140
+ }
141
+ if (g !== undefined) {
142
+ this.g = g;
143
+ }
144
+ if (b !== undefined) {
145
+ this.b = b;
146
+ }
147
+ if (min !== undefined) {
148
+ this.min = min;
149
+ }
150
+ if (max !== undefined) {
151
+ this.max = max;
152
+ }
153
+ }
154
+ }
155
+ Color.RGBMinMaxDto = RGBMinMaxDto;
156
+ class RGBObjectDto {
157
+ constructor(rgb) {
158
+ if (rgb !== undefined) {
159
+ this.rgb = rgb;
160
+ }
161
+ }
162
+ }
163
+ Color.RGBObjectDto = RGBObjectDto;
164
+ })(Color || (Color = {}));
@@ -0,0 +1,8 @@
1
+ export * from "./color-inputs";
2
+ export * from "./lists-inputs";
3
+ export * from "./logic-inputs";
4
+ export * from "./math-inputs";
5
+ export * from "./point-inputs";
6
+ export * from "./text-inputs";
7
+ export * from "./vector-inputs";
8
+ export * from "./transforms-inputs";
@@ -0,0 +1,8 @@
1
+ export * from "./color-inputs";
2
+ export * from "./lists-inputs";
3
+ export * from "./logic-inputs";
4
+ export * from "./math-inputs";
5
+ export * from "./point-inputs";
6
+ export * from "./text-inputs";
7
+ export * from "./vector-inputs";
8
+ export * from "./transforms-inputs";
@@ -0,0 +1,10 @@
1
+ export * from "./color-inputs";
2
+ export * from "./lists-inputs";
3
+ export * from "./logic-inputs";
4
+ export * from "./math-inputs";
5
+ export * from "./point-inputs";
6
+ export * from "./text-inputs";
7
+ export * from "./base-inputs";
8
+ export * from "./text-inputs";
9
+ export * from "./vector-inputs";
10
+ export * from "./transforms-inputs";
@@ -0,0 +1,10 @@
1
+ export * from "./color-inputs";
2
+ export * from "./lists-inputs";
3
+ export * from "./logic-inputs";
4
+ export * from "./math-inputs";
5
+ export * from "./point-inputs";
6
+ export * from "./text-inputs";
7
+ export * from "./base-inputs";
8
+ export * from "./text-inputs";
9
+ export * from "./vector-inputs";
10
+ export * from "./transforms-inputs";