@nano-app/frontend 0.6.3 → 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.
- package/build/core/const.d.ts +1 -3
- package/build/core/const.js +1 -2
- package/build/core/loader/FileLoader.js +1 -2
- package/build/core/loader/FileReader.js +1 -2
- package/build/core/loader/Validator.js +1 -2
- package/build/core/types/api.d.ts +1 -3
- package/build/core/types/objects.d.ts +1 -3
- package/build/core/utils/Formatter.js +1 -2
- package/build/creators/createController.d.ts +1 -3
- package/build/creators/createController.js +1 -2
- package/build/creators/createStores.js +2 -3
- package/build/index.d.ts +2 -2
- package/build/next.d.ts +1 -3
- package/build/next.js +2 -3
- package/build/proxy.d.ts +1 -3
- package/build/proxy.js +1 -2
- package/build/react/NanoAppProvider.d.ts +1 -3
- package/build/react/NanoAppProvider.js +1 -2
- package/build/stores/ApiStore.js +1 -2
- package/build/stores/AuthStore.js +1 -2
- package/build/stores/Store.d.ts +1 -3
- package/build/stores/Store.js +1 -2
- package/build/stores/storeFiles.js +1 -2
- package/build/types/component.d.ts +1 -3
- package/build/types/store.d.ts +2 -4
- package/package.json +4 -4
package/build/core/const.d.ts
CHANGED
package/build/core/const.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|
package/build/stores/ApiStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IS_SERVER, REQUEST_FAILED } from "../core/const.js";
|
|
2
2
|
import Store from "./Store.js";
|
|
3
|
-
|
|
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
|
-
|
|
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 };
|
package/build/stores/Store.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/build/stores/Store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { observable, runInAction } from "mobx";
|
|
2
|
-
|
|
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
|
-
|
|
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
|
+
};
|
package/build/types/store.d.ts
CHANGED
|
@@ -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.
|
|
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,7 +51,7 @@
|
|
|
51
51
|
"react": ">=19.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"glob": "^
|
|
54
|
+
"glob": "^14.0.3",
|
|
55
55
|
"jiti": "^2.7.0",
|
|
56
56
|
"mobx": "^7.1.3",
|
|
57
57
|
"mobx-react-lite": "^5.1.0"
|
|
@@ -60,13 +60,13 @@
|
|
|
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.
|
|
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.
|
|
69
|
+
"tsdown": "^0.23.4",
|
|
70
70
|
"tsx": "^4.23.15",
|
|
71
71
|
"typescript": "^7.0.2"
|
|
72
72
|
}
|