@juspay/svelte-ui-components 3.2.3 → 3.3.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.
- package/dist/deprecation.d.ts +42 -0
- package/dist/deprecation.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 2 of `docs/EVENT_CASING_MIGRATION.md`: tell a consumer, once, that a
|
|
3
|
+
* prop spelling is going away and what replaces it.
|
|
4
|
+
*
|
|
5
|
+
* Two constraints shape this.
|
|
6
|
+
*
|
|
7
|
+
* It is dev-only. A production warning is noise a consumer cannot act on
|
|
8
|
+
* mid-incident, and 142 props warning in a production console would bury real
|
|
9
|
+
* output. `import.meta.env.DEV` is the guard because it is what the bundler
|
|
10
|
+
* this library is built with statically replaces, so the whole call is removed
|
|
11
|
+
* from a production build rather than merely skipped at runtime.
|
|
12
|
+
*
|
|
13
|
+
* It warns once per component-and-prop, not once per render. A deprecated prop
|
|
14
|
+
* on a list row would otherwise warn on every one of a thousand rows, and a
|
|
15
|
+
* consumer would learn less from a thousand identical lines than from one.
|
|
16
|
+
*
|
|
17
|
+
* Internal. Nothing here is re-exported from `src/lib/index.ts`, because a
|
|
18
|
+
* consumer has no call for it: the components invoke it themselves when they
|
|
19
|
+
* are handed a deprecated spelling. That is this library's normal way of
|
|
20
|
+
* marking a module internal rather than an omission -- `src/lib/utils.ts`
|
|
21
|
+
* exports ten functions and the barrel re-exports three, leaving
|
|
22
|
+
* `getStorageItem`, `hexToRgb` and five others reachable only from inside.
|
|
23
|
+
* Exporting these two would add public API that 4.0.0 then has to keep.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The release that removes the old spellings, named in one place so the message
|
|
27
|
+
* and the migration plan cannot drift apart.
|
|
28
|
+
*
|
|
29
|
+
* 4.0.0 is a commitment, not a placeholder. An earlier draft of this string was
|
|
30
|
+
* written while #506 was expected to cut the major; it shipped inside 3.2.0 as
|
|
31
|
+
* a minor instead, which briefly left this warning promising a version nothing
|
|
32
|
+
* was committed to. `docs/EVENT_CASING_MIGRATION.md` holds the plan; a test
|
|
33
|
+
* pins this value so moving it is a deliberate edit and not a silent one.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEPRECATION_REMOVAL_VERSION = "4.0.0";
|
|
36
|
+
/**
|
|
37
|
+
* Exposed for tests. A module-level Set survives between test cases, so a
|
|
38
|
+
* second case asserting "warns once" would pass vacuously by inheriting the
|
|
39
|
+
* first case's suppression rather than by exercising it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const resetDeprecationWarnings: () => void;
|
|
42
|
+
export declare const warnDeprecatedProp: (component: string, oldName: string, newName: string) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 2 of `docs/EVENT_CASING_MIGRATION.md`: tell a consumer, once, that a
|
|
3
|
+
* prop spelling is going away and what replaces it.
|
|
4
|
+
*
|
|
5
|
+
* Two constraints shape this.
|
|
6
|
+
*
|
|
7
|
+
* It is dev-only. A production warning is noise a consumer cannot act on
|
|
8
|
+
* mid-incident, and 142 props warning in a production console would bury real
|
|
9
|
+
* output. `import.meta.env.DEV` is the guard because it is what the bundler
|
|
10
|
+
* this library is built with statically replaces, so the whole call is removed
|
|
11
|
+
* from a production build rather than merely skipped at runtime.
|
|
12
|
+
*
|
|
13
|
+
* It warns once per component-and-prop, not once per render. A deprecated prop
|
|
14
|
+
* on a list row would otherwise warn on every one of a thousand rows, and a
|
|
15
|
+
* consumer would learn less from a thousand identical lines than from one.
|
|
16
|
+
*
|
|
17
|
+
* Internal. Nothing here is re-exported from `src/lib/index.ts`, because a
|
|
18
|
+
* consumer has no call for it: the components invoke it themselves when they
|
|
19
|
+
* are handed a deprecated spelling. That is this library's normal way of
|
|
20
|
+
* marking a module internal rather than an omission -- `src/lib/utils.ts`
|
|
21
|
+
* exports ten functions and the barrel re-exports three, leaving
|
|
22
|
+
* `getStorageItem`, `hexToRgb` and five others reachable only from inside.
|
|
23
|
+
* Exporting these two would add public API that 4.0.0 then has to keep.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The release that removes the old spellings, named in one place so the message
|
|
27
|
+
* and the migration plan cannot drift apart.
|
|
28
|
+
*
|
|
29
|
+
* 4.0.0 is a commitment, not a placeholder. An earlier draft of this string was
|
|
30
|
+
* written while #506 was expected to cut the major; it shipped inside 3.2.0 as
|
|
31
|
+
* a minor instead, which briefly left this warning promising a version nothing
|
|
32
|
+
* was committed to. `docs/EVENT_CASING_MIGRATION.md` holds the plan; a test
|
|
33
|
+
* pins this value so moving it is a deliberate edit and not a silent one.
|
|
34
|
+
*/
|
|
35
|
+
export const DEPRECATION_REMOVAL_VERSION = '4.0.0';
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
/**
|
|
38
|
+
* Exposed for tests. A module-level Set survives between test cases, so a
|
|
39
|
+
* second case asserting "warns once" would pass vacuously by inheriting the
|
|
40
|
+
* first case's suppression rather than by exercising it.
|
|
41
|
+
*/
|
|
42
|
+
export const resetDeprecationWarnings = () => {
|
|
43
|
+
seen.clear();
|
|
44
|
+
};
|
|
45
|
+
export const warnDeprecatedProp = (component, oldName, newName) => {
|
|
46
|
+
if (import.meta.env.DEV !== true) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const key = `${component}.${oldName}`;
|
|
50
|
+
if (seen.has(key)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
seen.add(key);
|
|
54
|
+
console.warn(`[svelte-ui-components] \`${oldName}\` on <${component}> is deprecated and will be ` +
|
|
55
|
+
`removed in ${DEPRECATION_REMOVAL_VERSION}. Use \`${newName}\` instead — both work today. ` +
|
|
56
|
+
`Run \`npx sui-codemod --dry-run ./src\` to see every affected call site.`);
|
|
57
|
+
};
|