@oddsquad/vite-plugin-lit 0.3.0 → 0.4.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.
- package/CHANGELOG.md +48 -0
- package/README.md +10 -6
- package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js → browser-agent-rpc-BXhoSh1z-CdtPhBL-.js} +2 -2
- package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js.map → browser-agent-rpc-BXhoSh1z-CdtPhBL-.js.map} +1 -1
- package/dist/client/assets/flow-DK8vmxvN.js +745 -0
- package/dist/client/assets/flow-DK8vmxvN.js.map +1 -0
- package/dist/client/assets/{index-CFrVgNfS.js → index-DVe6M4HV.js} +976 -102
- package/dist/client/assets/index-DVe6M4HV.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/lib/devframe/protocol.d.ts.map +1 -1
- package/lib/devframe/protocol.js +1 -0
- package/lib/devframe/protocol.js.map +1 -1
- package/lib/devframe/vite.d.ts.map +1 -1
- package/lib/devframe/vite.js +1 -0
- package/lib/devframe/vite.js.map +1 -1
- package/lib/options.d.ts +131 -0
- package/lib/options.d.ts.map +1 -0
- package/lib/options.js +128 -0
- package/lib/options.js.map +1 -0
- package/lib/plugin.d.ts +6 -148
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +14 -477
- package/lib/plugin.js.map +1 -1
- package/lib/plugins/css-literals.d.ts +15 -0
- package/lib/plugins/css-literals.d.ts.map +1 -0
- package/lib/plugins/css-literals.js +154 -0
- package/lib/plugins/css-literals.js.map +1 -0
- package/lib/plugins/css-queries.d.ts +20 -0
- package/lib/plugins/css-queries.d.ts.map +1 -0
- package/lib/plugins/css-queries.js +139 -0
- package/lib/plugins/css-queries.js.map +1 -0
- package/lib/plugins/open-in-editor.d.ts +16 -0
- package/lib/plugins/open-in-editor.d.ts.map +1 -0
- package/lib/plugins/open-in-editor.js +91 -0
- package/lib/plugins/open-in-editor.js.map +1 -0
- package/lib/plugins/shared.d.ts +13 -0
- package/lib/plugins/shared.d.ts.map +1 -0
- package/lib/plugins/shared.js +23 -0
- package/lib/plugins/shared.js.map +1 -0
- package/lib/plugins/timeline-virtual.d.ts +19 -0
- package/lib/plugins/timeline-virtual.d.ts.map +1 -0
- package/lib/plugins/timeline-virtual.js +53 -0
- package/lib/plugins/timeline-virtual.js.map +1 -0
- package/lib/runtime/css.d.ts.map +1 -1
- package/lib/runtime/css.js +9 -2
- package/lib/runtime/css.js.map +1 -1
- package/lib/runtime/inspector/install.js +61 -11
- package/lib/runtime/inspector/install.js.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.js +19 -6
- package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
- package/lib/runtime/timeline/install.js +10 -5
- package/lib/runtime/timeline/install.js.map +1 -1
- package/lib/runtime/timeline/public-api.d.ts +2 -2
- package/lib/runtime/timeline/public-api.js +2 -2
- package/lib/runtime/timeline/public-api.js.map +1 -1
- package/lib/runtime/timeline/render.d.ts +15 -6
- package/lib/runtime/timeline/render.d.ts.map +1 -1
- package/lib/runtime/timeline/render.js +150 -11
- package/lib/runtime/timeline/render.js.map +1 -1
- package/package.json +4 -1
- package/types/timeline.d.ts +12 -1
- package/types/timeline.d.ts.map +1 -1
- package/types/timeline.js +2 -0
- package/types/timeline.js.map +1 -1
- package/dist/client/assets/index-CFrVgNfS.js.map +0 -1
- package/lib/timeline-plugin.d.ts +0 -72
- package/lib/timeline-plugin.d.ts.map +0 -1
- package/lib/timeline-plugin.js +0 -359
- package/lib/timeline-plugin.js.map +0 -1
|
@@ -1350,6 +1350,928 @@ var c = e$1(class extends i {
|
|
|
1350
1350
|
}
|
|
1351
1351
|
});
|
|
1352
1352
|
//#endregion
|
|
1353
|
+
//#region node_modules/.pnpm/@lit-labs+virtualizer@2.1.1/node_modules/@lit-labs/virtualizer/events.js
|
|
1354
|
+
/**
|
|
1355
|
+
* @license
|
|
1356
|
+
* Copyright 2021 Google LLC
|
|
1357
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1358
|
+
*/
|
|
1359
|
+
var RangeChangedEvent = class RangeChangedEvent extends Event {
|
|
1360
|
+
constructor(range) {
|
|
1361
|
+
super(RangeChangedEvent.eventName, { bubbles: false });
|
|
1362
|
+
this.first = range.first;
|
|
1363
|
+
this.last = range.last;
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
RangeChangedEvent.eventName = "rangeChanged";
|
|
1367
|
+
var VisibilityChangedEvent = class VisibilityChangedEvent extends Event {
|
|
1368
|
+
constructor(range) {
|
|
1369
|
+
super(VisibilityChangedEvent.eventName, { bubbles: false });
|
|
1370
|
+
this.first = range.first;
|
|
1371
|
+
this.last = range.last;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
VisibilityChangedEvent.eventName = "visibilityChanged";
|
|
1375
|
+
var UnpinnedEvent = class UnpinnedEvent extends Event {
|
|
1376
|
+
constructor() {
|
|
1377
|
+
super(UnpinnedEvent.eventName, { bubbles: false });
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
UnpinnedEvent.eventName = "unpinned";
|
|
1381
|
+
//#endregion
|
|
1382
|
+
//#region node_modules/.pnpm/@lit-labs+virtualizer@2.1.1/node_modules/@lit-labs/virtualizer/ScrollerController.js
|
|
1383
|
+
/**
|
|
1384
|
+
* @license
|
|
1385
|
+
* Copyright 2021 Google LLC
|
|
1386
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1387
|
+
*/
|
|
1388
|
+
var ScrollerShim = class {
|
|
1389
|
+
constructor(element) {
|
|
1390
|
+
this._element = null;
|
|
1391
|
+
const node = element ?? window;
|
|
1392
|
+
this._node = node;
|
|
1393
|
+
if (element) this._element = element;
|
|
1394
|
+
}
|
|
1395
|
+
get element() {
|
|
1396
|
+
return this._element || document.scrollingElement || document.documentElement;
|
|
1397
|
+
}
|
|
1398
|
+
get scrollTop() {
|
|
1399
|
+
return this.element.scrollTop || window.scrollY;
|
|
1400
|
+
}
|
|
1401
|
+
get scrollLeft() {
|
|
1402
|
+
return this.element.scrollLeft || window.scrollX;
|
|
1403
|
+
}
|
|
1404
|
+
get scrollHeight() {
|
|
1405
|
+
return this.element.scrollHeight;
|
|
1406
|
+
}
|
|
1407
|
+
get scrollWidth() {
|
|
1408
|
+
return this.element.scrollWidth;
|
|
1409
|
+
}
|
|
1410
|
+
get viewportHeight() {
|
|
1411
|
+
return this._element ? this._element.getBoundingClientRect().height : window.innerHeight;
|
|
1412
|
+
}
|
|
1413
|
+
get viewportWidth() {
|
|
1414
|
+
return this._element ? this._element.getBoundingClientRect().width : window.innerWidth;
|
|
1415
|
+
}
|
|
1416
|
+
get maxScrollTop() {
|
|
1417
|
+
return this.scrollHeight - this.viewportHeight;
|
|
1418
|
+
}
|
|
1419
|
+
get maxScrollLeft() {
|
|
1420
|
+
return this.scrollWidth - this.viewportWidth;
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
var ScrollerController = class extends ScrollerShim {
|
|
1424
|
+
constructor(client, element) {
|
|
1425
|
+
super(element);
|
|
1426
|
+
this._clients = /* @__PURE__ */ new Set();
|
|
1427
|
+
this._retarget = null;
|
|
1428
|
+
this._end = null;
|
|
1429
|
+
this.__destination = null;
|
|
1430
|
+
this.correctingScrollError = false;
|
|
1431
|
+
this._checkForArrival = this._checkForArrival.bind(this);
|
|
1432
|
+
this._updateManagedScrollTo = this._updateManagedScrollTo.bind(this);
|
|
1433
|
+
this.scrollTo = this.scrollTo.bind(this);
|
|
1434
|
+
this.scrollBy = this.scrollBy.bind(this);
|
|
1435
|
+
const node = this._node;
|
|
1436
|
+
this._originalScrollTo = node.scrollTo;
|
|
1437
|
+
this._originalScrollBy = node.scrollBy;
|
|
1438
|
+
this._originalScroll = node.scroll;
|
|
1439
|
+
this._attach(client);
|
|
1440
|
+
}
|
|
1441
|
+
get _destination() {
|
|
1442
|
+
return this.__destination;
|
|
1443
|
+
}
|
|
1444
|
+
get scrolling() {
|
|
1445
|
+
return this._destination !== null;
|
|
1446
|
+
}
|
|
1447
|
+
scrollTo(p1, p2) {
|
|
1448
|
+
const options = typeof p1 === "number" && typeof p2 === "number" ? {
|
|
1449
|
+
left: p1,
|
|
1450
|
+
top: p2
|
|
1451
|
+
} : p1;
|
|
1452
|
+
this._scrollTo(options);
|
|
1453
|
+
}
|
|
1454
|
+
scrollBy(p1, p2) {
|
|
1455
|
+
const options = typeof p1 === "number" && typeof p2 === "number" ? {
|
|
1456
|
+
left: p1,
|
|
1457
|
+
top: p2
|
|
1458
|
+
} : p1;
|
|
1459
|
+
if (options.top !== void 0) options.top += this.scrollTop;
|
|
1460
|
+
if (options.left !== void 0) options.left += this.scrollLeft;
|
|
1461
|
+
this._scrollTo(options);
|
|
1462
|
+
}
|
|
1463
|
+
_nativeScrollTo(options) {
|
|
1464
|
+
this._originalScrollTo.bind(this._element || window)(options);
|
|
1465
|
+
}
|
|
1466
|
+
_scrollTo(options, retarget = null, end = null) {
|
|
1467
|
+
if (this._end !== null) this._end();
|
|
1468
|
+
if (options.behavior === "smooth") {
|
|
1469
|
+
this._setDestination(options);
|
|
1470
|
+
this._retarget = retarget;
|
|
1471
|
+
this._end = end;
|
|
1472
|
+
} else this._resetScrollState();
|
|
1473
|
+
this._nativeScrollTo(options);
|
|
1474
|
+
}
|
|
1475
|
+
_setDestination(options) {
|
|
1476
|
+
let { top, left } = options;
|
|
1477
|
+
top = top === void 0 ? void 0 : Math.max(0, Math.min(top, this.maxScrollTop));
|
|
1478
|
+
left = left === void 0 ? void 0 : Math.max(0, Math.min(left, this.maxScrollLeft));
|
|
1479
|
+
if (this._destination !== null && left === this._destination.left && top === this._destination.top) return false;
|
|
1480
|
+
this.__destination = {
|
|
1481
|
+
top,
|
|
1482
|
+
left,
|
|
1483
|
+
behavior: "smooth"
|
|
1484
|
+
};
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
_resetScrollState() {
|
|
1488
|
+
this.__destination = null;
|
|
1489
|
+
this._retarget = null;
|
|
1490
|
+
this._end = null;
|
|
1491
|
+
}
|
|
1492
|
+
_updateManagedScrollTo(coordinates) {
|
|
1493
|
+
if (this._destination) {
|
|
1494
|
+
if (this._setDestination(coordinates)) this._nativeScrollTo(this._destination);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
managedScrollTo(options, retarget, end) {
|
|
1498
|
+
this._scrollTo(options, retarget, end);
|
|
1499
|
+
return this._updateManagedScrollTo;
|
|
1500
|
+
}
|
|
1501
|
+
correctScrollError(coordinates) {
|
|
1502
|
+
this.correctingScrollError = true;
|
|
1503
|
+
requestAnimationFrame(() => requestAnimationFrame(() => this.correctingScrollError = false));
|
|
1504
|
+
this._nativeScrollTo(coordinates);
|
|
1505
|
+
if (this._retarget) this._setDestination(this._retarget());
|
|
1506
|
+
if (this._destination) this._nativeScrollTo(this._destination);
|
|
1507
|
+
}
|
|
1508
|
+
_checkForArrival() {
|
|
1509
|
+
if (this._destination !== null) {
|
|
1510
|
+
const { scrollTop, scrollLeft } = this;
|
|
1511
|
+
let { top, left } = this._destination;
|
|
1512
|
+
top = Math.min(top || 0, this.maxScrollTop);
|
|
1513
|
+
left = Math.min(left || 0, this.maxScrollLeft);
|
|
1514
|
+
const topDiff = Math.abs(top - scrollTop);
|
|
1515
|
+
const leftDiff = Math.abs(left - scrollLeft);
|
|
1516
|
+
if (topDiff < 1 && leftDiff < 1) {
|
|
1517
|
+
if (this._end) this._end();
|
|
1518
|
+
this._resetScrollState();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
detach(client) {
|
|
1523
|
+
this._clients.delete(client);
|
|
1524
|
+
/**
|
|
1525
|
+
* If there aren't any more clients, then return the node's default
|
|
1526
|
+
* scrolling methods
|
|
1527
|
+
*/
|
|
1528
|
+
if (this._clients.size === 0) {
|
|
1529
|
+
this._node.scrollTo = this._originalScrollTo;
|
|
1530
|
+
this._node.scrollBy = this._originalScrollBy;
|
|
1531
|
+
this._node.scroll = this._originalScroll;
|
|
1532
|
+
this._node.removeEventListener("scroll", this._checkForArrival);
|
|
1533
|
+
}
|
|
1534
|
+
return null;
|
|
1535
|
+
}
|
|
1536
|
+
_attach(client) {
|
|
1537
|
+
this._clients.add(client);
|
|
1538
|
+
/**
|
|
1539
|
+
* The node should only have the methods shimmed when adding the first
|
|
1540
|
+
* client – otherwise it's redundant
|
|
1541
|
+
*/
|
|
1542
|
+
if (this._clients.size === 1) {
|
|
1543
|
+
this._node.scrollTo = this.scrollTo;
|
|
1544
|
+
this._node.scrollBy = this.scrollBy;
|
|
1545
|
+
this._node.scroll = this.scrollTo;
|
|
1546
|
+
this._node.addEventListener("scroll", this._checkForArrival);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region \0vite/preload-helper.js
|
|
1552
|
+
var scriptRel = "modulepreload";
|
|
1553
|
+
var assetsURL = function(dep, importerUrl) {
|
|
1554
|
+
return new URL(dep, importerUrl).href;
|
|
1555
|
+
};
|
|
1556
|
+
var seen = {};
|
|
1557
|
+
var __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
1558
|
+
let promise = Promise.resolve();
|
|
1559
|
+
if (deps && deps.length > 0) {
|
|
1560
|
+
const links = document.getElementsByTagName("link");
|
|
1561
|
+
const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
|
|
1562
|
+
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
|
|
1563
|
+
function allSettled(promises) {
|
|
1564
|
+
return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
|
|
1565
|
+
status: "fulfilled",
|
|
1566
|
+
value
|
|
1567
|
+
}), (reason) => ({
|
|
1568
|
+
status: "rejected",
|
|
1569
|
+
reason
|
|
1570
|
+
}))));
|
|
1571
|
+
}
|
|
1572
|
+
function importMetaResolve(specifier) {
|
|
1573
|
+
if (import.meta.resolve) return import.meta.resolve(specifier);
|
|
1574
|
+
return new URL(
|
|
1575
|
+
specifier,
|
|
1576
|
+
/** #__KEEP__ */
|
|
1577
|
+
import.meta.url
|
|
1578
|
+
).href;
|
|
1579
|
+
}
|
|
1580
|
+
promise = allSettled(deps.map((dep) => {
|
|
1581
|
+
dep = assetsURL(dep, importerUrl);
|
|
1582
|
+
dep = importMetaResolve(dep);
|
|
1583
|
+
if (dep in seen) return;
|
|
1584
|
+
seen[dep] = true;
|
|
1585
|
+
const isCss = dep.endsWith(".css");
|
|
1586
|
+
for (let i = links.length - 1; i >= 0; i--) {
|
|
1587
|
+
const link = links[i];
|
|
1588
|
+
if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
|
|
1589
|
+
}
|
|
1590
|
+
const link = document.createElement("link");
|
|
1591
|
+
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
1592
|
+
if (!isCss) link.as = "script";
|
|
1593
|
+
link.crossOrigin = "";
|
|
1594
|
+
link.href = dep;
|
|
1595
|
+
if (cspNonce) link.setAttribute("nonce", cspNonce);
|
|
1596
|
+
document.head.appendChild(link);
|
|
1597
|
+
if (isCss) return new Promise((res, rej) => {
|
|
1598
|
+
link.addEventListener("load", res);
|
|
1599
|
+
link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
|
|
1600
|
+
});
|
|
1601
|
+
}).filter((p) => p !== void 0));
|
|
1602
|
+
}
|
|
1603
|
+
function handlePreloadError(err) {
|
|
1604
|
+
const e = new Event("vite:preloadError", { cancelable: true });
|
|
1605
|
+
e.payload = err;
|
|
1606
|
+
window.dispatchEvent(e);
|
|
1607
|
+
if (!e.defaultPrevented) throw err;
|
|
1608
|
+
}
|
|
1609
|
+
return promise.then((res) => {
|
|
1610
|
+
for (const item of res || []) {
|
|
1611
|
+
if (item.status !== "rejected") continue;
|
|
1612
|
+
handlePreloadError(item.reason);
|
|
1613
|
+
}
|
|
1614
|
+
return baseModule().catch(handlePreloadError);
|
|
1615
|
+
});
|
|
1616
|
+
};
|
|
1617
|
+
//#endregion
|
|
1618
|
+
//#region node_modules/.pnpm/@lit-labs+virtualizer@2.1.1/node_modules/@lit-labs/virtualizer/Virtualizer.js
|
|
1619
|
+
/**
|
|
1620
|
+
* @license
|
|
1621
|
+
* Copyright 2021 Google LLC
|
|
1622
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1623
|
+
*/
|
|
1624
|
+
var _ResizeObserver = typeof window !== "undefined" ? window.ResizeObserver : void 0;
|
|
1625
|
+
var virtualizerRef = Symbol("virtualizerRef");
|
|
1626
|
+
var SIZER_ATTRIBUTE = "virtualizer-sizer";
|
|
1627
|
+
var DefaultLayoutConstructor;
|
|
1628
|
+
/**
|
|
1629
|
+
* Provides virtual scrolling boilerplate.
|
|
1630
|
+
*
|
|
1631
|
+
* Extensions of this class must set hostElement and layout.
|
|
1632
|
+
*
|
|
1633
|
+
* Extensions of this class must also override VirtualRepeater's DOM
|
|
1634
|
+
* manipulation methods.
|
|
1635
|
+
*/
|
|
1636
|
+
var Virtualizer = class {
|
|
1637
|
+
constructor(config) {
|
|
1638
|
+
this._benchmarkStart = null;
|
|
1639
|
+
this._layout = null;
|
|
1640
|
+
this._clippingAncestors = [];
|
|
1641
|
+
/**
|
|
1642
|
+
* Layout provides these values, we set them on _render().
|
|
1643
|
+
* TODO @straversi: Can we find an XOR type, usable for the key here?
|
|
1644
|
+
*/
|
|
1645
|
+
this._scrollSize = null;
|
|
1646
|
+
/**
|
|
1647
|
+
* Difference between scroll target's current and required scroll offsets.
|
|
1648
|
+
* Provided by layout.
|
|
1649
|
+
*/
|
|
1650
|
+
this._scrollError = null;
|
|
1651
|
+
/**
|
|
1652
|
+
* A list of the positions (top, left) of the children in the current range.
|
|
1653
|
+
*/
|
|
1654
|
+
this._childrenPos = null;
|
|
1655
|
+
this._childMeasurements = null;
|
|
1656
|
+
this._toBeMeasured = /* @__PURE__ */ new Map();
|
|
1657
|
+
this._rangeChanged = true;
|
|
1658
|
+
this._itemsChanged = true;
|
|
1659
|
+
this._visibilityChanged = true;
|
|
1660
|
+
this._scrollerController = null;
|
|
1661
|
+
this._isScroller = false;
|
|
1662
|
+
this._sizer = null;
|
|
1663
|
+
/**
|
|
1664
|
+
* Resize observer attached to hostElement.
|
|
1665
|
+
*/
|
|
1666
|
+
this._hostElementRO = null;
|
|
1667
|
+
/**
|
|
1668
|
+
* Resize observer attached to children.
|
|
1669
|
+
*/
|
|
1670
|
+
this._childrenRO = null;
|
|
1671
|
+
this._mutationObserver = null;
|
|
1672
|
+
this._scrollEventListeners = [];
|
|
1673
|
+
this._scrollEventListenerOptions = { passive: true };
|
|
1674
|
+
this._loadListener = this._childLoaded.bind(this);
|
|
1675
|
+
/**
|
|
1676
|
+
* Index of element to scroll into view, plus scroll
|
|
1677
|
+
* behavior options, as imperatively specified via
|
|
1678
|
+
* `element(index).scrollIntoView()`
|
|
1679
|
+
*/
|
|
1680
|
+
this._scrollIntoViewTarget = null;
|
|
1681
|
+
this._updateScrollIntoViewCoordinates = null;
|
|
1682
|
+
/**
|
|
1683
|
+
* Items to render. Set by items.
|
|
1684
|
+
*/
|
|
1685
|
+
this._items = [];
|
|
1686
|
+
/**
|
|
1687
|
+
* Index of the first child in the range, not necessarily the first visible child.
|
|
1688
|
+
* TODO @straversi: Consider renaming these.
|
|
1689
|
+
*/
|
|
1690
|
+
this._first = -1;
|
|
1691
|
+
/**
|
|
1692
|
+
* Index of the last child in the range.
|
|
1693
|
+
*/
|
|
1694
|
+
this._last = -1;
|
|
1695
|
+
/**
|
|
1696
|
+
* Index of the first item intersecting the viewport.
|
|
1697
|
+
*/
|
|
1698
|
+
this._firstVisible = -1;
|
|
1699
|
+
/**
|
|
1700
|
+
* Index of the last item intersecting the viewport.
|
|
1701
|
+
*/
|
|
1702
|
+
this._lastVisible = -1;
|
|
1703
|
+
this._scheduled = /* @__PURE__ */ new WeakSet();
|
|
1704
|
+
/**
|
|
1705
|
+
* Invoked at the end of each render cycle: children in the range are
|
|
1706
|
+
* measured, and their dimensions passed to this callback. Use it to layout
|
|
1707
|
+
* children as needed.
|
|
1708
|
+
*/
|
|
1709
|
+
this._measureCallback = null;
|
|
1710
|
+
this._measureChildOverride = null;
|
|
1711
|
+
/**
|
|
1712
|
+
* State for `layoutComplete` promise
|
|
1713
|
+
*/
|
|
1714
|
+
this._layoutCompletePromise = null;
|
|
1715
|
+
this._layoutCompleteResolver = null;
|
|
1716
|
+
this._layoutCompleteRejecter = null;
|
|
1717
|
+
this._pendingLayoutComplete = null;
|
|
1718
|
+
/**
|
|
1719
|
+
* Layout initialization is async because we dynamically load
|
|
1720
|
+
* the default layout if none is specified. This state is to track
|
|
1721
|
+
* whether init is complete.
|
|
1722
|
+
*/
|
|
1723
|
+
this._layoutInitialized = null;
|
|
1724
|
+
/**
|
|
1725
|
+
* Track connection state to guard against errors / unnecessary work
|
|
1726
|
+
*/
|
|
1727
|
+
this._connected = false;
|
|
1728
|
+
if (!config) throw new Error("Virtualizer constructor requires a configuration object");
|
|
1729
|
+
if (config.hostElement) this._init(config);
|
|
1730
|
+
else throw new Error("Virtualizer configuration requires the \"hostElement\" property");
|
|
1731
|
+
}
|
|
1732
|
+
set items(items) {
|
|
1733
|
+
if (Array.isArray(items) && items !== this._items) {
|
|
1734
|
+
this._itemsChanged = true;
|
|
1735
|
+
this._items = items;
|
|
1736
|
+
this._schedule(this._updateLayout);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
_init(config) {
|
|
1740
|
+
this._isScroller = !!config.scroller;
|
|
1741
|
+
this._initHostElement(config);
|
|
1742
|
+
const layoutConfig = config.layout || {};
|
|
1743
|
+
this._layoutInitialized = this._initLayout(layoutConfig);
|
|
1744
|
+
}
|
|
1745
|
+
_initObservers() {
|
|
1746
|
+
this._mutationObserver = new MutationObserver(this._finishDOMUpdate.bind(this));
|
|
1747
|
+
this._hostElementRO = new _ResizeObserver(() => this._hostElementSizeChanged());
|
|
1748
|
+
this._childrenRO = new _ResizeObserver(this._childrenSizeChanged.bind(this));
|
|
1749
|
+
}
|
|
1750
|
+
_initHostElement(config) {
|
|
1751
|
+
const hostElement = this._hostElement = config.hostElement;
|
|
1752
|
+
this._applyVirtualizerStyles();
|
|
1753
|
+
hostElement[virtualizerRef] = this;
|
|
1754
|
+
}
|
|
1755
|
+
connected() {
|
|
1756
|
+
this._initObservers();
|
|
1757
|
+
const includeSelf = this._isScroller;
|
|
1758
|
+
this._clippingAncestors = getClippingAncestors(this._hostElement, includeSelf);
|
|
1759
|
+
this._scrollerController = new ScrollerController(this, this._clippingAncestors[0]);
|
|
1760
|
+
this._schedule(this._updateLayout);
|
|
1761
|
+
this._observeAndListen();
|
|
1762
|
+
this._connected = true;
|
|
1763
|
+
}
|
|
1764
|
+
_observeAndListen() {
|
|
1765
|
+
this._mutationObserver.observe(this._hostElement, { childList: true });
|
|
1766
|
+
this._hostElementRO.observe(this._hostElement);
|
|
1767
|
+
this._scrollEventListeners.push(window);
|
|
1768
|
+
window.addEventListener("scroll", this, this._scrollEventListenerOptions);
|
|
1769
|
+
this._clippingAncestors.forEach((ancestor) => {
|
|
1770
|
+
ancestor.addEventListener("scroll", this, this._scrollEventListenerOptions);
|
|
1771
|
+
this._scrollEventListeners.push(ancestor);
|
|
1772
|
+
this._hostElementRO.observe(ancestor);
|
|
1773
|
+
});
|
|
1774
|
+
this._hostElementRO.observe(this._scrollerController.element);
|
|
1775
|
+
this._children.forEach((child) => this._childrenRO.observe(child));
|
|
1776
|
+
this._scrollEventListeners.forEach((target) => target.addEventListener("scroll", this, this._scrollEventListenerOptions));
|
|
1777
|
+
}
|
|
1778
|
+
disconnected() {
|
|
1779
|
+
this._scrollEventListeners.forEach((target) => target.removeEventListener("scroll", this, this._scrollEventListenerOptions));
|
|
1780
|
+
this._scrollEventListeners = [];
|
|
1781
|
+
this._clippingAncestors = [];
|
|
1782
|
+
this._scrollerController?.detach(this);
|
|
1783
|
+
this._scrollerController = null;
|
|
1784
|
+
this._mutationObserver?.disconnect();
|
|
1785
|
+
this._mutationObserver = null;
|
|
1786
|
+
this._hostElementRO?.disconnect();
|
|
1787
|
+
this._hostElementRO = null;
|
|
1788
|
+
this._childrenRO?.disconnect();
|
|
1789
|
+
this._childrenRO = null;
|
|
1790
|
+
this._rejectLayoutCompletePromise("disconnected");
|
|
1791
|
+
this._connected = false;
|
|
1792
|
+
}
|
|
1793
|
+
_applyVirtualizerStyles() {
|
|
1794
|
+
const style = this._hostElement.style;
|
|
1795
|
+
style.display = style.display || "block";
|
|
1796
|
+
style.position = style.position || "relative";
|
|
1797
|
+
style.contain = style.contain || "size layout";
|
|
1798
|
+
if (this._isScroller) {
|
|
1799
|
+
style.overflow = style.overflow || "auto";
|
|
1800
|
+
style.minHeight = style.minHeight || "150px";
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
_getSizer() {
|
|
1804
|
+
const hostElement = this._hostElement;
|
|
1805
|
+
if (!this._sizer) {
|
|
1806
|
+
let sizer = hostElement.querySelector(`[${SIZER_ATTRIBUTE}]`);
|
|
1807
|
+
if (!sizer) {
|
|
1808
|
+
sizer = document.createElement("div");
|
|
1809
|
+
sizer.setAttribute(SIZER_ATTRIBUTE, "");
|
|
1810
|
+
hostElement.appendChild(sizer);
|
|
1811
|
+
}
|
|
1812
|
+
Object.assign(sizer.style, {
|
|
1813
|
+
position: "absolute",
|
|
1814
|
+
margin: "-2px 0 0 0",
|
|
1815
|
+
padding: 0,
|
|
1816
|
+
visibility: "hidden",
|
|
1817
|
+
fontSize: "2px"
|
|
1818
|
+
});
|
|
1819
|
+
sizer.textContent = " ";
|
|
1820
|
+
sizer.setAttribute(SIZER_ATTRIBUTE, "");
|
|
1821
|
+
this._sizer = sizer;
|
|
1822
|
+
}
|
|
1823
|
+
return this._sizer;
|
|
1824
|
+
}
|
|
1825
|
+
async updateLayoutConfig(layoutConfig) {
|
|
1826
|
+
await this._layoutInitialized;
|
|
1827
|
+
const Ctor = layoutConfig.type || DefaultLayoutConstructor;
|
|
1828
|
+
if (typeof Ctor === "function" && this._layout instanceof Ctor) {
|
|
1829
|
+
const config = { ...layoutConfig };
|
|
1830
|
+
delete config.type;
|
|
1831
|
+
this._layout.config = config;
|
|
1832
|
+
return true;
|
|
1833
|
+
}
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1836
|
+
async _initLayout(layoutConfig) {
|
|
1837
|
+
let config;
|
|
1838
|
+
let Ctor;
|
|
1839
|
+
if (typeof layoutConfig.type === "function") {
|
|
1840
|
+
Ctor = layoutConfig.type;
|
|
1841
|
+
const copy = { ...layoutConfig };
|
|
1842
|
+
delete copy.type;
|
|
1843
|
+
config = copy;
|
|
1844
|
+
} else config = layoutConfig;
|
|
1845
|
+
if (Ctor === void 0) DefaultLayoutConstructor = Ctor = (await __vitePreload(async () => {
|
|
1846
|
+
const { FlowLayout } = await import("./flow-DK8vmxvN.js");
|
|
1847
|
+
return { FlowLayout };
|
|
1848
|
+
}, [], import.meta.url)).FlowLayout;
|
|
1849
|
+
this._layout = new Ctor((message) => this._handleLayoutMessage(message), config);
|
|
1850
|
+
if (this._layout.measureChildren && typeof this._layout.updateItemSizes === "function") {
|
|
1851
|
+
if (typeof this._layout.measureChildren === "function") this._measureChildOverride = this._layout.measureChildren;
|
|
1852
|
+
this._measureCallback = this._layout.updateItemSizes.bind(this._layout);
|
|
1853
|
+
}
|
|
1854
|
+
if (this._layout.listenForChildLoadEvents) this._hostElement.addEventListener("load", this._loadListener, true);
|
|
1855
|
+
this._schedule(this._updateLayout);
|
|
1856
|
+
}
|
|
1857
|
+
startBenchmarking() {
|
|
1858
|
+
if (this._benchmarkStart === null) this._benchmarkStart = window.performance.now();
|
|
1859
|
+
}
|
|
1860
|
+
stopBenchmarking() {
|
|
1861
|
+
if (this._benchmarkStart !== null) {
|
|
1862
|
+
const now = window.performance.now();
|
|
1863
|
+
const timeElapsed = now - this._benchmarkStart;
|
|
1864
|
+
const virtualizationTime = performance.getEntriesByName("uv-virtualizing", "measure").filter((e) => e.startTime >= this._benchmarkStart && e.startTime < now).reduce((t, m) => t + m.duration, 0);
|
|
1865
|
+
this._benchmarkStart = null;
|
|
1866
|
+
return {
|
|
1867
|
+
timeElapsed,
|
|
1868
|
+
virtualizationTime
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
_measureChildren() {
|
|
1874
|
+
const mm = {};
|
|
1875
|
+
const children = this._children;
|
|
1876
|
+
const fn = this._measureChildOverride || this._measureChild;
|
|
1877
|
+
for (let i = 0; i < children.length; i++) {
|
|
1878
|
+
const child = children[i];
|
|
1879
|
+
const idx = this._first + i;
|
|
1880
|
+
if (this._itemsChanged || this._toBeMeasured.has(child)) mm[idx] = fn.call(this, child, this._items[idx]);
|
|
1881
|
+
}
|
|
1882
|
+
this._childMeasurements = mm;
|
|
1883
|
+
this._schedule(this._updateLayout);
|
|
1884
|
+
this._toBeMeasured.clear();
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Returns the width, height, and margins of the given child.
|
|
1888
|
+
*/
|
|
1889
|
+
_measureChild(element) {
|
|
1890
|
+
const { width, height } = element.getBoundingClientRect();
|
|
1891
|
+
return Object.assign({
|
|
1892
|
+
width,
|
|
1893
|
+
height
|
|
1894
|
+
}, getMargins(element));
|
|
1895
|
+
}
|
|
1896
|
+
async _schedule(method) {
|
|
1897
|
+
if (!this._scheduled.has(method)) {
|
|
1898
|
+
this._scheduled.add(method);
|
|
1899
|
+
await Promise.resolve();
|
|
1900
|
+
this._scheduled.delete(method);
|
|
1901
|
+
method.call(this);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
async _updateDOM(state) {
|
|
1905
|
+
this._scrollSize = state.scrollSize;
|
|
1906
|
+
this._adjustRange(state.range);
|
|
1907
|
+
this._childrenPos = state.childPositions;
|
|
1908
|
+
this._scrollError = state.scrollError || null;
|
|
1909
|
+
const { _rangeChanged, _itemsChanged } = this;
|
|
1910
|
+
if (this._visibilityChanged) {
|
|
1911
|
+
this._notifyVisibility();
|
|
1912
|
+
this._visibilityChanged = false;
|
|
1913
|
+
}
|
|
1914
|
+
if (_rangeChanged || _itemsChanged) {
|
|
1915
|
+
this._notifyRange();
|
|
1916
|
+
this._rangeChanged = false;
|
|
1917
|
+
}
|
|
1918
|
+
this._finishDOMUpdate();
|
|
1919
|
+
}
|
|
1920
|
+
_finishDOMUpdate() {
|
|
1921
|
+
if (this._connected) {
|
|
1922
|
+
this._children.forEach((child) => this._childrenRO.observe(child));
|
|
1923
|
+
this._checkScrollIntoViewTarget(this._childrenPos);
|
|
1924
|
+
this._positionChildren(this._childrenPos);
|
|
1925
|
+
this._sizeHostElement(this._scrollSize);
|
|
1926
|
+
this._correctScrollError();
|
|
1927
|
+
if (this._benchmarkStart && "mark" in window.performance) window.performance.mark("uv-end");
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
_updateLayout() {
|
|
1931
|
+
if (this._layout && this._connected) {
|
|
1932
|
+
this._layout.items = this._items;
|
|
1933
|
+
this._updateView();
|
|
1934
|
+
if (this._childMeasurements !== null) {
|
|
1935
|
+
if (this._measureCallback) this._measureCallback(this._childMeasurements);
|
|
1936
|
+
this._childMeasurements = null;
|
|
1937
|
+
}
|
|
1938
|
+
this._layout.reflowIfNeeded();
|
|
1939
|
+
if (this._benchmarkStart && "mark" in window.performance) window.performance.mark("uv-end");
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
_handleScrollEvent() {
|
|
1943
|
+
if (this._benchmarkStart && "mark" in window.performance) {
|
|
1944
|
+
try {
|
|
1945
|
+
window.performance.measure("uv-virtualizing", "uv-start", "uv-end");
|
|
1946
|
+
} catch (e) {
|
|
1947
|
+
console.warn("Error measuring performance data: ", e);
|
|
1948
|
+
}
|
|
1949
|
+
window.performance.mark("uv-start");
|
|
1950
|
+
}
|
|
1951
|
+
if (this._scrollerController.correctingScrollError === false) this._layout?.unpin();
|
|
1952
|
+
this._schedule(this._updateLayout);
|
|
1953
|
+
}
|
|
1954
|
+
handleEvent(event) {
|
|
1955
|
+
switch (event.type) {
|
|
1956
|
+
case "scroll":
|
|
1957
|
+
if (event.currentTarget === window || this._clippingAncestors.includes(event.currentTarget)) this._handleScrollEvent();
|
|
1958
|
+
break;
|
|
1959
|
+
default: console.warn("event not handled", event);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
_handleLayoutMessage(message) {
|
|
1963
|
+
if (message.type === "stateChanged") this._updateDOM(message);
|
|
1964
|
+
else if (message.type === "visibilityChanged") {
|
|
1965
|
+
this._firstVisible = message.firstVisible;
|
|
1966
|
+
this._lastVisible = message.lastVisible;
|
|
1967
|
+
this._notifyVisibility();
|
|
1968
|
+
} else if (message.type === "unpinned") this._hostElement.dispatchEvent(new UnpinnedEvent());
|
|
1969
|
+
}
|
|
1970
|
+
get _children() {
|
|
1971
|
+
const arr = [];
|
|
1972
|
+
let next = this._hostElement.firstElementChild;
|
|
1973
|
+
while (next) {
|
|
1974
|
+
if (!next.hasAttribute(SIZER_ATTRIBUTE)) arr.push(next);
|
|
1975
|
+
next = next.nextElementSibling;
|
|
1976
|
+
}
|
|
1977
|
+
return arr;
|
|
1978
|
+
}
|
|
1979
|
+
_updateView() {
|
|
1980
|
+
const hostElement = this._hostElement;
|
|
1981
|
+
const scrollingElement = this._scrollerController?.element;
|
|
1982
|
+
const layout = this._layout;
|
|
1983
|
+
if (hostElement && scrollingElement && layout) {
|
|
1984
|
+
let top, left, bottom, right;
|
|
1985
|
+
const hostElementBounds = hostElement.getBoundingClientRect();
|
|
1986
|
+
top = 0;
|
|
1987
|
+
left = 0;
|
|
1988
|
+
bottom = window.innerHeight;
|
|
1989
|
+
right = window.innerWidth;
|
|
1990
|
+
const ancestorBounds = this._clippingAncestors.map((ancestor) => ancestor.getBoundingClientRect());
|
|
1991
|
+
ancestorBounds.unshift(hostElementBounds);
|
|
1992
|
+
for (const bounds of ancestorBounds) {
|
|
1993
|
+
top = Math.max(top, bounds.top);
|
|
1994
|
+
left = Math.max(left, bounds.left);
|
|
1995
|
+
bottom = Math.min(bottom, bounds.bottom);
|
|
1996
|
+
right = Math.min(right, bounds.right);
|
|
1997
|
+
}
|
|
1998
|
+
const scrollingElementBounds = scrollingElement.getBoundingClientRect();
|
|
1999
|
+
const offsetWithinScroller = {
|
|
2000
|
+
left: hostElementBounds.left - scrollingElementBounds.left,
|
|
2001
|
+
top: hostElementBounds.top - scrollingElementBounds.top
|
|
2002
|
+
};
|
|
2003
|
+
const totalScrollSize = {
|
|
2004
|
+
width: scrollingElement.scrollWidth,
|
|
2005
|
+
height: scrollingElement.scrollHeight
|
|
2006
|
+
};
|
|
2007
|
+
const scrollTop = top - hostElementBounds.top + hostElement.scrollTop;
|
|
2008
|
+
const scrollLeft = left - hostElementBounds.left + hostElement.scrollLeft;
|
|
2009
|
+
const height = Math.max(0, bottom - top);
|
|
2010
|
+
layout.viewportSize = {
|
|
2011
|
+
width: Math.max(0, right - left),
|
|
2012
|
+
height
|
|
2013
|
+
};
|
|
2014
|
+
layout.viewportScroll = {
|
|
2015
|
+
top: scrollTop,
|
|
2016
|
+
left: scrollLeft
|
|
2017
|
+
};
|
|
2018
|
+
layout.totalScrollSize = totalScrollSize;
|
|
2019
|
+
layout.offsetWithinScroller = offsetWithinScroller;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Styles the host element so that its size reflects the
|
|
2024
|
+
* total size of all items.
|
|
2025
|
+
*/
|
|
2026
|
+
_sizeHostElement(size) {
|
|
2027
|
+
const max = 82e5;
|
|
2028
|
+
const h = size && size.width !== null ? Math.min(max, size.width) : 0;
|
|
2029
|
+
const v = size && size.height !== null ? Math.min(max, size.height) : 0;
|
|
2030
|
+
if (this._isScroller) this._getSizer().style.transform = `translate(${h}px, ${v}px)`;
|
|
2031
|
+
else {
|
|
2032
|
+
const style = this._hostElement.style;
|
|
2033
|
+
style.minWidth = h ? `${h}px` : "100%";
|
|
2034
|
+
style.minHeight = v ? `${v}px` : "100%";
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Sets the top and left transform style of the children from the values in
|
|
2039
|
+
* pos.
|
|
2040
|
+
*/
|
|
2041
|
+
_positionChildren(pos) {
|
|
2042
|
+
if (pos) pos.forEach(({ top, left, width, height, xOffset, yOffset }, index) => {
|
|
2043
|
+
const child = this._children[index - this._first];
|
|
2044
|
+
if (child) {
|
|
2045
|
+
child.style.position = "absolute";
|
|
2046
|
+
child.style.boxSizing = "border-box";
|
|
2047
|
+
child.style.transform = `translate(${left}px, ${top}px)`;
|
|
2048
|
+
if (width !== void 0) child.style.width = width + "px";
|
|
2049
|
+
if (height !== void 0) child.style.height = height + "px";
|
|
2050
|
+
child.style.left = xOffset === void 0 ? null : xOffset + "px";
|
|
2051
|
+
child.style.top = yOffset === void 0 ? null : yOffset + "px";
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
async _adjustRange(range) {
|
|
2056
|
+
const { _first, _last, _firstVisible, _lastVisible } = this;
|
|
2057
|
+
this._first = range.first;
|
|
2058
|
+
this._last = range.last;
|
|
2059
|
+
this._firstVisible = range.firstVisible;
|
|
2060
|
+
this._lastVisible = range.lastVisible;
|
|
2061
|
+
this._rangeChanged = this._rangeChanged || this._first !== _first || this._last !== _last;
|
|
2062
|
+
this._visibilityChanged = this._visibilityChanged || this._firstVisible !== _firstVisible || this._lastVisible !== _lastVisible;
|
|
2063
|
+
}
|
|
2064
|
+
_correctScrollError() {
|
|
2065
|
+
if (this._scrollError) {
|
|
2066
|
+
const { scrollTop, scrollLeft } = this._scrollerController;
|
|
2067
|
+
const { top, left } = this._scrollError;
|
|
2068
|
+
this._scrollError = null;
|
|
2069
|
+
this._scrollerController.correctScrollError({
|
|
2070
|
+
top: scrollTop - top,
|
|
2071
|
+
left: scrollLeft - left
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
element(index) {
|
|
2076
|
+
if (index === Infinity) index = this._items.length - 1;
|
|
2077
|
+
return this._items?.[index] === void 0 ? void 0 : { scrollIntoView: (options = {}) => this._scrollElementIntoView({
|
|
2078
|
+
...options,
|
|
2079
|
+
index
|
|
2080
|
+
}) };
|
|
2081
|
+
}
|
|
2082
|
+
_scrollElementIntoView(options) {
|
|
2083
|
+
if (options.index >= this._first && options.index <= this._last) this._children[options.index - this._first].scrollIntoView(options);
|
|
2084
|
+
else {
|
|
2085
|
+
options.index = Math.min(options.index, this._items.length - 1);
|
|
2086
|
+
if (options.behavior === "smooth") {
|
|
2087
|
+
const coordinates = this._layout.getScrollIntoViewCoordinates(options);
|
|
2088
|
+
const { behavior } = options;
|
|
2089
|
+
this._updateScrollIntoViewCoordinates = this._scrollerController.managedScrollTo(Object.assign(coordinates, { behavior }), () => this._layout.getScrollIntoViewCoordinates(options), () => this._scrollIntoViewTarget = null);
|
|
2090
|
+
this._scrollIntoViewTarget = options;
|
|
2091
|
+
} else this._layout.pin = options;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* If we are smoothly scrolling to an element and the target element
|
|
2096
|
+
* is in the DOM, we update our target coordinates as needed
|
|
2097
|
+
*/
|
|
2098
|
+
_checkScrollIntoViewTarget(pos) {
|
|
2099
|
+
const { index } = this._scrollIntoViewTarget || {};
|
|
2100
|
+
if (index && pos?.has(index)) this._updateScrollIntoViewCoordinates(this._layout.getScrollIntoViewCoordinates(this._scrollIntoViewTarget));
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Emits a rangechange event with the current first, last, firstVisible, and
|
|
2104
|
+
* lastVisible.
|
|
2105
|
+
*/
|
|
2106
|
+
_notifyRange() {
|
|
2107
|
+
this._hostElement.dispatchEvent(new RangeChangedEvent({
|
|
2108
|
+
first: this._first,
|
|
2109
|
+
last: this._last
|
|
2110
|
+
}));
|
|
2111
|
+
}
|
|
2112
|
+
_notifyVisibility() {
|
|
2113
|
+
this._hostElement.dispatchEvent(new VisibilityChangedEvent({
|
|
2114
|
+
first: this._firstVisible,
|
|
2115
|
+
last: this._lastVisible
|
|
2116
|
+
}));
|
|
2117
|
+
}
|
|
2118
|
+
get layoutComplete() {
|
|
2119
|
+
if (!this._layoutCompletePromise) this._layoutCompletePromise = new Promise((resolve, reject) => {
|
|
2120
|
+
this._layoutCompleteResolver = resolve;
|
|
2121
|
+
this._layoutCompleteRejecter = reject;
|
|
2122
|
+
});
|
|
2123
|
+
return this._layoutCompletePromise;
|
|
2124
|
+
}
|
|
2125
|
+
_rejectLayoutCompletePromise(reason) {
|
|
2126
|
+
if (this._layoutCompleteRejecter !== null) this._layoutCompleteRejecter(reason);
|
|
2127
|
+
this._resetLayoutCompleteState();
|
|
2128
|
+
}
|
|
2129
|
+
_scheduleLayoutComplete() {
|
|
2130
|
+
if (this._layoutCompletePromise && this._pendingLayoutComplete === null) this._pendingLayoutComplete = requestAnimationFrame(() => requestAnimationFrame(() => this._resolveLayoutCompletePromise()));
|
|
2131
|
+
}
|
|
2132
|
+
_resolveLayoutCompletePromise() {
|
|
2133
|
+
if (this._layoutCompleteResolver !== null) this._layoutCompleteResolver();
|
|
2134
|
+
this._resetLayoutCompleteState();
|
|
2135
|
+
}
|
|
2136
|
+
_resetLayoutCompleteState() {
|
|
2137
|
+
this._layoutCompletePromise = null;
|
|
2138
|
+
this._layoutCompleteResolver = null;
|
|
2139
|
+
this._layoutCompleteRejecter = null;
|
|
2140
|
+
this._pendingLayoutComplete = null;
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* Render and update the view at the next opportunity with the given
|
|
2144
|
+
* hostElement size.
|
|
2145
|
+
*/
|
|
2146
|
+
_hostElementSizeChanged() {
|
|
2147
|
+
this._schedule(this._updateLayout);
|
|
2148
|
+
}
|
|
2149
|
+
_childLoaded() {}
|
|
2150
|
+
_childrenSizeChanged(changes) {
|
|
2151
|
+
if (this._layout?.measureChildren) {
|
|
2152
|
+
for (const change of changes) this._toBeMeasured.set(change.target, change.contentRect);
|
|
2153
|
+
this._measureChildren();
|
|
2154
|
+
}
|
|
2155
|
+
this._scheduleLayoutComplete();
|
|
2156
|
+
this._itemsChanged = false;
|
|
2157
|
+
this._rangeChanged = false;
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
function getMargins(el) {
|
|
2161
|
+
const style = window.getComputedStyle(el);
|
|
2162
|
+
return {
|
|
2163
|
+
marginTop: getMarginValue(style.marginTop),
|
|
2164
|
+
marginRight: getMarginValue(style.marginRight),
|
|
2165
|
+
marginBottom: getMarginValue(style.marginBottom),
|
|
2166
|
+
marginLeft: getMarginValue(style.marginLeft)
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
function getMarginValue(value) {
|
|
2170
|
+
const float = value ? parseFloat(value) : NaN;
|
|
2171
|
+
return Number.isNaN(float) ? 0 : float;
|
|
2172
|
+
}
|
|
2173
|
+
function getParentElement(el) {
|
|
2174
|
+
if (el.assignedSlot !== null) return el.assignedSlot;
|
|
2175
|
+
if (el.parentElement !== null) return el.parentElement;
|
|
2176
|
+
const parentNode = el.parentNode;
|
|
2177
|
+
if (parentNode && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) return parentNode.host || null;
|
|
2178
|
+
return null;
|
|
2179
|
+
}
|
|
2180
|
+
function getElementAncestors(el, includeSelf = false) {
|
|
2181
|
+
const ancestors = [];
|
|
2182
|
+
let parent = includeSelf ? el : getParentElement(el);
|
|
2183
|
+
while (parent !== null) {
|
|
2184
|
+
ancestors.push(parent);
|
|
2185
|
+
parent = getParentElement(parent);
|
|
2186
|
+
}
|
|
2187
|
+
return ancestors;
|
|
2188
|
+
}
|
|
2189
|
+
function getClippingAncestors(el, includeSelf = false) {
|
|
2190
|
+
let foundFixed = false;
|
|
2191
|
+
return getElementAncestors(el, includeSelf).filter((a) => {
|
|
2192
|
+
if (foundFixed) return false;
|
|
2193
|
+
const style = getComputedStyle(a);
|
|
2194
|
+
foundFixed = style.position === "fixed";
|
|
2195
|
+
return style.overflow !== "visible";
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
//#endregion
|
|
2199
|
+
//#region node_modules/.pnpm/@lit-labs+virtualizer@2.1.1/node_modules/@lit-labs/virtualizer/virtualize.js
|
|
2200
|
+
/**
|
|
2201
|
+
* @license
|
|
2202
|
+
* Copyright 2021 Google LLC
|
|
2203
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2204
|
+
*/
|
|
2205
|
+
var defaultKeyFunction = (item) => item;
|
|
2206
|
+
var defaultRenderItem = (item, idx) => b`${idx}: ${JSON.stringify(item, null, 2)}`;
|
|
2207
|
+
var VirtualizeDirective = class extends f {
|
|
2208
|
+
constructor(part) {
|
|
2209
|
+
super(part);
|
|
2210
|
+
this._virtualizer = null;
|
|
2211
|
+
this._first = 0;
|
|
2212
|
+
this._last = -1;
|
|
2213
|
+
this._renderItem = (item, idx) => defaultRenderItem(item, idx + this._first);
|
|
2214
|
+
this._keyFunction = (item, idx) => defaultKeyFunction(item, idx + this._first);
|
|
2215
|
+
this._items = [];
|
|
2216
|
+
if (part.type !== t.CHILD) throw new Error("The virtualize directive can only be used in child expressions");
|
|
2217
|
+
}
|
|
2218
|
+
render(config) {
|
|
2219
|
+
if (config) this._setFunctions(config);
|
|
2220
|
+
const itemsToRender = [];
|
|
2221
|
+
if (this._first >= 0 && this._last >= this._first) for (let i = this._first; i <= this._last; i++) itemsToRender.push(this._items[i]);
|
|
2222
|
+
return c(itemsToRender, this._keyFunction, this._renderItem);
|
|
2223
|
+
}
|
|
2224
|
+
update(part, [config]) {
|
|
2225
|
+
this._setFunctions(config);
|
|
2226
|
+
const itemsChanged = this._items !== config.items;
|
|
2227
|
+
this._items = config.items || [];
|
|
2228
|
+
if (this._virtualizer) this._updateVirtualizerConfig(part, config);
|
|
2229
|
+
else this._initialize(part, config);
|
|
2230
|
+
return itemsChanged ? E : this.render();
|
|
2231
|
+
}
|
|
2232
|
+
async _updateVirtualizerConfig(part, config) {
|
|
2233
|
+
if (!await this._virtualizer.updateLayoutConfig(config.layout || {})) {
|
|
2234
|
+
const hostElement = part.parentNode;
|
|
2235
|
+
this._makeVirtualizer(hostElement, config);
|
|
2236
|
+
}
|
|
2237
|
+
this._virtualizer.items = this._items;
|
|
2238
|
+
}
|
|
2239
|
+
_setFunctions(config) {
|
|
2240
|
+
const { renderItem, keyFunction } = config;
|
|
2241
|
+
if (renderItem) this._renderItem = (item, idx) => renderItem(item, idx + this._first);
|
|
2242
|
+
if (keyFunction) this._keyFunction = (item, idx) => keyFunction(item, idx + this._first);
|
|
2243
|
+
}
|
|
2244
|
+
_makeVirtualizer(hostElement, config) {
|
|
2245
|
+
if (this._virtualizer) this._virtualizer.disconnected();
|
|
2246
|
+
const { layout, scroller, items } = config;
|
|
2247
|
+
this._virtualizer = new Virtualizer({
|
|
2248
|
+
hostElement,
|
|
2249
|
+
layout,
|
|
2250
|
+
scroller
|
|
2251
|
+
});
|
|
2252
|
+
this._virtualizer.items = items;
|
|
2253
|
+
this._virtualizer.connected();
|
|
2254
|
+
}
|
|
2255
|
+
_initialize(part, config) {
|
|
2256
|
+
const hostElement = part.parentNode;
|
|
2257
|
+
if (hostElement && hostElement.nodeType === 1) {
|
|
2258
|
+
hostElement.addEventListener("rangeChanged", (e) => {
|
|
2259
|
+
this._first = e.first;
|
|
2260
|
+
this._last = e.last;
|
|
2261
|
+
this.setValue(this.render());
|
|
2262
|
+
});
|
|
2263
|
+
this._makeVirtualizer(hostElement, config);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
disconnected() {
|
|
2267
|
+
this._virtualizer?.disconnected();
|
|
2268
|
+
}
|
|
2269
|
+
reconnected() {
|
|
2270
|
+
this._virtualizer?.connected();
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
var virtualize = e$1(VirtualizeDirective);
|
|
2274
|
+
//#endregion
|
|
1353
2275
|
//#region src/lib/timeline/derive.ts
|
|
1354
2276
|
/**
|
|
1355
2277
|
* @license
|
|
@@ -4013,73 +4935,6 @@ function toAgentToolName(id) {
|
|
|
4013
4935
|
return id.replace(/[^\w-]+/g, "_").slice(0, MAX_TOOL_NAME_LENGTH);
|
|
4014
4936
|
}
|
|
4015
4937
|
//#endregion
|
|
4016
|
-
//#region \0vite/preload-helper.js
|
|
4017
|
-
var scriptRel = "modulepreload";
|
|
4018
|
-
var assetsURL = function(dep, importerUrl) {
|
|
4019
|
-
return new URL(dep, importerUrl).href;
|
|
4020
|
-
};
|
|
4021
|
-
var seen = {};
|
|
4022
|
-
var __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
4023
|
-
let promise = Promise.resolve();
|
|
4024
|
-
if (deps && deps.length > 0) {
|
|
4025
|
-
const links = document.getElementsByTagName("link");
|
|
4026
|
-
const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
|
|
4027
|
-
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
|
|
4028
|
-
function allSettled(promises) {
|
|
4029
|
-
return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
|
|
4030
|
-
status: "fulfilled",
|
|
4031
|
-
value
|
|
4032
|
-
}), (reason) => ({
|
|
4033
|
-
status: "rejected",
|
|
4034
|
-
reason
|
|
4035
|
-
}))));
|
|
4036
|
-
}
|
|
4037
|
-
function importMetaResolve(specifier) {
|
|
4038
|
-
if (import.meta.resolve) return import.meta.resolve(specifier);
|
|
4039
|
-
return new URL(
|
|
4040
|
-
specifier,
|
|
4041
|
-
/** #__KEEP__ */
|
|
4042
|
-
import.meta.url
|
|
4043
|
-
).href;
|
|
4044
|
-
}
|
|
4045
|
-
promise = allSettled(deps.map((dep) => {
|
|
4046
|
-
dep = assetsURL(dep, importerUrl);
|
|
4047
|
-
dep = importMetaResolve(dep);
|
|
4048
|
-
if (dep in seen) return;
|
|
4049
|
-
seen[dep] = true;
|
|
4050
|
-
const isCss = dep.endsWith(".css");
|
|
4051
|
-
for (let i = links.length - 1; i >= 0; i--) {
|
|
4052
|
-
const link = links[i];
|
|
4053
|
-
if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
|
|
4054
|
-
}
|
|
4055
|
-
const link = document.createElement("link");
|
|
4056
|
-
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
4057
|
-
if (!isCss) link.as = "script";
|
|
4058
|
-
link.crossOrigin = "";
|
|
4059
|
-
link.href = dep;
|
|
4060
|
-
if (cspNonce) link.setAttribute("nonce", cspNonce);
|
|
4061
|
-
document.head.appendChild(link);
|
|
4062
|
-
if (isCss) return new Promise((res, rej) => {
|
|
4063
|
-
link.addEventListener("load", res);
|
|
4064
|
-
link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
|
|
4065
|
-
});
|
|
4066
|
-
}).filter((p) => p !== void 0));
|
|
4067
|
-
}
|
|
4068
|
-
function handlePreloadError(err) {
|
|
4069
|
-
const e = new Event("vite:preloadError", { cancelable: true });
|
|
4070
|
-
e.payload = err;
|
|
4071
|
-
window.dispatchEvent(e);
|
|
4072
|
-
if (!e.defaultPrevented) throw err;
|
|
4073
|
-
}
|
|
4074
|
-
return promise.then((res) => {
|
|
4075
|
-
for (const item of res || []) {
|
|
4076
|
-
if (item.status !== "rejected") continue;
|
|
4077
|
-
handlePreloadError(item.reason);
|
|
4078
|
-
}
|
|
4079
|
-
return baseModule().catch(handlePreloadError);
|
|
4080
|
-
});
|
|
4081
|
-
};
|
|
4082
|
-
//#endregion
|
|
4083
4938
|
//#region node_modules/.pnpm/devframe@1.0.0_@devframes+agentic@1.0.0_cac@7.0.0_srvx@1.0.5/node_modules/devframe/dist/client/index.mjs
|
|
4084
4939
|
/** Devframe runtime routes and static output conventions. */
|
|
4085
4940
|
var DEVFRAME_CONNECTION_META_FILENAME = "__connection.json";
|
|
@@ -5980,7 +6835,7 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
5980
6835
|
bootstrapAuthSettled = true;
|
|
5981
6836
|
});
|
|
5982
6837
|
if (connectionMeta.mcp) __vitePreload(async () => {
|
|
5983
|
-
const { setupBrowserAgentRpcBridge } = await import("./browser-agent-rpc-BXhoSh1z-
|
|
6838
|
+
const { setupBrowserAgentRpcBridge } = await import("./browser-agent-rpc-BXhoSh1z-CdtPhBL-.js");
|
|
5984
6839
|
return { setupBrowserAgentRpcBridge };
|
|
5985
6840
|
}, [], import.meta.url).then(({ setupBrowserAgentRpcBridge }) => {
|
|
5986
6841
|
if (!closed) disposeBrowserAgentBridge = setupBrowserAgentRpcBridge(rpc);
|
|
@@ -6042,6 +6897,7 @@ var SESSION_STATE_KEY = "session";
|
|
|
6042
6897
|
var LAYER_FLAGS = {
|
|
6043
6898
|
"lit-lifecycle": "litLifecycleEnabled",
|
|
6044
6899
|
"lit-render": "litRenderEnabled",
|
|
6900
|
+
"lit-render-verbose": "litRenderVerboseEnabled",
|
|
6045
6901
|
mouse: "mouseEventEnabled",
|
|
6046
6902
|
keyboard: "keyboardEventEnabled"
|
|
6047
6903
|
};
|
|
@@ -6206,6 +7062,8 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6206
7062
|
this._scrollRef = e();
|
|
6207
7063
|
this._elementsCache = [];
|
|
6208
7064
|
this._rowsCache = [];
|
|
7065
|
+
this._visibleCache = [];
|
|
7066
|
+
this._regexInvalid = false;
|
|
6209
7067
|
}
|
|
6210
7068
|
static {
|
|
6211
7069
|
this.styles = [tokens, i$5`
|
|
@@ -6288,6 +7146,9 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6288
7146
|
color: var(--lit-devtools-text-muted);
|
|
6289
7147
|
}
|
|
6290
7148
|
.row {
|
|
7149
|
+
/* The virtualizer positions rows absolutely; stretch them back. */
|
|
7150
|
+
box-sizing: border-box;
|
|
7151
|
+
width: 100%;
|
|
6291
7152
|
display: flex;
|
|
6292
7153
|
align-items: baseline;
|
|
6293
7154
|
gap: var(--lit-devtools-space-4);
|
|
@@ -6402,6 +7263,16 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6402
7263
|
this._elementsCache = this._computeElements();
|
|
6403
7264
|
if (this._elementFilter !== null && !this.events.some((ev) => ev.meta?.elementId === this._elementFilter)) this._elementFilter = null;
|
|
6404
7265
|
}
|
|
7266
|
+
if (changed.has("events") || changed.has("_raw") || changed.has("layers") || changed.has("_elementFilter") || changed.has("_regex")) {
|
|
7267
|
+
let re = null;
|
|
7268
|
+
this._regexInvalid = false;
|
|
7269
|
+
if (this._regex !== "") try {
|
|
7270
|
+
re = new RegExp(this._regex, "i");
|
|
7271
|
+
} catch {
|
|
7272
|
+
this._regexInvalid = true;
|
|
7273
|
+
}
|
|
7274
|
+
this._visibleCache = this._rowsCache.filter((row) => this._isVisible(row) && (re === null || re.test(this._haystack(row))));
|
|
7275
|
+
}
|
|
6405
7276
|
}
|
|
6406
7277
|
updated(changed) {
|
|
6407
7278
|
if (changed.has("events")) {
|
|
@@ -6454,14 +7325,7 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6454
7325
|
}
|
|
6455
7326
|
render() {
|
|
6456
7327
|
const elements = this._elementsCache;
|
|
6457
|
-
|
|
6458
|
-
let regexInvalid = false;
|
|
6459
|
-
if (this._regex !== "") try {
|
|
6460
|
-
re = new RegExp(this._regex, "i");
|
|
6461
|
-
} catch {
|
|
6462
|
-
regexInvalid = true;
|
|
6463
|
-
}
|
|
6464
|
-
const visible = this._rowsCache.filter((row) => this._isVisible(row) && (re === null || re.test(this._haystack(row))));
|
|
7328
|
+
const visible = this._visibleCache;
|
|
6465
7329
|
const selected = this._selectedKey === null ? void 0 : this._rowsCache.find((row) => row.key === this._selectedKey);
|
|
6466
7330
|
return b`
|
|
6467
7331
|
${this.events.length > 0 ? b`
|
|
@@ -6486,7 +7350,7 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6486
7350
|
</select>
|
|
6487
7351
|
` : A}
|
|
6488
7352
|
<input
|
|
6489
|
-
class="regex ${
|
|
7353
|
+
class="regex ${this._regexInvalid ? "invalid" : ""}"
|
|
6490
7354
|
type="text"
|
|
6491
7355
|
spellcheck="false"
|
|
6492
7356
|
placeholder="filter regex…"
|
|
@@ -6508,39 +7372,49 @@ var TimelineEventList = class TimelineEventList extends i$2 {
|
|
|
6508
7372
|
>
|
|
6509
7373
|
</div>
|
|
6510
7374
|
` : A}
|
|
6511
|
-
|
|
6512
|
-
|
|
7375
|
+
${visible.length === 0 ? b`
|
|
7376
|
+
<div class="scroll">
|
|
6513
7377
|
<div class="empty">
|
|
6514
7378
|
<span>No events recorded.</span>
|
|
6515
7379
|
<span class="hint"
|
|
6516
7380
|
>Press Record then interact with the page.</span
|
|
6517
7381
|
>
|
|
6518
7382
|
</div>
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
7383
|
+
</div>
|
|
7384
|
+
` : b`
|
|
7385
|
+
<div class="scroll" ${n(this._scrollRef)}>
|
|
7386
|
+
${virtualize({
|
|
7387
|
+
scroller: true,
|
|
7388
|
+
items: visible,
|
|
7389
|
+
keyFunction: (row, i) => row?.key ?? i,
|
|
7390
|
+
renderItem: (row) => row ? this._renderRow(row) : b``
|
|
7391
|
+
})}
|
|
7392
|
+
</div>
|
|
7393
|
+
`}
|
|
7394
|
+
${selected ? this._renderDetail(selected) : A}
|
|
7395
|
+
`;
|
|
7396
|
+
}
|
|
7397
|
+
/** One row of the virtualized list (`virtualize`'s `renderItem`). */
|
|
7398
|
+
_renderRow(row) {
|
|
7399
|
+
return b`
|
|
7400
|
+
<div
|
|
7401
|
+
class="row ${this._selectedKey === row.key ? "selected" : ""}"
|
|
7402
|
+
@click=${() => {
|
|
6523
7403
|
this._selectedKey = row.key;
|
|
6524
7404
|
}}
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
class="dur ${row.duration === void 0 ? "open" : ""}"
|
|
6538
|
-
>${renderDuration(row)}</span
|
|
6539
|
-
>
|
|
6540
|
-
</div>
|
|
6541
|
-
`)}
|
|
7405
|
+
>
|
|
7406
|
+
<span class="time">${row.start.toFixed(1)}ms</span>
|
|
7407
|
+
<span
|
|
7408
|
+
class="dot"
|
|
7409
|
+
style=${"background:" + this._colorOf(row.layerId)}
|
|
7410
|
+
></span>
|
|
7411
|
+
<span class="title">${row.name}</span>
|
|
7412
|
+
${row.changed?.length ? b`<span class="changed">${row.changed.join(", ")}</span>` : A}
|
|
7413
|
+
<span class="subtitle">${row.subtitle ?? A}</span>
|
|
7414
|
+
<span class="dur ${row.duration === void 0 ? "open" : ""}"
|
|
7415
|
+
>${renderDuration(row)}</span
|
|
7416
|
+
>
|
|
6542
7417
|
</div>
|
|
6543
|
-
${selected ? this._renderDetail(selected) : A}
|
|
6544
7418
|
`;
|
|
6545
7419
|
}
|
|
6546
7420
|
_renderDetail(row) {
|
|
@@ -9737,4 +10611,4 @@ LitDevtoolsPanel = __decorate([t$2("lit-devtools-panel")], LitDevtoolsPanel);
|
|
|
9737
10611
|
//#endregion
|
|
9738
10612
|
export { onBrowserAgentToolsChanged as n, nanoid as r, listBrowserAgentTools as t };
|
|
9739
10613
|
|
|
9740
|
-
//# sourceMappingURL=index-
|
|
10614
|
+
//# sourceMappingURL=index-DVe6M4HV.js.map
|