@wocart/theme 1.1.0 → 1.1.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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/settings.d.ts +5 -3
- package/dist/settings.js +3 -1
- package/dist/types.d.ts +3 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to `@wocart/theme` are recorded here. The package follows
|
|
|
5
5
|
major version, and an export is marked `@deprecated` for at least one minor
|
|
6
6
|
release before a major removes it.
|
|
7
7
|
|
|
8
|
+
## 1.1.1 — 2026-10-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `resolveThemeSettings` returns its values typed from the theme's
|
|
13
|
+
declaration (`InferSettings<typeof theme>`) instead of
|
|
14
|
+
`Record<string, unknown>`, as the README promised: a setting with a default
|
|
15
|
+
is a value, any other may be absent. `ThemeSettingsResult` takes the values'
|
|
16
|
+
type as an optional parameter. No runtime change.
|
|
17
|
+
|
|
8
18
|
## 1.1.0 — 2026-10-17
|
|
9
19
|
|
|
10
20
|
### Added
|
package/README.md
CHANGED
|
@@ -329,7 +329,7 @@ export const theme = defineTheme({
|
|
|
329
329
|
});
|
|
330
330
|
|
|
331
331
|
const { values, issues } = resolveThemeSettings(theme, config?.themeSettings, { locales: [locale] });
|
|
332
|
-
values.headerMenu; // "main-menu" —
|
|
332
|
+
values.headerMenu; // "main-menu" — values: InferSettings<typeof theme>, from 1.1.1
|
|
333
333
|
```
|
|
334
334
|
|
|
335
335
|
- **Reading never fails.** Each setting takes the merchant's value when the
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { ResolutionScope, ThemeDefinition, ThemeSettingsIssue, ThemeSettingsResult } from "./types.js";
|
|
1
|
+
import type { InferSettings, ResolutionScope, ThemeDefinition, ThemeSettingsIssue, ThemeSettingsResult } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* The effective settings for rendering: every declared setting, from the
|
|
4
4
|
* store's value when the declaration accepts it, else from the theme's
|
|
5
5
|
* default. `stored` is the persisted object as it arrived (anything else —
|
|
6
6
|
* null, an array — reads as no values and is reported). Translated text uses
|
|
7
|
-
* `scope.locales`; text settings may default from `scope.content`.
|
|
7
|
+
* `scope.locales`; text settings may default from `scope.content`. The
|
|
8
|
+
* values are typed from the declaration (`InferSettings<typeof theme>`): a
|
|
9
|
+
* setting with a default is always there, any other may be absent.
|
|
8
10
|
*/
|
|
9
|
-
export declare function resolveThemeSettings(theme:
|
|
11
|
+
export declare function resolveThemeSettings<T extends ThemeDefinition>(theme: T, stored: unknown, scope?: ResolutionScope): ThemeSettingsResult<InferSettings<T>>;
|
|
10
12
|
/**
|
|
11
13
|
* What a writer must check before saving a store's settings for a theme:
|
|
12
14
|
* every key declared, every value accepted by its setting — in every language
|
package/dist/settings.js
CHANGED
|
@@ -29,7 +29,9 @@ const PAGE_TO_SETTINGS = {
|
|
|
29
29
|
* store's value when the declaration accepts it, else from the theme's
|
|
30
30
|
* default. `stored` is the persisted object as it arrived (anything else —
|
|
31
31
|
* null, an array — reads as no values and is reported). Translated text uses
|
|
32
|
-
* `scope.locales`; text settings may default from `scope.content`.
|
|
32
|
+
* `scope.locales`; text settings may default from `scope.content`. The
|
|
33
|
+
* values are typed from the declaration (`InferSettings<typeof theme>`): a
|
|
34
|
+
* setting with a default is always there, any other may be absent.
|
|
33
35
|
*/
|
|
34
36
|
export function resolveThemeSettings(theme, stored, scope = {}) {
|
|
35
37
|
const issues = [];
|
package/dist/types.d.ts
CHANGED
|
@@ -449,8 +449,8 @@ export interface ThemeSettingsIssue {
|
|
|
449
449
|
message: string;
|
|
450
450
|
}
|
|
451
451
|
/** The effective settings: every value checked, the rest from the theme's defaults. */
|
|
452
|
-
export interface ThemeSettingsResult {
|
|
453
|
-
values:
|
|
452
|
+
export interface ThemeSettingsResult<V = Record<string, unknown>> {
|
|
453
|
+
values: V;
|
|
454
454
|
issues: ThemeSettingsIssue[];
|
|
455
455
|
}
|
|
456
456
|
type SettingsFieldsOf<T> = T extends {
|
|
@@ -463,8 +463,7 @@ type SettingsFieldsOf<T> = T extends {
|
|
|
463
463
|
* with a `default` is always present, any other may be absent.
|
|
464
464
|
*
|
|
465
465
|
* ```ts
|
|
466
|
-
* const { values } = resolveThemeSettings(theme, stored);
|
|
467
|
-
* const settings = values as InferSettings<typeof theme>;
|
|
466
|
+
* const { values } = resolveThemeSettings(theme, stored); // values: InferSettings<typeof theme>
|
|
468
467
|
* ```
|
|
469
468
|
*/
|
|
470
469
|
export type InferSettings<T extends ThemeDefinition> = {
|
package/package.json
CHANGED