saloe 0.0.86 → 0.0.88

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,7 +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 ({ id, pending, success, error }) => {
41
+ const awaitHtml = async ({ env, id, pending, success, error }) => {
42
+ if (!util.isServiceWorker({ env: env ?? (self == null ? void 0 : self.env) })) return success();
42
43
  id = id ?? Math.floor(Math.random() * 1e9);
43
44
  const pendingId = `pending_${id}`;
44
45
  const pendingRoutePathname = `/~/components/${pendingId}`;
@@ -51,7 +52,7 @@ const awaitHtml = async ({ id, pending, success, error }) => {
51
52
  async () => html`
52
53
  ${await success().then((template) => template).catch((err) => {
53
54
  console.error(err == null ? void 0 : err.stack);
54
- return error ? error({ id, err }) : "";
55
+ return error ? error({ id, err }) : err;
55
56
  })}
56
57
  `
57
58
  ],
package/dist/html.es.js CHANGED
@@ -4,7 +4,7 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
4
4
  var _a;
5
5
  import { stream as stream$1 } from "./worker.es.js";
6
6
  import { addRoute } from "./router.es.js";
7
- import { getScope, getEnv } from "./util.es.js";
7
+ import { isServiceWorker, getScope, getEnv } from "./util.es.js";
8
8
  const html = (s, ...args) => {
9
9
  var _a2;
10
10
  return (_a2 = s == null ? void 0 : s.map((ss, i) => `${ss}${(args == null ? void 0 : args.at(i)) ?? ""}`)) == null ? void 0 : _a2.join("");
@@ -36,7 +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 ({ id, pending, success, error }) => {
39
+ const awaitHtml = async ({ env, id, pending, success, error }) => {
40
+ if (!isServiceWorker({ env: env ?? (self == null ? void 0 : self.env) })) return success();
40
41
  id = id ?? Math.floor(Math.random() * 1e9);
41
42
  const pendingId = `pending_${id}`;
42
43
  const pendingRoutePathname = `/~/components/${pendingId}`;
@@ -49,7 +50,7 @@ const awaitHtml = async ({ id, pending, success, error }) => {
49
50
  async () => html`
50
51
  ${await success().then((template) => template).catch((err) => {
51
52
  console.error(err == null ? void 0 : err.stack);
52
- return error ? error({ id, err }) : "";
53
+ return error ? error({ id, err }) : err;
53
54
  })}
54
55
  `
55
56
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saloe",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "description": "Tools for making web development easy and efficient",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/html.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { stream as streamAsWorker } from './worker'
2
2
  import { addRoute, removeRoute } from './router'
3
- import { getScope, getEnv } from './util'
3
+ import { getScope, getEnv, isServiceWorker } from './util'
4
4
 
5
5
 
6
6
  const html = (s, ...args) => {
@@ -37,7 +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 ({ id, pending, success, error }) => {
40
+ const awaitHtml = async ({ env, id, pending, success, error }) => {
41
+ if (!isServiceWorker({ env: env ?? self?.env })) return success()
42
+
41
43
  id = id ?? Math.floor(Math.random() * 1_000_000_000)
42
44
 
43
45
  const pendingId = `pending_${id}`
@@ -56,7 +58,7 @@ const awaitHtml = async ({ id, pending, success, error }) => {
56
58
  .then((template) => template)
57
59
  .catch((err) => {
58
60
  console.error(err?.stack)
59
- return error ? error({ id, err }) : ''
61
+ return error ? error({ id, err }) : err
60
62
  })
61
63
  }
62
64
  `