swift-rust 1.0.0 → 1.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.
package/bin/build.mjs CHANGED
@@ -347,6 +347,17 @@ async function main() {
347
347
  process.stdout.write(` ${paint("green", "✓")} copied public/\n`);
348
348
  }
349
349
 
350
+ // App-directory metadata icons (app/favicon.ico, app/icon.svg, …) → static root.
351
+ // The <link> tags are already baked into the rendered HTML by the dev server.
352
+ const APP_ICON_FILES = ["favicon.ico", "favicon.svg", "icon.svg", "icon.png", "apple-icon.png"];
353
+ for (const name of APP_ICON_FILES) {
354
+ const src = join(APP_DIR, name);
355
+ if (existsSync(src)) {
356
+ cpSync(src, join(STATIC_DIR, name));
357
+ process.stdout.write(` ${paint("green", "✓")} ${name}\n`);
358
+ }
359
+ }
360
+
350
361
  writeConfigJson(OUT_DIR, hasPublic);
351
362
 
352
363
  const total = Date.now() - start;
@@ -690,11 +690,38 @@ function errorOverlayHTML(message, stack, extra) {
690
690
  return renderErrorOverlay({ message, stack, ...(extra || {}) });
691
691
  }
692
692
 
693
+ // Metadata icon files looked up at the root of the app directory (app/ or
694
+ // app/src/), Next.js App Router style. Found files are served from the site
695
+ // root and auto-linked in <head>.
696
+ const APP_ICON_FILES = ["favicon.ico", "favicon.svg", "icon.svg", "icon.png", "apple-icon.png"];
697
+
698
+ function discoverAppIcons() {
699
+ const icons = [];
700
+ for (const name of APP_ICON_FILES) {
701
+ const file = join(APP_DIR, name);
702
+ if (existsSync(file) && statSync(file).isFile()) icons.push({ name, file });
703
+ }
704
+ return icons;
705
+ }
706
+
707
+ function buildAppIconsLinkTags() {
708
+ return discoverAppIcons()
709
+ .map(({ name }) => {
710
+ const ext = extname(name).toLowerCase();
711
+ if (name.startsWith("apple-icon")) return `<link rel="apple-touch-icon" href="/${name}" />`;
712
+ if (ext === ".ico") return `<link rel="icon" href="/${name}" sizes="any" />`;
713
+ if (ext === ".svg") return `<link rel="icon" href="/${name}" type="image/svg+xml" />`;
714
+ return `<link rel="icon" href="/${name}" />`;
715
+ })
716
+ .join("\n");
717
+ }
718
+
693
719
  async function buildHead(head) {
694
720
  const css = await getProcessedGlobalsCss();
695
721
  const fontLink = buildGoogleFontsLinkTag();
696
722
  return [
697
723
  head || "",
724
+ buildAppIconsLinkTags(),
698
725
  fontLink,
699
726
  css ? `<style data-swift-rust-globals>${escapeForStyleTag(css)}</style>` : "",
700
727
  ].filter(Boolean).join("\n");
@@ -954,6 +981,22 @@ async function handleRequest(req, res) {
954
981
  return;
955
982
  }
956
983
 
984
+ // App-directory metadata icons (app/favicon.ico, app/icon.svg, …) served
985
+ // from the site root, Next.js style.
986
+ {
987
+ const iconName = pathname.replace(/^\/+/, "");
988
+ if (APP_ICON_FILES.includes(iconName)) {
989
+ const candidate = join(APP_DIR, iconName);
990
+ if (existsSync(candidate) && statSync(candidate).isFile()) {
991
+ const ext = extname(candidate).toLowerCase();
992
+ const mime = { ".ico": "image/x-icon", ".svg": "image/svg+xml", ".png": "image/png" }[ext] || "application/octet-stream";
993
+ res.writeHead(200, { "Content-Type": mime });
994
+ res.end(readFileSync(candidate));
995
+ return;
996
+ }
997
+ }
998
+ }
999
+
957
1000
  if (existsSync(PUBLIC_DIR)) {
958
1001
  const safe = pathname.replace(/\.\.+/g, "").replace(/^\/+/, "");
959
1002
  const candidate = join(PUBLIC_DIR, safe);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swift-rust",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "The full-stack React framework powered with Rust + Bun. TSX-first, Rust rendering, 10x faster than Next.js, single binary deploy.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://swift-rust.dev",