Skip to content

Commit

Permalink
Update explorer to new protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jun 21, 2024
1 parent b7eaf0a commit a3ce899
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion deps/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20357,7 +20357,7 @@ int ecs_app_run(
}

/* Monitoring periodically collects statistics */
if (desc->enable_monitor) {
if (desc->enable_stats) {
#ifdef FLECS_STATS
ECS_IMPORT(world, FlecsStats);
#else
Expand Down
6 changes: 3 additions & 3 deletions deps/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10729,7 +10729,7 @@ typedef struct ecs_app_desc_t {
int32_t threads; /**< Number of threads. */
int32_t frames; /**< Number of frames to run (0 for infinite) */
bool enable_rest; /**< Enables ECS access over HTTP, necessary for explorer */
bool enable_monitor; /**< Periodically collect statistics */
bool enable_stats; /**< Periodically collect statistics */
uint16_t port; /**< HTTP port used by REST API */

ecs_app_init_action_t init; /**< If set, function is ran before starting the
Expand Down Expand Up @@ -19333,8 +19333,8 @@ struct app_builder {
return *this;
}

app_builder& enable_monitor(bool value = true) {
desc_.enable_monitor = value;
app_builder& enable_stats(bool value = true) {
desc_.enable_stats = value;
return *this;
}

Expand Down
35 changes: 20 additions & 15 deletions etc/v4/flecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const flecs = {
query = flecs.trimQuery(query);
query = query.replaceAll(", ", ",");

params.q = encodeURIComponent(query);
params.expr = encodeURIComponent(query);
return this._.requestQuery(
this, params, recv, err, abort, params.poll_interval_ms);
},
Expand All @@ -248,14 +248,14 @@ const flecs = {
},

// Set component
set: function(path, component, data) {
set: function(path, component, value) {
path = this._.escapePath(path);
if (typeof data == "object") {
data = JSON.stringify(data);
data = encodeURIComponent(data);
if (typeof value == "object") {
value = JSON.stringify(value);
value = encodeURIComponent(value);
}
return this._.request(this, "PUT", "component/" + path,
{component: component, data: data});
{component: component, value: value});
},

// Get component
Expand All @@ -274,33 +274,38 @@ const flecs = {
// Add component
add: function(path, component) {
path = this._.escapePath(path);
return this._.request(this, "PUT", "add/" + path,
return this._.request(this, "PUT", "component/" + path,
{component: component});
},

// Remove component
remove: function(path, component) {
path = this._.escapePath(path);
return this._.request(this, "PUT", "remove/" + path,
return this._.request(this, "DELETE", "component/" + path,
{component: component});
},

// Enable entity
enable: function(path) {
// Enable entity/component
enable: function(path, component) {
path = this._.escapePath(path);
return this._.request(this, "PUT", "enable/" + path, {});
return this._.request(this, "PUT", "toggle/" + path, {
enable: true, component: component

});
},

// Disable entity
disable: function(path) {
// Disable entity/component
disable: function(path, component) {
path = this._.escapePath(path);
return this._.request(this, "PUT", "disable/" + path, {});
return this._.request(this, "PUT", "toggle/" + path, {
enable: false, component: component
});
},

// Delete entity
delete: function(path) {
path = this._.escapePath(path);
return this._.request(this, "PUT", "delete/" + path, {});
return this._.request(this, "DELETE", "entity/" + path, {});
},

// Update script code
Expand Down
1 change: 1 addition & 0 deletions etc/v4/js/components/code-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ onMounted(() => {
editor = ace.edit("editor");
editor.setValue(value.value);
editor.setOption("highlightActiveLine", false);
editor.setOption("tabSize", 2);
editor.setTheme("ace/theme/flecs-script");
editor.session.setMode("ace/mode/flecs-query");
Expand Down
2 changes: 2 additions & 0 deletions etc/v4/js/components/pages/entities/flecs-script.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ function onScriptChange(editorObj) {
onMounted(() => {
editorObj = ace.edit("editor");
editorObj.setOption("highlightActiveLine", false);
editorObj.setOption("tabSize", 2);
editorObj.setBehavioursEnabled(true);
editorObj.setTheme("ace/theme/flecs-script");
editorObj.session.setMode("ace/mode/flecs-script");
Expand Down
4 changes: 2 additions & 2 deletions etc/v4/js/components/pages/queries/query-browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const css = computed(() => {
const itemIcon = (item) => {
if (item.observer) {
return "bell";
} else if (item.is_set[1]) {
} else if (!item.fields.is_set || item.fields.is_set[1]) {
return "code";
} else {
return "search";
Expand All @@ -150,7 +150,7 @@ const queryKind = (item) => {
if (item.observer) {
return "observer";
} else {
let isSystem = item.is_set[1];
let isSystem = !item.fields.is_set || item.fields.is_set[1];
if (isSystem) {
return "system";
}
Expand Down
2 changes: 1 addition & 1 deletion etc/v4/js/components/pages/queries/query-cpp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const defaultSrc = (term) => {
}
const isTemplateArg = (term) => {
if (!term.has_data) {
if (!term.has_value) {
return false;
}
if (!term.first) {
Expand Down
2 changes: 1 addition & 1 deletion etc/v4/js/components/pages/queries/query-expr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const skipInout = (term) => {
return true;
}
if ((!term.has_data && term.inout == "none")) {
if ((!term.has_value && term.inout == "none")) {
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions etc/v4/js/components/pages/queries/query-list-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ const docKey = "(Description,Brief)";
// (ChildOf, scope), $this ~= expr, ...
const isScopedQuery = computed(() => {
return props.prop.is_set.length == 6;
return props.prop.fields.is_set.length == 6;
})
const isComponent = computed(() => {
return isScopedQuery.value ? props.prop.is_set[3] : props.prop.is_set[2];
return isScopedQuery.value ? props.prop.fields.is_set[3] : props.prop.fields.is_set[2];
});
const isRelationship = computed(() => {
return isScopedQuery.value ? props.prop.is_set[4] : props.prop.is_set[3];
return isScopedQuery.value ? props.prop.fields.is_set[4] : props.prop.fields.is_set[3];
});
const isModule = computed(() => {
return isScopedQuery.value ? props.prop.is_set[5] : props.prop.is_set[4];
return isScopedQuery.value ? props.prop.fields.is_set[5] : props.prop.fields.is_set[4];
});
const description = computed(() => {
Expand Down
4 changes: 2 additions & 2 deletions etc/v4/js/components/prop-browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ watch(() => props.first, () => {
props.conn.query(query, {try: true, rows: true, limit: 1}, (reply) => {
if (reply.results) {
let result = reply.results[0];
if (result.is_set && result.is_set[1]) {
if (!result.fields.is_set || result.fields.is_set[1]) {
oneof.value = result.vars.parent;
} else if (result.is_set[0]) {
} else if (!result.fields.is_set || result.fields.is_set[0]) {
oneof.value = props.first;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions etc/v4/js/components/widgets/table/entity-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const tableHeaders = computed(() => {
schema: field.schema,
index: index++,
get: (result) => {
if (!result.is_set || result.is_set[i]) {
return result.fields[i].data;
if (!result.fields.is_set || result.fields.is_set[i]) {
return result.fields.values[i];
} else {
return undefined;
}
Expand Down
16 changes: 8 additions & 8 deletions etc/v4/js/components/widgets/tree/entity-subtree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ function updateQuery() {
Object.assign(treeItem, item);
treeItem.path = path;
treeItem.isModule = item.is_set[0];
treeItem.isComponent = item.is_set[1] || item.is_set[2] || item.is_set[3];
treeItem.isTarget = item.is_set[4];
treeItem.isQuery = item.is_set[5];
treeItem.isPrefab = item.is_set[6];
treeItem.isDisabled = item.is_set[7];
treeItem.isParent = item.is_set[8];
treeItem.baseEntity = item.is_set[9] ? item.vars["base"] : undefined;
treeItem.isModule = item.fields.is_set[0];
treeItem.isComponent = item.fields.is_set[1] || item.fields.is_set[2] || item.fields.is_set[3];
treeItem.isTarget = item.fields.is_set[4];
treeItem.isQuery = item.fields.is_set[5];
treeItem.isPrefab = item.fields.is_set[6];
treeItem.isDisabled = item.fields.is_set[7];
treeItem.isParent = item.fields.is_set[8];
treeItem.baseEntity = item.fields.is_set[9] ? item.vars["base"] : undefined;
if (item.doc) {
treeItem.label = item.doc.label;
Expand Down

0 comments on commit a3ce899

Please sign in to comment.