@surfside/ads 2.0.0 → 3.6.0-0652b02f.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.
Files changed (88) hide show
  1. package/README.md +15 -69
  2. package/lib/cjs/BuildInfo.js +9 -0
  3. package/lib/cjs/BuildInfo.js.map +1 -0
  4. package/lib/cjs/Constants.js +5 -0
  5. package/lib/cjs/Constants.js.map +1 -0
  6. package/lib/cjs/Init.js +130 -0
  7. package/lib/cjs/Init.js.map +1 -0
  8. package/lib/cjs/components/Banner.js +136 -0
  9. package/lib/cjs/components/Banner.js.map +1 -0
  10. package/lib/cjs/components/Card.js +170 -0
  11. package/lib/cjs/components/Card.js.map +1 -0
  12. package/lib/cjs/components/Carousel.js +249 -0
  13. package/lib/cjs/components/Carousel.js.map +1 -0
  14. package/lib/cjs/components/Creative.js +285 -0
  15. package/lib/cjs/components/Creative.js.map +1 -0
  16. package/lib/cjs/components/Dynamic.js +310 -0
  17. package/lib/cjs/components/Dynamic.js.map +1 -0
  18. package/lib/cjs/components/SimpleCreative.js +81 -0
  19. package/lib/cjs/components/SimpleCreative.js.map +1 -0
  20. package/lib/cjs/components/Video.js +144 -0
  21. package/lib/cjs/components/Video.js.map +1 -0
  22. package/lib/cjs/demo/test.js +7 -0
  23. package/lib/cjs/demo/test.js.map +1 -0
  24. package/lib/cjs/index.module.js +107 -0
  25. package/lib/cjs/index.module.js.map +1 -0
  26. package/lib/cjs/index.script.js +102 -0
  27. package/lib/cjs/index.script.js.map +1 -0
  28. package/lib/cjs/index.script.mock.js +154 -0
  29. package/lib/cjs/index.script.mock.js.map +1 -0
  30. package/lib/cjs/service/Init.js +3 -0
  31. package/lib/cjs/service/Init.js.map +1 -0
  32. package/lib/cjs/util/Attributes.js +93 -0
  33. package/lib/cjs/util/Attributes.js.map +1 -0
  34. package/lib/cjs/util/Types.js +3 -0
  35. package/lib/cjs/util/Types.js.map +1 -0
  36. package/lib/esm/BuildInfo.js +6 -0
  37. package/lib/esm/BuildInfo.js.map +1 -0
  38. package/lib/esm/Constants.js +2 -0
  39. package/lib/esm/Constants.js.map +1 -0
  40. package/lib/esm/Init.js +92 -0
  41. package/lib/esm/Init.js.map +1 -0
  42. package/lib/esm/components/Banner.js +132 -0
  43. package/lib/esm/components/Banner.js.map +1 -0
  44. package/lib/esm/components/Card.js +166 -0
  45. package/lib/esm/components/Card.js.map +1 -0
  46. package/lib/esm/components/Carousel.js +245 -0
  47. package/lib/esm/components/Carousel.js.map +1 -0
  48. package/lib/esm/components/Creative.js +280 -0
  49. package/lib/esm/components/Creative.js.map +1 -0
  50. package/lib/esm/components/Dynamic.js +306 -0
  51. package/lib/esm/components/Dynamic.js.map +1 -0
  52. package/lib/esm/components/SimpleCreative.js +75 -0
  53. package/lib/esm/components/SimpleCreative.js.map +1 -0
  54. package/lib/esm/components/Video.js +140 -0
  55. package/lib/esm/components/Video.js.map +1 -0
  56. package/lib/esm/demo/test.js +5 -0
  57. package/lib/esm/demo/test.js.map +1 -0
  58. package/lib/esm/index.module.js +67 -0
  59. package/lib/esm/index.module.js.map +1 -0
  60. package/lib/esm/index.script.js +100 -0
  61. package/lib/esm/index.script.js.map +1 -0
  62. package/lib/esm/index.script.mock.js +152 -0
  63. package/lib/esm/index.script.mock.js.map +1 -0
  64. package/lib/esm/service/Init.js +2 -0
  65. package/lib/esm/service/Init.js.map +1 -0
  66. package/lib/esm/util/Attributes.js +81 -0
  67. package/lib/esm/util/Attributes.js.map +1 -0
  68. package/lib/esm/util/Types.js +2 -0
  69. package/lib/esm/util/Types.js.map +1 -0
  70. package/lib/types/BuildInfo.d.ts +5 -0
  71. package/lib/types/Constants.d.ts +1 -0
  72. package/lib/types/Init.d.ts +31 -0
  73. package/lib/types/components/Banner.d.ts +17 -0
  74. package/lib/types/components/Card.d.ts +18 -0
  75. package/lib/types/components/Carousel.d.ts +32 -0
  76. package/lib/types/components/Creative.d.ts +84 -0
  77. package/lib/types/components/Dynamic.d.ts +24 -0
  78. package/lib/types/components/SimpleCreative.d.ts +20 -0
  79. package/lib/types/components/Video.d.ts +23 -0
  80. package/lib/types/demo/test.d.ts +1 -0
  81. package/lib/types/index.module.d.ts +12 -0
  82. package/lib/types/index.script.d.ts +1 -0
  83. package/lib/types/index.script.mock.d.ts +1 -0
  84. package/lib/types/service/Init.d.ts +1 -0
  85. package/lib/types/util/Attributes.d.ts +24 -0
  86. package/lib/types/util/Types.d.ts +3 -0
  87. package/package.json +42 -73
  88. package/lib/index.js +0 -2
@@ -0,0 +1,81 @@
1
+ import { Err, Ok } from '@surfside/ads-core';
2
+ export const ReadAttribute = (element, attr) => {
3
+ const value = element.getAttribute(attr);
4
+ if (value === null) {
5
+ return Err(new AttributeNotFoundError(element, attr));
6
+ }
7
+ return Ok(value);
8
+ };
9
+ export const ReadNumberAttribute = (element, attr) => {
10
+ const strValue = ReadAttribute(element, attr);
11
+ if (!strValue.ok) {
12
+ return strValue;
13
+ }
14
+ const value = Number(strValue.value);
15
+ if (Number.isNaN(value)) {
16
+ return Err(new AttributeNotANumberError(element, attr));
17
+ }
18
+ return Ok(value);
19
+ };
20
+ export const ReadIntAttribute = (element, attr) => {
21
+ const numValue = ReadNumberAttribute(element, attr);
22
+ if (!numValue.ok) {
23
+ return numValue;
24
+ }
25
+ if (!Number.isInteger(numValue.value)) {
26
+ return Err(new AttributeNotIntError(element, attr));
27
+ }
28
+ return numValue;
29
+ };
30
+ export const ReadBoolAttribute = (element, attr) => {
31
+ const strValue = ReadAttribute(element, attr);
32
+ if (!strValue.ok) {
33
+ return strValue;
34
+ }
35
+ const value = strValue.value.toLowerCase();
36
+ switch (value) {
37
+ case 'true': {
38
+ return Ok(true);
39
+ }
40
+ case 'false': {
41
+ return Ok(false);
42
+ }
43
+ default: {
44
+ return Err(new AttributeNotBoolError(element, attr));
45
+ }
46
+ }
47
+ };
48
+ export class AttributeNotFoundError extends Error {
49
+ element;
50
+ attribute;
51
+ constructor(element, attribute) {
52
+ super(`Attribute '${attribute}' was not found on element`);
53
+ this.element = element;
54
+ this.attribute = attribute;
55
+ }
56
+ }
57
+ export class AttributeWrongTypeError extends Error {
58
+ element;
59
+ attribute;
60
+ constructor(element, attribute, message) {
61
+ super(message);
62
+ this.element = element;
63
+ this.attribute = attribute;
64
+ }
65
+ }
66
+ export class AttributeNotANumberError extends AttributeWrongTypeError {
67
+ constructor(element, attribute) {
68
+ super(element, attribute, `Attribute '${attribute}' is not a number`);
69
+ }
70
+ }
71
+ export class AttributeNotBoolError extends AttributeWrongTypeError {
72
+ constructor(element, attribute) {
73
+ super(element, attribute, `Attribute '${attribute}' is not a boolean`);
74
+ }
75
+ }
76
+ export class AttributeNotIntError extends AttributeWrongTypeError {
77
+ constructor(element, attribute) {
78
+ super(element, attribute, `Attribute '${attribute}' is not an integer`);
79
+ }
80
+ }
81
+ //# sourceMappingURL=Attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attributes.js","sourceRoot":"../@surfside-ads/","sources":["util/Attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,oBAAoB,CAAC;AAE1D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,IAAY,EAAkB,EAAE;IAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,IAAI,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAE,IAAY,EAAkB,EAAE;IAClF,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf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names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare const VersionInfo: {
2
+ buildBranch: string;
3
+ buildHash: string;
4
+ buildVer: string;
5
+ };
@@ -0,0 +1 @@
1
+ export declare const DefaultMinCardWidth = 300;
@@ -0,0 +1,31 @@
1
+ import { type ISurfAdsWebConfigurationOverrides, type ISurfAdsWebDependencies } from '@surfside/ads-core-web';
2
+ import { SurfsideBanner } from './components/Banner';
3
+ import { SurfsideVideo } from './components/Video';
4
+ import { SurfsideCarousel } from './components/Carousel';
5
+ import { SurfsideProductCard } from './components/Card';
6
+ import { SurfsideDynamicZone } from './components/Dynamic';
7
+ import { type ILogger, type Result } from '@surfside/ads-core';
8
+ export type ISurfAdsConfiguration = {
9
+ logger?: ILogger;
10
+ telemetry?: boolean;
11
+ getUserId?: (logger?: ILogger) => Promise<string | undefined>;
12
+ overrides?: {
13
+ services?: Partial<ISurfAdsWebConfigurationOverrides>;
14
+ dependencies?: Partial<ISurfAdsWebDependencies>;
15
+ };
16
+ } & Partial<ISurfAdsWebConfigurationOverrides>;
17
+ export interface ISurfsideAdsApi {
18
+ bannerComponent: typeof SurfsideBanner;
19
+ videoComponent: typeof SurfsideVideo;
20
+ carouselComponent: typeof SurfsideCarousel;
21
+ productCardComponent: typeof SurfsideProductCard;
22
+ dynamicZoneComponent: typeof SurfsideDynamicZone;
23
+ }
24
+ /** Injects dependencies into the advertising web components and passes them an initializer service.
25
+ * Be warned! This function has no side effects, but it returns stateful classes. The web components
26
+ * call their own initialization functions lazily with side effects. Once you begin
27
+ * using Surfside Ads Web components, you have moved out of functional programming land and into OOP
28
+ * land. State for Surfside ads web components is managed within the web component classes.
29
+ */
30
+ export declare const CreateSurfAds: (config?: ISurfAdsConfiguration) => Result<ISurfsideAdsApi>;
31
+ export declare const LoadSurfAds: (config?: ISurfAdsConfiguration) => Result<ISurfsideAdsApi>;
@@ -0,0 +1,17 @@
1
+ import { type ILogger } from '@surfside/ads-core';
2
+ import { SimpleCreativeComponent, type CompletedSimpleCreativeAttributes } from './SimpleCreative';
3
+ import { type InitApi } from './Creative';
4
+ import { type GetUserIdFn } from '@surfside/ads-core-web';
5
+ export declare class SurfsideBanner extends SimpleCreativeComponent {
6
+ private _cancellationToken;
7
+ private _bounce;
8
+ static get observedAttributes(): string[];
9
+ constructor(initApi: InitApi, getUserId: GetUserIdFn, logger?: ILogger);
10
+ protected getComponentName(): string;
11
+ attributeChangedCallback(this: this, name: string, oldValue: string | null, newValue: string | null): Promise<void>;
12
+ connectedCallback(): Promise<void>;
13
+ adoptedCallback(): void;
14
+ disconnectedCallback(): void;
15
+ connectedMoveCallback(): void;
16
+ render(this: this & CompletedSimpleCreativeAttributes): Promise<void>;
17
+ }
@@ -0,0 +1,18 @@
1
+ import { type RecommenderType } from '@surfside/ads-core';
2
+ import { type CompletedBaseAttributes, CreativeComponent } from './Creative';
3
+ export type CompletedCardAttributes = CompletedBaseAttributes & {
4
+ strategy: string;
5
+ recommend: string;
6
+ };
7
+ export declare class SurfsideProductCard extends CreativeComponent {
8
+ private _cancellationToken;
9
+ protected recommend: RecommenderType;
10
+ protected strategy: string;
11
+ private _bounce;
12
+ static get observedAttributes(): string[];
13
+ protected getComponentName(): string;
14
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): Promise<void>;
15
+ connectedCallback(): Promise<void>;
16
+ disconnectedCallback(): void;
17
+ render(this: this & CompletedCardAttributes): Promise<void>;
18
+ }
@@ -0,0 +1,32 @@
1
+ import { type ILogger, type RecommenderType } from '@surfside/ads-core';
2
+ import { type CompletedBaseAttributes, CreativeComponent, type InitApi } from './Creative';
3
+ import { type GetUserIdFn } from '@surfside/ads-core-web';
4
+ export declare const NextType: {
5
+ readonly Product: "product";
6
+ readonly Page: "page";
7
+ };
8
+ export type CompletedCarouselAttributes = CompletedBaseAttributes & {
9
+ maxItems: number | undefined;
10
+ cardMinWidth: number;
11
+ cardMaxWidth: number | undefined;
12
+ strategy: string;
13
+ recommend: string;
14
+ nextType: string;
15
+ };
16
+ export declare class SurfsideCarousel extends CreativeComponent {
17
+ private _cancellationToken;
18
+ private _renderDebounce?;
19
+ protected maxItems?: number | null;
20
+ protected cardMinWidth: number;
21
+ protected cardMaxWidth?: number | null;
22
+ protected strategy: string;
23
+ protected recommend: RecommenderType;
24
+ protected nextType: 'page' | 'product';
25
+ static get observedAttributes(): string[];
26
+ constructor(initApi: InitApi, getUserId: GetUserIdFn, logger?: ILogger);
27
+ protected getComponentName(): string;
28
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): Promise<void>;
29
+ connectedCallback(): Promise<void>;
30
+ disconnectedCallback(): void;
31
+ render(this: this & CompletedCarouselAttributes): Promise<void>;
32
+ }
@@ -0,0 +1,84 @@
1
+ import { type AsyncResult, type ILogger, type IContextLogger } from '@surfside/ads-core';
2
+ import { type GetUserIdFn, type ISurfsideWebApi } from '@surfside/ads-core-web';
3
+ export type CompletedBaseAttributes = {
4
+ accountId: string;
5
+ siteId: string;
6
+ locationId: string;
7
+ channelId: string;
8
+ zoneId: string;
9
+ keywords: string[];
10
+ api: ISurfsideWebApi;
11
+ };
12
+ export type BaseAttributeNames = 'account-id' | 'site-id' | 'location-id' | 'channel-id' | 'zone-id' | 'keywords' | 'category';
13
+ export type InitApi = (accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, url: string) => AsyncResult<ISurfsideWebApi>;
14
+ export declare const ProductFeedStrategy: {
15
+ readonly Sponsored: "sponsored";
16
+ readonly Hybrid: "hybrid";
17
+ readonly Recommended: "recommended";
18
+ };
19
+ export declare const RecommenderTypeInputs: {
20
+ TopProducts: string;
21
+ ForYou: string;
22
+ BuyAgain: string;
23
+ PastPurchases: string;
24
+ };
25
+ export declare const AttributeValOrThrow: (element: Element, attribute: string, value: string | null) => string;
26
+ export declare const DEBOUNCE_THRESHOLD = 10;
27
+ export declare abstract class CreativeComponent extends HTMLElement {
28
+ private _initApi;
29
+ private _getUserId;
30
+ protected accountId: string | undefined;
31
+ protected siteId: string | undefined;
32
+ protected locationId: string | undefined;
33
+ protected channelId: string | undefined;
34
+ protected zoneId: string | undefined;
35
+ protected category: string[];
36
+ protected keywords: string[];
37
+ protected shadow: ShadowRoot;
38
+ protected api?: ISurfsideWebApi;
39
+ protected log?: IContextLogger;
40
+ protected totem: string | undefined;
41
+ private _stopTimer?;
42
+ protected restartEndToEndTimer: () => void;
43
+ private _instanceId;
44
+ protected get instanceId(): string;
45
+ private readonly _monkeyHistoryReplaceCallback;
46
+ private _reauctionTimer;
47
+ private _reauctionCallback;
48
+ private _reauctionRemainingMs;
49
+ private _reauctionStartedAt;
50
+ private _windowBlurred;
51
+ private readonly _blurCallback;
52
+ private readonly _focusCallback;
53
+ private readonly _visibilityChangeCallback;
54
+ constructor(_initApi: InitApi, _getUserId: GetUserIdFn, logger?: ILogger);
55
+ connectedCallback(): void;
56
+ protected abstract getComponentName(): string;
57
+ protected static get observedBaseAttributes(): string[];
58
+ protected getBaseAttributeValues(): {
59
+ accountId: string | undefined;
60
+ siteId: string | undefined;
61
+ channelId: string | undefined;
62
+ locationId: string | undefined;
63
+ zoneId: string | undefined;
64
+ category: string[];
65
+ keywords: string[];
66
+ };
67
+ protected attributesLoaded(): boolean;
68
+ protected lazyLoadApi(): Promise<void>;
69
+ protected baseAttributeChangedCallback(key: BaseAttributeNames, oldValue: string | null, newValue: string | null, logger?: IContextLogger): Promise<void>;
70
+ disconnectedCallback(): void;
71
+ private reauctionPaused;
72
+ /**
73
+ * Schedules `callback` to run after `intervalMs`, replacing any pending re-auction.
74
+ * The countdown is paused while the window is blurred or the document is hidden, and
75
+ * resumes with the remaining time once the page regains focus.
76
+ */
77
+ protected scheduleReauction(callback: () => void, intervalMs: number): void;
78
+ protected clearReauction(): void;
79
+ private startReauctionTimer;
80
+ private pauseReauction;
81
+ private resumeReauction;
82
+ protected initApi(): Promise<void>;
83
+ protected readBaseAttributes(): asserts this is this & CompletedBaseAttributes;
84
+ }
@@ -0,0 +1,24 @@
1
+ import { type IDynamicZoneRequest, type RecommenderType } from '@surfside/ads-core';
2
+ import { type CompletedBaseAttributes, CreativeComponent } from './Creative';
3
+ export type CompletedDynamicAttributes = CompletedBaseAttributes & {
4
+ maxItems: number | undefined;
5
+ cardMinWidth?: number;
6
+ strategy?: string;
7
+ recommend?: string;
8
+ nextType?: string;
9
+ };
10
+ export declare class SurfsideDynamicZone extends CreativeComponent {
11
+ private _cancellationToken;
12
+ protected maxItems?: number;
13
+ protected cardMinWidth?: number;
14
+ protected strategy?: string;
15
+ protected recommend?: RecommenderType;
16
+ protected nextType?: 'page' | 'product';
17
+ private _bounce;
18
+ protected getComponentName(): string;
19
+ static get observedAttributes(): string[];
20
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): Promise<void>;
21
+ disconnectedCallback(): void;
22
+ render(this: this & CompletedDynamicAttributes): Promise<void>;
23
+ requestAndRender(this: this & CompletedDynamicAttributes, dynamicZoneRequest: IDynamicZoneRequest): Promise<void>;
24
+ }
@@ -0,0 +1,20 @@
1
+ import { type BaseAttributeNames, CreativeComponent, type InitApi, type CompletedBaseAttributes } from './Creative';
2
+ import type { GetUserIdFn } from '@surfside/ads-core-web';
3
+ import { type IContextLogger, type ILogger } from '@surfside/ads-core';
4
+ export type CompletedSimpleCreativeAttributes = CompletedBaseAttributes & {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export type SimpleCreativeAttributeNames = BaseAttributeNames | 'width' | 'height';
9
+ export declare const IntValOrThrow: (element: Element, attribute: string, value: string | null) => number;
10
+ export declare const IntValOr: <T>(element: Element, attribute: string, value: string | null, or: T) => number | T;
11
+ export declare abstract class SimpleCreativeComponent extends CreativeComponent {
12
+ protected width?: number | null;
13
+ protected height?: number | null;
14
+ constructor(initApi: InitApi, getUserId: GetUserIdFn, logger?: ILogger);
15
+ protected attributesLoaded(): boolean;
16
+ protected static get observedSimpleAttributes(): string[];
17
+ protected handleSimpleAttributeChange(name: string, oldValue: string | null, newValue: string | null, logger?: IContextLogger): Promise<void>;
18
+ simpleAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null, logger?: IContextLogger): Promise<void>;
19
+ readSimpleAttributes(): asserts this is this & CompletedSimpleCreativeAttributes;
20
+ }
@@ -0,0 +1,23 @@
1
+ import { type ILogger } from '@surfside/ads-core';
2
+ import { SimpleCreativeComponent, type CompletedSimpleCreativeAttributes } from './SimpleCreative';
3
+ import { type InitApi } from './Creative';
4
+ import { type GetUserIdFn } from '@surfside/ads-core-web';
5
+ export type CompletedVideoAttributes = CompletedSimpleCreativeAttributes & {
6
+ minDuration: number;
7
+ maxDuration: number;
8
+ };
9
+ export declare class SurfsideVideo extends SimpleCreativeComponent {
10
+ private _cancellationToken;
11
+ protected minDuration?: number | null;
12
+ protected maxDuration?: number | null;
13
+ private _bounce;
14
+ static get observedAttributes(): string[];
15
+ constructor(initApi: InitApi, getUserId: GetUserIdFn, logger?: ILogger);
16
+ protected getComponentName(): string;
17
+ protected attributesLoaded(): boolean;
18
+ attributeChangedCallback(this: this, name: string, oldValue: string | null, newValue: string | null): Promise<void>;
19
+ protected readVideoAttributes(): asserts this is this & CompletedVideoAttributes;
20
+ connectedCallback(): Promise<void>;
21
+ disconnectedCallback(): void;
22
+ render(this: this & CompletedVideoAttributes): Promise<void>;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type AsyncResult, type ILogger } from '@surfside/ads-core';
2
+ import { type ISurfsideClientApi } from '@surfside/ads-core-client';
3
+ export * from './Init';
4
+ export type Initializer = (accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, logger?: ILogger) => AsyncResult<ISurfsideClientApi>;
5
+ export declare const InitSurfAdsWebComponents: (initializer?: Initializer) => void;
6
+ export declare const SurfsideAdsVersionTable: {
7
+ [x: string]: {
8
+ buildBranch: string;
9
+ buildHash: string;
10
+ buildVer: string;
11
+ };
12
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { type Result } from '@surfside/ads-core';
2
+ export declare const ReadAttribute: (element: Element, attr: string) => Result<string>;
3
+ export declare const ReadNumberAttribute: (element: Element, attr: string) => Result<number>;
4
+ export declare const ReadIntAttribute: (element: Element, attr: string) => Result<number>;
5
+ export declare const ReadBoolAttribute: (element: Element, attr: string) => Result<boolean>;
6
+ export declare class AttributeNotFoundError extends Error {
7
+ element: Element;
8
+ attribute: string;
9
+ constructor(element: Element, attribute: string);
10
+ }
11
+ export declare abstract class AttributeWrongTypeError extends Error {
12
+ element: Element;
13
+ attribute: string;
14
+ constructor(element: Element, attribute: string, message: string);
15
+ }
16
+ export declare class AttributeNotANumberError extends AttributeWrongTypeError {
17
+ constructor(element: Element, attribute: string);
18
+ }
19
+ export declare class AttributeNotBoolError extends AttributeWrongTypeError {
20
+ constructor(element: Element, attribute: string);
21
+ }
22
+ export declare class AttributeNotIntError extends AttributeWrongTypeError {
23
+ constructor(element: Element, attribute: string);
24
+ }
@@ -0,0 +1,3 @@
1
+ export type NoneNullable<T> = {
2
+ [K in keyof T]: NonNullable<T[K]>;
3
+ };
package/package.json CHANGED
@@ -1,73 +1,42 @@
1
- {
2
- "name": "@surfside/ads",
3
- "version": "2.0.0",
4
- "description": "Client code for surfside ads",
5
- "files": ["lib/index.js"],
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
8
- "type": "module",
9
- "scripts": {
10
- "lint": "npx eslint -c ./.eslintrc.json src/**/*.ts",
11
- "build:mock": "npx cross-env NODE_ENV=development ENVIRONMENT=MOCK TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack --mode=development --config webpack.config.ts",
12
- "build:local": "npx cross-env NODE_ENV=development ENVIRONMENT=LOCAL TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack --mode=development --config webpack.config.ts",
13
- "build:staging": "npx cross-env NODE_ENV=development ENVIRONMENT=STAGING TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack --mode=development --config webpack.config.ts",
14
- "build:prod": "npx cross-env NODE_ENV=production cross-env ENVIRONMENT=PROD TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack --mode=production --node-env=production --config webpack.config.ts",
15
- "watch": "webpack --watch",
16
- "serve": "npx cross-env NODE_ENV=development ENVIRONMENT=MOCK TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack serve --mode=development --config webpack.config.ts",
17
- "serve:local": "npx cross-env NODE_ENV=development ENVIRONMENT=LOCAL TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack serve --mode=development --config webpack.config.ts",
18
- "serve:staging": "npx cross-env NODE_ENV=development ENVIRONMENT=STAGING TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack serve --mode=development --config webpack.config.ts",
19
- "serve:prod": "npx cross-env NODE_ENV=production ENVIRONMENT=PROD LOG_LEVEL=DEBUG TS_NODE_PROJECT=./tsconfig.webpack.json NODE_OPTIONS='--import=tsx' webpack serve --mode=production --config webpack.config.ts",
20
- "docs": "npx typedoc --out docs --entryPointStrategy expand ./src",
21
- "playwright:install-deps": "npx playwright install-deps",
22
- "playwright:install": "npx playwright install",
23
- "pretest": "npx npm-run-all playwright:install-deps playwright:install",
24
- "test": "npx playwright test",
25
- "test:ui": "npx playwright test --ui"
26
- },
27
- "author": "Collin Oswalt, Ranveer Dhaliwal, Alec Below, Michael Blanche, Elsa Chen",
28
- "license": "UNLICENSED",
29
- "devDependencies": {
30
- "@fluentui/web-components": "^2.6.1",
31
- "@playwright/test": "^1.49.1",
32
- "@stylistic/eslint-plugin-ts": "^1.5.4",
33
- "@surfside/ads-core": "^1.0.0",
34
- "@types/handlebars": "^4.1.0",
35
- "@types/node": "^20.12.13",
36
- "@typescript-eslint/eslint-plugin": "^6.20.0",
37
- "@webpack-cli/generators": "^3.0.7",
38
- "copy-webpack-plugin": "^12.0.2",
39
- "cross-env": "^7.0.3",
40
- "css-loader": "^7.1.2",
41
- "eslint": "^8.56.0",
42
- "eslint-config-standard-with-typescript": "^43.0.1",
43
- "eslint-plugin-import": "^2.29.1",
44
- "eslint-plugin-n": "^16.6.2",
45
- "eslint-plugin-promise": "^6.1.1",
46
- "famfamfam-silk": "^1.0.0",
47
- "git-rev-sync": "^3.0.2",
48
- "handlebars-loader": "^1.7.3",
49
- "html-loader": "^5.0.0",
50
- "html-webpack-plugin": "^5.6.0",
51
- "lerna": "^8.1.8",
52
- "monaco-editor": "^0.50.0",
53
- "npm-run-all": "^4.1.5",
54
- "raw-loader": "^4.0.2",
55
- "sass": "^1.79.4",
56
- "sass-loader": "^16.0.2",
57
- "style-loader": "^4.0.0",
58
- "ts-loader": "^9.5.1",
59
- "ts-node": "^10.9.2",
60
- "tsconfig-paths-webpack-plugin": "^4.1.0",
61
- "tsx": "^4.19.1",
62
- "typedoc": "^0.25.13",
63
- "typescript": "^5.3.3",
64
- "webpack": "^5.94.0",
65
- "webpack-bundle-analyzer": "^4.10.2",
66
- "webpack-cli": "^5.1.4",
67
- "webpack-dev-server": "^5.1.0",
68
- "yargs": "^17.7.2"
69
- },
70
- "dependencies": {
71
- "handlebars": "^4.7.8"
72
- }
73
- }
1
+ {
2
+ "name": "@surfside/ads",
3
+ "version": "3.6.0-0652b02f.0",
4
+ "module": "./lib/esm/index.module.js",
5
+ "main": "./lib/cjs/index.module.js",
6
+ "types": "./lib/types/index.module.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./lib/esm/index.module.js",
10
+ "require": "./lib/cjs/index.module.js",
11
+ "types": "./lib/types/index.module.d.ts"
12
+ }
13
+ },
14
+ "license": "UNLICENSED",
15
+ "type": "module",
16
+ "files": [
17
+ "lib/",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "bun x npm-run-all --parallel \"types\" \"esm\" \"cjs\" && bun run bun.build.ts",
22
+ "build:debug": "bun ./debug.build.ts",
23
+ "types": "tsc -p ./tsconfig.types.json",
24
+ "esm": "tsc -p ./tsconfig.esm.json",
25
+ "cjs": "tsc -p tsconfig.cjs.json",
26
+ "serve": "bun ./tests/tools/server",
27
+ "serve-dist": "npx serve dist --listen 3001 --cors",
28
+ "lint": "npx eslint src"
29
+ },
30
+ "devDependencies": {
31
+ "@playwright/test": "^1.60.0",
32
+ "@types/bun": "latest"
33
+ },
34
+ "peerDependencies": {
35
+ "typescript": "^5"
36
+ },
37
+ "dependencies": {
38
+ "@surfside/ads-core": "2.6.0-0652b02f.0",
39
+ "@surfside/ads-core-mock": "0.6.0-0652b02f.0",
40
+ "@surfside/ads-core-web": "0.6.0-0652b02f.0"
41
+ }
42
+ }