why-hydration 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +108 -1
  2. package/README.md +220 -33
  3. package/dist/{chunk-WQLUD25W.js → chunk-3OAI2ZHY.js} +375 -118
  4. package/dist/chunk-3OAI2ZHY.js.map +1 -0
  5. package/dist/{chunk-OGQEPU7G.cjs → chunk-DXPTZB3Z.cjs} +44 -2
  6. package/dist/chunk-DXPTZB3Z.cjs.map +1 -0
  7. package/dist/{chunk-DSO337ME.cjs → chunk-KX6G7I4Y.cjs} +384 -118
  8. package/dist/chunk-KX6G7I4Y.cjs.map +1 -0
  9. package/dist/chunk-MK3TYHKM.js +966 -0
  10. package/dist/chunk-MK3TYHKM.js.map +1 -0
  11. package/dist/chunk-R7IWOK5M.cjs +989 -0
  12. package/dist/chunk-R7IWOK5M.cjs.map +1 -0
  13. package/dist/{chunk-FV3PEJQE.js → chunk-XIM33ZGB.js} +44 -2
  14. package/dist/chunk-XIM33ZGB.js.map +1 -0
  15. package/dist/index.cjs +32 -24
  16. package/dist/index.d.cts +43 -5
  17. package/dist/index.d.ts +43 -5
  18. package/dist/index.js +2 -2
  19. package/dist/next/index.cjs +5 -5
  20. package/dist/next/index.d.cts +1 -1
  21. package/dist/next/index.d.ts +1 -1
  22. package/dist/next/index.js +3 -3
  23. package/dist/next/script.cjs +2 -2
  24. package/dist/next/script.js +1 -1
  25. package/dist/react.cjs +5 -5
  26. package/dist/react.d.cts +23 -3
  27. package/dist/react.d.ts +23 -3
  28. package/dist/react.js +3 -3
  29. package/dist/{types-6wTih14e.d.cts → types-C14vcpBO.d.cts} +9 -0
  30. package/dist/{types-6wTih14e.d.ts → types-C14vcpBO.d.ts} +9 -0
  31. package/package.json +1 -1
  32. package/dist/chunk-3KULWJ7A.js +0 -569
  33. package/dist/chunk-3KULWJ7A.js.map +0 -1
  34. package/dist/chunk-5CBGYE7A.cjs +0 -592
  35. package/dist/chunk-5CBGYE7A.cjs.map +0 -1
  36. package/dist/chunk-DSO337ME.cjs.map +0 -1
  37. package/dist/chunk-FV3PEJQE.js.map +0 -1
  38. package/dist/chunk-OGQEPU7G.cjs.map +0 -1
  39. package/dist/chunk-WQLUD25W.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var chunk5CBGYE7A_cjs = require('../chunk-5CBGYE7A.cjs');
5
- require('../chunk-DSO337ME.cjs');
6
- require('../chunk-OGQEPU7G.cjs');
4
+ var chunkR7IWOK5M_cjs = require('../chunk-R7IWOK5M.cjs');
5
+ require('../chunk-KX6G7I4Y.cjs');
6
+ require('../chunk-DXPTZB3Z.cjs');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "HydrationInspector", {
11
11
  enumerable: true,
12
- get: function () { return chunk5CBGYE7A_cjs.HydrationInspector; }
12
+ get: function () { return chunkR7IWOK5M_cjs.HydrationInspector; }
13
13
  });
14
14
  Object.defineProperty(exports, "createHydrationInspector", {
15
15
  enumerable: true,
16
- get: function () { return chunk5CBGYE7A_cjs.createHydrationInspector; }
16
+ get: function () { return chunkR7IWOK5M_cjs.createHydrationInspector; }
17
17
  });
18
18
  //# sourceMappingURL=index.cjs.map
19
19
  //# sourceMappingURL=index.cjs.map
@@ -1,3 +1,3 @@
1
1
  export { HydrationInspector, HydrationInspectorHandle, HydrationInspectorProps, InspectorOptions, OverlayOptions, createHydrationInspector } from '../react.cjs';
2
- export { d as HydrationCauseCategory, H as HydrationReport } from '../types-6wTih14e.cjs';
2
+ export { d as HydrationCauseCategory, H as HydrationReport } from '../types-C14vcpBO.cjs';
3
3
  import 'react';
@@ -1,3 +1,3 @@
1
1
  export { HydrationInspector, HydrationInspectorHandle, HydrationInspectorProps, InspectorOptions, OverlayOptions, createHydrationInspector } from '../react.js';
2
- export { d as HydrationCauseCategory, H as HydrationReport } from '../types-6wTih14e.js';
2
+ export { d as HydrationCauseCategory, H as HydrationReport } from '../types-C14vcpBO.js';
3
3
  import 'react';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- export { HydrationInspector, createHydrationInspector } from '../chunk-3KULWJ7A.js';
3
- import '../chunk-WQLUD25W.js';
4
- import '../chunk-FV3PEJQE.js';
2
+ export { HydrationInspector, createHydrationInspector } from '../chunk-MK3TYHKM.js';
3
+ import '../chunk-3OAI2ZHY.js';
4
+ import '../chunk-XIM33ZGB.js';
5
5
  //# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOGQEPU7G_cjs = require('../chunk-OGQEPU7G.cjs');
3
+ var chunkDXPTZB3Z_cjs = require('../chunk-DXPTZB3Z.cjs');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopNamespace(e) {
@@ -25,7 +25,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
25
 
26
26
  function HydrationSnapshotScript(props = {}) {
27
27
  if (process.env.NODE_ENV === "production") return null;
28
- const source = chunkOGQEPU7G_cjs.getSnapshotScriptSource(props.selectors);
28
+ const source = chunkDXPTZB3Z_cjs.getSnapshotScriptSource(props.selectors);
29
29
  return React__namespace.createElement("script", {
30
30
  nonce: props.nonce,
31
31
  suppressHydrationWarning: true,
@@ -1,4 +1,4 @@
1
- import { getSnapshotScriptSource } from '../chunk-FV3PEJQE.js';
1
+ import { getSnapshotScriptSource } from '../chunk-XIM33ZGB.js';
2
2
  import * as React from 'react';
3
3
 
4
4
  function HydrationSnapshotScript(props = {}) {
package/dist/react.cjs CHANGED
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var chunk5CBGYE7A_cjs = require('./chunk-5CBGYE7A.cjs');
5
- require('./chunk-DSO337ME.cjs');
6
- require('./chunk-OGQEPU7G.cjs');
4
+ var chunkR7IWOK5M_cjs = require('./chunk-R7IWOK5M.cjs');
5
+ require('./chunk-KX6G7I4Y.cjs');
6
+ require('./chunk-DXPTZB3Z.cjs');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "HydrationInspector", {
11
11
  enumerable: true,
12
- get: function () { return chunk5CBGYE7A_cjs.HydrationInspector; }
12
+ get: function () { return chunkR7IWOK5M_cjs.HydrationInspector; }
13
13
  });
14
14
  Object.defineProperty(exports, "createHydrationInspector", {
15
15
  enumerable: true,
16
- get: function () { return chunk5CBGYE7A_cjs.createHydrationInspector; }
16
+ get: function () { return chunkR7IWOK5M_cjs.createHydrationInspector; }
17
17
  });
18
18
  //# sourceMappingURL=react.cjs.map
19
19
  //# sourceMappingURL=react.cjs.map
package/dist/react.d.cts CHANGED
@@ -1,9 +1,29 @@
1
1
  import * as React from 'react';
2
- import { H as HydrationReport, C as Classifier } from './types-6wTih14e.cjs';
3
- export { a as Cause, b as DetectionContext, D as Divergence, d as HydrationCauseCategory } from './types-6wTih14e.cjs';
2
+ import { H as HydrationReport, C as Classifier } from './types-C14vcpBO.cjs';
3
+ export { a as Cause, b as DetectionContext, D as Divergence, d as HydrationCauseCategory } from './types-C14vcpBO.cjs';
4
+
5
+ /**
6
+ * Overlay languages.
7
+ *
8
+ * The overlay speaks the page's language where it can: an Arabic page gets an
9
+ * Arabic, right-to-left panel, and everything else gets English. The engine's
10
+ * own output (`cause.explanation`, the console, `onReport`) is always English;
11
+ * only this view is translated, by looking causes up by `messageId`.
12
+ *
13
+ * Only the overlay imports this module, so it is tree-shaken out of production
14
+ * builds together with the rest of the dev implementation.
15
+ */
16
+
17
+ type OverlayLocale = 'en' | 'ar';
4
18
 
5
19
  interface OverlayOptions {
6
20
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
21
+ /**
22
+ * Language of the panel. `'auto'` (the default) follows the page's
23
+ * `<html lang>`: an Arabic page gets an Arabic, right-to-left panel and
24
+ * every other page gets English. Pass `'en'` or `'ar'` to pin it.
25
+ */
26
+ locale?: 'auto' | OverlayLocale;
7
27
  }
8
28
 
9
29
  interface InspectorOptions {
@@ -35,4 +55,4 @@ interface HydrationInspectorHandle {
35
55
  }
36
56
  declare function createHydrationInspector(options?: InspectorOptions): HydrationInspectorHandle;
37
57
 
38
- export { Classifier, HydrationInspector, type HydrationInspectorHandle, type HydrationInspectorProps, HydrationReport, type InspectorOptions, type OverlayOptions, createHydrationInspector };
58
+ export { Classifier, HydrationInspector, type HydrationInspectorHandle, type HydrationInspectorProps, HydrationReport, type InspectorOptions, type OverlayLocale, type OverlayOptions, createHydrationInspector };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,29 @@
1
1
  import * as React from 'react';
2
- import { H as HydrationReport, C as Classifier } from './types-6wTih14e.js';
3
- export { a as Cause, b as DetectionContext, D as Divergence, d as HydrationCauseCategory } from './types-6wTih14e.js';
2
+ import { H as HydrationReport, C as Classifier } from './types-C14vcpBO.js';
3
+ export { a as Cause, b as DetectionContext, D as Divergence, d as HydrationCauseCategory } from './types-C14vcpBO.js';
4
+
5
+ /**
6
+ * Overlay languages.
7
+ *
8
+ * The overlay speaks the page's language where it can: an Arabic page gets an
9
+ * Arabic, right-to-left panel, and everything else gets English. The engine's
10
+ * own output (`cause.explanation`, the console, `onReport`) is always English;
11
+ * only this view is translated, by looking causes up by `messageId`.
12
+ *
13
+ * Only the overlay imports this module, so it is tree-shaken out of production
14
+ * builds together with the rest of the dev implementation.
15
+ */
16
+
17
+ type OverlayLocale = 'en' | 'ar';
4
18
 
5
19
  interface OverlayOptions {
6
20
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
21
+ /**
22
+ * Language of the panel. `'auto'` (the default) follows the page's
23
+ * `<html lang>`: an Arabic page gets an Arabic, right-to-left panel and
24
+ * every other page gets English. Pass `'en'` or `'ar'` to pin it.
25
+ */
26
+ locale?: 'auto' | OverlayLocale;
7
27
  }
8
28
 
9
29
  interface InspectorOptions {
@@ -35,4 +55,4 @@ interface HydrationInspectorHandle {
35
55
  }
36
56
  declare function createHydrationInspector(options?: InspectorOptions): HydrationInspectorHandle;
37
57
 
38
- export { Classifier, HydrationInspector, type HydrationInspectorHandle, type HydrationInspectorProps, HydrationReport, type InspectorOptions, type OverlayOptions, createHydrationInspector };
58
+ export { Classifier, HydrationInspector, type HydrationInspectorHandle, type HydrationInspectorProps, HydrationReport, type InspectorOptions, type OverlayLocale, type OverlayOptions, createHydrationInspector };
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- export { HydrationInspector, createHydrationInspector } from './chunk-3KULWJ7A.js';
3
- import './chunk-WQLUD25W.js';
4
- import './chunk-FV3PEJQE.js';
2
+ export { HydrationInspector, createHydrationInspector } from './chunk-MK3TYHKM.js';
3
+ import './chunk-3OAI2ZHY.js';
4
+ import './chunk-XIM33ZGB.js';
5
5
  //# sourceMappingURL=react.js.map
6
6
  //# sourceMappingURL=react.js.map
@@ -14,9 +14,18 @@ interface Divergence {
14
14
  interface Cause {
15
15
  category: HydrationCauseCategory;
16
16
  confidence: number;
17
+ /** Always English — this is what the console prints and `onReport` gets. */
17
18
  explanation: string;
18
19
  suggestion: string;
19
20
  docsUrl?: string;
21
+ /**
22
+ * Which message produced `explanation`/`suggestion`, so a renderer can show
23
+ * the same cause in another language. Set by every built-in rule; custom
24
+ * classifiers may leave it out, and renderers then fall back to the English.
25
+ */
26
+ messageId?: string;
27
+ /** The values interpolated into that message (attribute names, tokens…). */
28
+ params?: Readonly<Record<string, string | readonly string[]>>;
20
29
  }
21
30
  type Classifier = (divergence: Divergence) => Cause | null;
22
31
  interface SourceLocation {
@@ -14,9 +14,18 @@ interface Divergence {
14
14
  interface Cause {
15
15
  category: HydrationCauseCategory;
16
16
  confidence: number;
17
+ /** Always English — this is what the console prints and `onReport` gets. */
17
18
  explanation: string;
18
19
  suggestion: string;
19
20
  docsUrl?: string;
21
+ /**
22
+ * Which message produced `explanation`/`suggestion`, so a renderer can show
23
+ * the same cause in another language. Set by every built-in rule; custom
24
+ * classifiers may leave it out, and renderers then fall back to the English.
25
+ */
26
+ messageId?: string;
27
+ /** The values interpolated into that message (attribute names, tokens…). */
28
+ params?: Readonly<Record<string, string | readonly string[]>>;
20
29
  }
21
30
  type Classifier = (divergence: Divergence) => Cause | null;
22
31
  interface SourceLocation {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "why-hydration",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Tells you which component broke hydration, what differed, and how to fix it — in dev, with zero production cost.",
5
5
  "license": "MIT",
6
6
  "author": "Razan Aboushi (https://www.linkedin.com/in/razan-aboushi/)",