@twin.org/core 0.0.4-next.1 → 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 +40 -11
- 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/sharedObjectBuffer.d.ts +74 -0
- package/dist/types/utils/sharedStore.d.ts +2 -2
- package/docs/changelog.md +225 -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/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
|
@@ -72,6 +72,34 @@ All the factories.
|
|
|
72
72
|
|
|
73
73
|
***
|
|
74
74
|
|
|
75
|
+
### getFactory() {#getfactory}
|
|
76
|
+
|
|
77
|
+
> `static` **getFactory**\<`T`\>(`typeName`): `Factory`\<`T`\> \| `undefined`
|
|
78
|
+
|
|
79
|
+
Get a specific factory by type name.
|
|
80
|
+
|
|
81
|
+
#### Type Parameters
|
|
82
|
+
|
|
83
|
+
##### T
|
|
84
|
+
|
|
85
|
+
`T` = `unknown`
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
##### typeName
|
|
90
|
+
|
|
91
|
+
`string`
|
|
92
|
+
|
|
93
|
+
The type name of the factory.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`Factory`\<`T`\> \| `undefined`
|
|
98
|
+
|
|
99
|
+
The factory instance if it exists, otherwise undefined.
|
|
100
|
+
|
|
101
|
+
***
|
|
102
|
+
|
|
75
103
|
### resetFactories() {#resetfactories}
|
|
76
104
|
|
|
77
105
|
> `static` **resetFactories**(): `void`
|
|
@@ -536,6 +536,114 @@ GuardError If the value does not match the assertion.
|
|
|
536
536
|
|
|
537
537
|
***
|
|
538
538
|
|
|
539
|
+
### dateString() {#datestring}
|
|
540
|
+
|
|
541
|
+
> `static` **dateString**(`source`, `property`, `value`): `asserts value is string`
|
|
542
|
+
|
|
543
|
+
Is the property a date-only string (ISO 8601 date, no time component).
|
|
544
|
+
|
|
545
|
+
#### Parameters
|
|
546
|
+
|
|
547
|
+
##### source
|
|
548
|
+
|
|
549
|
+
`string`
|
|
550
|
+
|
|
551
|
+
The source of the error.
|
|
552
|
+
|
|
553
|
+
##### property
|
|
554
|
+
|
|
555
|
+
`string`
|
|
556
|
+
|
|
557
|
+
The name of the property.
|
|
558
|
+
|
|
559
|
+
##### value
|
|
560
|
+
|
|
561
|
+
`unknown`
|
|
562
|
+
|
|
563
|
+
The value to test.
|
|
564
|
+
|
|
565
|
+
#### Returns
|
|
566
|
+
|
|
567
|
+
`asserts value is string`
|
|
568
|
+
|
|
569
|
+
#### Throws
|
|
570
|
+
|
|
571
|
+
GuardError If the value does not match the assertion.
|
|
572
|
+
|
|
573
|
+
***
|
|
574
|
+
|
|
575
|
+
### dateTimeString() {#datetimestring}
|
|
576
|
+
|
|
577
|
+
> `static` **dateTimeString**(`source`, `property`, `value`): `asserts value is string`
|
|
578
|
+
|
|
579
|
+
Is the property a date-time string (ISO 8601 with T separator).
|
|
580
|
+
|
|
581
|
+
#### Parameters
|
|
582
|
+
|
|
583
|
+
##### source
|
|
584
|
+
|
|
585
|
+
`string`
|
|
586
|
+
|
|
587
|
+
The source of the error.
|
|
588
|
+
|
|
589
|
+
##### property
|
|
590
|
+
|
|
591
|
+
`string`
|
|
592
|
+
|
|
593
|
+
The name of the property.
|
|
594
|
+
|
|
595
|
+
##### value
|
|
596
|
+
|
|
597
|
+
`unknown`
|
|
598
|
+
|
|
599
|
+
The value to test.
|
|
600
|
+
|
|
601
|
+
#### Returns
|
|
602
|
+
|
|
603
|
+
`asserts value is string`
|
|
604
|
+
|
|
605
|
+
#### Throws
|
|
606
|
+
|
|
607
|
+
GuardError If the value does not match the assertion.
|
|
608
|
+
|
|
609
|
+
***
|
|
610
|
+
|
|
611
|
+
### timeString() {#timestring}
|
|
612
|
+
|
|
613
|
+
> `static` **timeString**(`source`, `property`, `value`): `asserts value is string`
|
|
614
|
+
|
|
615
|
+
Is the property a time-only string (ISO 8601 time, no date component).
|
|
616
|
+
|
|
617
|
+
#### Parameters
|
|
618
|
+
|
|
619
|
+
##### source
|
|
620
|
+
|
|
621
|
+
`string`
|
|
622
|
+
|
|
623
|
+
The source of the error.
|
|
624
|
+
|
|
625
|
+
##### property
|
|
626
|
+
|
|
627
|
+
`string`
|
|
628
|
+
|
|
629
|
+
The name of the property.
|
|
630
|
+
|
|
631
|
+
##### value
|
|
632
|
+
|
|
633
|
+
`unknown`
|
|
634
|
+
|
|
635
|
+
The value to test.
|
|
636
|
+
|
|
637
|
+
#### Returns
|
|
638
|
+
|
|
639
|
+
`asserts value is string`
|
|
640
|
+
|
|
641
|
+
#### Throws
|
|
642
|
+
|
|
643
|
+
GuardError If the value does not match the assertion.
|
|
644
|
+
|
|
645
|
+
***
|
|
646
|
+
|
|
539
647
|
### timestampMilliseconds() {#timestampmilliseconds}
|
|
540
648
|
|
|
541
649
|
> `static` **timestampMilliseconds**(`source`, `property`, `value`): `asserts value is number`
|
|
@@ -32,7 +32,7 @@ The value to test.
|
|
|
32
32
|
|
|
33
33
|
`value is undefined`
|
|
34
34
|
|
|
35
|
-
True if the value is
|
|
35
|
+
True if the value is undefined.
|
|
36
36
|
|
|
37
37
|
***
|
|
38
38
|
|
|
@@ -54,7 +54,7 @@ The value to test.
|
|
|
54
54
|
|
|
55
55
|
`value is null`
|
|
56
56
|
|
|
57
|
-
True if the value is
|
|
57
|
+
True if the value is null.
|
|
58
58
|
|
|
59
59
|
***
|
|
60
60
|
|
|
@@ -76,7 +76,7 @@ The value to test.
|
|
|
76
76
|
|
|
77
77
|
value is null \| undefined
|
|
78
78
|
|
|
79
|
-
True if the value is
|
|
79
|
+
True if the value is null or undefined.
|
|
80
80
|
|
|
81
81
|
***
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ True if the value is a empty.
|
|
|
84
84
|
|
|
85
85
|
> `static` **notEmpty**(`value`): `boolean`
|
|
86
86
|
|
|
87
|
-
Is the property
|
|
87
|
+
Is the property not null or undefined.
|
|
88
88
|
|
|
89
89
|
#### Parameters
|
|
90
90
|
|
|
@@ -98,7 +98,7 @@ The value to test.
|
|
|
98
98
|
|
|
99
99
|
`boolean`
|
|
100
100
|
|
|
101
|
-
True if the value is
|
|
101
|
+
True if the value is not null or undefined.
|
|
102
102
|
|
|
103
103
|
***
|
|
104
104
|
|
|
@@ -128,7 +128,7 @@ True if the value is a string.
|
|
|
128
128
|
|
|
129
129
|
> `static` **stringValue**(`value`): `value is string`
|
|
130
130
|
|
|
131
|
-
Is the value a string.
|
|
131
|
+
Is the value a non-empty string.
|
|
132
132
|
|
|
133
133
|
#### Parameters
|
|
134
134
|
|
|
@@ -142,7 +142,7 @@ The value to test.
|
|
|
142
142
|
|
|
143
143
|
`value is string`
|
|
144
144
|
|
|
145
|
-
True if the value is a string.
|
|
145
|
+
True if the value is a non-empty string.
|
|
146
146
|
|
|
147
147
|
***
|
|
148
148
|
|
|
@@ -512,7 +512,7 @@ The value to test.
|
|
|
512
512
|
|
|
513
513
|
`value is number`
|
|
514
514
|
|
|
515
|
-
True if the value is a
|
|
515
|
+
True if the value is a timestamp in seconds.
|
|
516
516
|
|
|
517
517
|
***
|
|
518
518
|
|
|
@@ -534,7 +534,7 @@ The value to test.
|
|
|
534
534
|
|
|
535
535
|
`value is number`
|
|
536
536
|
|
|
537
|
-
True if the value is a
|
|
537
|
+
True if the value is a timestamp in milliseconds.
|
|
538
538
|
|
|
539
539
|
***
|
|
540
540
|
|
|
@@ -506,7 +506,7 @@ The object without the omitted keys, or undefined if the input was undefined.
|
|
|
506
506
|
|
|
507
507
|
> `static` **toExtended**(`obj`): `any`
|
|
508
508
|
|
|
509
|
-
|
|
509
|
+
Convert the non JSON primitives to extended types.
|
|
510
510
|
|
|
511
511
|
#### Parameters
|
|
512
512
|
|
|
@@ -528,7 +528,7 @@ The object with extended properties.
|
|
|
528
528
|
|
|
529
529
|
> `static` **fromExtended**(`obj`): `any`
|
|
530
530
|
|
|
531
|
-
|
|
531
|
+
Convert the extended types to non JSON primitives.
|
|
532
532
|
|
|
533
533
|
#### Parameters
|
|
534
534
|
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Class: SharedObjectBuffer
|
|
2
|
+
|
|
3
|
+
Manages per-object SharedArrayBuffers that store objects as UTF-8 JSON.
|
|
4
|
+
Buffer layout: 4-byte Int32 header (current data byte length) followed by the JSON-encoded object.
|
|
5
|
+
Buffers are explicitly created with create and cached in SharedStore.
|
|
6
|
+
On a worker thread an existing buffer is fetched via a MessagePort handshake
|
|
7
|
+
(same protocol as Mutex) and cached locally.
|
|
8
|
+
Buffers grow automatically when the payload exceeds capacity; when the payload drops well below
|
|
9
|
+
capacity the buffer is replaced with a smaller one. The caller must hold the objectId-keyed Mutex
|
|
10
|
+
around every read and write. The main thread's worker message handler must forward messages to
|
|
11
|
+
both Mutex.handleWorkerMessage and SharedObjectBuffer.handleWorkerMessage.
|
|
12
|
+
|
|
13
|
+
## Constructors
|
|
14
|
+
|
|
15
|
+
### Constructor
|
|
16
|
+
|
|
17
|
+
> **new SharedObjectBuffer**(): `SharedObjectBuffer`
|
|
18
|
+
|
|
19
|
+
#### Returns
|
|
20
|
+
|
|
21
|
+
`SharedObjectBuffer`
|
|
22
|
+
|
|
23
|
+
## Properties
|
|
24
|
+
|
|
25
|
+
### CLASS\_NAME {#class_name}
|
|
26
|
+
|
|
27
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
28
|
+
|
|
29
|
+
Runtime name for the class.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### DEFAULT\_CAPACITY\_BYTES {#default_capacity_bytes}
|
|
34
|
+
|
|
35
|
+
> `readonly` `static` **DEFAULT\_CAPACITY\_BYTES**: `number`
|
|
36
|
+
|
|
37
|
+
Default payload capacity per object (1 MiB). The first caller that creates the buffer
|
|
38
|
+
for an object determines its initial capacity; later callers that pass a different value
|
|
39
|
+
are ignored.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
43
|
+
### MAX\_CAPACITY\_BYTES {#max_capacity_bytes}
|
|
44
|
+
|
|
45
|
+
> `readonly` `static` **MAX\_CAPACITY\_BYTES**: `number`
|
|
46
|
+
|
|
47
|
+
Default upper bound for how large a buffer may grow (256 MiB).
|
|
48
|
+
Override per-object via the maxCapacityBytes option on create.
|
|
49
|
+
|
|
50
|
+
## Methods
|
|
51
|
+
|
|
52
|
+
### create() {#create}
|
|
53
|
+
|
|
54
|
+
> `static` **create**(`objectId`, `options?`): `Promise`\<`void`\>
|
|
55
|
+
|
|
56
|
+
Create the buffer for the given objectId if it does not already exist.
|
|
57
|
+
Must be called while holding Mutex.lock(objectId).
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
##### objectId
|
|
62
|
+
|
|
63
|
+
`string`
|
|
64
|
+
|
|
65
|
+
The object id that identifies the buffer.
|
|
66
|
+
|
|
67
|
+
##### options?
|
|
68
|
+
|
|
69
|
+
[`ISharedObjectBufferOptions`](../interfaces/ISharedObjectBufferOptions.md)
|
|
70
|
+
|
|
71
|
+
Optional capacity configuration used when creating the buffer.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<`void`\>
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### read() {#read}
|
|
80
|
+
|
|
81
|
+
> `static` **read**\<`T`\>(`objectId`): `Promise`\<`T` \| `undefined`\>
|
|
82
|
+
|
|
83
|
+
Read and decode the object stored for the given objectId.
|
|
84
|
+
Must be called while holding Mutex.lock(objectId).
|
|
85
|
+
|
|
86
|
+
#### Type Parameters
|
|
87
|
+
|
|
88
|
+
##### T
|
|
89
|
+
|
|
90
|
+
`T`
|
|
91
|
+
|
|
92
|
+
#### Parameters
|
|
93
|
+
|
|
94
|
+
##### objectId
|
|
95
|
+
|
|
96
|
+
`string`
|
|
97
|
+
|
|
98
|
+
The object id that identifies the buffer.
|
|
99
|
+
|
|
100
|
+
#### Returns
|
|
101
|
+
|
|
102
|
+
`Promise`\<`T` \| `undefined`\>
|
|
103
|
+
|
|
104
|
+
The stored object, or undefined when nothing has been written yet.
|
|
105
|
+
|
|
106
|
+
***
|
|
107
|
+
|
|
108
|
+
### write() {#write}
|
|
109
|
+
|
|
110
|
+
> `static` **write**\<`T`\>(`objectId`, `value`): `Promise`\<`void`\>
|
|
111
|
+
|
|
112
|
+
Encode and write the object into the buffer for the given objectId.
|
|
113
|
+
The buffer must already exist, usually by calling create first.
|
|
114
|
+
When the encoded payload exceeds the current buffer capacity the buffer is grown
|
|
115
|
+
in-place via SharedArrayBuffer.grow so every thread with a reference sees the
|
|
116
|
+
new size without any pointer swap. When the payload is smaller than
|
|
117
|
+
_SHRINK_THRESHOLD of the current capacity and the capacity exceeds
|
|
118
|
+
DEFAULT_CAPACITY_BYTES, the buffer is replaced with a smaller one on the calling thread.
|
|
119
|
+
Must be called while holding Mutex.lock(objectId).
|
|
120
|
+
|
|
121
|
+
#### Type Parameters
|
|
122
|
+
|
|
123
|
+
##### T
|
|
124
|
+
|
|
125
|
+
`T`
|
|
126
|
+
|
|
127
|
+
#### Parameters
|
|
128
|
+
|
|
129
|
+
##### objectId
|
|
130
|
+
|
|
131
|
+
`string`
|
|
132
|
+
|
|
133
|
+
The object id that identifies the buffer.
|
|
134
|
+
|
|
135
|
+
##### value
|
|
136
|
+
|
|
137
|
+
`T`
|
|
138
|
+
|
|
139
|
+
The object to persist.
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`Promise`\<`void`\>
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### remove() {#remove}
|
|
148
|
+
|
|
149
|
+
> `static` **remove**(`objectId`): `void`
|
|
150
|
+
|
|
151
|
+
Remove the stored object and release the buffer for the given objectId.
|
|
152
|
+
The entry is deleted from the local cache so subsequent reads or writes will
|
|
153
|
+
create or fetch a fresh buffer. Worker threads that have cached the old buffer
|
|
154
|
+
reference continue using it until they restart or re-request via the worker protocol.
|
|
155
|
+
Must be called while holding Mutex.lock(objectId).
|
|
156
|
+
|
|
157
|
+
#### Parameters
|
|
158
|
+
|
|
159
|
+
##### objectId
|
|
160
|
+
|
|
161
|
+
`string`
|
|
162
|
+
|
|
163
|
+
The object id that identifies the buffer.
|
|
164
|
+
|
|
165
|
+
#### Returns
|
|
166
|
+
|
|
167
|
+
`void`
|
|
168
|
+
|
|
169
|
+
***
|
|
170
|
+
|
|
171
|
+
### handleWorkerMessage() {#handleworkermessage}
|
|
172
|
+
|
|
173
|
+
> `static` **handleWorkerMessage**(`msg`): `boolean`
|
|
174
|
+
|
|
175
|
+
Inspect a message from a worker thread and, if it is a SharedObjectBuffer
|
|
176
|
+
buffer-fetch request, respond to it synchronously.
|
|
177
|
+
Call this from the main thread's worker message handler alongside
|
|
178
|
+
Mutex.handleWorkerMessage.
|
|
179
|
+
|
|
180
|
+
#### Parameters
|
|
181
|
+
|
|
182
|
+
##### msg
|
|
183
|
+
|
|
184
|
+
`unknown`
|
|
185
|
+
|
|
186
|
+
The raw message received from the worker.
|
|
187
|
+
|
|
188
|
+
#### Returns
|
|
189
|
+
|
|
190
|
+
`boolean`
|
|
191
|
+
|
|
192
|
+
True if the message was a SharedObjectBuffer protocol message, false otherwise.
|
|
@@ -297,19 +297,6 @@ The string split into words.
|
|
|
297
297
|
> `static` **isUtf8**(`data`): `boolean`
|
|
298
298
|
|
|
299
299
|
Check if a Node.js Buffer or Uint8Array is UTF-8.
|
|
300
|
-
Url https://tools.ietf.org/html/rfc3629
|
|
301
|
-
Source https://github.com/hcodes/isutf8
|
|
302
|
-
UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4.
|
|
303
|
-
UTF8-1 = %x00-7F.
|
|
304
|
-
UTF8-2 = %xC2-DF UTF8-tail.
|
|
305
|
-
UTF8-3 = %xE0 %xA0-BF UTF8-tail.
|
|
306
|
-
- %xE1-EC 2( UTF8-tail ).
|
|
307
|
-
- %xED %x80-9F UTF8-tail.
|
|
308
|
-
- %xEE-EF 2( UTF8-tail ).
|
|
309
|
-
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ).
|
|
310
|
-
- %xF1-F3 3( UTF8-tail ).
|
|
311
|
-
- %xF4 %x80-8F 2( UTF8-tail ).
|
|
312
|
-
UTF8-tail = %x80-BF.
|
|
313
300
|
|
|
314
301
|
#### Parameters
|
|
315
302
|
|
|
@@ -324,3 +311,19 @@ The data to check.
|
|
|
324
311
|
`boolean`
|
|
325
312
|
|
|
326
313
|
True if the data is utf8.
|
|
314
|
+
|
|
315
|
+
#### See
|
|
316
|
+
|
|
317
|
+
- https://tools.ietf.org/html/rfc3629
|
|
318
|
+
- https://github.com/hcodes/isutf8
|
|
319
|
+
UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4.
|
|
320
|
+
UTF8-1 = %x00-7F.
|
|
321
|
+
UTF8-2 = %xC2-DF UTF8-tail.
|
|
322
|
+
UTF8-3 = %xE0 %xA0-BF UTF8-tail.
|
|
323
|
+
- %xE1-EC 2( UTF8-tail ).
|
|
324
|
+
- %xED %x80-9F UTF8-tail.
|
|
325
|
+
- %xEE-EF 2( UTF8-tail ).
|
|
326
|
+
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ).
|
|
327
|
+
- %xF1-F3 3( UTF8-tail ).
|
|
328
|
+
- %xF4 %x80-8F 2( UTF8-tail ).
|
|
329
|
+
UTF8-tail = %x80-BF.
|
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.
|