streetui 1.3.0 → 1.5.0

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,6 +1,6 @@
1
- import { S as StreetApp } from './compile-CTA4MLX6.cjs';
2
- export { V as VERSION } from './compile-CTA4MLX6.cjs';
3
- import { R as RenderHandle, H as HydrationDiagnostic } from './hydration-diagnostics-Cu2ZRxL1.cjs';
1
+ import { S as StreetApp } from './compile-DGHUC0T6.cjs';
2
+ export { V as VERSION } from './compile-DGHUC0T6.cjs';
3
+ import { R as RenderHandle, H as HydrationDiagnostic } from './hydration-diagnostics-D9odszLZ.cjs';
4
4
  export * from 'streetui/diagnostics';
5
5
 
6
6
  /**
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as StreetApp } from './compile-CTA4MLX6.js';
2
- export { V as VERSION } from './compile-CTA4MLX6.js';
3
- import { R as RenderHandle, H as HydrationDiagnostic } from './hydration-diagnostics-DqkNk4EU.js';
1
+ import { S as StreetApp } from './compile-DGHUC0T6.js';
2
+ export { V as VERSION } from './compile-DGHUC0T6.js';
3
+ import { R as RenderHandle, H as HydrationDiagnostic } from './hydration-diagnostics-Cv0Bi9Aj.js';
4
4
  export * from 'streetui/diagnostics';
5
5
 
6
6
  /**
package/dist/testing.js CHANGED
@@ -275,7 +275,6 @@ var BrowserDOMAdapter = class {
275
275
  return Array.from(node.childNodes);
276
276
  }
277
277
  };
278
- var browserDOMAdapter = new BrowserDOMAdapter();
279
278
 
280
279
  // ../dom/src/server-node.ts
281
280
  var ServerStyle = class {
@@ -316,13 +315,30 @@ var ServerElement = class {
316
315
  parent = null;
317
316
  tagName;
318
317
  attributes = /* @__PURE__ */ new Map();
319
- /** JS properties set via `setProperty` (e.g. input `value`, `checked`). */
320
- properties = /* @__PURE__ */ new Map();
321
318
  children = [];
322
- style = new ServerStyle();
319
+ // Lazily-allocated stores. On the 10k-row SSR corpus ~0% of elements carry JS
320
+ // properties or inline styles (measured, §5: 1 of 80,029 elements uses
321
+ // `properties`, 0 use `style`), so eagerly allocating a `properties` Map plus
322
+ // a `ServerStyle` (which itself holds a Map) per element wasted ~240k
323
+ // allocations per /users render — all in the dominant mount phase. These are
324
+ // created on first WRITE via the `properties`/`style` getters; the serializer
325
+ // reads the raw `_properties`/`_style` fields so a READ never forces an
326
+ // allocation. Output is byte-identical: an unset store previously serialized
327
+ // to nothing (empty `properties.has(...)` / `style.isEmpty`), and a null store
328
+ // is skipped the same way.
329
+ _properties = null;
330
+ _style = null;
323
331
  constructor(tagName) {
324
332
  this.tagName = tagName.toLowerCase();
325
333
  }
334
+ /** JS properties set via `setProperty` (e.g. input `value`, `checked`). Allocated on first access. */
335
+ get properties() {
336
+ return this._properties ??= /* @__PURE__ */ new Map();
337
+ }
338
+ /** Inline-style holder mirroring `element.style`. Allocated on first access. */
339
+ get style() {
340
+ return this._style ??= new ServerStyle();
341
+ }
326
342
  };
327
343
  var VOID_ELEMENTS = /* @__PURE__ */ new Set([
328
344
  "area",
@@ -345,11 +361,66 @@ var SERIALIZED_PROPERTIES = {
345
361
  checked: "boolean",
346
362
  selected: "boolean"
347
363
  };
364
+ var SERIALIZED_PROPERTY_ENTRIES = Object.entries(SERIALIZED_PROPERTIES);
365
+ var TEXT_SPECIAL = /[&<>]/;
366
+ var ATTR_SPECIAL = /[&<>"]/;
348
367
  function escapeHtmlText(value) {
349
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
368
+ if (!TEXT_SPECIAL.test(value)) return value;
369
+ let out = "";
370
+ let last = 0;
371
+ for (let i = 0; i < value.length; i++) {
372
+ let esc;
373
+ switch (value.charCodeAt(i)) {
374
+ case 38:
375
+ esc = "&amp;";
376
+ break;
377
+ // &
378
+ case 60:
379
+ esc = "&lt;";
380
+ break;
381
+ // <
382
+ case 62:
383
+ esc = "&gt;";
384
+ break;
385
+ // >
386
+ default:
387
+ continue;
388
+ }
389
+ out += value.slice(last, i) + esc;
390
+ last = i + 1;
391
+ }
392
+ return out + value.slice(last);
350
393
  }
351
394
  function escapeHtmlAttr(value) {
352
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
395
+ if (!ATTR_SPECIAL.test(value)) return value;
396
+ let out = "";
397
+ let last = 0;
398
+ for (let i = 0; i < value.length; i++) {
399
+ let esc;
400
+ switch (value.charCodeAt(i)) {
401
+ case 38:
402
+ esc = "&amp;";
403
+ break;
404
+ // &
405
+ case 60:
406
+ esc = "&lt;";
407
+ break;
408
+ // <
409
+ case 62:
410
+ esc = "&gt;";
411
+ break;
412
+ // >
413
+ case 34:
414
+ esc = "&quot;";
415
+ break;
416
+ // "
417
+ default:
418
+ continue;
419
+ }
420
+ out += value.slice(last, i) + esc;
421
+ last = i + 1;
422
+ }
423
+ return out + value.slice(last);
353
424
  }
354
425
  function serializeAttributes(el) {
355
426
  const parts = [];
@@ -360,20 +431,24 @@ function serializeAttributes(el) {
360
431
  parts.push(` ${name}="${escapeHtmlAttr(value)}"`);
361
432
  }
362
433
  }
363
- for (const [name, kind] of Object.entries(SERIALIZED_PROPERTIES)) {
364
- if (!el.properties.has(name)) continue;
365
- if (el.attributes.has(name)) continue;
366
- const raw = el.properties.get(name);
367
- if (kind === "boolean") {
368
- if (raw === true) parts.push(` ${name}`);
369
- } else {
370
- if (raw !== void 0 && raw !== null) {
371
- parts.push(` ${name}="${escapeHtmlAttr(String(raw))}"`);
434
+ const props = el._properties;
435
+ if (props !== null) {
436
+ for (const [name, kind] of SERIALIZED_PROPERTY_ENTRIES) {
437
+ if (!props.has(name)) continue;
438
+ if (el.attributes.has(name)) continue;
439
+ const raw = props.get(name);
440
+ if (kind === "boolean") {
441
+ if (raw === true) parts.push(` ${name}`);
442
+ } else {
443
+ if (raw !== void 0 && raw !== null) {
444
+ parts.push(` ${name}="${escapeHtmlAttr(String(raw))}"`);
445
+ }
372
446
  }
373
447
  }
374
448
  }
375
- if (!el.style.isEmpty && !el.attributes.has("style")) {
376
- parts.push(` style="${escapeHtmlAttr(el.style.toCss())}"`);
449
+ const style = el._style;
450
+ if (style !== null && !style.isEmpty && !el.attributes.has("style")) {
451
+ parts.push(` style="${escapeHtmlAttr(style.toCss())}"`);
377
452
  }
378
453
  return parts.join("");
379
454
  }
@@ -574,7 +649,6 @@ var ServerDOMAdapter = class {
574
649
  return serializeServerNode(asServer(node));
575
650
  }
576
651
  };
577
- var serverDOMAdapter = new ServerDOMAdapter();
578
652
 
579
653
  // ../renderer/src/render-context.ts
580
654
  function createRenderContext(dom, graph, container, hydrationDiagnostics) {
@@ -1961,7 +2035,7 @@ function formatInspection(inspection) {
1961
2035
  }
1962
2036
 
1963
2037
  // src/version.ts
1964
- var VERSION = "1.3.0";
2038
+ var VERSION = "1.5.0";
1965
2039
  export {
1966
2040
  VERSION,
1967
2041
  analyzeGraph,