@vtex/ads-stories 0.0.0-bootstrap.0 → 0.1.0-test.040e2b9

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @vtex/ads-stories
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - First release of `@vtex/ads-stories`: the `<vtex-ads-story>` web component (placeholder), with ESM and CommonJS builds and type declarations.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
1
  # @vtex/ads-stories
2
2
 
3
- Placeholder publish reserving the package name.
3
+ VTEX Ads Stories web component. Framework-agnostic: works on any HTML5 page,
4
+ including VTEX IO, FastStore and non-VTEX storefronts.
5
+
6
+ > Work in progress. Currently renders a placeholder.
7
+
8
+ ## npm
9
+
10
+ ```bash
11
+ npm install @vtex/ads-stories
12
+ ```
13
+
14
+ Register the element once, on the client:
15
+
16
+ ```javascript
17
+ import { defineVtexAdsStories } from "@vtex/ads-stories";
18
+
19
+ defineVtexAdsStories();
20
+ ```
21
+
22
+ ```html
23
+ <vtex-ads-story name="VTEX Ads"></vtex-ads-story>
24
+ ```
25
+
26
+ Importing the package has no side effects: nothing is registered until
27
+ `defineVtexAdsStories()` is called. It can be imported during server-side
28
+ rendering, where `defineVtexAdsStories()` does nothing. Both ESM (`import`) and
29
+ CommonJS (`require`) builds are published, with type declarations.
30
+
31
+ ## CDN
32
+
33
+ WIP: To be defined
34
+
35
+ ## Customization
36
+
37
+ ```css
38
+ vtex-ads-story {
39
+ --vtex-ads-story-font-family: "Inter", sans-serif;
40
+ --vtex-ads-story-color-text: #1f1f1f;
41
+ }
42
+ ```
43
+
44
+ ## Development
45
+
46
+ Run from the repository root:
47
+
48
+ ```bash
49
+ pnpm stories:dev
50
+ ```
51
+
52
+ This starts a dev server with `index.html`, reloading on save.
@@ -0,0 +1,8 @@
1
+ "use strict";var VtexAdsStories=(()=>{var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var e in t)a(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of m(t))!h.call(r,s)&&s!==e&&a(r,s,{get:()=>t[s],enumerable:!(d=c(t,s))||d.enumerable});return r};var y=r=>u(a({},"__esModule",{value:!0}),r);var E={};f(E,{TAG_NAME:()=>n,VtexAdsStoryElement:()=>o,defineVtexAdsStories:()=>i});var n="vtex-ads-story",l,p=(l=globalThis.HTMLElement)!=null?l:Object,x=`
2
+ :host {
3
+ display: block;
4
+ font-family: var(--vtex-ads-story-font-family, inherit);
5
+ color: var(--vtex-ads-story-color-text, inherit);
6
+ }
7
+ `,A="world",o=class extends p{static get observedAttributes(){return["name"]}get name(){var t,e;return(e=(t=this.getAttribute("name"))==null?void 0:t.trim())!=null?e:""}set name(t){this.setAttribute("name",t)}render(){var e;let t=(e=this.shadowRoot)==null?void 0:e.querySelector("[part='root']");t&&(t.textContent=`Hello ${this.name||A}!`)}connectedCallback(){if(!this.shadowRoot){let t=this.attachShadow({mode:"open"});t.innerHTML=`<style>${x}</style><div part="root"></div>`}this.upgradeProperty("name"),this.render()}upgradeProperty(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;let e=this[t];Reflect.deleteProperty(this,t),this[t]=e}attributeChangedCallback(){this.render()}};function i(){typeof customElements!="undefined"&&(customElements.get(n)||customElements.define(n,o))}i();return y(E);})();
8
+ //# sourceMappingURL=vtex-ads-stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cdn.ts","../../src/story/story.ts"],"sourcesContent":["import { defineVtexAdsStories } from \"./story\";\n\ndefineVtexAdsStories();\n\nexport { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","export const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n`;\n\nconst DEFAULT_NAME = \"world\";\n\nexport class VtexAdsStoryElement extends BaseElement {\n static get observedAttributes() {\n return [\"name\"];\n }\n\n get name(): string {\n return this.getAttribute(\"name\")?.trim() ?? \"\";\n }\n\n set name(value: string) {\n this.setAttribute(\"name\", value);\n }\n\n private render() {\n const container = this.shadowRoot?.querySelector(\"[part='root']\");\n if (!container) return;\n\n // textContent keeps the name as plain text (no HTML injection).\n container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div part=\"root\"></div>`;\n }\n\n this.upgradeProperty(\"name\");\n this.render();\n }\n\n // A property set before the element is defined (e.g. while the CDN script\n // loads) becomes an own property that shadows the class getter/setter.\n // Remove it and set it again so it goes through the setter.\n private upgradeProperty(prop: \"name\") {\n if (!Object.prototype.hasOwnProperty.call(this, prop)) return;\n\n const value = this[prop];\n Reflect.deleteProperty(this, prop);\n this[prop] = value;\n }\n\n attributeChangedCallback() {\n this.render();\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":"kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,wBAAAC,EAAA,yBAAAC,ICAO,IAAMC,EAAW,iBAAxBC,EAGMC,GAAkCD,EAAA,WAAW,cAAX,KAAAA,EAA0B,OAE5DE,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQTC,EAAe,QAERC,EAAN,cAAkCH,CAAY,CACnD,WAAW,oBAAqB,CAC9B,MAAO,CAAC,MAAM,CAChB,CAEA,IAAI,MAAe,CApBrB,IAAAD,EAAAK,EAqBI,OAAOA,GAAAL,EAAA,KAAK,aAAa,MAAM,IAAxB,YAAAA,EAA2B,SAA3B,KAAAK,EAAqC,EAC9C,CAEA,IAAI,KAAKC,EAAe,CACtB,KAAK,aAAa,OAAQA,CAAK,CACjC,CAEQ,QAAS,CA5BnB,IAAAN,EA6BI,IAAMO,GAAYP,EAAA,KAAK,aAAL,YAAAA,EAAiB,cAAc,iBAC5CO,IAGLA,EAAU,YAAc,SAAS,KAAK,MAAQJ,CAAY,IAC5D,CAEA,mBAAoB,CAClB,GAAI,CAAC,KAAK,WAAY,CACpB,IAAMK,EAAO,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAC/CA,EAAK,UAAY,UAAUN,CAAM,iCACnC,CAEA,KAAK,gBAAgB,MAAM,EAC3B,KAAK,OAAO,CACd,CAKQ,gBAAgBO,EAAc,CACpC,GAAI,CAAC,OAAO,UAAU,eAAe,KAAK,KAAMA,CAAI,EAAG,OAEvD,IAAMH,EAAQ,KAAKG,CAAI,EACvB,QAAQ,eAAe,KAAMA,CAAI,EACjC,KAAKA,CAAI,EAAIH,CACf,CAEA,0BAA2B,CACzB,KAAK,OAAO,CACd,CACF,EAEO,SAASI,GAAuB,CACjC,OAAO,gBAAmB,cAC1B,eAAe,IAAIX,CAAQ,GAE/B,eAAe,OAAOA,EAAUK,CAAmB,EACrD,CDjEAO,EAAqB","names":["cdn_exports","__export","TAG_NAME","VtexAdsStoryElement","defineVtexAdsStories","TAG_NAME","_a","BaseElement","styles","DEFAULT_NAME","VtexAdsStoryElement","_b","value","container","root","prop","defineVtexAdsStories","defineVtexAdsStories"]}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ TAG_NAME: () => TAG_NAME,
24
+ VtexAdsStoryElement: () => VtexAdsStoryElement,
25
+ defineVtexAdsStories: () => defineVtexAdsStories
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/story/story.ts
30
+ var TAG_NAME = "vtex-ads-story";
31
+ var _a;
32
+ var BaseElement = (_a = globalThis.HTMLElement) != null ? _a : Object;
33
+ var styles = `
34
+ :host {
35
+ display: block;
36
+ font-family: var(--vtex-ads-story-font-family, inherit);
37
+ color: var(--vtex-ads-story-color-text, inherit);
38
+ }
39
+ `;
40
+ var DEFAULT_NAME = "world";
41
+ var VtexAdsStoryElement = class extends BaseElement {
42
+ static get observedAttributes() {
43
+ return ["name"];
44
+ }
45
+ get name() {
46
+ var _a2, _b;
47
+ return (_b = (_a2 = this.getAttribute("name")) == null ? void 0 : _a2.trim()) != null ? _b : "";
48
+ }
49
+ set name(value) {
50
+ this.setAttribute("name", value);
51
+ }
52
+ render() {
53
+ var _a2;
54
+ const container = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("[part='root']");
55
+ if (!container) return;
56
+ container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;
57
+ }
58
+ connectedCallback() {
59
+ if (!this.shadowRoot) {
60
+ const root = this.attachShadow({ mode: "open" });
61
+ root.innerHTML = `<style>${styles}</style><div part="root"></div>`;
62
+ }
63
+ this.upgradeProperty("name");
64
+ this.render();
65
+ }
66
+ // A property set before the element is defined (e.g. while the CDN script
67
+ // loads) becomes an own property that shadows the class getter/setter.
68
+ // Remove it and set it again so it goes through the setter.
69
+ upgradeProperty(prop) {
70
+ if (!Object.prototype.hasOwnProperty.call(this, prop)) return;
71
+ const value = this[prop];
72
+ Reflect.deleteProperty(this, prop);
73
+ this[prop] = value;
74
+ }
75
+ attributeChangedCallback() {
76
+ this.render();
77
+ }
78
+ };
79
+ function defineVtexAdsStories() {
80
+ if (typeof customElements === "undefined") return;
81
+ if (customElements.get(TAG_NAME)) return;
82
+ customElements.define(TAG_NAME, VtexAdsStoryElement);
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ TAG_NAME,
87
+ VtexAdsStoryElement,
88
+ defineVtexAdsStories
89
+ });
90
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/story/story.ts"],"sourcesContent":["export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","export const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n`;\n\nconst DEFAULT_NAME = \"world\";\n\nexport class VtexAdsStoryElement extends BaseElement {\n static get observedAttributes() {\n return [\"name\"];\n }\n\n get name(): string {\n return this.getAttribute(\"name\")?.trim() ?? \"\";\n }\n\n set name(value: string) {\n this.setAttribute(\"name\", value);\n }\n\n private render() {\n const container = this.shadowRoot?.querySelector(\"[part='root']\");\n if (!container) return;\n\n // textContent keeps the name as plain text (no HTML injection).\n container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div part=\"root\"></div>`;\n }\n\n this.upgradeProperty(\"name\");\n this.render();\n }\n\n // A property set before the element is defined (e.g. while the CDN script\n // loads) becomes an own property that shadows the class getter/setter.\n // Remove it and set it again so it goes through the setter.\n private upgradeProperty(prop: \"name\") {\n if (!Object.prototype.hasOwnProperty.call(this, prop)) return;\n\n const value = this[prop];\n Reflect.deleteProperty(this, prop);\n this[prop] = value;\n }\n\n attributeChangedCallback() {\n this.render();\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAW;AAAxB;AAGA,IAAM,eAAkC,gBAAW,gBAAX,YAA0B;AAElE,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQf,IAAM,eAAe;AAEd,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,WAAW,qBAAqB;AAC9B,WAAO,CAAC,MAAM;AAAA,EAChB;AAAA,EAEA,IAAI,OAAe;AApBrB,QAAAA,KAAA;AAqBI,YAAO,MAAAA,MAAA,KAAK,aAAa,MAAM,MAAxB,gBAAAA,IAA2B,WAA3B,YAAqC;AAAA,EAC9C;AAAA,EAEA,IAAI,KAAK,OAAe;AACtB,SAAK,aAAa,QAAQ,KAAK;AAAA,EACjC;AAAA,EAEQ,SAAS;AA5BnB,QAAAA;AA6BI,UAAM,aAAYA,MAAA,KAAK,eAAL,gBAAAA,IAAiB,cAAc;AACjD,QAAI,CAAC,UAAW;AAGhB,cAAU,cAAc,SAAS,KAAK,QAAQ,YAAY;AAAA,EAC5D;AAAA,EAEA,oBAAoB;AAClB,QAAI,CAAC,KAAK,YAAY;AACpB,YAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/C,WAAK,YAAY,UAAU,MAAM;AAAA,IACnC;AAEA,SAAK,gBAAgB,MAAM;AAC3B,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKQ,gBAAgB,MAAc;AACpC,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,EAAG;AAEvD,UAAM,QAAQ,KAAK,IAAI;AACvB,YAAQ,eAAe,MAAM,IAAI;AACjC,SAAK,IAAI,IAAI;AAAA,EACf;AAAA,EAEA,2BAA2B;AACzB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,uBAAuB;AACrC,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,mBAAmB;AACrD;","names":["_a"]}
@@ -0,0 +1,14 @@
1
+ declare const TAG_NAME = "vtex-ads-story";
2
+ declare const BaseElement: typeof HTMLElement;
3
+ declare class VtexAdsStoryElement extends BaseElement {
4
+ static get observedAttributes(): string[];
5
+ get name(): string;
6
+ set name(value: string);
7
+ private render;
8
+ connectedCallback(): void;
9
+ private upgradeProperty;
10
+ attributeChangedCallback(): void;
11
+ }
12
+ declare function defineVtexAdsStories(): void;
13
+
14
+ export { TAG_NAME, VtexAdsStoryElement, defineVtexAdsStories };
@@ -0,0 +1,14 @@
1
+ declare const TAG_NAME = "vtex-ads-story";
2
+ declare const BaseElement: typeof HTMLElement;
3
+ declare class VtexAdsStoryElement extends BaseElement {
4
+ static get observedAttributes(): string[];
5
+ get name(): string;
6
+ set name(value: string);
7
+ private render;
8
+ connectedCallback(): void;
9
+ private upgradeProperty;
10
+ attributeChangedCallback(): void;
11
+ }
12
+ declare function defineVtexAdsStories(): void;
13
+
14
+ export { TAG_NAME, VtexAdsStoryElement, defineVtexAdsStories };
@@ -0,0 +1,61 @@
1
+ // src/story/story.ts
2
+ var TAG_NAME = "vtex-ads-story";
3
+ var _a;
4
+ var BaseElement = (_a = globalThis.HTMLElement) != null ? _a : Object;
5
+ var styles = `
6
+ :host {
7
+ display: block;
8
+ font-family: var(--vtex-ads-story-font-family, inherit);
9
+ color: var(--vtex-ads-story-color-text, inherit);
10
+ }
11
+ `;
12
+ var DEFAULT_NAME = "world";
13
+ var VtexAdsStoryElement = class extends BaseElement {
14
+ static get observedAttributes() {
15
+ return ["name"];
16
+ }
17
+ get name() {
18
+ var _a2, _b;
19
+ return (_b = (_a2 = this.getAttribute("name")) == null ? void 0 : _a2.trim()) != null ? _b : "";
20
+ }
21
+ set name(value) {
22
+ this.setAttribute("name", value);
23
+ }
24
+ render() {
25
+ var _a2;
26
+ const container = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("[part='root']");
27
+ if (!container) return;
28
+ container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;
29
+ }
30
+ connectedCallback() {
31
+ if (!this.shadowRoot) {
32
+ const root = this.attachShadow({ mode: "open" });
33
+ root.innerHTML = `<style>${styles}</style><div part="root"></div>`;
34
+ }
35
+ this.upgradeProperty("name");
36
+ this.render();
37
+ }
38
+ // A property set before the element is defined (e.g. while the CDN script
39
+ // loads) becomes an own property that shadows the class getter/setter.
40
+ // Remove it and set it again so it goes through the setter.
41
+ upgradeProperty(prop) {
42
+ if (!Object.prototype.hasOwnProperty.call(this, prop)) return;
43
+ const value = this[prop];
44
+ Reflect.deleteProperty(this, prop);
45
+ this[prop] = value;
46
+ }
47
+ attributeChangedCallback() {
48
+ this.render();
49
+ }
50
+ };
51
+ function defineVtexAdsStories() {
52
+ if (typeof customElements === "undefined") return;
53
+ if (customElements.get(TAG_NAME)) return;
54
+ customElements.define(TAG_NAME, VtexAdsStoryElement);
55
+ }
56
+ export {
57
+ TAG_NAME,
58
+ VtexAdsStoryElement,
59
+ defineVtexAdsStories
60
+ };
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/story/story.ts"],"sourcesContent":["export const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n`;\n\nconst DEFAULT_NAME = \"world\";\n\nexport class VtexAdsStoryElement extends BaseElement {\n static get observedAttributes() {\n return [\"name\"];\n }\n\n get name(): string {\n return this.getAttribute(\"name\")?.trim() ?? \"\";\n }\n\n set name(value: string) {\n this.setAttribute(\"name\", value);\n }\n\n private render() {\n const container = this.shadowRoot?.querySelector(\"[part='root']\");\n if (!container) return;\n\n // textContent keeps the name as plain text (no HTML injection).\n container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div part=\"root\"></div>`;\n }\n\n this.upgradeProperty(\"name\");\n this.render();\n }\n\n // A property set before the element is defined (e.g. while the CDN script\n // loads) becomes an own property that shadows the class getter/setter.\n // Remove it and set it again so it goes through the setter.\n private upgradeProperty(prop: \"name\") {\n if (!Object.prototype.hasOwnProperty.call(this, prop)) return;\n\n const value = this[prop];\n Reflect.deleteProperty(this, prop);\n this[prop] = value;\n }\n\n attributeChangedCallback() {\n this.render();\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":";AAAO,IAAM,WAAW;AAAxB;AAGA,IAAM,eAAkC,gBAAW,gBAAX,YAA0B;AAElE,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQf,IAAM,eAAe;AAEd,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,WAAW,qBAAqB;AAC9B,WAAO,CAAC,MAAM;AAAA,EAChB;AAAA,EAEA,IAAI,OAAe;AApBrB,QAAAA,KAAA;AAqBI,YAAO,MAAAA,MAAA,KAAK,aAAa,MAAM,MAAxB,gBAAAA,IAA2B,WAA3B,YAAqC;AAAA,EAC9C;AAAA,EAEA,IAAI,KAAK,OAAe;AACtB,SAAK,aAAa,QAAQ,KAAK;AAAA,EACjC;AAAA,EAEQ,SAAS;AA5BnB,QAAAA;AA6BI,UAAM,aAAYA,MAAA,KAAK,eAAL,gBAAAA,IAAiB,cAAc;AACjD,QAAI,CAAC,UAAW;AAGhB,cAAU,cAAc,SAAS,KAAK,QAAQ,YAAY;AAAA,EAC5D;AAAA,EAEA,oBAAoB;AAClB,QAAI,CAAC,KAAK,YAAY;AACpB,YAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/C,WAAK,YAAY,UAAU,MAAM;AAAA,IACnC;AAEA,SAAK,gBAAgB,MAAM;AAC3B,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKQ,gBAAgB,MAAc;AACpC,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,EAAG;AAEvD,UAAM,QAAQ,KAAK,IAAI;AACvB,YAAQ,eAAe,MAAM,IAAI;AACjC,SAAK,IAAI,IAAI;AAAA,EACf;AAAA,EAEA,2BAA2B;AACzB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,uBAAuB;AACrC,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,mBAAmB;AACrD;","names":["_a"]}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@vtex/ads-stories",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "VTEX Ads Stories web component (placeholder; real versions ship from CI)",
5
- "license": "UNLICENSED"
3
+ "type": "module",
4
+ "version": "0.1.0-test.040e2b9",
5
+ "description": "VTEX Ads Stories web component",
6
+ "main": "dist/cjs/index.cjs",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/esm/index.d.ts",
13
+ "default": "./dist/esm/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/cjs/index.d.cts",
17
+ "default": "./dist/cjs/index.cjs"
18
+ }
19
+ },
20
+ "./cdn": "./dist/cdn/vtex-ads-stories.js"
21
+ },
22
+ "sideEffects": [
23
+ "./dist/cdn/*"
24
+ ],
25
+ "files": [
26
+ "dist",
27
+ "src",
28
+ "!src/**/*.test.ts",
29
+ "README.md",
30
+ "CHANGELOG.md"
31
+ ],
32
+ "scripts": {
33
+ "prepack": "node ../../scripts/ensure-publish-auth.mjs",
34
+ "build": "tsup",
35
+ "build:watch": "tsup --watch",
36
+ "clean": "rimraf dist",
37
+ "dev": "vite",
38
+ "preview:cdn": "tsup && vite --open /?cdn",
39
+ "check-types": "tsc --noEmit",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest --coverage.enabled=false"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/vtex/ads-js.git",
49
+ "directory": "packages/ads-stories"
50
+ },
51
+ "homepage": "https://github.com/vtex/ads-js/tree/main/packages/ads-stories#readme",
52
+ "devDependencies": {
53
+ "@types/node": "^22.15.21",
54
+ "tsup": "^8.5.0",
55
+ "vite": "^5.0.0"
56
+ }
6
57
  }
package/src/cdn.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { defineVtexAdsStories } from "./story";
2
+
3
+ defineVtexAdsStories();
4
+
5
+ export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from "./story";
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from "./story";
@@ -0,0 +1 @@
1
+ export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from "./story";
@@ -0,0 +1,68 @@
1
+ export const TAG_NAME = "vtex-ads-story";
2
+
3
+ // Keeps the module importable where HTMLElement doesn't exist (SSR, Node).
4
+ const BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;
5
+
6
+ const styles = `
7
+ :host {
8
+ display: block;
9
+ font-family: var(--vtex-ads-story-font-family, inherit);
10
+ color: var(--vtex-ads-story-color-text, inherit);
11
+ }
12
+ `;
13
+
14
+ const DEFAULT_NAME = "world";
15
+
16
+ export class VtexAdsStoryElement extends BaseElement {
17
+ static get observedAttributes() {
18
+ return ["name"];
19
+ }
20
+
21
+ get name(): string {
22
+ return this.getAttribute("name")?.trim() ?? "";
23
+ }
24
+
25
+ set name(value: string) {
26
+ this.setAttribute("name", value);
27
+ }
28
+
29
+ private render() {
30
+ const container = this.shadowRoot?.querySelector("[part='root']");
31
+ if (!container) return;
32
+
33
+ // textContent keeps the name as plain text (no HTML injection).
34
+ container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;
35
+ }
36
+
37
+ connectedCallback() {
38
+ if (!this.shadowRoot) {
39
+ const root = this.attachShadow({ mode: "open" });
40
+ root.innerHTML = `<style>${styles}</style><div part="root"></div>`;
41
+ }
42
+
43
+ this.upgradeProperty("name");
44
+ this.render();
45
+ }
46
+
47
+ // A property set before the element is defined (e.g. while the CDN script
48
+ // loads) becomes an own property that shadows the class getter/setter.
49
+ // Remove it and set it again so it goes through the setter.
50
+ private upgradeProperty(prop: "name") {
51
+ if (!Object.prototype.hasOwnProperty.call(this, prop)) return;
52
+
53
+ const value = this[prop];
54
+ Reflect.deleteProperty(this, prop);
55
+ this[prop] = value;
56
+ }
57
+
58
+ attributeChangedCallback() {
59
+ this.render();
60
+ }
61
+ }
62
+
63
+ export function defineVtexAdsStories() {
64
+ if (typeof customElements === "undefined") return;
65
+ if (customElements.get(TAG_NAME)) return;
66
+
67
+ customElements.define(TAG_NAME, VtexAdsStoryElement);
68
+ }