object-input-stream 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ori Levenglick
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,303 @@
1
+ # object-input-stream
2
+
3
+ Java's ObjectInputStream for JavaScript.
4
+
5
+ Read Java serialized objects in Node and in the browser.
6
+
7
+ ## Basic Usage
8
+
9
+ #### Create Stream
10
+
11
+ ```js
12
+ import ObjectInputStream from 'object-input-stream';
13
+
14
+ const data = new Uint8Array( /* Java object serialization stream data */ );
15
+ const ois = new ObjectInputStream(data);
16
+ ```
17
+
18
+ #### Read Raw Bytes
19
+
20
+ ```js
21
+ ois.read1(); // unsigned byte. -1 if not available
22
+ ois.read(5); // up to 5 bytes as Uint8Array
23
+ ois.readFully(5); // exactly 5 bytes as Uint8Array. EOFException if not available
24
+ ```
25
+
26
+ #### Read Primitive Values
27
+
28
+ ```js
29
+ ois.readByte(); // number
30
+ ois.readUnsignedByte(); // number
31
+ ois.readChar(); // utf-16 code unit. JS string of length 1
32
+ ois.readShort(); // number
33
+ ois.readUnsignedShort(); // number
34
+ ois.readInt(); // number
35
+ ois.readLong(); // bigint
36
+ ois.readFloat(); // number
37
+ ois.readDouble(); // number
38
+ ois.readUTF(); // string
39
+ ```
40
+
41
+ #### Read Objects
42
+
43
+ ```js
44
+ ois.readObject();
45
+ ```
46
+
47
+ May return:
48
+
49
+ - Null
50
+ - Class instance
51
+ - String
52
+ - Array
53
+ - Enum constant
54
+ - Class
55
+ - Class descriptor (ObjectStreamClass instance)
56
+ - Any value returned by a custom `readResolve` method
57
+
58
+ ## Advanced Usage
59
+
60
+ ### Class Handlers
61
+
62
+ On the first time a class descriptor is read from stream (either by itself or as part of a class / object), a JavaScript class is selected or dynamically created to correspond to it.
63
+ When a class object occurs in stream, its corresponding JavaScript class will be returned from `readObject`.
64
+ When an object occurs in stream, it will be instantiated using the 0-argument constructor of the JavaScript class that corresponds to its Java class, and then deserialized using its `readObject`, `readExternal`, and/or `readResolve` methods.
65
+
66
+ #### Custom Class Handlers
67
+
68
+ You can "register" classes with an ObjectInputStream, so that when they occur in stream, your class with be selected:
69
+
70
+ ```js
71
+ ois.registerSerializable("fully.qualified.ClassName", SerializableClass);
72
+ ois.registerExternalizable("fully.qualified.ClassName", ExternalizableClass);
73
+ ois.registerEnum("fully.qualified.ClassName", EnumObject);
74
+ ois.registerClass("fully.qualified.ClassName", GeneralClass);
75
+ ```
76
+
77
+ ##### Serializable Classes
78
+
79
+ ```ts
80
+ import { ObjectInputStream, Serializable } from 'object-input-stream';
81
+
82
+ class CustomSerializable implements Serializable {
83
+ // Optional
84
+ // If exists and different from the one on stream when an instance is deserialized, failes with InvalidClassException
85
+ static readonly serialVersionUID: bigint
86
+ // Optional
87
+ readObject(ois: ObjectInputStream): void {
88
+ // You can use ois, exactly the same as in Java
89
+ // ois.readFields() and ois.defaultReadObject() are available
90
+ }
91
+ // Optional
92
+ readResolve(): any {
93
+ // If exists on a deserialized instance, this method is called
94
+ // and its return value replaces the instance itself
95
+ }
96
+ }
97
+
98
+ ois.registerSerializable("com.mypackage.CustomSerializable", CustomSerializable);
99
+ ```
100
+
101
+ > Note: if you recreate and register an entire inheritence chain of serializable classes, their `readObject` methods will be called in order, same as in Java. For every class in the chain that doesn't have a JavaScript handler / where the handler class doesn't have a `readObject` method, `ois.defaultReadObject` is called, again, same as in Java.
102
+
103
+ > Warning: Java serializable classes that write their fields before writing anything else to stream MUST have a custom handler class that replicates this behavior. Not doing that would lead to undefined behavior.
104
+
105
+ ##### Externalizable Classes
106
+
107
+ ```ts
108
+ import { ObjectInputStream, Externalizable } from 'object-input-stream';
109
+
110
+ class CustomExternalizable implements Externalizable {
111
+ // Optional
112
+ readExternal(ois: ObjectInputStream): void {
113
+ // You can use ois, exactly the same as in Java
114
+ }
115
+ // Optional
116
+ readResolve(): any {
117
+ // If exists on a deserialized instance, this method is called
118
+ // and its return value replaces the instance itself
119
+ }
120
+ }
121
+
122
+ ois.registerExternalizable("com.mypackage.CustomExternalizable", CustomExternalizable);
123
+ ```
124
+
125
+ > Warning: Java externalizable objects written using `PROTOCOL_VERSION_1` MUST have a custom handler class that reads all written data to stream. Not doing that would lead to undefined behavior.
126
+
127
+ ##### Enum Objects
128
+
129
+ ```ts
130
+ import { ObjectInputStream, Enum } from 'object-input-stream';
131
+
132
+ const CustomEnum: Enum = {
133
+ constantName1: constantValue1,
134
+ constantName2: constantValue2,
135
+ constantName3: constantValue3,
136
+ constantName4: constantValue4,
137
+ }
138
+
139
+ ois.registerEnum("com.mypackage.CustomEnum", CustomEnum);
140
+
141
+ // If CustomEnum.constantName1 is read from stream, ois.readObject() will return constantValue1.
142
+ // If CustomEnum.class is read, the CustomEnum object itself will be returned.
143
+ ```
144
+
145
+ ##### General Classes
146
+
147
+ ```ts
148
+ const CustomClass: any = /* literally anything */
149
+
150
+ ois.registerEnum("com.mypackage.CustomClass", CustomClass);
151
+
152
+ // A non-serializable, non-externalizable, non-enum class instance cannot be written to stream.
153
+ // If the class object itself is read from stream, whatever you registered will be returned.
154
+ ```
155
+
156
+ ##### Proxy Classes
157
+
158
+ It is not possible to register proxy classes. They are always dynamically generated - just like in Java.
159
+
160
+ #### Dynamically Generated Class Handlers
161
+
162
+ ##### Serializable Classes
163
+
164
+ Dynamically generated serializable class handlers are of the following structure:
165
+
166
+ ```ts
167
+ class ExampleSerializable {
168
+ // Class descriptor
169
+ static readonly $desc: ObjectStreamClass
170
+ // Fields deserialized using ois.defaultReadObject()
171
+ [field: string]: any
172
+ // Object annotation. Any extra data written by writeObject() methods after the fields
173
+ $annotation: any[][]
174
+ // Populates fields and annotation
175
+ readObject(ois: ObjectInputStream): void
176
+ }
177
+ ```
178
+
179
+ ##### Externalizable Classes
180
+
181
+ Dynamically generated externalizable class handlers are of the following structure:
182
+
183
+ ```ts
184
+ class ExampleExternalizable {
185
+ // Class descriptor
186
+ static readonly $desc: ObjectStreamClass
187
+ // Object annotation. All data written by the writeExternal() method
188
+ $annotation: any[]
189
+ // Populates annotation
190
+ readExternal(ois: ObjectInputStream): void
191
+ }
192
+ ```
193
+
194
+ ##### Enum Objects
195
+
196
+ Dynamically generated enum object handlers are of the following structure:
197
+
198
+ ```ts
199
+ class ExampleEnum {
200
+ // Class descriptor
201
+ static readonly $desc: ObjectStreamClass
202
+ // Creates a proxy object around itself, where for any string s, this[s] is s itself.
203
+ // This means that enum constants are read as just the string constant names themselves.
204
+ constructor()
205
+ }
206
+ ```
207
+
208
+ ##### General Classes
209
+
210
+ Dynamically generated general class handlers are of the following structure:
211
+
212
+ ```ts
213
+ class ExampleEnum {
214
+ // Class descriptor
215
+ static readonly $desc: ObjectStreamClass
216
+ }
217
+ ```
218
+
219
+ ##### Proxy Classes
220
+
221
+ Dynamically generated general class handlers are of the following structure:
222
+
223
+ ```ts
224
+ class ExampleProxy {
225
+ // A list of the proxy interface names associated with the class
226
+ static readonly proxyInterfaces: string[] = []
227
+ // The proxy handler class / lambda from Java
228
+ h?: InvocationHandler
229
+ // Creates a proxy object that calls this.h on property access
230
+ constructor(h?: InvocationHandler)
231
+ }
232
+
233
+ interface InvocationHandler {
234
+ invoke: (proxy: BaseProxy, method: string, args: any[]) => any
235
+ }
236
+ ```
237
+
238
+ #### Built-in Class Handlers
239
+
240
+ Primitive wrapper types have built-in handler classes that implement `readResolve` to replace instances with their primitive values. E.g. if the next object on stream is an `Integer` of value 5 and you call `readObject`, it will return the primitive value `5`.
241
+
242
+ - `java.lang.Byte`
243
+ - `java.lang.Short`
244
+ - `java.lang.Integer`
245
+ - `java.lang.Long`
246
+ - `java.lang.Float`
247
+ - `java.lang.Double`
248
+ - `java.lang.Character`
249
+ - `java.lang.Boolean`
250
+
251
+ Some standard library container types also have built-in handler classes, which extend the corresponding JavaScript container types (`Array`, `Set`, `Map`).
252
+
253
+ - `java.util.ArrayList`
254
+ - `java.util.LinkedList`
255
+ - `java.util.ArrayDeque`
256
+ - `java.util.HashSet`
257
+ - `java.util.LinkedHashSet`
258
+ - `java.util.TreeSet`
259
+ - `java.util.HashMap`
260
+ - `java.util.LinkedHashMap`
261
+ - `java.util.TreeMap`
262
+
263
+ > NOTE: in JavaScript, `Set`s and `Map`s determine item equlity using the strict equality operator `===`, not `equals()`, `hashCode()` or `compareTo()` methods.
264
+
265
+ ##### Overriding Built-in Class Handlers
266
+
267
+ You can override any handler at any moment by calling `registerSerializable`, `registerExternalizable`, `registerEnum` or `registerClass`. You can only do so before the corresponding class descriptor is read from stream, or after a reset.
268
+
269
+ You can also decide which classes (if any) are considered built-in by passing a second `info` parameter to `ObjectInputStream`.
270
+
271
+ ```ts
272
+ type OisOptions = {
273
+ // Mappings between built-in "fully.qualified.ClassNames" and their handlers
274
+ initialClasses?: {
275
+ serializable?: Map<string, SerializableCtor>,
276
+ externalizable?: Map<string, ExternalizableCtor>,
277
+ enum?: Map<string, Enum>,
278
+ general?: Map<string, any>,
279
+ }
280
+ }
281
+ ```
282
+
283
+ ## AST
284
+
285
+ ```js
286
+ // TODO
287
+ ```
288
+
289
+ ## Limitations
290
+
291
+ - Requires a runtime that supports `bigint` (all modern runtimes)
292
+ - Doesn't support strings over 9 petabytes in size (`Number.MAX_SAFE_INTEGER` bytes)
293
+
294
+ ## TODO
295
+
296
+ - [ ] ObjectInputStreamAST class: emit AST after parsing
297
+ - [ ] Complete existing tests
298
+ - [ ] Expand tests
299
+ - [ ] Classes
300
+ - [ ] Class descriptors
301
+ - [ ] Proxy classes
302
+ - [ ] Enums
303
+ - [ ] Sudden death: a brazillian randomly generated primitives and objects with a complex reference graph and readObject/readExternal
package/dist/ast.d.ts ADDED
@@ -0,0 +1,278 @@
1
+ import type ObjectInputStream from '.';
2
+ export interface Ast {
3
+ data: Uint8Array;
4
+ root: RootNode;
5
+ }
6
+ export default Ast;
7
+ export type Node = RootNode | MagicNode | VersionNode | ContentsNode | BlockDataSequenceNode | BlockDataNode | PrimitiveNode | UtfNode | LongUtfNode | UtfBodyNode | BytesNode | SkippedNode | ObjectNode | TCNode | ClassDescInfoNode | ProxyClassDescInfoNode;
8
+ export interface RootNode extends BaseNode<[MagicNode, VersionNode, ContentsNode]> {
9
+ type: "root";
10
+ }
11
+ export interface MagicNode extends BaseNode<null> {
12
+ type: "magic";
13
+ value: typeof ObjectInputStream.STREAM_MAGIC;
14
+ }
15
+ export interface VersionNode extends BaseNode<null> {
16
+ type: "version";
17
+ value: typeof ObjectInputStream.STREAM_VERSION;
18
+ }
19
+ export interface ContentsNode extends BaseNode<(BlockDataSequenceNode | ObjectNode)[]> {
20
+ type: "contents";
21
+ }
22
+ interface BaseNode<C extends BaseNode<any>[] | null> {
23
+ type: string;
24
+ span: {
25
+ start: number;
26
+ end: number;
27
+ };
28
+ children: C;
29
+ jsValue?: any;
30
+ }
31
+ export type PrimitiveNode = ByteNode | UnsignedByteNode | ShortNode | UnsignedShortNode | IntNode | FloatNode | DoubleNode | CharNode | BooleanNode | LongNode;
32
+ interface BasePrimitiveNode extends BaseNode<null> {
33
+ type: "primitive";
34
+ dataType: string;
35
+ value: number | string | boolean | bigint;
36
+ }
37
+ interface NumberNode extends BasePrimitiveNode {
38
+ dataType: string;
39
+ value: number;
40
+ }
41
+ export type ByteNode = NumberNode & {
42
+ dataType: "byte";
43
+ };
44
+ export type UnsignedByteNode = NumberNode & {
45
+ dataType: "unsigned-byte";
46
+ };
47
+ export type ShortNode = NumberNode & {
48
+ dataType: "short";
49
+ };
50
+ export type UnsignedShortNode = NumberNode & {
51
+ dataType: "unsigned-short";
52
+ };
53
+ export type IntNode = NumberNode & {
54
+ dataType: "int";
55
+ };
56
+ export type FloatNode = NumberNode & {
57
+ dataType: "float";
58
+ };
59
+ export type DoubleNode = NumberNode & {
60
+ dataType: "double";
61
+ };
62
+ export interface CharNode extends BasePrimitiveNode {
63
+ dataType: "char";
64
+ value: string;
65
+ }
66
+ export interface BooleanNode extends BasePrimitiveNode {
67
+ dataType: "boolean";
68
+ value: boolean;
69
+ }
70
+ export interface LongNode extends BasePrimitiveNode {
71
+ dataType: "long";
72
+ value: bigint;
73
+ }
74
+ export interface UtfNode extends BaseNode<[UnsignedShortNode, UtfBodyNode]> {
75
+ type: "utf";
76
+ }
77
+ export interface LongUtfNode extends BaseNode<[LongNode, UtfBodyNode]> {
78
+ type: "long-utf";
79
+ }
80
+ export interface UtfBodyNode extends BaseNode<null> {
81
+ type: "utf-body";
82
+ value: string;
83
+ }
84
+ export interface BytesNode extends BaseNode<null> {
85
+ type: "bytes";
86
+ }
87
+ export interface SkippedNode extends BaseNode<null> {
88
+ type: "skipped";
89
+ reason: string;
90
+ }
91
+ export interface BlockDataSequenceNode extends BaseNode<BlockDataNode[]> {
92
+ type: "blockdata-sequence";
93
+ values: (PrimitiveNode | UtfNode | SkippedNode)[];
94
+ }
95
+ export interface BlockDataNode extends BaseNode<[
96
+ TC_BLOCKDATA_Node,
97
+ UnsignedByteNode,
98
+ BytesNode
99
+ ] | [
100
+ TC_BLOCKDATALONG_Node,
101
+ LongNode,
102
+ BytesNode
103
+ ]> {
104
+ type: "blockdata";
105
+ }
106
+ export type ObjectNode = NewObjectNode | NewClassNode | NewArrayNode | NewStringNode | NewEnumNode | NewClassDescNode | PrevObjectNode | NullNode | ExceptionNode | ResetNode;
107
+ export type ClassDescNode = NewClassDescNode | NullNode | PrevObjectNode;
108
+ interface BaseObjectNode<C extends [TCNode, ...BaseNode<any>[]]> extends BaseNode<C> {
109
+ type: "object";
110
+ objectType: string;
111
+ }
112
+ export interface NewObjectNode extends BaseObjectNode<[
113
+ TC_OBJECT_Node,
114
+ ClassDescNode,
115
+ ...ClassDataNode[]
116
+ ]> {
117
+ objectType: "new-object";
118
+ handle: Handle;
119
+ }
120
+ export interface NewClassNode extends BaseObjectNode<[TC_CLASS_Node, ClassDescNode]> {
121
+ objectType: "new-class";
122
+ handle: Handle;
123
+ }
124
+ export interface NewArrayNode extends BaseObjectNode<[TC_ARRAY_Node, ClassDescNode, IntNode, ValuesNode]> {
125
+ objectType: "new-array";
126
+ handle: Handle;
127
+ }
128
+ export interface NewStringNode extends BaseObjectNode<[
129
+ TC_STRING_Node,
130
+ UtfNode
131
+ ] | [
132
+ TC_LONGSTRING_Node,
133
+ LongUtfNode
134
+ ]> {
135
+ objectType: "new-string";
136
+ handle: Handle;
137
+ }
138
+ export interface NewEnumNode extends BaseObjectNode<[TC_ENUM_Node, ClassDescNode, ObjectNode]> {
139
+ objectType: "new-enum";
140
+ handle: Handle;
141
+ }
142
+ export interface NewClassDescNode extends BaseObjectNode<[
143
+ TC_CLASSDESC_Node,
144
+ UtfNode,
145
+ LongNode,
146
+ ClassDescInfoNode
147
+ ] | [
148
+ TC_PROXYCLASSDESC_Node,
149
+ ProxyClassDescInfoNode
150
+ ]> {
151
+ objectType: "new-class-desc";
152
+ handle: Handle;
153
+ }
154
+ export interface PrevObjectNode extends BaseObjectNode<[TC_REFERENCE_Node, IntNode]> {
155
+ objectType: "prev-object";
156
+ value: Handle;
157
+ }
158
+ export interface NullNode extends BaseObjectNode<[TC_NULL_Node]> {
159
+ objectType: "null";
160
+ }
161
+ export interface ExceptionNode extends BaseObjectNode<[TC_EXCEPTION_Node, ObjectNode]> {
162
+ objectType: "exception";
163
+ exceptionEpoch: number;
164
+ newEpoch: number;
165
+ }
166
+ export interface ResetNode extends BaseObjectNode<[TC_RESET_Node]> {
167
+ objectType: "reset";
168
+ newEpoch: number;
169
+ }
170
+ export interface ClassDescInfoNode extends BaseNode<[ByteNode, FieldsNode, ContentsNode, TC_ENDBLOCKDATA_Node, ClassDescNode]> {
171
+ type: "class-desc-info";
172
+ }
173
+ export interface ProxyClassDescInfoNode extends BaseNode<[IntNode, ...UtfNode[], ContentsNode, TC_ENDBLOCKDATA_Node, ClassDescNode]> {
174
+ type: "proxy-class-desc-info";
175
+ }
176
+ export type ClassDataNode = NoWrClassNode | WrClassNode | ExternalClassNode | OldExternalClassNode;
177
+ interface BaseClassDataNode<C extends BaseNode<any>[] | null> extends BaseNode<C> {
178
+ type: "class-data";
179
+ classType: string;
180
+ }
181
+ export interface NoWrClassNode extends BaseClassDataNode<[ValuesNode]> {
182
+ classType: "serializable";
183
+ writeMethod: false;
184
+ }
185
+ export interface WrClassNode extends BaseClassDataNode<[
186
+ ValuesNode,
187
+ ContentsNode
188
+ ] | [
189
+ ContentsNode,
190
+ ValuesNode,
191
+ ContentsNode
192
+ ] | [
193
+ ContentsNode,
194
+ ValuesNode
195
+ ] | [
196
+ ContentsNode
197
+ ]> {
198
+ classType: "serializable";
199
+ writeMethod: true;
200
+ }
201
+ export interface ExternalClassNode extends BaseClassDataNode<[ContentsNode]> {
202
+ classType: "externalizable";
203
+ protocolVersion: 2;
204
+ }
205
+ export interface OldExternalClassNode extends BaseClassDataNode<(ObjectNode | PrimitiveNode | UtfNode | BytesNode)[]> {
206
+ classType: "externalizable";
207
+ protocolVersion: 1;
208
+ }
209
+ export interface FieldsNode extends BaseNode<[ShortNode, ...FieldDescNode[]]> {
210
+ type: "fields";
211
+ }
212
+ export interface ValuesNode extends BaseNode<(PrimitiveNode | ObjectNode)[]> {
213
+ type: "values";
214
+ }
215
+ export type FieldDescNode = PrimitiveDescNode | ObjectDescNode;
216
+ export interface PrimitiveDescNode extends BaseNode<[UnsignedByteNode, UtfNode]> {
217
+ type: "field-desc";
218
+ fieldType: "primitive";
219
+ }
220
+ export interface ObjectDescNode extends BaseNode<[UnsignedByteNode, UtfNode, ObjectNode]> {
221
+ type: "field-desc";
222
+ fieldType: "object";
223
+ }
224
+ interface BaseTCNode extends BaseNode<null> {
225
+ type: "tc";
226
+ value: number;
227
+ }
228
+ type TCNode = TC_NULL_Node | TC_REFERENCE_Node | TC_CLASSDESC_Node | TC_OBJECT_Node | TC_STRING_Node | TC_ARRAY_Node | TC_CLASS_Node | TC_BLOCKDATA_Node | TC_ENDBLOCKDATA_Node | TC_RESET_Node | TC_BLOCKDATALONG_Node | TC_EXCEPTION_Node | TC_LONGSTRING_Node | TC_PROXYCLASSDESC_Node | TC_ENUM_Node;
229
+ export type TC_NULL_Node = BaseTCNode & {
230
+ value: typeof ObjectInputStream.TC_NULL;
231
+ };
232
+ export type TC_REFERENCE_Node = BaseTCNode & {
233
+ value: typeof ObjectInputStream.TC_REFERENCE;
234
+ };
235
+ export type TC_CLASSDESC_Node = BaseTCNode & {
236
+ value: typeof ObjectInputStream.TC_CLASSDESC;
237
+ };
238
+ export type TC_OBJECT_Node = BaseTCNode & {
239
+ value: typeof ObjectInputStream.TC_OBJECT;
240
+ };
241
+ export type TC_STRING_Node = BaseTCNode & {
242
+ value: typeof ObjectInputStream.TC_STRING;
243
+ };
244
+ export type TC_ARRAY_Node = BaseTCNode & {
245
+ value: typeof ObjectInputStream.TC_ARRAY;
246
+ };
247
+ export type TC_CLASS_Node = BaseTCNode & {
248
+ value: typeof ObjectInputStream.TC_CLASS;
249
+ };
250
+ export type TC_BLOCKDATA_Node = BaseTCNode & {
251
+ value: typeof ObjectInputStream.TC_BLOCKDATA;
252
+ };
253
+ export type TC_ENDBLOCKDATA_Node = BaseTCNode & {
254
+ value: typeof ObjectInputStream.TC_ENDBLOCKDATA;
255
+ };
256
+ export type TC_RESET_Node = BaseTCNode & {
257
+ value: typeof ObjectInputStream.TC_RESET;
258
+ };
259
+ export type TC_BLOCKDATALONG_Node = BaseTCNode & {
260
+ value: typeof ObjectInputStream.TC_BLOCKDATALONG;
261
+ };
262
+ export type TC_EXCEPTION_Node = BaseTCNode & {
263
+ value: typeof ObjectInputStream.TC_EXCEPTION;
264
+ };
265
+ export type TC_LONGSTRING_Node = BaseTCNode & {
266
+ value: typeof ObjectInputStream.TC_LONGSTRING;
267
+ };
268
+ export type TC_PROXYCLASSDESC_Node = BaseTCNode & {
269
+ value: typeof ObjectInputStream.TC_PROXYCLASSDESC;
270
+ };
271
+ export type TC_ENUM_Node = BaseTCNode & {
272
+ value: typeof ObjectInputStream.TC_ENUM;
273
+ };
274
+ export type Handle = {
275
+ epoch: number;
276
+ handle: number;
277
+ };
278
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,GAAG,CAAC;AAevC,MAAM,WAAW,GAAG;IAChB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,QAAQ,CAAA;CACjB;AACD,eAAe,GAAG,CAAA;AAElB,MAAM,MAAM,IAAI,GACZ,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,GACjD,qBAAqB,GAAG,aAAa,GACrC,aAAa,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAC7E,UAAU,GAAG,MAAM,GAAG,iBAAiB,GAAG,sBAAsB,CAAA;AAEpE,MAAM,WAAW,QAAS,SAAQ,QAAQ,CAAC,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AAK,EAAE,OAAO,iBAAiB,CAAC,YAAY,CAAA;CAAC,CAAA;AAChG,MAAM,MAAM,kBAAkB,GAAO,UAAU,GAAG;IAAC,KAAK,EAAE,OAAO,iBAAiB,CAAC,aAAa,CAAA;CAAC,CAAA;AACjG,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG;IAAC,KAAK,EAAE,OAAO,iBAAiB,CAAC,iBAAiB,CAAA;CAAC,CAAA;AACrG,MAAM,MAAM,YAAY,GAAa,UAAU,GAAG;IAAC,KAAK,EAAE,OAAO,iBAAiB,CAAC,OAAO,CAAA;CAAC,CAAA;AAE3F,MAAM,MAAM,MAAM,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAA"}
package/dist/ast.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":""}