pixijs / customize

Customize the list of packages to use for PixiJS v5
https://pixijs.io/customize
11 stars 5 forks source link

Feature Request: Support PixiPlayground Browser Link #4

Open bigtimebuddy opened 5 years ago

bigtimebuddy commented 5 years ago

cc @englercj

Here's an example of JSFiddle POST API for auto-filling: https://docs.jsfiddle.net/api/display-a-fiddle-from-post

Basically, there are two pieces of information that I post to JSFiddle and CodePen: a snippet of JS code that bootstraps all the plugins, and a list of external resources that are loaded in a specific order. I also set an initial title/description.

This could probably work with PixiPlayground as Settings > Custom URL > External Scripts. And contents to populate the code area.

englercj commented 5 years ago

I can put something like this together for playground this weekend. Thanks @bigtimebuddy!

englercj commented 5 years ago

Actually I just realized, you can hit the API to create a new playground just like the app does normally.

I don't have good docs, but here is the handler: https://github.com/englercj/playground/blob/master/server/src/routes/playgrounds.ts#L122

Just make a POST to https://pixiplayground.com/api/playground with JSON data. Something like:

{
    "name": "",
    "description": "",
    "contents": "",
    "author": "",
    "pixiVersion": "",
    "isPublic": true,
    "externaljs": [
        { "url": "" },
        { "url": "" }
    ]
}

Where pixiVersion is the URL to your generated file, and the externaljs array is the list of scripts to load (they will be loaded in order). Only contents and pixiVersion are required.

The API call will return a resolved playground data JSON object which includes the generated slug that you can use to craft the URL the user should navigate to, which is https://pixiplayground.com/#/edit/<slug>.

Does this work?

bigtimebuddy commented 5 years ago

What is pixiVersion? The semver? If I provide a version does try to load that bundle?

englercj commented 5 years ago

pixiVersion can be:

The value here will be loaded first before externaljs.