@appdirect/sfb-toolkit 6.0.0 → 6.0.2

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 (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/agent/.cursor/rules/sfb-storefront.mdc +1 -0
  3. package/agent/.cursor/skills/sfb-custom-components/SKILL.md +1 -0
  4. package/agent/.cursor/skills/sfb-localization-settings/SKILL.md +77 -7
  5. package/agent/AGENTS.md +70 -8
  6. package/agent/CLAUDE.md +1 -0
  7. package/coverage/clover.xml +284 -266
  8. package/coverage/coverage-final.json +11 -11
  9. package/coverage/lcov-report/config/index.html +1 -1
  10. package/coverage/lcov-report/config/index.js.html +3 -3
  11. package/coverage/lcov-report/index.html +19 -19
  12. package/coverage/lcov-report/src/constants/customUserAttributesMock.js.html +1 -1
  13. package/coverage/lcov-report/src/constants/index.html +1 -1
  14. package/coverage/lcov-report/src/constants/pageUrls.js.html +1 -1
  15. package/coverage/lcov-report/src/constants/userMock.js.html +1 -1
  16. package/coverage/lcov-report/src/controllers/controllers-utils/assetsUtils.js.html +1 -1
  17. package/coverage/lcov-report/src/controllers/controllers-utils/index.html +1 -1
  18. package/coverage/lcov-report/src/controllers/controllers-utils/locale.js.html +1 -1
  19. package/coverage/lcov-report/src/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  20. package/coverage/lcov-report/src/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  21. package/coverage/lcov-report/src/controllers/data-filters/index.html +1 -1
  22. package/coverage/lcov-report/src/controllers/data-filters/media-url-filter.js.html +1 -1
  23. package/coverage/lcov-report/src/controllers/index.html +1 -1
  24. package/coverage/lcov-report/src/controllers/index.js.html +1 -1
  25. package/coverage/lcov-report/src/front-end-utils/src/components/base/ResultItem.js.html +1 -1
  26. package/coverage/lcov-report/src/front-end-utils/src/components/base/SearchBar.js.html +1 -1
  27. package/coverage/lcov-report/src/front-end-utils/src/components/base/index.html +1 -1
  28. package/coverage/lcov-report/src/front-end-utils/src/components/base/item.js.html +1 -1
  29. package/coverage/lcov-report/src/front-end-utils/src/components/container.js.html +1 -1
  30. package/coverage/lcov-report/src/front-end-utils/src/components/data-view.js.html +1 -1
  31. package/coverage/lcov-report/src/front-end-utils/src/components/header-view.js.html +1 -1
  32. package/coverage/lcov-report/src/front-end-utils/src/components/index.html +1 -1
  33. package/coverage/lcov-report/src/front-end-utils/src/components/search.js.html +1 -1
  34. package/coverage/lcov-report/src/front-end-utils/src/constants/index.html +1 -1
  35. package/coverage/lcov-report/src/front-end-utils/src/constants/pageUrl.js.html +1 -1
  36. package/coverage/lcov-report/src/front-end-utils/src/constants/roleType.js.html +1 -1
  37. package/coverage/lcov-report/src/front-end-utils/src/constants/searchType.js.html +1 -1
  38. package/coverage/lcov-report/src/front-end-utils/src/utils/debounce.js.html +1 -1
  39. package/coverage/lcov-report/src/front-end-utils/src/utils/index.html +1 -1
  40. package/coverage/lcov-report/src/middlewares/config.js.html +1 -1
  41. package/coverage/lcov-report/src/middlewares/index.html +1 -1
  42. package/coverage/lcov-report/src/routes/index.html +1 -1
  43. package/coverage/lcov-report/src/routes/media-proxy.js.html +1 -1
  44. package/coverage/lcov-report/src/tools/compile-styles.js.html +1 -1
  45. package/coverage/lcov-report/src/tools/custom-components-export-compat-loader.js.html +1 -1
  46. package/coverage/lcov-report/src/tools/index.html +19 -19
  47. package/coverage/lcov-report/src/tools/prompt-questions.js.html +32 -32
  48. package/coverage/lcov-report/src/tools/proxy-fetch.js.html +4 -4
  49. package/coverage/lcov-report/src/tools/resolve-components-react.js.html +1 -1
  50. package/coverage/lcov-report/src/tools/sass-legacy-compat.js.html +1 -1
  51. package/coverage/lcov-report/src/tools/toolkit-cli-argv.js.html +1 -1
  52. package/coverage/lcov-report/src/tools/toolkit-common-fun.js.html +280 -70
  53. package/coverage/lcov-report/src/tools/toolkit-common-vars-namespace.js.html +8 -8
  54. package/coverage/lcov-report/src/tools/toolkit-common-vars.js.html +34 -34
  55. package/coverage/lcov-report/src/tools/toolkit-components-fun.js.html +32 -32
  56. package/coverage/lcov-report/src/tools/toolkit-components-vars.js.html +25 -25
  57. package/coverage/lcov-report/src/tools/toolkit-install-agent-guidance.js.html +1 -1
  58. package/coverage/lcov-report/src/tools/toolkit-live-reload.js.html +1 -1
  59. package/coverage/lcov-report/src/tools/toolkit-path.js.html +1 -1
  60. package/coverage/lcov-report/src/tools/toolkit-spawn.js.html +13 -13
  61. package/coverage/lcov-report/src/tools/toolkit-v6-theme-risk.js.html +30 -30
  62. package/coverage/lcov-report/src/tools/toolkit-zip-utils.js.html +7 -7
  63. package/coverage/lcov.info +351 -320
  64. package/npm-shrinkwrap.json +10 -10
  65. package/package.json +3 -3
  66. package/src/tools/toolkit-common-fun.js +83 -13
  67. package/stage-publish.log +25 -0
  68. package/themes-param.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.2
4
+
5
+ Patch release. Toolkit behavior is unchanged from 6.0.1. This version exists so the package can be published again; 6.0.1 is already on npmjs.
6
+
7
+ ## 6.0.1
8
+
9
+ ### Fixes
10
+
11
+ - Custom-components metadata no longer prepends free-floating `data-custom-components-*` attributes into `base.html` when `<ad-theme>` / `data-sfb-theme-components-version` is missing; inserts or repairs a full `<ad-theme>` block instead (and strips corrupt leading attrs from older toolkit bugs)
12
+
13
+ ### AI agent guidance
14
+
15
+ - Hard rule: **all user-facing text must be localized** (never hardcode copy only in JSX, Nunjucks, or bare `settings.json` values)
16
+ - Check the **current preview locale** first (URL `/en-US/…` → usually `translations/en-us.yml`)
17
+ - Documented outside-`settings.json` localization from storefront docs: Nunjucks `{{ t(i18n.custom…) }}` / `formatMessage`, and `i18n.overrides` for page-api labels / CTA `actionType`s
18
+ - Refresh in existing workspaces with `sfb-toolkit install-agent-guidance`
19
+
3
20
  ## 6.0.0
4
21
 
5
22
  ### Upgrade notice
@@ -12,6 +12,7 @@ alwaysApply: true
12
12
  - If `themes/<active>/customComponents/` is missing, run `sfb-toolkit components` before `components-add` or `components-copy`.
13
13
  - For `components-copy`, use `.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md`, then confirm on the theme. Prefer CSS/settings/`components-add`; ask if no catalog match. No interactive no-args copy.
14
14
  - Before editing `settings.json`, call `window.__ADComponents.<Name>.schema()` in the browser (or ask the human for the output). Never invent setting keys/types.
15
+ - **All user-facing text must be localized** (React/JSX, Nunjucks, schema/`settings.json` inputs, CTA/label overrides). Put strings in theme localization YAML for the **current preview locale** (URL `/en-US/…` → usually `translations/en-us.yml`). Settings → `isLocalized: true`; templates → `{{ t(i18n.custom…) }}` / `formatMessage`; page-api labels/CTAs → `i18n.overrides`. Never hardcode display copy only in source or settings.
15
16
  - Prefer `sfb-toolkit package -a` after translation/settings changes.
16
17
  - Keep `Component.schema().name`, exports, `<component name>`, and `window.__ADComponents` keys aligned.
17
18
  - Localized settings store **keys** (`isLocalized: true`); strings live in `translations/*.yml`.
@@ -39,5 +39,6 @@ Edit under `themes/<name>/customComponents/`. Verify with `start`.
39
39
 
40
40
  - `schema().name` === index export === `<component name>` === `window.__ADComponents` key
41
41
  - **Before editing `settings.json`:** `window.__ADComponents.<Name>.schema()` in DevTools — use `form` for field names/types; never invent keys
42
+ - **All user-facing text must be localized** (including schema / settings titles, labels, buttons, and any JSX/Nunjucks copy) → `translations/<locale>.yml` for the **current preview locale** (usually `en-US` → `en-us.yml`); settings use `isLocalized: true`. See `sfb-localization-settings`.
42
43
  - Orderable ids: `Name:orderable:<uuid>` in `settings.json`
43
44
  - Overriding atoms/library comps is high risk — retest thoroughly
@@ -1,19 +1,88 @@
1
1
  ---
2
2
  name: sfb-localization-settings
3
- description: Wire storefront theme translations and settings.json defaults without conflating i18n layers or schema contracts.
3
+ description: Wire storefront theme translations for settings.json, Nunjucks i18n.custom, and i18n.overrides. All user-facing text must be localized (usually en-us.yml for /en-US previews).
4
4
  ---
5
5
 
6
6
  # Localization + settings.json
7
7
 
8
- ## Three i18n layers
8
+ ## Hard rule: all user-facing text is localized
9
9
 
10
- 1. **Theme YAML** — `translations/<lang>-<COUNTRY>.yml` (e.g. `en-us.yml`). Flat keys like `uieditor.home.….field: text`. `isLocalized: true` settings store the **key**.
11
- 2. **Schema / defaultValue keys** — `uieditor.sfbComponent.*` may appear as settings **values** pointing at UI-editor defaults (not theme YAML). To customize, add a theme YAML key and point settings at it with `isLocalized: true`.
12
- 3. **Nunjucks / page-api** — `{{ t(i18n.custom…) }}`, `i18n.overrides` (CTA by `actionType`).
10
+ **Always localize.** Headings, labels, buttons, helper text, menus, empty states, errors, Nunjucks copy, and custom-component UI must live in theme localization YAML (or the correct i18n layer below) — never hardcoded only in React/JSX, Nunjucks, or bare `settings.json` strings.
13
11
 
14
- YAML alone does not enable marketplace languages.
12
+ That includes:
15
13
 
16
- ## settings.json
14
+ - Component editor inputs (`Component.schema().form` → `settings.json`)
15
+ - Theme templates / macros / includes (Nunjucks)
16
+ - CTA and page-api label overrides
17
+
18
+ Do **not** change only the string in `settings.json` or JSX and stop.
19
+
20
+ ### Check the current locale first
21
+
22
+ 1. Look at the preview URL: `http://localhost:<port>/<locale>/…` (e.g. `/en-US/home`).
23
+ 2. Map to a file under `themes/<active>/translations/`: locale lowercased → `en-us.yml`, `fr-ca.yml`, …
24
+ 3. **Usually the locale is `en-US`** → edit **`en-us.yml`**.
25
+ 4. Add or update the translation key there; wire settings/templates to that key.
26
+
27
+ File rules: `themes/<themeName>/translations/<lang>-<country>.yml` (ISO 639-1 + ISO 3166-1). Per-theme only. YAML alone does **not** enable marketplace languages.
28
+
29
+ ## 1) Schema / settings.json text
30
+
31
+ ```json
32
+ "title": {
33
+ "value": "uieditor.home.HeroBanner:orderable:<uuid>.title",
34
+ "isLocalized": true,
35
+ "type": "TEXT"
36
+ }
37
+ ```
38
+
39
+ ```yaml
40
+ uieditor.home.HeroBanner:orderable:<uuid>.title: Find the tools your team already loves
41
+ ```
42
+
43
+ Reuse neighboring key shapes in the same YAML file.
44
+
45
+ ## 2) Outside settings — Nunjucks (`i18n.custom`)
46
+
47
+ Theme-authored template strings use nested YAML and `i18n.custom.*`:
48
+
49
+ ```yaml
50
+ home:
51
+ welcome: Welcome my friend
52
+ startingat: The product {productName} costs {startingPrice}.
53
+ comments: Posted {num, plural, one{# comment} other{# comments}}
54
+ ```
55
+
56
+ ```html
57
+ {{ t(i18n.custom.home.welcome) }}
58
+ {{ formatMessage(t(i18n.custom.home.startingat), { productName: name, startingPrice: price }) }}
59
+ {{ formatMessage(t(i18n.custom.home.comments), { num: 2 }) }}
60
+ ```
61
+
62
+ - All theme-sourced strings are under `i18n.custom…`
63
+ - Use `formatMessage` + ICU for variables and plurals (FormatJS)
64
+
65
+ ## 3) Outside settings — label / CTA overrides (`i18n.overrides`)
66
+
67
+ Relabel page-api / Data Viewer i18n objects (Plaza) or CTA buttons (Plaza + Classic) via `i18n.overrides` in the locale YAML. Discover paths with the developer toolbar Data Viewer.
68
+
69
+ ```yaml
70
+ i18n.overrides:
71
+ application.overview.i18n.featuresAndBenefits: Top features
72
+ application.overview.callToActions.view.label: See More
73
+ application.callToActions.items.BUY: Purchase
74
+ application.editions.items.callToAction.BUY: Buy this edition
75
+ ```
76
+
77
+ For CTA lists keyed by `actionType`, drop the numeric index and use the uppercase type (`BUY`, `CONFIGURE`, …) instead of `.label`.
78
+
79
+ ## Three i18n layers (do not mix)
80
+
81
+ 1. **Theme YAML** — `translations/<lang>-<COUNTRY>.yml`: `uieditor…` / menus (settings), nested `i18n.custom` (Nunjucks), `i18n.overrides` (labels/CTAs).
82
+ 2. **Schema / defaultValue keys** — `uieditor.sfbComponent.*` may appear as settings values pointing at UI-editor defaults. Customize with a theme YAML key + `isLocalized: true`.
83
+ 3. **Nunjucks / page-api wiring** — `t` / `formatMessage`; page-api `i18n.*` overridable via `i18n.overrides`.
84
+
85
+ ## settings.json contract
17
86
 
18
87
  **Required first:**
19
88
 
@@ -24,6 +93,7 @@ window.__ADComponents.<Name>.schema()
24
93
  Use `form` field names + `type` / defaults from that object. Do not invent keys.
25
94
 
26
95
  - Live values: `{ value, type }` under `pages.<page>.components`
96
+ - Text-like form fields → locale YAML + `isLocalized: true`
27
97
  - Map keys must match the HTML `id` / `Name:orderable:<uuid>`
28
98
  - `editor-properties.json` = style schema; `design-properties.json` = header/footer defaults
29
99
  - Ship with `sfb-toolkit package -a` after edits
package/agent/AGENTS.md CHANGED
@@ -13,6 +13,7 @@ This workspace is an **AppDirect Storefront Builder (SFB) toolkit project**. The
13
13
  5. **Preserve HTML structure and ABEM classnames** when restyling — public API. Prefer additive CSS.
14
14
  6. **If there is no `customComponents/` folder**, run `sfb-toolkit components` before `components-add` / `components-copy`.
15
15
  7. **Pick `components-copy` targets from the catalog, not from guesses.** Read `.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md` (export name, editor title, what it does, page). Confirm the export is on the theme (`<component name>`, `settings.json`, or `Object.keys(window.__ADComponents)`). Prefer CSS / `settings.json` / `components-add` when a fork is not required. Pass explicit names + `-r`/`-c`/`-s` — no interactive no-args copy. If nothing in the catalog matches, **ask the human**.
16
+ 8. **All user-facing text must be localized.** Never hardcode display copy in React/JSX, Nunjucks, or as a bare string-only `settings.json` value. Put strings in theme localization YAML for the **current preview locale** (URL `/en-US/…` → usually `themes/<name>/translations/en-us.yml`). Schema / `settings.json` text inputs use `isLocalized: true` + a YAML key. See Localization below.
16
17
 
17
18
  ## Toolkit commands
18
19
 
@@ -119,16 +120,77 @@ If `window.__ADComponents.<Name>` is missing, the page bundle did not load that
119
120
 
120
121
  ## Localization (three layers — do not mix)
121
122
 
122
- 1. **Theme instance content** — `themes/<name>/translations/<lang>-<COUNTRY>.yml` (e.g. `en-us.yml`, `fr-ca.yml`). Often flat dotted keys:
123
- - `uieditor.home.Slider:orderable:<uuid>.buttonLabel: Buy now`
124
- - Menu titles: `uieditor.menuItem.title.<uuid>: …`
125
- - Settings with `isLocalized: true` store the **key**, not the string: `{ "value": "uieditor.…", "isLocalized": true, "type": "TEXTAREA" }`
126
- 2. **Schema / defaultValue keys** — `uieditor.sfbComponent.*` / `uieditor.editorProperties.*`. Appear as schema titles **and** sometimes as default `settings.json` values (e.g. `"value": "uieditor.sfbComponent.footer.newsletterTitle.defaultValue"`). Those strings usually live in the localization service / UI-editor bundles, not theme YAML. To customize tenant-visible copy, prefer a **theme translation key** + `isLocalized: true` pointing at your `translations/*.yml` entry.
127
- 3. **Nunjucks / page-api** — templates may use `{{ t(i18n.custom.home.welcome) }}` or page-api `i18n.*`. Overrides: `i18n.overrides` (Data Viewer paths; CTA labels by `actionType` such as BUY).
123
+ ### Always localize (required)
128
124
 
129
- Adding YAML does **not** enable marketplace languages by itself.
125
+ **Every** user-visible string is localization content — component labels, headings, buttons, helper text, menu titles, empty states, errors, Nunjucks copy, custom-component UI. Do not ship hardcoded English (or any language) in source or settings alone.
130
126
 
131
- When changing copy: update the right layer **and** the settings/template reference.
127
+ Before editing any storefront copy:
128
+
129
+ 1. Read the **current preview locale** from the browser URL (`http://localhost:3555/en-US/home` → `en-US`).
130
+ 2. Map it to the theme file: lowercase with a hyphen → `themes/<active>/translations/en-us.yml` (same for `fr-CA` → `fr-ca.yml`).
131
+ 3. **Default assumption:** locale is **`en-US`** / file **`en-us.yml`** unless the preview URL or human says otherwise.
132
+ 4. Put new/changed strings in **that** YAML file (and wire the key from settings/template/component). Do not only edit `settings.json` or JSX.
133
+
134
+ ### Schema / `settings.json` text inputs → YAML
135
+
136
+ Editor text fields on components (titles, taglines, button labels, helper text, etc. from `Component.schema().form` and live values in `settings.json`) follow the same rule:
137
+
138
+ - Use `{ "value": "<theme.i18n.key>", "isLocalized": true, "type": "…" }` in `settings.json`.
139
+ - Add/update the matching key in the **current locale** YAML, e.g.
140
+ `uieditor.home.HeroBanner:orderable:<uuid>.title: Find the tools your team already loves`
141
+ - Never leave the display string only in `settings.json` — preview for that locale will miss or show the wrong text.
142
+ - Follow existing key patterns next to neighboring entries in the same YAML file.
143
+
144
+ ### Outside `settings.json` — Nunjucks theme strings (`i18n.custom`)
145
+
146
+ Theme template / layout copy (pages, macros, includes) is **also** localized via the same YAML files. Theme-authored strings use the `i18n.custom.*` path (nested YAML under the page/section):
147
+
148
+ ```yaml
149
+ # themes/<name>/translations/en-us.yml
150
+ home:
151
+ welcome: Welcome my friend
152
+ startingat: The product {productName} costs {startingPrice}.
153
+ comments: Posted {num, plural, one{# comment} other{# comments}}
154
+ ```
155
+
156
+ ```html
157
+ {{ t(i18n.custom.home.welcome) }}
158
+ {{ formatMessage(t(i18n.custom.home.startingat), { productName: name, startingPrice: price }) }}
159
+ {{ formatMessage(t(i18n.custom.home.comments), { num: 2 }) }}
160
+ ```
161
+
162
+ - File naming: `themes/<themeName>/translations/<lang>-<country>.yml` (ISO 639-1 + ISO 3166-1, e.g. `fr-ca.yml`).
163
+ - `formatMessage` + ICU syntax for variables and plurals (FormatJS).
164
+ - One locale file per language; translations are **per theme** (not shared across themes).
165
+ - Adding YAML does **not** enable marketplace languages by itself — marketplace language support is a separate config.
166
+
167
+ ### Outside `settings.json` — label / CTA overrides (`i18n.overrides`)
168
+
169
+ To relabel page-api / Data Viewer strings (Plaza) or CTA button text (Plaza + Classic), add an `i18n.overrides` section in the locale YAML. Find paths with the developer toolbar Data Viewer.
170
+
171
+ Examples:
172
+
173
+ ```yaml
174
+ i18n.overrides:
175
+ application.overview.i18n.featuresAndBenefits: Top features
176
+ application.overview.callToActions.fix.label: See More
177
+ application.callToActions.items.BUY: Purchase
178
+ application.editions.items.callToAction.BUY: Buy this edition
179
+ ```
180
+
181
+ For CTA items keyed by `actionType`, drop the numeric index and use the uppercase type (`BUY`, `CONFIGURE`, …) instead of `.label`.
182
+
183
+ ### Three layers
184
+
185
+ 1. **Theme instance content** — `themes/<name>/translations/<lang>-<COUNTRY>.yml` (e.g. `en-us.yml`, `fr-ca.yml`):
186
+ - Flat / dotted keys for Theme Editor + `settings.json` (`uieditor.…`, menus)
187
+ - Nested keys for Nunjucks via `{{ t(i18n.custom…) }}` / `formatMessage`
188
+ - `i18n.overrides` for page-api i18n objects and CTA labels
189
+ - Settings with `isLocalized: true` store the **key**, not the string
190
+ 2. **Schema / defaultValue keys** — `uieditor.sfbComponent.*` / `uieditor.editorProperties.*`. Appear as schema titles **and** sometimes as default `settings.json` values. Those strings usually live in the localization service / UI-editor bundles, not theme YAML. To customize tenant-visible copy, prefer a **theme translation key** + `isLocalized: true` pointing at your `translations/*.yml` entry.
191
+ 3. **Nunjucks / page-api wiring** — templates call `t` / `formatMessage`; page-api supplies `i18n.*` that overrides can replace.
192
+
193
+ When changing copy: update the right layer **and** the settings/template reference (YAML + `isLocalized` key, or YAML + `t(i18n.custom…)`, or `i18n.overrides`).
132
194
 
133
195
  ## settings.json and style contracts
134
196
 
package/agent/CLAUDE.md CHANGED
@@ -11,6 +11,7 @@ Follow **AGENTS.md** as the source of truth for this workspace (commands, theme
11
11
  - No `customComponents/` yet → run `sfb-toolkit components` before add/copy.
12
12
  - For `components-copy`, use `.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md`, confirm on theme; ask if no match. Prefer CSS/settings/`components-add`.
13
13
  - Before editing `settings.json`, call `window.__ADComponents.<Name>.schema()` in the browser (hard rule). Never invent setting keys.
14
+ - **All user-facing text must be localized** → theme `translations/<locale>.yml` for the **current preview locale** (usually `en-US` → `en-us.yml`): settings `isLocalized: true`, Nunjucks `t(i18n.custom…)` / `formatMessage`, labels/CTAs `i18n.overrides` (never hardcode copy only in JSX/settings/templates).
14
15
  - Prefer `sfb-toolkit package -a` after translation/settings changes.
15
16
  - Keep `schema().name` / export / `<component name>` / `window.__ADComponents` aligned.
16
17