@betarena/ad-engine 0.0.1
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/.nvmrc +1 -0
- package/README.md +47 -0
- package/dist/assets/index-B8Xhprrv.js +1 -0
- package/dist/index.html +13 -0
- package/dist/vite.svg +1 -0
- package/index.html +13 -0
- package/package.json +23 -0
- package/public/vite.svg +1 -0
- package/svelte.config.js +7 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +7 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v18.19.0
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Svelte + TS + Vite
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Svelte and TypeScript in Vite.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
|
8
|
+
|
|
9
|
+
## Need an official Svelte framework?
|
|
10
|
+
|
|
11
|
+
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
|
12
|
+
|
|
13
|
+
## Technical considerations
|
|
14
|
+
|
|
15
|
+
**Why use this over SvelteKit?**
|
|
16
|
+
|
|
17
|
+
- It brings its own routing solution which might not be preferable for some users.
|
|
18
|
+
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
|
19
|
+
|
|
20
|
+
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
|
21
|
+
|
|
22
|
+
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
|
23
|
+
|
|
24
|
+
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
|
25
|
+
|
|
26
|
+
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
|
27
|
+
|
|
28
|
+
**Why include `.vscode/extensions.json`?**
|
|
29
|
+
|
|
30
|
+
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
|
31
|
+
|
|
32
|
+
**Why enable `allowJs` in the TS template?**
|
|
33
|
+
|
|
34
|
+
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
|
|
35
|
+
|
|
36
|
+
**Why is HMR not preserving my local component state?**
|
|
37
|
+
|
|
38
|
+
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
|
39
|
+
|
|
40
|
+
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
// store.ts
|
|
44
|
+
// An extremely simple external store
|
|
45
|
+
import { writable } from 'svelte/store'
|
|
46
|
+
export default writable(0)
|
|
47
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var te=Object.defineProperty;var ne=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var S=(e,t,n)=>(ne(e,typeof t!="symbol"?t+"":t,n),n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const f of o.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function N(){}function K(e){return e()}function B(){return Object.create(null)}function W(e){e.forEach(K)}function R(e){return typeof e=="function"}function V(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function ie(e){return Object.keys(e).length===0}const re=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function C(e,t){e.appendChild(t)}function m(e,t,n){e.insertBefore(t,n||null)}function h(e){e.parentNode&&e.parentNode.removeChild(e)}function x(e){return document.createElement(e)}function j(e){return document.createTextNode(e)}function z(){return j(" ")}function oe(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function F(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function se(e){return Array.from(e.childNodes)}function G(e,t){t=""+t,e.data!==t&&(e.data=t)}let A;function T(e){A=e}function ue(){if(!A)throw new Error("Function called outside component initialization");return A}function ce(e){ue().$$.on_mount.push(e)}const E=[],k=[];let L=[];const D=[],de=Promise.resolve();let P=!1;function fe(){P||(P=!0,de.then(J))}function U(e){L.push(e)}const I=new Set;let b=0;function J(){if(b!==0)return;const e=A;do{try{for(;b<E.length;){const t=E[b];b++,T(t),ae(t.$$)}}catch(t){throw E.length=0,b=0,t}for(T(null),E.length=0,b=0;k.length;)k.pop()();for(let t=0;t<L.length;t+=1){const n=L[t];I.has(n)||(I.add(n),n())}L.length=0}while(E.length);for(;D.length;)D.pop()();P=!1,I.clear(),T(e)}function ae(e){if(e.fragment!==null){e.update(),W(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(U)}}function le(e){const t=[],n=[];L.forEach(i=>e.indexOf(i)===-1?t.push(i):n.push(i)),n.forEach(i=>i()),L=t}const M=new Set;let he;function Q(e,t){e&&e.i&&(M.delete(e),e.i(t))}function pe(e,t,n,i){if(e&&e.o){if(M.has(e))return;M.add(e),he.c.push(()=>{M.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}else i&&i()}function me(e){e&&e.c()}function X(e,t,n){const{fragment:i,after_update:r}=e.$$;i&&i.m(t,n),U(()=>{const o=e.$$.on_mount.map(K).filter(R);e.$$.on_destroy?e.$$.on_destroy.push(...o):W(o),e.$$.on_mount=[]}),r.forEach(U)}function Y(e,t){const n=e.$$;n.fragment!==null&&(le(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ge(e,t){e.$$.dirty[0]===-1&&(E.push(e),fe(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Z(e,t,n,i,r,o,f=null,g=[-1]){const l=A;T(e);const s=e.$$={fragment:null,ctx:[],props:o,update:N,not_equal:r,bound:B(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:B(),dirty:g,skip_bound:!1,root:t.target||l.$$.root};f&&f(s.root);let _=!1;if(s.ctx=n?n(e,t.props||{},(a,y,...u)=>{const p=u.length?u[0]:y;return s.ctx&&r(s.ctx[a],s.ctx[a]=p)&&(!s.skip_bound&&s.bound[a]&&s.bound[a](p),_&&ge(e,a)),y}):[],s.update(),_=!0,W(s.before_update),s.fragment=i?i(s.ctx):!1,t.target){if(t.hydrate){const a=se(t.target);s.fragment&&s.fragment.l(a),a.forEach(h)}else s.fragment&&s.fragment.c();t.intro&&Q(e.$$.fragment),X(e,t.target,t.anchor),J()}T(l)}class ee{constructor(){S(this,"$$");S(this,"$$set")}$destroy(){Y(this,1),this.$destroy=N}$on(t,n){if(!R(n))return N;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const r=i.indexOf(n);r!==-1&&i.splice(r,1)}}$set(t){this.$$set&&!ie(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const _e="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(_e);const{window:ye}=re;function we(e){var w;let t,n,i,r,o,f=((w=e[1])==null?void 0:w.country_code)+"",g,l,s,_,a,y,u,p,v;return{c(){t=x("div"),n=j("Device Type: "),i=j(e[0]),r=z(),o=x("div"),g=j(f),l=z(),s=x("div"),s.innerHTML="",_=z(),a=x("hr"),y=z(),u=x("div"),u.innerHTML="",F(s,"data-betarena-zone-id","1"),F(u,"data-betarena-zone-id","2")},m(c,d){m(c,t,d),C(t,n),C(t,i),m(c,r,d),m(c,o,d),C(o,g),m(c,l,d),m(c,s,d),m(c,_,d),m(c,a,d),m(c,y,d),m(c,u,d),p||(v=oe(ye,"resize",e[4]),p=!0)},p(c,[d]){var O;d&1&&G(i,c[0]),d&2&&f!==(f=((O=c[1])==null?void 0:O.country_code)+"")&&G(g,f)},i:N,o:N,d(c){c&&(h(t),h(r),h(o),h(l),h(s),h(_),h(a),h(y),h(u)),p=!1,v()}}}function $e(e,t,n){let{deviceWidthList:i=[768,1024]}=t,r="desktop",o=null,f,g;function l(){window.innerWidth<i[0]?n(0,r="mobile"):window.innerWidth>=i[0]&&window.innerWidth<i[1]?n(0,r="tablet"):n(0,r="desktop")}async function s(){const u=await fetch("https://get.geojs.io/v1/ip/geo.json",{method:"GET"});n(1,o=await u.json())}async function _(u){var w,c,d,O;if(!u||u.length==0)return;f=await(await fetch(`https://betarena-test-e2748dab12f5.herokuapp.com/ads?zoneIds=${u}`,{method:"GET"})).json()??[];const v=new Map(f.ads);for(const H of g){const q=(w=H.attributes.getNamedItem("data-betarena-zone-id"))==null?void 0:w.value;if(!q||!o)continue;const $=v.get(parseInt(q));!((c=$==null?void 0:$.targeting)!=null&&c.device.includes(r))||$.targeting.country.exclude.length>0&&$.targeting.country.exclude.includes(((d=o.country_code)==null?void 0:d.toUpperCase())??"EN")||$.targeting.country.include.length>0&&!$.targeting.country.include.includes(((O=o.country_code)==null?void 0:O.toUpperCase())??"EN")||(H.innerHTML=$.name)}}async function a(){var p;l(),await s(),g=document.querySelectorAll("[data-betarena-zone-id]");const u=[];for(const v of g){const w=(p=v.attributes.getNamedItem("data-betarena-zone-id"))==null?void 0:p.value;w&&u.push(w)}_(u)}ce(async()=>{await a()});const y=()=>{l()};return e.$$set=u=>{"deviceWidthList"in u&&n(3,i=u.deviceWidthList)},[r,o,l,i,y]}class ve extends ee{constructor(t){super(),Z(this,t,$e,we,V,{deviceWidthList:3})}}function be(e){let t,n,i;return n=new ve({}),{c(){t=x("main"),me(n.$$.fragment)},m(r,o){m(r,t,o),X(n,t,null),i=!0},p:N,i(r){i||(Q(n.$$.fragment,r),i=!0)},o(r){pe(n.$$.fragment,r),i=!1},d(r){r&&h(t),Y(n)}}}class xe extends ee{constructor(t){super(),Z(this,t,null,be,V,{})}}new xe({target:document});
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + Svelte + TS</title>
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-B8Xhprrv.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + Svelte + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@betarena/ad-engine",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Betarena Ad-Engine Component Logic",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
12
|
+
"npm:|:link": "npm link"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
|
16
|
+
"@tsconfig/svelte": "^5.0.2",
|
|
17
|
+
"svelte": "^4.2.12",
|
|
18
|
+
"svelte-check": "^3.6.6",
|
|
19
|
+
"tslib": "^2.6.2",
|
|
20
|
+
"typescript": "^5.2.2",
|
|
21
|
+
"vite": "^5.1.6"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/svelte.config.js
ADDED