pixelplay 1.0.11 → 1.0.13
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 +10 -12
- package/dist/server.d.ts +10 -12
- package/dist/server.js +26 -78
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +26 -78
- package/dist/server.mjs.map +1 -1
- package/package.json +74 -74
package/dist/server.mjs
CHANGED
|
@@ -1551,118 +1551,66 @@ ${globalsVars}
|
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
1553
|
// src/license.ts
|
|
1554
|
-
import { readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
1555
|
-
import { resolve } from "path";
|
|
1556
1554
|
var POLAR_ORG_ID = "0f5f2ec4-1ce3-4e23-8099-c3d77aadb8cf";
|
|
1557
|
-
var ACTIVATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/activate";
|
|
1558
1555
|
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
1556
|
var initialised = false;
|
|
1562
|
-
function initPixelPlay(options) {
|
|
1557
|
+
async function initPixelPlay(options) {
|
|
1563
1558
|
if (initialised) return;
|
|
1564
1559
|
initialised = true;
|
|
1565
1560
|
const key = options == null ? void 0 : options.licenseKey;
|
|
1561
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
1566
1562
|
if (!key) {
|
|
1563
|
+
if (isProduction) {
|
|
1564
|
+
throw new Error(
|
|
1565
|
+
"\n\n\u{1F6AB} PixelPlay UI \u2014 Build failed: No license key provided.\n Set PIXELPLAY_LICENSE_KEY in your environment variables.\n Purchase a license at https://dennisisaac.com/ui-kit/pricing\n"
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1567
1568
|
console.warn(
|
|
1568
|
-
"\n\u26A0\uFE0F PixelPlay UI \u2014 No license key provided.\n Components will
|
|
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"
|
|
1569
|
+
"\n\u26A0\uFE0F PixelPlay UI \u2014 No license key provided.\n Components will work in development, but production builds require a valid key.\n Purchase a license at https://dennisisaac.com/ui-kit/pricing\n"
|
|
1591
1570
|
);
|
|
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
1571
|
return;
|
|
1600
1572
|
}
|
|
1601
|
-
|
|
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
|
-
})
|
|
1573
|
+
if (!isProduction) {
|
|
1574
|
+
validateKey(key, false).catch(() => {
|
|
1613
1575
|
});
|
|
1614
|
-
|
|
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) {
|
|
1576
|
+
return;
|
|
1633
1577
|
}
|
|
1578
|
+
await validateKey(key, true);
|
|
1634
1579
|
}
|
|
1635
|
-
async function validateKey(key,
|
|
1580
|
+
async function validateKey(key, throwOnError) {
|
|
1636
1581
|
try {
|
|
1637
1582
|
const res = await fetch(VALIDATE_URL, {
|
|
1638
1583
|
method: "POST",
|
|
1639
1584
|
headers: { "Content-Type": "application/json" },
|
|
1640
1585
|
body: JSON.stringify({
|
|
1641
1586
|
key,
|
|
1642
|
-
organization_id: POLAR_ORG_ID
|
|
1643
|
-
activation_id: activationId
|
|
1587
|
+
organization_id: POLAR_ORG_ID
|
|
1644
1588
|
})
|
|
1645
1589
|
});
|
|
1646
1590
|
if (!res.ok) {
|
|
1647
1591
|
const status = res.status;
|
|
1648
1592
|
if (status === 404 || status === 422) {
|
|
1649
|
-
|
|
1650
|
-
|
|
1593
|
+
const msg = "\n\u{1F6AB} 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";
|
|
1594
|
+
if (throwOnError) throw new Error(msg);
|
|
1595
|
+
console.warn("\u26A0\uFE0F " + msg);
|
|
1651
1596
|
return;
|
|
1652
1597
|
}
|
|
1653
1598
|
return;
|
|
1654
1599
|
}
|
|
1655
1600
|
const data = await res.json();
|
|
1656
1601
|
if (data.status === "revoked" || data.status === "disabled") {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
\u26A0\uFE0F PixelPlay UI \u2014 License key has been ${data.status}.
|
|
1602
|
+
const msg = `
|
|
1603
|
+
\u{1F6AB} PixelPlay UI \u2014 License key has been ${data.status}.
|
|
1660
1604
|
Please contact support or purchase a new license at
|
|
1661
1605
|
https://dennisisaac.com/ui-kit/pricing
|
|
1662
|
-
|
|
1663
|
-
);
|
|
1606
|
+
`;
|
|
1607
|
+
if (throwOnError) throw new Error(msg);
|
|
1608
|
+
console.warn("\u26A0\uFE0F " + msg);
|
|
1609
|
+
}
|
|
1610
|
+
} catch (err) {
|
|
1611
|
+
if (err instanceof Error && err.message.includes("PixelPlay UI")) {
|
|
1612
|
+
throw err;
|
|
1664
1613
|
}
|
|
1665
|
-
} catch (e) {
|
|
1666
1614
|
}
|
|
1667
1615
|
}
|
|
1668
1616
|
export {
|