satyamark-react 0.0.9 → 0.0.10

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.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -40,6 +30,52 @@ __export(src_exports, {
40
30
  });
41
31
  module.exports = __toCommonJS(src_exports);
42
32
 
33
+ // src/utils/iconRegistry.ts
34
+ var ICON_URLS = {
35
+ correct: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/correct_gjiadc.png",
36
+ incorrect: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/incorrect_lb9yfb.png",
37
+ insufficient: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/insufficient_lvtzjc.png",
38
+ uncertain: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/uncertain_fq5d2c.png",
39
+ ai: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/ai_dlykbo.png",
40
+ nonai: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/nonai_coy4w5.png",
41
+ verifyable: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/verifyable_jugvwe.png",
42
+ unverifyable: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/unverifyable_yzm5se.png",
43
+ pending: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325440/pending_gpqshq.png"
44
+ };
45
+
46
+ // src/utils/iconLoader.ts
47
+ var iconLoadMap = /* @__PURE__ */ new Map();
48
+ function loadIcon(key) {
49
+ const existing = iconLoadMap.get(key);
50
+ if (existing)
51
+ return existing;
52
+ const promise = new Promise((resolve, reject) => {
53
+ const img = new Image();
54
+ img.onload = () => resolve();
55
+ img.onerror = () => {
56
+ iconLoadMap.delete(key);
57
+ reject(new Error(`Failed to load icon: ${key}`));
58
+ };
59
+ img.src = ICON_URLS[key];
60
+ });
61
+ iconLoadMap.set(key, promise);
62
+ return promise;
63
+ }
64
+ function preloadIcons() {
65
+ const run = () => {
66
+ Object.keys(ICON_URLS).forEach(loadIcon);
67
+ };
68
+ if ("requestIdleCallback" in window) {
69
+ window.requestIdleCallback(run);
70
+ } else {
71
+ setTimeout(run, 0);
72
+ }
73
+ }
74
+ function ensureIconLoaded(key) {
75
+ return loadIcon(key).catch(() => {
76
+ });
77
+ }
78
+
43
79
  // src/satyamark_connect.ts
44
80
  var wsUrl = "wss://satyamark.onrender.com";
45
81
  var socket = null;
@@ -59,6 +95,7 @@ function onConnected(cb) {
59
95
  }
60
96
  function init(connectionData, options) {
61
97
  var _a;
98
+ preloadIcons();
62
99
  if (socket && socket.readyState == WebSocket.OPEN && storedConnectionData == connectionData) {
63
100
  console.log("Already Connected: ", connectionData);
64
101
  return;
@@ -202,27 +239,9 @@ async function process(divRef, dataId) {
202
239
  }
203
240
 
204
241
  // src/satyamark_status_controller.ts
205
- var import_verifyable = __toESM(require("./verifyable-AYGD2AEO.png"));
206
- var import_unverifyable = __toESM(require("./unverifyable-2LSQEVJT.png"));
207
- var import_insufficient = __toESM(require("./insufficient-FBXL3GLE.png"));
208
- var import_correct = __toESM(require("./correct-AW5V6TXB.png"));
209
- var import_incorrect = __toESM(require("./incorrect-KHIGXY2C.png"));
210
- var import_pending = __toESM(require("./pending-SWS5I5G5.png"));
211
- var import_ai = __toESM(require("./ai-J46U5IDK.png"));
212
- var import_nonai = __toESM(require("./nonai-LPEFMQBT.png"));
213
242
  var jobMap = {};
214
243
  var DEFAULT_ICON_SIZE = 20;
215
244
  var satyamark_url = "https://satyamark.vercel.app/chat";
216
- var iconMap = {
217
- verifyable: import_verifyable.default,
218
- unverifyable: import_unverifyable.default,
219
- insufficient: import_insufficient.default,
220
- correct: import_correct.default,
221
- incorrect: import_incorrect.default,
222
- pending: import_pending.default,
223
- ai: import_ai.default,
224
- nonai: import_nonai.default
225
- };
226
245
  function registerStatus(jobId, rootElement, options = {}) {
227
246
  var _a;
228
247
  jobMap[jobId] = {
@@ -236,7 +255,8 @@ function updateIcon(jobId, rawMark, data) {
236
255
  if (!entry)
237
256
  return;
238
257
  const { root, iconSize } = entry;
239
- const mark = rawMark != null ? rawMark : "pending";
258
+ const mark = rawMark in ICON_URLS ? rawMark : "pending";
259
+ ensureIconLoaded(mark);
240
260
  const container = root.querySelector("[data-satyamark-status-container]");
241
261
  if (!container)
242
262
  return;
@@ -248,7 +268,7 @@ function updateIcon(jobId, rawMark, data) {
248
268
  icon.style.display = "block";
249
269
  icon.style.width = iconSize + "px";
250
270
  icon.style.height = iconSize + "px";
251
- icon.src = iconMap[mark] || iconMap["pending"];
271
+ icon.src = ICON_URLS[mark];
252
272
  container.appendChild(icon);
253
273
  const type = data == null ? void 0 : data.type;
254
274
  const isValidType = type === "text" || type === "image";
package/dist/index.mjs CHANGED
@@ -1,3 +1,49 @@
1
+ // src/utils/iconRegistry.ts
2
+ var ICON_URLS = {
3
+ correct: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/correct_gjiadc.png",
4
+ incorrect: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/incorrect_lb9yfb.png",
5
+ insufficient: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325442/insufficient_lvtzjc.png",
6
+ uncertain: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/uncertain_fq5d2c.png",
7
+ ai: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/ai_dlykbo.png",
8
+ nonai: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/nonai_coy4w5.png",
9
+ verifyable: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/verifyable_jugvwe.png",
10
+ unverifyable: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325441/unverifyable_yzm5se.png",
11
+ pending: "https://res.cloudinary.com/dfamljkyo/image/upload/v1768325440/pending_gpqshq.png"
12
+ };
13
+
14
+ // src/utils/iconLoader.ts
15
+ var iconLoadMap = /* @__PURE__ */ new Map();
16
+ function loadIcon(key) {
17
+ const existing = iconLoadMap.get(key);
18
+ if (existing)
19
+ return existing;
20
+ const promise = new Promise((resolve, reject) => {
21
+ const img = new Image();
22
+ img.onload = () => resolve();
23
+ img.onerror = () => {
24
+ iconLoadMap.delete(key);
25
+ reject(new Error(`Failed to load icon: ${key}`));
26
+ };
27
+ img.src = ICON_URLS[key];
28
+ });
29
+ iconLoadMap.set(key, promise);
30
+ return promise;
31
+ }
32
+ function preloadIcons() {
33
+ const run = () => {
34
+ Object.keys(ICON_URLS).forEach(loadIcon);
35
+ };
36
+ if ("requestIdleCallback" in window) {
37
+ window.requestIdleCallback(run);
38
+ } else {
39
+ setTimeout(run, 0);
40
+ }
41
+ }
42
+ function ensureIconLoaded(key) {
43
+ return loadIcon(key).catch(() => {
44
+ });
45
+ }
46
+
1
47
  // src/satyamark_connect.ts
2
48
  var wsUrl = "wss://satyamark.onrender.com";
3
49
  var socket = null;
@@ -17,6 +63,7 @@ function onConnected(cb) {
17
63
  }
18
64
  function init(connectionData, options) {
19
65
  var _a;
66
+ preloadIcons();
20
67
  if (socket && socket.readyState == WebSocket.OPEN && storedConnectionData == connectionData) {
21
68
  console.log("Already Connected: ", connectionData);
22
69
  return;
@@ -160,27 +207,9 @@ async function process(divRef, dataId) {
160
207
  }
161
208
 
162
209
  // src/satyamark_status_controller.ts
163
- import verifyableIcon from "./verifyable-AYGD2AEO.png";
164
- import unverifyableIcon from "./unverifyable-2LSQEVJT.png";
165
- import insufficientIcon from "./insufficient-FBXL3GLE.png";
166
- import correctIcon from "./correct-AW5V6TXB.png";
167
- import incorrectIcon from "./incorrect-KHIGXY2C.png";
168
- import pendingIcon from "./pending-SWS5I5G5.png";
169
- import aiIcon from "./ai-J46U5IDK.png";
170
- import nonaiIcon from "./nonai-LPEFMQBT.png";
171
210
  var jobMap = {};
172
211
  var DEFAULT_ICON_SIZE = 20;
173
212
  var satyamark_url = "https://satyamark.vercel.app/chat";
174
- var iconMap = {
175
- verifyable: verifyableIcon,
176
- unverifyable: unverifyableIcon,
177
- insufficient: insufficientIcon,
178
- correct: correctIcon,
179
- incorrect: incorrectIcon,
180
- pending: pendingIcon,
181
- ai: aiIcon,
182
- nonai: nonaiIcon
183
- };
184
213
  function registerStatus(jobId, rootElement, options = {}) {
185
214
  var _a;
186
215
  jobMap[jobId] = {
@@ -194,7 +223,8 @@ function updateIcon(jobId, rawMark, data) {
194
223
  if (!entry)
195
224
  return;
196
225
  const { root, iconSize } = entry;
197
- const mark = rawMark != null ? rawMark : "pending";
226
+ const mark = rawMark in ICON_URLS ? rawMark : "pending";
227
+ ensureIconLoaded(mark);
198
228
  const container = root.querySelector("[data-satyamark-status-container]");
199
229
  if (!container)
200
230
  return;
@@ -206,7 +236,7 @@ function updateIcon(jobId, rawMark, data) {
206
236
  icon.style.display = "block";
207
237
  icon.style.width = iconSize + "px";
208
238
  icon.style.height = iconSize + "px";
209
- icon.src = iconMap[mark] || iconMap["pending"];
239
+ icon.src = ICON_URLS[mark];
210
240
  container.appendChild(icon);
211
241
  const type = data == null ? void 0 : data.type;
212
242
  const isValidType = type === "text" || type === "image";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "satyamark-react",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Official React SDK for SatyaMark — a lightweight UI library to embed transparent content verification marks, confidence indicators, and trust signals into React applications.",
5
5
  "license": "MIT",
6
6
  "author": "DK",
@@ -28,8 +28,7 @@
28
28
  "module": "dist/index.mjs",
29
29
  "types": "dist/index.d.ts",
30
30
  "files": [
31
- "dist",
32
- "public"
31
+ "dist"
33
32
  ],
34
33
  "exports": {
35
34
  ".": {
Binary file
package/dist/ai.png DELETED
Binary file
Binary file
package/dist/correct.png DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/nonai.png DELETED
Binary file
Binary file
package/dist/pending.png DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/public/Logo.png DELETED
Binary file