pixelplay 1.0.10 → 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 +29 -1
- package/dist/server.d.ts +29 -1
- package/dist/server.js +66 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +65 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +74 -74
package/dist/server.d.mts
CHANGED
|
@@ -192,4 +192,32 @@ declare const darkTheme: ThemeTokens;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function generateThemeCSS(): string;
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* PixelPlay UI — License validation via Polar.sh customer-portal API.
|
|
197
|
+
*
|
|
198
|
+
* Behaviour:
|
|
199
|
+
* - Development (`next dev`): console warning if no key, components work fine.
|
|
200
|
+
* - Production build (`next build`): validates key against Polar API.
|
|
201
|
+
* Build fails if the key is missing, invalid, or revoked.
|
|
202
|
+
*
|
|
203
|
+
* This uses the public customer-portal endpoint (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 at the top of your root layout (server component):
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { initPixelPlay } from "pixelplay/server";
|
|
215
|
+
* initPixelPlay({ licenseKey: process.env.PIXELPLAY_LICENSE_KEY });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* In development: logs a warning if no key — components still work.
|
|
219
|
+
* In production builds: validates the key and fails the build if invalid.
|
|
220
|
+
*/
|
|
221
|
+
declare function initPixelPlay(options?: InitOptions): Promise<void>;
|
|
222
|
+
|
|
223
|
+
export { type ThemeTokens, darkTheme, generateThemeCSS, initPixelPlay, lightTheme };
|
package/dist/server.d.ts
CHANGED
|
@@ -192,4 +192,32 @@ declare const darkTheme: ThemeTokens;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function generateThemeCSS(): string;
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* PixelPlay UI — License validation via Polar.sh customer-portal API.
|
|
197
|
+
*
|
|
198
|
+
* Behaviour:
|
|
199
|
+
* - Development (`next dev`): console warning if no key, components work fine.
|
|
200
|
+
* - Production build (`next build`): validates key against Polar API.
|
|
201
|
+
* Build fails if the key is missing, invalid, or revoked.
|
|
202
|
+
*
|
|
203
|
+
* This uses the public customer-portal endpoint (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 at the top of your root layout (server component):
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { initPixelPlay } from "pixelplay/server";
|
|
215
|
+
* initPixelPlay({ licenseKey: process.env.PIXELPLAY_LICENSE_KEY });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* In development: logs a warning if no key — components still work.
|
|
219
|
+
* In production builds: validates the key and fails the build if invalid.
|
|
220
|
+
*/
|
|
221
|
+
declare function initPixelPlay(options?: InitOptions): Promise<void>;
|
|
222
|
+
|
|
223
|
+
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,75 @@ ${globalsVars}
|
|
|
1577
1578
|
}
|
|
1578
1579
|
return blocks.join("\n\n");
|
|
1579
1580
|
}
|
|
1581
|
+
|
|
1582
|
+
// src/license.ts
|
|
1583
|
+
var POLAR_ORG_ID = "0f5f2ec4-1ce3-4e23-8099-c3d77aadb8cf";
|
|
1584
|
+
var VALIDATE_URL = "https://api.polar.sh/v1/customer-portal/license-keys/validate";
|
|
1585
|
+
var initialised = false;
|
|
1586
|
+
async function initPixelPlay(options) {
|
|
1587
|
+
if (initialised) return;
|
|
1588
|
+
initialised = true;
|
|
1589
|
+
const key = options == null ? void 0 : options.licenseKey;
|
|
1590
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
1591
|
+
if (!key) {
|
|
1592
|
+
if (isProduction) {
|
|
1593
|
+
throw new Error(
|
|
1594
|
+
"\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"
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
console.warn(
|
|
1598
|
+
"\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"
|
|
1599
|
+
);
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
if (!isProduction) {
|
|
1603
|
+
validateKey(key, false).catch(() => {
|
|
1604
|
+
});
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
await validateKey(key, true);
|
|
1608
|
+
}
|
|
1609
|
+
async function validateKey(key, throwOnError) {
|
|
1610
|
+
try {
|
|
1611
|
+
const res = await fetch(VALIDATE_URL, {
|
|
1612
|
+
method: "POST",
|
|
1613
|
+
headers: { "Content-Type": "application/json" },
|
|
1614
|
+
body: JSON.stringify({
|
|
1615
|
+
key,
|
|
1616
|
+
organization_id: POLAR_ORG_ID
|
|
1617
|
+
})
|
|
1618
|
+
});
|
|
1619
|
+
if (!res.ok) {
|
|
1620
|
+
const status = res.status;
|
|
1621
|
+
if (status === 404 || status === 422) {
|
|
1622
|
+
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";
|
|
1623
|
+
if (throwOnError) throw new Error(msg);
|
|
1624
|
+
console.warn("\u26A0\uFE0F " + msg);
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
const data = await res.json();
|
|
1630
|
+
if (data.status === "revoked" || data.status === "disabled") {
|
|
1631
|
+
const msg = `
|
|
1632
|
+
\u{1F6AB} PixelPlay UI \u2014 License key has been ${data.status}.
|
|
1633
|
+
Please contact support or purchase a new license at
|
|
1634
|
+
https://dennisisaac.com/ui-kit/pricing
|
|
1635
|
+
`;
|
|
1636
|
+
if (throwOnError) throw new Error(msg);
|
|
1637
|
+
console.warn("\u26A0\uFE0F " + msg);
|
|
1638
|
+
}
|
|
1639
|
+
} catch (err) {
|
|
1640
|
+
if (err instanceof Error && err.message.includes("PixelPlay UI")) {
|
|
1641
|
+
throw err;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1580
1645
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1581
1646
|
0 && (module.exports = {
|
|
1582
1647
|
darkTheme,
|
|
1583
1648
|
generateThemeCSS,
|
|
1649
|
+
initPixelPlay,
|
|
1584
1650
|
lightTheme
|
|
1585
1651
|
});
|
|
1586
1652
|
//# sourceMappingURL=server.js.map
|