@ianlucas/cs2-lib-inspect 2.1.0 → 3.0.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/dist/index.d.ts +2 -0
- package/dist/index.js +11 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ export declare const CS2PreviewRarity: {
|
|
|
11
11
|
export declare const CS2_PREVIEW_HAS_STICKERS: CS2ItemTypeValues[];
|
|
12
12
|
export declare const CS2_PREVIEW_INSPECTABLE_ITEMS: CS2ItemTypeValues[];
|
|
13
13
|
export declare const CS2_PREVIEW_URL = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20";
|
|
14
|
+
export declare const CS2_PREVIEW_COMMAND = "csgo_econ_action_preview";
|
|
14
15
|
export declare function generateInspectLink(item: CS2EconomyItem | CS2InventoryItem): string;
|
|
16
|
+
export declare function isCommandInspect(inspectLink: string): boolean;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export const CS2_PREVIEW_INSPECTABLE_ITEMS = [
|
|
|
34
34
|
CS2ItemType.Weapon
|
|
35
35
|
];
|
|
36
36
|
export const CS2_PREVIEW_URL = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20";
|
|
37
|
+
export const CS2_PREVIEW_COMMAND = "csgo_econ_action_preview";
|
|
37
38
|
function floatToBytes(floatValue) {
|
|
38
39
|
const floatArray = new Float32Array(1);
|
|
39
40
|
floatArray[0] = floatValue;
|
|
@@ -71,7 +72,7 @@ function getInventoryItemPreviewData(item) {
|
|
|
71
72
|
customname: nameTag,
|
|
72
73
|
killeaterscoretype: statTrak !== undefined ? 0 : undefined,
|
|
73
74
|
killeatervalue: statTrak,
|
|
74
|
-
paintseed: item.hasSeed() ? seed ?? CS2_MIN_SEED : undefined,
|
|
75
|
+
paintseed: item.hasSeed() ? (seed ?? CS2_MIN_SEED) : undefined,
|
|
75
76
|
paintwear: item.hasWear() ? floatToBytes(item.getWear()) : undefined,
|
|
76
77
|
stickers: stickers !== undefined
|
|
77
78
|
? item.someStickers().map(([slot, { id, wear, x, y }]) => ({
|
|
@@ -99,5 +100,13 @@ function generateHex(attributes) {
|
|
|
99
100
|
return buffer.toString("hex").toUpperCase();
|
|
100
101
|
}
|
|
101
102
|
export function generateInspectLink(item) {
|
|
102
|
-
|
|
103
|
+
const hex = generateHex(item instanceof CS2InventoryItem ? getInventoryItemPreviewData(item) : getEconomyItemPreviewData(item));
|
|
104
|
+
// There's a char limit for launching the game using the steam:// protocol.
|
|
105
|
+
if (CS2_PREVIEW_URL.length + hex.length > 300) {
|
|
106
|
+
return `${CS2_PREVIEW_COMMAND} ${hex}`;
|
|
107
|
+
}
|
|
108
|
+
return `${CS2_PREVIEW_URL}${hex}`;
|
|
109
|
+
}
|
|
110
|
+
export function isCommandInspect(inspectLink) {
|
|
111
|
+
return inspectLink.startsWith(CS2_PREVIEW_COMMAND);
|
|
103
112
|
}
|
package/package.json
CHANGED