@schibsted/sps-sdk 5.2.0-CBT-20902.2 → 5.2.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/esm/sps.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type Environment, type SpsParams, type GetPosterByDecisionParams, type
2
2
  import { type ContentType, type TrackingData, type TrackingParamsProps } from "./tracking/create-tracking-params.js";
3
3
  import { SpsPublication } from "./sps/publication.js";
4
4
  import { type SPSPosterResponse } from "./apiClient.js";
5
- import type { PlacementType, PlacementTypeWithOptionalFallback, PlacementTypeWithRequiredFallback, PlacementTypeWithStringContent } from "./sps/placement.js";
5
+ import type { PlacementType, PlacementTypeWithOptionalFallback, PlacementTypeWithRequiredFallback } from "./sps/placement.js";
6
6
  /**
7
7
  * The full poster response enriched with segment names, tracking data, and Pulse event objects.
8
8
  * Returned by {@link SPS.getPoster} and {@link SPS.getPosterByDecision}.
@@ -94,32 +94,25 @@ export type SpsRequestOptions<T extends PlacementType> = {
94
94
  timeoutMs?: number;
95
95
  };
96
96
  /**
97
- * Options for {@link SPS.renderFrontpagePlacements} and {@link SPS.renderArticlePagePlacements}.
97
+ * Options for {@link SPS.getFrontpagePlacements} and {@link SPS.getArticlePagePlacements}.
98
98
  * @typeParam T - The placement type
99
99
  * @typeParam P - The params shape sent to SPS for this request
100
100
  */
101
101
  export type SpsContextPlacementsOptions<T extends PlacementType, P extends SpsParams = SpsParams> = Omit<SpsRequestOptions<T>, "fallbackPoster" | "showFallbackPosterOnNoContent"> & {
102
102
  /** Query params forwarded to the SPS API for the whole request. */
103
103
  params?: P;
104
+ /** Placement types to exclude from the priority-ordered result. */
105
+ excludedPlacementTypes?: PlacementType[];
104
106
  /**
105
107
  * Per-type fallback posters to return when the SPS context API call fails entirely
106
108
  * (network error or non-OK response). Each entry is enriched the same way as a real poster.
107
109
  */
108
110
  fallbackPosters?: FallbackPostersMap;
109
111
  };
110
- /**
111
- * Options for {@link renderFrontpagePlacements} and {@link renderArticlePagePlacements}.
112
- * The SDK sets `context` in `params` and fires TPaaS Pulse events.
113
- * @typeParam P - The params shape sent to SPS for this request
114
- */
115
- export type RenderPlacementsOptions<P extends SpsParams = SpsParams> = Pick<SpsOptions, "publication" | "environment" | "cookieDomain" | "domain"> & Omit<SpsContextPlacementsOptions<PlacementType, P>, "params" | "pulseEvents" | "tracking" | "generateLoginUrl"> & {
116
- /** Query params forwarded to the SPS API for the whole request. `context` is set by the SDK. */
117
- params?: Omit<P, "context">;
118
- };
119
112
  /**
120
113
  * Maps placement types to their fallback poster content.
121
- * Used by {@link SPS.renderFrontpagePlacements} and {@link SPS.renderArticlePagePlacements}
122
- * to render pre-configured posters when the SPS API call fails entirely.
114
+ * Used by {@link SPS.getFrontpagePlacements} and {@link SPS.getArticlePagePlacements}
115
+ * to return pre-configured posters when the SPS API call fails entirely.
123
116
  */
124
117
  export type FallbackPostersMap = {
125
118
  [T in PlacementType]?: SPSPosterResponse<T>;
@@ -133,8 +126,8 @@ export type SpsContextDecisionsOptions<P extends SpsParams = SpsParams> = {
133
126
  params?: P;
134
127
  /** Pass `req.headers.cookie` when calling server-side. */
135
128
  cookies?: string;
136
- /** Placement types to include in the priority-ordered result. */
137
- placementTypes?: PlacementType[];
129
+ /** Placement types to exclude from the priority-ordered result. */
130
+ excludedPlacementTypes?: PlacementType[];
138
131
  };
139
132
  /**
140
133
  * Variant of {@link SpsRequestOptions} that requires a `fallbackPoster` and forces
@@ -145,14 +138,6 @@ export type SpsRequestOptionsWithFallback<T extends PlacementType> = SpsRequestO
145
138
  fallbackPoster: SPSPosterResponse<T>;
146
139
  showFallbackPosterOnNoContent: true;
147
140
  };
148
- /**
149
- * A placement type and the host element its poster is rendered in.
150
- * Used by {@link SPS.renderFrontpagePlacements} and {@link SPS.renderArticlePagePlacements}.
151
- */
152
- export type PlacementElement = {
153
- placementType: PlacementTypeWithStringContent;
154
- element: HTMLElement;
155
- };
156
141
  /**
157
142
  * Options for the dismiss functionality, enabling a placement to be hidden when
158
143
  * an element with `data-dismiss-on-click` is clicked inside the placement.
@@ -310,28 +295,6 @@ export declare class SPS {
310
295
  */
311
296
  getPosterByDecision: GetPosterByDecision;
312
297
  private enrichPosterResponse;
313
- /**
314
- * Fetches priority-ordered placements for the frontpage context and renders each one
315
- * in an iframe inside its element. Must be called from a browser environment.
316
- * Also exported as {@link renderFrontpagePlacements}, which needs no SDK instance.
317
- *
318
- * @param placements - The placement types to fetch, each with the element to render it in.
319
- * @param options - The publication and environment to request from, and request options including `params`.
320
- * @returns The placement types that were rendered.
321
- */
322
- static renderFrontpagePlacements<P extends FrontpageParams = FrontpageParams>(placements: PlacementElement[], options: RenderPlacementsOptions<P>): Promise<PlacementTypeWithStringContent[]>;
323
- /**
324
- * Fetches priority-ordered placements for the article page context and renders each one
325
- * in an iframe inside its element. Must be called from a browser environment.
326
- * Also exported as {@link renderArticlePagePlacements}, which needs no SDK instance.
327
- *
328
- * @param placements - The placement types to fetch, each with the element to render it in.
329
- * @param options - The publication and environment to request from, and request options including `params`.
330
- * @returns The placement types that were rendered.
331
- */
332
- static renderArticlePagePlacements<P extends ArticlePageParams = ArticlePageParams>(placements: PlacementElement[], options: RenderPlacementsOptions<P>): Promise<PlacementTypeWithStringContent[]>;
333
- private static renderContextPlacements;
334
- private renderPlacements;
335
298
  /**
336
299
  * Fetches priority-ordered placements (full content) for the frontpage context.
337
300
  * Must be called from a browser environment.
@@ -339,11 +302,12 @@ export declare class SPS {
339
302
  * Applies the same post-processing as {@link SPS.getPoster}: rewrites login/redirect
340
303
  * placeholder variables and appends tracking search params to links.
341
304
  *
342
- * @param placementTypes - The placement types to request.
343
- * @param options - Request options including tracking context, URL rewrite callbacks, and `params`.
305
+ * @param options - Optional request options including tracking context, URL rewrite callbacks, `params`, and `excludedPlacementTypes`.
344
306
  * @returns Array of enriched placements for the frontpage context, fallback posters (if configured) on API failure, or `[]` otherwise.
345
307
  */
346
- private getFrontpagePlacements;
308
+ getFrontpagePlacements<P extends FrontpageParams = FrontpageParams>(options?: SpsContextPlacementsOptions<PlacementType, P>): Promise<(Poster<PlacementType> & {
309
+ type: PlacementType;
310
+ })[]>;
347
311
  /**
348
312
  * Fetches priority-ordered placements (full content) for the article page context.
349
313
  * Must be called from a browser environment.
@@ -351,11 +315,12 @@ export declare class SPS {
351
315
  * Applies the same post-processing as {@link SPS.getPoster}: rewrites login/redirect
352
316
  * placeholder variables and appends tracking search params to links.
353
317
  *
354
- * @param placementTypes - The placement types to request.
355
- * @param options - Request options including tracking context, URL rewrite callbacks, and `params`.
318
+ * @param options - Optional request options including tracking context, URL rewrite callbacks, `params`, and `excludedPlacementTypes`.
356
319
  * @returns Array of enriched placements for the article page context, fallback posters (if configured) on API failure, or `[]` otherwise.
357
320
  */
358
- private getArticlePagePlacements;
321
+ getArticlePagePlacements<P extends ArticlePageParams = ArticlePageParams>(options?: SpsContextPlacementsOptions<PlacementType, P>): Promise<(Poster<PlacementType> & {
322
+ type: PlacementType;
323
+ })[]>;
359
324
  private enrichContextPlacements;
360
325
  private enrichFallbackPosters;
361
326
  /**
@@ -364,7 +329,7 @@ export declare class SPS {
364
329
  *
365
330
  * Returns values compatible with {@link SPS.getPosterByDecision}.
366
331
  *
367
- * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`placementTypes`.
332
+ * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`excludedPlacementTypes`.
368
333
  * @returns Array of decisions for the frontpage context, or `[]` on error.
369
334
  */
370
335
  getFrontpageDecisions<P extends FrontpageParams = FrontpageParams>(options?: SpsContextDecisionsOptions<P>): Promise<Decision<PlacementType>[]>;
@@ -374,11 +339,9 @@ export declare class SPS {
374
339
  *
375
340
  * Returns values compatible with {@link SPS.getPosterByDecision}.
376
341
  *
377
- * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`placementTypes`.
342
+ * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`excludedPlacementTypes`.
378
343
  * @returns Array of decisions for the article page context, or `[]` on error.
379
344
  */
380
345
  getArticlePageDecisions<P extends ArticlePageParams = ArticlePageParams>(options?: SpsContextDecisionsOptions<P>): Promise<Decision<PlacementType>[]>;
381
346
  }
382
- export declare const renderFrontpagePlacements: typeof SPS.renderFrontpagePlacements;
383
- export declare const renderArticlePagePlacements: typeof SPS.renderArticlePagePlacements;
384
347
  export {};
package/dist/esm/sps.js CHANGED
@@ -5,20 +5,6 @@ import { SpsPublication } from "./sps/publication.js";
5
5
  import { fetchDecision, fetchDecisionsByContext, fetchPlacementsByContext, fetchPoster, } from "./apiClient.js";
6
6
  import { addDismiss, getDismissIframeId, isDismissed } from "./actions/dismiss.js";
7
7
  import { addConsentForwarding } from "./actions/consent.js";
8
- import { renderPosterInIframe } from "./actions/iframe.js";
9
- /**
10
- * The domain SPS is requested from for each publication, used by {@link renderFrontpagePlacements}
11
- * and {@link renderArticlePagePlacements}. Publications not listed use the default domain.
12
- */
13
- const publicationDomains = {
14
- [SpsPublication.AB]: "aftonbladet.se",
15
- [SpsPublication.AP]: "aftenposten.no",
16
- [SpsPublication.BT]: "bt.no",
17
- [SpsPublication.E24]: "e24.no",
18
- [SpsPublication.SA]: "aftenbladet.no",
19
- [SpsPublication.SVD]: "svd.se",
20
- [SpsPublication.VG]: "vg.no",
21
- };
22
8
  /**
23
9
  * Main entry point for the SPS SDK. Provides methods to fetch posters and decisions
24
10
  * from the SPS API for a given publication and environment.
@@ -212,61 +198,6 @@ export class SPS {
212
198
  pulseObject,
213
199
  };
214
200
  }
215
- /**
216
- * Fetches priority-ordered placements for the frontpage context and renders each one
217
- * in an iframe inside its element. Must be called from a browser environment.
218
- * Also exported as {@link renderFrontpagePlacements}, which needs no SDK instance.
219
- *
220
- * @param placements - The placement types to fetch, each with the element to render it in.
221
- * @param options - The publication and environment to request from, and request options including `params`.
222
- * @returns The placement types that were rendered.
223
- */
224
- static async renderFrontpagePlacements(placements, options) {
225
- return SPS.renderContextPlacements("frontpage", placements, options);
226
- }
227
- /**
228
- * Fetches priority-ordered placements for the article page context and renders each one
229
- * in an iframe inside its element. Must be called from a browser environment.
230
- * Also exported as {@link renderArticlePagePlacements}, which needs no SDK instance.
231
- *
232
- * @param placements - The placement types to fetch, each with the element to render it in.
233
- * @param options - The publication and environment to request from, and request options including `params`.
234
- * @returns The placement types that were rendered.
235
- */
236
- static async renderArticlePagePlacements(placements, options) {
237
- return SPS.renderContextPlacements("article", placements, options);
238
- }
239
- static async renderContextPlacements(context, placements, { publication, environment, cookieDomain, domain, params, ...options }) {
240
- const sps = new SPS({
241
- publication,
242
- domain: domain ?? publicationDomains[publication],
243
- environment,
244
- cookieDomain,
245
- });
246
- const contextOptions = {
247
- ...options,
248
- params: { ...params, context },
249
- pulseEvents: { tpaas: true },
250
- };
251
- return sps.renderPlacements(placements, (placementTypes) => context === "frontpage"
252
- ? sps.getFrontpagePlacements(placementTypes, contextOptions)
253
- : sps.getArticlePagePlacements(placementTypes, contextOptions));
254
- }
255
- async renderPlacements(placements, fetchPosters) {
256
- const placementTypes = placements.map((p) => p.placementType);
257
- if (new Set(placementTypes).size !== placementTypes.length) {
258
- throw new Error("[SPS sdk] Each placement type can only be rendered in one element");
259
- }
260
- const posters = await fetchPosters(placementTypes);
261
- placements.forEach(({ element }) => element.replaceChildren());
262
- return Promise.all(posters.flatMap((poster) => {
263
- const placement = placements.find((p) => p.placementType === poster.type);
264
- if (!placement) {
265
- return [];
266
- }
267
- return renderPosterInIframe(placement.element, poster.iframeId, poster.content).then(() => placement.placementType);
268
- }));
269
- }
270
201
  /**
271
202
  * Fetches priority-ordered placements (full content) for the frontpage context.
272
203
  * Must be called from a browser environment.
@@ -274,15 +205,14 @@ export class SPS {
274
205
  * Applies the same post-processing as {@link SPS.getPoster}: rewrites login/redirect
275
206
  * placeholder variables and appends tracking search params to links.
276
207
  *
277
- * @param placementTypes - The placement types to request.
278
- * @param options - Request options including tracking context, URL rewrite callbacks, and `params`.
208
+ * @param options - Optional request options including tracking context, URL rewrite callbacks, `params`, and `excludedPlacementTypes`.
279
209
  * @returns Array of enriched placements for the frontpage context, fallback posters (if configured) on API failure, or `[]` otherwise.
280
210
  */
281
- async getFrontpagePlacements(placementTypes, options) {
211
+ async getFrontpagePlacements(options = {}) {
282
212
  await this.validateClientEnvironment();
283
- const result = await fetchPlacementsByContext(this.publication, "frontpage", this.endpoint, options.params, undefined, placementTypes, options.timeoutMs);
213
+ const result = await fetchPlacementsByContext(this.publication, "frontpage", this.endpoint, options.params, undefined, options.excludedPlacementTypes, options.timeoutMs);
284
214
  if (!result) {
285
- return options.fallbackPosters ? this.enrichFallbackPosters(placementTypes, options) : [];
215
+ return options.fallbackPosters ? this.enrichFallbackPosters(options) : [];
286
216
  }
287
217
  return this.enrichContextPlacements(result.placements, options);
288
218
  }
@@ -293,15 +223,14 @@ export class SPS {
293
223
  * Applies the same post-processing as {@link SPS.getPoster}: rewrites login/redirect
294
224
  * placeholder variables and appends tracking search params to links.
295
225
  *
296
- * @param placementTypes - The placement types to request.
297
- * @param options - Request options including tracking context, URL rewrite callbacks, and `params`.
226
+ * @param options - Optional request options including tracking context, URL rewrite callbacks, `params`, and `excludedPlacementTypes`.
298
227
  * @returns Array of enriched placements for the article page context, fallback posters (if configured) on API failure, or `[]` otherwise.
299
228
  */
300
- async getArticlePagePlacements(placementTypes, options) {
229
+ async getArticlePagePlacements(options = {}) {
301
230
  await this.validateClientEnvironment();
302
- const result = await fetchPlacementsByContext(this.publication, "article", this.endpoint, options.params, undefined, placementTypes, options.timeoutMs);
231
+ const result = await fetchPlacementsByContext(this.publication, "article", this.endpoint, options.params, undefined, options.excludedPlacementTypes, options.timeoutMs);
303
232
  if (!result) {
304
- return options.fallbackPosters ? this.enrichFallbackPosters(placementTypes, options) : [];
233
+ return options.fallbackPosters ? this.enrichFallbackPosters(options) : [];
305
234
  }
306
235
  return this.enrichContextPlacements(result.placements, options);
307
236
  }
@@ -317,9 +246,9 @@ export class SPS {
317
246
  return { ...enriched, type: placement.placementType };
318
247
  }));
319
248
  }
320
- async enrichFallbackPosters(placementTypes, options) {
249
+ async enrichFallbackPosters(options) {
321
250
  return Promise.all(Object.entries(options.fallbackPosters ?? {})
322
- .filter(([placementType]) => placementTypes.includes(placementType))
251
+ .filter(([placementType]) => !options.excludedPlacementTypes?.includes(placementType))
323
252
  .filter(([, poster]) => poster !== undefined)
324
253
  .map(async ([placementType, poster]) => {
325
254
  const enriched = await this.enrichPosterResponse(poster, placementType, options, undefined, {
@@ -339,11 +268,11 @@ export class SPS {
339
268
  *
340
269
  * Returns values compatible with {@link SPS.getPosterByDecision}.
341
270
  *
342
- * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`placementTypes`.
271
+ * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`excludedPlacementTypes`.
343
272
  * @returns Array of decisions for the frontpage context, or `[]` on error.
344
273
  */
345
274
  async getFrontpageDecisions(options = {}) {
346
- const { placements } = await fetchDecisionsByContext(this.publication, "frontpage", this.endpoint, options.params, options.cookies, options.placementTypes);
275
+ const { placements } = await fetchDecisionsByContext(this.publication, "frontpage", this.endpoint, options.params, options.cookies, options.excludedPlacementTypes);
347
276
  return placements.map((d) => ({
348
277
  placementType: d.placementType,
349
278
  contentKey: d.contentKey,
@@ -356,11 +285,11 @@ export class SPS {
356
285
  *
357
286
  * Returns values compatible with {@link SPS.getPosterByDecision}.
358
287
  *
359
- * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`placementTypes`.
288
+ * @param options - Optional. Pass `cookies: req.headers.cookie` when calling server-side, and/or `params`/`excludedPlacementTypes`.
360
289
  * @returns Array of decisions for the article page context, or `[]` on error.
361
290
  */
362
291
  async getArticlePageDecisions(options = {}) {
363
- const { placements } = await fetchDecisionsByContext(this.publication, "article", this.endpoint, options.params, options.cookies, options.placementTypes);
292
+ const { placements } = await fetchDecisionsByContext(this.publication, "article", this.endpoint, options.params, options.cookies, options.excludedPlacementTypes);
364
293
  return placements.map((d) => ({
365
294
  placementType: d.placementType,
366
295
  contentKey: d.contentKey,
@@ -368,6 +297,4 @@ export class SPS {
368
297
  }));
369
298
  }
370
299
  }
371
- export const renderFrontpagePlacements = SPS.renderFrontpagePlacements;
372
- export const renderArticlePagePlacements = SPS.renderArticlePagePlacements;
373
300
  //# sourceMappingURL=sps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sps.js","sourceRoot":"","sources":["../../src/sps.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAOZ,MAAM,GAAG,CAAC;AACX,OAAO,EACL,oBAAoB,GAIrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,GAIZ,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAuTxD;;;GAGG;AACH,MAAM,kBAAkB,GAA4C;IAClE,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,gBAAgB;IACrC,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,gBAAgB;IACrC,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,OAAO;IAC5B,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ;IAC9B,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,gBAAgB;IACrC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ;IAC9B,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,OAAO;CAC7B,CAAC;AAEF;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M,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAClD,IAAI,CAAC,WAAW,EAChB,SAAS,EACT,IAAI,CAAC,QAAQ,EACb,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC/B,CAAC;QACF,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC;YACzC,aAAa,EAAE,CAAC,CAAC,aAAa;YAC9B,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,YAAY,EAAE,CAAC,CAAC,YAAY;SAC7B,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/sps-sdk",
3
- "version": "5.2.0-CBT-20902.2",
3
+ "version": "5.2.0",
4
4
  "description": "SPS SDK for node.js",
5
5
  "packageManager": "pnpm@10.27.0",
6
6
  "engines": {
@@ -1,6 +0,0 @@
1
- /**
2
- * Renders poster content in an iframe that replaces the children of `element`.
3
- * The iframe grows to the height of its content, and links navigate the top window.
4
- * Resolves once the iframe has loaded and its first height is applied.
5
- */
6
- export declare const renderPosterInIframe: (element: HTMLElement, iframeId: string, content: string) => Promise<void>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderPosterInIframe = void 0;
4
- const resetDocumentSpacing = (doc) => {
5
- [doc.documentElement, doc.body].forEach((el) => {
6
- el.style.margin = "0";
7
- el.style.padding = "0";
8
- el.style.overflow = "hidden";
9
- });
10
- };
11
- const navigateTopOnLinkClick = (doc) => {
12
- doc.addEventListener("click", (event) => {
13
- const anchor = event.target?.closest("a");
14
- if (!anchor?.href) {
15
- return;
16
- }
17
- event.preventDefault();
18
- // Delay navigation so click tracking inside the poster has time to fire
19
- setTimeout(() => window.top?.location.assign(anchor.href), 100);
20
- });
21
- };
22
- /**
23
- * Renders poster content in an iframe that replaces the children of `element`.
24
- * The iframe grows to the height of its content, and links navigate the top window.
25
- * Resolves once the iframe has loaded and its first height is applied.
26
- */
27
- const renderPosterInIframe = (element, iframeId, content) => new Promise((resolve) => {
28
- const iframe = document.createElement("iframe");
29
- iframe.id = iframeId;
30
- iframe.style.border = "0";
31
- iframe.style.display = "block";
32
- iframe.style.width = "100%";
33
- iframe.addEventListener("load", () => {
34
- const doc = iframe.contentDocument;
35
- resetDocumentSpacing(doc);
36
- navigateTopOnLinkClick(doc);
37
- const updateHeight = () => {
38
- iframe.style.height = `${doc.body.scrollHeight}px`;
39
- };
40
- updateHeight();
41
- new ResizeObserver(updateHeight).observe(doc.body);
42
- resolve();
43
- }, { once: true });
44
- iframe.srcdoc = content;
45
- element.replaceChildren(iframe);
46
- });
47
- exports.renderPosterInIframe = renderPosterInIframe;
48
- //# sourceMappingURL=iframe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iframe.js","sourceRoot":"","sources":["../../../src/actions/iframe.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG,CAAC,GAAa,EAAQ,EAAE;IACnD,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;QAC7C,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;QACtB,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QACvB,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,GAAa,EAAQ,EAAE;IACrD,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACtC,MAAM,MAAM,GAAI,KAAK,CAAC,MAAyB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;YA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C,eAAe,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AA7BQ,QAAA,oBAAoB,wBA6B5B"}
@@ -1,52 +0,0 @@
1
- import type { RenderPlacementsOptions } from "./sps.js";
2
- import type { PlacementTypeWithStringContent } from "./sps/placement.js";
3
- export declare const PLACEMENT_ELEMENT_TAG = "sps-placement";
4
- export declare const PLACEMENT_LOADED_EVENT = "sps-loaded";
5
- export declare const PLACEMENT_ERROR_EVENT = "sps-error";
6
- /**
7
- * Page-wide configuration for `<sps-placement>` elements, set with {@link configureSps}.
8
- * Takes the options of {@link renderFrontpagePlacements} and {@link renderArticlePagePlacements},
9
- * plus the page context.
10
- */
11
- export type ConfigureSpsOptions = RenderPlacementsOptions & {
12
- /** Which kind of page the placements are on. */
13
- context: "frontpage" | "article";
14
- };
15
- /** Detail of the `sps-loaded` event dispatched on every element of a finished load. */
16
- export type PlacementLoadedDetail = {
17
- /** The placement types that were rendered by the load this element was part of. */
18
- rendered: PlacementTypeWithStringContent[];
19
- };
20
- /** Detail of the `sps-error` event dispatched when a load fails. */
21
- export type PlacementErrorDetail = {
22
- error: unknown;
23
- };
24
- /** Methods of the `<sps-placement>` element. */
25
- export interface SpsPlacementElement extends HTMLElement {
26
- /**
27
- * Loads this element together with the other elements of its `group`, like
28
- * {@link loadPlacements} for that group.
29
- */
30
- load(): Promise<PlacementTypeWithStringContent[]>;
31
- }
32
- /**
33
- * Loads the `<sps-placement>` elements of a group in one request, so SPS can choose between their
34
- * placement types. Elements without a `group` attribute are in the default group. Loading again
35
- * replaces what was rendered. Nothing is loaded until {@link configureSps} has been called.
36
- *
37
- * @param group - The group to load. Defaults to the group of elements without a `group` attribute.
38
- * @returns The placement types that were rendered, which is empty when SPS returned none.
39
- */
40
- export declare const loadPlacements: (group?: string) => Promise<PlacementTypeWithStringContent[]>;
41
- /**
42
- * Configures the SDK for the page and defines the `<sps-placement>` element.
43
- *
44
- * Nothing is loaded by this call: call {@link loadPlacements} or `load()` on an element when you
45
- * are ready. Calling this again replaces the configuration.
46
- *
47
- * In an environment without custom elements, such as Node, the configuration is stored and
48
- * nothing else happens.
49
- *
50
- * @param options - The publication and environment to request from, the page context, and request options including `params`.
51
- */
52
- export declare const configureSps: (options: ConfigureSpsOptions) => void;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configureSps = exports.loadPlacements = exports.PLACEMENT_ERROR_EVENT = exports.PLACEMENT_LOADED_EVENT = exports.PLACEMENT_ELEMENT_TAG = void 0;
4
- const sps_1 = require("./sps.js");
5
- exports.PLACEMENT_ELEMENT_TAG = "sps-placement";
6
- exports.PLACEMENT_LOADED_EVENT = "sps-loaded";
7
- exports.PLACEMENT_ERROR_EVENT = "sps-error";
8
- const DEFAULT_GROUP = "default";
9
- let config;
10
- const loadElements = async (elements) => {
11
- if (!config) {
12
- console.warn("[SPS sdk] Call configureSps before loading placements");
13
- return [];
14
- }
15
- if (elements.length === 0) {
16
- return [];
17
- }
18
- const { context, ...options } = config;
19
- const render = context === "frontpage" ? sps_1.renderFrontpagePlacements : sps_1.renderArticlePagePlacements;
20
- const placements = elements.map((element) => ({
21
- placementType: element.getAttribute("type"),
22
- element,
23
- }));
24
- try {
25
- const rendered = await render(placements, options);
26
- elements.forEach((element) => {
27
- element.hidden = !rendered.includes(element.getAttribute("type"));
28
- element.dispatchEvent(new CustomEvent(exports.PLACEMENT_LOADED_EVENT, {
29
- detail: { rendered },
30
- bubbles: true,
31
- }));
32
- });
33
- return rendered;
34
- }
35
- catch (error) {
36
- console.error("[SPS sdk] Failed to load placements", error);
37
- elements.forEach((element) => element.dispatchEvent(new CustomEvent(exports.PLACEMENT_ERROR_EVENT, {
38
- detail: { error },
39
- bubbles: true,
40
- })));
41
- return [];
42
- }
43
- };
44
- const getGroup = (element) => element.getAttribute("group") ?? DEFAULT_GROUP;
45
- /**
46
- * Loads the `<sps-placement>` elements of a group in one request, so SPS can choose between their
47
- * placement types. Elements without a `group` attribute are in the default group. Loading again
48
- * replaces what was rendered. Nothing is loaded until {@link configureSps} has been called.
49
- *
50
- * @param group - The group to load. Defaults to the group of elements without a `group` attribute.
51
- * @returns The placement types that were rendered, which is empty when SPS returned none.
52
- */
53
- const loadPlacements = (group = DEFAULT_GROUP) => {
54
- const members = [...document.querySelectorAll(exports.PLACEMENT_ELEMENT_TAG)].filter((member) => getGroup(member) === group && member.getAttribute("type"));
55
- return loadElements(members);
56
- };
57
- exports.loadPlacements = loadPlacements;
58
- // Defined lazily: extending HTMLElement at module scope would throw when the SDK is imported in Node
59
- const definePlacementElement = () => {
60
- if (customElements.get(exports.PLACEMENT_ELEMENT_TAG)) {
61
- return;
62
- }
63
- // Zero specificity, so any rule from the host page wins
64
- const style = document.createElement("style");
65
- style.textContent = `:where(${exports.PLACEMENT_ELEMENT_TAG}) { display: block; }`;
66
- document.head.appendChild(style);
67
- customElements.define(exports.PLACEMENT_ELEMENT_TAG, class extends HTMLElement {
68
- load() {
69
- return (0, exports.loadPlacements)(getGroup(this));
70
- }
71
- });
72
- };
73
- /**
74
- * Configures the SDK for the page and defines the `<sps-placement>` element.
75
- *
76
- * Nothing is loaded by this call: call {@link loadPlacements} or `load()` on an element when you
77
- * are ready. Calling this again replaces the configuration.
78
- *
79
- * In an environment without custom elements, such as Node, the configuration is stored and
80
- * nothing else happens.
81
- *
82
- * @param options - The publication and environment to request from, the page context, and request options including `params`.
83
- */
84
- const configureSps = (options) => {
85
- config = options;
86
- if (typeof customElements !== "undefined") {
87
- definePlacementElement();
88
- }
89
- };
90
- exports.configureSps = configureSps;
91
- //# sourceMappingURL=configure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/configure.ts"],"names":[],"mappings":";;;AAAA,+BAA+E;AAIlE,QAAA,qBAAqB,GAAG,eAAe,CAAC;AACxC,QAAA,sBAAsB,GAAG,YAAY,CAAC;AACtC,QAAA,qBAAqB,GAAG,WAAW,CAAC;AAEjD,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CAAC,CAAC,CAAC;QACxC,CAAC;KACF,CACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAQ,EAAE;IACjE,MAAM,GAAG,OAAO,CAAC;IACjB,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;QAC1C,sBAAsB,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Renders poster content in an iframe that replaces the children of `element`.
3
- * The iframe grows to the height of its content, and links navigate the top window.
4
- * Resolves once the iframe has loaded and its first height is applied.
5
- */
6
- export declare const renderPosterInIframe: (element: HTMLElement, iframeId: string, content: string) => Promise<void>;
@@ -1,44 +0,0 @@
1
- const resetDocumentSpacing = (doc) => {
2
- [doc.documentElement, doc.body].forEach((el) => {
3
- el.style.margin = "0";
4
- el.style.padding = "0";
5
- el.style.overflow = "hidden";
6
- });
7
- };
8
- const navigateTopOnLinkClick = (doc) => {
9
- doc.addEventListener("click", (event) => {
10
- const anchor = event.target?.closest("a");
11
- if (!anchor?.href) {
12
- return;
13
- }
14
- event.preventDefault();
15
- // Delay navigation so click tracking inside the poster has time to fire
16
- setTimeout(() => window.top?.location.assign(anchor.href), 100);
17
- });
18
- };
19
- /**
20
- * Renders poster content in an iframe that replaces the children of `element`.
21
- * The iframe grows to the height of its content, and links navigate the top window.
22
- * Resolves once the iframe has loaded and its first height is applied.
23
- */
24
- export const renderPosterInIframe = (element, iframeId, content) => new Promise((resolve) => {
25
- const iframe = document.createElement("iframe");
26
- iframe.id = iframeId;
27
- iframe.style.border = "0";
28
- iframe.style.display = "block";
29
- iframe.style.width = "100%";
30
- iframe.addEventListener("load", () => {
31
- const doc = iframe.contentDocument;
32
- resetDocumentSpacing(doc);
33
- navigateTopOnLinkClick(doc);
34
- const updateHeight = () => {
35
- iframe.style.height = `${doc.body.scrollHeight}px`;
36
- };
37
- updateHeight();
38
- new ResizeObserver(updateHeight).observe(doc.body);
39
- resolve();
40
- }, { once: true });
41
- iframe.srcdoc = content;
42
- element.replaceChildren(iframe);
43
- });
44
- //# sourceMappingURL=iframe.js.map