@vikejs/license-components 0.0.3 → 0.0.5
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/FreeTrialForm.js +13 -18
- package/dist/FreeTrialForm.js.map +1 -1
- package/dist/LicenseSnippet.d.ts +6 -0
- package/dist/LicenseSnippet.d.ts.map +1 -0
- package/dist/LicenseSnippet.js +67 -0
- package/dist/LicenseSnippet.js.map +1 -0
- package/dist/renderTokens.d.ts +4 -0
- package/dist/renderTokens.d.ts.map +1 -0
- package/dist/renderTokens.js +31 -0
- package/dist/renderTokens.js.map +1 -0
- package/package.json +1 -1
package/dist/FreeTrialForm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
export { FreeTrialForm };
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { LicenseSnippet } from './LicenseSnippet.js';
|
|
5
5
|
// Resolve the API origin at call time (client-only — `submit` is the sole caller). The docs dev
|
|
6
6
|
// server runs on :3001 by convention and pairs with the dashboard dev on :3000, so a page served
|
|
7
7
|
// from `localhost:3001` targets the local dashboard; every other context (prod vike.dev, `vike
|
|
@@ -54,7 +54,7 @@ function ResultView({ result }) {
|
|
|
54
54
|
}
|
|
55
55
|
const { license, unavailable } = result.data;
|
|
56
56
|
const licenseEntries = Object.entries(license);
|
|
57
|
-
return (_jsxs(_Fragment, { children: [licenseEntries.length > 0 && (_jsxs("section", { style: successBoxStyle, children: [_jsx("strong", { children: "
|
|
57
|
+
return (_jsxs(_Fragment, { children: [licenseEntries.length > 0 && (_jsxs("section", { style: successBoxStyle, children: [_jsx("strong", { children: "License key" }), _jsxs("p", { style: captionStyle, children: ["Set", ' ', _jsx("a", { href: "https://vike.dev/license", style: linkStyle, children: _jsx("code", { children: "+license" }) }), ' ', "in your ", _jsx("code", { children: "+config.js" }), " file:"] }), _jsx(LicenseSnippet, { license: license }), licenseEntries.map(([domain, value]) => (_jsx(Summary, { domain: domain, value: value }, domain)))] })), unavailable.length > 0 && _jsx(UnavailableList, { items: unavailable })] }));
|
|
58
58
|
}
|
|
59
59
|
function Summary({ domain, value }) {
|
|
60
60
|
// A `string` value is a forever entry (no-expiry grant); `{ expires }` is time-limited
|
|
@@ -96,28 +96,23 @@ function formatDate(iso) {
|
|
|
96
96
|
const baseStyle = { fontFamily: 'system-ui, sans-serif', maxWidth: 640 };
|
|
97
97
|
const inputStyle = { width: '100%', padding: '8px 10px', fontSize: 14, boxSizing: 'border-box' };
|
|
98
98
|
const buttonStyle = { padding: '10px 14px', fontSize: 14, cursor: 'pointer' };
|
|
99
|
-
// Result boxes share one frame; only the tint differs (success / warn / error).
|
|
99
|
+
// Result boxes share one frame; only the tint differs (success / warn / error). Each sets its own
|
|
100
|
+
// text `color` (not just a background) so the box stays legible regardless of the host page's prose
|
|
101
|
+
// color — tints match the dashboard's messageStyles.ts so the two surfaces feel like one product.
|
|
100
102
|
const boxStyle = { padding: 16, borderRadius: 6, marginTop: 16 };
|
|
101
|
-
const successBoxStyle = { ...boxStyle, background: '#e7f7e0' };
|
|
102
|
-
const warnBoxStyle = { ...boxStyle, background: '#fff3cd' };
|
|
103
|
-
const errorBoxStyle = { ...boxStyle, background: '#fde2e1' };
|
|
103
|
+
const successBoxStyle = { ...boxStyle, background: '#e7f7e0', color: '#256029' };
|
|
104
|
+
const warnBoxStyle = { ...boxStyle, background: '#fff3cd', color: '#7a5b00' };
|
|
105
|
+
const errorBoxStyle = { ...boxStyle, background: '#fde2e1', color: '#9d2222' };
|
|
106
|
+
// Caption introducing the snippet — matches the dashboard's LicenseKeysPanel caption.
|
|
107
|
+
const captionStyle = { fontSize: 13, margin: '0 0 4px' };
|
|
108
|
+
// vike.dev/license link color (docpress src/css/link.css), same as the dashboard.
|
|
109
|
+
const linkStyle = { color: '#4747ff', textDecoration: 'none' };
|
|
104
110
|
const dlStyle = {
|
|
105
111
|
margin: '8px 0 0',
|
|
106
112
|
display: 'grid',
|
|
107
113
|
gridTemplateColumns: 'auto 1fr',
|
|
108
114
|
columnGap: 12,
|
|
109
|
-
rowGap:
|
|
115
|
+
rowGap: 1,
|
|
110
116
|
fontSize: 13,
|
|
111
117
|
};
|
|
112
|
-
const snippetStyle = {
|
|
113
|
-
background: '#fff',
|
|
114
|
-
padding: 10,
|
|
115
|
-
margin: '4px 0 12px',
|
|
116
|
-
fontSize: 12,
|
|
117
|
-
overflowX: 'auto',
|
|
118
|
-
border: '1px solid #ddd',
|
|
119
|
-
borderRadius: 4,
|
|
120
|
-
whiteSpace: 'pre',
|
|
121
|
-
};
|
|
122
|
-
const installHintStyle = { marginTop: 8, fontSize: 13, color: '#444' };
|
|
123
118
|
//# sourceMappingURL=FreeTrialForm.js.map
|
|
@@ -1 +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,
|
|
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,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,gGAAgG;AAChG,iGAAiG;AACjG,+FAA+F;AAC/F,kGAAkG;AAClG,iGAAiG;AACjG,+BAA+B;AAC/B,SAAS,WAAW;IAClB,MAAM,IAAI,GACR,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM;QAC9D,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,uBAAuB,CAAA;IAC7B,OAAO,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CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LicenseSnippet.d.ts","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAY3C,iBAAS,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,2CA2C3D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export { LicenseSnippet };
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { renderLicenseSnippetLines } from './snippet.js';
|
|
5
|
+
import { renderTokens } from './renderTokens.js';
|
|
6
|
+
// The license-snippet code block — the SINGLE rendering shared by the dashboard's `LicenseKeysPanel`
|
|
7
|
+
// and license-components' `FreeTrialForm`, so the two surfaces are byte-identical (symlinked into
|
|
8
|
+
// `packages/license-components/src/` alongside snippet.ts / wire.ts / renderTokens.tsx).
|
|
9
|
+
//
|
|
10
|
+
// CSS is injected as a scoped `<style>` (everything under `.license-snippet`) rather than a CSS
|
|
11
|
+
// import, because license-components is compiled by `tsc` (no CSS-import support); Vite (the
|
|
12
|
+
// dashboard) is fine with it too. `// pages/+config.js` + a blank line lead the block (context lines:
|
|
13
|
+
// `license: false`, not diff-highlighted, excluded from Copy) — mirrors vike.dev/license.
|
|
14
|
+
function LicenseSnippet({ license }) {
|
|
15
|
+
const [copied, setCopied] = useState(false);
|
|
16
|
+
const lines = [
|
|
17
|
+
{ text: '// pages/+config.js', license: false },
|
|
18
|
+
{ text: '', license: false },
|
|
19
|
+
...renderLicenseSnippetLines(license),
|
|
20
|
+
];
|
|
21
|
+
// Copy only the `license: {…}` lines (not the filename comment or `export default {}` wrapper), so
|
|
22
|
+
// a customer with an existing +config pastes just the key — matches the diff-highlighted lines.
|
|
23
|
+
async function copy() {
|
|
24
|
+
try {
|
|
25
|
+
await navigator.clipboard.writeText(lines
|
|
26
|
+
.filter((l) => l.license)
|
|
27
|
+
.map((l) => l.text)
|
|
28
|
+
.join('\n'));
|
|
29
|
+
setCopied(true);
|
|
30
|
+
setTimeout(() => setCopied(false), 1500);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// clipboard can reject (denied permission / insecure context) — leave the button unchanged.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs("div", { style: snippetWrapStyle, children: [_jsx("style", { children: SNIPPET_CSS }), _jsx("pre", { className: "license-snippet", children: _jsx("code", { children: lines.map((line, i) => (_jsx("span", { className: `line${line.license ? ' add' : ''}${line.text.startsWith('//') ? ' comment' : ''}`, children: line.text === '' ? ' ' : renderTokens(line.text) }, i))) }) }), _jsx("button", { type: "button", onClick: copy, style: copyButtonStyle, children: copied ? 'Copied' : 'Copy' })] }));
|
|
37
|
+
}
|
|
38
|
+
const snippetWrapStyle = { position: 'relative', margin: '8px 0' };
|
|
39
|
+
const copyButtonStyle = {
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: 6,
|
|
42
|
+
right: 6,
|
|
43
|
+
padding: '4px 8px',
|
|
44
|
+
fontSize: 12,
|
|
45
|
+
background: '#fff',
|
|
46
|
+
border: '1px solid #ddd',
|
|
47
|
+
borderRadius: 4,
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
color: '#333',
|
|
50
|
+
};
|
|
51
|
+
// github-light look (docpress's Shiki theme) without the dependency. `background:#f4f4f4` is solid
|
|
52
|
+
// (not docpress's rgba-on-white) so the block reads as a light code surface — dark text on light —
|
|
53
|
+
// on any host box tint or theme. `display:inline-block; min-width:100%` on the <code> is what lets a
|
|
54
|
+
// line's diff background span the full SCROLL width (not just the visible width); `!important` on it
|
|
55
|
+
// + `.line` because a host's typography CSS (e.g. the docs' `.prose pre code`) otherwise overrides
|
|
56
|
+
// the display and clips the highlight horizontally.
|
|
57
|
+
const SNIPPET_CSS = `
|
|
58
|
+
.license-snippet { margin: 0; border-radius: 6px; overflow-x: auto; background: #f4f4f4; font-size: 12px; line-height: 1.6; }
|
|
59
|
+
.license-snippet code { display: inline-block !important; min-width: 100% !important; padding: 16px 0; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; color: #24292e; background: transparent; border-radius: 0; font-size: inherit; }
|
|
60
|
+
.license-snippet .line { display: block !important; position: relative; padding: 0 16px; white-space: pre; }
|
|
61
|
+
.license-snippet .line.add { background: #d7ecdf; }
|
|
62
|
+
.license-snippet .line.add::before { content: '+'; position: absolute; top: -1px; left: 4px; color: #89d189; font-size: 1.2em; font-weight: 500; }
|
|
63
|
+
.license-snippet .line.comment { color: #6a737d; }
|
|
64
|
+
.license-snippet .tok-kw { color: #d73a49; }
|
|
65
|
+
.license-snippet .tok-str { color: #032f62; }
|
|
66
|
+
`;
|
|
67
|
+
//# sourceMappingURL=LicenseSnippet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LicenseSnippet.js","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,qGAAqG;AACrG,kGAAkG;AAClG,yFAAyF;AACzF,EAAE;AACF,gGAAgG;AAChG,6FAA6F;AAC7F,sGAAsG;AACtG,0FAA0F;AAC1F,SAAS,cAAc,CAAC,EAAE,OAAO,EAA2B;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG;QACZ,EAAE,IAAI,EAAE,qBAAqB,EAA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I,EAAE,KAAK,EAAE,eAAe,YACxD,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GACpB,IACL,CACP,CAAA;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,EAAE,QAAQ,EAAE,UAAmB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC3E,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,UAAmB;IAC7B,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,gBAAgB;IACxB,YAAY,EAAE,CAAC;IACf,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,MAAM;CACd,CAAA;AACD,mGAAmG;AACnG,mGAAmG;AACnG,qGAAqG;AACrG,qGAAqG;AACrG,mGAAmG;AACnG,oDAAoD;AACpD,MAAM,WAAW,GAAG;;;;;;;;;CASnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTokens.d.ts","sourceRoot":"","sources":["../src/renderTokens.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAUtC,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAyB7C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export { renderTokens };
|
|
3
|
+
// Syntax-highlight one line of the license snippet — the single source of truth for its token
|
|
4
|
+
// markup, shared by the dashboard's `LicenseKeysPanel` and license-components' `FreeTrialForm`.
|
|
5
|
+
//
|
|
6
|
+
// Approximates Shiki's `github-light` theme (docpress's, which powers vike.dev/docs) without the
|
|
7
|
+
// dependency: single-quoted string literals blue, `export`/`default` keywords red. The snippet is
|
|
8
|
+
// a fixed shape and its strings hold only domains + base64url keys (no nested quotes / keywords),
|
|
9
|
+
// so this split-based tokenizer is unambiguous. Emits `.tok-str` / `.tok-kw` spans; each consumer
|
|
10
|
+
// supplies the matching CSS (the dashboard's snippet.css, FreeTrialForm's inlined <style>).
|
|
11
|
+
function renderTokens(text) {
|
|
12
|
+
const nodes = [];
|
|
13
|
+
text.split(/('[^']*')/g).forEach((seg, i) => {
|
|
14
|
+
if (i % 2 === 1) {
|
|
15
|
+
nodes.push(_jsx("span", { className: "tok-str", children: seg }, i));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
seg.split(/\b(export|default)\b/g).forEach((part, j) => {
|
|
19
|
+
if (!part)
|
|
20
|
+
return;
|
|
21
|
+
if (j % 2 === 1) {
|
|
22
|
+
nodes.push(_jsx("span", { className: "tok-kw", children: part }, `${i}-${j}`));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
nodes.push(part);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return nodes;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=renderTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTokens.js","sourceRoot":"","sources":["../src/renderTokens.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,CAAA;AAIvB,8FAA8F;AAC9F,gGAAgG;AAChG,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,kGAAkG;AAClG,kGAAkG;AAClG,4FAA4F;AAC5F,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAChB,KAAK,CAAC,IAAI,CACR,eAAc,SAAS,EAAC,SAAS,YAC9B,GAAG,IADK,CAAC,CAEL,CACR,CAAA;YACD,OAAM;QACR,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACrD,IAAI,CAAC,IAAI;gBAAE,OAAM;YACjB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChB,KAAK,CAAC,IAAI,CACR,eAAwB,SAAS,EAAC,QAAQ,YACvC,IAAI,IADI,GAAG,CAAC,IAAI,CAAC,EAAE,CAEf,CACR,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC"}
|