PHP namespaces stay PRC\Platform\Scripts and PRC\Platform\Script_Modules so existing REST endpoint classes keep working after the move out of prc-platform-core.
Layout
| Path | Contents |
|---|---|
includes/scripts/ | First-party @prc/* and third-party JS/CSS source plus build output |
includes/script-modules/ | @prc/d3 and @prc/topojson script modules |
includes/scripts/src/third-party/d3/ and d3-v7/ | UMD bundles exposed as window.d3 and window.d3v7 |
includes/class-bootstrap.php | Wires classes into the plugin Loader |
Third-party D3 globals
Legacy chart and interactive bundles externalize D3 to script handles built from the UMD d3/dist/d3.js entry (not d3/src). Each webpack build must export the populated UMD global as the library default:
| Build output | Global | Typical consumer |
|---|---|---|
build/third-party/d3/ | window.d3 | Older interactives |
build/third-party/d3-v7/ | window.d3v7 | import * as d3 from 'd3v7' |
Rebuild vendors after D3 version changes:
npx turbo build --filter=@prc/scriptsLoad order
client-mu-plugins/plugin-loader.php loads prc-scripts after prc-icon-library / prc-post-publish-pipeline and immediately before prc-block-library, so handles exist before consumers that list Requires Plugins: prc-scripts.
Internal REST helpers
Some @prc/components packages register editor helper routes under prc-api/v3 (for example /utils/postid-by-url and /components/wp-entity-search). Those support shared UI controls and are not a public product API.
Shared UI components
| Component | Path | Consumers |
|---|---|---|
CalendarHeatmap, AnalyticsPeriodControls, monthKeyFromIndex | @prc/components/calendar-heatmap | Dataset stats panel, quiz analytics — month grid with optional onCellClick drill-down to daily cells |
AudienceBuildPanel | @prc/components/audience-build-panel | Datasets, quiz-builder, email-builder — DataForm audience cards with rebuild/delete/draft actions |
See the plugin README for import examples and prop shapes.
Storybook
Root Storybook (.storybook/) discovers stories under plugins/prc-scripts/includes/scripts/src/@prc/ and chart stories under plugins/prc-charting-library/src/.
| Command | Purpose |
|---|---|
npm run storybook | Dev server at http://localhost:6006 |
npm run build-storybook | Static build |
Production builds externalize @prc/* to window.* via dependency-extraction.js. Storybook aliases those packages to source instead. See the plugin README for mocks, decorators, and how to add a story.