An open source design system that's fully customizable and agent ready
TypeScript
feat(charts): bootstrap @astryxdesign/charts package (canary-only) (#3570)
Cindy Zhangadbd0e549819
diff --git a/README.md b/README.mdindex deb7c1021f..107a68756a 100644--- a/README.md+++ b/README.md@@ -58,7 +58,7 @@ Then use it as `npm run astryx -- component --list`. This avoids path errors whe| [`@astryxdesign/build`](packages/build) | Build plugins for StyleX source builds | [README](packages/build/README.md) || [`@astryxdesign/theme-*`](packages/themes) | Seven ready-made, fully customizable themes (neutral, butter, chocolate, matcha, stone, gothic, y2k) | [README](packages/themes) |-> `@astryxdesign/lab` (experimental components) is used internally for Storybook and the sandbox and is not published to npm. `@astryxdesign/vega` (Vega/Vega-Lite chart wrapper) is published to npm only under the `@canary` dist-tag — there is no stable release yet.+> `@astryxdesign/lab` (experimental components) is used internally for Storybook and the sandbox and is not published to npm. `@astryxdesign/vega` (Vega/Vega-Lite chart wrapper) and `@astryxdesign/charts` (chart components) are published to npm only under the `@canary` dist-tag — there is no stable release yet.## Principlesdiff --git a/package.json b/package.jsonindex d6655e045c..ecc9e7df77 100644--- a/package.json+++ b/package.json@@ -4,7 +4,7 @@"private": true,"license": "MIT","scripts": {- "build": "pnpm -F @astryxdesign/build build && pnpm -F @astryxdesign/core build && pnpm -F @astryxdesign/lab build && pnpm -F @astryxdesign/vega build && pnpm -F @astryxdesign/theme-neutral build && pnpm -F @astryxdesign/theme-matcha build && pnpm -F @astryxdesign/theme-stone build && pnpm -F @astryxdesign/theme-gothic build && pnpm -F @astryxdesign/theme-chocolate build && pnpm -F @astryxdesign/theme-y2k build && pnpm -F @astryxdesign/theme-butter build && pnpm bundle:cli-themes",+ "build": "pnpm -F @astryxdesign/build build && pnpm -F @astryxdesign/core build && pnpm -F @astryxdesign/lab build && pnpm -F @astryxdesign/charts build && pnpm -F @astryxdesign/vega build && pnpm -F @astryxdesign/theme-neutral build && pnpm -F @astryxdesign/theme-matcha build && pnpm -F @astryxdesign/theme-stone build && pnpm -F @astryxdesign/theme-gothic build && pnpm -F @astryxdesign/theme-chocolate build && pnpm -F @astryxdesign/theme-y2k build && pnpm -F @astryxdesign/theme-butter build && pnpm bundle:cli-themes","bundle:cli-themes": "node scripts/generate-cli-themes.mjs","dev": "pnpm -F @astryxdesign/storybook dev","test": "vitest run",diff --git a/packages/README.md b/packages/README.mdindex 5a66270dfc..199d06c611 100644--- a/packages/README.md+++ b/packages/README.md@@ -4,11 +4,12 @@ Published npm packages for the Astryx design system.<!-- SYNC: When files in this directory change, update this document. -->-| Directory | Package | Purpose |-| --------- | ----------------------- | ------------------------------------------------------------------ |-| `core/` | `@astryxdesign/core` | Core UI components, theme system, and utilities |-| `cli/` | `@astryxdesign/cli` | CLI tooling: component docs, templates, scaffolding, codemods |-| `build/` | `@astryxdesign/build` | Build plugins for StyleX source builds (Babel, PostCSS, Vite) |-| `themes/` | `@astryxdesign/theme-*` | Visual themes (default, neutral, daily, brutalist, meta, whatsapp) |-| `vega/` | `@astryxdesign/vega` | Vega/Vega-Lite chart wrapper (canary only) |-| `lab/` | — | Experimental components (not published) |+| Directory | Package | Purpose |+| --------- | ----------------------- | ---------------------------------------------------------------------- |+| `core/` | `@astryxdesign/core` | Core UI components, theme system, and utilities |+| `cli/` | `@astryxdesign/cli` | CLI tooling: component docs, templates, scaffolding, codemods |+| `build/` | `@astryxdesign/build` | Build plugins for StyleX source builds (Babel, PostCSS, Vite) |+| `themes/` | `@astryxdesign/theme-*` | Visual themes (default, neutral, daily, brutalist, meta, whatsapp) |+| `vega/` | `@astryxdesign/vega` | Vega/Vega-Lite chart wrapper (canary only) |+| `charts/` | `@astryxdesign/charts` | Chart components — themeable wrappers over a peer engine (canary only) |+| `lab/` | — | Experimental components (not published) |diff --git a/packages/charts/CHANGELOG.md b/packages/charts/CHANGELOG.mdnew file mode 100644index 0000000000..5ec8675cd6--- /dev/null+++ b/packages/charts/CHANGELOG.md@@ -0,0 +1 @@+# @astryxdesign/chartsdiff --git a/packages/charts/README.md b/packages/charts/README.mdnew file mode 100644index 0000000000..1bddbe9928--- /dev/null+++ b/packages/charts/README.md@@ -0,0 +1,33 @@+# @astryxdesign/charts++Astryx chart components. This package provides thin, themeable wrappers over a peer charting engine — it owns the design-system surface while leaving the rendering engine as a peer dependency the consumer manages.++It ships to npm **only under the `@canary` dist-tag** — there is never a stable (`latest`) release yet.++## Status++**Bootstrap scaffold.** The package is set up and building but ships no components yet. Add components under `src/` and export them from `src/index.ts`. The StyleX + Astryx-token build setup mirrors `@astryxdesign/lab`, so components can consume `@astryxdesign/core` theme tokens directly.++> When the first component adds StyleX styles, wire up a pre-compiled stylesheet the same way `lab` does: add a `charts` target to `scripts/build-css.mjs`, restore the `build:css` script and the `./charts.css` export in `package.json`, and document the `import '@astryxdesign/charts/charts.css'` step below.++## Usage++Inside the monorepo (storybook/sandbox), imports resolve via pnpm workspaces:++```tsx+import {} from /* ... */ '@astryxdesign/charts';+```++### Trying charts in your own project (canary)++`@astryxdesign/charts` is published **only** under the `@canary` dist-tag, so you must request that tag explicitly. There is no `latest` version to install.++```bash+npm install @astryxdesign/charts@canary @astryxdesign/core@canary+```++> Canary builds track the latest commit on `main` (`0.x.y-canary.<sha>`). They can break between any two versions — pin an exact version if you need stability.++## Why no stable release?++`package.json` keeps `"private": true` plus an `"astryx": { "canaryOnly": true }` marker. The release workflow's stable (`latest`) job skips both private and `canaryOnly` packages, while the canary job strips `private` in its ephemeral CI checkout only (never in git) to publish the `@canary` tag. The committed `private: true` is npm's hard guarantee that no stable publish can ever happen — **do not remove it.**diff --git a/packages/charts/babel-plugin-add-extensions.cjs b/packages/charts/babel-plugin-add-extensions.cjsnew file mode 100644index 0000000000..9e652e966e--- /dev/null+++ b/packages/charts/babel-plugin-add-extensions.cjs@@ -0,0 +1,61 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/* eslint-disable @typescript-eslint/no-require-imports, no-undef */++/**+ * Babel plugin that appends .js to relative import/export paths.+ *+ * TypeScript source uses extensionless imports (e.g. './XDSButton').+ * Node.js ESM requires explicit extensions for "type": "module" packages.+ * This plugin rewrites them during compilation so no postbuild step is needed.+ *+ * Handles both file imports ('./XDSButton' → './XDSButton.js') and+ * directory imports ('./domainTokens' → './domainTokens/index.js').+ */+const fs = require('fs');+const nodePath = require('path');++module.exports = function addExtensions() {+ const SKIP = /\.(?:js|mjs|cjs|json|css)$/;++ return {+ visitor: {+ 'ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration'(+ path,+ state,+ ) {+ const source = path.node.source;+ if (!source) return;+ const value = source.value;++ // Compat alias barrels self-re-export from `'.'` in source. Node ESM+ // does not support directory imports in built output, so make the self+ // reference explicit (`./index.js`) during compilation.+ if (value === '.') {+ source.value = './index.js';+ return;+ }+ if (value === '..') {+ source.value = '../index.js';+ return;+ }++ if (!value.startsWith('./') && !value.startsWith('../')) return;+ if (SKIP.test(value)) return;++ const dir = nodePath.dirname(state.filename);+ const asFile = nodePath.join(dir, value + '.ts');+ const asTsx = nodePath.join(dir, value + '.tsx');+ const asIndex = nodePath.join(dir, value, 'index.ts');+ const asIndexTsx = nodePath.join(dir, value, 'index.tsx');++ if (fs.existsSync(asFile) || fs.existsSync(asTsx)) {+ source.value = value + '.js';+ } else if (fs.existsSync(asIndex) || fs.existsSync(asIndexTsx)) {+ source.value = value + '/index.js';+ } else {+ source.value = value + '.js';+ }+ },+ },+ };+};diff --git a/packages/charts/babel.config.js b/packages/charts/babel.config.jsnew file mode 100644index 0000000000..00856dd852--- /dev/null+++ b/packages/charts/babel.config.js@@ -0,0 +1,46 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file babel.config.js+ * @input Uses @babel/preset-react, @babel/preset-typescript, the local+ * add-extensions plugin, and @stylexjs/babel-plugin+ * @output Babel config for compiling charts src -> dist (ESM .js with StyleX)+ * @position Build config for @astryxdesign/charts+ *+ * Mirrors packages/lab/babel.config.js: charts consumes core's StyleX theme+ * tokens (@astryxdesign/core/theme/tokens.stylex), a cross-package reference+ * core never makes. The StyleX resolver therefore needs an alias to core's+ * source and a monorepo-root rootDir.+ *+ * SYNC: When modified, update this header and /packages/charts/README.md+ */++/* global module, require, __dirname */+// eslint-disable-next-line @typescript-eslint/no-require-imports+const path = require('path');++const rootDir = path.resolve(__dirname, '../..');++module.exports = {+ presets: [+ ['@babel/preset-react', {runtime: 'automatic'}],+ ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],+ ],+ plugins: [+ './babel-plugin-add-extensions.cjs',+ [+ '@stylexjs/babel-plugin',+ {+ dev: false,+ runtimeInjection: false,+ genConditionalClasses: true,+ treeshakeCompensation: true,+ aliases: {+ '@astryxdesign/core/*': [path.join(rootDir, 'packages/core/src/*')],+ '@astryxdesign/core': [path.join(rootDir, 'packages/core/src')],+ },+ unstable_moduleResolution: {type: 'commonJS', rootDir},+ },+ ],+ ],+};diff --git a/packages/charts/package.json b/packages/charts/package.jsonnew file mode 100644index 0000000000..14a95d9a9c--- /dev/null+++ b/packages/charts/package.json@@ -0,0 +1,60 @@+{+ "name": "@astryxdesign/charts",+ "version": "0.1.3",+ "private": true,+ "description": "Astryx chart components — thin, themeable wrappers over a peer charting engine. Published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",+ "author": "Meta Open Source",+ "license": "MIT",+ "homepage": "https://github.com/facebook/astryx#readme",+ "repository": {+ "type": "git",+ "url": "git+https://github.com/facebook/astryx.git",+ "directory": "packages/charts"+ },+ "bugs": {+ "url": "https://github.com/facebook/astryx/issues"+ },+ "keywords": [+ "astryx",+ "charts",+ "data-visualization",+ "design-system"+ ],+ "astryx": {+ "canaryOnly": true,+ "_comment": "Published ONLY to the @canary dist-tag (see .github/workflows/release.yml). Never published as a stable `latest` release. `private: true` is intentional and must stay — it is npm's hard guarantee against an accidental stable publish."+ },+ "main": "./dist/index.js",+ "module": "./dist/index.js",+ "types": "./dist/index.d.ts",+ "sideEffects": false,+ "files": [+ "dist",+ "src",+ "README.md",+ "CHANGELOG.md"+ ],+ "exports": {+ ".": {+ "source": "./src/index.ts",+ "types": "./dist/index.d.ts",+ "default": "./dist/index.js"+ }+ },+ "scripts": {+ "prepack": "pnpm build",+ "build": "rm -rf dist && pnpm build:esm && tsc --project tsconfig.build.json",+ "build:esm": "babel src --out-dir dist --extensions '.ts,.tsx' --out-file-extension '.js' --ignore '**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts' --config-file ./babel.config.js",+ "dev": "babel src --watch --out-dir dist --extensions '.ts,.tsx' --out-file-extension '.js' --ignore '**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*' --config-file ./babel.config.js",+ "test": "vitest run --root ../..",+ "test:watch": "vitest --root ../..",+ "lint": "eslint src",+ "typecheck": "tsc --project tsconfig.json --noEmit"+ },+ "peerDependencies": {+ "@stylexjs/stylex": ">=0.10.0",+ "@astryxdesign/core": "0.1.3",+ "react": ">=19.0.0",+ "react-dom": ">=19.0.0"+ }+}diff --git a/packages/charts/src/index.ts b/packages/charts/src/index.tsnew file mode 100644index 0000000000..2706cc1df4--- /dev/null+++ b/packages/charts/src/index.ts@@ -0,0 +1,17 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @astryxdesign/charts — Astryx chart components+ *+ * Thin, themeable wrappers over a peer charting engine. This package owns the+ * design-system surface while leaving the rendering engine as a peer+ * dependency the consumer manages.+ *+ * This package is published to npm ONLY under the @canary dist-tag+ * (npm install @astryxdesign/charts@canary). It is never released as a+ * stable (latest) version.+ *+ * Bootstrap scaffold — no components yet. Add exports here as components land.+ */++export {};diff --git a/packages/charts/tsconfig.build.json b/packages/charts/tsconfig.build.jsonnew file mode 100644index 0000000000..5966f8174f--- /dev/null+++ b/packages/charts/tsconfig.build.json@@ -0,0 +1,21 @@+{+ "extends": "../../tsconfig.json",+ "compilerOptions": {+ "outDir": "./dist",+ "rootDir": "./src",+ "noEmit": false,+ "declaration": true,+ "declarationMap": true,+ "emitDeclarationOnly": true,+ "sourceMap": false+ },+ "include": ["src"],+ "exclude": [+ "src/**/*.test.ts",+ "src/**/*.test.tsx",+ "src/**/*.doc.mjs",+ "src/**/__tests__/**",+ "src/**/*.perf.test.ts",+ "src/**/*.perf.test.tsx"+ ]+}diff --git a/packages/charts/tsconfig.json b/packages/charts/tsconfig.jsonnew file mode 100644index 0000000000..49e05cea1e--- /dev/null+++ b/packages/charts/tsconfig.json@@ -0,0 +1,8 @@+{+ "extends": "../../tsconfig.json",+ "compilerOptions": {+ "outDir": "./dist",+ "rootDir": "./src"+ },+ "include": ["src"]+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 6155065638..7014747f4f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -709,6 +709,21 @@ importers:specifier: '>=0.28.1'version: 0.28.1+ packages/charts:+ dependencies:+ '@astryxdesign/core':+ specifier: 0.1.3+ version: link:../core+ '@stylexjs/stylex':+ specifier: '>=0.10.0'+ version: 0.18.3+ react:+ specifier: '>=19.0.0'+ version: 19.2.7+ react-dom:+ specifier: '>=19.0.0'+ version: 19.2.7([email protected])+packages/cli:dependencies:'@clack/prompts':