pxengine 0.1.65 → 0.1.66

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.cjs CHANGED
@@ -39164,25 +39164,48 @@ var import_react_dom2 = __toESM(require("react-dom"), 1);
39164
39164
  var import_framer_motion5 = require("framer-motion");
39165
39165
 
39166
39166
  // src/molecules/creator-discovery/CreatorWidget/defaultFetchers.ts
39167
+ function getBackendOrigin2() {
39168
+ if (typeof window === "undefined") return null;
39169
+ return window.__NEXT_DATA__?.runtimeConfig?.NEXT_PUBLIC_AGENT_BACKEND ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_AGENT_BACKEND : void 0) ?? null;
39170
+ }
39171
+ function getAuthToken2() {
39172
+ if (typeof document === "undefined") return null;
39173
+ for (const name of ["adminTokenBuilder", "adminToken", "token"]) {
39174
+ const match2 = document.cookie.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
39175
+ if (match2?.[1]) return match2[1];
39176
+ }
39177
+ return null;
39178
+ }
39179
+ function buildHeaders2(includeJson = false) {
39180
+ const headers = {};
39181
+ if (includeJson) headers["Content-Type"] = "application/json";
39182
+ if (getBackendOrigin2()) {
39183
+ const token = getAuthToken2();
39184
+ if (token) headers["Authorization"] = `Bearer ${token}`;
39185
+ }
39186
+ return headers;
39187
+ }
39167
39188
  async function defaultFetchVersions(params) {
39189
+ const backend = getBackendOrigin2();
39168
39190
  const versionParam = params.version ? `&version=${params.version}` : "";
39169
- const res = await fetch(
39170
- `/api/get-creator-versions?sessionId=${params.sessionId}${versionParam}&validated=${params.validated}`
39171
- );
39191
+ const url = backend ? `${backend}/api/creators/versions?sessionId=${params.sessionId}${versionParam}&validated=${params.validated}` : `/api/get-creator-versions?sessionId=${params.sessionId}${versionParam}&validated=${params.validated}`;
39192
+ const res = await fetch(url, { headers: buildHeaders2() });
39172
39193
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
39173
39194
  return res.json();
39174
39195
  }
39175
39196
  async function defaultFetchStatus(params) {
39176
- const res = await fetch(
39177
- `/api/get-creator-detail-status?session_id=${params.sessionId}&version_no=${params.versionNo}`
39178
- );
39197
+ const backend = getBackendOrigin2();
39198
+ const url = backend ? `${backend}/api/creators/version-status?session_id=${params.sessionId}&version_no=${params.versionNo}` : `/api/get-creator-detail-status?session_id=${params.sessionId}&version_no=${params.versionNo}`;
39199
+ const res = await fetch(url, { headers: buildHeaders2() });
39179
39200
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
39180
39201
  return res.json();
39181
39202
  }
39182
39203
  async function defaultFetchCreatorDetails(params) {
39183
- const res = await fetch("/api/get-creator-details-by-id", {
39204
+ const backend = getBackendOrigin2();
39205
+ const url = backend ? `${backend}/api/creators/details-by-id` : `/api/get-creator-details-by-id`;
39206
+ const res = await fetch(url, {
39184
39207
  method: "POST",
39185
- headers: { "Content-Type": "application/json" },
39208
+ headers: buildHeaders2(true),
39186
39209
  body: JSON.stringify({
39187
39210
  creator_ids: params.creatorIds,
39188
39211
  session_id: params.sessionId,