Webãµã€ããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«å€ãã
埩ç¿
äžã®å³ã¯ãWebãµã€ããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«å€ããããšãã§ããã³ãŒãã瀺ããŠããŸãã ç¹ã«ããªã¬ã³ãžè²ã®7ã€ã®ãJSONãè¡ããå€æãã®åå ã§ãã ããã°ã©ã ããã¹ãã®æ®ãã®ãã©ã°ã¡ã³ãã¯ãã¢ããªã±ãŒã·ã§ã³ãå®è¡ãããŠããã¢ãã€ã«ãã©ãããã©ãŒã ã«é¢é£ããæ©èœã説æããŠããŸãã
ãã®ã¢ãããŒãã䜿çšããããã«ããªãœãŒã¹ã®å€èŠ³ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ã«è¿ã¥ããç¹å®ã®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããŠãµã€ããããçŽãå¿ èŠããªããšèšãã°ã©ãã§ããããã ããã«ãéçºããã»ã¹å šäœããéåžžã®URLã䜿çšããŠäžèšã®ãããªã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«ãµã€ããæ¥ç¶ããå Žåã¯ã©ããªããŸããïŒ
ããã«ãå¥ã®è³ªåããããŸãïŒãJSONãç·šéããã ãã§ããã€ãã£ãAPIãšãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã³ã³ããŒãã³ãã䜿çšããŠãããŒãžéã®ã·ã¹ãã é·ç§»ã䜿çšããããšã¯å¯èœã§ããïŒã
ãããã®è³ªåã«å¯ŸããçããèããŠããéãããã§ã話ããããããŒã«ã䜿çšããŠäœæãããæå°éã®ã¢ããªã±ãŒã·ã§ã³ãã©ã®ããã«èŠããŠåäœããããèŠãŠã¿ãããšããå§ãããŸãã
æå°éã®ã¢ããªã±ãŒã·ã§ã³
ãã®ã¢ããªã±ãŒã·ã§ã³ã§github.comã䜿çšããŠããŒãžãåã蟌ãã ããšã«æ³šæããŠãã ãã ããã ããä»ã®ãã¹ãŠã¯ã äžéšããã²ãŒã·ã§ã³ããŒãäžéšã³ã³ãããŒã«ããã«ãªã©ã®ãã€ãã£ãã³ã³ããŒãã³ãã§ã ã åæã«ãã¢ããªã±ãŒã·ã§ã³ã®ããŒãžéã®é·ç§»ã¯ã·ã¹ãã æ©èœã䜿çšããŸãã ããã¯èªåçã«è¡ããããµã€ãã³ãŒããžã®ä»å ¥ã¯äžèŠã§ãã
ãããã©ã®ããã«è¡ããããã«ã€ããŠè©±ãåã«ãåççãªè³ªåããããããããŸããã ããã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã®ã³ã³ããå ã®WebããŒãžïŒã
ãã質åã§ããã å®éããã®èšäºã¯ãã®çãã«å°å¿µããŠããŸãã äžèšã§èšãã°ãããã§æ€èšããæ¹æ³è«ã®æ¬è³ªã¯ãWebã³ã³ãã³ãã衚瀺ããã³ã³ãããšã¢ããªã±ãŒã·ã§ã³ã®éã«åæ¹åã®éä¿¡ãã£ãã«ãäœæããããšã§ãã ããã«ãããã¢ããªã±ãŒã·ã§ã³ã¯ã³ã³ããå ã«ããJavaScripté¢æ°ãåŒã³åºãããšãã§ããã³ã³ããã¯å€éšã«ãããã€ãã£ãAPIãžã®ã¢ã¯ã»ã¹ãèš±å¯ããŸãã
äžèšã®äŸãèŠãŠãã ããã
QRã³ãŒãç³è«
ãã®ã¢ããªã±ãŒã·ã§ã³ã®äž»ãªã³ã³ããŒãã³ãã¯æ¬¡ã®ãšããã§ãã
- çµã¿èŸŒã¿ã®ããã²ãŒã·ã§ã³æ©èœããµããŒããããã€ãã£ãããã²ãŒã·ã§ã³ããããŒã
- Webã¢ããªã±ãŒã·ã§ã³ãçæããQRã³ãŒããåã蟌ãŸããŠããWebViewèŠçŽ ã
- ãŠã£ã³ããŠã®äžéšã«ããã¹ããå
¥åããããã®ã·ã¹ãã ã³ã³ããŒãã³ãã
ãããã®ãã¹ãŠã®èŠçŽ ã®èª¬æã¯ãäžèšã®JSONããŒã¯ã¢ããå±æ§ãšåæ§ã®å±æ§ãç §åããã ãã§å®è¡ã§ããŸãã
æåŸã«ãã¢ããªã±ãŒã·ã§ã³ã³ã³ããŒãã³ãã®çžäºäœçšãããã«ç€ºãããŠãããšããäºå®ã«æ³šæãæã£ãŠãã ããã ã€ãŸããæ°ããããŒã¿ãå ¥åãããšQRã³ãŒããå€æŽãããŸãã ããã¯ã転éãããããŒã¿ã«åºã¥ããŠQRã³ãŒããäœæããWebã¢ããªã±ãŒã·ã§ã³å ã«ããJavaScripté¢æ°ãåŒã³åºãæ©èœã®ãããã§ãã
ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®éçºã®ããã®ãã¬ãŒã ã¯ãŒã¯ã®ãããããããã€ãã£ãã¢ããªã±ãŒã·ã§ã³ãžã®Webã³ã³ãããŒã®ééçãªçµ±åãã®åé¡ãæ ¹æ¬çã«è§£æ±ºããããšããªãã£ãããšã«æ³šæããŠãã ããã
ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®æªæ¥ã«ã€ããŠè©±ããšããããã¯éåžžãHTML5ãŸãã¯ãã€ãã£ãAPIã«åºã¥ããŠãã©ã¡ãã®ã¢ãããŒããåã€ããšããåé¡ãäžå¿ã«å±éããŸãã ç¹åŸŽçãªã®ã¯ããã®ãããªæšè«ã§ã¯ãããã2ã€ã®ã¢ãããŒãã®å ±åãšããããŒãã¯æèµ·ãããŠããããããã«ãçžä¹å¹æã®å¹æã¯èæ ®ãããŠããŸãããããã¯ãããŸããŸãªæè¡ã®å ±å䜿çšã®ãããã§ãéæããã®ã容æã§ã¯ãªãçµæã1ã€ã ãã«é Œãããšãã§ããŸã
ãã®èšäºã§ã¯ã次ã®ããšã«ã€ããŠã話ããŸãã
- å€ãã®å ŽåãWebã³ãŒããšãã€ãã£ãã³ã³ããŒãã³ããå
±æããããšããå§ãããŸãã
- HTMLãšãã€ãã£ãã³ã³ããŒãã³ãã®ééçãªçµ±åãç°¡åãªã¿ã¹ã¯ã§ã¯ãªãçç±ãšããããã©ããã£ãŠè§£æ±ºãããã«ã€ããŠã
- ãããŠãæãéèŠãªããšãšããŠãããã§èª¬æãããã¯ãããžãŒã䜿çšããŠãç¬èªã®ã¢ããªã±ãŒã·ã§ã³ãè¿
éã«éçºããæ¹æ³ã«ã€ããŠèª¬æããŸãã
ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã§Webãã¯ãããžãŒã䜿çšããçç±
ç¶è¡ããåã«ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã§HTMLãšJSã®æ©èœã䜿çšããã®ãéåžžãã©ãããããã³åæ§ã®ã¢ãããŒãããã€åœ¹ç«ã€ãã«ã€ããŠæåã«è©±ããŸãããã Webãã¯ãããžãŒãšã¢ãã€ã«ãã©ãããã©ãŒã ã®ãã€ãã£ãæ©èœãçµã¿åããããšäŸ¿å©ãªå ŽåããããŸãã
â1ã Webçšã«äœæããããã¯ãããžãŒã®äœ¿çš
ã¢ããªã±ãŒã·ã§ã³ã®äžéšã®å®è£ ã§ã¯ãWebãã¯ãããžãŒã䜿çšããã®ãçã«ããªã£ãŠããå ŽåããããŸãã ããšãã°ã WebSocketã¯WebããŒã¹ã®ãã¯ãããžãŒã§ãã ããã䜿çšããã«ã¯ãWebSocketãåã«ããšãã¥ã¬ãŒãããããµãŒãããŒãã£ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãã代ããã«ãã¢ãã€ã«ãã©ãããã©ãŒã ã«çµã¿èŸŒãŸããWebãšã³ãžã³ïŒiOSã®
WKWebView
ããã³Androidã®
WebView
ïŒã䜿çšã§ããŸãã
ãã®ã¢ãããŒãã§ã¯ãè¿œå ã®ã©ã€ãã©ãªã䜿çšããå¿ èŠã¯ãããŸãããå¿ èŠãªããšãå®è¡ããã«ã¯ãæšæºãã¯ãããžãŒã䜿çšããŠååã§ãã ããã¯æ¬¡ã®ç¶æ³ã«ç§ãã¡ãå°ããŸãã
â2ã ã¢ããªã±ãŒã·ã§ã³ããã±ãŒãžã®ãµã€ãºãçž®å°ãã
ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã§Webãã¯ãããžãŒã䜿çšãããšããããã®ãã¯ãããžãŒãªãã§ã¯å·šå€§ãªãµãŒãããŒãã£ã©ã€ãã©ãªãå¿ èŠã«ãªãããšãå®è¡ã§ããŸãã
ããšãã°ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«QRã³ãŒããžã§ãã¬ãŒã¿ãŒãåã蟌ãã«ã¯ãã¢ããªã±ãŒã·ã§ã³ããã±ãŒãžã®ãµã€ãºã倧ãããããµãŒãããŒãã£ã©ã€ãã©ãªãå¿ èŠã§ãã ãã ããã·ã³ãã«ãª
<script>
ã³ã³ã¹ãã©ã¯ãã䜿çšããŠWebããŒãžãšããŒãžã«æ¥ç¶ãããJSã©ã€ãã©ãªã衚瀺ããããã®æšæºããŒã«ã䜿çšããå ŽåããµãŒãããŒãã£ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããã«å¿ èŠãªãã¹ãŠãååŸã§ããŸãã
â3ã ä¿¡é Œã§ããã¢ãã€ã«ã©ã€ãã©ãªã®äžè¶³ã®åé¡ã解決ãã
ä¿¡é Œæ§ãé«ãå®å®ããã¢ãã€ã«å®è£ ã¯ãææ°ã®ãã¯ãããžãŒã®ããã€ãã«å¯ŸããŠãŸã äœæãããŠããŸããã ãã ãããããã®ãã¯ãããžãŒã®ã»ãšãã©ã¯Webç°å¢ã§äœ¿çšã§ããŸãã ãã®çµæãããããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«çµ±åããæãå¹æçãªæ¹æ³ã¯ãé©åãªJavaScriptã©ã€ãã©ãªã䜿çšããããšã§ãã
â4ã ã¢ãã€ã«ãã©ãããã©ãŒã ãšWebã¢ããªã±ãŒã·ã§ã³ã®äž¡æ¹ã®æ©èœã䜿çšãããããžã§ã¯ãã®éçº
Webãµã€ããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«å€æããããšããå€ãã®åå¿è éçºè ã¯å°é£ãªç¶æ³ã«é¥ããWebãããžã§ã¯ãã®äžéšã®æ©èœã¯ãã¿ãŒã²ããã¢ãã€ã«ãã©ãããã©ãŒã ããšã«ãŒãããåäœæããã«ã¯è€éãããããšãããããŸãã
ããšãã°ãç¹å®ã®ãµã€ãã®ããŒãžã®1ã€ãè€éãããŠã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®åœ¢åŒã«ãã°ããå€æã§ããªãå ŽåããããŸããããµã€ãã®ä»ã®ã³ã³ãã³ãã¯ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«ç°¡åã«ç§»æ€ã§ããŸãã
ãã®ãããªå Žåãã»ãšãã©ã®ã¢ããªã±ãŒã·ã§ã³ãã¢ãã€ã«ãã©ãããã©ãŒã ã䜿çšããŠäœæã§ããã°éåžžã«åœ¹ç«ã¡ãŸãããç¹ã«è€éãªããŒãžã¯å ã®åœ¢åŒã§ã¢ããªã±ãŒã·ã§ã³ã«ééçã«çµ±åã§ããŸãã
ã©ã®ããã«æ©èœããŸããïŒ
âAã ãžã£ãœããã
Jasonetteã¯ãJSONããŒã¯ã¢ããã«åºã¥ããã¯ãã¹ãã©ãããã©ãŒã ãã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã®äœæãç®çãšãããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã§ãã
Jasonetteãã¬ãŒã ã¯ãŒã¯ã¯Webãã©ãŠã¶ãŒã«äŒŒãŠããŸãããHTMLã³ãŒããWebããŒãžã«å€æãã代ããã«ãJSONããŒã¯ã¢ãããiOSããã³Androidã®ãã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã«å€æããŸãã ãã©ãŠã¶ãŒãšã®é¡äŒŒç¹ã¯ãJasonetteã«åºã¥ãã¢ããªã±ãŒã·ã§ã³ã«ã¯ãæçµçãªã¢ããªã±ãŒã·ã§ã³ã®äœæããã»ã¹ã§ç°ãªãJSONããŒã¿ã»ããã解éããåãåºæ¬ã³ãŒãããããšããäºå®ã«ãããŸãã éçºè ã¯ã©ã€ãã©ãªã³ãŒããæäœããå¿ èŠã¯ãããŸããã ã¢ããªã±ãŒã·ã§ã³ãäœæããããã»ã¹ã¯ãJSONèšè¿°ãæºåããããšã§ããããã«ãããJasonetteã¯ãªã¢ã«ã¿ã€ã ã§WebããŒãžããã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã«å€æã§ããŸãã
Jasonetteã«ã€ããŠè©³ããã¯ãã¡ããã芧ãã ãã ã äžè¬ã«ãJasonetteãããžã§ã¯ãã¯ãã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã®éçºãç®çãšããŠããŸããããã§ã¯ããããã®ãã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã«HTMLããŒãžãçµ±åããæ¹æ³ã«ã€ããŠèª¬æããŸãã
âBã Jasonette Webã³ã³ãããŒ
ãã€ãã£ãã®ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³èªäœã¯åªããŠããŸãããæšæºã®Webã³ã³ããã䜿çšããŠå®è¡ã§ããWebãã¯ãããžãŒã䜿çšãããå ŽåããããŸãã ãã ããã¢ããªã±ãŒã·ã§ã³ãžã®çµ±åã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããã Webãã¯ãããžãŒããã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã«ã·ãŒã ã¬ã¹ã«çµ±åããããã«å¿ èŠãªãã®ã¯æ¬¡ã®ãšããã§ãã
- Webã³ã³ããã¯ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã€ã³ã¿ãŒãã§ã€ã¹ã®èªç¶ãªéšåã§ããå¿
èŠããããŸãã ã³ã³ããã¯ãã¢ããªã±ãŒã·ã§ã³ã®ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®ä»ã®ã³ã³ããŒãã³ãã®ããã«èŠããã¯ãã§ãã ãã以å€ã®å Žåã¯ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«è¡šç€ºãããWebãµã€ãã§ããå®éã®ç¶æ
ã®ããã«èŠãããæ±ãã«ãããã®ã«ãªããŸãã
- 芪ã¢ããªã±ãŒã·ã§ã³ã¯ãåWebã³ã³ãããå¶åŸ¡ã§ããå¿
èŠããããŸãã ãã®ã¢ãããŒãã䜿çšãããšãWebããŒãžã®ã³ã³ãã³ãã衚瀺ããã³ã³ãããŒã«ã®äžéšã§ããã¢ããªã±ãŒã·ã§ã³ã«ã圱é¿ãäžãã䟿å©ãªæ段ãæäŸãããŸãã
- åWebã³ã³ããã¯ã芪ã¢ããªã±ãŒã·ã§ã³ã§ã·ã¹ãã ã€ãã³ããããªã¬ãŒã§ããå¿
èŠããããŸãã ã¢ããªã±ãŒã·ã§ã³ã«åã蟌ãŸããWebã³ã³ããã«ã¯ããã€ãã£ãAPIã«ã¢ã¯ã»ã¹ããæ©èœãå¿
èŠã§ãã
å®éãããããã¹ãŠãå®è£ ããã«ã¯å€å€§ãªåŽåãå¿ èŠãªã®ã§ããã®ãªã¹ãã®æåã®æ®µèœããå§ããŸããããã€ãã£ãã¢ããªã±ãŒã·ã§ã³ã®ããŒãžã«Webã³ã³ãããåã蟌ãã ãã§ãã ããã§ã JSON Web Containerã®æåã®ããŒãžã§ã³ããªãªãŒã¹ããŸããã
ãã®ããšã¯æçšã§ããããšãå€æããŸãããã芪ã¢ããªã±ãŒã·ã§ã³ããã³Webã³ã³ãããŒãšå¯Ÿè©±ããæ©èœãæ¬ ããŠããŸããã ã€ãŸãã芪ã¢ããªã±ãŒã·ã§ã³ã¯Webã³ã³ãããå¶åŸ¡ã§ãããã³ã³ããã¯èŠªã¢ããªã±ãŒã·ã§ã³ã«ã¢ã¯ã»ã¹ã§ããŸããã§ããã ãã®çµæãã³ã³ããã¯ã¢ããªã±ãŒã·ã§ã³ãšããŠã®ç°å¢ããå®å šã«éé¢ãããŸããã
âCã Jasonette Web Container 2.0ïŒã¢ããªã±ãŒã·ã§ã³ãšã³ã³ãããŒã®çžäºäœçš
æåã®ããŒãžã§ã³ã®ãªãªãŒã¹åŸãäžèšã®ã¿ã¹ã¯ã®2çªç®ã®éšåãè©ŠããŸãããããã¯ãã³ã³ãããŒã芪ã¢ããªã±ãŒã·ã§ã³ãšå¯Ÿè©±ã§ããããã«ããããšã§ããã
éåžžã®Webã³ã³ããã«ã€ã³ã¿ã©ã¯ãã£ãæ©èœãè¿œå ããæ¹æ³ã説æããŸããããããã«ãããã¯ããã«åŒ·åã§èå³æ·±ããã®ã«ãªããŸããã
å®è£ ïŒã€ã³ã¿ã©ã¯ãã£ãWebã³ã³ãã
â1ã URLã®èªã¿èŸŒã¿
ææŠãã
以åã æåã®ããŒãžã§ã³ã§ã¯ãããŒã¿ã衚瀺ããããã®ã³ã³ããŒãã³ããšããŠWebã³ã³ãããŒã䜿çšããããã«ãæåã«å±æ§
$jason.body.background.type
ã«
"html"
ãèšè¿°ãã次ã«å±æ§
$jason.body.background.text
ãHTMLã³ãŒããå ¥åããŸãã
{ "$jason": { "head": { ... }, "body": { "background": { "type": "html", "text": "<html><body><h1>Hello World</h1></body></html>" } } } }
éçºè ã«ãšã£ãŠãããŒãžã®HTMLã³ãŒãå šäœã1è¡ã§å ¥åããã®ã§ã¯ãªããWebããŒãžãžã®éåžžã®ãªã³ã¯ã䜿çšããŠã³ã³ãããåæåããæ¹ã䟿å©ã§ããããšã¯éåžžã«èªç¶ã§ãã
解決ç
Web Container 2.0ã§ã¯
url
å±æ§ãå°å ¥ãããŸããã ç¹ã«ãããŒã«ã«ãã¡ã€ã«ããµããŒãããŸãã
file://...
ã䜿çšããããšã§ã
file://...
ã³ã³ãããŒå ã®æ§æäœã䜿çšããŠãã¢ããªã±ãŒã·ã§ã³ã«ä»å±ã®ãã¡ã€ã«ã衚瀺ã§ããŸãã
{ "$jason": { "head": { ... }, "body": { "background": { "type": "html", "url": "file://index.html" } } } }
WebããŒãžãåæ§ã®æ¹æ³ã§ã€ã³ã¿ãŒãããããåºåãããŸãïŒ
http[s]://âŠ
ãšãã圢åŒã®æ§æã䜿çšïŒã
{ "$jason": { "head": { ... }, "body": { "background": { "type": "html", "url": "https://news.ycombinator.com" } } } }
â2ã ã¢ããªã±ãŒã·ã§ã³ãšWebã³ã³ããéã®åæ¹åã®çžäºäœçš
ææŠãã
以åã¯ãWebã³ã³ããã¯ç¹å®ã®ã³ã³ãã³ãã衚瀺ããããã«ã®ã¿äœ¿çšãããã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ãšå¯Ÿè©±ã§ããŸããã§ããã ããã¯ããããã䜿çšããããã®æ¬¡ã®ã·ããªãªãäžå¯èœã§ããããšãæå³ããŸããã
- Webã³ã³ãããžã®Jasonetteã®åœ±é¿ã ã€ãŸããã³ã³ããã«ããJavaScripté¢æ°ãJasonetteã¢ããªã±ãŒã·ã§ã³ããåŒã³åºãããšã¯ã§ããŸããã§ããã
- Jasonetteãžã®ã³ã³ããã®åœ±é¿ã ã³ã³ããå
ã«ããã³ãŒããããã€ãã£ãAPIãåŒã³åºãããšã¯ã§ããŸããã§ããã
Webã³ã³ããã¯ããŒãžã®è¡šç€ºã«ã®ã¿äœ¿çšã§ããŸãã ããã¯ãããŒãžããããã®èŠçŽ å ã«ãããã®ã«ã¢ã¯ã»ã¹ã§ããªãå Žåã«ã
iframe
èŠçŽ ãéåžžã®WebããŒãžã«åã蟌ãŸããæ¹æ³ã«äŒŒãŠããŸãã
解決ç
Jasonetteãããžã§ã¯ãã®ç®æšã¯ãã¯ãã¹ãã©ãããã©ãŒã ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãèšè¿°ããæšæºã®ããŒã¯ã¢ããèšèªãäœæããããšã§ãã ãã®å Žåã芪ã¢ããªã±ãŒã·ã§ã³ãšåWebã³ã³ãããŒéã®çžäºäœçšãæ£ç¢ºã«èšè¿°ããããšãã§ããããŒã¯ã¢ããèšèªãå¿ èŠã§ãã
ãããéæããããã«ã JSON-RPCãã¯ãããžãŒã䜿çšããŠãã¢ããªã±ãŒã·ã§ã³ãšWebã³ã³ãããŒã®çžäºäœçšã確ç«ããããšãã§ããŸããã Jasonetteã®ãã¹ãŠãJSONãªããžã§ã¯ããšããŠè¡šçŸããããããéä¿¡ãããã³ã«ãšããŠæšæºã®JSON-RPC圢åŒã䜿çšããããšã¯å®å šã«èªç¶ã§ããã
JSON-RPCã䜿çšããåã¯ãJasonetteãšWebã³ã³ãããŒã¯çžäºäœçšã§ããŸããã§ããã JSON-RPCã®å®è£ åŸãã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ãšã³ã³ãããŒéã®åæ¹åéä¿¡ãå¯èœã«ãªããŸãã
Webã³ã³ããã«ããJSé¢æ°ãåŒã³åºãããšãã§ããããã«ãã¢ã¯ã·ã§ã³
$agent.request
ã宣èšããŸãã
{ "type": "$agent.request", "options": { "id": "$webcontainer", "method": "login", "params": ["username", "password"] } }
$ agent.requestã¯ãWebã³ã³ãããžã®JSON-RPCãªã¯ãšã¹ããéå§ãããã€ãã£ãAPIã§ãã ãã®ã¡ã«ããºã ã䜿çšããã«ã¯ã
options
ãªããžã§ã¯ãããã©ã¡ãŒã¿ãŒãšããŠæž¡ãå¿ èŠããããŸãã
options
ãªããžã§ã¯ãã¯ãWebã³ã³ããã«éä¿¡ãããJSON-RPCãªã¯ãšã¹ãã§ãã
ãã®å±æ§ãèæ ®ããŠãã ããã
-
id
ïŒWebã³ã³ããã¯ããšãŒãžã§ã³ãã®äœã¬ãã«ã¢ãŒããã¯ãã£ã®äžã«æ§ç¯ãããŸãã éåžžãè€æ°ã®ãšãŒãžã§ã³ããåäžã®view
é¢é£ä»ããããšãã§ãview
ãåview
ã«ã¯äžæã®èå¥åïŒIDïŒããããŸãã ãã ããWebã³ã³ããã¯ãèå¥å$webcontainer
ã®ã¿ãæã€ããšãã§ããç¹å¥ãªã¿ã€ãã®ãšãŒãžã§ã³ãã§ãããã®ããããªã¯ãšã¹ãã§ãã®èå¥åã䜿çšããŸãã
-
method
ïŒåŒã³åºãJavaScripté¢æ°ã®ååã
-
params
ïŒåŒã³åºãããJSé¢æ°ã«æž¡ããã©ã¡ãŒã¿ãŒã®é åã
èšè¿°ãããããŒã¯ã¢ããã®å®å šãªã³ãŒãã¯æ¬¡ã®ãšããã§ãã
{ "$jason": { "head": { "actions": { "$load": { "type": "$agent.request", "options": { "id": "$webcontainer", "method": "login", "params": ["alice", "1234"] } } } }, "body": { "header": { "title": "Web Container 2.0" }, "background": { "type": "html", "url": "file://index.html" } } } }
ããã§äžããããã³ãŒãã®æå³ãèæ ®ããŠãã ããã
èŠçŽ ïŒ$ jason.head.actionsã$ Load ïŒãããŒãããå ŽåãWebã³ã³ãããšãŒãžã§ã³ãïŒ $ agent.request ïŒã®
options
説æãããŠããJSON-RPCãªã¯ãšã¹ããå®è¡ããå¿ èŠããã
options
ã
Webã³ã³ããã®ãã©ã¡ãŒã¿ãŒã¯$ jason.body.backgroundã§èšå®ãã
file://index.html
ãã®å ŽåãããŒã«ã«ãã¡ã€ã«
file://index.html
ã
ã³ã³ããã®åŒã³åºãäžã«ã
login
é¢æ°ãæ€çŽ¢ãã
login
é¢æ°ãåŒã³åºããããšã
params
ãããã§2ã€ã®åŒæ°
"alice"
ãš
"1234"
ãæž¡ãããŸãã 次ã®ããã«ãªããŸãã
login("alice", "1234")
ããã§ã¯ã芪ã¢ããªã±ãŒã·ã§ã³ãWebã³ã³ãããŒããJSé¢æ°ãåŒã³åºãæ¹æ³ã«ã€ããŠã®ã¿èª¬æããŸããããã³ã³ãããŒãã¢ããªã±ãŒã·ã§ã³ãåŒã³åºããŠãã€ãã£ãAPIãåŒã³åºããšãã«ã éã®ããã»ã¹ãå¯èœã§ãã 詳现ã«ã€ããŠã¯ããšãŒãžã§ã³ãã®ããã¥ã¡ã³ããåç §ããŠãã ããã
äŸ
QRã³ãŒããäœæããããã®ã¢ããªã±ãŒã·ã§ã³ã®äŸã説æããŸããããããã¯æ¢ã«äžã§èŠãŸããã
QRã³ãŒãç³è«
- ãŠã£ã³ããŠã®äžéšã«ããããã¹ãå
¥åã³ã³ããŒãã³ãã¯ã100ïŒ
ãã€ãã£ãã§ãã
- QRã³ãŒãã¯ãWebã³ã³ãããŒã§ãã¹ããããWebã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠçæãããŸã ã
- ãŠãŒã¶ãŒããã£ãŒã«ãã«ããã¹ããå
¥åããŠ[
Generate
]ãã¿ã³Generate
æŒããšãWebã³ã³ãããŒãšãŒãžã§ã³ãã®$agent.request
ãåŒã³åºãããqr
JSé¢æ°ãåŒã³åºãããŸãã
ãã®ã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒãã¯ãã¡ãã§ã芧ããã ããŸã
â3ã ã¹ã¯ãªããã€ã³ãžã§ã¯ã·ã§ã³
ææŠãã
HTMLãœãŒã¹ãèªã¿èŸŒãŸããåŸã«JavaScriptã³ãŒããWebã³ã³ããã«åçã«åã蟌ãå¿ èŠãããå ŽåããããŸãã
ç¬èªã®Webãã©ãŠã¶ãäœæããããšæ³åããŠãã ããã ãããè¡ãã«ã¯ãåäœã«åœ±é¿ãäžããããã«ãåWebã³ã³ããã«JSã¹ã¯ãªãããåã蟌ãå¿ èŠããããŸãã å³å¯ã«èšãã°ããããWebãã©ãŠã¶ãŒã®æ¡åŒµæ©èœã®ä»çµã¿ã§ãã
Webãã©ãŠã¶ãŒãéçºããŠããªãå Žåã§ããçŽæ¥å¶åŸ¡ã§ããªãããŒãžã«å¿ èŠãªåäœãæäŸããå¿ èŠãããå Žåã¯ãã¹ã¯ãªããã€ã³ãžã§ã¯ã·ã§ã³ã䜿çšããå¿ èŠããããŸãã ã¢ãã€ã«ã¢ããªãšWebã³ã³ããã察話ããå¯äžã®æ¹æ³ã¯ã
$agent
APIã䜿çšããããšã§ãã ãã ããHTMLã³ã³ãã³ããå€æŽã§ããªãå Žåã
$agent
ã€ã³ã¿ãŒãã§ã€ã¹ãWebã³ã³ããã«è¿œå ããå¯äžã®æ¹æ³ã¯ãã¹ã¯ãªãããåçã«æ¿å ¥ããããšã§ãã
解決ç
ãã§ã«è¿°ã¹ãããã«ã
$jason.body.background
Webã³ã³ãããŒã¯åãªããšãŒãžã§ã³ãã§ãã ããã¯ãããã䜿çšããå Žåãéåžžã®ãšãŒãžã§ã³ãã䜿çšããå Žåãšåã
$agent.inject
ã¡ãœããã䜿çšã§ããããšãæå³ããŸãã
Webã³ã³ãããŒã«ããŒããããããŒãžã«JSã³ãŒããåã蟌ã
â4ã URLããã²ãŒã·ã§ã³åŠç
以åã¯ãWebã³ã³ããã¯2ã€ã®ã¢ãŒãã®ããããã§ã2ã€ã®æ¹æ³ã§ã®ã¿ãªã³ã¯ã®ã¯ãªãã¯ãåŠçã§ããŸããã
- èªã¿åãå°çšã¢ãŒãã§ã¯ãWebã³ã³ãããŒã¯èªã¿åãå°çšèŠçŽ ãšèŠãªãããŸãããã¿ãããã¹ã¯ããŒã«ãªã©ã®ãã¹ãŠã®ã€ãã³ãã¯ç¡èŠãããŸãã 以äžã§èª¬æããããã«ããã¹ãŠã®Webã³ã³ãããŒã¯ãéåžžã®ãã©ãŠã¶ãŒã¢ãŒãã«åãæ¿ãããããŸã§èªã¿åãå°çšç¶æ
ã§ãã
- ãéåžžã®ãã©ãŠã¶ãã¢ãŒãã§ã¯ãWebã³ã³ããã¯éåžžã®ãã©ãŠã¶ã§äœæ¥ããŠãããã®ããã«ããŒãžãšå¯Ÿè©±ã§ããŸãã ãã®ã¢ãŒããæå¹ã«ããã«ã¯ãå€
"type": "$default"
ãaction
å±æ§ã«æžã蟌ã¿ãŸãã
ææŠãã
ããã§ã®åé¡ã¯ãäžèšã§èª¬æãããªãã·ã§ã³ã®äž¡æ¹ããããã¹ãŠãŸãã¯ç¡ãã®æŠå¿µãè¡šããœãªã¥ãŒã·ã§ã³ã§ããããšã§ãã
èªã¿åãå°çšã¢ãŒãã§äœæ¥ããŠããå Žåãã³ã³ããã¯ãã¹ãŠã®ãŠãŒã¶ãŒæäœãç¡èŠããŸãã
ãéåžžã®ãã©ãŠã¶ãã¢ãŒãã§åäœããŠããå ŽåãWebã³ã³ããã¯æåéããã©ãŠã¶ã®ããã«æ©èœããŸãã ãŠãŒã¶ãŒããªã³ã¯ãã¿ãããããšããªã³ã¯ãã€ãªããããŒãžãèªã¿èŸŒãŸããŸãã åæã«ãéçºè ã«ã¯ããã®ã€ãã³ããã€ã³ã¿ãŒã»ããããŠãããšãã°ãããçš®ã®ãã€ãã£ãAPIãåŒã³åºãæ©äŒããããŸããã
解決ç
æ°ããWebã³ã³ããã®æ©èœã®ãããã§ããªã³ã¯ã®ã¯ãªãã¯ãåŠçããã¡ã«ããºã ã®èª¬æãå«ã
$jason.body.background
action
å±æ§ãèšå®ã§ããŸãã
ãªã³ã¯ã€ã³ã¿ã©ã¯ã·ã§ã³ãåŠçããããã®ã¢ã¯ã·ã§ã³
äŸãèããŠã¿ãŸãããã
{ "$jason": { "head": { "actions": { "displayBanner": { "type": "$util.banner", "options": { "title": "Clicked", "description": "Link {{$jason.url}} clicked!" } } } }, "body": { "background": { "type": "html", "url": "file://index.html", "action": { "trigger": "displayBanner" } } } } }
ããã§ã
"trigger": "displayBanner"
ã¢ã¯ã·ã§ã³
"trigger": "displayBanner"
ãWebã³ã³ãããŒã«
"trigger": "displayBanner"
ããŸããã ããã¯ããŠãŒã¶ãŒãWebã³ã³ããã«è¡šç€ºãããŠããããŒãžã«è¡šç€ºãããŠãããªã³ã¯ãã¯ãªãã¯ãããšã
displayBanner
ã¢ã¯ã·ã§ã³ãåŒã³åºãããããšãæå³ããŸãã ãã ããWebã³ã³ããèªäœã¯ãªã³ã¯ã®ã¯ãªãã¯ãåŠçããŸããã
ããã«ã
displayBanner
ã€ãã³ããåæãããšã
$jason
å€æ°ã«æ°ä»ãã§ãããã ãã®å Žåãã¯ãªãã¯ããããªã³ã¯ã¯ããã®å€æ°ãä»ããŠã¢ã¯ã·ã§ã³ã«æž¡ãããŸãã ããšãã°ãã¢ãã¬ã¹
"https://google.com"
ãå«ããªã³ã¯ãã¯ãªãã¯ãããšã次ã
$jason
ããŸãã
{ "url": "https://google.com" }
ããã¯ã
$jason.url
ã®å€ãåæããããšã«ãããããŸããŸãªã¢ã¯ã·ã§ã³ãåŒã³åºãããšãã§ããããšãæå³ããŸãã
å¥ã®äŸãèããŠã¿ãŸããããããã¯Webãã©ãŠã¶ãŒã®å®è£ ã§ãã
{ "$jason": { "head": { "actions": { "handleLink": [{ "{{#if $jason.url.indexOf('signin') !== -1 }}": { "type": "$href", "options": { "url": "file://key.html" } } }, { "{{#else}}": { "type": "$default" } }] } }, "body": { "background": { "type": "html", "url": "file://index.html", "action": { "trigger": "handleLink" } } } } }
ããã§ã¯ãURLã«
signin
æååãå«ãŸããŠãããã©ããããã§ãã¯ãããã§ãã¯ã®çµæã«å¿ããŠãããŸããŸãªã¢ã¯ã·ã§ã³ãå®è¡ããŸãã
- URLã«
signin
ãå«ãŸããå Žåããã€ãã£ããã°ã€ã³ãŠã£ã³ããŠãéããŸãã
- URLã«ãã®è¡ãå«ãŸããŠããªãå Žåã
"type": "$default"
ãã©ã¡ãŒã¿ãŒã§æå®ãããã¢ã¯ã·ã§ã³ãå®è¡ãããŸã"type": "$default"
ããã®çµæãããã°ã©ã ã¯éåžžã®ãã©ãŠã¶ãŒã®ããã«åäœããŸãã
äŸ
âWebãã©ãŠã¶éçº
ããã§ãã¢ããªã±ãŒã·ã§ã³éçºã«æ°ããWebã³ã³ããèŠçŽ ã掻çšã§ããŸãã ã€ãŸããç§ãã¡ã¯æ¬¡ã®ããšã«ã€ããŠè©±ããŠããïŒ
- éåžžã®ãã©ãŠã¶ã®åäœã«å¯Ÿå¿ããããªã³ã¯ã®ã¯ãªãã¯ã®æšæºåŠçã®å¯èœæ§ã
- ã³ã³ãã³ãã«åºã¥ããŠãªã³ã¯ã®ã¯ãªãã¯ãåŠçããæ©èœã
ããã«ãããããšãã°ãæåéã1.5è¡ã®JSONã³ãŒããèšè¿°ããŠç¬èªã®ãã©ãŠã¶ãŒãäœæããæ©äŒãäžããããŸãã ãªã³ã¯ã®ã¯ãªãã¯ãã€ã³ã¿ãŒã»ããã§ããããã«ãªã£ãããã
$jason.url
ã解æããŠãç°ãªãURLã«å¯Ÿå¿ããã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸãã
äŸãèããŠã¿ãŸãããã
æšæºçãªãã©ãŠã¶ã®åäœ
ããã§ãWebã³ã³ããã¯éåžžã®ãã©ãŠã¶ã®ããã«åäœããŸãïŒ
"type": "$default"
ïŒã
$ jason.urlãã©ã¡ãŒã¿ãŒã®åæã«åºã¥ãåäœ
ããã§ããªã³ã¯ãã¯ãªãã¯ãããšãããŒãžéã®ãã€ãã£ãé·ç§»ãé©çšãããŸãã
ããã¯ã
$jason.url
å€ã«åºã¥ããŠããŸããŸãªã¢ã¯ã·ã§ã³ãåŠçããããšã§å®çŸã§ããŸãã
ãã®ãããªã¢ããªã±ãŒã·ã§ã³ãäœæããæåã®ã¹ãããã¯ã
visit
ã¢ã¯ã·ã§ã³ãWebã³ã³ãããŒã«ã¢ã¿ãããã
visit
ã§ãã
{ ... "body": { "background": { "type": "html", "url": "https://news.ycombinator.com", "action": { "trigger": "visit" } } } }
2çªç®ã®ã¹ãããã¯ã
$jason.url
åæã«åºã¥ããŠã
visit
ã¢ã¯ã·ã§ã³ã§å¯Ÿå¿ããæäœãå®è¡ããããš
$jason.url
ã
以äžã«ã
newest
ã
show
ã
ask
ãªã©ã®è¡ã
$jason.url
å«ãŸããŠãããã©ããããã§ãã¯ããæ¹æ³ã瀺ããŸãïŒ
$jason.url
ãªã³ã¯ããããŸãïŒã ãã®ãããªãã®ãèŠã€ãã£ãå Žåã¯ãWebã³ã³ãããŒãéåžžã®ãã©ãŠã¶ãŒã®ããã«åäœã§ããããã«ããå€ã
"type": "$default"
ã
äžèšã®ãã³ãã¬ãŒãã«äžèŽãããã®ãèŠã€ãããªãã£ãå Žåã¯ã
$href
ãã€ãã£ããæ°ãããŠã£ã³ããŠã«åãæ¿ãããŠãŒã¶ãŒãã¯ãªãã¯ããURLããã©ã¡ãŒã¿ãŒãšããŠæž¡ããŸãã
... "actions": { "visit": [ { "{{#if /\\/(newest|show|ask)$/.test($jason.url) }}": { "type": "$default" } }, { "{{#else}}": { "type": "$href", "options": { "url": "https://jasonette.github.io/Jasonpedia/webcontainer/agent/hijack.json", "preload": { "background": "#ffffff" }, "options": { "url": "{{$jason.url}}" } } } } ] },
ãã㧠ããã®äŸã®å®å šãªJSONã³ãŒããèŠãããšãã§ããŸããããã¯ããã£ã48è¡ããå¿ èŠãšããŸããã
hybridãã€ããªããã¢ããªã±ãŒã·ã§ã³ã®é«ééçº
ããã€ããªãããã¢ããªã±ãŒã·ã§ã³ãšã¯ãéåžžããã€ãã£ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«ãã©ããããããéåžžã®Webã¢ããªã±ãŒã·ã§ã³ãæå³ããŸãã
ãã ããããã§ã¯å¥ã®ããšã念é ã«çœ®ããŠããŸãã ç§ãã¡ã®å Žåãåãã¢ããªã±ãŒã·ã§ã³ãè€æ°ã®ãã€ãã£ãè¡šçŸãšè€æ°ã®Webè¡šçŸãåæã«æã€ããšãã§ããå Žåãå®éã®ãã€ããªããã¢ããªã±ãŒã·ã§ã³ã«ã€ããŠè©±ããŸãã ããã«ããã®ãããªã¢ããªã±ãŒã·ã§ã³ã®1ã€ã®è¡šçŸã«ã¯ãããã€ãã®ãã€ãã£ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã³ã³ããŒãã³ããšWebã³ã³ãããå«ããããšãã§ãããããã¯ãã¹ãŠ1ã€ã®ãã€ãã£ãã¬ã€ã¢ãŠãã§è¡šç€ºãããŸãã
Webã³ã³ãã³ãã衚瀺ããã³ã³ãããŒã«ãšæšæºã³ã³ãããŒã«ã®éã®ç§»è¡ã¯ããããã®éã®å¢çãæ€åºããããšãå°é£ã«ãªãã»ã©ç®ã«èŠããªãããã«ããå¿ èŠããããŸãã
ãã€ããªããã¢ããªã±ãŒã·ã§ã³
ãã®äŸã§ã¯ã jasonbase.comãWebã³ã³ãããŒã«è¡šç€ºããã¢ããªã±ãŒã·ã§ã³ãäœæããŸãããããã¯ãããŒã¿èŠèŠåã®äž»èŠãªèŠçŽ ãšããŠæ©èœããŸãã
Jasonbaseã¯ãJasonetteããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ã®JSONããŒã¯ã¢ããããã¹ãããããã«ç¹å¥ã«äœæããç¡æã®ãã¹ãã£ã³ã°ãµãŒãã¹ã§ãã
, â , Jasonette-, , , -,
$href
JASON.
Jasonbase.com , . - Jasonette- - , , , , , , , .
.
ãŸãšã
, , , .
, , , :
- - .
- JavaScript-, .
- , , API.
, Jasonette, , :
- , , - .
- (JSON-RPC), , , -.
, â , , , , .
, , ( , - , ). , , JS- , .
, Jasonette, , , , . , , , .
, , : « â ». , Jasonette, , , , , , HTML, , .
- Jasonette , -. «» «-». .
, , , , HTML-. , . , .
, , Jasonette - . , . â .
芪æãªãèªè ïŒ Jasonette - ?