@fedify/fedify 2.5.0-dev.2664 → 2.5.0-dev.2710

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 (266) hide show
  1. package/dist/compat/mod.d.cts +1 -1
  2. package/dist/compat/mod.d.ts +1 -1
  3. package/dist/{context-xrqq4Hrq.d.ts → context-CuLvR1Os.d.ts} +2 -2
  4. package/dist/{context-C1NqcIct.d.cts → context-apq0IBg2.d.cts} +2 -2
  5. package/dist/federation/mod.cjs +1 -1
  6. package/dist/federation/mod.d.cts +3 -3
  7. package/dist/federation/mod.d.ts +3 -3
  8. package/dist/federation/mod.js +1 -1
  9. package/dist/{federation-FbwcnRHg.cjs → federation-JvzYDx0P.cjs} +5 -5
  10. package/dist/{http-DbvOPsFZ.cjs → http-BG5cDmTS.cjs} +1 -1
  11. package/dist/{http-CWn0K5jD.js → http-MUf125Jc.js} +1 -1
  12. package/dist/{key-dwwAg5bA.d.ts → key-BZw-YiK5.d.ts} +2 -2
  13. package/dist/{key-DlHT4R6k.d.cts → key-D5fbQkKM.d.cts} +2 -2
  14. package/dist/{kv-cache-B-fOrhb-.cjs → kv-cache-A2po7h0_.cjs} +1 -1
  15. package/dist/{kv-cache-BC837EqC.js → kv-cache-CbWc1BZA.js} +1 -1
  16. package/dist/{ld-CWVpo_NM.d.cts → ld-DEi9ERHf.d.cts} +1 -1
  17. package/dist/{ld-o4LnhCYY.d.ts → ld-DlC78ioJ.d.ts} +1 -1
  18. package/dist/{middleware-n2UrG62B.js → middleware-DzzdJ7Wz.js} +5 -5
  19. package/dist/{mod-D22ZsiKi.d.ts → mod-BJRtsw7l.d.ts} +1 -1
  20. package/dist/{mod-C1nT74IG.d.cts → mod-BamwZjJx.d.cts} +1 -1
  21. package/dist/{mod-DO0epJGH.d.ts → mod-BkTi19dI.d.ts} +1 -1
  22. package/dist/{mod-CQC9xlLZ.d.ts → mod-CMtF0VVy.d.ts} +1 -1
  23. package/dist/{mod-YvA4Rk8J.d.cts → mod-D2Z9MiCm.d.cts} +1 -1
  24. package/dist/{mod-TwiQgEf3.d.cts → mod-DB2NOzQF.d.cts} +1 -1
  25. package/dist/mod.cjs +4 -4
  26. package/dist/mod.d.cts +6 -6
  27. package/dist/mod.d.ts +6 -6
  28. package/dist/mod.js +4 -4
  29. package/dist/{portable-collection-DQhIkX5a.js → portable-collection-CAer9RWN.js} +1 -1
  30. package/dist/{portable-collection-DseoiPPj.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
  31. package/dist/sig/mod.cjs +2 -2
  32. package/dist/sig/mod.d.cts +3 -3
  33. package/dist/sig/mod.d.ts +3 -3
  34. package/dist/sig/mod.js +2 -2
  35. package/dist/utils/mod.cjs +1 -1
  36. package/dist/utils/mod.d.cts +1 -1
  37. package/dist/utils/mod.d.ts +1 -1
  38. package/dist/utils/mod.js +1 -1
  39. package/package.json +22 -9
  40. package/skills/fedify/SKILL.md +10 -0
  41. package/dist/accept-CPVqki78.mjs +0 -145
  42. package/dist/activity-listener-CELFAodc.mjs +0 -44
  43. package/dist/assert-D1Eafmd_.mjs +0 -23
  44. package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
  45. package/dist/assert_exists-cffSpJ7X.mjs +0 -28
  46. package/dist/assert_false-CPdRnc3E.mjs +0 -23
  47. package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
  48. package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
  49. package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
  50. package/dist/assert_rejects-CTptdYck.mjs +0 -39
  51. package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
  52. package/dist/assert_throws-BYITOvPO.mjs +0 -74
  53. package/dist/assertion_error-B-cx0fFA.mjs +0 -31
  54. package/dist/audience-CHQ-FlLD.mjs +0 -95
  55. package/dist/builder-CGJ-NXcZ.mjs +0 -911
  56. package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
  57. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
  58. package/dist/client-5SIFzW3q.mjs +0 -441
  59. package/dist/codec-C6rTrpIp.mjs +0 -147
  60. package/dist/collection-CnnP1UAv.mjs +0 -44
  61. package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
  62. package/dist/compat/outgoing-jsonld.test.mjs +0 -257
  63. package/dist/compat/public-audience.test.d.mts +0 -2
  64. package/dist/compat/public-audience.test.mjs +0 -187
  65. package/dist/compat/secured-document.test.d.mts +0 -2
  66. package/dist/compat/secured-document.test.mjs +0 -58
  67. package/dist/compat/transformers.test.d.mts +0 -2
  68. package/dist/compat/transformers.test.mjs +0 -62
  69. package/dist/compound-proof-CnzwOddk.mjs +0 -1019
  70. package/dist/context-LgGFFSz7.mjs +0 -146
  71. package/dist/deno-eoFpPk7W.mjs +0 -8
  72. package/dist/dist-_geWsuaI.mjs +0 -189
  73. package/dist/docloader-DwkipyL1.mjs +0 -136
  74. package/dist/esm-BHXXx4Wx.mjs +0 -1233
  75. package/dist/exporter-DVG68ozH.mjs +0 -263
  76. package/dist/federation/audience.test.d.mts +0 -2
  77. package/dist/federation/audience.test.mjs +0 -130
  78. package/dist/federation/builder.test.d.mts +0 -2
  79. package/dist/federation/builder.test.mjs +0 -396
  80. package/dist/federation/circuit-breaker.test.d.mts +0 -2
  81. package/dist/federation/circuit-breaker.test.mjs +0 -1277
  82. package/dist/federation/collection.test.d.mts +0 -2
  83. package/dist/federation/collection.test.mjs +0 -21
  84. package/dist/federation/compound-fanout.test.d.mts +0 -2
  85. package/dist/federation/compound-fanout.test.mjs +0 -231
  86. package/dist/federation/handler-compound-proof.test.d.mts +0 -2
  87. package/dist/federation/handler-compound-proof.test.mjs +0 -384
  88. package/dist/federation/handler.test.d.mts +0 -2
  89. package/dist/federation/handler.test.mjs +0 -5445
  90. package/dist/federation/hashlink-media.test.d.mts +0 -2
  91. package/dist/federation/hashlink-media.test.mjs +0 -422
  92. package/dist/federation/idempotency.test.d.mts +0 -2
  93. package/dist/federation/idempotency.test.mjs +0 -207
  94. package/dist/federation/inbox-actorless.test.d.mts +0 -2
  95. package/dist/federation/inbox-actorless.test.mjs +0 -522
  96. package/dist/federation/inbox-authentication.test.d.mts +0 -2
  97. package/dist/federation/inbox-authentication.test.mjs +0 -220
  98. package/dist/federation/inbox-report.test.d.mts +0 -2
  99. package/dist/federation/inbox-report.test.mjs +0 -719
  100. package/dist/federation/inbox-view.test.d.mts +0 -2
  101. package/dist/federation/inbox-view.test.mjs +0 -369
  102. package/dist/federation/inbox.test.d.mts +0 -2
  103. package/dist/federation/inbox.test.mjs +0 -139
  104. package/dist/federation/keycache.test.d.mts +0 -2
  105. package/dist/federation/keycache.test.mjs +0 -337
  106. package/dist/federation/kv.test.d.mts +0 -2
  107. package/dist/federation/kv.test.mjs +0 -88
  108. package/dist/federation/metrics.test.d.mts +0 -2
  109. package/dist/federation/metrics.test.mjs +0 -634
  110. package/dist/federation/middleware.test.d.mts +0 -2
  111. package/dist/federation/middleware.test.mjs +0 -9314
  112. package/dist/federation/mq.test.d.mts +0 -2
  113. package/dist/federation/mq.test.mjs +0 -591
  114. package/dist/federation/negotiation.test.d.mts +0 -2
  115. package/dist/federation/negotiation.test.mjs +0 -18
  116. package/dist/federation/outbound-body.test.d.mts +0 -2
  117. package/dist/federation/outbound-body.test.mjs +0 -149
  118. package/dist/federation/outbound-capture.test.d.mts +0 -2
  119. package/dist/federation/outbound-capture.test.mjs +0 -394
  120. package/dist/federation/outbound-dispatch.test.d.mts +0 -2
  121. package/dist/federation/outbound-dispatch.test.mjs +0 -368
  122. package/dist/federation/outbound-document.test.d.mts +0 -2
  123. package/dist/federation/outbound-document.test.mjs +0 -171
  124. package/dist/federation/outbound-provenance.test.d.mts +0 -2
  125. package/dist/federation/outbound-provenance.test.mjs +0 -543
  126. package/dist/federation/outbound-report.test.d.mts +0 -2
  127. package/dist/federation/outbound-report.test.mjs +0 -5475
  128. package/dist/federation/outbound-workers.test.d.mts +0 -2
  129. package/dist/federation/outbound-workers.test.mjs +0 -64
  130. package/dist/federation/outbound-workflow.test.d.mts +0 -2
  131. package/dist/federation/outbound-workflow.test.mjs +0 -154
  132. package/dist/federation/outgoing-proof.test.d.mts +0 -2
  133. package/dist/federation/outgoing-proof.test.mjs +0 -933
  134. package/dist/federation/portable-actor.test.d.mts +0 -2
  135. package/dist/federation/portable-actor.test.mjs +0 -496
  136. package/dist/federation/portable-chain.test.d.mts +0 -2
  137. package/dist/federation/portable-chain.test.mjs +0 -370
  138. package/dist/federation/portable-collection.test.d.mts +0 -2
  139. package/dist/federation/portable-collection.test.mjs +0 -832
  140. package/dist/federation/portable-delivery.test.d.mts +0 -2
  141. package/dist/federation/portable-delivery.test.mjs +0 -845
  142. package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
  143. package/dist/federation/portable-gateway-keys.test.mjs +0 -692
  144. package/dist/federation/portable-inbox.test.d.mts +0 -2
  145. package/dist/federation/portable-inbox.test.mjs +0 -1960
  146. package/dist/federation/portable-parse-uri.test.d.mts +0 -2
  147. package/dist/federation/portable-parse-uri.test.mjs +0 -348
  148. package/dist/federation/portable-route-activity.test.d.mts +0 -2
  149. package/dist/federation/portable-route-activity.test.mjs +0 -259
  150. package/dist/federation/portable.test.d.mts +0 -2
  151. package/dist/federation/portable.test.mjs +0 -1072
  152. package/dist/federation/retry.test.d.mts +0 -2
  153. package/dist/federation/retry.test.mjs +0 -42
  154. package/dist/federation/router.test.d.mts +0 -2
  155. package/dist/federation/router.test.mjs +0 -123
  156. package/dist/federation/send.test.d.mts +0 -2
  157. package/dist/federation/send.test.mjs +0 -1421
  158. package/dist/federation/tasks/codec.test.d.mts +0 -2
  159. package/dist/federation/tasks/codec.test.mjs +0 -302
  160. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  161. package/dist/federation/tasks/enqueue.test.mjs +0 -1095
  162. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  163. package/dist/federation/tasks/tasks.test.mjs +0 -1229
  164. package/dist/federation/temporal.test.d.mts +0 -2
  165. package/dist/federation/temporal.test.mjs +0 -71
  166. package/dist/federation/webfinger.test.d.mts +0 -2
  167. package/dist/federation/webfinger.test.mjs +0 -944
  168. package/dist/http-l1zKGCll.mjs +0 -1449
  169. package/dist/inbox-CWX3EBTO.mjs +0 -399
  170. package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
  171. package/dist/inbox-view-DkPCF71K.mjs +0 -385
  172. package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
  173. package/dist/keycache-N2opu4-3.mjs +0 -221
  174. package/dist/keys-DIJNHW-Y.mjs +0 -120
  175. package/dist/kv-DBRWVx3Q.mjs +0 -104
  176. package/dist/kv-DCHkaJ9-.mjs +0 -92
  177. package/dist/kv-cache-8eJh4Xum.mjs +0 -121
  178. package/dist/ld-Cdt8qD-r.mjs +0 -1752
  179. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
  180. package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
  181. package/dist/metrics-BnfvSPj9.mjs +0 -818
  182. package/dist/middleware-CwnXJze2.mjs +0 -5
  183. package/dist/middleware-D_W_LdJN.mjs +0 -9971
  184. package/dist/mq-eF96QxUT.mjs +0 -288
  185. package/dist/negotiation-BAKO9nih.mjs +0 -96
  186. package/dist/nodeinfo/client.test.d.mts +0 -2
  187. package/dist/nodeinfo/client.test.mjs +0 -1364
  188. package/dist/nodeinfo/handler.test.d.mts +0 -2
  189. package/dist/nodeinfo/handler.test.mjs +0 -94
  190. package/dist/nodeinfo/types.test.d.mts +0 -2
  191. package/dist/nodeinfo/types.test.mjs +0 -192
  192. package/dist/otel/exporter.test.d.mts +0 -2
  193. package/dist/otel/exporter.test.mjs +0 -887
  194. package/dist/outbound-body-CckPA5gc.mjs +0 -83
  195. package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
  196. package/dist/outbound-document-BMgwLXTY.mjs +0 -179
  197. package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
  198. package/dist/owner-DukEQnv3.mjs +0 -267
  199. package/dist/portable-collection-OHaqa11n.mjs +0 -418
  200. package/dist/portable-key-BkOLJxVz.mjs +0 -549
  201. package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
  202. package/dist/proof-Y7omSVvc.mjs +0 -1420
  203. package/dist/public-audience--klBIOk1.mjs +0 -197
  204. package/dist/retry-zX5xw5e0.mjs +0 -34
  205. package/dist/router-u5O5KCQr.mjs +0 -156
  206. package/dist/secured-document-CxzZZ9nL.mjs +0 -35
  207. package/dist/send-ccQynabr.mjs +0 -710
  208. package/dist/sig/accept.test.d.mts +0 -2
  209. package/dist/sig/accept.test.mjs +0 -416
  210. package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
  211. package/dist/sig/compound-proof-discovery.test.mjs +0 -331
  212. package/dist/sig/compound-proof-producer.test.d.mts +0 -2
  213. package/dist/sig/compound-proof-producer.test.mjs +0 -107
  214. package/dist/sig/compound-proof-verification.test.d.mts +0 -2
  215. package/dist/sig/compound-proof-verification.test.mjs +0 -1017
  216. package/dist/sig/compound-proof.test.d.mts +0 -2
  217. package/dist/sig/compound-proof.test.mjs +0 -411
  218. package/dist/sig/http.test.d.mts +0 -2
  219. package/dist/sig/http.test.mjs +0 -3328
  220. package/dist/sig/key-owner-evidence.test.d.mts +0 -2
  221. package/dist/sig/key-owner-evidence.test.mjs +0 -100
  222. package/dist/sig/key.test.d.mts +0 -2
  223. package/dist/sig/key.test.mjs +0 -1250
  224. package/dist/sig/ld.test.d.mts +0 -2
  225. package/dist/sig/ld.test.mjs +0 -1044
  226. package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
  227. package/dist/sig/mitra-receive-interop.test.mjs +0 -260
  228. package/dist/sig/mitra-send-interop.test.d.mts +0 -2
  229. package/dist/sig/mitra-send-interop.test.mjs +0 -461
  230. package/dist/sig/owner.test.d.mts +0 -2
  231. package/dist/sig/owner.test.mjs +0 -202
  232. package/dist/sig/portable-collection.test.d.mts +0 -2
  233. package/dist/sig/portable-collection.test.mjs +0 -697
  234. package/dist/sig/portable-interop.test.d.mts +0 -2
  235. package/dist/sig/portable-interop.test.mjs +0 -156
  236. package/dist/sig/portable-key-id.test.d.mts +0 -2
  237. package/dist/sig/portable-key-id.test.mjs +0 -67
  238. package/dist/sig/portable-key.test.d.mts +0 -2
  239. package/dist/sig/portable-key.test.mjs +0 -1438
  240. package/dist/sig/proof.test.d.mts +0 -2
  241. package/dist/sig/proof.test.mjs +0 -2638
  242. package/dist/sig/tootik-request-interop.test.d.mts +0 -2
  243. package/dist/sig/tootik-request-interop.test.mjs +0 -190
  244. package/dist/sig/tootik-send-interop.test.d.mts +0 -2
  245. package/dist/sig/tootik-send-interop.test.mjs +0 -331
  246. package/dist/sig/verification.test.d.mts +0 -2
  247. package/dist/sig/verification.test.mjs +0 -310
  248. package/dist/std__assert-DvMDRPes.mjs +0 -8
  249. package/dist/tasks-BCUmQbbz.mjs +0 -77
  250. package/dist/temporal-f_K4lAVR.mjs +0 -95
  251. package/dist/testing/context.test.d.mts +0 -2
  252. package/dist/testing/context.test.mjs +0 -19
  253. package/dist/testing/kv.test.d.mts +0 -2
  254. package/dist/testing/kv.test.mjs +0 -101
  255. package/dist/testing/mod.d.mts +0 -6099
  256. package/dist/testing/mod.mjs +0 -9
  257. package/dist/testing-vrnD5Uaa.mjs +0 -8
  258. package/dist/types-DE_LV1JB.mjs +0 -46
  259. package/dist/utils/docloader.test.d.mts +0 -2
  260. package/dist/utils/docloader.test.mjs +0 -1076
  261. package/dist/utils/kv-cache.test.d.mts +0 -2
  262. package/dist/utils/kv-cache.test.mjs +0 -261
  263. package/dist/verification-C3954hQh.mjs +0 -5
  264. package/dist/verification-Dpfcw8ml.mjs +0 -105
  265. package/dist/vocab/cjs.test.d.mts +0 -2
  266. package/dist/vocab/cjs.test.mjs +0 -27
@@ -1,987 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { t as AssertionError } from "./assertion_error-B-cx0fFA.mjs";
5
- //#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/equal.js
6
- function isKeyedCollection(x) {
7
- return [Symbol.iterator, "size"].every((k) => k in x);
8
- }
9
- function constructorsEqual(a, b) {
10
- return a.constructor === b.constructor || a.constructor === Object && !b.constructor || !a.constructor && b.constructor === Object;
11
- }
12
- /**
13
- * Deep equality comparison used in assertions
14
- *
15
- * @param c The actual value
16
- * @param d The expected value
17
- * @returns `true` if the values are deeply equal, `false` otherwise
18
- *
19
- * @example Usage
20
- * ```ts
21
- * import { equal } from "@std/assert/equal";
22
- *
23
- * equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
24
- * equal({ foo: "bar" }, { foo: "baz" }); // Returns `false
25
- * ```
26
- */ function equal(c, d) {
27
- const seen = /* @__PURE__ */ new Map();
28
- return function compare(a, b) {
29
- if (a && b && (a instanceof RegExp && b instanceof RegExp || a instanceof URL && b instanceof URL)) return String(a) === String(b);
30
- if (a instanceof Date && b instanceof Date) {
31
- const aTime = a.getTime();
32
- const bTime = b.getTime();
33
- if (Number.isNaN(aTime) && Number.isNaN(bTime)) return true;
34
- return aTime === bTime;
35
- }
36
- if (typeof a === "number" && typeof b === "number") return Number.isNaN(a) && Number.isNaN(b) || a === b;
37
- if (Object.is(a, b)) return true;
38
- if (a && typeof a === "object" && b && typeof b === "object") {
39
- if (a && b && !constructorsEqual(a, b)) return false;
40
- if (a instanceof WeakMap || b instanceof WeakMap) {
41
- if (!(a instanceof WeakMap && b instanceof WeakMap)) return false;
42
- throw new TypeError("cannot compare WeakMap instances");
43
- }
44
- if (a instanceof WeakSet || b instanceof WeakSet) {
45
- if (!(a instanceof WeakSet && b instanceof WeakSet)) return false;
46
- throw new TypeError("cannot compare WeakSet instances");
47
- }
48
- if (a instanceof WeakRef || b instanceof WeakRef) {
49
- if (!(a instanceof WeakRef && b instanceof WeakRef)) return false;
50
- return compare(a.deref(), b.deref());
51
- }
52
- if (seen.get(a) === b) return true;
53
- if (Object.keys(a).length !== Object.keys(b).length) return false;
54
- seen.set(a, b);
55
- if (isKeyedCollection(a) && isKeyedCollection(b)) {
56
- if (a.size !== b.size) return false;
57
- let unmatchedEntries = a.size;
58
- for (const [aKey, aValue] of a.entries()) for (const [bKey, bValue] of b.entries()) if (aKey === aValue && bKey === bValue && compare(aKey, bKey) || compare(aKey, bKey) && compare(aValue, bValue)) {
59
- unmatchedEntries--;
60
- break;
61
- }
62
- return unmatchedEntries === 0;
63
- }
64
- const merged = {
65
- ...a,
66
- ...b
67
- };
68
- for (const key of [...Object.getOwnPropertyNames(merged), ...Object.getOwnPropertySymbols(merged)]) {
69
- if (!compare(a && a[key], b && b[key])) return false;
70
- if (key in a && !(key in b) || key in b && !(key in a)) return false;
71
- }
72
- return true;
73
- }
74
- return false;
75
- }(c, d);
76
- }
77
- //#endregion
78
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/format.js
79
- /**
80
- * Converts the input into a string. Objects, Sets and Maps are sorted so as to
81
- * make tests less flaky.
82
- *
83
- * @param v Value to be formatted
84
- *
85
- * @returns The formatted string
86
- *
87
- * @example Usage
88
- * ```ts
89
- * import { format } from "@std/internal/format";
90
- * import { assertEquals } from "@std/assert";
91
- *
92
- * assertEquals(format({ a: 1, b: 2 }), "{\n a: 1,\n b: 2,\n}");
93
- * assertEquals(format(new Set([1, 2])), "Set(2) {\n 1,\n 2,\n}");
94
- * assertEquals(format(new Map([[1, 2]])), "Map(1) {\n 1 => 2,\n}");
95
- * ```
96
- */ function format(v) {
97
- const { Deno } = globalThis;
98
- return typeof Deno?.inspect === "function" ? Deno.inspect(v, {
99
- depth: Infinity,
100
- sorted: true,
101
- trailingComma: true,
102
- compact: false,
103
- iterableLimit: Infinity,
104
- getters: true,
105
- strAbbreviateSize: Infinity
106
- }) : `"${String(v).replace(/(?=["\\])/g, "\\")}"`;
107
- }
108
- //#endregion
109
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/assertion_state.js
110
- /**
111
- * Check the test suite internal state
112
- *
113
- * @example Usage
114
- * ```ts ignore
115
- * import { AssertionState } from "@std/internal";
116
- *
117
- * const assertionState = new AssertionState();
118
- * ```
119
- */ var AssertionState = class {
120
- #state;
121
- constructor() {
122
- this.#state = {
123
- assertionCount: void 0,
124
- assertionCheck: false,
125
- assertionTriggered: false,
126
- assertionTriggeredCount: 0
127
- };
128
- if (typeof globalThis?.addEventListener === "function") globalThis.addEventListener("unload", () => {
129
- this.#ensureCleanedUp();
130
- });
131
- else if (typeof globalThis?.process?.on === "function") globalThis.process.on("exit", () => {
132
- this.#ensureCleanedUp();
133
- });
134
- else console.warn("AssertionCounter cleanup step was not registered");
135
- }
136
- #ensureCleanedUp() {
137
- if (this.#state.assertionCheck || this.#state.assertionCount !== void 0) throw new Error("AssertionCounter was not cleaned up: If tests are not otherwise failing, ensure `expect.hasAssertion` and `expect.assertions` are only run in bdd tests");
138
- }
139
- /**
140
- * Get the number that through `expect.assertions` api set.
141
- *
142
- * @returns the number that through `expect.assertions` api set.
143
- *
144
- * @example Usage
145
- * ```ts ignore
146
- * import { AssertionState } from "@std/internal";
147
- *
148
- * const assertionState = new AssertionState();
149
- * assertionState.assertionCount;
150
- * ```
151
- */ get assertionCount() {
152
- return this.#state.assertionCount;
153
- }
154
- /**
155
- * Get a certain number that assertions were called before.
156
- *
157
- * @returns return a certain number that assertions were called before.
158
- *
159
- * @example Usage
160
- * ```ts ignore
161
- * import { AssertionState } from "@std/internal";
162
- *
163
- * const assertionState = new AssertionState();
164
- * assertionState.assertionTriggeredCount;
165
- * ```
166
- */ get assertionTriggeredCount() {
167
- return this.#state.assertionTriggeredCount;
168
- }
169
- /**
170
- * If `expect.hasAssertions` called, then through this method to update #state.assertionCheck value.
171
- *
172
- * @param val Set #state.assertionCheck's value
173
- *
174
- * @example Usage
175
- * ```ts ignore
176
- * import { AssertionState } from "@std/internal";
177
- *
178
- * const assertionState = new AssertionState();
179
- * assertionState.setAssertionCheck(true);
180
- * ```
181
- */ setAssertionCheck(val) {
182
- this.#state.assertionCheck = val;
183
- }
184
- /**
185
- * If any matchers was called, `#state.assertionTriggered` will be set through this method.
186
- *
187
- * @param val Set #state.assertionTriggered's value
188
- *
189
- * @example Usage
190
- * ```ts ignore
191
- * import { AssertionState } from "@std/internal";
192
- *
193
- * const assertionState = new AssertionState();
194
- * assertionState.setAssertionTriggered(true);
195
- * ```
196
- */ setAssertionTriggered(val) {
197
- this.#state.assertionTriggered = val;
198
- }
199
- /**
200
- * If `expect.assertions` called, then through this method to update #state.assertionCheck value.
201
- *
202
- * @param num Set #state.assertionCount's value, for example if the value is set 2, that means
203
- * you must have two assertion matchers call in your test suite.
204
- *
205
- * @example Usage
206
- * ```ts ignore
207
- * import { AssertionState } from "@std/internal";
208
- *
209
- * const assertionState = new AssertionState();
210
- * assertionState.setAssertionCount(2);
211
- * ```
212
- */ setAssertionCount(num) {
213
- this.#state.assertionCount = num;
214
- }
215
- /**
216
- * If any matchers was called, `#state.assertionTriggeredCount` value will plus one internally.
217
- *
218
- * @example Usage
219
- * ```ts ignore
220
- * import { AssertionState } from "@std/internal";
221
- *
222
- * const assertionState = new AssertionState();
223
- * assertionState.updateAssertionTriggerCount();
224
- * ```
225
- */ updateAssertionTriggerCount() {
226
- if (this.#state.assertionCount !== void 0) this.#state.assertionTriggeredCount += 1;
227
- }
228
- /**
229
- * Check Assertion internal state, if `#state.assertionCheck` is set true, but
230
- * `#state.assertionTriggered` is still false, then should throw an Assertion Error.
231
- *
232
- * @returns a boolean value, that the test suite is satisfied with the check. If not,
233
- * it should throw an AssertionError.
234
- *
235
- * @example Usage
236
- * ```ts ignore
237
- * import { AssertionState } from "@std/internal";
238
- *
239
- * const assertionState = new AssertionState();
240
- * if (assertionState.checkAssertionErrorState()) {
241
- * // throw AssertionError("");
242
- * }
243
- * ```
244
- */ checkAssertionErrorState() {
245
- return this.#state.assertionCheck && !this.#state.assertionTriggered;
246
- }
247
- /**
248
- * Reset all assertion state when every test suite function ran completely.
249
- *
250
- * @example Usage
251
- * ```ts ignore
252
- * import { AssertionState } from "@std/internal";
253
- *
254
- * const assertionState = new AssertionState();
255
- * assertionState.resetAssertionState();
256
- * ```
257
- */ resetAssertionState() {
258
- this.#state = {
259
- assertionCount: void 0,
260
- assertionCheck: false,
261
- assertionTriggered: false,
262
- assertionTriggeredCount: 0
263
- };
264
- }
265
- /**
266
- * Check Assertion called state, if `#state.assertionCount` is set to a number value, but
267
- * `#state.assertionTriggeredCount` is less then it, then should throw an assertion error.
268
- *
269
- * @returns a boolean value, that the test suite is satisfied with the check. If not,
270
- * it should throw an AssertionError.
271
- *
272
- * @example Usage
273
- * ```ts ignore
274
- * import { AssertionState } from "@std/internal";
275
- *
276
- * const assertionState = new AssertionState();
277
- * if (assertionState.checkAssertionCountSatisfied()) {
278
- * // throw AssertionError("");
279
- * }
280
- * ```
281
- */ checkAssertionCountSatisfied() {
282
- return this.#state.assertionCount !== void 0 && this.#state.assertionCount !== this.#state.assertionTriggeredCount;
283
- }
284
- };
285
- new AssertionState();
286
- //#endregion
287
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/styles.js
288
- const { Deno } = globalThis;
289
- const enabled = !(typeof Deno?.noColor === "boolean" ? Deno.noColor : false);
290
- function code(open, close) {
291
- return {
292
- open: `\x1b[${open.join(";")}m`,
293
- close: `\x1b[${close}m`,
294
- regexp: new RegExp(`\\x1b\\[${close}m`, "g")
295
- };
296
- }
297
- function run(str, code) {
298
- return enabled ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}` : str;
299
- }
300
- /**
301
- * Sets the style of text to be printed to bold.
302
- *
303
- * Disable by setting the `NO_COLOR` environmental variable.
304
- *
305
- * @param str Text to make bold
306
- *
307
- * @returns Bold text for printing
308
- *
309
- * @example Usage
310
- * ```ts no-assert
311
- * import { bold } from "@std/internal/styles";
312
- *
313
- * console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
314
- * ```
315
- */ function bold(str) {
316
- return run(str, code([1], 22));
317
- }
318
- /**
319
- * Sets the color of text to be printed to red.
320
- *
321
- * Disable by setting the `NO_COLOR` environmental variable.
322
- *
323
- * @param str Text to make red
324
- *
325
- * @returns Red text for printing
326
- *
327
- * @example Usage
328
- * ```ts no-assert
329
- * import { red } from "@std/internal/styles";
330
- *
331
- * console.log(red("Hello, world!")); // Prints "Hello, world!" in red
332
- * ```
333
- */ function red(str) {
334
- return run(str, code([31], 39));
335
- }
336
- /**
337
- * Sets the color of text to be printed to green.
338
- *
339
- * Disable by setting the `NO_COLOR` environmental variable.
340
- *
341
- * @param str Text to make green
342
- *
343
- * @returns Green text for print
344
- *
345
- * @example Usage
346
- * ```ts no-assert
347
- * import { green } from "@std/internal/styles";
348
- *
349
- * console.log(green("Hello, world!")); // Prints "Hello, world!" in green
350
- * ```
351
- */ function green(str) {
352
- return run(str, code([32], 39));
353
- }
354
- /**
355
- * Sets the color of text to be printed to white.
356
- *
357
- * @param str Text to make white
358
- *
359
- * @returns White text for print
360
- *
361
- * @example Usage
362
- * ```ts no-assert
363
- * import { white } from "@std/internal/styles";
364
- *
365
- * console.log(white("Hello, world!")); // Prints "Hello, world!" in white
366
- * ```
367
- */ function white(str) {
368
- return run(str, code([37], 39));
369
- }
370
- /**
371
- * Sets the color of text to be printed to gray.
372
- *
373
- * @param str Text to make gray
374
- *
375
- * @returns Gray text for print
376
- *
377
- * @example Usage
378
- * ```ts no-assert
379
- * import { gray } from "@std/internal/styles";
380
- *
381
- * console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
382
- * ```
383
- */ function gray(str) {
384
- return brightBlack(str);
385
- }
386
- /**
387
- * Sets the color of text to be printed to bright-black.
388
- *
389
- * @param str Text to make bright-black
390
- *
391
- * @returns Bright-black text for print
392
- *
393
- * @example Usage
394
- * ```ts no-assert
395
- * import { brightBlack } from "@std/internal/styles";
396
- *
397
- * console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
398
- * ```
399
- */ function brightBlack(str) {
400
- return run(str, code([90], 39));
401
- }
402
- /**
403
- * Sets the background color of text to be printed to red.
404
- *
405
- * @param str Text to make its background red
406
- *
407
- * @returns Red background text for print
408
- *
409
- * @example Usage
410
- * ```ts no-assert
411
- * import { bgRed } from "@std/internal/styles";
412
- *
413
- * console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
414
- * ```
415
- */ function bgRed(str) {
416
- return run(str, code([41], 49));
417
- }
418
- /**
419
- * Sets the background color of text to be printed to green.
420
- *
421
- * @param str Text to make its background green
422
- *
423
- * @returns Green background text for print
424
- *
425
- * @example Usage
426
- * ```ts no-assert
427
- * import { bgGreen } from "@std/internal/styles";
428
- *
429
- * console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
430
- * ```
431
- */ function bgGreen(str) {
432
- return run(str, code([42], 49));
433
- }
434
- const ANSI_PATTERN = new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"), "g");
435
- /**
436
- * Remove ANSI escape codes from the string.
437
- *
438
- * @param string Text to remove ANSI escape codes from
439
- *
440
- * @returns Text without ANSI escape codes
441
- *
442
- * @example Usage
443
- * ```ts no-assert
444
- * import { red, stripAnsiCode } from "@std/internal/styles";
445
- *
446
- * console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
447
- * ```
448
- */ function stripAnsiCode(string) {
449
- return string.replace(ANSI_PATTERN, "");
450
- }
451
- //#endregion
452
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/build_message.js
453
- /**
454
- * Colors the output of assertion diffs.
455
- *
456
- * @param diffType Difference type, either added or removed.
457
- * @param background If true, colors the background instead of the text.
458
- *
459
- * @returns A function that colors the input string.
460
- *
461
- * @example Usage
462
- * ```ts
463
- * import { createColor } from "@std/internal";
464
- * import { assertEquals } from "@std/assert";
465
- * import { bold, green, red, white } from "@std/fmt/colors";
466
- *
467
- * assertEquals(createColor("added")("foo"), green(bold("foo")));
468
- * assertEquals(createColor("removed")("foo"), red(bold("foo")));
469
- * assertEquals(createColor("common")("foo"), white("foo"));
470
- * ```
471
- */ function createColor(diffType, background = false) {
472
- switch (diffType) {
473
- case "added": return (s) => background ? bgGreen(white(s)) : green(bold(s));
474
- case "removed": return (s) => background ? bgRed(white(s)) : red(bold(s));
475
- default: return white;
476
- }
477
- }
478
- /**
479
- * Prefixes `+` or `-` in diff output.
480
- *
481
- * @param diffType Difference type, either added or removed
482
- *
483
- * @returns A string representing the sign.
484
- *
485
- * @example Usage
486
- * ```ts
487
- * import { createSign } from "@std/internal";
488
- * import { assertEquals } from "@std/assert";
489
- *
490
- * assertEquals(createSign("added"), "+ ");
491
- * assertEquals(createSign("removed"), "- ");
492
- * assertEquals(createSign("common"), " ");
493
- * ```
494
- */ function createSign(diffType) {
495
- switch (diffType) {
496
- case "added": return "+ ";
497
- case "removed": return "- ";
498
- default: return " ";
499
- }
500
- }
501
- /**
502
- * Builds a message based on the provided diff result.
503
- *
504
- * @param diffResult The diff result array.
505
- * @param options Optional parameters for customizing the message.
506
- *
507
- * @returns An array of strings representing the built message.
508
- *
509
- * @example Usage
510
- * ```ts no-assert
511
- * import { diffStr, buildMessage } from "@std/internal";
512
- *
513
- * const diffResult = diffStr("Hello, world!", "Hello, world");
514
- *
515
- * console.log(buildMessage(diffResult));
516
- * // [
517
- * // "",
518
- * // "",
519
- * // " [Diff] Actual / Expected",
520
- * // "",
521
- * // "",
522
- * // "- Hello, world!",
523
- * // "+ Hello, world",
524
- * // "",
525
- * // ]
526
- * ```
527
- */ function buildMessage(diffResult, options = {}) {
528
- const { stringDiff = false } = options;
529
- const messages = [
530
- "",
531
- "",
532
- ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(bold("Expected"))}`,
533
- "",
534
- ""
535
- ];
536
- const diffMessages = diffResult.map((result) => {
537
- const color = createColor(result.type);
538
- const line = result.details?.map((detail) => detail.type !== "common" ? createColor(detail.type, true)(detail.value) : detail.value).join("") ?? result.value;
539
- return color(`${createSign(result.type)}${line}`);
540
- });
541
- messages.push(...stringDiff ? [diffMessages.join("")] : diffMessages, "");
542
- return messages;
543
- }
544
- //#endregion
545
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/diff.js
546
- const REMOVED = 1;
547
- const COMMON = 2;
548
- const ADDED = 3;
549
- /**
550
- * Creates an array of common elements between two arrays.
551
- *
552
- * @typeParam T The type of elements in the arrays.
553
- *
554
- * @param A The first array.
555
- * @param B The second array.
556
- *
557
- * @returns An array containing the common elements between the two arrays.
558
- *
559
- * @example Usage
560
- * ```ts
561
- * import { createCommon } from "@std/internal/diff";
562
- * import { assertEquals } from "@std/assert";
563
- *
564
- * const a = [1, 2, 3];
565
- * const b = [1, 2, 4];
566
- *
567
- * assertEquals(createCommon(a, b), [1, 2]);
568
- * ```
569
- */ function createCommon(A, B) {
570
- const common = [];
571
- if (A.length === 0 || B.length === 0) return [];
572
- for (let i = 0; i < Math.min(A.length, B.length); i += 1) {
573
- const a = A[i];
574
- const b = B[i];
575
- if (a !== void 0 && a === b) common.push(a);
576
- else return common;
577
- }
578
- return common;
579
- }
580
- /**
581
- * Asserts that the value is a {@linkcode FarthestPoint}.
582
- * If not, an error is thrown.
583
- *
584
- * @param value The value to check.
585
- *
586
- * @returns A void value that returns once the assertion completes.
587
- *
588
- * @example Usage
589
- * ```ts
590
- * import { assertFp } from "@std/internal/diff";
591
- * import { assertThrows } from "@std/assert";
592
- *
593
- * assertFp({ y: 0, id: 0 });
594
- * assertThrows(() => assertFp({ id: 0 }));
595
- * assertThrows(() => assertFp({ y: 0 }));
596
- * assertThrows(() => assertFp(undefined));
597
- * ```
598
- */ function assertFp(value) {
599
- if (value == null || typeof value !== "object" || typeof value?.y !== "number" || typeof value?.id !== "number") throw new Error(`Unexpected value, expected 'FarthestPoint': received ${typeof value}`);
600
- }
601
- /**
602
- * Creates an array of backtraced differences.
603
- *
604
- * @typeParam T The type of elements in the arrays.
605
- *
606
- * @param A The first array.
607
- * @param B The second array.
608
- * @param current The current {@linkcode FarthestPoint}.
609
- * @param swapped Boolean indicating if the arrays are swapped.
610
- * @param routes The routes array.
611
- * @param diffTypesPtrOffset The offset of the diff types in the routes array.
612
- *
613
- * @returns An array of backtraced differences.
614
- *
615
- * @example Usage
616
- * ```ts
617
- * import { backTrace } from "@std/internal/diff";
618
- * import { assertEquals } from "@std/assert";
619
- *
620
- * assertEquals(
621
- * backTrace([], [], { y: 0, id: 0 }, false, new Uint32Array(0), 0),
622
- * [],
623
- * );
624
- * ```
625
- */ function backTrace(A, B, current, swapped, routes, diffTypesPtrOffset) {
626
- const M = A.length;
627
- const N = B.length;
628
- const result = [];
629
- let a = M - 1;
630
- let b = N - 1;
631
- let j = routes[current.id];
632
- let type = routes[current.id + diffTypesPtrOffset];
633
- while (true) {
634
- if (!j && !type) break;
635
- const prev = j;
636
- if (type === REMOVED) {
637
- result.unshift({
638
- type: swapped ? "removed" : "added",
639
- value: B[b]
640
- });
641
- b -= 1;
642
- } else if (type === ADDED) {
643
- result.unshift({
644
- type: swapped ? "added" : "removed",
645
- value: A[a]
646
- });
647
- a -= 1;
648
- } else {
649
- result.unshift({
650
- type: "common",
651
- value: A[a]
652
- });
653
- a -= 1;
654
- b -= 1;
655
- }
656
- j = routes[prev];
657
- type = routes[prev + diffTypesPtrOffset];
658
- }
659
- return result;
660
- }
661
- /**
662
- * Creates a {@linkcode FarthestPoint}.
663
- *
664
- * @param k The current index.
665
- * @param M The length of the first array.
666
- * @param routes The routes array.
667
- * @param diffTypesPtrOffset The offset of the diff types in the routes array.
668
- * @param ptr The current pointer.
669
- * @param slide The slide {@linkcode FarthestPoint}.
670
- * @param down The down {@linkcode FarthestPoint}.
671
- *
672
- * @returns A {@linkcode FarthestPoint}.
673
- *
674
- * @example Usage
675
- * ```ts
676
- * import { createFp } from "@std/internal/diff";
677
- * import { assertEquals } from "@std/assert";
678
- *
679
- * assertEquals(
680
- * createFp(
681
- * 0,
682
- * 0,
683
- * new Uint32Array(0),
684
- * 0,
685
- * 0,
686
- * { y: -1, id: 0 },
687
- * { y: 0, id: 0 },
688
- * ),
689
- * { y: -1, id: 1 },
690
- * );
691
- * ```
692
- */ function createFp(k, M, routes, diffTypesPtrOffset, ptr, slide, down) {
693
- if (slide && slide.y === -1 && down && down.y === -1) return {
694
- y: 0,
695
- id: 0
696
- };
697
- const isAdding = down?.y === -1 || k === M || (slide?.y ?? 0) > (down?.y ?? 0) + 1;
698
- if (slide && isAdding) {
699
- const prev = slide.id;
700
- ptr++;
701
- routes[ptr] = prev;
702
- routes[ptr + diffTypesPtrOffset] = ADDED;
703
- return {
704
- y: slide.y,
705
- id: ptr
706
- };
707
- }
708
- if (down && !isAdding) {
709
- const prev = down.id;
710
- ptr++;
711
- routes[ptr] = prev;
712
- routes[ptr + diffTypesPtrOffset] = REMOVED;
713
- return {
714
- y: down.y + 1,
715
- id: ptr
716
- };
717
- }
718
- throw new Error("Unexpected missing FarthestPoint");
719
- }
720
- /**
721
- * Renders the differences between the actual and expected values.
722
- *
723
- * @typeParam T The type of elements in the arrays.
724
- *
725
- * @param A Actual value
726
- * @param B Expected value
727
- *
728
- * @returns An array of differences between the actual and expected values.
729
- *
730
- * @example Usage
731
- * ```ts
732
- * import { diff } from "@std/internal/diff";
733
- * import { assertEquals } from "@std/assert";
734
- *
735
- * const a = [1, 2, 3];
736
- * const b = [1, 2, 4];
737
- *
738
- * assertEquals(diff(a, b), [
739
- * { type: "common", value: 1 },
740
- * { type: "common", value: 2 },
741
- * { type: "removed", value: 3 },
742
- * { type: "added", value: 4 },
743
- * ]);
744
- * ```
745
- */ function diff(A, B) {
746
- const prefixCommon = createCommon(A, B);
747
- A = A.slice(prefixCommon.length);
748
- B = B.slice(prefixCommon.length);
749
- const swapped = B.length > A.length;
750
- [A, B] = swapped ? [B, A] : [A, B];
751
- const M = A.length;
752
- const N = B.length;
753
- if (!M && !N && !prefixCommon.length) return [];
754
- if (!N) return [...prefixCommon.map((value) => ({
755
- type: "common",
756
- value
757
- })), ...A.map((value) => ({
758
- type: swapped ? "added" : "removed",
759
- value
760
- }))];
761
- const offset = N;
762
- const delta = M - N;
763
- const length = M + N + 1;
764
- const fp = Array.from({ length }, () => ({
765
- y: -1,
766
- id: -1
767
- }));
768
- /**
769
- * Note: this buffer is used to save memory and improve performance. The first
770
- * half is used to save route and the last half is used to save diff type.
771
- */ const routes = new Uint32Array((M * N + length + 1) * 2);
772
- const diffTypesPtrOffset = routes.length / 2;
773
- let ptr = 0;
774
- function snake(k, A, B, slide, down) {
775
- const M = A.length;
776
- const N = B.length;
777
- const fp = createFp(k, M, routes, diffTypesPtrOffset, ptr, slide, down);
778
- ptr = fp.id;
779
- while (fp.y + k < M && fp.y < N && A[fp.y + k] === B[fp.y]) {
780
- const prev = fp.id;
781
- ptr++;
782
- fp.id = ptr;
783
- fp.y += 1;
784
- routes[ptr] = prev;
785
- routes[ptr + diffTypesPtrOffset] = COMMON;
786
- }
787
- return fp;
788
- }
789
- let currentFp = fp[delta + offset];
790
- assertFp(currentFp);
791
- let p = -1;
792
- while (currentFp.y < N) {
793
- p = p + 1;
794
- for (let k = -p; k < delta; ++k) {
795
- const index = k + offset;
796
- fp[index] = snake(k, A, B, fp[index - 1], fp[index + 1]);
797
- }
798
- for (let k = delta + p; k > delta; --k) {
799
- const index = k + offset;
800
- fp[index] = snake(k, A, B, fp[index - 1], fp[index + 1]);
801
- }
802
- const index = delta + offset;
803
- fp[delta + offset] = snake(delta, A, B, fp[index - 1], fp[index + 1]);
804
- currentFp = fp[delta + offset];
805
- assertFp(currentFp);
806
- }
807
- return [...prefixCommon.map((value) => ({
808
- type: "common",
809
- value
810
- })), ...backTrace(A, B, currentFp, swapped, routes, diffTypesPtrOffset)];
811
- }
812
- //#endregion
813
- //#region ../../node_modules/.pnpm/@jsr+std__internal@1.0.8/node_modules/@jsr/std__internal/diff_str.js
814
- /**
815
- * Unescape invisible characters.
816
- *
817
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences}
818
- *
819
- * @param string String to unescape.
820
- *
821
- * @returns Unescaped string.
822
- *
823
- * @example Usage
824
- * ```ts
825
- * import { unescape } from "@std/internal/diff-str";
826
- * import { assertEquals } from "@std/assert";
827
- *
828
- * assertEquals(unescape("Hello\nWorld"), "Hello\\n\nWorld");
829
- * ```
830
- */ function unescape(string) {
831
- return string.replaceAll("\\", "\\\\").replaceAll("\b", "\\b").replaceAll("\f", "\\f").replaceAll(" ", "\\t").replaceAll("\v", "\\v").replaceAll(/\r\n|\r|\n/g, (str) => str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n");
832
- }
833
- const WHITESPACE_SYMBOLS = /((?:\\[bftv]|[^\S\r\n])+|\\[rn\\]|[()[\]{}'"\r\n]|\b)/;
834
- /**
835
- * Tokenizes a string into an array of tokens.
836
- *
837
- * @param string The string to tokenize.
838
- * @param wordDiff If true, performs word-based tokenization. Default is false.
839
- *
840
- * @returns An array of tokens.
841
- *
842
- * @example Usage
843
- * ```ts
844
- * import { tokenize } from "@std/internal/diff-str";
845
- * import { assertEquals } from "@std/assert";
846
- *
847
- * assertEquals(tokenize("Hello\nWorld"), ["Hello\n", "World"]);
848
- * ```
849
- */ function tokenize(string, wordDiff = false) {
850
- if (wordDiff) return string.split(WHITESPACE_SYMBOLS).filter((token) => token);
851
- const tokens = [];
852
- const lines = string.split(/(\n|\r\n)/).filter((line) => line);
853
- for (const [i, line] of lines.entries()) if (i % 2) tokens[tokens.length - 1] += line;
854
- else tokens.push(line);
855
- return tokens;
856
- }
857
- /**
858
- * Create details by filtering relevant word-diff for current line and merge
859
- * "space-diff" if surrounded by word-diff for cleaner displays.
860
- *
861
- * @param line Current line
862
- * @param tokens Word-diff tokens
863
- *
864
- * @returns Array of diff results.
865
- *
866
- * @example Usage
867
- * ```ts
868
- * import { createDetails } from "@std/internal/diff-str";
869
- * import { assertEquals } from "@std/assert";
870
- *
871
- * const tokens = [
872
- * { type: "added", value: "a" },
873
- * { type: "removed", value: "b" },
874
- * { type: "common", value: "c" },
875
- * ] as const;
876
- * assertEquals(
877
- * createDetails({ type: "added", value: "a" }, [...tokens]),
878
- * [{ type: "added", value: "a" }, { type: "common", value: "c" }]
879
- * );
880
- * ```
881
- */ function createDetails(line, tokens) {
882
- return tokens.filter(({ type }) => type === line.type || type === "common").map((result, i, t) => {
883
- const token = t[i - 1];
884
- if (result.type === "common" && token && token.type === t[i + 1]?.type && /\s+/.test(result.value)) return {
885
- ...result,
886
- type: token.type
887
- };
888
- return result;
889
- });
890
- }
891
- const NON_WHITESPACE_REGEXP = /\S/;
892
- /**
893
- * Renders the differences between the actual and expected strings. Partially
894
- * inspired from {@link https://github.com/kpdecker/jsdiff}.
895
- *
896
- * @param A Actual string
897
- * @param B Expected string
898
- *
899
- * @returns Array of diff results.
900
- *
901
- * @example Usage
902
- * ```ts
903
- * import { diffStr } from "@std/internal/diff-str";
904
- * import { assertEquals } from "@std/assert";
905
- *
906
- * assertEquals(diffStr("Hello!", "Hello"), [
907
- * {
908
- * type: "removed",
909
- * value: "Hello!\n",
910
- * details: [
911
- * { type: "common", value: "Hello" },
912
- * { type: "removed", value: "!" },
913
- * { type: "common", value: "\n" }
914
- * ]
915
- * },
916
- * {
917
- * type: "added",
918
- * value: "Hello\n",
919
- * details: [
920
- * { type: "common", value: "Hello" },
921
- * { type: "common", value: "\n" }
922
- * ]
923
- * }
924
- * ]);
925
- * ```
926
- */ function diffStr(A, B) {
927
- const diffResult = diff(tokenize(`${unescape(A)}\n`), tokenize(`${unescape(B)}\n`));
928
- const added = [];
929
- const removed = [];
930
- for (const result of diffResult) {
931
- if (result.type === "added") added.push(result);
932
- if (result.type === "removed") removed.push(result);
933
- }
934
- const hasMoreRemovedLines = added.length < removed.length;
935
- const aLines = hasMoreRemovedLines ? added : removed;
936
- const bLines = hasMoreRemovedLines ? removed : added;
937
- for (const a of aLines) {
938
- let tokens = [];
939
- let b;
940
- while (bLines.length) {
941
- b = bLines.shift();
942
- const tokenized = [tokenize(a.value, true), tokenize(b.value, true)];
943
- if (hasMoreRemovedLines) tokenized.reverse();
944
- tokens = diff(tokenized[0], tokenized[1]);
945
- if (tokens.some(({ type, value }) => type === "common" && NON_WHITESPACE_REGEXP.test(value))) break;
946
- }
947
- a.details = createDetails(a, tokens);
948
- if (b) b.details = createDetails(b, tokens);
949
- }
950
- return diffResult;
951
- }
952
- //#endregion
953
- //#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_equals.js
954
- /**
955
- * Make an assertion that `actual` and `expected` are equal, deeply. If not
956
- * deeply equal, then throw.
957
- *
958
- * Type parameter can be specified to ensure values under comparison have the
959
- * same type.
960
- *
961
- * @example Usage
962
- * ```ts no-eval
963
- * import { assertEquals } from "@std/assert/assert-equals";
964
- *
965
- * assertEquals("world", "world"); // Doesn't throw
966
- * assertEquals("hello", "world"); // Throws
967
- * ```
968
- *
969
- * Note: formatter option is experimental and may be removed in the future.
970
- *
971
- * @typeParam T The type of the values to compare. This is usually inferred.
972
- * @param actual The actual value to compare.
973
- * @param expected The expected value to compare.
974
- * @param msg The optional message to display if the assertion fails.
975
- * @param options The optional object for the assertion.
976
- */ function assertEquals(actual, expected, msg) {
977
- if (equal(actual, expected)) return;
978
- let message = `Values are not equal${msg ? `: ${msg}` : "."}`;
979
- const actualString = format(actual);
980
- const expectedString = format(expected);
981
- const stringDiff = typeof actual === "string" && typeof expected === "string";
982
- const diffMsg = buildMessage(stringDiff ? diffStr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n")), { stringDiff }).join("\n");
983
- message = `${message}\n${diffMsg}`;
984
- throw new AssertionError(message);
985
- }
986
- //#endregion
987
- export { red as a, equal as c, buildMessage as i, diffStr as n, stripAnsiCode as o, diff as r, format as s, assertEquals as t };