@gravity-ai/api 1.4.0 → 1.5.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/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +242 -8
- package/dist/index.mjs +242 -8
- package/dist/opentui.js +1 -1
- package/dist/opentui.mjs +1 -1
- package/dist/{types-C20oXLJd.d.mts → types-FOlyOpps.d.mts} +18 -4
- package/dist/{types-C20oXLJd.d.ts → types-FOlyOpps.d.ts} +18 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-
|
|
2
|
-
export { e as AdAction, f as AdLayout, g as AdUnit, h as ApiErrorResponse, D as DeviceObject, F as FrameSize, i as Gender, H as HostTheme, L as LeadFormConfig, j as LeadFormField, k as LeadFormPrefill, l as McpConnect, m as McpConnectHandler, n as McpConnectRequest, o as McpConnectResult, p as ModelUsage, q as Placement, r as PromptAction, R as RenderEnvelope, s as Role, S as SlotSize, T as TextMetrics, U as UnitCapability, t as UnknownAdAction, u as UserObject } from './types-
|
|
1
|
+
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-FOlyOpps.mjs';
|
|
2
|
+
export { e as AdAction, f as AdLayout, g as AdUnit, h as ApiErrorResponse, D as DeviceObject, F as FrameSize, i as Gender, H as HostTheme, L as LeadFormConfig, j as LeadFormField, k as LeadFormPrefill, l as McpConnect, m as McpConnectHandler, n as McpConnectRequest, o as McpConnectResult, p as ModelUsage, q as Placement, r as PromptAction, R as RenderEnvelope, s as Role, S as SlotSize, T as TextMetrics, U as UnitCapability, t as UnknownAdAction, u as UserObject } from './types-FOlyOpps.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gravity ad client.
|
|
@@ -371,6 +371,10 @@ declare function hashPii(values: RawIdentity): Promise<HashedIdentity>;
|
|
|
371
371
|
*
|
|
372
372
|
* - TCF v2: `window.__tcfapi(command, version, callback)`
|
|
373
373
|
* - US Privacy (CCPA): `window.__uspapi(command, version, callback)`
|
|
374
|
+
* - GPP v1.1: `window.__gpp(command, callback, parameter, version)`
|
|
375
|
+
*
|
|
376
|
+
* It also reads the browser's Global Privacy Control signal
|
|
377
|
+
* (`navigator.globalPrivacyControl`).
|
|
374
378
|
*
|
|
375
379
|
* This module reads those APIs (when present) and shapes the result into the
|
|
376
380
|
* `consent` object the Gravity ad API accepts, so consent collected by the
|
|
@@ -385,6 +389,12 @@ interface ConsentSignal {
|
|
|
385
389
|
tcfString?: string;
|
|
386
390
|
/** IAB US Privacy (CCPA) string, e.g. `"1YNN"`. */
|
|
387
391
|
usPrivacy?: string;
|
|
392
|
+
/** IAB Global Privacy Platform (GPP) string from the publisher's CMP. */
|
|
393
|
+
gpp?: string;
|
|
394
|
+
/** GPP section ids that apply to this request (`applicableSections`). */
|
|
395
|
+
gppSid?: number[];
|
|
396
|
+
/** Global Privacy Control. Only `true` is a signal; omit it otherwise. */
|
|
397
|
+
gpc?: boolean;
|
|
388
398
|
}
|
|
389
399
|
/**
|
|
390
400
|
* Synchronously return the current CMP consent signal, or `undefined` when
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-
|
|
2
|
-
export { e as AdAction, f as AdLayout, g as AdUnit, h as ApiErrorResponse, D as DeviceObject, F as FrameSize, i as Gender, H as HostTheme, L as LeadFormConfig, j as LeadFormField, k as LeadFormPrefill, l as McpConnect, m as McpConnectHandler, n as McpConnectRequest, o as McpConnectResult, p as ModelUsage, q as Placement, r as PromptAction, R as RenderEnvelope, s as Role, S as SlotSize, T as TextMetrics, U as UnitCapability, t as UnknownAdAction, u as UserObject } from './types-
|
|
1
|
+
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-FOlyOpps.js';
|
|
2
|
+
export { e as AdAction, f as AdLayout, g as AdUnit, h as ApiErrorResponse, D as DeviceObject, F as FrameSize, i as Gender, H as HostTheme, L as LeadFormConfig, j as LeadFormField, k as LeadFormPrefill, l as McpConnect, m as McpConnectHandler, n as McpConnectRequest, o as McpConnectResult, p as ModelUsage, q as Placement, r as PromptAction, R as RenderEnvelope, s as Role, S as SlotSize, T as TextMetrics, U as UnitCapability, t as UnknownAdAction, u as UserObject } from './types-FOlyOpps.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gravity ad client.
|
|
@@ -371,6 +371,10 @@ declare function hashPii(values: RawIdentity): Promise<HashedIdentity>;
|
|
|
371
371
|
*
|
|
372
372
|
* - TCF v2: `window.__tcfapi(command, version, callback)`
|
|
373
373
|
* - US Privacy (CCPA): `window.__uspapi(command, version, callback)`
|
|
374
|
+
* - GPP v1.1: `window.__gpp(command, callback, parameter, version)`
|
|
375
|
+
*
|
|
376
|
+
* It also reads the browser's Global Privacy Control signal
|
|
377
|
+
* (`navigator.globalPrivacyControl`).
|
|
374
378
|
*
|
|
375
379
|
* This module reads those APIs (when present) and shapes the result into the
|
|
376
380
|
* `consent` object the Gravity ad API accepts, so consent collected by the
|
|
@@ -385,6 +389,12 @@ interface ConsentSignal {
|
|
|
385
389
|
tcfString?: string;
|
|
386
390
|
/** IAB US Privacy (CCPA) string, e.g. `"1YNN"`. */
|
|
387
391
|
usPrivacy?: string;
|
|
392
|
+
/** IAB Global Privacy Platform (GPP) string from the publisher's CMP. */
|
|
393
|
+
gpp?: string;
|
|
394
|
+
/** GPP section ids that apply to this request (`applicableSections`). */
|
|
395
|
+
gppSid?: number[];
|
|
396
|
+
/** Global Privacy Control. Only `true` is a signal; omit it otherwise. */
|
|
397
|
+
gpc?: boolean;
|
|
388
398
|
}
|
|
389
399
|
/**
|
|
390
400
|
* Synchronously return the current CMP consent signal, or `undefined` when
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@gravity-ai/api",
|
|
42
|
-
version: "1.
|
|
42
|
+
version: "1.5.0",
|
|
43
43
|
description: "Gravity JS SDK for retrieving targeted advertisements",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
module: "dist/index.mjs",
|
|
@@ -141,6 +141,195 @@ var pkg = (() => {
|
|
|
141
141
|
})();
|
|
142
142
|
var SDK = { name: pkg.name, version: pkg.version };
|
|
143
143
|
|
|
144
|
+
// ../ui/src/psp.ts
|
|
145
|
+
var SPEC_LINK_PROTOCOLS = ["http:", "https:", "mailto:"];
|
|
146
|
+
var SHADCN_CHANNEL_DEFAULTS = {
|
|
147
|
+
background: "0 0% 100%",
|
|
148
|
+
foreground: "240 6% 10%",
|
|
149
|
+
card: "0 0% 100%",
|
|
150
|
+
"card-foreground": "240 6% 10%",
|
|
151
|
+
primary: "221 83% 53%",
|
|
152
|
+
"primary-foreground": "0 0% 100%",
|
|
153
|
+
muted: "240 5% 96%",
|
|
154
|
+
"muted-foreground": "240 5% 47%",
|
|
155
|
+
accent: "221 83% 53%",
|
|
156
|
+
"accent-foreground": "0 0% 100%",
|
|
157
|
+
border: "240 5% 90%"
|
|
158
|
+
};
|
|
159
|
+
var SHADCN_HOST_TOKENS = Object.keys(SHADCN_CHANNEL_DEFAULTS);
|
|
160
|
+
var PSP1_COLOR_TOKENS = [
|
|
161
|
+
"background",
|
|
162
|
+
"foreground",
|
|
163
|
+
"card",
|
|
164
|
+
"card-foreground",
|
|
165
|
+
"primary",
|
|
166
|
+
"primary-foreground",
|
|
167
|
+
"muted",
|
|
168
|
+
"muted-foreground",
|
|
169
|
+
"accent",
|
|
170
|
+
"accent-foreground",
|
|
171
|
+
"border"
|
|
172
|
+
];
|
|
173
|
+
var PSP1_MAX_FONT_SIZE_PX = 20;
|
|
174
|
+
var PSP1_MAX_SPACING_PX = 32;
|
|
175
|
+
var PSP1_MAX_IMAGE_PX = 64;
|
|
176
|
+
var ok = null;
|
|
177
|
+
function err(msg) {
|
|
178
|
+
return msg;
|
|
179
|
+
}
|
|
180
|
+
var PX_RE = /^\d+(\.\d+)?px$/;
|
|
181
|
+
var PX_LIST_RE = /^\d+(\.\d+)?px( \d+(\.\d+)?px){0,3}$/;
|
|
182
|
+
var EM_RE = /^-?\d+(\.\d+)?em$/;
|
|
183
|
+
var TOKEN_RE = new RegExp(
|
|
184
|
+
`^\\$(${PSP1_COLOR_TOKENS.join("|")})(/(100|[1-9]?[0-9]))?$`
|
|
185
|
+
);
|
|
186
|
+
function pxNumber(value) {
|
|
187
|
+
if (typeof value === "number") return value >= 0 ? value : null;
|
|
188
|
+
if (typeof value === "string" && PX_RE.test(value)) return parseFloat(value);
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
function ruleColor(value) {
|
|
192
|
+
if (typeof value !== "string") return err("color must be a string");
|
|
193
|
+
if (value === "transparent" || TOKEN_RE.test(value)) return ok;
|
|
194
|
+
return err(`color must be "transparent" or a $token, got "${value}"`);
|
|
195
|
+
}
|
|
196
|
+
function rulePx(cap) {
|
|
197
|
+
return (value) => {
|
|
198
|
+
const px2 = pxNumber(value);
|
|
199
|
+
if (px2 === null) return err(`must be a px value, got "${value}"`);
|
|
200
|
+
if (px2 > cap) return err(`exceeds ${cap}px cap (${px2}px)`);
|
|
201
|
+
return ok;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function rulePxList(cap) {
|
|
205
|
+
return (value) => {
|
|
206
|
+
if (typeof value === "number") {
|
|
207
|
+
if (value < 0) return err(`must not be negative (${value}px)`);
|
|
208
|
+
return value <= cap ? ok : err(`exceeds ${cap}px cap (${value}px)`);
|
|
209
|
+
}
|
|
210
|
+
if (typeof value !== "string" || !PX_LIST_RE.test(value)) {
|
|
211
|
+
return err(`must be 1-4 px values, got "${value}"`);
|
|
212
|
+
}
|
|
213
|
+
for (const part of value.split(" ")) {
|
|
214
|
+
if (parseFloat(part) > cap) {
|
|
215
|
+
return err(`exceeds ${cap}px cap ("${value}")`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return ok;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function ruleEnum(...allowed) {
|
|
222
|
+
return (value) => allowed.includes(value) ? ok : err(`must be one of ${allowed.join("|")}, got "${value}"`);
|
|
223
|
+
}
|
|
224
|
+
var ruleDimension = (value, node) => {
|
|
225
|
+
if (value === "100%") return ok;
|
|
226
|
+
const px2 = pxNumber(value);
|
|
227
|
+
if (px2 === null) return err(`must be px or "100%", got "${value}"`);
|
|
228
|
+
if (node.type === "image" && px2 > PSP1_MAX_IMAGE_PX) {
|
|
229
|
+
return err(`image dimension exceeds ${PSP1_MAX_IMAGE_PX}px cap (${px2}px)`);
|
|
230
|
+
}
|
|
231
|
+
return ok;
|
|
232
|
+
};
|
|
233
|
+
var ruleRadius = (value) => {
|
|
234
|
+
if (value === "full" || value === "$radius") return ok;
|
|
235
|
+
const px2 = pxNumber(value);
|
|
236
|
+
if (px2 === null) {
|
|
237
|
+
return err(`must be px, "full", or "$radius", got "${value}"`);
|
|
238
|
+
}
|
|
239
|
+
return ok;
|
|
240
|
+
};
|
|
241
|
+
var ruleBorder = (value) => {
|
|
242
|
+
if (typeof value !== "string") return err("border must be a string");
|
|
243
|
+
const m = value.match(/^1px solid (\$\S+)$/);
|
|
244
|
+
if (!m || ruleColor(m[1]) !== null) {
|
|
245
|
+
return err(`must be "1px solid $token", got "${value}"`);
|
|
246
|
+
}
|
|
247
|
+
return ok;
|
|
248
|
+
};
|
|
249
|
+
var ruleLineHeight = (value) => {
|
|
250
|
+
if (typeof value === "boolean") return err("must be a number");
|
|
251
|
+
const n = typeof value === "number" ? value : parseFloat(value);
|
|
252
|
+
if (typeof value === "string" && !/^\d+(\.\d+)?$/.test(value)) {
|
|
253
|
+
return err(`must be a unitless multiplier, got "${value}"`);
|
|
254
|
+
}
|
|
255
|
+
if (Number.isNaN(n) || n < 1 || n > 2) {
|
|
256
|
+
return err(`must be a unitless multiplier in [1, 2], got "${value}"`);
|
|
257
|
+
}
|
|
258
|
+
return ok;
|
|
259
|
+
};
|
|
260
|
+
var ruleOpacity = (value) => {
|
|
261
|
+
if (typeof value === "boolean") return err("must be a number");
|
|
262
|
+
if (typeof value === "string" && !/^\d+(\.\d+)?$/.test(value)) {
|
|
263
|
+
return err(`must be a unitless number, got "${value}"`);
|
|
264
|
+
}
|
|
265
|
+
const n = typeof value === "number" ? value : parseFloat(value);
|
|
266
|
+
if (Number.isNaN(n) || n < 0 || n > 1) {
|
|
267
|
+
return err(`must be in [0, 1], got "${value}"`);
|
|
268
|
+
}
|
|
269
|
+
return ok;
|
|
270
|
+
};
|
|
271
|
+
var ruleMaxLines = (value) => {
|
|
272
|
+
if (typeof value === "boolean") return err("must be an integer");
|
|
273
|
+
if (typeof value === "string" && !/^\d+$/.test(value)) {
|
|
274
|
+
return err(`must be an integer, got "${value}"`);
|
|
275
|
+
}
|
|
276
|
+
const n = typeof value === "number" ? value : parseInt(value, 10);
|
|
277
|
+
if (!Number.isInteger(n) || n < 1 || n > 10) {
|
|
278
|
+
return err(`must be an integer in [1, 10], got "${value}"`);
|
|
279
|
+
}
|
|
280
|
+
return ok;
|
|
281
|
+
};
|
|
282
|
+
var ruleLetterSpacing = (value) => {
|
|
283
|
+
if (typeof value === "string" && EM_RE.test(value)) return ok;
|
|
284
|
+
return err(`must be an em value, got "${value}"`);
|
|
285
|
+
};
|
|
286
|
+
var ruleBool = (value) => value === true || value === false ? ok : err(`must be a boolean, got "${value}"`);
|
|
287
|
+
var PSP1_STYLE_RULES = {
|
|
288
|
+
// Layout
|
|
289
|
+
direction: ruleEnum("row", "column"),
|
|
290
|
+
gap: rulePx(PSP1_MAX_SPACING_PX),
|
|
291
|
+
align: ruleEnum("start", "center", "end", "baseline"),
|
|
292
|
+
justify: ruleEnum("start", "center", "end", "space-between"),
|
|
293
|
+
grow: ruleEnum(0, 1),
|
|
294
|
+
shrink: ruleEnum(0, 1),
|
|
295
|
+
spacerBefore: ruleBool,
|
|
296
|
+
// Box
|
|
297
|
+
padding: rulePxList(PSP1_MAX_SPACING_PX),
|
|
298
|
+
paddingTop: rulePx(PSP1_MAX_SPACING_PX),
|
|
299
|
+
paddingRight: rulePx(PSP1_MAX_SPACING_PX),
|
|
300
|
+
paddingBottom: rulePx(PSP1_MAX_SPACING_PX),
|
|
301
|
+
paddingLeft: rulePx(PSP1_MAX_SPACING_PX),
|
|
302
|
+
margin: rulePxList(PSP1_MAX_SPACING_PX),
|
|
303
|
+
marginTop: rulePx(PSP1_MAX_SPACING_PX),
|
|
304
|
+
marginRight: rulePx(PSP1_MAX_SPACING_PX),
|
|
305
|
+
marginBottom: rulePx(PSP1_MAX_SPACING_PX),
|
|
306
|
+
marginLeft: rulePx(PSP1_MAX_SPACING_PX),
|
|
307
|
+
width: ruleDimension,
|
|
308
|
+
height: ruleDimension,
|
|
309
|
+
maxWidth: rulePx(Infinity),
|
|
310
|
+
minWidth: (value) => value === 0 || value === "0" || pxNumber(value) !== null ? ok : err(`must be 0 or px, got "${value}"`),
|
|
311
|
+
// Surface
|
|
312
|
+
background: ruleColor,
|
|
313
|
+
border: ruleBorder,
|
|
314
|
+
borderRadius: ruleRadius,
|
|
315
|
+
elevation: ruleEnum("none", "sm", "md"),
|
|
316
|
+
opacity: ruleOpacity,
|
|
317
|
+
// Text
|
|
318
|
+
fontSize: rulePx(PSP1_MAX_FONT_SIZE_PX),
|
|
319
|
+
fontWeight: ruleEnum(400, 500, 600, 700, 800),
|
|
320
|
+
lineHeight: ruleLineHeight,
|
|
321
|
+
letterSpacing: ruleLetterSpacing,
|
|
322
|
+
color: ruleColor,
|
|
323
|
+
textTransform: ruleEnum("none", "uppercase"),
|
|
324
|
+
textDecoration: ruleEnum("none", "underline"),
|
|
325
|
+
textAlign: ruleEnum("left", "center", "right"),
|
|
326
|
+
maxLines: ruleMaxLines,
|
|
327
|
+
nowrap: ruleBool,
|
|
328
|
+
// Image
|
|
329
|
+
fit: ruleEnum("contain", "cover")
|
|
330
|
+
};
|
|
331
|
+
var ALLOWED_URL_PROTOCOLS = SPEC_LINK_PROTOCOLS.map((p) => p.slice(0, -1));
|
|
332
|
+
|
|
144
333
|
// ../ui/src/theme.ts
|
|
145
334
|
var GRAVITY_DARK_VARS = {
|
|
146
335
|
"--gravity-bg": "#1F1F23",
|
|
@@ -390,9 +579,9 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
390
579
|
const data = await res.json();
|
|
391
580
|
const ads = Array.isArray(data) ? data : [data];
|
|
392
581
|
return { ads, status: res.status, elapsed, requestBody: body };
|
|
393
|
-
} catch (
|
|
582
|
+
} catch (err2) {
|
|
394
583
|
const elapsed = (performance.now() - start).toFixed(0);
|
|
395
|
-
const error =
|
|
584
|
+
const error = err2 instanceof Error ? err2.name === "TimeoutError" ? `Timeout (${timeoutMs}ms)` : err2.message : String(err2);
|
|
396
585
|
return { ads: [], status: 0, elapsed, error, requestBody: body };
|
|
397
586
|
}
|
|
398
587
|
}
|
|
@@ -454,7 +643,10 @@ function findCmpApi(name) {
|
|
|
454
643
|
}
|
|
455
644
|
var cachedTcf;
|
|
456
645
|
var cachedUsp;
|
|
646
|
+
var cachedGpp;
|
|
457
647
|
var tcfListening = false;
|
|
648
|
+
var tcfBroken = false;
|
|
649
|
+
var gppListening = false;
|
|
458
650
|
var cmpWaitExhausted = false;
|
|
459
651
|
function ensureListening() {
|
|
460
652
|
if (typeof window === "undefined") return;
|
|
@@ -474,6 +666,21 @@ function ensureListening() {
|
|
|
474
666
|
cachedTcf = { gdprApplies: false };
|
|
475
667
|
}
|
|
476
668
|
});
|
|
669
|
+
} catch {
|
|
670
|
+
tcfBroken = true;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const gpp = gppListening ? void 0 : findCmpApi("__gpp");
|
|
674
|
+
if (gpp) {
|
|
675
|
+
gppListening = true;
|
|
676
|
+
try {
|
|
677
|
+
gpp("addEventListener", (data, success) => {
|
|
678
|
+
if (!success || typeof data !== "object" || data === null) return;
|
|
679
|
+
cacheGppPing(data.pingData);
|
|
680
|
+
});
|
|
681
|
+
gpp("ping", (data, success) => {
|
|
682
|
+
if (success) cacheGppPing(data);
|
|
683
|
+
});
|
|
477
684
|
} catch {
|
|
478
685
|
}
|
|
479
686
|
}
|
|
@@ -489,13 +696,38 @@ function ensureListening() {
|
|
|
489
696
|
}
|
|
490
697
|
}
|
|
491
698
|
}
|
|
699
|
+
function cacheGppPing(ping) {
|
|
700
|
+
if (typeof ping !== "object" || ping === null) return;
|
|
701
|
+
const p = ping;
|
|
702
|
+
if (p.signalStatus !== "ready") return;
|
|
703
|
+
if (typeof p.gppString !== "string" || !p.gppString) return;
|
|
704
|
+
const raw = Array.isArray(p.applicableSections) ? p.applicableSections : [];
|
|
705
|
+
const readable = raw.every((id) => Number.isInteger(id));
|
|
706
|
+
const sections = readable ? raw.filter((id) => id !== -1) : [];
|
|
707
|
+
cachedGpp = sections.length ? { gpp: p.gppString, gppSid: sections } : { gpp: p.gppString };
|
|
708
|
+
}
|
|
709
|
+
function tcfPending() {
|
|
710
|
+
return !cachedTcf && !tcfBroken && Boolean(findCmpApi("__tcfapi"));
|
|
711
|
+
}
|
|
712
|
+
function cmpSettled() {
|
|
713
|
+
return !tcfPending() && (cachedGpp !== void 0 || !findCmpApi("__gpp"));
|
|
714
|
+
}
|
|
715
|
+
function detectGpc() {
|
|
716
|
+
return typeof navigator !== "undefined" && navigator.globalPrivacyControl === true;
|
|
717
|
+
}
|
|
492
718
|
function detectCmpConsent() {
|
|
493
719
|
ensureListening();
|
|
494
|
-
|
|
720
|
+
const gpc = detectGpc();
|
|
721
|
+
if (!cachedTcf && !cachedUsp && !cachedGpp && !gpc) return void 0;
|
|
495
722
|
const consent = {};
|
|
496
723
|
if (cachedTcf?.gdprApplies !== void 0) consent.gdprApplies = cachedTcf.gdprApplies;
|
|
497
724
|
if (cachedTcf?.tcfString) consent.tcfString = cachedTcf.tcfString;
|
|
498
725
|
if (cachedUsp) consent.usPrivacy = cachedUsp;
|
|
726
|
+
if (cachedGpp && !tcfPending()) {
|
|
727
|
+
consent.gpp = cachedGpp.gpp;
|
|
728
|
+
if (cachedGpp.gppSid) consent.gppSid = [...cachedGpp.gppSid];
|
|
729
|
+
}
|
|
730
|
+
if (gpc) consent.gpc = true;
|
|
499
731
|
if (Object.keys(consent).length === 0) return void 0;
|
|
500
732
|
return consent;
|
|
501
733
|
}
|
|
@@ -505,20 +737,22 @@ if (typeof window !== "undefined") ensureListening();
|
|
|
505
737
|
function readCmpConsent(timeoutMs = 500) {
|
|
506
738
|
ensureListening();
|
|
507
739
|
const immediate = detectCmpConsent();
|
|
508
|
-
if (immediate || cmpWaitExhausted || typeof window === "undefined") {
|
|
740
|
+
if (immediate && cmpSettled() || cmpWaitExhausted || typeof window === "undefined") {
|
|
509
741
|
return Promise.resolve(immediate);
|
|
510
742
|
}
|
|
511
743
|
return new Promise((resolve) => {
|
|
512
744
|
const started = Date.now();
|
|
513
745
|
const poll = () => {
|
|
514
746
|
const consent = detectCmpConsent();
|
|
515
|
-
if (consent) return resolve(consent);
|
|
747
|
+
if (consent && cmpSettled()) return resolve(consent);
|
|
516
748
|
const elapsed = Date.now() - started;
|
|
517
|
-
const cmpPresent = Boolean(
|
|
749
|
+
const cmpPresent = Boolean(
|
|
750
|
+
findCmpApi("__tcfapi") || findCmpApi("__uspapi") || findCmpApi("__gpp")
|
|
751
|
+
);
|
|
518
752
|
if (cmpPresent) {
|
|
519
753
|
if (elapsed >= timeoutMs) {
|
|
520
754
|
cmpWaitExhausted = true;
|
|
521
|
-
return resolve(
|
|
755
|
+
return resolve(consent);
|
|
522
756
|
}
|
|
523
757
|
} else if (elapsed >= timeoutMs || Date.now() - graceStartedAt >= NO_CMP_GRACE_MS) {
|
|
524
758
|
return resolve(void 0);
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@gravity-ai/api",
|
|
11
|
-
version: "1.
|
|
11
|
+
version: "1.5.0",
|
|
12
12
|
description: "Gravity JS SDK for retrieving targeted advertisements",
|
|
13
13
|
main: "dist/index.js",
|
|
14
14
|
module: "dist/index.mjs",
|
|
@@ -92,6 +92,195 @@ var pkg = (() => {
|
|
|
92
92
|
})();
|
|
93
93
|
var SDK = { name: pkg.name, version: pkg.version };
|
|
94
94
|
|
|
95
|
+
// ../ui/src/psp.ts
|
|
96
|
+
var SPEC_LINK_PROTOCOLS = ["http:", "https:", "mailto:"];
|
|
97
|
+
var SHADCN_CHANNEL_DEFAULTS = {
|
|
98
|
+
background: "0 0% 100%",
|
|
99
|
+
foreground: "240 6% 10%",
|
|
100
|
+
card: "0 0% 100%",
|
|
101
|
+
"card-foreground": "240 6% 10%",
|
|
102
|
+
primary: "221 83% 53%",
|
|
103
|
+
"primary-foreground": "0 0% 100%",
|
|
104
|
+
muted: "240 5% 96%",
|
|
105
|
+
"muted-foreground": "240 5% 47%",
|
|
106
|
+
accent: "221 83% 53%",
|
|
107
|
+
"accent-foreground": "0 0% 100%",
|
|
108
|
+
border: "240 5% 90%"
|
|
109
|
+
};
|
|
110
|
+
var SHADCN_HOST_TOKENS = Object.keys(SHADCN_CHANNEL_DEFAULTS);
|
|
111
|
+
var PSP1_COLOR_TOKENS = [
|
|
112
|
+
"background",
|
|
113
|
+
"foreground",
|
|
114
|
+
"card",
|
|
115
|
+
"card-foreground",
|
|
116
|
+
"primary",
|
|
117
|
+
"primary-foreground",
|
|
118
|
+
"muted",
|
|
119
|
+
"muted-foreground",
|
|
120
|
+
"accent",
|
|
121
|
+
"accent-foreground",
|
|
122
|
+
"border"
|
|
123
|
+
];
|
|
124
|
+
var PSP1_MAX_FONT_SIZE_PX = 20;
|
|
125
|
+
var PSP1_MAX_SPACING_PX = 32;
|
|
126
|
+
var PSP1_MAX_IMAGE_PX = 64;
|
|
127
|
+
var ok = null;
|
|
128
|
+
function err(msg) {
|
|
129
|
+
return msg;
|
|
130
|
+
}
|
|
131
|
+
var PX_RE = /^\d+(\.\d+)?px$/;
|
|
132
|
+
var PX_LIST_RE = /^\d+(\.\d+)?px( \d+(\.\d+)?px){0,3}$/;
|
|
133
|
+
var EM_RE = /^-?\d+(\.\d+)?em$/;
|
|
134
|
+
var TOKEN_RE = new RegExp(
|
|
135
|
+
`^\\$(${PSP1_COLOR_TOKENS.join("|")})(/(100|[1-9]?[0-9]))?$`
|
|
136
|
+
);
|
|
137
|
+
function pxNumber(value) {
|
|
138
|
+
if (typeof value === "number") return value >= 0 ? value : null;
|
|
139
|
+
if (typeof value === "string" && PX_RE.test(value)) return parseFloat(value);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function ruleColor(value) {
|
|
143
|
+
if (typeof value !== "string") return err("color must be a string");
|
|
144
|
+
if (value === "transparent" || TOKEN_RE.test(value)) return ok;
|
|
145
|
+
return err(`color must be "transparent" or a $token, got "${value}"`);
|
|
146
|
+
}
|
|
147
|
+
function rulePx(cap) {
|
|
148
|
+
return (value) => {
|
|
149
|
+
const px2 = pxNumber(value);
|
|
150
|
+
if (px2 === null) return err(`must be a px value, got "${value}"`);
|
|
151
|
+
if (px2 > cap) return err(`exceeds ${cap}px cap (${px2}px)`);
|
|
152
|
+
return ok;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function rulePxList(cap) {
|
|
156
|
+
return (value) => {
|
|
157
|
+
if (typeof value === "number") {
|
|
158
|
+
if (value < 0) return err(`must not be negative (${value}px)`);
|
|
159
|
+
return value <= cap ? ok : err(`exceeds ${cap}px cap (${value}px)`);
|
|
160
|
+
}
|
|
161
|
+
if (typeof value !== "string" || !PX_LIST_RE.test(value)) {
|
|
162
|
+
return err(`must be 1-4 px values, got "${value}"`);
|
|
163
|
+
}
|
|
164
|
+
for (const part of value.split(" ")) {
|
|
165
|
+
if (parseFloat(part) > cap) {
|
|
166
|
+
return err(`exceeds ${cap}px cap ("${value}")`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return ok;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function ruleEnum(...allowed) {
|
|
173
|
+
return (value) => allowed.includes(value) ? ok : err(`must be one of ${allowed.join("|")}, got "${value}"`);
|
|
174
|
+
}
|
|
175
|
+
var ruleDimension = (value, node) => {
|
|
176
|
+
if (value === "100%") return ok;
|
|
177
|
+
const px2 = pxNumber(value);
|
|
178
|
+
if (px2 === null) return err(`must be px or "100%", got "${value}"`);
|
|
179
|
+
if (node.type === "image" && px2 > PSP1_MAX_IMAGE_PX) {
|
|
180
|
+
return err(`image dimension exceeds ${PSP1_MAX_IMAGE_PX}px cap (${px2}px)`);
|
|
181
|
+
}
|
|
182
|
+
return ok;
|
|
183
|
+
};
|
|
184
|
+
var ruleRadius = (value) => {
|
|
185
|
+
if (value === "full" || value === "$radius") return ok;
|
|
186
|
+
const px2 = pxNumber(value);
|
|
187
|
+
if (px2 === null) {
|
|
188
|
+
return err(`must be px, "full", or "$radius", got "${value}"`);
|
|
189
|
+
}
|
|
190
|
+
return ok;
|
|
191
|
+
};
|
|
192
|
+
var ruleBorder = (value) => {
|
|
193
|
+
if (typeof value !== "string") return err("border must be a string");
|
|
194
|
+
const m = value.match(/^1px solid (\$\S+)$/);
|
|
195
|
+
if (!m || ruleColor(m[1]) !== null) {
|
|
196
|
+
return err(`must be "1px solid $token", got "${value}"`);
|
|
197
|
+
}
|
|
198
|
+
return ok;
|
|
199
|
+
};
|
|
200
|
+
var ruleLineHeight = (value) => {
|
|
201
|
+
if (typeof value === "boolean") return err("must be a number");
|
|
202
|
+
const n = typeof value === "number" ? value : parseFloat(value);
|
|
203
|
+
if (typeof value === "string" && !/^\d+(\.\d+)?$/.test(value)) {
|
|
204
|
+
return err(`must be a unitless multiplier, got "${value}"`);
|
|
205
|
+
}
|
|
206
|
+
if (Number.isNaN(n) || n < 1 || n > 2) {
|
|
207
|
+
return err(`must be a unitless multiplier in [1, 2], got "${value}"`);
|
|
208
|
+
}
|
|
209
|
+
return ok;
|
|
210
|
+
};
|
|
211
|
+
var ruleOpacity = (value) => {
|
|
212
|
+
if (typeof value === "boolean") return err("must be a number");
|
|
213
|
+
if (typeof value === "string" && !/^\d+(\.\d+)?$/.test(value)) {
|
|
214
|
+
return err(`must be a unitless number, got "${value}"`);
|
|
215
|
+
}
|
|
216
|
+
const n = typeof value === "number" ? value : parseFloat(value);
|
|
217
|
+
if (Number.isNaN(n) || n < 0 || n > 1) {
|
|
218
|
+
return err(`must be in [0, 1], got "${value}"`);
|
|
219
|
+
}
|
|
220
|
+
return ok;
|
|
221
|
+
};
|
|
222
|
+
var ruleMaxLines = (value) => {
|
|
223
|
+
if (typeof value === "boolean") return err("must be an integer");
|
|
224
|
+
if (typeof value === "string" && !/^\d+$/.test(value)) {
|
|
225
|
+
return err(`must be an integer, got "${value}"`);
|
|
226
|
+
}
|
|
227
|
+
const n = typeof value === "number" ? value : parseInt(value, 10);
|
|
228
|
+
if (!Number.isInteger(n) || n < 1 || n > 10) {
|
|
229
|
+
return err(`must be an integer in [1, 10], got "${value}"`);
|
|
230
|
+
}
|
|
231
|
+
return ok;
|
|
232
|
+
};
|
|
233
|
+
var ruleLetterSpacing = (value) => {
|
|
234
|
+
if (typeof value === "string" && EM_RE.test(value)) return ok;
|
|
235
|
+
return err(`must be an em value, got "${value}"`);
|
|
236
|
+
};
|
|
237
|
+
var ruleBool = (value) => value === true || value === false ? ok : err(`must be a boolean, got "${value}"`);
|
|
238
|
+
var PSP1_STYLE_RULES = {
|
|
239
|
+
// Layout
|
|
240
|
+
direction: ruleEnum("row", "column"),
|
|
241
|
+
gap: rulePx(PSP1_MAX_SPACING_PX),
|
|
242
|
+
align: ruleEnum("start", "center", "end", "baseline"),
|
|
243
|
+
justify: ruleEnum("start", "center", "end", "space-between"),
|
|
244
|
+
grow: ruleEnum(0, 1),
|
|
245
|
+
shrink: ruleEnum(0, 1),
|
|
246
|
+
spacerBefore: ruleBool,
|
|
247
|
+
// Box
|
|
248
|
+
padding: rulePxList(PSP1_MAX_SPACING_PX),
|
|
249
|
+
paddingTop: rulePx(PSP1_MAX_SPACING_PX),
|
|
250
|
+
paddingRight: rulePx(PSP1_MAX_SPACING_PX),
|
|
251
|
+
paddingBottom: rulePx(PSP1_MAX_SPACING_PX),
|
|
252
|
+
paddingLeft: rulePx(PSP1_MAX_SPACING_PX),
|
|
253
|
+
margin: rulePxList(PSP1_MAX_SPACING_PX),
|
|
254
|
+
marginTop: rulePx(PSP1_MAX_SPACING_PX),
|
|
255
|
+
marginRight: rulePx(PSP1_MAX_SPACING_PX),
|
|
256
|
+
marginBottom: rulePx(PSP1_MAX_SPACING_PX),
|
|
257
|
+
marginLeft: rulePx(PSP1_MAX_SPACING_PX),
|
|
258
|
+
width: ruleDimension,
|
|
259
|
+
height: ruleDimension,
|
|
260
|
+
maxWidth: rulePx(Infinity),
|
|
261
|
+
minWidth: (value) => value === 0 || value === "0" || pxNumber(value) !== null ? ok : err(`must be 0 or px, got "${value}"`),
|
|
262
|
+
// Surface
|
|
263
|
+
background: ruleColor,
|
|
264
|
+
border: ruleBorder,
|
|
265
|
+
borderRadius: ruleRadius,
|
|
266
|
+
elevation: ruleEnum("none", "sm", "md"),
|
|
267
|
+
opacity: ruleOpacity,
|
|
268
|
+
// Text
|
|
269
|
+
fontSize: rulePx(PSP1_MAX_FONT_SIZE_PX),
|
|
270
|
+
fontWeight: ruleEnum(400, 500, 600, 700, 800),
|
|
271
|
+
lineHeight: ruleLineHeight,
|
|
272
|
+
letterSpacing: ruleLetterSpacing,
|
|
273
|
+
color: ruleColor,
|
|
274
|
+
textTransform: ruleEnum("none", "uppercase"),
|
|
275
|
+
textDecoration: ruleEnum("none", "underline"),
|
|
276
|
+
textAlign: ruleEnum("left", "center", "right"),
|
|
277
|
+
maxLines: ruleMaxLines,
|
|
278
|
+
nowrap: ruleBool,
|
|
279
|
+
// Image
|
|
280
|
+
fit: ruleEnum("contain", "cover")
|
|
281
|
+
};
|
|
282
|
+
var ALLOWED_URL_PROTOCOLS = SPEC_LINK_PROTOCOLS.map((p) => p.slice(0, -1));
|
|
283
|
+
|
|
95
284
|
// ../ui/src/theme.ts
|
|
96
285
|
var GRAVITY_DARK_VARS = {
|
|
97
286
|
"--gravity-bg": "#1F1F23",
|
|
@@ -341,9 +530,9 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
341
530
|
const data = await res.json();
|
|
342
531
|
const ads = Array.isArray(data) ? data : [data];
|
|
343
532
|
return { ads, status: res.status, elapsed, requestBody: body };
|
|
344
|
-
} catch (
|
|
533
|
+
} catch (err2) {
|
|
345
534
|
const elapsed = (performance.now() - start).toFixed(0);
|
|
346
|
-
const error =
|
|
535
|
+
const error = err2 instanceof Error ? err2.name === "TimeoutError" ? `Timeout (${timeoutMs}ms)` : err2.message : String(err2);
|
|
347
536
|
return { ads: [], status: 0, elapsed, error, requestBody: body };
|
|
348
537
|
}
|
|
349
538
|
}
|
|
@@ -405,7 +594,10 @@ function findCmpApi(name) {
|
|
|
405
594
|
}
|
|
406
595
|
var cachedTcf;
|
|
407
596
|
var cachedUsp;
|
|
597
|
+
var cachedGpp;
|
|
408
598
|
var tcfListening = false;
|
|
599
|
+
var tcfBroken = false;
|
|
600
|
+
var gppListening = false;
|
|
409
601
|
var cmpWaitExhausted = false;
|
|
410
602
|
function ensureListening() {
|
|
411
603
|
if (typeof window === "undefined") return;
|
|
@@ -425,6 +617,21 @@ function ensureListening() {
|
|
|
425
617
|
cachedTcf = { gdprApplies: false };
|
|
426
618
|
}
|
|
427
619
|
});
|
|
620
|
+
} catch {
|
|
621
|
+
tcfBroken = true;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const gpp = gppListening ? void 0 : findCmpApi("__gpp");
|
|
625
|
+
if (gpp) {
|
|
626
|
+
gppListening = true;
|
|
627
|
+
try {
|
|
628
|
+
gpp("addEventListener", (data, success) => {
|
|
629
|
+
if (!success || typeof data !== "object" || data === null) return;
|
|
630
|
+
cacheGppPing(data.pingData);
|
|
631
|
+
});
|
|
632
|
+
gpp("ping", (data, success) => {
|
|
633
|
+
if (success) cacheGppPing(data);
|
|
634
|
+
});
|
|
428
635
|
} catch {
|
|
429
636
|
}
|
|
430
637
|
}
|
|
@@ -440,13 +647,38 @@ function ensureListening() {
|
|
|
440
647
|
}
|
|
441
648
|
}
|
|
442
649
|
}
|
|
650
|
+
function cacheGppPing(ping) {
|
|
651
|
+
if (typeof ping !== "object" || ping === null) return;
|
|
652
|
+
const p = ping;
|
|
653
|
+
if (p.signalStatus !== "ready") return;
|
|
654
|
+
if (typeof p.gppString !== "string" || !p.gppString) return;
|
|
655
|
+
const raw = Array.isArray(p.applicableSections) ? p.applicableSections : [];
|
|
656
|
+
const readable = raw.every((id) => Number.isInteger(id));
|
|
657
|
+
const sections = readable ? raw.filter((id) => id !== -1) : [];
|
|
658
|
+
cachedGpp = sections.length ? { gpp: p.gppString, gppSid: sections } : { gpp: p.gppString };
|
|
659
|
+
}
|
|
660
|
+
function tcfPending() {
|
|
661
|
+
return !cachedTcf && !tcfBroken && Boolean(findCmpApi("__tcfapi"));
|
|
662
|
+
}
|
|
663
|
+
function cmpSettled() {
|
|
664
|
+
return !tcfPending() && (cachedGpp !== void 0 || !findCmpApi("__gpp"));
|
|
665
|
+
}
|
|
666
|
+
function detectGpc() {
|
|
667
|
+
return typeof navigator !== "undefined" && navigator.globalPrivacyControl === true;
|
|
668
|
+
}
|
|
443
669
|
function detectCmpConsent() {
|
|
444
670
|
ensureListening();
|
|
445
|
-
|
|
671
|
+
const gpc = detectGpc();
|
|
672
|
+
if (!cachedTcf && !cachedUsp && !cachedGpp && !gpc) return void 0;
|
|
446
673
|
const consent = {};
|
|
447
674
|
if (cachedTcf?.gdprApplies !== void 0) consent.gdprApplies = cachedTcf.gdprApplies;
|
|
448
675
|
if (cachedTcf?.tcfString) consent.tcfString = cachedTcf.tcfString;
|
|
449
676
|
if (cachedUsp) consent.usPrivacy = cachedUsp;
|
|
677
|
+
if (cachedGpp && !tcfPending()) {
|
|
678
|
+
consent.gpp = cachedGpp.gpp;
|
|
679
|
+
if (cachedGpp.gppSid) consent.gppSid = [...cachedGpp.gppSid];
|
|
680
|
+
}
|
|
681
|
+
if (gpc) consent.gpc = true;
|
|
450
682
|
if (Object.keys(consent).length === 0) return void 0;
|
|
451
683
|
return consent;
|
|
452
684
|
}
|
|
@@ -456,20 +688,22 @@ if (typeof window !== "undefined") ensureListening();
|
|
|
456
688
|
function readCmpConsent(timeoutMs = 500) {
|
|
457
689
|
ensureListening();
|
|
458
690
|
const immediate = detectCmpConsent();
|
|
459
|
-
if (immediate || cmpWaitExhausted || typeof window === "undefined") {
|
|
691
|
+
if (immediate && cmpSettled() || cmpWaitExhausted || typeof window === "undefined") {
|
|
460
692
|
return Promise.resolve(immediate);
|
|
461
693
|
}
|
|
462
694
|
return new Promise((resolve) => {
|
|
463
695
|
const started = Date.now();
|
|
464
696
|
const poll = () => {
|
|
465
697
|
const consent = detectCmpConsent();
|
|
466
|
-
if (consent) return resolve(consent);
|
|
698
|
+
if (consent && cmpSettled()) return resolve(consent);
|
|
467
699
|
const elapsed = Date.now() - started;
|
|
468
|
-
const cmpPresent = Boolean(
|
|
700
|
+
const cmpPresent = Boolean(
|
|
701
|
+
findCmpApi("__tcfapi") || findCmpApi("__uspapi") || findCmpApi("__gpp")
|
|
702
|
+
);
|
|
469
703
|
if (cmpPresent) {
|
|
470
704
|
if (elapsed >= timeoutMs) {
|
|
471
705
|
cmpWaitExhausted = true;
|
|
472
|
-
return resolve(
|
|
706
|
+
return resolve(consent);
|
|
473
707
|
}
|
|
474
708
|
} else if (elapsed >= timeoutMs || Date.now() - graceStartedAt >= NO_CMP_GRACE_MS) {
|
|
475
709
|
return resolve(void 0);
|
package/dist/opentui.js
CHANGED
|
@@ -29,7 +29,7 @@ var import_child_process = require("child_process");
|
|
|
29
29
|
// viewability.ts
|
|
30
30
|
var MAX_TRACKED_IMPRESSIONS = 1e3;
|
|
31
31
|
var SDK = "opentui";
|
|
32
|
-
var SDK_VERSION = "1.
|
|
32
|
+
var SDK_VERSION = "1.5.0";
|
|
33
33
|
var beaconsSent = /* @__PURE__ */ new Set();
|
|
34
34
|
function sendViewabilityBeacon(impUrl, ev) {
|
|
35
35
|
const key = `${ev} ${impUrl}`;
|
package/dist/opentui.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { execFile } from "child_process";
|
|
|
8
8
|
// viewability.ts
|
|
9
9
|
var MAX_TRACKED_IMPRESSIONS = 1e3;
|
|
10
10
|
var SDK = "opentui";
|
|
11
|
-
var SDK_VERSION = "1.
|
|
11
|
+
var SDK_VERSION = "1.5.0";
|
|
12
12
|
var beaconsSent = /* @__PURE__ */ new Set();
|
|
13
13
|
function sendViewabilityBeacon(impUrl, ev) {
|
|
14
14
|
const key = `${ev} ${impUrl}`;
|
|
@@ -668,14 +668,21 @@ interface GravityContextOverrides {
|
|
|
668
668
|
device?: Record<string, unknown>;
|
|
669
669
|
/**
|
|
670
670
|
* Explicit consent signal. When omitted in a browser, the SDK reads the
|
|
671
|
-
* page's IAB CMP APIs (`__tcfapi` / `__uspapi`) and
|
|
672
|
-
*
|
|
673
|
-
*
|
|
671
|
+
* page's IAB CMP APIs (`__tcfapi` / `__uspapi` / `__gpp`) and
|
|
672
|
+
* `navigator.globalPrivacyControl`, and attaches the settled decision
|
|
673
|
+
* automatically. Pass this to override (it replaces the detected object
|
|
674
|
+
* as a whole), or in server-side runtimes where no CMP is readable.
|
|
674
675
|
*/
|
|
675
676
|
consent?: {
|
|
676
677
|
gdprApplies?: boolean;
|
|
677
678
|
tcfString?: string;
|
|
678
679
|
usPrivacy?: string;
|
|
680
|
+
/** IAB GPP string. */
|
|
681
|
+
gpp?: string;
|
|
682
|
+
/** GPP section ids that apply to this request. */
|
|
683
|
+
gppSid?: number[];
|
|
684
|
+
/** Global Privacy Control. Send only `true`. */
|
|
685
|
+
gpc?: boolean;
|
|
679
686
|
};
|
|
680
687
|
}
|
|
681
688
|
/** The context object returned by `gravityContext()` and sent in the request body. */
|
|
@@ -687,13 +694,20 @@ interface GravityContext {
|
|
|
687
694
|
device: Record<string, unknown>;
|
|
688
695
|
/**
|
|
689
696
|
* End-user privacy/consent signal. Auto-detected from the page's CMP
|
|
690
|
-
* (`window.__tcfapi` / `window.__uspapi`
|
|
697
|
+
* (`window.__tcfapi` / `window.__uspapi` / `window.__gpp`) and from
|
|
698
|
+
* `navigator.globalPrivacyControl` in browsers; callers can
|
|
691
699
|
* override via `GravityContextOverrides.consent`.
|
|
692
700
|
*/
|
|
693
701
|
consent?: {
|
|
694
702
|
gdprApplies?: boolean;
|
|
695
703
|
tcfString?: string;
|
|
696
704
|
usPrivacy?: string;
|
|
705
|
+
/** IAB GPP string. */
|
|
706
|
+
gpp?: string;
|
|
707
|
+
/** GPP section ids that apply to this request. */
|
|
708
|
+
gppSid?: number[];
|
|
709
|
+
/** Global Privacy Control. Send only `true`. */
|
|
710
|
+
gpc?: boolean;
|
|
697
711
|
};
|
|
698
712
|
}
|
|
699
713
|
/** Options for `gravityAds()`. */
|
|
@@ -668,14 +668,21 @@ interface GravityContextOverrides {
|
|
|
668
668
|
device?: Record<string, unknown>;
|
|
669
669
|
/**
|
|
670
670
|
* Explicit consent signal. When omitted in a browser, the SDK reads the
|
|
671
|
-
* page's IAB CMP APIs (`__tcfapi` / `__uspapi`) and
|
|
672
|
-
*
|
|
673
|
-
*
|
|
671
|
+
* page's IAB CMP APIs (`__tcfapi` / `__uspapi` / `__gpp`) and
|
|
672
|
+
* `navigator.globalPrivacyControl`, and attaches the settled decision
|
|
673
|
+
* automatically. Pass this to override (it replaces the detected object
|
|
674
|
+
* as a whole), or in server-side runtimes where no CMP is readable.
|
|
674
675
|
*/
|
|
675
676
|
consent?: {
|
|
676
677
|
gdprApplies?: boolean;
|
|
677
678
|
tcfString?: string;
|
|
678
679
|
usPrivacy?: string;
|
|
680
|
+
/** IAB GPP string. */
|
|
681
|
+
gpp?: string;
|
|
682
|
+
/** GPP section ids that apply to this request. */
|
|
683
|
+
gppSid?: number[];
|
|
684
|
+
/** Global Privacy Control. Send only `true`. */
|
|
685
|
+
gpc?: boolean;
|
|
679
686
|
};
|
|
680
687
|
}
|
|
681
688
|
/** The context object returned by `gravityContext()` and sent in the request body. */
|
|
@@ -687,13 +694,20 @@ interface GravityContext {
|
|
|
687
694
|
device: Record<string, unknown>;
|
|
688
695
|
/**
|
|
689
696
|
* End-user privacy/consent signal. Auto-detected from the page's CMP
|
|
690
|
-
* (`window.__tcfapi` / `window.__uspapi`
|
|
697
|
+
* (`window.__tcfapi` / `window.__uspapi` / `window.__gpp`) and from
|
|
698
|
+
* `navigator.globalPrivacyControl` in browsers; callers can
|
|
691
699
|
* override via `GravityContextOverrides.consent`.
|
|
692
700
|
*/
|
|
693
701
|
consent?: {
|
|
694
702
|
gdprApplies?: boolean;
|
|
695
703
|
tcfString?: string;
|
|
696
704
|
usPrivacy?: string;
|
|
705
|
+
/** IAB GPP string. */
|
|
706
|
+
gpp?: string;
|
|
707
|
+
/** GPP section ids that apply to this request. */
|
|
708
|
+
gppSid?: number[];
|
|
709
|
+
/** Global Privacy Control. Send only `true`. */
|
|
710
|
+
gpc?: boolean;
|
|
697
711
|
};
|
|
698
712
|
}
|
|
699
713
|
/** Options for `gravityAds()`. */
|