@nano-app/frontend 0.6.2 → 0.6.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.
@@ -1,4 +1,2 @@
1
- //#region ../core/const.d.ts
2
1
  /** Name of the app: the backend's main plugin and the frontend's store of UI state, always present */
3
- export declare const APP_NAME = "app";
4
- //#endregion
2
+ export declare const APP_NAME = "app";
@@ -1,4 +1,4 @@
1
- //#region ../core/const.ts
1
+ // ../core/const.ts
2
2
  /** HTTP methods a route can handle */
3
3
  const HTTP_METHODS = [
4
4
  "GET",
@@ -15,5 +15,4 @@ const STORES_ENV = "NANO_APP_STORES";
15
15
  const REQUEST_FAILED = "Request failed";
16
16
  /** Error of a component outside the provider */
17
17
  const MISSING_PROVIDER = "[nano-app] [ERROR] A component has no stores. Wrap the root layout with NanoAppProvider.";
18
- //#endregion
19
18
  export { HTTP_METHODS, IS_SERVER, MISSING_PROVIDER, REQUEST_FAILED, STORES_ENV };
@@ -2,7 +2,7 @@ import Validator from "./Validator.js";
2
2
  import FileReader from "./FileReader.js";
3
3
  import Formatter from "../utils/Formatter.js";
4
4
  import { glob } from "glob";
5
- //#region ../core/loader/FileLoader.ts
5
+ // ../core/loader/FileLoader.ts
6
6
  /** Finds, loads and validates the consumer's files */
7
7
  var FileLoader = class {
8
8
  /**
@@ -34,5 +34,4 @@ var FileLoader = class {
34
34
  return Validator.validate(oEntries, extension);
35
35
  }
36
36
  };
37
- //#endregion
38
37
  export { FileLoader as default };
@@ -1,7 +1,7 @@
1
1
  import { isAbsolute, resolve } from "node:path";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { createJiti } from "jiti";
4
- //#region ../core/loader/FileReader.ts
4
+ // ../core/loader/FileReader.ts
5
5
  /** Reads and loads files from disk, resolved from `cwd` */
6
6
  var FileReader = class {
7
7
  /** Loader of the consumer's modules; the Prisma runtime is loaded natively */
@@ -27,5 +27,4 @@ var FileReader = class {
27
27
  return sAbsolutePath;
28
28
  }
29
29
  };
30
- //#endregion
31
30
  export { FileReader as default };
@@ -1,5 +1,5 @@
1
1
  import { HTTP_METHODS } from "../const.js";
2
- //#region ../core/loader/Validator.ts
2
+ // ../core/loader/Validator.ts
3
3
  const STORE_TYPES = ["app", "api"];
4
4
  /** Checks the consumer's files: invalid ones are warned about and discarded */
5
5
  var Validator = class Validator {
@@ -56,5 +56,4 @@ var Validator = class Validator {
56
56
  return this.oValidators[sExtension]?.()(oEntry, sFilePath) ? oEntry : void 0;
57
57
  }
58
58
  };
59
- //#endregion
60
59
  export { Validator as default };
@@ -1,4 +1,3 @@
1
- //#region ../core/types/api.d.ts
2
1
  /** API response */
3
2
  export type ApiResponse<T = any> = {
4
3
  status?: number;
@@ -6,5 +5,4 @@ export type ApiResponse<T = any> = {
6
5
  result?: T;
7
6
  message?: string;
8
7
  warning?: boolean;
9
- };
10
- //#endregion
8
+ };
@@ -1,4 +1,2 @@
1
- //#region ../core/types/objects.d.ts
2
1
  /** Generic object */
3
- export type NanoObject<T = any> = Record<string, T>;
4
- //#endregion
2
+ export type NanoObject<T = any> = Record<string, T>;
@@ -1,4 +1,4 @@
1
- //#region ../core/utils/Formatter.ts
1
+ // ../core/utils/Formatter.ts
2
2
  /** Formats values for logs and messages */
3
3
  var Formatter = class {
4
4
  /** Message of anything thrown: its `message` when it has one, else the value itself */
@@ -11,5 +11,4 @@ var Formatter = class {
11
11
  return oDate.toISOString().slice(0, 19).replace("T", " ");
12
12
  }
13
13
  };
14
- //#endregion
15
14
  export { Formatter as default };
@@ -1,6 +1,4 @@
1
1
  import { NanoObject } from "../core/types/objects.js";
2
2
  import { ComponentContext, Controller } from "../types/component.js";
3
- //#region src/creators/createController.d.ts
4
3
  /** Creates a controller: methods on the stores and the props, for the views bound to it */
5
- export default function createController<M extends NanoObject>(fnMethods: (context: ComponentContext) => M): Controller<M>;
6
- //#endregion
4
+ export default function createController<M extends NanoObject>(fnMethods: (context: ComponentContext) => M): Controller<M>;
@@ -2,7 +2,7 @@
2
2
  import { IS_SERVER } from "../core/const.js";
3
3
  import { useStores } from "../react/NanoAppProvider.js";
4
4
  import { enableStaticRendering, observer } from "mobx-react-lite";
5
- //#region src/creators/createController.ts
5
+ // src/creators/createController.ts
6
6
  enableStaticRendering(IS_SERVER);
7
7
  /** Creates a controller: methods on the stores and the props, for the views bound to it */
8
8
  function createController(fnMethods) {
@@ -23,5 +23,4 @@ function createController(fnMethods) {
23
23
  }))
24
24
  };
25
25
  }
26
- //#endregion
27
26
  export { createController as default };
@@ -1,8 +1,8 @@
1
- import Store from "../stores/Store.js";
2
1
  import ApiStore from "../stores/ApiStore.js";
3
2
  import AuthStore from "../stores/AuthStore.js";
3
+ import Store from "../stores/Store.js";
4
4
  import STORE_FILES from "../stores/storeFiles.js";
5
- //#region src/creators/createStores.ts
5
+ // src/creators/createStores.ts
6
6
  /** Stores of one React tree, from the ones `withNanoApp` inlined at build time */
7
7
  function createStores() {
8
8
  return {
@@ -16,5 +16,4 @@ function createStore(sName, oFile) {
16
16
  if (oFile.auth) return new AuthStore(sName, oFile.auth, oFile.data);
17
17
  return new ApiStore(sName, oFile.data);
18
18
  }
19
- //#endregion
20
19
  export { createStores as default };
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ApiError } from "./types/store.js";
2
1
  import { NanoAppProvider } from "./react/NanoAppProvider.js";
3
- import { ComponentContext, ComponentProps, Controller, View } from "./types/component.js";
4
2
  import createController from "./creators/createController.js";
3
+ import { ComponentContext, ComponentProps, Controller, View } from "./types/component.js";
4
+ import { ApiError } from "./types/store.js";
5
5
  export { type ApiError, type ComponentContext, type ComponentProps, type Controller, NanoAppProvider, type View, createController };
package/build/next.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { NextConfig } from "next";
2
- //#region src/next.d.ts
3
2
  /**
4
3
  * Wraps the app's Next config: loads its stores while Next reads `next.config.ts`, before compiling.
5
4
  * Node only: never import it from the app's components.
6
5
  */
7
- export declare function withNanoApp(oNextConfig?: NextConfig): () => Promise<NextConfig>;
8
- //#endregion
6
+ export declare function withNanoApp(oNextConfig?: NextConfig): () => Promise<NextConfig>;
package/build/next.js CHANGED
@@ -1,6 +1,6 @@
1
- import { STORES_ENV } from "./core/const.js";
2
1
  import FileLoader from "./core/loader/FileLoader.js";
3
- //#region src/next.ts
2
+ import { STORES_ENV } from "./core/const.js";
3
+ // src/next.ts
4
4
  /**
5
5
  * Wraps the app's Next config: loads its stores while Next reads `next.config.ts`, before compiling.
6
6
  * Node only: never import it from the app's components.
@@ -17,5 +17,4 @@ function withNanoApp(oNextConfig = {}) {
17
17
  };
18
18
  };
19
19
  }
20
- //#endregion
21
20
  export { withNanoApp };
package/build/proxy.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  import { NextRequest } from "next/server";
2
- //#region src/proxy.d.ts
3
2
  /** Sends `/api/<store>/<path>` to the backend of `<store>`, in `API_<STORE>_URL`, with its headers */
4
- export declare function proxy(oReq: NextRequest): Promise<Response>;
5
- //#endregion
3
+ export declare function proxy(oReq: NextRequest): Promise<Response>;
package/build/proxy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import STORE_FILES from "./stores/storeFiles.js";
2
2
  import { NextResponse } from "next/server";
3
- //#region src/proxy.ts
3
+ // src/proxy.ts
4
4
  /** Sends `/api/<store>/<path>` to the backend of `<store>`, in `API_<STORE>_URL`, with its headers */
5
5
  async function proxy(oReq) {
6
6
  const [, sPrefix, sName, ...aPath] = oReq.nextUrl.pathname.split("/");
@@ -21,5 +21,4 @@ async function proxy(oReq) {
21
21
  });
22
22
  return new Response(oRes.body, oRes);
23
23
  }
24
- //#endregion
25
24
  export { proxy };
@@ -1,7 +1,5 @@
1
1
  import { ReactNode } from "react";
2
- //#region src/react/NanoAppProvider.d.ts
3
2
  /** Root of the app's React tree: wraps the root layout and gives the tree its own stores */
4
3
  export declare function NanoAppProvider({ children }: {
5
4
  children: ReactNode;
6
- }): ReactNode;
7
- //#endregion
5
+ }): ReactNode;
@@ -3,7 +3,7 @@ import { MISSING_PROVIDER } from "../core/const.js";
3
3
  import createStores from "../creators/createStores.js";
4
4
  import { createContext, use, useRef } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
- //#region src/react/NanoAppProvider.tsx
6
+ // src/react/NanoAppProvider.tsx
7
7
  /** Stores of the tree, read by the components */
8
8
  const StoreContext = createContext(null);
9
9
  /** Root of the app's React tree: wraps the root layout and gives the tree its own stores */
@@ -21,5 +21,4 @@ function useStores() {
21
21
  if (!oStores) throw new Error(MISSING_PROVIDER);
22
22
  return oStores;
23
23
  }
24
- //#endregion
25
24
  export { NanoAppProvider, useStores };
@@ -1,6 +1,6 @@
1
1
  import { IS_SERVER, REQUEST_FAILED } from "../core/const.js";
2
2
  import Store from "./Store.js";
3
- //#region src/stores/ApiStore.ts
3
+ // src/stores/ApiStore.ts
4
4
  /** Backend of an `api` store through its proxy; each read keeps its `ApiResponse` in the store */
5
5
  var ApiStore = class ApiStore extends Store {
6
6
  sName;
@@ -112,5 +112,4 @@ var ApiStore = class ApiStore extends Store {
112
112
  return oQuery ? `${sPath}?${JSON.stringify(oQuery)}` : sPath;
113
113
  }
114
114
  };
115
- //#endregion
116
115
  export { ApiStore as default };
@@ -1,6 +1,6 @@
1
1
  import { IS_SERVER } from "../core/const.js";
2
2
  import ApiStore from "./ApiStore.js";
3
- //#region src/stores/AuthStore.ts
3
+ // src/stores/AuthStore.ts
4
4
  /** Api store of a backend with Better Auth: signs in and out, and keeps the session */
5
5
  var AuthStore = class extends ApiStore {
6
6
  sBasePath;
@@ -56,5 +56,4 @@ var AuthStore = class extends ApiStore {
56
56
  return oResponse;
57
57
  }
58
58
  };
59
- //#endregion
60
59
  export { AuthStore as default };
@@ -1,5 +1,4 @@
1
1
  import { NanoObject } from "../core/types/objects.js";
2
- //#region src/stores/Store.d.ts
3
2
  /** State of one store, read and written by path (`/drawer/isOpen`) */
4
3
  export default class Store {
5
4
  private oState;
@@ -11,5 +10,4 @@ export default class Store {
11
10
  set(sPath: string, oValue: unknown): void;
12
11
  /** Keys of a path, with or without the leading slash */
13
12
  private static keys;
14
- }
15
- //#endregion
13
+ }
@@ -1,5 +1,5 @@
1
1
  import { observable, runInAction } from "mobx";
2
- //#region src/stores/Store.ts
2
+ // src/stores/Store.ts
3
3
  /** State of one store, read and written by path (`/drawer/isOpen`) */
4
4
  var Store = class Store {
5
5
  oState;
@@ -29,5 +29,4 @@ var Store = class Store {
29
29
  return sPath.split("/").filter(Boolean);
30
30
  }
31
31
  };
32
- //#endregion
33
32
  export { Store as default };
@@ -1,5 +1,4 @@
1
- //#region src/stores/storeFiles.ts
1
+ // src/stores/storeFiles.ts
2
2
  /** Store files that `withNanoApp` inlined at build time, read once when the app loads */
3
3
  const STORE_FILES = JSON.parse(process.env.NANO_APP_STORES ?? "{}");
4
- //#endregion
5
4
  export { STORE_FILES as default };
@@ -1,7 +1,6 @@
1
1
  import { NanoObject } from "../core/types/objects.js";
2
2
  import { Stores } from "./store.js";
3
3
  import { ReactNode } from "react";
4
- //#region src/types/component.d.ts
5
4
  /** Props a component receives from its parent */
6
5
  export type ComponentProps = NanoObject<any>;
7
6
  /** What a controller and its views receive: the props and the stores */
@@ -17,5 +16,4 @@ export type Controller<M extends NanoObject> = {
17
16
  bindView(view: View<M>): (props: ComponentProps) => ReactNode;
18
17
  /** Creates a controller with these methods merged over its own: a method with the same name wins */
19
18
  extend<E extends NanoObject>(methods: (context: ComponentContext) => E): Controller<Omit<M, keyof E> & E>;
20
- };
21
- //#endregion
19
+ };
@@ -1,8 +1,7 @@
1
1
  import { APP_NAME } from "../core/const.js";
2
- import { NanoObject } from "../core/types/objects.js";
3
2
  import { ApiResponse } from "../core/types/api.js";
3
+ import { NanoObject } from "../core/types/objects.js";
4
4
  import Store from "../stores/Store.js";
5
- //#region src/types/store.d.ts
6
5
  /** A failed request in the `/error/list` of its api store: its `ApiResponse` and when it failed */
7
6
  export type ApiError = ApiResponse & {
8
7
  /** Milliseconds since the epoch, from `Date.now()` */
@@ -11,5 +10,4 @@ export type ApiError = ApiResponse & {
11
10
  /** Stores of a React tree by name: a `Store` per `app` file, an `ApiStore` per `api` file */
12
11
  export type Stores = NanoObject<any> & {
13
12
  [APP_NAME]: Store;
14
- };
15
- //#endregion
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-app/frontend",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "React provider for Next.js apps on top of @nano-app/backend",
5
5
  "type": "module",
6
6
  "exports": {
@@ -51,22 +51,22 @@
51
51
  "react": ">=19.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "glob": "^13.0.6",
54
+ "glob": "^14.0.3",
55
55
  "jiti": "^2.7.0",
56
- "mobx": "^7.1.0",
56
+ "mobx": "^7.1.3",
57
57
  "mobx-react-lite": "^5.1.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@happy-dom/global-registrator": "^21.0.3",
61
61
  "@testing-library/dom": "^10.4.2",
62
62
  "@testing-library/react": "^16.3.3",
63
- "@types/node": "^26.6.5",
63
+ "@types/node": "^26.6.6",
64
64
  "@types/react": "^19.3.0",
65
65
  "happy-dom": "^21.0.3",
66
66
  "next": "^16.4.3",
67
67
  "react": "^19.3.1",
68
68
  "react-dom": "^19.3.1",
69
- "tsdown": "^0.23.1",
69
+ "tsdown": "^0.23.4",
70
70
  "tsx": "^4.23.15",
71
71
  "typescript": "^7.0.2"
72
72
  }