ovr 4.1.0 → 4.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/app/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,MAAM,YAAY,CAAC;AAGpB,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAA;CAAE,KAAK,GAAG,CAAC,OAAO,CAAC;AAShE,qBAAa,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;;IAC7C,gFAAgF;IAChF,GAAG,EAAE,OAAO,CAAC;IAEb,4EAA4E;IAC5E,GAAG,EAAE,GAAG,CAAC;IAET;;;;;;;OAOG;IACH,MAAM,EAAG,CAAC,CAAC;IAEX,oCAAoC;IACpC,KAAK,EAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE/B,+FAA+F;IAC/F,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAE7B,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,OAAO,UAAiB;IAQxB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAI7B,IAAI,mEAAkB;gBAGrB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,aAA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M,CAAC,EAAE,MAAM,CAAC;QAEhB,gFAAgF;QAChF,OAAO,CAAC,EAAE,WAAW,CAAC;KACtB;IAYF;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM;IAO3C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM;IAO/B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM;IAOpC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,GAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAS;IAK1E;;OAEG;IACH,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE;IAI9B;;OAEG;IACH,MAAM,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE;IAI1B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;IAkEvC;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM;IAed;;OAEG;IACH,KAAK;IA+BL;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,GAAG;CAUV"}
@@ -170,6 +170,7 @@ export class Context {
170
170
  // HTML partial - just use the layouts + page
171
171
  gen = toGenerator(Page);
172
172
  }
173
+ let result;
173
174
  this.html(new ReadableStream({
174
175
  pull: async (c) => {
175
176
  if (this.req.signal.aborted) {
@@ -177,7 +178,7 @@ export class Context {
177
178
  gen.return();
178
179
  return;
179
180
  }
180
- const result = await gen.next();
181
+ result = await gen.next();
181
182
  if (result.done)
182
183
  c.close();
183
184
  else
@@ -40,12 +40,14 @@ export class Chunk {
40
40
  // tracks the position of the last successful match in the input string
41
41
  let start = 0;
42
42
  let result = "";
43
+ // index of the match
44
+ let i;
45
+ let match;
43
46
  // since `g` flag is used, regex maintains state with each loop,
44
47
  // checking from the lastIndex onward each time
45
48
  while (regex.test(s)) {
46
- // index of the match
47
- const i = regex.lastIndex - 1;
48
- const match = s[i];
49
+ i = regex.lastIndex - 1;
50
+ match = s[i];
49
51
  result +=
50
52
  // everything that didn't match during this test
51
53
  s.slice(start, i) +
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,IAAI,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAIvE,wBAAwB;AACxB,yBAAiB,GAAG,CAAC;IACpB,6BAA6B;IAC7B,UAAiB,iBAAkB,SAAQ,EAAE;KAAG;IAEhD,kBAAkB;IAClB,KAAY,OAAO,GAAG,aAAa,CAClC,YAAY,CACT,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,IAAI,GACJ,SAAS,GACT,MAAM,GACN,QAAQ,CAAC,OAAO,CAAC,GACjB,aAAa,CAAC,OAAO,CAAC,CACxB,CACD,CAAC;CACF;AAED,+BAA+B;AAC/B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AAuBhD;;;;;;;GAOG;AACH,wBAAuB,GAAG,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACjD,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,MAAM,EACzC,KAAK,EAAE,CAAC,wCAwCR;AAED;;;;;GAKG;AACH,wBAAuB,QAAQ,CAAC,KAAK,GAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,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OAAO,CAAA;CAAO,wCAErE;AAED;;;GAGG;AACH,wBAAuB,WAAW,CACjC,OAAO,EAAE,GAAG,CAAC,OAAO,GAClB,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CA8GtC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GAAU,SAAS,GAAG,CAAC,OAAO,oBAOlD,CAAC"}
package/dist/jsx/index.js CHANGED
@@ -37,25 +37,28 @@ export async function* jsx(tag, props) {
37
37
  }
38
38
  // intrinsic element
39
39
  const { children, ...rest } = props;
40
- const attributes = [];
41
- for (let key in rest) {
42
- const value = rest[key]; // needs to come before reassigning keys
40
+ let attributes = "";
41
+ let key;
42
+ let value;
43
+ for (key in rest) {
44
+ value = rest[key]; // needs to come before reassigning keys
43
45
  if (key === "className")
44
46
  key = "class";
45
47
  else if (key === "htmlFor")
46
48
  key = "for";
47
49
  if (value === true) {
48
50
  // just put the key without the value
49
- attributes.push(` ${key}`);
51
+ attributes += ` ${key}`;
50
52
  }
51
- else if (typeof value === "string" ||
52
- typeof value === "number" ||
53
- typeof value === "bigint") {
54
- attributes.push(` ${key}="${Chunk.escape(String(value), true)}"`);
53
+ else if (typeof value === "string") {
54
+ attributes += ` ${key}="${Chunk.escape(value, true)}"`;
55
+ }
56
+ else if (typeof value === "number" || typeof value === "bigint") {
57
+ attributes += ` ${key}="${value}"`;
55
58
  }
56
59
  // otherwise, don't include the attribute
57
60
  }
58
- yield new Chunk(`<${tag}${attributes.join("")}>`, true);
61
+ yield new Chunk(`<${tag}${attributes}>`, true);
59
62
  if (voidElements.has(tag))
60
63
  return;
61
64
  yield* toGenerator(children);
@@ -94,7 +97,8 @@ export async function* toGenerator(element) {
94
97
  if (typeof element === "object") {
95
98
  if (Symbol.asyncIterator in element) {
96
99
  // async iterable - lazily resolve
97
- for await (const children of element)
100
+ let children;
101
+ for await (children of element)
98
102
  yield* toGenerator(children);
99
103
  return;
100
104
  }
@@ -106,10 +110,11 @@ export async function* toGenerator(element) {
106
110
  typeof iterator.return === "function") {
107
111
  // sync generator
108
112
  // process lazily - avoids loading all in memory
109
- const yieldIterations = 50;
113
+ const yieldIterations = 150;
110
114
  let yieldCounter = yieldIterations;
115
+ let result;
111
116
  while (true) {
112
- const result = iterator.next();
117
+ result = iterator.next();
113
118
  if (result.done)
114
119
  break;
115
120
  yield* toGenerator(result.value);
@@ -125,19 +130,21 @@ export async function* toGenerator(element) {
125
130
  // other iterable - array, set, etc.
126
131
  // process children in parallel
127
132
  const generators = [];
133
+ let result;
128
134
  while (true) {
129
- const result = iterator.next();
135
+ result = iterator.next();
130
136
  if (result.done)
131
137
  break;
132
138
  generators.push(toGenerator(result.value));
133
139
  }
134
- const queue = new Array(generators.length).fill(null);
135
- let current = 0;
140
+ const queue = new Array(generators.length);
136
141
  const complete = new Set();
137
- for await (const { index, result: { done, value: chunk }, } of merge(generators)) {
138
- if (done) {
139
- complete.add(index);
140
- if (index === current) {
142
+ let current = 0;
143
+ let m;
144
+ for await (m of merge(generators)) {
145
+ if (m.result.done) {
146
+ complete.add(m.index);
147
+ if (m.index === current) {
141
148
  while (++current < generators.length) {
142
149
  if (queue[current]) {
143
150
  // yield whatever is in the next queue even if it hasn't completed yet
@@ -150,15 +157,15 @@ export async function* toGenerator(element) {
150
157
  }
151
158
  }
152
159
  }
153
- else if (index === current) {
154
- yield chunk; // stream the current value directly
160
+ else if (m.index === current) {
161
+ yield m.result.value; // stream the current value directly
155
162
  }
156
163
  else {
157
164
  // queue the value for later
158
- if (queue[index])
159
- queue[index].concat(chunk);
165
+ if (queue[m.index])
166
+ queue[m.index].concat(m.result.value);
160
167
  else
161
- queue[index] = chunk;
168
+ queue[m.index] = m.result.value;
162
169
  }
163
170
  }
164
171
  // clear the queue
@@ -181,8 +188,9 @@ export async function* toGenerator(element) {
181
188
  * @returns Concatenated HTML
182
189
  */
183
190
  export const toString = async (element) => {
184
- const buffer = [];
185
- for await (const chunk of toGenerator(element))
186
- buffer.push(chunk);
187
- return buffer.join("");
191
+ let buffer = "";
192
+ let chunk;
193
+ for await (chunk of toGenerator(element))
194
+ buffer += chunk.value;
195
+ return buffer;
188
196
  };
@@ -7,5 +7,8 @@
7
7
  * @param generators Resolved in parallel.
8
8
  * @yields `IteratorResult` and `index` of the resolved generator.
9
9
  */
10
- export declare function merge<T>(generators: AsyncGenerator<T, void>[]): AsyncGenerator<any, void, unknown>;
10
+ export declare function merge<T>(generators: AsyncGenerator<T, void>[]): AsyncGenerator<{
11
+ index: number;
12
+ result: IteratorResult<T, void>;
13
+ }, void, unknown>;
11
14
  //# sourceMappingURL=merge-async-generators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge-async-generators.d.ts","sourceRoot":"","sources":["../../src/jsx/merge-async-generators.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,wBAAuB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,sCA6BpE"}
1
+ {"version":3,"file":"merge-async-generators.d.ts","sourceRoot":"","sources":["../../src/jsx/merge-async-generators.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,wBAAuB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE;;;kBA6BpE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ovr",
3
3
  "description": "Progressive HTML Rendering",
4
- "version": "4.1.0",
4
+ "version": "4.1.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -233,6 +233,8 @@ export class Context<P extends Params = Params> {
233
233
  gen = toGenerator(Page);
234
234
  }
235
235
 
236
+ let result: IteratorResult<Chunk>;
237
+
236
238
  this.html(
237
239
  new ReadableStream<string>({
238
240
  pull: async (c) => {
@@ -242,7 +244,7 @@ export class Context<P extends Params = Params> {
242
244
  return;
243
245
  }
244
246
 
245
- const result = await gen.next();
247
+ result = await gen.next();
246
248
  if (result.done) c.close();
247
249
  else c.enqueue(result.value.value);
248
250
  },
@@ -46,20 +46,20 @@ export class Chunk {
46
46
  // tracks the position of the last successful match in the input string
47
47
  let start = 0;
48
48
  let result = "";
49
+ // index of the match
50
+ let i: number;
51
+ let match: string | undefined;
49
52
 
50
53
  // since `g` flag is used, regex maintains state with each loop,
51
54
  // checking from the lastIndex onward each time
52
55
  while (regex.test(s)) {
53
- // index of the match
54
- const i = regex.lastIndex - 1;
55
- const match = s[i];
56
-
56
+ i = regex.lastIndex - 1;
57
+ match = s[i];
57
58
  result +=
58
59
  // everything that didn't match during this test
59
60
  s.slice(start, i) +
60
61
  // replacement
61
62
  (match === "&" ? "&amp;" : match === '"' ? "&quot;" : "&lt;");
62
-
63
63
  start = regex.lastIndex;
64
64
  }
65
65
 
package/src/jsx/index.ts CHANGED
@@ -72,28 +72,28 @@ export async function* jsx<P extends Props = Props>(
72
72
  // intrinsic element
73
73
  const { children, ...rest } = props;
74
74
 
75
- const attributes: string[] = [];
75
+ let attributes = "";
76
+ let key: string;
77
+ let value: JSX.Element;
76
78
 
77
- for (let key in rest) {
78
- const value = rest[key]; // needs to come before reassigning keys
79
+ for (key in rest) {
80
+ value = rest[key]; // needs to come before reassigning keys
79
81
 
80
82
  if (key === "className") key = "class";
81
83
  else if (key === "htmlFor") key = "for";
82
84
 
83
85
  if (value === true) {
84
86
  // just put the key without the value
85
- attributes.push(` ${key}`);
86
- } else if (
87
- typeof value === "string" ||
88
- typeof value === "number" ||
89
- typeof value === "bigint"
90
- ) {
91
- attributes.push(` ${key}="${Chunk.escape(String(value), true)}"`);
87
+ attributes += ` ${key}`;
88
+ } else if (typeof value === "string") {
89
+ attributes += ` ${key}="${Chunk.escape(value, true)}"`;
90
+ } else if (typeof value === "number" || typeof value === "bigint") {
91
+ attributes += ` ${key}="${value}"`;
92
92
  }
93
93
  // otherwise, don't include the attribute
94
94
  }
95
95
 
96
- yield new Chunk(`<${tag}${attributes.join("")}>`, true);
96
+ yield new Chunk(`<${tag}${attributes}>`, true);
97
97
 
98
98
  if (voidElements.has(tag)) return;
99
99
 
@@ -139,7 +139,9 @@ export async function* toGenerator(
139
139
  if (typeof element === "object") {
140
140
  if (Symbol.asyncIterator in element) {
141
141
  // async iterable - lazily resolve
142
- for await (const children of element) yield* toGenerator(children);
142
+ let children: JSX.Element;
143
+
144
+ for await (children of element) yield* toGenerator(children);
143
145
 
144
146
  return;
145
147
  }
@@ -155,11 +157,12 @@ export async function* toGenerator(
155
157
  ) {
156
158
  // sync generator
157
159
  // process lazily - avoids loading all in memory
158
- const yieldIterations = 50;
160
+ const yieldIterations = 150;
159
161
  let yieldCounter = yieldIterations;
162
+ let result: IteratorResult<JSX.Element>;
160
163
 
161
164
  while (true) {
162
- const result = iterator.next();
165
+ result = iterator.next();
163
166
 
164
167
  if (result.done) break;
165
168
  yield* toGenerator(result.value);
@@ -178,26 +181,24 @@ export async function* toGenerator(
178
181
  // other iterable - array, set, etc.
179
182
  // process children in parallel
180
183
  const generators: AsyncGenerator<Chunk, void, unknown>[] = [];
184
+ let result: IteratorResult<JSX.Element>;
181
185
 
182
186
  while (true) {
183
- const result = iterator.next();
187
+ result = iterator.next();
184
188
  if (result.done) break;
185
189
  generators.push(toGenerator(result.value));
186
190
  }
187
191
 
188
- const queue: (Chunk | null)[] = new Array(generators.length).fill(null);
189
-
190
- let current = 0;
192
+ const queue: (Chunk | null)[] = new Array(generators.length);
191
193
  const complete = new Set<number>();
194
+ let current = 0;
195
+ let m: { index: number; result: IteratorResult<Chunk, void> };
192
196
 
193
- for await (const {
194
- index,
195
- result: { done, value: chunk },
196
- } of merge(generators)) {
197
- if (done) {
198
- complete.add(index);
197
+ for await (m of merge(generators)) {
198
+ if (m.result.done) {
199
+ complete.add(m.index);
199
200
 
200
- if (index === current) {
201
+ if (m.index === current) {
201
202
  while (++current < generators.length) {
202
203
  if (queue[current]) {
203
204
  // yield whatever is in the next queue even if it hasn't completed yet
@@ -209,12 +210,12 @@ export async function* toGenerator(
209
210
  if (!complete.has(current)) break;
210
211
  }
211
212
  }
212
- } else if (index === current) {
213
- yield chunk; // stream the current value directly
213
+ } else if (m.index === current) {
214
+ yield m.result.value; // stream the current value directly
214
215
  } else {
215
216
  // queue the value for later
216
- if (queue[index]) queue[index].concat(chunk);
217
- else queue[index] = chunk;
217
+ if (queue[m.index]) queue[m.index]!.concat(m.result.value);
218
+ else queue[m.index] = m.result.value;
218
219
  }
219
220
  }
220
221
 
@@ -241,7 +242,10 @@ export async function* toGenerator(
241
242
  * @returns Concatenated HTML
242
243
  */
243
244
  export const toString = async (element: JSX.Element) => {
244
- const buffer: Chunk[] = [];
245
- for await (const chunk of toGenerator(element)) buffer.push(chunk);
246
- return buffer.join("");
245
+ let buffer = "";
246
+ let chunk: Chunk;
247
+
248
+ for await (chunk of toGenerator(element)) buffer += chunk.value;
249
+
250
+ return buffer;
247
251
  };
@@ -14,7 +14,7 @@ const next = async <T, R>(iterator: AsyncIterator<T, R>, index: number) => ({
14
14
  */
15
15
  export async function* merge<T>(generators: AsyncGenerator<T, void>[]) {
16
16
  const iterators = generators.map((gen) => gen[Symbol.asyncIterator]());
17
- const promises = new Map<number, Promise<any>>();
17
+ const promises = new Map<number, ReturnType<typeof next<T, void>>>();
18
18
 
19
19
  iterators.forEach((iterator, index) =>
20
20
  promises.set(index, next(iterator, index)),