Skip to content

Conversation

@bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented Nov 5, 2025

Motivation for the change, related issues

In the past when we had only JSON Blueprints v1 it was easy download and customize a Blueprint with vanilla JS, but today we have Blueprints v1 and v2, JSON Blueprints, and bundles.

For a site that uses the @wp-playground/client package, there's currently no easy way to download a Blueprint and adjust it, but the Playground website has helper functions that enable the query API to fetch and override a Blueprint.

This PR moves the resolveBlueprintFromURL, applyQueryOverrides, parseBlueprint functions, and related types to the @wp-playground/blueprints package, so users can import and use these helper functions.

We had to move the code out of the website package because it isn't public, while the Blueprint package is.

The PR also moves the base64 related helpers to @wp-playground/common as this seemed like a appropriate place for these helpers.

Implementation details

TBD

Testing Instructions (or ideally a Blueprint)

  • CI

TODO

  • Resolve lazy-loaded libraries errors

…parseBlueprint functions in the @wp-playground/blueprints package
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the codebase to consolidate base64 utilities and blueprint resolution logic by moving them from website-specific code into shared packages. The changes improve code reusability and better organize the codebase structure.

  • Moved base64 encoding/decoding utilities from packages/playground/website to @wp-playground/common with improved cross-environment support
  • Moved blueprint parsing and URL resolution logic from packages/playground/website to @wp-playground/blueprints
  • Added comprehensive test coverage for the newly relocated functionality

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/playground/website/src/lib/base64.ts Removed file - base64 utilities moved to @wp-playground/common
packages/playground/website/src/lib/state/url/router.ts Removed parseBlueprint function and base64 import, now using blueprints package
packages/playground/website/src/components/site-manager/site-info-panel/index.tsx Updated import to use encodeStringAsBase64 from @wp-playground/common
packages/playground/website/src/lib/state/redux/slice-sites.ts Consolidated imports to use blueprint utilities from @wp-playground/blueprints
packages/playground/common/src/base64.ts Added base64 utilities with Node.js/browser compatibility
packages/playground/common/src/index.ts Exported base64 utilities
packages/playground/common/src/test/base64.spec.ts Added comprehensive tests for base64 utilities
packages/playground/blueprints/src/lib/utils/parse-blueprint.ts New file with parseBlueprint function and documentation
packages/playground/blueprints/src/lib/utils/parse-blueprint.spec.ts Added tests for parseBlueprint function
packages/playground/blueprints/src/lib/resolve-blueprint-from-url.ts Moved blueprint URL resolution logic from website package
packages/playground/blueprints/src/test/resolve-blueprint-from-url.spec.ts Added comprehensive tests for URL resolution
packages/playground/blueprints/src/lib/apply-query-overrides.ts Refactored to separate concerns and use dynamic imports
packages/playground/blueprints/src/test/apply-query-overrides.spec.ts Added comprehensive tests for query overrides
packages/playground/blueprints/src/index.ts Exported new blueprint utilities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamziel
Copy link
Collaborator

adamziel commented Nov 5, 2025

What is the use-case for this? All these functions will either change or be removed to integrate Blueprints v2. In v2, all the logic runs in PHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants