@decocms/start 0.30.2 → 0.30.4

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @decocms/start
1
+ # @decocms/start
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@decocms/start.svg)](https://www.npmjs.com/package/@decocms/start)
4
4
  [![license](https://img.shields.io/npm/l/@decocms/start.svg)](https://github.com/decocms/deco-start/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "0.30.2",
3
+ "version": "0.30.4",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./src/index.ts",
@@ -228,10 +228,12 @@ if (!G.__deco._builtinMatchersRegistered) {
228
228
  "website/matchers/never.ts": () => false,
229
229
  "website/matchers/device.ts": (rule, ctx) => {
230
230
  const ua = (ctx.userAgent || "").toLowerCase();
231
- const isMobile = /mobile|android|iphone|ipad|ipod|webos|blackberry|opera mini|iemobile/i.test(ua);
232
- if (rule.mobile) return isMobile;
233
- if (rule.desktop) return !isMobile;
234
- return true;
231
+ const isTablet = /ipad|android(?!.*mobile)|tablet/i.test(ua);
232
+ const isMobile = !isTablet && /mobile|android|iphone|ipod|webos|blackberry|opera mini|iemobile/i.test(ua);
233
+ const isDesktop = !isMobile && !isTablet;
234
+ // If no flags are set, match everything (permissive default)
235
+ if (!rule.mobile && !rule.tablet && !rule.desktop) return true;
236
+ return !!(rule.mobile && isMobile) || !!(rule.tablet && isTablet) || !!(rule.desktop && isDesktop);
235
237
  },
236
238
  "website/matchers/random.ts": (rule) => {
237
239
  const traffic = typeof rule.traffic === "number" ? rule.traffic : 0.5;
@@ -94,12 +94,29 @@ function isSafePattern(pattern: string): boolean {
94
94
  }
95
95
 
96
96
  function pathnameMatcher(rule: Record<string, unknown>, ctx: MatcherContext): boolean {
97
+ const path = ctx.path ?? "";
98
+
99
+ // CMS "case" format: { type: "Includes" | "Equals" | "Not Includes" | "Starts With", pathname: "/..." }
100
+ const caseObj = rule.case as { type?: string; pathname?: string } | undefined;
101
+ if (caseObj?.pathname) {
102
+ switch (caseObj.type) {
103
+ case "Equals":
104
+ return path === caseObj.pathname;
105
+ case "Not Includes":
106
+ return !path.includes(caseObj.pathname);
107
+ case "Starts With":
108
+ return path.startsWith(caseObj.pathname);
109
+ case "Includes":
110
+ default:
111
+ return path.includes(caseObj.pathname);
112
+ }
113
+ }
114
+
115
+ // Standard format: pattern (regex), includes (exact/glob), excludes (exact/glob)
97
116
  const pattern = rule.pattern as string | undefined;
98
117
  const includes = rule.includes as string[] | undefined;
99
118
  const excludes = rule.excludes as string[] | undefined;
100
119
 
101
- const path = ctx.path ?? "";
102
-
103
120
  if (pattern) {
104
121
  if (!isSafePattern(pattern)) {
105
122
  console.warn(
@@ -137,6 +154,9 @@ function pathnameMatcher(rule: Record<string, unknown>, ctx: MatcherContext): bo
137
154
  if (excluded) return false;
138
155
  }
139
156
 
157
+ // No constraints specified — vacuously true
158
+ if (!pattern && !includes?.length && !excludes?.length) return false;
159
+
140
160
  return true;
141
161
  }
142
162