saloe 0.0.83 → 0.0.85

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.cjs.js CHANGED
@@ -38,8 +38,8 @@ const stream = ({ head, body, scripts, env, status, args }) => {
38
38
  ];
39
39
  return worker.stream({ callbacks, headers, status });
40
40
  };
41
- const awaitHtml = async ({ pending, success, error }) => {
42
- const id = Math.floor(Math.random() * 1e9);
41
+ const awaitHtml = async ({ id, pending, success, error }) => {
42
+ id = id ?? Math.floor(Math.random() * 1e9);
43
43
  const pendingId = `pending_${id}`;
44
44
  const pendingRoutePathname = `/~/components/${pendingId}`;
45
45
  const route = async () => {
@@ -57,7 +57,6 @@ const awaitHtml = async ({ pending, success, error }) => {
57
57
  ],
58
58
  headers
59
59
  });
60
- router.removeRoute({ pathname: pendingRoutePathname });
61
60
  return streamResult;
62
61
  };
63
62
  router.addRoute({
package/dist/html.es.js CHANGED
@@ -3,7 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
4
4
  var _a;
5
5
  import { stream as stream$1 } from "./worker.es.js";
6
- import { addRoute, removeRoute } from "./router.es.js";
6
+ import { addRoute } from "./router.es.js";
7
7
  import { getScope, getEnv } from "./util.es.js";
8
8
  const html = (s, ...args) => {
9
9
  var _a2;
@@ -36,8 +36,8 @@ const stream = ({ head, body, scripts, env, status, args }) => {
36
36
  ];
37
37
  return stream$1({ callbacks, headers, status });
38
38
  };
39
- const awaitHtml = async ({ pending, success, error }) => {
40
- const id = Math.floor(Math.random() * 1e9);
39
+ const awaitHtml = async ({ id, pending, success, error }) => {
40
+ id = id ?? Math.floor(Math.random() * 1e9);
41
41
  const pendingId = `pending_${id}`;
42
42
  const pendingRoutePathname = `/~/components/${pendingId}`;
43
43
  const route = async () => {
@@ -55,7 +55,6 @@ const awaitHtml = async ({ pending, success, error }) => {
55
55
  ],
56
56
  headers
57
57
  });
58
- removeRoute({ pathname: pendingRoutePathname });
59
58
  return streamResult;
60
59
  };
61
60
  addRoute({
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const listener = ({
4
- SRC_ELEMEMENTS_QUERY = []
4
+ SRC_ELEMEMENTS_QUERY = [],
5
+ listenAfterMs = 2500
5
6
  } = {}) => {
6
7
  const EVENTS_PREVENT_DEFAULT_MANDATORY = [
7
8
  "submit"
@@ -198,13 +199,14 @@ const listener = ({
198
199
  window.onload = () => {
199
200
  setTimeout(() => {
200
201
  document.body.saloeListen();
201
- }, 2500);
202
+ }, listenAfterMs);
202
203
  };
203
204
  };
204
205
  const getScriptListener = ({
205
- SRC_ELEMEMENTS_QUERY = []
206
+ SRC_ELEMEMENTS_QUERY = [],
207
+ listenAfterMs = 2500
206
208
  } = {}) => {
207
- return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)} })<\/script>`;
209
+ return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)}, listenAfterMs: ${listenAfterMs} })<\/script>`;
208
210
  };
209
211
  exports.getScriptListener = getScriptListener;
210
212
  exports.listener = listener;
@@ -1,5 +1,6 @@
1
1
  const listener = ({
2
- SRC_ELEMEMENTS_QUERY = []
2
+ SRC_ELEMEMENTS_QUERY = [],
3
+ listenAfterMs = 2500
3
4
  } = {}) => {
4
5
  const EVENTS_PREVENT_DEFAULT_MANDATORY = [
5
6
  "submit"
@@ -196,13 +197,14 @@ const listener = ({
196
197
  window.onload = () => {
197
198
  setTimeout(() => {
198
199
  document.body.saloeListen();
199
- }, 2500);
200
+ }, listenAfterMs);
200
201
  };
201
202
  };
202
203
  const getScriptListener = ({
203
- SRC_ELEMEMENTS_QUERY = []
204
+ SRC_ELEMEMENTS_QUERY = [],
205
+ listenAfterMs = 2500
204
206
  } = {}) => {
205
- return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)} })<\/script>`;
207
+ return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)}, listenAfterMs: ${listenAfterMs} })<\/script>`;
206
208
  };
207
209
  export {
208
210
  getScriptListener,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saloe",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "description": "Tools for making web development easy and efficient",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/html.js CHANGED
@@ -37,9 +37,9 @@ const stream = ({ head, body, scripts, env, status, args }) => {
37
37
  return streamAsWorker({ callbacks, headers, status })
38
38
  }
39
39
 
40
- const awaitHtml = async ({ pending, success, error }) => {
41
- const id = Math.floor(Math.random() * 1_000_000_000)
42
-
40
+ const awaitHtml = async ({ id, pending, success, error }) => {
41
+ id = id ?? Math.floor(Math.random() * 1_000_000_000)
42
+
43
43
  const pendingId = `pending_${id}`
44
44
  const pendingRoutePathname = `/~/components/${pendingId}`
45
45
 
@@ -64,7 +64,7 @@ const awaitHtml = async ({ pending, success, error }) => {
64
64
  headers,
65
65
  })
66
66
 
67
- removeRoute({ pathname: pendingRoutePathname })
67
+ // removeRoute({ pathname: pendingRoutePathname })
68
68
 
69
69
  return streamResult
70
70
  }
package/src/listener.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const listener = ({
2
- SRC_ELEMEMENTS_QUERY = []
2
+ SRC_ELEMEMENTS_QUERY = [],
3
+ listenAfterMs = 2_500,
3
4
  } = {}) => {
4
5
  const EVENTS_PREVENT_DEFAULT_MANDATORY = [
5
6
  'submit'
@@ -16,24 +17,12 @@ const listener = ({
16
17
  'invalid',
17
18
  ]
18
19
 
19
- // const addListener = ({ srcElement, eventName, listeners }) => {
20
- // srcElement?.addEventListener(eventName, (e) => {
21
- // executeListeners({ e, srcElement, listeners })
22
- // })
23
- // }
24
-
25
20
  const addListener = ({ srcElement, eventName, listeners, afterExecuteListeners }) => {
26
21
  srcElement?.addEventListener(eventName, (e) => {
27
22
  executeListeners({ e, srcElement, listeners, afterExecuteListeners })
28
23
  })
29
24
  }
30
25
 
31
- // const executeListeners = async ({ e, srcElement, listeners }) => {
32
- // listeners?.forEach((listener) => {
33
- // if (listener) listener({ e, srcElement })
34
- // })
35
- // }
36
-
37
26
  const executeListeners = async ({ e, srcElement, listeners, afterExecuteListeners }) => {
38
27
  await Promise.all(
39
28
  (listeners ?? []).map((listener) => {
@@ -291,14 +280,15 @@ const listener = ({
291
280
  window.onload = () => {
292
281
  setTimeout(() => {
293
282
  document.body.saloeListen()
294
- }, 2_500)
283
+ }, listenAfterMs)
295
284
  }
296
285
  }
297
286
 
298
287
  const getScriptListener = ({
299
288
  SRC_ELEMEMENTS_QUERY = [],
289
+ listenAfterMs = 2_500
300
290
  } = {}) => {
301
- return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)} })</script>`
291
+ return `<script defer>(${listener.toString()})({ SRC_ELEMEMENTS_QUERY: ${JSON.stringify(SRC_ELEMEMENTS_QUERY)}, listenAfterMs: ${listenAfterMs} })</script>`
302
292
  }
303
293
 
304
294
  export {