@vikejs/license-components 0.0.1

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.
@@ -0,0 +1,3 @@
1
+ export { FreeTrialForm };
2
+ declare function FreeTrialForm(): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=FreeTrialForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FreeTrialForm.d.ts","sourceRoot":"","sources":["../src/FreeTrialForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,CAAA;AAmBxB,iBAAS,aAAa,4CAmDrB"}
@@ -0,0 +1,116 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ export { FreeTrialForm };
3
+ import { useState } from 'react';
4
+ import { renderLicenseSnippet } from './snippet.js';
5
+ // Vite replaces `import.meta.env.DEV` at build time, so the prod bundle never carries the
6
+ // localhost branch. Consumers must build with Vite.
7
+ const ENDPOINT = import.meta.env.DEV
8
+ ? 'http://localhost:3000/api/free-trial/get-license-key'
9
+ : 'https://dash.vike.dev/api/free-trial/get-license-key';
10
+ function FreeTrialForm() {
11
+ const [domainsInput, setDomainsInput] = useState('');
12
+ const [result, setResult] = useState({ kind: 'idle' });
13
+ async function submit(e) {
14
+ e.preventDefault();
15
+ if (!domainsInput.trim()) {
16
+ setResult({ kind: 'error', message: 'Enter at least one domain.' });
17
+ return;
18
+ }
19
+ setResult({ kind: 'loading' });
20
+ try {
21
+ // Send the field verbatim; the server's `parseDomains` splits + canonicalizes, so
22
+ // domain parsing lives in exactly one place (matches the dashboard's LicenseKeysPanel).
23
+ const resp = await fetch(ENDPOINT, {
24
+ method: 'POST',
25
+ headers: { 'content-type': 'application/json' },
26
+ body: JSON.stringify({ domainsInput }),
27
+ });
28
+ if (resp.status === 200) {
29
+ setResult({ kind: 'success', data: (await resp.json()) });
30
+ return;
31
+ }
32
+ setResult({ kind: 'error', message: await describeErrorResponse(resp) });
33
+ }
34
+ catch {
35
+ // fetch throws (TypeError) only on transport failure — offline, DNS, TLS. Surface a
36
+ // friendly line instead of the raw error message.
37
+ setResult({ kind: 'error', message: "Couldn't reach the server. Check your connection and try again." });
38
+ }
39
+ }
40
+ return (_jsxs("div", { style: baseStyle, children: [_jsxs("form", { onSubmit: submit, style: { display: 'grid', gap: '0.75em' }, children: [_jsxs("label", { children: [_jsx("div", { style: { fontSize: 13, marginBottom: 4 }, children: "Domains (comma or space-separated)" }), _jsx("input", { type: "text", value: domainsInput, onChange: (e) => setDomainsInput(e.target.value), placeholder: "example.com, app.example.com", style: inputStyle })] }), _jsx("button", { type: "submit", disabled: result.kind === 'loading', style: buttonStyle, children: result.kind === 'loading' ? 'Submitting…' : 'Request free trial' })] }), _jsx(ResultView, { result: result })] }));
41
+ }
42
+ function ResultView({ result }) {
43
+ if (result.kind === 'idle' || result.kind === 'loading')
44
+ return null;
45
+ if (result.kind === 'error') {
46
+ return (_jsxs("section", { style: errorBoxStyle, children: [_jsx("strong", { children: "Error" }), _jsx("p", { style: { margin: '4px 0 0' }, children: result.message })] }));
47
+ }
48
+ const { license, unavailable } = result.data;
49
+ const licenseEntries = Object.entries(license);
50
+ return (_jsxs(_Fragment, { children: [licenseEntries.length > 0 && (_jsxs("section", { style: successBoxStyle, children: [_jsx("strong", { children: "Your license" }), _jsxs("p", { style: installHintStyle, children: ["Copy into your ", _jsx("code", { children: "pages/+config.js" }), " (see", ' ', _jsx("a", { href: "https://vike.dev/license#install", children: "vike.dev/license" }), "). Already have a ", _jsx("code", { children: "+config" }), "? Merge just the ", _jsx("code", { children: "license" }), " key."] }), _jsx("pre", { style: snippetStyle, children: renderLicenseSnippet(license) }), licenseEntries.map(([domain, value]) => (_jsx(Summary, { domain: domain, value: value }, domain)))] })), unavailable.length > 0 && _jsx(UnavailableList, { items: unavailable })] }));
51
+ }
52
+ function Summary({ domain, value }) {
53
+ // A `string` value is a forever entry (no-expiry grant); `{ expires }` is time-limited
54
+ // (a trial, or a time-boxed grant). The expiry alone tells the two apart — no separate
55
+ // provenance field needed.
56
+ const expires = typeof value === 'string' ? null : value.expires;
57
+ return (_jsxs("dl", { style: dlStyle, children: [_jsx("dt", { children: "Domain" }), _jsx("dd", { children: domain }), _jsx("dt", { children: "Expires" }), _jsx("dd", { children: expires === null ? 'never' : formatDate(expires) })] }));
58
+ }
59
+ function UnavailableList({ items }) {
60
+ return (_jsxs("section", { style: warnBoxStyle, children: [_jsx("strong", { children: "We can't cover these domains" }), _jsxs("p", { style: { margin: '4px 0 8px', fontSize: 13 }, children: ["Don't add these to your ", _jsx("code", { children: "+config.js" }), " \u2014 they won't verify. To get a working key,", ' ', _jsx("a", { href: "https://vike.dev/pricing", children: "purchase a license" }), " or", ' ', _jsx("a", { href: "https://vike.dev/free", children: "request a maintainer grant" }), "."] }), _jsx("ul", { style: { margin: '6px 0 0', paddingLeft: 20, fontSize: 13 }, children: items.map((u) => (_jsx("li", { children: describeUnavailable(u) }, u.domain))) })] }));
61
+ }
62
+ // Map a non-200 response to a user-facing line — never echo raw HTTP status / jargon (the
63
+ // previous `HTTP <status>: <body>` leaked both). The server's 400 body is already a human
64
+ // validation message ("Invalid domains: …", "Too many domains: max 21.") so surface it as-is —
65
+ // which also covers the over-limit case (G2: feedback only when they hit it, no standing hint);
66
+ // 429 is the rate limit; anything else is a generic retry line. See REVIEW-UX G1.
67
+ async function describeErrorResponse(resp) {
68
+ if (resp.status === 429)
69
+ return 'Too many requests — please wait a minute and try again.';
70
+ if (resp.status === 400) {
71
+ const text = (await resp.text()).trim();
72
+ return text || 'Please check the domains you entered and try again.';
73
+ }
74
+ return 'Something went wrong on our end. Please try again, or email support@vike.dev.';
75
+ }
76
+ // `trial-expired` is the only `unavailable` reason the server emits (a missing coverage row is an
77
+ // asserted invariant server-side, not a user-facing case).
78
+ function describeUnavailable(u) {
79
+ return `${u.domain} — previous free trial expired ${formatDate(u.expiresAt)}; the per-domain trial quota is used up.`;
80
+ }
81
+ function formatDate(iso) {
82
+ try {
83
+ return new Date(iso).toISOString().slice(0, 10);
84
+ }
85
+ catch {
86
+ return iso;
87
+ }
88
+ }
89
+ const baseStyle = { fontFamily: 'system-ui, sans-serif', maxWidth: 640 };
90
+ const inputStyle = { width: '100%', padding: '8px 10px', fontSize: 14, boxSizing: 'border-box' };
91
+ const buttonStyle = { padding: '10px 14px', fontSize: 14, cursor: 'pointer' };
92
+ // Result boxes share one frame; only the tint differs (success / warn / error).
93
+ const boxStyle = { padding: 16, borderRadius: 6, marginTop: 16 };
94
+ const successBoxStyle = { ...boxStyle, background: '#e7f7e0' };
95
+ const warnBoxStyle = { ...boxStyle, background: '#fff3cd' };
96
+ const errorBoxStyle = { ...boxStyle, background: '#fde2e1' };
97
+ const dlStyle = {
98
+ margin: '8px 0 0',
99
+ display: 'grid',
100
+ gridTemplateColumns: 'auto 1fr',
101
+ columnGap: 12,
102
+ rowGap: 4,
103
+ fontSize: 13,
104
+ };
105
+ const snippetStyle = {
106
+ background: '#fff',
107
+ padding: 10,
108
+ margin: '4px 0 12px',
109
+ fontSize: 12,
110
+ overflowX: 'auto',
111
+ border: '1px solid #ddd',
112
+ borderRadius: 4,
113
+ whiteSpace: 'pre',
114
+ };
115
+ const installHintStyle = { marginTop: 8, fontSize: 13, color: '#444' };
116
+ //# sourceMappingURL=FreeTrialForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FreeTrialForm.js","sourceRoot":"","sources":["../src/FreeTrialForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,0FAA0F;AAC1F,oDAAoD;AACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;IAClC,CAAC,CAAC,sDAAsD;IACxD,CAAC,CAAC,sDAAsD,CAAA;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MAAM,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { FreeTrialForm } from './FreeTrialForm.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { FreeTrialForm } from './FreeTrialForm.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,10 @@
1
+ export { renderLicenseSnippet, renderLicenseSnippetLines };
2
+ export type { SnippetLine };
3
+ import type { LicenseMap } from './wire.js';
4
+ type SnippetLine = {
5
+ text: string;
6
+ license: boolean;
7
+ };
8
+ declare function renderLicenseSnippetLines(license: LicenseMap): SnippetLine[];
9
+ declare function renderLicenseSnippet(license: LicenseMap): string;
10
+ //# sourceMappingURL=snippet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../src/snippet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,CAAA;AAE3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAM3C,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAA;AASrD,iBAAS,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,EAAE,CAerE;AAKD,iBAAS,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAIzD"}
@@ -0,0 +1,32 @@
1
+ export { renderLicenseSnippet, renderLicenseSnippetLines };
2
+ // Structured form of the snippet — the single source of truth for its shape. Used by:
3
+ // - the dashboard's `LicenseKeysPanel` (diff-highlights + copies the `license` lines),
4
+ // - `renderLicenseSnippet` below (the flat-string form for the CLI + free-trial form).
5
+ //
6
+ // Any future format change (switching to `defineConfig`, renaming the `license` key) is one
7
+ // edit here. Handles both forever-valid (`string`) and time-limited (`{expires, key}`) entries;
8
+ // callers handing a `Record<string, string>` (dashboard's paid flavor) hit the string branch only.
9
+ function renderLicenseSnippetLines(license) {
10
+ const lines = [
11
+ { text: 'export default {', license: false },
12
+ { text: ' license: {', license: true },
13
+ ];
14
+ for (const [domain, value] of Object.entries(license)) {
15
+ const text = typeof value === 'string'
16
+ ? ` '${domain}': '${value}',`
17
+ : ` '${domain}': { expires: '${value.expires}', key: '${value.key}' },`;
18
+ lines.push({ text, license: true });
19
+ }
20
+ // Trailing comma so the copied `license: {…},` block slots cleanly into an existing config.
21
+ lines.push({ text: ' },', license: true }, { text: '}', license: false });
22
+ return lines;
23
+ }
24
+ // Flat-string form for the maintainer `pnpm write:grant` CLI (prefixed for terminal output) and
25
+ // `<FreeTrialForm>`'s "Your license" panel (license-components, via the symlink at
26
+ // `packages/license-components/src/snippet.ts`).
27
+ function renderLicenseSnippet(license) {
28
+ return renderLicenseSnippetLines(license)
29
+ .map((line) => line.text)
30
+ .join('\n');
31
+ }
32
+ //# sourceMappingURL=snippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snippet.js","sourceRoot":"","sources":["../src/snippet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAA;AAW1D,sFAAsF;AACtF,yFAAyF;AACzF,yFAAyF;AACzF,EAAE;AACF,4FAA4F;AAC5F,gGAAgG;AAChG,mGAAmG;AACnG,SAAS,yBAAyB,CAAC,OAAmB;IACpD,MAAM,KAAK,GAAkB;QAC3B,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE;QAC5C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE;KACxC,CAAA;IACD,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,GACR,OAAO,KAAK,KAAK,QAAQ;YACvB,CAAC,CAAC,QAAQ,MAAM,OAAO,KAAK,IAAI;YAChC,CAAC,CAAC,QAAQ,MAAM,kBAAkB,KAAK,CAAC,OAAO,YAAY,KAAK,CAAC,GAAG,MAAM,CAAA;QAC9E,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACrC,CAAC;IACD,4FAA4F;IAC5F,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1E,OAAO,KAAK,CAAA;AACd,CAAC;AAED,gGAAgG;AAChG,mFAAmF;AACnF,iDAAiD;AACjD,SAAS,oBAAoB,CAAC,OAAmB;IAC/C,OAAO,yBAAyB,CAAC,OAAO,CAAC;SACtC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC"}
package/dist/wire.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export type { FreeTrialResponse, LicenseMap, LicenseValue, TimeLimitedLicense, Unavailable };
2
+ interface FreeTrialResponse {
3
+ license: LicenseMap;
4
+ unavailable: Unavailable[];
5
+ }
6
+ type LicenseMap = Record<string, LicenseValue>;
7
+ type LicenseValue = string | TimeLimitedLicense;
8
+ interface TimeLimitedLicense {
9
+ expires: string;
10
+ key: string;
11
+ }
12
+ type Unavailable = {
13
+ domain: string;
14
+ reason: 'trial-expired';
15
+ expiresAt: string;
16
+ };
17
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAA;AAe5F,UAAU,iBAAiB;IACzB,OAAO,EAAE,UAAU,CAAA;IACnB,WAAW,EAAE,WAAW,EAAE,CAAA;CAC3B;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAC9C,KAAK,YAAY,GAAG,MAAM,GAAG,kBAAkB,CAAA;AAE/C,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAKD,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA"}
package/dist/wire.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vikejs/license-components",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "peerDependencies": {
17
+ "react": "^18.0.0 || ^19.0.0"
18
+ },
19
+ "dependencies": {},
20
+ "devDependencies": {
21
+ "@types/react": "^19.2.15",
22
+ "@types/react-dom": "^19.2.3",
23
+ "react-dom": "^19.2.6",
24
+ "typescript": "^6.0.3",
25
+ "vike": "0.4.259-commit-58f1d2c",
26
+ "vike-react": "^0.6.23",
27
+ "vite": "^8.0.14"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/vikejs/vike-dashboard.git",
32
+ "directory": "packages/license-components"
33
+ },
34
+ "scripts": {
35
+ "// === Dev": "",
36
+ "dev": "vite playground",
37
+ "typecheck": "tsc --noEmit",
38
+ "// === Build ===": "",
39
+ "build": "tsc",
40
+ "// === Release": "",
41
+ "release": "npm version patch && npm publish && git push && git push --tags"
42
+ }
43
+ }