@timber-js/app 0.2.0-alpha.165 → 0.2.0-alpha.166

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 (62) hide show
  1. package/dist/_chunks/{actions-CSDD6x7U.js → actions-CDPfMp_I.js} +3 -3
  2. package/dist/_chunks/{actions-CSDD6x7U.js.map → actions-CDPfMp_I.js.map} +1 -1
  3. package/dist/_chunks/{cache-api-eb1gydM7.js → cache-api-DygSeKCB.js} +2 -2
  4. package/dist/_chunks/{cache-api-eb1gydM7.js.map → cache-api-DygSeKCB.js.map} +1 -1
  5. package/dist/_chunks/{cli-schema-sync-mGfRbjh2.js → cli-schema-sync-EXGYPhI2.js} +3 -3
  6. package/dist/_chunks/{cli-schema-sync-mGfRbjh2.js.map → cli-schema-sync-EXGYPhI2.js.map} +1 -1
  7. package/dist/_chunks/{define-CFmvb4Bt.js → define-COtkxMRT.js} +16 -28
  8. package/dist/_chunks/define-COtkxMRT.js.map +1 -0
  9. package/dist/_chunks/{define-Bssfp6ot.js → define-c4au4I9R.js} +2 -2
  10. package/dist/_chunks/{define-Bssfp6ot.js.map → define-c4au4I9R.js.map} +1 -1
  11. package/dist/_chunks/{logger-B_O6-mdJ.js → logger-t3uxAmbX.js} +3 -3
  12. package/dist/_chunks/{logger-B_O6-mdJ.js.map → logger-t3uxAmbX.js.map} +1 -1
  13. package/dist/_chunks/{plugin-context-BnaiU_cF.js → plugin-context---kTF5v8.js} +2 -2
  14. package/dist/_chunks/{plugin-context-BnaiU_cF.js.map → plugin-context---kTF5v8.js.map} +1 -1
  15. package/dist/_chunks/{resolve-schema-3iUvBV5T.js → resolve-schema-Dz3fcFUo.js} +2 -2
  16. package/dist/_chunks/{resolve-schema-3iUvBV5T.js.map → resolve-schema-Dz3fcFUo.js.map} +1 -1
  17. package/dist/_chunks/{schema-bridge-BY3QLBL7.js → schema-bridge-DT_Tn0Xf.js} +2 -2
  18. package/dist/_chunks/{schema-bridge-BY3QLBL7.js.map → schema-bridge-DT_Tn0Xf.js.map} +1 -1
  19. package/dist/_chunks/{use-query-states-CbeQmext.js → use-query-states-DFvWd-EA.js} +65 -7
  20. package/dist/_chunks/use-query-states-DFvWd-EA.js.map +1 -0
  21. package/dist/_chunks/{walkers-BL3MCMgO.js → walkers-DBVzXuWc.js} +3 -3
  22. package/dist/_chunks/{walkers-BL3MCMgO.js.map → walkers-DBVzXuWc.js.map} +1 -1
  23. package/dist/adapters/nitro.js +1 -1
  24. package/dist/cache/index.js +1 -1
  25. package/dist/cli.js +2 -2
  26. package/dist/client/internal.js +1 -1
  27. package/dist/client/use-query-states.d.ts.map +1 -1
  28. package/dist/codec.js +1 -1
  29. package/dist/cookies/index.js +1 -1
  30. package/dist/dev-tools/logs.d.ts +15 -1
  31. package/dist/dev-tools/logs.d.ts.map +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +104 -20
  34. package/dist/index.js.map +1 -1
  35. package/dist/params/index.js +1 -1
  36. package/dist/routing/index.js +2 -2
  37. package/dist/schema-bridge.d.ts.map +1 -1
  38. package/dist/search-params/define.d.ts +35 -4
  39. package/dist/search-params/define.d.ts.map +1 -1
  40. package/dist/search-params/index.js +3 -7
  41. package/dist/search-params/index.js.map +1 -1
  42. package/dist/search-params/wrappers.d.ts +2 -2
  43. package/dist/search-params/wrappers.d.ts.map +1 -1
  44. package/dist/segment-params/index.js +1 -1
  45. package/dist/server/index.js +2 -2
  46. package/dist/server/internal.js +8 -6
  47. package/dist/server/internal.js.map +1 -1
  48. package/dist/server/stream-utils.d.ts.map +1 -1
  49. package/docs/api/33-api-search-params.mdx +13 -0
  50. package/docs/learn/00-introduction.mdx +1 -2
  51. package/package.json +8 -7
  52. package/src/cli.ts +0 -0
  53. package/src/client/use-query-states.ts +99 -7
  54. package/src/dev-tools/logs.ts +119 -34
  55. package/src/index.ts +14 -1
  56. package/src/schema-bridge.ts +4 -3
  57. package/src/search-params/define.ts +57 -51
  58. package/src/search-params/wrappers.ts +17 -26
  59. package/src/server/stream-utils.ts +8 -6
  60. package/LICENSE +0 -8
  61. package/dist/_chunks/define-CFmvb4Bt.js.map +0 -1
  62. package/dist/_chunks/use-query-states-CbeQmext.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { a as __esmMin, o as __exportAll, s as __toCommonJS } from "./_chunks/dist-BA3u1z3W.js";
2
2
  import { c as isDynamicMetadataExtension, l as isMetadataRouteServePath, r as canonicalize } from "./_chunks/canonicalize-P41GR6tY.js";
3
3
  import { t as matchUrlParts } from "./_chunks/tree-match-D2l830j2.js";
4
- import { h as swallow } from "./_chunks/logger-B_O6-mdJ.js";
5
- import { i as scanRoutes } from "./_chunks/cli-schema-sync-mGfRbjh2.js";
6
- import { a as generateRouteMap, c as fileHasDirective, d as getPrerenderExport, i as validateSchemaAgainstRoutes, l as fileHasExport, n as collectInterceptionRewrites, o as fileHasAnyExport, s as fileHasDefaultExport, t as collectLeafRoutes, u as fileHasStarExport } from "./_chunks/walkers-BL3MCMgO.js";
7
- import { a as resolveAppDir, c as createNoopTimer, n as loadTimberConfigFile, o as resolveBuildDir, r as mergeFileConfig, s as resolveClientJavascript, t as createPluginContext } from "./_chunks/plugin-context-BnaiU_cF.js";
4
+ import { h as swallow } from "./_chunks/logger-t3uxAmbX.js";
5
+ import { i as scanRoutes } from "./_chunks/cli-schema-sync-EXGYPhI2.js";
6
+ import { a as generateRouteMap, c as fileHasDirective, d as getPrerenderExport, i as validateSchemaAgainstRoutes, l as fileHasExport, n as collectInterceptionRewrites, o as fileHasAnyExport, s as fileHasDefaultExport, t as collectLeafRoutes, u as fileHasStarExport } from "./_chunks/walkers-DBVzXuWc.js";
7
+ import { a as resolveAppDir, c as createNoopTimer, n as loadTimberConfigFile, o as resolveBuildDir, r as mergeFileConfig, s as resolveClientJavascript, t as createPluginContext } from "./_chunks/plugin-context---kTF5v8.js";
8
8
  import { t as fnv1aHash } from "./_chunks/fast-hash-D6hIVt1Y.js";
9
9
  import { t as formatSize } from "./_chunks/format-CfwjgPz9.js";
10
+ import { createLogger, parseAst } from "vite";
10
11
  import { basename, dirname, extname, join, normalize, relative, resolve, win32 } from "node:path";
11
12
  import { builtinModules, createRequire } from "node:module";
12
13
  import react, { reactCompilerPreset } from "@vitejs/plugin-react";
@@ -21,7 +22,6 @@ import { styleText } from "node:util";
21
22
  import { constants, createGzip, gzipSync } from "node:zlib";
22
23
  import { copyFile, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
23
24
  import { createHash, randomUUID } from "node:crypto";
24
- import { parseAst } from "vite";
25
25
  //#region src/plugins/content.ts
26
26
  var CONFIG_FILE_NAMES$1 = [
27
27
  "content-collections.ts",
@@ -6453,6 +6453,76 @@ function timberBuildManifest(ctx) {
6453
6453
  }
6454
6454
  //#endregion
6455
6455
  //#region src/dev-tools/logs.ts
6456
+ /**
6457
+ * Snapshot of the original console methods, captured at module load time
6458
+ * (before any patching). Used as Vite's `customLogger` console so that
6459
+ * forwardConsole output bypasses our patch entirely — eliminating the
6460
+ * server→browser→server forwarding loop without string matching.
6461
+ */
6462
+ var originalConsole = {
6463
+ log: console.log.bind(console),
6464
+ warn: console.warn.bind(console),
6465
+ error: console.error.bind(console),
6466
+ debug: console.debug.bind(console),
6467
+ info: console.info.bind(console)
6468
+ };
6469
+ /**
6470
+ * Wrap a Vite Logger so its output methods route through `originalConsole`
6471
+ * instead of the global (potentially patched) console. This prevents the
6472
+ * server→browser→server forwarding loop even when the user supplies their
6473
+ * own `customLogger` that internally calls console methods.
6474
+ */
6475
+ function wrapLoggerWithOriginalConsole(logger) {
6476
+ function withOriginals(fn) {
6477
+ const saved = {
6478
+ log: console.log,
6479
+ warn: console.warn,
6480
+ error: console.error,
6481
+ debug: console.debug,
6482
+ info: console.info
6483
+ };
6484
+ console.log = originalConsole.log;
6485
+ console.warn = originalConsole.warn;
6486
+ console.error = originalConsole.error;
6487
+ console.debug = originalConsole.debug;
6488
+ console.info = originalConsole.info;
6489
+ try {
6490
+ return fn();
6491
+ } finally {
6492
+ console.log = saved.log;
6493
+ console.warn = saved.warn;
6494
+ console.error = saved.error;
6495
+ console.debug = saved.debug;
6496
+ console.info = saved.info;
6497
+ }
6498
+ }
6499
+ return {
6500
+ get hasWarned() {
6501
+ return logger.hasWarned;
6502
+ },
6503
+ set hasWarned(v) {
6504
+ logger.hasWarned = v;
6505
+ },
6506
+ info(msg, opts) {
6507
+ withOriginals(() => logger.info(msg, opts));
6508
+ },
6509
+ warn(msg, opts) {
6510
+ withOriginals(() => logger.warn(msg, opts));
6511
+ },
6512
+ warnOnce(msg, opts) {
6513
+ withOriginals(() => logger.warnOnce(msg, opts));
6514
+ },
6515
+ error(msg, opts) {
6516
+ withOriginals(() => logger.error(msg, opts));
6517
+ },
6518
+ clearScreen(type) {
6519
+ logger.clearScreen(type);
6520
+ },
6521
+ hasErrorLogged(error) {
6522
+ return logger.hasErrorLogged(error);
6523
+ }
6524
+ };
6525
+ }
6456
6526
  var LOG_LEVELS = [
6457
6527
  "log",
6458
6528
  "warn",
@@ -6575,28 +6645,37 @@ function isFrameworkInternalCaller() {
6575
6645
  * 3. Sends via server.hot.send() — dropped if no clients connected
6576
6646
  */
6577
6647
  function patchConsole(server, projectRoot) {
6578
- const originals = /* @__PURE__ */ new Map();
6648
+ const prevConsole = /* @__PURE__ */ new Map();
6649
+ const patchingLevel = /* @__PURE__ */ new Set();
6579
6650
  for (const level of LOG_LEVELS) {
6580
- originals.set(level, console[level].bind(console));
6651
+ prevConsole.set(level, console[level].bind(console));
6581
6652
  console[level] = (...args) => {
6582
- originals.get(level)(...args);
6583
- if (isFrameworkInternalCaller()) return;
6584
- if (typeof args[0] === "string" && args[0].includes("[console.")) return;
6653
+ if (patchingLevel.has(level)) {
6654
+ prevConsole.get(level)(...args);
6655
+ return;
6656
+ }
6657
+ patchingLevel.add(level);
6585
6658
  try {
6586
- const payload = {
6587
- level,
6588
- args: args.map((arg) => serializeArg(arg)),
6589
- location: extractCallerLocation(projectRoot),
6590
- timestamp: Date.now()
6591
- };
6592
- server.hot.send("timber:server-log", payload);
6593
- } catch (e) {
6594
- originals.get("debug")("[timber] server log forwarding failed:", e instanceof Error ? e.message : e);
6659
+ prevConsole.get(level)(...args);
6660
+ if (isFrameworkInternalCaller()) return;
6661
+ try {
6662
+ const payload = {
6663
+ level,
6664
+ args: args.map((arg) => serializeArg(arg)),
6665
+ location: extractCallerLocation(projectRoot),
6666
+ timestamp: Date.now()
6667
+ };
6668
+ server.hot.send("timber:server-log", payload);
6669
+ } catch (e) {
6670
+ originalConsole.debug("[timber] server log forwarding failed:", e instanceof Error ? e.message : e);
6671
+ }
6672
+ } finally {
6673
+ patchingLevel.delete(level);
6595
6674
  }
6596
6675
  };
6597
6676
  }
6598
6677
  return () => {
6599
- for (const [level, original] of originals) console[level] = original;
6678
+ for (const [level, prev] of prevConsole) console[level] = prev;
6600
6679
  };
6601
6680
  }
6602
6681
  /**
@@ -9545,10 +9624,15 @@ function timber(config) {
9545
9624
  previewConfig.strictPort = resolvedDevPortExplicit;
9546
9625
  }
9547
9626
  serverConfig.forwardConsole = resolveForwardConsole(ctx.config.devBrowserLogs);
9627
+ const customLogger = userConfig.customLogger ? wrapLoggerWithOriginalConsole(userConfig.customLogger) : createLogger(userConfig.logLevel ?? "info", {
9628
+ allowClearScreen: userConfig.clearScreen ?? true,
9629
+ console: originalConsole
9630
+ });
9548
9631
  return {
9549
9632
  build: { outDir: buildOutDir },
9550
9633
  environments: envOutDirs,
9551
9634
  optimizeDeps: { exclude: timberOptimizeDepsExclude },
9635
+ customLogger,
9552
9636
  server: serverConfig,
9553
9637
  preview: previewConfig
9554
9638
  };