Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions playground/entities.html
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
<html>

<head>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
</head>
</head>

<body>
<body>
<script type="module">
import init, { createClient, ClientConfig } from '../pkg/dojo_c.js';
import { ThemeManager, UpdateManager } from './setup.js';

const themeManager = new ThemeManager();
const updateManager = new UpdateManager();
import init, { createClient, ClientConfig } from "../pkg/dojo_c.js";
import { ThemeManager, UpdateManager } from "./setup.js";

async function run() {
await init();
const themeManager = new ThemeManager();
const updateManager = new UpdateManager();

let config = {
rpcUrl: 'http://localhost:5050',
toriiUrl: 'http://localhost:8080',
relayUrl: '',
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
}
async function run() {
await init();

let cconfig = new ClientConfig(config.rpcUrl, config.toriiUrl, config.relayUrl, config.worldAddress);
const client = await createClient(cconfig);
let config = {
toriiUrl: "http://localhost:8080",
relayUrl: "",
worldAddress:
"0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be",
};

let entities = await client.getEntities({
limit: 10,
offset: 0,
dont_include_hashed_keys: true,
order_by: [],
entity_models: [],
entity_updated_after: 0,

});
const client = await createClient(config);

updateManager.displayUpdate('fetch', entities);
let entities = await client.getEntities({
limit: 10,
offset: 0,
dont_include_hashed_keys: true,
order_by: [],
entity_models: [],
entity_updated_after: 0,
});

const subscription = await client.onEntityUpdated(
[
{
Keys: {
keys: [undefined],
pattern_matching: "VariableLen",
models: []
}
}
], (entity_id, models) => {
updateManager.displayUpdate('update', {
entity_id: entity_id,
models: models
});
});
updateManager.displayUpdate("fetch", entities);

// Keeps the subscription alive.
window.addEventListener('beforeunload', () => {
if (subscription) {
subscription.cancel();
}
const subscription = await client.onEntityUpdated(
[
{
Keys: {
keys: [undefined],
pattern_matching: "VariableLen",
models: [],
},
},
],
(entity_id, models) => {
updateManager.displayUpdate("update", {
entity_id: entity_id,
models: models,
});
}
}
);

run().catch(error => {
console.error(error);
updateManager.displayUpdate('error', error.toString());
// Keeps the subscription alive.
window.addEventListener("beforeunload", () => {
if (subscription) {
subscription.cancel();
}
});
}

console.log("a");
</script>
</body>
run().catch((error) => {
console.error(error);
updateManager.displayUpdate("error", error.toString());
});

</html>
console.log("a");
</script>
</body>
</html>
4 changes: 1 addition & 3 deletions playground/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
await init();

let config = {
rpcUrl: 'http://localhost:5050',
toriiUrl: 'http://localhost:8080',
relayUrl: '',
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
}

let cconfig = new ClientConfig(config.rpcUrl, config.toriiUrl, config.relayUrl, config.worldAddress);
const client = await createClient(cconfig);
const client = await createClient(config);

const is_historical = false;

Expand Down
56 changes: 56 additions & 0 deletions playground/tokens.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<html>

</html>

<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
</head>

<body>
<script type="module">
import init, { createClient, ClientConfig } from '../pkg/dojo_c.js';
import { ThemeManager, UpdateManager } from './setup.js';

const themeManager = new ThemeManager();
const updateManager = new UpdateManager();

async function run() {
await init();

let config = {
toriiUrl: 'http://localhost:8080',
relayUrl: '',
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
}

const client = await createClient(config);

let tokens = await client.getTokens([], []);

updateManager.displayUpdate("fetch", tokens);

const subscription = await client.onTokenUpdated([], [], (token) => {
updateManager.displayUpdate("update", token);
});

// Keeps the subscription alive.
window.addEventListener('beforeunload', () => {
if (subscription) {
subscription.cancel();
}
});
}

run().catch(error => {
console.error(error);
updateManager.displayUpdate('error', error.toString());
});

console.log("a");
</script>
</body>

</html>