@hyperspan/framework 0.5.3 → 0.5.5

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.
@@ -3,7 +3,7 @@ import {
3
3
  __toESM
4
4
  } from "./chunk-atw8cdg1.js";
5
5
 
6
- // ../../node_modules/timestring/index.js
6
+ // node_modules/timestring/index.js
7
7
  var require_timestring = __commonJS((exports, module) => {
8
8
  module.exports = parseTimestring;
9
9
  var DEFAULT_OPTS = {
@@ -73,7 +73,7 @@ var require_timestring = __commonJS((exports, module) => {
73
73
  }
74
74
  });
75
75
 
76
- // ../../node_modules/hono/dist/middleware/etag/digest.js
76
+ // node_modules/hono/dist/middleware/etag/digest.js
77
77
  var mergeBuffers = (buffer1, buffer2) => {
78
78
  if (!buffer1) {
79
79
  return buffer2;
@@ -102,7 +102,7 @@ var generateDigest = async (stream, generator) => {
102
102
  return Array.prototype.map.call(new Uint8Array(result), (x) => x.toString(16).padStart(2, "0")).join("");
103
103
  };
104
104
 
105
- // ../../node_modules/hono/dist/middleware/etag/index.js
105
+ // node_modules/hono/dist/middleware/etag/index.js
106
106
  var RETAINED_304_HEADERS = [
107
107
  "cache-control",
108
108
  "content-location",
package/dist/server.js CHANGED
@@ -76,7 +76,7 @@ import { html, isHSHtml, renderStream, renderAsync, render } from "@hyperspan/ht
76
76
  import { readdir } from "node:fs/promises";
77
77
  import { basename, extname, join as join2 } from "node:path";
78
78
 
79
- // ../../node_modules/isbot/index.mjs
79
+ // node_modules/isbot/index.mjs
80
80
  var fullPattern = " daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^azure|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|agent|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|fetcher|firephp|functionize|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/";
81
81
  var naivePattern = /bot|crawl|http|lighthouse|scan|search|spider/i;
82
82
  var pattern;
@@ -95,7 +95,7 @@ function isbot(userAgent) {
95
95
  return Boolean(userAgent) && getPattern().test(userAgent);
96
96
  }
97
97
 
98
- // ../../node_modules/hono/dist/compose.js
98
+ // node_modules/hono/dist/compose.js
99
99
  var compose = (middleware, onError, onNotFound) => {
100
100
  return (context, next) => {
101
101
  let index = -1;
@@ -139,10 +139,10 @@ var compose = (middleware, onError, onNotFound) => {
139
139
  };
140
140
  };
141
141
 
142
- // ../../node_modules/hono/dist/request/constants.js
142
+ // node_modules/hono/dist/request/constants.js
143
143
  var GET_MATCH_RESULT = Symbol();
144
144
 
145
- // ../../node_modules/hono/dist/utils/body.js
145
+ // node_modules/hono/dist/utils/body.js
146
146
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
147
147
  const { all = false, dot = false } = options;
148
148
  const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
@@ -210,7 +210,7 @@ var handleParsingNestedValues = (form, key, value) => {
210
210
  });
211
211
  };
212
212
 
213
- // ../../node_modules/hono/dist/utils/url.js
213
+ // node_modules/hono/dist/utils/url.js
214
214
  var splitPath = (path) => {
215
215
  const paths = path.split("/");
216
216
  if (paths[0] === "") {
@@ -279,7 +279,7 @@ var tryDecode = (str, decoder) => {
279
279
  var tryDecodeURI = (str) => tryDecode(str, decodeURI);
280
280
  var getPath = (request) => {
281
281
  const url = request.url;
282
- const start = url.indexOf("/", url.charCodeAt(9) === 58 ? 13 : 8);
282
+ const start = url.indexOf("/", url.indexOf(":") + 4);
283
283
  let i = start;
284
284
  for (;i < url.length; i++) {
285
285
  const charCode = url.charCodeAt(i);
@@ -405,7 +405,7 @@ var getQueryParams = (url, key) => {
405
405
  };
406
406
  var decodeURIComponent_ = decodeURIComponent;
407
407
 
408
- // ../../node_modules/hono/dist/request.js
408
+ // node_modules/hono/dist/request.js
409
409
  var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
410
410
  var HonoRequest = class {
411
411
  raw;
@@ -516,7 +516,7 @@ var HonoRequest = class {
516
516
  }
517
517
  };
518
518
 
519
- // ../../node_modules/hono/dist/utils/html.js
519
+ // node_modules/hono/dist/utils/html.js
520
520
  var HtmlEscapedCallbackPhase = {
521
521
  Stringify: 1,
522
522
  BeforeStream: 2,
@@ -554,7 +554,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
554
554
  }
555
555
  };
556
556
 
557
- // ../../node_modules/hono/dist/context.js
557
+ // node_modules/hono/dist/context.js
558
558
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
559
559
  var setDefaultContentType = (contentType, headers) => {
560
560
  return {
@@ -720,7 +720,7 @@ var Context = class {
720
720
  };
721
721
  };
722
722
 
723
- // ../../node_modules/hono/dist/router.js
723
+ // node_modules/hono/dist/router.js
724
724
  var METHOD_NAME_ALL = "ALL";
725
725
  var METHOD_NAME_ALL_LOWERCASE = "all";
726
726
  var METHODS = ["get", "post", "put", "delete", "options", "patch"];
@@ -728,10 +728,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
728
728
  var UnsupportedPathError = class extends Error {
729
729
  };
730
730
 
731
- // ../../node_modules/hono/dist/utils/constants.js
731
+ // node_modules/hono/dist/utils/constants.js
732
732
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
733
733
 
734
- // ../../node_modules/hono/dist/hono-base.js
734
+ // node_modules/hono/dist/hono-base.js
735
735
  var notFoundHandler = (c) => {
736
736
  return c.text("404 Not Found", 404);
737
737
  };
@@ -950,7 +950,7 @@ var Hono = class {
950
950
  };
951
951
  };
952
952
 
953
- // ../../node_modules/hono/dist/router/reg-exp-router/node.js
953
+ // node_modules/hono/dist/router/reg-exp-router/node.js
954
954
  var LABEL_REG_EXP_STR = "[^/]+";
955
955
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
956
956
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -1054,7 +1054,7 @@ var Node = class {
1054
1054
  }
1055
1055
  };
1056
1056
 
1057
- // ../../node_modules/hono/dist/router/reg-exp-router/trie.js
1057
+ // node_modules/hono/dist/router/reg-exp-router/trie.js
1058
1058
  var Trie = class {
1059
1059
  #context = { varIndex: 0 };
1060
1060
  #root = new Node;
@@ -1110,7 +1110,7 @@ var Trie = class {
1110
1110
  }
1111
1111
  };
1112
1112
 
1113
- // ../../node_modules/hono/dist/router/reg-exp-router/router.js
1113
+ // node_modules/hono/dist/router/reg-exp-router/router.js
1114
1114
  var emptyParam = [];
1115
1115
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
1116
1116
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
@@ -1292,7 +1292,7 @@ var RegExpRouter = class {
1292
1292
  }
1293
1293
  };
1294
1294
 
1295
- // ../../node_modules/hono/dist/router/smart-router/router.js
1295
+ // node_modules/hono/dist/router/smart-router/router.js
1296
1296
  var SmartRouter = class {
1297
1297
  name = "SmartRouter";
1298
1298
  #routers = [];
@@ -1347,7 +1347,7 @@ var SmartRouter = class {
1347
1347
  }
1348
1348
  };
1349
1349
 
1350
- // ../../node_modules/hono/dist/router/trie-router/node.js
1350
+ // node_modules/hono/dist/router/trie-router/node.js
1351
1351
  var emptyParams = /* @__PURE__ */ Object.create(null);
1352
1352
  var Node2 = class {
1353
1353
  #methods;
@@ -1501,7 +1501,7 @@ var Node2 = class {
1501
1501
  }
1502
1502
  };
1503
1503
 
1504
- // ../../node_modules/hono/dist/router/trie-router/router.js
1504
+ // node_modules/hono/dist/router/trie-router/router.js
1505
1505
  var TrieRouter = class {
1506
1506
  name = "TrieRouter";
1507
1507
  #node;
@@ -1523,7 +1523,7 @@ var TrieRouter = class {
1523
1523
  }
1524
1524
  };
1525
1525
 
1526
- // ../../node_modules/hono/dist/hono.js
1526
+ // node_modules/hono/dist/hono.js
1527
1527
  var Hono2 = class extends Hono {
1528
1528
  constructor(options = {}) {
1529
1529
  super(options);
@@ -1533,14 +1533,14 @@ var Hono2 = class extends Hono {
1533
1533
  }
1534
1534
  };
1535
1535
 
1536
- // ../../node_modules/hono/dist/adapter/bun/serve-static.js
1536
+ // node_modules/hono/dist/adapter/bun/serve-static.js
1537
1537
  import { stat } from "node:fs/promises";
1538
1538
  import { join } from "node:path";
1539
1539
 
1540
- // ../../node_modules/hono/dist/utils/compress.js
1540
+ // node_modules/hono/dist/utils/compress.js
1541
1541
  var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
1542
1542
 
1543
- // ../../node_modules/hono/dist/utils/mime.js
1543
+ // node_modules/hono/dist/utils/mime.js
1544
1544
  var getMimeType = (filename, mimes = baseMimes) => {
1545
1545
  const regexp = /\.([a-zA-Z0-9]+?)$/;
1546
1546
  const match = filename.match(regexp);
@@ -1613,7 +1613,7 @@ var _baseMimes = {
1613
1613
  };
1614
1614
  var baseMimes = _baseMimes;
1615
1615
 
1616
- // ../../node_modules/hono/dist/middleware/serve-static/path.js
1616
+ // node_modules/hono/dist/middleware/serve-static/path.js
1617
1617
  var defaultJoin = (...paths) => {
1618
1618
  let result = paths.filter((p) => p !== "").join("/");
1619
1619
  result = result.replace(/(?<=\/)\/+/g, "");
@@ -1629,7 +1629,7 @@ var defaultJoin = (...paths) => {
1629
1629
  return resolved.join("/") || ".";
1630
1630
  };
1631
1631
 
1632
- // ../../node_modules/hono/dist/middleware/serve-static/index.js
1632
+ // node_modules/hono/dist/middleware/serve-static/index.js
1633
1633
  var ENCODINGS = {
1634
1634
  br: ".br",
1635
1635
  zstd: ".zst",
@@ -1695,7 +1695,7 @@ var serveStatic = (options) => {
1695
1695
  };
1696
1696
  };
1697
1697
 
1698
- // ../../node_modules/hono/dist/adapter/bun/serve-static.js
1698
+ // node_modules/hono/dist/adapter/bun/serve-static.js
1699
1699
  var serveStatic2 = (options) => {
1700
1700
  return async function serveStatic2(c, next) {
1701
1701
  const getContent = async (path) => {
@@ -1719,7 +1719,7 @@ var serveStatic2 = (options) => {
1719
1719
  };
1720
1720
  };
1721
1721
 
1722
- // ../../node_modules/hono/dist/helper/ssg/middleware.js
1722
+ // node_modules/hono/dist/helper/ssg/middleware.js
1723
1723
  var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
1724
1724
  var SSG_DISABLED_RESPONSE = (() => {
1725
1725
  try {
@@ -1731,10 +1731,10 @@ var SSG_DISABLED_RESPONSE = (() => {
1731
1731
  return null;
1732
1732
  }
1733
1733
  })();
1734
- // ../../node_modules/hono/dist/adapter/bun/ssg.js
1734
+ // node_modules/hono/dist/adapter/bun/ssg.js
1735
1735
  var { write } = Bun;
1736
1736
 
1737
- // ../../node_modules/hono/dist/helper/websocket/index.js
1737
+ // node_modules/hono/dist/helper/websocket/index.js
1738
1738
  var WSContext = class {
1739
1739
  #init;
1740
1740
  constructor(init) {
@@ -1782,10 +1782,10 @@ var defineWebSocketHelper = (handler) => {
1782
1782
  };
1783
1783
  };
1784
1784
 
1785
- // ../../node_modules/hono/dist/adapter/bun/server.js
1785
+ // node_modules/hono/dist/adapter/bun/server.js
1786
1786
  var getBunServer = (c) => ("server" in c.env) ? c.env.server : c.env;
1787
1787
 
1788
- // ../../node_modules/hono/dist/adapter/bun/websocket.js
1788
+ // node_modules/hono/dist/adapter/bun/websocket.js
1789
1789
  var upgradeWebSocket = defineWebSocketHelper((c, events) => {
1790
1790
  const server = getBunServer(c);
1791
1791
  if (!server) {
@@ -1804,7 +1804,7 @@ var upgradeWebSocket = defineWebSocketHelper((c, events) => {
1804
1804
  return;
1805
1805
  });
1806
1806
 
1807
- // ../../node_modules/hono/dist/http-exception.js
1807
+ // node_modules/hono/dist/http-exception.js
1808
1808
  var HTTPException = class extends Error {
1809
1809
  res;
1810
1810
  status;
@@ -1827,7 +1827,7 @@ var HTTPException = class extends Error {
1827
1827
  }
1828
1828
  };
1829
1829
 
1830
- // ../../node_modules/hono/dist/middleware/csrf/index.js
1830
+ // node_modules/hono/dist/middleware/csrf/index.js
1831
1831
  var secFetchSiteValues = ["same-origin", "same-site", "none", "cross-site"];
1832
1832
  var isSecFetchSite = (value) => secFetchSiteValues.includes(value);
1833
1833
  var isSafeMethodRe = /^(GET|HEAD)$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperspan/framework",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Hyperspan Web Framework",
5
5
  "main": "dist/server.ts",
6
6
  "types": "src/server.ts",
@@ -65,7 +65,7 @@
65
65
  "typescript": "^5.8.3"
66
66
  },
67
67
  "dependencies": {
68
- "@hyperspan/html": "0.1.7",
68
+ "@hyperspan/html": "0.2.0",
69
69
  "hono": "^4.9.4",
70
70
  "isbot": "^5.1.30",
71
71
  "timestring": "^7.0.0",
@@ -110,8 +110,13 @@ window.customElements.define('hs-action', HSAction);
110
110
  const actionFormObserver = new MutationObserver((list) => {
111
111
  list.forEach((mutation) => {
112
112
  mutation.addedNodes.forEach((node) => {
113
- if (node instanceof HTMLFormElement) {
114
- bindHSActionForm(node.closest('hs-action') as HSAction, node);
113
+ if (node && ('closest' in node || node instanceof HTMLFormElement)) {
114
+ bindHSActionForm(
115
+ (node as HTMLElement).closest('hs-action') as HSAction,
116
+ node instanceof HTMLFormElement
117
+ ? node
118
+ : ((node as HTMLElement | HTMLFormElement).querySelector('form') as HTMLFormElement)
119
+ );
115
120
  }
116
121
  });
117
122
  });
@@ -127,6 +132,7 @@ function bindHSActionForm(hsActionElement: HSAction, form: HTMLFormElement) {
127
132
 
128
133
  form.setAttribute('action', hsActionElement.getAttribute('url') || '');
129
134
  const submitHandler = (e: Event) => {
135
+ e.preventDefault();
130
136
  formSubmitToRoute(e, form as HTMLFormElement, {
131
137
  afterResponse: () => bindHSActionForm(hsActionElement, form),
132
138
  });
@@ -140,10 +146,8 @@ function bindHSActionForm(hsActionElement: HSAction, form: HTMLFormElement) {
140
146
  */
141
147
  type TFormSubmitOptons = { afterResponse: () => any };
142
148
  function formSubmitToRoute(e: Event, form: HTMLFormElement, opts: TFormSubmitOptons) {
143
- e.preventDefault();
144
-
145
- const formUrl = form.getAttribute('action') || '';
146
149
  const formData = new FormData(form);
150
+ const formUrl = form.getAttribute('action') || '';
147
151
  const method = form.getAttribute('method')?.toUpperCase() || 'POST';
148
152
  const headers = {
149
153
  Accept: 'text/html',