hono 3.12.9 → 3.12.11

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.
@@ -19,16 +19,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var html_exports = {};
20
20
  __export(html_exports, {
21
21
  html: () => html,
22
- raw: () => raw
22
+ raw: () => import_html.raw
23
23
  });
24
24
  module.exports = __toCommonJS(html_exports);
25
25
  var import_html = require("../../utils/html");
26
- const raw = (value, callbacks) => {
27
- const escapedString = new String(value);
28
- escapedString.isEscaped = true;
29
- escapedString.callbacks = callbacks;
30
- return escapedString;
31
- };
32
26
  const html = (strings, ...values) => {
33
27
  const buffer = [""];
34
28
  for (let i = 0, len = strings.length - 1; i < len; i++) {
@@ -55,7 +49,7 @@ const html = (strings, ...values) => {
55
49
  }
56
50
  }
57
51
  buffer[0] += strings[strings.length - 1];
58
- return buffer.length === 1 ? raw(buffer[0]) : (0, import_html.stringBufferToString)(buffer);
52
+ return buffer.length === 1 ? (0, import_html.raw)(buffer[0]) : (0, import_html.stringBufferToString)(buffer);
59
53
  };
60
54
  // Annotate the CommonJS export names for ESM import in node:
61
55
  0 && (module.exports = {
@@ -100,7 +100,6 @@ class Node {
100
100
  search(method, path) {
101
101
  const handlerSets = [];
102
102
  this.params = {};
103
- const params = {};
104
103
  const curNode = this;
105
104
  let curNodes = [curNode];
106
105
  const parts = (0, import_url.splitPath)(path);
@@ -124,6 +123,7 @@ class Node {
124
123
  }
125
124
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
126
125
  const pattern = node.patterns[k];
126
+ const params = { ...node.params };
127
127
  if (pattern === "*") {
128
128
  const astNode = node.children["*"];
129
129
  if (astNode) {
@@ -149,10 +149,10 @@ class Node {
149
149
  if (isLast === true) {
150
150
  handlerSets.push(...this.gHSets(child, method, params, node.params));
151
151
  if (child.children["*"]) {
152
- handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
152
+ handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
153
153
  }
154
154
  } else {
155
- child.params = { ...params };
155
+ child.params = params;
156
156
  tempNodes.push(child);
157
157
  }
158
158
  }
@@ -164,7 +164,7 @@ class Node {
164
164
  const results = handlerSets.sort((a, b) => {
165
165
  return a.score - b.score;
166
166
  });
167
- return [results.map(({ handler, params: params2 }) => [handler, params2])];
167
+ return [results.map(({ handler, params }) => [handler, params])];
168
168
  }
169
169
  }
170
170
  // Annotate the CommonJS export names for ESM import in node:
@@ -20,16 +20,22 @@ var html_exports = {};
20
20
  __export(html_exports, {
21
21
  HtmlEscapedCallbackPhase: () => HtmlEscapedCallbackPhase,
22
22
  escapeToBuffer: () => escapeToBuffer,
23
+ raw: () => raw,
23
24
  resolveCallback: () => resolveCallback,
24
25
  stringBufferToString: () => stringBufferToString
25
26
  });
26
27
  module.exports = __toCommonJS(html_exports);
27
- var import_html = require("../helper/html");
28
28
  const HtmlEscapedCallbackPhase = {
29
29
  Stringify: 1,
30
30
  BeforeStream: 2,
31
31
  Stream: 3
32
32
  };
33
+ const raw = (value, callbacks) => {
34
+ const escapedString = new String(value);
35
+ escapedString.isEscaped = true;
36
+ escapedString.callbacks = callbacks;
37
+ return escapedString;
38
+ };
33
39
  const escapeRe = /[&<>'"]/;
34
40
  const stringBufferToString = async (buffer) => {
35
41
  let str = "";
@@ -57,7 +63,7 @@ const stringBufferToString = async (buffer) => {
57
63
  str = buf[0];
58
64
  }
59
65
  }
60
- return (0, import_html.raw)(str, callbacks);
66
+ return raw(str, callbacks);
61
67
  };
62
68
  const escapeToBuffer = (str, buffer) => {
63
69
  const match = str.search(escapeRe);
@@ -109,7 +115,7 @@ const resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =
109
115
  ).then(() => buffer[0])
110
116
  );
111
117
  if (preserveCallbacks) {
112
- return (0, import_html.raw)(await resStr, callbacks);
118
+ return raw(await resStr, callbacks);
113
119
  } else {
114
120
  return resStr;
115
121
  }
@@ -118,6 +124,7 @@ const resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =
118
124
  0 && (module.exports = {
119
125
  HtmlEscapedCallbackPhase,
120
126
  escapeToBuffer,
127
+ raw,
121
128
  resolveCallback,
122
129
  stringBufferToString
123
130
  });
@@ -1,11 +1,5 @@
1
1
  // src/helper/html/index.ts
2
- import { escapeToBuffer, stringBufferToString } from "../../utils/html.js";
3
- var raw = (value, callbacks) => {
4
- const escapedString = new String(value);
5
- escapedString.isEscaped = true;
6
- escapedString.callbacks = callbacks;
7
- return escapedString;
8
- };
2
+ import { escapeToBuffer, stringBufferToString, raw } from "../../utils/html.js";
9
3
  var html = (strings, ...values) => {
10
4
  const buffer = [""];
11
5
  for (let i = 0, len = strings.length - 1; i < len; i++) {
@@ -78,7 +78,6 @@ var Node = class {
78
78
  search(method, path) {
79
79
  const handlerSets = [];
80
80
  this.params = {};
81
- const params = {};
82
81
  const curNode = this;
83
82
  let curNodes = [curNode];
84
83
  const parts = splitPath(path);
@@ -102,6 +101,7 @@ var Node = class {
102
101
  }
103
102
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
104
103
  const pattern = node.patterns[k];
104
+ const params = { ...node.params };
105
105
  if (pattern === "*") {
106
106
  const astNode = node.children["*"];
107
107
  if (astNode) {
@@ -127,10 +127,10 @@ var Node = class {
127
127
  if (isLast === true) {
128
128
  handlerSets.push(...this.gHSets(child, method, params, node.params));
129
129
  if (child.children["*"]) {
130
- handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
130
+ handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
131
131
  }
132
132
  } else {
133
- child.params = { ...params };
133
+ child.params = params;
134
134
  tempNodes.push(child);
135
135
  }
136
136
  }
@@ -142,7 +142,7 @@ var Node = class {
142
142
  const results = handlerSets.sort((a, b) => {
143
143
  return a.score - b.score;
144
144
  });
145
- return [results.map(({ handler, params: params2 }) => [handler, params2])];
145
+ return [results.map(({ handler, params }) => [handler, params])];
146
146
  }
147
147
  };
148
148
  export {
@@ -1,3 +1,4 @@
1
- import type { HtmlEscapedString, HtmlEscapedCallback } from '../../utils/html';
2
- export declare const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) => HtmlEscapedString;
1
+ import { raw } from '../../utils/html';
2
+ import type { HtmlEscapedString } from '../../utils/html';
3
+ export { raw };
3
4
  export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>;
@@ -380,7 +380,7 @@ type ExtractParams<Path extends string> = string extends Path ? Record<string, s
380
380
  [K in Param | keyof ExtractParams<`/${Rest}`>]: string;
381
381
  } : Path extends `${infer Start}:${infer Param}` ? {
382
382
  [K in Param]: string;
383
- } : never;
383
+ } : {};
384
384
  export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = {
385
385
  [P in keyof OrigSchema as MergePath<SubPath, P & string>]: {
386
386
  [M in keyof OrigSchema[P]]: OrigSchema[P][M] extends {
@@ -29,6 +29,7 @@ export type HtmlEscapedString = string & HtmlEscaped;
29
29
  * ]
30
30
  */
31
31
  export type StringBuffer = (string | Promise<string>)[];
32
+ export declare const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) => HtmlEscapedString;
32
33
  export declare const stringBufferToString: (buffer: StringBuffer) => Promise<HtmlEscapedString>;
33
34
  export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
34
35
  export declare const resolveCallback: (str: string | HtmlEscapedString, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]) => Promise<string>;
@@ -1,10 +1,15 @@
1
1
  // src/utils/html.ts
2
- import { raw } from "../helper/html/index.js";
3
2
  var HtmlEscapedCallbackPhase = {
4
3
  Stringify: 1,
5
4
  BeforeStream: 2,
6
5
  Stream: 3
7
6
  };
7
+ var raw = (value, callbacks) => {
8
+ const escapedString = new String(value);
9
+ escapedString.isEscaped = true;
10
+ escapedString.callbacks = callbacks;
11
+ return escapedString;
12
+ };
8
13
  var escapeRe = /[&<>'"]/;
9
14
  var stringBufferToString = async (buffer) => {
10
15
  let str = "";
@@ -92,6 +97,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
92
97
  export {
93
98
  HtmlEscapedCallbackPhase,
94
99
  escapeToBuffer,
100
+ raw,
95
101
  resolveCallback,
96
102
  stringBufferToString
97
103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.9",
3
+ "version": "3.12.11",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",