@decocms/start 5.1.1 → 5.2.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.
@@ -54,6 +54,12 @@ function createDecoRouter(options) {
54
54
  routeTree,
55
55
  scrollRestoration = true,
56
56
  defaultPreload = "intent",
57
+ defaultPreloadStaleTime,
58
+ defaultPreloadGcTime,
59
+ defaultPreloadDelay,
60
+ defaultStaleTime,
61
+ defaultPendingMs,
62
+ defaultPendingMinMs,
57
63
  trailingSlash,
58
64
  context,
59
65
  Wrap
@@ -62,6 +68,12 @@ function createDecoRouter(options) {
62
68
  routeTree,
63
69
  scrollRestoration,
64
70
  defaultPreload,
71
+ defaultPreloadStaleTime,
72
+ defaultPreloadGcTime,
73
+ defaultPreloadDelay,
74
+ defaultStaleTime,
75
+ defaultPendingMs,
76
+ defaultPendingMinMs,
65
77
  trailingSlash,
66
78
  context,
67
79
  Wrap,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tanstack/sdk/router.ts"],"sourcesContent":["/**\n * Deco-flavored TanStack Router factory.\n *\n * Uses standard URLSearchParams serialization instead of TanStack's default\n * JSON-based format. Required because VTEX (and most commerce platforms) uses\n * filter URLs like `?filter.brand=Nike&filter.brand=Adidas` which must\n * round-trip correctly through the router's search system.\n */\nimport { createRouter as createTanStackRouter } from \"@tanstack/react-router\";\nimport type {\n\tSearchSerializer,\n\tSearchParser,\n\tAnyRoute,\n\tTrailingSlashOption,\n} from \"@tanstack/react-router\";\n\nexport const decoParseSearch: SearchParser = (searchStr) => {\n\tconst str = searchStr.startsWith(\"?\") ? searchStr.slice(1) : searchStr;\n\tif (!str) return {};\n\n\tconst params = new URLSearchParams(str);\n\tconst result: Record<string, string | string[]> = {};\n\n\tfor (const key of new Set(params.keys())) {\n\t\tconst values = params.getAll(key);\n\t\tresult[key] = values.length === 1 ? values[0] : values;\n\t}\n\treturn result;\n};\n\nexport const decoStringifySearch: SearchSerializer = (search) => {\n\tconst params = new URLSearchParams();\n\tfor (const [key, value] of Object.entries(search)) {\n\t\tif (value === undefined || value === null || value === \"\") continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) params.append(key, String(v));\n\t\t} else {\n\t\t\tparams.append(key, String(value));\n\t\t}\n\t}\n\tconst str = params.toString();\n\treturn str ? `?${str}` : \"\";\n};\n\nexport interface CreateDecoRouterOptions {\n\trouteTree: AnyRoute;\n\tscrollRestoration?: boolean;\n\tdefaultPreload?: \"intent\" | \"viewport\" | \"render\" | false;\n\ttrailingSlash?: TrailingSlashOption;\n\t/**\n\t * Router context — passed to all route loaders/components via routeContext.\n\t * Commonly used for { queryClient } per TanStack Query integration docs.\n\t */\n\tcontext?: Record<string, unknown>;\n\t/**\n\t * Non-DOM provider component to wrap the entire router.\n\t * Per TanStack docs, only non-DOM-rendering components (providers) should\n\t * be used — anything else causes hydration errors.\n\t *\n\t * Example: QueryClientProvider wrapping\n\t * Wrap: ({ children }) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>\n\t */\n\tWrap?: (props: { children: any }) => any;\n}\n\n/**\n * Create a TanStack Router with Deco defaults:\n * - URLSearchParams-based search serialization (not JSON)\n * - Scroll restoration enabled\n * - Preload on intent\n */\nexport function createDecoRouter(options: CreateDecoRouterOptions) {\n\tconst {\n\t\trouteTree,\n\t\tscrollRestoration = true,\n\t\tdefaultPreload = \"intent\",\n\t\ttrailingSlash,\n\t\tcontext,\n\t\tWrap,\n\t} = options;\n\n\treturn createTanStackRouter({\n\t\trouteTree,\n\t\tscrollRestoration,\n\t\tdefaultPreload,\n\t\ttrailingSlash,\n\t\tcontext: context as any,\n\t\tWrap,\n\t\tparseSearch: decoParseSearch,\n\t\tstringifySearch: decoStringifySearch,\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,0BAAqD;AAQ9C,IAAM,kBAAgC,CAAC,cAAc;AAC3D,QAAM,MAAM,UAAU,WAAW,GAAG,IAAI,UAAU,MAAM,CAAC,IAAI;AAC7D,MAAI,CAAC,IAAK,QAAO,CAAC;AAElB,QAAM,SAAS,IAAI,gBAAgB,GAAG;AACtC,QAAM,SAA4C,CAAC;AAEnD,aAAW,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG;AACzC,UAAM,SAAS,OAAO,OAAO,GAAG;AAChC,WAAO,GAAG,IAAI,OAAO,WAAW,IAAI,OAAO,CAAC,IAAI;AAAA,EACjD;AACA,SAAO;AACR;AAEO,IAAM,sBAAwC,CAAC,WAAW;AAChE,QAAM,SAAS,IAAI,gBAAgB;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI;AAC3D,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,iBAAW,KAAK,MAAO,QAAO,OAAO,KAAK,OAAO,CAAC,CAAC;AAAA,IACpD,OAAO;AACN,aAAO,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,IACjC;AAAA,EACD;AACA,QAAM,MAAM,OAAO,SAAS;AAC5B,SAAO,MAAM,IAAI,GAAG,KAAK;AAC1B;AA6BO,SAAS,iBAAiB,SAAkC;AAClE,QAAM;AAAA,IACL;AAAA,IACA,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,aAAO,oBAAAA,cAAqB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB,CAAC;AACF;","names":["createTanStackRouter"]}
1
+ {"version":3,"sources":["../../../src/tanstack/sdk/router.ts"],"sourcesContent":["/**\n * Deco-flavored TanStack Router factory.\n *\n * Uses standard URLSearchParams serialization instead of TanStack's default\n * JSON-based format. Required because VTEX (and most commerce platforms) uses\n * filter URLs like `?filter.brand=Nike&filter.brand=Adidas` which must\n * round-trip correctly through the router's search system.\n */\nimport { createRouter as createTanStackRouter } from \"@tanstack/react-router\";\nimport type {\n\tSearchSerializer,\n\tSearchParser,\n\tAnyRoute,\n\tTrailingSlashOption,\n} from \"@tanstack/react-router\";\n\nexport const decoParseSearch: SearchParser = (searchStr) => {\n\tconst str = searchStr.startsWith(\"?\") ? searchStr.slice(1) : searchStr;\n\tif (!str) return {};\n\n\tconst params = new URLSearchParams(str);\n\tconst result: Record<string, string | string[]> = {};\n\n\tfor (const key of new Set(params.keys())) {\n\t\tconst values = params.getAll(key);\n\t\tresult[key] = values.length === 1 ? values[0] : values;\n\t}\n\treturn result;\n};\n\nexport const decoStringifySearch: SearchSerializer = (search) => {\n\tconst params = new URLSearchParams();\n\tfor (const [key, value] of Object.entries(search)) {\n\t\tif (value === undefined || value === null || value === \"\") continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) params.append(key, String(v));\n\t\t} else {\n\t\t\tparams.append(key, String(value));\n\t\t}\n\t}\n\tconst str = params.toString();\n\treturn str ? `?${str}` : \"\";\n};\n\nexport interface CreateDecoRouterOptions {\n\trouteTree: AnyRoute;\n\tscrollRestoration?: boolean;\n\tdefaultPreload?: \"intent\" | \"viewport\" | \"render\" | false;\n\t/**\n\t * How long a preloaded route stays \"fresh\" before a click re-fetches it.\n\t * When using `defaultPreload: \"intent\"`, this is what makes hover → click\n\t * navigation truly instant. Without it, TanStack uses a short default and\n\t * the prefetched data may be considered stale by the time the user clicks.\n\t *\n\t * Recommended for commerce storefronts: 60_000 (1 minute).\n\t * @default undefined (TanStack default — short)\n\t */\n\tdefaultPreloadStaleTime?: number;\n\t/**\n\t * How long a preloaded route stays in memory before garbage collection.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPreloadGcTime?: number;\n\t/**\n\t * Delay before firing a preload after `hover`/`touchstart`.\n\t * @default undefined (TanStack default — ~50ms)\n\t */\n\tdefaultPreloadDelay?: number;\n\t/**\n\t * Default staleTime applied to all route loaders (not just preload).\n\t * @default undefined (TanStack default — 0)\n\t */\n\tdefaultStaleTime?: number;\n\t/**\n\t * Milliseconds to wait before showing the pending component on slow\n\t * navigations. Useful when `eager` sections block the route swap.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPendingMs?: number;\n\t/**\n\t * Minimum milliseconds the pending component must be shown once revealed.\n\t * Prevents flash if the loader resolves right after the pending UI appears.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPendingMinMs?: number;\n\ttrailingSlash?: TrailingSlashOption;\n\t/**\n\t * Router context — passed to all route loaders/components via routeContext.\n\t * Commonly used for { queryClient } per TanStack Query integration docs.\n\t */\n\tcontext?: Record<string, unknown>;\n\t/**\n\t * Non-DOM provider component to wrap the entire router.\n\t * Per TanStack docs, only non-DOM-rendering components (providers) should\n\t * be used — anything else causes hydration errors.\n\t *\n\t * Example: QueryClientProvider wrapping\n\t * Wrap: ({ children }) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>\n\t */\n\tWrap?: (props: { children: any }) => any;\n}\n\n/**\n * Create a TanStack Router with Deco defaults:\n * - URLSearchParams-based search serialization (not JSON)\n * - Scroll restoration enabled\n * - Preload on intent\n *\n * For commerce storefronts, pair `defaultPreload: \"intent\"` (default) with\n * `defaultPreloadStaleTime: 60_000` so hover prefetch is reused on click —\n * see the `deco-pdp-fast-navigation` skill for the full pattern.\n */\nexport function createDecoRouter(options: CreateDecoRouterOptions) {\n\tconst {\n\t\trouteTree,\n\t\tscrollRestoration = true,\n\t\tdefaultPreload = \"intent\",\n\t\tdefaultPreloadStaleTime,\n\t\tdefaultPreloadGcTime,\n\t\tdefaultPreloadDelay,\n\t\tdefaultStaleTime,\n\t\tdefaultPendingMs,\n\t\tdefaultPendingMinMs,\n\t\ttrailingSlash,\n\t\tcontext,\n\t\tWrap,\n\t} = options;\n\n\treturn createTanStackRouter({\n\t\trouteTree,\n\t\tscrollRestoration,\n\t\tdefaultPreload,\n\t\tdefaultPreloadStaleTime,\n\t\tdefaultPreloadGcTime,\n\t\tdefaultPreloadDelay,\n\t\tdefaultStaleTime,\n\t\tdefaultPendingMs,\n\t\tdefaultPendingMinMs,\n\t\ttrailingSlash,\n\t\tcontext: context as any,\n\t\tWrap,\n\t\tparseSearch: decoParseSearch,\n\t\tstringifySearch: decoStringifySearch,\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,0BAAqD;AAQ9C,IAAM,kBAAgC,CAAC,cAAc;AAC3D,QAAM,MAAM,UAAU,WAAW,GAAG,IAAI,UAAU,MAAM,CAAC,IAAI;AAC7D,MAAI,CAAC,IAAK,QAAO,CAAC;AAElB,QAAM,SAAS,IAAI,gBAAgB,GAAG;AACtC,QAAM,SAA4C,CAAC;AAEnD,aAAW,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG;AACzC,UAAM,SAAS,OAAO,OAAO,GAAG;AAChC,WAAO,GAAG,IAAI,OAAO,WAAW,IAAI,OAAO,CAAC,IAAI;AAAA,EACjD;AACA,SAAO;AACR;AAEO,IAAM,sBAAwC,CAAC,WAAW;AAChE,QAAM,SAAS,IAAI,gBAAgB;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI;AAC3D,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,iBAAW,KAAK,MAAO,QAAO,OAAO,KAAK,OAAO,CAAC,CAAC;AAAA,IACpD,OAAO;AACN,aAAO,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,IACjC;AAAA,EACD;AACA,QAAM,MAAM,OAAO,SAAS;AAC5B,SAAO,MAAM,IAAI,GAAG,KAAK;AAC1B;AAsEO,SAAS,iBAAiB,SAAkC;AAClE,QAAM;AAAA,IACL;AAAA,IACA,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,aAAO,oBAAAA,cAAqB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB,CAAC;AACF;","names":["createTanStackRouter"]}
@@ -5,6 +5,43 @@ export interface CreateDecoRouterOptions {
5
5
  routeTree: AnyRoute;
6
6
  scrollRestoration?: boolean;
7
7
  defaultPreload?: "intent" | "viewport" | "render" | false;
8
+ /**
9
+ * How long a preloaded route stays "fresh" before a click re-fetches it.
10
+ * When using `defaultPreload: "intent"`, this is what makes hover → click
11
+ * navigation truly instant. Without it, TanStack uses a short default and
12
+ * the prefetched data may be considered stale by the time the user clicks.
13
+ *
14
+ * Recommended for commerce storefronts: 60_000 (1 minute).
15
+ * @default undefined (TanStack default — short)
16
+ */
17
+ defaultPreloadStaleTime?: number;
18
+ /**
19
+ * How long a preloaded route stays in memory before garbage collection.
20
+ * @default undefined (TanStack default)
21
+ */
22
+ defaultPreloadGcTime?: number;
23
+ /**
24
+ * Delay before firing a preload after `hover`/`touchstart`.
25
+ * @default undefined (TanStack default — ~50ms)
26
+ */
27
+ defaultPreloadDelay?: number;
28
+ /**
29
+ * Default staleTime applied to all route loaders (not just preload).
30
+ * @default undefined (TanStack default — 0)
31
+ */
32
+ defaultStaleTime?: number;
33
+ /**
34
+ * Milliseconds to wait before showing the pending component on slow
35
+ * navigations. Useful when `eager` sections block the route swap.
36
+ * @default undefined (TanStack default)
37
+ */
38
+ defaultPendingMs?: number;
39
+ /**
40
+ * Minimum milliseconds the pending component must be shown once revealed.
41
+ * Prevents flash if the loader resolves right after the pending UI appears.
42
+ * @default undefined (TanStack default)
43
+ */
44
+ defaultPendingMinMs?: number;
8
45
  trailingSlash?: TrailingSlashOption;
9
46
  /**
10
47
  * Router context — passed to all route loaders/components via routeContext.
@@ -28,6 +65,10 @@ export interface CreateDecoRouterOptions {
28
65
  * - URLSearchParams-based search serialization (not JSON)
29
66
  * - Scroll restoration enabled
30
67
  * - Preload on intent
68
+ *
69
+ * For commerce storefronts, pair `defaultPreload: "intent"` (default) with
70
+ * `defaultPreloadStaleTime: 60_000` so hover prefetch is reused on click —
71
+ * see the `deco-pdp-fast-navigation` skill for the full pattern.
31
72
  */
32
73
  export declare function createDecoRouter(options: CreateDecoRouterOptions): import("@tanstack/router-core").RouterCore<AnyRoute, "always" | "never" | "preserve", false, import("@tanstack/history").RouterHistory, Record<string, any>>;
33
74
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/tanstack/sdk/router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,mBAAmB,EACnB,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,eAAe,EAAE,YAY7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAYjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACvC,SAAS,EAAE,QAAQ,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE,KAAK,GAAG,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,gKAoBhE"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/tanstack/sdk/router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,mBAAmB,EACnB,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,eAAe,EAAE,YAY7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAYjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACvC,SAAS,EAAE,QAAQ,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1D;;;;;;;;OAQG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE,KAAK,GAAG,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,gKAgChE"}
@@ -29,6 +29,12 @@ function createDecoRouter(options) {
29
29
  routeTree,
30
30
  scrollRestoration = true,
31
31
  defaultPreload = "intent",
32
+ defaultPreloadStaleTime,
33
+ defaultPreloadGcTime,
34
+ defaultPreloadDelay,
35
+ defaultStaleTime,
36
+ defaultPendingMs,
37
+ defaultPendingMinMs,
32
38
  trailingSlash,
33
39
  context,
34
40
  Wrap
@@ -37,6 +43,12 @@ function createDecoRouter(options) {
37
43
  routeTree,
38
44
  scrollRestoration,
39
45
  defaultPreload,
46
+ defaultPreloadStaleTime,
47
+ defaultPreloadGcTime,
48
+ defaultPreloadDelay,
49
+ defaultStaleTime,
50
+ defaultPendingMs,
51
+ defaultPendingMinMs,
40
52
  trailingSlash,
41
53
  context,
42
54
  Wrap,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tanstack/sdk/router.ts"],"sourcesContent":["/**\n * Deco-flavored TanStack Router factory.\n *\n * Uses standard URLSearchParams serialization instead of TanStack's default\n * JSON-based format. Required because VTEX (and most commerce platforms) uses\n * filter URLs like `?filter.brand=Nike&filter.brand=Adidas` which must\n * round-trip correctly through the router's search system.\n */\nimport { createRouter as createTanStackRouter } from \"@tanstack/react-router\";\nimport type {\n\tSearchSerializer,\n\tSearchParser,\n\tAnyRoute,\n\tTrailingSlashOption,\n} from \"@tanstack/react-router\";\n\nexport const decoParseSearch: SearchParser = (searchStr) => {\n\tconst str = searchStr.startsWith(\"?\") ? searchStr.slice(1) : searchStr;\n\tif (!str) return {};\n\n\tconst params = new URLSearchParams(str);\n\tconst result: Record<string, string | string[]> = {};\n\n\tfor (const key of new Set(params.keys())) {\n\t\tconst values = params.getAll(key);\n\t\tresult[key] = values.length === 1 ? values[0] : values;\n\t}\n\treturn result;\n};\n\nexport const decoStringifySearch: SearchSerializer = (search) => {\n\tconst params = new URLSearchParams();\n\tfor (const [key, value] of Object.entries(search)) {\n\t\tif (value === undefined || value === null || value === \"\") continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) params.append(key, String(v));\n\t\t} else {\n\t\t\tparams.append(key, String(value));\n\t\t}\n\t}\n\tconst str = params.toString();\n\treturn str ? `?${str}` : \"\";\n};\n\nexport interface CreateDecoRouterOptions {\n\trouteTree: AnyRoute;\n\tscrollRestoration?: boolean;\n\tdefaultPreload?: \"intent\" | \"viewport\" | \"render\" | false;\n\ttrailingSlash?: TrailingSlashOption;\n\t/**\n\t * Router context — passed to all route loaders/components via routeContext.\n\t * Commonly used for { queryClient } per TanStack Query integration docs.\n\t */\n\tcontext?: Record<string, unknown>;\n\t/**\n\t * Non-DOM provider component to wrap the entire router.\n\t * Per TanStack docs, only non-DOM-rendering components (providers) should\n\t * be used — anything else causes hydration errors.\n\t *\n\t * Example: QueryClientProvider wrapping\n\t * Wrap: ({ children }) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>\n\t */\n\tWrap?: (props: { children: any }) => any;\n}\n\n/**\n * Create a TanStack Router with Deco defaults:\n * - URLSearchParams-based search serialization (not JSON)\n * - Scroll restoration enabled\n * - Preload on intent\n */\nexport function createDecoRouter(options: CreateDecoRouterOptions) {\n\tconst {\n\t\trouteTree,\n\t\tscrollRestoration = true,\n\t\tdefaultPreload = \"intent\",\n\t\ttrailingSlash,\n\t\tcontext,\n\t\tWrap,\n\t} = options;\n\n\treturn createTanStackRouter({\n\t\trouteTree,\n\t\tscrollRestoration,\n\t\tdefaultPreload,\n\t\ttrailingSlash,\n\t\tcontext: context as any,\n\t\tWrap,\n\t\tparseSearch: decoParseSearch,\n\t\tstringifySearch: decoStringifySearch,\n\t});\n}\n"],"mappings":";AAQA,SAAS,gBAAgB,4BAA4B;AAQ9C,IAAM,kBAAgC,CAAC,cAAc;AAC3D,QAAM,MAAM,UAAU,WAAW,GAAG,IAAI,UAAU,MAAM,CAAC,IAAI;AAC7D,MAAI,CAAC,IAAK,QAAO,CAAC;AAElB,QAAM,SAAS,IAAI,gBAAgB,GAAG;AACtC,QAAM,SAA4C,CAAC;AAEnD,aAAW,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG;AACzC,UAAM,SAAS,OAAO,OAAO,GAAG;AAChC,WAAO,GAAG,IAAI,OAAO,WAAW,IAAI,OAAO,CAAC,IAAI;AAAA,EACjD;AACA,SAAO;AACR;AAEO,IAAM,sBAAwC,CAAC,WAAW;AAChE,QAAM,SAAS,IAAI,gBAAgB;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI;AAC3D,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,iBAAW,KAAK,MAAO,QAAO,OAAO,KAAK,OAAO,CAAC,CAAC;AAAA,IACpD,OAAO;AACN,aAAO,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,IACjC;AAAA,EACD;AACA,QAAM,MAAM,OAAO,SAAS;AAC5B,SAAO,MAAM,IAAI,GAAG,KAAK;AAC1B;AA6BO,SAAS,iBAAiB,SAAkC;AAClE,QAAM;AAAA,IACL;AAAA,IACA,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,SAAO,qBAAqB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB,CAAC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/tanstack/sdk/router.ts"],"sourcesContent":["/**\n * Deco-flavored TanStack Router factory.\n *\n * Uses standard URLSearchParams serialization instead of TanStack's default\n * JSON-based format. Required because VTEX (and most commerce platforms) uses\n * filter URLs like `?filter.brand=Nike&filter.brand=Adidas` which must\n * round-trip correctly through the router's search system.\n */\nimport { createRouter as createTanStackRouter } from \"@tanstack/react-router\";\nimport type {\n\tSearchSerializer,\n\tSearchParser,\n\tAnyRoute,\n\tTrailingSlashOption,\n} from \"@tanstack/react-router\";\n\nexport const decoParseSearch: SearchParser = (searchStr) => {\n\tconst str = searchStr.startsWith(\"?\") ? searchStr.slice(1) : searchStr;\n\tif (!str) return {};\n\n\tconst params = new URLSearchParams(str);\n\tconst result: Record<string, string | string[]> = {};\n\n\tfor (const key of new Set(params.keys())) {\n\t\tconst values = params.getAll(key);\n\t\tresult[key] = values.length === 1 ? values[0] : values;\n\t}\n\treturn result;\n};\n\nexport const decoStringifySearch: SearchSerializer = (search) => {\n\tconst params = new URLSearchParams();\n\tfor (const [key, value] of Object.entries(search)) {\n\t\tif (value === undefined || value === null || value === \"\") continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) params.append(key, String(v));\n\t\t} else {\n\t\t\tparams.append(key, String(value));\n\t\t}\n\t}\n\tconst str = params.toString();\n\treturn str ? `?${str}` : \"\";\n};\n\nexport interface CreateDecoRouterOptions {\n\trouteTree: AnyRoute;\n\tscrollRestoration?: boolean;\n\tdefaultPreload?: \"intent\" | \"viewport\" | \"render\" | false;\n\t/**\n\t * How long a preloaded route stays \"fresh\" before a click re-fetches it.\n\t * When using `defaultPreload: \"intent\"`, this is what makes hover → click\n\t * navigation truly instant. Without it, TanStack uses a short default and\n\t * the prefetched data may be considered stale by the time the user clicks.\n\t *\n\t * Recommended for commerce storefronts: 60_000 (1 minute).\n\t * @default undefined (TanStack default — short)\n\t */\n\tdefaultPreloadStaleTime?: number;\n\t/**\n\t * How long a preloaded route stays in memory before garbage collection.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPreloadGcTime?: number;\n\t/**\n\t * Delay before firing a preload after `hover`/`touchstart`.\n\t * @default undefined (TanStack default — ~50ms)\n\t */\n\tdefaultPreloadDelay?: number;\n\t/**\n\t * Default staleTime applied to all route loaders (not just preload).\n\t * @default undefined (TanStack default — 0)\n\t */\n\tdefaultStaleTime?: number;\n\t/**\n\t * Milliseconds to wait before showing the pending component on slow\n\t * navigations. Useful when `eager` sections block the route swap.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPendingMs?: number;\n\t/**\n\t * Minimum milliseconds the pending component must be shown once revealed.\n\t * Prevents flash if the loader resolves right after the pending UI appears.\n\t * @default undefined (TanStack default)\n\t */\n\tdefaultPendingMinMs?: number;\n\ttrailingSlash?: TrailingSlashOption;\n\t/**\n\t * Router context — passed to all route loaders/components via routeContext.\n\t * Commonly used for { queryClient } per TanStack Query integration docs.\n\t */\n\tcontext?: Record<string, unknown>;\n\t/**\n\t * Non-DOM provider component to wrap the entire router.\n\t * Per TanStack docs, only non-DOM-rendering components (providers) should\n\t * be used — anything else causes hydration errors.\n\t *\n\t * Example: QueryClientProvider wrapping\n\t * Wrap: ({ children }) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>\n\t */\n\tWrap?: (props: { children: any }) => any;\n}\n\n/**\n * Create a TanStack Router with Deco defaults:\n * - URLSearchParams-based search serialization (not JSON)\n * - Scroll restoration enabled\n * - Preload on intent\n *\n * For commerce storefronts, pair `defaultPreload: \"intent\"` (default) with\n * `defaultPreloadStaleTime: 60_000` so hover prefetch is reused on click —\n * see the `deco-pdp-fast-navigation` skill for the full pattern.\n */\nexport function createDecoRouter(options: CreateDecoRouterOptions) {\n\tconst {\n\t\trouteTree,\n\t\tscrollRestoration = true,\n\t\tdefaultPreload = \"intent\",\n\t\tdefaultPreloadStaleTime,\n\t\tdefaultPreloadGcTime,\n\t\tdefaultPreloadDelay,\n\t\tdefaultStaleTime,\n\t\tdefaultPendingMs,\n\t\tdefaultPendingMinMs,\n\t\ttrailingSlash,\n\t\tcontext,\n\t\tWrap,\n\t} = options;\n\n\treturn createTanStackRouter({\n\t\trouteTree,\n\t\tscrollRestoration,\n\t\tdefaultPreload,\n\t\tdefaultPreloadStaleTime,\n\t\tdefaultPreloadGcTime,\n\t\tdefaultPreloadDelay,\n\t\tdefaultStaleTime,\n\t\tdefaultPendingMs,\n\t\tdefaultPendingMinMs,\n\t\ttrailingSlash,\n\t\tcontext: context as any,\n\t\tWrap,\n\t\tparseSearch: decoParseSearch,\n\t\tstringifySearch: decoStringifySearch,\n\t});\n}\n"],"mappings":";AAQA,SAAS,gBAAgB,4BAA4B;AAQ9C,IAAM,kBAAgC,CAAC,cAAc;AAC3D,QAAM,MAAM,UAAU,WAAW,GAAG,IAAI,UAAU,MAAM,CAAC,IAAI;AAC7D,MAAI,CAAC,IAAK,QAAO,CAAC;AAElB,QAAM,SAAS,IAAI,gBAAgB,GAAG;AACtC,QAAM,SAA4C,CAAC;AAEnD,aAAW,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG;AACzC,UAAM,SAAS,OAAO,OAAO,GAAG;AAChC,WAAO,GAAG,IAAI,OAAO,WAAW,IAAI,OAAO,CAAC,IAAI;AAAA,EACjD;AACA,SAAO;AACR;AAEO,IAAM,sBAAwC,CAAC,WAAW;AAChE,QAAM,SAAS,IAAI,gBAAgB;AACnC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI;AAC3D,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,iBAAW,KAAK,MAAO,QAAO,OAAO,KAAK,OAAO,CAAC,CAAC;AAAA,IACpD,OAAO;AACN,aAAO,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,IACjC;AAAA,EACD;AACA,QAAM,MAAM,OAAO,SAAS;AAC5B,SAAO,MAAM,IAAI,GAAG,KAAK;AAC1B;AAsEO,SAAS,iBAAiB,SAAkC;AAClE,QAAM;AAAA,IACL;AAAA,IACA,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,SAAO,qBAAqB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB,CAAC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "5.1.1",
3
+ "version": "5.2.1",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./dist/index.cjs",