Skip to content

feat: Integrate the common library - #590

Merged
jamesrweb merged 1 commit into
mainfrom
adopt-common-package
Sep 6, 2026
Merged

feat: Integrate the common library#590
jamesrweb merged 1 commit into
mainfrom
adopt-common-package

Conversation

@jamesrweb

Copy link
Copy Markdown
Member

Related Issue

N / A

PR Type

  • 🐛 Bug Fix
  • ✨ New Feature
  • 🔨 Code Refactor
  • 📝 Documentation Update
  • 🧪 Test Update
  • 🔧 Build/CI Update
  • 🧹 Chore
  • ⏪ Revert

Description

Adopts @p5-wrapper/common
as the source of truth for the shared p5 contracts, lifecycle utilities, and
constants that were previously duplicated in this repository. The React
package keeps only what is genuinely React-specific: the P5Canvas component
tree and the P5CanvasProps contract that binds common's OutputNode type
parameter to ReactNode.

This is the first adoption of the new shared package within the organisation.

Proposed Changes

  • Added @p5-wrapper/common@^0.1.0 as a runtime dependency and removed
    microdiff (it now lives inside common; this package's runtime dependencies
    are @p5-wrapper/common and react-error-boundary)
  • Removed the duplicated shared sources (19 files, ~520 lines): the contracts
    (p5, SketchProps, Sketch, P5CanvasInstance, Updater,
    CanvasContainer, CanvasContainerRef, P5CanvasInstanceRef,
    P5CanvasInternalProps), the CanvasContainerClassName constant, the utils
    (createP5CanvasInstance, updateP5CanvasInstance,
    removeP5CanvasInstance, propsAreEqual, logErrorBoundaryError), and
    their test files
  • src/components/P5Canvas.tsx now passes common's propsAreEqual directly
    into React.memo — no local wrapper
  • src/contracts/P5CanvasProps.ts is the only remaining local contract: it
    binds common's P5CanvasProps<Props, OutputNode> to ReactNode, keeping
    the public type structurally identical to the previous local definition
  • src/main.tsx re-exports the shared contracts and constant from
    @p5-wrapper/common; the public API surface (names and shapes) is unchanged
  • config/vite/library.ts adds @p5-wrapper/common to the Rollup externals
    and globals so it is never bundled into dist/component
  • pnpm-workspace.yaml adds @p5-wrapper/common@0.1.0 to
    minimumReleaseAgeExclude — the package was published within the release-age
    window and could not otherwise be resolved under
    minimumReleaseAgeStrict (this exclusion can be dropped once 0.1.0 ages past
    the window)
  • Test suite trimmed to component behaviour only (tests/components/);
    shared-surface tests (exports guard, constants, utils) are now owned by
    @p5-wrapper/common's own suite
  • AGENTS.md updated throughout: dependency contract, code philosophy, layer
    architecture, testing structure, file organisation, build externals,
    guardrails, and future topics now reflect the common adoption

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing (please describe)

pnpm integrate (format:check → lint → test → build, the local CI mirror)
passes fully: 22 passed + 2 pre-existing skipped tests, with
@p5-wrapper/common correctly externalised in the ESM and CJS outputs in
dist/component. Manual checks confirmed the public exports map, entry
filenames (main.mjs/main.cjs), and bundled types are unchanged, and that
no shared module is bundled into the library output.

Screenshots/Recordings

Not applicable — no user-facing behaviour change.

Breaking Changes

  • Yes (please describe)
  • No

The public API (P5Canvas, CanvasContainerClassName, and the exported
types) keeps the same names and structurally identical shapes. Consumers are
unaffected; the only visible difference is that @p5-wrapper/common is now
installed transitively as a runtime dependency.

Checklist

  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My changes generate no new warnings

Additional Notes

  • Coverage will shift in the CI coverage-delta comment: the removed tests
    covered code that now lives in @p5-wrapper/common, where it is tested by
    that package's own suite
  • The two it.skip loading-UI tests are pre-existing and remain skipped,
    tracked in Future Topics
  • Follow-up opportunities (not part of this change): pruning the now-unused
    @utils/* and @constants/* path aliases, migrating
    @p5-wrapper/next and @p5-wrapper/custom-element onto common, and
    dropping the minimumReleaseAgeExclude entry once 0.1.0 matures

Important: This can be deployed as a patch deployment since the exposed API surface is 1:1 but the idea is that in future, we can remove the dependency of the common library as a major release which consumers would then install alongside the react library, for example.

@jamesrweb jamesrweb self-assigned this Sep 6, 2026
@jamesrweb
jamesrweb requested a review from yevdyko as a code owner September 6, 2026 00:46
@jamesrweb jamesrweb added enhancement dependencies Pull requests that update a dependency file documentation Pull requests that update project documentation npm labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Coverage report for commit: c1da626
File: ./coverage/clover.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  80% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  90% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
 100% │ ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ 100.0%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution / ▒ = Previous Distribution
Summary - Lines: 100.00% ⏹️ | Methods: 100.00% ⏹️ | Branches: 100.00% ⏹️
FilesLinesMethodsBranches
src/components
   P5Canvas.tsx100.00%100.00%100.00%
   P5CanvasGuard.tsx100.00%100.00%100.00%
   P5CanvasWithSketch.tsx100.00%100.00%100.00%
src/contracts
   P5CanvasProps.ts100.00%100.00%100.00%
src
   main.tsx100.00%100.00%100.00%

🤖 comment via lucassabreu/comment-coverage-clover

@yevdyko yevdyko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct. Thanks 🚀

@jamesrweb
jamesrweb merged commit 13f818c into main Sep 6, 2026
7 checks passed
@jamesrweb
jamesrweb deleted the adopt-common-package branch September 6, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Pull requests that update project documentation enhancement npm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants