@spirobel/mininext 0.2.16 → 0.2.18
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/html.d.ts +2 -2
- package/dist/html.js +1 -1
- package/dist/mininext.d.ts +2 -3
- package/dist/mininext.js +2 -3
- package/dist/url.d.ts +1 -1
- package/mininext/html.ts +3 -3
- package/mininext/mininext.ts +1 -13
- package/mininext/url.ts +2 -2
- package/package.json +1 -1
package/dist/html.d.ts
CHANGED
|
@@ -41,8 +41,8 @@ export declare const cssReset: HtmlString;
|
|
|
41
41
|
* ]);
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
export declare function head(defaultHead:
|
|
45
|
-
export declare function htmlResponder(mini: Mini, maybeUnresolved: HandlerReturnType, head?:
|
|
44
|
+
export declare function head(defaultHead: HtmlHandler): void;
|
|
45
|
+
export declare function htmlResponder(mini: Mini, maybeUnresolved: HandlerReturnType, head?: HtmlHandler, options?: ResponseInit): Promise<Response>;
|
|
46
46
|
/**
|
|
47
47
|
* Generic html error type guard
|
|
48
48
|
* @param submissionResult output of some function
|
package/dist/html.js
CHANGED
|
@@ -159,7 +159,7 @@ export const cssReset = html ` <style>
|
|
|
159
159
|
color: #fff; /* Set the default text color to white for better contrast */
|
|
160
160
|
}
|
|
161
161
|
</style>`;
|
|
162
|
-
let default_head = html `
|
|
162
|
+
let default_head = (mini) => mini.html `
|
|
163
163
|
<title>mini-next</title>
|
|
164
164
|
${commonHead} ${cssReset}
|
|
165
165
|
`;
|
package/dist/mininext.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { url, Mini, type HtmlHandler } from "./url";
|
|
2
|
-
import {
|
|
2
|
+
import { isError, HtmlString, head, commonHead, cssReset } from "./html";
|
|
3
3
|
declare global {
|
|
4
4
|
var PROJECT_ROOT: string | undefined;
|
|
5
5
|
}
|
|
6
6
|
declare function build(backendPath?: string): Promise<void>;
|
|
7
7
|
declare const standardDevReloader: HtmlString;
|
|
8
8
|
declare function makeEntrypoint(): Promise<(w: any) => Promise<Response>>;
|
|
9
|
-
|
|
10
|
-
export { url, css, json, html, head, build, makeEntrypoint, isError, HtmlString, type HtmlHandler, Mini, standardDevReloader, commonHead, cssReset, };
|
|
9
|
+
export { url, head, build, makeEntrypoint, isError, HtmlString, type HtmlHandler, Mini, standardDevReloader, commonHead, cssReset, };
|
package/dist/mininext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { url, Mini } from "./url";
|
|
2
|
-
import { html,
|
|
2
|
+
import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
|
|
3
3
|
import { watch } from "fs/promises";
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
function projectRoot() {
|
|
@@ -158,5 +158,4 @@ async function makeEntrypoint() {
|
|
|
158
158
|
}
|
|
159
159
|
return module.default;
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
export { url, css, json, html, head, build, makeEntrypoint, isError, HtmlString, Mini, standardDevReloader, commonHead, cssReset, };
|
|
161
|
+
export { url, head, build, makeEntrypoint, isError, HtmlString, Mini, standardDevReloader, commonHead, cssReset, };
|
package/dist/url.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class Mini<X = undefined> {
|
|
|
34
34
|
dangerjson: typeof dangerjson<X>;
|
|
35
35
|
data: X;
|
|
36
36
|
req: Request;
|
|
37
|
-
head: (head: HtmlString) => undefined;
|
|
37
|
+
head: (head: HtmlHandler | HtmlString) => undefined;
|
|
38
38
|
headers: (headers: HeadersInit, overwrite?: boolean) => undefined;
|
|
39
39
|
options: (options: ResponseInit) => undefined;
|
|
40
40
|
deliver: typeof url.deliver;
|
package/mininext/html.ts
CHANGED
|
@@ -194,7 +194,7 @@ export const cssReset = html` <style>
|
|
|
194
194
|
color: #fff; /* Set the default text color to white for better contrast */
|
|
195
195
|
}
|
|
196
196
|
</style>`;
|
|
197
|
-
let default_head = html`
|
|
197
|
+
let default_head: HtmlHandler = (mini: Mini) => mini.html`
|
|
198
198
|
<title>mini-next</title>
|
|
199
199
|
${commonHead} ${cssReset}
|
|
200
200
|
`;
|
|
@@ -217,14 +217,14 @@ let default_head = html`
|
|
|
217
217
|
* ]);
|
|
218
218
|
* ```
|
|
219
219
|
*/
|
|
220
|
-
export function head(defaultHead:
|
|
220
|
+
export function head(defaultHead: HtmlHandler) {
|
|
221
221
|
default_head = defaultHead;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
export async function htmlResponder(
|
|
225
225
|
mini: Mini,
|
|
226
226
|
maybeUnresolved: HandlerReturnType,
|
|
227
|
-
head:
|
|
227
|
+
head: HtmlHandler = default_head,
|
|
228
228
|
options: ResponseInit = {
|
|
229
229
|
headers: {
|
|
230
230
|
"Content-Type": "text/html; charset=utf-8",
|
package/mininext/mininext.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { url, Mini, type HtmlHandler } from "./url";
|
|
2
|
-
import {
|
|
3
|
-
html,
|
|
4
|
-
json,
|
|
5
|
-
isError,
|
|
6
|
-
HtmlString,
|
|
7
|
-
head,
|
|
8
|
-
commonHead,
|
|
9
|
-
cssReset,
|
|
10
|
-
} from "./html";
|
|
2
|
+
import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
|
|
11
3
|
import { watch } from "fs/promises";
|
|
12
4
|
import * as path from "path";
|
|
13
5
|
function projectRoot() {
|
|
@@ -178,12 +170,8 @@ async function makeEntrypoint() {
|
|
|
178
170
|
}
|
|
179
171
|
return module.default as (w: any) => Promise<Response>;
|
|
180
172
|
}
|
|
181
|
-
const css = html;
|
|
182
173
|
export {
|
|
183
174
|
url,
|
|
184
|
-
css,
|
|
185
|
-
json,
|
|
186
|
-
html,
|
|
187
175
|
head,
|
|
188
176
|
build,
|
|
189
177
|
makeEntrypoint,
|
package/mininext/url.ts
CHANGED
|
@@ -54,7 +54,7 @@ export class Mini<X = undefined> {
|
|
|
54
54
|
|
|
55
55
|
data: X;
|
|
56
56
|
req!: Request;
|
|
57
|
-
head!: (head: HtmlString) => undefined;
|
|
57
|
+
head!: (head: HtmlHandler | HtmlString) => undefined;
|
|
58
58
|
headers!: (headers: HeadersInit, overwrite?: boolean) => undefined;
|
|
59
59
|
options!: (options: ResponseInit) => undefined;
|
|
60
60
|
deliver!: typeof url.deliver;
|
|
@@ -409,7 +409,7 @@ export class url {
|
|
|
409
409
|
const handler = url.direct_handlers_html.get(reqPath);
|
|
410
410
|
if (handler) {
|
|
411
411
|
//this is the source of mini
|
|
412
|
-
let handlerHead: HtmlString | undefined = undefined;
|
|
412
|
+
let handlerHead: HtmlHandler | HtmlString | undefined = undefined;
|
|
413
413
|
let handlerOptions: ResponseInit = {
|
|
414
414
|
headers: {
|
|
415
415
|
"Content-Type": "text/html; charset=utf-8",
|