@streamlayer/feature-advertisement 1.0.0 → 1.1.1-rc.10.p6eb7304a
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/classic/package.json +5 -0
- package/lib/advertisement.d.ts +6 -6
- package/lib/advertisement.js +32 -17
- package/lib/cjs/advertisement.d.ts +64 -0
- package/lib/cjs/advertisement.js +322 -0
- package/lib/cjs/index.d.ts +21 -0
- package/lib/cjs/index.js +41 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/units/ad-macros.d.ts +7 -0
- package/lib/cjs/units/ad-macros.js +91 -0
- package/lib/cjs/units/external-ad.d.ts +127 -0
- package/lib/cjs/units/external-ad.js +421 -0
- package/lib/cjs/units/external-pause-ad.d.ts +50 -0
- package/lib/cjs/units/external-pause-ad.js +259 -0
- package/lib/cjs/units/gam.d.ts +26 -0
- package/lib/cjs/units/gam.js +152 -0
- package/lib/cjs/units/parse-vast-extensions.d.ts +26 -0
- package/lib/cjs/units/parse-vast-extensions.js +56 -0
- package/lib/cjs/units/pause-ad-card.d.ts +49 -0
- package/lib/cjs/units/pause-ad-card.js +136 -0
- package/lib/cjs/units/pause-ad.d.ts +16 -0
- package/lib/cjs/units/pause-ad.js +52 -0
- package/lib/cjs/units/sponsor-logo.d.ts +78 -0
- package/lib/cjs/units/sponsor-logo.js +194 -0
- package/lib/cjs/units/ssai-ad-break.d.ts +21 -0
- package/lib/cjs/units/ssai-ad-break.js +11 -0
- package/lib/cjs/units/ssai-creative.d.ts +89 -0
- package/lib/cjs/units/ssai-creative.js +136 -0
- package/lib/cjs/units/ssai-detector.d.ts +180 -0
- package/lib/cjs/units/ssai-detector.js +1172 -0
- package/lib/cjs/units/ssai-log.d.ts +16 -0
- package/lib/cjs/units/ssai-log.js +23 -0
- package/lib/cjs/units/ssai-preload.d.ts +20 -0
- package/lib/cjs/units/ssai-preload.js +62 -0
- package/lib/cjs/units/ssai-providers.d.ts +117 -0
- package/lib/cjs/units/ssai-providers.js +300 -0
- package/lib/cjs/units/vast-tracker.d.ts +45 -0
- package/lib/cjs/units/vast-tracker.js +64 -0
- package/lib/classic/_virtual/_rollupPluginBabelHelpers.js +71 -0
- package/lib/classic/advertisement.js +348 -0
- package/lib/classic/cjs/_virtual/_rollupPluginBabelHelpers.js +77 -0
- package/lib/classic/cjs/advertisement.js +350 -0
- package/lib/classic/cjs/index.js +49 -0
- package/lib/classic/cjs/package.json +1 -0
- package/lib/classic/cjs/units/ad-macros.js +115 -0
- package/lib/classic/cjs/units/external-ad.js +500 -0
- package/lib/classic/cjs/units/external-pause-ad.js +278 -0
- package/lib/classic/cjs/units/gam.js +173 -0
- package/lib/classic/cjs/units/parse-vast-extensions.js +60 -0
- package/lib/classic/cjs/units/pause-ad-card.js +134 -0
- package/lib/classic/cjs/units/pause-ad.js +72 -0
- package/lib/classic/cjs/units/sponsor-logo.js +201 -0
- package/lib/classic/cjs/units/ssai-ad-break.js +11 -0
- package/lib/classic/cjs/units/ssai-creative.js +142 -0
- package/lib/classic/cjs/units/ssai-detector.js +1195 -0
- package/lib/classic/cjs/units/ssai-log.js +23 -0
- package/lib/classic/cjs/units/ssai-preload.js +72 -0
- package/lib/classic/cjs/units/ssai-providers.js +361 -0
- package/lib/classic/cjs/units/vast-tracker.js +81 -0
- package/lib/classic/index.js +29 -0
- package/lib/classic/units/ad-macros.js +113 -0
- package/lib/classic/units/external-ad.js +491 -0
- package/lib/classic/units/external-pause-ad.js +275 -0
- package/lib/classic/units/gam.js +171 -0
- package/lib/classic/units/parse-vast-extensions.js +58 -0
- package/lib/classic/units/pause-ad-card.js +131 -0
- package/lib/classic/units/pause-ad.js +70 -0
- package/lib/classic/units/sponsor-logo.js +197 -0
- package/lib/classic/units/ssai-ad-break.js +9 -0
- package/lib/classic/units/ssai-creative.js +140 -0
- package/lib/classic/units/ssai-detector.js +1192 -0
- package/lib/classic/units/ssai-log.js +21 -0
- package/lib/classic/units/ssai-preload.js +68 -0
- package/lib/classic/units/ssai-providers.js +351 -0
- package/lib/classic/units/vast-tracker.js +77 -0
- package/lib/index.d.ts +15 -12
- package/lib/index.js +14 -7
- package/lib/units/ad-macros.d.ts +7 -0
- package/lib/units/ad-macros.js +87 -0
- package/lib/units/external-ad.d.ts +71 -2
- package/lib/units/external-ad.js +94 -66
- package/lib/units/external-pause-ad.js +7 -1
- package/lib/units/gam.d.ts +11 -1
- package/lib/units/gam.js +65 -17
- package/lib/units/parse-vast-extensions.d.ts +10 -1
- package/lib/units/parse-vast-extensions.js +5 -1
- package/lib/units/pause-ad-card.d.ts +49 -0
- package/lib/units/pause-ad-card.js +130 -0
- package/lib/units/pause-ad.d.ts +1 -18
- package/lib/units/pause-ad.js +2 -49
- package/lib/units/sponsor-logo.d.ts +78 -0
- package/lib/units/sponsor-logo.js +188 -0
- package/lib/units/ssai-ad-break.d.ts +1 -1
- package/lib/units/ssai-creative.d.ts +1 -1
- package/lib/units/ssai-creative.js +1 -1
- package/lib/units/ssai-detector.d.ts +1 -1
- package/lib/units/ssai-detector.js +27 -11
- package/lib/units/ssai-log.d.ts +16 -0
- package/lib/units/ssai-log.js +18 -0
- package/lib/units/ssai-preload.d.ts +1 -1
- package/lib/units/ssai-providers.d.ts +1 -1
- package/lib/units/ssai-providers.js +48 -11
- package/lib/units/vast-tracker.d.ts +1 -1
- package/lib/vast-client.d.ts +9 -0
- package/package.json +43 -10
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Logger } from '@streamlayer/sdk-web-logger';
|
|
2
|
+
/**
|
|
3
|
+
* `ssaiq` — the SSAI ad NARRATIVE log: one line per thing that happens to a
|
|
4
|
+
* server-stitched ad, in the order it happens. The manifest tag the playout
|
|
5
|
+
* published, the metadata round trip it triggers, the break the SDK opens from
|
|
6
|
+
* it, and every beacon fired against it.
|
|
7
|
+
*
|
|
8
|
+
* Named for the Quortex/Synamedia DAI integration it was built for, but it is
|
|
9
|
+
* the path itself that is logged, so a StreamLayer-dialect stream tells the same
|
|
10
|
+
* story. Detector internals — clock sources, poll ticks, fold bookkeeping — stay
|
|
11
|
+
* on `ssai:*`, where `SL_DEBUG` can reach them without filling a demo window.
|
|
12
|
+
*
|
|
13
|
+
* A host publishes it to the page with `SL_LOG_EVENTS=ssaiq` (see
|
|
14
|
+
* `sdk-web-logger`); the demo's log window renders exactly that.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ssaiq: Logger;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createLogger } from '@streamlayer/sdk-web-logger';
|
|
2
|
+
/**
|
|
3
|
+
* `ssaiq` — the SSAI ad NARRATIVE log: one line per thing that happens to a
|
|
4
|
+
* server-stitched ad, in the order it happens. The manifest tag the playout
|
|
5
|
+
* published, the metadata round trip it triggers, the break the SDK opens from
|
|
6
|
+
* it, and every beacon fired against it.
|
|
7
|
+
*
|
|
8
|
+
* Named for the Quortex/Synamedia DAI integration it was built for, but it is
|
|
9
|
+
* the path itself that is logged, so a StreamLayer-dialect stream tells the same
|
|
10
|
+
* story. Detector internals — clock sources, poll ticks, fold bookkeeping — stay
|
|
11
|
+
* on `ssai:*`, where `SL_DEBUG` can reach them without filling a demo window.
|
|
12
|
+
*
|
|
13
|
+
* A host publishes it to the page with `SL_LOG_EVENTS=ssaiq` (see
|
|
14
|
+
* `sdk-web-logger`); the demo's log window renders exactly that.
|
|
15
|
+
*/
|
|
16
|
+
// Explicit type: the inferred pino type is not nameable across package
|
|
17
|
+
// boundaries (TS2742) when this file is compiled on its own.
|
|
18
|
+
export const ssaiq = createLogger('ssaiq');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SsaiCreative } from './ssai-creative';
|
|
1
|
+
import type { SsaiCreative } from './ssai-creative.js';
|
|
2
2
|
/**
|
|
3
3
|
* How long the overlay is willing to wait for artwork. A slow or dead image host
|
|
4
4
|
* must never hold the bar back — the ad is already playing, and a bar that shows
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SsaiCreative } from './ssai-creative';
|
|
1
|
+
import type { SsaiCreative } from './ssai-creative.js';
|
|
2
2
|
export declare const DEFAULT_CREATIVE_API_BASE = "https://hls.next.streamlayer.io/api/creatives/";
|
|
3
3
|
/**
|
|
4
4
|
* A creative provider encapsulates everything that differs between ad sources:
|
|
@@ -1,7 +1,53 @@
|
|
|
1
1
|
import { createLogger } from '@streamlayer/sdk-web-logger';
|
|
2
2
|
import { VASTClient } from '@dailymotion/vast-client';
|
|
3
|
+
import { ssaiq } from './ssai-log.js';
|
|
3
4
|
const log = createLogger('ssai:provider');
|
|
4
5
|
export const DEFAULT_CREATIVE_API_BASE = 'https://hls.next.streamlayer.io/api/creatives/';
|
|
6
|
+
/**
|
|
7
|
+
* One creative-metadata round trip, on the narrative log: the request the SDK
|
|
8
|
+
* made and the body the ad service answered with, verbatim. This is the half of
|
|
9
|
+
* the story the manifest cannot tell — the ad's identity comes from the playout,
|
|
10
|
+
* its content comes from here.
|
|
11
|
+
*/
|
|
12
|
+
const fetchCreativeJson = async (providerId, url, signal) => {
|
|
13
|
+
// `adApiBase` is customer infrastructure and may carry a key in its query;
|
|
14
|
+
// the request uses the URL as given, the log gets it with such values masked.
|
|
15
|
+
const shown = maskUrlSecrets(url);
|
|
16
|
+
ssaiq.info({ provider: providerId, url: shown }, `[GET] → ${shown}`);
|
|
17
|
+
let response;
|
|
18
|
+
try {
|
|
19
|
+
response = await fetch(url, { signal });
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
// An abort is the SDK cancelling its own request (break ended, creative
|
|
23
|
+
// changed) — a note, not a failure.
|
|
24
|
+
if (error?.name === 'AbortError') {
|
|
25
|
+
ssaiq.debug({ provider: providerId, url: shown }, `[GET] ✗ aborted ${shown}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
ssaiq.warn({ provider: providerId, url: shown, error: String(error) }, `[GET] ✗ ${shown}`);
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
ssaiq.warn({ provider: providerId, url: shown, status: response.status }, `[GET] ✗ ${response.status} ${shown}`);
|
|
34
|
+
throw new Error(`${providerId} creative request failed: ${response.status}`);
|
|
35
|
+
}
|
|
36
|
+
let raw;
|
|
37
|
+
try {
|
|
38
|
+
raw = (await response.json());
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// A 200 with a body that is not JSON would otherwise leave the log looking
|
|
42
|
+
// like a request still in flight.
|
|
43
|
+
ssaiq.warn({ provider: providerId, url: shown, error: String(error) }, `[GET] ✗ ${response.status} ${shown} — not JSON`);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
ssaiq.info({ provider: providerId, status: response.status, body: raw }, `[GET] ← ${response.status} ad metadata — ${raw?.advertiser || raw?.title || raw?.creativeId || 'ad'}`);
|
|
47
|
+
return raw;
|
|
48
|
+
};
|
|
49
|
+
/** `?apiKey=…` → `?apiKey=«redacted»`, for URLs that go on a screen. Regex, not `URL`: this ships to 2016 TV engines. */
|
|
50
|
+
const maskUrlSecrets = (url) => url.replace(/([?&][^=&]*(?:token|secret|password|key|authorization)[^=&]*=)[^&]*/gi, '$1«redacted»');
|
|
5
51
|
/**
|
|
6
52
|
* Shared low-level beacon helper. Prefers `navigator.sendBeacon` and falls back
|
|
7
53
|
* to a no-cors `fetch`. Used by the default impression path and available to
|
|
@@ -100,12 +146,7 @@ export const createStreamLayerProvider = (config = {}) => {
|
|
|
100
146
|
return {
|
|
101
147
|
id: 'streamlayer',
|
|
102
148
|
resolve: async (creativeId, signal) => {
|
|
103
|
-
const
|
|
104
|
-
const response = await fetch(url, { signal });
|
|
105
|
-
if (!response.ok) {
|
|
106
|
-
throw new Error(`creative request failed: ${response.status}`);
|
|
107
|
-
}
|
|
108
|
-
const raw = (await response.json());
|
|
149
|
+
const raw = await fetchCreativeJson('streamlayer', buildCreativeUrl(creativeApiBase, creativeId), signal);
|
|
109
150
|
return mapApiResponse({ ...raw, creativeId: raw.creativeId || creativeId });
|
|
110
151
|
},
|
|
111
152
|
fireImpression: fireDefaultImpression,
|
|
@@ -149,11 +190,7 @@ export const createQuortexProvider = (config = {}) => {
|
|
|
149
190
|
if (!adApiBase) {
|
|
150
191
|
throw new Error('quortex provider is missing `adApiBase`');
|
|
151
192
|
}
|
|
152
|
-
const
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
throw new Error(`quortex creative request failed: ${response.status}`);
|
|
155
|
-
}
|
|
156
|
-
const raw = (await response.json());
|
|
193
|
+
const raw = await fetchCreativeJson('quortex', buildQuortexUrl(adApiBase, tenantName, adId), signal);
|
|
157
194
|
return mapApiResponse({ ...raw, creativeId: raw.creativeId || adId });
|
|
158
195
|
},
|
|
159
196
|
fireImpression: fireDefaultImpression,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* player) and they are billing-visible, so collapsing them here would silently change counts.
|
|
14
14
|
*/
|
|
15
15
|
import { VASTTracker, VastAd, VastCompanionAd, VastCreativeCompanion, VastCreativeLinear, VastCreativeNonLinear, VastNonLinearAd } from '@dailymotion/vast-client';
|
|
16
|
-
import type { AdCompanion, AdData } from './external-ad';
|
|
16
|
+
import type { AdCompanion, AdData } from './external-ad.js';
|
|
17
17
|
/** The creative (and, for non-linear creatives, the variation) a tracker reports through. */
|
|
18
18
|
export type VastTrackerTarget = {
|
|
19
19
|
ad: VastAd;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module '@dailymotion/vast-client' {
|
|
2
|
+
export interface VastAd {}
|
|
3
|
+
export interface VastCompanionAd {}
|
|
4
|
+
export interface VastCreativeCompanion {}
|
|
5
|
+
export interface VastCreativeLinear {}
|
|
6
|
+
export interface VastCreativeNonLinear {}
|
|
7
|
+
export interface VastNonLinearAd {}
|
|
8
|
+
export interface VastResponse {}
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/feature-advertisement",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1-rc.10.p6eb7304a",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dailymotion/vast-client": "^6.4.
|
|
5
|
+
"@dailymotion/vast-client": "^6.4.5",
|
|
6
6
|
"@streamlayer/sl-eslib": "^5.268.1",
|
|
7
|
+
"core-js": "^3.50.0",
|
|
7
8
|
"uuid": "^11.1.0",
|
|
8
9
|
"nanostores": "^1.1.0",
|
|
9
|
-
"@streamlayer/sdk-web-core": "
|
|
10
|
-
"@streamlayer/sdk-web-
|
|
11
|
-
"@streamlayer/sdk-web-
|
|
12
|
-
"@streamlayer/sdk-web-types": "
|
|
13
|
-
"@streamlayer/sdk-web-
|
|
14
|
-
"@streamlayer/sdk-web-
|
|
10
|
+
"@streamlayer/sdk-web-core": "1.23.2-rc.10.p6eb7304a",
|
|
11
|
+
"@streamlayer/sdk-web-interfaces": "1.11.2-rc.10.p6eb7304a",
|
|
12
|
+
"@streamlayer/sdk-web-api": "1.18.2-rc.10.p6eb7304a",
|
|
13
|
+
"@streamlayer/sdk-web-types": "2.0.2-rc.10.p6eb7304a",
|
|
14
|
+
"@streamlayer/sdk-web-storage": "1.2.2-rc.10.p6eb7304a",
|
|
15
|
+
"@streamlayer/sdk-web-logger": "1.2.2-rc.10.p6eb7304a"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@types/vast-client": "^3.0.4"
|
|
@@ -19,8 +20,40 @@
|
|
|
19
20
|
"type": "module",
|
|
20
21
|
"main": "./lib/index.js",
|
|
21
22
|
"typings": "./lib/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"default": "./lib/index.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./lib/cjs/index.d.ts",
|
|
31
|
+
"default": "./lib/cjs/index.js"
|
|
32
|
+
},
|
|
33
|
+
"module": "./lib/index.js",
|
|
34
|
+
"default": "./lib/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./*": "./*",
|
|
37
|
+
"./classic": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./lib/index.d.ts",
|
|
40
|
+
"default": "./lib/classic/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./lib/cjs/index.d.ts",
|
|
44
|
+
"default": "./lib/classic/cjs/index.js"
|
|
45
|
+
},
|
|
46
|
+
"module": "./lib/classic/index.js",
|
|
47
|
+
"default": "./lib/classic/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
22
51
|
"files": [
|
|
23
52
|
"lib/",
|
|
53
|
+
"classic/",
|
|
24
54
|
"package.json"
|
|
25
|
-
]
|
|
26
|
-
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"vmap": "^3.2.0"
|
|
58
|
+
}
|
|
59
|
+
}
|