pixelplay 1.0.10 → 1.0.11
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/dist/server.d.mts +31 -1
- package/dist/server.d.ts +31 -1
- package/dist/server.js +118 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +117 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -1549,9 +1549,126 @@ ${globalsVars}
|
|
|
1549
1549
|
}
|
|
1550
1550
|
return blocks.join("\n\n");
|
|
1551
1551
|
}
|
|
1552
|
+
|
|
1553
|
+
// src/license.ts
|
|
1554
|
+
import { readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
1555
|
+
import { resolve } from "path";
|
|
1556
|
+
var POLAR_ORG_ID = "0f5f2ec4-1ce3-4e23-8099-c3d77aadb8cf";
|
|
1557
|
+
var ACTIVATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/activate";
|
|
1558
|
+
var VALIDATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/validate";
|
|
1559
|
+
var CACHE_DIR = resolve(process.cwd(), "node_modules", ".cache", "pixelplay");
|
|
1560
|
+
var ACTIVATION_FILE = resolve(CACHE_DIR, "activation.json");
|
|
1561
|
+
var initialised = false;
|
|
1562
|
+
function initPixelPlay(options) {
|
|
1563
|
+
if (initialised) return;
|
|
1564
|
+
initialised = true;
|
|
1565
|
+
const key = options == null ? void 0 : options.licenseKey;
|
|
1566
|
+
if (!key) {
|
|
1567
|
+
console.warn(
|
|
1568
|
+
"\n\u26A0\uFE0F PixelPlay UI \u2014 No license key provided.\n Components will still work, but please purchase a license at\n https://dennisisaac.com/ui-kit/pricing\n Then add PIXELPLAY_LICENSE_KEY to your environment variables.\n"
|
|
1569
|
+
);
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
activateOrValidate(key).catch(() => {
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
function loadActivation() {
|
|
1576
|
+
try {
|
|
1577
|
+
const raw = readFileSync(ACTIVATION_FILE, "utf-8");
|
|
1578
|
+
const data = JSON.parse(raw);
|
|
1579
|
+
if ((data == null ? void 0 : data.activationId) && (data == null ? void 0 : data.key)) return data;
|
|
1580
|
+
} catch (e) {
|
|
1581
|
+
}
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1584
|
+
function saveActivation(activation) {
|
|
1585
|
+
try {
|
|
1586
|
+
mkdirSync(CACHE_DIR, { recursive: true });
|
|
1587
|
+
writeFileSync(
|
|
1588
|
+
ACTIVATION_FILE,
|
|
1589
|
+
JSON.stringify(activation, null, 2),
|
|
1590
|
+
"utf-8"
|
|
1591
|
+
);
|
|
1592
|
+
} catch (e) {
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
async function activateOrValidate(key) {
|
|
1596
|
+
const stored = loadActivation();
|
|
1597
|
+
if (stored && stored.key === key) {
|
|
1598
|
+
await validateKey(key, stored.activationId);
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
await activateKey(key);
|
|
1602
|
+
}
|
|
1603
|
+
async function activateKey(key) {
|
|
1604
|
+
try {
|
|
1605
|
+
const res = await fetch(ACTIVATE_URL, {
|
|
1606
|
+
method: "POST",
|
|
1607
|
+
headers: { "Content-Type": "application/json" },
|
|
1608
|
+
body: JSON.stringify({
|
|
1609
|
+
key,
|
|
1610
|
+
organization_id: POLAR_ORG_ID,
|
|
1611
|
+
label: `project:${process.cwd()}`
|
|
1612
|
+
})
|
|
1613
|
+
});
|
|
1614
|
+
if (!res.ok) {
|
|
1615
|
+
const status = res.status;
|
|
1616
|
+
if (status === 404 || status === 422) {
|
|
1617
|
+
console.warn(
|
|
1618
|
+
"\n\u26A0\uFE0F PixelPlay UI \u2014 Invalid license key.\n The provided PIXELPLAY_LICENSE_KEY could not be validated.\n Please check your key or purchase a license at\n https://dennisisaac.com/ui-kit/pricing\n"
|
|
1619
|
+
);
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
if (status === 403) {
|
|
1623
|
+
console.warn(
|
|
1624
|
+
"\n\u26A0\uFE0F PixelPlay UI \u2014 Activation limit reached.\n This license key has been activated on the maximum number of projects.\n Deactivate an existing project at https://polar.sh or upgrade your plan.\n"
|
|
1625
|
+
);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
const data = await res.json();
|
|
1631
|
+
saveActivation({ activationId: data.id, key });
|
|
1632
|
+
} catch (e) {
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
async function validateKey(key, activationId) {
|
|
1636
|
+
try {
|
|
1637
|
+
const res = await fetch(VALIDATE_URL, {
|
|
1638
|
+
method: "POST",
|
|
1639
|
+
headers: { "Content-Type": "application/json" },
|
|
1640
|
+
body: JSON.stringify({
|
|
1641
|
+
key,
|
|
1642
|
+
organization_id: POLAR_ORG_ID,
|
|
1643
|
+
activation_id: activationId
|
|
1644
|
+
})
|
|
1645
|
+
});
|
|
1646
|
+
if (!res.ok) {
|
|
1647
|
+
const status = res.status;
|
|
1648
|
+
if (status === 404 || status === 422) {
|
|
1649
|
+
saveActivation({ activationId: "", key: "" });
|
|
1650
|
+
await activateKey(key);
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
const data = await res.json();
|
|
1656
|
+
if (data.status === "revoked" || data.status === "disabled") {
|
|
1657
|
+
console.warn(
|
|
1658
|
+
`
|
|
1659
|
+
\u26A0\uFE0F PixelPlay UI \u2014 License key has been ${data.status}.
|
|
1660
|
+
Please contact support or purchase a new license at
|
|
1661
|
+
https://dennisisaac.com/ui-kit/pricing
|
|
1662
|
+
`
|
|
1663
|
+
);
|
|
1664
|
+
}
|
|
1665
|
+
} catch (e) {
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1552
1668
|
export {
|
|
1553
1669
|
darkTheme,
|
|
1554
1670
|
generateThemeCSS,
|
|
1671
|
+
initPixelPlay,
|
|
1555
1672
|
lightTheme
|
|
1556
1673
|
};
|
|
1557
1674
|
//# sourceMappingURL=server.mjs.map
|