@spirobel/mininext 0.2.6 → 0.2.7

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 CHANGED
@@ -19,6 +19,8 @@ export declare class DangerJsonInHtml extends HtmlString {
19
19
  }
20
20
  export declare const json: <X = undefined>(strings: TemplateStringsArray, ...values: JsonStringValues<X>[]) => JsonString;
21
21
  export declare const dangerjson: <X = undefined>(strings: TemplateStringsArray, ...values: JsonStringValues<X>[]) => DangerJsonInHtml;
22
+ export declare const commonHead = "\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <script>\n /* prevent form resubmission */\n if (window.history.replaceState) {\n window.history.replaceState(null, null, window.location.href);\n }\n </script>";
23
+ export declare const cssReset = "\n <style>\n /* CSS Reset */\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n\n /* Set the background color to black */\n html,\n body {\n background-color: #000;\n color: #fff; /* Set the default text color to white for better contrast */\n }\n </style>";
22
24
  /**
23
25
  * Set the default head for all pages. Can still be overwritten on a per page basis
24
26
  * @param defaultHead - HtmlString
package/dist/html.js CHANGED
@@ -103,9 +103,16 @@ function JsonTemplateProcessor(danger = false) {
103
103
  }
104
104
  export const json = JsonTemplateProcessor();
105
105
  export const dangerjson = JsonTemplateProcessor(true);
106
- let default_head = html ` <title>mini-next</title>
106
+ export const commonHead = /*html*/ `
107
107
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
108
- <style>
108
+ <script>
109
+ /* prevent form resubmission */
110
+ if (window.history.replaceState) {
111
+ window.history.replaceState(null, null, window.location.href);
112
+ }
113
+ </script>`;
114
+ export const cssReset = /*html*/ `
115
+ <style>
109
116
  /* CSS Reset */
110
117
  * {
111
118
  margin: 0;
@@ -119,13 +126,11 @@ let default_head = html ` <title>mini-next</title>
119
126
  background-color: #000;
120
127
  color: #fff; /* Set the default text color to white for better contrast */
121
128
  }
122
- </style>
123
- <script>
124
- /* prevent form resubmission */
125
- if (window.history.replaceState) {
126
- window.history.replaceState(null, null, window.location.href);
127
- }
128
- </script>`;
129
+ </style>`;
130
+ let default_head = html `
131
+ <title>mini-next</title>
132
+ ${commonHead} ${cssReset}
133
+ `;
129
134
  /**
130
135
  * Set the default head for all pages. Can still be overwritten on a per page basis
131
136
  * @param defaultHead - HtmlString
@@ -168,7 +173,7 @@ export async function htmlResponder(mini, maybeUnresolved, head = default_head,
168
173
  flattend.unshift(/*html*/ `<!DOCTYPE html>
169
174
  <html>
170
175
  <head>
171
- ${Reloader || ""} ${head}
176
+ ${global.Reloader || ""} ${head}
172
177
  </head>
173
178
  <body>
174
179
  `);
@@ -1,5 +1,5 @@
1
1
  import { url, Mini, type HtmlHandler } from "./url";
2
- import { html, isError, HtmlString, head } from "./html";
2
+ import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
3
3
  declare function build(backendPath?: string): Promise<void>;
4
4
  declare const standardDevReloader = "\n <script>\n function reloader() {\n let socket = null;\n\n function connectWebSocket() {\n if (socket) {\n return;\n }\n socket = new WebSocket(\"ws://localhost:3001/reload\");\n\n socket.addEventListener(\"message\", (event) => {\n window.location.reload();\n });\n\n socket.addEventListener(\"close\", (event) => {\n // Reestablish the connection after 1 second\n socket = null;\n });\n\n socket.addEventListener(\"error\", (event) => {\n socket = null;\n });\n }\n connectWebSocket(); // connect to reloader, if it does not work:\n setInterval(connectWebSocket, 1000); // retry every 1 second\n }\n reloader();\n </script>\n ";
5
- export { url, html, head, build, isError, HtmlString, type HtmlHandler, Mini, standardDevReloader, };
5
+ export { url, html, head, build, 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, isError, HtmlString, head } from "./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
  const PROJECT_ROOT = import.meta.dir + "/../../../../";
@@ -142,4 +142,4 @@ const standardDevReloader = /*html*/ `
142
142
  reloader();
143
143
  </script>
144
144
  `;
145
- export { url, html, head, build, isError, HtmlString, Mini, standardDevReloader, };
145
+ export { url, html, head, build, isError, HtmlString, Mini, standardDevReloader, commonHead, cssReset, };
package/package.json CHANGED
@@ -5,14 +5,14 @@
5
5
  "main": "dist/mininext.js",
6
6
  "types": "dist/mininext.d.ts",
7
7
  "scripts": {
8
- "publish": "npm publish",
8
+ "publish": "bun run build && npm publish",
9
9
  "build": "tsc",
10
10
  "postversion": "git push --follow-tags",
11
11
  "preversion": "bun run build"
12
12
 
13
13
  },
14
14
  "files": ["dist", "mininext"],
15
- "version": "0.2.6",
15
+ "version": "0.2.7",
16
16
  "devDependencies": {
17
17
  "@types/bun": "latest"
18
18
  },