Skip to content

Commit db7784f

Browse files
Merge main into fix/issue-21821
2 parents 67c9f4b + 6e79211 commit db7784f

457 files changed

Lines changed: 17311 additions & 8812 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.repos/alchemy-effect/packages/frontend-frameworks/src/core/NodeServe.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface NodeServeHandler {
4848
export interface NodeServeEntryOptions {
4949
/**
5050
* JS expression resolving the on-disk client-assets directory
51-
* (typically `fileURLToPath(new URL("../client/", import.meta.url))`).
51+
* (typically `fileURLToPath(new URL("../shared/", import.meta.url))`).
5252
* Omit to skip static-file serving (Next.js handles its own assets).
5353
*/
5454
readonly clientDirExpression?: string | undefined;

‎.repos/alchemy-effect/packages/frontend-frameworks/src/core/test/NodeServe.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ describe("relativeClientDirExpression", () => {
2828
"/project/dist/server/serve-node.mjs",
2929
"/project/dist/client",
3030
),
31-
).toBe(`fileURLToPath(new URL("../client/", import.meta.url))`);
31+
).toBe(`fileURLToPath(new URL("../shared/", import.meta.url))`);
3232
});
3333
});
3434

3535
describe("makeNodeServeEntrySource", () => {
3636
it("listens on PORT, answers /health, serves static files, then the fetch handler", () => {
3737
const source = makeNodeServeEntrySource({
38-
clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
38+
clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
3939
handler: {
4040
kind: "fetch",
4141
imports: `import { handler } from "./index.mjs";`,
@@ -131,7 +131,7 @@ describe("makeNodeServeEntrySource", () => {
131131

132132
it("does not map GET / onto public/index.html (SSR home stays on the handler)", () => {
133133
const source = makeNodeServeEntrySource({
134-
clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
134+
clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
135135
handler: {
136136
kind: "node",
137137
imports: `import { handler } from "./index.mjs";`,
4.05 KB
Loading
1.88 KB
Loading
1.39 KB
Loading
285 Bytes
Loading
-381 Bytes
Loading
1.68 KB
Loading

‎apps/mobile/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"config:prod": "APP_VARIANT=production expo config",
4242
"profile:android:hermes": "mkdir -p profiles/review && react-native profile-hermes profiles/review",
4343
"sync:chip-icons": "node scripts/sync-context-chip-icons.mjs",
44+
"sync:link-icons": "node scripts/sync-link-icons.ts",
4445
"sync:pierre-icons": "node scripts/sync-pierre-file-icons.mjs",
4546
"measure-renders": "node scripts/measure-renders.mts",
4647
"generate": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/generate-uniwind-themes.mts",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// The native markdown renderer draws a link's icon from a raster image, so each source control
2+
// host's mark is rendered from its definition's artwork into a bundled PNG.
3+
import * as NodeFS from "node:fs";
4+
import * as NodeModule from "node:module";
5+
import * as NodePath from "node:path";
6+
import * as NodeURL from "node:url";
7+
8+
import {
9+
sourceControlClients,
10+
type SourceControlIcon,
11+
} from "@t3tools/client-runtime/source-control-clients";
12+
13+
const appDirectory = NodePath.resolve(
14+
NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)),
15+
"..",
16+
);
17+
const outputDirectory = NodePath.join(appDirectory, "assets/link-icons");
18+
const generatedModulePath = NodePath.join(appDirectory, "src/lib/markdownLinkIcons.generated.ts");
19+
const sharp = NodeModule.createRequire(
20+
NodePath.resolve(appDirectory, "../../scripts/package.json"),
21+
)("sharp");
22+
23+
const SIZE = 64;
24+
25+
function attribute(name: string, value: string | number | undefined): string {
26+
return value === undefined ? "" : ` ${name}="${value}"`;
27+
}
28+
29+
// A monochrome mark is tinted by the renderer, which only reads its alpha.
30+
function svgMarkup(icon: SourceControlIcon): string {
31+
const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
32+
value === undefined
33+
? "none"
34+
: typeof value === "string"
35+
? value.replace("currentColor", "#ffffff")
36+
: `url(#${value.gradient})`;
37+
const gradients = (icon.gradients ?? [])
38+
.map(
39+
(gradient) =>
40+
`<linearGradient id="${gradient.id}" x1="${gradient.x1}" y1="${gradient.y1}" x2="${gradient.x2}" y2="${gradient.y2}" gradientUnits="userSpaceOnUse"${attribute("gradientTransform", gradient.transform)}>${gradient.stops
41+
.map(
42+
(stop) =>
43+
`<stop offset="${stop.offset}" stop-color="${stop.color}"${attribute("stop-opacity", stop.opacity)}/>`,
44+
)
45+
.join("")}</linearGradient>`,
46+
)
47+
.join("");
48+
const paths = icon.paths
49+
.map(
50+
(path) =>
51+
`<path d="${path.d}" fill="${paint(path.fill)}"${attribute("fill-rule", path.fillRule)}${attribute("fill-opacity", path.fillOpacity)}${attribute("stroke", path.stroke === undefined ? undefined : paint(path.stroke))}${attribute("stroke-width", path.strokeWidth)}/>`,
52+
)
53+
.join("");
54+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="${icon.viewBox}" fill="none"><defs>${gradients}</defs>${paths}</svg>`;
55+
}
56+
57+
NodeFS.rmSync(outputDirectory, { recursive: true, force: true });
58+
NodeFS.mkdirSync(outputDirectory, { recursive: true });
59+
60+
const kinds: string[] = [];
61+
for (const definition of sourceControlClients.definitions) {
62+
if (definition.icon === null) continue;
63+
await sharp(Buffer.from(svgMarkup(definition.icon)), { density: 72 * 4 })
64+
.resize(SIZE, SIZE, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } })
65+
.png()
66+
.toFile(NodePath.join(outputDirectory, `${definition.kind}.png`));
67+
kinds.push(definition.kind);
68+
}
69+
70+
NodeFS.writeFileSync(
71+
generatedModulePath,
72+
`import type { ImageSourcePropType } from "react-native";\n\nexport const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {\n${kinds
73+
.toSorted()
74+
.map(
75+
(kind) =>
76+
` ${/^\w+$/u.test(kind) ? kind : `"${kind}"`}: require("../../assets/link-icons/${kind}.png"),`,
77+
)
78+
.join("\n")}\n};\n`,
79+
);

0 commit comments

Comments
 (0)