Repository navigation
Commit d996c38
perf(i18n, app-shell)!: the marketplace pages' strings leave the eager language packs for a lazy
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuUBtTWuZmgP7aDAfaaeufU6)_
Fixes #30588
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no `skills/`, `.claude/` or `docs/` text names the
moved keys or teaches the pack shape (the 17 `marketplace.` hits there
are `marketplace.zod.ts` and marketplace prose)
## 维护者速读
- 改了什么:应用市场两张页面(目录页、应用详情页)用到的文案从十个语言包里搬出,放进一个按需加载的 `marketplace`
文案包;打开市场页时才下载当前语言那一份(外加英文兜底),下载完成前页面显示原有的加载骨架,下载失败显示控制台自己的「出错了 /
重试」。Studio 软件包页也会用到的那部分文案(卸载、未加载徽标、依赖缺失与协议提示)留在语言包里不动。文字本身一个字没改。
- 为什么改:#30588。控制台首屏必载的英文语言包 `i18n-locale-en` 已到 59,951 / 60,000 gz,只剩 49
字节,挡住了 #30545、#30552 两个要加市场文案的 PR;上限不许抬。现在读数 57,003,余量 2,997(合入 main 之后的
head `54db079b`)。
- 风险与回滚:只改前端与构建分组;首屏总量 2,204,342 → 2,201,442
gz,没有新增首屏块,十份市场文案、加载器和加载框架都不在首屏。直接读语言包对象的代码(包入口的
`en`、`@object-ui/i18n/locales/CODE`)不再含被搬走的键,属 TypeScript
层面的收窄,changeset 写明了迁移。回滚即还原本 PR。
-
先看:`ui/packages/i18n/src/namespaces/marketplace/index.ts`(加载与就绪判断)、`ui/packages/app-shell/src/console/marketplace/MarketplaceNamespaceGate.tsx`(页面框架)、`ui/apps/console/vite.config.ts`
的 `i18n-ns-marketplace*` 与 `marketplace-namespace-gate` 分组(为什么两组都要
`includeDependenciesRecursively: false`)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.namespaceGate-30588.test.tsx
packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts
packages/i18n/src/__tests__/marketplace-namespace-lazy.test.tsx`,预期 14
个用例全绿(中文页先骨架后中文、从不出现英文或原始键;切换语言时不误弹示例数据横幅)。
- 需要你做的:改动约 6,600 行(41 个文件,+4,338 / −2,294)(多为十个语言文件里整段搬移),超过 3,000
行人工合并线,请在席位复核通过后批准合并。
## What changes
- **A lazy `marketplace` namespace.**
`ui/packages/i18n/src/namespaces/marketplace/CODE.ts` (ten files) are
partial packs: the same shape as `src/locales/CODE.ts`, holding the
`marketplace` group cut out of that pack, text unchanged (each
language's pack merged with its catalogue is deep-equal to its pack at
`bdbaf80c`). `index.ts` loads them through ten literal `import()`s and
exports `useMarketplaceNamespace()`, `loadMarketplaceCatalogue()`,
`isMarketplaceCatalogueLoaded()`, `resolveMarketplaceLanguage()` and the
namespace constants. New published subpath
`@object-ui/i18n/namespaces/marketplace`.
- **How a page waits.** `useMarketplaceNamespace()` reads the i18next
instance react-i18next serves, works out the two catalogues the language
needs (its own, `zh-CN` served by `zh`, plus `en`, the packs'
`fallbackLng`), merges the resident ones into the instance deep and
without overwriting (a host's own `resources` win, as they do over the
packs), and answers `loading` / `ready` / `failed` with a `retry()`. It
records per instance which catalogues it installed, so a host resource
that spells one `marketplace.*` key does not stop the rest of that
language's catalogue. A catalogue the all-ten door registered
(`registerBuiltInLocales()`) is used without a fetch. A failed fetch
stays failed until `retry()` (or a later mount) asks again: no loop.
- **The page frame.** App-shell's `MarketplaceNamespaceGate` wraps the
bodies of `MarketplacePage` and `MarketplacePackagePage`: the existing
copy-free skeleton (`MarketplaceResolving`) while loading and after a
language switch, the console's resident
`console.errors.somethingWentWrong` with `console.errors.tryAgain` when
a catalogue cannot be fetched, the page once ready. The skeleton after a
language switch unmounts the page body while the visitor stays on the
page, so the frame also says when it is holding the page back
(`marketplaceFrameHolding.ts`), and `SampleDataLeaveBanner`'s unmount
cleanup asks it before raising the banner that follows an installer off
the package page.
- **What stays in the packs.** Studio's packages page
(`views/metadata-admin/PackagesPage.tsx`), outside the marketplace
route, renders `MarketplaceRowActions`, `MarketplaceNotLoaded` and the
`dependencyMissing` / `protocolCheckSkipped` readers. Their keys stay
resident in all ten packs: `marketplace.installedAdditiveNote`,
`marketplace.notLoaded.*`,
`marketplace.action.uninstall|uninstalling|details`,
`marketplace.uninstall.confirm|confirmNotLoaded|successInList|successNotLoaded`,
`marketplace.install.dependencyMissing.*`,
`marketplace.install.protocolCheckSkipped.*` (19 leaves in `en`). The
new `marketplaceNamespaceBoundary.test.ts` holds that set to what those
files read.
- **The all-ten door stays complete.** `@object-ui/i18n/locales` now
hands out each language as its pack deep-merged with its namespace
catalogue and refuses a key defined in both, so `all-locales-key-parity`
and every suite walking `builtInLocales` still walk the moved keys, and
`registerBuiltInLocales()` still makes every string resident. The
package entry's `en` is the resident pack alone.
- **The i18n gates learn the namespace.**
`check-i18n-call-site-keys.mjs` (`collectEnKeys`, hence
`check-i18n-dead-keys.mjs` too) and `check-i18n-en-drift.mjs` read
`namespaces/marketplace/CODE.ts` beside each pack, refuse a key defined
in both places, and keep the namespace file optional for fixture roots.
No other gate rule changed.
- **Chunking.** `ui/apps/console/vite.config.ts` gains
`i18n-ns-marketplace` (the loader) and ten `i18n-ns-marketplace-CODE`
groups, plus `marketplace-namespace-gate` (the frame). The loader's and
the frame's groups take `includeDependenciesRecursively: false`; the
comment there gives the two measured reasons (the default stole
`locales/registry.ts` and the preload helper into an eager loader chunk;
the frame otherwise lands in the chunk the two pages share with the
eager packages page).
- **Ceiling untouched.** `PER_CHUNK_GZIP_CEILINGS` and
`PER_CHUNK_BASELINE` are unchanged; the new reading is recorded in prose
beside `'i18n-locale-en': 60_000`. `locales/registry.ts` and the pack
file names are unchanged.
- **Changeset.** `.changeset/30588-marketplace-lazy-namespace.md`,
`@object-ui/i18n` and `@object-ui/app-shell` patch, BREAKING with its
migration, ADR-0087 `not-required (runtime-interface-only
ui/packages/i18n/src/locales/en.ts#TranslationKeys)`.
Branch: the harness-assigned `claude/project-thread-9mg01c`, not
`claude/issue-30588-*`; the card is #30588.
## Tests
- New `packages/i18n/src/__tests__/marketplace-namespace.test.ts` (56
cases): ten literal `import()` loaders and no static catalogue import
(read by the TypeScript parser); every catalogue holds only the
`marketplace` group and the probe key, no pack holds the probe key, no
leaf is in both a pack and its catalogue; the all-ten door's languages
are exactly pack plus catalogue; the entry's `en` lacks the moved keys;
language resolution; the loader refuses an unknown code and memoises.
- New `packages/i18n/src/__tests__/marketplace-namespace-lazy.test.tsx`
(5 cases, registry re-registered as packs alone): `zh-CN` answers
loading first, then every render of the probe is Chinese (no English, no
raw key) and only `zh` and `en` were fetched; a switch to `ja` waits
again; `sv` is served by `en`; a host resource for `marketplace.title`
wins and `marketplace.refresh` still arrives in Chinese; a failing `ko`
chunk answers failed once, makes no second request on its own, and
`retry()` loads it.
- New
`packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.namespaceGate-30588.test.tsx`
(4 cases, a MutationObserver records every text node the page adds): the
catalogue page in `zh-CN` and the package page in `de` show the
skeleton, then their language, and never the English text or a raw key;
an `ar` chunk that fails shows the Arabic resident error words, and Try
again fetches it and renders Arabic; on a package page with a
sample-data record from this session, a switch from `zh-CN` to `ja`
raises no banner in any language, and leaving the page raises it in
Japanese. Before the frame said it was holding, that case failed: the
switch raised the banner in Chinese while the installer was still on the
page (`expected … not to contain '"Service Desk" 中有示例数据。'`).
- New
`packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts`
(5 cases): finds every module outside `console/marketplace/` that
imports into it, holds that both pages render under the frame, and that
every `marketplace.*` key spelled by a file reachable from an ungated
door is a resident pack key.
- Gate tests: `scripts/__tests__/check-i18n-call-site-keys.test.ts` and
`check-i18n-en-drift.test.ts` gain the namespace cases (a group moved
into the namespace is no drift; a change inside it is; a key in both is
refused).
- **Ablation (the dispatch's).** With the commit in place,
`scripts/ablation-replace.mjs` replaced `MarketplacePage`'s
`MarketplaceNamespaceGate` wrapper with a bare fragment (the page no
longer loads the namespace): the frame test went red, 2 failed / 3, the
first frame reading `expected 'marketplace.titlemarketplace.subtitle…'
not to match /\bmarketplace\.[A-Za-z]/`. The same on
`MarketplacePackagePage`: 1 failed / 3. Both restored by the tool's
trap: blob equals HEAD, `git diff HEAD` empty.
- **The boundary test catches the gap it was written for.** At the packs
of `69ab56e1` (before the Studio keys went back), it failed 2 / 5,
naming the eleven `MarketplaceRowActions.tsx` keys.
## Acceptance notes
- **Bundle readings** (console `CI=true vite build`,
`apps/console/dist/eager-closure.json`): `i18n-locale-en` 59,951 at
`bdbaf80c` → 57,010 at `17e15c7f` (ceiling 60,000, headroom 49 → 2,990).
Eager closure 2,204,342 → 2,201,442 gz, 103 → 103 eager chunks with the
same names on both sides; no other chunk moved by more than 40 bytes. No
`i18n-ns-marketplace*` chunk and no `marketplace-namespace-gate` chunk
is eager. The ten catalogue chunks read 3,724 (`en`) to 5,048 (`ru`) gz
each, the loader 1,315 gz, the frame 704 gz, all lazy. The prose beside
the ceiling records 2,201,440, read at `5986ae70`; the 2 bytes are
chunk-hash noise.
- **Screenshots** (live stack, console via vite): catalogue page in
`zh-CN`
([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-catalog-zh-CN-1440.png?raw=true))
and `de`
([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-catalog-de-1440.png?raw=true));
package page in `zh-CN`
([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-package-zh-CN-1440.png?raw=true))
and `de`
([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-package-de-1440.png?raw=true)),
1440 wide. A Playwright run recorded every text node each page added on
the way: no raw `marketplace.` key and no English title or subtitle in
any of them, no page error. The language files (`zh` and `en`, `de` and
`en`) were requested only once the marketplace page opened; the dev
server serves the loader module itself at boot, since dev has no chunks
(the production readings above are the lazy ones). Shots committed at
`af733e30` and removed from the tree by the next commit; they predate
`17e15c7f`, which changes only when the sample-data banner is raised.
- **Language switch while a page is open** shows the skeleton until the
new language's catalogue lands, which unmounts the page body: a
half-filled install dialog is lost on a switch, and the page reads its
package again. Chosen over keeping the body mounted, which would show
English for a moment. The one unmount cleanup in these pages that means
the visitor left, the sample-data banner, checks the frame first (fixed
in this PR, see Tests).
- **For #30511 / PR #30595:** that card renames packs to `zh-Hans` /
`zh-Hant` / `pt-BR`; after this lands it adds the matching
`namespaces/marketplace/CODE.ts` files and loader entries (the shape
test pins one loader per `BUILT_IN_LANGUAGE_CODES` entry, so it will say
so).
- **For PR #30545 / PR #30552:** their new
`marketplace.install.preview.*` and related keys belong in the namespace
catalogues, unless Studio's packages page reads them.
## Verification
All on head `17e15c7f` unless noted. Lock readings are the lock's own
VERDICT lines.
**Re-run on `54db079b`** (origin/main merged at `64857f64`; PR #30653's
new `purgeConfirmAtMost` wording carried into
`namespaces/marketplace/<lang>.ts` in all ten languages, one test stub
for its `countLocalSampleData` read; os-dev-report 6671129796): every
pack deep-merged with its catalogue deep-equals main's pack at
`47c457b23`; console/marketplace + i18n vitest 150 files, 1980 tests
passed; ui `scripts/` 170 files, 4979 tests; `check:i18n-keys`,
`check:i18n-dead-keys`, `check-i18n-en-drift.mjs --base origin/main`
exit 0; `i18n-locale-en` 57,003 gz (headroom 2,997); 57/57 derived gates
exit 0; full dogfood 421 files, 3513 tests passed. The readings below
are the `17e15c7f` ones.
- `pnpm --dir ui exec vitest run
packages/app-shell/src/console/marketplace packages/i18n`: 150 files
passed, 1960 tests passed, 13 skipped.
- `pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin` (Studio's packages page and
the rest of that view): run with the marketplace directory at
`ae5aac72`, 780 files, 8133 passed, 1 skipped. Later commits touch only
the frame, the namespace hook, the banner and tests; the boundary test
holds that nothing outside the marketplace pages reaches them.
- `pnpm --filter @object-ui/app-shell run type-check` (source and
tests): exit 0. `pnpm --filter @object-ui/console run type-check` then
`build:plugin`: exit 0. `pnpm --filter @object-ui/i18n run type-check`:
exit 0 (no i18n source change after `f10a7fdf`).
- **Reverse check on the narrowed type** (one-off file in app-shell,
against the rebuilt `@object-ui/i18n` dist, removed after):
`en.marketplace.action.uninstall` compiled and `en.marketplace.title`
gave exactly one error, `TS2339: Property 'title' does not exist`; `git
status` clean after.
- `pnpm --dir ui run check:i18n-keys` (4,210 keys),
`check:i18n-dead-keys` (report identical to base: same 94 entries),
`node scripts/check-i18n-en-drift.mjs --base bdbaf80` (0 en values
changed): exit 0 each.
- `pnpm --dir ui check:eager-closure`, `pnpm --dir ui
check:eager-locale-catalogues`: exit 0;
`scripts/__tests__/check-eager-closure-budget.test.ts` (174): exit 0.
- `node scripts/check-adr-0087-registration.mjs --base origin/main`:
verified `runtime-interface-only` on `TranslationKeys`.
- eslint `--no-inline-config` on every changed source, test and script:
0 errors; the only warnings are pre-existing ones in the two page files.
- `node scripts/pm/dispatch-gates.mjs --commands`: 57 derived families,
the same list at `9cf51c22` and at `17e15c7f`. All 57 exit 0; `--ran`
reconciles 57 run, 0 NOT-MEASURED, 0 UNRUN. `check:dual-build-cjs-loads`
first answered PREREQUISITE NOT MET (seven root dists absent) and passed
once they were built; `pnpm --dir ui exec vitest run scripts/` passed on
`17e15c7f` (170 files, 4979 tests, 2 skipped). Re-run on `17e15c7f`
after the last commits: `check:type-check-debt`,
`check:type-check-coverage`, `check:nul-bytes`,
`check:test-source-alias`, `check:cross-package-test-inputs`,
`check:published-files`, `check:undeclared-dep-imports`,
`check:sourcemap-no-sources-content`, `check-empty-changeset`,
`check-changeset-no-major`, `check-adr-0087-registration`, all exit 0.
Outside the derived list, `pnpm --dir ui run check:new-line-citations`:
0 new citations.
- **Full dogfood** (the narrowing arm): `pnpm exec turbo run build
--filter='@objectstack/dogfood^...'` (69 tasks), then `pnpm --filter
@objectstack/dogfood test` under the lock on `17e15c7f`: exit 0, Test
Files 420 passed, 3 skipped (423); Tests 3496 passed, 36 skipped (3532).
No failure.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgXDwFw71MwSG9FKYDQ
<!-- signed: domain:ui#1 · os-sales · session_01L6bhgWn6zhNa4LL7VB1rtL
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>marketplace namespace (#30640)1 parent c17719d commit d996c38
41 files changed
Lines changed: 4339 additions & 2294 deletions
File tree
- .changeset
- ui
- apps/console
- packages
- app-shell/src/console/marketplace
- __tests__
- i18n
- src
- __tests__
- locales
- namespaces/marketplace
- scripts
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
1238 | 1278 | | |
1239 | 1279 | | |
1240 | 1280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
166 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
167 | 180 | | |
168 | 181 | | |
169 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
309 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
310 | 323 | | |
311 | 324 | | |
312 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| 49 | + | |
| 50 | + | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
| |||
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
63 | | - | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
0 commit comments