@adhese/sdk-devtools 0.2.0 → 0.4.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/cjs/index.js CHANGED
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require$$0 = require("react");
4
4
  async function createDevtools(context) {
5
- const devtools = await Promise.resolve().then(() => require("./devtools.js"));
5
+ const main = await Promise.resolve().then(() => require("./devtools.js")).then((n) => n.main);
6
6
  const wrapperElement = document.createElement("div");
7
7
  document.body.appendChild(wrapperElement);
8
- const unmount = devtools.createAdheseDevtools(wrapperElement, context);
8
+ const unmount = main.createAdheseDevtools(wrapperElement, context);
9
9
  return () => {
10
10
  unmount();
11
11
  wrapperElement.outerHTML = "";
12
12
  };
13
13
  }
14
- const Devtools = require$$0.lazy(() => Promise.resolve().then(() => require("./devtools.js")).then((module2) => ({ default: module2.Devtools })));
14
+ const Devtools = require$$0.lazy(() => Promise.resolve().then(() => require("./devtools.js")).then((n) => n.Devtools).then((module2) => ({ default: module2.Devtools })));
15
15
  exports.Devtools = Devtools;
16
16
  exports.createDevtools = createDevtools;
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import type { AdheseContext } from '@adhese/sdk';\nimport { lazy } from 'react';\n\nexport async function createDevtools(context: AdheseContext): Promise<() => void> {\n const devtools = await import('@devtools');\n\n const wrapperElement = document.createElement('div');\n document.body.appendChild(wrapperElement);\n\n const unmount = devtools.createAdheseDevtools(wrapperElement, context);\n\n return () => {\n unmount();\n wrapperElement.outerHTML = '';\n };\n}\n\n// eslint-disable-next-line ts/naming-convention\nexport const Devtools = lazy(() => import('@devtools').then(module => ({ default: module.Devtools })));\n"],"names":["lazy","module"],"mappings":";;;AAGA,eAAsB,eAAe,SAA6C;AAC1E,QAAA,WAAW,MAAM,QAAO,QAAA,EAAA,KAAA,MAAA,QAAA,eAAW;AAEnC,QAAA,iBAAiB,SAAS,cAAc,KAAK;AAC1C,WAAA,KAAK,YAAY,cAAc;AAExC,QAAM,UAAU,SAAS,qBAAqB,gBAAgB,OAAO;AAErE,SAAO,MAAM;AACH;AACR,mBAAe,YAAY;AAAA,EAAA;AAE/B;AAGO,MAAM,WAAWA,WAAA,KAAK,MAAM,QAAO,QAAA,EAAA,KAAA,MAAA,QAAA,eAAW,CAAA,EAAE,KAAK,CAAAC,aAAW,EAAE,SAASA,QAAO,WAAW,CAAC;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import type { AdheseContext } from '@adhese/sdk';\nimport { lazy } from 'react';\n\nexport async function createDevtools(context: AdheseContext): Promise<() => void> {\n const main = await import('./main');\n\n const wrapperElement = document.createElement('div');\n document.body.appendChild(wrapperElement);\n\n const unmount = main.createAdheseDevtools(wrapperElement, context);\n\n return () => {\n unmount();\n wrapperElement.outerHTML = '';\n };\n}\n\n// eslint-disable-next-line ts/naming-convention\nexport const Devtools = lazy(() => import('./Devtools').then(module => ({ default: module.Devtools })));\n"],"names":["lazy","module"],"mappings":";;;AAGA,eAAsB,eAAe,SAA6C;AAC1E,QAAA,OAAO,MAAM,QAAO,QAAA,EAAA,KAAA,MAAA,QAAA,eAAQ;AAE5B,QAAA,iBAAiB,SAAS,cAAc,KAAK;AAC1C,WAAA,KAAK,YAAY,cAAc;AAExC,QAAM,UAAU,KAAK,qBAAqB,gBAAgB,OAAO;AAEjE,SAAO,MAAM;AACH;AACR,mBAAe,YAAY;AAAA,EAAA;AAE/B;AAGO,MAAM,WAAWA,WAAA,KAAK,MAAM,QAAO,QAAA,EAAA,KAAA,MAAA,QAAA,eAAY,CAAA,EAAA,KAAA,OAAA,EAAA,QAAA,EAAE,KAAK,CAAAC,aAAW,EAAE,SAASA,QAAO,WAAW,CAAC;;;"}
@@ -1,5 +1,6 @@
1
1
  import require$$0, { forwardRef, useState, useEffect, useMemo, Fragment, useCallback, useId, useRef } from "react";
2
2
  import require$$0$1, { createPortal } from "react-dom";
3
+ import { upperFirst } from "lodash-es";
3
4
  import { clsx } from "clsx";
4
5
  import { twMerge } from "tailwind-merge";
5
6
  import { cva } from "class-variance-authority";
@@ -7,7 +8,6 @@ import { Slot } from "@radix-ui/react-slot";
7
8
  import * as SheetPrimitive from "@radix-ui/react-dialog";
8
9
  import { Cross2Icon } from "@radix-ui/react-icons";
9
10
  import * as TabsPrimitive from "@radix-ui/react-tabs";
10
- import { upperFirst } from "lodash-es";
11
11
  import * as SwitchPrimitives from "@radix-ui/react-switch";
12
12
  import * as LabelPrimitive from "@radix-ui/react-label";
13
13
  var jsxRuntime = { exports: {} };
@@ -1251,10 +1251,20 @@ function SlotsTable({ adheseContext }) {
1251
1251
  var _a;
1252
1252
  return (_a = formattedSlot.ad) == null ? void 0 : _a.preview;
1253
1253
  });
1254
+ const origins = useMemo(() => {
1255
+ const set = /* @__PURE__ */ new Set();
1256
+ for (const slot of formattedSlots) {
1257
+ const ad = slot.getAd();
1258
+ if (ad)
1259
+ set.add(ad.origin);
1260
+ }
1261
+ return Array.from(set);
1262
+ }, [formattedSlots]);
1254
1263
  return formattedSlots.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Table, { children: [
1255
1264
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow, { children: [
1256
1265
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Name" }),
1257
1266
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Format" }),
1267
+ origins.length > 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Origin" }),
1258
1268
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Location" }),
1259
1269
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Render Status" }),
1260
1270
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableHead, { children: "Campaign ID" }),
@@ -1285,6 +1295,7 @@ function SlotsTable({ adheseContext }) {
1285
1295
  /* @__PURE__ */ jsxRuntimeExports.jsx("del", { className: "text-red-300 italic", children: format }),
1286
1296
  /* @__PURE__ */ jsxRuntimeExports.jsx("ins", { className: "no-underline text-green-700", children: ad == null ? void 0 : ad.adFormat })
1287
1297
  ] }) }),
1298
+ origins.length > 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { children: (ad == null ? void 0 : ad.origin) && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { className: cn(slotIndexBadgeClasses[origins.indexOf(ad.origin) % slotIndexBadgeClasses.length], "text-white"), children: upperFirst(ad.origin.toLowerCase()) }) }),
1288
1299
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { children: location }),
1289
1300
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1290
1301
  Badge,
@@ -1641,13 +1652,10 @@ function FronttailSettings({
1641
1652
  id: `fronttailDebugKey${id}`,
1642
1653
  value: fronttailDebugKey,
1643
1654
  onChange: onFronttailDebugKeyChange,
1644
- className: cn(
1645
- "max-w-60",
1646
- {
1647
- // eslint-disable-next-line ts/naming-convention
1648
- "border-destructive": fronttailDebugKey.length < 4
1649
- }
1650
- )
1655
+ className: cn("max-w-60", {
1656
+ // eslint-disable-next-line ts/naming-convention
1657
+ "border-destructive": fronttailDebugKey.length < 4
1658
+ })
1651
1659
  }
1652
1660
  ),
1653
1661
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -1753,6 +1761,10 @@ function Devtools({ adheseContext }) {
1753
1761
  /* @__PURE__ */ jsxRuntimeExports.jsx(PreviewButton, {})
1754
1762
  ] }) });
1755
1763
  }
1764
+ const Devtools$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1765
+ __proto__: null,
1766
+ Devtools
1767
+ }, Symbol.toStringTag, { value: "Module" }));
1756
1768
  function createAdheseDevtools(element, context) {
1757
1769
  const root = createRoot(element);
1758
1770
  root.render(/* @__PURE__ */ jsxRuntimeExports.jsx(Devtools, { adheseContext: context }));
@@ -1760,8 +1772,12 @@ function createAdheseDevtools(element, context) {
1760
1772
  root.unmount();
1761
1773
  };
1762
1774
  }
1763
- export {
1764
- Devtools,
1775
+ const main = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1776
+ __proto__: null,
1765
1777
  createAdheseDevtools
1778
+ }, Symbol.toStringTag, { value: "Module" }));
1779
+ export {
1780
+ Devtools$1 as D,
1781
+ main as m
1766
1782
  };
1767
1783
  //# sourceMappingURL=devtools.js.map