@spirobel/mininext 0.2.6 → 0.2.8

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: HtmlString;
23
+ export declare const cssReset: HtmlString;
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,29 +103,35 @@ 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>
107
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
108
- <style>
109
- /* CSS Reset */
110
- * {
111
- margin: 0;
112
- padding: 0;
113
- box-sizing: border-box;
114
- }
115
-
116
- /* Set the background color to black */
117
- html,
118
- body {
119
- background-color: #000;
120
- color: #fff; /* Set the default text color to white for better contrast */
121
- }
122
- </style>
106
+ export const commonHead = html ` <meta
107
+ name="viewport"
108
+ content="width=device-width, initial-scale=1.0"
109
+ />
123
110
  <script>
124
111
  /* prevent form resubmission */
125
112
  if (window.history.replaceState) {
126
113
  window.history.replaceState(null, null, window.location.href);
127
114
  }
128
115
  </script>`;
116
+ export const cssReset = html ` <style>
117
+ /* CSS Reset */
118
+ * {
119
+ margin: 0;
120
+ padding: 0;
121
+ box-sizing: border-box;
122
+ }
123
+
124
+ /* Set the background color to black */
125
+ html,
126
+ body {
127
+ background-color: #000;
128
+ color: #fff; /* Set the default text color to white for better contrast */
129
+ }
130
+ </style>`;
131
+ let default_head = html `
132
+ <title>mini-next</title>
133
+ ${commonHead} ${cssReset}
134
+ `;
129
135
  /**
130
136
  * Set the default head for all pages. Can still be overwritten on a per page basis
131
137
  * @param defaultHead - HtmlString
@@ -168,7 +174,7 @@ export async function htmlResponder(mini, maybeUnresolved, head = default_head,
168
174
  flattend.unshift(/*html*/ `<!DOCTYPE html>
169
175
  <html>
170
176
  <head>
171
- ${Reloader || ""} ${head}
177
+ ${global.Reloader || ""} ${head}
172
178
  </head>
173
179
  <body>
174
180
  `);
@@ -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/mininext/html.ts CHANGED
@@ -145,30 +145,31 @@ function JsonTemplateProcessor(danger: boolean = false) {
145
145
  }
146
146
  export const json = JsonTemplateProcessor();
147
147
  export const dangerjson = JsonTemplateProcessor(true);
148
- export const commonHead = /*html*/ `
149
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
148
+ export const commonHead = html` <meta
149
+ name="viewport"
150
+ content="width=device-width, initial-scale=1.0"
151
+ />
150
152
  <script>
151
153
  /* prevent form resubmission */
152
154
  if (window.history.replaceState) {
153
155
  window.history.replaceState(null, null, window.location.href);
154
156
  }
155
157
  </script>`;
156
- export const cssReset = /*html*/ `
157
- <style>
158
- /* CSS Reset */
159
- * {
160
- margin: 0;
161
- padding: 0;
162
- box-sizing: border-box;
163
- }
158
+ export const cssReset = html` <style>
159
+ /* CSS Reset */
160
+ * {
161
+ margin: 0;
162
+ padding: 0;
163
+ box-sizing: border-box;
164
+ }
164
165
 
165
- /* Set the background color to black */
166
- html,
167
- body {
168
- background-color: #000;
169
- color: #fff; /* Set the default text color to white for better contrast */
170
- }
171
- </style>`;
166
+ /* Set the background color to black */
167
+ html,
168
+ body {
169
+ background-color: #000;
170
+ color: #fff; /* Set the default text color to white for better contrast */
171
+ }
172
+ </style>`;
172
173
  let default_head = html`
173
174
  <title>mini-next</title>
174
175
  ${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.8",
16
16
  "devDependencies": {
17
17
  "@types/bun": "latest"
18
18
  },