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.d.mts
CHANGED
|
@@ -192,4 +192,34 @@ declare const darkTheme: ThemeTokens;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function generateThemeCSS(): string;
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* PixelPlay UI — License validation + activation via Polar.sh customer-portal API.
|
|
197
|
+
*
|
|
198
|
+
* Flow:
|
|
199
|
+
* 1. First run → activate the key (registers this project as an activation instance)
|
|
200
|
+
* 2. Subsequent runs → validate the key with the stored activation ID
|
|
201
|
+
* 3. Activation ID is persisted in node_modules/.cache/pixelplay/activation.json
|
|
202
|
+
*
|
|
203
|
+
* This uses the public customer-portal endpoints (no auth token required).
|
|
204
|
+
*/
|
|
205
|
+
interface InitOptions {
|
|
206
|
+
/** The customer's license key (from PIXELPLAY_LICENSE_KEY env var) */
|
|
207
|
+
licenseKey?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Initialise PixelPlay and validate the license key.
|
|
211
|
+
*
|
|
212
|
+
* Call this once in your root layout (server component):
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { initPixelPlay } from "pixelplay/server";
|
|
215
|
+
* initPixelPlay({ licenseKey: process.env.PIXELPLAY_LICENSE_KEY });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* On first run, the key is activated (counts toward the activation limit).
|
|
219
|
+
* On subsequent runs, the stored activation is validated.
|
|
220
|
+
* If the key is missing or invalid, a console warning is logged.
|
|
221
|
+
* Components continue to work regardless.
|
|
222
|
+
*/
|
|
223
|
+
declare function initPixelPlay(options?: InitOptions): void;
|
|
224
|
+
|
|
225
|
+
export { type ThemeTokens, darkTheme, generateThemeCSS, initPixelPlay, lightTheme };
|
package/dist/server.d.ts
CHANGED
|
@@ -192,4 +192,34 @@ declare const darkTheme: ThemeTokens;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function generateThemeCSS(): string;
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* PixelPlay UI — License validation + activation via Polar.sh customer-portal API.
|
|
197
|
+
*
|
|
198
|
+
* Flow:
|
|
199
|
+
* 1. First run → activate the key (registers this project as an activation instance)
|
|
200
|
+
* 2. Subsequent runs → validate the key with the stored activation ID
|
|
201
|
+
* 3. Activation ID is persisted in node_modules/.cache/pixelplay/activation.json
|
|
202
|
+
*
|
|
203
|
+
* This uses the public customer-portal endpoints (no auth token required).
|
|
204
|
+
*/
|
|
205
|
+
interface InitOptions {
|
|
206
|
+
/** The customer's license key (from PIXELPLAY_LICENSE_KEY env var) */
|
|
207
|
+
licenseKey?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Initialise PixelPlay and validate the license key.
|
|
211
|
+
*
|
|
212
|
+
* Call this once in your root layout (server component):
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { initPixelPlay } from "pixelplay/server";
|
|
215
|
+
* initPixelPlay({ licenseKey: process.env.PIXELPLAY_LICENSE_KEY });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* On first run, the key is activated (counts toward the activation limit).
|
|
219
|
+
* On subsequent runs, the stored activation is validated.
|
|
220
|
+
* If the key is missing or invalid, a console warning is logged.
|
|
221
|
+
* Components continue to work regardless.
|
|
222
|
+
*/
|
|
223
|
+
declare function initPixelPlay(options?: InitOptions): void;
|
|
224
|
+
|
|
225
|
+
export { type ThemeTokens, darkTheme, generateThemeCSS, initPixelPlay, lightTheme };
|
package/dist/server.js
CHANGED
|
@@ -22,6 +22,7 @@ var server_exports = {};
|
|
|
22
22
|
__export(server_exports, {
|
|
23
23
|
darkTheme: () => darkTheme,
|
|
24
24
|
generateThemeCSS: () => generateThemeCSS,
|
|
25
|
+
initPixelPlay: () => initPixelPlay,
|
|
25
26
|
lightTheme: () => lightTheme
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(server_exports);
|
|
@@ -1577,10 +1578,127 @@ ${globalsVars}
|
|
|
1577
1578
|
}
|
|
1578
1579
|
return blocks.join("\n\n");
|
|
1579
1580
|
}
|
|
1581
|
+
|
|
1582
|
+
// src/license.ts
|
|
1583
|
+
var import_fs = require("fs");
|
|
1584
|
+
var import_path = require("path");
|
|
1585
|
+
var POLAR_ORG_ID = "0f5f2ec4-1ce3-4e23-8099-c3d77aadb8cf";
|
|
1586
|
+
var ACTIVATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/activate";
|
|
1587
|
+
var VALIDATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/validate";
|
|
1588
|
+
var CACHE_DIR = (0, import_path.resolve)(process.cwd(), "node_modules", ".cache", "pixelplay");
|
|
1589
|
+
var ACTIVATION_FILE = (0, import_path.resolve)(CACHE_DIR, "activation.json");
|
|
1590
|
+
var initialised = false;
|
|
1591
|
+
function initPixelPlay(options) {
|
|
1592
|
+
if (initialised) return;
|
|
1593
|
+
initialised = true;
|
|
1594
|
+
const key = options == null ? void 0 : options.licenseKey;
|
|
1595
|
+
if (!key) {
|
|
1596
|
+
console.warn(
|
|
1597
|
+
"\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"
|
|
1598
|
+
);
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
activateOrValidate(key).catch(() => {
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
function loadActivation() {
|
|
1605
|
+
try {
|
|
1606
|
+
const raw = (0, import_fs.readFileSync)(ACTIVATION_FILE, "utf-8");
|
|
1607
|
+
const data = JSON.parse(raw);
|
|
1608
|
+
if ((data == null ? void 0 : data.activationId) && (data == null ? void 0 : data.key)) return data;
|
|
1609
|
+
} catch (e) {
|
|
1610
|
+
}
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1613
|
+
function saveActivation(activation) {
|
|
1614
|
+
try {
|
|
1615
|
+
(0, import_fs.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
1616
|
+
(0, import_fs.writeFileSync)(
|
|
1617
|
+
ACTIVATION_FILE,
|
|
1618
|
+
JSON.stringify(activation, null, 2),
|
|
1619
|
+
"utf-8"
|
|
1620
|
+
);
|
|
1621
|
+
} catch (e) {
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
async function activateOrValidate(key) {
|
|
1625
|
+
const stored = loadActivation();
|
|
1626
|
+
if (stored && stored.key === key) {
|
|
1627
|
+
await validateKey(key, stored.activationId);
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
await activateKey(key);
|
|
1631
|
+
}
|
|
1632
|
+
async function activateKey(key) {
|
|
1633
|
+
try {
|
|
1634
|
+
const res = await fetch(ACTIVATE_URL, {
|
|
1635
|
+
method: "POST",
|
|
1636
|
+
headers: { "Content-Type": "application/json" },
|
|
1637
|
+
body: JSON.stringify({
|
|
1638
|
+
key,
|
|
1639
|
+
organization_id: POLAR_ORG_ID,
|
|
1640
|
+
label: `project:${process.cwd()}`
|
|
1641
|
+
})
|
|
1642
|
+
});
|
|
1643
|
+
if (!res.ok) {
|
|
1644
|
+
const status = res.status;
|
|
1645
|
+
if (status === 404 || status === 422) {
|
|
1646
|
+
console.warn(
|
|
1647
|
+
"\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"
|
|
1648
|
+
);
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
if (status === 403) {
|
|
1652
|
+
console.warn(
|
|
1653
|
+
"\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"
|
|
1654
|
+
);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
const data = await res.json();
|
|
1660
|
+
saveActivation({ activationId: data.id, key });
|
|
1661
|
+
} catch (e) {
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
async function validateKey(key, activationId) {
|
|
1665
|
+
try {
|
|
1666
|
+
const res = await fetch(VALIDATE_URL, {
|
|
1667
|
+
method: "POST",
|
|
1668
|
+
headers: { "Content-Type": "application/json" },
|
|
1669
|
+
body: JSON.stringify({
|
|
1670
|
+
key,
|
|
1671
|
+
organization_id: POLAR_ORG_ID,
|
|
1672
|
+
activation_id: activationId
|
|
1673
|
+
})
|
|
1674
|
+
});
|
|
1675
|
+
if (!res.ok) {
|
|
1676
|
+
const status = res.status;
|
|
1677
|
+
if (status === 404 || status === 422) {
|
|
1678
|
+
saveActivation({ activationId: "", key: "" });
|
|
1679
|
+
await activateKey(key);
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
const data = await res.json();
|
|
1685
|
+
if (data.status === "revoked" || data.status === "disabled") {
|
|
1686
|
+
console.warn(
|
|
1687
|
+
`
|
|
1688
|
+
\u26A0\uFE0F PixelPlay UI \u2014 License key has been ${data.status}.
|
|
1689
|
+
Please contact support or purchase a new license at
|
|
1690
|
+
https://dennisisaac.com/ui-kit/pricing
|
|
1691
|
+
`
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
} catch (e) {
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1580
1697
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1581
1698
|
0 && (module.exports = {
|
|
1582
1699
|
darkTheme,
|
|
1583
1700
|
generateThemeCSS,
|
|
1701
|
+
initPixelPlay,
|
|
1584
1702
|
lightTheme
|
|
1585
1703
|
});
|
|
1586
1704
|
//# sourceMappingURL=server.js.map
|