@litfamily/litcodex 1.0.4 → 1.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/README.md +114 -75
- package/dist/cli-model-route.js +27 -27
- package/dist/cli.js +6 -4
- package/dist/config-migration/catalog.d.ts +40 -1
- package/dist/config-migration/catalog.js +202 -57
- package/dist/config-migration/cli.d.ts +2 -1
- package/dist/config-migration/cli.js +34 -32
- package/dist/config-migration/gpt56-policy.d.ts +19 -10
- package/dist/config-migration/gpt56-policy.js +92 -50
- package/dist/config-migration/index.d.ts +2 -0
- package/dist/config-migration/index.js +28 -10
- package/dist/install/doctor-config.js +5 -5
- package/dist/install/doctor-render.js +16 -16
- package/dist/install/doctor.js +2 -2
- package/dist/install/execute.js +5 -4
- package/dist/install/generated-skill-payload-hashes.d.ts +30 -3
- package/dist/install/generated-skill-payload-hashes.js +30 -3
- package/dist/install/host-capabilities.d.ts +3 -4
- package/dist/install/host-capabilities.js +17 -19
- package/dist/install/install-model-prompt.js +44 -26
- package/dist/install/install-options.js +41 -46
- package/dist/install/install-presentation.js +2 -1
- package/dist/install/skill-catalog.d.ts +1 -1
- package/dist/install/skill-catalog.js +6 -1
- package/dist/install/skill-resource-hashes.d.ts +1 -1
- package/dist/install/skill-resource-hashes.js +1 -1
- package/dist/install/uninstall.js +6 -7
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
- package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
- package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/agents/litcodex-default.toml +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/agents/litcodex-explorer.toml +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/agents/litcodex-librarian.toml +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/agents/litcodex-metis.toml +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/litwork.md +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.d.ts +2 -1
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.js +9 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
- package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
- package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +22 -19
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/canonical-library.md +7 -1
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/complete-contract.md +17 -11
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/default-editorial-pixel.json +64 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/production-interview.md +25 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/SKILL.md +94 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/references/decoration-patterns.md +36 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/references/facts-and-assembly.md +36 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/references/motion-and-delivery.md +47 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/references/typography-and-imagery.md +34 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/scripts/validate-readme-facts.mjs +130 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/cover-source.json +35 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/index.html +61 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/index.motion.json +6 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/package-lock.json +1969 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/package.json +14 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/readme-cover-section.md +85 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/readme-facts.json +11 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/package-lock.json +3783 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/package.json +15 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/ReadmeCover.tsx +102 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/Root.tsx +48 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/index.tsx +4 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/layout.ts +35 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/motion.ts +25 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/typography/package-lock.json +133 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/typography/package.json +8 -0
- package/marketplace/plugins/litcodex/skills/readme-studio/templates/typography/shape-text-to-svg.mjs +238 -0
- package/model-catalog.json +163 -4
- package/node_modules/@litcodex/lit-loop/agents/litcodex-default.toml +1 -1
- package/node_modules/@litcodex/lit-loop/agents/litcodex-explorer.toml +1 -1
- package/node_modules/@litcodex/lit-loop/agents/litcodex-librarian.toml +1 -1
- package/node_modules/@litcodex/lit-loop/agents/litcodex-metis.toml +1 -1
- package/node_modules/@litcodex/lit-loop/directives/litwork.md +1 -1
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/package.json +2 -2
- package/readme-assets/badge-version.svg +1 -1
- package/readme-assets/cover-motion-still.webp +0 -0
- package/readme-assets/litfamily-machines.png +0 -0
package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "readme-studio-remotion-cover",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"render": "remotion render",
|
|
7
|
+
"still": "remotion still"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@remotion/cli": "4.0.526",
|
|
11
|
+
"react": "19.3.0",
|
|
12
|
+
"react-dom": "19.3.0",
|
|
13
|
+
"remotion": "4.0.526"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { AbsoluteFill, Img, interpolate, staticFile, useCurrentFrame } from "remotion";
|
|
2
|
+
import { getReadmeCoverLayout } from "./layout";
|
|
3
|
+
import { coverLoopProgress, titleMotionAt } from "./motion";
|
|
4
|
+
import type { ReadmeCoverProps } from "./Root";
|
|
5
|
+
|
|
6
|
+
const clamp = { extrapolateLeft: "clamp" as const, extrapolateRight: "clamp" as const };
|
|
7
|
+
|
|
8
|
+
export const ReadmeCover = ({ theme, mobile }: ReadmeCoverProps) => {
|
|
9
|
+
const frame = useCurrentFrame();
|
|
10
|
+
const progress = coverLoopProgress(frame);
|
|
11
|
+
const titleMotion = titleMotionAt(frame);
|
|
12
|
+
const backgroundScale = interpolate(progress, [0, 1], [1.035, 1.075], clamp);
|
|
13
|
+
const glowOpacity = interpolate(progress, [0, 1], [0.34, 0.52], clamp);
|
|
14
|
+
const rimOpacity = interpolate(progress, [0, 1], [0.16, 0.3], clamp);
|
|
15
|
+
const layout = getReadmeCoverLayout(theme, mobile);
|
|
16
|
+
const light = theme === "light";
|
|
17
|
+
const field = mobile ? layout.textFieldColor : `linear-gradient(90deg, ${layout.textFieldColor} 0%, ${layout.textFieldColor} 88%, transparent 100%)`;
|
|
18
|
+
const focalMask = mobile
|
|
19
|
+
? "linear-gradient(180deg, transparent 44%, rgba(0,0,0,.55) 56%, #000 68%)"
|
|
20
|
+
: "linear-gradient(90deg, transparent 47%, rgba(0,0,0,.55) 58%, #000 67%)";
|
|
21
|
+
const rimColor = light ? "rgba(232,106,74,.34)" : "rgba(169,220,200,.42)";
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<AbsoluteFill style={{ backgroundColor: light ? "#F4F1E9" : "#10191E", color: layout.ink, overflow: "hidden" }}>
|
|
25
|
+
<Img
|
|
26
|
+
id="depth-background"
|
|
27
|
+
src={staticFile("cover-background.png")}
|
|
28
|
+
alt=""
|
|
29
|
+
style={{ position: "absolute", left: "-4%", top: "-4%", width: "108%", height: "108%", objectFit: "cover", objectPosition: mobile ? layout.mobileArtworkObjectPosition : "center center", filter: "blur(18px)", scale: backgroundScale * 1.02 }}
|
|
30
|
+
/>
|
|
31
|
+
<Img
|
|
32
|
+
id="focal-plane"
|
|
33
|
+
src={staticFile("cover-background.png")}
|
|
34
|
+
alt=""
|
|
35
|
+
style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: layout.mobileArtworkObjectFit, objectPosition: mobile ? layout.mobileArtworkObjectPosition : "center center", scale: backgroundScale, maskImage: focalMask, WebkitMaskImage: focalMask }}
|
|
36
|
+
/>
|
|
37
|
+
<AbsoluteFill style={{ background: `linear-gradient(115deg, ${light ? "rgba(251,248,240,.14)" : "rgba(8,17,22,.16)"} 0%, transparent 58%, ${light ? "rgba(232,106,74,.10)" : "rgba(169,220,200,.10)"} 100%)` }} />
|
|
38
|
+
<AbsoluteFill
|
|
39
|
+
id="rim-light"
|
|
40
|
+
style={{
|
|
41
|
+
pointerEvents: "none",
|
|
42
|
+
background: mobile
|
|
43
|
+
? `linear-gradient(180deg, transparent 58%, ${rimColor} 62%, transparent 72%), radial-gradient(ellipse at 88% 96%, ${rimColor} 0%, transparent 48%)`
|
|
44
|
+
: `linear-gradient(90deg, transparent 53%, ${rimColor} 60%, transparent 68%), radial-gradient(ellipse at 94% 18%, ${rimColor} 0%, transparent 48%)`,
|
|
45
|
+
opacity: rimOpacity,
|
|
46
|
+
mixBlendMode: light ? "soft-light" : "screen",
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
<div style={{ position: "absolute", top: 0, left: 0, width: `${layout.textFieldWidthPercent}%`, height: `${layout.textFieldHeightPercent}%`, background: field, opacity: layout.textFieldOpacity, pointerEvents: "none" }} />
|
|
50
|
+
<div
|
|
51
|
+
style={{
|
|
52
|
+
position: "absolute",
|
|
53
|
+
width: mobile ? 470 : 620,
|
|
54
|
+
height: mobile ? 470 : 620,
|
|
55
|
+
top: mobile ? "6%" : "-12%",
|
|
56
|
+
right: mobile ? "-14%" : "-4%",
|
|
57
|
+
borderRadius: "50%",
|
|
58
|
+
background: layout.accentGlow,
|
|
59
|
+
filter: "blur(82px)",
|
|
60
|
+
opacity: glowOpacity,
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
<div
|
|
64
|
+
style={{
|
|
65
|
+
position: "absolute",
|
|
66
|
+
inset: layout.sideInsetPx,
|
|
67
|
+
border: `1px solid ${layout.frameBorder}`,
|
|
68
|
+
transform: mobile ? "none" : "perspective(1200px) rotateY(-3deg)",
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
<Img
|
|
72
|
+
src={staticFile(layout.microLabelAsset)}
|
|
73
|
+
alt=""
|
|
74
|
+
style={{ position: "absolute", left: layout.sideInsetPx, top: `${layout.microLabelTopPercent}%`, width: `${layout.microLabelWidthPercent}%`, height: `${layout.microLabelHeightPercent}%`, objectFit: "contain", objectPosition: "left center" }}
|
|
75
|
+
/>
|
|
76
|
+
<Img
|
|
77
|
+
src={staticFile(layout.titleAsset)}
|
|
78
|
+
alt=""
|
|
79
|
+
style={{ position: "absolute", top: `${layout.titleTopPercent}%`, left: layout.sideInsetPx, width: `${layout.titleWidthPercent}%`, height: `${layout.titleHeightPercent}%`, objectFit: "contain", objectPosition: "left center", translate: `0px ${titleMotion.titleOffsetY}px` }}
|
|
80
|
+
/>
|
|
81
|
+
<Img
|
|
82
|
+
src={staticFile(layout.subtitleAsset)}
|
|
83
|
+
alt=""
|
|
84
|
+
style={{ position: "absolute", left: layout.sideInsetPx, bottom: `${layout.subtitleBottomPercent}%`, width: `${layout.subtitleWidthPercent}%`, maxHeight: `${layout.subtitleMaxHeightPercent}%`, objectFit: "contain", objectPosition: "left center", translate: `0px ${titleMotion.subtitleOffsetY}px` }}
|
|
85
|
+
/>
|
|
86
|
+
<div
|
|
87
|
+
style={{
|
|
88
|
+
position: "absolute",
|
|
89
|
+
left: layout.sideInsetPx,
|
|
90
|
+
bottom: `${layout.separatorBottomPercent}%`,
|
|
91
|
+
width: `${layout.separatorWidthPercent}%`,
|
|
92
|
+
height: 1,
|
|
93
|
+
background: layout.separatorColor,
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
<svg aria-hidden="true" viewBox="0 0 1600 800" preserveAspectRatio="none" style={{ position: "absolute", inset: 0, width: "100%", height: "100%", opacity: 0.06, mixBlendMode: "soft-light", pointerEvents: "none" }}>
|
|
97
|
+
<filter id="grain"><feTurbulence type="fractalNoise" baseFrequency=".72" numOctaves="2" seed="17" /><feColorMatrix values=".35 0 0 0 .2 0 .35 0 0 .2 0 0 .35 0 .2 0 0 0 .18 0" /></filter>
|
|
98
|
+
<rect width="100%" height="100%" filter="url(#grain)" />
|
|
99
|
+
</svg>
|
|
100
|
+
</AbsoluteFill>
|
|
101
|
+
);
|
|
102
|
+
};
|
package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/Root.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Composition } from "remotion";
|
|
2
|
+
import { ReadmeCover } from "./ReadmeCover";
|
|
3
|
+
|
|
4
|
+
export type ReadmeCoverProps = {
|
|
5
|
+
theme: "light" | "dark";
|
|
6
|
+
mobile: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Root = () => (
|
|
10
|
+
<>
|
|
11
|
+
<Composition<ReadmeCoverProps>
|
|
12
|
+
id="ReadmeCoverWideLight"
|
|
13
|
+
component={ReadmeCover}
|
|
14
|
+
width={1600}
|
|
15
|
+
height={800}
|
|
16
|
+
fps={60}
|
|
17
|
+
durationInFrames={300}
|
|
18
|
+
defaultProps={{ theme: "light", mobile: false }}
|
|
19
|
+
/>
|
|
20
|
+
<Composition<ReadmeCoverProps>
|
|
21
|
+
id="ReadmeCoverWideDark"
|
|
22
|
+
component={ReadmeCover}
|
|
23
|
+
width={1600}
|
|
24
|
+
height={800}
|
|
25
|
+
fps={60}
|
|
26
|
+
durationInFrames={300}
|
|
27
|
+
defaultProps={{ theme: "dark", mobile: false }}
|
|
28
|
+
/>
|
|
29
|
+
<Composition<ReadmeCoverProps>
|
|
30
|
+
id="ReadmeCoverMobileLight"
|
|
31
|
+
component={ReadmeCover}
|
|
32
|
+
width={1080}
|
|
33
|
+
height={1350}
|
|
34
|
+
fps={60}
|
|
35
|
+
durationInFrames={300}
|
|
36
|
+
defaultProps={{ theme: "light", mobile: true }}
|
|
37
|
+
/>
|
|
38
|
+
<Composition<ReadmeCoverProps>
|
|
39
|
+
id="ReadmeCoverMobileDark"
|
|
40
|
+
component={ReadmeCover}
|
|
41
|
+
width={1080}
|
|
42
|
+
height={1350}
|
|
43
|
+
fps={60}
|
|
44
|
+
durationInFrames={300}
|
|
45
|
+
defaultProps={{ theme: "dark", mobile: true }}
|
|
46
|
+
/>
|
|
47
|
+
</>
|
|
48
|
+
);
|
package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/layout.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ReadmeCoverTheme = "light" | "dark";
|
|
2
|
+
|
|
3
|
+
export function getReadmeCoverLayout(theme: ReadmeCoverTheme, mobile: boolean) {
|
|
4
|
+
const light = theme === "light";
|
|
5
|
+
return {
|
|
6
|
+
titleAsset: `title-outline-${theme}.svg`,
|
|
7
|
+
subtitleAsset: `subtitle-outline-${theme}.svg`,
|
|
8
|
+
microLabelAsset: `micro-label-outline-${theme}.svg`,
|
|
9
|
+
ink: light ? "#15242A" : "#F4F1E9",
|
|
10
|
+
textFieldColor: light ? "#FBF8F0" : "#0C151A",
|
|
11
|
+
textFieldOpacity: 0.98,
|
|
12
|
+
textFieldWidthPercent: mobile ? 100 : 62,
|
|
13
|
+
textFieldHeightPercent: mobile ? 55 : 100,
|
|
14
|
+
mobileArtworkHeightPercent: mobile ? 45 : 0,
|
|
15
|
+
mobileArtworkObjectFit: "cover" as const,
|
|
16
|
+
mobileArtworkObjectPosition: mobile ? "84% center" : "center center",
|
|
17
|
+
artworkStartPercent: mobile ? null : 62,
|
|
18
|
+
sideInsetPx: mobile ? 76 : 126,
|
|
19
|
+
titleLeftPercent: mobile ? 7 : 7.875,
|
|
20
|
+
titleWidthPercent: mobile ? 86 : 50,
|
|
21
|
+
titleHeightPercent: mobile ? 22 : 27,
|
|
22
|
+
titleTopPercent: mobile ? 21 : 29,
|
|
23
|
+
subtitleWidthPercent: mobile ? 76 : 38,
|
|
24
|
+
subtitleMaxHeightPercent: mobile ? 5.5 : 6,
|
|
25
|
+
subtitleBottomPercent: mobile ? 45 : 19,
|
|
26
|
+
microLabelWidthPercent: mobile ? 56 : 32,
|
|
27
|
+
microLabelHeightPercent: mobile ? 3.5 : 3.2,
|
|
28
|
+
microLabelTopPercent: mobile ? 12 : 12,
|
|
29
|
+
separatorWidthPercent: mobile ? 72 : 42,
|
|
30
|
+
separatorBottomPercent: mobile ? 12 : 10,
|
|
31
|
+
frameBorder: light ? "rgba(21,36,42,.42)" : "rgba(244,241,233,.44)",
|
|
32
|
+
accentGlow: light ? "rgba(232,106,74,.16)" : "rgba(169,220,200,.18)",
|
|
33
|
+
separatorColor: light ? "rgba(21,36,42,.6)" : "rgba(244,241,233,.64)",
|
|
34
|
+
};
|
|
35
|
+
}
|
package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/src/motion.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function easeInOutCubic(progress: number) {
|
|
2
|
+
const t = Math.max(0, Math.min(1, progress));
|
|
3
|
+
return t < 0.5 ? 4 * t ** 3 : 1 - ((-2 * t + 2) ** 3) / 2;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function easedSegment(frame: number, start: number, end: number) {
|
|
7
|
+
if (frame <= start) return 0;
|
|
8
|
+
if (frame >= end) return 1;
|
|
9
|
+
return easeInOutCubic((frame - start) / (end - start));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function coverLoopProgress(frame: number) {
|
|
13
|
+
if (!Number.isFinite(frame)) throw new Error("cover frame must be finite");
|
|
14
|
+
const easeIn = easedSegment(frame, 36, 138);
|
|
15
|
+
const easeOut = easedSegment(frame, 162, 264);
|
|
16
|
+
return easeIn * (1 - easeOut);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function titleMotionAt(frame: number) {
|
|
20
|
+
if (!Number.isFinite(frame)) throw new Error("cover frame must be finite");
|
|
21
|
+
const enter = easedSegment(frame, 0, 18);
|
|
22
|
+
const settle = easedSegment(frame, 18, 48);
|
|
23
|
+
const pulse = enter * (1 - settle);
|
|
24
|
+
return { titleOffsetY: 8 * pulse, subtitleOffsetY: pulse === 0 ? 0 : -4 * pulse };
|
|
25
|
+
}
|
package/marketplace/plugins/litcodex/skills/readme-studio/templates/typography/package-lock.json
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "readme-studio-typography-tool",
|
|
3
|
+
"lockfileVersion": 3,
|
|
4
|
+
"requires": true,
|
|
5
|
+
"packages": {
|
|
6
|
+
"": {
|
|
7
|
+
"name": "readme-studio-typography-tool",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"fontkit": "2.0.4"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"node_modules/@swc/helpers": {
|
|
13
|
+
"version": "0.5.23",
|
|
14
|
+
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz",
|
|
15
|
+
"integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"tslib": "^2.8.0"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"node_modules/base64-js": {
|
|
22
|
+
"version": "1.5.1",
|
|
23
|
+
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
|
24
|
+
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
|
25
|
+
"funding": [
|
|
26
|
+
{
|
|
27
|
+
"type": "github",
|
|
28
|
+
"url": "https://github.com/sponsors/feross"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "patreon",
|
|
32
|
+
"url": "https://www.patreon.com/feross"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "consulting",
|
|
36
|
+
"url": "https://feross.org/support"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"license": "MIT"
|
|
40
|
+
},
|
|
41
|
+
"node_modules/brotli": {
|
|
42
|
+
"version": "1.3.3",
|
|
43
|
+
"resolved": "https://registry.npmjs.org/brotli/-/brotli-1.3.3.tgz",
|
|
44
|
+
"integrity": "sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"base64-js": "^1.1.2"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"node_modules/clone": {
|
|
51
|
+
"version": "2.1.2",
|
|
52
|
+
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
|
53
|
+
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=0.8"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"node_modules/dfa": {
|
|
60
|
+
"version": "1.2.0",
|
|
61
|
+
"resolved": "https://registry.npmjs.org/dfa/-/dfa-1.2.0.tgz",
|
|
62
|
+
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
|
|
63
|
+
"license": "MIT"
|
|
64
|
+
},
|
|
65
|
+
"node_modules/fast-deep-equal": {
|
|
66
|
+
"version": "3.1.3",
|
|
67
|
+
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
|
68
|
+
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
|
69
|
+
"license": "MIT"
|
|
70
|
+
},
|
|
71
|
+
"node_modules/fontkit": {
|
|
72
|
+
"version": "2.0.4",
|
|
73
|
+
"resolved": "https://registry.npmjs.org/fontkit/-/fontkit-2.0.4.tgz",
|
|
74
|
+
"integrity": "sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==",
|
|
75
|
+
"license": "MIT",
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@swc/helpers": "^0.5.12",
|
|
78
|
+
"brotli": "^1.3.2",
|
|
79
|
+
"clone": "^2.1.2",
|
|
80
|
+
"dfa": "^1.2.0",
|
|
81
|
+
"fast-deep-equal": "^3.1.3",
|
|
82
|
+
"restructure": "^3.0.0",
|
|
83
|
+
"tiny-inflate": "^1.0.3",
|
|
84
|
+
"unicode-properties": "^1.4.0",
|
|
85
|
+
"unicode-trie": "^2.0.0"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"node_modules/pako": {
|
|
89
|
+
"version": "0.2.9",
|
|
90
|
+
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
|
|
91
|
+
"integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==",
|
|
92
|
+
"license": "MIT"
|
|
93
|
+
},
|
|
94
|
+
"node_modules/restructure": {
|
|
95
|
+
"version": "3.0.2",
|
|
96
|
+
"resolved": "https://registry.npmjs.org/restructure/-/restructure-3.0.2.tgz",
|
|
97
|
+
"integrity": "sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw==",
|
|
98
|
+
"license": "MIT"
|
|
99
|
+
},
|
|
100
|
+
"node_modules/tiny-inflate": {
|
|
101
|
+
"version": "1.0.3",
|
|
102
|
+
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
|
|
103
|
+
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",
|
|
104
|
+
"license": "MIT"
|
|
105
|
+
},
|
|
106
|
+
"node_modules/tslib": {
|
|
107
|
+
"version": "2.8.1",
|
|
108
|
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
|
109
|
+
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
|
110
|
+
"license": "0BSD"
|
|
111
|
+
},
|
|
112
|
+
"node_modules/unicode-properties": {
|
|
113
|
+
"version": "1.4.1",
|
|
114
|
+
"resolved": "https://registry.npmjs.org/unicode-properties/-/unicode-properties-1.4.1.tgz",
|
|
115
|
+
"integrity": "sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==",
|
|
116
|
+
"license": "MIT",
|
|
117
|
+
"dependencies": {
|
|
118
|
+
"base64-js": "^1.3.0",
|
|
119
|
+
"unicode-trie": "^2.0.0"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"node_modules/unicode-trie": {
|
|
123
|
+
"version": "2.0.0",
|
|
124
|
+
"resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-2.0.0.tgz",
|
|
125
|
+
"integrity": "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==",
|
|
126
|
+
"license": "MIT",
|
|
127
|
+
"dependencies": {
|
|
128
|
+
"pako": "^0.2.5",
|
|
129
|
+
"tiny-inflate": "^1.0.0"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
package/marketplace/plugins/litcodex/skills/readme-studio/templates/typography/shape-text-to-svg.mjs
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { lstatSync, realpathSync, writeFileSync } from "node:fs";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
export const MAX_FONT_BYTES = 64 * 1024 * 1024;
|
|
10
|
+
|
|
11
|
+
function escapeXml(value) {
|
|
12
|
+
return String(value).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function number(value) {
|
|
16
|
+
const rounded = Number(value.toFixed(4));
|
|
17
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function missingCodePoint(font, text) {
|
|
21
|
+
if (typeof font.hasGlyphForCodePoint !== "function") return null;
|
|
22
|
+
for (const character of text) {
|
|
23
|
+
const codePoint = character.codePointAt(0);
|
|
24
|
+
if (codePoint !== undefined && !font.hasGlyphForCodePoint(codePoint)) {
|
|
25
|
+
return `missing glyph U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} in selected font`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function validateFontFile(fontPath) {
|
|
32
|
+
if (typeof fontPath !== "string" || fontPath.trim().length === 0) throw new Error("an explicit font path is required");
|
|
33
|
+
let stat;
|
|
34
|
+
try {
|
|
35
|
+
stat = lstatSync(fontPath);
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error("font file must be an accessible regular non-symlink file");
|
|
38
|
+
}
|
|
39
|
+
if (stat.isSymbolicLink() || !stat.isFile()) throw new Error("font path must be a regular non-symlink file");
|
|
40
|
+
if (stat.size <= 0) throw new Error("font file must be non-empty");
|
|
41
|
+
if (stat.size > MAX_FONT_BYTES) throw new Error(`font exceeds the ${MAX_FONT_BYTES / (1024 * 1024)} MiB limit`);
|
|
42
|
+
return { path: realpathSync(fontPath), size: stat.size };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function writeOutputNoClobber(outputRoot, output, contents) {
|
|
46
|
+
if (typeof outputRoot !== "string" || outputRoot.trim().length === 0) throw new Error("an explicit output root is required");
|
|
47
|
+
if (typeof output !== "string" || output.trim().length === 0) throw new Error("a non-empty output path is required");
|
|
48
|
+
const rootCandidate = resolve(outputRoot);
|
|
49
|
+
let rootStat;
|
|
50
|
+
try {
|
|
51
|
+
rootStat = lstatSync(rootCandidate);
|
|
52
|
+
} catch {
|
|
53
|
+
throw new Error("output root must be an existing directory");
|
|
54
|
+
}
|
|
55
|
+
if (rootStat.isSymbolicLink()) throw new Error("output root must not be a symlink");
|
|
56
|
+
if (!rootStat.isDirectory()) throw new Error("output root must be an existing directory");
|
|
57
|
+
const canonicalRoot = realpathSync(rootCandidate);
|
|
58
|
+
const targetCandidate = isAbsolute(output) ? resolve(output) : resolve(canonicalRoot, output);
|
|
59
|
+
const targetRelative = relative(canonicalRoot, targetCandidate);
|
|
60
|
+
if (targetRelative === "" || targetRelative === ".." || targetRelative.startsWith(`..${sep}`) || isAbsolute(targetRelative)) {
|
|
61
|
+
throw new Error("output path must resolve inside the explicit output root");
|
|
62
|
+
}
|
|
63
|
+
const segments = targetRelative.split(sep);
|
|
64
|
+
let parent = canonicalRoot;
|
|
65
|
+
for (const segment of segments.slice(0, -1)) {
|
|
66
|
+
parent = join(parent, segment);
|
|
67
|
+
let stat;
|
|
68
|
+
try {
|
|
69
|
+
stat = lstatSync(parent);
|
|
70
|
+
} catch {
|
|
71
|
+
throw new Error(`output parent does not exist or cannot be inspected: ${parent}`);
|
|
72
|
+
}
|
|
73
|
+
if (stat.isSymbolicLink()) throw new Error(`output parent chain contains a symlink: ${parent}`);
|
|
74
|
+
if (!stat.isDirectory()) throw new Error(`output parent is not a directory: ${parent}`);
|
|
75
|
+
if (realpathSync(parent) !== parent) throw new Error(`output parent chain is not canonical or contains a symlink: ${parent}`);
|
|
76
|
+
}
|
|
77
|
+
const target = join(parent, segments[segments.length - 1]);
|
|
78
|
+
let existing;
|
|
79
|
+
try {
|
|
80
|
+
existing = lstatSync(target);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (!error || typeof error !== "object" || error.code !== "ENOENT") throw error;
|
|
83
|
+
}
|
|
84
|
+
if (existing) throw new Error(`refusing to overwrite existing output: ${target}`);
|
|
85
|
+
try {
|
|
86
|
+
writeFileSync(target, contents, { encoding: "utf8", flag: "wx" });
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error && typeof error === "object" && error.code === "EEXIST") throw new Error(`refusing to overwrite existing output: ${target}`);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
return target;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function shapeTextToSvg({ text, fontPath, fontkit, fontSize = 100, tracking = 0, title = text, fill = "#151a20" } = {}) {
|
|
95
|
+
if (typeof text !== "string" || text.length === 0 || text.trim().length === 0) throw new Error("text must be non-empty");
|
|
96
|
+
if (Array.from(text).length > 500) throw new Error("text exceeds the 500-character cover limit");
|
|
97
|
+
if (typeof fontPath !== "string" || fontPath.trim().length === 0) throw new Error("an explicit font path is required");
|
|
98
|
+
if (!Number.isFinite(fontSize) || fontSize <= 0 || !Number.isFinite(tracking)) throw new Error("font size must be positive and tracking must be finite");
|
|
99
|
+
if (!/^#[\da-f]{3}(?:[\da-f]{3})?$/iu.test(fill)) throw new Error("fill must be a 3- or 6-digit hex color");
|
|
100
|
+
if (!fontkit || typeof fontkit.openSync !== "function") throw new Error("fontkit@2.0.4 is required from the task-local typography tool");
|
|
101
|
+
|
|
102
|
+
const font = fontkit.openSync(fontPath);
|
|
103
|
+
const missing = missingCodePoint(font, text);
|
|
104
|
+
if (missing) throw new Error(missing);
|
|
105
|
+
const unitsPerEm = font.unitsPerEm;
|
|
106
|
+
if (!Number.isFinite(unitsPerEm) || unitsPerEm <= 0) throw new Error("font has invalid unitsPerEm metadata");
|
|
107
|
+
const ascent = font.ascent ?? unitsPerEm * 0.8;
|
|
108
|
+
const descent = font.descent ?? -unitsPerEm * 0.2;
|
|
109
|
+
if (!Number.isFinite(ascent) || !Number.isFinite(descent) || ascent <= descent) throw new Error("font has invalid finite vertical metrics");
|
|
110
|
+
const run = font.layout(text);
|
|
111
|
+
if (!run || !Array.isArray(run.glyphs) || !Array.isArray(run.positions) || run.glyphs.length === 0) {
|
|
112
|
+
throw new Error("fontkit returned no shaped glyph run");
|
|
113
|
+
}
|
|
114
|
+
if (run.glyphs.length !== run.positions.length) throw new Error("fontkit glyph and position counts do not match");
|
|
115
|
+
const scale = fontSize / unitsPerEm;
|
|
116
|
+
const padding = fontSize * 0.08;
|
|
117
|
+
if (!Number.isFinite(scale) || scale <= 0 || !Number.isFinite(padding) || padding <= 0) throw new Error("font produced invalid SVG geometry");
|
|
118
|
+
const glyphs = [];
|
|
119
|
+
let penX = 0;
|
|
120
|
+
let penY = 0;
|
|
121
|
+
let minX = 0;
|
|
122
|
+
let maxX = 0;
|
|
123
|
+
let minYUp = Math.min(0, descent);
|
|
124
|
+
let maxYUp = Math.max(0, ascent);
|
|
125
|
+
|
|
126
|
+
for (let index = 0; index < run.glyphs.length; index += 1) {
|
|
127
|
+
const glyph = run.glyphs[index];
|
|
128
|
+
const position = run.positions[index];
|
|
129
|
+
if (glyph.id === 0) throw new Error("fontkit shaped a missing glyph (.notdef); verify glyph coverage or choose another font");
|
|
130
|
+
for (const key of ["xAdvance", "yAdvance", "xOffset", "yOffset"]) {
|
|
131
|
+
if (!Number.isFinite(position[key])) throw new Error(`fontkit returned an invalid ${key}`);
|
|
132
|
+
}
|
|
133
|
+
const pathData = glyph.path?.toSVG?.();
|
|
134
|
+
if (typeof pathData !== "string") throw new Error(`glyph ${glyph.id} has no SVG outline`);
|
|
135
|
+
const originX = penX + position.xOffset * scale;
|
|
136
|
+
const originYUp = penY + position.yOffset;
|
|
137
|
+
if (pathData.length > 0) {
|
|
138
|
+
const bbox = glyph.bbox ?? glyph.path?.bbox;
|
|
139
|
+
if (
|
|
140
|
+
!bbox ||
|
|
141
|
+
![bbox.minX, bbox.maxX, bbox.minY, bbox.maxY].every(Number.isFinite) ||
|
|
142
|
+
bbox.minX > bbox.maxX ||
|
|
143
|
+
bbox.minY > bbox.maxY
|
|
144
|
+
) {
|
|
145
|
+
throw new Error(`glyph bounding box for glyph ${glyph.id} must contain finite, ordered min/max coordinates`);
|
|
146
|
+
}
|
|
147
|
+
const glyphMinX = originX + bbox.minX * scale;
|
|
148
|
+
const glyphMaxX = originX + bbox.maxX * scale;
|
|
149
|
+
const glyphMinYUp = originYUp + bbox.minY;
|
|
150
|
+
const glyphMaxYUp = originYUp + bbox.maxY;
|
|
151
|
+
if (![originX, originYUp, glyphMinX, glyphMaxX, glyphMinYUp, glyphMaxYUp].every(Number.isFinite)) {
|
|
152
|
+
throw new Error(`glyph ${glyph.id} produced non-finite SVG geometry`);
|
|
153
|
+
}
|
|
154
|
+
minX = Math.min(minX, glyphMinX);
|
|
155
|
+
maxX = Math.max(maxX, glyphMaxX);
|
|
156
|
+
minYUp = Math.min(minYUp, glyphMinYUp);
|
|
157
|
+
maxYUp = Math.max(maxYUp, glyphMaxYUp);
|
|
158
|
+
glyphs.push({ pathData, originX, originYUp });
|
|
159
|
+
}
|
|
160
|
+
penX += position.xAdvance * scale + (index < run.glyphs.length - 1 ? tracking : 0);
|
|
161
|
+
penY += position.yAdvance;
|
|
162
|
+
if (!Number.isFinite(penX) || !Number.isFinite(penY)) throw new Error("shaped run produced non-finite advance geometry");
|
|
163
|
+
minX = Math.min(minX, penX);
|
|
164
|
+
maxX = Math.max(maxX, penX);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const width = maxX - minX + padding * 2;
|
|
168
|
+
const height = (maxYUp - minYUp) * scale + padding * 2;
|
|
169
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) throw new Error("font produced non-positive or non-finite SVG geometry");
|
|
170
|
+
const baseline = padding + maxYUp * scale;
|
|
171
|
+
const glyphNodes = glyphs.map(({ pathData, originX, originYUp }) => {
|
|
172
|
+
const x = padding + originX - minX;
|
|
173
|
+
const y = baseline - originYUp * scale;
|
|
174
|
+
return `<path d="${escapeXml(pathData)}" transform="translate(${number(x)} ${number(y)}) scale(${number(scale)} ${number(-scale)})"/>`;
|
|
175
|
+
});
|
|
176
|
+
const familyName = typeof font.familyName === "string" && font.familyName.length > 0 ? font.familyName : "selected font";
|
|
177
|
+
const fontFile = basename(fontPath);
|
|
178
|
+
const safeTitle = escapeXml(title);
|
|
179
|
+
const description = escapeXml(`Editable source text: ${text}; font: ${familyName} (${fontFile})`);
|
|
180
|
+
return [
|
|
181
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${number(width)} ${number(height)}" role="img" aria-labelledby="title description" data-font-family="${escapeXml(familyName)}" data-font-file="${escapeXml(fontFile)}">`,
|
|
182
|
+
`<title id="title">${safeTitle}</title>`,
|
|
183
|
+
`<desc id="description">${description}</desc>`,
|
|
184
|
+
`<g fill="${fill}">${glyphNodes.join("")}</g>`,
|
|
185
|
+
"</svg>",
|
|
186
|
+
"",
|
|
187
|
+
].join("\n");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function parseArgs(argv) {
|
|
191
|
+
const options = {};
|
|
192
|
+
const values = new Map([
|
|
193
|
+
["--font", "fontPath"],
|
|
194
|
+
["--text", "text"],
|
|
195
|
+
["--output-root", "outputRoot"],
|
|
196
|
+
["--output", "output"],
|
|
197
|
+
["--font-size", "fontSize"],
|
|
198
|
+
["--tracking", "tracking"],
|
|
199
|
+
["--title", "title"],
|
|
200
|
+
["--fill", "fill"],
|
|
201
|
+
]);
|
|
202
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
203
|
+
const key = argv[index];
|
|
204
|
+
const property = values.get(key);
|
|
205
|
+
if (!property) throw new Error(`unknown option ${key}`);
|
|
206
|
+
const value = argv[index + 1];
|
|
207
|
+
if (value === undefined || value.startsWith("--")) throw new Error(`${key} requires a value`);
|
|
208
|
+
options[property] = value;
|
|
209
|
+
index += 1;
|
|
210
|
+
}
|
|
211
|
+
if (!options.fontPath || !options.text || !options.outputRoot || !options.output) throw new Error("usage: shape-text-to-svg.mjs --font <font-file> --text <source-text> --output-root <existing-task-workspace> --output <relative-new-svg-path> [--font-size 100] [--tracking 0] [--fill #151a20]");
|
|
212
|
+
for (const key of ["fontSize", "tracking"]) {
|
|
213
|
+
if (options[key] !== undefined) {
|
|
214
|
+
options[key] = Number(options[key]);
|
|
215
|
+
if (!Number.isFinite(options[key])) throw new Error(`--${key === "fontSize" ? "font-size" : key} must be numeric`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return options;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function main(argv) {
|
|
222
|
+
const options = parseArgs(argv);
|
|
223
|
+
const fontFile = validateFontFile(resolve(options.fontPath));
|
|
224
|
+
const fontkit = require("fontkit");
|
|
225
|
+
const svg = shapeTextToSvg({ ...options, fontPath: fontFile.path, fontkit });
|
|
226
|
+
writeOutputNoClobber(options.outputRoot, options.output, svg);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
const isMain = process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
231
|
+
if (isMain) {
|
|
232
|
+
try {
|
|
233
|
+
main(process.argv.slice(2));
|
|
234
|
+
} catch (error) {
|
|
235
|
+
process.stderr.write(`readme-studio: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
236
|
+
process.exitCode = 1;
|
|
237
|
+
}
|
|
238
|
+
}
|