@octostar/map-component 0.9.0 → 0.10.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.
Files changed (59) hide show
  1. package/README.md +38 -43
  2. package/dist/de-CiibAOpt.js +584 -0
  3. package/dist/de-CiibAOpt.js.map +1 -0
  4. package/dist/es-D8jViCNt.js +584 -0
  5. package/dist/es-D8jViCNt.js.map +1 -0
  6. package/dist/fr-ftr3hxY2.js +584 -0
  7. package/dist/fr-ftr3hxY2.js.map +1 -0
  8. package/dist/index.mjs +996 -638
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/it-JiSfNdMa.js +584 -0
  11. package/dist/it-JiSfNdMa.js.map +1 -0
  12. package/dist/pt-BR-DfnZxiOD.js +584 -0
  13. package/dist/pt-BR-DfnZxiOD.js.map +1 -0
  14. package/dist/pt-PT-Cvl_rDbf.js +584 -0
  15. package/dist/pt-PT-Cvl_rDbf.js.map +1 -0
  16. package/dist/types/components/cluster-pie-chart.d.ts.map +1 -1
  17. package/dist/types/components/drawing-toolbar.d.ts +1 -1
  18. package/dist/types/components/icon-picker.d.ts +1 -1
  19. package/dist/types/components/ingest-progress-overlay.d.ts +1 -1
  20. package/dist/types/components/layers-panel.d.ts +2 -2
  21. package/dist/types/components/layers-panel.d.ts.map +1 -1
  22. package/dist/types/components/map-context-menu.d.ts +1 -1
  23. package/dist/types/components/map-editor-canvas.d.ts +1 -1
  24. package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
  25. package/dist/types/components/point-icon-settings.d.ts +2 -2
  26. package/dist/types/components/properties-panel.d.ts +1 -1
  27. package/dist/types/components/properties-panel.d.ts.map +1 -1
  28. package/dist/types/components/status-indicator.d.ts +1 -1
  29. package/dist/types/components/timebar.d.ts +2 -3
  30. package/dist/types/components/timebar.d.ts.map +1 -1
  31. package/dist/types/i18n/icuContext.d.ts +10 -0
  32. package/dist/types/i18n/icuContext.d.ts.map +1 -0
  33. package/dist/types/i18n/index.d.ts +17 -0
  34. package/dist/types/i18n/index.d.ts.map +1 -0
  35. package/dist/types/i18n/locale.d.ts +12 -0
  36. package/dist/types/i18n/locale.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +1 -3
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/lib/feature-cap.d.ts +3 -24
  40. package/dist/types/lib/feature-cap.d.ts.map +1 -1
  41. package/dist/types/lib/host-icon-scale.d.ts +1 -1
  42. package/dist/types/lib/host-owned-layers.d.ts +1 -1
  43. package/dist/types/lib/ingest-pipeline.d.ts.map +1 -1
  44. package/dist/types/lib/labels/icon-labels.d.ts +33 -0
  45. package/dist/types/lib/labels/icon-labels.d.ts.map +1 -0
  46. package/dist/types/lib/labels/message-labels.d.ts +112 -0
  47. package/dist/types/lib/labels/message-labels.d.ts.map +1 -0
  48. package/dist/types/lib/labels/panel-labels.d.ts +328 -0
  49. package/dist/types/lib/labels/panel-labels.d.ts.map +1 -0
  50. package/dist/types/lib/layer-colors.d.ts +1 -1
  51. package/dist/types/lib/map-editor-api.d.ts +7 -9
  52. package/dist/types/lib/map-editor-api.d.ts.map +1 -1
  53. package/dist/types/lib/map-labels.d.ts +602 -609
  54. package/dist/types/lib/map-labels.d.ts.map +1 -1
  55. package/dist/types/lib/paint-feature.d.ts +1 -1
  56. package/dist/types/lib/shard-constants.d.ts +1 -1
  57. package/dist/types/lib/shard-fingerprint.d.ts +1 -1
  58. package/dist/types/lib/shard-pipeline.d.ts +1 -1
  59. package/package.json +18 -2
package/README.md CHANGED
@@ -65,6 +65,7 @@ This outputs:
65
65
  ```bash
66
66
  pnpm test # Vitest: pure logic in Node, no map
67
67
  pnpm test:e2e # Playwright: builds the demo app, drives the real map in Chromium
68
+ pnpm check:host-types # packs the library and type-checks a small host app (scripts/host-types) against it
68
69
  ```
69
70
 
70
71
  The e2e suite (`e2e/`) runs in CI on every PR into `main`. It clicks, drags,
@@ -141,54 +142,48 @@ Host requirements:
141
142
  />
142
143
  ```
143
144
 
144
- ### Translating the map: `labels`
145
+ ### Language: `language`
145
146
 
146
- Every string the map draws itself (panels, toolbar, menus, tooltips, toasts,
147
- confirm dialogs, icon names) comes from the `labels` prop. Without it the map
148
- is in English. A host that localizes passes a complete `MapLabels` object;
149
- `DEFAULT_MAP_LABELS` holds the English text and lists every key.
147
+ The map translates every string it draws itself (panels, toolbar, menus,
148
+ tooltips, toasts, confirm dialogs, icon names) into Italian, French, German,
149
+ Spanish, Brazilian and European Portuguese. It shows the language of:
150
+
151
+ 1. the `language` prop, a locale tag (`it`, `it-CH`, `pt-BR`), when the map
152
+ ships it;
153
+ 2. else the page's `<html lang>`, which the Octostar shell and the apps set to
154
+ the user's locale, so a host usually passes nothing;
155
+ 3. else English.
156
+
157
+ The whole tag formats numbers: `it-CH` reads the Italian catalog with Swiss
158
+ digit grouping (an apostrophe between thousands, where `it` writes `12.345`).
150
159
 
151
160
  ```tsx
152
- import { MapEditorCanvas, type MapLabels } from '@octostar/map-component';
153
-
154
- const labels: MapLabels = {
155
- layersPanel: {
156
- title: t('Layers'),
157
- groupLayerCount: count => t('{count, plural, one {# layer} other {# layers}}', { count }),
158
- // ...the group's other keys
159
- },
160
- // ...every other group
161
- };
162
-
163
- <MapEditorCanvas labels={labels} />;
161
+ <MapEditorCanvas language={userLocale} />
164
162
  ```
165
163
 
166
- - Keys are grouped by surface (`layersPanel`, `drawingToolbar`, `toasts`,
167
- `iconNames`, ...). The type requires every key, so when the map adds a
168
- string the host's typecheck fails until it supplies it. Don't spread
169
- `DEFAULT_MAP_LABELS` into it: that silences the check.
170
- - Text with runtime values is a function that returns the whole sentence;
171
- plurals are the host's to handle.
172
- - Each key has one meaning. Two keys can share English text
173
- (`navigate.searchAddress` and `navigate.goToCoordinates` are both "Go") and
174
- still take different translations.
175
- - `iconNames` is keyed by icon id. The icon picker searches the shown name as
176
- well as the English name and the id.
177
- - Layer names the map creates are stored in English whatever `labels` says:
178
- "Default Layer", "New Layer", "Loaded from workspace" and "N workspace
179
- features". Hosts match layers by name across users' maps (share links), so
180
- a stored name must not depend on who created it. Only the display follows
181
- the host: any layer whose stored name is "Default Layer" shows
182
- `labels.canvas.defaultLayerName` (matched by name, since restoring a saved
183
- map gives layers new ids); once renamed it shows its own name.
184
- - Feature text the map writes when a feature is created (a new text label's
185
- "New Label") takes `labels` at that moment and is kept as written.
186
- - **Breaking for `Timebar` hosts:** `TimebarLabels` is now `MapLabels['timebar']`,
187
- with 9 required keys (it had 4: `play`, `pause`, `reset`, `cumulative`). A
188
- host that declares a full `TimebarLabels` must add `toggle`, `featureCount`,
189
- `selectedCount`, `binEvents` and `binEventsWithSelection` before it
190
- compiles. The `Timebar` prop itself is still `labels?: Partial<TimebarLabels>`,
191
- and inside the map the Timebar uses `labels.timebar`.
164
+ Each language's catalog is a separate chunk the map fetches the first time it
165
+ shows that language; until it lands the map shows English. The map reads
166
+ `<html lang>` when it renders, so a host that switches the language without a
167
+ reload passes `language`, which the map follows at once. The map keeps its
168
+ own i18next instance, so a host's i18next (its language, its catalogs) is never
169
+ read or changed. A `Timebar` a host renders on its own follows `<html lang>`.
170
+
171
+ The catalogs live in `client/src/i18n` (gettext `po/*.po` are the source of
172
+ truth, `GLOSSARY.md` the binding terms). After adding or changing a `t()`
173
+ string, run `pnpm i18n:update`, translate the new `msgstr` in every `po/*.po`,
174
+ then `pnpm i18n:compile`; `pnpm i18n:check` and `pnpm lint:i18n` run in CI.
175
+
176
+ ### Text stored in data stays English
177
+
178
+ Layer names the map creates are stored in English in every language: "Default
179
+ Layer", "New Layer", "Loaded from workspace" and "N workspace features". Hosts
180
+ match layers by name across users' maps (share links), so a stored name must
181
+ not depend on who created it. Only the display follows the language: any layer
182
+ whose stored name is "Default Layer" shows the translated name (matched by
183
+ name, since restoring a saved map gives layers new ids); once renamed it shows
184
+ its own name. Text the map writes into a feature when it is created (a new
185
+ text label's "New Label") is in the language shown at that moment and is kept
186
+ as written.
192
187
 
193
188
  ## License
194
189