Skip to content

Latest commit

 

History

History
134 lines (112 loc) · 3.9 KB

STANDARD.md

File metadata and controls

134 lines (112 loc) · 3.9 KB

Generative Platform Standard Description

Standard versioning

This standard is versioned using Semantic Versioning. The version number is defined in package.json file.

Signal format

The main communication channel between Platform and Project is window.postMessage method. In the context of this standard, we call these messages "signals". Platform can send signal to Project and Project can send signal to Platform.

Signal is a valid JSON object that required to have a type field which value should be the following string:

gps:[f|b]:[message-type]

Where:

  • gps: is a type namespace (meaning "Generative Platform Standard")
  • f: or b: is a direction of the signal
  • f: (forward) indicates a signal from Platform to Project
  • b: (backward) indicates a signal from Project to Platform

Additional fields are optional and depend on the signal type.

Signal types

gps:f:init

Description

This signal should be sent from Platform to Project to initialize the communication channel. After the message is received by Project it should send a gps:b:init message back to Platform. Version of the standard should be specified in the v field. It is allowed to omit minor and patch numbers if they are zero (e.g. "1" instead of "1.0.0"").

Example

{
  "type": "gps:f:init",
  "v": "1"
}

gps:b:init

Description

This signal should be sent from Project to Platform in response to gps:f:init message. As a payload, it should contain additional field "implementsSignals" which should ab an array of all possible signals (both forward and backward) that are supported by this project.

Example

{
    "type": "gps:b:init",
    "implementsSignals": [
        {
            "type": "gps:f:download",
            "key": "download-small",
            "text": "512 x 515"
        },
        {
            "type": "gps:f:download",
            "key": "download-medium",
            "text": "1024 x 1024"
        },
        {
            "type": "gps:b:load-compl",
        },
        {
            "type": "gps:b:capt-prev",
        }
    ]
}

gps:b:load-compl

Description

This signal should be sent from Project to Platform when the project is ready to be rendered. As a result, Platform should hide the loading indicator and show the project.

Example

{
    "type": "gps:b:load-compl"
}

gps:b:capt-prev

Description

This signal should be sent from Project to Platform when the project is ready to be captured. It is especially important for projects that have some kind of animation. Platform can use this signal in order to make a screenshot of a Project.

Example

{
    "type": "gps:b:capt-prev"
}

gps:f:download

Description

This signal should be sent from Platform to Project when the user clicks on the download button. Therefore, Project should generate a data url with the image and send it back to Platform via gps:b:download signal. Two additional properties that can exists are key and text. key is a unique identifier of the download option and text is a text that should be displayed to the user. It is helpful when Project supports multiple download options (e.g. different sizes of the image).

Example

{
  "type": "gps:f:download",
  "key": "download-medium",
  "text": "1024 x 1024"
}

gps:b:download

Description

Project should reply on gps:f:download signal with this signal. It should contain a data url with the image that should be downloaded. Projects are supposed to be used with sandbox attribute, so it is not possible to download the image directly from the Project. Two required properties are dataUrl and ext. dataUrl is a data url with the image and ext is a file extension of the image.

Example

{
  "type": "gps:b:download",
  "dataUrl": "...",
  "ext": "png"
}