jagproject 26.3.13 → 26.3.18

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.
@@ -9,7 +9,7 @@ const libsignal_1 = require("../Signal/libsignal");
9
9
  const browser_utils_1 = require("../Utils/browser-utils");
10
10
  const logger_1 = __importDefault(require("../Utils/logger"));
11
11
  const waVer = require("./wileys-version.json");
12
- exports.version = waVer?.version || [2, 3000, 1035023383];
12
+ exports.version = waVer?.version || [2, 3000, 1035247988];
13
13
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
14
14
  exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
15
15
  exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
@@ -1,56 +1,75 @@
1
- "use strict";
1
+ const fs = require('fs')
2
+ const path = require('path')
2
3
 
3
- const fs = require("fs");
4
- const path = require("path");
5
- const axios = require("axios");
4
+ const URL = 'https://wppconnect.io/whatsapp-versions/'
6
5
 
7
- const URL = "https://wppconnect.io/whatsapp-versions/";
8
- const OUT_FILE = path.join(__dirname, "wileys-version.json");
6
+ async function main() {
7
+ try {
8
+ const res = await fetch(URL, {
9
+ headers: {
10
+ 'user-agent': 'Mozilla/5.0'
11
+ }
12
+ })
9
13
 
14
+ if (!res.ok) {
15
+ throw new Error(`HTTP ${res.status} ${res.statusText}`)
16
+ }
10
17
 
11
- function parseCurrentVersion(html) {
12
- // cari "Current Version" lalu ambil versi setelahnya (format: 2.3000.1032562324-alpha)
13
- const m = html.match(/Current Version[\s\S]{0,800}?\b(\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?)\b/);
14
- if (!m) return null;
18
+ const html = await res.text()
15
19
 
16
- const full = m[1]; // "2.3000.1032562324-alpha"
17
- const numeric = full.split("-")[0]; // "2.3000.1032562324"
20
+ const match = html.match(/Current Version[\s\S]{0,1200}?\b(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?)\b/i)
18
21
 
19
- const parts = numeric.split(".").map((x) => Number(x));
20
- if (parts.length !== 3 || parts.some((n) => !Number.isFinite(n))) return null;
22
+ if (!match) {
23
+ console.log('Skip update WA Web version: versi tidak ditemukan')
24
+ process.exit(0)
25
+ }
21
26
 
22
- return { full, parts };
23
- }
27
+ const rawWithSuffix = match[1].trim()
24
28
 
25
- async function main() {
26
- try {
27
- const res = await axios.get(URL, {
28
- timeout: 15000,
29
- headers: {
30
- // biar gak gampang diblok
31
- "User-Agent": "Mozilla/5.0 (Node.js) wileyss-wa-version-updater",
32
- "Accept": "text/html,application/xhtml+xml",
33
- },
34
- });
35
-
36
- const parsed = parseCurrentVersion(res.data);
37
- if (!parsed) throw new Error("Gagal parse Current Version dari halaman.");
38
-
39
- const payload = {
40
- version: parsed.parts,
41
- source: URL,
42
- fetchedAt: new Date().toISOString(),
43
- raw: parsed.full,
44
- };
45
-
46
- fs.writeFileSync(OUT_FILE, JSON.stringify(payload, null, 2), "utf8");
47
- console.log("[wileyss] WA Web version updated:", parsed.full, "=>", parsed.parts);
29
+ // buang suffix seperti -alpha, -beta, dll
30
+ const cleanRaw = rawWithSuffix.split('-')[0].trim()
31
+
32
+ const version = cleanRaw.split('.').map(Number)
33
+
34
+ if (version.length !== 3 || version.some(Number.isNaN)) {
35
+ throw new Error(`Format versi tidak valid: ${cleanRaw}`)
36
+ }
37
+
38
+ // 1) update wileys-version.json
39
+ const jsonPath = path.join(__dirname, 'wileys-version.json')
40
+ const jsonData = {
41
+ version,
42
+ raw: cleanRaw
43
+ }
44
+ fs.writeFileSync(jsonPath, JSON.stringify(jsonData, null, 2) + '\n', 'utf8')
45
+
46
+ // 2) update lib/Defaults/index.js
47
+ const indexPath = path.join(__dirname, 'index.js')
48
+ let indexContent = fs.readFileSync(indexPath, 'utf8')
49
+
50
+ const newVersionArray = `[${version.join(', ')}]`
51
+
52
+ const pattern = /exports\.version\s*=\s*waVer\?\.version\s*\|\|\s*\[[^\]]+\];?/
53
+
54
+ if (!pattern.test(indexContent)) {
55
+ throw new Error('Baris exports.version tidak ditemukan di lib/Defaults/index.js')
56
+ }
57
+
58
+ indexContent = indexContent.replace(
59
+ pattern,
60
+ `exports.version = waVer?.version || ${newVersionArray};`
61
+ )
62
+
63
+ fs.writeFileSync(indexPath, indexContent, 'utf8')
64
+
65
+ console.log('WA version updated:', {
66
+ version,
67
+ raw: cleanRaw
68
+ })
48
69
  } catch (err) {
49
- console.log("[wileyss] Skip update WA Web version (offline / gagal fetch).");
50
- console.log("[wileyss] Reason:", err?.message || err);
51
- // jangan bikin install gagal
52
- process.exit(0);
70
+ console.error('Gagal update WA version:', err.message)
71
+ process.exit(1)
53
72
  }
54
73
  }
55
74
 
56
- main();
75
+ main()
@@ -1,3 +1,8 @@
1
1
  {
2
- "version": [2, 3000, 1035023383]
2
+ "version": [
3
+ 2,
4
+ 3000,
5
+ 1035247988
6
+ ],
7
+ "raw": "2.3000.1035247988"
3
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jagproject",
3
- "version": "26.03.13",
4
- "update": "12 Maret 2026",
3
+ "version": "26.03.18",
4
+ "update": "17 Maret 2026",
5
5
  "description": "WhatsApp Web API Library",
6
6
  "keywords": [
7
7
  "jagoan",
@@ -41,8 +41,9 @@
41
41
  "gen:protobuf": "sh WAProto/GenerateStatics.sh",
42
42
  "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
43
43
  "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
44
- "prepack": "echo 'Wileys WhatsApp Library'",
44
+ "prepack": "node ./lib/Defaults/update-wa-version.js",
45
45
  "prepare": "echo 'Wileys WhatsApp Library'",
46
+ "postinstall": "node ./lib/Defaults/update-wa-version.js",
46
47
  "preinstall": "node ./engine-requirements.js",
47
48
  "release": "release-it",
48
49
  "test": "jest"