@blockcast/mmt-container 2.2.0-main.5dbada939c04 → 2.2.0-main.5deae23da0f9
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/README.md +108 -2
- package/dist/ad-beacon.d.ts +39 -0
- package/dist/ad-beacon.d.ts.map +1 -0
- package/dist/ad-beacon.js +21 -0
- package/dist/ad-beacon.js.map +7 -0
- package/dist/ad-creative-timeline.d.ts +1 -0
- package/dist/ad-creative-timeline.d.ts.map +1 -1
- package/dist/ad-creative-timeline.js +20 -0
- package/dist/ad-creative-timeline.js.map +3 -3
- package/dist/block-policy.d.ts +103 -21
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +347 -110
- package/dist/block-policy.js.map +2 -2
- package/dist/browser-runtime.js +487 -158
- package/dist/browser-runtime.js.map +3 -3
- package/dist/event-timeline-mmtp.d.ts +17 -0
- package/dist/event-timeline-mmtp.d.ts.map +1 -0
- package/dist/event-timeline-mmtp.js +3117 -0
- package/dist/event-timeline-mmtp.js.map +7 -0
- package/dist/fec-manager.d.ts +16 -2
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +377 -123
- package/dist/fec-manager.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-bmff-timing.d.ts +11 -0
- package/dist/iso-bmff-timing.d.ts.map +1 -1
- package/dist/iso-bmff-timing.js +20 -0
- package/dist/iso-bmff-timing.js.map +2 -2
- package/dist/mfu-reassembler.d.ts +2 -0
- package/dist/mfu-reassembler.d.ts.map +1 -1
- package/dist/mfu-reassembler.js +4 -2
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +8 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +46 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +51 -5
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-decode-pipeline.js +46 -2
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +7 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +57 -10
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +14 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +487 -158
- package/dist/multicast-manager.js.map +2 -2
- package/dist/multicast-transport.js +44 -22
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +46 -2
- package/dist/no-modules.js.map +2 -2
- package/dist/repair-fetch.d.ts +7 -2
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +46 -2
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +9 -5
- package/src/ad-beacon.ts +51 -0
- package/src/ad-creative-timeline.ts +3 -0
- package/src/block-policy.ts +519 -163
- package/src/event-timeline-mmtp.ts +55 -0
- package/src/fec-manager.ts +43 -14
- package/src/index.ts +1 -0
- package/src/iso-bmff-timing.ts +21 -0
- package/src/mfu-reassembler.ts +4 -0
- package/src/mmtp-container-parser.ts +31 -0
- package/src/mmtp-router.ts +37 -13
- package/src/multicast-manager.ts +20 -0
- package/src/repair-fetch.ts +7 -2
package/README.md
CHANGED
|
@@ -357,8 +357,12 @@ Every FEC block still gets in-band FEC decode. On top of that:
|
|
|
357
357
|
from the MPU's RAP fragment once two RAPs proved G fragments per MPU, every
|
|
358
358
|
later RAP fragment held to that spacing) against catalog geometry (framerate,
|
|
359
359
|
`interleaveDepthMs`, keyframe interval). Geometry that cannot be derived
|
|
360
|
-
exactly, or any violated invariant, runs the track `all-protected
|
|
361
|
-
|
|
360
|
+
exactly, or any violated invariant, runs the track `all-protected`: that
|
|
361
|
+
rule is off, and only the MPU rule below can still call a block `delta`,
|
|
362
|
+
on a track whose catalog passes its test. This window rule calls a block
|
|
363
|
+
`delta` only on such a track too, and stops for the epoch when the MPU
|
|
364
|
+
rule does (below). Nothing else calls a block `delta`.
|
|
365
|
+
A block every symbol of which vanished is
|
|
362
366
|
materialised from the surrounding block evidence. A frame split across
|
|
363
367
|
ADJACENT blocks (a block closing at K symbols) is expected; only source
|
|
364
368
|
packets whose authored order and block order disagree (a round-robin
|
|
@@ -366,6 +370,108 @@ Every FEC block still gets in-band FEC decode. On top of that:
|
|
|
366
370
|
`configureTrackFec(packetId, config, catalogTrackName)` so ABR rungs that
|
|
367
371
|
share a packetId each classify with their own framerate and GOP; a rung on
|
|
368
372
|
such a packetId without its own geometry runs `stream-geometry-absent`.
|
|
373
|
+
- **The MPU rule.** A publisher starts an MPU at every keyframe, so an MPU
|
|
374
|
+
holds one RAP: its first sample. The rule needs no block geometry and
|
|
375
|
+
runs in both modes. It reads the DU header held last before a block (L)
|
|
376
|
+
and the one held first after it (U); a header that FEC rebuilt counts.
|
|
377
|
+
- **The catalog test.** No packet says that a publisher keeps one RAP to
|
|
378
|
+
an MPU, and a publisher of draft-ramadan-moq-mmt up to -02 could put
|
|
379
|
+
more in one. The rule classes a block only on a track whose catalog
|
|
380
|
+
carries a keyframe interval equal to its group duration. So pass
|
|
381
|
+
`groupDurationMs` (`catalogGroupDurationMs`) to `configureTrackFec` for
|
|
382
|
+
every FEC-protected video track, next to `keyframeIntervalTicks` or
|
|
383
|
+
`keyframeIntervalMs`. A player that takes this version and does not
|
|
384
|
+
pass it gets no `delta` on its track at all: not those the
|
|
385
|
+
`dep_counter` run gave before, and not those of the window rule. Whole
|
|
386
|
+
numbers compare exactly, ticks over the timescale against
|
|
387
|
+
milliseconds; a group duration that came from ticks is a double, and
|
|
388
|
+
equal when the two differ by no more than 2 × `Number.EPSILON` times
|
|
389
|
+
the group duration. Without an interval, without a group duration, or
|
|
390
|
+
with two that differ, no block of the track is `delta`, by this rule or
|
|
391
|
+
by the window rule (draft-ramadan-moq-fec-multicast-01 Block
|
|
392
|
+
Classification: such a track gets no non-keyframe-bearing block). Every
|
|
393
|
+
short block is then repaired at keyframe priority. The classifier mode
|
|
394
|
+
can still read `classifying` on such a track, and an `unknown` block
|
|
395
|
+
then also gets the keyframe repair budget (`keyframeBudgetEligible`).
|
|
396
|
+
A player that sets that budget can then show something else for such
|
|
397
|
+
a block: its FETCH can be admitted where a `delta` one is refused
|
|
398
|
+
(`rtt-exceeds-budget`), its frames are then repaired, and the frames
|
|
399
|
+
behind it wait for the FETCH, up to the budget.
|
|
400
|
+
The stall-or-conceal decision (`decideGap`) does not read the class or
|
|
401
|
+
this test and is unchanged. That is a difference from the draft, which
|
|
402
|
+
has video on such a track wait for the next RAP after a failed repair:
|
|
403
|
+
here a gap inside one MPU still conceals (`delta-lost`) where the
|
|
404
|
+
catalog interval puts no keyframe in it (`mpuBoundsRapsFor`), though a
|
|
405
|
+
keyframe off that interval may be what was lost.
|
|
406
|
+
`BlockClassifier.mpuRuleOff`, `FECManager.mpuRuleOffFor` and
|
|
407
|
+
`BlockPolicyStats.mpuRuleOff` say which (`keyframe-interval-absent`,
|
|
408
|
+
`group-duration-absent`, `keyframe-interval-not-group-duration`), or
|
|
409
|
+
name what the stream showed (below), or are null while the rule runs.
|
|
410
|
+
- **Same MPU:** the block is `delta`, unless L may be part of the MPU's
|
|
411
|
+
first sample (it carries `RAP_flag`, or it is a later data unit of a
|
|
412
|
+
sample). Then it is `delta` only if every packet from L to the next
|
|
413
|
+
sample's DU header arrived, in earlier blocks.
|
|
414
|
+
- **U in the next MPU:** the block may hold that MPU's start and stays
|
|
415
|
+
`unknown`, unless the start arrived whole: every packet from the last
|
|
416
|
+
packet of L's MPU through the next MPU's metadata and first sample.
|
|
417
|
+
- **More than one MPU apart, or no header held on one side yet:**
|
|
418
|
+
`unknown`. The next DU header of the track asks again.
|
|
419
|
+
- "Every packet arrived" is read from the FEC source symbol id (the
|
|
420
|
+
block's SS_Start plus the ESI), which `FECManager.trackBlock` hands to
|
|
421
|
+
`BlockClassifier.observe`. `packet_sequence_number` is not read for it:
|
|
422
|
+
a hop may write it anew on every packet it forwards (cast's bridge
|
|
423
|
+
does), so a packet lost before that hop leaves no gap in it. A packet
|
|
424
|
+
that FEC rebuilt does not count as arrived.
|
|
425
|
+
- `dep_counter` is parsed and passed on (`SourceSymbolEvidence.depCounter`),
|
|
426
|
+
and decides nothing. A reclassification by this rule carries the
|
|
427
|
+
evidence `mpu-rule`; `dependent-run` stays in the type and is never sent.
|
|
428
|
+
- The rule stops for the epoch, the window rule with it, and every
|
|
429
|
+
`delta` class is withdrawn, at the first evidence that the stream does
|
|
430
|
+
not keep one RAP to an MPU:
|
|
431
|
+
- `mpuBoundsRaps` going false (`mpu-bounds-raps-refuted`).
|
|
432
|
+
- A DU header held (arrived or rebuilt) that carries `RAP_flag` and is
|
|
433
|
+
not of its MPU's first sample (`rap-inside-mpu`): it is not the first
|
|
434
|
+
sample of its movie fragment (`sample_number` above 1), or it lies in
|
|
435
|
+
another movie fragment than the first DU header held of its MPU. It
|
|
436
|
+
sees what `mpuBoundsRaps` cannot: a RAP that starts a later movie
|
|
437
|
+
fragment of an MPU whose fragments hold several samples, and a RAP
|
|
438
|
+
known only from a header that FEC rebuilt. A DU header in a
|
|
439
|
+
repair-less span is not held.
|
|
440
|
+
- An MPU longer than the keyframe interval
|
|
441
|
+
(`mpu-longer-than-keyframe-interval`): two of its samples lie an
|
|
442
|
+
interval or more apart by decode time. A track of an earlier revision
|
|
443
|
+
whose interval equals its group duration can hold a second keyframe
|
|
444
|
+
only in such an MPU. The decode times are those of every sample that
|
|
445
|
+
held movie fragment metadata (FT=1) times, arrived or rebuilt, whether
|
|
446
|
+
or not the sample itself is held: the parser reports them
|
|
447
|
+
(`onMovieFragmentTiming`) before the packet's block is tracked, and
|
|
448
|
+
the router hands them to `FECManager.noteSampleDecodeTimes`. The
|
|
449
|
+
router feeds a rebuilt block's FT=1 before it reads that block's
|
|
450
|
+
rebuilt DU headers, so the check comes first there too. They
|
|
451
|
+
decide whether the rule applies, never a block's class. The times of
|
|
452
|
+
the two MPUs of the highest numbers are kept; a report for an MPU
|
|
453
|
+
behind both (a slow repair) is not, and only the span of that one
|
|
454
|
+
report is read.
|
|
455
|
+
Neither of the last two sets `mpuBoundsRaps` or the classifier mode.
|
|
456
|
+
- A block is still checked on its own where the catalog interval, counted
|
|
457
|
+
in frames from the MPU positions of L and U, puts a keyframe between
|
|
458
|
+
them. It reads a frame count where no decode time is known (the movie
|
|
459
|
+
fragment metadata was lost) and covers a header that FEC rebuilt.
|
|
460
|
+
- What is left: on a track that passes the catalog test and still puts a
|
|
461
|
+
second keyframe in an MPU, a block that lost that keyframe can read
|
|
462
|
+
`delta` until one of the three is seen. Movie fragment metadata that
|
|
463
|
+
arrives before the track's first FT=0 times nothing.
|
|
464
|
+
- Only the DU headers of the two newest MPUs are held. If MPU numbers go
|
|
465
|
+
back with no source discontinuity (a restart nothing signalled, or the
|
|
466
|
+
2^32 wrap), the rule gives no class until the next one. A DU header of
|
|
467
|
+
an MPU behind them is read for one thing: `RAP_flag` with a
|
|
468
|
+
`sample_number` above 1 still stops the rule (`rap-inside-mpu`). What it
|
|
469
|
+
would show only next to other headers of its MPU, or a late report next
|
|
470
|
+
to other reports of its MPU, is not seen.
|
|
471
|
+
- DU headers that lie against the block order stop this rule until the
|
|
472
|
+
next source discontinuity (`du-headers-out-of-order`), and every `delta`
|
|
473
|
+
class is withdrawn once. That state does not stop the window rule, which
|
|
474
|
+
reads the order from the packets that arrived (`block-not-contiguous`).
|
|
369
475
|
- **Repair priority.** `wireRepairFetch` dispatches P0 (`keyframe`/`unknown`)
|
|
370
476
|
and P1 (`audio`) immediately; P2 (`delta`) only while no P0/P1 is queued or
|
|
371
477
|
in flight, earliest deadline first, preempted by any new P0/P1. No timers.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-01 7, 12):
|
|
3
|
+
* which URL to request and when. No I/O and no timers here (the cmcd-producer.ts precedent):
|
|
4
|
+
* the player sends each plan at sendAtMs with
|
|
5
|
+
* fetch(url, { mode: 'no-cors', credentials: 'omit', keepalive: true, referrerPolicy: 'no-referrer' }).
|
|
6
|
+
* The player calls this only for events the timeline emitted, so only for verified records.
|
|
7
|
+
*/
|
|
8
|
+
import type { AdTrackEvent } from './ad-creative-timeline.js';
|
|
9
|
+
export interface AdBeaconPolicy {
|
|
10
|
+
/** Lower-case host[:port] beacons may go to (riedl 12.1), typically the distributor's beacon proxy. Empty: nothing is sent. */
|
|
11
|
+
readonly authorities: readonly string[];
|
|
12
|
+
/** Uniform jitter window W in ms (riedl 7.2). Size it from the audience: W >= 1000 * N * k / C ms, for N receivers,
|
|
13
|
+
* k requests each at that instant and C beacon-proxy requests/s. */
|
|
14
|
+
readonly jitterMs: number;
|
|
15
|
+
/** Event types sent at once, unjittered: the verification-critical ones (riedl 7.2). */
|
|
16
|
+
readonly immediate?: readonly string[];
|
|
17
|
+
/** Pseudonymous, session-scoped client id appended as a query parameter (riedl 7.1). Never a device id. */
|
|
18
|
+
readonly clientId?: {
|
|
19
|
+
readonly param: string;
|
|
20
|
+
readonly value: string;
|
|
21
|
+
};
|
|
22
|
+
/** Query parameter carrying the event's wallclock ms on a jittered request (riedl 7.2). */
|
|
23
|
+
readonly eventTimeParam?: string;
|
|
24
|
+
/** URLs sent per event at most; the rest are suppressed (riedl 12.2). Default 16. */
|
|
25
|
+
readonly maxUrlsPerEvent?: number;
|
|
26
|
+
}
|
|
27
|
+
export type AdBeaconPlan = {
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly sendAtMs: number;
|
|
30
|
+
readonly eventType: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly url: string;
|
|
33
|
+
readonly suppressed: 'authority' | 'cap' | 'macro';
|
|
34
|
+
readonly eventType: string;
|
|
35
|
+
};
|
|
36
|
+
/** `random` gives the jitter phase in [0, 1). The player passes one phase drawn per session, so a device's events
|
|
37
|
+
* keep their order and spacing while the audience still spreads uniformly over [0, W) (riedl 7.2). */
|
|
38
|
+
export declare function planAdBeacons(event: AdTrackEvent, policy: AdBeaconPolicy, nowMs: number, random?: () => number): AdBeaconPlan[];
|
|
39
|
+
//# sourceMappingURL=ad-beacon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ad-beacon.d.ts","sourceRoot":"","sources":["../src/ad-beacon.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,MAAM,WAAW,cAAc;IAC7B,+HAA+H;IAC/H,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC;yEACqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACtC,2GAA2G;IAC3G,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACtE,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,qFAAqF;IACrF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAK5G;uGACuG;AACvG,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,MAAoB,GAAG,YAAY,EAAE,CAgB5I"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/ad-beacon.ts
|
|
2
|
+
var VAST_MACRO = /\[[A-Z0-9_]+\]/;
|
|
3
|
+
function planAdBeacons(event, policy, nowMs, random = Math.random) {
|
|
4
|
+
const jittered = policy.jitterMs > 0 && !(policy.immediate ?? []).includes(event.eventType);
|
|
5
|
+
const delay = jittered ? Math.floor(random() * policy.jitterMs) : 0;
|
|
6
|
+
const params = [];
|
|
7
|
+
if (policy.clientId) params.push(`${encodeURIComponent(policy.clientId.param)}=${encodeURIComponent(policy.clientId.value)}`);
|
|
8
|
+
if (policy.eventTimeParam && jittered) params.push(`${encodeURIComponent(policy.eventTimeParam)}=${nowMs}`);
|
|
9
|
+
return event.urls.map((raw, i) => {
|
|
10
|
+
if (i >= (policy.maxUrlsPerEvent ?? 16)) return { url: raw, suppressed: "cap", eventType: event.eventType };
|
|
11
|
+
if (VAST_MACRO.test(raw)) return { url: raw, suppressed: "macro", eventType: event.eventType };
|
|
12
|
+
const url = new URL(raw);
|
|
13
|
+
if (!policy.authorities.includes(url.host)) return { url: raw, suppressed: "authority", eventType: event.eventType };
|
|
14
|
+
if (params.length > 0) url.search = url.search ? `${url.search}&${params.join("&")}` : `?${params.join("&")}`;
|
|
15
|
+
return { url: url.href, sendAtMs: nowMs + delay, eventType: event.eventType };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
planAdBeacons
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ad-beacon.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ad-beacon.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-01 7, 12):\n * which URL to request and when. No I/O and no timers here (the cmcd-producer.ts precedent):\n * the player sends each plan at sendAtMs with\n * fetch(url, { mode: 'no-cors', credentials: 'omit', keepalive: true, referrerPolicy: 'no-referrer' }).\n * The player calls this only for events the timeline emitted, so only for verified records.\n */\nimport type { AdTrackEvent } from './ad-creative-timeline.js'\n\nexport interface AdBeaconPolicy {\n /** Lower-case host[:port] beacons may go to (riedl 12.1), typically the distributor's beacon proxy. Empty: nothing is sent. */\n readonly authorities: readonly string[]\n /** Uniform jitter window W in ms (riedl 7.2). Size it from the audience: W >= 1000 * N * k / C ms, for N receivers,\n * k requests each at that instant and C beacon-proxy requests/s. */\n readonly jitterMs: number\n /** Event types sent at once, unjittered: the verification-critical ones (riedl 7.2). */\n readonly immediate?: readonly string[]\n /** Pseudonymous, session-scoped client id appended as a query parameter (riedl 7.1). Never a device id. */\n readonly clientId?: { readonly param: string; readonly value: string }\n /** Query parameter carrying the event's wallclock ms on a jittered request (riedl 7.2). */\n readonly eventTimeParam?: string\n /** URLs sent per event at most; the rest are suppressed (riedl 12.2). Default 16. */\n readonly maxUrlsPerEvent?: number\n}\n\nexport type AdBeaconPlan =\n | { readonly url: string; readonly sendAtMs: number; readonly eventType: string }\n | { readonly url: string; readonly suppressed: 'authority' | 'cap' | 'macro'; readonly eventType: string }\n\n/** A VAST macro such as [CACHEBUSTING]: riedl 7's first pattern (client-side substitution) is not supported. */\nconst VAST_MACRO = /\\[[A-Z0-9_]+\\]/\n\n/** `random` gives the jitter phase in [0, 1). The player passes one phase drawn per session, so a device's events\n * keep their order and spacing while the audience still spreads uniformly over [0, W) (riedl 7.2). */\nexport function planAdBeacons(event: AdTrackEvent, policy: AdBeaconPolicy, nowMs: number, random: () => number = Math.random): AdBeaconPlan[] {\n const jittered = policy.jitterMs > 0 && !(policy.immediate ?? []).includes(event.eventType)\n const delay = jittered ? Math.floor(random() * policy.jitterMs) : 0\n const params: string[] = []\n if (policy.clientId) params.push(`${encodeURIComponent(policy.clientId.param)}=${encodeURIComponent(policy.clientId.value)}`)\n if (policy.eventTimeParam && jittered) params.push(`${encodeURIComponent(policy.eventTimeParam)}=${nowMs}`)\n return event.urls.map((raw, i): AdBeaconPlan => {\n if (i >= (policy.maxUrlsPerEvent ?? 16)) return { url: raw, suppressed: 'cap', eventType: event.eventType }\n // Never sent unexpanded, and a device-identifier macro is never expanded (riedl 7.1, R33).\n if (VAST_MACRO.test(raw)) return { url: raw, suppressed: 'macro', eventType: event.eventType }\n const url = new URL(raw) // https and parseable: checked when the record was accepted (riedl 12.3)\n if (!policy.authorities.includes(url.host)) return { url: raw, suppressed: 'authority', eventType: event.eventType }\n // Append without re-encoding the capability URL's own query; a fragment stays last.\n if (params.length > 0) url.search = url.search ? `${url.search}&${params.join('&')}` : `?${params.join('&')}`\n return { url: url.href, sendAtMs: nowMs + delay, eventType: event.eventType }\n })\n}\n"],
|
|
5
|
+
"mappings": ";AA8BA,IAAM,aAAa;AAIZ,SAAS,cAAc,OAAqB,QAAwB,OAAe,SAAuB,KAAK,QAAwB;AAC5I,QAAM,WAAW,OAAO,WAAW,KAAK,EAAE,OAAO,aAAa,CAAC,GAAG,SAAS,MAAM,SAAS;AAC1F,QAAM,QAAQ,WAAW,KAAK,MAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAClE,QAAM,SAAmB,CAAC;AAC1B,MAAI,OAAO,SAAU,QAAO,KAAK,GAAG,mBAAmB,OAAO,SAAS,KAAK,CAAC,IAAI,mBAAmB,OAAO,SAAS,KAAK,CAAC,EAAE;AAC5H,MAAI,OAAO,kBAAkB,SAAU,QAAO,KAAK,GAAG,mBAAmB,OAAO,cAAc,CAAC,IAAI,KAAK,EAAE;AAC1G,SAAO,MAAM,KAAK,IAAI,CAAC,KAAK,MAAoB;AAC9C,QAAI,MAAM,OAAO,mBAAmB,IAAK,QAAO,EAAE,KAAK,KAAK,YAAY,OAAO,WAAW,MAAM,UAAU;AAE1G,QAAI,WAAW,KAAK,GAAG,EAAG,QAAO,EAAE,KAAK,KAAK,YAAY,SAAS,WAAW,MAAM,UAAU;AAC7F,UAAM,MAAM,IAAI,IAAI,GAAG;AACvB,QAAI,CAAC,OAAO,YAAY,SAAS,IAAI,IAAI,EAAG,QAAO,EAAE,KAAK,KAAK,YAAY,aAAa,WAAW,MAAM,UAAU;AAEnH,QAAI,OAAO,SAAS,EAAG,KAAI,SAAS,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,OAAO,KAAK,GAAG,CAAC,KAAK,IAAI,OAAO,KAAK,GAAG,CAAC;AAC3G,WAAO,EAAE,KAAK,IAAI,MAAM,UAAU,QAAQ,OAAO,WAAW,MAAM,UAAU;AAAA,EAC9E,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AdCreativeKeys, type AdCreativeRecord, type AdIndex, type AdObjectDrop, type AdRecordDrop } from './ad-creative-record.js';
|
|
2
2
|
export * from './ad-creative-record.js';
|
|
3
|
+
export * from './ad-beacon.js';
|
|
3
4
|
export interface AdScheduledEvent {
|
|
4
5
|
/** Unique within a record: container key, tracking type and its occurrence. */
|
|
5
6
|
readonly eventKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ad-creative-timeline.d.ts","sourceRoot":"","sources":["../src/ad-creative-timeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAC/F,MAAM,yBAAyB,CAAA;AAEhC,cAAc,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"ad-creative-timeline.d.ts","sourceRoot":"","sources":["../src/ad-creative-timeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,EAAE,KA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AM,YAAY,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AACtE,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;AAEjE,MAAM,WAAW,yBAAyB;IACxC,4EAA4E;IAC5E,IAAI,EAAE,cAAc,CAAA;IACpB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAAA;IAC5C,mHAAmH;IACnH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wHAAwH;IACxH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAkCD;;;;;;GAMG;AACH,qBAAa,kBAAkB;;IAC7B,wGAAwG;IACxG,IAAI,EAAE,cAAc,CAAA;gBAYR,OAAO,EAAE,yBAAyB;IAO9C,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAOrD,mGAAmG;IACnG,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAmG3D,wGAAwG;IACxG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CA6DnC"}
|
|
@@ -2266,6 +2266,24 @@ function parseAdCreativeObject(bytes, keys) {
|
|
|
2266
2266
|
return { verdict: "accepted", records: doc.map((record) => parseAdCreativeRecord(record, keys)) };
|
|
2267
2267
|
}
|
|
2268
2268
|
|
|
2269
|
+
// src/ad-beacon.ts
|
|
2270
|
+
var VAST_MACRO = /\[[A-Z0-9_]+\]/;
|
|
2271
|
+
function planAdBeacons(event, policy, nowMs, random = Math.random) {
|
|
2272
|
+
const jittered = policy.jitterMs > 0 && !(policy.immediate ?? []).includes(event.eventType);
|
|
2273
|
+
const delay = jittered ? Math.floor(random() * policy.jitterMs) : 0;
|
|
2274
|
+
const params = [];
|
|
2275
|
+
if (policy.clientId) params.push(`${encodeURIComponent(policy.clientId.param)}=${encodeURIComponent(policy.clientId.value)}`);
|
|
2276
|
+
if (policy.eventTimeParam && jittered) params.push(`${encodeURIComponent(policy.eventTimeParam)}=${nowMs}`);
|
|
2277
|
+
return event.urls.map((raw, i) => {
|
|
2278
|
+
if (i >= (policy.maxUrlsPerEvent ?? 16)) return { url: raw, suppressed: "cap", eventType: event.eventType };
|
|
2279
|
+
if (VAST_MACRO.test(raw)) return { url: raw, suppressed: "macro", eventType: event.eventType };
|
|
2280
|
+
const url = new URL(raw);
|
|
2281
|
+
if (!policy.authorities.includes(url.host)) return { url: raw, suppressed: "authority", eventType: event.eventType };
|
|
2282
|
+
if (params.length > 0) url.search = url.search ? `${url.search}&${params.join("&")}` : `?${params.join("&")}`;
|
|
2283
|
+
return { url: url.href, sendAtMs: nowMs + delay, eventType: event.eventType };
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2269
2287
|
// src/ad-creative-timeline.ts
|
|
2270
2288
|
var FRACTION = /* @__PURE__ */ new Map([
|
|
2271
2289
|
["podStart", 0],
|
|
@@ -2292,6 +2310,7 @@ function containerEvents(tracking, startMs, durationS, prefix, slotKey) {
|
|
|
2292
2310
|
const n = occurrences.get(type) ?? 0;
|
|
2293
2311
|
occurrences.set(type, n + 1);
|
|
2294
2312
|
const fraction = FRACTION.get(type);
|
|
2313
|
+
if (event["offset"] !== void 0 && seconds(event["offset"]) === void 0) continue;
|
|
2295
2314
|
const atS = seconds(event["offset"]) ?? (fraction === 0 ? 0 : fraction !== void 0 && durationS !== void 0 ? fraction * durationS : void 0);
|
|
2296
2315
|
if (atS === void 0) continue;
|
|
2297
2316
|
events.push({
|
|
@@ -2510,6 +2529,7 @@ export {
|
|
|
2510
2529
|
importAdCreativeJwks,
|
|
2511
2530
|
parseAdCreativeObject,
|
|
2512
2531
|
parseAdCreativeRecord,
|
|
2532
|
+
planAdBeacons,
|
|
2513
2533
|
scheduleAdRecord,
|
|
2514
2534
|
verifyAdCreativeSig
|
|
2515
2535
|
};
|