@feng3d/reactivity 1.0.4 → 1.0.6

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.
Files changed (106) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +158 -158
  3. package/dist/assets/RobotoMono-Medium-DVgDz_OO.woff2 +0 -0
  4. package/dist/assets/RobotoMono-Regular-BPoF81uy.woff2 +0 -0
  5. package/dist/assets/index-a2qCSG5V.css +629 -0
  6. package/dist/assets/index.html-Dyp3udP2.js +200 -0
  7. package/dist/assets/modulepreload-polyfill-DaKOjhqt.js +37 -0
  8. package/dist/assets/package-9zMEdmDL.js +2540 -0
  9. package/dist/assets/src//345/244/215/346/235/202/346/203/205/345/206/265/345/217/226/345/200/274/index.html-a69uOZEV.js +59 -0
  10. package/dist/assets/src//346/225/260/347/273/204/index.html-CaZ_5kCZ.js +43 -0
  11. package/dist/docs/.nojekyll +1 -0
  12. package/dist/docs/assets/hierarchy.js +1 -0
  13. package/dist/docs/assets/highlight.css +92 -0
  14. package/dist/docs/assets/icons.js +18 -0
  15. package/dist/docs/assets/icons.svg +1 -0
  16. package/dist/docs/assets/main.js +60 -0
  17. package/dist/docs/assets/navigation.js +1 -0
  18. package/dist/docs/assets/search.js +1 -0
  19. package/dist/docs/assets/style.css +1640 -0
  20. package/dist/docs/classes/ComputedReactivity.html +72 -0
  21. package/dist/docs/classes/EffectReactivity.html +62 -0
  22. package/dist/docs/classes/EffectScope.html +40 -0
  23. package/dist/docs/classes/Reactivity.html +35 -0
  24. package/dist/docs/classes/RefReactivity.html +57 -0
  25. package/dist/docs/functions/batchRun.html +15 -0
  26. package/dist/docs/functions/computed.html +5 -0
  27. package/dist/docs/functions/effect.html +11 -0
  28. package/dist/docs/functions/effectScope.html +5 -0
  29. package/dist/docs/functions/forceTrack.html +6 -0
  30. package/dist/docs/functions/getCurrentScope.html +4 -0
  31. package/dist/docs/functions/isProxy.html +5 -0
  32. package/dist/docs/functions/isReactive.html +5 -0
  33. package/dist/docs/functions/isRef.html +5 -0
  34. package/dist/docs/functions/noTrack.html +6 -0
  35. package/dist/docs/functions/onScopeDispose.html +6 -0
  36. package/dist/docs/functions/reactive.html +19 -0
  37. package/dist/docs/functions/ref.html +13 -0
  38. package/dist/docs/functions/toRaw.html +4 -0
  39. package/dist/docs/hierarchy.html +1 -0
  40. package/dist/docs/index.html +129 -0
  41. package/dist/docs/interfaces/Computed.html +9 -0
  42. package/dist/docs/interfaces/Effect.html +8 -0
  43. package/dist/docs/interfaces/Ref.html +9 -0
  44. package/dist/docs/modules.html +1 -0
  45. package/dist/docs/types/Reactive.html +3 -0
  46. package/dist/docs/types/UnReadonly.html +3 -0
  47. package/dist/files/RobotoMono-Medium.woff2 +0 -0
  48. package/dist/files/RobotoMono-Regular.woff2 +0 -0
  49. package/dist/files/ic_code_black_24dp.svg +4 -0
  50. package/dist/files/ic_search_black_24dp.svg +4 -0
  51. package/dist/files/main.css +629 -0
  52. package/dist/files/thumbnails.svg +7 -0
  53. package/dist/files.json +7 -0
  54. package/dist/index.html +84 -0
  55. package/dist/index.js +735 -156
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.umd.cjs +735 -156
  58. package/dist/index.umd.cjs.map +1 -1
  59. package/dist/screenshots//345/244/215/346/235/202/346/203/205/345/206/265/345/217/226/345/200/274.jpg +0 -0
  60. package/dist/screenshots//346/225/260/347/273/204.jpg +0 -0
  61. package/dist/src//345/244/215/346/235/202/346/203/205/345/206/265/345/217/226/345/200/274/index.html +70 -0
  62. package/dist/src//346/225/260/347/273/204/index.html +65 -0
  63. package/dist/tags.json +2 -0
  64. package/lib/Reactivity.d.ts +47 -13
  65. package/lib/Reactivity.d.ts.map +1 -1
  66. package/lib/arrayInstrumentations.d.ts +10 -0
  67. package/lib/arrayInstrumentations.d.ts.map +1 -1
  68. package/lib/baseHandlers.d.ts +3 -1
  69. package/lib/baseHandlers.d.ts.map +1 -1
  70. package/lib/batch.d.ts +17 -5
  71. package/lib/batch.d.ts.map +1 -1
  72. package/lib/collectionHandlers.d.ts +21 -0
  73. package/lib/collectionHandlers.d.ts.map +1 -1
  74. package/lib/computed.d.ts +75 -27
  75. package/lib/computed.d.ts.map +1 -1
  76. package/lib/effect.d.ts +25 -0
  77. package/lib/effect.d.ts.map +1 -1
  78. package/lib/effectScope.d.ts +129 -0
  79. package/lib/effectScope.d.ts.map +1 -0
  80. package/lib/index.d.ts +6 -5
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/property.d.ts.map +1 -1
  83. package/lib/reactive.d.ts +63 -14
  84. package/lib/reactive.d.ts.map +1 -1
  85. package/lib/ref.d.ts +66 -4
  86. package/lib/ref.d.ts.map +1 -1
  87. package/lib/shared/constants.d.ts +7 -7
  88. package/lib/shared/constants.d.ts.map +1 -1
  89. package/lib/shared/general.d.ts +1 -1
  90. package/lib/shared/general.d.ts.map +1 -1
  91. package/package.json +71 -66
  92. package/src/Reactivity.ts +168 -126
  93. package/src/arrayInstrumentations.ts +801 -448
  94. package/src/baseHandlers.ts +312 -220
  95. package/src/batch.ts +118 -91
  96. package/src/collectionHandlers.ts +486 -298
  97. package/src/computed.ts +253 -204
  98. package/src/effect.ts +146 -108
  99. package/src/effectScope.ts +294 -0
  100. package/src/index.ts +9 -8
  101. package/src/property.ts +231 -225
  102. package/src/reactive.ts +186 -130
  103. package/src/ref.ts +150 -88
  104. package/src/shared/constants.ts +41 -41
  105. package/src/shared/general.ts +109 -109
  106. package/tsconfig.json +19 -19
@@ -0,0 +1,200 @@
1
+ import "./modulepreload-polyfill-DaKOjhqt.js";
2
+ const panel = document.getElementById("panel");
3
+ const content = document.getElementById("content");
4
+ const viewer = document.getElementById("viewer");
5
+ const filterInput = document.getElementById("filterInput");
6
+ const clearSearchButton = document.getElementById("clearSearchButton");
7
+ const expandButton = document.getElementById("expandButton");
8
+ const viewSrcButton = document.getElementById("button");
9
+ const panelScrim = document.getElementById("panelScrim");
10
+ const previewsToggler = document.getElementById("previewsToggler");
11
+ const sectionLink = document.querySelector("#sections > a");
12
+ const sectionDefaultHref = sectionLink.href;
13
+ const links = {};
14
+ const validRedirects = /* @__PURE__ */ new Map();
15
+ const container = document.createElement("div");
16
+ let selected = null;
17
+ init();
18
+ async function init() {
19
+ content.appendChild(container);
20
+ viewSrcButton.style.display = "none";
21
+ const files = await (await fetch("./files.json")).json();
22
+ const tags = await (await fetch("./tags.json")).json();
23
+ for (const key in files) {
24
+ const category = files[key];
25
+ const header = document.createElement("h2");
26
+ header.textContent = key;
27
+ header.setAttribute("data-category", key);
28
+ container.appendChild(header);
29
+ for (let i = 0; i < category.length; i++) {
30
+ const file = category[i];
31
+ if (file) {
32
+ validRedirects.set(file, `src/${file}/index.html`);
33
+ const link = createLink(file, tags[file]);
34
+ container.appendChild(link);
35
+ links[file] = link;
36
+ }
37
+ }
38
+ }
39
+ if (window.location.hash !== "") {
40
+ let file = window.location.hash.substring(1);
41
+ file = decodeURIComponent(file);
42
+ if (validRedirects.has(file) === true) {
43
+ selectFile(file);
44
+ viewer.src = validRedirects.get(file);
45
+ viewer.style.display = "unset";
46
+ } else {
47
+ console.warn(`Invalid redirect for ${file}`);
48
+ }
49
+ }
50
+ if (viewer.src === "") {
51
+ viewer.srcdoc = document.getElementById("PlaceholderHTML").innerHTML;
52
+ viewer.style.display = "unset";
53
+ }
54
+ filterInput.value = extractQuery();
55
+ if (filterInput.value !== "") {
56
+ panel.classList.add("searchFocused");
57
+ updateFilter(files, tags);
58
+ } else {
59
+ updateLink("");
60
+ }
61
+ filterInput.onfocus = function() {
62
+ panel.classList.add("searchFocused");
63
+ };
64
+ filterInput.onblur = function() {
65
+ if (filterInput.value === "") {
66
+ panel.classList.remove("searchFocused");
67
+ }
68
+ };
69
+ clearSearchButton.onclick = function() {
70
+ filterInput.value = "";
71
+ updateFilter(files, tags);
72
+ filterInput.focus();
73
+ };
74
+ filterInput.addEventListener("input", function() {
75
+ updateFilter(files, tags);
76
+ });
77
+ expandButton.addEventListener("click", function(event) {
78
+ event.preventDefault();
79
+ panel.classList.toggle("open");
80
+ });
81
+ panelScrim.onclick = function(event) {
82
+ event.preventDefault();
83
+ panel.classList.toggle("open");
84
+ };
85
+ previewsToggler.onclick = function(event) {
86
+ event.preventDefault();
87
+ content.classList.toggle("minimal");
88
+ };
89
+ if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent)) {
90
+ viewer.style.width = getComputedStyle(viewer).width;
91
+ viewer.style.height = getComputedStyle(viewer).height;
92
+ viewer.setAttribute("scrolling", "no");
93
+ }
94
+ }
95
+ function createLink(file, tags) {
96
+ const external = Array.isArray(tags) && tags.includes("external") ? ' <span class="tag">external</span>' : "";
97
+ const template = `
98
+ <div class="card">
99
+ <a href="${validRedirects.get(file)}" target="viewer">
100
+ <div class="cover">
101
+ <img src="screenshots/${file}.jpg" loading="lazy" width="400" />
102
+ </div>
103
+ <div class="title">${getName(file)}${external}</div>
104
+ </a>
105
+ </div>
106
+ `;
107
+ const link = createElementFromHTML(template);
108
+ const element = link.querySelector('a[target="viewer"]');
109
+ element.addEventListener("click", function(event) {
110
+ if (event.button !== 0 || event.ctrlKey || event.altKey || event.metaKey) return;
111
+ selectFile(file);
112
+ });
113
+ return link;
114
+ }
115
+ function selectFile(file) {
116
+ if (selected !== null) links[selected].classList.remove("selected");
117
+ links[file].classList.add("selected");
118
+ window.location.hash = file;
119
+ viewer.focus();
120
+ viewer.style.display = "unset";
121
+ panel.classList.remove("open");
122
+ selected = file;
123
+ viewSrcButton.style.display = "";
124
+ viewSrcButton.href = `https://gitee.com/feng3d/reactivity/tree/master/examples/src/${selected}/index.ts`;
125
+ viewSrcButton.title = `View source code for ${getName(selected)} on GitHub`;
126
+ }
127
+ function escapeRegExp(string) {
128
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
129
+ }
130
+ function updateFilter(files, tags) {
131
+ let v = filterInput.value.trim();
132
+ v = v.replace(/\s+/gi, " ");
133
+ if (v !== "") {
134
+ window.history.replaceState({}, "", `?q=${v}${window.location.hash}`);
135
+ } else {
136
+ window.history.replaceState({}, "", window.location.pathname + window.location.hash);
137
+ }
138
+ const exp = new RegExp(escapeRegExp(v), "gi");
139
+ for (const key in files) {
140
+ const section = files[key];
141
+ for (let i = 0; i < section.length; i++) {
142
+ filterExample(section[i], exp, tags);
143
+ }
144
+ }
145
+ layoutList(files);
146
+ updateLink(v);
147
+ }
148
+ function updateLink(search) {
149
+ if (search) {
150
+ const link = sectionLink.href.split(/[?#]/)[0];
151
+ sectionLink.href = `${link}?q=${search}`;
152
+ } else {
153
+ sectionLink.href = sectionDefaultHref;
154
+ }
155
+ }
156
+ function filterExample(file, exp, tags) {
157
+ const link = links[file];
158
+ if (!link) return;
159
+ if (file in tags) file += ` ${tags[file].join(" ")}`;
160
+ const res = file.replace(/_+/g, " ").match(exp);
161
+ if (res && res.length > 0) {
162
+ link.classList.remove("hidden");
163
+ } else {
164
+ link.classList.add("hidden");
165
+ }
166
+ }
167
+ function getName(file) {
168
+ return file;
169
+ }
170
+ function layoutList(files) {
171
+ for (const key in files) {
172
+ let collapsed = true;
173
+ const section = files[key];
174
+ for (let i = 0; i < section.length; i++) {
175
+ const file = section[i];
176
+ if (links[file].classList.contains("hidden") === false) {
177
+ collapsed = false;
178
+ break;
179
+ }
180
+ }
181
+ const element = document.querySelector(`h2[data-category="${key}"]`);
182
+ if (collapsed) {
183
+ element.classList.add("hidden");
184
+ } else {
185
+ element.classList.remove("hidden");
186
+ }
187
+ }
188
+ }
189
+ function extractQuery() {
190
+ const search = window.location.search;
191
+ if (search.indexOf("?q=") !== -1) {
192
+ return decodeURI(search.slice(3));
193
+ }
194
+ return "";
195
+ }
196
+ function createElementFromHTML(htmlString) {
197
+ const div = document.createElement("div");
198
+ div.innerHTML = htmlString.trim();
199
+ return div.firstChild;
200
+ }
@@ -0,0 +1,37 @@
1
+ (function polyfill() {
2
+ const relList = document.createElement("link").relList;
3
+ if (relList && relList.supports && relList.supports("modulepreload")) {
4
+ return;
5
+ }
6
+ for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
7
+ processPreload(link);
8
+ }
9
+ new MutationObserver((mutations) => {
10
+ for (const mutation of mutations) {
11
+ if (mutation.type !== "childList") {
12
+ continue;
13
+ }
14
+ for (const node of mutation.addedNodes) {
15
+ if (node.tagName === "LINK" && node.rel === "modulepreload")
16
+ processPreload(node);
17
+ }
18
+ }
19
+ }).observe(document, { childList: true, subtree: true });
20
+ function getFetchOpts(link) {
21
+ const fetchOpts = {};
22
+ if (link.integrity) fetchOpts.integrity = link.integrity;
23
+ if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
24
+ if (link.crossOrigin === "use-credentials")
25
+ fetchOpts.credentials = "include";
26
+ else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
27
+ else fetchOpts.credentials = "same-origin";
28
+ return fetchOpts;
29
+ }
30
+ function processPreload(link) {
31
+ if (link.ep)
32
+ return;
33
+ link.ep = true;
34
+ const fetchOpts = getFetchOpts(link);
35
+ fetch(link.href, fetchOpts);
36
+ }
37
+ })();