@tanstack/virtual-core 3.0.0-beta.12 → 3.0.0-beta.13

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.
@@ -0,0 +1,86 @@
1
+ /**
2
+ * virtual-core
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var props = ["bottom", "height", "left", "right", "top", "width"];
16
+
17
+ var rectChanged = function rectChanged(a, b) {
18
+ if (a === void 0) {
19
+ a = {};
20
+ }
21
+
22
+ if (b === void 0) {
23
+ b = {};
24
+ }
25
+
26
+ return props.some(function (prop) {
27
+ return a[prop] !== b[prop];
28
+ });
29
+ };
30
+
31
+ var observedNodes = /*#__PURE__*/new Map();
32
+ var rafId;
33
+
34
+ var run = function run() {
35
+ var changedStates = [];
36
+ observedNodes.forEach(function (state, node) {
37
+ var newRect = node.getBoundingClientRect();
38
+
39
+ if (rectChanged(newRect, state.rect)) {
40
+ state.rect = newRect;
41
+ changedStates.push(state);
42
+ }
43
+ });
44
+ changedStates.forEach(function (state) {
45
+ state.callbacks.forEach(function (cb) {
46
+ return cb(state.rect);
47
+ });
48
+ });
49
+ rafId = window.requestAnimationFrame(run);
50
+ };
51
+
52
+ function observeRect(node, cb) {
53
+ return {
54
+ observe: function observe() {
55
+ var wasEmpty = observedNodes.size === 0;
56
+
57
+ if (observedNodes.has(node)) {
58
+ observedNodes.get(node).callbacks.push(cb);
59
+ } else {
60
+ observedNodes.set(node, {
61
+ rect: undefined,
62
+ hasRectChanged: false,
63
+ callbacks: [cb]
64
+ });
65
+ }
66
+
67
+ if (wasEmpty) run();
68
+ },
69
+ unobserve: function unobserve() {
70
+ var state = observedNodes.get(node);
71
+
72
+ if (state) {
73
+ // Remove the callback
74
+ var index = state.callbacks.indexOf(cb);
75
+ if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
76
+
77
+ if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
78
+
79
+ if (!observedNodes.size) cancelAnimationFrame(rafId);
80
+ }
81
+ }
82
+ };
83
+ }
84
+
85
+ exports["default"] = observeRect;
86
+ //# sourceMappingURL=observe-rect.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-rect.esm.js","sources":["../../../../../../../../node_modules/@reach/observe-rect/dist/observe-rect.esm.js"],"sourcesContent":["var props = [\"bottom\", \"height\", \"left\", \"right\", \"top\", \"width\"];\n\nvar rectChanged = function rectChanged(a, b) {\n if (a === void 0) {\n a = {};\n }\n\n if (b === void 0) {\n b = {};\n }\n\n return props.some(function (prop) {\n return a[prop] !== b[prop];\n });\n};\n\nvar observedNodes = /*#__PURE__*/new Map();\nvar rafId;\n\nvar run = function run() {\n var changedStates = [];\n observedNodes.forEach(function (state, node) {\n var newRect = node.getBoundingClientRect();\n\n if (rectChanged(newRect, state.rect)) {\n state.rect = newRect;\n changedStates.push(state);\n }\n });\n changedStates.forEach(function (state) {\n state.callbacks.forEach(function (cb) {\n return cb(state.rect);\n });\n });\n rafId = window.requestAnimationFrame(run);\n};\n\nfunction observeRect(node, cb) {\n return {\n observe: function observe() {\n var wasEmpty = observedNodes.size === 0;\n\n if (observedNodes.has(node)) {\n observedNodes.get(node).callbacks.push(cb);\n } else {\n observedNodes.set(node, {\n rect: undefined,\n hasRectChanged: false,\n callbacks: [cb]\n });\n }\n\n if (wasEmpty) run();\n },\n unobserve: function unobserve() {\n var state = observedNodes.get(node);\n\n if (state) {\n // Remove the callback\n var index = state.callbacks.indexOf(cb);\n if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference\n\n if (!state.callbacks.length) observedNodes[\"delete\"](node); // Stop the loop\n\n if (!observedNodes.size) cancelAnimationFrame(rafId);\n }\n }\n };\n}\n\nexport default observeRect;\n//# sourceMappingURL=observe-rect.esm.js.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C,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AACnE;AACA,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAC7D,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
package/build/stats.html CHANGED
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"node_modules/@reach/observe-rect/dist/observe-rect.esm.js","uid":"b160-1"},{"name":"packages/virtual-core/src","children":[{"uid":"b160-3","name":"utils.ts"},{"uid":"b160-5","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"b160-1":{"renderedLength":1732,"gzipLength":652,"brotliLength":0,"mainUid":"b160-0"},"b160-3":{"renderedLength":1432,"gzipLength":544,"brotliLength":0,"mainUid":"b160-2"},"b160-5":{"renderedLength":13712,"gzipLength":3162,"brotliLength":0,"mainUid":"b160-4"}},"nodeMetas":{"b160-0":{"id":"/node_modules/@reach/observe-rect/dist/observe-rect.esm.js","moduleParts":{"index.production.js":"b160-1"},"imported":[],"importedBy":[{"uid":"b160-4"}]},"b160-2":{"id":"/packages/virtual-core/src/utils.ts","moduleParts":{"index.production.js":"b160-3"},"imported":[],"importedBy":[{"uid":"b160-4"}]},"b160-4":{"id":"/packages/virtual-core/src/index.ts","moduleParts":{"index.production.js":"b160-5"},"imported":[{"uid":"b160-0"},{"uid":"b160-2"}],"importedBy":[],"isEntry":true}},"env":{"rollup":"2.75.4"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"node_modules/@reach/observe-rect/dist/observe-rect.esm.js","uid":"a984-1"},{"name":"packages/virtual-core/src","children":[{"uid":"a984-3","name":"utils.ts"},{"uid":"a984-5","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"a984-1":{"renderedLength":1732,"gzipLength":652,"brotliLength":0,"mainUid":"a984-0"},"a984-3":{"renderedLength":1432,"gzipLength":544,"brotliLength":0,"mainUid":"a984-2"},"a984-5":{"renderedLength":13712,"gzipLength":3162,"brotliLength":0,"mainUid":"a984-4"}},"nodeMetas":{"a984-0":{"id":"/node_modules/@reach/observe-rect/dist/observe-rect.esm.js","moduleParts":{"index.production.js":"a984-1"},"imported":[],"importedBy":[{"uid":"a984-4"}]},"a984-2":{"id":"/packages/virtual-core/src/utils.ts","moduleParts":{"index.production.js":"a984-3"},"imported":[],"importedBy":[{"uid":"a984-4"}]},"a984-4":{"id":"/packages/virtual-core/src/index.ts","moduleParts":{"index.production.js":"a984-5"},"imported":[{"uid":"a984-0"},{"uid":"a984-2"}],"importedBy":[],"isEntry":true}},"env":{"rollup":"2.75.4"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
package/build/stats.json CHANGED
@@ -8,17 +8,17 @@
8
8
  "children": [
9
9
  {
10
10
  "name": "node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
11
- "uid": "b160-7"
11
+ "uid": "a984-7"
12
12
  },
13
13
  {
14
14
  "name": "packages/virtual-core/src",
15
15
  "children": [
16
16
  {
17
- "uid": "b160-9",
17
+ "uid": "a984-9",
18
18
  "name": "utils.ts"
19
19
  },
20
20
  {
21
- "uid": "b160-11",
21
+ "uid": "a984-11",
22
22
  "name": "index.ts"
23
23
  }
24
24
  ]
@@ -29,61 +29,61 @@
29
29
  "isRoot": true
30
30
  },
31
31
  "nodeParts": {
32
- "b160-7": {
32
+ "a984-7": {
33
33
  "renderedLength": 1732,
34
34
  "gzipLength": 652,
35
35
  "brotliLength": 0,
36
- "mainUid": "b160-6"
36
+ "mainUid": "a984-6"
37
37
  },
38
- "b160-9": {
38
+ "a984-9": {
39
39
  "renderedLength": 1432,
40
40
  "gzipLength": 544,
41
41
  "brotliLength": 0,
42
- "mainUid": "b160-8"
42
+ "mainUid": "a984-8"
43
43
  },
44
- "b160-11": {
44
+ "a984-11": {
45
45
  "renderedLength": 13712,
46
46
  "gzipLength": 3162,
47
47
  "brotliLength": 0,
48
- "mainUid": "b160-10"
48
+ "mainUid": "a984-10"
49
49
  }
50
50
  },
51
51
  "nodeMetas": {
52
- "b160-6": {
52
+ "a984-6": {
53
53
  "id": "/node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
54
54
  "moduleParts": {
55
- "index.production.js": "b160-7"
55
+ "index.production.js": "a984-7"
56
56
  },
57
57
  "imported": [],
58
58
  "importedBy": [
59
59
  {
60
- "uid": "b160-10"
60
+ "uid": "a984-10"
61
61
  }
62
62
  ]
63
63
  },
64
- "b160-8": {
64
+ "a984-8": {
65
65
  "id": "/packages/virtual-core/src/utils.ts",
66
66
  "moduleParts": {
67
- "index.production.js": "b160-9"
67
+ "index.production.js": "a984-9"
68
68
  },
69
69
  "imported": [],
70
70
  "importedBy": [
71
71
  {
72
- "uid": "b160-10"
72
+ "uid": "a984-10"
73
73
  }
74
74
  ]
75
75
  },
76
- "b160-10": {
76
+ "a984-10": {
77
77
  "id": "/packages/virtual-core/src/index.ts",
78
78
  "moduleParts": {
79
- "index.production.js": "b160-11"
79
+ "index.production.js": "a984-11"
80
80
  },
81
81
  "imported": [
82
82
  {
83
- "uid": "b160-6"
83
+ "uid": "a984-6"
84
84
  },
85
85
  {
86
- "uid": "b160-8"
86
+ "uid": "a984-8"
87
87
  }
88
88
  ],
89
89
  "importedBy": [],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/virtual-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "3.0.0-beta.12",
4
+ "version": "3.0.0-beta.13",
5
5
  "description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/virtual#readme",
@@ -33,7 +33,7 @@
33
33
  "node": ">=12"
34
34
  },
35
35
  "files": [
36
- "build/*",
36
+ "build/**",
37
37
  "src"
38
38
  ],
39
39
  "dependencies": {