@oliversalzburg/js-utils 0.0.6 → 0.0.8

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 (56) hide show
  1. package/LICENSES.md +17 -0
  2. package/lib/dom/core.d.ts +12 -0
  3. package/lib/dom/core.js +23 -0
  4. package/lib/dom/core.js.map +1 -0
  5. package/lib/dom/index.d.ts +1 -0
  6. package/lib/dom/index.js +2 -0
  7. package/lib/dom/index.js.map +1 -0
  8. package/lib/error-serializer.js +1 -2
  9. package/lib/error-serializer.js.map +1 -1
  10. package/lib/error-serializer.test.d.ts +1 -0
  11. package/lib/error-serializer.test.js +117 -0
  12. package/lib/error-serializer.test.js.map +1 -0
  13. package/lib/graphics/canvas.d.ts +21 -0
  14. package/lib/graphics/canvas.js +21 -0
  15. package/lib/graphics/canvas.js.map +1 -1
  16. package/lib/graphics/render-loop.d.ts +21 -3
  17. package/lib/graphics/render-loop.js +25 -2
  18. package/lib/graphics/render-loop.js.map +1 -1
  19. package/lib/index.d.ts +1 -0
  20. package/lib/index.js +1 -0
  21. package/lib/index.js.map +1 -1
  22. package/lib/math/core.js +1 -1
  23. package/lib/math/core.js.map +1 -1
  24. package/lib/math/index.d.ts +2 -0
  25. package/lib/math/index.js +2 -0
  26. package/lib/math/index.js.map +1 -1
  27. package/lib/math/vector.d.ts +2 -33
  28. package/lib/math/vector.js +2 -41
  29. package/lib/math/vector.js.map +1 -1
  30. package/lib/math/vector2.d.ts +164 -0
  31. package/lib/math/vector2.js +255 -0
  32. package/lib/math/vector2.js.map +1 -0
  33. package/lib/math/vector3.d.ts +45 -0
  34. package/lib/math/vector3.js +58 -0
  35. package/lib/math/vector3.js.map +1 -0
  36. package/lib/random.d.ts +6 -3
  37. package/lib/random.js +15 -12
  38. package/lib/random.js.map +1 -1
  39. package/package.json +13 -13
  40. package/docs/README.md +0 -3
  41. package/docs/classes/AbstractError.md +0 -271
  42. package/docs/classes/Canvas.md +0 -177
  43. package/docs/classes/InternalError.md +0 -301
  44. package/docs/classes/InvalidArgumentError.md +0 -277
  45. package/docs/classes/InvalidOperationError.md +0 -277
  46. package/docs/classes/NotImplementedError.md +0 -276
  47. package/docs/classes/PermissionViolationError.md +0 -277
  48. package/docs/classes/Random.md +0 -109
  49. package/docs/classes/RenderLoop.md +0 -49
  50. package/docs/classes/ResourceConflictError.md +0 -276
  51. package/docs/classes/UnexpectedNilError.md +0 -169
  52. package/docs/classes/UnknownError.md +0 -280
  53. package/docs/classes/Vector2.md +0 -79
  54. package/docs/classes/Vector3.md +0 -106
  55. package/docs/modules.md +0 -1313
  56. package/typedoc.json +0 -8
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@oliversalzburg/js-utils",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "license": "MIT",
6
6
  "author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
7
7
  "type": "module",
8
8
  "exports": {
9
- ".": {
10
- "default": "./lib/index.js"
11
- }
9
+ ".": "./lib/index.js",
10
+ "./lib": "./lib/index.js",
11
+ "./lib/*": "./lib/*.js",
12
+ "./lib/*.js": "./lib/*.js"
12
13
  },
13
14
  "scripts": {
14
15
  "build": "yarn run build:tsc",
15
16
  "build:esbuild": "node build.js",
16
17
  "build:tsc": "tsc",
17
- "docs:typedoc": "typedoc --plugin typedoc-plugin-markdown",
18
+ "docs:typedoc": "typedoc",
18
19
  "lint": "yarn run lint:eslint && yarn run lint:prettier && yarn run lint:tsc",
19
20
  "lint:eslint": "eslint source ./*js",
20
21
  "lint:prettier": "prettier --check source ./*js",
@@ -30,14 +31,14 @@
30
31
  },
31
32
  "types": "./lib/index.d.ts",
32
33
  "devDependencies": {
33
- "@types/chai": "4.3.9",
34
- "@types/chai-as-promised": "7.1.7",
35
- "@types/eslint": "8.44.6",
36
- "@types/mocha": "10.0.3",
37
- "@types/node": "20.8.10",
34
+ "@types/chai": "4.3.10",
35
+ "@types/chai-as-promised": "7.1.8",
36
+ "@types/eslint": "8.44.7",
37
+ "@types/mocha": "10.0.4",
38
+ "@types/node": "20.9.0",
38
39
  "@types/web": "0.0.119",
39
- "@typescript-eslint/eslint-plugin": "6.9.1",
40
- "@typescript-eslint/parser": "6.9.1",
40
+ "@typescript-eslint/eslint-plugin": "6.10.0",
41
+ "@typescript-eslint/parser": "6.10.0",
41
42
  "c8": "8.0.1",
42
43
  "chai": "4.3.10",
43
44
  "chai-as-promised": "7.1.1",
@@ -50,7 +51,6 @@
50
51
  "prettier-package-json": "2.8.0",
51
52
  "prettier-plugin-organize-imports": "3.2.3",
52
53
  "typedoc": "0.25.3",
53
- "typedoc-plugin-markdown": "3.17.0",
54
54
  "typescript": "5.2.2"
55
55
  },
56
56
  "packageManager": "yarn@4.0.1"
package/docs/README.md DELETED
@@ -1,3 +0,0 @@
1
- @oliversalzburg/js-utils / [Exports](modules.md)
2
-
3
- # JS Utils
@@ -1,271 +0,0 @@
1
- [@oliversalzburg/js-utils](../README.md) / [Exports](../modules.md) / AbstractError
2
-
3
- # Class: AbstractError
4
-
5
- Base class for all errors.
6
-
7
- ## Hierarchy
8
-
9
- - `Error`
10
-
11
- ↳ **`AbstractError`**
12
-
13
- ↳↳ [`InternalError`](InternalError.md)
14
-
15
- ↳↳ [`InvalidArgumentError`](InvalidArgumentError.md)
16
-
17
- ↳↳ [`InvalidOperationError`](InvalidOperationError.md)
18
-
19
- ↳↳ [`NotImplementedError`](NotImplementedError.md)
20
-
21
- ↳↳ [`PermissionViolationError`](PermissionViolationError.md)
22
-
23
- ↳↳ [`ResourceConflictError`](ResourceConflictError.md)
24
-
25
- ↳↳ [`UnknownError`](UnknownError.md)
26
-
27
- ## Constructors
28
-
29
- ### constructor
30
-
31
- • **new AbstractError**(`code`, `message`, `status`): [`AbstractError`](AbstractError.md)
32
-
33
- Constructs a new [AbstractError](AbstractError.md).
34
-
35
- #### Parameters
36
-
37
- | Name | Type | Description |
38
- | :-------- | :------- | :------------------------------------------ |
39
- | `code` | `string` | The main identification code for the error. |
40
- | `message` | `string` | The main error message. |
41
- | `status` | `number` | The HTTP status code to return. |
42
-
43
- #### Returns
44
-
45
- [`AbstractError`](AbstractError.md)
46
-
47
- #### Overrides
48
-
49
- Error.constructor
50
-
51
- #### Defined in
52
-
53
- [errors/AbstractError.ts:37](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L37)
54
-
55
- ## Properties
56
-
57
- ### cause
58
-
59
- • `Optional` **cause**: `unknown`
60
-
61
- #### Inherited from
62
-
63
- Error.cause
64
-
65
- #### Defined in
66
-
67
- ../node_modules/typescript/lib/lib.es2022.error.d.ts:24
68
-
69
- ---
70
-
71
- ### code
72
-
73
- • **code**: `string`
74
-
75
- An application-unique, readable error code.
76
-
77
- #### Defined in
78
-
79
- [errors/AbstractError.ts:29](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L29)
80
-
81
- ---
82
-
83
- ### info
84
-
85
- • **info**: [`Maybe`](../modules.md#maybe)\<`string`\>
86
-
87
- A user-friendly error message that may be transported to the client.
88
-
89
- **`Deprecated`**
90
-
91
- User-friendly errors should be read from `extensions`.
92
-
93
- #### Defined in
94
-
95
- [errors/AbstractError.ts:24](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L24)
96
-
97
- ---
98
-
99
- ### inner
100
-
101
- • **inner**: [`Maybe`](../modules.md#maybe)\<`Error`\>
102
-
103
- Another error that should be transported with this error.
104
-
105
- **`Deprecated`**
106
-
107
- We don't make use of this or interpret nested errors at all.
108
-
109
- #### Defined in
110
-
111
- [errors/AbstractError.ts:18](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L18)
112
-
113
- ---
114
-
115
- ### message
116
-
117
- • **message**: `string`
118
-
119
- #### Inherited from
120
-
121
- Error.message
122
-
123
- #### Defined in
124
-
125
- ../node_modules/typescript/lib/lib.es5.d.ts:1068
126
-
127
- ---
128
-
129
- ### name
130
-
131
- • **name**: `string`
132
-
133
- #### Inherited from
134
-
135
- Error.name
136
-
137
- #### Defined in
138
-
139
- ../node_modules/typescript/lib/lib.es5.d.ts:1067
140
-
141
- ---
142
-
143
- ### stack
144
-
145
- • `Optional` **stack**: `string`
146
-
147
- #### Inherited from
148
-
149
- Error.stack
150
-
151
- #### Defined in
152
-
153
- ../node_modules/typescript/lib/lib.es5.d.ts:1069
154
-
155
- ---
156
-
157
- ### status
158
-
159
- • **status**: `number`
160
-
161
- The HTTP status code to associate with this error.
162
-
163
- **`Deprecated`**
164
-
165
- We no longer respond to HTTP requests with error-specifc
166
- status codes.
167
-
168
- #### Defined in
169
-
170
- [errors/AbstractError.ts:12](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L12)
171
-
172
- ---
173
-
174
- ### prepareStackTrace
175
-
176
- ▪ `Static` `Optional` **prepareStackTrace**: (`err`: `Error`, `stackTraces`: `CallSite`[]) => `any`
177
-
178
- #### Type declaration
179
-
180
- ▸ (`err`, `stackTraces`): `any`
181
-
182
- Optional override for formatting stack traces
183
-
184
- ##### Parameters
185
-
186
- | Name | Type |
187
- | :------------ | :----------- |
188
- | `err` | `Error` |
189
- | `stackTraces` | `CallSite`[] |
190
-
191
- ##### Returns
192
-
193
- `any`
194
-
195
- **`See`**
196
-
197
- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
198
-
199
- #### Inherited from
200
-
201
- Error.prepareStackTrace
202
-
203
- #### Defined in
204
-
205
- ../node_modules/@types/node/globals.d.ts:11
206
-
207
- ---
208
-
209
- ### stackTraceLimit
210
-
211
- ▪ `Static` **stackTraceLimit**: `number`
212
-
213
- #### Inherited from
214
-
215
- Error.stackTraceLimit
216
-
217
- #### Defined in
218
-
219
- ../node_modules/@types/node/globals.d.ts:13
220
-
221
- ## Methods
222
-
223
- ### captureStackTrace
224
-
225
- ▸ **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
226
-
227
- Create .stack property on a target object
228
-
229
- #### Parameters
230
-
231
- | Name | Type |
232
- | :---------------- | :--------- |
233
- | `targetObject` | `object` |
234
- | `constructorOpt?` | `Function` |
235
-
236
- #### Returns
237
-
238
- `void`
239
-
240
- #### Inherited from
241
-
242
- Error.captureStackTrace
243
-
244
- #### Defined in
245
-
246
- ../node_modules/@types/node/globals.d.ts:4
247
-
248
- ---
249
-
250
- ### isAbstractError
251
-
252
- ▸ **isAbstractError**(`error`, `allowForeignModule?`): error is AbstractError
253
-
254
- Checks if an object is an instance of [AbstractError](AbstractError.md), or one of its subclasses.
255
-
256
- #### Parameters
257
-
258
- | Name | Type | Default value | Description |
259
- | :------------------- | :-------- | :------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
260
- | `error` | `unknown` | `undefined` | The object to check. |
261
- | `allowForeignModule` | `boolean` | `true` | Only check for similar looking error codes. You're going to want to use this if you're dealing with a setup where multiple versions of js-utils are loaded. |
262
-
263
- #### Returns
264
-
265
- error is AbstractError
266
-
267
- `true` if the object is an [AbstractError](AbstractError.md), `false` otherwise.
268
-
269
- #### Defined in
270
-
271
- [errors/AbstractError.ts:58](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/errors/AbstractError.ts#L58)
@@ -1,177 +0,0 @@
1
- [@oliversalzburg/js-utils](../README.md) / [Exports](../modules.md) / Canvas
2
-
3
- # Class: Canvas
4
-
5
- A wrapper around [`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)
6
- to provide some convience for double-buffered drawing.
7
-
8
- ## Constructors
9
-
10
- ### constructor
11
-
12
- • **new Canvas**(`canvas`, `width`, `height`): [`Canvas`](Canvas.md)
13
-
14
- Constructs a new [Canvas](Canvas.md).
15
-
16
- #### Parameters
17
-
18
- | Name | Type | Description |
19
- | :------- | :------------------ | :------------------------ |
20
- | `canvas` | `HTMLCanvasElement` | The canvas to wrap. |
21
- | `width` | `number` | The width of the canvas. |
22
- | `height` | `number` | The height of the canvas. |
23
-
24
- #### Returns
25
-
26
- [`Canvas`](Canvas.md)
27
-
28
- #### Defined in
29
-
30
- [graphics/canvas.ts:22](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L22)
31
-
32
- ## Properties
33
-
34
- ### buffer
35
-
36
- • `Readonly` **buffer**: `Uint8ClampedArray`
37
-
38
- #### Defined in
39
-
40
- [graphics/canvas.ts:14](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L14)
41
-
42
- ---
43
-
44
- ### canvas
45
-
46
- • `Readonly` **canvas**: `HTMLCanvasElement`
47
-
48
- #### Defined in
49
-
50
- [graphics/canvas.ts:9](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L9)
51
-
52
- ---
53
-
54
- ### context
55
-
56
- • `Readonly` **context**: `CanvasRenderingContext2D`
57
-
58
- #### Defined in
59
-
60
- [graphics/canvas.ts:12](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L12)
61
-
62
- ---
63
-
64
- ### height
65
-
66
- • `Readonly` **height**: `number`
67
-
68
- #### Defined in
69
-
70
- [graphics/canvas.ts:11](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L11)
71
-
72
- ---
73
-
74
- ### pixMap
75
-
76
- • `Readonly` **pixMap**: `ImageData`
77
-
78
- #### Defined in
79
-
80
- [graphics/canvas.ts:13](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L13)
81
-
82
- ---
83
-
84
- ### width
85
-
86
- • `Readonly` **width**: `number`
87
-
88
- #### Defined in
89
-
90
- [graphics/canvas.ts:10](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L10)
91
-
92
- ## Methods
93
-
94
- ### clearWith
95
-
96
- ▸ **clearWith**(`color`): `void`
97
-
98
- Fills the entire backbuffer with the given color.
99
-
100
- #### Parameters
101
-
102
- | Name | Type | Description |
103
- | :------ | :------- | :------------------------------------- |
104
- | `color` | `number` | The color to fill the backbuffer with. |
105
-
106
- #### Returns
107
-
108
- `void`
109
-
110
- #### Defined in
111
-
112
- [graphics/canvas.ts:75](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L75)
113
-
114
- ---
115
-
116
- ### getPixel32
117
-
118
- ▸ **getPixel32**(`x`, `y`): `number`
119
-
120
- Returns the color of a pixel in the backbuffer.
121
-
122
- #### Parameters
123
-
124
- | Name | Type | Description |
125
- | :--- | :------- | :---------------------------- |
126
- | `x` | `number` | The X coordinate to retrieve. |
127
- | `y` | `number` | The X coordinate to retrieve. |
128
-
129
- #### Returns
130
-
131
- `number`
132
-
133
- The color of the pixel at the given local.
134
-
135
- #### Defined in
136
-
137
- [graphics/canvas.ts:47](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L47)
138
-
139
- ---
140
-
141
- ### setPixel32
142
-
143
- ▸ **setPixel32**(`x`, `y`, `color`): `void`
144
-
145
- Colors a pixel in the backbuffer.
146
-
147
- #### Parameters
148
-
149
- | Name | Type | Description |
150
- | :------ | :------- | :------------------------------------ |
151
- | `x` | `number` | The X coordinate to color. |
152
- | `y` | `number` | The Y coordinate to color. |
153
- | `color` | `number` | The color to place at the coordinate. |
154
-
155
- #### Returns
156
-
157
- `void`
158
-
159
- #### Defined in
160
-
161
- [graphics/canvas.ts:63](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L63)
162
-
163
- ---
164
-
165
- ### update
166
-
167
- ▸ **update**(): `void`
168
-
169
- Draws the backbuffer onto the canvas.
170
-
171
- #### Returns
172
-
173
- `void`
174
-
175
- #### Defined in
176
-
177
- [graphics/canvas.ts:37](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L37)