@gtkx/config 1.6.0 → 2.0.0-beta.1
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/README.md +5 -5
- package/dist/config-error.d.ts +2 -13
- package/dist/config-error.d.ts.map +1 -1
- package/dist/config-error.js +3 -53
- package/dist/config-error.js.map +1 -1
- package/dist/config.d.ts +26 -46
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +47 -92
- package/dist/config.js.map +1 -1
- package/dist/deploy.js +1 -1
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/loader.d.ts +1 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +20 -9
- package/dist/loader.js.map +1 -1
- package/dist/schema-text.d.ts +1 -2
- package/dist/schema-text.d.ts.map +1 -1
- package/dist/schema-text.js +1 -1
- package/dist/schema-text.js.map +1 -1
- package/dist/virtual.d.ts.map +1 -1
- package/dist/virtual.js +1 -2
- package/dist/virtual.js.map +1 -1
- package/package.json +10 -4
- package/src/config-error.ts +3 -76
- package/src/config.ts +59 -165
- package/src/deploy.ts +1 -1
- package/src/index.ts +0 -2
- package/src/internal.ts +1 -3
- package/src/loader.ts +32 -9
- package/src/schema-text.ts +1 -1
- package/src/virtual.ts +1 -4
- package/dist/deprecations.d.ts +0 -5
- package/dist/deprecations.d.ts.map +0 -1
- package/dist/deprecations.js +0 -97
- package/dist/deprecations.js.map +0 -1
- package/src/deprecations.ts +0 -130
package/src/deprecations.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { warn } from "@gtkx/utils";
|
|
2
|
-
import type { Config } from "./config.ts";
|
|
3
|
-
|
|
4
|
-
type DeprecationId = (typeof DEPRECATION_IDS)[number];
|
|
5
|
-
|
|
6
|
-
type FutureDeprecation = {
|
|
7
|
-
id: DeprecationId;
|
|
8
|
-
flag: keyof NonNullable<Config["future"]>;
|
|
9
|
-
change: string;
|
|
10
|
-
unchecked?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const SHOWN_ENV = "GTKX_DEPRECATIONS_SHOWN";
|
|
14
|
-
const GUIDE_URL = "https://gtkx.dev/guide/upgrading-to-2";
|
|
15
|
-
const ENTRY_COLUMN = 30;
|
|
16
|
-
const BUILD_REPORTS = " The build, not tsc, reports the specifiers still to change.";
|
|
17
|
-
const NOTHING_REPORTS = " Nothing reports this one; check the app yourself.";
|
|
18
|
-
const SILENT_SITES = " `Array.isArray` and `JSON.stringify` change silently; grep for them.";
|
|
19
|
-
|
|
20
|
-
const DEPRECATION_IDS = [
|
|
21
|
-
"gtkx-v2-byte-arrays",
|
|
22
|
-
"gtkx-v2-value-returns",
|
|
23
|
-
"gtkx-v2-finish-results",
|
|
24
|
-
"gtkx-v2-inout-returns",
|
|
25
|
-
"gtkx-v2-resource-imports",
|
|
26
|
-
"gtkx-v2-default-libraries",
|
|
27
|
-
"gtkx-v2-tree-shaking",
|
|
28
|
-
] as const;
|
|
29
|
-
|
|
30
|
-
const FUTURE_DEPRECATIONS: FutureDeprecation[] = [
|
|
31
|
-
{
|
|
32
|
-
id: "gtkx-v2-byte-arrays",
|
|
33
|
-
flag: "v2ByteArrays",
|
|
34
|
-
change: "Byte sequences come back as number[]. In 2.0 they come back as Uint8Array.",
|
|
35
|
-
unchecked: SILENT_SITES,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: "gtkx-v2-value-returns",
|
|
39
|
-
flag: "v2ValueReturns",
|
|
40
|
-
change: "Bindings that return a GValue hand back the box. In 2.0 they hand back its contents, as unknown.",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "gtkx-v2-finish-results",
|
|
44
|
-
flag: "v2FinishResults",
|
|
45
|
-
change: "Async pairs with out parameters resolve with a leading success boolean. In 2.0 it is dropped.",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: "gtkx-v2-inout-returns",
|
|
49
|
-
flag: "v2InoutReturns",
|
|
50
|
-
change: "Inout records repeat in the return value. In 2.0 the repeated entry is dropped.",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: "gtkx-v2-resource-imports",
|
|
54
|
-
flag: "v2ResourceImports",
|
|
55
|
-
change: "Assets resolve through the #data/ import map. In 2.0 they resolve through ?resource imports.",
|
|
56
|
-
unchecked: BUILD_REPORTS,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "gtkx-v2-default-libraries",
|
|
60
|
-
flag: "v2DefaultLibraries",
|
|
61
|
-
change: "Only Gtk-4.0 is bound by default. In 2.0 Adw-1 is bound alongside it.",
|
|
62
|
-
unchecked: NOTHING_REPORTS,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: "gtkx-v2-tree-shaking",
|
|
66
|
-
flag: "v2TreeShaking",
|
|
67
|
-
change:
|
|
68
|
-
"The stores register every class eagerly. " +
|
|
69
|
-
"In 2.0 each class registers itself and unused ones drop from bundles.",
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
const shownRoots: Map<string, string> = new Map();
|
|
74
|
-
|
|
75
|
-
const isSilenced = (config: Config, id: DeprecationId): boolean => (config.deprecations?.silence ?? []).includes(id);
|
|
76
|
-
|
|
77
|
-
const unsetDeprecations = (config: Config): FutureDeprecation[] =>
|
|
78
|
-
FUTURE_DEPRECATIONS.filter((deprecation) => config.future?.[deprecation.flag] !== true);
|
|
79
|
-
|
|
80
|
-
const formatSummary = (unset: number, silenced: number): string => {
|
|
81
|
-
const note = silenced === 0 ? "" : ` ${String(silenced)} of them silenced here.`;
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
`${String(unset)} of ${String(FUTURE_DEPRECATIONS.length)} future flags are unset. ` +
|
|
85
|
-
`Their behavior becomes the default in GTKX 2.0.${note}`
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const formatDeprecation = (deprecation: FutureDeprecation): string =>
|
|
90
|
-
` [${deprecation.id}]`.padEnd(ENTRY_COLUMN) +
|
|
91
|
-
`future: { ${deprecation.flag}: true }\n ${deprecation.change}` +
|
|
92
|
-
(deprecation.unchecked ?? "");
|
|
93
|
-
|
|
94
|
-
const formatAdvice = (pending: FutureDeprecation[]): string => {
|
|
95
|
-
if (pending.every((deprecation) => deprecation.unchecked === undefined)) {
|
|
96
|
-
return " Set one flag at a time and run tsc: every affected call site is a type error.";
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return " Set one flag at a time and run tsc: it reports every affected call site except where noted above.";
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const formatBlock = (unset: FutureDeprecation[], pending: FutureDeprecation[], first: FutureDeprecation): string =>
|
|
103
|
-
[
|
|
104
|
-
formatSummary(unset.length, unset.length - pending.length),
|
|
105
|
-
"",
|
|
106
|
-
...pending.flatMap((deprecation) => [formatDeprecation(deprecation), ""]),
|
|
107
|
-
formatAdvice(pending),
|
|
108
|
-
` Guide ${GUIDE_URL}`,
|
|
109
|
-
` Silence deprecations: { silence: [${JSON.stringify(first.id)}] }`,
|
|
110
|
-
].join("\n");
|
|
111
|
-
|
|
112
|
-
const hasShown = (root: string, signature: string): boolean =>
|
|
113
|
-
shownRoots.get(root) === signature || process.env[SHOWN_ENV] === signature;
|
|
114
|
-
|
|
115
|
-
const warnDeprecations = (config: Config, root: string): void => {
|
|
116
|
-
const unset = unsetDeprecations(config);
|
|
117
|
-
const pending = unset.filter((deprecation) => !isSilenced(config, deprecation.id));
|
|
118
|
-
const [first] = pending;
|
|
119
|
-
const signature = pending.map((deprecation) => deprecation.id).join(",");
|
|
120
|
-
|
|
121
|
-
if (first === undefined || hasShown(root, signature)) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
shownRoots.set(root, signature);
|
|
126
|
-
process.env[SHOWN_ENV] = signature;
|
|
127
|
-
warn(formatBlock(unset, pending, first));
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export { DEPRECATION_IDS, warnDeprecations };
|