=== App To Page ===
Contributors: szub
Tags: static, spa, vite, react, github
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Upload a built front-end app (Vite/React/Vue or plain HTML/JS) — or pull from GitHub — and serve it at any URL on your site.

== Description ==

App To Page lets you take the built output of any browser-only app — a Vite/React/Vue `dist/` folder, or a plain HTML/JS game like Snake — and serve it at a URL on your site. Zip it and upload it, or connect a GitHub repo and pull the build. The plugin intercepts the request and streams your app's files, bypassing the WordPress theme entirely, so your app renders exactly as it does locally.

= What you can do =

* **Upload a build** — drag a `.zip` of your `dist/`/`build/` folder, pick a URL, publish.
* **Deploy from GitHub** — connect a repository and pull a built app from a Release asset or a branch on demand, with a "check for updates" button. App To Page serves the built artifact; it never runs a build on your server.
* **Pre-publish health check** — on every upload/update, the plugin scans for broken asset references, risky absolute base paths, and oversized bundles, and surfaces them before you go live.
* **Access control** — keep an app public, restrict it to logged-in users, or limit it to specific roles and users.
* **Private preview** — preview a draft privately, then publish when it's ready.

= How it works =

1. Open the **App To Page** screen in the left admin menu.
2. Either drag a `.zip` of your built app onto the dropzone (the contents of `dist/`/`build/`, with an `index.html` at the top level — a single wrapping folder is fine), or choose **From GitHub** and connect a repository. Confirm the name and URL.
3. Preview the draft privately, then publish it.
4. Visit the URL. Your app is live. Optionally restrict who can view it.

= Notes for bundlers (Vite/React/Vue) =

For assets to resolve at any mount path, build with a **relative base**:

`// vite.config.js`
`export default { base: './' }`

Then build and zip the `dist/` folder. Create React App users can set `"homepage": "."` in `package.json`. Plain HTML/JS apps with relative paths work as-is.

The plugin injects a `<base>` tag and rewrites root-absolute references in `index.html` automatically, but JavaScript files built with an absolute base (`/assets/...`) can still hard-code paths the plugin can't safely rewrite — hence the relative-base recommendation. The health check flags this as "check base path."

= Security =

Uploads are admin-only. On extraction the plugin strips server-executable and config files (PHP, CGI, `.htaccess`, etc.), stores apps in an unguessable directory, and serves files only through the plugin (never directly). Served pages carry a conservative Content-Security-Policy. You confirm you trust an app before publishing it.

== External services ==

This plugin can connect to **GitHub** so you can deploy a built app directly from a repository. GitHub is contacted **only when you choose to use the GitHub features** (connecting an account, listing your repositories, checking for updates, or pulling a build) — never automatically or on the front end.

When you use those features, the plugin contacts:

* `api.github.com` — to authorize your account (GitHub's device flow), list the repositories you grant access to, look up the latest release or branch, and request the build artifact.
* `github.com` — GitHub's device-flow sign-in/authorization endpoints.
* `codeload.github.com` and `*.githubusercontent.com` — to download the release asset or branch archive.

Data sent to GitHub: your GitHub access token (stored on your site and sent as an authorization header on these requests) and the repository, branch, and release identifiers you select. No other site data is transmitted, and the token is used only to read your builds.

This service is provided by GitHub, Inc. Use of it is subject to GitHub's Terms of Service (https://docs.github.com/site-policy/github-terms/github-terms-of-service) and Privacy Statement (https://docs.github.com/site-policy/privacy-policies/github-privacy-statement).

== Roadmap ==

* Per-app version history and one-click rollback.
* Auto-deploy on a GitHub release (webhook).
* Runtime error surfacing for deployed apps.

== Screenshots ==

1. Your apps at a glance — upload a `.zip` or deploy from GitHub, with live status and a pre-publish health badge on each app.
2. App detail — manage an app, see its health status, optionally connect a GitHub repository, and preview the deployed app live right in the dashboard.
3. Deploy from GitHub — pick a repository, choose a URL and who can view it, and create a draft from a Release asset or branch.
4. Settings — connect your GitHub account in two steps (or paste a personal access token), and choose whether to keep or delete your apps when the plugin is uninstalled.

== Changelog ==

= 1.0.0 =
* Initial public release.
* ZIP upload with automatic extraction, entry detection, and base-path fixing.
* Permalink-independent serving with single-page-app fallback; correct MIME types and caching.
* Deploy from GitHub: connect a repo and pull a build from a Release asset or branch, with update checking (GitHub App device-flow sign-in or a personal access token).
* Pre-publish health check (broken assets, absolute-base risk, oversized bundles).
* Access control: public, logged-in only, or restricted to specific roles/users.
* Private draft preview; admin-only uploads with executable-file stripping and a Content-Security-Policy.
