Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- run: npm ci
- run: npm run typecheck
- run: npm run build
- run: npx wrangler deploy worker.js --dry-run
- run: npm test
41 changes: 0 additions & 41 deletions .github/workflows/deploy-cloudflare-production.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/deploy-pollinations-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy / Pollinations production

on:
push:
branches: [production]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: websim-production
cancel-in-progress: false

jobs:
deploy:
if: github.ref == 'refs/heads/production' && (github.event_name == 'workflow_dispatch' || vars.AUTO_DEPLOY == 'true')
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: "24"
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm test
- name: Publish Websim
env:
POLLINATIONS_API_KEY: ${{ secrets.POLLINATIONS_API_KEY }}
run: npm run deploy
- name: Verify deployed files
run: |
set -euo pipefail
for file in dist/index.html dist/assets/*; do
curl --fail --location --silent --show-error --retry 5 --retry-all-errors \
--retry-delay 5 --max-time 30 \
"https://websim.pollinations.app/${file#dist/}" --output /tmp/websim-asset
cmp "$file" /tmp/websim-asset
done
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
.dev.vars*
.env*
.DS_Store
test-results/
98 changes: 62 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,84 @@
# Websim

Worker-backed BYOP app for generating shareable single-file HTML pages with Pollinations.
[![Made with pollinations.ai](https://cdn.jsdelivr.net/npm/@pollinations/ui@0.1.0-alpha.25/dist/brand/badge-made-with.svg)](https://pollinations.ai/?ref=badge)

## Local Development
Generate, preview and save single-file HTML pages using your own Pollinations Pollen.
The browser uses the published `@pollinations/sdk` and `@pollinations/ui` packages;
there are no local package links, monorepo imports or app-specific backend.

```bash
## Local development

Use Node.js 24:

```sh
npm ci
npm run dev
```

The Worker runs on `http://localhost:16386` and serves the Vite-built app from `dist`.
Dependencies come from npm; no Pollinations monorepo checkout is required.
Build the frontend with `npm run build`.
Run `npm run typecheck` to check the frontend types.
Open `http://localhost:16386/`. Use `localhost` for the registered login callback.
`npm run typecheck`, `npm test` and `npm run build` check the app. `npm run preview`
serves the production build on the same port. With an existing API key supplied
securely as `POLLINATIONS_API_KEY`, `npm run test:live` checks real generation
through the published SDK for every model choice; it consumes Pollen.

For browser checks, install Chromium with `npx playwright install chromium`,
start `npm run preview`, and run `npm run test:browser` with the same securely
supplied test key. This checks real generation, cancellation, legacy links,
PKCE requests, Save/Open isolation, mobile layout and disconnect. It also saves
an unauthenticated catalog screenshot to `screenshots/websim.png`.

![Websim app screenshot](screenshots/websim.png)

## Routes
## Login and generated pages

- `/` serves the React app shell using `@pollinations/sdk` and `@pollinations/ui`.
- `/api/generate` accepts `POST { "prompt": "...", "model": "openai-fast" }` and returns generated HTML.
- `/{prompt}/?model=openai-fast` is a legacy generation URL and requires `Authorization: Bearer ...`.
- `/api/health` returns Worker configuration health without exposing tokens.
The published SDK handles PKCE sign-in using public app key
`pk_wYCqFfSdCXZL8UBW`. User keys stay in session storage; generation calls the
Pollinations API directly with the signed-in user's key. The account menu shows
Pollen and permissions and lets users disconnect.

## Auth
Legacy `/{prompt}/?model=...` browser links now open the app with that prompt
and an allowed model selected. They normalize to the root callback before login;
nothing generates until the user chooses Generate. The static app does not serve
the old `/api/generate`, `/api/health` or bearer-authenticated raw HTML endpoints.
Machine clients should call the published Pollinations SDK/API directly.

The frontend uses the publishable app key `pk_wYCqFfSdCXZL8UBW`.
Both Preview and Open isolate generated scripts in a sandboxed iframe. Save
exports the generated HTML itself. The page-generation prompt uses inline
illustrations so saved pages do not require embedded API credentials.

Generation requires the incoming `Authorization: Bearer ...` header from the BYOP app shell.
## Publishing

The destination is `https://websim.pollinations.app`. Like any external app:

```sh
npm run build
polli sites deploy dist --name websim
```

## Deployment
Use the published CLI included in this repository (`npm run deploy` does both).
The owning account is `polli@pollinations.ai`; Sites requires `account:machines`.
No Cloudflare credential is needed by the app's final deployment workflow.

Production deploys run through **Deploy / Cloudflare production** in GitHub Actions,
always from the `production` branch. Configure the repository variable
`CLOUDFLARE_ACCOUNT_ID` and the production environment secret
`CLOUDFLARE_API_TOKEN`. The app itself stores no server-side Pollinations key;
generation uses each signed-in user's Pollen.
**Deploy / Pollinations production** runs from `production` in GitHub Actions,
using its environment secret `POLLINATIONS_API_KEY`. Keep `AUTO_DEPLOY` unset until
cutover is verified; then enable it for pushes to `production`. Promote `main`
to `production` through a PR. Never put the deployment key in Vite/browser config.

The deployment token needs **Editor** access only to the existing `websim` Worker.
Its custom domains, `websim.pollinations.ai` and `websim.myceli.ai`, stay managed in
Cloudflare. CI updates the Worker without changing its domain registrations.
`websim.pollinations.app` is a later, separate domain migration.
The Sites cutover is still pending. Preserve the current Worker until the Site,
login callback, generation, prompt links and assets are verified. The exact
Cloudflare route currently serving `websim.pollinations.app/*` must be handed
back to Sites, and `.ai` should redirect with paths/query strings preserved.
Check remaining raw API clients before retiring the old Worker. Rollback restores
the old route and disables the Sites workflow; retain the old Worker for this.

Automatic deployments stay off until the monorepo deployment registration has
been removed from its `production` branch. For the first deployment, check that
the monorepo has no running Websim deployment, then dispatch this repository's
production workflow manually. Verify the active Worker version, assets, login,
and a real generation before removing the monorepo copy. Set the repository
variable `AUTO_DEPLOY` to `true` after the handoff; subsequent pushes to
`production` deploy automatically. Promote changes from `main` through a PR.
## Catalog submission

For rollback, revert the affected commit and promote it to `production` through
GitHub Actions. Keep automatic deployments under a single repository's ownership.
Hosting and the community catalog are separate. Submit the working public URL,
this repository, a real screenshot, category `build`, platform `web` and language
`en` through the normal [app-submission form](https://github.com/pollinations/pollinations/issues/new?template=app-submission.yml). The README badge above supplies the
required credit. Review and approval are still required for a catalog listing.

## Source and attribution

Extracted from [Pollinations Websim](https://github.com/pollinations/pollinations/tree/daa3b5910521060efb43194677e172044d514097/apps/websim).
The app's Git history, including its earlier directory names, preserves the
original authors and commit messages. See [LICENSE](LICENSE).
Git history preserves the original authors and earlier directory names. See [LICENSE](LICENSE).
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
property="og:description"
content="Generate shareable single-file HTML pages with Pollinations Websim."
/>
<meta property="og:image" content="https://websim.pollinations.ai/og-image.png" />
<meta property="og:image" content="https://websim.pollinations.app/og-image.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="pollinations.ai logo" />
<meta property="og:locale" content="en_US" />
<meta property="og:url" content="https://websim.pollinations.ai" />
<meta property="og:url" content="https://websim.pollinations.app" />
<meta property="og:site_name" content="pollinations.ai" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary_large_image" />
Expand All @@ -47,7 +47,7 @@
name="twitter:description"
content="Generate shareable single-file HTML pages with Pollinations Websim."
/>
<meta name="twitter:image" content="https://websim.pollinations.ai/og-image.png" />
<meta name="twitter:image" content="https://websim.pollinations.app/og-image.png" />
<meta name="twitter:image:alt" content="pollinations.ai logo" />

<link rel="icon" type="image/x-icon" href="/favicon.ico" />
Expand All @@ -57,7 +57,7 @@
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png" />
<link rel="apple-touch-icon" sizes="167x167" href="/apple-touch-icon-167x167.png" />
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="canonical" href="https://websim.pollinations.ai" />
<link rel="canonical" href="https://websim.pollinations.app" />

<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down
2 changes: 0 additions & 2 deletions models.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ export const WEB_SIM_MODELS = /** @type {const} */ ([
detail: "More complete HTML",
},
]);

export const ALLOWED_MODEL_IDS = WEB_SIM_MODELS.map((model) => model.id);
Loading
Loading