repluggable-core 0.0.0-pr302.475 → 0.0.0-pr303.476

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 (302) hide show
  1. package/dist/es/{src/API.d.ts → API.d.ts} +8 -46
  2. package/dist/es/API.d.ts.map +1 -0
  3. package/dist/es/API.js +2 -0
  4. package/dist/es/API.js.map +1 -0
  5. package/dist/es/__internal.d.ts.map +1 -0
  6. package/dist/es/__internal.js +5 -0
  7. package/dist/es/__internal.js.map +1 -0
  8. package/dist/es/index.d.ts +3 -0
  9. package/dist/es/index.d.ts.map +1 -0
  10. package/dist/es/index.js +2 -0
  11. package/dist/es/index.js.map +1 -0
  12. package/dist/src/API.d.ts +8 -46
  13. package/dist/src/API.d.ts.map +1 -1
  14. package/dist/src/API.js +0 -4
  15. package/dist/src/API.js.map +1 -1
  16. package/dist/src/__internal.d.ts.map +1 -1
  17. package/dist/src/__internal.js +1 -1
  18. package/dist/src/__internal.js.map +1 -1
  19. package/dist/src/index.d.ts +2 -10
  20. package/dist/src/index.d.ts.map +1 -1
  21. package/dist/src/index.js +15 -22
  22. package/dist/src/index.js.map +1 -1
  23. package/package.json +3 -21
  24. package/src/API.ts +9 -47
  25. package/src/__internal.ts +1 -1
  26. package/src/index.ts +2 -42
  27. package/tsconfig.json +2 -9
  28. package/__tests__/spec-setup.js +0 -3
  29. package/dist/es/src/API.d.ts.map +0 -1
  30. package/dist/es/src/API.js +0 -3
  31. package/dist/es/src/API.js.map +0 -1
  32. package/dist/es/src/IterableWeakMap.d.ts +0 -20
  33. package/dist/es/src/IterableWeakMap.d.ts.map +0 -1
  34. package/dist/es/src/IterableWeakMap.js +0 -93
  35. package/dist/es/src/IterableWeakMap.js.map +0 -1
  36. package/dist/es/src/__internal.d.ts.map +0 -1
  37. package/dist/es/src/__internal.js +0 -5
  38. package/dist/es/src/__internal.js.map +0 -1
  39. package/dist/es/src/appHost.d.ts +0 -7
  40. package/dist/es/src/appHost.d.ts.map +0 -1
  41. package/dist/es/src/appHost.js +0 -898
  42. package/dist/es/src/appHost.js.map +0 -1
  43. package/dist/es/src/appHostServices.d.ts +0 -12
  44. package/dist/es/src/appHostServices.d.ts.map +0 -1
  45. package/dist/es/src/appHostServices.js +0 -25
  46. package/dist/es/src/appHostServices.js.map +0 -1
  47. package/dist/es/src/appHostUtils.d.ts +0 -4
  48. package/dist/es/src/appHostUtils.d.ts.map +0 -1
  49. package/dist/es/src/appHostUtils.js +0 -8
  50. package/dist/es/src/appHostUtils.js.map +0 -1
  51. package/dist/es/src/extensionSlot.d.ts +0 -8
  52. package/dist/es/src/extensionSlot.d.ts.map +0 -1
  53. package/dist/es/src/extensionSlot.js +0 -59
  54. package/dist/es/src/extensionSlot.js.map +0 -1
  55. package/dist/es/src/hot.d.ts +0 -14
  56. package/dist/es/src/hot.d.ts.map +0 -1
  57. package/dist/es/src/hot.js +0 -52
  58. package/dist/es/src/hot.js.map +0 -1
  59. package/dist/es/src/index.d.ts +0 -11
  60. package/dist/es/src/index.d.ts.map +0 -1
  61. package/dist/es/src/index.js +0 -10
  62. package/dist/es/src/index.js.map +0 -1
  63. package/dist/es/src/installedShellsState.d.ts +0 -19
  64. package/dist/es/src/installedShellsState.d.ts.map +0 -1
  65. package/dist/es/src/installedShellsState.js +0 -30
  66. package/dist/es/src/installedShellsState.js.map +0 -1
  67. package/dist/es/src/interceptAnyObject.d.ts +0 -7
  68. package/dist/es/src/interceptAnyObject.d.ts.map +0 -1
  69. package/dist/es/src/interceptAnyObject.js +0 -21
  70. package/dist/es/src/interceptAnyObject.js.map +0 -1
  71. package/dist/es/src/invokeSlotCallbacks.d.ts +0 -3
  72. package/dist/es/src/invokeSlotCallbacks.d.ts.map +0 -1
  73. package/dist/es/src/invokeSlotCallbacks.js +0 -20
  74. package/dist/es/src/invokeSlotCallbacks.js.map +0 -1
  75. package/dist/es/src/loggers.d.ts +0 -4
  76. package/dist/es/src/loggers.d.ts.map +0 -1
  77. package/dist/es/src/loggers.js +0 -100
  78. package/dist/es/src/loggers.js.map +0 -1
  79. package/dist/es/src/monitorAPI.d.ts +0 -3
  80. package/dist/es/src/monitorAPI.d.ts.map +0 -1
  81. package/dist/es/src/monitorAPI.js +0 -53
  82. package/dist/es/src/monitorAPI.js.map +0 -1
  83. package/dist/es/src/repluggableAppDebug/index.d.ts +0 -2
  84. package/dist/es/src/repluggableAppDebug/index.d.ts.map +0 -1
  85. package/dist/es/src/repluggableAppDebug/index.js +0 -2
  86. package/dist/es/src/repluggableAppDebug/index.js.map +0 -1
  87. package/dist/es/src/repluggableAppDebug/performanceDebugInfo.d.ts +0 -15
  88. package/dist/es/src/repluggableAppDebug/performanceDebugInfo.d.ts.map +0 -1
  89. package/dist/es/src/repluggableAppDebug/performanceDebugInfo.js +0 -94
  90. package/dist/es/src/repluggableAppDebug/performanceDebugInfo.js.map +0 -1
  91. package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts +0 -24
  92. package/dist/es/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +0 -1
  93. package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js +0 -132
  94. package/dist/es/src/repluggableAppDebug/repluggableAppDebug.js.map +0 -1
  95. package/dist/es/src/tarjanGraph.d.ts +0 -27
  96. package/dist/es/src/tarjanGraph.d.ts.map +0 -1
  97. package/dist/es/src/tarjanGraph.js +0 -94
  98. package/dist/es/src/tarjanGraph.js.map +0 -1
  99. package/dist/es/src/throttledStore.d.ts +0 -32
  100. package/dist/es/src/throttledStore.d.ts.map +0 -1
  101. package/dist/es/src/throttledStore.js +0 -240
  102. package/dist/es/src/throttledStore.js.map +0 -1
  103. package/dist/es/test/IterableWeakMap.spec.d.ts +0 -2
  104. package/dist/es/test/IterableWeakMap.spec.d.ts.map +0 -1
  105. package/dist/es/test/IterableWeakMap.spec.js +0 -218
  106. package/dist/es/test/IterableWeakMap.spec.js.map +0 -1
  107. package/dist/es/test/appHost.mock.d.ts +0 -4
  108. package/dist/es/test/appHost.mock.d.ts.map +0 -1
  109. package/dist/es/test/appHost.mock.js +0 -54
  110. package/dist/es/test/appHost.mock.js.map +0 -1
  111. package/dist/es/test/appHost.spec.d.ts +0 -2
  112. package/dist/es/test/appHost.spec.d.ts.map +0 -1
  113. package/dist/es/test/appHost.spec.js +0 -1451
  114. package/dist/es/test/appHost.spec.js.map +0 -1
  115. package/dist/es/test/installedShellsState.spec.d.ts +0 -2
  116. package/dist/es/test/installedShellsState.spec.d.ts.map +0 -1
  117. package/dist/es/test/installedShellsState.spec.js +0 -28
  118. package/dist/es/test/installedShellsState.spec.js.map +0 -1
  119. package/dist/es/test/interceptAnyObject.spec.d.ts +0 -2
  120. package/dist/es/test/interceptAnyObject.spec.d.ts.map +0 -1
  121. package/dist/es/test/interceptAnyObject.spec.js +0 -166
  122. package/dist/es/test/interceptAnyObject.spec.js.map +0 -1
  123. package/dist/es/test/loggers.spec.d.ts +0 -2
  124. package/dist/es/test/loggers.spec.d.ts.map +0 -1
  125. package/dist/es/test/loggers.spec.js +0 -218
  126. package/dist/es/test/loggers.spec.js.map +0 -1
  127. package/dist/es/test/repluggableAppDebug.spec.d.ts +0 -2
  128. package/dist/es/test/repluggableAppDebug.spec.d.ts.map +0 -1
  129. package/dist/es/test/repluggableAppDebug.spec.js +0 -107
  130. package/dist/es/test/repluggableAppDebug.spec.js.map +0 -1
  131. package/dist/es/test/testKit.spec.d.ts +0 -2
  132. package/dist/es/test/testKit.spec.d.ts.map +0 -1
  133. package/dist/es/test/testKit.spec.js +0 -129
  134. package/dist/es/test/testKit.spec.js.map +0 -1
  135. package/dist/es/testKit/emptyLoggerOptions.d.ts +0 -3
  136. package/dist/es/testKit/emptyLoggerOptions.d.ts.map +0 -1
  137. package/dist/es/testKit/emptyLoggerOptions.js +0 -15
  138. package/dist/es/testKit/emptyLoggerOptions.js.map +0 -1
  139. package/dist/es/testKit/index.d.ts +0 -33
  140. package/dist/es/testKit/index.d.ts.map +0 -1
  141. package/dist/es/testKit/index.js +0 -132
  142. package/dist/es/testKit/index.js.map +0 -1
  143. package/dist/es/testKit/mockPackage.d.ts +0 -23
  144. package/dist/es/testKit/mockPackage.d.ts.map +0 -1
  145. package/dist/es/testKit/mockPackage.js +0 -95
  146. package/dist/es/testKit/mockPackage.js.map +0 -1
  147. package/dist/es/testKit/withConsoleErrors.d.ts +0 -2
  148. package/dist/es/testKit/withConsoleErrors.d.ts.map +0 -1
  149. package/dist/es/testKit/withConsoleErrors.js +0 -12
  150. package/dist/es/testKit/withConsoleErrors.js.map +0 -1
  151. package/dist/es/testKit/withThrowOnError.d.ts +0 -3
  152. package/dist/es/testKit/withThrowOnError.d.ts.map +0 -1
  153. package/dist/es/testKit/withThrowOnError.js +0 -27
  154. package/dist/es/testKit/withThrowOnError.js.map +0 -1
  155. package/dist/src/IterableWeakMap.d.ts +0 -20
  156. package/dist/src/IterableWeakMap.d.ts.map +0 -1
  157. package/dist/src/IterableWeakMap.js +0 -97
  158. package/dist/src/IterableWeakMap.js.map +0 -1
  159. package/dist/src/appHost.d.ts +0 -7
  160. package/dist/src/appHost.d.ts.map +0 -1
  161. package/dist/src/appHost.js +0 -906
  162. package/dist/src/appHost.js.map +0 -1
  163. package/dist/src/appHostServices.d.ts +0 -12
  164. package/dist/src/appHostServices.d.ts.map +0 -1
  165. package/dist/src/appHostServices.js +0 -29
  166. package/dist/src/appHostServices.js.map +0 -1
  167. package/dist/src/appHostUtils.d.ts +0 -4
  168. package/dist/src/appHostUtils.d.ts.map +0 -1
  169. package/dist/src/appHostUtils.js +0 -16
  170. package/dist/src/appHostUtils.js.map +0 -1
  171. package/dist/src/extensionSlot.d.ts +0 -8
  172. package/dist/src/extensionSlot.d.ts.map +0 -1
  173. package/dist/src/extensionSlot.js +0 -67
  174. package/dist/src/extensionSlot.js.map +0 -1
  175. package/dist/src/hot.d.ts +0 -14
  176. package/dist/src/hot.d.ts.map +0 -1
  177. package/dist/src/hot.js +0 -56
  178. package/dist/src/hot.js.map +0 -1
  179. package/dist/src/installedShellsState.d.ts +0 -19
  180. package/dist/src/installedShellsState.d.ts.map +0 -1
  181. package/dist/src/installedShellsState.js +0 -38
  182. package/dist/src/installedShellsState.js.map +0 -1
  183. package/dist/src/interceptAnyObject.d.ts +0 -7
  184. package/dist/src/interceptAnyObject.d.ts.map +0 -1
  185. package/dist/src/interceptAnyObject.js +0 -28
  186. package/dist/src/interceptAnyObject.js.map +0 -1
  187. package/dist/src/invokeSlotCallbacks.d.ts +0 -3
  188. package/dist/src/invokeSlotCallbacks.d.ts.map +0 -1
  189. package/dist/src/invokeSlotCallbacks.js +0 -24
  190. package/dist/src/invokeSlotCallbacks.js.map +0 -1
  191. package/dist/src/loggers.d.ts +0 -4
  192. package/dist/src/loggers.d.ts.map +0 -1
  193. package/dist/src/loggers.js +0 -104
  194. package/dist/src/loggers.js.map +0 -1
  195. package/dist/src/monitorAPI.d.ts +0 -3
  196. package/dist/src/monitorAPI.d.ts.map +0 -1
  197. package/dist/src/monitorAPI.js +0 -57
  198. package/dist/src/monitorAPI.js.map +0 -1
  199. package/dist/src/repluggableAppDebug/index.d.ts +0 -2
  200. package/dist/src/repluggableAppDebug/index.d.ts.map +0 -1
  201. package/dist/src/repluggableAppDebug/index.js +0 -6
  202. package/dist/src/repluggableAppDebug/index.js.map +0 -1
  203. package/dist/src/repluggableAppDebug/performanceDebugInfo.d.ts +0 -15
  204. package/dist/src/repluggableAppDebug/performanceDebugInfo.d.ts.map +0 -1
  205. package/dist/src/repluggableAppDebug/performanceDebugInfo.js +0 -101
  206. package/dist/src/repluggableAppDebug/performanceDebugInfo.js.map +0 -1
  207. package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts +0 -24
  208. package/dist/src/repluggableAppDebug/repluggableAppDebug.d.ts.map +0 -1
  209. package/dist/src/repluggableAppDebug/repluggableAppDebug.js +0 -139
  210. package/dist/src/repluggableAppDebug/repluggableAppDebug.js.map +0 -1
  211. package/dist/src/tarjanGraph.d.ts +0 -27
  212. package/dist/src/tarjanGraph.d.ts.map +0 -1
  213. package/dist/src/tarjanGraph.js +0 -100
  214. package/dist/src/tarjanGraph.js.map +0 -1
  215. package/dist/src/throttledStore.d.ts +0 -32
  216. package/dist/src/throttledStore.d.ts.map +0 -1
  217. package/dist/src/throttledStore.js +0 -249
  218. package/dist/src/throttledStore.js.map +0 -1
  219. package/dist/test/IterableWeakMap.spec.d.ts +0 -2
  220. package/dist/test/IterableWeakMap.spec.d.ts.map +0 -1
  221. package/dist/test/IterableWeakMap.spec.js +0 -220
  222. package/dist/test/IterableWeakMap.spec.js.map +0 -1
  223. package/dist/test/appHost.mock.d.ts +0 -4
  224. package/dist/test/appHost.mock.d.ts.map +0 -1
  225. package/dist/test/appHost.mock.js +0 -59
  226. package/dist/test/appHost.mock.js.map +0 -1
  227. package/dist/test/appHost.spec.d.ts +0 -2
  228. package/dist/test/appHost.spec.d.ts.map +0 -1
  229. package/dist/test/appHost.spec.js +0 -1456
  230. package/dist/test/appHost.spec.js.map +0 -1
  231. package/dist/test/installedShellsState.spec.d.ts +0 -2
  232. package/dist/test/installedShellsState.spec.d.ts.map +0 -1
  233. package/dist/test/installedShellsState.spec.js +0 -30
  234. package/dist/test/installedShellsState.spec.js.map +0 -1
  235. package/dist/test/interceptAnyObject.spec.d.ts +0 -2
  236. package/dist/test/interceptAnyObject.spec.d.ts.map +0 -1
  237. package/dist/test/interceptAnyObject.spec.js +0 -171
  238. package/dist/test/interceptAnyObject.spec.js.map +0 -1
  239. package/dist/test/loggers.spec.d.ts +0 -2
  240. package/dist/test/loggers.spec.d.ts.map +0 -1
  241. package/dist/test/loggers.spec.js +0 -220
  242. package/dist/test/loggers.spec.js.map +0 -1
  243. package/dist/test/repluggableAppDebug.spec.d.ts +0 -2
  244. package/dist/test/repluggableAppDebug.spec.d.ts.map +0 -1
  245. package/dist/test/repluggableAppDebug.spec.js +0 -109
  246. package/dist/test/repluggableAppDebug.spec.js.map +0 -1
  247. package/dist/test/testKit.spec.d.ts +0 -2
  248. package/dist/test/testKit.spec.d.ts.map +0 -1
  249. package/dist/test/testKit.spec.js +0 -134
  250. package/dist/test/testKit.spec.js.map +0 -1
  251. package/dist/testKit/emptyLoggerOptions.d.ts +0 -3
  252. package/dist/testKit/emptyLoggerOptions.d.ts.map +0 -1
  253. package/dist/testKit/emptyLoggerOptions.js +0 -18
  254. package/dist/testKit/emptyLoggerOptions.js.map +0 -1
  255. package/dist/testKit/index.d.ts +0 -33
  256. package/dist/testKit/index.d.ts.map +0 -1
  257. package/dist/testKit/index.js +0 -160
  258. package/dist/testKit/index.js.map +0 -1
  259. package/dist/testKit/mockPackage.d.ts +0 -23
  260. package/dist/testKit/mockPackage.d.ts.map +0 -1
  261. package/dist/testKit/mockPackage.js +0 -101
  262. package/dist/testKit/mockPackage.js.map +0 -1
  263. package/dist/testKit/withConsoleErrors.d.ts +0 -2
  264. package/dist/testKit/withConsoleErrors.d.ts.map +0 -1
  265. package/dist/testKit/withConsoleErrors.js +0 -16
  266. package/dist/testKit/withConsoleErrors.js.map +0 -1
  267. package/dist/testKit/withThrowOnError.d.ts +0 -3
  268. package/dist/testKit/withThrowOnError.d.ts.map +0 -1
  269. package/dist/testKit/withThrowOnError.js +0 -31
  270. package/dist/testKit/withThrowOnError.js.map +0 -1
  271. package/jest.config.js +0 -16
  272. package/src/IterableWeakMap.ts +0 -124
  273. package/src/appHost.ts +0 -1222
  274. package/src/appHostServices.ts +0 -42
  275. package/src/appHostUtils.ts +0 -11
  276. package/src/extensionSlot.ts +0 -96
  277. package/src/hot.ts +0 -53
  278. package/src/installedShellsState.ts +0 -54
  279. package/src/interceptAnyObject.ts +0 -39
  280. package/src/invokeSlotCallbacks.ts +0 -20
  281. package/src/loggers.ts +0 -112
  282. package/src/monitorAPI.ts +0 -71
  283. package/src/repluggableAppDebug/debug.d.ts +0 -37
  284. package/src/repluggableAppDebug/index.ts +0 -1
  285. package/src/repluggableAppDebug/performanceDebugInfo.ts +0 -96
  286. package/src/repluggableAppDebug/repluggableAppDebug.ts +0 -192
  287. package/src/tarjanGraph.ts +0 -96
  288. package/src/throttledStore.ts +0 -355
  289. package/test/IterableWeakMap.spec.ts +0 -280
  290. package/test/appHost.mock.ts +0 -58
  291. package/test/appHost.spec.ts +0 -1765
  292. package/test/installedShellsState.spec.ts +0 -39
  293. package/test/interceptAnyObject.spec.ts +0 -217
  294. package/test/loggers.spec.ts +0 -288
  295. package/test/repluggableAppDebug.spec.ts +0 -118
  296. package/test/testKit.spec.tsx +0 -153
  297. package/testKit/emptyLoggerOptions.ts +0 -16
  298. package/testKit/index.ts +0 -177
  299. package/testKit/mockPackage.ts +0 -110
  300. package/testKit/withConsoleErrors.ts +0 -12
  301. package/testKit/withThrowOnError.ts +0 -34
  302. /package/dist/es/{src/__internal.d.ts → __internal.d.ts} +0 -0
@@ -1,280 +0,0 @@
1
- import { IterableWeakMap } from '../src/IterableWeakMap'
2
-
3
- describe('IterableWeakMap', () => {
4
- function runCommonTests() {
5
- describe('#constructor', () => {
6
- it('should add initial values to Map', function () {
7
- const ref = {}
8
- const value = {}
9
- const iwm = new IterableWeakMap([[ref, value]])
10
-
11
- const entries = Array.from(iwm.entries())
12
- expect(entries).toEqual([[ref, value]])
13
- })
14
- })
15
-
16
- describe('#set', () => {
17
- it('should add new value', function () {
18
- const iwm = new IterableWeakMap()
19
- const ref = {}
20
- const value = {}
21
-
22
- iwm.set(ref, value)
23
-
24
- const entries = Array.from(iwm.entries())
25
- expect(entries).toEqual([[ref, value]])
26
- })
27
- })
28
-
29
- describe('#get', () => {
30
- it('should return value if ref exists in Map', function () {
31
- const iwm = new IterableWeakMap()
32
- const ref = {}
33
- const value = {}
34
-
35
- iwm.set(ref, value)
36
-
37
- const getValue = iwm.get(ref)
38
- expect(getValue).toEqual(value)
39
- })
40
-
41
- it("should return undefined if ref doesn't exist in Map", function () {
42
- const iwm = new IterableWeakMap()
43
- const ref = {}
44
- const value = {}
45
- const ref2 = {}
46
-
47
- iwm.set(ref, value)
48
-
49
- const getValue = iwm.get(ref2)
50
- expect(getValue).toBeUndefined()
51
- })
52
- })
53
-
54
- describe('#delete', () => {
55
- it('should delete value from Map and return true', function () {
56
- const iwm = new IterableWeakMap()
57
- const ref = {}
58
- const value = {}
59
-
60
- iwm.set(ref, value)
61
-
62
- const res = iwm.delete(ref)
63
-
64
- expect(iwm.size).toBe(0)
65
- expect(res).toBeTruthy()
66
- })
67
-
68
- it('should return false if there is no ref in Map', function () {
69
- const iwm = new IterableWeakMap()
70
- const ref = {}
71
- const value = {}
72
- const refToDelete = {}
73
-
74
- iwm.set(ref, value)
75
-
76
- const res = iwm.delete(refToDelete)
77
-
78
- expect(iwm.size).toBe(1)
79
- expect(res).toBeFalsy()
80
- })
81
- })
82
-
83
- describe('#size', () => {
84
- it('should return size of Map', function () {
85
- const iwm = new IterableWeakMap()
86
- const ref = {}
87
- const value = {}
88
- const ref2 = {}
89
- const value2 = {}
90
-
91
- iwm.set(ref, value)
92
- iwm.set(ref2, value2)
93
-
94
- expect(iwm.size).toBe(2)
95
- })
96
- })
97
-
98
- describe('#has', () => {
99
- it('should return true if map has ref', function () {
100
- const iwm = new IterableWeakMap()
101
- const ref = {}
102
- const value = {}
103
-
104
- iwm.set(ref, value)
105
-
106
- expect(iwm.has(ref)).toBe(true)
107
- })
108
-
109
- it("should return false if map doesn't have ref", function () {
110
- const iwm = new IterableWeakMap()
111
- const ref = {}
112
- const value = {}
113
- const ref2 = {}
114
-
115
- iwm.set(ref, value)
116
-
117
- expect(iwm.has(ref2)).toBe(false)
118
- })
119
- })
120
-
121
- describe('#clear', () => {
122
- it('should delete all refs from Map', function () {
123
- const iwm = new IterableWeakMap()
124
- const ref = {}
125
- const value = {}
126
- const ref2 = {}
127
- const value2 = {}
128
-
129
- iwm.set(ref, value)
130
- iwm.set(ref2, value2)
131
-
132
- expect(iwm.size).toBe(2)
133
-
134
- iwm.clear()
135
-
136
- expect(iwm.size).toBe(0)
137
- })
138
- })
139
-
140
- describe('#forEach', () => {
141
- it('should iterate over all entries in Map', function () {
142
- const iwm = new IterableWeakMap()
143
- const ref = {}
144
- const value = {}
145
- const ref2 = {}
146
- const value2 = {}
147
-
148
- iwm.set(ref, value)
149
- iwm.set(ref2, value2)
150
-
151
- const res: [object, object, IterableWeakMap<any, any>][] = []
152
-
153
- iwm.forEach((v, k, map) => {
154
- res.push([v, k, map])
155
- })
156
-
157
- expect(res).toEqual([
158
- [ref, value, iwm],
159
- [ref2, value2, iwm]
160
- ])
161
- })
162
- })
163
-
164
- describe('#keys', () => {
165
- it('should return all keys in Map', function () {
166
- const iwm = new IterableWeakMap()
167
- const ref = {}
168
- const value = {}
169
- const ref2 = {}
170
- const value2 = {}
171
-
172
- iwm.set(ref, value)
173
- iwm.set(ref2, value2)
174
-
175
- const res = Array.from(iwm.keys())
176
-
177
- expect(res).toEqual([ref, ref2])
178
- })
179
- })
180
-
181
- describe('#valeus', () => {
182
- it('should return all values in Map', function () {
183
- const iwm = new IterableWeakMap()
184
- const ref = {}
185
- const value = {}
186
- const ref2 = {}
187
- const value2 = {}
188
-
189
- iwm.set(ref, value)
190
- iwm.set(ref2, value2)
191
-
192
- const res = Array.from(iwm.values())
193
-
194
- expect(res).toEqual([value, value2])
195
- })
196
- })
197
- }
198
-
199
- describe('environment supports WeakRef and FinalizationRegistry', () => {
200
- runCommonTests()
201
-
202
- describe('memory', () => {
203
- let originalFinalizationRegistry: FinalizationRegistry<any>
204
- let cleanupMemory = (ref: any) => {}
205
-
206
- beforeEach(() => {
207
- originalFinalizationRegistry = FinalizationRegistry as any
208
- globalThis.FinalizationRegistry = function (cleanupCb: (heldValue: any) => void) {
209
- const heldValueSet = new Map()
210
-
211
- cleanupMemory = ref => {
212
- const heldValue = heldValueSet.get(ref)
213
-
214
- cleanupCb(heldValue)
215
- }
216
-
217
- return {
218
- register(target: object, heldValue: any, unregisterToken?: object) {
219
- heldValueSet.set(target, heldValue)
220
- },
221
- unregister() {}
222
- } as unknown as FinalizationRegistry<any>
223
- } as any
224
- })
225
-
226
- afterEach(() => {
227
- globalThis.FinalizationRegistry = originalFinalizationRegistry as any
228
- })
229
-
230
- it('should be auto cleaned when ref in Map is freeing in program', function () {
231
- const iwm = new IterableWeakMap()
232
- const ref = {}
233
- const value = {}
234
- const ref2 = {}
235
- const value2 = {}
236
-
237
- iwm.set(ref, value)
238
- iwm.set(ref2, value2)
239
-
240
- expect(iwm.size).toBe(2)
241
- expect(Array.from(iwm.entries())).toEqual([
242
- [ref, value],
243
- [ref2, value2]
244
- ])
245
-
246
- // emulate freeing "ref" in memory
247
- cleanupMemory(ref)
248
-
249
- expect(iwm.size).toBe(1)
250
- expect(Array.from(iwm.entries())).toEqual([[ref2, value2]])
251
- })
252
- })
253
- })
254
-
255
- describe("environment doesn't support WeakRef and FinalizationRegistry", () => {
256
- let originalWeakRef: WeakRefConstructor | undefined
257
- let originalFinalizationRegistry: FinalizationRegistryConstructor | undefined
258
-
259
- beforeAll(() => {
260
- originalWeakRef = global.WeakRef
261
- // @ts-ignore
262
- delete global.WeakRef
263
- originalFinalizationRegistry = global.FinalizationRegistry
264
- // @ts-ignore
265
- delete global.FinalizationRegistry
266
- })
267
-
268
- afterAll(() => {
269
- if (originalWeakRef && originalFinalizationRegistry) {
270
- global.WeakRef = originalWeakRef
271
- originalWeakRef = undefined
272
-
273
- global.FinalizationRegistry = originalFinalizationRegistry
274
- originalFinalizationRegistry = undefined
275
- }
276
- })
277
-
278
- runCommonTests()
279
- })
280
- })
@@ -1,58 +0,0 @@
1
- import { EntryPoint, SlotKey } from '../src/API'
2
-
3
- export const createCircularEntryPoints = (usePublicAPIKeys: boolean = false): EntryPoint[] => {
4
- const MockAPI1: SlotKey<{}> = { name: 'Mock-API-1', public: usePublicAPIKeys }
5
- const MockAPI2: SlotKey<{}> = { name: 'Mock-API-2', public: usePublicAPIKeys }
6
- const MockAPI3: SlotKey<{}> = { name: 'Mock-API-3', public: usePublicAPIKeys }
7
- const MockAPI4: SlotKey<{}> = { name: 'Mock-API-4', public: usePublicAPIKeys }
8
-
9
- const ep1Deps = usePublicAPIKeys
10
- ? [
11
- { name: 'Mock-API-2', public: true },
12
- { name: 'Mock-API-3', public: true }
13
- ]
14
- : [MockAPI2, MockAPI3]
15
- const ep2Deps = usePublicAPIKeys ? [{ name: 'Mock-API-4', public: true }] : [MockAPI4]
16
- const ep3Deps = usePublicAPIKeys ? [{ name: 'Mock-API-4', public: true }] : [MockAPI4]
17
- const ep4Deps = usePublicAPIKeys ? [{ name: 'Mock-API-1', public: true }] : [MockAPI1]
18
-
19
- return [
20
- {
21
- name: 'MOCK_ENTRY_POINT_1',
22
- getDependencyAPIs: () => ep1Deps,
23
- declareAPIs: () => [MockAPI1]
24
- },
25
- {
26
- name: 'MOCK_ENTRY_POINT_2',
27
- getDependencyAPIs: () => ep2Deps,
28
- declareAPIs: () => [MockAPI2]
29
- },
30
- {
31
- name: 'MOCK_ENTRY_POINT_3',
32
- getDependencyAPIs: () => ep3Deps,
33
- declareAPIs: () => [MockAPI3]
34
- },
35
- {
36
- name: 'MOCK_ENTRY_POINT_4',
37
- getDependencyAPIs: () => ep4Deps,
38
- declareAPIs: () => [MockAPI4]
39
- }
40
- ]
41
- }
42
-
43
- export const createDirectCircularEntryPoints = (usePublicAPIKeys: boolean = false): EntryPoint[] => {
44
- const MockAPI1: SlotKey<{}> = { name: 'Mock-API-1', public: usePublicAPIKeys }
45
- const MockAPI2: SlotKey<{}> = { name: 'Mock-API-2', public: usePublicAPIKeys }
46
- return [
47
- {
48
- name: 'MOCK_ENTRY_POINT_1',
49
- getDependencyAPIs: () => [usePublicAPIKeys ? { name: 'Mock-API-2', public: true } : MockAPI2],
50
- declareAPIs: () => [MockAPI1]
51
- },
52
- {
53
- name: 'MOCK_ENTRY_POINT_2',
54
- getDependencyAPIs: () => [usePublicAPIKeys ? { name: 'Mock-API-1', public: true } : MockAPI1],
55
- declareAPIs: () => [MockAPI2]
56
- }
57
- ]
58
- }