@spirobel/mininext 0.2.8 → 0.2.9
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 +1 -1
- package/dist/html.js +6 -4
- package/dist/mininext.d.ts +1 -1
- package/dist/mininext.js +25 -25
- package/mininext/html.ts +7 -5
- package/mininext/mininext.ts +25 -25
- package/package.json +1 -1
package/dist/html.d.ts
CHANGED
package/dist/html.js
CHANGED
|
@@ -168,16 +168,16 @@ export async function htmlResponder(mini, maybeUnresolved, head = default_head,
|
|
|
168
168
|
when you embed unescaped json elements in an html document.
|
|
169
169
|
</div>`;
|
|
170
170
|
}
|
|
171
|
-
const definitelyResolved = await maybeUnresolved.resolve(mini);
|
|
172
|
-
const flattend = definitelyResolved.flat(Infinity);
|
|
173
171
|
if (!(maybeUnresolved instanceof JsonString)) {
|
|
174
|
-
|
|
172
|
+
maybeUnresolved = html `<!DOCTYPE html>
|
|
175
173
|
<html>
|
|
176
174
|
<head>
|
|
177
175
|
${global.Reloader || ""} ${head}
|
|
178
176
|
</head>
|
|
179
177
|
<body>
|
|
180
|
-
|
|
178
|
+
${maybeUnresolved}
|
|
179
|
+
</body>
|
|
180
|
+
</html> `;
|
|
181
181
|
}
|
|
182
182
|
else {
|
|
183
183
|
const headers = {
|
|
@@ -186,6 +186,8 @@ export async function htmlResponder(mini, maybeUnresolved, head = default_head,
|
|
|
186
186
|
};
|
|
187
187
|
options.headers = headers;
|
|
188
188
|
}
|
|
189
|
+
const definitelyResolved = await maybeUnresolved.resolve(mini);
|
|
190
|
+
const flattend = definitelyResolved.flat(Infinity);
|
|
189
191
|
async function* stepGen() {
|
|
190
192
|
let index = 0;
|
|
191
193
|
while (index < flattend.length) {
|
package/dist/mininext.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { url, Mini, type HtmlHandler } from "./url";
|
|
2
2
|
import { html, isError, HtmlString, head, commonHead, cssReset } from "./html";
|
|
3
3
|
declare function build(backendPath?: string): Promise<void>;
|
|
4
|
-
declare const standardDevReloader
|
|
4
|
+
declare const standardDevReloader: HtmlString;
|
|
5
5
|
export { url, html, head, build, isError, HtmlString, type HtmlHandler, Mini, standardDevReloader, commonHead, cssReset, };
|
package/dist/mininext.js
CHANGED
|
@@ -112,34 +112,34 @@ async function devServer() {
|
|
|
112
112
|
watchAndBuild("frontend");
|
|
113
113
|
watchAndBuild("backend");
|
|
114
114
|
}
|
|
115
|
-
const standardDevReloader =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
const standardDevReloader = html `
|
|
116
|
+
<script>
|
|
117
|
+
function reloader() {
|
|
118
|
+
let socket = null;
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
function connectWebSocket() {
|
|
121
|
+
if (socket) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
socket = new WebSocket("ws://localhost:3001/reload");
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
socket.addEventListener("message", (event) => {
|
|
127
|
+
window.location.reload();
|
|
128
|
+
});
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
socket.addEventListener("close", (event) => {
|
|
131
|
+
// Reestablish the connection after 1 second
|
|
132
|
+
socket = null;
|
|
133
|
+
});
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
connectWebSocket(); // connect to reloader, if it does not work:
|
|
140
|
-
setInterval(connectWebSocket, 1000); // retry every 1 second
|
|
135
|
+
socket.addEventListener("error", (event) => {
|
|
136
|
+
socket = null;
|
|
137
|
+
});
|
|
141
138
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
connectWebSocket(); // connect to reloader, if it does not work:
|
|
140
|
+
setInterval(connectWebSocket, 1000); // retry every 1 second
|
|
141
|
+
}
|
|
142
|
+
reloader();
|
|
143
|
+
</script>
|
|
144
|
+
`;
|
|
145
145
|
export { url, html, head, build, isError, HtmlString, Mini, standardDevReloader, commonHead, cssReset, };
|
package/mininext/html.ts
CHANGED
|
@@ -216,16 +216,16 @@ export async function htmlResponder(
|
|
|
216
216
|
when you embed unescaped json elements in an html document.
|
|
217
217
|
</div>`;
|
|
218
218
|
}
|
|
219
|
-
const definitelyResolved = await maybeUnresolved.resolve(mini);
|
|
220
|
-
const flattend = definitelyResolved.flat(Infinity);
|
|
221
219
|
if (!(maybeUnresolved instanceof JsonString)) {
|
|
222
|
-
|
|
220
|
+
maybeUnresolved = html`<!DOCTYPE html>
|
|
223
221
|
<html>
|
|
224
222
|
<head>
|
|
225
223
|
${global.Reloader || ""} ${head}
|
|
226
224
|
</head>
|
|
227
225
|
<body>
|
|
228
|
-
|
|
226
|
+
${maybeUnresolved}
|
|
227
|
+
</body>
|
|
228
|
+
</html> `;
|
|
229
229
|
} else {
|
|
230
230
|
const headers = {
|
|
231
231
|
...options.headers,
|
|
@@ -233,6 +233,8 @@ export async function htmlResponder(
|
|
|
233
233
|
};
|
|
234
234
|
options.headers = headers;
|
|
235
235
|
}
|
|
236
|
+
const definitelyResolved = await maybeUnresolved.resolve(mini);
|
|
237
|
+
const flattend = definitelyResolved.flat(Infinity);
|
|
236
238
|
|
|
237
239
|
async function* stepGen() {
|
|
238
240
|
let index = 0;
|
|
@@ -263,5 +265,5 @@ export function isError(
|
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
declare global {
|
|
266
|
-
var Reloader:
|
|
268
|
+
var Reloader: HtmlString | undefined;
|
|
267
269
|
}
|
package/mininext/mininext.ts
CHANGED
|
@@ -121,36 +121,36 @@ async function devServer() {
|
|
|
121
121
|
watchAndBuild("frontend");
|
|
122
122
|
watchAndBuild("backend");
|
|
123
123
|
}
|
|
124
|
-
const standardDevReloader =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
const standardDevReloader = html`
|
|
125
|
+
<script>
|
|
126
|
+
function reloader() {
|
|
127
|
+
let socket = null;
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
function connectWebSocket() {
|
|
130
|
+
if (socket) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
socket = new WebSocket("ws://localhost:3001/reload");
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
socket.addEventListener("message", (event) => {
|
|
136
|
+
window.location.reload();
|
|
137
|
+
});
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
socket.addEventListener("close", (event) => {
|
|
140
|
+
// Reestablish the connection after 1 second
|
|
141
|
+
socket = null;
|
|
142
|
+
});
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
connectWebSocket(); // connect to reloader, if it does not work:
|
|
149
|
-
setInterval(connectWebSocket, 1000); // retry every 1 second
|
|
144
|
+
socket.addEventListener("error", (event) => {
|
|
145
|
+
socket = null;
|
|
146
|
+
});
|
|
150
147
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
connectWebSocket(); // connect to reloader, if it does not work:
|
|
149
|
+
setInterval(connectWebSocket, 1000); // retry every 1 second
|
|
150
|
+
}
|
|
151
|
+
reloader();
|
|
152
|
+
</script>
|
|
153
|
+
`;
|
|
154
154
|
|
|
155
155
|
export {
|
|
156
156
|
url,
|