@highfivve/ad-tag 5.11.9 → 5.11.10

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.
@@ -0,0 +1,34 @@
1
+ import { mkInitStep } from 'ad-tag/ads/adPipeline';
2
+ const name = 'styles loader';
3
+ export const createStylesLoader = () => {
4
+ let stylesConfig = null;
5
+ const config__ = () => stylesConfig;
6
+ const configure__ = (moduleConfig) => {
7
+ if (moduleConfig?.styles?.enabled) {
8
+ stylesConfig = moduleConfig.styles;
9
+ }
10
+ };
11
+ const loadStylesheet = (context, config) => {
12
+ const link = context.window__.document.createElement('link');
13
+ link.rel = 'stylesheet';
14
+ link.href = config.href;
15
+ link.addEventListener('error', () => context.logger__.error(name, `failed to load stylesheet ${config.href}`));
16
+ context.window__.document.head.prepend(link);
17
+ return Promise.resolve();
18
+ };
19
+ const initSteps__ = () => {
20
+ const config = stylesConfig;
21
+ return config ? [mkInitStep('styles-init', ctx => loadStylesheet(ctx, config))] : [];
22
+ };
23
+ return {
24
+ name,
25
+ configKey: 'styles',
26
+ description: "injects the publisher's stylesheet as a base layer in <head>",
27
+ moduleType: 'creatives',
28
+ config__,
29
+ configure__,
30
+ initSteps__,
31
+ configureSteps__: () => [],
32
+ prepareRequestAdsSteps__: () => []
33
+ };
34
+ };
@@ -0,0 +1,2 @@
1
+ import { createStylesLoader } from '../ads/modules/styles';
2
+ window.moli.registerModule(createStylesLoader());
@@ -321,6 +321,8 @@ const MoliAnalyticsModule = ({ config }) => (React.createElement(React.Fragment,
321
321
  "delay: ",
322
322
  config.batchDelay ?? 100,
323
323
  "ms"))));
324
+ const StylesModule = ({ config }) => (React.createElement(Row, { label: "Stylesheet" },
325
+ React.createElement(Tag, null, config.href)));
324
326
  const GenericModule = ({ config, subEntry }) => (React.createElement(React.Fragment, null, Object.entries(config)
325
327
  .filter(([key]) => key !== 'enabled')
326
328
  .map(([key, value]) => (React.createElement(TagContainer, { key: key, subEntry: subEntry },
@@ -338,6 +340,7 @@ const moduleComponents = {
338
340
  identitylink: IdentityLinkModule,
339
341
  pubstack: PubstackModule,
340
342
  skin: SkinModule,
343
+ styles: StylesModule,
341
344
  stickyHeaderAd: StickyHeaderAdModule,
342
345
  utiq: UtiqModule,
343
346
  prebidFirstPartyData: PrebidFirstPartyDataModule,
@@ -1,3 +1,3 @@
1
1
  export const packageJson = {
2
- version: '5.11.9'
2
+ version: '5.11.10'
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highfivve/ad-tag",
3
- "version": "5.11.9",
3
+ "version": "5.11.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "An ad tag implementation called moli",
6
6
  "main": "./lib/index.js",