@@ -8,14 +8,61 @@ multi-channel rendering where iframes are not available.
88
99## Abstract
1010
11- TokenScript cards rely on an iframe or webview to be securely embedded in other applications and allow rendering of the UI as well
12- as orchestrating transactions and other off-chain processes.
13- Without an iframe or webview, interactive TokenScript cannot be achieved at this time.
11+ TokenScript cards rely on an iframe or webview to be securely embedded in other applications and allow rendering of the
12+ UI as well as orchestrating transactions and other off-chain processes.
13+ Without an iframe or webview, interactive TokenScripts cannot be achieved at this time.
1414
15- A good example of this is Farcaster frames or Metamask snaps.
15+ A good example of this is Farcaster frames or Metamask snaps, where the execution logic must be completely decoupled
16+ from UI rendering.
1617
1718## Motivation
1819
20+ Since its conception, TokenScript has relied heavily on iframes or webviews for the execution of Javascript logic.
21+ As discussed in the abstract, this imposes framework limitations where normal TokenScript cards cannot be used
22+ in user-agents that do not support iframes or use server-side APIs to invoke wallet interactions.
1923
24+ ## Specification
25+
26+ The EIP will focus only on UI rendering, but will touch on how complex actions could be enabled in the future.
27+ It will introduce an alternative rendering model that uses HTML & CSS templates that do not contain any Javascript code
28+ but provide a high level of flexibility. These templates can easily be parsed and rendered into an image for use in
29+ channels that cannot make use of iframes.
30+
31+ Triggering any actions for this card will go through the same flow as an iframe based card, with one key change:
32+
33+ 1 . Invalidate attributes
34+ 2 . Reload token metadata
35+ 3 . Reload attributes and ~~ push new card data to the iframe~~ rerender the iframe using the updated card data
36+
37+ This allows image frames to be reactive to changes made by the user.
38+ It also allows for server-side rendering support for TokenScript cards in a secure manner that does not require the
39+ use of a headless browser or other resource intensive runtime.
40+
41+ ### Dependencies
42+
43+ The flexibility of this implementation will draw on improvements made in [ TIP-1] ( ./tip-1.md ) & [ TIP-2] ( ./tip-2.md ) .
44+
45+ ### Mustache templates
46+
47+ [ Mustache] ( https://github.com/janl/mustache.js ) or [ Handlebars] ( https://handlebarsjs.com/ ) are two good candidates as a template language.
48+ They call themselves logic-less templates however they do provide conditional and iterable support, just not in the way you may expect.
49+
50+ One advantage of a templating languages like this is that they do not impose any sandboxing requirements, unlike some
51+ other general programming language based solution.
52+
53+ ### Defining an image renderer card
54+
55+ To define an image-rendered card, we introduce the renderer attribute to the ` ts:view ` element.
56+
57+ ``` xml
58+
59+ ```
60+
61+ ### Engine integration
62+
63+ The existing ViewController model of the engine is changed to enable the image based rendering model.
64+ It is based on the current IViewBinding interface, which leaves the actual implementation to the user-agent (TS viewer, API server, etc.).
65+ Where possible the same controller APIs are reused and modified to make cross-compatible with the new rendering model.
66+
67+ ## Considerations
2068
21- ## Specification
0 commit comments