From 627c2941e34a14ecad94bc6edb499a1f2397fa97 Mon Sep 17 00:00:00 2001 From: Daniel Adams Date: Wed, 16 Oct 2024 09:21:10 -1000 Subject: [PATCH] Remove remaining Web SDK files and references --- README.md | 1 - package.json | 1 - web/README.md | 30 ------------ web/index.html | 18 ------- web/package.json | 26 ---------- web/src/index.js | 108 ------------------------------------------ web/webpack.config.js | 16 ------- 7 files changed, 200 deletions(-) delete mode 100644 web/README.md delete mode 100644 web/index.html delete mode 100644 web/package.json delete mode 100644 web/src/index.js delete mode 100644 web/webpack.config.js diff --git a/README.md b/README.md index a8f5935..8b5d6b6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ Currently, we support the following platforms: - [babylon.js](https://github.com/zestyxyz/ads-sdk/tree/main/babylonjs) - [react-three-fiber](https://github.com/zestyxyz/ads-sdk/tree/main/r3f) - [three.js](https://github.com/zestyxyz/ads-sdk/tree/main/threejs) -- [web](https://github.com/zestyxyz/ads-sdk/tree/main/web) - [unity](https://github.com/zestyxyz/ads-sdk/tree/main/unity) - [wonderland](https://github.com/zestyxyz/ads-sdk/tree/main/wonderland) diff --git a/package.json b/package.json index 232c50f..016f096 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "r3f", "threejs", "utils", - "web", "wonderland" ] } diff --git a/web/README.md b/web/README.md deleted file mode 100644 index 8723c86..0000000 --- a/web/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# zesty-web - -This is the Web SDK for Zesty Banner integration. - -```html - - - - - - - - - -``` - -## Local dev - -```sh -yarn -yarn dev -``` - -If you've run `yarn` at the top level, you don't need to run it here again. - -## Build - -```sh -yarn build -``` diff --git a/web/index.html b/web/index.html deleted file mode 100644 index 7e68542..0000000 --- a/web/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Zesty Web - - - - - -
-

Zesty Test Website

- - - -
- - diff --git a/web/package.json b/web/package.json deleted file mode 100644 index 851aa92..0000000 --- a/web/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@zestymarket/web-sdk", - "version": "3.0.0", - "description": "Web SDK for Zesty Banner integration into an HTML page.", - "main": "dist/zesty-web-sdk.js", - "scripts": { - "test": "webpack --mode=development", - "build": "webpack --mode=production", - "dev": "webpack serve --config webpack.config.js --mode development --progress --open" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/zestymarket/zesty-sdk.git" - }, - "author": "", - "bugs": { - "url": "https://github.com/zestymarket/zesty-sdk/issues" - }, - "homepage": "https://github.com/zestymarket/zesty-sdk#readme", - "dependencies": {}, - "devDependencies": { - "webpack": "^5.73.0", - "webpack-cli": "^4.10.0", - "webpack-dev-server": "^4.9.2" - } -} diff --git a/web/src/index.js b/web/src/index.js deleted file mode 100644 index 46910ad..0000000 --- a/web/src/index.js +++ /dev/null @@ -1,108 +0,0 @@ -import { sendOnLoadMetric, sendOnClickMetric, fetchCampaignAd } from '../../utils/networking'; -import { formats, defaultFormat, defaultStyle } from '../../utils/formats'; -import { openURL } from '../../utils/helpers'; -import { version } from '../package.json'; - -console.log('Zesty SDK Version: ', version); - -class Zesty extends HTMLElement { - constructor() { - super(); - this.adUnit = ''; - this.format = defaultFormat; - this.bannerstyle = defaultStyle; - this.width = '100%'; - this.height = '100%'; - this.shadow = this.attachShadow({ mode: 'open' }); - this.beacon = true; - - this.adjustHeightandWidth = this.adjustHeightandWidth.bind(this); - } - - connectedCallback() { - this.style.cursor = 'pointer'; - - this.adUnit = this.hasAttribute('ad-unit') ? this.getAttribute('ad-unit') : this.adUnit; - this.format = this.hasAttribute('format') ? this.getAttribute('format') : this.format; - this.bannerstyle = this.hasAttribute('bannerstyle') - ? this.getAttribute('bannerstyle') - : this.bannerstyle; - this.height = this.hasAttribute('height') ? this.getAttribute('height') : this.height; - this.width = this.hasAttribute('width') ? this.getAttribute('width') : this.width; - this.beacon = this.hasAttribute('beacon') ? this.getAttribute('beacon') : this.beacon; - - this.adjustHeightandWidth(); - - async function loadBanner(adUnit, format, style, shadow, width, height, beacon) { - const activeCampaign = await fetchCampaignAd(adUnit, format, style); - - const { id, asset_url: image, cta_url: url } = activeCampaign.Ads[0]; - - const img = document.createElement('img'); - shadow.appendChild(img); - img.setAttribute('id', id); - img.style.width = width; - img.style.height = height; - img.setAttribute('crossorigin', ''); - img.setAttribute('data-url', url); - img.addEventListener('click', (e) => { - e.preventDefault(); - openURL(url); - if (beacon) { - sendOnClickMetric(adUnit, activeCampaign.CampaignId); - } - }); - - if (beacon) { - sendOnLoadMetric(adUnit, activeCampaign.CampaignId); - } - - if (image) { - img.setAttribute('src', image); - return new Promise((resolve, reject) => { - img.onload = () => resolve({ img, url }); - img.onerror = () => reject(new Error('img load error')); - }); - } else { - return { id: 'blank' }; - } - } - - loadBanner( - this.adUnit, - this.format, - this.bannerstyle, - this.shadow, - this.width, - this.height, - this.beacon - ); - } - - /** - * Adjusts height and width after setting initial values in order to scale the image correctly. - */ - adjustHeightandWidth() { - // Use regex to split height/width and its suffix. - // Will get an array of ['', num, suffix]. - const numMatch = /(\d+)/; - const height = this.height.split(numMatch); - const width = this.width.split(numMatch); - // If height was set explicitly, keep it. - // Otherwise, scale it off the width according to format or keep the default if neither were set. - this.height = this.hasAttribute('height') - ? this.height - : this.hasAttribute('width') - ? `${width[1] / formats[this.format].width}${width[2]}` - : this.height; - // If height was set explicitly, scale width off of it according to format. - // Otherwise, use explicitly set width or use default value if neither were set. - this.width = this.hasAttribute('height') - ? `${height[1] * formats[this.format].width}${height[2]}` - : this.hasAttribute('width') - ? this.width - : this.width; - } -} - -customElements.define('zesty-web', Zesty); diff --git a/web/webpack.config.js b/web/webpack.config.js deleted file mode 100644 index 04e585f..0000000 --- a/web/webpack.config.js +++ /dev/null @@ -1,16 +0,0 @@ -const path = require('path'); - -module.exports = { - entry: { - 'zesty-web-sdk': './src/index.js', - }, - output: { - filename: '[name].js', - path: path.resolve(__dirname, 'dist') - }, - devServer: { - contentBase: __dirname, - publicPath: '/dist/', - disableHostCheck: true // required for localtunnel to work (https://github.com/webpack/webpack-dev-server/issues/882) - }, -};