nano-stripe
Version:
A lightweight and framework-agnostic strpe component to track payments and conversion.
27 lines (26 loc) • 896 B
JavaScript
// src/index.ts
var BaseHTMLElement;
if (typeof window === "undefined" || typeof HTMLElement === "undefined") {
class DummyHTMLElement {
}
BaseHTMLElement = DummyHTMLElement;
} else {
BaseHTMLElement = HTMLElement;
}
var NanoStripe = class extends BaseHTMLElement {
constructor() {
super();
this.projectKey = this.getAttribute("projectKey");
this.userId = this.getAttribute("userId");
this.sessionId = typeof localStorage !== "undefined" && localStorage.getItem("nanoStripeSessionId") || typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID() || Math.random().toString(36).slice(2);
if (typeof localStorage !== "undefined") {
localStorage.setItem("nanoStripeSessionId", this.sessionId);
}
}
};
if (typeof window !== "undefined" && window.customElements) {
customElements.define("nano-stripe", NanoStripe);
}
export {
NanoStripe
};