space-data-module-sdk 0.8.0 → 0.8.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 (43) hide show
  1. package/README.md +17 -3
  2. package/bin/space-data-module.js +8 -6
  3. package/package.json +2 -2
  4. package/schemas/spacedatastandards/PLG.fbs +191 -0
  5. package/src/bundle/wasm.js +31 -9
  6. package/src/compliance/index.js +4 -0
  7. package/src/compliance/pluginCompliance.js +158 -2
  8. package/src/embeddedManifest.js +25 -5
  9. package/src/generated/orbpro/invoke/plugin-invoke-request.js +2 -2
  10. package/src/generated/orbpro/invoke/plugin-invoke-response.js +2 -2
  11. package/src/generated/orbpro/stream/flat-buffer-type-ref.js +2 -2
  12. package/src/generated/orbpro/stream/typed-arena-buffer.js +2 -2
  13. package/src/generated/spacedatastandards/plg/entry-function.js +86 -0
  14. package/src/generated/spacedatastandards/plg/entry-function.ts +119 -0
  15. package/src/generated/spacedatastandards/plg/index.js +16 -0
  16. package/src/generated/spacedatastandards/plg/index.ts +11 -0
  17. package/src/generated/spacedatastandards/plg/plg.js +657 -0
  18. package/src/generated/spacedatastandards/plg/plg.ts +924 -0
  19. package/src/generated/spacedatastandards/plg/plugin-capability.js +66 -0
  20. package/src/generated/spacedatastandards/plg/plugin-capability.ts +84 -0
  21. package/src/generated/spacedatastandards/plg/plugin-category.js +15 -0
  22. package/src/generated/spacedatastandards/plg/plugin-category.ts +53 -0
  23. package/src/generated/spacedatastandards/plg/plugin-dependency.js +63 -0
  24. package/src/generated/spacedatastandards/plg/plugin-dependency.ts +86 -0
  25. package/src/generated/spacedatastandards/plg/publication-state.js +9 -0
  26. package/src/generated/spacedatastandards/plg/publication-state.ts +23 -0
  27. package/src/generated/spacedatastandards/plg/purchase-tier.js +9 -0
  28. package/src/generated/spacedatastandards/plg/purchase-tier.ts +23 -0
  29. package/src/invoke/codec.js +1 -1
  30. package/src/manifest/browser.js +7 -0
  31. package/src/manifest/codec.js +73 -0
  32. package/src/manifest/index.js +7 -0
  33. package/src/manifest/legacyToPlg.js +249 -0
  34. package/src/manifest/plgCodec.js +826 -0
  35. package/src/standards/sharedCatalog.js +132 -0
  36. package/src/testing/native/wasmedge_emscripten_pthread_runner.c +17 -3
  37. package/src/vendor/flatbuffers/LICENSE +202 -0
  38. package/src/vendor/flatbuffers/builder.js +534 -0
  39. package/src/vendor/flatbuffers/byte-buffer.js +253 -0
  40. package/src/vendor/flatbuffers/constants.js +4 -0
  41. package/src/vendor/flatbuffers/encoding.js +5 -0
  42. package/src/vendor/flatbuffers/flatbuffers.js +5 -0
  43. package/src/vendor/flatbuffers/utils.js +4 -0
@@ -0,0 +1,253 @@
1
+ import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from './constants.js';
2
+ import { Encoding } from './encoding.js';
3
+ import { float32, float64, int32, isLittleEndian } from './utils.js';
4
+ export class ByteBuffer {
5
+ /**
6
+ * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
7
+ */
8
+ constructor(bytes_) {
9
+ this.bytes_ = bytes_;
10
+ this.position_ = 0;
11
+ this.text_decoder_ = new TextDecoder();
12
+ }
13
+ /**
14
+ * Create and allocate a new ByteBuffer with a given size.
15
+ */
16
+ static allocate(byte_size) {
17
+ return new ByteBuffer(new Uint8Array(byte_size));
18
+ }
19
+ clear() {
20
+ this.position_ = 0;
21
+ }
22
+ /**
23
+ * Get the underlying `Uint8Array`.
24
+ */
25
+ bytes() {
26
+ return this.bytes_;
27
+ }
28
+ /**
29
+ * Get the buffer's position.
30
+ */
31
+ position() {
32
+ return this.position_;
33
+ }
34
+ /**
35
+ * Set the buffer's position.
36
+ */
37
+ setPosition(position) {
38
+ this.position_ = position;
39
+ }
40
+ /**
41
+ * Get the buffer's capacity.
42
+ */
43
+ capacity() {
44
+ return this.bytes_.length;
45
+ }
46
+ readInt8(offset) {
47
+ return (this.readUint8(offset) << 24) >> 24;
48
+ }
49
+ readUint8(offset) {
50
+ return this.bytes_[offset];
51
+ }
52
+ readInt16(offset) {
53
+ return (this.readUint16(offset) << 16) >> 16;
54
+ }
55
+ readUint16(offset) {
56
+ return this.bytes_[offset] | (this.bytes_[offset + 1] << 8);
57
+ }
58
+ readInt32(offset) {
59
+ return (this.bytes_[offset] |
60
+ (this.bytes_[offset + 1] << 8) |
61
+ (this.bytes_[offset + 2] << 16) |
62
+ (this.bytes_[offset + 3] << 24));
63
+ }
64
+ readUint32(offset) {
65
+ return this.readInt32(offset) >>> 0;
66
+ }
67
+ readInt64(offset) {
68
+ return BigInt.asIntN(64, BigInt(this.readUint32(offset)) +
69
+ (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
70
+ }
71
+ readUint64(offset) {
72
+ return BigInt.asUintN(64, BigInt(this.readUint32(offset)) +
73
+ (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
74
+ }
75
+ readFloat32(offset) {
76
+ int32[0] = this.readInt32(offset);
77
+ return float32[0];
78
+ }
79
+ readFloat64(offset) {
80
+ int32[isLittleEndian ? 0 : 1] = this.readInt32(offset);
81
+ int32[isLittleEndian ? 1 : 0] = this.readInt32(offset + 4);
82
+ return float64[0];
83
+ }
84
+ writeInt8(offset, value) {
85
+ this.bytes_[offset] = value;
86
+ }
87
+ writeUint8(offset, value) {
88
+ this.bytes_[offset] = value;
89
+ }
90
+ writeInt16(offset, value) {
91
+ this.bytes_[offset] = value;
92
+ this.bytes_[offset + 1] = value >> 8;
93
+ }
94
+ writeUint16(offset, value) {
95
+ this.bytes_[offset] = value;
96
+ this.bytes_[offset + 1] = value >> 8;
97
+ }
98
+ writeInt32(offset, value) {
99
+ this.bytes_[offset] = value;
100
+ this.bytes_[offset + 1] = value >> 8;
101
+ this.bytes_[offset + 2] = value >> 16;
102
+ this.bytes_[offset + 3] = value >> 24;
103
+ }
104
+ writeUint32(offset, value) {
105
+ this.bytes_[offset] = value;
106
+ this.bytes_[offset + 1] = value >> 8;
107
+ this.bytes_[offset + 2] = value >> 16;
108
+ this.bytes_[offset + 3] = value >> 24;
109
+ }
110
+ writeInt64(offset, value) {
111
+ this.writeInt32(offset, Number(BigInt.asIntN(32, value)));
112
+ this.writeInt32(offset + 4, Number(BigInt.asIntN(32, value >> BigInt(32))));
113
+ }
114
+ writeUint64(offset, value) {
115
+ this.writeUint32(offset, Number(BigInt.asUintN(32, value)));
116
+ this.writeUint32(offset + 4, Number(BigInt.asUintN(32, value >> BigInt(32))));
117
+ }
118
+ writeFloat32(offset, value) {
119
+ float32[0] = value;
120
+ this.writeInt32(offset, int32[0]);
121
+ }
122
+ writeFloat64(offset, value) {
123
+ float64[0] = value;
124
+ this.writeInt32(offset, int32[isLittleEndian ? 0 : 1]);
125
+ this.writeInt32(offset + 4, int32[isLittleEndian ? 1 : 0]);
126
+ }
127
+ /**
128
+ * Return the file identifier. Behavior is undefined for FlatBuffers whose
129
+ * schema does not include a file_identifier (likely points at padding or the
130
+ * start of a the root vtable).
131
+ */
132
+ getBufferIdentifier() {
133
+ if (this.bytes_.length <
134
+ this.position_ + SIZEOF_INT + FILE_IDENTIFIER_LENGTH) {
135
+ throw new Error('FlatBuffers: ByteBuffer is too short to contain an identifier.');
136
+ }
137
+ let result = '';
138
+ for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {
139
+ result += String.fromCharCode(this.readInt8(this.position_ + SIZEOF_INT + i));
140
+ }
141
+ return result;
142
+ }
143
+ /**
144
+ * Look up a field in the vtable, return an offset into the object, or 0 if the
145
+ * field is not present.
146
+ */
147
+ __offset(bb_pos, vtable_offset) {
148
+ const vtable = bb_pos - this.readInt32(bb_pos);
149
+ return vtable_offset < this.readInt16(vtable)
150
+ ? this.readInt16(vtable + vtable_offset)
151
+ : 0;
152
+ }
153
+ /**
154
+ * Initialize any Table-derived type to point to the union at the given offset.
155
+ */
156
+ __union(t, offset) {
157
+ t.bb_pos = offset + this.readInt32(offset);
158
+ t.bb = this;
159
+ return t;
160
+ }
161
+ /**
162
+ * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
163
+ * This allocates a new string and converts to wide chars upon each access.
164
+ *
165
+ * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
166
+ * "optionalEncoding" argument. This is useful for avoiding conversion when
167
+ * the data will just be packaged back up in another FlatBuffer later on.
168
+ *
169
+ * @param offset
170
+ * @param opt_encoding Defaults to UTF16_STRING
171
+ */
172
+ __string(offset, opt_encoding) {
173
+ offset += this.readInt32(offset);
174
+ const length = this.readInt32(offset);
175
+ offset += SIZEOF_INT;
176
+ const utf8bytes = this.bytes_.subarray(offset, offset + length);
177
+ if (opt_encoding === Encoding.UTF8_BYTES)
178
+ return utf8bytes;
179
+ else
180
+ return this.text_decoder_.decode(utf8bytes);
181
+ }
182
+ /**
183
+ * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
184
+ * if a string then return a new one
185
+ *
186
+ * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this
187
+ * makes the behaviour of __union_with_string different compared to __union
188
+ */
189
+ __union_with_string(o, offset) {
190
+ if (typeof o === 'string') {
191
+ return this.__string(offset);
192
+ }
193
+ return this.__union(o, offset);
194
+ }
195
+ /**
196
+ * Retrieve the relative offset stored at "offset"
197
+ */
198
+ __indirect(offset) {
199
+ return offset + this.readInt32(offset);
200
+ }
201
+ /**
202
+ * Get the start of data of a vector whose offset is stored at "offset" in this object.
203
+ */
204
+ __vector(offset) {
205
+ return offset + this.readInt32(offset) + SIZEOF_INT; // data starts after the length
206
+ }
207
+ /**
208
+ * Get the length of a vector whose offset is stored at "offset" in this object.
209
+ */
210
+ __vector_len(offset) {
211
+ return this.readInt32(offset + this.readInt32(offset));
212
+ }
213
+ __has_identifier(ident) {
214
+ if (ident.length != FILE_IDENTIFIER_LENGTH) {
215
+ throw new Error('FlatBuffers: file identifier must be length ' + FILE_IDENTIFIER_LENGTH);
216
+ }
217
+ for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {
218
+ if (ident.charCodeAt(i) != this.readInt8(this.position() + SIZEOF_INT + i)) {
219
+ return false;
220
+ }
221
+ }
222
+ return true;
223
+ }
224
+ /**
225
+ * A helper function for generating list for obj api
226
+ */
227
+ createScalarList(listAccessor, listLength) {
228
+ const ret = [];
229
+ for (let i = 0; i < listLength; ++i) {
230
+ const val = listAccessor(i);
231
+ if (val !== null) {
232
+ ret.push(val);
233
+ }
234
+ }
235
+ return ret;
236
+ }
237
+ /**
238
+ * A helper function for generating list for obj api
239
+ * @param listAccessor function that accepts an index and return data at that index
240
+ * @param listLength listLength
241
+ * @param res result list
242
+ */
243
+ createObjList(listAccessor, listLength) {
244
+ const ret = [];
245
+ for (let i = 0; i < listLength; ++i) {
246
+ const val = listAccessor(i);
247
+ if (val !== null) {
248
+ ret.push(val.unpack());
249
+ }
250
+ }
251
+ return ret;
252
+ }
253
+ }
@@ -0,0 +1,4 @@
1
+ export const SIZEOF_SHORT = 2;
2
+ export const SIZEOF_INT = 4;
3
+ export const FILE_IDENTIFIER_LENGTH = 4;
4
+ export const SIZE_PREFIX_LENGTH = 4;
@@ -0,0 +1,5 @@
1
+ export var Encoding;
2
+ (function (Encoding) {
3
+ Encoding[Encoding["UTF8_BYTES"] = 1] = "UTF8_BYTES";
4
+ Encoding[Encoding["UTF16_STRING"] = 2] = "UTF16_STRING";
5
+ })(Encoding || (Encoding = {}));
@@ -0,0 +1,5 @@
1
+ export { FILE_IDENTIFIER_LENGTH, SIZEOF_INT, SIZEOF_SHORT, SIZE_PREFIX_LENGTH, } from './constants.js';
2
+ export { float32, float64, int32, isLittleEndian } from './utils.js';
3
+ export { Builder } from './builder.js';
4
+ export { ByteBuffer } from './byte-buffer.js';
5
+ export { Encoding } from './encoding.js';
@@ -0,0 +1,4 @@
1
+ export const int32 = new Int32Array(2);
2
+ export const float32 = new Float32Array(int32.buffer);
3
+ export const float64 = new Float64Array(int32.buffer);
4
+ export const isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;