11< html >
2-
3- < head >
2+ < head >
43 < meta content ="text/html;charset=utf-8 " http-equiv ="Content-Type " />
5- < link rel ="stylesheet "
6- href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css ">
4+ < link
5+ rel ="stylesheet "
6+ href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css "
7+ />
78 < script src ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js "> </ script >
8- </ head >
9+ </ head >
910
10- < body >
11+ < body >
1112 < script type ="module ">
12- import init , { createClient , ClientConfig } from '../pkg/dojo_c.js' ;
13- import { ThemeManager , UpdateManager } from './setup.js' ;
14-
15- const themeManager = new ThemeManager ( ) ;
16- const updateManager = new UpdateManager ( ) ;
13+ import init , { createClient , ClientConfig } from "../pkg/dojo_c.js" ;
14+ import { ThemeManager , UpdateManager } from "./setup.js" ;
1715
18- async function run ( ) {
19- await init ( ) ;
16+ const themeManager = new ThemeManager ( ) ;
17+ const updateManager = new UpdateManager ( ) ;
2018
21- let config = {
22- rpcUrl : 'http://localhost:5050' ,
23- toriiUrl : 'http://localhost:8080' ,
24- relayUrl : '' ,
25- worldAddress : '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
26- }
19+ async function run ( ) {
20+ await init ( ) ;
2721
28- let cconfig = new ClientConfig ( config . rpcUrl , config . toriiUrl , config . relayUrl , config . worldAddress ) ;
29- const client = await createClient ( cconfig ) ;
22+ let config = {
23+ toriiUrl : "http://localhost:8080" ,
24+ relayUrl : "" ,
25+ worldAddress :
26+ "0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be" ,
27+ } ;
3028
31- let entities = await client . getEntities ( {
32- limit : 10 ,
33- offset : 0 ,
34- dont_include_hashed_keys : true ,
35- order_by : [ ] ,
36- entity_models : [ ] ,
37- entity_updated_after : 0 ,
38-
39- } ) ;
29+ const client = await createClient ( config ) ;
4030
41- updateManager . displayUpdate ( 'fetch' , entities ) ;
31+ let entities = await client . getEntities ( {
32+ limit : 10 ,
33+ offset : 0 ,
34+ dont_include_hashed_keys : true ,
35+ order_by : [ ] ,
36+ entity_models : [ ] ,
37+ entity_updated_after : 0 ,
38+ } ) ;
4239
43- const subscription = await client . onEntityUpdated (
44- [
45- {
46- Keys : {
47- keys : [ undefined ] ,
48- pattern_matching : "VariableLen" ,
49- models : [ ]
50- }
51- }
52- ] , ( entity_id , models ) => {
53- updateManager . displayUpdate ( 'update' , {
54- entity_id : entity_id ,
55- models : models
56- } ) ;
57- } ) ;
40+ updateManager . displayUpdate ( "fetch" , entities ) ;
5841
59- // Keeps the subscription alive.
60- window . addEventListener ( 'beforeunload' , ( ) => {
61- if ( subscription ) {
62- subscription . cancel ( ) ;
63- }
42+ const subscription = await client . onEntityUpdated (
43+ [
44+ {
45+ Keys : {
46+ keys : [ undefined ] ,
47+ pattern_matching : "VariableLen" ,
48+ models : [ ] ,
49+ } ,
50+ } ,
51+ ] ,
52+ ( entity_id , models ) => {
53+ updateManager . displayUpdate ( "update" , {
54+ entity_id : entity_id ,
55+ models : models ,
6456 } ) ;
65- }
57+ }
58+ ) ;
6659
67- run ( ) . catch ( error => {
68- console . error ( error ) ;
69- updateManager . displayUpdate ( 'error' , error . toString ( ) ) ;
60+ // Keeps the subscription alive.
61+ window . addEventListener ( "beforeunload" , ( ) => {
62+ if ( subscription ) {
63+ subscription . cancel ( ) ;
64+ }
7065 } ) ;
66+ }
7167
72- console . log ( "a" ) ;
73- </ script >
74- </ body >
68+ run ( ) . catch ( ( error ) => {
69+ console . error ( error ) ;
70+ updateManager . displayUpdate ( "error" , error . toString ( ) ) ;
71+ } ) ;
7572
76- </ html >
73+ console . log ( "a" ) ;
74+ </ script >
75+ </ body >
76+ </ html >
0 commit comments