@surfside/ads-core-web 0.1.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _exports: any;
2
+ export = _exports;
@@ -0,0 +1,16 @@
1
+ import { type Result } from '@surfside/ads-core-client';
2
+ export declare const GetAttribute: (element: Element, attributeName: string) => Result<string>;
3
+ export declare const GetAttributeOr: (element: Element, attributeName: string, or: string) => string;
4
+ export declare const GetNumberAttribute: (element: Element, attributeName: string) => Result<number>;
5
+ export declare const GetNumberAttributeOr: (element: Element, attributeName: string, or: number) => number;
6
+ export declare class MissingAttributeError extends Error {
7
+ readonly element: Element;
8
+ readonly attributeName: string;
9
+ constructor(element: Element, attributeName: string);
10
+ }
11
+ export declare class NotANumberError extends Error {
12
+ readonly element: Element;
13
+ readonly attributeName: string;
14
+ readonly value: string;
15
+ constructor(element: Element, attributeName: string, value: string);
16
+ }
@@ -0,0 +1,2 @@
1
+ export declare const PixelTracker: (url: string) => HTMLImageElement;
2
+ export declare const ScriptTracker: (url: string) => HTMLScriptElement;
@@ -0,0 +1,2 @@
1
+ export * from './Dom';
2
+ export * from './Trackers';
@@ -0,0 +1,15 @@
1
+ import { type AsyncResult, type ILogger, type ISurfsideClientApi } from '@surfside/ads-core-client';
2
+ import { type RenderCarouselFn } from './rendering/Carousel';
3
+ import { type RenderBannerFn } from './rendering';
4
+ import { type RenderProductCardFn } from './rendering/ProductCard';
5
+ import { type RenderVideoFn } from './rendering/Video';
6
+ export * from './rendering';
7
+ export * from './helpers';
8
+ export interface ISurfsideWebApi extends ISurfsideClientApi {
9
+ renderBanner: RenderBannerFn;
10
+ renderVideo: RenderVideoFn;
11
+ renderProductCard: RenderProductCardFn;
12
+ renderCarousel: RenderCarouselFn;
13
+ }
14
+ export declare const InitSurfAdsWebInternal: (apiResAsync: AsyncResult<ISurfsideClientApi>) => AsyncResult<ISurfsideWebApi>;
15
+ export declare const InitSurfAdsWeb: (accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, logger?: ILogger) => AsyncResult<ISurfsideWebApi>;
@@ -0,0 +1,7 @@
1
+ import { type IBuiltBannerResponse, type ILogger, type Result } from '@surfside/ads-core';
2
+ export type RenderBannerFn = (builtBanner: IBuiltBannerResponse) => Result<HTMLElement>;
3
+ export declare const RenderBanner: (logger: ILogger | undefined, builtBanner: IBuiltBannerResponse) => Result<HTMLElement>;
4
+ export declare class MissingNurlError extends Error {
5
+ readonly bannerResponse: IBuiltBannerResponse;
6
+ constructor(bannerResponse: IBuiltBannerResponse);
7
+ }
@@ -0,0 +1,25 @@
1
+ import { type AsyncResult, type Callbacks, type ILogger } from '@surfside/ads-core-client';
2
+ import type { IBuiltCarousel } from '@surfside/ads-core';
3
+ import type { EvaluateProductCardTemplateFn } from '@surfside/ads-core';
4
+ export interface ILimitedCarousel {
5
+ type: 'limited';
6
+ limit: number;
7
+ }
8
+ export interface IInfiniteCarousel {
9
+ type: 'infinite';
10
+ }
11
+ export type CarouselLimits = ILimitedCarousel | IInfiniteCarousel;
12
+ export interface IRenderedCarousel {
13
+ element: HTMLElement;
14
+ init: () => AsyncResult<boolean>;
15
+ }
16
+ export type RenderCarouselFn = (carousel: IBuiltCarousel, cardMinWidth: number, carouselLimits: CarouselLimits, nextType: 'page' | 'product') => AsyncResult<IRenderedCarousel>;
17
+ export declare const RenderCarousel: (logger: ILogger | undefined, evaluateProductCardTemplate: EvaluateProductCardTemplateFn, sponsoredByEnabled: boolean, productCardStylesheet: string, carouselStylesheet: string, callbacks: Callbacks, carousel: IBuiltCarousel, cardMinWidth: number, carouselLimits: CarouselLimits, nextType: "page" | "product") => AsyncResult<IRenderedCarousel>;
18
+ export declare class MalformedCarouselError extends Error {
19
+ readonly parent: HTMLElement;
20
+ constructor(parent: HTMLElement);
21
+ }
22
+ export declare class EmptyFirstPageError extends Error {
23
+ readonly parent: HTMLElement;
24
+ constructor(parent: HTMLElement);
25
+ }
@@ -0,0 +1,13 @@
1
+ import { type Callbacks, type ILogger, type IProductInformation, type Result } from '@surfside/ads-core';
2
+ export interface IProductCallbackWrapper {
3
+ callbacks: Callbacks;
4
+ product: IProductInformation;
5
+ }
6
+ export declare const Template: (logger: ILogger | undefined, className: string, template: string, style?: string, callbacks?: IProductCallbackWrapper) => Result<HTMLElement>;
7
+ export declare const QuerySelectorResult: (element: Element, selector: string) => Result<Element>;
8
+ export declare const ReplaceWith: (parent: Element, originalSelector: string, element: Element) => Result<Element>;
9
+ export declare class MissingTemplateElementError extends Error {
10
+ readonly parent: Element;
11
+ readonly selector: string;
12
+ constructor(parent: Element, selector: string);
13
+ }
@@ -0,0 +1,8 @@
1
+ import { type Callbacks, type IBuiltProductCardResponse, type ILogger, type Result } from '@surfside/ads-core-client';
2
+ import type { EvaluateProductCardTemplateFn } from '@surfside/ads-core';
3
+ export type RenderProductCardFn = (productCard: IBuiltProductCardResponse) => Result<HTMLElement>;
4
+ export declare const RenderProductCard: (logger: ILogger | undefined, stylesheet: string, javascriptCallbacks: Callbacks, evaluateProductCardTemplate: EvaluateProductCardTemplateFn, productCard: IBuiltProductCardResponse) => Result<HTMLElement>;
5
+ export declare class MissingTrackersError extends Error {
6
+ readonly productCardResponse: IBuiltProductCardResponse;
7
+ constructor(productCardResponse: IBuiltProductCardResponse);
8
+ }
@@ -0,0 +1,16 @@
1
+ import { type IBuiltVideo, type IDevice, type IGeoContext, type ILogger, type Result } from '@surfside/ads-core-client';
2
+ export type RenderVideoFn = (builtVideo: IBuiltVideo) => Result<HTMLElement>;
3
+ export interface ITrackerState {
4
+ fired: boolean;
5
+ url?: string;
6
+ }
7
+ export interface IVideoTrackers {
8
+ start: ITrackerState;
9
+ firstQuartile: ITrackerState;
10
+ midpoint: ITrackerState;
11
+ thirdQuartile: ITrackerState;
12
+ complete: ITrackerState;
13
+ stop: ITrackerState;
14
+ impression: ITrackerState;
15
+ }
16
+ export declare const RenderVideo: (logger: ILogger | undefined, deviceInfo: IDevice | undefined, geo: IGeoContext | undefined, userAgent: string | undefined, builtVideo: IBuiltVideo) => Result<HTMLElement>;
@@ -0,0 +1,2 @@
1
+ import { type ILogger, type Result } from '@surfside/ads-core';
2
+ export declare const RenderWatermark: (logger: ILogger | undefined) => Result<HTMLElement>;
@@ -0,0 +1,6 @@
1
+ export * from './Banner';
2
+ export * from './Carousel';
3
+ export * from './Framework';
4
+ export * from './ProductCard';
5
+ export * from './Video';
6
+ export * from './Watermark';
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@surfside/ads-core-web",
3
+ "module": "./lib/esm/index.js",
4
+ "main": "./lib/cjs/index.js",
5
+ "types": "./lib/types/index.d.ts",
6
+ "version": "0.1.0",
7
+ "license": "UNLICENSED",
8
+ "files": [
9
+ "lib/",
10
+ "README.md"
11
+ ],
12
+ "type": "module",
13
+ "scripts": {
14
+ "build": "bun bun.build.ts",
15
+ "lint": "npx eslint"
16
+ },
17
+ "devDependencies": {
18
+ "@eslint/js": "^9.25.1",
19
+ "@types/bun": "latest",
20
+ "eslint": "^9.25.1",
21
+ "handlebars": "^4.7.8",
22
+ "typescript-eslint": "^8.31.0",
23
+ "@surfside/ads-core-client": "^0.1.0",
24
+ "@surfside/ads-core-mock": "^0.1.0",
25
+ "typescript": "^5.8.3"
26
+ }
27
+ }