@ianlucas/cs2-lib-inspect 1.0.2 → 1.0.3
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/econ.d.ts +141 -0
- package/dist/econ.js +422 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.js +90 -0
- package/package.json +3 -7
- package/dist/esm/index.js +0 -559
package/dist/econ.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
4
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
5
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
6
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
7
|
+
/**
|
|
8
|
+
* @generated from protobuf message CEconItemPreviewDataBlock
|
|
9
|
+
*/
|
|
10
|
+
export interface CEconItemPreviewDataBlock {
|
|
11
|
+
/**
|
|
12
|
+
* @generated from protobuf field: optional uint32 accountid = 1;
|
|
13
|
+
*/
|
|
14
|
+
accountid?: number;
|
|
15
|
+
/**
|
|
16
|
+
* @generated from protobuf field: optional uint64 itemid = 2;
|
|
17
|
+
*/
|
|
18
|
+
itemid?: bigint;
|
|
19
|
+
/**
|
|
20
|
+
* @generated from protobuf field: optional uint32 defindex = 3;
|
|
21
|
+
*/
|
|
22
|
+
defindex?: number;
|
|
23
|
+
/**
|
|
24
|
+
* @generated from protobuf field: optional uint32 paintindex = 4;
|
|
25
|
+
*/
|
|
26
|
+
paintindex?: number;
|
|
27
|
+
/**
|
|
28
|
+
* @generated from protobuf field: optional uint32 rarity = 5;
|
|
29
|
+
*/
|
|
30
|
+
rarity?: number;
|
|
31
|
+
/**
|
|
32
|
+
* @generated from protobuf field: optional uint32 quality = 6;
|
|
33
|
+
*/
|
|
34
|
+
quality?: number;
|
|
35
|
+
/**
|
|
36
|
+
* @generated from protobuf field: optional uint32 paintwear = 7;
|
|
37
|
+
*/
|
|
38
|
+
paintwear?: number;
|
|
39
|
+
/**
|
|
40
|
+
* @generated from protobuf field: optional uint32 paintseed = 8;
|
|
41
|
+
*/
|
|
42
|
+
paintseed?: number;
|
|
43
|
+
/**
|
|
44
|
+
* @generated from protobuf field: optional uint32 killeaterscoretype = 9;
|
|
45
|
+
*/
|
|
46
|
+
killeaterscoretype?: number;
|
|
47
|
+
/**
|
|
48
|
+
* @generated from protobuf field: optional uint32 killeatervalue = 10;
|
|
49
|
+
*/
|
|
50
|
+
killeatervalue?: number;
|
|
51
|
+
/**
|
|
52
|
+
* @generated from protobuf field: optional string customname = 11;
|
|
53
|
+
*/
|
|
54
|
+
customname?: string;
|
|
55
|
+
/**
|
|
56
|
+
* @generated from protobuf field: repeated CEconItemPreviewDataBlock.Sticker stickers = 12;
|
|
57
|
+
*/
|
|
58
|
+
stickers: CEconItemPreviewDataBlock_Sticker[];
|
|
59
|
+
/**
|
|
60
|
+
* @generated from protobuf field: optional uint32 inventory = 13;
|
|
61
|
+
*/
|
|
62
|
+
inventory?: number;
|
|
63
|
+
/**
|
|
64
|
+
* @generated from protobuf field: optional uint32 origin = 14;
|
|
65
|
+
*/
|
|
66
|
+
origin?: number;
|
|
67
|
+
/**
|
|
68
|
+
* @generated from protobuf field: optional uint32 questid = 15;
|
|
69
|
+
*/
|
|
70
|
+
questid?: number;
|
|
71
|
+
/**
|
|
72
|
+
* @generated from protobuf field: optional uint32 dropreason = 16;
|
|
73
|
+
*/
|
|
74
|
+
dropreason?: number;
|
|
75
|
+
/**
|
|
76
|
+
* @generated from protobuf field: optional uint32 musicindex = 17;
|
|
77
|
+
*/
|
|
78
|
+
musicindex?: number;
|
|
79
|
+
/**
|
|
80
|
+
* @generated from protobuf field: optional int32 entindex = 18;
|
|
81
|
+
*/
|
|
82
|
+
entindex?: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @generated from protobuf message CEconItemPreviewDataBlock.Sticker
|
|
86
|
+
*/
|
|
87
|
+
export interface CEconItemPreviewDataBlock_Sticker {
|
|
88
|
+
/**
|
|
89
|
+
* @generated from protobuf field: optional uint32 slot = 1;
|
|
90
|
+
*/
|
|
91
|
+
slot?: number;
|
|
92
|
+
/**
|
|
93
|
+
* @generated from protobuf field: optional uint32 sticker_id = 2;
|
|
94
|
+
*/
|
|
95
|
+
stickerId?: number;
|
|
96
|
+
/**
|
|
97
|
+
* @generated from protobuf field: optional float wear = 3;
|
|
98
|
+
*/
|
|
99
|
+
wear?: number;
|
|
100
|
+
/**
|
|
101
|
+
* @generated from protobuf field: optional float scale = 4;
|
|
102
|
+
*/
|
|
103
|
+
scale?: number;
|
|
104
|
+
/**
|
|
105
|
+
* @generated from protobuf field: optional float rotation = 5;
|
|
106
|
+
*/
|
|
107
|
+
rotation?: number;
|
|
108
|
+
/**
|
|
109
|
+
* @generated from protobuf field: optional uint32 tint_id = 6;
|
|
110
|
+
*/
|
|
111
|
+
tintId?: number;
|
|
112
|
+
/**
|
|
113
|
+
* @generated from protobuf field: optional uint32 offset_x = 7;
|
|
114
|
+
*/
|
|
115
|
+
offsetX?: number;
|
|
116
|
+
/**
|
|
117
|
+
* @generated from protobuf field: optional uint32 offset_y = 8;
|
|
118
|
+
*/
|
|
119
|
+
offsetY?: number;
|
|
120
|
+
}
|
|
121
|
+
declare class CEconItemPreviewDataBlock$Type extends MessageType<CEconItemPreviewDataBlock> {
|
|
122
|
+
constructor();
|
|
123
|
+
create(value?: PartialMessage<CEconItemPreviewDataBlock>): CEconItemPreviewDataBlock;
|
|
124
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: CEconItemPreviewDataBlock): CEconItemPreviewDataBlock;
|
|
125
|
+
internalBinaryWrite(message: CEconItemPreviewDataBlock, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @generated MessageType for protobuf message CEconItemPreviewDataBlock
|
|
129
|
+
*/
|
|
130
|
+
export declare const CEconItemPreviewDataBlock: CEconItemPreviewDataBlock$Type;
|
|
131
|
+
declare class CEconItemPreviewDataBlock_Sticker$Type extends MessageType<CEconItemPreviewDataBlock_Sticker> {
|
|
132
|
+
constructor();
|
|
133
|
+
create(value?: PartialMessage<CEconItemPreviewDataBlock_Sticker>): CEconItemPreviewDataBlock_Sticker;
|
|
134
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: CEconItemPreviewDataBlock_Sticker): CEconItemPreviewDataBlock_Sticker;
|
|
135
|
+
internalBinaryWrite(message: CEconItemPreviewDataBlock_Sticker, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @generated MessageType for protobuf message CEconItemPreviewDataBlock.Sticker
|
|
139
|
+
*/
|
|
140
|
+
export declare const CEconItemPreviewDataBlock_Sticker: CEconItemPreviewDataBlock_Sticker$Type;
|
|
141
|
+
export {};
|
package/dist/econ.js
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { WireType } from "@protobuf-ts/runtime";
|
|
2
|
+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
3
|
+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
4
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
5
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
6
|
+
class CEconItemPreviewDataBlock$Type extends MessageType {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("CEconItemPreviewDataBlock", [
|
|
9
|
+
{
|
|
10
|
+
no: 1,
|
|
11
|
+
name: "accountid",
|
|
12
|
+
kind: "scalar",
|
|
13
|
+
opt: true,
|
|
14
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
no: 2,
|
|
18
|
+
name: "itemid",
|
|
19
|
+
kind: "scalar",
|
|
20
|
+
opt: true,
|
|
21
|
+
T: 4 /*ScalarType.UINT64*/,
|
|
22
|
+
L: 0 /*LongType.BIGINT*/,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
no: 3,
|
|
26
|
+
name: "defindex",
|
|
27
|
+
kind: "scalar",
|
|
28
|
+
opt: true,
|
|
29
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
no: 4,
|
|
33
|
+
name: "paintindex",
|
|
34
|
+
kind: "scalar",
|
|
35
|
+
opt: true,
|
|
36
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
no: 5,
|
|
40
|
+
name: "rarity",
|
|
41
|
+
kind: "scalar",
|
|
42
|
+
opt: true,
|
|
43
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
no: 6,
|
|
47
|
+
name: "quality",
|
|
48
|
+
kind: "scalar",
|
|
49
|
+
opt: true,
|
|
50
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
no: 7,
|
|
54
|
+
name: "paintwear",
|
|
55
|
+
kind: "scalar",
|
|
56
|
+
opt: true,
|
|
57
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
no: 8,
|
|
61
|
+
name: "paintseed",
|
|
62
|
+
kind: "scalar",
|
|
63
|
+
opt: true,
|
|
64
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
no: 9,
|
|
68
|
+
name: "killeaterscoretype",
|
|
69
|
+
kind: "scalar",
|
|
70
|
+
opt: true,
|
|
71
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
no: 10,
|
|
75
|
+
name: "killeatervalue",
|
|
76
|
+
kind: "scalar",
|
|
77
|
+
opt: true,
|
|
78
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
no: 11,
|
|
82
|
+
name: "customname",
|
|
83
|
+
kind: "scalar",
|
|
84
|
+
opt: true,
|
|
85
|
+
T: 9 /*ScalarType.STRING*/,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
no: 12,
|
|
89
|
+
name: "stickers",
|
|
90
|
+
kind: "message",
|
|
91
|
+
repeat: 1 /*RepeatType.PACKED*/,
|
|
92
|
+
T: () => CEconItemPreviewDataBlock_Sticker,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
no: 13,
|
|
96
|
+
name: "inventory",
|
|
97
|
+
kind: "scalar",
|
|
98
|
+
opt: true,
|
|
99
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
no: 14,
|
|
103
|
+
name: "origin",
|
|
104
|
+
kind: "scalar",
|
|
105
|
+
opt: true,
|
|
106
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
no: 15,
|
|
110
|
+
name: "questid",
|
|
111
|
+
kind: "scalar",
|
|
112
|
+
opt: true,
|
|
113
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
no: 16,
|
|
117
|
+
name: "dropreason",
|
|
118
|
+
kind: "scalar",
|
|
119
|
+
opt: true,
|
|
120
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
no: 17,
|
|
124
|
+
name: "musicindex",
|
|
125
|
+
kind: "scalar",
|
|
126
|
+
opt: true,
|
|
127
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
no: 18,
|
|
131
|
+
name: "entindex",
|
|
132
|
+
kind: "scalar",
|
|
133
|
+
opt: true,
|
|
134
|
+
T: 5 /*ScalarType.INT32*/,
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
create(value) {
|
|
139
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
140
|
+
message.stickers = [];
|
|
141
|
+
if (value !== undefined)
|
|
142
|
+
reflectionMergePartial(this, message, value);
|
|
143
|
+
return message;
|
|
144
|
+
}
|
|
145
|
+
internalBinaryRead(reader, length, options, target) {
|
|
146
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
147
|
+
while (reader.pos < end) {
|
|
148
|
+
let [fieldNo, wireType] = reader.tag();
|
|
149
|
+
switch (fieldNo) {
|
|
150
|
+
case /* optional uint32 accountid */ 1:
|
|
151
|
+
message.accountid = reader.uint32();
|
|
152
|
+
break;
|
|
153
|
+
case /* optional uint64 itemid */ 2:
|
|
154
|
+
message.itemid = reader.uint64().toBigInt();
|
|
155
|
+
break;
|
|
156
|
+
case /* optional uint32 defindex */ 3:
|
|
157
|
+
message.defindex = reader.uint32();
|
|
158
|
+
break;
|
|
159
|
+
case /* optional uint32 paintindex */ 4:
|
|
160
|
+
message.paintindex = reader.uint32();
|
|
161
|
+
break;
|
|
162
|
+
case /* optional uint32 rarity */ 5:
|
|
163
|
+
message.rarity = reader.uint32();
|
|
164
|
+
break;
|
|
165
|
+
case /* optional uint32 quality */ 6:
|
|
166
|
+
message.quality = reader.uint32();
|
|
167
|
+
break;
|
|
168
|
+
case /* optional uint32 paintwear */ 7:
|
|
169
|
+
message.paintwear = reader.uint32();
|
|
170
|
+
break;
|
|
171
|
+
case /* optional uint32 paintseed */ 8:
|
|
172
|
+
message.paintseed = reader.uint32();
|
|
173
|
+
break;
|
|
174
|
+
case /* optional uint32 killeaterscoretype */ 9:
|
|
175
|
+
message.killeaterscoretype = reader.uint32();
|
|
176
|
+
break;
|
|
177
|
+
case /* optional uint32 killeatervalue */ 10:
|
|
178
|
+
message.killeatervalue = reader.uint32();
|
|
179
|
+
break;
|
|
180
|
+
case /* optional string customname */ 11:
|
|
181
|
+
message.customname = reader.string();
|
|
182
|
+
break;
|
|
183
|
+
case /* repeated CEconItemPreviewDataBlock.Sticker stickers */ 12:
|
|
184
|
+
message.stickers.push(CEconItemPreviewDataBlock_Sticker.internalBinaryRead(reader, reader.uint32(), options));
|
|
185
|
+
break;
|
|
186
|
+
case /* optional uint32 inventory */ 13:
|
|
187
|
+
message.inventory = reader.uint32();
|
|
188
|
+
break;
|
|
189
|
+
case /* optional uint32 origin */ 14:
|
|
190
|
+
message.origin = reader.uint32();
|
|
191
|
+
break;
|
|
192
|
+
case /* optional uint32 questid */ 15:
|
|
193
|
+
message.questid = reader.uint32();
|
|
194
|
+
break;
|
|
195
|
+
case /* optional uint32 dropreason */ 16:
|
|
196
|
+
message.dropreason = reader.uint32();
|
|
197
|
+
break;
|
|
198
|
+
case /* optional uint32 musicindex */ 17:
|
|
199
|
+
message.musicindex = reader.uint32();
|
|
200
|
+
break;
|
|
201
|
+
case /* optional int32 entindex */ 18:
|
|
202
|
+
message.entindex = reader.int32();
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
let u = options.readUnknownField;
|
|
206
|
+
if (u === "throw")
|
|
207
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
208
|
+
let d = reader.skip(wireType);
|
|
209
|
+
if (u !== false)
|
|
210
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return message;
|
|
214
|
+
}
|
|
215
|
+
internalBinaryWrite(message, writer, options) {
|
|
216
|
+
/* optional uint32 accountid = 1; */
|
|
217
|
+
if (message.accountid !== undefined)
|
|
218
|
+
writer.tag(1, WireType.Varint).uint32(message.accountid);
|
|
219
|
+
/* optional uint64 itemid = 2; */
|
|
220
|
+
if (message.itemid !== undefined)
|
|
221
|
+
writer.tag(2, WireType.Varint).uint64(message.itemid);
|
|
222
|
+
/* optional uint32 defindex = 3; */
|
|
223
|
+
if (message.defindex !== undefined)
|
|
224
|
+
writer.tag(3, WireType.Varint).uint32(message.defindex);
|
|
225
|
+
/* optional uint32 paintindex = 4; */
|
|
226
|
+
if (message.paintindex !== undefined)
|
|
227
|
+
writer.tag(4, WireType.Varint).uint32(message.paintindex);
|
|
228
|
+
/* optional uint32 rarity = 5; */
|
|
229
|
+
if (message.rarity !== undefined)
|
|
230
|
+
writer.tag(5, WireType.Varint).uint32(message.rarity);
|
|
231
|
+
/* optional uint32 quality = 6; */
|
|
232
|
+
if (message.quality !== undefined)
|
|
233
|
+
writer.tag(6, WireType.Varint).uint32(message.quality);
|
|
234
|
+
/* optional uint32 paintwear = 7; */
|
|
235
|
+
if (message.paintwear !== undefined)
|
|
236
|
+
writer.tag(7, WireType.Varint).uint32(message.paintwear);
|
|
237
|
+
/* optional uint32 paintseed = 8; */
|
|
238
|
+
if (message.paintseed !== undefined)
|
|
239
|
+
writer.tag(8, WireType.Varint).uint32(message.paintseed);
|
|
240
|
+
/* optional uint32 killeaterscoretype = 9; */
|
|
241
|
+
if (message.killeaterscoretype !== undefined)
|
|
242
|
+
writer.tag(9, WireType.Varint).uint32(message.killeaterscoretype);
|
|
243
|
+
/* optional uint32 killeatervalue = 10; */
|
|
244
|
+
if (message.killeatervalue !== undefined)
|
|
245
|
+
writer.tag(10, WireType.Varint).uint32(message.killeatervalue);
|
|
246
|
+
/* optional string customname = 11; */
|
|
247
|
+
if (message.customname !== undefined)
|
|
248
|
+
writer.tag(11, WireType.LengthDelimited).string(message.customname);
|
|
249
|
+
/* repeated CEconItemPreviewDataBlock.Sticker stickers = 12; */
|
|
250
|
+
for (let i = 0; i < message.stickers.length; i++)
|
|
251
|
+
CEconItemPreviewDataBlock_Sticker.internalBinaryWrite(message.stickers[i], writer.tag(12, WireType.LengthDelimited).fork(), options).join();
|
|
252
|
+
/* optional uint32 inventory = 13; */
|
|
253
|
+
if (message.inventory !== undefined)
|
|
254
|
+
writer.tag(13, WireType.Varint).uint32(message.inventory);
|
|
255
|
+
/* optional uint32 origin = 14; */
|
|
256
|
+
if (message.origin !== undefined)
|
|
257
|
+
writer.tag(14, WireType.Varint).uint32(message.origin);
|
|
258
|
+
/* optional uint32 questid = 15; */
|
|
259
|
+
if (message.questid !== undefined)
|
|
260
|
+
writer.tag(15, WireType.Varint).uint32(message.questid);
|
|
261
|
+
/* optional uint32 dropreason = 16; */
|
|
262
|
+
if (message.dropreason !== undefined)
|
|
263
|
+
writer.tag(16, WireType.Varint).uint32(message.dropreason);
|
|
264
|
+
/* optional uint32 musicindex = 17; */
|
|
265
|
+
if (message.musicindex !== undefined)
|
|
266
|
+
writer.tag(17, WireType.Varint).uint32(message.musicindex);
|
|
267
|
+
/* optional int32 entindex = 18; */
|
|
268
|
+
if (message.entindex !== undefined)
|
|
269
|
+
writer.tag(18, WireType.Varint).int32(message.entindex);
|
|
270
|
+
let u = options.writeUnknownFields;
|
|
271
|
+
if (u !== false)
|
|
272
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
273
|
+
return writer;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @generated MessageType for protobuf message CEconItemPreviewDataBlock
|
|
278
|
+
*/
|
|
279
|
+
export const CEconItemPreviewDataBlock = new CEconItemPreviewDataBlock$Type();
|
|
280
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
281
|
+
class CEconItemPreviewDataBlock_Sticker$Type extends MessageType {
|
|
282
|
+
constructor() {
|
|
283
|
+
super("CEconItemPreviewDataBlock.Sticker", [
|
|
284
|
+
{
|
|
285
|
+
no: 1,
|
|
286
|
+
name: "slot",
|
|
287
|
+
kind: "scalar",
|
|
288
|
+
opt: true,
|
|
289
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
no: 2,
|
|
293
|
+
name: "sticker_id",
|
|
294
|
+
kind: "scalar",
|
|
295
|
+
opt: true,
|
|
296
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
no: 3,
|
|
300
|
+
name: "wear",
|
|
301
|
+
kind: "scalar",
|
|
302
|
+
opt: true,
|
|
303
|
+
T: 2 /*ScalarType.FLOAT*/,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
no: 4,
|
|
307
|
+
name: "scale",
|
|
308
|
+
kind: "scalar",
|
|
309
|
+
opt: true,
|
|
310
|
+
T: 2 /*ScalarType.FLOAT*/,
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
no: 5,
|
|
314
|
+
name: "rotation",
|
|
315
|
+
kind: "scalar",
|
|
316
|
+
opt: true,
|
|
317
|
+
T: 2 /*ScalarType.FLOAT*/,
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
no: 6,
|
|
321
|
+
name: "tint_id",
|
|
322
|
+
kind: "scalar",
|
|
323
|
+
opt: true,
|
|
324
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
no: 7,
|
|
328
|
+
name: "offset_x",
|
|
329
|
+
kind: "scalar",
|
|
330
|
+
opt: true,
|
|
331
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
no: 8,
|
|
335
|
+
name: "offset_y",
|
|
336
|
+
kind: "scalar",
|
|
337
|
+
opt: true,
|
|
338
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
339
|
+
},
|
|
340
|
+
]);
|
|
341
|
+
}
|
|
342
|
+
create(value) {
|
|
343
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
344
|
+
if (value !== undefined)
|
|
345
|
+
reflectionMergePartial(this, message, value);
|
|
346
|
+
return message;
|
|
347
|
+
}
|
|
348
|
+
internalBinaryRead(reader, length, options, target) {
|
|
349
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
350
|
+
while (reader.pos < end) {
|
|
351
|
+
let [fieldNo, wireType] = reader.tag();
|
|
352
|
+
switch (fieldNo) {
|
|
353
|
+
case /* optional uint32 slot */ 1:
|
|
354
|
+
message.slot = reader.uint32();
|
|
355
|
+
break;
|
|
356
|
+
case /* optional uint32 sticker_id */ 2:
|
|
357
|
+
message.stickerId = reader.uint32();
|
|
358
|
+
break;
|
|
359
|
+
case /* optional float wear */ 3:
|
|
360
|
+
message.wear = reader.float();
|
|
361
|
+
break;
|
|
362
|
+
case /* optional float scale */ 4:
|
|
363
|
+
message.scale = reader.float();
|
|
364
|
+
break;
|
|
365
|
+
case /* optional float rotation */ 5:
|
|
366
|
+
message.rotation = reader.float();
|
|
367
|
+
break;
|
|
368
|
+
case /* optional uint32 tint_id */ 6:
|
|
369
|
+
message.tintId = reader.uint32();
|
|
370
|
+
break;
|
|
371
|
+
case /* optional uint32 offset_x */ 7:
|
|
372
|
+
message.offsetX = reader.uint32();
|
|
373
|
+
break;
|
|
374
|
+
case /* optional uint32 offset_y */ 8:
|
|
375
|
+
message.offsetY = reader.uint32();
|
|
376
|
+
break;
|
|
377
|
+
default:
|
|
378
|
+
let u = options.readUnknownField;
|
|
379
|
+
if (u === "throw")
|
|
380
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
381
|
+
let d = reader.skip(wireType);
|
|
382
|
+
if (u !== false)
|
|
383
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return message;
|
|
387
|
+
}
|
|
388
|
+
internalBinaryWrite(message, writer, options) {
|
|
389
|
+
/* optional uint32 slot = 1; */
|
|
390
|
+
if (message.slot !== undefined)
|
|
391
|
+
writer.tag(1, WireType.Varint).uint32(message.slot);
|
|
392
|
+
/* optional uint32 sticker_id = 2; */
|
|
393
|
+
if (message.stickerId !== undefined)
|
|
394
|
+
writer.tag(2, WireType.Varint).uint32(message.stickerId);
|
|
395
|
+
/* optional float wear = 3; */
|
|
396
|
+
if (message.wear !== undefined)
|
|
397
|
+
writer.tag(3, WireType.Bit32).float(message.wear);
|
|
398
|
+
/* optional float scale = 4; */
|
|
399
|
+
if (message.scale !== undefined)
|
|
400
|
+
writer.tag(4, WireType.Bit32).float(message.scale);
|
|
401
|
+
/* optional float rotation = 5; */
|
|
402
|
+
if (message.rotation !== undefined)
|
|
403
|
+
writer.tag(5, WireType.Bit32).float(message.rotation);
|
|
404
|
+
/* optional uint32 tint_id = 6; */
|
|
405
|
+
if (message.tintId !== undefined)
|
|
406
|
+
writer.tag(6, WireType.Varint).uint32(message.tintId);
|
|
407
|
+
/* optional uint32 offset_x = 7; */
|
|
408
|
+
if (message.offsetX !== undefined)
|
|
409
|
+
writer.tag(7, WireType.Varint).uint32(message.offsetX);
|
|
410
|
+
/* optional uint32 offset_y = 8; */
|
|
411
|
+
if (message.offsetY !== undefined)
|
|
412
|
+
writer.tag(8, WireType.Varint).uint32(message.offsetY);
|
|
413
|
+
let u = options.writeUnknownFields;
|
|
414
|
+
if (u !== false)
|
|
415
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
416
|
+
return writer;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @generated MessageType for protobuf message CEconItemPreviewDataBlock.Sticker
|
|
421
|
+
*/
|
|
422
|
+
export const CEconItemPreviewDataBlock_Sticker = new CEconItemPreviewDataBlock_Sticker$Type();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
declare function CS_generateInspectLink(item: CS_Item | CS_BaseInventoryItem | CS_InventoryItem): string;
|
|
5
|
-
|
|
6
|
-
export { CS_PREVIEW_URL, CS_generateInspectLink };
|
|
1
|
+
import { CS_BaseInventoryItem, CS_InventoryItem, CS_Item } from "@ianlucas/cs2-lib";
|
|
2
|
+
export declare const CS_PREVIEW_URL = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20";
|
|
3
|
+
export declare function CS_generateInspectLink(item: CS_Item | CS_BaseInventoryItem | CS_InventoryItem): string;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) candyboyz, Ian Lucas. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { CS_Economy, CS_MIN_SEED, CS_MIN_STICKER_WEAR, CS_MIN_WEAR, CS_NONE, CS_RARITY_ANCIENT_COLOR, CS_RARITY_COMMON_COLOR, CS_RARITY_IMMORTAL_COLOR, CS_RARITY_LEGENDARY_COLOR, CS_RARITY_MYTHICAL_COLOR, CS_RARITY_RARE_COLOR, CS_RARITY_UNCOMMON_COLOR } from "@ianlucas/cs2-lib";
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
|
+
import CRC32 from "crc-32";
|
|
8
|
+
import { CEconItemPreviewDataBlock } from "./econ";
|
|
9
|
+
const CS_RARITY_INT = {
|
|
10
|
+
[CS_RARITY_COMMON_COLOR]: 1,
|
|
11
|
+
[CS_RARITY_UNCOMMON_COLOR]: 2,
|
|
12
|
+
[CS_RARITY_RARE_COLOR]: 3,
|
|
13
|
+
[CS_RARITY_MYTHICAL_COLOR]: 4,
|
|
14
|
+
[CS_RARITY_LEGENDARY_COLOR]: 5,
|
|
15
|
+
[CS_RARITY_ANCIENT_COLOR]: 6,
|
|
16
|
+
[CS_RARITY_IMMORTAL_COLOR]: 7
|
|
17
|
+
};
|
|
18
|
+
const MISSING_ITEM_DEF = {
|
|
19
|
+
graffiti: 1348,
|
|
20
|
+
patch: 4609,
|
|
21
|
+
sticker: 1209,
|
|
22
|
+
musickit: 1314
|
|
23
|
+
};
|
|
24
|
+
export const CS_PREVIEW_URL = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20";
|
|
25
|
+
function floatToBytes(floatValue) {
|
|
26
|
+
const floatArray = new Float32Array(1);
|
|
27
|
+
floatArray[0] = floatValue;
|
|
28
|
+
const byteArray = new Uint32Array(floatArray.buffer);
|
|
29
|
+
return byteArray[0];
|
|
30
|
+
}
|
|
31
|
+
function getItemAttributes(item) {
|
|
32
|
+
const { def, index, rarity, type, tint, wearmin } = item;
|
|
33
|
+
const hasStickerObject = MISSING_ITEM_DEF[type] !== undefined;
|
|
34
|
+
const hasPaintIndex = !hasStickerObject && type !== "musickit";
|
|
35
|
+
return {
|
|
36
|
+
defindex: MISSING_ITEM_DEF[type] ?? def,
|
|
37
|
+
musicindex: type === "musickit" ? index : undefined,
|
|
38
|
+
paintindex: hasPaintIndex ? index : undefined,
|
|
39
|
+
paintseed: CS_Economy.hasSeed(item) ? CS_MIN_SEED : undefined,
|
|
40
|
+
paintwear: CS_Economy.hasWear(item) ? wearmin ?? CS_MIN_WEAR : undefined,
|
|
41
|
+
rarity: CS_RARITY_INT[rarity] ?? 0,
|
|
42
|
+
stickers: hasStickerObject
|
|
43
|
+
? [
|
|
44
|
+
{
|
|
45
|
+
tintId: tint,
|
|
46
|
+
stickerId: index,
|
|
47
|
+
slot: 0
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
: []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function getBaseInventoryItemAttributes({ id, nametag, seed, stattrak, stickers, stickerswear, wear }) {
|
|
54
|
+
const item = CS_Economy.getById(id);
|
|
55
|
+
const baseAttributes = getItemAttributes(item);
|
|
56
|
+
return {
|
|
57
|
+
...baseAttributes,
|
|
58
|
+
customname: nametag,
|
|
59
|
+
killeaterscoretype: stattrak !== undefined ? 0 : undefined,
|
|
60
|
+
killeatervalue: stattrak,
|
|
61
|
+
paintseed: CS_Economy.hasSeed(item) ? seed ?? CS_MIN_SEED : undefined,
|
|
62
|
+
paintwear: CS_Economy.hasWear(item) ? floatToBytes(wear ?? item.wearmin ?? CS_MIN_WEAR) : undefined,
|
|
63
|
+
stickers: stickers !== undefined
|
|
64
|
+
? stickers
|
|
65
|
+
.map((sticker, slot) => ({
|
|
66
|
+
slot,
|
|
67
|
+
stickerId: CS_Economy.getById(sticker).index,
|
|
68
|
+
wear: stickerswear?.[slot] ?? CS_MIN_STICKER_WEAR
|
|
69
|
+
}))
|
|
70
|
+
.filter(({ stickerId }) => stickerId !== CS_NONE)
|
|
71
|
+
: baseAttributes.stickers
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function generateHex(attributes) {
|
|
75
|
+
const payload = Buffer.concat([Uint8Array.from([0]), CEconItemPreviewDataBlock.toBinary(attributes)]);
|
|
76
|
+
const crc = CRC32.buf(payload);
|
|
77
|
+
const xCrc = (crc & 0xffff) ^ (CEconItemPreviewDataBlock.toBinary(attributes).byteLength * crc);
|
|
78
|
+
const crcBuffer = Buffer.alloc(4);
|
|
79
|
+
crcBuffer.writeUInt32BE((xCrc & 0xffffffff) >>> 0, 0);
|
|
80
|
+
const buffer = Buffer.concat([payload, crcBuffer]);
|
|
81
|
+
return buffer.toString("hex").toUpperCase();
|
|
82
|
+
}
|
|
83
|
+
export function CS_generateInspectLink(item) {
|
|
84
|
+
const econ = {
|
|
85
|
+
...(typeof item.uid === undefined
|
|
86
|
+
? getItemAttributes(item)
|
|
87
|
+
: getBaseInventoryItemAttributes(item))
|
|
88
|
+
};
|
|
89
|
+
return `${CS_PREVIEW_URL}${generateHex(econ)}`;
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ianlucas/cs2-lib-inspect",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A utility for creating inspect links for CS2 items",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "ianlucas/cs2-lib-inspect",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/esm/index.js",
|
|
9
9
|
"types": "dist/index.d.mts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist/**/*"
|
|
12
|
-
],
|
|
13
10
|
"scripts": {
|
|
14
11
|
"format": "prettier . --write",
|
|
15
|
-
"prepack": "
|
|
16
|
-
"protoc": "npx protoc --ts_out src --proto_path protos protos/econ.proto",
|
|
12
|
+
"prepack": "([ -d dist ] && rm -rf dist); tsc",
|
|
13
|
+
"protoc": "npx protoc --ts_out src --proto_path src/protos protos/econ.proto",
|
|
17
14
|
"test": "jest"
|
|
18
15
|
},
|
|
19
16
|
"dependencies": {
|
|
@@ -27,7 +24,6 @@
|
|
|
27
24
|
"devDependencies": {
|
|
28
25
|
"@protobuf-ts/plugin": "^2.9.3",
|
|
29
26
|
"prettier": "^3.2.5",
|
|
30
|
-
"tsup": "^8.0.1",
|
|
31
27
|
"typescript": "^5.3.3"
|
|
32
28
|
}
|
|
33
29
|
}
|
package/dist/esm/index.js
DELETED
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import {
|
|
3
|
-
CS_Economy,
|
|
4
|
-
CS_MIN_SEED,
|
|
5
|
-
CS_MIN_STICKER_WEAR,
|
|
6
|
-
CS_MIN_WEAR,
|
|
7
|
-
CS_NONE,
|
|
8
|
-
CS_RARITY_ANCIENT_COLOR,
|
|
9
|
-
CS_RARITY_COMMON_COLOR,
|
|
10
|
-
CS_RARITY_IMMORTAL_COLOR,
|
|
11
|
-
CS_RARITY_LEGENDARY_COLOR,
|
|
12
|
-
CS_RARITY_MYTHICAL_COLOR,
|
|
13
|
-
CS_RARITY_RARE_COLOR,
|
|
14
|
-
CS_RARITY_UNCOMMON_COLOR
|
|
15
|
-
} from "@ianlucas/cs2-lib";
|
|
16
|
-
import { Buffer } from "buffer";
|
|
17
|
-
import CRC32 from "crc-32";
|
|
18
|
-
|
|
19
|
-
// src/econ.ts
|
|
20
|
-
import { WireType } from "@protobuf-ts/runtime";
|
|
21
|
-
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
22
|
-
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
23
|
-
import { MessageType } from "@protobuf-ts/runtime";
|
|
24
|
-
var CEconItemPreviewDataBlock$Type = class extends MessageType {
|
|
25
|
-
constructor() {
|
|
26
|
-
super("CEconItemPreviewDataBlock", [
|
|
27
|
-
{
|
|
28
|
-
no: 1,
|
|
29
|
-
name: "accountid",
|
|
30
|
-
kind: "scalar",
|
|
31
|
-
opt: true,
|
|
32
|
-
T: 13
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
no: 2,
|
|
36
|
-
name: "itemid",
|
|
37
|
-
kind: "scalar",
|
|
38
|
-
opt: true,
|
|
39
|
-
T: 4,
|
|
40
|
-
L: 0
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
no: 3,
|
|
44
|
-
name: "defindex",
|
|
45
|
-
kind: "scalar",
|
|
46
|
-
opt: true,
|
|
47
|
-
T: 13
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
no: 4,
|
|
51
|
-
name: "paintindex",
|
|
52
|
-
kind: "scalar",
|
|
53
|
-
opt: true,
|
|
54
|
-
T: 13
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
no: 5,
|
|
58
|
-
name: "rarity",
|
|
59
|
-
kind: "scalar",
|
|
60
|
-
opt: true,
|
|
61
|
-
T: 13
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
no: 6,
|
|
65
|
-
name: "quality",
|
|
66
|
-
kind: "scalar",
|
|
67
|
-
opt: true,
|
|
68
|
-
T: 13
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
no: 7,
|
|
72
|
-
name: "paintwear",
|
|
73
|
-
kind: "scalar",
|
|
74
|
-
opt: true,
|
|
75
|
-
T: 13
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
no: 8,
|
|
79
|
-
name: "paintseed",
|
|
80
|
-
kind: "scalar",
|
|
81
|
-
opt: true,
|
|
82
|
-
T: 13
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
no: 9,
|
|
86
|
-
name: "killeaterscoretype",
|
|
87
|
-
kind: "scalar",
|
|
88
|
-
opt: true,
|
|
89
|
-
T: 13
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
no: 10,
|
|
93
|
-
name: "killeatervalue",
|
|
94
|
-
kind: "scalar",
|
|
95
|
-
opt: true,
|
|
96
|
-
T: 13
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
no: 11,
|
|
100
|
-
name: "customname",
|
|
101
|
-
kind: "scalar",
|
|
102
|
-
opt: true,
|
|
103
|
-
T: 9
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
no: 12,
|
|
107
|
-
name: "stickers",
|
|
108
|
-
kind: "message",
|
|
109
|
-
repeat: 1,
|
|
110
|
-
T: () => CEconItemPreviewDataBlock_Sticker
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
no: 13,
|
|
114
|
-
name: "inventory",
|
|
115
|
-
kind: "scalar",
|
|
116
|
-
opt: true,
|
|
117
|
-
T: 13
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
no: 14,
|
|
121
|
-
name: "origin",
|
|
122
|
-
kind: "scalar",
|
|
123
|
-
opt: true,
|
|
124
|
-
T: 13
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
no: 15,
|
|
128
|
-
name: "questid",
|
|
129
|
-
kind: "scalar",
|
|
130
|
-
opt: true,
|
|
131
|
-
T: 13
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
no: 16,
|
|
135
|
-
name: "dropreason",
|
|
136
|
-
kind: "scalar",
|
|
137
|
-
opt: true,
|
|
138
|
-
T: 13
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
no: 17,
|
|
142
|
-
name: "musicindex",
|
|
143
|
-
kind: "scalar",
|
|
144
|
-
opt: true,
|
|
145
|
-
T: 13
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
no: 18,
|
|
149
|
-
name: "entindex",
|
|
150
|
-
kind: "scalar",
|
|
151
|
-
opt: true,
|
|
152
|
-
T: 5
|
|
153
|
-
}
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
create(value) {
|
|
157
|
-
const message = globalThis.Object.create(this.messagePrototype);
|
|
158
|
-
message.stickers = [];
|
|
159
|
-
if (value !== void 0)
|
|
160
|
-
reflectionMergePartial(this, message, value);
|
|
161
|
-
return message;
|
|
162
|
-
}
|
|
163
|
-
internalBinaryRead(reader, length, options, target) {
|
|
164
|
-
let message = target ?? this.create(), end = reader.pos + length;
|
|
165
|
-
while (reader.pos < end) {
|
|
166
|
-
let [fieldNo, wireType] = reader.tag();
|
|
167
|
-
switch (fieldNo) {
|
|
168
|
-
case /* optional uint32 accountid */
|
|
169
|
-
1:
|
|
170
|
-
message.accountid = reader.uint32();
|
|
171
|
-
break;
|
|
172
|
-
case /* optional uint64 itemid */
|
|
173
|
-
2:
|
|
174
|
-
message.itemid = reader.uint64().toBigInt();
|
|
175
|
-
break;
|
|
176
|
-
case /* optional uint32 defindex */
|
|
177
|
-
3:
|
|
178
|
-
message.defindex = reader.uint32();
|
|
179
|
-
break;
|
|
180
|
-
case /* optional uint32 paintindex */
|
|
181
|
-
4:
|
|
182
|
-
message.paintindex = reader.uint32();
|
|
183
|
-
break;
|
|
184
|
-
case /* optional uint32 rarity */
|
|
185
|
-
5:
|
|
186
|
-
message.rarity = reader.uint32();
|
|
187
|
-
break;
|
|
188
|
-
case /* optional uint32 quality */
|
|
189
|
-
6:
|
|
190
|
-
message.quality = reader.uint32();
|
|
191
|
-
break;
|
|
192
|
-
case /* optional uint32 paintwear */
|
|
193
|
-
7:
|
|
194
|
-
message.paintwear = reader.uint32();
|
|
195
|
-
break;
|
|
196
|
-
case /* optional uint32 paintseed */
|
|
197
|
-
8:
|
|
198
|
-
message.paintseed = reader.uint32();
|
|
199
|
-
break;
|
|
200
|
-
case /* optional uint32 killeaterscoretype */
|
|
201
|
-
9:
|
|
202
|
-
message.killeaterscoretype = reader.uint32();
|
|
203
|
-
break;
|
|
204
|
-
case /* optional uint32 killeatervalue */
|
|
205
|
-
10:
|
|
206
|
-
message.killeatervalue = reader.uint32();
|
|
207
|
-
break;
|
|
208
|
-
case /* optional string customname */
|
|
209
|
-
11:
|
|
210
|
-
message.customname = reader.string();
|
|
211
|
-
break;
|
|
212
|
-
case /* repeated CEconItemPreviewDataBlock.Sticker stickers */
|
|
213
|
-
12:
|
|
214
|
-
message.stickers.push(
|
|
215
|
-
CEconItemPreviewDataBlock_Sticker.internalBinaryRead(
|
|
216
|
-
reader,
|
|
217
|
-
reader.uint32(),
|
|
218
|
-
options
|
|
219
|
-
)
|
|
220
|
-
);
|
|
221
|
-
break;
|
|
222
|
-
case /* optional uint32 inventory */
|
|
223
|
-
13:
|
|
224
|
-
message.inventory = reader.uint32();
|
|
225
|
-
break;
|
|
226
|
-
case /* optional uint32 origin */
|
|
227
|
-
14:
|
|
228
|
-
message.origin = reader.uint32();
|
|
229
|
-
break;
|
|
230
|
-
case /* optional uint32 questid */
|
|
231
|
-
15:
|
|
232
|
-
message.questid = reader.uint32();
|
|
233
|
-
break;
|
|
234
|
-
case /* optional uint32 dropreason */
|
|
235
|
-
16:
|
|
236
|
-
message.dropreason = reader.uint32();
|
|
237
|
-
break;
|
|
238
|
-
case /* optional uint32 musicindex */
|
|
239
|
-
17:
|
|
240
|
-
message.musicindex = reader.uint32();
|
|
241
|
-
break;
|
|
242
|
-
case /* optional int32 entindex */
|
|
243
|
-
18:
|
|
244
|
-
message.entindex = reader.int32();
|
|
245
|
-
break;
|
|
246
|
-
default:
|
|
247
|
-
let u = options.readUnknownField;
|
|
248
|
-
if (u === "throw")
|
|
249
|
-
throw new globalThis.Error(
|
|
250
|
-
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
|
|
251
|
-
);
|
|
252
|
-
let d = reader.skip(wireType);
|
|
253
|
-
if (u !== false)
|
|
254
|
-
(u === true ? UnknownFieldHandler.onRead : u)(
|
|
255
|
-
this.typeName,
|
|
256
|
-
message,
|
|
257
|
-
fieldNo,
|
|
258
|
-
wireType,
|
|
259
|
-
d
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return message;
|
|
264
|
-
}
|
|
265
|
-
internalBinaryWrite(message, writer, options) {
|
|
266
|
-
if (message.accountid !== void 0)
|
|
267
|
-
writer.tag(1, WireType.Varint).uint32(message.accountid);
|
|
268
|
-
if (message.itemid !== void 0)
|
|
269
|
-
writer.tag(2, WireType.Varint).uint64(message.itemid);
|
|
270
|
-
if (message.defindex !== void 0)
|
|
271
|
-
writer.tag(3, WireType.Varint).uint32(message.defindex);
|
|
272
|
-
if (message.paintindex !== void 0)
|
|
273
|
-
writer.tag(4, WireType.Varint).uint32(message.paintindex);
|
|
274
|
-
if (message.rarity !== void 0)
|
|
275
|
-
writer.tag(5, WireType.Varint).uint32(message.rarity);
|
|
276
|
-
if (message.quality !== void 0)
|
|
277
|
-
writer.tag(6, WireType.Varint).uint32(message.quality);
|
|
278
|
-
if (message.paintwear !== void 0)
|
|
279
|
-
writer.tag(7, WireType.Varint).uint32(message.paintwear);
|
|
280
|
-
if (message.paintseed !== void 0)
|
|
281
|
-
writer.tag(8, WireType.Varint).uint32(message.paintseed);
|
|
282
|
-
if (message.killeaterscoretype !== void 0)
|
|
283
|
-
writer.tag(9, WireType.Varint).uint32(message.killeaterscoretype);
|
|
284
|
-
if (message.killeatervalue !== void 0)
|
|
285
|
-
writer.tag(10, WireType.Varint).uint32(message.killeatervalue);
|
|
286
|
-
if (message.customname !== void 0)
|
|
287
|
-
writer.tag(11, WireType.LengthDelimited).string(message.customname);
|
|
288
|
-
for (let i = 0; i < message.stickers.length; i++)
|
|
289
|
-
CEconItemPreviewDataBlock_Sticker.internalBinaryWrite(
|
|
290
|
-
message.stickers[i],
|
|
291
|
-
writer.tag(12, WireType.LengthDelimited).fork(),
|
|
292
|
-
options
|
|
293
|
-
).join();
|
|
294
|
-
if (message.inventory !== void 0)
|
|
295
|
-
writer.tag(13, WireType.Varint).uint32(message.inventory);
|
|
296
|
-
if (message.origin !== void 0)
|
|
297
|
-
writer.tag(14, WireType.Varint).uint32(message.origin);
|
|
298
|
-
if (message.questid !== void 0)
|
|
299
|
-
writer.tag(15, WireType.Varint).uint32(message.questid);
|
|
300
|
-
if (message.dropreason !== void 0)
|
|
301
|
-
writer.tag(16, WireType.Varint).uint32(message.dropreason);
|
|
302
|
-
if (message.musicindex !== void 0)
|
|
303
|
-
writer.tag(17, WireType.Varint).uint32(message.musicindex);
|
|
304
|
-
if (message.entindex !== void 0)
|
|
305
|
-
writer.tag(18, WireType.Varint).int32(message.entindex);
|
|
306
|
-
let u = options.writeUnknownFields;
|
|
307
|
-
if (u !== false)
|
|
308
|
-
(u == true ? UnknownFieldHandler.onWrite : u)(
|
|
309
|
-
this.typeName,
|
|
310
|
-
message,
|
|
311
|
-
writer
|
|
312
|
-
);
|
|
313
|
-
return writer;
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
var CEconItemPreviewDataBlock = new CEconItemPreviewDataBlock$Type();
|
|
317
|
-
var CEconItemPreviewDataBlock_Sticker$Type = class extends MessageType {
|
|
318
|
-
constructor() {
|
|
319
|
-
super("CEconItemPreviewDataBlock.Sticker", [
|
|
320
|
-
{
|
|
321
|
-
no: 1,
|
|
322
|
-
name: "slot",
|
|
323
|
-
kind: "scalar",
|
|
324
|
-
opt: true,
|
|
325
|
-
T: 13
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
no: 2,
|
|
329
|
-
name: "sticker_id",
|
|
330
|
-
kind: "scalar",
|
|
331
|
-
opt: true,
|
|
332
|
-
T: 13
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
no: 3,
|
|
336
|
-
name: "wear",
|
|
337
|
-
kind: "scalar",
|
|
338
|
-
opt: true,
|
|
339
|
-
T: 2
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
no: 4,
|
|
343
|
-
name: "scale",
|
|
344
|
-
kind: "scalar",
|
|
345
|
-
opt: true,
|
|
346
|
-
T: 2
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
no: 5,
|
|
350
|
-
name: "rotation",
|
|
351
|
-
kind: "scalar",
|
|
352
|
-
opt: true,
|
|
353
|
-
T: 2
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
no: 6,
|
|
357
|
-
name: "tint_id",
|
|
358
|
-
kind: "scalar",
|
|
359
|
-
opt: true,
|
|
360
|
-
T: 13
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
no: 7,
|
|
364
|
-
name: "offset_x",
|
|
365
|
-
kind: "scalar",
|
|
366
|
-
opt: true,
|
|
367
|
-
T: 13
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
no: 8,
|
|
371
|
-
name: "offset_y",
|
|
372
|
-
kind: "scalar",
|
|
373
|
-
opt: true,
|
|
374
|
-
T: 13
|
|
375
|
-
}
|
|
376
|
-
]);
|
|
377
|
-
}
|
|
378
|
-
create(value) {
|
|
379
|
-
const message = globalThis.Object.create(this.messagePrototype);
|
|
380
|
-
if (value !== void 0)
|
|
381
|
-
reflectionMergePartial(
|
|
382
|
-
this,
|
|
383
|
-
message,
|
|
384
|
-
value
|
|
385
|
-
);
|
|
386
|
-
return message;
|
|
387
|
-
}
|
|
388
|
-
internalBinaryRead(reader, length, options, target) {
|
|
389
|
-
let message = target ?? this.create(), end = reader.pos + length;
|
|
390
|
-
while (reader.pos < end) {
|
|
391
|
-
let [fieldNo, wireType] = reader.tag();
|
|
392
|
-
switch (fieldNo) {
|
|
393
|
-
case /* optional uint32 slot */
|
|
394
|
-
1:
|
|
395
|
-
message.slot = reader.uint32();
|
|
396
|
-
break;
|
|
397
|
-
case /* optional uint32 sticker_id */
|
|
398
|
-
2:
|
|
399
|
-
message.stickerId = reader.uint32();
|
|
400
|
-
break;
|
|
401
|
-
case /* optional float wear */
|
|
402
|
-
3:
|
|
403
|
-
message.wear = reader.float();
|
|
404
|
-
break;
|
|
405
|
-
case /* optional float scale */
|
|
406
|
-
4:
|
|
407
|
-
message.scale = reader.float();
|
|
408
|
-
break;
|
|
409
|
-
case /* optional float rotation */
|
|
410
|
-
5:
|
|
411
|
-
message.rotation = reader.float();
|
|
412
|
-
break;
|
|
413
|
-
case /* optional uint32 tint_id */
|
|
414
|
-
6:
|
|
415
|
-
message.tintId = reader.uint32();
|
|
416
|
-
break;
|
|
417
|
-
case /* optional uint32 offset_x */
|
|
418
|
-
7:
|
|
419
|
-
message.offsetX = reader.uint32();
|
|
420
|
-
break;
|
|
421
|
-
case /* optional uint32 offset_y */
|
|
422
|
-
8:
|
|
423
|
-
message.offsetY = reader.uint32();
|
|
424
|
-
break;
|
|
425
|
-
default:
|
|
426
|
-
let u = options.readUnknownField;
|
|
427
|
-
if (u === "throw")
|
|
428
|
-
throw new globalThis.Error(
|
|
429
|
-
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
|
|
430
|
-
);
|
|
431
|
-
let d = reader.skip(wireType);
|
|
432
|
-
if (u !== false)
|
|
433
|
-
(u === true ? UnknownFieldHandler.onRead : u)(
|
|
434
|
-
this.typeName,
|
|
435
|
-
message,
|
|
436
|
-
fieldNo,
|
|
437
|
-
wireType,
|
|
438
|
-
d
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return message;
|
|
443
|
-
}
|
|
444
|
-
internalBinaryWrite(message, writer, options) {
|
|
445
|
-
if (message.slot !== void 0)
|
|
446
|
-
writer.tag(1, WireType.Varint).uint32(message.slot);
|
|
447
|
-
if (message.stickerId !== void 0)
|
|
448
|
-
writer.tag(2, WireType.Varint).uint32(message.stickerId);
|
|
449
|
-
if (message.wear !== void 0)
|
|
450
|
-
writer.tag(3, WireType.Bit32).float(message.wear);
|
|
451
|
-
if (message.scale !== void 0)
|
|
452
|
-
writer.tag(4, WireType.Bit32).float(message.scale);
|
|
453
|
-
if (message.rotation !== void 0)
|
|
454
|
-
writer.tag(5, WireType.Bit32).float(message.rotation);
|
|
455
|
-
if (message.tintId !== void 0)
|
|
456
|
-
writer.tag(6, WireType.Varint).uint32(message.tintId);
|
|
457
|
-
if (message.offsetX !== void 0)
|
|
458
|
-
writer.tag(7, WireType.Varint).uint32(message.offsetX);
|
|
459
|
-
if (message.offsetY !== void 0)
|
|
460
|
-
writer.tag(8, WireType.Varint).uint32(message.offsetY);
|
|
461
|
-
let u = options.writeUnknownFields;
|
|
462
|
-
if (u !== false)
|
|
463
|
-
(u == true ? UnknownFieldHandler.onWrite : u)(
|
|
464
|
-
this.typeName,
|
|
465
|
-
message,
|
|
466
|
-
writer
|
|
467
|
-
);
|
|
468
|
-
return writer;
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
var CEconItemPreviewDataBlock_Sticker = new CEconItemPreviewDataBlock_Sticker$Type();
|
|
472
|
-
|
|
473
|
-
// src/index.ts
|
|
474
|
-
var CS_RARITY_INT = {
|
|
475
|
-
[CS_RARITY_COMMON_COLOR]: 1,
|
|
476
|
-
[CS_RARITY_UNCOMMON_COLOR]: 2,
|
|
477
|
-
[CS_RARITY_RARE_COLOR]: 3,
|
|
478
|
-
[CS_RARITY_MYTHICAL_COLOR]: 4,
|
|
479
|
-
[CS_RARITY_LEGENDARY_COLOR]: 5,
|
|
480
|
-
[CS_RARITY_ANCIENT_COLOR]: 6,
|
|
481
|
-
[CS_RARITY_IMMORTAL_COLOR]: 7
|
|
482
|
-
};
|
|
483
|
-
var MISSING_ITEM_DEF = {
|
|
484
|
-
graffiti: 1348,
|
|
485
|
-
patch: 4609,
|
|
486
|
-
sticker: 1209,
|
|
487
|
-
musickit: 1314
|
|
488
|
-
};
|
|
489
|
-
var CS_PREVIEW_URL = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20";
|
|
490
|
-
function floatToBytes(floatValue) {
|
|
491
|
-
const floatArray = new Float32Array(1);
|
|
492
|
-
floatArray[0] = floatValue;
|
|
493
|
-
const byteArray = new Uint32Array(floatArray.buffer);
|
|
494
|
-
return byteArray[0];
|
|
495
|
-
}
|
|
496
|
-
function getItemAttributes(item) {
|
|
497
|
-
const { def, index, rarity, type, tint, wearmin } = item;
|
|
498
|
-
const hasStickerObject = MISSING_ITEM_DEF[type] !== void 0;
|
|
499
|
-
const hasPaintIndex = !hasStickerObject && type !== "musickit";
|
|
500
|
-
return {
|
|
501
|
-
defindex: MISSING_ITEM_DEF[type] ?? def,
|
|
502
|
-
musicindex: type === "musickit" ? index : void 0,
|
|
503
|
-
paintindex: hasPaintIndex ? index : void 0,
|
|
504
|
-
paintseed: CS_Economy.hasSeed(item) ? CS_MIN_SEED : void 0,
|
|
505
|
-
paintwear: CS_Economy.hasWear(item) ? wearmin ?? CS_MIN_WEAR : void 0,
|
|
506
|
-
rarity: CS_RARITY_INT[rarity] ?? 0,
|
|
507
|
-
stickers: hasStickerObject ? [
|
|
508
|
-
{
|
|
509
|
-
tintId: tint,
|
|
510
|
-
stickerId: index,
|
|
511
|
-
slot: 0
|
|
512
|
-
}
|
|
513
|
-
] : []
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
function getBaseInventoryItemAttributes({
|
|
517
|
-
id,
|
|
518
|
-
nametag,
|
|
519
|
-
seed,
|
|
520
|
-
stattrak,
|
|
521
|
-
stickers,
|
|
522
|
-
stickerswear,
|
|
523
|
-
wear
|
|
524
|
-
}) {
|
|
525
|
-
const item = CS_Economy.getById(id);
|
|
526
|
-
const baseAttributes = getItemAttributes(item);
|
|
527
|
-
return {
|
|
528
|
-
...baseAttributes,
|
|
529
|
-
customname: nametag,
|
|
530
|
-
killeaterscoretype: stattrak !== void 0 ? 0 : void 0,
|
|
531
|
-
killeatervalue: stattrak,
|
|
532
|
-
paintseed: CS_Economy.hasSeed(item) ? seed ?? CS_MIN_SEED : void 0,
|
|
533
|
-
paintwear: CS_Economy.hasWear(item) ? floatToBytes(wear ?? item.wearmin ?? CS_MIN_WEAR) : void 0,
|
|
534
|
-
stickers: stickers !== void 0 ? stickers.map((sticker, slot) => ({
|
|
535
|
-
slot,
|
|
536
|
-
stickerId: CS_Economy.getById(sticker).index,
|
|
537
|
-
wear: stickerswear?.[slot] ?? CS_MIN_STICKER_WEAR
|
|
538
|
-
})).filter(({ stickerId }) => stickerId !== CS_NONE) : baseAttributes.stickers
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
function generateHex(attributes) {
|
|
542
|
-
const payload = Buffer.concat([Uint8Array.from([0]), CEconItemPreviewDataBlock.toBinary(attributes)]);
|
|
543
|
-
const crc = CRC32.buf(payload);
|
|
544
|
-
const xCrc = crc & 65535 ^ CEconItemPreviewDataBlock.toBinary(attributes).byteLength * crc;
|
|
545
|
-
const crcBuffer = Buffer.alloc(4);
|
|
546
|
-
crcBuffer.writeUInt32BE((xCrc & 4294967295) >>> 0, 0);
|
|
547
|
-
const buffer = Buffer.concat([payload, crcBuffer]);
|
|
548
|
-
return buffer.toString("hex").toUpperCase();
|
|
549
|
-
}
|
|
550
|
-
function CS_generateInspectLink(item) {
|
|
551
|
-
const econ = {
|
|
552
|
-
...typeof item.uid === void 0 ? getItemAttributes(item) : getBaseInventoryItemAttributes(item)
|
|
553
|
-
};
|
|
554
|
-
return `${CS_PREVIEW_URL}${generateHex(econ)}`;
|
|
555
|
-
}
|
|
556
|
-
export {
|
|
557
|
-
CS_PREVIEW_URL,
|
|
558
|
-
CS_generateInspectLink
|
|
559
|
-
};
|