@timber-js/app 0.2.0-alpha.155 → 0.2.0-alpha.157

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.
Files changed (74) hide show
  1. package/dist/_chunks/{actions-8lJZYYGq.js → actions-CqE7SW7E.js} +4 -4
  2. package/dist/_chunks/{actions-8lJZYYGq.js.map → actions-CqE7SW7E.js.map} +1 -1
  3. package/dist/_chunks/{build-output-helper-B20ZuTSA.js → build-output-helper-C8q4Zpf5.js} +62 -9
  4. package/dist/_chunks/build-output-helper-C8q4Zpf5.js.map +1 -0
  5. package/dist/_chunks/{cache-api-e1E4i3Vy.js → cache-api-Cbyh3RW4.js} +2 -2
  6. package/dist/_chunks/{cache-api-e1E4i3Vy.js.map → cache-api-Cbyh3RW4.js.map} +1 -1
  7. package/dist/_chunks/canonicalize-P41GR6tY.js.map +1 -1
  8. package/dist/_chunks/{cli-schema-sync-ChsRzw8o.js → cli-schema-sync-DcmQrzJG.js} +14 -6
  9. package/dist/_chunks/{cli-schema-sync-ChsRzw8o.js.map → cli-schema-sync-DcmQrzJG.js.map} +1 -1
  10. package/dist/_chunks/define-CFmvb4Bt.js.map +1 -1
  11. package/dist/_chunks/fast-hash-D6hIVt1Y.js.map +1 -1
  12. package/dist/_chunks/format-CfwjgPz9.js.map +1 -1
  13. package/dist/_chunks/{href-validation-FiA_rToW.js → href-validation-CMc5JRls.js} +3 -3
  14. package/dist/_chunks/{href-validation-FiA_rToW.js.map → href-validation-CMc5JRls.js.map} +1 -1
  15. package/dist/_chunks/{logger-DvmCWhN9.js → logger-C5v1IMuh.js} +4 -4
  16. package/dist/_chunks/{logger-DvmCWhN9.js.map → logger-C5v1IMuh.js.map} +1 -1
  17. package/dist/_chunks/navigation-root-bUDZLw74.js.map +1 -1
  18. package/dist/_chunks/{plugin-context-GfDWsdd2.js → plugin-context-DUl3dnCF.js} +47 -2
  19. package/dist/_chunks/{plugin-context-GfDWsdd2.js.map → plugin-context-DUl3dnCF.js.map} +1 -1
  20. package/dist/_chunks/schema-bridge-BY3QLBL7.js.map +1 -1
  21. package/dist/_chunks/use-query-states-CbeQmext.js.map +1 -1
  22. package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +1 -1
  23. package/dist/_chunks/{validation-taUkvA4Q.js → validation-CnKhGJsp.js} +2 -2
  24. package/dist/_chunks/{validation-taUkvA4Q.js.map → validation-CnKhGJsp.js.map} +1 -1
  25. package/dist/_chunks/{walkers-DZuFKqFX.js → walkers-D5jCGPum.js} +2 -2
  26. package/dist/_chunks/{walkers-DZuFKqFX.js.map → walkers-D5jCGPum.js.map} +1 -1
  27. package/dist/adapters/build-output-helper.d.ts +1 -0
  28. package/dist/adapters/build-output-helper.d.ts.map +1 -1
  29. package/dist/adapters/cloudflare-dev.js.map +1 -1
  30. package/dist/adapters/cloudflare-kv-cache.js.map +1 -1
  31. package/dist/adapters/cloudflare.d.ts.map +1 -1
  32. package/dist/adapters/cloudflare.js +35 -5
  33. package/dist/adapters/cloudflare.js.map +1 -1
  34. package/dist/adapters/nitro.js +2 -2
  35. package/dist/adapters/nitro.js.map +1 -1
  36. package/dist/adapters/shared.d.ts +1 -11
  37. package/dist/adapters/shared.d.ts.map +1 -1
  38. package/dist/cache/index.js +1 -1
  39. package/dist/cache/index.js.map +1 -1
  40. package/dist/cli.js +2 -2
  41. package/dist/cli.js.map +1 -1
  42. package/dist/client/error-boundary.js.map +1 -1
  43. package/dist/client/index.js +1 -1
  44. package/dist/client/index.js.map +1 -1
  45. package/dist/client/internal.js.map +1 -1
  46. package/dist/codec.js.map +1 -1
  47. package/dist/cookies/index.js +1 -1
  48. package/dist/cookies/index.js.map +1 -1
  49. package/dist/fonts/google.d.ts.map +1 -1
  50. package/dist/index.js +58 -45
  51. package/dist/index.js.map +1 -1
  52. package/dist/plugins/fonts.d.ts.map +1 -1
  53. package/dist/routing/index.js +2 -2
  54. package/dist/search-params/index.js.map +1 -1
  55. package/dist/server/asset-headers.d.ts +7 -3
  56. package/dist/server/asset-headers.d.ts.map +1 -1
  57. package/dist/server/index.js +2 -2
  58. package/dist/server/index.js.map +1 -1
  59. package/dist/server/internal.js +20 -14
  60. package/dist/server/internal.js.map +1 -1
  61. package/dist/server/pipeline-phases.d.ts.map +1 -1
  62. package/docs/more/50-ai-agent-instructions.mdx +169 -0
  63. package/package.json +3 -3
  64. package/src/adapters/build-output-helper.ts +52 -2
  65. package/src/adapters/cloudflare.ts +34 -4
  66. package/src/adapters/shared.ts +34 -6
  67. package/src/fonts/google.ts +56 -5
  68. package/src/plugins/fonts.ts +6 -0
  69. package/src/server/asset-headers.ts +7 -3
  70. package/src/server/pipeline-phases.ts +10 -2
  71. package/src/server/stream-utils.ts +1 -1
  72. package/dist/_chunks/build-output-helper-B20ZuTSA.js.map +0 -1
  73. package/dist/_chunks/cli-schema-sync-D4urWkeV.js +0 -2
  74. package/dist/_chunks/plugin-context-DurqFBuY.js +0 -2
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { a as resolveAppDir, c as createNoopTimer, d as __toCommonJS, l as __esmMin, n as loadTimberConfigFile, o as resolveBuildDir, r as mergeFileConfig, s as resolveClientJavascript, t as createPluginContext, u as __exportAll } from "./_chunks/plugin-context-DUl3dnCF.js";
1
2
  import { c as isDynamicMetadataExtension, l as isMetadataRouteServePath, r as canonicalize } from "./_chunks/canonicalize-P41GR6tY.js";
2
3
  import { t as matchUrlParts } from "./_chunks/tree-match-D2l830j2.js";
3
- import { h as swallow } from "./_chunks/logger-DvmCWhN9.js";
4
- import { s as scanRoutes } from "./_chunks/cli-schema-sync-ChsRzw8o.js";
5
- import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, o as readFileCached, t as collectLeafRoutes } from "./_chunks/walkers-DZuFKqFX.js";
6
- import { a as mergeFileConfig, c as resolveClientJavascript, i as loadTimberConfigFile, o as resolveAppDir, r as createPluginContext, s as resolveBuildDir, u as createNoopTimer } from "./_chunks/plugin-context-GfDWsdd2.js";
4
+ import { h as swallow } from "./_chunks/logger-C5v1IMuh.js";
5
+ import { i as scanRoutes } from "./_chunks/cli-schema-sync-DcmQrzJG.js";
6
+ import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, o as readFileCached, t as collectLeafRoutes } from "./_chunks/walkers-D5jCGPum.js";
7
7
  import { t as fnv1aHash } from "./_chunks/fast-hash-D6hIVt1Y.js";
8
8
  import { t as formatSize } from "./_chunks/format-CfwjgPz9.js";
9
9
  import { basename, dirname, extname, join, normalize, relative, resolve, win32 } from "node:path";
@@ -17,33 +17,6 @@ import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
17
17
  import { createHash, randomUUID } from "node:crypto";
18
18
  import { parseAst } from "vite";
19
19
  import http from "node:http";
20
- //#region \0rolldown/runtime.js
21
- var __defProp = Object.defineProperty;
22
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
23
- var __getOwnPropNames = Object.getOwnPropertyNames;
24
- var __hasOwnProp = Object.prototype.hasOwnProperty;
25
- var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
26
- var __exportAll = (all, no_symbols) => {
27
- let target = {};
28
- for (var name in all) __defProp(target, name, {
29
- get: all[name],
30
- enumerable: true
31
- });
32
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
33
- return target;
34
- };
35
- var __copyProps = (to, from, except, desc) => {
36
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
37
- key = keys[i];
38
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
39
- get: ((k) => from[k]).bind(null, key),
40
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
41
- });
42
- }
43
- return to;
44
- };
45
- var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
- //#endregion
47
20
  //#region src/plugins/content.ts
48
21
  var CONFIG_FILE_NAMES$1 = [
49
22
  "content-collections.ts",
@@ -434,7 +407,7 @@ function calculateModuleRunnerOffset() {
434
407
  * Phases where the error originated in the RSC environment.
435
408
  * These use `server.environments.rsc.moduleGraph` for source-mapping.
436
409
  */
437
- var RSC_PHASES = new Set([
410
+ var RSC_PHASES = /* @__PURE__ */ new Set([
438
411
  "render",
439
412
  "access",
440
413
  "middleware",
@@ -1288,7 +1261,7 @@ init_config_validation();
1288
1261
  * text/* is handled via prefix matching; these are the specific
1289
1262
  * application/* and image/* types that are compressible.
1290
1263
  */
1291
- var COMPRESSIBLE_TYPES = new Set([
1264
+ var COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set([
1292
1265
  "text/html",
1293
1266
  "text/css",
1294
1267
  "text/plain",
@@ -1306,7 +1279,7 @@ var COMPRESSIBLE_TYPES = new Set([
1306
1279
  /**
1307
1280
  * Status codes that should never be compressed (no body or special semantics).
1308
1281
  */
1309
- var NO_COMPRESS_STATUSES = new Set([204, 304]);
1282
+ var NO_COMPRESS_STATUSES = /* @__PURE__ */ new Set([204, 304]);
1310
1283
  /**
1311
1284
  * Parse Accept-Encoding and return the best supported encoding.
1312
1285
  * Returns 'gzip' if the client accepts it, null otherwise.
@@ -3161,6 +3134,22 @@ function hashedFontBasename(srcPath, hash) {
3161
3134
  *
3162
3135
  * Design doc: 24-fonts.md §"Step 2: Font Download & Subsetting"
3163
3136
  */
3137
+ /**
3138
+ * Extract a recognizable error code (ETIMEDOUT, ENOTFOUND, etc.) from a
3139
+ * network error's cause chain. Node's undici-based `fetch` wraps the
3140
+ * system error inside `cause` (sometimes as an AggregateError).
3141
+ */
3142
+ function extractNetworkErrorCode(err) {
3143
+ if (!(err instanceof Error)) return void 0;
3144
+ const code = err.code;
3145
+ if (code) return code;
3146
+ const cause = err.cause;
3147
+ if (cause instanceof AggregateError) for (const inner of cause.errors) {
3148
+ const innerCode = inner.code;
3149
+ if (innerCode) return innerCode;
3150
+ }
3151
+ if (cause instanceof Error) return cause.code;
3152
+ }
3164
3153
  /** Google Fonts CSS API v2 base URL. */
3165
3154
  var GOOGLE_FONTS_API = "https://fonts.googleapis.com/css2";
3166
3155
  /**
@@ -3207,7 +3196,13 @@ function buildGoogleFontsUrl(font) {
3207
3196
  * We parse each block to extract the font URL, unicode-range, and subset label.
3208
3197
  */
3209
3198
  async function fetchGoogleFontsCss(url) {
3210
- const response = await fetch(url, { headers: { "User-Agent": WOFF2_USER_AGENT } });
3199
+ let response;
3200
+ try {
3201
+ response = await fetch(url, { headers: { "User-Agent": WOFF2_USER_AGENT } });
3202
+ } catch (err) {
3203
+ const code = extractNetworkErrorCode(err);
3204
+ throw new Error(`[timber] Failed to fetch Google Fonts CSS from ${url}` + (code ? ` (${code})` : "") + ". Build requires internet access for font optimization. If building offline, set TIMBER_SKIP_FONTS=1 to skip font downloading.");
3205
+ }
3211
3206
  if (!response.ok) throw new Error(`Google Fonts API returned ${response.status}: ${response.statusText} for ${url}`);
3212
3207
  return parseGoogleFontsCss(await response.text());
3213
3208
  }
@@ -3276,7 +3271,13 @@ function cacheKey(face) {
3276
3271
  * Download a single font file from its URL.
3277
3272
  */
3278
3273
  async function downloadFontFile(url) {
3279
- const response = await fetch(url);
3274
+ let response;
3275
+ try {
3276
+ response = await fetch(url);
3277
+ } catch (err) {
3278
+ const code = extractNetworkErrorCode(err);
3279
+ throw new Error(`[timber] Failed to download font file from ${url}` + (code ? ` (${code})` : "") + ". Build requires internet access for font optimization. If building offline, set TIMBER_SKIP_FONTS=1 to skip font downloading.");
3280
+ }
3280
3281
  if (!response.ok) throw new Error(`Failed to download font from ${url}: ${response.status}`);
3281
3282
  return Buffer.from(await response.arrayBuffer());
3282
3283
  }
@@ -3294,7 +3295,14 @@ async function downloadAndCacheFonts(fonts, projectRoot) {
3294
3295
  const googleFonts = fonts.filter((f) => f.provider === "google");
3295
3296
  const cached = [];
3296
3297
  for (const font of googleFonts) {
3297
- const filtered = filterBySubsets(await fetchGoogleFontsCss(buildGoogleFontsUrl(font)), font.subsets);
3298
+ const apiUrl = buildGoogleFontsUrl(font);
3299
+ let faces;
3300
+ try {
3301
+ faces = await fetchGoogleFontsCss(apiUrl);
3302
+ } catch (err) {
3303
+ throw new Error(`[timber] Failed to download font '${font.family}': ${err instanceof Error ? err.message : String(err)}`);
3304
+ }
3305
+ const filtered = filterBySubsets(faces, font.subsets);
3298
3306
  for (const face of filtered) {
3299
3307
  const key = cacheKey(face);
3300
3308
  const metaPath = join(cacheDir, `${key}.meta.json`);
@@ -3544,7 +3552,7 @@ var FALLBACK_METRICS = {
3544
3552
  * Known serif font families (lowercase).
3545
3553
  * Used for generic family detection when the name doesn't contain "serif".
3546
3554
  */
3547
- var SERIF_FAMILIES = new Set([
3555
+ var SERIF_FAMILIES = /* @__PURE__ */ new Set([
3548
3556
  "playfair display",
3549
3557
  "merriweather",
3550
3558
  "lora",
@@ -3645,7 +3653,7 @@ function walkChildNodes(node, visit) {
3645
3653
  * error (font calls must be module-level, same constraint as Next.js).
3646
3654
  * Module scope so it isn't rebuilt on every recursive walk call.
3647
3655
  */
3648
- var NESTED_SCOPE_TYPES = new Set([
3656
+ var NESTED_SCOPE_TYPES = /* @__PURE__ */ new Set([
3649
3657
  "FunctionDeclaration",
3650
3658
  "FunctionExpression",
3651
3659
  "ArrowFunctionExpression",
@@ -3919,12 +3927,12 @@ function extractLocalConfig(objNode) {
3919
3927
  }
3920
3928
  return null;
3921
3929
  }
3922
- var GOOGLE_FONT_SOURCES = new Set([
3930
+ var GOOGLE_FONT_SOURCES = /* @__PURE__ */ new Set([
3923
3931
  "@timber/fonts/google",
3924
3932
  "@timber-js/app/fonts/google",
3925
3933
  "next/font/google"
3926
3934
  ]);
3927
- var LOCAL_FONT_SOURCES = new Set([
3935
+ var LOCAL_FONT_SOURCES = /* @__PURE__ */ new Set([
3928
3936
  "@timber/fonts/local",
3929
3937
  "@timber-js/app/fonts/local",
3930
3938
  "next/font/local"
@@ -4600,8 +4608,8 @@ function renderEntryCss(entry, urlPrefix) {
4600
4608
  var comma = ",".charCodeAt(0);
4601
4609
  var semicolon = ";".charCodeAt(0);
4602
4610
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4603
- var intToChar = new Uint8Array(64);
4604
- var charToInt = new Uint8Array(128);
4611
+ var intToChar = /* @__PURE__ */ new Uint8Array(64);
4612
+ var charToInt = /* @__PURE__ */ new Uint8Array(128);
4605
4613
  for (let i = 0; i < chars.length; i++) {
4606
4614
  const c = chars.charCodeAt(i);
4607
4615
  intToChar[i] = c;
@@ -5665,7 +5673,7 @@ function buildFontResultLiteral(extracted) {
5665
5673
  *
5666
5674
  * See TIM-840.
5667
5675
  */
5668
- var FONT_IMPORT_SCANNABLE_EXTENSIONS = new Set([
5676
+ var FONT_IMPORT_SCANNABLE_EXTENSIONS = /* @__PURE__ */ new Set([
5669
5677
  ".js",
5670
5678
  ".jsx",
5671
5679
  ".ts",
@@ -5994,9 +6002,14 @@ function timberFonts(ctx) {
5994
6002
  if (pipeline.cssIdMap.matches(id)) {
5995
6003
  const importer = pipeline.cssIdMap.importerFor(id);
5996
6004
  if (!importer) return "";
6005
+ const skipFonts = process.env.TIMBER_SKIP_FONTS === "1";
5997
6006
  for (const font of pipeline.googleFonts()) {
5998
6007
  if (font.importer !== importer) continue;
5999
6008
  if (pipeline.hasFaces(font.id)) continue;
6009
+ if (skipFonts && !ctx.dev) {
6010
+ console.warn(`[timber-fonts] Skipping font "${font.family}" (TIMBER_SKIP_FONTS=1)`);
6011
+ continue;
6012
+ }
6000
6013
  try {
6001
6014
  if (ctx.dev) {
6002
6015
  const faces = await resolveDevFontFaces(font);
@@ -7065,7 +7078,7 @@ function timberServerBundle() {
7065
7078
  *
7066
7079
  * See TIM-997, TIM-1053, design/06-caching.md §"Cache Key Security".
7067
7080
  */
7068
- var CACHE_MODULE_SOURCES = new Set(["@timber-js/app/cache", "timber/cache"]);
7081
+ var CACHE_MODULE_SOURCES = /* @__PURE__ */ new Set(["@timber-js/app/cache", "timber/cache"]);
7069
7082
  /**
7070
7083
  * Find the local binding name(s) for `cache` imported from the cache module —
7071
7084
  * both named imports and namespace imports (TIM-1054).