@x-cmd/draw 0.5.5 → 0.5.7

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/dist/globe.d.ts CHANGED
@@ -2,3 +2,4 @@ export { globeProjection, globeLandPath, globeCountryPath, globeAreaPath, globeG
2
2
  export { COUNTRIES, resolveCountry, regionKey, parseRegionKey, type CountryKeys, } from './render/globe-keys.js';
3
3
  export { GLOBE_REGIONS, resolveRegion, type GlobeRegion, } from './render/globe-regions.js';
4
4
  export { resolveGlobeArea, allGlobeAreas, type GlobeArea, } from './render/globe-areas.js';
5
+ export { renderEarthGlobe, earthSceneFromUrl, type EarthScene, type EarthOpts, type EarthNode, type EarthLink, } from './render/globe-earth.js';
package/dist/globe.js CHANGED
@@ -4,3 +4,7 @@ export { globeProjection, globeLandPath, globeCountryPath, globeAreaPath, globeG
4
4
  export { COUNTRIES, resolveCountry, regionKey, parseRegionKey, } from './render/globe-keys.js';
5
5
  export { GLOBE_REGIONS, resolveRegion, } from './render/globe-regions.js';
6
6
  export { resolveGlobeArea, allGlobeAreas, } from './render/globe-areas.js';
7
+ // 地球仪那张(正射投影 + 国界 + 节点/连线)—— 底图就在上面那几个模块里,
8
+ // 放在这个入口是为了让浏览器端「要画球面就引这一个」✓
9
+ // (主入口 @x-cmd/draw/client 只给类型,不带这几百 KB 的底图 ✓)
10
+ export { renderEarthGlobe, earthSceneFromUrl, } from './render/globe-earth.js';
@@ -2,10 +2,12 @@ import { dayIso, daysInMonth, firstWeekday, isoDay, isoParts, isoWeekday } from
2
2
  import { TAB, card } from '../theme.js';
3
3
  import { esc, r2, svgDoc, TAG_RESERVE, textW, titleBlock, topLegend, trunc } from './svg.js';
4
4
  import { footerUnit, headerMeta, tipHeight, tipUnit } from './units.js';
5
+ import { BASELINE } from '../styles/baseline.js';
5
6
  const PAD = 24;
6
7
  const HEAD_FS = 12;
7
8
  const NUM_FS = 13;
8
- const EV_FS = 12;
9
+ // 事件名/节日名:跟基准表走(13 —— 读者上了年纪,12 读不清)
10
+ const EV_FS = BASELINE.eventName;
9
11
  /** 事件类别 → 色板序号 + 名字(中英) */
10
12
  const KINDS = {
11
13
  work: { c: 1, zh: '工作', en: 'Work' },
@@ -2,6 +2,7 @@
2
2
  import { FONT, TAB } from '../theme.js';
3
3
  import { ticks as d3Ticks, tickStep } from 'd3-array';
4
4
  import { ApiError } from '../specs/base.js';
5
+ import { BASELINE } from '../styles/baseline.js';
5
6
  import { INTER_WIDTHS } from '../styles/inter.js';
6
7
  import { isSlot } from '../styles/types.js';
7
8
  export function esc(s) {
@@ -123,7 +124,7 @@ export function topLegend(items, x, y, anchor = 'right', shape = 'circle') {
123
124
  for (const it of items) {
124
125
  const w = textW(it.name, 12);
125
126
  parts.push(swatch(cx, it.color, it.index));
126
- parts.push(`<text x="${r2(cx + gap)}" y="${r2(y)}" font-size="12" font-weight="500" fill="var(--d-text)"${lg(it.index)}>${esc(it.name)}</text>`);
127
+ parts.push(`<text x="${r2(cx + gap)}" y="${r2(y)}" font-size="${BASELINE.legend}" font-weight="500" fill="var(--d-text)"${lg(it.index)}>${esc(it.name)}</text>`);
127
128
  parts.push(hit(cx - 10, gap + w + 16, it.index));
128
129
  cx += gap + w + 26;
129
130
  }
@@ -134,7 +135,7 @@ export function topLegend(items, x, y, anchor = 'right', shape = 'circle') {
134
135
  const it = items[i];
135
136
  const w = textW(it.name, 12);
136
137
  const swatchX = cx - w - (shape === 'square' ? 18 : 10);
137
- parts.push(`<text x="${r2(cx)}" y="${r2(y)}" text-anchor="end" font-size="12" font-weight="500" fill="var(--d-text)"${lg(it.index)}>${esc(it.name)}</text>`);
138
+ parts.push(`<text x="${r2(cx)}" y="${r2(y)}" text-anchor="end" font-size="${BASELINE.legend}" font-weight="500" fill="var(--d-text)"${lg(it.index)}>${esc(it.name)}</text>`);
138
139
  parts.push(swatch(swatchX, it.color, it.index));
139
140
  parts.push(hit(swatchX - 8, w + (shape === 'square' ? 18 : 10) + 14, it.index));
140
141
  cx -= w + 28 + (shape === 'square' ? 8 : 0);
@@ -0,0 +1 @@
1
+ export { WORLD_COUNTRIES, WORLD_YEAR, type WorldCountry } from './world-data.js';
package/dist/world.js ADDED
@@ -0,0 +1,5 @@
1
+ // 世界的国家与年份数据 —— 单独一个入口。
2
+ //
3
+ // 为什么单独:球面的底图(GeoJSON)有半兆多,浏览器端只要「哪个国家、哪一年、
4
+ // 多少人口/人均 GDP」这张表时,不必把那半兆一起下载 ⇒ 这一个入口只有十几 KB。
5
+ export { WORLD_COUNTRIES, WORLD_YEAR } from './world-data.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-cmd/draw",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "SVG chart rendering as a service, a library, and a CLI — pie/bar/hbar/line/area/radar/gauge/scatter/combo/sankey/qr, same params everywhere",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -18,6 +18,10 @@
18
18
  "types": "./dist/globe.d.ts",
19
19
  "default": "./dist/globe.js"
20
20
  },
21
+ "./world": {
22
+ "types": "./dist/world.d.ts",
23
+ "default": "./dist/world.js"
24
+ },
21
25
  "./client": {
22
26
  "types": "./dist/client.d.ts",
23
27
  "default": "./dist/client.js"