@twin.org/core 0.0.3 → 0.0.4-next.10
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.
- package/dist/es/encoding/base64.js +2 -1
- package/dist/es/encoding/base64.js.map +1 -1
- package/dist/es/errors/conflictError.js +1 -1
- package/dist/es/errors/conflictError.js.map +1 -1
- package/dist/es/errors/generalError.js +1 -1
- package/dist/es/errors/generalError.js.map +1 -1
- package/dist/es/errors/notImplementedError.js +1 -1
- package/dist/es/errors/notImplementedError.js.map +1 -1
- package/dist/es/errors/validationError.js +1 -1
- package/dist/es/errors/validationError.js.map +1 -1
- package/dist/es/factories/factory.js +9 -0
- package/dist/es/factories/factory.js.map +1 -1
- package/dist/es/helpers/arrayHelper.js +1 -1
- package/dist/es/helpers/arrayHelper.js.map +1 -1
- package/dist/es/helpers/errorHelper.js +1 -1
- package/dist/es/helpers/errorHelper.js.map +1 -1
- package/dist/es/helpers/jsonHelper.js +1 -1
- package/dist/es/helpers/jsonHelper.js.map +1 -1
- package/dist/es/helpers/objectHelper.js +2 -2
- package/dist/es/helpers/objectHelper.js.map +1 -1
- package/dist/es/helpers/stringHelper.js +2 -2
- package/dist/es/helpers/stringHelper.js.map +1 -1
- package/dist/es/index.js +4 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IComponent.js.map +1 -1
- package/dist/es/models/ILocale.js.map +1 -1
- package/dist/es/models/ISharedObjectBufferOptions.js +4 -0
- package/dist/es/models/ISharedObjectBufferOptions.js.map +1 -0
- package/dist/es/models/ISharedObjectBufferWorkerMessage.js +2 -0
- package/dist/es/models/ISharedObjectBufferWorkerMessage.js.map +1 -0
- package/dist/es/models/IValidationFailure.js.map +1 -1
- package/dist/es/models/sharedObjectBufferMessageTypes.js +13 -0
- package/dist/es/models/sharedObjectBufferMessageTypes.js.map +1 -0
- package/dist/es/utils/asyncCache.js +4 -1
- package/dist/es/utils/asyncCache.js.map +1 -1
- package/dist/es/utils/coerce.js +10 -20
- package/dist/es/utils/coerce.js.map +1 -1
- package/dist/es/utils/compression.js +1 -1
- package/dist/es/utils/compression.js.map +1 -1
- package/dist/es/utils/guards.js +36 -0
- package/dist/es/utils/guards.js.map +1 -1
- package/dist/es/utils/is.js +9 -9
- package/dist/es/utils/is.js.map +1 -1
- package/dist/es/utils/mutex.js +55 -23
- package/dist/es/utils/mutex.js.map +1 -1
- package/dist/es/utils/sharedObjectBuffer.js +305 -0
- package/dist/es/utils/sharedObjectBuffer.js.map +1 -0
- package/dist/es/utils/sharedStore.js +2 -2
- package/dist/es/utils/sharedStore.js.map +1 -1
- package/dist/types/errors/conflictError.d.ts +1 -1
- package/dist/types/errors/generalError.d.ts +1 -1
- package/dist/types/errors/notImplementedError.d.ts +1 -1
- package/dist/types/errors/validationError.d.ts +1 -1
- package/dist/types/factories/factory.d.ts +6 -0
- package/dist/types/helpers/arrayHelper.d.ts +1 -1
- package/dist/types/helpers/errorHelper.d.ts +1 -1
- package/dist/types/helpers/jsonHelper.d.ts +1 -1
- package/dist/types/helpers/objectHelper.d.ts +2 -2
- package/dist/types/helpers/stringHelper.d.ts +2 -2
- package/dist/types/index.d.ts +4 -0
- package/dist/types/models/IComponent.d.ts +2 -2
- package/dist/types/models/ILocale.d.ts +1 -1
- package/dist/types/models/ISharedObjectBufferOptions.d.ts +17 -0
- package/dist/types/models/ISharedObjectBufferWorkerMessage.d.ts +29 -0
- package/dist/types/models/IValidationFailure.d.ts +1 -1
- package/dist/types/models/sharedObjectBufferMessageTypes.d.ts +13 -0
- package/dist/types/utils/asyncCache.d.ts +1 -8
- package/dist/types/utils/coerce.d.ts +10 -20
- package/dist/types/utils/compression.d.ts +1 -1
- package/dist/types/utils/guards.d.ts +24 -0
- package/dist/types/utils/is.d.ts +9 -9
- package/dist/types/utils/mutex.d.ts +7 -7
- package/dist/types/utils/sharedObjectBuffer.d.ts +74 -0
- package/dist/types/utils/sharedStore.d.ts +2 -2
- package/docs/changelog.md +306 -0
- package/docs/reference/classes/ArrayHelper.md +1 -1
- package/docs/reference/classes/AsyncCache.md +1 -1
- package/docs/reference/classes/Coerce.md +10 -50
- package/docs/reference/classes/Compression.md +1 -1
- package/docs/reference/classes/ConflictError.md +1 -1
- package/docs/reference/classes/ErrorHelper.md +1 -1
- package/docs/reference/classes/Factory.md +28 -0
- package/docs/reference/classes/GeneralError.md +1 -1
- package/docs/reference/classes/Guards.md +108 -0
- package/docs/reference/classes/Is.md +9 -9
- package/docs/reference/classes/JsonHelper.md +1 -1
- package/docs/reference/classes/Mutex.md +8 -8
- package/docs/reference/classes/NotImplementedError.md +1 -1
- package/docs/reference/classes/ObjectHelper.md +2 -2
- package/docs/reference/classes/SharedObjectBuffer.md +192 -0
- package/docs/reference/classes/SharedStore.md +2 -2
- package/docs/reference/classes/StringHelper.md +16 -13
- package/docs/reference/classes/ValidationError.md +1 -1
- package/docs/reference/index.md +5 -0
- package/docs/reference/interfaces/IComponent.md +2 -2
- package/docs/reference/interfaces/ILocale.md +1 -1
- package/docs/reference/interfaces/ISharedObjectBufferOptions.md +33 -0
- package/docs/reference/interfaces/ISharedObjectBufferWorkerMessage.md +44 -0
- package/docs/reference/interfaces/IValidationFailure.md +1 -1
- package/docs/reference/type-aliases/SharedObjectBufferMessageTypes.md +5 -0
- package/docs/reference/variables/SharedObjectBufferMessageTypes.md +13 -0
- package/locales/en.json +10 -2
- package/package.json +4 -4
package/docs/reference/index.md
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
- [I18n](classes/I18n.md)
|
|
41
41
|
- [Is](classes/Is.md)
|
|
42
42
|
- [Mutex](classes/Mutex.md)
|
|
43
|
+
- [SharedObjectBuffer](classes/SharedObjectBuffer.md)
|
|
43
44
|
- [SharedStore](classes/SharedStore.md)
|
|
44
45
|
- [Validation](classes/Validation.md)
|
|
45
46
|
|
|
@@ -56,6 +57,8 @@
|
|
|
56
57
|
- [ILocalesIndex](interfaces/ILocalesIndex.md)
|
|
57
58
|
- [IMutexWorkerMessage](interfaces/IMutexWorkerMessage.md)
|
|
58
59
|
- [IPatchOperation](interfaces/IPatchOperation.md)
|
|
60
|
+
- [ISharedObjectBufferOptions](interfaces/ISharedObjectBufferOptions.md)
|
|
61
|
+
- [ISharedObjectBufferWorkerMessage](interfaces/ISharedObjectBufferWorkerMessage.md)
|
|
59
62
|
- [IUrlParts](interfaces/IUrlParts.md)
|
|
60
63
|
- [IValidationFailure](interfaces/IValidationFailure.md)
|
|
61
64
|
|
|
@@ -65,6 +68,7 @@
|
|
|
65
68
|
- [CompressionType](type-aliases/CompressionType.md)
|
|
66
69
|
- [HealthStatus](type-aliases/HealthStatus.md)
|
|
67
70
|
- [MutexMessageTypes](type-aliases/MutexMessageTypes.md)
|
|
71
|
+
- [SharedObjectBufferMessageTypes](type-aliases/SharedObjectBufferMessageTypes.md)
|
|
68
72
|
- [ObjectOrArray](type-aliases/ObjectOrArray.md)
|
|
69
73
|
- [SingleOccurrenceArray](type-aliases/SingleOccurrenceArray.md)
|
|
70
74
|
- [SingleOccurrenceArrayDepthHelper](type-aliases/SingleOccurrenceArrayDepthHelper.md)
|
|
@@ -76,3 +80,4 @@
|
|
|
76
80
|
- [CompressionType](variables/CompressionType.md)
|
|
77
81
|
- [HealthStatus](variables/HealthStatus.md)
|
|
78
82
|
- [MutexMessageTypes](variables/MutexMessageTypes.md)
|
|
83
|
+
- [SharedObjectBufferMessageTypes](variables/SharedObjectBufferMessageTypes.md)
|
|
@@ -80,7 +80,7 @@ The node logging component type.
|
|
|
80
80
|
|
|
81
81
|
`Promise`\<`void`\>
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
A promise that resolves when the component has started.
|
|
84
84
|
|
|
85
85
|
***
|
|
86
86
|
|
|
@@ -102,7 +102,7 @@ The node logging component type.
|
|
|
102
102
|
|
|
103
103
|
`Promise`\<`void`\>
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
A promise that resolves when the component has stopped.
|
|
106
106
|
|
|
107
107
|
***
|
|
108
108
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Interface: ISharedObjectBufferOptions
|
|
2
|
+
|
|
3
|
+
Options for configuring buffer capacity when creating a shared object buffer.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### initialCapacityBytes? {#initialcapacitybytes}
|
|
8
|
+
|
|
9
|
+
> `optional` **initialCapacityBytes?**: `number`
|
|
10
|
+
|
|
11
|
+
Initial payload capacity hint in bytes.
|
|
12
|
+
Only honoured when the buffer does not yet exist; ignored on subsequent writes.
|
|
13
|
+
|
|
14
|
+
#### Default
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
1 MiB.
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
***
|
|
21
|
+
|
|
22
|
+
### maxCapacityBytes? {#maxcapacitybytes}
|
|
23
|
+
|
|
24
|
+
> `optional` **maxCapacityBytes?**: `number`
|
|
25
|
+
|
|
26
|
+
Maximum allowed payload capacity in bytes. The buffer will never grow beyond this limit.
|
|
27
|
+
Only honoured when the buffer does not yet exist; ignored on subsequent writes.
|
|
28
|
+
|
|
29
|
+
#### Default
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
256 MiB.
|
|
33
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Interface: ISharedObjectBufferWorkerMessage
|
|
2
|
+
|
|
3
|
+
Message sent from a worker thread to the main thread to request the SharedArrayBuffer for an object.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### type {#type}
|
|
8
|
+
|
|
9
|
+
> **type**: `"twin:sharedObjectBuffer:getBuffer"`
|
|
10
|
+
|
|
11
|
+
The message type discriminant.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### objectId {#objectid}
|
|
16
|
+
|
|
17
|
+
> **objectId**: `string`
|
|
18
|
+
|
|
19
|
+
The object id name that identifies which buffer is being requested.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### signal {#signal}
|
|
24
|
+
|
|
25
|
+
> **signal**: `SharedArrayBuffer`
|
|
26
|
+
|
|
27
|
+
One-shot SharedArrayBuffer used for the Atomics.wait/notify handshake so the
|
|
28
|
+
worker can block synchronously until the main thread has posted the response.
|
|
29
|
+
|
|
30
|
+
***
|
|
31
|
+
|
|
32
|
+
### port {#port}
|
|
33
|
+
|
|
34
|
+
> **port**: `MessagePort`
|
|
35
|
+
|
|
36
|
+
MessagePort through which the main thread returns the object buffer.
|
|
37
|
+
|
|
38
|
+
***
|
|
39
|
+
|
|
40
|
+
### options? {#options}
|
|
41
|
+
|
|
42
|
+
> `optional` **options?**: [`ISharedObjectBufferOptions`](ISharedObjectBufferOptions.md)
|
|
43
|
+
|
|
44
|
+
Options for creating or fetching the buffer.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Type Alias: SharedObjectBufferMessageTypes
|
|
2
|
+
|
|
3
|
+
> **SharedObjectBufferMessageTypes** = *typeof* [`SharedObjectBufferMessageTypes`](../variables/SharedObjectBufferMessageTypes.md)\[keyof *typeof* [`SharedObjectBufferMessageTypes`](../variables/SharedObjectBufferMessageTypes.md)\]
|
|
4
|
+
|
|
5
|
+
Union of all SharedObjectBuffer message type strings.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Variable: SharedObjectBufferMessageTypes
|
|
2
|
+
|
|
3
|
+
> `const` **SharedObjectBufferMessageTypes**: `object`
|
|
4
|
+
|
|
5
|
+
Message type constants for the SharedObjectBuffer worker-to-main-thread protocol.
|
|
6
|
+
|
|
7
|
+
## Type Declaration
|
|
8
|
+
|
|
9
|
+
### GetBuffer {#getbuffer}
|
|
10
|
+
|
|
11
|
+
> `readonly` **GetBuffer**: `"twin:sharedObjectBuffer:getBuffer"` = `"twin:sharedObjectBuffer:getBuffer"`
|
|
12
|
+
|
|
13
|
+
Worker requests the SharedArrayBuffer for a named object from the main thread.
|
package/locales/en.json
CHANGED
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
"bigint": "Property \"{property}\" must be a bigint, it is \"{value}\"",
|
|
56
56
|
"boolean": "Property \"{property}\" must be a boolean, it is \"{value}\"",
|
|
57
57
|
"date": "Property \"{property}\" must be a date, it is \"{value}\"",
|
|
58
|
+
"dateString": "Property \"{property}\" must be a date-only string in ISO 8601 format, it is \"{value}\"",
|
|
59
|
+
"dateTimeString": "Property \"{property}\" must be a date-time string in ISO 8601 format, it is \"{value}\"",
|
|
60
|
+
"timeString": "Property \"{property}\" must be a time string in ISO 8601 format, it is \"{value}\"",
|
|
58
61
|
"timestampMilliseconds": "Property \"{property}\" must be a timestamp in milliseconds, it is \"{value}\"",
|
|
59
62
|
"timestampSeconds": "Property \"{property}\" must be a timestamp in seconds, it is \"{value}\"",
|
|
60
63
|
"objectUndefined": "Property \"{property}\" must be an object, it is \"undefined\"",
|
|
@@ -67,8 +70,8 @@
|
|
|
67
70
|
"arrayEndsWith": "Property \"{property}\" must be an array ending with [{endValues}], it is \"{value}\"",
|
|
68
71
|
"uint8Array": "Property \"{property}\" must be a Uint8Array, it is \"{value}\"",
|
|
69
72
|
"function": "Property \"{property}\" must be a function, it is \"{value}\"",
|
|
70
|
-
"urn": "Property \"{property}\" must be a
|
|
71
|
-
"url": "Property \"{property}\" must be a
|
|
73
|
+
"urn": "Property \"{property}\" must be a URN formatted string, it is \"{value}\"",
|
|
74
|
+
"url": "Property \"{property}\" must be a URL formatted string, it is \"{value}\"",
|
|
72
75
|
"email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
|
|
73
76
|
"uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
|
|
74
77
|
"uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\""
|
|
@@ -107,6 +110,11 @@
|
|
|
107
110
|
"lockAlreadyReleased": "The key \"{key}\" is not currently locked",
|
|
108
111
|
"lockTimeout": "Failed to acquire lock for key \"{key}\" within the timeout of {timeout} milliseconds",
|
|
109
112
|
"bufferFetchFailed": "Failed to retrieve shared buffer for key \"{key}\" from the main thread"
|
|
113
|
+
},
|
|
114
|
+
"sharedObjectBuffer": {
|
|
115
|
+
"notCreated": "The shared buffer for object \"{objectId}\" has not been created",
|
|
116
|
+
"capacityExceeded": "The payload size of {required} bytes exceeds the maximum capacity of {capacity} bytes for object \"{objectId}\"",
|
|
117
|
+
"bufferFetchFailed": "Failed to retrieve shared buffer for object \"{objectId}\" from the main thread"
|
|
110
118
|
}
|
|
111
119
|
},
|
|
112
120
|
"errorNames": {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-next.10",
|
|
4
4
|
"description": "Helper methods/classes for data type checking/validation/guarding/error handling",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/iotaledger/framework.git",
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-framework.git",
|
|
8
8
|
"directory": "packages/core"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/nameof": "
|
|
17
|
+
"@twin.org/nameof": "0.0.4-next.10",
|
|
18
18
|
"intl-messageformat": "11.2.6",
|
|
19
19
|
"rfc6902": "5.2.0"
|
|
20
20
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"utilities"
|
|
46
46
|
],
|
|
47
47
|
"bugs": {
|
|
48
|
-
"url": "git+https://github.com/iotaledger/framework/issues"
|
|
48
|
+
"url": "git+https://github.com/iotaledger/twin-framework/issues"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://twindev.org"
|
|
51
51
|
}
|