@adhese/sdk 1.0.2 → 1.0.4
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/CHANGELOG.md +13 -0
- package/dist/{index.js → adheseSdk.js} +1 -1
- package/dist/adheseSdk.js.map +1 -0
- package/dist/cjs/{index.cjs → adheseSdk.cjs} +1 -1
- package/dist/cjs/adheseSdk.cjs.map +1 -0
- package/dist/cjs/hooks.cjs.map +1 -1
- package/dist/cjs/main.utils.cjs +7 -1
- package/dist/cjs/main.utils.cjs.map +1 -1
- package/dist/cjs/package.json.cjs +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/dist/main.utils.js +7 -1
- package/dist/main.utils.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +19 -4
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/{index.d.ts → adheseSdk.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @adhese/sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 32e1ca5: Update entry file name to make inspection after bundling easier
|
|
8
|
+
|
|
9
|
+
## 1.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 43a682c: Revert accidental change of Promise.allSettled to Promise.all which can cause issuess when a request fails
|
|
14
|
+
- 5393373: Add fallback legacy d.ts file for older ts version with very limited types
|
|
15
|
+
|
|
3
16
|
## 1.0.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adheseSdk.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adheseSdk.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/cjs/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","sources":["../../src/hooks.ts"],"sourcesContent":["import { createAsyncHook, createSyncHook } from '@adhese/sdk-shared';\nimport type { AdMultiRequestOptions } from './requestAds/requestAds';\nimport type { AdheseAd, AdheseSlotOptions } from './
|
|
1
|
+
{"version":3,"file":"hooks.cjs","sources":["../../src/hooks.ts"],"sourcesContent":["import { createAsyncHook, createSyncHook } from '@adhese/sdk-shared';\nimport type { AdMultiRequestOptions } from './requestAds/requestAds';\nimport type { AdheseAd, AdheseSlotOptions } from './adheseSdk';\n\n// eslint-disable-next-line ts/explicit-function-return-type,ts/explicit-module-boundary-types\nexport function createGlobalHooks() {\n const disposeFunctions = new Set<() => void>();\n\n let isInit = false;\n const [runOnInit, onInit, disposeOnInit] = createSyncHook({\n onRun(callbacks) {\n isInit = true;\n callbacks?.clear();\n },\n onAdd() {\n if (isInit)\n runOnInit();\n },\n });\n disposeFunctions.add(disposeOnInit);\n\n let isDisposed = false;\n const [runOnDispose, onDispose, disposeOnDispose] = createSyncHook({\n onRun(callbacks) {\n isDisposed = true;\n callbacks?.clear();\n },\n onAdd() {\n if (isDisposed)\n runOnDispose();\n },\n });\n disposeFunctions.add(disposeOnDispose);\n\n const [runOnRequest, onRequest, disposeOnRequest] = createAsyncHook<AdMultiRequestOptions>();\n disposeFunctions.add(disposeOnRequest);\n\n const [runOnResponse, onResponse, disposeOnResponse] = createAsyncHook<ReadonlyArray<AdheseAd>>();\n disposeFunctions.add(disposeOnResponse);\n\n const [runOnSlotCreate, onSlotCreate, disposeOnSlotCreate] = createSyncHook<AdheseSlotOptions>();\n disposeFunctions.add(disposeOnSlotCreate);\n\n function clearAll(): void {\n for (const disposeFunction of disposeFunctions)\n disposeFunction();\n }\n\n return {\n runOnInit,\n onInit,\n runOnDispose,\n onDispose,\n runOnRequest,\n onRequest,\n runOnResponse,\n onResponse,\n runOnSlotCreate,\n onSlotCreate,\n clearAll,\n };\n}\n"],"names":["createSyncHook","createAsyncHook"],"mappings":";;;AAKO,SAAS,oBAAoB;AAC5B,QAAA,uCAAuB;AAE7B,MAAI,SAAS;AACb,QAAM,CAAC,WAAW,QAAQ,aAAa,IAAIA,UAAAA,eAAe;AAAA,IACxD,MAAM,WAAW;AACN,eAAA;AACT,6CAAW;AAAA,IACb;AAAA,IACA,QAAQ;AACF,UAAA;AACQ;IACd;AAAA,EAAA,CACD;AACD,mBAAiB,IAAI,aAAa;AAElC,MAAI,aAAa;AACjB,QAAM,CAAC,cAAc,WAAW,gBAAgB,IAAIA,UAAAA,eAAe;AAAA,IACjE,MAAM,WAAW;AACF,mBAAA;AACb,6CAAW;AAAA,IACb;AAAA,IACA,QAAQ;AACF,UAAA;AACW;IACjB;AAAA,EAAA,CACD;AACD,mBAAiB,IAAI,gBAAgB;AAErC,QAAM,CAAC,cAAc,WAAW,gBAAgB,IAAIC,UAAuC,gBAAA;AAC3F,mBAAiB,IAAI,gBAAgB;AAErC,QAAM,CAAC,eAAe,YAAY,iBAAiB,IAAIA,UAAyC,gBAAA;AAChG,mBAAiB,IAAI,iBAAiB;AAEtC,QAAM,CAAC,iBAAiB,cAAc,mBAAmB,IAAID,UAAkC,eAAA;AAC/F,mBAAiB,IAAI,mBAAmB;AAExC,WAAS,WAAiB;AACxB,eAAW,mBAAmB;AACZ;EACpB;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
package/dist/cjs/main.utils.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const logger = require("./logger/logger.cjs");
|
|
3
4
|
function isPreviewMode() {
|
|
4
5
|
return window.location.search.includes("adhesePreviewCreativeId");
|
|
5
6
|
}
|
|
@@ -7,7 +8,12 @@ async function fetchAllUnrenderedSlots(slots) {
|
|
|
7
8
|
const filteredSlots = slots.filter((slot) => !slot.lazyLoading && !slot.data);
|
|
8
9
|
if (filteredSlots.length === 0)
|
|
9
10
|
return;
|
|
10
|
-
await Promise.
|
|
11
|
+
const results = await Promise.allSettled(filteredSlots.map((slot) => slot.request));
|
|
12
|
+
for (const [index, result] of results.entries()) {
|
|
13
|
+
if (result.status === "rejected") {
|
|
14
|
+
logger.logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
exports.fetchAllUnrenderedSlots = fetchAllUnrenderedSlots;
|
|
13
19
|
exports.isPreviewMode = isPreviewMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.utils.cjs","sources":["../../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n await Promise.
|
|
1
|
+
{"version":3,"file":"main.utils.cjs","sources":["../../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\nimport { logger } from './logger/logger';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n const results = await Promise.allSettled(filteredSlots.map(slot => slot.request));\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'rejected') {\n logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);\n }\n }\n}\n"],"names":["logger"],"mappings":";;;AAMO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,UAAU,MAAM,QAAQ,WAAW,cAAc,IAAI,CAAA,SAAQ,KAAK,OAAO,CAAC;AAEhF,aAAW,CAAC,OAAO,MAAM,KAAK,QAAQ,WAAW;AAC3C,QAAA,OAAO,WAAW,YAAY;AACzBA,aAAAA,OAAA,MAAM,sCAAsC,cAAc,KAAK,EAAE,IAAI,IAAI,OAAO,MAAM;AAAA,IAC/F;AAAA,EACF;AACF;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const name = "@adhese/sdk";
|
|
4
|
-
const version = "1.0.
|
|
4
|
+
const version = "1.0.4";
|
|
5
5
|
exports.name = name;
|
|
6
6
|
exports.version = version;
|
|
7
7
|
//# sourceMappingURL=package.json.cjs.map
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../src/hooks.ts"],"sourcesContent":["import { createAsyncHook, createSyncHook } from '@adhese/sdk-shared';\nimport type { AdMultiRequestOptions } from './requestAds/requestAds';\nimport type { AdheseAd, AdheseSlotOptions } from './
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../src/hooks.ts"],"sourcesContent":["import { createAsyncHook, createSyncHook } from '@adhese/sdk-shared';\nimport type { AdMultiRequestOptions } from './requestAds/requestAds';\nimport type { AdheseAd, AdheseSlotOptions } from './adheseSdk';\n\n// eslint-disable-next-line ts/explicit-function-return-type,ts/explicit-module-boundary-types\nexport function createGlobalHooks() {\n const disposeFunctions = new Set<() => void>();\n\n let isInit = false;\n const [runOnInit, onInit, disposeOnInit] = createSyncHook({\n onRun(callbacks) {\n isInit = true;\n callbacks?.clear();\n },\n onAdd() {\n if (isInit)\n runOnInit();\n },\n });\n disposeFunctions.add(disposeOnInit);\n\n let isDisposed = false;\n const [runOnDispose, onDispose, disposeOnDispose] = createSyncHook({\n onRun(callbacks) {\n isDisposed = true;\n callbacks?.clear();\n },\n onAdd() {\n if (isDisposed)\n runOnDispose();\n },\n });\n disposeFunctions.add(disposeOnDispose);\n\n const [runOnRequest, onRequest, disposeOnRequest] = createAsyncHook<AdMultiRequestOptions>();\n disposeFunctions.add(disposeOnRequest);\n\n const [runOnResponse, onResponse, disposeOnResponse] = createAsyncHook<ReadonlyArray<AdheseAd>>();\n disposeFunctions.add(disposeOnResponse);\n\n const [runOnSlotCreate, onSlotCreate, disposeOnSlotCreate] = createSyncHook<AdheseSlotOptions>();\n disposeFunctions.add(disposeOnSlotCreate);\n\n function clearAll(): void {\n for (const disposeFunction of disposeFunctions)\n disposeFunction();\n }\n\n return {\n runOnInit,\n onInit,\n runOnDispose,\n onDispose,\n runOnRequest,\n onRequest,\n runOnResponse,\n onResponse,\n runOnSlotCreate,\n onSlotCreate,\n clearAll,\n };\n}\n"],"names":[],"mappings":";AAKO,SAAS,oBAAoB;AAC5B,QAAA,uCAAuB;AAE7B,MAAI,SAAS;AACb,QAAM,CAAC,WAAW,QAAQ,aAAa,IAAI,eAAe;AAAA,IACxD,MAAM,WAAW;AACN,eAAA;AACT,6CAAW;AAAA,IACb;AAAA,IACA,QAAQ;AACF,UAAA;AACQ;IACd;AAAA,EAAA,CACD;AACD,mBAAiB,IAAI,aAAa;AAElC,MAAI,aAAa;AACjB,QAAM,CAAC,cAAc,WAAW,gBAAgB,IAAI,eAAe;AAAA,IACjE,MAAM,WAAW;AACF,mBAAA;AACb,6CAAW;AAAA,IACb;AAAA,IACA,QAAQ;AACF,UAAA;AACW;IACjB;AAAA,EAAA,CACD;AACD,mBAAiB,IAAI,gBAAgB;AAErC,QAAM,CAAC,cAAc,WAAW,gBAAgB,IAAI,gBAAuC;AAC3F,mBAAiB,IAAI,gBAAgB;AAErC,QAAM,CAAC,eAAe,YAAY,iBAAiB,IAAI,gBAAyC;AAChG,mBAAiB,IAAI,iBAAiB;AAEtC,QAAM,CAAC,iBAAiB,cAAc,mBAAmB,IAAI,eAAkC;AAC/F,mBAAiB,IAAI,mBAAmB;AAExC,WAAS,WAAiB;AACxB,eAAW,mBAAmB;AACZ;EACpB;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function createAdhese(options: any): any;
|
package/dist/main.utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from "./logger/logger.js";
|
|
1
2
|
function isPreviewMode() {
|
|
2
3
|
return window.location.search.includes("adhesePreviewCreativeId");
|
|
3
4
|
}
|
|
@@ -5,7 +6,12 @@ async function fetchAllUnrenderedSlots(slots) {
|
|
|
5
6
|
const filteredSlots = slots.filter((slot) => !slot.lazyLoading && !slot.data);
|
|
6
7
|
if (filteredSlots.length === 0)
|
|
7
8
|
return;
|
|
8
|
-
await Promise.
|
|
9
|
+
const results = await Promise.allSettled(filteredSlots.map((slot) => slot.request));
|
|
10
|
+
for (const [index, result] of results.entries()) {
|
|
11
|
+
if (result.status === "rejected") {
|
|
12
|
+
logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
9
15
|
}
|
|
10
16
|
export {
|
|
11
17
|
fetchAllUnrenderedSlots,
|
package/dist/main.utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.utils.js","sources":["../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n await Promise.
|
|
1
|
+
{"version":3,"file":"main.utils.js","sources":["../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\nimport { logger } from './logger/logger';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n const results = await Promise.allSettled(filteredSlots.map(slot => slot.request));\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'rejected') {\n logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);\n }\n }\n}\n"],"names":[],"mappings":";AAMO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,UAAU,MAAM,QAAQ,WAAW,cAAc,IAAI,CAAA,SAAQ,KAAK,OAAO,CAAC;AAEhF,aAAW,CAAC,OAAO,MAAM,KAAK,QAAQ,WAAW;AAC3C,QAAA,OAAO,WAAW,YAAY;AACzB,aAAA,MAAM,sCAAsC,cAAc,KAAK,EAAE,IAAI,IAAI,OAAO,MAAM;AAAA,IAC/F;AAAA,EACF;AACF;"}
|
package/dist/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhese/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"description": "Adhese SDK",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/adhese/sdk_typescript.git"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/adheseSdk.d.ts",
|
|
14
|
+
"import": "./dist/adheseSdk.js",
|
|
15
|
+
"require": "./dist/adheseSdk.cjs",
|
|
16
|
+
"types@<5.1": "./dist/legacy.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/adheseSdk.cjs",
|
|
20
|
+
"module": "./dist/adheseSdk.js",
|
|
21
|
+
"types": "./dist/adheseSdk.d.ts",
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"<5.1": {
|
|
24
|
+
"*": [
|
|
25
|
+
"./dist/legacy.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
14
29
|
"files": [
|
|
15
30
|
"CHANGELOG.md",
|
|
16
31
|
"LICENSE",
|
package/dist/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
File without changes
|