@spirobel/mininext 0.2.24 → 0.2.26
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/dist/mininext.js +1 -1
- package/dist/url.d.ts +3 -3
- package/mininext/mininext.ts +1 -1
- package/mininext/url.ts +4 -4
- package/package.json +2 -1
package/dist/mininext.js
CHANGED
|
@@ -48,7 +48,7 @@ async function buildBackend(backendPath = "backend/backend.ts") {
|
|
|
48
48
|
outdir: path.resolve(projectRoot(), "dist"),
|
|
49
49
|
naming: "backend.js",
|
|
50
50
|
minify: Bun.argv[2] === "dev" ? false : true, //production
|
|
51
|
-
target: "
|
|
51
|
+
target: "bun",
|
|
52
52
|
define: {
|
|
53
53
|
FrontendScripts: JSON.stringify(FrontendScripts),
|
|
54
54
|
FrontendScriptUrls: JSON.stringify(FrontendScriptUrls),
|
package/dist/url.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type Form = {
|
|
|
11
11
|
actionlink<Y = unknown>(qs?: string[] | string, settings?: LinkSettings): (mini: Mini<Y>) => string;
|
|
12
12
|
onPostSubmit<F>(cb: () => F): F | undefined;
|
|
13
13
|
};
|
|
14
|
-
export type DataMaker<X, Z = unknown> = ((mini: Mini
|
|
14
|
+
export type DataMaker<X, Z = unknown> = ((mini: Mini, rerun?: Z) => DataMakerReturnType<X>) | (() => DataMakerReturnType<X>);
|
|
15
15
|
export type DataMakerReturnType<X> = X | Promise<X>;
|
|
16
16
|
export type HandlerReturnType = JsonString | DangerJsonInHtml | HtmlString | string | void;
|
|
17
17
|
export type LazyHandlerReturnType = HandlerReturnType | Promise<HandlerReturnType>;
|
|
@@ -112,7 +112,7 @@ export declare class url {
|
|
|
112
112
|
* @example const {html,json, css, data, req, form, link, svg, deliver, route, params, header, head } = mini //pull everything out of the mini handbag
|
|
113
113
|
* @returns
|
|
114
114
|
*/
|
|
115
|
-
handler: (dataHandler: HtmlHandler<T>) => (oldmini: Mini
|
|
115
|
+
handler: (dataHandler: HtmlHandler<T>) => (oldmini: Mini) => Promise<string | void | DangerJsonInHtml>;
|
|
116
116
|
dataMaker: DataMaker<T, Z>;
|
|
117
117
|
/**
|
|
118
118
|
* use this to **specify the input type for the functions**,
|
|
@@ -146,7 +146,7 @@ export declare class url {
|
|
|
146
146
|
* @param handler - normal html handler with mini as the argument
|
|
147
147
|
* @returns a wrapped html handler that will only be called when the request is post
|
|
148
148
|
*/
|
|
149
|
-
static post(handler: HtmlHandler): (mini: Mini) => LazyHandlerReturnType;
|
|
149
|
+
static post<Y = unknown>(handler: HtmlHandler<Y>): (mini: Mini<Y>) => LazyHandlerReturnType;
|
|
150
150
|
/**
|
|
151
151
|
* wrap your handlers in this if you mutate something to prevent CSRF issues.
|
|
152
152
|
* @param handler - normal html handler with mini as the argument
|
package/mininext/mininext.ts
CHANGED
|
@@ -59,7 +59,7 @@ async function buildBackend(backendPath: string = "backend/backend.ts") {
|
|
|
59
59
|
outdir: path.resolve(projectRoot(), "dist"),
|
|
60
60
|
naming: "backend.js",
|
|
61
61
|
minify: Bun.argv[2] === "dev" ? false : true, //production
|
|
62
|
-
target: "
|
|
62
|
+
target: "bun",
|
|
63
63
|
define: {
|
|
64
64
|
FrontendScripts: JSON.stringify(FrontendScripts),
|
|
65
65
|
FrontendScriptUrls: JSON.stringify(FrontendScriptUrls),
|
package/mininext/url.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type Form = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export type DataMaker<X, Z = unknown> =
|
|
19
|
-
| ((mini: Mini
|
|
19
|
+
| ((mini: Mini, rerun?: Z) => DataMakerReturnType<X>)
|
|
20
20
|
| (() => DataMakerReturnType<X>);
|
|
21
21
|
export type DataMakerReturnType<X> = X | Promise<X>;
|
|
22
22
|
export type HandlerReturnType =
|
|
@@ -221,7 +221,7 @@ export class url {
|
|
|
221
221
|
* @returns
|
|
222
222
|
*/
|
|
223
223
|
handler: (dataHandler: HtmlHandler<T>) => {
|
|
224
|
-
return async (oldmini: Mini
|
|
224
|
+
return async (oldmini: Mini) => {
|
|
225
225
|
const data = await dataMaker(oldmini);
|
|
226
226
|
const mini = new Mini(oldmini, data);
|
|
227
227
|
|
|
@@ -272,8 +272,8 @@ export class url {
|
|
|
272
272
|
* @param handler - normal html handler with mini as the argument
|
|
273
273
|
* @returns a wrapped html handler that will only be called when the request is post
|
|
274
274
|
*/
|
|
275
|
-
static post(handler: HtmlHandler) {
|
|
276
|
-
return (mini: Mini) => {
|
|
275
|
+
static post<Y = unknown>(handler: HtmlHandler<Y>) {
|
|
276
|
+
return (mini: Mini<Y>) => {
|
|
277
277
|
if (mini.form.post) {
|
|
278
278
|
return handler(mini);
|
|
279
279
|
} else {
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spirobel/mininext",
|
|
3
|
+
"license" : "MIT" ,
|
|
3
4
|
"module": "dist/mininext.js",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"main": "dist/mininext.js",
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
},
|
|
13
14
|
"files": ["dist", "mininext"],
|
|
14
|
-
"version": "0.2.
|
|
15
|
+
"version": "0.2.26",
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/bun": "latest"
|
|
17
18
|
},
|