@protobase/cli 0.45.4 → 0.45.5

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.45.4";
2
+ var version = "0.45.5";
3
3
  //#endregion
4
4
  export { version };
@@ -0,0 +1,14 @@
1
+ //#region src/mobile/app-id.ts
2
+ const appIdPattern = /^[a-zA-Z][a-zA-Z0-9]*(?:\.[a-zA-Z][a-zA-Z0-9]*)+$/;
3
+ const suggestedAppId = (appId) => {
4
+ const suggestion = appId.split(".").map((segment) => segment.replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]+/, "")).filter(Boolean).join(".");
5
+ return appIdPattern.test(suggestion) ? suggestion : "com.example.app";
6
+ };
7
+ /** Whether `appId` can be the app's id on both iOS and Android. */
8
+ const isAppId = (appId) => typeof appId === "string" && appIdPattern.test(appId);
9
+ /** Why `appId` cannot be the app's id on both iOS and Android, with a fixed id to use instead. */
10
+ const appIdProblem = (appId) => {
11
+ return `mobile.appId must be a reverse-DNS id that iOS and Android both accept: at least two parts separated by dots, each starting with a letter and holding only letters and digits (no underscores or hyphens), such as ${typeof appId === "string" ? suggestedAppId(appId) : "com.example.app"}, not ${JSON.stringify(appId)}`;
12
+ };
13
+ //#endregion
14
+ export { appIdProblem, isAppId };
@@ -1,8 +1,8 @@
1
1
  import { pinnedProblem } from "./pinned-packages.js";
2
+ import { appIdProblem, isAppId } from "./app-id.js";
2
3
  import { packageNameProblem } from "./package-name.js";
3
4
  //#region src/mobile/mobile-config.ts
4
5
  const noMobileSection = "This project has no mobile section: add `mobile: { appId: 'com.example.app' }` to the default export of protobase.config.ts";
5
- const appIdPattern = /^[a-zA-Z][\w]*(?:\.[a-zA-Z][\w]*)+$/;
6
6
  const unauthenticated = /^(?:http:|git:|git\+http:)/i;
7
7
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  /** The project's `mobile` section, checked: an error says what to add or fix. */
@@ -10,7 +10,7 @@ const checkMobileConfig = (value) => {
10
10
  if (value === void 0) throw new Error(noMobileSection);
11
11
  if (!isRecord(value)) throw new Error("mobile in protobase.config.ts must be an object such as { appId: 'com.example.app' }");
12
12
  const { appId, plugins } = value;
13
- if (typeof appId !== "string" || !appIdPattern.test(appId.toLowerCase())) throw new Error(`mobile.appId must be a reverse-DNS id such as com.example.app: at least two parts separated by dots, each starting with a letter and holding only letters, digits and underscores, not ${JSON.stringify(appId)}`);
13
+ if (!isAppId(appId)) throw new Error(appIdProblem(appId));
14
14
  if (plugins === void 0) return { appId };
15
15
  if (!isRecord(plugins) || Object.values(plugins).some((spec) => typeof spec !== "string")) throw new Error("mobile.plugins must map each plugin's npm name to a version range, such as { '@capacitor/camera': '^8.0.0' }");
16
16
  for (const [name, spec] of Object.entries(plugins)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.45.4",
3
+ "version": "0.45.5",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "@better-auth/core": "^1.7.12",
37
37
  "@hono/node-server": "^2.1.3",
38
38
  "@hono/vite-dev-server": "^0.26.1",
39
- "@protobase/layout": "0.45.4",
40
- "@protobase/query": "0.45.4",
41
- "@protobase/schema": "0.45.4",
42
- "@protobase/server": "0.45.4",
43
- "@protobase/ui": "0.45.4",
39
+ "@protobase/layout": "0.45.5",
40
+ "@protobase/query": "0.45.5",
41
+ "@protobase/schema": "0.45.5",
42
+ "@protobase/server": "0.45.5",
43
+ "@protobase/ui": "0.45.5",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",
@@ -30,7 +30,7 @@ export default defineConfig({
30
30
  })
31
31
  ```
32
32
 
33
- - `appId` is the app's id in reverse-DNS form: at least two parts separated by dots, each starting with a letter and holding only letters, digits and underscores.
33
+ - `appId` is the app's id in reverse-DNS form, the same on iOS and Android: at least two parts separated by dots, each starting with a letter and holding only letters and digits. Underscores and hyphens are refused, as iOS rejects underscores and Android rejects hyphens; `protobase mobile` stops early on such an id and suggests one without them.
34
34
  - `plugins`, optional, are extra native [Capacitor plugins](https://capacitorjs.com/docs/plugins), npm name to version. Capacitor itself, `@capacitor/app`, `@capacitor/splash-screen` and `@capawesome/capacitor-live-update` come with Protobase at fixed versions and cannot be listed. A plugin runs native code with the app's rights, and one that writes files, such as `@capacitor/filesystem`, lets a script that got into the page point the iOS app at files it wrote (with Capacitor's own `WebView.setServerBasePath`), so list only plugins the app needs. On Android a plugin's JavaScript cannot call `CapacitorHttp`, `CapacitorCookies` or `WebView`, and `Capacitor.convertFileSrc` URLs do not load: call those from the plugin's native code.
35
35
 
36
36
  With a mobile section, the API answers the app's origins, `capacitor://localhost` on iOS and `https://localhost` on Android, through [CORS](../reference/api.md#cors). Apps without one get no new dependency, and `protobase build` and `protobase dev` work as before.